:root {
  --bg: #070605;
  --panel: #14100d;
  --velvet: #2a1014;
  --ink: #f6e7c1;
  --muted: #b7a88a;
  --gold: #e4c36a;
  --gold-deep: #a6852e;
  --red: #ff2a3a;
  --line: rgba(228, 195, 106, 0.55);
  --safe-top: env(safe-area-inset-top);
  --safe-bottom: env(safe-area-inset-bottom);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  max-width: 100%;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: Rajdhani, "Segoe UI", sans-serif;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(900px 380px at 0% -10%, rgba(255, 42, 58, 0.18), transparent 55%),
    radial-gradient(700px 320px at 100% 0%, rgba(228, 195, 106, 0.14), transparent 50%),
    var(--bg);
}

button, input, select { font: inherit; color: inherit; }

button { cursor: pointer; }

img { max-width: 100%; display: block; }

.shell {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.mast {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: calc(10px + var(--safe-top)) 14px 8px;
}

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

.gem {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  background: var(--red);
  transform: rotate(45deg);
  box-shadow: 0 0 12px rgba(255, 42, 58, 0.85);
  border: 1px solid var(--gold);
}

.brand strong {
  display: block;
  font-family: Cinzel, Palatino, Georgia, serif;
  font-size: 1.15rem;
  letter-spacing: 0.18em;
  line-height: 1;
}

.brand em {
  display: block;
  margin-top: 3px;
  font-style: normal;
  color: var(--gold);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 0.68rem;
}

#soundToggle {
  flex: 0 0 auto;
  max-width: 46%;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(20, 16, 13, 0.8);
  color: var(--gold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.75rem;
}

.ticker {
  overflow: hidden;
  width: 100%;
  border-top: 1px solid rgba(228, 195, 106, 0.28);
  border-bottom: 1px solid rgba(228, 195, 106, 0.28);
  background: linear-gradient(90deg, #1a0c10, #2a1014 50%, #1a0c10);
}

.ticker-track {
  display: flex;
  width: max-content;
  gap: 22px;
  padding: 6px 0;
  animation: ticker 32s linear infinite;
}

.ticker span {
  color: var(--gold);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.72rem;
  white-space: nowrap;
}

.ticker span:before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 10px;
  background: var(--red);
  transform: rotate(45deg);
  vertical-align: middle;
}

@keyframes ticker {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

main {
  flex: 1;
  width: 100%;
  overflow-x: hidden;
  padding: 12px 14px calc(102px + var(--safe-bottom));
}

.screen { display: none; }

.screen.is-on { display: block; }

.screen-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin: 4px 0 12px;
}

.screen-head h1,
.hero h1 {
  margin: 0;
  font-family: Cinzel, Palatino, Georgia, serif;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 0.92;
}

.screen-head h1 { font-size: clamp(1.8rem, 8vw, 2.6rem); }

.screen-head p,
.lede,
.note,
.blurb { color: var(--muted); }

.index {
  margin: 0;
  font-family: Cinzel, Palatino, Georgia, serif;
  font-size: clamp(2rem, 10vw, 3rem);
  color: rgba(228, 195, 106, 0.28);
  line-height: 0.8;
}

.plate {
  position: relative;
  border: 1px solid var(--line);
  background:
    linear-gradient(#e4c36a, #e4c36a) 8px 8px / 12px 1px no-repeat,
    linear-gradient(#e4c36a, #e4c36a) 8px 8px / 1px 12px no-repeat,
    linear-gradient(#e4c36a, #e4c36a) right 8px top 8px / 12px 1px no-repeat,
    linear-gradient(#e4c36a, #e4c36a) right 8px top 8px / 1px 12px no-repeat,
    linear-gradient(#e4c36a, #e4c36a) left 8px bottom 8px / 12px 1px no-repeat,
    linear-gradient(#e4c36a, #e4c36a) left 8px bottom 8px / 1px 12px no-repeat,
    linear-gradient(#e4c36a, #e4c36a) right 8px bottom 8px / 12px 1px no-repeat,
    linear-gradient(#e4c36a, #e4c36a) right 8px bottom 8px / 1px 12px no-repeat,
    radial-gradient(120% 80% at 0% 0%, rgba(228, 195, 106, 0.08), transparent 42%),
    linear-gradient(180deg, #1b1410, #0c0a09);
  box-shadow: inset 0 0 0 4px rgba(0, 0, 0, 0.35);
}

.hero { margin-bottom: 12px; }

.hero-frame { position: relative; overflow: hidden; }

.hero-frame img,
.banner img {
  width: 100%;
  height: clamp(220px, 62vw, 340px);
  object-fit: cover;
  object-position: center 60%;
}

.banner img { height: clamp(120px, 32vw, 180px); object-position: center; }

.hero-shade,
.banner-shade {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(7, 6, 5, 0.05) 0%, rgba(7, 6, 5, 0.2) 35%, rgba(7, 6, 5, 0.92) 100%);
}

.hero-copy {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 14px;
}

.kicker {
  margin: 0 0 4px;
  color: var(--gold);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  font-size: 0.72rem;
}

.hero h1 { font-size: clamp(2.6rem, 13vw, 4.4rem); }

.lede {
  margin: 4px 0 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 0.95rem;
}

.play, .ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 50px;
  padding: 0 16px;
  border-radius: 999px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 700;
}

.play {
  border: 1px solid var(--gold);
  color: #fff6e8;
  background: linear-gradient(180deg, #ff4d58 0%, #d01222 48%, #7c0c16 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 8px 18px rgba(208, 18, 34, 0.35);
}

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

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0;
}

.stat {
  padding: 10px 8px;
  text-align: center;
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.stat strong {
  display: block;
  margin-top: 2px;
  font-size: clamp(1.05rem, 4.6vw, 1.4rem);
  font-variant-numeric: tabular-nums;
  color: var(--gold);
}

.steps, .stack, .city-list, .records { list-style: none; margin: 0; padding: 0; }

.steps { display: flex; flex-direction: column; gap: 8px; }

.steps li, .up-next, .mode, .ribbon, .car, .city, .record {
  min-width: 0;
}

.steps li {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  padding: 10px;
}

.steps b {
  font-family: Cinzel, Palatino, Georgia, serif;
  color: var(--red);
  font-size: 1.1rem;
}

.steps h2, .block h2, .car h2, .city h2, .up-next h2, .ribbon h2 {
  margin: 0;
  font-size: 1.05rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.steps p, .block p, .city p, .car p, .up-next p, .mode p { margin: 4px 0 0; }

.block { margin-top: 12px; }

.block-title {
  margin: 16px 0 8px;
  font-family: Cinzel, Palatino, Georgia, serif;
  font-size: 1.2rem;
}

.up-next {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 10px;
  padding: 8px;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: #120e0c;
}

.up-next img, .ribbon img, .city img {
  width: 100%;
  height: 78px;
  object-fit: cover;
}

.ribbon {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 10px;
  width: 100%;
  margin-top: 10px;
  padding: 8px;
  text-align: left;
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 40%),
    #120e0c;
}

.ribbon.is-locked, .car.is-locked { opacity: 0.62; }

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

.tags i, .lock-line {
  font-style: normal;
  border: 1px solid rgba(228, 195, 106, 0.4);
  color: var(--gold);
  padding: 2px 6px;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.lock-line { display: inline-block; margin-top: 6px; color: var(--red); border-color: rgba(255, 42, 58, 0.5); }

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.banner { position: relative; margin-bottom: 12px; overflow: hidden; }

.banner-copy {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 12px;
}

.banner h1 {
  margin: 0;
  font-family: Cinzel, Palatino, Georgia, serif;
  font-size: clamp(1.8rem, 8vw, 2.5rem);
}

.modes, .cars, .pair { display: flex; flex-direction: column; gap: 10px; }

.mode, .car, .city, .record, .spec {
  padding: 12px;
}

.mode {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: #120e0c;
}

.mode.is-on {
  border-color: var(--gold);
  box-shadow: inset 0 0 0 1px rgba(228, 195, 106, 0.45);
}

.mode strong, .record strong { color: var(--gold); }

.field { display: block; margin: 12px 0; }

.field span {
  display: block;
  margin-bottom: 6px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: var(--gold);
}

select {
  width: 100%;
  min-height: 48px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #100c0a;
}

.car { border: 1px solid var(--line); background: #120e0c; }

.car.is-selected { box-shadow: inset 0 0 0 1px var(--gold); }

.car-photo {
  width: 100%;
  height: 150px;
  object-fit: cover;
  object-position: center 72%;
  margin-bottom: 8px;
}

.spec-row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 8px;
  margin-top: 6px;
  font-size: 0.92rem;
}

.spec-row span { color: var(--muted); }

.city { margin-top: 12px; }

.city img { height: 140px; margin: -12px -12px 10px; width: calc(100% + 24px); max-width: none; }

.lane {
  position: fixed;
  left: 10px;
  right: 10px;
  bottom: calc(8px + var(--safe-bottom));
  z-index: 5;
  height: 74px;
  max-width: 700px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  padding: 6px 4px 4px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(180deg, #1a120e, #090807);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
}

.lane:before {
  content: "";
  position: absolute;
  left: 8%;
  right: 8%;
  top: 20px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold) 12%, var(--gold) 88%, transparent);
  pointer-events: none;
}

.lane:after {
  content: "";
  position: absolute;
  left: -12px;
  right: -12px;
  top: 100%;
  height: 24px;
  background: #070605;
}

.lane button {
  position: relative;
  border: 0;
  background: transparent;
  padding: 0;
  min-width: 0;
  color: var(--gold);
}

.lane button b {
  display: block;
  width: 11px;
  height: 11px;
  margin: 10px auto 8px;
  border: 1px solid var(--gold);
  background: #120c0a;
  transform: rotate(45deg);
}

.lane button.is-on b {
  background: var(--red);
  box-shadow: 0 0 12px rgba(255, 42, 58, 0.9);
}

.lane button span {
  display: block;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.lane button.is-on span { color: #fff4df; }

.race {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 20;
  background: #070605;
  touch-action: none;
}

.race.is-on { display: block; }

#track {
  width: 100%;
  height: 100%;
  display: block;
}

.hud {
  position: absolute;
  top: calc(8px + var(--safe-top));
  left: 10px;
  right: 78px;
  z-index: 2;
  display: grid;
  gap: 6px;
}

.hud-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.hud-row div, .meter, .race-call {
  background: rgba(8, 6, 5, 0.72);
  border: 1px solid rgba(228, 195, 106, 0.35);
}

.hud-row div { padding: 6px 8px; }

.hud-row span, .meter span {
  display: block;
  color: var(--muted);
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.hud-row strong {
  font-size: 1.15rem;
  font-variant-numeric: tabular-nums;
  color: var(--gold);
}

.bar {
  height: 6px;
  background: rgba(228, 195, 106, 0.18);
  border: 1px solid rgba(228, 195, 106, 0.35);
}

.bar i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--gold), var(--red));
}

.meter {
  position: relative;
  height: 28px;
  padding: 0;
}

.meter i, .meter b {
  position: absolute;
  top: 8px;
  width: 10px;
  height: 10px;
  margin-left: -5px;
}

.meter i {
  background: var(--gold);
  transform: rotate(45deg);
}

.meter b {
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 8px var(--red);
}

.race-call {
  margin: 0;
  min-height: 28px;
  padding: 4px 8px;
  font-size: 0.85rem;
  letter-spacing: 0.06em;
}

.leave {
  position: absolute;
  top: calc(8px + var(--safe-top));
  right: 10px;
  z-index: 3;
  min-height: 36px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(8, 6, 5, 0.8);
  color: var(--gold);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.72rem;
}

.wheel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 10px 10px calc(10px + var(--safe-bottom));
}

.wheel button {
  min-height: 78px;
  border-radius: 16px;
  border: 1px solid var(--gold);
  background: linear-gradient(180deg, rgba(255, 42, 58, 0.2), rgba(8, 6, 5, 0.82));
  color: var(--ink);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
  font-size: clamp(0.85rem, 4.2vw, 1.05rem);
  touch-action: none;
}

.wheel button:active { background: linear-gradient(180deg, #ff2a3a, #6e0d16); }

.race-veil {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(7, 6, 5, 0.62);
}

.race-veil[hidden] { display: none !important; }

.race-card {
  width: min(100%, 420px);
  max-height: calc(100% - 12px);
  overflow: auto;
  padding: 16px;
}

.race-card h2 {
  margin: 0;
  font-family: Cinzel, Palatino, Georgia, serif;
  font-size: clamp(2rem, 10vw, 3.2rem);
  line-height: 0.95;
}

.race-card p { overflow-wrap: anywhere; }

.veil-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }

.veil-actions button[hidden] { display: none !important; }

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

@media (max-width: 340px) {
  .lane button span { letter-spacing: 0.02em; font-size: 9px; }
  .hero h1 { font-size: 2.3rem; }
  .wheel button { min-height: 64px; letter-spacing: 0.1em; }
}

@media (min-width: 700px) {
  .modes, .cars { display: grid; grid-template-columns: 1fr 1fr; }
  .modes { grid-template-columns: 1fr; }
  .cars { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-height: 520px) and (orientation: landscape) {
  .hero-frame img, .banner img { height: 160px; }
  .lane { height: 62px; }
  .lane button b { margin-top: 6px; }
  .wheel button { min-height: 52px; }
  main { padding-bottom: calc(84px + var(--safe-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
  .ticker-track { animation: none; }
  .gem { box-shadow: none; }
}
