/* SpotBid Live Scoring — dark sports visual language (BRD §29)
   Player names lead, team names follow; scores are the largest thing on any card. */
:root {
  --bg: #0d0c14;
  --surface: #16151f;
  --surface-2: #1e1c2b;
  --line: #2b2940;
  --fg: #f4f3fa;
  --muted: #9c99b5;
  --accent: #8b6cff;
  --accent-ink: #ffffff;
  --accent-soft: rgba(139, 108, 255, 0.16);
  --ball: #d4ec3a;            /* pickleball optic yellow: LIVE, GAME POINT, serve */
  --ball-ink: #1b2200;
  --ok: #3ddc97;
  --warn: #ffb547;
  --danger: #ff6b6b;
  --radius: 14px;
  --display: "Barlow Condensed", "Roboto Condensed", "Arial Narrow", system-ui, sans-serif;
  --body: "Barlow", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  /* status surfaces */
  --ok-bg: #0f3324; --danger-bg: #3a1418; --warn-bg: #3a2500; --trump-bg: #3a2a00;
  --danger-fg: #ffb3b3; --info-fg: #d6ccff; --line-strong: #3b3858;
  --ball-text: var(--ball);        /* highlight used as text or outline */
  --hero-glow: rgba(139, 108, 255, 0.35); --hero-a: #1b1830; --hero-b: #121119;
  --bar-bg: rgba(13, 12, 20, 0.92);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  color-scheme: dark;
}

/* Light theme. data-theme is set on <html> before first paint by views/partials/theme_head.php
   (user choice > tournament default; "system" follows the device). Brand colours from
   Admin > Settings > Appearance are injected after this file and win over these defaults. */
:root[data-theme="light"] {
  --bg: #f4f4f9;
  --surface: #ffffff;
  --surface-2: #ecebf4;
  --line: #dcdae8;
  --line-strong: #c4c1d8;
  --fg: #16151f;
  --muted: #5d5a75;
  --accent-soft: rgba(139, 108, 255, 0.14);
  --ok: #0c8a54; --warn: #a75a00; --danger: #c72f3b;
  --ok-bg: #e2f5ea; --danger-bg: #fde7e9; --warn-bg: #fff0d9; --trump-bg: #fff0d9;
  --danger-fg: #9b1c26; --info-fg: #4630b8;
  --ball-text: #5d6b00;
  --hero-glow: rgba(139, 108, 255, 0.22); --hero-a: #ffffff; --hero-b: #efecfb;
  --bar-bg: rgba(244, 244, 249, 0.94);
  --shadow: 0 10px 30px rgba(22, 21, 31, 0.15);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 16px/1.5 var(--body); min-height: 100vh;
  font-variant-numeric: tabular-nums;
}
a { color: inherit; }
img { max-width: 100%; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
/* WebView / touch: no grey tap flash, no double-tap zoom delay on controls */
a, button, summary, label, select, input { -webkit-tap-highlight-color: transparent; }
button, .btn, a, summary, label, .choice, .point-btn { touch-action: manipulation; }
/* Clip stray page-level overflow without turning <html>/<body> into scroll containers
   (overflow-x:hidden on both breaks swipe-scrolling of inner tables in some mobile browsers/WebViews) */
body { overflow-x: hidden; overflow-x: clip; -webkit-font-smoothing: antialiased; overscroll-behavior-y: none; }
/* 16px inputs stop iOS WebView zooming on focus */
input, select, textarea { font-size: 16px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

h1, h2, h3 { font-family: var(--display); font-weight: 700; letter-spacing: 0.01em; line-height: 1.1; margin: 0; text-wrap: balance; }
h1 { font-size: clamp(28px, 5vw, 40px); }
h2 { font-size: 24px; }
h3 { font-size: 19px; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.upper { text-transform: uppercase; letter-spacing: 0.08em; }
.label { font: 600 12px/1.2 var(--body); text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }

/* ---------- layout ---------- */
.wrap { max-width: 1120px; margin: 0 auto; padding-inline: 16px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-lg { display: flex; flex-direction: column; gap: 32px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: 16px; }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 12px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.section-head a { color: var(--accent); text-decoration: none; font-weight: 600; font-size: 14px; }

/* ---------- top bar & nav ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--bar-bg);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top, 0px);
}
.topbar .wrap { display: flex; align-items: center; gap: 16px; min-height: 58px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; min-width: 0; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; background: var(--accent); display: grid; place-items: center; flex: none; }
.brand-mark svg { width: 18px; height: 18px; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text b { font: 700 17px/1.1 var(--display); text-transform: uppercase; letter-spacing: 0.04em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text span { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topnav { margin-left: auto; display: flex; gap: 4px; }
.topnav a { text-decoration: none; padding: 8px 12px; border-radius: 10px; color: var(--muted); font-weight: 600; font-size: 15px; }
.topnav a[aria-current="page"], .topnav a:hover { color: var(--fg); background: var(--surface-2); }

.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: none;
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.bottomnav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 7px; text-decoration: none; color: var(--muted); font-size: 11px; font-weight: 600; }
.bottomnav a svg { width: 22px; height: 22px; }
.bottomnav a[aria-current="page"] { color: var(--fg); }
.bottomnav a[aria-current="page"] svg { color: var(--accent); }
@media (max-width: 760px) {
  .topnav { display: none; }
  .bottomnav { display: flex; }
  body.has-bottomnav main { padding-bottom: calc(84px + env(safe-area-inset-bottom, 0px)); }
}
main { padding-block: 20px 48px; }

/* ---------- chips & badges ---------- */
.chip { display: inline-flex; align-items: center; gap: 6px; font: 700 11px/1 var(--body); text-transform: uppercase; letter-spacing: 0.08em; padding: 5px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.chip.live { background: var(--ball); color: var(--ball-ink); }
.chip.live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: pulse 1.4s infinite; }
.chip.gp { background: transparent; color: var(--ball-text); box-shadow: inset 0 0 0 1.5px var(--ball-text); }
.chip.final { background: var(--accent-soft); color: var(--accent); }
.chip.trump { background: var(--trump-bg); color: var(--warn); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.danger { background: var(--danger-bg); color: var(--danger); }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
@keyframes pulse { 50% { opacity: 0.3; } }
@media (prefers-reduced-motion: reduce) { .chip.live::before { animation: none; } }

/* ---------- match card (player-first, BRD §11) ---------- */
.mcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; text-decoration: none; min-width: 0; }
a.mcard:hover { border-color: var(--line-strong); }
.mcard.is-live { border-color: #6d7a2a; border-color: color-mix(in srgb, var(--ball) 45%, var(--line)); }
.mcard-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mcard-head .slot { font: 700 15px/1 var(--display); letter-spacing: 0.06em; }
.mcard-head .meta { color: var(--muted); font-size: 13px; }
.mcard-head .right { margin-left: auto; display: flex; gap: 6px; }
.side { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; }
.side .names { font: 700 19px/1.15 var(--display); text-transform: uppercase; letter-spacing: 0.02em; overflow-wrap: anywhere; }
.side .team { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.side .score { font: 700 34px/1 var(--display); min-width: 1.4ch; text-align: right; }
.side.won .score { color: var(--fg); }
.side.lost .score, .side.lost .names { color: var(--muted); }
.side.won .names::after { content: " ✓"; color: var(--ok); }
.serve-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--ball-text); margin-left: 6px; vertical-align: middle; }
.team-swatch { width: 9px; height: 9px; border-radius: 3px; display: inline-block; flex: none; }
.vs { font: 700 12px/1 var(--display); color: var(--muted); letter-spacing: 0.2em; display: flex; align-items: center; gap: 10px; }
.vs::before, .vs::after { content: ""; height: 1px; background: var(--line); flex: 1; }
.games-line { font-size: 13px; color: var(--muted); }

/* ---------- hero ---------- */
.hero { border-radius: 20px; padding: 24px; background:
    radial-gradient(120% 140% at 100% 0%, var(--hero-glow), transparent 55%),
    linear-gradient(160deg, var(--hero-a), var(--hero-b)); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 14px; }
.hero .kpis { display: flex; gap: 24px; flex-wrap: wrap; }
.kpi b { display: block; font: 700 30px/1 var(--display); }
.kpi span { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; overflow-y: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table.data { border-collapse: collapse; width: 100%; font-size: 15px; }
table.data th, table.data td { padding: 10px 12px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data th { font: 600 11px/1.2 var(--body); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); background: var(--surface-2); }
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data td.name, table.data th.name { text-align: left; white-space: normal; min-width: 150px; }
table.data tr:last-child td { border-bottom: 0; }
table.data td.pos { width: 36px; color: var(--muted); font-weight: 700; }
table.data tr.qualify td.pos { color: var(--accent); }
table.data td a { text-decoration: none; font-weight: 600; }
table.data td a:hover { text-decoration: underline; }
td.strong, .strong { font-weight: 700; }
.form-pills { display: inline-flex; gap: 3px; }
.form-pills i { font-style: normal; width: 18px; height: 18px; border-radius: 5px; display: inline-grid; place-items: center; font-size: 10px; font-weight: 700; }
.form-pills .W { background: var(--ok-bg); color: var(--ok); }
.form-pills .L { background: var(--danger-bg); color: var(--danger); }
.form-pills .D { background: var(--surface-2); color: var(--muted); }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.tabs a, .tabs button { flex: none; text-decoration: none; border: 1px solid var(--line); background: transparent; padding: 8px 14px; border-radius: 999px; font-weight: 600; font-size: 14px; color: var(--muted); cursor: pointer; }
.tabs a[aria-current="page"], .tabs button[aria-selected="true"] { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.tabs .count { opacity: 0.7; margin-left: 4px; }

/* ---------- forms & buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 12px; padding: 11px 18px; font-weight: 700; font-size: 15px; cursor: pointer; text-decoration: none; background: var(--surface-2); color: var(--fg); min-height: 44px; }
.btn:hover { filter: brightness(1.12); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.ball { background: var(--ball); color: var(--ball-ink); }
.btn.danger { background: var(--danger-bg); color: var(--danger); }
.btn.ghost { background: transparent; box-shadow: inset 0 0 0 1px var(--line); }
.btn.small { padding: 6px 12px; min-height: 34px; font-size: 13px; border-radius: 9px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; filter: none; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-weight: 600; font-size: 14px; }
.field small { color: var(--muted); font-size: 12px; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=datetime-local], input[type=tel], select, textarea {
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-height: 44px; width: 100%;
}
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; }
.check { display: flex; gap: 10px; align-items: center; min-height: 44px; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 14px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.notice { border-radius: 12px; padding: 12px 14px; font-weight: 600; }
.notice.ok { background: var(--ok-bg); color: var(--ok); }
.notice.error { background: var(--danger-bg); color: var(--danger-fg); }
.notice.info { background: var(--accent-soft); color: var(--info-fg); }
.empty { border: 1px dashed var(--line); border-radius: var(--radius); padding: 28px 16px; text-align: center; color: var(--muted); }

/* ---------- profile ---------- */
.profile-head { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.avatar { width: 64px; height: 64px; border-radius: 18px; background: var(--surface-2); display: grid; place-items: center; font: 700 26px/1 var(--display); color: var(--accent); flex: none; }
.statgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.stat b { display: block; font: 700 26px/1.1 var(--display); }
.stat span { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }

/* ---------- timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.timeline li { display: grid; grid-template-columns: 70px 1fr auto; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; align-items: center; }
.timeline li .t { color: var(--muted); font-size: 12px; }
.timeline li.muted-row { color: var(--muted); }

/* ---------- bracket ---------- */
.bracket { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: 16px; align-items: start; }
.tie { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.tie header { padding: 10px 14px; background: var(--surface-2); display: flex; justify-content: space-between; }
.tie .team-row { display: flex; justify-content: space-between; padding: 12px 14px; border-top: 1px solid var(--line); font: 700 18px/1.2 var(--display); text-transform: uppercase; }
.tie .team-row.win { color: var(--ball-text); }

/* ---------- login ---------- */
.login-card { max-width: 420px; margin: 6vh auto 0; }

/* ---------- admin ---------- */
.admin-shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: 100vh; }
.admin-side { background: var(--surface); border-right: 1px solid var(--line); padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.admin-side .brand { padding: 4px 6px 16px; }
.admin-side a.nav { text-decoration: none; color: var(--muted); padding: 9px 12px; border-radius: 10px; font-weight: 600; font-size: 15px; }
.admin-side a.nav[aria-current="page"], .admin-side a.nav:hover { background: var(--surface-2); color: var(--fg); }
.admin-side .sep { height: 1px; background: var(--line); margin: 10px 4px; }
.admin-main { padding: 24px; min-width: 0; display: flex; flex-direction: column; gap: 20px; }
@media (max-width: 900px) {
  .admin-shell { grid-template-columns: minmax(0, 1fr); }
  .admin-side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; border-right: 0; border-bottom: 1px solid var(--line); }
  .admin-side .brand { width: 100%; padding-bottom: 8px; }
  .admin-side .sep { display: none; }
  .admin-main { padding: 16px; }
}
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.court { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.court.stale { border-color: var(--warn); }
.court .actions { display: flex; gap: 6px; flex-wrap: wrap; }
details.inline-form summary { cursor: pointer; list-style: none; }
details.inline-form summary::-webkit-details-marker { display: none; }
details.inline-form[open] { flex-basis: 100%; }
.inline-form form { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; margin-top: 8px; }
.settings-row { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--line); align-items: start; }
.settings-row:last-child { border-bottom: 0; }
@media (max-width: 640px) { .settings-row { grid-template-columns: minmax(0, 1fr); gap: 8px; } }
.settings-row .what b { display: block; }
.settings-row .what small { color: var(--muted); }
.order-list { display: flex; flex-direction: column; gap: 6px; }
.order-item { display: flex; align-items: center; gap: 8px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 6px 8px; }
.order-item span { flex: 1; }
.order-item button { background: var(--surface-2); border: 0; border-radius: 8px; width: 32px; height: 32px; cursor: pointer; }
.rule-tag { font-size: 11px; font-weight: 700; padding: 3px 7px; border-radius: 6px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.rule-tag.recalc { color: var(--info-fg); background: var(--accent-soft); }
.rule-tag.locked { color: var(--warn); background: var(--warn-bg); }
.preview-box { position: sticky; bottom: 0; background: var(--surface); border: 1px solid var(--accent); border-radius: var(--radius); padding: 14px 16px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

/* ---------- scorer app ---------- */
body.scorer { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.scorer-top { display: flex; align-items: center; gap: 10px; padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px; border-bottom: 1px solid var(--line); background: var(--surface); }
.scorer-top .who { margin-left: auto; font-size: 13px; color: var(--muted); }
.net { font: 700 11px/1 var(--body); letter-spacing: 0.08em; text-transform: uppercase; padding: 6px 9px; border-radius: 999px; }
.net.online { background: var(--ok-bg); color: var(--ok); }
.net.offline { background: var(--danger-bg); color: var(--danger); }
.net.syncing { background: var(--warn-bg); color: var(--warn); }
.scorer-tabs { display: flex; gap: 0; border-bottom: 1px solid var(--line); background: var(--surface); }
.scorer-tabs button { flex: 1; background: none; border: 0; border-bottom: 3px solid transparent; padding: 12px 6px; font-weight: 700; color: var(--muted); cursor: pointer; }
.scorer-tabs button[aria-selected="true"] { color: var(--fg); border-bottom-color: var(--accent); }
.scorer-body { flex: 1; padding: 16px; display: flex; flex-direction: column; gap: 12px; max-width: 640px; width: 100%; margin: 0 auto; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(20px + env(safe-area-inset-bottom, 0px)); background: var(--fg); color: var(--bg); padding: 12px 16px; border-radius: 12px; font-weight: 700; z-index: 50; max-width: calc(100% - 32px); box-shadow: var(--shadow); }
.toast.error { background: var(--danger); color: #1a0505; }

.live-head { text-align: center; display: flex; flex-direction: column; gap: 4px; }
.live-head .label { color: var(--ball-text); }
.live-head .meta { font: 700 16px/1.2 var(--display); text-transform: uppercase; letter-spacing: 0.06em; }
.live-side { background: var(--surface); border: 2px solid var(--line); border-radius: 20px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.live-side.serving { border-color: var(--ball-text); }
.live-side .players { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.live-side .pname { font: 700 22px/1.1 var(--display); text-transform: uppercase; display: inline-flex; align-items: center; gap: 6px; }
.live-side .pname .role { font: 800 10px/1 var(--body); letter-spacing: 0.1em; padding: 4px 6px; border-radius: 6px; }
.live-side .pname .role.serve { background: var(--ball); color: var(--ball-ink); }
.live-side .pname .role.receive { background: var(--surface-2); color: var(--fg); }
.live-side .tname { color: var(--muted); font-size: 14px; }
.live-side .scoreline { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 12px; align-items: center; }
.big-score { font: 700 clamp(84px, 26vw, 140px)/0.9 var(--display); text-align: center; }
.point-btn { background: var(--accent); color: #fff; border: 0; border-radius: 18px; min-height: 96px; font: 800 24px/1 var(--display); letter-spacing: 0.06em; cursor: pointer; touch-action: manipulation; user-select: none; }
.point-btn:active { transform: scale(0.98); filter: brightness(1.15); }
.point-btn[disabled] { opacity: 0.35; }
.gp-banner { text-align: center; font: 800 18px/1 var(--display); letter-spacing: 0.14em; color: var(--ball-ink); background: var(--ball); border-radius: 12px; padding: 10px; }
.vs-mid { text-align: center; font: 700 14px/1 var(--display); letter-spacing: 0.3em; color: var(--muted); }
.live-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--surface); border-radius: 20px 20px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom, 0px)); width: 100%; max-width: 640px; display: flex; flex-direction: column; gap: 14px; max-height: 90vh; max-height: 90dvh; overflow-y: auto; }
.choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choice { border: 2px solid var(--line); background: var(--bg); border-radius: 14px; padding: 14px 10px; font: 700 18px/1.2 var(--display); text-transform: uppercase; cursor: pointer; min-height: 64px; }
.choice[aria-pressed="true"] { border-color: var(--ball-text); background: #20230f; background: color-mix(in srgb, var(--ball) 12%, var(--bg)); }
.setup-summary { background: var(--surface-2); border-radius: 12px; padding: 12px 14px; font-weight: 600; }
.stepper { display: flex; align-items: center; gap: 10px; }
.stepper button { width: 48px; height: 48px; border-radius: 12px; border: 0; background: var(--surface-2); font-size: 22px; font-weight: 700; cursor: pointer; }
.stepper output { font: 700 40px/1 var(--display); min-width: 2ch; text-align: center; }
.net { white-space: nowrap; flex: none; }
.scorer-top .brand { flex: 1; min-width: 0; }
.scorer-top .who { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 30vw; }
@media (max-width: 480px) { .scorer-top .who { display: none; } }

.gp-banner.golden { background: linear-gradient(90deg, #ffd34d, var(--ball)); letter-spacing: 0.06em; font-size: 17px; }
.gp-banner.deuce { background: transparent; color: var(--ball-text); box-shadow: inset 0 0 0 2px var(--ball-text); }
.chip.golden { background: #ffd34d; color: #2a2000; }

/* ================================================================ mobile admin + WebView */
.admin-mobilebar, .admin-tabbar, .only-mobile { display: none; }
.icon-btn { width: 44px; height: 44px; border-radius: 12px; border: 0; background: var(--surface-2); display: inline-grid; place-items: center; cursor: pointer; flex: none; }
.icon-btn svg { width: 22px; height: 22px; }
.side-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.side-bottom { margin-top: auto; }
.nav-backdrop { display: none; }
.admin-tabbar a, .admin-tabbar button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 7px; text-decoration: none; color: var(--muted); font-size: 11px; font-weight: 600; background: none; border: 0; cursor: pointer; }
.admin-tabbar svg { width: 22px; height: 22px; }
.admin-tabbar [aria-current="page"] { color: var(--fg); }
.admin-tabbar [aria-current="page"] svg { color: var(--accent); }

@media (max-width: 900px) {
  .admin-mobilebar {
    display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 30;
    padding: calc(8px + env(safe-area-inset-top, 0px)) 16px 8px; background: var(--surface); border-bottom: 1px solid var(--line);
  }
  .mb-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
  .mb-title b { font: 700 18px/1.1 var(--display); text-transform: uppercase; letter-spacing: 0.04em; }
  .mb-title span { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .admin-shell { display: block; min-height: 0; }
  .admin-side {
    position: fixed; z-index: 50; top: 0; bottom: 0; left: 0; width: min(300px, 86vw); height: 100%;
    flex-direction: column; flex-wrap: nowrap; border-right: 1px solid var(--line); border-bottom: 0;
    padding: calc(12px + env(safe-area-inset-top, 0px)) 12px calc(12px + env(safe-area-inset-bottom, 0px));
    transform: translateX(-105%); transition: transform 0.22s ease; overflow-y: auto; visibility: hidden;
  }
  .admin-side .brand { width: auto; padding-bottom: 12px; }
  .admin-side .sep { display: block; }
  .admin-side a.nav { padding: 12px; font-size: 16px; }
  body.nav-open .admin-side { transform: none; visibility: visible; }
  body.nav-open { overflow: hidden; }
  .nav-backdrop:not([hidden]) { display: block; position: fixed; inset: 0; z-index: 45; background: rgba(0, 0, 0, 0.55); }
  .only-mobile { display: inline-grid; }
  .admin-main { padding: 16px 16px calc(88px + env(safe-area-inset-bottom, 0px)); gap: 16px; }
  .admin-tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .admin-main > .row.between > h1, .admin-main > h1 { font-size: 26px; }
}
@media (prefers-reduced-motion: reduce) { .admin-side { transition: none; } }

/* ---- tables that become cards on phones (cells carry data-label from their column header) */
@media (max-width: 640px) {
  .table-wrap:has(> table.stack-sm) { border: 0; background: transparent; overflow: visible; }
  table.data.stack-sm, table.data.stack-sm tbody { display: block; }
  table.data.stack-sm thead { display: none; }
  table.data.stack-sm tr {
    display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; padding: 12px 14px; margin-bottom: 10px;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  }
  table.data.stack-sm td { display: block; border: 0; padding: 0; text-align: left; white-space: normal; min-width: 0; overflow-wrap: anywhere; }
  table.data.stack-sm td[data-label]::before { content: attr(data-label); display: block; font: 600 10px/1.4 var(--body); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
  table.data.stack-sm td.name { grid-column: 1 / -1; min-width: 0; font-size: 16px; }
  table.data.stack-sm td:first-child.name::before { display: none; }
  table.data.stack-sm td:not([data-label]), table.data.stack-sm td[data-label=""] { grid-column: 1 / -1; }
  table.data.stack-sm td[data-label=""]::before { display: none; }
  table.data.stack-sm td .btn { width: 100%; }
  table.data.stack-sm td[colspan] { grid-column: 1 / -1; }
}
/* WebViews without :has() keep a plain scrolling table wrapper; cards still render inside it */

/* ---- toggle switch (bigger tap target than a checkbox) */
.switch { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; position: relative; font-weight: 600; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 46px; height: 28px; border-radius: 999px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); position: relative; flex: none; transition: background 0.15s; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--muted); transition: transform 0.15s, background 0.15s; }
.switch input:checked + .track { background: var(--accent); box-shadow: none; }
.switch input:checked + .track::after { transform: translateX(18px); background: #fff; }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch input:disabled + .track { opacity: 0.45; }
.switch .state-on { display: none; }
.switch input:checked ~ .state-on { display: inline; }
.switch input:checked ~ .state-off { display: none; }

/* ---- settings: categories + guided setup */
.settings-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 12px; padding: 4px; gap: 4px; }
.seg a { text-decoration: none; padding: 9px 14px; border-radius: 9px; font-weight: 700; font-size: 14px; color: var(--muted); min-height: 40px; display: inline-flex; align-items: center; }
.seg a[aria-current="page"] { background: var(--fg); color: var(--bg); }
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.scroll-x::-webkit-scrollbar { display: none; }
.subtabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.subtabs a { flex: none; text-decoration: none; padding: 10px 12px; font-weight: 600; font-size: 14px; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.subtabs a[aria-current="page"] { color: var(--fg); border-bottom-color: var(--accent); }
.subtabs .count { margin-left: 6px; font-size: 11px; background: var(--surface-2); padding: 1px 6px; border-radius: 999px; }
.settings-form .settings-row .what label { cursor: default; }
.settings-row .tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.settings-row .what small { display: block; }
.settings-row[hidden] { display: none; }
details.reason summary { cursor: pointer; color: var(--muted); padding: 6px 0; }
details.reason input { margin-top: 6px; }
.form-actions { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.override-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px 16px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.override-row:last-of-type { border-bottom: 0; }
.plain-list { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }
.stepper-head { display: flex; flex-direction: column; gap: 10px; }
.progress { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.steps { list-style: none; margin: 0; padding: 2px 0 4px; display: flex; gap: 6px; }
.steps li { flex: none; }
.steps a { display: flex; align-items: center; gap: 8px; text-decoration: none; padding: 6px 10px 6px 6px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); font-size: 13px; font-weight: 600; white-space: nowrap; }
.steps .dot { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); font-size: 12px; font-weight: 700; }
.steps li.done .dot { background: var(--ok-bg); color: var(--ok); }
.steps li.now a { border-color: var(--accent); color: var(--fg); }
.steps li.now .dot { background: var(--accent); color: #fff; }
@media (max-width: 640px) {
  .settings-head .seg { width: 100%; }
  .seg a { flex: 1; justify-content: center; }
  .steps li:not(.now) .txt { display: none; }
  .steps li:not(.now) a { padding: 6px; }
  .override-row { grid-template-columns: minmax(0, 1fr); }
  /* keep Save within thumb reach while the category is long */
  .settings-form .form-actions { position: sticky; bottom: calc(64px + env(safe-area-inset-bottom, 0px)); background: var(--surface); padding: 10px 0 4px; margin-bottom: -4px; z-index: 5; border-top: 1px solid var(--line); }
  .settings-form .form-actions .btn.primary { flex: 1; }
  .preview-box { bottom: calc(64px + env(safe-area-inset-bottom, 0px)); }
}

/* ---- general phone polish for admin pages */
@media (max-width: 640px) {
  .panel { padding: 14px; }
  .court .actions .btn, .court .actions summary.btn { min-height: 40px; }
  .inline-form form { flex-direction: column; align-items: stretch; }
  .inline-form form .btn { width: 100%; }
  .kpi-row .stat b { font-size: 22px; }
  .kpi-row .stat span { font-size: 10px; }
  .row.between > form, .row.between > .row { width: 100%; }
}
.section-head { flex-wrap: wrap; }
@media (max-width: 640px) {
  /* stat tiles become one swipeable strip instead of an uneven grid */
  .kpi-row { display: flex; overflow-x: auto; gap: 8px; scrollbar-width: none; margin-inline: -16px; padding-inline: 16px; }
  .kpi-row::-webkit-scrollbar { display: none; }
  .kpi-row .stat { flex: 0 0 auto; min-width: 96px; }
}
.icon-btn.only-mobile { display: none; }
@media (max-width: 900px) { .icon-btn.only-mobile { display: inline-grid; } }

/* ================================================================ theme switch */
.theme-menu { position: relative; flex: none; }
.theme-menu summary { list-style: none; cursor: pointer; }
.theme-menu summary::-webkit-details-marker { display: none; }
.theme-menu summary svg { display: none; }
:root[data-theme-mode="dark"] .theme-menu .i-dark,
:root[data-theme-mode="light"] .theme-menu .i-light,
:root[data-theme-mode="system"] .theme-menu .i-system,
:root:not([data-theme-mode]) .theme-menu .i-dark { display: block; }
.theme-pop {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 60; min-width: 150px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 6px;
  display: flex; flex-direction: column; gap: 2px; box-shadow: var(--shadow);
}
.theme-pop button { background: none; border: 0; text-align: left; padding: 10px 12px; border-radius: 8px; font-weight: 600; cursor: pointer; min-height: 40px; }
.theme-pop button:hover { background: var(--surface-2); }
.theme-pop button[aria-pressed="true"] { background: var(--accent-soft); color: var(--fg); }
.theme-pop button[aria-pressed="true"]::after { content: " ✓"; color: var(--accent); }
.topbar .theme-menu { margin-left: 4px; }
@media (max-width: 760px) { .topbar .theme-menu { margin-left: auto; } }

/* ---- Login / Admin entry in the public header */
.acct-btn { display: inline-flex; align-items: center; gap: 6px; flex: none; min-height: 40px; padding: 0 14px; border-radius: 12px; text-decoration: none; font-weight: 700; font-size: 14px; background: var(--accent); color: var(--accent-ink); }
.acct-btn svg { width: 18px; height: 18px; }
.acct-btn.signed-in { background: var(--surface-2); color: var(--fg); }
.acct-btn:hover { filter: brightness(1.1); }
.topbar .theme-menu + .acct-btn { margin-left: 4px; }
@media (max-width: 760px) {
  .topbar .acct-btn { margin-left: auto; padding: 0 12px; }
  .topbar .theme-menu + .acct-btn { margin-left: 4px; }
}
@media (max-width: 340px) { .topbar .acct-btn span { display: none; } .topbar .acct-btn { width: 44px; padding: 0; justify-content: center; } }

/* ---- Horizontal scrollers (tables, tab rows): smooth touch swipe, keep the swipe inside the
   scroller so the page or a native WebView container does not steal it, and mouse drag on desktop */
.table-wrap, .tabs, .scroll-x, .kpi-row {
  -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; touch-action: pan-x pan-y;
}
.table-wrap a, .tabs a, .tabs button, .scroll-x a, .kpi-row a { touch-action: pan-x pan-y; }
.drag-scroll { cursor: grab; }
.drag-scroll.dragging { cursor: grabbing; user-select: none; }
.drag-scroll.dragging a { pointer-events: none; }
.table-wrap::-webkit-scrollbar { height: 8px; }
.table-wrap::-webkit-scrollbar-thumb { background: var(--line); border-radius: 8px; }
.side-theme { display: flex; align-items: center; justify-content: space-between; padding: 6px 12px; }
.side-theme .theme-pop { right: auto; left: 0; top: auto; bottom: calc(100% + 6px); }
@media (max-width: 900px) { .only-desktop { display: none !important; } }

/* light-theme touch-ups for surfaces that were tuned for dark */
:root[data-theme="light"] .hero { border-color: var(--line); }
:root[data-theme="light"] .point-btn { color: var(--accent-ink); }
:root[data-theme="light"] .mcard.is-live { border-color: var(--ball-text); }
:root[data-theme="light"] .brand-mark svg circle:first-child { stroke: rgba(0,0,0,0.08); }
.point-btn { background: var(--accent); color: var(--accent-ink); }
.btn.primary { color: var(--accent-ink); }

/* colour setting */
.color-field { display: flex; gap: 8px; align-items: center; }
.color-field input[type=color] { width: 52px; height: 44px; padding: 2px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); flex: none; }
.color-field input[type=text] { font-family: var(--mono); }
.brand-preview { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 12px; border: 1px dashed var(--line); border-radius: 12px; }
/* team logo / player photo inside the avatar tile; falls back to initials if the image fails */
.avatar { position: relative; overflow: hidden; }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
