:root {
  --glass: rgba(14, 18, 26, 0.46);
  --glass-strong: rgba(14, 18, 26, 0.72);
  --line: rgba(255, 255, 255, 0.14);
  --ink: #fff;
  --muted: rgba(255, 255, 255, 0.68);
  --accent: #ffc477;
  --auto: #7fe3c4;
  --cruise: #8fc4ff;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #0d1016;
  color: var(--ink);
  font-family: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

canvas#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

kbd {
  display: inline-block; min-width: 1.5em; padding: 1px 5px; border-radius: 5px;
  border: 1px solid rgba(255, 255, 255, 0.28); background: rgba(255, 255, 255, 0.08);
  font: 600 10.5px/1.4 ui-monospace, Menlo, monospace; text-align: center; color: #fff;
}

.panel {
  background: var(--glass);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
}

/* ------------------------------------------------------------ HUD */

#hud { position: fixed; inset: 0; pointer-events: none; transition: opacity 0.4s; }
#hud.hidden { opacity: 0; }
#hud button { pointer-events: auto; }

#status {
  position: absolute; top: 18px; right: 18px; padding: 7px 14px;
  font-size: 12.5px; color: var(--muted); display: flex; gap: 8px; font-variant-numeric: tabular-nums;
}
#status i { opacity: 0.5; font-style: normal; }
#clock { color: #fff; font-weight: 600; }

#region {
  position: absolute; top: 14%; left: 50%; transform: translate(-50%, 8px);
  text-align: center; opacity: 0; transition: opacity 1.4s, transform 1.4s; text-shadow: 0 2px 24px rgba(0, 0, 0, 0.45);
}
#region.show { opacity: 1; transform: translate(-50%, 0); }
#region b { display: block; font-size: 40px; font-weight: 600; letter-spacing: 0.04em; }
#region small { display: block; margin-top: 4px; font-size: 12px; letter-spacing: 0.3em; text-transform: uppercase; color: var(--muted); }

#toast {
  position: absolute; top: 62px; left: 50%; transform: translateX(-50%);
  padding: 8px 16px; border-radius: 999px; background: var(--glass-strong); border: 1px solid var(--line);
  font-size: 13px; opacity: 0; transition: opacity 0.3s; white-space: nowrap;
}
#toast.show { opacity: 1; }

#speedo { position: absolute; left: 18px; bottom: 18px; padding: 12px 18px 12px 16px; min-width: 176px; }
#speedo .speed { display: flex; align-items: baseline; gap: 6px; }
#speedo .speed b { font-size: 44px; font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; }
#speedo .speed span { font-size: 12px; color: var(--muted); }
#speedo .row { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: 12px; }
#gear { font-weight: 700; color: var(--muted); min-width: 22px; font-variant-numeric: tabular-nums; }
.badge { padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; letter-spacing: 0.04em; background: rgba(255, 255, 255, 0.12); }
.badge.auto { background: rgba(127, 227, 196, 0.22); color: var(--auto); }
.badge.cruise { background: rgba(143, 196, 255, 0.22); color: var(--cruise); }
#lightsIcon { color: var(--accent); font-size: 14px; }
#lightsIcon.dim { opacity: 0.25; color: #fff; }

#quick {
  position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%);
  display: flex; gap: 2px; padding: 4px;
}
#quick button, #radio button {
  all: unset; cursor: pointer; padding: 7px 11px; border-radius: 10px; font-size: 12.5px; color: var(--muted);
  white-space: nowrap; transition: background 0.2s, color 0.2s;
}
#quick button:hover, #radio button:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
#quick button.on { background: rgba(255, 255, 255, 0.18); color: #fff; }
#quick kbd { margin-left: 4px; opacity: 0.7; }

#radio { position: absolute; right: 18px; bottom: 18px; display: flex; align-items: center; gap: 4px; padding: 6px; max-width: 320px; }
#radio button { font-size: 20px; padding: 4px 10px; }
#radio .info { min-width: 150px; text-align: center; }
#stName { font-size: 13.5px; font-weight: 600; }
#stMeta { font-size: 11px; color: var(--muted); }

#hint {
  position: absolute; left: 50%; bottom: 72px; transform: translateX(-50%);
  font-size: 12px; color: var(--muted); text-shadow: 0 1px 6px rgba(0, 0, 0, 0.6);
  opacity: 0; transition: opacity 1s; white-space: nowrap;
}
#hint.show { opacity: 1; }

/* ------------------------------------------------------------ menu */

#menu {
  position: fixed; inset: 0; z-index: 10; display: grid; place-items: center;
  background: rgba(8, 12, 18, 0.28); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  transition: opacity 0.35s;
}
#menu.hidden { opacity: 0; pointer-events: none; }
#menu.garage {
  justify-items: start; padding-left: 18px;
  background: linear-gradient(90deg, rgba(8, 12, 18, 0.35), transparent 55%);
  backdrop-filter: none; -webkit-backdrop-filter: none;
}
#menu.garage .menu-card { width: min(640px, calc(100vw - 36px)); }
#menu.garage .cars { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }

.menu-card {
  width: min(980px, calc(100vw - 32px)); height: min(640px, calc(100vh - 32px));
  display: grid; grid-template-columns: 210px 1fr;
  background: var(--glass-strong); border: 1px solid var(--line); border-radius: 20px; overflow: hidden;
  backdrop-filter: blur(18px) saturate(1.2); -webkit-backdrop-filter: blur(18px) saturate(1.2);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
}

.menu-nav { display: flex; flex-direction: column; gap: 2px; padding: 22px 14px; border-right: 1px solid var(--line); }
.menu-nav .logo { font-size: 22px; font-weight: 700; padding: 0 10px 18px; }
.menu-nav .logo small { display: block; font-size: 10.5px; font-weight: 500; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); margin-top: 3px; }
.menu-nav button {
  all: unset; cursor: pointer; padding: 9px 12px; border-radius: 10px; font-size: 14px; color: var(--muted);
}
.menu-nav button:hover { background: rgba(255, 255, 255, 0.07); color: #fff; }
.menu-nav button.on { background: rgba(255, 255, 255, 0.14); color: #fff; }
.menu-nav button.primary {
  margin-top: auto; text-align: center; background: #fff; color: #111; font-weight: 600; padding: 12px;
}
.menu-nav button.primary:hover { background: #ffe9c9; }

.menu-body { padding: 26px 30px; overflow-y: auto; }
.menu-body h2 { margin: 0 0 6px; font-size: 26px; }
.menu-body h3 { margin: 22px 0 8px; font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); }
.menu-body h3 small { letter-spacing: 0; text-transform: none; margin-left: 6px; color: #fff; }
.menu-body .lead { font-size: 15px; line-height: 1.55; color: rgba(255, 255, 255, 0.86); max-width: 600px; }
.menu-body .note { font-size: 12.5px; line-height: 1.5; color: var(--muted); margin: 6px 0; max-width: 640px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.chip {
  all: unset; cursor: pointer; padding: 7px 13px; border-radius: 999px; font-size: 13px;
  border: 1px solid var(--line); background: rgba(255, 255, 255, 0.05); color: rgba(255, 255, 255, 0.85);
}
.chip:hover { background: rgba(255, 255, 255, 0.12); }
.chip.on { background: #fff; color: #111; border-color: #fff; }

.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 6px 0 10px; }
.facts div { padding: 12px 14px; border-radius: 12px; background: rgba(255, 255, 255, 0.06); }
.facts b { display: block; font-size: 18px; }
.facts span { font-size: 11.5px; color: var(--muted); }

.cars { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; margin-top: 12px; }
.car {
  all: unset; cursor: pointer; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04); display: flex; flex-direction: column; gap: 5px;
}
.car:hover { background: rgba(255, 255, 255, 0.09); }
.car.on { border-color: var(--accent); background: rgba(255, 196, 119, 0.12); }
.car-name { font-weight: 600; font-size: 15px; }
.car-blurb { font-size: 11.5px; color: var(--muted); line-height: 1.4; min-height: 32px; }
.car-meta { font-size: 11px; color: var(--muted); margin-top: 3px; }
.stat { display: grid; grid-template-columns: 80px 1fr; align-items: center; font-size: 10.5px; color: var(--muted); }
.stat i { height: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.12); overflow: hidden; }
.stat b { display: block; height: 100%; background: var(--accent); }
.paints { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; font-size: 12px; color: var(--muted); }
.swatch { all: unset; cursor: pointer; width: 26px; height: 26px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.35); }
.swatch.on { border-color: #fff; box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.35); }

.looks { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.look {
  all: unset; cursor: pointer; padding: 10px; border-radius: 14px; border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04); display: flex; flex-direction: column; gap: 4px;
}
.look.on { border-color: var(--accent); background: rgba(255, 196, 119, 0.12); }
.look .sw { height: 46px; border-radius: 9px; margin-bottom: 4px; }
.look b { font-size: 14px; }
.look small { font-size: 11.5px; color: var(--muted); line-height: 1.35; }

.stations { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; margin-top: 10px; }
.station {
  all: unset; cursor: pointer; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
}
.station:hover { background: rgba(255, 255, 255, 0.09); }
.station.on { border-color: var(--accent); background: rgba(255, 196, 119, 0.12); }
.station b { display: block; font-size: 13.5px; }
.station small { display: block; font-size: 11.5px; color: var(--muted); margin-top: 3px; line-height: 1.35; }

.slider { display: grid; grid-template-columns: 150px 1fr; align-items: center; gap: 12px; max-width: 520px; margin: 8px 0; font-size: 13px; }
.slider input { accent-color: var(--accent); }

.controls { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 10px; }
.controls table { border-collapse: collapse; font-size: 12.5px; width: 100%; }
.controls th { text-align: left; font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); padding-bottom: 8px; }
.controls td { padding: 5px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.06); }
.controls td:first-child { white-space: nowrap; padding-right: 12px; }

@media (max-width: 900px) {
  #quick kbd, #status i, #hint { display: none; }
  .menu-card { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .menu-nav { flex-direction: row; flex-wrap: wrap; border-right: 0; border-bottom: 1px solid var(--line); padding: 12px; }
  .menu-nav .logo { display: none; }
  .menu-nav button.primary { margin-top: 0; margin-left: auto; }
  .looks, .controls, .facts { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  #radio { display: none; }
  #quick { bottom: 92px; }
}
