/* Layout: one phone-width column, scoreboard band pinned at top of live screen, thumb-zone controls at the bottom.
   Theme: a hard court seen from the stands. Court blue for our player and primary actions, the green surround
   as the page ground, optic-yellow ball for "who's serving" and live state, white court lines as the motif. */
:root {
  --bg: #E9F0EB; --surface: #FFFFFF; --ink: #0E1B26; --muted: #4F5E68; --line: #CFDAD3;
  --accent: #1D5FA8; --accent-ink: #FFFFFF; --accent-soft: #E1EBF6;
  --court: #1D5FA8; --court-deep: #123F73; --surround: #2E6B4B;
  --board: #0D2A4D; --board-ink: #F4F7F3; --board-muted: #94A8BE;
  --ball: #D9E43A; --ball-ink: #1F2A05;
  --warn: #A6460A; --ok: #1E7A45; --danger: #B42318;
  --font-display: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  --font-body: 'Public Sans', system-ui, -apple-system, sans-serif;
  --r: 12px;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #08130F; --surface: #101D18; --ink: #E6EEEA; --muted: #95A69E; --line: #22352D;
  --accent: #6AA5EC; --accent-ink: #061322; --accent-soft: #14283B;
  --court: #1A4F8C; --court-deep: #0E345F; --surround: #1C4A33;
  --board: #061A30; --board-ink: #EEF3EF; --board-muted: #8398AE;
  --ball: #D9E43A; --ball-ink: #1F2A05;
  --warn: #F0A060; --ok: #5CC28A; --danger: #F07A6E; color-scheme: dark } }
:root[data-theme="dark"] {
  --bg: #08130F; --surface: #101D18; --ink: #E6EEEA; --muted: #95A69E; --line: #22352D;
  --accent: #6AA5EC; --accent-ink: #061322; --accent-soft: #14283B;
  --court: #1A4F8C; --court-deep: #0E345F; --surround: #1C4A33;
  --board: #061A30; --board-ink: #EEF3EF; --board-muted: #8398AE;
  --ball: #D9E43A; --ball-ink: #1F2A05;
  --warn: #F0A060; --ok: #5CC28A; --danger: #F07A6E; color-scheme: dark }

* { box-sizing: border-box; }
body { background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 15px; line-height: 1.4; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.app { max-width: 480px; margin: 0 auto; min-height: 100vh; background: var(--bg); padding-bottom: 96px; }

.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--surface); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px; padding-block: 10px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--surface); }
.brand { font-family: var(--font-display); font-weight: 700; font-size: 22px; letter-spacing: 0.08em; text-transform: uppercase; flex: 1; display: flex; align-items: center; gap: 8px; }
.brand svg { flex: none; display: block; }
.brand b { font-weight: 700; color: var(--accent); }

/* court-line motif */
.court-hero { position: relative; overflow: hidden; border-radius: 16px; background: var(--court); color: #FFFFFF;
  padding: 20px 18px 18px; display: flex; flex-direction: column; gap: 6px; box-shadow: 0 0 0 6px var(--surround); margin: 6px; }
.court-hero::before { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .5;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 170' preserveAspectRatio='none' fill='none' stroke='white'%3E%3Crect x='10' y='10' width='380' height='150' stroke-width='2' vector-effect='non-scaling-stroke'/%3E%3Cpath d='M10 29H390M10 141H390M106 29V141M294 29V141M106 85H294M10 85H18M382 85H390' stroke-width='1.5' vector-effect='non-scaling-stroke'/%3E%3Cpath d='M200 4V166' stroke-width='3' stroke-dasharray='1 5' vector-effect='non-scaling-stroke'/%3E%3C/svg%3E") center / 100% 100% no-repeat; }
.court-hero > * { position: relative; }
.court-hero .eyebrow { color: rgba(255,255,255,.82); }
.court-hero h1 { font-size: 36px; }
.hero-stats { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.hero-stats span { background: rgba(6,20,38,.38); border: 1px solid rgba(255,255,255,.35); border-radius: 999px; padding: 4px 10px; font-size: 12px; font-weight: 600; }
.hero-stats b { font-family: var(--font-display); font-size: 16px; margin-right: 3px; }
.ballmark { width: 14px; height: 14px; border-radius: 50%; display: inline-block; flex: none;
  background: var(--ball) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='white' stroke-width='1.7'%3E%3Cpath d='M3.2 4.6c3.6 2.8 3.6 8 0 10.8M16.8 4.6c-3.6 2.8-3.6 8 0 10.8'/%3E%3C/svg%3E") center / 100% no-repeat; }
.back { border: 0; background: none; font-size: 26px; line-height: 1; padding: 4px 8px 4px 0; color: var(--ink); }
.as { display: flex; flex-direction: column; align-items: flex-end; gap: 0; }
.as label { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.as select { border: 1px solid var(--line); background: var(--surface); border-radius: 6px; padding: 4px 6px; font-size: 13px; max-width: 170px; }

.wrap { display: flex; flex-direction: column; gap: 22px; padding-block: 18px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.eyebrow { font-family: var(--font-display); font-size: 14px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); display: flex; justify-content: space-between; align-items: baseline; }
h1 { font-family: var(--font-display); font-size: 30px; margin: 0; line-height: 1.05; text-wrap: balance; }
h2 { margin: 0; }
.section { display: flex; flex-direction: column; gap: 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; display: flex; flex-direction: column; gap: 6px; text-align: left; width: 100%; }
button.card:hover { border-color: var(--accent); }
.card.live { border: 2px solid var(--court); box-shadow: inset 0 3px 0 var(--ball); }
.row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.pill { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; border-radius: 999px; padding: 3px 8px; white-space: nowrap; }
.pill.live { background: var(--ball); color: var(--ball-ink); display: inline-flex; align-items: center; gap: 5px; }
.pill.live .ballmark { width: 11px; height: 11px; box-shadow: 0 0 0 1.5px var(--ball-ink); }
@media (prefers-reduced-motion: no-preference) { .pill.live .ballmark { animation: bounce 1.2s ease-in-out infinite; } @keyframes bounce { 50% { transform: translateY(-2px); } } }
.pill.done { background: var(--accent-soft); color: var(--ink); }
.pill.pending { border: 1px solid var(--warn); color: var(--warn); }
.strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.ls { display: flex; flex-direction: column; align-items: center; padding: 5px 2px; background: var(--accent-soft); border-radius: 6px; font-size: 11px; color: var(--muted); }
.ls b { font-family: var(--font-display); font-size: 18px; color: var(--ink); font-variant-numeric: tabular-nums; line-height: 1.1; }
.mono { font-family: var(--font-display); font-size: 19px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: .02em; }

.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); display: flex; flex-direction: column; }
.list > * { border-bottom: 1px solid var(--line); }
.list > *:last-child { border-bottom: 0; }
.li { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: none; border: 0; width: 100%; text-align: left; min-height: 56px; }
button.li:hover { background: var(--accent-soft); }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--ball); color: var(--ball-ink); box-shadow: inset -3px -3px 0 rgba(0,0,0,.08); display: grid; place-items: center; font-family: var(--font-display); font-weight: 700; font-size: 17px; flex: none; }
.li .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.li b { font-weight: 600; }

.btn { border: 2px solid var(--ink); background: var(--surface); border-radius: var(--r); padding: 12px 14px; font-weight: 700; min-height: 48px; }
.btn.primary { background: var(--court); border-color: var(--court); color: #FFFFFF; box-shadow: inset 0 0 0 2px var(--court), inset 0 0 0 3.5px rgba(255,255,255,.55); }
.btn.dark { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.btn.ghost { border: 1px solid var(--line); font-weight: 600; }
.btn.sm { min-height: 36px; padding: 6px 10px; font-size: 13px; border-width: 1px; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.btns.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; display: flex; flex-direction: column; gap: 2px; }
.stat .v { font-family: var(--font-display); font-size: 28px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.stat .d { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* scoreboard */
.board { background: var(--board); color: var(--board-ink); padding-block: 14px; border-bottom: 5px solid var(--surround); box-shadow: inset 0 -2px 0 rgba(255,255,255,.55);
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); display: flex; flex-direction: column; gap: 4px; }
.brow { display: grid; grid-template-columns: 16px minmax(0, 1fr) auto 64px; gap: 8px; align-items: center; }
.brow .nm { font-weight: 700; font-size: 18px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brow .sets { display: flex; gap: 10px; font-family: var(--font-display); font-size: 22px; color: var(--board-muted); font-variant-numeric: tabular-nums; }
.brow .sets .cur { color: var(--board-ink); font-weight: 700; }
.brow .sets .won { color: var(--board-ink); }
.brow .pt { font-family: var(--font-display); font-size: 36px; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; line-height: 1; }
.bmeta { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--board-muted); padding-top: 6px; flex-wrap: wrap; }
.bmeta .flag { color: var(--ball); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }

.saved { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; background: var(--accent-soft); border: 1.5px solid var(--ok); }
.saved .tick { width: 28px; height: 28px; border-radius: 50%; background: var(--ok); color: var(--surface); display: grid; place-items: center; font-weight: 700; flex: none; }
.saved .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.saved .small { color: var(--muted); }
@media (prefers-reduced-motion: no-preference) {
  .board.flash .pt { animation: ptflash .6s ease-out; }
  .saved { animation: rise2 .2s ease-out; }
  @keyframes ptflash { 0% { color: var(--ball); transform: scale(1.15); } 100% { color: inherit; transform: none; } }
  @keyframes rise2 { from { opacity: 0; transform: translateY(-4px); } }
}
.sync { font-size: 12px; display: flex; align-items: center; gap: 6px; color: var(--ok); }
.sync.bad { color: var(--danger); }

/* entry pad */
.pad { display: flex; flex-direction: column; gap: 12px; }
.big { border: 2px solid var(--ink); background: var(--surface); border-radius: 12px; min-height: 68px; font-size: 19px; font-weight: 700; padding: 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.big small { font-size: 12px; font-weight: 500; color: var(--muted); }
.big.us { background: var(--court); border-color: var(--court); color: #FFFFFF; box-shadow: inset 0 0 0 3px var(--court), inset 0 0 0 4.5px rgba(255,255,255,.55); }
.big.us small { color: #FFFFFF; opacity: .85; }
.big.warn { border-color: var(--danger); color: var(--danger); }
.quick { border: 1px dashed var(--muted); background: transparent; border-radius: 10px; min-height: 48px; font-weight: 600; }
.toggle { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); min-height: 52px; }
.toggle input { width: 22px; height: 22px; accent-color: var(--accent); }
.steplabel { font-family: var(--font-display); font-size: 15px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; display: flex; justify-content: space-between; align-items: baseline; }
.steplabel button { background: none; border: 0; color: var(--accent); font-family: var(--font-body); font-size: 13px; text-transform: none; letter-spacing: 0; font-weight: 600; }
.dock { position: fixed; bottom: 0; left: 0; right: 0; z-index: 6; background: var(--surface); border-top: 1px solid var(--line);
  padding-top: 10px; padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.dock .in { max-width: 448px; margin: 0 auto; display: grid; grid-template-columns: 1.2fr 1fr 1fr 1fr; gap: 8px; }
.dock .in.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.dock button { min-height: 48px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; font-size: 13px; padding: 4px; }
.dock button.undo { border: 2px solid var(--ink); font-size: 15px; }

/* feed, tables */
.feed .li { min-height: 0; padding: 10px 14px; font-size: 14px; }
.tabs { display: flex; gap: 0; border: 2px solid var(--ink); border-radius: 10px; overflow: hidden; }
.tabs button { flex: 1; border: 0; background: var(--surface); padding: 10px 4px; font-weight: 700; min-height: 44px; }
.tabs button + button { border-left: 1px solid var(--line); }
.tabs button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
table.st { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; font-size: 14px; }
table.st th, table.st td { padding: 9px 10px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
table.st th { font-family: var(--font-display); font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; text-align: center; }
table.st td:first-child, table.st th:first-child { text-align: left; width: 32%; }
table.st td:last-child, table.st th:last-child { text-align: right; width: 32%; }
table.st td:nth-child(2) { text-align: center; color: var(--muted); font-size: 13px; }
table.st td .den { color: var(--muted); font-size: 12px; margin-left: 3px; }
table.st tr.sub th { background: var(--bg); }
.better { font-weight: 700; }
table.shots { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); font-size: 15px; font-variant-numeric: tabular-nums; }
table.shots th, table.shots td { padding: 9px 4px; text-align: center; border-bottom: 1px solid var(--line); }
table.shots th { font-family: var(--font-display); font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
table.shots td.lbl { color: var(--muted); font-size: 13px; width: 30%; }
table.shots td.w { color: var(--ok); font-weight: 700; }
table.shots td.ue { color: var(--danger); }
table.shots .gap { border-left: 1px solid var(--line); }
table.shots .den { color: var(--muted); font-size: 12px; margin-left: 3px; }
.chart { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; display: flex; flex-direction: column; gap: 6px; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .zero { stroke: var(--ink); stroke-width: 1.2; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2.4; stroke-linejoin: round; }
.chart .area { fill: var(--accent); opacity: .12; }
.chart .tick { stroke: var(--muted); stroke-width: 1; }
.chart .end { fill: var(--accent); }
.chart text { fill: var(--muted); font-size: 11px; font-family: var(--font-body); }
.chart text.endl { fill: var(--ink); font-weight: 700; font-size: 12px; }

/* forms & sheets */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .field legend { font-family: var(--font-display); font-size: 14px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 0; }
.field input, .field select, .field textarea { border: 1.5px solid var(--line); background: var(--surface); border-radius: 8px; padding: 12px; font-size: 16px; min-width: 0; width: 100%; }
.field textarea { min-height: 90px; resize: vertical; }
fieldset { border: 0; margin: 0; padding: 0; }
.choice { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--surface); cursor: pointer; }
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice input { margin-top: 3px; accent-color: var(--accent); width: 18px; height: 18px; }
.choices { display: flex; flex-direction: column; gap: 8px; }
.seg { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.seg label { text-align: center; padding: 14px 8px; border: 2px solid var(--line); border-radius: 10px; font-weight: 700; cursor: pointer; background: var(--surface); }
.seg label:has(input:checked) { border-color: var(--ink); background: var(--ink); color: var(--bg); }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.sheet-bg { position: fixed; inset: 0; background: rgba(5,10,14,.55); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--bg); width: 100%; max-width: 480px; max-height: 86vh; overflow: auto; border-radius: 16px 16px 0 0; display: flex; flex-direction: column; gap: 14px;
  padding-top: 18px; padding-bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.sheet h2 { font-family: var(--font-display); font-size: 24px; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(84px + env(safe-area-inset-bottom, 0px)); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-weight: 600; font-size: 14px; z-index: 30; max-width: calc(100% - 32px); text-align: center; }
.note { background: var(--accent-soft); border-radius: 8px; padding: 10px 12px; font-size: 13px; }
.dashed { border: 1px dashed var(--line); border-radius: var(--r); padding: 12px; color: var(--muted); font-size: 13px; display: flex; flex-direction: column; gap: 4px; }
.empty { text-align: center; padding: 20px; color: var(--muted); }
@media (prefers-reduced-motion: no-preference) { .toast { animation: rise .18s ease-out; } @keyframes rise { from { transform: translate(-50%, 8px); opacity: 0; } } }

/* ---- pilot additions ---- */
.iconbtn { border: 1px solid var(--line); background: var(--surface); width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.iconbtn svg { width: 22px; height: 22px; stroke: var(--ink); fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.banner { padding: 8px 16px; font-size: 13px; font-weight: 600; text-align: center; background: var(--accent-soft); border-bottom: 1px solid var(--line); color: var(--ink); }
.banner.alert { background: var(--danger); color: #FFFFFF; border-color: var(--danger); }
.sync.warn { color: var(--warn); }
.authwrap { max-width: 480px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; gap: 18px; padding-block: 24px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.court-hero .logo-row { display: flex; align-items: center; gap: 10px; }
.court-hero .logo-row span { font-family: var(--font-display); font-size: 26px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.codebox { font-family: var(--font-display); font-size: 34px; letter-spacing: .35em; text-align: center; font-variant-numeric: tabular-nums; }
.msg { font-size: 14px; padding: 10px 12px; border-radius: 8px; background: var(--accent-soft); }
.msg.err { background: transparent; border: 1.5px solid var(--danger); color: var(--danger); }
.linkbtn { background: none; border: 0; padding: 8px 0; color: var(--accent); font-weight: 600; text-align: left; font-size: 14px; }
.check { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; font-size: 14px; }
.check input { width: 22px; height: 22px; margin-top: 1px; flex: none; accent-color: var(--accent); }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 11px 14px; font-size: 14px; }
.kv span:first-child { color: var(--muted); }
.kv span:last-child { text-align: right; overflow-wrap: anywhere; }
.btn.danger { border-color: var(--danger); color: var(--danger); }
.btn.block { width: 100%; }
a.btn { display: flex; align-items: center; justify-content: center; text-decoration: none; text-align: center; color: inherit; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.legal h3 { font-family: var(--font-display); font-size: 17px; letter-spacing: .06em; text-transform: uppercase; margin: 14px 0 2px; }
.legal p { margin: 0; font-size: 14px; }
.tabs.two button { min-height: 40px; }
.approve-card { border: 2px solid var(--warn); }
.approve-card .btns { margin-top: 6px; }
noscript { display: block; padding: 24px; text-align: center; }
label.btn { display: flex; align-items: center; justify-content: center; text-align: center; cursor: pointer; }
.visually-hidden:focus + * { outline: 3px solid var(--accent); }
span.codebox { display: block; padding: 6px 0; }
.card .codebox { color: var(--accent); }
