/* Spectate viewer (0.47.1). Podium look: navy panels, orange = action, teal = status. */
:root {
  --navy-900: #0b1524;
  --navy-800: #101d30;
  --navy-700: #16263d;
  --navy-600: #26384e;
  --ink: #f4f7fb;
  --ink-dim: #b9c6d6;
  --orange: #ff782e;
  --orange-soft: rgba(255, 120, 46, 0.28);
  --teal: #71ded3;
  --teal-deep: #087b75;
  --panel: rgba(16, 29, 48, 0.9);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --gutter: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--navy-900);
  color: var(--ink);
  font-family: var(--font);
  overflow: hidden;
}

.spectate { position: fixed; inset: 0; }
.stage { position: absolute; inset: 0; }
.stage canvas { display: block; width: 100%; height: 100%; }

.panel {
  background: var(--panel);
  border: 2px solid var(--navy-600);
  border-radius: 6px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}
.eyebrow {
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--teal);
}

/* ---------- Code entry ---------- */
.join {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: min(420px, calc(100% - 2 * var(--gutter)));
  padding: 24px;
  border-top: 6px solid var(--teal);
  z-index: 5;
}
.join h1 { margin: 0 0 8px; font-size: 28px; font-weight: 800; }
.join-help { margin: 0 0 16px; color: var(--ink-dim); line-height: 1.4; }
.join label[for="code"] { display: block; font-weight: 700; margin-bottom: 6px; }
.join-row { display: flex; gap: 8px; }
.join-row input {
  flex: 1; min-width: 0;
  font: 800 24px/1 var(--font);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  padding: 10px 12px;
  color: var(--ink);
  background: var(--navy-700);
  border: 2px solid var(--navy-600);
  border-radius: 4px;
}
.join-row input:focus { outline: none; border-color: var(--teal); }
.btn-action {
  font: 800 16px/1 var(--font);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0 20px;
  color: #1a0d04;
  background: var(--orange);
  border: 0;
  border-radius: 4px;
  cursor: pointer;
}
.btn-action:hover { filter: brightness(1.08); }
.btn-action:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }

.home-link { color: inherit; text-decoration: none; }
.home-link:hover, .home-link:focus-visible { text-decoration: underline; }
/* Spectate lives under Game: the GAME crumb is underlined as the current section, with a 40 px tap height. */
.join .eyebrow .home-link { display: inline-block; padding: 12px 0; margin: -10px 0; }
.section-link { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 4px; }
.signin-panel[hidden], .code-panel[hidden] { display: none; }
.signin-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; }
.btn-link { display: inline-flex; align-items: center; min-height: 48px; text-decoration: none; }
.text-link { color: var(--teal); font-weight: 700; }
.signin-note {
  margin: 16px 0 0; padding-top: 12px; border-top: 1px solid var(--navy-600);
  display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--ink-dim);
}
.signin-note .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--teal); flex: none; }
.signin-note strong { color: var(--teal); }
.join-status { min-height: 1.3em; margin: 12px 0 0; color: var(--teal); font-weight: 600; }
.join-status.is-error { color: var(--orange); }
.join-status:empty { display: none; }

/* ---------- Broadcast overlay ---------- */
.overlay { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
.overlay[hidden] { display: none; }

.ov-title {
  position: absolute;
  top: var(--gutter); left: var(--gutter);
  padding: 8px 14px;
  font-weight: 800;
  font-size: 18px;
  letter-spacing: 0.06em;
  border-left: 6px solid var(--orange);
}
.ov-sep { color: var(--orange); margin: 0 6px; }

.ov-order {
  position: absolute;
  top: calc(var(--gutter) + 52px); left: var(--gutter);
  width: 230px;
  padding: 4px 0;
}
.ov-order ol { list-style: none; margin: 0; padding: 0; }
.ov-row {
  display: grid;
  grid-template-columns: 26px 44px 1fr auto;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  font-size: 15px;
  font-weight: 700;
  border-bottom: 1px solid rgba(38, 56, 78, 0.7);
  transition: background-color 0.6s;
}
.ov-row:last-child { border-bottom: 0; }
.ov-pos { color: var(--ink-dim); text-align: right; }
.ov-row:first-child .ov-pos { color: var(--orange); }
.ov-plate {
  text-align: center;
  background: var(--ink);
  color: var(--navy-800);
  border-radius: 3px;
  font-weight: 900;
  padding: 1px 0;
}
.ov-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ov-tail { font-size: 12px; color: var(--teal); }
.tag-club {
  display: inline-block;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--navy-800);
  background: var(--ink-dim);
  border-radius: 2px;
  padding: 1px 4px;
  margin-left: 6px;
  vertical-align: 1px;
}
/* A rider who just gained a place flashes orange. */
.ov-row.gained { animation: gained 1.4s ease-out; }
@keyframes gained {
  0%, 30% { background: var(--orange); color: #1a0d04; }
  100% { background: transparent; }
}

.ov-bar {
  position: absolute;
  left: var(--gutter); right: var(--gutter); bottom: var(--gutter);
  display: flex; align-items: center; gap: 14px;
  padding: 8px 14px;
  font-weight: 800;
  letter-spacing: 0.06em;
  border-bottom: 4px solid var(--teal);
}
.ov-track { font-size: 17px; }
.pill-live {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 999px;
  color: #04201d;
  background: var(--teal);
}
.pill-live::before {
  content: "";
  display: inline-block;
  width: 7px; height: 7px;
  margin-right: 6px;
  border-radius: 50%;
  background: #04201d;
  vertical-align: 1px;
  animation: blink 1.2s infinite;
}
.pill-live.is-ended { background: var(--navy-600); color: var(--ink-dim); }
.pill-live.is-ended::before { display: none; }
@keyframes blink { 50% { opacity: 0.2; } }
.ov-phase { font-size: 12px; color: var(--ink-dim); }
.ov-cam { margin-left: auto; font-size: 15px; white-space: nowrap; }
.ov-cam-label { color: var(--orange); font-size: 12px; }

.ov-results, .ov-next {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: min(460px, calc(100% - 2 * var(--gutter)));
  padding: 18px 20px;
  background: rgba(16, 29, 48, 0.97);
  border-top: 6px solid var(--orange);
}
.ov-results h2, .ov-next h2 { margin: 0 0 10px; font-size: 24px; font-weight: 900; letter-spacing: 0.04em; }
.ov-results ol { list-style: none; margin: 0; padding: 0; }
.res-row {
  display: grid;
  grid-template-columns: 28px 46px 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 7px 0;
  font-weight: 700;
  border-bottom: 1px solid var(--navy-600);
}
.res-row:last-child { border-bottom: 0; }
.res-row:first-child .res-pos { color: var(--orange); }
.res-pos { text-align: right; font-weight: 900; }
.res-time { font-variant-numeric: tabular-nums; }
.res-gap { font-variant-numeric: tabular-nums; color: var(--teal); font-size: 13px; min-width: 52px; text-align: right; }
.ov-next { border-top-color: var(--teal); text-align: center; }
/* Shown under the results once the room has ended (404 or ended:true). The overlay ignores the pointer, the link doesn't. */
.ov-ended-note { margin: 12px 0 0; color: var(--ink-dim); pointer-events: auto; }
.ov-ended-note[hidden] { display: none; }
.ov-ended-note a { color: var(--orange); font-weight: 800; }
.ov-next-note { margin: 0; color: var(--ink-dim); }

/* ---------- Phone ---------- */
@media (max-width: 640px) {
  :root { --gutter: 10px; }
  .ov-title { font-size: 14px; padding: 6px 10px; }
  .ov-order { top: calc(var(--gutter) + 40px); width: 180px; }
  .ov-row { grid-template-columns: 18px 36px 1fr auto; font-size: 13px; padding: 4px 8px; gap: 5px; }
  .ov-bar { flex-wrap: wrap; gap: 6px 10px; padding: 6px 10px; }
  .ov-track { font-size: 14px; }
  .ov-cam { font-size: 13px; }
  .res-row { grid-template-columns: 22px 40px 1fr auto; font-size: 14px; }
  .res-gap { display: none; }
}
/* 11-15: a visible way back to the site from the full-screen viewer (critic) */
.back-link{margin:14px 0 0;padding-top:12px;border-top:1px solid rgba(255,255,255,.12);font-size:14px}
.back-link .text-link{display:inline-flex;align-items:center;min-height:40px}
