/* UBRR / Range ledger. Local assets only; no build step required. */
:root {
  color-scheme: light;
  --color-charcoal: #20221f;
  --color-off-white: #f4f2ec;
  --color-white: #ffffff;
  --color-brass: #c8a14a;
  --color-brass-dark: #70551b;
  --color-alert: #a12420;
  --color-grey-mid: #595d55;
  --color-grey-light: #d5d7cd;
  --color-border: #818578;
  --color-success: #285438;
  --color-focus: #155e9b;
  --font-body: system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Rockwell", "Roboto Slab", "DejaVu Serif", Georgia, serif;
  --radius: 4px;
  --space-1: .5rem;
  --space-2: 1rem;
  --space-3: 1.5rem;
  --space-4: 2.5rem;
  --page-width: 76rem;
}
* { box-sizing: border-box; }
/* The [hidden] attribute's default display:none can be silently overridden
   by any author rule that sets `display` on the same element (e.g. a
   .status-chip also marked hidden) — confirmed live via a screenshot of
   the live board showing a PROVISIONAL chip it should have hidden. Keep
   [hidden] authoritative everywhere. */
[hidden] { display: none !important; }
html { scroll-padding-top: 1rem; }
body { margin: 0; background: var(--color-off-white); color: var(--color-charcoal); font-family: var(--font-body); line-height: 1.6; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.2; text-wrap: balance; }
h1 { max-width: 28ch; margin: 0 0 1rem; font-size: clamp(2rem, 4vw, 3.25rem); letter-spacing: -.045em; }
h2 { margin: 2rem 0 1rem; font-size: clamp(1.35rem, 2.5vw, 1.8rem); letter-spacing: -.025em; }
h3 { font-size: 1.2rem; }
p { margin: 0 0 1rem; }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: .22em; }
a:hover { color: var(--color-brass-dark); text-decoration-thickness: 2px; }
img { max-width: 100%; }
:focus-visible { outline: 3px solid var(--color-focus); outline-offset: 4px; }
:target { scroll-margin-top: 1rem; }
.skip-link { position: fixed; left: 1rem; top: -8rem; z-index: 100; padding: .75rem 1rem; background: white; color: var(--color-charcoal); }
.skip-link:focus { top: 1rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.site-header { background: var(--color-charcoal); color: white; border-bottom: 4px solid var(--color-brass); }
.site-header__bar { max-width: 90rem; margin: auto; padding: .85rem clamp(1rem, 3vw, 2rem); display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem 1.5rem; }
.site-header__brand { display: flex; align-items: center; gap: .75rem; text-decoration: none; }
.site-header__brand:hover { color: white; }
.site-header__brand strong { display: block; font-family: var(--font-display); font-size: 1.5rem; line-height: 1.2; letter-spacing: .06em; }
.site-header__brand small { display: block; color: #d5d7cd; font-size: .65rem; text-transform: uppercase; letter-spacing: .12em; }
.site-header__logo { width: 52px; height: 52px; border-radius: 50%; }
.site-header__menu-toggle { background: transparent; border-color: #aaa; color: white; }
.site-nav { display: none; width: 100%; flex-direction: column; align-items: stretch; gap: .2rem; padding-top: .75rem; border-top: 1px solid #60645a; }
.site-nav.is-open { display: flex; }
.site-nav a, .site-nav button { display: flex; align-items: center; min-height: 44px; padding: .5rem .75rem; color: white; text-decoration: none; font-size: .875rem; font-weight: 650; border-radius: var(--radius); }
.site-nav a:hover, .site-nav button:hover { color: var(--color-charcoal); background: var(--color-brass); }
.site-nav a[href="/register"] { border: 1px solid var(--color-brass); }
.site-nav__logout { margin: 0; }
.site-nav__logout button { width: 100%; background: transparent; border: 0; }
.site-header :focus-visible { outline-color: var(--color-brass); }
main { max-width: var(--page-width); min-height: 65vh; margin: 0 auto; padding: clamp(1.5rem, 4vw, 3.5rem) clamp(1rem, 3vw, 2rem); }
main > h1, .page-header { padding-bottom: 1.25rem; border-bottom: 1px solid var(--color-grey-light); margin-bottom: 1.5rem; }
main > section + section { margin-top: 2.5rem; }
.eyebrow { display: block; color: var(--color-brass-dark); font-size: .75rem; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; margin-bottom: .75rem; }
.site-footer { max-width: var(--page-width); margin: auto; padding: 1.5rem 2rem 2.5rem; border-top: 1px solid var(--color-grey-light); color: var(--color-grey-mid); font-size: .8rem; }
.site-footer p { margin: 0; }
.site-footer a { display: inline-flex; align-items: center; min-height: 44px; margin: 0 .4rem; }
.button, button { display: inline-flex; align-items: center; justify-content: center; min-height: 46px; padding: .65rem 1.1rem; border: 1px solid var(--color-charcoal); border-radius: var(--radius); background: var(--color-charcoal); color: white; font: inherit; font-size: .9rem; font-weight: 700; text-align: center; line-height: 1.4; text-decoration: none; cursor: pointer; }
.button:hover, button:hover { background: var(--color-brass); border-color: var(--color-charcoal); color: var(--color-charcoal); }
.button--ghost { background: transparent; color: var(--color-charcoal); }
.actions { display: flex; flex-wrap: wrap; gap: .65rem; align-items: center; }
.hero { position: relative; display: grid; gap: 1.5rem; padding: clamp(1.5rem, 4vw, 3rem); margin-bottom: 2rem; background: var(--color-charcoal); color: white; border-radius: var(--radius); border-bottom: 5px solid var(--color-brass); }
.hero__logo { width: 112px; height: 112px; border-radius: 50%; }
.hero h1 { max-width: 16ch; font-size: clamp(2.3rem, 5.5vw, 4.4rem); margin-bottom: 1.25rem; }
.hero p { max-width: 60ch; color: #e0e1da; }
.hero .eyebrow { color: var(--color-brass); }
.hero .button { background: var(--color-brass); border-color: var(--color-brass); color: var(--color-charcoal); }
.hero .button--ghost { background: transparent; color: white; border-color: #b2b6ab; }
.hero .button:hover { background: white; color: var(--color-charcoal); }
.hero :focus-visible { outline-color: white; }
.match-facts { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--color-grey-light); background: white; margin-bottom: 2.5rem; }
.match-facts div { padding: 1rem .5rem; text-align: center; }
.match-facts div + div { border-left: 1px solid var(--color-grey-light); }
.match-facts strong { display: block; font-family: var(--font-display); font-size: 1.65rem; line-height: 1.2; }
.match-facts span { font-size: .75rem; color: var(--color-grey-mid); }
.home-columns { display: grid; gap: 2rem; }
.home-columns h2 { margin-top: 0; }
.section-link { display: inline-flex; align-items: center; min-height: 44px; font-weight: 700; font-size: .9rem; }
.card-list { display: grid; gap: .75rem; padding: 0; list-style: none; }
.card, .club-panel { background: white; border: 1px solid var(--color-grey-light); border-radius: var(--radius); padding: 1.25rem; }
.card { display: flex; flex-direction: column; gap: .4rem; border-left: 3px solid var(--color-brass); }
.card span { font-size: .875rem; color: var(--color-grey-mid); }
.card a { display: flex; align-items: center; min-height: 44px; font-weight: 700; }
.club-panel { margin-bottom: 1.5rem; }
.club-panel h2 { margin-top: 0; }
.club-panel h2 .meta { display: block; margin-top: .5rem; font-family: var(--font-body); letter-spacing: 0; }
/* Scrolling belongs to a wrapper: preserve native table semantics and sticky cells. */
.table-scroll { max-width: 100%; max-height: 34rem; overflow: auto; overscroll-behavior-x: contain; margin: 1rem 0 2rem; background: white; border: 1px solid var(--color-grey-light); border-radius: var(--radius); scrollbar-color: var(--color-border) var(--color-off-white); }
.data-table { width: 100%; min-width: 34rem; border-collapse: separate; border-spacing: 0; font-size: .875rem; text-align: left; font-variant-numeric: tabular-nums; }
.data-table th, .data-table td { padding: .65rem 1rem; border-bottom: 1px solid var(--color-grey-light); vertical-align: middle; }
.data-table thead th { position: sticky; top: 0; z-index: 1; background: var(--color-charcoal); color: white; font-size: .7rem; font-weight: 700; letter-spacing: .065em; text-transform: uppercase; white-space: nowrap; }
.data-table td { min-width: 5rem; }
.data-table tbody tr:nth-child(even) { background: #f7f7f2; }
.data-table tbody tr:hover { background: #f4eddc; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table td a { display: inline-flex; align-items: center; min-height: 44px; font-weight: 650; }
.data-table .num { text-align: right; white-space: nowrap; }
.data-table--results { min-width: 38rem; }
.data-table--results td:last-child { font-weight: 800; }
.data-table--standings td:last-child { font-weight: inherit; }
.data-table--standings td.score-total { font-weight: 800; }
.data-table .date-cell { white-space: nowrap; }
.table-scroll-frame { position: relative; margin: 1rem 0 2rem; }
.table-scroll-frame > .table-scroll { margin: 0; }
.data-table--results td:has(.rank-badge--1) { border-left: 3px solid var(--color-brass); }
.data-table tr.row-error { background: #fcebe8; }
.table-hint { margin: 1rem 0 -.5rem; color: var(--color-grey-mid); font-size: .8rem; }
.class-heading { display: flex; flex-wrap: wrap; align-items: center; gap: .65rem; padding-top: 1.5rem; margin-bottom: .5rem; border-top: 1px solid var(--color-grey-light); }
.class-chip { display: inline-flex; align-items: center; justify-content: center; min-width: 2.25rem; max-width: 100%; padding: .25rem .7rem; border: 1px solid var(--color-border); border-radius: var(--radius); background: #eceee6; color: var(--color-charcoal); font-family: var(--font-body); font-size: .8rem; font-weight: 750; line-height: 1.5; letter-spacing: .02em; white-space: normal; overflow-wrap: anywhere; }
.class-key { display: flex; flex-wrap: wrap; gap: .5rem; padding: 0; list-style: none; }
.rank-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 2rem; min-height: 2rem; padding: .2rem .4rem; border-radius: 50%; background: #eeefe9; font-weight: 800; font-variant-numeric: tabular-nums; }
.rank-badge--1 { background: var(--color-brass); color: var(--color-charcoal); box-shadow: inset 0 0 0 1px var(--color-brass-dark); }
.rank-badge--2 { background: #dadeda; box-shadow: inset 0 0 0 1px #747b74; }
.rank-badge--3 { background: #e8d6bf; box-shadow: inset 0 0 0 1px #8c6943; }
.status-chip { display: inline-flex; align-items: center; gap: .35rem; padding: .2rem .65rem; border: 1px solid var(--color-border); border-radius: 999px; background: #f0f1eb; color: #474b43; font-size: .75rem; font-weight: 700; line-height: 1.5; overflow-wrap: anywhere; }
.status-chip::before { content: ''; flex: 0 0 .35rem; width: .35rem; height: .35rem; border-radius: 50%; background: currentColor; }
.status-chip--approved, .status-chip--paid, .status-chip--shipped { background: #edf5ee; color: var(--color-success); border-color: #72957a; }
.status-chip--submitted, .status-chip--invoiced { background: #faf0d7; color: #70551b; border-color: #9a7d37; }
.status-chip--unpaid { background: #fcebe8; color: var(--color-alert); border-color: #bc6862; }
.status-chip--scheduled { background: #eaf1f6; color: #245271; border-color: #708fa3; }
/* Forms keep their existing names, actions and validation behavior. */
label, legend { font-size: .875rem; font-weight: 700; }
input, select, textarea { max-width: 100%; min-width: 0; min-height: 46px; padding: .65rem .75rem; border: 1px solid var(--color-border); border-radius: var(--radius); background: white; color: var(--color-charcoal); font: inherit; line-height: 1.4; }
input::placeholder, textarea::placeholder { color: var(--color-grey-mid); opacity: 1; }
input[type="number"] { font-variant-numeric: tabular-nums; }
input[type="checkbox"], input[type="radio"] { min-height: 24px; width: 24px; margin: 0; flex-shrink: 0; accent-color: var(--color-charcoal); }
label:has(input[type="checkbox"]), label:has(input[type="radio"]) { display: flex; align-items: center; gap: .75rem; min-height: 44px; padding: .5rem 0; }
fieldset { min-width: 0; margin: .5rem 0; padding: 1rem; border: 1px solid var(--color-border); border-radius: var(--radius); }
legend { padding: 0 .35rem; }
.stacked-form, .scorer-form { display: flex; flex-direction: column; gap: .6rem; width: 100%; max-width: 36rem; padding: clamp(1rem, 3vw, 1.75rem); background: white; border: 1px solid var(--color-grey-light); border-radius: var(--radius); }
.stacked-form > label:not(:first-of-type), .scorer-form > label:not(:first-of-type) { margin-top: .65rem; }
.stacked-form > button, .scorer-form > button { margin-top: 1rem; }
.inline-form, .filter-form { display: flex; flex-wrap: wrap; align-items: end; gap: .75rem; margin: 1rem 0 1.5rem; }
.filter-form { padding: 1rem; border: 1px solid var(--color-grey-light); background: #eaece4; border-radius: var(--radius); }
.form-field { display: flex; flex: 1 1 10rem; flex-direction: column; gap: .4rem; min-width: 0; }
.form-field--small { flex: 0 1 7rem; }
.form-field > input, .form-field > select { width: 100%; }
.inline-form > input, .inline-form > select { max-width: 100%; }
.data-table .inline-form { margin: 0; flex-wrap: nowrap; align-items: center; }
.data-table .inline-form label { display: flex; flex-direction: column; gap: .3rem; }
.data-table .inline-form input { min-width: 12rem; }
.auth-page { max-width: 32rem; margin: 0 auto; }
.auth-page h1 { margin-bottom: 1rem; }
.auth-page .stacked-form { margin: 1.5rem 0; }
.auth-page > p > a { display: inline-flex; min-height: 44px; align-items: center; }
.help-text, .meta, .note { color: var(--color-grey-mid); font-size: .875rem; }
.help-text { margin: 0; }
.meta { margin-bottom: 1.5rem; }
.note { padding: 1rem; background: #eaece4; border-left: 3px solid var(--color-border); }
.empty-state { padding: 2rem 1.5rem; margin: 1rem 0; border: 1px dashed var(--color-border); background: #fafaf6; color: var(--color-grey-mid); border-radius: var(--radius); }
.flash, .form-errors { padding: 1rem 1.25rem; margin: 0 0 1.5rem; border: 1px solid; border-left-width: 4px; border-radius: var(--radius); }
.form-errors { padding-left: 2rem; }
.flash--error, .form-errors { background: #fcebe8; color: var(--color-alert); }
.flash--success { background: #edf5ee; color: var(--color-success); }
/* Device saves and network sync remain separate, explicit actions. */
.scorer-toolbar { position: sticky; top: .5rem; z-index: 5; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .5rem .75rem; align-items: center; margin: 1rem 0 1.5rem; padding: .75rem; border: 2px solid var(--color-charcoal); border-radius: var(--radius); background: white; box-shadow: 0 4px 0 #20221f18; }
.connection-indicator { margin: 0; padding: .6rem; border-radius: var(--radius); font-size: .85rem; font-weight: 750; line-height: 1.4; }
.connection-indicator[data-state="online"] { background: #edf5ee; color: var(--color-success); }
.connection-indicator[data-state="offline"] { background: #fcebe8; color: var(--color-alert); }
.connection-indicator[data-state="unknown"] { background: #eceee6; }
#sync-btn { min-height: 52px; padding-inline: 1.25rem; background: var(--color-brass); color: var(--color-charcoal); }
#sync-btn:hover { background: var(--color-charcoal); color: white; }
#sync-status { grid-column: 1 / -1; font-size: .85rem; font-weight: 700; overflow-wrap: anywhere; }
#sync-status:empty { display: none; }
.scorer-form input, .scorer-form select, .scorer-form button { min-height: 54px; border-color: var(--color-charcoal); font-size: 1rem; }
.scorer-form button { font-size: 1.1rem; }
.scorer-form input[type="number"] { font-weight: 750; }
.card-inputs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; margin-top: 1rem; }
.card-inputs .form-field { padding: .75rem; background: var(--color-off-white); border: 1px solid var(--color-grey-light); border-radius: var(--radius); }
.card-inputs input { text-align: right; font-size: 1.3rem; }
#scorer-app { scroll-margin-top: 1rem; }
#scorer-app :is(input, select, button) { scroll-margin-top: 12rem; }
#pending-table { min-width: 42rem; }
#pending-table td:nth-child(4) { text-align: right; font-weight: 800; }
#pending-table td:last-child { min-width: 12rem; max-width: 26rem; }
#pending-table td:nth-child(2) { font-weight: 700; }
#pending-rows:empty::after { content: 'Saved entries appear here.'; display: table-cell; padding: 1.5rem 1rem; color: var(--color-grey-mid); }
.scorer-help { max-width: 65ch; }
.rules-page { max-width: 74ch; margin-inline: auto; padding: clamp(1rem, 3vw, 2.5rem); background: white; border: 1px solid var(--color-grey-light); border-top: 4px solid var(--color-brass); border-radius: var(--radius); }
.rules-page h2 { margin-top: 2.5rem; padding-top: 1.5rem; border-top: 1px solid var(--color-grey-light); }
.rules-page h3 { margin-top: 1.75rem; }
.rules-page ul { padding-left: 1.3rem; }
.rules-page li { padding-left: .25rem; margin-bottom: .6rem; }
.target-sample { max-width: 640px; margin: 2rem 0; padding: 1rem; background: white; border: 1px solid var(--color-grey-light); border-top: 4px solid var(--color-brass); box-shadow: 0 5px 16px #20221f0d; }
.target-sample img { display: block; width: 100%; height: auto; border: 1px solid var(--color-grey-light); }
.target-sample__caption { padding-top: 1rem; margin-bottom: 0; color: var(--color-alert); font-size: .8rem; font-weight: 750; }
.error-page { max-width: 42rem; margin: 2rem auto; padding: 2rem; background: white; border-top: 4px solid var(--color-brass); }
.pagination { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.pagination a, .pagination span { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; padding: .5rem; border: 1px solid var(--color-border); border-radius: var(--radius); }
.pagination [aria-current="page"] { background: var(--color-charcoal); color: white; }
@media screen and (max-width: 599px) {
  /* Keep rank, shooter and total in the initial phone viewport. */
  .data-table--standings { table-layout: fixed; width: 23rem; min-width: 100%; }
  .data-table--yearly { width: 33rem; }
  .data-table--standings th, .data-table--standings td { padding: .65rem .5rem; }
  .data-table--standings .overall-rank { display: none; }
  .data-table--standings th:first-child, .data-table--standings td:first-child { width: 4rem; min-width: 4rem; white-space: normal; }
  .data-table--standings .shooter-cell { width: 8rem; min-width: 8rem; max-width: 8rem; overflow-wrap: anywhere; }
  .data-table--standings .score-total { width: 6rem; min-width: 6rem; }
  .data-table--standings th.score-total { white-space: normal; }
  /* Overlay the scrolling content so striped rows cannot cover the cue. */
  .table-scroll-frame::after { content: ''; position: absolute; top: 1px; right: 1px; bottom: 1px; width: 1rem; z-index: 2; border-radius: 0 var(--radius) var(--radius) 0; background: linear-gradient(to right, transparent, #20221f40); pointer-events: none; }
  .table-scroll--schedule { max-height: none; }
}
@media (min-width: 720px) {
  .hero { grid-template-columns: minmax(0, 1fr) 180px; align-items: center; }
  .hero__logo { grid-column: 2; grid-row: 1; width: 180px; height: 180px; }
  .hero__copy { grid-column: 1; grid-row: 1; }
  .home-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .match-facts div { padding: 1.25rem; }
  .match-facts strong { font-size: 2rem; }
  .scorer-form { max-width: 42rem; }
  .card-inputs { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .scorer-toolbar { max-width: 52rem; }
}
@media (min-width: 1100px) {
  .site-header__menu-toggle { display: none; }
  .site-nav { display: flex; flex: 1; width: auto; flex-direction: row; flex-wrap: wrap; justify-content: flex-end; align-items: center; padding: 0; border: 0; }
}
@media (max-width: 479px) {
  .filter-form .form-field:first-child { flex-basis: 100%; }
  .filter-form button { flex-grow: 1; }
  .inline-form > label { flex-basis: 100%; }
  .inline-form > input, .inline-form > select { width: 100%; }
  .data-table .inline-form > label { flex-basis: auto; }
  .site-header__brand small { font-size: .6rem; }
}
/* Keep secondary actions usable by touch, including links below forms. */
main > p > a, main > section > p > a, .note a { display: inline-flex; align-items: center; min-height: 44px; }
.inline-form > .form-field { flex: 1 1 12rem; max-width: 24rem; }
.data-table .inline-form > .form-field { min-width: 10rem; }
#pending-table td:nth-child(3) { text-align: right; }
@media (max-width: 479px) {
  .inline-form > .form-field { flex-basis: 100%; max-width: none; }
  .inline-form > button { width: 100%; }
  .data-table .inline-form > button { width: auto; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
@media (forced-colors: active) {
  .rank-badge, .class-chip, .status-chip, .connection-indicator { border: 1px solid CanvasText; }
}
@media print {
  .site-header, .site-footer, .site-nav, form, .target-sample, .scorer-toolbar, .table-hint, .pagination { display: none !important; }
  body, main, .rules-page { background: white; color: black; padding: 0; }
  .table-scroll { overflow: visible; max-height: none; border: 0; }
  .data-table, .data-table--results, #pending-table { min-width: 0; font-size: 9pt; }
  .data-table thead th { position: static; background: white; color: black; border-bottom: 2px solid black; }
  .data-table th, .data-table td { padding: .35rem; }
  tr, .card { break-inside: avoid; }
  h1, h2, h3 { break-after: avoid; }
}

/* Shared match-day primitives. No external assets or animated transitions. */
#checkin-results { list-style: none; padding: 0; border: 1px solid var(--color-border); border-radius: var(--radius); }
#checkin-results:empty { border: 0; }
#checkin-results li { border-bottom: 1px solid var(--color-grey-light); }
#checkin-results li:last-child { border-bottom: 0; }
#checkin-results button { width: 100%; text-align: left; background: white; color: var(--color-charcoal); border: 0; }
#checkin-results button:hover, #checkin-results button:focus-visible { background: var(--color-brass); }
#sg-grid .sg-cell { width: 100%; font-variant-numeric: tabular-nums; background: white; }
#sg-numpad-dialog { border: 2px solid var(--color-charcoal); border-radius: var(--radius); }
#sg-numpad-dialog::backdrop { background: rgba(32, 34, 31, .65); }
#sg-numpad-display { display: block; font-variant-numeric: tabular-nums; border-radius: var(--radius); }
#sg-numpad-keys { display: grid; grid-template-columns: repeat(3, 1fr); }
#sg-bull-rows { display: grid; gap: .35rem; margin: var(--space-1) 0; max-height: 40vh; overflow-y: auto; }
#sg-bull-rows > div { display: flex; align-items: center; gap: var(--space-1); }
#sg-bull-rows input[type="number"] { width: 5rem; }
#live-board { margin: 0 auto; padding: var(--space-3) var(--space-2); }
#lb-provisional { background: var(--color-alert); color: white; display: inline-block; font-weight: 800; letter-spacing: .08em; }

/* Match-day workspace: broad contrast, four cards within a phone viewport. */
main:has(#scoregrid-app), main:has(#checkin-app) { padding-top: 1.25rem; }
.matchday-heading h1 { margin: 0; font-size: clamp(1.8rem, 4vw, 2.5rem); }
.matchday-heading .eyebrow { margin-bottom: .35rem; letter-spacing: .06em; }
.matchday-links { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .65rem; margin: .5rem 0 1rem; font-size: .85rem; }
.matchday-links a { display: inline-flex; align-items: center; min-height: 44px; }
.sg-toolbar { position: sticky; top: 0; z-index: 5; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: .4rem; padding: .5rem; background: white; border: 2px solid var(--color-charcoal); border-radius: var(--radius); box-shadow: 0 3px 0 #20221f20; }
#sg-sync-btn { min-height: 48px; background: var(--color-brass); color: var(--color-charcoal); }
#sg-sync-status { grid-column: 1 / -1; font-size: .85rem; font-weight: 650; }
#sg-sync-status:empty { display: none; }
.sg-overview { margin: 1rem 0 .5rem; }
#sg-progress { margin: 0; font-weight: 800; }
.sg-overview .meta { margin: .2rem 0; }
.sg-scroll { max-height: none; margin-top: .5rem; }
#sg-grid { min-width: 0; }
#sg-grid td { min-width: 0; padding: .65rem .4rem; }
#sg-grid th { padding: .65rem .4rem; }
#sg-grid td:nth-child(1) { font-size: 1.4rem; font-weight: 800; }
#sg-grid td:nth-child(2) { max-width: 17rem; font-weight: 750; overflow-wrap: anywhere; }
#sg-grid td:nth-child(3) { font-weight: 750; }
.sg-row-status { display: block; margin-top: .25rem; font-size: .75rem; font-weight: 550; }
#sg-grid .sg-cell { display: flex; flex-direction: column; gap: .15rem; min-width: 56px; min-height: 78px; padding: .4rem .2rem; border: 2px solid var(--color-border); color: var(--color-charcoal); line-height: 1.2; }
.sg-cell strong { font-size: 1.5rem; }
.sg-card-label { font-size: .7rem; font-weight: 650; }
.sg-cell-status { font-size: .65rem; font-weight: 750; }
#sg-grid .sg-cell--empty { border-style: dashed; }
#sg-grid .sg-cell[data-state="synced"].sg-cell--filled { border-color: var(--color-success); background: #edf5ee; color: var(--color-success); }
#sg-grid .sg-cell[data-state="local"].sg-cell--filled { border-color: var(--color-brass-dark); background: #faf0d7; color: var(--color-brass-dark); }
#sg-grid .sg-cell.sg-cell--error[data-state] { border-color: var(--color-alert); color: var(--color-alert); background: #fcebe8; }
#sg-grid .sg-cell--next { border-color: var(--color-charcoal); border-style: solid; box-shadow: 0 0 0 1px var(--color-charcoal); }
#sg-grid .sg-cell--next .sg-cell-status { background: var(--color-charcoal); color: white; padding: .1rem .5rem; border-radius: 2px; }
#sg-grid .sg-cell[aria-current="true"] { outline: 3px solid var(--color-focus); outline-offset: 2px; }
#sg-grid .sg-cell:hover { background: var(--color-brass); color: var(--color-charcoal); }
#sg-grid .sg-cell:focus-visible { outline: 3px solid var(--color-focus); outline-offset: 3px; }
#sg-numpad-dialog { width: min(96vw, 30rem); max-width: 30rem; max-height: calc(100dvh - 1rem); padding: 1rem; color: var(--color-charcoal); background: var(--color-off-white); overflow-y: auto; }
#sg-numpad-dialog h2 { margin: 0; font: 800 1.5rem/1.25 var(--font-body); }
#sg-numpad-subtitle { margin: .35rem 0 .5rem; font-size: 1rem; color: var(--color-charcoal); }
#sg-numpad-display { margin: .5rem 0; padding: .25rem .75rem; font-size: 3rem; font-weight: 850; text-align: right; background: white; border: 2px solid var(--color-charcoal); line-height: 1.35; }
#sg-numpad-keys { gap: .5rem; margin-bottom: .5rem; }
#sg-numpad-keys button { min-height: 60px; background: white; color: var(--color-charcoal); border: 2px solid var(--color-charcoal); font-size: 1.65rem; }
#sg-numpad-keys button:hover { background: var(--color-brass); }
#sg-numpad-keys #sg-key-clear { font-size: 1rem; }
#sg-bull-detail summary { min-height: 44px; padding: .6rem 0; font-size: .8rem; cursor: pointer; }
.sg-numpad-actions { display: grid; grid-template-columns: 1fr 2fr; gap: .5rem; margin-top: .5rem; }
.sg-numpad-actions button { min-height: 56px; font-size: 1rem; }
#sg-numpad-cancel { background: white; color: var(--color-charcoal); }
#sg-numpad-save { background: var(--color-brass); color: var(--color-charcoal); }
#sg-numpad-error { color: var(--color-alert); font-weight: 700; }
#scoregrid-app button:disabled { opacity: .65; cursor: wait; }
@media (max-width: 699px) {
  /* Explicit table roles preserve associations when rows become bench cards. */
  .sg-scroll { overflow: visible; border: 0; background: transparent; }
  #sg-grid, #sg-grid-body { display: block; width: 100%; }
  #sg-grid thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  #sg-grid tr { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .5rem; padding: .75rem; margin-bottom: .75rem; background: white; border: 1px solid var(--color-border); border-radius: var(--radius); }
  #sg-grid td { display: block; padding: 0; border: 0; }
  #sg-grid td:nth-child(1) { grid-column: 1; grid-row: 1; align-self: start; font-size: 1.3rem; }
  #sg-grid td:nth-child(1)::before { content: 'Bench'; display: block; font-size: .65rem; text-transform: uppercase; letter-spacing: .06em; }
  #sg-grid td:nth-child(2) { grid-column: 2 / 5; grid-row: 1; max-width: none; line-height: 1.35; font-size: 1rem; }
  #sg-grid td:nth-child(3) { grid-column: 1 / 3; grid-row: 3; align-self: center; font-size: .8rem; }
  #sg-grid td:nth-child(3)::before { content: 'Class '; font-weight: 500; }
  #sg-grid td:nth-child(n+4):nth-child(-n+7) { grid-row: 2; }
  #sg-grid td:nth-child(8) { grid-column: 3; grid-row: 3; }
  #sg-grid td:nth-child(9) { grid-column: 4; grid-row: 3; }
  #sg-grid td:nth-child(8)::before { content: 'Total '; font-size: .65rem; }
  #sg-grid td:nth-child(9)::before { content: 'Place '; font-size: .65rem; }
  #sg-grid .sg-cell { width: 100%; min-width: 0; min-height: 84px; }
  #sg-grid .num { font-weight: 800; }
  #sg-numpad-dialog { margin: auto auto .5rem; }
}
@media (max-height: 650px) {
  #sg-numpad-keys button { min-height: 44px; }
  #sg-numpad-display { font-size: 2rem; }
}

/* Check-in: choose once, then keep the bench roster in view. */
.checkin-match-status { margin: .5rem 0 1rem; font-size: .85rem; }
.checkin-broadcast { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1rem; margin-bottom: 1rem; padding: 1rem; background: #eaece4; border: 1px solid var(--color-border); border-left: 4px solid var(--color-charcoal); border-radius: var(--radius); }
.checkin-broadcast p { margin: .1rem 0 0; font-size: .85rem; }
#checkin-live-public-toggle { gap: .75rem; min-height: 52px; background: white; color: var(--color-charcoal); }
#checkin-live-public-toggle::before { content: 'OFF'; border: 1px solid currentColor; border-radius: 1rem; padding: .2rem .5rem; font-size: .7rem; }
#checkin-live-public-toggle[aria-pressed="true"] { background: var(--color-success); color: white; }
#checkin-live-public-toggle[aria-pressed="true"]::before { content: 'ON'; }
#checkin-live-status { flex-basis: 100%; font-weight: 650; }
#checkin-live-status:empty { display: none; }
#checkin-app { display: grid; gap: 1.5rem; align-items: start; }
#checkin-form { max-width: none; gap: .5rem; border-color: var(--color-border); }
#checkin-form h2 { margin: 0 0 .5rem; }
#checkin-form input, #checkin-form select { min-height: 52px; border-color: var(--color-charcoal); }
#checkin-results { max-width: none; max-height: 19rem; overflow-y: auto; margin: 0; }
#checkin-results button { min-height: 56px; padding: .75rem; border-radius: 0; font-size: 1rem; }
#checkin-results [aria-selected="true"] button { background: var(--color-brass); color: var(--color-charcoal); box-shadow: inset 4px 0 var(--color-charcoal); }
#checkin-selected { margin: 0; padding: .5rem .75rem; background: #edf5ee; border-left: 4px solid var(--color-success); color: var(--color-success); font-weight: 750; }
#checkin-selected:empty, #checkin-search-status:empty, #checkin-status:empty { display: none; }
#checkin-form #checkin-walkin-toggle { margin: 0; align-self: start; padding: .5rem 0; background: transparent; color: var(--color-charcoal); border: 0; text-decoration: underline; text-underline-offset: .25em; }
#checkin-walkin { display: grid; grid-template-columns: 1fr; gap: .4rem; padding: .75rem; background: var(--color-off-white); border: 1px solid var(--color-border); }
.checkin-assignment { display: grid; gap: 1rem; margin-top: .5rem; }
#checkin-class-choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .4rem; }
#checkin-class-choices button { min-height: 48px; padding: .5rem; background: white; color: var(--color-charcoal); font-size: .8rem; }
#checkin-bench { width: 100%; }
#checkin-bench-choices { display: flex; flex-wrap: wrap; gap: .5rem; }
#checkin-bench-choices button { min-width: 48px; min-height: 48px; background: white; color: var(--color-charcoal); }
#checkin-class-choices [aria-pressed="true"], #checkin-bench-choices [aria-pressed="true"] { background: var(--color-charcoal); color: white; box-shadow: inset 0 -3px var(--color-brass); }
#checkin-form #checkin-submit { margin-top: .5rem; min-height: 56px; background: var(--color-brass); color: var(--color-charcoal); font-size: 1rem; }
#checkin-status { margin: 0; font-weight: 650; overflow-wrap: anywhere; }
.checkin-roster-heading { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .5rem; }
.checkin-roster-heading h2, .checkin-roster-heading p { margin: 0 0 .25rem; }
#checkin-roster-count { font-size: .85rem; font-weight: 750; }
.checkin-roster .table-scroll { max-height: none; margin-top: .75rem; }
#checkin-roster-table { min-width: 0; table-layout: fixed; }
#checkin-roster-table th, #checkin-roster-table td { min-width: 0; padding: .65rem .4rem; overflow-wrap: anywhere; }
#checkin-roster-table th:first-child { width: 3.5rem; }
#checkin-roster-table th:nth-child(3) { width: 3.25rem; }
#checkin-roster-table th:last-child { width: 4.8rem; }
#checkin-roster-table td:first-child { font-size: 1.3rem; font-weight: 800; }
#checkin-roster-table td:nth-child(2) { font-weight: 750; }
#checkin-roster-table .meta { display: block; margin: .2rem 0 0; font-size: .7rem; font-weight: 500; }
.checkin-remove { padding: .5rem .25rem; min-height: 44px; width: 100%; background: white; color: var(--color-alert); border-color: var(--color-border); font-size: .75rem; }
#checkin-app button:disabled, #checkin-live-public-toggle:disabled { opacity: .65; cursor: wait; }
@media (min-width: 900px) {
  #checkin-app { grid-template-columns: minmax(20rem, 5fr) minmax(0, 7fr); }
}

/* Public board: server-ranked divisions; measured, single-screen TV layout. */
.live-board-page { background: var(--color-off-white); }
#live-board { max-width: 88rem; }
.lb-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; padding-bottom: 1rem; border-bottom: 3px solid var(--color-charcoal); margin-bottom: 1.5rem; }
.lb-heading .eyebrow { margin: 0 0 .35rem; }
#live-board h1 { max-width: none; margin: 0; font-size: clamp(1.6rem, 3vw, 3rem); }
#lb-provisional { flex-shrink: 0; margin: 0; border: 2px solid var(--color-alert); border-radius: 3px; padding: .5rem .75rem; font-size: 1rem; }
#lb-provisional::before { display: none; }
#lb-classes { position: relative; min-width: 0; }
.lb-class { min-width: 0; margin-bottom: 1.5rem; border: 1px solid var(--color-grey-light); border-radius: var(--radius); background: white; }
.lb-class h2 { margin: 0; padding: .55rem .75rem; background: var(--color-charcoal); color: white; font-family: var(--font-body); font-weight: 800; font-size: 1.25rem; letter-spacing: 0; overflow-wrap: anywhere; }
.lb-range { margin: 0; padding: .25rem .75rem; background: #eaece4; font-size: .8rem; font-weight: 650; }
.lb-table-scroll { max-width: 100%; overflow: auto; overscroll-behavior-x: contain; scrollbar-color: var(--color-border) var(--color-off-white); }
.lb-table-scroll:focus-visible { outline-offset: -3px; }
.lb-table { width: 100%; min-width: 0; table-layout: auto; background: white; font-size: 1.125rem; line-height: 1.2; }
.lb-table th, .lb-table td { min-width: 0; padding: .4em .5em; }
.lb-table thead th { position: static; background: #eaece4; color: var(--color-charcoal); font-size: .8rem; letter-spacing: 0; text-transform: none; }
.lb-table .lb-name { min-width: 8em; width: 100%; font-weight: 750; overflow-wrap: anywhere; }
.lb-table .lb-place { white-space: nowrap; }
.lb-table .lb-total { border-left: 2px solid var(--color-grey-light); font-weight: 850; }
.lb-table td.lb-total { font-size: 1.12em; }
.lb-table .lb-card { min-width: 3.1em; }
.lb-table tbody tr { --lb-row-bg: white; }
.lb-table tbody tr:nth-child(even) { --lb-row-bg: #f7f7f2; }
.lb-table tbody tr.lb-place-1 { --lb-row-bg: #faf1d8; }
.lb-table tbody tr.lb-place-2 { --lb-row-bg: #edf0f3; }
.lb-table tbody tr.lb-place-3 { --lb-row-bg: #f6e9df; }
.lb-table tbody td { background: var(--lb-row-bg); }
.lb-place-badge { display: inline-block; min-width: 2.65em; padding: .16em .22em; border: 1px solid transparent; border-radius: 3px; text-align: center; font-size: .85em; font-weight: 800; }
.lb-place-1 .lb-place-badge { background: #e8c76e; border-color: #917021; color: #36290b; }
.lb-place-2 .lb-place-badge { background: #d8dfe6; border-color: #7c8995; color: #263540; }
.lb-place-3 .lb-place-badge { background: #e6b998; border-color: #a66e43; color: #452813; }
.lb-table .lb-pending { color: #73776d; font-weight: 400; }
.lb-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1rem; border-top: 2px solid var(--color-charcoal); padding-top: .65rem; }
#lb-updated { margin: 0; font-size: .85rem; font-weight: 750; color: var(--color-charcoal); }
.lb-refresh-note { margin: .15rem 0 0; color: var(--color-grey-mid); font-size: .75rem; }
#lb-paging { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; }
#lb-page-label { min-width: 9ch; font-weight: 800; margin-right: .5rem; }
#lb-paging button { min-width: 44px; min-height: 44px; background: white; color: var(--color-charcoal); }
#lb-paging button[aria-pressed="true"] { background: var(--color-charcoal); color: white; }
#lb-paging button:disabled { opacity: .55; cursor: default; }
#lb-error { margin: 0; font-weight: 750; }
/* No opacity or page transitions: only cells with changed content receive a
   brief inset marker. Rank tints and numeric contrast remain steady. */
@keyframes lb-score-change { from { box-shadow: inset 0 -3px var(--color-brass-dark); } to { box-shadow: inset 0 0 transparent; } }
@media (prefers-reduced-motion: no-preference) {
  .lb-changed { animation: lb-score-change 1.8s ease-out; }
}
body.is-kiosk #live-board { display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto; gap: .75rem; width: 100%; height: 100vh; height: 100dvh; min-height: 0; max-width: none; padding: 1.25rem 1.5rem; }
body.is-kiosk .lb-heading { flex-wrap: nowrap; gap: 1rem; margin: 0; padding-bottom: .7rem; }
body.is-kiosk .lb-heading > div { min-width: 0; }
body.is-kiosk .lb-heading .eyebrow { font-size: 1rem; }
body.is-kiosk #live-board h1 { font-size: clamp(1.5rem, 2vw, 2.4rem); line-height: 1.15; overflow-wrap: anywhere; }
body.is-kiosk #lb-provisional { font-size: 1.125rem; }
body.is-kiosk #lb-classes { min-height: 0; }
body.is-kiosk .lb-page { display: grid; gap: 1rem; height: 100%; min-height: 0; font-size: var(--lb-size, 18px); }
body.is-kiosk .lb-columns-1 { grid-template-columns: minmax(0, 1fr); }
body.is-kiosk .lb-columns-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
body.is-kiosk .lb-columns-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.lb-size-32 { --lb-size: 32px; }
.lb-size-30 { --lb-size: 30px; }
.lb-size-28 { --lb-size: 28px; }
.lb-size-26 { --lb-size: 26px; }
.lb-size-24 { --lb-size: 24px; }
.lb-size-22 { --lb-size: 22px; }
.lb-size-20 { --lb-size: 20px; }
.lb-size-18 { --lb-size: 18px; }
body.is-kiosk .lb-column { display: flex; flex-direction: column; gap: .65rem; min-width: 0; min-height: 0; overflow: auto; }
body.is-kiosk .lb-column > .lb-class { flex: none; }
body.is-kiosk .lb-class { margin: 0; }
body.is-kiosk .lb-class h2 { font-size: 1em; padding: .35em .5em; }
body.is-kiosk .lb-range { font-size: max(14px, .55em); line-height: 1.25; padding: .2em .75em; }
body.is-kiosk .lb-table { font-size: inherit; }
body.is-kiosk .lb-table th { font-size: max(14px, .6em); padding: .35em .5em; }
body.is-kiosk .lb-table td { padding: .22em .35em; }
body.is-kiosk .lb-table .lb-name { min-width: 7em; }
body.is-kiosk .lb-table .lb-card { min-width: 2.6em; }
body.is-kiosk .lb-place-badge { font-size: max(18px, .8em); }
body.is-kiosk #lb-updated, body.is-kiosk #lb-page-label { font-size: 1.125rem; }
body.is-kiosk .lb-refresh-note { font-size: 1rem; }
body.is-kiosk #lb-error { padding: .4rem .75rem; font-size: 1rem; }
body.is-kiosk .lb-measure { position: absolute; inset: 0; visibility: hidden; pointer-events: none; }
/* A focusable scroll region keeps every card accessible on a phone. Opaque
   sticky name/total cells retain context at either end of the score strip. */
body:not(.is-kiosk) .lb-table .lb-name { position: sticky; left: 0; z-index: 1; }
body:not(.is-kiosk) .lb-table .lb-total { position: sticky; right: 0; z-index: 2; }
body:not(.is-kiosk) .lb-table thead .lb-name, body:not(.is-kiosk) .lb-table thead .lb-total { z-index: 3; }
@media (max-width: 599px) {
  .lb-table { font-size: 1rem; }
  .lb-table th, .lb-table td { padding: .6em .4em; }
  body:not(.is-kiosk) .lb-table .lb-name { min-width: 8.5rem; max-width: 8.5rem; }
  body.is-kiosk #live-board { padding: .5rem; gap: .5rem; }
  body.is-kiosk .lb-heading { flex-wrap: wrap; gap: .5rem; }
}
@media (max-height: 650px) {
  body.is-kiosk #live-board { padding-block: .5rem; gap: .5rem; }
  body.is-kiosk .lb-heading .eyebrow, body.is-kiosk .lb-refresh-note { display: none; }
  body.is-kiosk #live-board h1 { font-size: 1.5rem; }
}
@media print {
  .sg-toolbar, .sg-numpad-actions, #lb-paging, .checkin-broadcast { display: none; }
  body.is-kiosk #live-board { display: block; height: auto; padding: 0; }
}
