:root {
  --bg: #0B0E14;
  --bg-grad: radial-gradient(90% 60% at 50% -5%, #15200B 0%, #0A0A0C 55%);
  --card: #11151E;          /* default card surface (design-mockup pages) */
  --surface: #151A24;       /* legacy elevated surface (engine) */
  --border: #1E2530;
  --border-strong: #2A2F3A;
  --divider: #1A212C;
  --text: #F5F7FA;
  --text-2: #C4CBD6;
  --a7: #A7AFBC;
  --muted: #8A93A3;
  --dim: #7C8390;
  --lime: #CBFF2E;
  --pink: #FF6FB5;
  --orange: #FF8A3D;
  --yellow: #FFD23D;
  --green: #46E08F;
  --purple: #B98BFF;
  --cyan: #4FD8E8;
  --blue: #7FA8FF;
  --lime-border: rgba(203,255,46,0.55); /* active/open lime outline */
  --lime-tint: rgba(203,255,46,0.08);   /* selected row / subtle lime fill */
  --hover: rgba(255,255,255,0.05);      /* row hover */
  --ink: #0B0E14; /* text on lime */
  --r-card: 20px;
  --r-lg: 24px;
  --r-sm: 14px;
  --r-pill: 999px;
  --maxw: 480px;
  --font-display: 'Anton', sans-serif;
  --font-bold: 'Archivo', sans-serif;
  --font-label: 'Space Grotesk', sans-serif;
  --font-body: 'Hanken Grotesk', system-ui, sans-serif;
}
* { box-sizing: border-box; }
/* Reduced motion: neutralize looping/decorative animation and long transitions
   across all stylesheets. Elements snap to their final visible state, so nothing
   that relies on an entrance (dropdowns, reveals) ships hidden. Applies globally —
   this file loads first on every page. Confetti is guarded separately in JS. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
html, body { margin: 0; }
/* Native <select> popups render on an OS-default (often white) surface. Without this,
   options inherit the control's colour (e.g. lime, or white) and become unreadable on
   that surface. Android/desktop Chrome honour these; iOS uses its own legible picker. */
option { background: var(--card); color: var(--text); }
body {
  background: var(--bg-grad);
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  min-height: 100dvh;
}
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }
@keyframes flash { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
.scr::-webkit-scrollbar { width: 0; height: 0; }
.scr { scrollbar-width: none; }

/* App layout: centered column, fixed app bar + bottom nav, scrolling middle. */
.app { display: flex; flex-direction: column; align-items: center; min-height: 100dvh; }
.shell {
  width: 100%; max-width: var(--maxw); margin: 0 auto;
  height: 100dvh; overflow: hidden; display: flex; flex-direction: column;
  background: var(--bg); position: relative;
}
.shell-scroll { flex: 1; overflow-y: auto; padding: 6px 22px 24px; }

h1.screen-title {
  font-family: var(--font-display); font-weight: 400; font-size: 40px;
  line-height: 1; margin: 10px 0 4px; text-transform: uppercase;
}
.eyebrow { font-family: var(--font-label); font-weight: 600; font-size: 12px; letter-spacing: 0.18em; color: var(--muted); }
.subtle { font-size: 13.5px; color: var(--muted); }

.btn-primary {
  cursor: pointer; border: none; background: var(--lime); color: var(--ink);
  border-radius: 16px; padding: 16px; font-family: var(--font-bold);
  font-weight: 800; font-size: 16px; letter-spacing: 0.02em;
}
.btn-primary:disabled { opacity: 0.4; cursor: default; }
.btn-ghost {
  cursor: pointer; background: transparent; border: 1.5px solid var(--border-strong);
  color: var(--text-2); border-radius: 16px; padding: 16px;
  font-family: var(--font-bold); font-weight: 800; font-size: 15px;
}
.btn-ghost:disabled { opacity: 0.4; cursor: default; }
.btn-danger { cursor: pointer; border: none; background: var(--pink); color: var(--ink); border-radius: 14px; padding: 12px 16px; font-family: var(--font-bold); font-weight: 800; }
.pill { font-family: var(--font-label); font-weight: 600; font-size: 12.5px; padding: 7px 12px; border-radius: 999px; background: var(--surface); color: var(--text-2); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); padding: 16px; }
.input {
  background: var(--surface); border: 1.5px solid var(--border); border-radius: var(--r-sm);
  padding: 14px 16px; color: var(--text); font-family: var(--font-body); font-size: 15px; outline: none;
}
.input:focus { border-color: var(--lime); }
.row { display: flex; gap: 10px; align-items: center; }
.between { justify-content: space-between; }
.icon { width: 1em; height: 1em; }

.appbar { display: flex; justify-content: space-between; align-items: center; padding: 14px 22px 10px; flex-shrink: 0; }
.wordmark { font-family: var(--font-display); font-size: 20px; letter-spacing: 0.02em; }
.wordmark span { color: var(--lime); }
.appbar-right { display: inline-flex; align-items: center; gap: 10px; }
.live-chip { display: inline-flex; align-items: center; gap: 7px; font-family: var(--font-label); font-weight: 600; font-size: 12px; letter-spacing: 0.05em; padding: 6px 12px; border-radius: 999px; background: var(--surface); color: var(--muted); }
.live-chip .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); }
/* Only a genuinely live round gets the lime colour + blinking dot; finished/setup are static and muted. */
.live-chip.is-live { color: var(--lime); }
.live-chip.is-live .dot { background: var(--lime); animation: blink 1.4s infinite; }
.conn { width: 8px; height: 8px; border-radius: 50%; background: var(--dim); }
.conn.live { background: var(--lime); }
.conn.offline { background: var(--orange); }
.iconbtn { cursor: pointer; background: transparent; border: none; color: var(--text-2); padding: 6px; display: inline-flex; }
.iconbtn .icon { width: 20px; height: 20px; }
.bottomnav { display: flex; justify-content: space-around; align-items: center; padding: 12px 16px max(20px, env(safe-area-inset-bottom)); border-top: 1px solid var(--surface); background: var(--bg); flex-shrink: 0; }
.navbtn { cursor: pointer; border: none; background: transparent; display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--dim); }
.navbtn .icon { width: 22px; height: 22px; }
.navbtn span { font-size: 10px; font-weight: 600; font-family: var(--font-label); }
.navbtn.active { color: var(--lime); }

.landing { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 40px 22px; }
.landing-head { margin-bottom: 22px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.tlist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.trow { display: flex; align-items: center; gap: 8px; }
.titem { flex: 1; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 12px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 12px 14px; color: var(--text); text-align: left; }
.titem-main { display: flex; flex-direction: column; min-width: 0; }
.titem-name { font-family: var(--font-bold); font-weight: 800; font-size: 15px; }
.titem-meta { font-size: 12px; color: var(--muted); }
.status-badge { font-family: var(--font-label); font-weight: 700; font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; padding: 4px 9px; border-radius: 999px; background: var(--surface); color: var(--muted); }
.status-badge.active { background: var(--lime); color: var(--ink); }
.status-badge.finished { color: var(--lime); }
.tdel { cursor: pointer; background: transparent; border: none; color: var(--dim); padding: 8px; }
.tdel:hover { color: var(--pink); }
code { font-family: var(--font-label); color: var(--lime); }

.addrow { display: flex; gap: 9px; margin-bottom: 18px; }
.addrow .input { flex: 1; min-width: 0; }
.addbtn { cursor: pointer; border: none; background: var(--lime); color: var(--ink); border-radius: var(--r-sm); padding: 0 20px; font-family: var(--font-bold); font-weight: 800; font-size: 22px; }
.plist { display: flex; flex-direction: column; gap: 8px; }
.prow { display: flex; align-items: center; gap: 12px; background: var(--surface); border-radius: 16px; padding: 12px 14px; }
.avatar { width: 36px; height: 36px; flex-shrink: 0; border-radius: 50%; background: var(--bg); border: 1.5px solid var(--border-strong); display: flex; align-items: center; justify-content: center; font-family: var(--font-label); font-weight: 700; font-size: 14px; color: var(--lime); }
.pname { flex: 1; font-weight: 600; font-size: 16px; }
.prow-x { cursor: pointer; border: none; background: transparent; color: var(--dim); padding: 6px; }
.prow-x:hover { color: var(--pink); }
.prow-x .icon { width: 18px; height: 18px; }
.full { width: 100%; }

.shuffle-btn { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 14px; color: var(--lime); }
.shuffle-btn .icon { width: 16px; height: 16px; }
.tcards { display: flex; flex-direction: column; gap: 10px; }
.tcard { display: flex; align-items: center; gap: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 15px 16px; }
.tbadge { width: 44px; height: 44px; flex-shrink: 0; border-radius: 13px; display: flex; align-items: center; justify-content: center; font-family: var(--font-display); font-size: 20px; color: var(--ink); }
.tbadge .icon { width: 18px; height: 18px; }
.tcard-main { flex: 1; min-width: 0; }
.tname-in { width: 100%; background: transparent; border: none; color: var(--text); font-family: var(--font-bold); font-weight: 800; font-size: 18px; padding: 2px 0; outline: none; }
.tname-in:focus { color: var(--lime); }
.lock { flex-shrink: 0; }
.lock .icon { width: 16px; height: 16px; color: var(--muted); }
.pair-sel { flex: 1; min-width: 0; padding: 12px; }
.courts-in { width: 80px; text-align: center; }
.notice { border-radius: var(--r-sm); padding: 12px 14px; font-size: 13px; margin-bottom: 14px; }
.notice.warn { background: rgba(255,138,61,0.12); color: var(--orange); }

.rnav { display: flex; justify-content: space-between; align-items: center; margin: 8px 0 4px; }
.navsq { cursor: pointer; width: 44px; height: 44px; border-radius: 12px; border: 1.5px solid var(--border-strong); background: var(--surface); color: var(--text-2); display: flex; align-items: center; justify-content: center; }
.navsq:disabled { color: var(--border-strong); }
.navsq .icon { width: 18px; height: 18px; }
.rnav-mid { text-align: center; }
.rnav-label { font-family: var(--font-display); font-size: 26px; line-height: 1; }
.rnav-of { font-family: var(--font-label); font-weight: 600; font-size: 11px; letter-spacing: 0.12em; color: var(--muted); margin-top: 2px; }
.timer { text-align: center; padding: 14px 0 4px; }
.timer-label { font-family: var(--font-label); font-weight: 600; font-size: 12px; letter-spacing: 0.22em; color: var(--muted); }
.timer-label.done { color: var(--pink); }
.clock { font-family: var(--font-display); font-size: 96px; line-height: 0.92; color: var(--lime); margin: 6px 0 4px; text-shadow: 0 0 38px rgba(203,255,46,0.35); }
.clock-wrap.warn .clock { color: var(--orange); text-shadow: 0 0 38px rgba(255,138,61,0.35); }
.clock-wrap.done .clock { color: var(--pink); text-shadow: 0 0 38px rgba(255,111,181,0.4); }
.timebar { height: 7px; border-radius: 999px; background: var(--surface); overflow: hidden; margin: 8px 4px 0; }
.timebar i { display: block; height: 100%; background: var(--lime); border-radius: 999px; transition: width 0.4s linear; }
.clock-wrap.warn ~ .timebar i { background: var(--orange); }
.timer-actions { display: flex; gap: 10px; margin-top: 16px; }
.timer-go { flex: 2; }
.timer-go.paused { background: var(--surface); color: var(--text); }
.timer-actions .btn-ghost { flex: 1; }
.presets { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; justify-content: center; }
.preset { cursor: pointer; border: 1.5px solid var(--border-strong); background: var(--surface); color: var(--text-2); border-radius: 999px; padding: 7px 14px; font-family: var(--font-label); font-weight: 600; font-size: 12.5px; }
.preset.active { background: var(--lime); color: var(--ink); border-color: var(--lime); }
.preset:disabled { opacity: 0.5; }
.preset.buzzer.on { color: var(--lime); border-color: var(--lime); }
.preset .icon { width: 14px; height: 14px; }
.preset-input { width: 56px; text-align: center; padding: 7px 6px; outline: none; -moz-appearance: textfield; }
.preset-input:focus { border-color: var(--lime); color: var(--text); }
.preset-input::-webkit-outer-spin-button, .preset-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.scores { margin-top: 18px; display: flex; flex-direction: column; gap: 10px; }
.scard2 { background: var(--surface); border-radius: 18px; padding: 14px 15px; }
.sc-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.sc-court { font-family: var(--font-label); font-weight: 600; font-size: 11px; letter-spacing: 0.1em; color: var(--muted); }
.sc-status { font-size: 11px; color: var(--muted); }
.link-btn { cursor: pointer; background: transparent; border: none; color: var(--lime); font-size: 12px; font-weight: 600; }
.scoreline { display: flex; align-items: center; justify-content: space-between; margin-bottom: 9px; }
.scoreline:last-of-type { margin-bottom: 0; }
.sl-team { display: flex; align-items: center; gap: 9px; min-width: 0; }
.sl-name { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sl-team.win .sl-name { color: var(--lime); }
.score-show { font-family: var(--font-display); font-size: 24px; min-width: 24px; text-align: center; }
.score-show.win { color: var(--lime); }
.stepper { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.step { cursor: pointer; width: 44px; height: 44px; border-radius: 12px; border: 1.5px solid var(--border-strong); background: transparent; color: var(--muted); font-size: 20px; line-height: 1; }
.step.plus { border: none; background: var(--lime); color: var(--ink); font-weight: 700; }
.step-val { width: 40px; background: transparent; border: none; color: var(--text); font-family: var(--font-display); font-size: 24px; text-align: center; outline: none; -moz-appearance: textfield; }
.step-val::-webkit-outer-spin-button, .step-val::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.sc-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.sc-foot .sm { padding: 9px 16px; font-size: 13px; border-radius: 12px; }

/* ── Home screen ─────────────────────────────────────────────────────────── */
.home-title { font-family: var(--font-display); font-weight: 400; font-size: 46px; line-height: 0.94; letter-spacing: 0.005em; margin: 6px 0 14px; text-transform: uppercase; }
.chiprow { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.setup-cta .btn-ghost { display: flex; align-items: center; justify-content: center; gap: 8px; }
.cta-card { width: 100%; text-align: left; cursor: pointer; border: none; background: var(--lime); color: var(--ink); border-radius: var(--r-lg); padding: 20px; margin-bottom: 14px; display: block; }
.cta-top { display: flex; justify-content: space-between; align-items: flex-start; }
.cta-eyebrow { display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-label); font-weight: 700; font-size: 11px; letter-spacing: 0.1em; }
.cta-eyebrow .dot.ink { width: 6px; height: 6px; border-radius: 50%; background: var(--ink); animation: blink 1.4s infinite; }
.cta-round { font-family: var(--font-display); font-size: 30px; line-height: 1; margin-top: 8px; }
.cta-sub { font-family: var(--font-label); font-weight: 600; font-size: 13px; margin-top: 6px; opacity: 0.7; }
.cta-time { font-family: var(--font-display); font-size: 40px; line-height: 1; }
.cta-foot { margin-top: 16px; display: flex; align-items: center; justify-content: space-between; font-family: var(--font-bold); font-weight: 800; font-size: 15px; }
.cta-foot .arr { font-size: 20px; }
.cta-card.finished { background: var(--surface); color: var(--lime); border: 1px solid var(--lime); }
/* The blinking dot signals "live"; a finished tournament is static — stop the pulse. */
.cta-card.finished .cta-eyebrow .dot.ink { background: var(--lime); animation: none; }
.qgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.qcard { cursor: pointer; text-align: left; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 20px; padding: 18px; }
.qcard .icon { width: 24px; height: 24px; color: var(--lime); }
.qcard-title { font-family: var(--font-bold); font-weight: 800; font-size: 16px; margin-top: 14px; }
.qcard-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

/* ── Schedule screen ─────────────────────────────────────────────────────── */
.scards { display: flex; flex-direction: column; gap: 14px; }
.scard { cursor: pointer; text-align: left; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 20px; padding: 16px; display: block; width: 100%; }
.scard.live { border-color: var(--lime); }
.scard-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.scard-label { font-family: var(--font-display); font-size: 22px; }
.status-pill { font-family: var(--font-label); font-weight: 700; font-size: 10.5px; letter-spacing: 0.1em; padding: 5px 10px; border-radius: 999px; background: var(--bg); color: var(--muted); }
.status-pill.live { background: var(--lime); color: var(--ink); }
.scard-body { display: flex; flex-direction: column; gap: 8px; }
.swave { font-family: var(--font-label); font-weight: 600; font-size: 10px; letter-spacing: 0.1em; color: var(--dim); margin-top: 4px; }
.srow { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.scourt { font-family: var(--font-label); font-weight: 600; font-size: 10px; letter-spacing: 0.05em; color: var(--muted); width: 28px; flex-shrink: 0; }
.sdot { width: 9px; height: 9px; border-radius: 3px; flex-shrink: 0; }
.sname { flex: 1; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sname.r { text-align: right; }
.svs { color: var(--dim); font-size: 11px; font-family: var(--font-label); }

/* ── Board (leaderboard) screen ──────────────────────────────────────────── */
.brows { display: flex; flex-direction: column; gap: 9px; }
.brow { display: flex; align-items: center; gap: 13px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 14px 16px; }
.brow.lead { background: rgba(203,255,46,0.08); border-color: rgba(203,255,46,0.4); }
.brank { font-family: var(--font-display); font-size: 22px; width: 26px; text-align: center; color: var(--dim); }
.brank.lead { color: var(--lime); }
.tbadge.sm { width: 36px; height: 36px; border-radius: 11px; font-size: 16px; }
.bmain { flex: 1; min-width: 0; }
.bname { font-family: var(--font-bold); font-weight: 800; font-size: 15.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brec { font-family: var(--font-label); font-weight: 500; font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.bdiff { text-align: right; }
.bdiff-n { font-family: var(--font-display); font-size: 26px; line-height: 1; color: var(--muted); }
.bdiff-n.pos { color: var(--lime); }
.bdiff-n.neg { color: var(--pink); }
.bdiff-l { font-family: var(--font-label); font-weight: 600; font-size: 10px; letter-spacing: 0.08em; color: var(--muted); }
.board-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 20px; }
.board-foot .btn-ghost, .board-foot .btn-primary { padding: 12px 18px; font-size: 14px; border-radius: 14px; }

/* ── Modals + time's-up banner ───────────────────────────────────────────── */
.overlay { position: fixed; inset: 0; background: rgba(6,7,11,0.7); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50; }
.modal { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-lg); padding: 22px; color: var(--text); }
.modal h2 { font-family: var(--font-display); font-weight: 400; font-size: 26px; text-transform: uppercase; margin: 0 0 8px; }
.modal .field { display: flex; flex-direction: column; gap: 6px; }
.modal .lbl { font-size: 12px; color: var(--muted); }
.modal input { background: var(--bg); border: 1.5px solid var(--border); border-radius: var(--r-sm); padding: 12px 14px; color: var(--text); font-family: var(--font-body); outline: none; }
.modal input:focus { border-color: var(--lime); }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }
.champ { text-align: center; }
.champ .crown { width: 56px; height: 56px; color: var(--lime); }
.champ .who { font-family: var(--font-display); font-size: 30px; text-transform: uppercase; margin: 6px 0; }
.champ .players, .champ .record { color: var(--muted); font-size: 13px; }
.qr-wrap { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.qr-wrap canvas { border-radius: 12px; background: #fff; padding: 8px; }
.timeup { position: absolute; left: 16px; right: 16px; bottom: 92px; background: var(--pink); color: var(--ink); border-radius: 18px; padding: 16px 18px; display: flex; align-items: center; gap: 12px; box-shadow: 0 16px 40px -10px rgba(255,111,181,0.6); animation: flash 1s infinite; cursor: pointer; z-index: 5; }
.timeup .icon { width: 26px; height: 26px; }
.timeup-title { font-family: var(--font-bold); font-weight: 900; font-size: 17px; }
.timeup-sub { font-size: 12.5px; font-weight: 600; }

/* ── Round footer (advance / go-current) ── */
.round-foot { margin-top: 20px; }
