/* Race-day look: black, Spartan red and white, heavy condensed italic caps.
   Single dark theme on purpose: it sits over a live camera feed and must read in sunlight. */
:root {
  --black: #0b0b0b;
  --ink: #161616;
  --steel: #2b2b2b;
  --line: #3a3a3a;
  --white: #ffffff;
  --muted: #a6a6a6;
  --red: #e2231a;
  --red-deep: #a8150f;
  --good: #22c55e;
  --warn: #ffb020;
  --display: "Barlow Condensed", "Arial Narrow", "Roboto Condensed", Impact, sans-serif;
  --body: "Barlow", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--black);
  color: var(--white);
  font: 16px/1.45 var(--body);
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }

/* Landscape with rotation lock on: turn the whole page a quarter turn so it
   reads upright on a phone standing on its side. Fixed-position children are
   placed against the turned body. */
html.turn-left body, html.turn-right body {
  position: fixed; top: 0; left: 0; overflow: auto;
  width: 100vh; height: 100vw;
  width: 100dvh; height: 100dvw;
  transform-origin: top left;
}
html.turn-left body { transform: rotate(90deg) translateY(-100%); }
html.turn-right body { transform: rotate(-90deg) translateX(-100%); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

h1, h2, h3, .eyebrow, .btn, .bibchip, .targetchip, .num, .countdown, .flash, .done-label, .done-num, .timer, .rf-num {
  font-family: var(--display);
  text-transform: uppercase;
}
h1, h2, h3 { text-wrap: balance; margin: 0; }

/* ---------- pages (home, results, settings) ---------- */
.page {
  min-height: 100%;
  padding: max(20px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(32px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.masthead { position: relative; padding: 28px 0 8px; }
.masthead .slash {
  position: absolute; inset: 0 -16px auto -16px; height: 10px;
  background: var(--red);
  clip-path: polygon(0 0, 100% 0, 96% 100%, 0 100%);
}
.eyebrow {
  margin: 0;
  color: var(--red);
  font-weight: 700;
  letter-spacing: 0.14em;
  font-size: 0.95rem;
}
h1 {
  font-style: italic;
  font-weight: 900;
  font-size: clamp(4rem, 19vw, 7.5rem);
  line-height: 0.82;
  letter-spacing: -0.01em;
  margin: 6px 0 14px;
}
.lede { margin: 0; color: var(--muted); max-width: 52ch; }

.panel {
  background: var(--ink);
  border-top: 4px solid var(--red);
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.panel h3 { font-size: 1.35rem; font-weight: 700; letter-spacing: 0.04em; margin-top: 8px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 0.9rem; color: var(--muted); }
input[type="text"], input[type="number"], select, textarea {
  font: inherit;
  color: var(--white);
  background: var(--black);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 12px;
  width: 100%;
}
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible {
  outline: 3px solid var(--red);
  outline-offset: 2px;
}
.check { display: flex; align-items: center; gap: 10px; }
.check input { width: 22px; height: 22px; accent-color: var(--red); }

.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.seg button {
  font: 600 1rem var(--body);
  color: var(--muted);
  background: var(--black);
  border: 1px solid var(--line);
  padding: 12px 8px;
  border-radius: 2px;
  cursor: pointer;
}
.seg-big button { font: italic 800 1.7rem var(--display); text-transform: uppercase; padding: 10px 6px; }
.seg button[aria-checked="true"] { color: var(--white); border-color: var(--red); background: var(--red-deep); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: 0.06em;
  padding: 12px 20px;
  border: 2px solid transparent;
  border-radius: 2px;
  cursor: pointer;
  color: var(--white);
  background: transparent;
  text-decoration: none;
  user-select: none;
}
.btn-red { background: var(--red); border-color: var(--red); }
.btn-red:active { background: var(--red-deep); }
.btn-ghost { border-color: var(--line); background: rgba(11, 11, 11, 0.6); }
.btn-ghost:active { border-color: var(--white); }
.btn-big {
  font-size: 1.7rem;
  font-style: italic;
  font-weight: 800;
  padding: 16px 24px;
  clip-path: polygon(0 0, 100% 0, calc(100% - 14px) 100%, 0 100%);
}
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.badge {
  font-family: var(--body);
  font-size: 0.8rem;
  background: var(--red);
  padding: 1px 7px;
  border-radius: 2px;
  font-variant-numeric: tabular-nums;
}

.links { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-results { flex-basis: 100%; justify-content: space-between; padding: 18px 22px; }
.btn-results .badge { font-size: 1.1rem; padding: 2px 12px; font-style: normal; }
.cog-btn {
  position: absolute; top: 22px; right: 0; width: 56px; height: 56px; padding: 10px;
  border: 2px solid var(--line); background: var(--ink); color: var(--white); cursor: pointer;
}
.cog-btn:active { border-color: var(--white); }
.cog-btn svg { width: 100%; height: 100%; display: block; }
.saved-note { margin: 0; padding: 10px 12px; background: var(--good); color: var(--black); font-weight: 700; }
.video-cell { display: flex; gap: 6px; }
.player-card { width: min(100%, 720px); max-height: 100%; overflow-y: auto; gap: 12px; }
.player-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.player-head h2 { font-size: 2rem; font-style: italic; font-weight: 900; }
.player-head .rules-x { position: static; flex: none; }
#playerVideo { width: 100%; max-height: 65vh; background: #000; display: block; }
.status { margin: 0; color: var(--muted); font-size: 0.92rem; }
.error { margin: 0; color: var(--white); background: var(--red-deep); padding: 10px 12px; }
.warn { margin: 0; color: var(--warn); font-size: 0.92rem; flex-basis: 100%; }
.empty { color: var(--muted); }

.tips h2 { font-size: 1.4rem; font-weight: 700; letter-spacing: 0.04em; margin-bottom: 8px; }
.tips ol { margin: 0; padding-left: 1.3em; color: var(--muted); display: grid; gap: 6px; }
.tips li::marker { color: var(--red); font-family: var(--display); font-weight: 700; }

.page-head { display: flex; align-items: center; gap: 14px; }
.page-head h2 { font-size: 2.4rem; font-style: italic; font-weight: 900; }
.row { display: flex; flex-wrap: wrap; gap: 8px; }

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; font-size: 0.95rem; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--steel); white-space: nowrap; }
th { font: 700 0.85rem var(--display); text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
.pill { font: 700 0.8rem var(--display); text-transform: uppercase; letter-spacing: 0.08em; padding: 2px 8px; border-radius: 2px; }
.pill.ok { background: var(--good); color: var(--black); }
.pill.bad { background: var(--red); color: var(--white); }
.pill.warn { background: #f59e0b; color: var(--black); } /* questionable: the judge couldn't tell */
.pill.test { background: var(--steel); color: var(--white); }
td .btn { font-size: 0.9rem; padding: 4px 10px; }

/* ---------- camera stage + HUD ---------- */
#stage { position: fixed; inset: 0; background: #000; }
#video { display: none; }
#canvas { width: 100%; height: 100%; object-fit: contain; display: block; }
/* Test videos: the video plays underneath, the canvas only draws outlines. */
#stage.overlay #video { display: block; position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
#stage.overlay #canvas { position: absolute; inset: 0; }

.hud {
  position: fixed; inset: 0;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: max(14px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  pointer-events: none;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.75);
}
.hud button, .hud input, .hud form, .hud label { pointer-events: auto; }
.hud.center { justify-content: center; align-items: center; }
.hud-top { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.hud-title { font-size: clamp(2rem, 8vw, 3.4rem); font-style: italic; font-weight: 900; line-height: 0.95; }
.hud-sub { margin: 0; max-width: 40ch; }
.hud-bottom { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.reading { margin: 0; font-size: 1.2rem; background: rgba(11, 11, 11, 0.7); padding: 6px 12px; }
.reading strong { font: 800 1.6rem var(--display); letter-spacing: 0.06em; font-variant-numeric: tabular-nums; }
.reading-meta { margin: -6px 0 0; font-size: 0.85rem; color: var(--muted); }
.ocr-peek { display: block; height: 56px; max-width: 100%; margin: 0 0 8px; background: #fff; border: 3px solid var(--red); }
.ocr-peek[hidden] { display: none; }
.manual { display: flex; flex-wrap: wrap; gap: 8px; width: min(100%, 420px); }
.manual input { flex: 1 1 160px; font-size: 1.4rem; }

.bibchip {
  background: var(--red);
  padding: 4px 14px 4px 12px;
  font-weight: 700;
  font-size: 1.3rem;
  letter-spacing: 0.06em;
  clip-path: polygon(0 0, 100% 0, calc(100% - 8px) 100%, 0 100%);
  text-shadow: none;
}
.bibchip strong { font-size: 1.6rem; margin-left: 4px; }

.checks { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 6px; font-size: 1.15rem; }
.checks li { padding-left: 32px; position: relative; }
.checks li::before {
  content: ""; position: absolute; left: 0; top: 0.15em;
  width: 22px; height: 22px; border: 2px solid var(--white); border-radius: 2px;
}
.checks li.ok::before { background: var(--good); border-color: var(--good); }

.countdown {
  font-style: italic; font-weight: 900;
  font-size: min(60vw, 60vh);
  line-height: 1;
  color: var(--white);
}
.countdown.go { color: var(--red); }

.hud-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.timer { font-weight: 700; font-size: 1.8rem; font-variant-numeric: tabular-nums; letter-spacing: 0.04em; }
.rec { font: 700 0.9rem var(--body); letter-spacing: 0.1em; display: flex; align-items: center; gap: 6px; }
.rec::before { content: ""; width: 12px; height: 12px; border-radius: 50%; background: var(--red); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0.2; } }

.counter {
  position: absolute; left: 0; right: 0; top: 50%; transform: translateY(-55%);
  text-align: center; line-height: 0.8;
  font-family: var(--display);
}
.num {
  font-style: italic; font-weight: 900;
  font-size: clamp(9rem, 42vw, 22rem);
  font-variant-numeric: tabular-nums;
  -webkit-text-stroke: 3px var(--black);
}
.of { font: italic 800 clamp(2.5rem, 11vw, 6rem) var(--display); color: var(--muted); }
.num.bump { animation: bump 0.35s ease-out; }
@keyframes bump { from { transform: scale(1.18); } to { transform: scale(1); } }

.flash {
  position: absolute; left: 50%; bottom: 22%; transform: translateX(-50%) skewX(-8deg);
  padding: 8px 22px; font-weight: 900; font-style: italic; font-size: clamp(1.6rem, 7vw, 3rem);
  text-align: center; line-height: 1; white-space: nowrap; text-shadow: none;
}
.flash small { display: block; font: 700 clamp(1rem, 4.5vw, 1.5rem) var(--body); text-transform: none; font-style: normal; margin-top: 4px; white-space: normal; }
.flash.good { background: var(--good); color: var(--black); }
.flash.bad { background: var(--red); color: var(--white); }

.hud-warn {
  align-self: center; margin: 0; background: var(--warn); color: var(--black);
  font-weight: 700; padding: 8px 14px; text-shadow: none; text-align: center;
  position: absolute; top: 34%; left: 50%; transform: translateX(-50%); width: max-content; max-width: calc(100% - 32px);
}
.norep-tally { margin: 0; font-size: 1.1rem; }
.debug {
  position: absolute; right: max(10px, env(safe-area-inset-right)); top: 70px; margin: 0;
  font: 12px/1.35 ui-monospace, Consolas, monospace; background: rgba(0, 0, 0, 0.7); padding: 8px; text-shadow: none;
  max-width: 46vw; white-space: pre-wrap;
}

/* ---------- whole-screen per-rep flash ---------- */
.rep-flash {
  position: fixed; inset: 0; z-index: 5;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  padding: 16px; text-align: center; pointer-events: none;
}
.rep-flash.good { background: var(--good); color: var(--black); }
.rep-flash.bad { background: var(--red); color: var(--white); }
.rf-num {
  font-style: italic; font-weight: 900; line-height: 0.8;
  font-size: min(75vh, 85vw); font-variant-numeric: tabular-nums;
}
.rf-cross .big-icon { width: min(62vh, 78vw); height: auto; display: block; }
.rf-reasons { margin: 0; font: 800 clamp(1.5rem, 6vw, 2.6rem)/1.1 var(--display); text-transform: uppercase; max-width: 22ch; }
.rep-flash.good .rf-cross, .rep-flash.good .rf-reasons, .rep-flash.bad .rf-num, .rep-flash.start .rf-cross { display: none; }
.rep-flash.start { background: var(--good); color: var(--black); }
.rep-flash.start .rf-num { font-size: min(34vh, 24vw); line-height: 0.9; }
.rep-flash.start .rf-reasons { font: italic 900 min(26vh, 30vw)/0.9 var(--display); max-width: none; }
.rep-flash.pop { animation: pop 0.25s ease-out; }
@keyframes pop { from { transform: scale(1.06); } to { transform: scale(1); } }

.targetchip {
  background: var(--white); color: var(--black); text-shadow: none;
  padding: 2px 14px 2px 12px; font-weight: 700; font-size: 1.2rem; letter-spacing: 0.06em;
  clip-path: polygon(0 0, 100% 0, calc(100% - 8px) 100%, 0 100%);
}
.targetchip strong { font-size: 1.6rem; font-style: italic; }

/* ---------- finish: whole-screen tick or cross ---------- */
.done-screen {
  position: fixed; inset: 0; z-index: 4; overflow-y: auto;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  text-align: center;
  background: var(--good); color: var(--black);
}
.done-screen.bad { background: var(--red); color: var(--white); }
.done-screen.test { background: var(--steel); color: var(--white); }
.done-screen .big-icon { width: min(42vh, 70vw); height: auto; display: block; }
.done-cross, .done-screen.bad .done-tick, .done-screen.test .done-tick { display: none; }
.done-screen.bad .done-cross, .done-screen.test .done-cross { display: block; }
.done-label { margin: 0; font-weight: 900; font-style: italic; font-size: clamp(2.6rem, 11vw, 4.5rem); line-height: 0.9; }
.done-num { margin: 0; font-weight: 900; font-style: italic; font-size: clamp(3rem, 14vw, 5.5rem); line-height: 0.9; font-variant-numeric: tabular-nums; }
.done-num .of { font: inherit; font-size: 0.5em; color: inherit; opacity: 0.7; }
.done-stats { display: grid; grid-template-columns: repeat(3, auto); gap: 6px 28px; margin: 4px 0; }
.done-stats dt { font: 700 0.85rem var(--display); text-transform: uppercase; letter-spacing: 0.1em; opacity: 0.75; }
.done-stats dd { margin: 0; font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.done-note { margin: 0; font-weight: 600; opacity: 0.85; }
.btn-dark { background: var(--black); border-color: var(--black); color: var(--white); }

/* ---------- attempt detail ---------- */
.subhead { font-size: 1.4rem; font-weight: 700; letter-spacing: 0.04em; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px 16px; margin: 0; background: var(--ink); border-top: 4px solid var(--red); padding: 14px 16px; }
.facts dt { font: 700 0.8rem var(--display); text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.reps-table td:last-child { white-space: normal; min-width: 14ch; }
#resultsBody tr { cursor: pointer; }
#resultsBody tr:hover td { background: var(--ink); }

.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.7); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 10; }
#confirm { z-index: 30; }

.exit-btn {
  position: fixed; z-index: 7;
  top: max(12px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right));
  display: flex; align-items: center; gap: 8px; min-height: 48px; padding: 6px 12px 6px 16px;
  border: 2px solid var(--white); background: rgba(11, 11, 11, 0.75); color: var(--white); cursor: pointer;
  font: 700 1.1rem var(--display); text-transform: uppercase; letter-spacing: 0.06em;
}
.exit-btn:active { background: var(--red-deep); }
.exit-btn svg { width: 20px; height: 20px; display: block; color: var(--red); }
/* Keep the camera screens' top text clear of the exit button. */
.hud-top, .hud-bar { padding-right: 104px; }
.modal-card { background: var(--ink); border-top: 4px solid var(--red); padding: 20px; width: min(100%, 400px); display: flex; flex-direction: column; gap: 16px; }
.modal-card p { margin: 0; font-size: 1.1rem; }

/* ---------- "What counts?" button and panel ---------- */
.rules-btn {
  position: fixed; z-index: 6;
  right: max(16px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 8px; min-height: 48px;
  padding: 6px 18px 6px 8px; border: 0; cursor: pointer;
  background: var(--red); color: var(--white);
  font: 700 1.1rem var(--display); text-transform: uppercase; letter-spacing: 0.06em;
  clip-path: polygon(0 0, 100% 0, calc(100% - 8px) 100%, 0 100%);
}
.rules-btn:active { background: var(--red-deep); }
.rules-q {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%;
  background: var(--white); color: var(--red); font-size: 1.3rem; font-weight: 900;
}
/* Keep the button clear of the station's own buttons. */
body.has-rules-btn .hud-bottom, body.has-rules-btn .page { padding-bottom: 72px; }
body.has-rules-btn .done-screen { padding-bottom: max(88px, env(safe-area-inset-bottom)); }

.rules {
  position: fixed; inset: 0; z-index: 20; overflow-y: auto;
  display: flex; align-items: flex-end; justify-content: flex-end;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: rgba(0, 0, 0, 0.75);
}
.rules-card {
  width: min(100%, 560px); margin-top: auto;
  background: var(--ink); border-top: 6px solid var(--red); padding: 18px 18px 14px;
  display: flex; flex-direction: column; gap: 10px; position: relative;
  transform-origin: bottom right; animation: rules-pop 0.2s ease-out;
}
@keyframes rules-pop { from { transform: scale(0.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.rules-card h2 { font-size: clamp(1.8rem, 7vw, 2.4rem); font-style: italic; font-weight: 900; line-height: 0.95; }
.rules-flow { margin: 0; color: var(--muted); }
.std-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; counter-reset: std; }
.std-list li { background: var(--black); padding: 10px; display: flex; flex-direction: column; gap: 6px; counter-increment: std; }
.std-list h3 { font-size: 1.25rem; font-weight: 700; line-height: 1; }
.std-list h3::before { content: counter(std) ". "; color: var(--red); }
.std-list p { margin: 0; font-size: 0.9rem; color: var(--muted); line-height: 1.3; }
.std-fig { width: 100%; max-height: 110px; display: block; }
.std-fig .ground { stroke: var(--line); stroke-width: 3; }
.std-fig .body { fill: none; stroke: var(--white); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }
.std-fig .body circle { fill: var(--white); stroke: none; }
.std-fig .mark { fill: none; stroke: var(--red); stroke-width: 4; stroke-linecap: round; }
.std-fig .mark circle { fill: var(--red); stroke: none; }
.rules-note { margin: 0; font-weight: 600; }
.std-plain { grid-template-columns: 1fr; }
.std-plain li { gap: 4px; }
.exercise-banner { margin: 0; padding: 10px 12px; background: var(--steel); border-left: 4px solid var(--red); font-weight: 600; }
.exercise-banner.practice { background: var(--red-deep); border-left-color: var(--white); }
.rules-x {
  position: absolute; top: 8px; right: 8px; width: 52px; height: 52px; padding: 12px;
  border: 0; background: var(--red); color: var(--white); cursor: pointer;
}
.rules-x:active { background: var(--red-deep); }
.rules-x svg { width: 100%; height: 100%; display: block; }
.rules-card .eyebrow, .rules-card h2 { padding-right: 56px; }

@media (prefers-reduced-motion: reduce) {
  .num.bump, .rec::before, .rep-flash.pop, .rules-card { animation: none; }
}

/* Judging strictness slider */
.strict-field input[type=range] { width: 100%; accent-color: var(--red, #e2231a); margin: 10px 0 2px; }
.strict-ends { display: flex; justify-content: space-between; font-size: 0.8rem; opacity: 0.75; }
.strict-more { margin-top: 10px; font-size: 0.9rem; }
.strict-more summary { cursor: pointer; font-weight: 600; }
.strict-more ul { margin: 6px 0; padding-left: 20px; }
.strict-more li { margin: 4px 0; }

/* Loader (test video) */
.loader { position: fixed; inset: 0; z-index: 40; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; background: rgba(11, 11, 11, 0.9); color: var(--white); }
.loader[hidden] { display: none; }
.loader p { margin: 0; font: italic 800 1.4rem var(--display); text-transform: uppercase; letter-spacing: 0.02em; }
.loader-spin { width: 64px; height: 64px; border-radius: 50%; border: 6px solid var(--steel); border-top-color: var(--red); animation: loader-spin 0.8s linear infinite; }
@keyframes loader-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .loader-spin { animation-duration: 2.4s; } }

/* ---------- several athletes (test) ---------- */
/* Top left, under the timer: one row per athlete, in the order they started. */
.multi-list {
  display: none; flex-direction: column; align-items: flex-start; gap: 6px;
  position: absolute; left: max(16px, env(safe-area-inset-left)); top: calc(max(14px, env(safe-area-inset-top)) + 52px);
  max-height: calc(100% - 200px); overflow: hidden;
}
#count.multi .multi-list { display: flex; }
#count.multi .counter, #count.multi .norep-tally, #count.multi .bibchip { display: none; }
.mchip { --ath: var(--red); display: flex; align-items: baseline; gap: 8px; background: rgba(0,0,0,0.65); border-left: 6px solid var(--ath); padding: 4px 12px 4px 8px; font: 700 1.5rem var(--display); font-variant-numeric: tabular-nums; }
.mchip b { font-size: 1.1rem; background: var(--ath); padding: 0 6px; }
.mchip.ok span::after { content: " ✓"; color: var(--good); }
.done-multi { display: none; list-style: none; margin: 4px 0; padding: 0; width: min(100%, 420px); }
.done-screen.multi .done-multi { display: grid; gap: 6px; }
.done-screen.multi .done-stats { display: none; }
.done-multi li { border-left: 8px solid var(--ath, transparent); display: grid; grid-template-columns: 1fr auto auto; gap: 14px; align-items: baseline; background: rgba(0,0,0,0.25); padding: 6px 12px; }
.done-multi b { font: 700 1.2rem var(--display); text-transform: uppercase; }
.done-multi span { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.done-multi li.ok span::after { content: " ✓"; }

.spartan-default { display: grid; gap: 6px; padding-bottom: 14px; border-bottom: 1px solid var(--line, #333); }
.spartan-default .btn { justify-self: start; }

/* ---------- test video controls ---------- */
.seek { display: flex; align-items: center; gap: 10px; width: 100%; pointer-events: auto; background: rgba(0,0,0,0.55); padding: 6px 10px; }
.seek[hidden] { display: none; }
.seek-play { min-width: 48px; min-height: 40px; padding: 4px 10px; font-size: 1rem; }
.seek input[type="range"] { flex: 1; min-width: 0; accent-color: var(--red); height: 32px; }
.seek-time { font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.test-info { margin: 0; font-size: 0.9rem; font-weight: 600; background: rgba(0,0,0,0.55); padding: 3px 8px; }
.test-info[hidden] { display: none; }
.seek-turn { display: flex; gap: 6px; }
.seek-turn[hidden] { display: none; }
.mchip.gone { opacity: 0.45; }
.stream-lost { position: absolute; left: 50%; top: 45%; transform: translateX(-50%); margin: 0; background: var(--warn); color: var(--black); font-weight: 700; padding: 10px 16px; z-index: 3; }
.stream-lost[hidden] { display: none; }
#streamForm input { width: 100%; }

.home-link { display: inline-block; color: var(--white); font-weight: 700; text-decoration: none; margin-bottom: 6px; position: relative; z-index: 1; }

/* a camera's settings in the Receiver's video review: its name and reps at the top */
.camera-top { display: grid; gap: 10px; padding-bottom: 14px; margin-bottom: 14px; border-bottom: 2px solid var(--line); }

/* the judge inside a camera in the Receiver's video review: no home screen or exit button, just the judging */
html.embedded #home > * { display: none !important; }
html.embedded #home { display: grid; place-items: center; min-height: 100vh; }
html.embedded #home::before { content: "Connecting to the camera…"; color: var(--muted); font-weight: 700; font-size: 1.2rem; }
/* only EXIT stays inside a camera (it stops the AI judge); End round and What counts? are the review's */
html.embedded #endAttempt, html.embedded #rulesBtn { display: none !important; }
html.rules-only #home::before { content: none; }
/* Pick athlete and Details in the video review: just the analysis, with no way to the judge's own home or saved results */
html.analysis #home > * { display: none !important; }
html.analysis #home { display: grid; place-items: center; min-height: 100vh; }
html.analysis #home::before { content: "Getting the video ready…"; color: var(--muted); font-weight: 700; font-size: 1.2rem; }
html.analysis #home #homeError:not([hidden]) { display: block !important; }
html.analysis #attemptBack, html.analysis #nextAthlete, html.analysis #doneMenu, html.analysis .back { display: none !important; }
.at-number { align-items: flex-end; gap: 10px; margin: 6px 0 12px; }
.at-number .field { flex: 1; min-width: 180px; }

/* Burpee practice: the challenges instead of the station's settings */
html.practice-mode #goSettings, html.practice-mode #openStation, html.practice-mode nav.links > :not(#goResults),
html.practice-mode #home .field:has(#customReps), html.practice-mode #home .field:has(.seg [data-reps]), html.practice-mode label[for="stationName"],
html.practice-mode .done-stats > div:first-child, html.practice-mode #done .of { display: none !important; }
html.practice-mode #position .bibchip, html.practice-mode #wrongBib, html.practice-mode #count .bibchip { display: none !important; }
html.practice-mode #nextAthlete, html.practice-mode #doneMenu { width: 100%; max-width: 420px; justify-content: center; text-align: center; }
html.practice-mode #doneMenu { background: transparent; color: inherit; border-color: currentColor; }
html.practice-mode .done-screen .big-icon { width: min(20vh, 36vw); }
.setup-pictures { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; max-width: 560px; margin: 10px 0 14px; }
.setup-pictures figure { margin: 0; background: #0b0b0b; border-top: 4px solid #22c55e; }
.setup-pictures .setup-bad { border-top-color: #e2231a; }
.setup-pictures figcaption { padding: 7px 8px 2px; font: italic 800 1.15rem var(--display); text-transform: uppercase; color: #22c55e; }
.setup-pictures .setup-bad figcaption { color: #ff5a52; }
.setup-pictures svg { display: block; width: 100%; }
.setup-pictures p { margin: 0; padding: 4px 8px 9px; font-size: 0.86rem; line-height: 1.25; }
.setup-tips { margin: 0 0 14px; padding-left: 20px; display: grid; gap: 6px; }
.setup-cams { display: grid; gap: 10px; margin-bottom: 12px; }
.setup-cams .btn { width: 100%; justify-content: center; }
.mute-btn {
  position: fixed; z-index: 11;
  top: calc(max(12px, env(safe-area-inset-top)) + 56px); right: max(12px, env(safe-area-inset-right));
  min-height: 44px; padding: 6px 12px; cursor: pointer;
  border: 2px solid var(--white); background: rgba(11, 11, 11, 0.75); color: var(--white);
  font: 700 1rem var(--display); text-transform: uppercase; letter-spacing: 0.06em;
}
.mute-btn[aria-pressed="true"] { background: var(--white); color: var(--black); }
.countdown.words { font-size: min(22vw, 30vh); text-align: center; }
.callout {
  position: absolute; left: 0; right: 0; top: 14%; text-align: center; pointer-events: none;
  font: italic 900 clamp(5rem, 26vw, 12rem) var(--display); line-height: 1; color: var(--red); -webkit-text-stroke: 2px var(--white);
}
.submit-ask { width: 100%; max-width: 420px; margin: 4px 0; }
.submit-ask p { margin: 0 0 8px; font-weight: 700; font-size: 1.2rem; }
.submit-ask .row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.submit-ask .btn { justify-content: center; }
.submit-ask .btn-ghost { background: transparent; color: inherit; border-color: currentColor; }
/* the quiet judge in the Receiver: no per-athlete counts on screen (they are recorded and looked up in review) */
html.embedded #multiList, html.embedded #rfNum, html.embedded #repFlash { display: none !important; }
html.embedded #cntWarn { font-size: 0.95rem; }
html.embedded #exitStation { display: none !important; } /* the tile's own Stop AI judge does this */
html.upload-clean #cntWarn, html.upload-clean #testInfo, html.upload-clean #exitStation, html.upload-clean #cntTimer { display: none !important; }
html.embedded #home #homeError:not([hidden]) { display: block !important; }
/* a camera judge with its tracking hidden: the plain video, the drawing layer kept but invisible */
html.hide-tracking #stage #video { display: block; position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
html.hide-tracking #stage #canvas { opacity: 0; }
.camera-top .check { display: flex; gap: 8px; align-items: flex-start; grid-column: 1 / -1; }
.camera-top .cfg-actions { grid-column: 1 / -1; display: flex; gap: 10px; justify-content: flex-end; }
/* ...shown as a sheet there: one surface, no heading of its own, Close / Save in a bar held at the foot */
html.cfg-sheet, html.cfg-sheet body { background: var(--ink); }
html.cfg-sheet #settings { max-width: none; padding: 0; gap: 0; min-height: 100vh; }
html.cfg-sheet #settings .page-head { display: none; }
html.cfg-sheet #settingsForm { border-top: 0; padding: 20px 20px 0; gap: 14px; }
html.cfg-sheet .camera-top { grid-template-columns: 2fr 1fr; gap: 12px 14px; }
html.cfg-sheet .camera-top .field:has(#c_name) { grid-column: 1; }
html.cfg-sheet .cfg-foot { position: sticky; bottom: 0; z-index: 5; display: flex; justify-content: flex-end; gap: 10px; margin: 8px -20px 0; padding: 12px 20px;
  background: var(--ink); border-top: 1px solid var(--line); box-shadow: 0 -10px 18px rgba(0, 0, 0, .35); }
html.cfg-sheet .cfg-foot .btn { min-width: 120px; justify-content: center; }
html.cfg-sheet #settingsSaved { display: none !important; }
@media (max-width: 520px) { html.cfg-sheet .camera-top { grid-template-columns: 1fr; } html.cfg-sheet .cfg-foot .btn { flex: 1; } }
/* the burpee scoreboard (its own page and the practice page) */
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
.chips button { font: 700 1rem var(--body); padding: 9px 14px; border: 1px solid var(--line); background: transparent; color: var(--white); cursor: pointer; }
.chips button[aria-pressed="true"] { background: var(--white); color: var(--black); border-color: var(--white); }
.chips.big button { font: italic 800 1.3rem var(--display); text-transform: uppercase; flex: 1; }
.ex-tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 10px -16px 4px; padding: 0 16px; }
.ex-tabs::-webkit-scrollbar { display: none; }
.ex-tabs button { flex: 0 0 auto; padding: 9px 14px; border: 0; border-bottom: 3px solid transparent; background: transparent; color: var(--muted); font: italic 800 1.15rem var(--display); text-transform: uppercase; cursor: pointer; }
.ex-tabs button[aria-pressed="true"] { color: var(--white); border-bottom-color: var(--red); }
.ex-pager { display: flex; align-items: flex-start; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.ex-pager::-webkit-scrollbar { display: none; }
.ex-panel { flex: 0 0 100%; min-width: 0; box-sizing: border-box; scroll-snap-align: start; scroll-snap-stop: always; }
.ex-name { margin: 10px 0 2px; font: italic 900 2.2rem var(--display); text-transform: uppercase; }
.ex-flow { margin: 0 0 8px; }
.best-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 10px 0 18px; padding: 12px 14px; border: 1px solid var(--line); }
.best-score { display: grid; line-height: 1.1; }
.best-score b { font: italic 900 3.2rem var(--display); }
.best-score small { color: var(--muted); }
.best-row .btn { flex: 0 0 auto; min-width: 120px; justify-content: center; }
.board-title { margin: 18px 0 4px; font: italic 800 1.5rem var(--display); text-transform: uppercase; }
.history-more { margin-top: 10px; }
.board.history tr td.name small { line-height: 1.3; }
.board { width: 100%; border-collapse: collapse; margin-top: 6px; font-variant-numeric: tabular-nums; }
.board td { padding: 10px 8px; border-bottom: 1px solid var(--line); }
.board td.rank { width: 2.5em; color: var(--muted); font-weight: 700; }
.board td.reps { text-align: right; font: 800 1.4rem var(--display); }
.board tr.mine td { background: color-mix(in srgb, var(--red) 16%, transparent); }
.board tr.mine td.name::after { content: " (you)"; color: var(--muted); font-weight: 600; }
.board tr.gap td { border: 0; color: var(--muted); text-align: center; padding: 2px; }
.board tr:nth-child(1) td.rank { color: #f2c94c; } .board tr:nth-child(2) td.rank { color: #c0c6cc; } .board tr:nth-child(3) td.rank { color: #d08b52; }
html.practice-mode .of { display: none !important; }
.practice-back { display: block; color: var(--white); font-weight: 700; text-decoration: none; margin-bottom: 10px; }
#cntWarn.too-slow { color: #fff; background: #b91c1c; padding: 2px 8px; }
/* the name every app user gives on first use */
.name-gate { z-index: 50; }
.name-gate h2 { margin: 0; font: italic 800 1.8rem var(--display); text-transform: uppercase; }
.name-field { display: grid; gap: 6px; font-weight: 700; }
.name-field input { font: inherit; padding: 12px; background: #222; color: #fff; border: 1px solid #555; }
.name-gate .btn { justify-content: center; }
.name-gate .error { margin: 0; color: #ff8a84; font-size: 1rem; }

/* the language menu on the judge's home screen and the recordings page (i18n.js fills it) */
.langPick { font: inherit; font-size: .9rem; color: var(--white); background: var(--ink); border: 1px solid var(--line); padding: 5px 8px; border-radius: 8px; width: auto; max-width: 10em; }
.masthead .langPick { position: relative; z-index: 1; margin-top: 12px; }
/* Arabic and Thai (i18n.js sets <html lang>): no slanted lettering or added letter spacing, which break Arabic's joined letters */
html[lang="ar"] *, html[lang="th"] * { font-style: normal !important; letter-spacing: 0 !important; }
