:root {
  --ink: #17161c;
  --panel: rgba(23, 22, 28, 0.74);
  --card: #24232c;
  --line: #3a3844;
  --muted: #b9b6c6;
  --text: #ffffff;
  --gold: #ffd35c;
  --good: #7fdc9a;
  --bad: #ff9a8b;
  --font: ui-rounded, "SF Pro Rounded", "Trebuchet MS", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--ink);
  color: var(--text);
  font-family: var(--font);
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

#stage,
#stage canvas {
  position: fixed;
  inset: 0;
  display: block;
}

#huds {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  pointer-events: none;
}

/* In-game display */

.hud {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.hud + .hud {
  border-top: 3px solid var(--ink);
}

.gauges,
.car-status {
  position: absolute;
  top: 12px;
  border-radius: 14px;
  background: var(--panel);
}

.gauges {
  left: 12px;
  width: 236px;
  padding: 8px 14px 12px;
}

.speed-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.speed {
  font-size: 46px;
  font-weight: 700;
  line-height: 1.1;
}

.unit {
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
}

.gear {
  margin-left: auto;
  color: var(--gold);
  font-size: 36px;
  font-weight: 700;
}

.meter {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 8px;
  align-items: center;
  margin-top: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.track {
  height: 11px;
  overflow: hidden;
  border-radius: 5px;
  background: #34323d;
}

.fill {
  height: 100%;
  border-radius: 5px;
}

.car-status {
  right: 12px;
  width: 132px;
  padding: 8px 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-align: center;
}

.car-status svg {
  display: block;
  width: 100%;
  height: auto;
  margin: 4px 0;
}

.standing {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 16px;
  border-radius: 12px;
  background: var(--panel);
  font-size: 22px;
  font-weight: 700;
  white-space: nowrap;
}

.alert,
.toasts,
.countdown {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 90%;
  text-align: center;
  text-shadow: 0 2px 0 var(--ink), 0 0 10px var(--ink);
}

.alert {
  top: 74px;
  color: var(--gold);
  font-size: 30px;
  font-weight: 700;
}

.toasts {
  top: 118px;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.35;
}

.countdown {
  top: 32%;
  font-size: 130px;
  font-weight: 700;
}

.hud.split .gauges {
  top: 6px;
  left: 6px;
  width: 200px;
  padding: 2px 10px 8px;
}

.hud.split .speed {
  font-size: 30px;
}

.hud.split .gear {
  font-size: 24px;
}

.hud.split .car-status {
  top: 6px;
  right: 6px;
  width: 92px;
  padding: 4px 6px;
}

.hud.split .standing {
  top: 6px;
  font-size: 18px;
}

.hud.split .alert {
  top: 46px;
  font-size: 22px;
}

.hud.split .toasts {
  top: 78px;
  font-size: 16px;
}

.hud.split .countdown {
  top: 16%;
  font-size: 90px;
}

@media (max-width: 900px) {
  .gauges {
    width: 190px;
    padding: 4px 10px 8px;
  }

  .speed {
    font-size: 34px;
  }

  .gear {
    font-size: 28px;
  }

  .meter {
    grid-template-columns: 78px 1fr;
    font-size: 10px;
  }

  .car-status {
    width: 96px;
    padding: 4px 6px;
  }

  .standing {
    top: 126px;
    left: 12px;
    transform: none;
    font-size: 16px;
  }

  .alert {
    top: 166px;
    font-size: 22px;
  }

  .toasts {
    top: 200px;
    font-size: 16px;
  }

  .hud.split .standing {
    top: auto;
    bottom: 6px;
    left: 6px;
  }
}

/* Touch buttons */

#touch {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.pad {
  position: absolute;
  display: grid;
  place-items: center;
  width: 96px;
  height: 96px;
  border: 3px solid rgba(255, 255, 255, 0.55);
  border-radius: 50%;
  background: rgba(30, 30, 40, 0.34);
  color: var(--text);
  font: 700 18px var(--font);
  pointer-events: auto;
  touch-action: none;
}

.pad.down {
  background: rgba(255, 255, 255, 0.38);
}

.pad.small {
  width: 66px;
  height: 66px;
  font-size: 12px;
}

.pad[hidden] {
  display: none;
}

/* Menus */

#screen {
  position: fixed;
  inset: 0;
  overflow-y: auto;
  touch-action: pan-y;
}

#screen:empty {
  display: none;
}

.menu,
.result {
  min-height: 100%;
  padding: 16px;
  background: var(--ink);
}

.menu-inner,
.result-inner {
  max-width: 1040px;
  margin: 0 auto;
}

.top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.back {
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
}

h1 {
  margin: 4px 0 0;
  color: var(--gold);
  font-size: clamp(32px, 6vw, 46px);
  line-height: 1.1;
  text-align: center;
}

.tagline {
  margin: 4px 0 12px;
  color: var(--muted);
  text-align: center;
}

.choices {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
  justify-content: center;
  margin-bottom: 8px;
}

.choice-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.choice-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.chip {
  padding: 8px 14px;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--text);
  font: 700 15px var(--font);
  cursor: pointer;
}

.chip.active {
  border-color: var(--gold);
  background: var(--gold);
  color: var(--ink);
}

.note {
  min-height: 20px;
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.cars {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 10px;
}

.car-card {
  position: relative;
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 10px;
  padding: 10px;
  border: 3px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.car-card.selected {
  border-color: var(--gold);
}

.car-card img {
  width: 112px;
  height: 80px;
  border-radius: 8px;
  object-fit: cover;
  background: #2f2e39;
}

.car-name {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 18px;
  font-weight: 700;
}

.car-class {
  color: var(--gold);
  font-size: 13px;
  white-space: nowrap;
}

.car-stats {
  color: #d6d3e0;
  font-size: 13px;
}

.car-plus {
  color: var(--good);
  font-size: 13px;
}

.car-minus {
  color: var(--bad);
  font-size: 13px;
}

.badge {
  position: absolute;
  top: 6px;
  left: 6px;
  padding: 2px 8px;
  border-radius: 8px;
  background: var(--gold);
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.menu-bottom {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
}

.help {
  flex: 1 1 340px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.go {
  padding: 14px 44px;
  border: 0;
  border-radius: 12px;
  background: var(--gold);
  color: var(--ink);
  font: 700 24px var(--font);
  cursor: pointer;
}

.go.plain {
  background: var(--muted);
}

.result {
  display: grid;
  place-items: center;
}

.result-inner {
  width: 100%;
  max-width: 620px;
  text-align: center;
}

.result h2 {
  margin: 0;
  color: var(--gold);
  font-size: clamp(38px, 8vw, 62px);
}

.result h2.lost {
  color: var(--bad);
}

.why {
  margin: 8px 0 18px;
  color: #d6d3e0;
  font-size: 18px;
}

.standings {
  margin: 0 0 22px;
  padding: 0;
  list-style: none;
}

.standings li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 19px;
  font-weight: 700;
}

.standings li.you {
  color: var(--gold);
}

.standings span {
  color: var(--muted);
  font-size: 14px;
  font-weight: 400;
}

.result-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
}

.pause {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(23, 22, 28, 0.6);
  font-size: 34px;
  font-weight: 700;
  pointer-events: none;
}

.pause[hidden] {
  display: none;
}
