:root {
  --bg: #f3f0e8;
  --surface: #ffffff;
  --surface-2: #ebe7dc;
  --ink: #15201a;
  --muted: #56645b;
  --line: #d9d3c4;
  --court: #2d7a56;
  --court-deep: #1f5c41;
  --court-line: #f8f8f2;
  --accent: #d9f24a;
  --accent-ink: #4b5a00;
  --a: #f0603a;
  --a-soft: #fde3da;
  --b: #2b78e4;
  --b-soft: #dce9fc;
  --good: #1d8a4e;
  --bad: #d23b3b;
  --warn: #b7791f;
  --shadow: 0 1px 2px rgba(20, 30, 25, 0.06), 0 8px 24px rgba(20, 30, 25, 0.08);
  --radius: 16px;
  --font: 'Barlow', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --display: 'Barlow Condensed', 'Barlow', system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #0e1411;
    --surface: #17201b;
    --surface-2: #1f2a24;
    --ink: #eef3ef;
    --muted: #9dafa4;
    --line: #2c3a32;
    --accent-ink: #e4ff6b;
    --a-soft: #3a211a;
    --b-soft: #182a44;
    --good: #4bd18a;
    --bad: #ff6b6b;
    --warn: #f0b350;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.3);
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --bg: #0e1411;
  --surface: #17201b;
  --surface-2: #1f2a24;
  --ink: #eef3ef;
  --muted: #9dafa4;
  --line: #2c3a32;
  --accent-ink: #e4ff6b;
  --a-soft: #3a211a;
  --b-soft: #182a44;
  --good: #4bd18a;
  --bad: #ff6b6b;
  --warn: #f0b350;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--font);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}
main { flex: 1; width: 100%; max-width: 1120px; margin: 0 auto; padding: 16px 16px 40px; outline: none; }
a { color: inherit; }
b { font-weight: 700; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 8px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: 8px; z-index: 99; }

/* ------------------------------------------------------------ Top bar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: max(10px, env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; white-space: nowrap; text-decoration: none; font: 800 22px/1 var(--display); letter-spacing: 0.02em; text-transform: uppercase; }
.brand svg { width: 28px; height: 28px; }
.nav { display: flex; gap: 4px; margin-left: auto; }
.nav a { text-decoration: none; padding: 8px 14px; border-radius: 999px; font-weight: 600; color: var(--muted); }
.nav a.on { background: var(--ink); color: var(--bg); }
.icon-btn { border: 0; background: transparent; color: var(--muted); width: 40px; height: 40px; border-radius: 50%; cursor: pointer; display: grid; place-items: center; }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:hover { background: var(--surface-2); }
.foot { text-align: center; color: var(--muted); font-size: 13px; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); }

/* ------------------------------------------------------------ Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 12px; padding: 11px 18px; min-height: 44px;
  font: 600 15px/1.1 var(--font); text-decoration: none; cursor: pointer;
  background: var(--ink); color: var(--bg);
  transition: transform 0.12s, background 0.2s, opacity 0.2s;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn.ghost { background: var(--surface-2); color: var(--ink); }
.btn.alt { background: var(--accent); color: #1c2400; }
.btn.big { padding: 14px 24px; font-size: 17px; min-height: 52px; }
.btn.sm { padding: 6px 12px; min-height: 34px; font-size: 14px; }
.btn.danger { background: var(--bad); color: #fff; }
.btn.team-a { background: var(--a); color: #fff; }
.btn.team-b { background: var(--b); color: #fff; }
.btn.on { outline: 2px solid var(--accent); outline-offset: 1px; }
.danger-text { color: var(--bad) !important; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
:focus-visible { outline: 3px solid var(--b); outline-offset: 2px; }
main:focus, main:focus-visible { outline: none; }

.seg { display: inline-flex; background: var(--surface-2); padding: 4px; border-radius: 12px; gap: 2px; flex-wrap: wrap; }
.seg.wrap { display: flex; }
.seg-btn { border: 0; background: transparent; color: var(--muted); font: 600 14px var(--font); padding: 8px 14px; border-radius: 9px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; min-height: 38px; }
.seg-btn.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.seg-btn input { position: absolute; opacity: 0; pointer-events: none; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 999px; padding: 7px 13px; font: 600 14px var(--font); cursor: pointer; min-height: 36px; }
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.pill { display: inline-block; background: var(--accent); color: #1c2400; font-weight: 700; font-size: 13px; padding: 5px 12px; border-radius: 999px; }
.badge { background: var(--surface-2); padding: 3px 10px; border-radius: 999px; font-weight: 600; font-size: 13px; }

.page-title { font: 800 clamp(32px, 6vw, 48px)/1 var(--display); text-transform: uppercase; letter-spacing: 0.01em; margin: 12px 0 12px; display: flex; gap: 12px; align-items: baseline; }
.page-title .num, .lesson-card .num { font-family: var(--display); color: var(--court); }
.lead { color: var(--muted); font-size: 18px; margin-top: 0; }
.hint { color: var(--muted); font-size: 14px; margin: 6px 0 0; }

/* ------------------------------------------------------------ Court SVG */
.court-wrap { width: 100%; }
.court-svg { width: 100%; height: auto; display: block; border-radius: 14px; touch-action: manipulation; }
.court-svg.tappable { cursor: crosshair; }
.court-surround { fill: var(--court-deep); }
.court-floor { fill: var(--court); }
.cl { stroke: var(--court-line); stroke-width: 0.045; stroke-linecap: square; transition: stroke 0.3s, stroke-width 0.3s, opacity 0.3s; }
.cl.hl { stroke: var(--accent); stroke-width: 0.11; }
.cl.dim { opacity: 0.45; }
.net-band { stroke: #fff; stroke-width: 0.1; }
.net-mesh { stroke: rgba(0, 0, 0, 0.35); stroke-width: 0.05; stroke-dasharray: 0.06 0.06; }
.post { fill: #e7e7e0; }
.net.flash .net-band { animation: netflash 1.1s ease; }
@keyframes netflash { 0%, 100% { stroke: #fff; } 20%, 60% { stroke: var(--bad); stroke-width: 0.22; } }
.area { transition: opacity 0.3s; }
.area-play { fill: rgba(255, 255, 255, 0.1); }
.area-serve-from { fill: rgba(217, 242, 74, 0.22); }
.area-serve-to { fill: url(#hatch); stroke: var(--accent); stroke-width: 0.06; stroke-dasharray: 0.18 0.1; }
.court-label { fill: #fff; font: 700 0.34px var(--display); letter-spacing: 0.02em; text-transform: uppercase; paint-order: stroke; stroke: rgba(0, 0, 0, 0.25); stroke-width: 0.05; }
.court-label.big { font-size: 0.42px; }
.court-label.shout { fill: var(--accent); font-size: 0.42px; }
.court-label.meas { fill: rgba(255,255,255,0.75); font-size: 0.295px; text-transform: none; letter-spacing: 0; }
.dim-line { stroke: rgba(255,255,255,0.5); stroke-width: 0.04; }

.player { transition: transform 0.6s cubic-bezier(0.35, 0, 0.2, 1); }
.player .body { stroke: #fff; stroke-width: 0.08; }
.player.team-A .body { fill: var(--a); }
.player.team-B .body { fill: var(--b); }
.player .ring { fill: none; stroke: var(--accent); stroke-width: 0.07; opacity: 0; }
.player.server .ring { opacity: 1; animation: ring 1.6s ease-in-out infinite; transform-origin: 0 0; }
.player.receiver .ring { opacity: 0.55; stroke-dasharray: 0.15 0.12; }
.player.faded { opacity: 0.45; }
@keyframes ring { 0%, 100% { transform: scale(0.85); opacity: 1; } 50% { transform: scale(1.08); opacity: 0.5; } }
.player .initial { fill: #fff; font: 800 0.46px var(--display); pointer-events: none; }
.player .pname { fill: #fff; font: 700 0.4px var(--font); paint-order: stroke; stroke: rgba(0, 0, 0, 0.45); stroke-width: 0.06; pointer-events: none; }
.player.flash-bad .body { animation: pbad 1.2s ease; }
.player.flash-good .body { animation: pgood 1.2s ease; }
@keyframes pbad { 25%, 65% { fill: var(--bad); r: 0.68; } }
@keyframes pgood { 25%, 65% { fill: var(--good); r: 0.68; } }
.tappable .player { cursor: pointer; }

.shuttle .cork { fill: #fff; stroke: #c9c9c0; stroke-width: 0.02; }
.shuttle .skirt { fill: rgba(255, 255, 255, 0.9); stroke: #d6d6cf; stroke-width: 0.015; }
.shuttle .skirt-edge { stroke: #bbb; stroke-width: 0.02; }
.shuttle-shadow { fill: rgba(0, 0, 0, 0.35); filter: url(#soft); }
.landing .dot { fill: #fff; }
.landing.in .pulse { fill: none; stroke: var(--accent); stroke-width: 0.06; animation: land 1.4s ease-out infinite; }
.landing.out .pulse { fill: none; stroke: #ff6b6b; stroke-width: 0.06; animation: land 1.4s ease-out infinite; }
.landing.out .dot { fill: #ff6b6b; }
.landing-text { font: 800 0.34px var(--display); fill: #fff; paint-order: stroke; stroke: rgba(0, 0, 0, 0.5); stroke-width: 0.06; }
.landing.out .landing-text { fill: #ffb3b3; }
@keyframes land { from { r: 0.1; opacity: 1; } to { r: 0.6; opacity: 0; } }

/* ------------------------------------------------------------ Home */
.hero { display: grid; gap: 24px; align-items: center; padding: 12px 0 24px; }
.hero h1 { font: 800 clamp(36px, 7vw, 64px)/0.98 var(--display); text-transform: uppercase; margin: 14px 0; letter-spacing: 0.005em; }
.hero h1 em { font-style: normal; background: linear-gradient(transparent 62%, var(--accent) 62%); padding: 0 4px; }
.hero p { font-size: 18px; color: var(--muted); max-width: 52ch; }
.hero-court { border-radius: 18px; box-shadow: var(--shadow); transform: perspective(1200px) rotateX(18deg); transform-origin: bottom; }
@media (min-width: 900px) {
  .hero { grid-template-columns: 1fr 1.05fr; }
}
.feature-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.feature { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; text-decoration: none; display: grid; gap: 4px; transition: transform 0.15s, border-color 0.2s; }
.feature:hover { transform: translateY(-2px); border-color: var(--court); }
.feature span { color: var(--muted); font-size: 15px; }

/* ------------------------------------------------------------ Learn */
.lesson-grid { list-style: none; padding: 0; margin: 20px 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.lesson-card { display: grid; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; text-decoration: none; height: 100%; transition: transform 0.15s, border-color 0.2s; }
.lesson-card:hover { transform: translateY(-2px); border-color: var(--court); }
.lesson-card .num { font-size: 28px; font-weight: 800; line-height: 1; }
.lesson-card b { font-size: 18px; }
.lesson-card span:last-child { color: var(--muted); font-size: 15px; }
.crumb { color: var(--muted); text-decoration: none; font-weight: 600; font-size: 15px; }
.lesson-body { display: grid; gap: 20px; }
@media (min-width: 960px) {
  .lesson-body { grid-template-columns: minmax(280px, 0.8fr) 1.4fr; align-items: start; }
  .lesson-text { position: sticky; top: 80px; }
}
.lesson-text { font-size: 17px; }
.lesson-text p:first-child { margin-top: 0; }
.lesson-text ul { padding-left: 20px; }
.lesson-text li { margin: 4px 0; }
.stage { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 12px; display: grid; gap: 12px; box-shadow: var(--shadow); min-width: 0; }
.controls { display: grid; gap: 10px; }
.stage > .seg, .controls > .seg { justify-self: start; }
.caption { min-height: 3.2em; background: var(--surface-2); border-radius: 12px; padding: 10px 14px; font-size: 16px; border-left: 4px solid var(--line); }
.caption.tone-a { border-left-color: var(--a); }
.caption.tone-b { border-left-color: var(--b); }
.caption.tone-good { border-left-color: var(--good); }
.caption.tone-bad { border-left-color: var(--bad); }
.caption.tone-warn { border-left-color: var(--warn); }
.caption .step { font: 700 13px var(--display); background: var(--ink); color: var(--bg); border-radius: 6px; padding: 2px 6px; margin-right: 6px; }
.lesson-nav { display: flex; justify-content: space-between; gap: 8px; margin-top: 24px; flex-wrap: wrap; }
.mini-score { display: flex; justify-content: center; gap: 10px; font: 700 20px var(--display); align-items: center; }
.mini-score .ms { padding: 4px 14px; border-radius: 10px; min-width: 76px; text-align: center; }
.mini-score .ms.a { background: var(--a-soft); color: var(--a); }
.mini-score .ms.b { background: var(--b-soft); color: var(--b); }
.mini-score b { display: inline-block; font-size: 30px; min-width: 1.2em; }
.mini-score .games { color: var(--muted); font-size: 16px; }
.quiz-score { font-weight: 600; }
.timeline { display: flex; gap: 6px; overflow-x: auto; min-height: 34px; padding-bottom: 2px; }
.tl-chip { flex: none; padding: 5px 10px; border-radius: 999px; font: 600 13px var(--font); background: var(--surface-2); animation: pop 0.35s ease; }
.tl-chip.game { background: var(--ink); color: var(--bg); }
.tl-chip.ends { background: var(--accent); color: #1c2400; }
@keyframes pop { from { transform: scale(0.6); opacity: 0; } }

/* race bars (winning a game) */
.race { display: grid; gap: 10px; position: relative; padding: 8px 0 30px; }
.track { display: grid; grid-template-columns: 26px 1fr 40px auto; gap: 10px; align-items: center; }
.who { font: 800 20px var(--display); text-align: center; }
.who.a { color: var(--a); }
.who.b { color: var(--b); }
.bar { height: 22px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.fill { height: 100%; border-radius: 999px; transition: width 0.35s cubic-bezier(0.2, 1.4, 0.4, 1); }
.track[data-side='A'] .fill { background: var(--a); }
.track[data-side='B'] .fill { background: var(--b); }
.track .val { font: 800 28px var(--display); text-align: right; }
.step-btns { display: flex; gap: 4px; }
.bar { position: relative; }
.ticks i { position: absolute; top: 0; bottom: 0; border-left: 2px dashed color-mix(in srgb, var(--ink) 35%, transparent); }
.track.scale { margin-top: -4px; }
.marks { position: relative; height: 30px; }
.marks span { position: absolute; top: 0; transform: translateX(-50%); font: 700 14px var(--display); color: var(--muted); text-align: center; line-height: 1; }
.marks span.end { transform: translateX(-100%); text-align: right; }
.marks span i { display: block; font-style: normal; font-size: 11px; text-transform: uppercase; }
@media (max-width: 480px) {
  .track { grid-template-columns: 22px 1fr 34px; }
  .step-btns { grid-column: 2 / 4; justify-content: flex-end; }
  .track.scale { grid-template-columns: 22px 1fr 34px; }
}
/* side view */
.side-view { width: 100%; height: auto; border-radius: 14px; }
.sv-bg { fill: var(--surface-2); }
.sv-floor { stroke: var(--court); stroke-width: 6; }
.sv-limit { stroke: var(--warn); stroke-width: 2; stroke-dasharray: 8 6; }
.sv-limit-t { fill: var(--warn); font: 700 14px var(--display); }
.sv-net line { stroke: var(--muted); stroke-width: 3; }
.sv-mesh { fill: none; stroke: var(--muted); stroke-dasharray: 3 3; }
.sv-person .arm-hold { transition: opacity .2s; }
.sv-person line, .sv-person circle { stroke: var(--ink); stroke-width: 6; stroke-linecap: round; fill: var(--ink); }
.sv-person .shaft { stroke-width: 3; }
.sv-person .head { fill: none; stroke: var(--ink); stroke-width: 3; }
.sv-shuttle .cork { fill: #fff; stroke: var(--ink); stroke-width: 1.5; }
.sv-shuttle .skirt { fill: #fff; stroke: var(--ink); stroke-width: 1.5; }
.sv-verdict { font: 800 26px var(--display); fill: var(--muted); }
.sv-verdict.good { fill: var(--good); }
.sv-verdict.bad { fill: var(--bad); }

/* ------------------------------------------------------------ Umpire setup */
.setup { max-width: 680px; margin: 0 auto; }
.setup-form { display: grid; gap: 16px; }
.setup-form fieldset { border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); padding: 14px 16px 16px; margin: 0; }
.setup-form legend { font: 700 14px var(--font); text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); padding: 0 6px; }
.teams { display: grid; gap: 16px; grid-template-columns: 1fr 1fr; }
@media (max-width: 520px) { .teams { grid-template-columns: 1fr; } }
.team { display: grid; gap: 8px; }
.team-A legend { color: var(--a) !important; }
.team-B legend { color: var(--b) !important; }
.team input { font: 500 16px var(--font); padding: 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); width: 100%; }
.team-A input:focus { outline: 2px solid var(--a); }
.team-B input:focus { outline: 2px solid var(--b); }
.doubles-only { display: none; }
.is-doubles .doubles-only { display: block; }
.toss { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.coin { width: 52px; height: 52px; position: relative; transform-style: preserve-3d; }
.coin .face { position: absolute; inset: 0; border-radius: 50%; display: grid; place-items: center; font: 800 22px var(--display); color: #fff; backface-visibility: hidden; }
.coin .face.a { background: var(--a); }
.coin .face.b { background: var(--b); transform: rotateY(180deg); }
.coin.flip-A { animation: flipA 1.2s cubic-bezier(0.3, 0, 0.2, 1) forwards; }
.coin.flip-B { animation: flipB 1.2s cubic-bezier(0.3, 0, 0.2, 1) forwards; }
@keyframes flipA { 0% { transform: translateY(0) rotateY(0); } 50% { transform: translateY(-40px) rotateY(900deg); } 100% { transform: translateY(0) rotateY(1800deg); } }
@keyframes flipB { 0% { transform: translateY(0) rotateY(0); } 50% { transform: translateY(-40px) rotateY(990deg); } 100% { transform: translateY(0) rotateY(1980deg); } }
.history h2 { font: 800 24px var(--display); text-transform: uppercase; margin: 32px 0 8px; }
.hist-list { list-style: none; padding: 0; margin: 0 0 10px; display: grid; gap: 6px; }
.hist-list li { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; }
.hist-when, .hist-dur { color: var(--muted); font-size: 14px; }
.hist-names .w { color: var(--good); }
.hist-scores { font-weight: 700; margin-left: auto; }

/* ------------------------------------------------------------ Match */
.match { display: grid; gap: 10px; max-width: 980px; margin: 0 auto; position: relative; }
.match-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.games-strip { display: flex; gap: 6px; flex-wrap: wrap; }
.gchip { background: var(--surface-2); border-radius: 8px; padding: 3px 9px; font-size: 14px; color: var(--muted); }
.gchip b { color: var(--ink); }
.gchip.cur { background: var(--ink); color: var(--bg); }
.gchip.cur b { color: var(--bg); }
.match-meta { display: flex; gap: 8px; align-items: center; }
.clock { font: 700 18px var(--display); font-variant-numeric: tabular-nums; color: var(--muted); }
.board { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.board-side { border-radius: var(--radius); padding: 10px 14px 12px; background: var(--surface); border: 2px solid var(--line); position: relative; overflow: hidden; min-width: 0; transition: border-color 0.3s; }
.board-side.team-A { border-color: color-mix(in srgb, var(--a) 35%, var(--line)); }
.board-side.team-B { border-color: color-mix(in srgb, var(--b) 35%, var(--line)); }
.board-side.serving.team-A { border-color: var(--a); background: var(--a-soft); }
.board-side.serving.team-B { border-color: var(--b); background: var(--b-soft); }
.board-side.winner { outline: 3px solid var(--accent); }
.bs-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 16px; }
.team-A .bs-name { color: var(--a); }
.team-B .bs-name { color: var(--b); }
.bs-score { font: 800 clamp(64px, 16vw, 120px)/0.95 var(--display); font-variant-numeric: tabular-nums; display: inline-block; }
.bs-games { display: flex; gap: 5px; margin-top: 2px; }
.bs-games i { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--muted); }
.bs-games i.on { background: var(--ink); border-color: var(--ink); }
.bs-serve { min-height: 1.4em; font-size: 14px; font-weight: 600; color: var(--muted); display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.shuttle-ico { width: 16px; height: 16px; border-radius: 50%; background: radial-gradient(circle at 35% 50%, #fff 0 35%, var(--accent) 36%); box-shadow: 0 0 0 2px var(--ink) inset; animation: bob 1.2s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-3px); } }
.call { background: var(--ink); color: var(--bg); border-radius: 14px; padding: 10px 16px; text-align: center; min-height: 64px; display: grid; align-content: center; }
.call-main { font: 800 clamp(22px, 5vw, 32px)/1.1 var(--display); text-transform: uppercase; letter-spacing: 0.01em; }
.call-sub { font-size: 14px; opacity: 0.75; }
.call.tone-interval, .call.tone-game { background: var(--warn); color: #1c1300; }
.call.tone-match { background: var(--accent); color: #1c2400; }
.match-court .court-svg { max-height: 46vh; }
.point-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.point-btn { border: 0; border-radius: 18px; min-height: 96px; color: #fff; cursor: pointer; display: grid; align-content: center; gap: 2px; font-family: var(--font); transition: transform 0.08s, filter 0.2s; box-shadow: 0 4px 0 rgba(0, 0, 0, 0.18); -webkit-tap-highlight-color: transparent; }
.point-btn.team-A { background: var(--a); }
.point-btn.team-B { background: var(--b); }
.point-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2); }
.point-btn:disabled { filter: grayscale(0.8); opacity: 0.5; }
.pb-label { font: 800 30px/1 var(--display); text-transform: uppercase; }
.pb-name { font-size: 14px; opacity: 0.9; padding: 0 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tools { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.tools .btn { padding: 8px 12px; min-height: 40px; font-size: 14px; }
.tools .btn.on { background: var(--ink); color: var(--bg); outline: none; }
.live-panel { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px; display: grid; gap: 8px; }
.live-row { display: flex; gap: 6px; }
.live-row input { flex: 1; min-width: 0; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); font: 14px var(--font); }
.err { color: var(--bad); }
.rally-log { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px 10px 34px; max-height: 260px; overflow: auto; margin: 0; font-size: 14px; }
.rally-log li { padding: 3px 0; border-bottom: 1px dashed var(--line); }
.lg-g { color: var(--muted); font-size: 12px; }

.overlay { position: fixed; inset: 0; background: rgba(8, 14, 11, 0.55); backdrop-filter: blur(3px); z-index: 40; display: grid; place-items: center; padding: 16px; animation: fade 0.2s ease; }
.overlay[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } }
.ov-card { background: var(--surface); border-radius: 22px; padding: 22px; width: min(420px, 100%); text-align: center; display: grid; gap: 10px; box-shadow: var(--shadow); animation: rise 0.3s cubic-bezier(0.2, 1.3, 0.4, 1); }
@keyframes rise { from { transform: translateY(20px) scale(0.96); opacity: 0; } }
.ov-card h2 { font: 800 32px/1 var(--display); text-transform: uppercase; margin: 0; }
.ov-card p { margin: 0; color: var(--muted); }
.ov-card .btn-row { justify-content: center; }
.ov-kicker { font: 700 13px var(--font); text-transform: uppercase; letter-spacing: 0.08em; color: var(--warn); }
.ov-scores { display: flex; gap: 8px; justify-content: center; }
.ov-scores span { font: 800 28px var(--display); color: var(--ink); background: var(--surface-2); border-radius: 10px; padding: 2px 12px; }
.countdown { position: relative; width: 150px; height: 150px; margin: 4px auto; }
.countdown svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.cd-track { fill: none; stroke: var(--surface-2); stroke-width: 8; }
.cd-ring { fill: none; stroke: var(--court); stroke-width: 8; stroke-linecap: round; stroke-dasharray: 276.5; stroke-dashoffset: 0; animation: cd linear forwards; }
.ov-card.warn .cd-ring { stroke: var(--warn); }
@keyframes cd { to { stroke-dashoffset: 276.5; } }
.countdown b { position: absolute; inset: 0; display: grid; place-items: center; font: 800 38px var(--display); font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------ Spectator */
.spectate { max-width: 900px; margin: 0 auto; display: grid; gap: 12px; }
.live-badge { justify-self: start; background: var(--bad); color: #fff; font: 800 15px var(--display); letter-spacing: 0.08em; padding: 4px 12px; border-radius: 999px; display: flex; align-items: center; gap: 6px; }
.live-badge .dot { width: 8px; height: 8px; border-radius: 50%; background: #fff; animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: 0.2; } }

@media (min-width: 900px) {
  .match { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
@media (max-width: 420px) {
  .topbar { gap: 6px; padding-left: 12px; padding-right: 8px; }
  .brand { font-size: 18px; gap: 6px; }
  .brand svg { width: 24px; height: 24px; }
  .nav a { padding: 7px 11px; }
}

/* Types of serve (side view of the whole court) */
.st-zone { fill: var(--good); opacity: 0.55; transition: x .4s, width .4s; }
.st-tick { stroke: var(--muted); stroke-width: 2; }
.st-tick-t { fill: var(--muted); font: 600 11px var(--font); }
.st-view .st-long { opacity: 0.45; }
.st-view.is-doubles .st-long { opacity: 1; fill: var(--ink); stroke: var(--ink); }
.st-view text.st-long { stroke: none; }
.st-net-t { fill: var(--muted); font: 600 11px var(--font); }
.st-person line, .st-person circle { stroke: var(--ink); stroke-width: 4; stroke-linecap: round; fill: var(--ink); }
.st-person.receiver line, .st-person.receiver circle { stroke: var(--b); fill: var(--b); }
.st-person.server line, .st-person.server circle { stroke: var(--a); fill: var(--a); }
.st-reach { stroke: var(--b); stroke-width: 1.5; stroke-dasharray: 3 4; opacity: 0.7; }
.st-reach-t { fill: var(--b); font: 600 11px var(--font); opacity: 0.8; }
.st-trail { fill: none; stroke-width: 2.5; stroke-dasharray: 5 5; opacity: 0.9; }
.st-trail.drawing { stroke-dasharray: none; }
.st-mark circle { stroke: var(--surface); stroke-width: 2; }
.st-mark text { font: 700 12px var(--font); }
.st-low { stroke: var(--good); } .st-mark.st-low circle, .st-mark.st-low text { fill: var(--good); }
.st-high { stroke: var(--b); } .st-mark.st-high circle, .st-mark.st-high text { fill: var(--b); }
.st-flick { stroke: var(--a); } .st-mark.st-flick circle, .st-mark.st-flick text { fill: var(--a); }
.st-drive { stroke: var(--warn); } .st-mark.st-drive circle, .st-mark.st-drive text { fill: var(--warn); }
.st-racket line { stroke: var(--ink); stroke-width: 2; stroke-linecap: round; }
.st-racket .st-arm { stroke: var(--a); stroke-width: 4; }
.st-racket ellipse { fill: none; stroke: var(--ink); stroke-width: 2; }
.st-legend text { font: 700 12px var(--font); fill: var(--ink); stroke: none; }
.st-legend .st-trail { stroke-dasharray: 5 4; }
