/* Timing Tower: one look across every page.
   Deep navy, ice-blue actions, monospace numbers that line up like a race timing screen.
   Status colors: mint = done, ice = uploading, yellow = due, purple = first in, coral = out. */
:root {
  --asphalt: #0a121e;      /* page */
  --slab: #0f1b2b;         /* panels, header */
  --slab-2: #132235;       /* raised / video well */
  --line: #1d2d42;         /* panel borders */
  --rule: #142236;         /* row dividers */
  --edge: #2c4562;         /* outline buttons, inputs */
  --chalk: #e8f0f8;        /* text */
  --dust: #7f93a8;         /* labels */
  --mist: #9fb3c8;         /* secondary text */
  --faint: #4d6178;
  --signal: #9fe1ff;       /* ice blue: primary actions */
  --signal-ink: #0a121e;
  --due: #ffd76a;
  --go: #6ee7b7;
  --out: #f28b8b;
  --out-bar: #3a2430;
  --wait: #9fe1ff;
  --first: #c792ff;
  --live: #ff5d6c;
  --display: "Chakra Petch", "Arial Narrow", sans-serif;
  --body: "IBM Plex Sans", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  --r: 2px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--asphalt);
  color: var(--chalk);
  font: 15px/1.45 var(--body);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--signal); }
a:hover { color: #c8efff; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }
[hidden] { display: none !important; }
.wrap {
  max-width: 1280px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 0 48px;
}
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.star { width: 16px; height: 16px; flex: none; display: block; }

/* ---------- header bar ---------- */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap;
  margin: 0 calc(-1 * max(16px, env(safe-area-inset-left, 0px))) 0;
  padding: 12px max(16px, env(safe-area-inset-left, 0px));
  padding-top: max(12px, env(safe-area-inset-top, 0px));
  background: var(--slab); border-bottom: 1px solid var(--line);
}
.logo { display: flex; align-items: center; gap: 9px; min-width: 0; text-decoration: none; color: inherit; }
.brand {
  font-family: var(--display); font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
  font-size: 16px; line-height: 1.1; margin: 0; overflow-wrap: anywhere;
}
h1.page { font-family: var(--display); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; font-size: clamp(26px, 6vw, 36px); line-height: 1; margin: 22px 0 6px; }
.eyebrow { font-size: 10px; text-transform: uppercase; letter-spacing: .14em; color: var(--dust); font-weight: 600; }
.live-tag { display: inline-flex; align-items: center; gap: 6px; font-family: var(--display); font-weight: 700; font-size: 12px; letter-spacing: .12em; color: var(--live); text-transform: uppercase; white-space: nowrap; }
.live-tag.idle { color: var(--dust); }
.live-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: pulse 1.6s infinite; }
.live-tag.idle .live-dot { animation: none; }
@keyframes pulse { 50% { opacity: .3; } }

/* ---------- stat strip (Round / Deadline / Still in) ---------- */
.stats {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 0 calc(-1 * max(16px, env(safe-area-inset-left, 0px)));
  border-bottom: 1px solid var(--line);
}
.stat { display: flex; flex-direction: column; gap: 2px; padding: 10px 16px; border-right: 1px solid var(--line); min-width: 0; }
.stat:last-child { border-right: 0; }
.stat .eyebrow { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat .v { font-family: var(--mono); font-weight: 600; font-size: 22px; line-height: 1.15; white-space: nowrap; }
.stat .v small { font-size: inherit; color: var(--faint); }
.stat .v.clock { color: var(--due); }
.stat .v.clock.hot { color: var(--live); }
.stat .v.clock.calm { color: var(--chalk); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px; border-radius: 0;
  border: 1px solid var(--edge); background: transparent; color: var(--chalk);
  font: 700 14px/1 var(--display); letter-spacing: .08em; text-transform: uppercase;
  text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--mist); color: var(--chalk); }
.btn.primary {
  background: var(--signal); color: var(--signal-ink); border-color: var(--signal);
  clip-path: polygon(0 0, 100% 0, calc(100% - 10px) 100%, 0 100%); padding-right: 24px;
}
.btn.primary:hover { background: #c8efff; color: var(--signal-ink); }
.btn.danger { color: var(--out); border-color: #5a3340; }
.btn.small { min-height: 34px; padding: 0 12px; font-size: 12px; }
.btn.small.primary { padding-right: 18px; clip-path: polygon(0 0, 100% 0, calc(100% - 7px) 100%, 0 100%); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- player ---------- */
.stage { position: relative; aspect-ratio: 16 / 9; max-width: 100%; background: var(--slab-2); overflow: hidden; }
.stage::before { content: ""; position: absolute; inset: 0; background-image: radial-gradient(#22344c 1px, transparent 1px); background-size: 14px 14px; }
.stage video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; opacity: 0; transition: opacity .12s linear; }
.stage video.front { opacity: 1; }
.ov { position: absolute; pointer-events: none; z-index: 2; }
/* name plate: ice-blue round block + dark name bar, bottom left */
.ov-name { left: 12px; bottom: 12px; display: flex; align-items: stretch; height: clamp(40px, 6vw, 72px); max-width: calc(100% - 24px); }
.ov-name .r { display: grid; place-items: center; aspect-ratio: 1; background: var(--signal); color: var(--signal-ink); font-family: var(--display); font-weight: 700; font-size: clamp(16px, 2.6vw, 30px); }
.ov-name .p { display: flex; align-items: center; gap: 12px; padding: 0 clamp(12px, 1.6vw, 22px); background: rgb(10 18 30 / .92); min-width: 0; }
.ov-name .n { font-family: var(--display); font-weight: 700; text-transform: uppercase; font-size: clamp(18px, 3vw, 40px); line-height: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ov-name .a { font-family: var(--mono); font-size: clamp(12px, 1.4vw, 18px); color: var(--dust); white-space: nowrap; }
.ov-round { display: none; }
.ov-count { top: 10px; right: 12px; font-family: var(--mono); font-size: 12px; color: var(--mist); background: rgb(10 18 30 / .8); padding: 3px 8px; }
.sound { position: absolute; left: 12px; top: 10px; pointer-events: auto; z-index: 3; background: rgb(10 18 30 / .85); }
.empty { position: absolute; inset: 0; z-index: 1; display: grid; place-items: center; text-align: center; padding: 24px; color: var(--mist); }
.empty strong { display: block; font-family: var(--display); font-size: clamp(20px, 4vw, 30px); color: var(--chalk); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; }
@media (prefers-reduced-motion: reduce) { .live-dot { animation: none; } .stage video { transition: none; } }

/* ---------- section heads ---------- */
.section-h { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px; margin: 24px 0 10px; }
.section-h h2, h2.sec { font-family: var(--display); font-weight: 700; text-transform: uppercase; letter-spacing: .1em; font-size: 16px; margin: 0; }
.tally { color: var(--dust); font-size: 13px; }
.tally b { color: var(--chalk); font-family: var(--mono); }

/* ---------- athlete list ---------- */
.tower { --cols: 5px minmax(0, 1fr) auto; }
.tower .th, .tower .tr {
  display: grid; grid-template-columns: var(--cols); align-items: center; column-gap: 12px;
  padding: 0 6px 0 0; width: 100%; text-align: left; color: inherit; font: inherit; background: none; border: 0;
}
.tower .th { padding-block: 6px; font-size: 10px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--dust); border-bottom: 1px solid var(--line); }
.tower .th .c-at { text-align: right; }
.tower .tr { min-height: 48px; padding-block: 6px; border-bottom: 1px solid var(--rule); }
button.tr { cursor: pointer; }
button.tr:hover { background: rgb(159 225 255 / .05); }
.tr .flag { align-self: stretch; margin-block: 2px; background: var(--edge); }
.tr.done .flag, .tr.finished .flag { background: var(--go); }
.tr.uploading .flag { background: var(--wait); }
.tr.due .flag { background: var(--due); }
.tr.out .flag { background: var(--out-bar); }
.tr .who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.tr .nm { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tr .ag { color: var(--dust); font-weight: 400; margin-left: 6px; font-family: var(--mono); font-size: 13px; }
.tr .at { text-align: right; font-family: var(--mono); font-size: 12px; font-weight: 600; white-space: nowrap; }
.tr.done .at, .tr.finished .at { color: var(--go); }
.tr .at.first { color: var(--first); }
.tr.uploading .at { color: var(--wait); }
.tr.due .at { color: var(--due); }
.tr.waiting .at { color: var(--dust); }
.tr.out { color: #5b6e83; }
.tr.out .nm { text-decoration: line-through; text-decoration-thickness: 1px; }
.tr.out .at { color: var(--out); }
.tr.out .av { opacity: .5; }
.tower .gap { height: 10px; border-bottom: 1px solid var(--line); }

/* round pips (athlete panel + admin only) */
.pip { width: 6px; height: 10px; background: var(--line); flex: none; }
.pip.done { background: var(--mist); }
.pip.up { background: var(--wait); }
.pip.miss { background: var(--out); }
.pip.now { box-shadow: 0 0 0 1px var(--due); }
.sub-pips .pip { width: auto; flex: 1; height: 6px; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 12px 4px; font-size: 11px; color: var(--dust); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 8px; height: 8px; display: inline-block; }

/* avatars (check-in photos) */
.av { width: 28px; height: 28px; object-fit: cover; background: var(--slab-2); display: block; flex: none; }
.av.ini { display: grid; place-items: center; font-family: var(--display); font-weight: 700; font-size: 11px; color: var(--faint); }
.av.lg { width: 84px; height: 84px; font-size: 28px; }

/* status labels */
.pill { font-family: var(--mono); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; padding: 3px 7px; white-space: nowrap; border: 1px solid currentColor; }
.pill.done, .pill.finished { color: var(--go); }
.pill.due { color: var(--due); }
.pill.uploading { color: var(--wait); }
.pill.out { color: var(--out); }
.pill.waiting { color: var(--dust); }

/* ---------- forms ---------- */
.card { background: var(--slab); border: 1px solid var(--line); padding: 18px; }
.card > h2:first-child, .card > .sec:first-child { margin-top: 0; }
.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field label, .lbl { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .12em; color: var(--mist); }
.hint { color: var(--dust); font-size: 13px; }
input[type=datetime-local] { height: 48px; }
input[type=text], input[type=password], input[type=number], input[type=datetime-local], input[type=search], select, textarea {
  width: 100%; min-height: 48px; padding: 10px 14px; background: var(--asphalt); border: 1px solid var(--edge); border-radius: 0;
}
input:focus, select:focus, textarea:focus { border-color: var(--signal); outline: none; }
textarea { min-height: 140px; font-family: var(--mono); font-size: 13px; }
.msg { padding: 12px 14px; font-weight: 600; border-left: 0; position: relative; padding-left: 30px; }
.msg::before { content: ""; position: absolute; left: 12px; top: 18px; width: 8px; height: 8px; transform: rotate(45deg); background: currentColor; }
.msg.bad { background: rgb(242 139 139 / .1); color: #ffc2c2; }
.msg.good { background: rgb(110 231 183 / .1); color: #b6f5dc; }
.msg.info { background: var(--slab-2); color: var(--chalk); }
.msg.info::before { background: var(--signal); }
.bar { height: 10px; background: var(--asphalt); border: 1px solid var(--edge); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--signal); transition: width .2s; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.grow { flex: 1; min-width: 0; }
