:root {
  color-scheme: dark;
  --ink: #f5f1e8;
  --muted: #9da6a6;
  --panel: rgba(8, 11, 12, 0.72);
  --line: rgba(255, 255, 255, 0.2);
  --acid: #e9ff70;
  --orange: #ff7a28;
  --cyan: #4ee7ff;
  --red: #ff493d;
  --green: #64f39a;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #07090a;
  color: var(--ink);
  font-family: "Arial Narrow", "Roboto Condensed", "Segoe UI", sans-serif;
}

button {
  font: inherit;
}

#game {
  display: block;
  width: 100vw;
  height: 100vh;
  background: #111;
  touch-action: none;
}

.noise {
  position: fixed;
  inset: 0;
  z-index: 2;
  opacity: 0.055;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.95' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.85'/%3E%3C/svg%3E");
}

.cinema {
  position: fixed;
  left: 0;
  right: 0;
  z-index: 3;
  height: 8px;
  background: #050606;
  pointer-events: none;
}

.cinema--top { top: 0; }
.cinema--bottom { bottom: 0; }

.hud {
  position: fixed;
  inset: 18px 20px auto;
  z-index: 5;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 16px;
  align-items: start;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.35s ease, transform 0.35s ease;
}

body.racing .hud,
body.counting .hud {
  opacity: 1;
  transform: translateY(0);
}

.telemetry {
  display: flex;
  align-items: stretch;
  gap: 8px;
}

.telemetry--right {
  justify-content: flex-end;
  pointer-events: auto;
}

.brand-mark,
.metric,
.race-clock,
.icon-button {
  border-top: 1px solid rgba(255, 255, 255, 0.28);
  background: linear-gradient(180deg, rgba(6, 8, 9, 0.78), rgba(6, 8, 9, 0.42));
  backdrop-filter: blur(12px);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.18);
}

.brand-mark {
  width: 62px;
  min-height: 54px;
  display: grid;
  place-content: center;
  text-align: center;
  border-left: 3px solid var(--orange);
}

.brand-mark span {
  font-weight: 1000;
  font-size: 23px;
  line-height: 0.9;
  font-style: italic;
}

.brand-mark small {
  margin-top: 5px;
  color: var(--orange);
  font-size: 7px;
  font-weight: 900;
  letter-spacing: 0.15em;
}

.metric {
  min-width: 86px;
  min-height: 54px;
  padding: 8px 11px;
  display: grid;
  align-content: center;
  gap: 4px;
}

.metric--wide {
  min-width: 176px;
}

.metric--right {
  text-align: right;
}

.metric > span,
.race-clock span,
.system__label span,
.gear span {
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.14em;
}

.metric strong {
  overflow: hidden;
  max-width: 230px;
  font-size: 17px;
  line-height: 1;
  letter-spacing: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric strong b {
  color: var(--acid);
  font-size: 23px;
}

.metric strong i {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.race-clock {
  min-width: 232px;
  padding: 8px 20px 10px;
  text-align: center;
  border-top-color: var(--acid);
  clip-path: polygon(6% 0, 94% 0, 100% 100%, 0 100%);
}

.race-clock strong {
  display: block;
  margin: 2px 0;
  font-family: "Courier New", monospace;
  font-size: clamp(24px, 3vw, 36px);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

.race-clock small {
  color: var(--acid);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.icon-button {
  width: 46px;
  min-height: 54px;
  border: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.28);
  color: var(--ink);
  cursor: pointer;
  font-size: 21px;
}

.icon-button:hover {
  color: var(--acid);
}

.speedometer {
  position: fixed;
  left: 20px;
  bottom: 24px;
  z-index: 5;
  width: 174px;
  height: 118px;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.35s ease, transform 0.35s ease;
  pointer-events: none;
}

body.racing .speedometer,
body.counting .speedometer {
  opacity: 1;
  transform: translateY(0);
}

.speedometer__arc {
  position: absolute;
  inset: 0;
  border: 2px solid rgba(255, 255, 255, 0.23);
  border-bottom: 0;
  border-radius: 100px 100px 0 0;
  clip-path: polygon(0 0, 100% 0, 86% 100%, 14% 100%);
  background:
    conic-gradient(from 244deg at 50% 100%, var(--cyan) 0 25deg, var(--acid) 25deg 78deg, var(--orange) 78deg 116deg, transparent 116deg 360deg);
  opacity: 0.72;
  mask: radial-gradient(circle at 50% 100%, transparent 0 56%, #000 57%);
}

.speedometer__value {
  position: absolute;
  inset: 33px 0 auto;
  text-align: center;
  text-shadow: 0 4px 18px rgba(0, 0, 0, 0.7);
}

.speedometer__value strong {
  display: block;
  font-family: "Courier New", monospace;
  font-size: 50px;
  font-style: italic;
  line-height: 0.9;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

.speedometer__value span {
  color: var(--muted);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.22em;
}

.gear {
  position: absolute;
  left: 6px;
  bottom: 0;
  display: grid;
  text-align: center;
}

.gear b {
  color: var(--acid);
  font-size: 25px;
}

.systems {
  position: fixed;
  right: 20px;
  bottom: 26px;
  z-index: 5;
  width: min(290px, 32vw);
  display: grid;
  gap: 9px;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.35s ease, transform 0.35s ease;
  pointer-events: none;
}

body.racing .systems,
body.counting .systems {
  opacity: 1;
  transform: translateY(0);
}

.system__label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
}

.system__label b {
  font-family: "Courier New", monospace;
  font-size: 12px;
}

.system__track {
  height: 7px;
  padding: 1px;
  border: 1px solid rgba(255, 255, 255, 0.23);
  background: rgba(0, 0, 0, 0.48);
  transform: skewX(-14deg);
}

.system__track i {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--cyan);
  box-shadow: 0 0 14px rgba(78, 231, 255, 0.55);
  transition: width 0.1s linear;
}

.system__track--damage i {
  background: var(--green);
  box-shadow: 0 0 14px rgba(100, 243, 154, 0.4);
}

.system__track--combo i {
  background: var(--acid);
  box-shadow: 0 0 14px rgba(233, 255, 112, 0.4);
}

.route {
  position: fixed;
  left: 50%;
  bottom: 25px;
  z-index: 5;
  width: min(460px, 42vw);
  transform: translateX(-50%) translateY(12px);
  opacity: 0;
  transition: opacity 0.35s ease, transform 0.35s ease;
  pointer-events: none;
}

body.racing .route,
body.counting .route {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.route__line {
  position: relative;
  height: 4px;
  background: rgba(255, 255, 255, 0.18);
}

.route__line::after {
  content: "";
  position: absolute;
  inset: -4px 0;
  background: repeating-linear-gradient(90deg, transparent 0 calc(25% - 1px), rgba(255,255,255,.55) calc(25% - 1px) 25%);
}

.route__line i {
  display: block;
  width: 0;
  height: 100%;
  background: var(--acid);
  box-shadow: 0 0 16px rgba(233, 255, 112, 0.55);
}

.route__markers {
  display: flex;
  justify-content: space-between;
  margin-top: 7px;
  color: rgba(255, 255, 255, 0.45);
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.route__markers span.active {
  color: var(--acid);
}

.event-callout {
  position: fixed;
  top: 29%;
  left: 50%;
  z-index: 7;
  transform: translate(-50%, -50%) scale(0.88);
  text-align: center;
  opacity: 0;
  pointer-events: none;
}

.event-callout.show {
  animation: callout 1.05s ease both;
}

.event-callout strong {
  display: block;
  color: var(--acid);
  font-size: clamp(30px, 5vw, 64px);
  font-style: italic;
  font-weight: 1000;
  line-height: 0.9;
  text-shadow: 0 5px 0 rgba(0,0,0,.32), 0 0 30px rgba(233,255,112,.35);
}

.event-callout span {
  display: inline-block;
  margin-top: 8px;
  padding: 4px 10px;
  background: rgba(0, 0, 0, 0.62);
  color: #fff;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.16em;
}

@keyframes callout {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(1.35); }
  16%, 68% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -62%) scale(0.95); }
}

.countdown {
  position: fixed;
  inset: 0;
  z-index: 9;
  display: grid;
  place-content: center;
  text-align: center;
  pointer-events: none;
  opacity: 0;
}

body.counting .countdown {
  opacity: 1;
}

.countdown span,
.countdown small {
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.32em;
  text-shadow: 0 2px 12px #000;
}

.countdown strong {
  margin: 8px 0;
  color: var(--acid);
  font-size: clamp(120px, 22vw, 280px);
  font-style: italic;
  font-weight: 1000;
  line-height: 0.72;
  text-shadow: 0 14px 0 rgba(0,0,0,.26), 0 0 70px rgba(233,255,112,.25);
}

.menu-screen,
.results-screen {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(340px, 0.7fr);
  align-items: end;
  gap: 6vw;
  padding: clamp(28px, 6vw, 90px);
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.menu-screen.hidden,
.results-screen {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.results-screen.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.menu-screen__wash {
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(90deg, rgba(5,7,8,.94) 0%, rgba(5,7,8,.64) 42%, rgba(5,7,8,.06) 72%, rgba(5,7,8,.38) 100%);
}

.menu-copy {
  max-width: 760px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--orange);
  font-size: 11px;
  font-weight: 1000;
  letter-spacing: 0.28em;
}

.menu-copy h1 {
  margin: 0;
  font-size: clamp(82px, 13vw, 190px);
  font-style: italic;
  font-weight: 1000;
  line-height: 0.73;
  letter-spacing: 0;
  text-shadow: 0 12px 0 rgba(0,0,0,.25);
}

.lead {
  max-width: 650px;
  margin: 28px 0 0;
  color: #d3d9d7;
  font-size: clamp(16px, 1.7vw, 23px);
  line-height: 1.36;
}

.menu-actions {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-top: 32px;
}

.primary-button,
.text-button {
  pointer-events: auto;
  cursor: pointer;
}

.primary-button {
  min-width: 250px;
  min-height: 56px;
  padding: 0 10px 0 19px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border: 0;
  background: var(--acid);
  color: #111509;
  clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 50%, calc(100% - 14px) 100%, 0 100%);
  font-weight: 1000;
  letter-spacing: 0.06em;
  box-shadow: 0 14px 34px rgba(0,0,0,.28);
}

.primary-button b {
  padding: 7px 13px;
  border: 1px solid rgba(0,0,0,.36);
  font-size: 10px;
}

.primary-button:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.text-button {
  min-height: 48px;
  border: 0;
  border-bottom: 1px solid rgba(255,255,255,.35);
  background: transparent;
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.text-button:hover {
  color: var(--acid);
}

.control-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 9px 18px;
  margin-top: 26px;
  color: #8f9997;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.control-strip b {
  color: #fff;
}

.briefing,
.stage-results {
  align-self: center;
  border-left: 1px solid rgba(255,255,255,.25);
  background: rgba(5,7,8,.38);
  backdrop-filter: blur(9px);
  padding: 0 0 0 20px;
}

.briefing__head {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.13em;
}

.briefing__head b {
  max-width: 250px;
  overflow: hidden;
  color: var(--acid);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stage-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.stage-list li {
  min-height: 74px;
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 12px;
  border-top: 1px solid rgba(255,255,255,.14);
  color: rgba(255,255,255,.58);
}

.stage-list li:last-child {
  border-bottom: 1px solid rgba(255,255,255,.14);
}

.stage-list li > span {
  font-family: "Courier New", monospace;
  font-size: 23px;
}

.stage-list li div {
  display: grid;
  gap: 4px;
}

.stage-list li div b {
  font-size: 15px;
}

.stage-list li div small {
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.1em;
}

.stage-list li i {
  font-size: 8px;
  font-style: normal;
  font-weight: 900;
  letter-spacing: 0.1em;
}

.stage-list li.active {
  color: #fff;
}

.stage-list li.active > span,
.stage-list li.active i {
  color: var(--orange);
}

.record-board {
  margin-top: 18px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.record-board div {
  display: grid;
  gap: 5px;
}

.record-board span {
  color: var(--muted);
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.11em;
}

.record-board b {
  overflow: hidden;
  font-family: "Courier New", monospace;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.results-screen {
  background: linear-gradient(90deg, rgba(5,7,8,.95), rgba(5,7,8,.62) 50%, rgba(5,7,8,.24));
}

.results-main h2 {
  margin: 0;
  font-size: clamp(46px, 7vw, 100px);
  font-style: italic;
  line-height: 0.9;
}

.results-main > p:not(.eyebrow) {
  color: var(--muted);
  font-size: 17px;
}

.result-grade {
  float: left;
  width: clamp(88px, 10vw, 140px);
  margin: 0 22px 12px 0;
  color: var(--acid);
  font-size: clamp(90px, 14vw, 180px);
  font-style: italic;
  font-weight: 1000;
  line-height: 0.72;
  text-shadow: 0 0 44px rgba(233,255,112,.25);
}

.result-stats {
  clear: both;
  max-width: 720px;
  margin-top: 28px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.result-stats div {
  min-height: 78px;
  padding: 15px 14px;
  display: grid;
  gap: 7px;
  border-right: 1px solid var(--line);
}

.result-stats div:first-child { padding-left: 0; }
.result-stats div:last-child { border-right: 0; }

.result-stats span {
  color: var(--muted);
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.result-stats b {
  font-family: "Courier New", monospace;
  font-size: 19px;
}

.stage-results {
  display: grid;
}

.stage-result {
  min-height: 74px;
  display: grid;
  grid-template-columns: 38px 1fr auto;
  align-items: center;
  gap: 12px;
  border-top: 1px solid var(--line);
}

.stage-result:last-child {
  border-bottom: 1px solid var(--line);
}

.stage-result > span {
  color: var(--orange);
  font-family: "Courier New", monospace;
}

.stage-result div {
  display: grid;
  gap: 3px;
}

.stage-result small {
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.1em;
}

.stage-result > b {
  font-family: "Courier New", monospace;
}

.pause-screen {
  position: fixed;
  inset: 0;
  z-index: 12;
  display: grid;
  place-content: center;
  text-align: center;
  background: rgba(3, 5, 6, 0.72);
  backdrop-filter: blur(8px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.pause-screen.show {
  opacity: 1;
  visibility: visible;
}

.pause-screen span {
  color: var(--orange);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.3em;
}

.pause-screen strong {
  margin: 10px 0;
  font-size: clamp(34px, 6vw, 82px);
  font-style: italic;
}

.pause-screen small {
  color: var(--muted);
}

.touch-controls {
  position: fixed;
  inset: auto 12px 14px;
  z-index: 11;
  display: none;
  justify-content: space-between;
  pointer-events: none;
}

.touch-controls div {
  display: flex;
  gap: 8px;
  pointer-events: auto;
}

.touch-controls button {
  width: 54px;
  height: 54px;
  border: 1px solid rgba(255,255,255,.28);
  background: rgba(5,7,8,.56);
  color: #fff;
  backdrop-filter: blur(10px);
  font-size: 25px;
  font-weight: 1000;
}

@media (max-width: 1000px) {
  .metric--wide,
  .brand-mark { display: none; }
  .systems { width: 220px; }
  .route { width: 35vw; }
  .menu-screen,
  .results-screen {
    grid-template-columns: 1fr 320px;
    gap: 28px;
    padding: 42px;
  }
}

@media (max-width: 760px) {
  .cinema { height: 5px; }
  .hud {
    inset: 9px 9px auto;
    grid-template-columns: 1fr auto;
  }
  .race-clock {
    grid-column: 1 / -1;
    grid-row: 1;
    min-width: 190px;
    justify-self: center;
  }
  .telemetry--left { grid-column: 1; grid-row: 2; }
  .telemetry--right { grid-column: 2; grid-row: 2; }
  .telemetry--right .metric:first-child,
  .telemetry--right .icon-button { display: none; }
  .metric { min-width: 68px; min-height: 42px; padding: 6px 8px; }
  .metric strong { font-size: 14px; }
  .speedometer {
    left: 8px;
    bottom: 72px;
    width: 126px;
    height: 88px;
  }
  .speedometer__value { top: 28px; }
  .speedometer__value strong { font-size: 38px; }
  .gear { display: none; }
  .systems {
    right: 8px;
    bottom: 78px;
    width: 150px;
  }
  .route {
    bottom: 68px;
    width: calc(100vw - 190px);
  }
  .route__markers span:nth-child(2),
  .route__markers span:nth-child(4) { display: none; }
  .menu-screen,
  .results-screen {
    grid-template-columns: 1fr;
    align-items: end;
    padding: 24px 20px 32px;
    overflow-y: auto;
  }
  .menu-screen__wash,
  .results-screen {
    background: linear-gradient(0deg, rgba(5,7,8,.97), rgba(5,7,8,.32) 78%, rgba(5,7,8,.1));
  }
  .menu-copy h1 { font-size: clamp(76px, 25vw, 118px); }
  .lead { margin-top: 18px; font-size: 16px; }
  .briefing { display: none; }
  .menu-actions { margin-top: 22px; flex-wrap: wrap; }
  .primary-button { min-width: min(100%, 320px); }
  .control-strip { display: none; }
  .results-screen { align-content: end; }
  .stage-results { display: none; }
  .result-stats { grid-template-columns: 1fr 1fr; }
  .result-stats div:nth-child(2) { border-right: 0; }
  .touch-controls { display: flex; }
  body:not(.racing):not(.counting) .touch-controls { display: none; }
}

@media (max-height: 700px) and (min-width: 761px) {
  .menu-screen { padding-top: 25px; padding-bottom: 25px; }
  .menu-copy h1 { font-size: 92px; }
  .lead { margin-top: 17px; font-size: 16px; }
  .menu-actions { margin-top: 19px; }
  .control-strip { margin-top: 15px; }
  .stage-list li { min-height: 58px; }
}
