:root {
  --navy: #0e1620;
  --mirage: #16202c;
  --slate: #365169;
  --gold: #ffd000;
  --gold-deep: #c9a000;
  --ink: #ffffff;
  --dim: #c5d0dc;
  --red: #c1121f;
  --line: rgba(255, 208, 0, 0.38);
  --glow: 0 0 22px rgba(255, 208, 0, 0.42);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  max-width: 100%;
  background:
    radial-gradient(900px 380px at 50% -8%, rgba(255, 208, 0, 0.16), transparent 58%),
    radial-gradient(700px 420px at 100% 12%, rgba(54, 81, 105, 0.45), transparent 50%),
    var(--navy);
  color: var(--ink);
  font-family: Inter, "Segoe UI", "Avenir Next", "Trebuchet MS", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.55;
}

img, canvas, svg {
  max-width: 100%;
  height: auto;
  display: block;
}

button, select, input {
  font-family: inherit;
  font-size: 1rem;
}

button {
  touch-action: manipulation;
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.shell {
  width: min(920px, 100%);
  margin: 0 auto;
  padding: 10px 12px calc(28px + env(safe-area-inset-bottom));
  min-width: 0;
  overflow-x: hidden;
}

h1, h2, h3, p, strong {
  overflow-wrap: break-word;
  word-break: normal;
}

.scoreboard {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(54, 81, 105, 0.35), rgba(14, 22, 32, 0.92)),
    var(--mirage);
  box-shadow: inset 0 1px 0 rgba(255, 208, 0, 0.2), var(--glow);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.mark-wrap {
  width: 46px;
  height: 46px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 35% 30%, #ffe566, var(--gold) 42%, #8a6b00 78%);
  box-shadow: 0 0 0 2px #fff, 0 0 16px rgba(255, 208, 0, 0.65);
}

.baton-pip {
  width: 22px;
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, #16202c, #2a3b52);
  transform: rotate(-28deg);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

.brand-copy { min-width: 0; }

.live, .kicker, .clock-label {
  margin: 0;
  color: var(--gold);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.3;
}

.live {
  display: flex;
  align-items: center;
  gap: 6px;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 8px var(--gold);
  animation: pulse 1.4s ease-in-out infinite;
}

.mark {
  margin: 0;
  font-style: italic;
  font-weight: 900;
  letter-spacing: -0.04em;
  font-size: clamp(22px, 6.4vw, 34px);
  line-height: 0.95;
  color: #fff;
  -webkit-text-stroke: 1.4px var(--gold);
  text-shadow: 2px 2px 0 #0b1220, 0 0 18px rgba(255, 208, 0, 0.35);
}

.sub {
  margin: 2px 0 0;
  color: var(--dim);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.clock-stack {
  text-align: right;
  min-width: 0;
}

.clock {
  margin: 0;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  font-size: clamp(18px, 5.2vw, 28px);
  color: var(--gold);
  text-shadow: 0 0 12px rgba(255, 208, 0, 0.55);
  letter-spacing: 0.04em;
}

.chip {
  border: 1px solid var(--line);
  background: rgba(14, 22, 32, 0.7);
  color: var(--ink);
  border-radius: 999px;
  min-height: 40px;
  padding: 0 12px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.chip[aria-pressed="false"] {
  background: var(--gold);
  color: var(--mirage);
  font-weight: 800;
}

.lanes {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
  margin: 10px 0 14px;
  padding: 10px 8px 8px;
  border-radius: 20px 20px 12px 12px;
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.05) 0 2px, transparent 2px 18%),
    linear-gradient(180deg, #1a2838, #0b1220);
  border: 1px solid var(--line);
  position: relative;
  overflow: hidden;
}

.lanes::before {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 7px;
  background: linear-gradient(90deg, #c1121f, #e85d04, #ffd000, #2a9d8f, #1d4ed8, #7c3aed);
  opacity: 0.9;
}

.lane {
  position: relative;
  z-index: 1;
  min-width: 0;
  min-height: 54px;
  border: 0;
  padding: 8px 4px 10px;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(54, 81, 105, 0.35), rgba(11, 18, 32, 0.92));
  border-radius: 14px 14px 6px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  box-shadow: inset 3px 0 0 var(--stripe);
}

.lane:nth-child(1) { transform: translateY(8px); }
.lane:nth-child(2) { transform: translateY(5px); }
.lane:nth-child(3) { transform: translateY(2px); }
.lane:nth-child(4) { transform: translateY(0); }
.lane:nth-child(5) { transform: translateY(3px); }
.lane:nth-child(6) { transform: translateY(6px); }

.lane i {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #fff;
  color: var(--mirage);
  font-style: normal;
  font-weight: 800;
  font-size: 11px;
}

.lane span {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  max-width: 100%;
  line-height: 1.15;
  text-align: center;
}

.lane.on {
  background: linear-gradient(180deg, var(--gold), var(--gold-deep));
  color: var(--mirage);
  box-shadow: 0 0 0 2px #fff, var(--glow);
}

.lane.on i {
  background: var(--mirage);
  color: var(--gold);
}

.panel { display: none; min-width: 0; }
.panel.on { display: block; }

.hero-strip {
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  margin-bottom: 12px;
  border: 1px solid var(--line);
}

.hero-strip img {
  width: 100%;
  height: min(38vw, 220px);
  object-fit: cover;
}

.hero-copy {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 14px 14px 12px;
  background: linear-gradient(180deg, transparent, rgba(11, 18, 32, 0.92));
}

.hero-copy h2 {
  margin: 4px 0 0;
  font-size: clamp(16px, 5vw, 26px);
  line-height: 1.2;
  max-width: 100%;
}

.hud {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 8px;
}

.capsule {
  min-width: 0;
  padding: 8px 8px 7px;
  border-radius: 999px;
  background: rgba(22, 32, 44, 0.92);
  border: 1px solid rgba(255, 208, 0, 0.28);
  text-align: center;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.03);
}

.capsule span {
  display: block;
  color: var(--gold);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 700;
}

.capsule strong {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.15;
  overflow: hidden;
}

.legs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 8px;
}

.leg-pip {
  min-width: 0;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dim);
  padding: 6px 4px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(14, 22, 32, 0.7);
}

.leg-pip.on {
  color: var(--mirage);
  background: var(--gold);
  border-color: var(--gold);
}

.leg-pip.done {
  color: #fff;
  background: var(--slate);
}

.stage {
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #070c12;
  box-shadow: var(--glow);
}

#track {
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 10;
  max-height: min(58vh, 520px);
  touch-action: manipulation;
}

.toast {
  position: absolute;
  left: 50%;
  top: 18%;
  transform: translateX(-50%);
  padding: 8px 16px;
  border-radius: 999px;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  background: var(--gold);
  color: var(--mirage);
  box-shadow: var(--glow);
  pointer-events: none;
}

.toast.bad {
  background: var(--red);
  color: #fff;
}

.status {
  margin: 10px 0;
  color: var(--dim);
  font-size: 14px;
}

.picks {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}

.pick {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--gold);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 700;
}

.pick select {
  width: 100%;
  min-height: 44px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--mirage);
  color: var(--ink);
  padding: 0 10px;
}

.controls {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 8px;
}

.cta, .ghost {
  min-height: 48px;
  border-radius: 999px;
  border: 0;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.cta {
  background: linear-gradient(180deg, #ffe566, var(--gold));
  color: var(--mirage);
  box-shadow: var(--glow);
}

.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  list-style: none;
  padding: 12px 0 0;
  margin: 0;
  color: var(--dim);
  font-size: 12px;
}

.swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}

.swatch.crest { background: var(--gold); box-shadow: 0 0 8px var(--gold); }
.swatch.clip { background: var(--red); }
.swatch.lock { background: #7c3aed; }
.swatch.ghost { background: rgba(255, 255, 255, 0.45); }

.panel-head { margin: 4px 0 14px; }

.panel-head h2, .block-title {
  margin: 4px 0 8px;
  font-size: clamp(22px, 6vw, 30px);
  line-height: 1.2;
}

.panel-head p { margin: 0; color: var(--dim); }

.mosaic, .oval-list, .kit-list, .board-grid, .runs {
  display: grid;
  gap: 10px;
}

.card, .story, .oval-card, .kit-card, .best-card, .run-row {
  min-width: 0;
  border-radius: 18px;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(54, 81, 105, 0.22), rgba(14, 22, 32, 0.94));
  border: 1px solid rgba(255, 208, 0, 0.22);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.card img, .story img, .oval-card img, .kit-card img {
  width: 100%;
  height: min(42vw, 200px);
  object-fit: cover;
}

.card-body, .oval-card .copy, .kit-card .copy {
  padding: 12px;
}

.card h3, .story h3, .oval-card h3, .kit-card h3, .best-card strong {
  margin: 4px 0 8px;
  font-size: 18px;
}

.story {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  margin-bottom: 12px;
}

.story div { padding: 12px; }

.story p { margin: 0 0 10px; color: var(--dim); }

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.tag {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255, 208, 0, 0.12);
  color: var(--gold);
  border: 1px solid rgba(255, 208, 0, 0.28);
}

.tag.off {
  color: var(--dim);
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.1);
}

.best-card, .run-row {
  padding: 12px;
}

.best-card span, .run-row span {
  color: var(--gold);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 700;
}

.best-card b, .run-row b {
  display: block;
  margin-top: 4px;
  font-size: 22px;
  color: var(--gold);
  text-shadow: 0 0 10px rgba(255, 208, 0, 0.4);
}

.run-row {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) auto;
  gap: 8px;
  align-items: center;
}

.empty {
  color: var(--dim);
  padding: 16px;
  text-align: center;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.82); }
}

@media (max-width: 420px) {
  .scoreboard {
    grid-template-columns: minmax(0, 1fr) auto;
  }
  .chip {
    grid-column: 1 / -1;
    justify-self: start;
  }
  .lanes {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    padding-bottom: 12px;
  }
  .hud .capsule:nth-child(1) strong,
  .hud .capsule:nth-child(2) strong {
    font-size: 11px;
  }
  .lane:nth-child(n) { transform: none; }
  .hud {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .controls, .picks {
    grid-template-columns: minmax(0, 1fr);
  }
  .hero-strip img {
    height: 160px;
  }
}

@media (min-width: 640px) {
  .story {
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
    align-items: stretch;
  }
  .story.reverse {
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  }
  .story.reverse img { order: 2; }
  .story img, .oval-card img, .kit-card img {
    height: 100%;
    min-height: 180px;
  }
  .oval-list, .kit-list, .board-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 860px) {
  .hud { gap: 10px; }
  .capsule strong { font-size: 14px; }
}
