/* Layout: evergreen rail + top bar framing a warm off-white work surface; courts drawn as mini badminton courts.
   Phone: bottom tabs, one court at a time. Tablet: rail + 2x2 courts. Wide: courts + persistent queue sidebar. */
:root {
  --brand-900: #102A27; --brand-800: #163a34; --brand-700: #1F5147; --brand-ink: #1F5147;
  --accent: #C7F36B; --accent-ink: #13261F; --accent-soft: #EEF9D6;
  --page: #F5F7F3; --surface: #FFFFFF; --surface-2: #EEF3EF; --text: #162421; --muted: #61716D; --border: #DEE7E2;
  --success: #237D57; --warning: #A86415; --danger: #B33D42; --info: #2767A7;
  --success-bg: #E1F1E8; --warning-bg: #F8ECDC; --danger-bg: #F7E3E4; --info-bg: #E2ECF7;
  --court: #1F5147; --court-draft: #2a5f54; --court-line: rgba(242, 247, 239, .5); --court-ink: #F2F7EF; --court-chip: rgba(255, 255, 255, .1); --court-chip-line: rgba(255, 255, 255, .2);
  --rail-bg: #102A27; --rail-ink: #DCE7E2; --rail-muted: #8FAAA2; --rail-active: rgba(199, 243, 107, .14);
  --on-dark: #F2F7EF; --scrim: rgba(6, 16, 14, .5);
  --shadow: 0 10px 30px rgba(16, 42, 39, .14);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --r-card: 16px; --r-field: 12px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --brand-ink: #B5DECF; --accent-soft: #24331A;
    --page: #0C1513; --surface: #14201D; --surface-2: #1A2925; --text: #E3ECE8; --muted: #98AAA4; --border: #273832;
    --success: #5AC592; --warning: #E5A85A; --danger: #E9787D; --info: #7DB3EC;
    --success-bg: #15302A; --warning-bg: #352A19; --danger-bg: #3A1F22; --info-bg: #182B3F;
    --court: #1A473D; --court-draft: #22564b; --rail-bg: #091A17; --scrim: rgba(0, 0, 0, .6);
    --shadow: 0 10px 30px rgba(0, 0, 0, .45);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --brand-ink: #B5DECF; --accent-soft: #24331A;
  --page: #0C1513; --surface: #14201D; --surface-2: #1A2925; --text: #E3ECE8; --muted: #98AAA4; --border: #273832;
  --success: #5AC592; --warning: #E5A85A; --danger: #E9787D; --info: #7DB3EC;
  --success-bg: #15302A; --warning-bg: #352A19; --danger-bg: #3A1F22; --info-bg: #182B3F;
  --court: #1A473D; --court-draft: #22564b; --rail-bg: #091A17; --scrim: rgba(0, 0, 0, .6);
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  color-scheme: dark;
}

html, body { min-height: 100%; }
body { background: var(--page); color: var(--text); font-family: var(--font); font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 70; background: var(--brand-900); }
* { box-sizing: border-box; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; text-wrap: balance; line-height: 1.2; }
h1 { font-size: 28px; font-weight: 750; letter-spacing: -.02em; }
h2 { font-size: 20px; font-weight: 700; letter-spacing: -.01em; }
h3 { font-size: 17px; font-weight: 700; }
p { margin: 0; }
a { color: var(--brand-ink); }
.num, .timer { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.cap { font-size: 12px; line-height: 1.35; }
.eyebrow { font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--info); outline-offset: 2px; }
svg.i { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
svg.i.sm { width: 14px; height: 14px; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- shell ---------- */
.shell { min-height: 100%; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto 1fr; }
.topbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 40; background: var(--brand-900); color: var(--on-dark);
  padding-block: 10px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: flex; align-items: center; gap: 12px; min-height: 56px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; letter-spacing: .06em; color: var(--on-dark); text-decoration: none; }
.brand .mark { width: 32px; height: 32px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; }
.brand .mark svg { width: 20px; height: 20px; }
.tb-session { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.tb-session strong { font-size: 15px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-meta { display: flex; gap: 10px; align-items: center; font-size: 12px; color: var(--rail-muted); flex-wrap: wrap; }
.live { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 800; letter-spacing: .1em; color: var(--accent); }
.live::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 0 rgba(199, 243, 107, .6); animation: pulse 2s infinite; }
.live.closed { color: var(--rail-muted); } .live.closed::before { background: var(--rail-muted); animation: none; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(199, 243, 107, .5); } 70% { box-shadow: 0 0 0 8px rgba(199, 243, 107, 0); } 100% { box-shadow: 0 0 0 0 rgba(199, 243, 107, 0); } }
.tb-right { display: flex; align-items: center; gap: 8px; }
.tb-stat { display: none; flex-direction: column; align-items: flex-end; font-size: 12px; color: var(--rail-muted); }
.tb-stat b { color: var(--on-dark); font-size: 15px; font-variant-numeric: tabular-nums; }
.sync { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--rail-muted); }
.sync.off { color: #F4B860; }
.role-chip { min-height: 44px; display: inline-flex; align-items: center; gap: 8px; padding: 0 12px; border-radius: 999px; border: 1px solid rgba(255, 255, 255, .2); background: rgba(255, 255, 255, .06); color: var(--on-dark); cursor: pointer; font-size: 13px; font-weight: 600; }
.role-chip .av { width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-size: 11px; font-weight: 800; }
.offline-bar { background: var(--warning-bg); color: var(--warning); font-weight: 600; font-size: 13px; padding-block: 8px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); display: flex; gap: 8px; align-items: center; }

.main { min-width: 0; padding-block: 16px 108px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); width: 100%; max-width: 1600px; margin: 0 auto; }
.rail { display: none; }
.bottomnav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; background: var(--surface); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0px); padding-left: max(8px, env(safe-area-inset-left, 0px)); padding-right: max(8px, env(safe-area-inset-right, 0px));
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); }
.bottomnav a { min-height: 60px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; font-weight: 600; color: var(--muted); text-decoration: none; }
.bottomnav a[aria-current="page"] { color: var(--brand-ink); }
.bottomnav a[aria-current="page"] svg { background: var(--accent-soft); border-radius: 10px; width: 44px; padding: 2px 10px; height: 26px; }

@media (min-width: 600px) { .tb-stat { display: flex; } }
@media (min-width: 900px) {
  .shell { grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto auto 1fr; }
  .topbar, .offline-bar, .main { grid-column: 2; }
  .topbar { padding-left: 24px; }
  .topbar .brand { display: none; }
  .rail { display: flex; flex-direction: column; grid-column: 1; grid-row: 1 / 4; position: sticky; top: 0; align-self: start; height: 100vh; height: 100dvh;
    background: var(--rail-bg); color: var(--rail-ink); width: 224px; padding-block: 14px; padding-left: max(12px, env(safe-area-inset-left, 0px)); padding-right: 12px; gap: 4px; overflow-y: auto; }
  .rail .brand { padding: 4px 8px 16px; }
  .rail a, .rail button.rail-item { min-height: 46px; display: flex; align-items: center; gap: 12px; padding: 0 12px; border-radius: 12px; color: var(--rail-ink); text-decoration: none; font-weight: 600; font-size: 14px; background: none; border: 0; cursor: pointer; text-align: left; }
  .rail a:hover, .rail button.rail-item:hover { background: rgba(255, 255, 255, .06); }
  .rail a[aria-current="page"] { background: var(--rail-active); color: var(--accent); }
  .rail .spacer { flex: 1; }
  .rail .rail-foot { font-size: 11px; color: var(--rail-muted); padding: 8px 12px; }
  .shell.rail-mini .rail { width: 76px; }
  .shell.rail-mini .rail .lbl, .shell.rail-mini .rail .brand span, .shell.rail-mini .rail .rail-foot { display: none; }
  .shell.rail-mini .rail a, .shell.rail-mini .rail button.rail-item { justify-content: center; padding: 0; }
  .bottomnav { display: none; }
  .main { padding-block: 20px 40px; padding-left: 24px; padding-right: max(24px, env(safe-area-inset-right, 0px)); }
}

/* ---------- primitives ---------- */
.stack { display: grid; gap: 16px; }
.stack.tight { gap: 8px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head p { color: var(--muted); margin-top: 4px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); padding: 16px; min-width: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px; }
.btn { min-height: 44px; padding: 0 16px; border-radius: var(--r-field); font-weight: 650; font-size: 15px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.primary:hover { filter: brightness(.96); }
.btn.dark { background: var(--brand-700); color: var(--on-dark); border-color: transparent; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--brand-ink); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--danger); }
.btn.block { width: 100%; }
.btn.icon { padding: 0; width: 44px; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row > .btn { flex: 1 1 auto; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 650; padding: 4px 10px; border-radius: 999px; white-space: nowrap; line-height: 1.3; }
.pill svg { width: 12px; height: 12px; }
.pill.ok { background: var(--success-bg); color: var(--success); }
.pill.warn { background: var(--warning-bg); color: var(--warning); }
.pill.bad { background: var(--danger-bg); color: var(--danger); }
.pill.info { background: var(--info-bg); color: var(--info); }
.pill.neutral { background: var(--surface-2); color: var(--muted); }
.pill.brand { background: var(--accent); color: var(--accent-ink); }
.tag { display: inline-flex; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px; background: var(--surface-2); color: var(--muted); letter-spacing: .02em; }
.tag.guest { background: var(--info-bg); color: var(--info); }
.tag.prov { background: var(--warning-bg); color: var(--warning); }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 12px; padding: 4px; gap: 4px; flex-wrap: wrap; }
.seg button { min-height: 40px; border: 0; background: transparent; border-radius: 9px; padding: 0 14px; font-weight: 650; color: var(--muted); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .08); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chip { min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); font-weight: 600; font-size: 14px; color: var(--muted); cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.chip[aria-pressed="true"] { background: var(--brand-700); color: var(--on-dark); border-color: transparent; }
.field { display: grid; gap: 6px; }
.field label, .field .lbl { font-size: 13px; font-weight: 650; }
.input, select.input, textarea.input { min-height: 46px; border: 1px solid var(--border); border-radius: var(--r-field); background: var(--surface); padding: 0 14px; width: 100%; }
textarea.input { padding: 10px 14px; min-height: 80px; resize: vertical; }
.input:focus { outline: 2px solid var(--brand-700); outline-offset: 0; border-color: transparent; }
.search { position: relative; }
.search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search .input { padding-left: 42px; }
.err { color: var(--danger); font-size: 13px; font-weight: 600; }
.note { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; font-size: 13px; color: var(--muted); }
.note.warn { background: var(--warning-bg); color: var(--warning); }
.empty { text-align: center; padding: 32px 16px; display: grid; gap: 10px; justify-items: center; color: var(--muted); }
.empty h3 { color: var(--text); }
.av { width: 36px; height: 36px; border-radius: 50%; background: var(--surface-2); color: var(--brand-ink); display: grid; place-items: center; font-weight: 750; font-size: 13px; flex: none; }
.av.lg { width: 64px; height: 64px; font-size: 22px; }
.st { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 650; }
.st.available { color: var(--success); } .st.playing { color: var(--info); } .st.break { color: var(--warning); } .st.gone, .st.out { color: var(--muted); }
.st svg { width: 14px; height: 14px; }

/* ---------- board ---------- */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar .grow { flex: 1; }
.court-tabs { display: flex; gap: 6px; margin-bottom: 12px; overflow-x: auto; scrollbar-width: none; }
.court-tabs button { min-height: 44px; min-width: 52px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 0 12px; }
.court-tabs button[aria-pressed="true"] { background: var(--brand-900); color: var(--on-dark); border-color: transparent; }
.court-tabs .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.court-tabs .dot.playing { background: var(--info); } .court-tabs .dot.free, .court-tabs .dot.suggested { background: var(--success); } .court-tabs .dot.needs, .court-tabs .dot.closing { background: var(--warning); }
.board-layout { display: grid; gap: 16px; }
.court-grid { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
@media (max-width: 899px) { .court-grid:not(.all) .court-card:not(.is-current) { display: none; } }
@media (min-width: 600px) { .court-grid.all { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 900px) { .court-tabs { display: none; } .court-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .court-grid.single { grid-template-columns: minmax(0, 1fr); } }
@media (min-width: 1200px) { .board-layout { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; } }

.court-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); padding: 14px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.court-card.needs { border-color: var(--warning); }
.cc-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cc-head h3 { font-size: 15px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.cc-head .timer { margin-left: auto; font-size: 22px; font-weight: 750; letter-spacing: -.01em; }
.court-area { position: relative; background: var(--court); color: var(--court-ink); border-radius: 12px; padding: 16px 12px; display: grid; gap: 10px; min-height: 180px; align-content: center;
  border: 2px solid var(--court-line); }
.court-area::before { content: ""; position: absolute; inset: 10px 18px; border-left: 1px solid var(--court-line); border-right: 1px solid var(--court-line); pointer-events: none; opacity: .6; }
.court-area.draft { background: var(--court-draft); border-style: dashed; border-color: var(--accent); }
.court-area.off { background: var(--surface-2); color: var(--muted); border-color: var(--border); border-style: dashed; }
.court-area.off::before { display: none; }
.court-area .msg { position: relative; text-align: center; display: grid; gap: 6px; justify-items: center; padding: 0 8px; }
.team { position: relative; display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.team .side { font-size: 10px; font-weight: 800; letter-spacing: .12em; opacity: .7; align-self: center; }
.net { position: relative; display: flex; align-items: center; gap: 10px; font-size: 11px; font-weight: 800; letter-spacing: .16em; color: var(--court-ink); }
.net::before, .net::after { content: ""; flex: 1; border-top: 2px dashed var(--court-line); }
.pchip { display: inline-flex; align-items: center; gap: 6px; background: var(--court-chip); border: 1px solid var(--court-chip-line); padding: 4px 12px; border-radius: 999px; font-weight: 650; min-height: 38px; max-width: 100%; }
.pchip .r { font-size: 12px; opacity: .78; font-variant-numeric: tabular-nums; }
.pchip .flag { display: inline-flex; color: var(--accent); }
.pchip .g { font-size: 10px; font-weight: 800; letter-spacing: .06em; background: var(--court-chip-line); border-radius: 4px; padding: 1px 4px; }
.cc-foot { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.cc-foot .btn { flex: 1 1 auto; }
.cc-note { font-size: 13px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.cc-note.warn { color: var(--warning); font-weight: 600; }
.board-foot { margin-top: 16px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; justify-content: space-between; padding: 12px 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); }
.board-foot .counts { font-weight: 650; font-variant-numeric: tabular-nums; }

.queue-panel { display: none; }
.mobile-queue { display: grid; gap: 12px; margin-top: 14px; }
@media (min-width: 900px) { .queue-panel { display: block; } .mobile-queue { display: none; } }
@media (min-width: 1200px) { .queue-panel { position: sticky; top: 76px; } .queue-panel .seg { display: none; } .queue-panel .qsec[hidden] { display: block !important; } }
.qsec { display: grid; gap: 10px; }
.qrow { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 10px 0; border-top: 1px solid var(--border); }
.qrow:first-child { border-top: 0; }
.qrow .pos { font-weight: 800; color: var(--muted); font-variant-numeric: tabular-nums; text-align: center; }
.qrow .who { min-width: 0; }
.qrow .who b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 650; }
.qrow .who span { font-size: 12px; color: var(--muted); }
.qrow .w { text-align: right; font-variant-numeric: tabular-nums; font-weight: 750; }
.qrow .w small { display: block; font-size: 11px; color: var(--muted); font-weight: 500; }
.long { color: var(--warning); display: inline-flex; gap: 4px; align-items: center; font-size: 11px; font-weight: 700; }
.next-card { background: var(--surface-2); border-radius: 12px; padding: 12px; display: grid; gap: 6px; text-align: center; }
.next-card .vs { font-size: 11px; font-weight: 800; letter-spacing: .14em; color: var(--muted); }

/* ---------- sheets / drawer ---------- */
.scrim { position: fixed; inset: 0; z-index: 80; background: var(--scrim); display: flex; align-items: flex-end; justify-content: center; }
.scrim.enter { animation: fade .15s ease-out; }
.scrim.enter .sheet { animation: up .2s ease-out; }
.sheet { background: var(--surface); width: 100%; max-width: 640px; max-height: 92vh; max-height: 92dvh; overflow-y: auto; border-radius: 22px 22px 0 0; box-shadow: var(--shadow);
  padding: 18px max(18px, env(safe-area-inset-right, 0px)) calc(18px + env(safe-area-inset-bottom, 0px)) max(18px, env(safe-area-inset-left, 0px)); display: grid; gap: 16px; align-content: start; }
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.sheet-head p { color: var(--muted); font-size: 14px; margin-top: 2px; }
.sheet-foot { position: sticky; bottom: calc(-18px - env(safe-area-inset-bottom, 0px)); background: var(--surface); padding-top: 12px; padding-bottom: calc(18px + env(safe-area-inset-bottom, 0px)); margin-bottom: calc(-18px - env(safe-area-inset-bottom, 0px)); display: flex; gap: 10px; flex-wrap: wrap; border-top: 1px solid var(--border); }
.sheet-foot .btn { flex: 1 1 auto; }
@media (min-width: 900px) {
  .scrim { justify-content: flex-end; align-items: stretch; }
  .sheet { width: 460px; max-width: 100%; max-height: none; height: 100%; border-radius: 22px 0 0 22px; }
  .scrim.enter .sheet { animation: left .2s ease-out; }
  .scrim.center.enter .sheet { animation: up .2s ease-out; }
  .scrim.center { justify-content: center; align-items: center; }
  .scrim.center .sheet { height: auto; max-height: 90vh; border-radius: 22px; }
}
@keyframes fade { from { opacity: 0; } } @keyframes up { from { transform: translateY(24px); opacity: .6; } } @keyframes left { from { transform: translateX(24px); opacity: .6; } }
.teams2 { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 420px) { .teams2 { grid-template-columns: 1fr 1fr; } }
.tcard { border: 1px solid var(--border); border-radius: 14px; padding: 12px; display: grid; gap: 6px; }
.tcard .tp { display: flex; justify-content: space-between; gap: 8px; font-weight: 650; }
.tcard .tp span { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 600; }
.tcard .tsum { font-size: 12px; color: var(--muted); border-top: 1px dashed var(--border); padding-top: 6px; }
.meter { display: grid; gap: 6px; }
.meter .bar { height: 10px; border-radius: 999px; background: var(--surface-2); position: relative; overflow: hidden; display: flex; }
.meter .a { background: var(--brand-700); } .meter .b { background: var(--accent); }
.meter .lbls { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.why { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.why li { display: flex; gap: 8px; font-size: 14px; }
.why li svg { color: var(--success); margin-top: 2px; }
.factors { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.factor { background: var(--surface-2); border-radius: 10px; padding: 8px; text-align: center; }
.factor b { display: block; font-size: 17px; font-variant-numeric: tabular-nums; }
.factor span { font-size: 11px; color: var(--muted); }
.stale { background: var(--warning-bg); color: var(--warning); border-radius: 12px; padding: 12px; display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; font-weight: 600; }
.pick { display: grid; gap: 8px; }
.pick button { min-height: 52px; display: flex; align-items: center; gap: 10px; text-align: left; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); padding: 8px 12px; cursor: pointer; }
.pick button:hover { border-color: var(--brand-700); }
.pick button .grow { flex: 1; min-width: 0; }
.pick button[aria-pressed="true"] { border-color: var(--brand-700); background: var(--accent-soft); }
.radio-card { display: flex; gap: 12px; align-items: center; border: 2px solid var(--border); border-radius: 14px; padding: 14px; cursor: pointer; min-height: 64px; }
.radio-card input { width: 22px; height: 22px; accent-color: var(--brand-700); }
.radio-card:has(input:checked) { border-color: var(--brand-700); background: var(--accent-soft); }
.radio-card .t { font-size: 12px; font-weight: 800; letter-spacing: .1em; color: var(--muted); }
.radio-card .n { font-weight: 700; }
.score { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: end; }
.score .input { text-align: center; font-size: 22px; font-weight: 750; min-height: 56px; font-variant-numeric: tabular-nums; }
.score .dash { padding-bottom: 14px; color: var(--muted); font-weight: 700; }
.toast-root { position: fixed; left: 0; right: 0; bottom: calc(76px + env(safe-area-inset-bottom, 0px)); z-index: 90; display: flex; justify-content: center; pointer-events: none; padding: 0 16px; }
@media (min-width: 900px) { .toast-root { bottom: 24px; } }
.toast { pointer-events: auto; background: var(--brand-900); color: var(--on-dark); border-radius: 14px; padding: 10px 10px 10px 16px; display: flex; gap: 12px; align-items: center; box-shadow: var(--shadow); max-width: 560px; font-weight: 600; animation: up .2s ease-out; }
.toast.err { background: var(--danger); }
.toast .btn { min-height: 40px; background: var(--accent); color: var(--accent-ink); border: 0; }

/* ---------- lists, tables, stats ---------- */
.list { display: grid; }
.lrow { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-top: 1px solid var(--border); min-height: 60px; background: none; border-left: 0; border-right: 0; border-bottom: 0; width: 100%; text-align: left; cursor: pointer; color: inherit; }
.lrow:first-child { border-top: 0; }
.lrow:hover { background: var(--surface-2); }
.lrow .grow { flex: 1; min-width: 0; }
.lrow .grow b { display: block; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lrow .grow span { font-size: 13px; color: var(--muted); }
.lrow input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--brand-700); }
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: left; font-size: 12px; font-weight: 700; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.t td { padding: 12px; border-bottom: 1px solid var(--border); white-space: nowrap; font-variant-numeric: tabular-nums; }
table.t tr.click { cursor: pointer; } table.t tr.click:hover td { background: var(--surface-2); }
.only-wide { display: none; } @media (min-width: 900px) { .only-wide { display: block; } .only-narrow { display: none; } }
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 900px) { .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px; display: grid; gap: 2px; }
.kpi span { font-size: 12px; color: var(--muted); font-weight: 600; }
.kpi b { font-size: 24px; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi small { font-size: 12px; color: var(--muted); }
.grid2 { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) { .grid2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.lb { display: grid; }
.lb .lbr { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 9px 0; border-top: 1px solid var(--border); }
.lb .lbr:first-child { border-top: 0; }
.lb .lbr .pos { font-weight: 800; color: var(--muted); text-align: center; font-variant-numeric: tabular-nums; }
.lb .lbr:first-child .pos { color: var(--accent-ink); background: var(--accent); border-radius: 8px; }
.lb .lbr .v { font-weight: 750; font-variant-numeric: tabular-nums; text-align: right; }
.lb .lbr .v small { display: block; font-size: 11px; color: var(--muted); font-weight: 500; }
.profile-head { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.rating-big { margin-left: auto; text-align: right; }
.rating-big b { font-size: 34px; font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.spark { width: 100%; height: 140px; display: block; }
.spark text { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.mrow { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 14px; border-top: 1px solid var(--border); }
.mrow:first-child { border-top: 0; }
.res { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; font-weight: 800; font-size: 13px; }
.res.W { background: var(--success-bg); color: var(--success); } .res.L { background: var(--danger-bg); color: var(--danger); } .res.X { background: var(--surface-2); color: var(--muted); }
.timeline { display: grid; }
.tl { display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); font-size: 14px; }
.tl:first-child { border-top: 0; }
.tl time { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 13px; }
.tl .who { font-size: 12px; color: var(--muted); }
.court-ctl { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 12px 0; border-top: 1px solid var(--border); }
.court-ctl:first-child { border-top: 0; }
.set-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(120px, 200px); gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--border); }
.set-row:first-child { border-top: 0; }
.set-row p { font-size: 13px; color: var(--muted); }

/* ---------- my session ---------- */
.status-hero { border-radius: 18px; padding: 18px; display: grid; gap: 10px; background: var(--brand-900); color: var(--on-dark); }
.status-hero .big { font-size: 13px; font-weight: 800; letter-spacing: .12em; color: var(--accent); display: flex; align-items: center; gap: 8px; }
.status-hero .stats3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.status-hero .stats3 div { background: rgba(255, 255, 255, .06); border-radius: 12px; padding: 10px; }
.status-hero .stats3 b { display: block; font-size: 22px; font-variant-numeric: tabular-nums; }
.status-hero .stats3 span { font-size: 11px; color: var(--rail-muted); }
.status-hero .note { background: rgba(255, 255, 255, .08); color: var(--rail-ink); }
.my-grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); max-width: 980px; }
@media (min-width: 900px) { .my-grid { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); align-items: start; } }

/* ---------- sign in ---------- */
.signin { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1fr); background: var(--page); }
.signin .hero { background: var(--brand-900); color: var(--on-dark); padding-block: 32px; padding-left: max(24px, env(safe-area-inset-left, 0px)); padding-right: max(24px, env(safe-area-inset-right, 0px)); display: grid; gap: 18px; align-content: center; position: relative; overflow: hidden; }
.signin .hero h1 { font-size: clamp(32px, 6vw, 56px); line-height: 1; letter-spacing: -.035em; font-weight: 850; }
.signin .hero h1 em { font-style: normal; color: var(--accent); }
.signin .hero p { color: var(--rail-ink); max-width: 34ch; }
.signin .hero svg.courtart { width: min(420px, 100%); height: auto; opacity: .9; }
.signin .form { padding-block: 32px; padding-left: max(24px, env(safe-area-inset-left, 0px)); padding-right: max(24px, env(safe-area-inset-right, 0px)); display: grid; align-content: center; }
.signin .form > div { width: 100%; max-width: 400px; margin: 0 auto; display: grid; gap: 14px; }
@media (min-width: 900px) { .signin { grid-template-columns: 1.1fr 1fr; } .signin .hero { padding: 56px; } }

/* ---------- display mode ---------- */
.display { min-height: 100vh; min-height: 100dvh; background: var(--brand-900); color: var(--on-dark); padding-block: 20px; padding-left: max(20px, env(safe-area-inset-left, 0px)); padding-right: max(20px, env(safe-area-inset-right, 0px)); display: grid; gap: 18px; align-content: start; }
.display .dh { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.display .dh h1 { font-size: clamp(22px, 3vw, 36px); }
.display .clock { font-size: clamp(28px, 4vw, 48px); font-weight: 800; font-variant-numeric: tabular-nums; }
.display .dgrid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) { .display .dgrid { grid-template-columns: minmax(0, 3fr) minmax(260px, 1fr); } }
.display .dcourts { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 700px) { .display .dcourts { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.display .dc { background: rgba(255, 255, 255, .04); border: 1px solid rgba(255, 255, 255, .1); border-radius: 18px; padding: 14px; display: grid; gap: 10px; }
.display .dc .court-area { min-height: 200px; font-size: 18px; }
.display .dc .pchip { font-size: 18px; min-height: 46px; }
.display .dq { background: rgba(255, 255, 255, .04); border: 1px solid rgba(255, 255, 255, .1); border-radius: 18px; padding: 16px; display: grid; gap: 8px; align-content: start; }
.display .dq .r { display: flex; justify-content: space-between; font-size: 18px; padding: 6px 0; border-top: 1px solid rgba(255, 255, 255, .08); font-variant-numeric: tabular-nums; }
.display .exit { position: fixed; right: max(16px, env(safe-area-inset-right, 0px)); bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }
.more-list .lrow svg { color: var(--brand-ink); }
button.qrow { background: none; border-left: 0; border-right: 0; border-bottom: 0; width: 100%; text-align: left; color: inherit; cursor: pointer; font: inherit; }
button.qrow:hover { background: var(--surface-2); }
button.qrow[aria-pressed="true"] { background: var(--accent-soft); }
button.qrow[aria-pressed="true"] .pos { color: var(--brand-ink); }

/* ---------- hosted app additions ---------- */
html { padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
body { margin: 0; }
[hidden] { display: none !important; }
img { max-width: 100%; }
.shell.plain { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
.shell.plain .topbar, .shell.plain .main { grid-column: 1 / -1; }
.shell.plain .topbar .brand { display: flex; }
.shell.plain .main { max-width: 1040px; padding-bottom: 48px; }
.qr { max-width: 240px; width: 100%; margin: 0 auto; background: #fff; padding: 10px; border-radius: 14px; }
.qr svg { width: 100%; height: auto; display: block; }
a.role-chip { text-decoration: none; }
details summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; }
.kpi b span { font-size: inherit; color: inherit; font-weight: inherit; }

.lb-toggle { width: 100%; margin-top: 6px; min-height: 40px; font-size: 14px; }

/* ---------- join QR, recent results ---------- */
.code-chip { display: inline-flex; align-items: center; gap: 5px; min-height: 30px; padding: 2px 10px; border-radius: 999px; border: 1px solid rgba(199, 243, 107, .45); background: rgba(199, 243, 107, .12); color: var(--accent); font: inherit; font-size: 12px; font-weight: 800; letter-spacing: .12em; cursor: pointer; }
.code-chip:hover { background: rgba(199, 243, 107, .2); }
.rr-list { display: grid; }
.rr { display: flex; gap: 10px; align-items: center; padding: 10px 0; border-top: 1px solid var(--border); font-size: 14px; }
.rr:first-child { border-top: 0; }
.rr .grow { flex: 1; min-width: 0; }
.rr .btn { min-height: 40px; padding: 0 12px; font-size: 14px; }
.display .dside { display: grid; gap: 16px; align-content: start; }
.display .djoin { text-align: center; justify-items: center; }
.display .djoin .qr { max-width: 220px; }
.display .djoin p { font-size: 15px; color: var(--rail-ink); }
.display .dcode { font-size: clamp(32px, 4vw, 48px); letter-spacing: .18em; color: var(--accent); font-variant-numeric: tabular-nums; }

.display .court-area.off { background: rgba(255, 255, 255, .04); color: var(--rail-muted); border-color: rgba(255, 255, 255, .14); }
.display .pill.neutral { background: rgba(255, 255, 255, .1); color: var(--rail-ink); }

/* WhatsApp sharing + club invite */
.btn.wa { background: #25D366; color: #08261A; border-color: transparent; text-decoration: none; }
.btn.wa:hover { filter: brightness(.95); }
.invite-row { display: grid; grid-template-columns: 132px 1fr; gap: 14px; align-items: start; }
.invite-row .qr { width: 132px; background: #fff; border-radius: 10px; padding: 6px; }
.invite-row .qr svg { display: block; width: 100%; height: auto; }
@media (max-width: 420px) { .invite-row { grid-template-columns: 1fr; } .invite-row .qr { width: 168px; margin: 0 auto; } }

/* men / women and match formats */
.pill.fmt { background: var(--surface-2); color: var(--text); }
.segr { position: relative; }
.segr input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segr span { display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; border-radius: 9px; font-weight: 650; color: var(--muted); }
.segr input:checked + span { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .08); }
.segr input:focus-visible + span { outline: 3px solid var(--focus, #6CB4FF); outline-offset: 1px; }

/* organiser invites + club team */
.fyi { background: var(--warning-bg); color: var(--text); border-radius: 12px; padding: 12px 14px; font-size: 14px; line-height: 1.5; }
.fyi b { display: block; margin-bottom: 2px; }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; color: inherit; text-decoration: underline; cursor: pointer; font-weight: 650; }
.av.org { background: var(--accent); color: var(--accent-ink); }
.av.org svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; }
