:root {
  --bg: #05070b;
  --ink: #e8eef6;
  --muted: #8d9bb0;
  --accent: #37c6ff;
  --accent-2: #ff8a3d;
  --panel: rgba(12, 18, 27, 0.82);
  --line: rgba(120, 160, 200, 0.22);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  overflow: hidden;
}

#app { position: fixed; inset: 0; }
#scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.hidden { display: none !important; }

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(120% 90% at 50% 20%, rgba(20, 40, 70, 0.55), rgba(3, 5, 9, 0.92));
  backdrop-filter: blur(6px);
  z-index: 20;
}

/* ---------------- garage ---------------- */
.garage-inner {
  width: min(1180px, 94vw);
  max-height: 94vh;
  overflow: auto;
  padding: 24px 26px 28px;
}
.garage-head h1 {
  margin: 0;
  font-size: clamp(28px, 4.4vw, 52px);
  letter-spacing: 2px;
  font-weight: 800;
}
.garage-head h1 span {
  font-size: 0.34em;
  letter-spacing: 6px;
  color: var(--accent);
  vertical-align: middle;
  margin-left: 12px;
  font-weight: 600;
}
.garage-head p { margin: 6px 0 20px; color: var(--muted); font-size: 15px; }

.car-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.car-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  background: var(--panel);
  cursor: pointer;
  transition: transform 0.14s ease, border-color 0.14s ease, background 0.14s ease;
}
.car-card:hover { transform: translateY(-3px); }
.car-card.active {
  border-color: var(--accent);
  background: rgba(20, 48, 74, 0.9);
  box-shadow: 0 0 0 1px rgba(55, 198, 255, 0.35), 0 12px 30px rgba(0, 0, 0, 0.45);
}
.car-swatch {
  height: 54px;
  border-radius: 10px;
  margin-bottom: 10px;
  background: linear-gradient(135deg, var(--c1), var(--c2));
  position: relative;
  overflow: hidden;
}
.car-swatch::after {
  content: "";
  position: absolute;
  left: 12%;
  right: 12%;
  top: 46%;
  height: 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.32);
}
.car-card h3 { margin: 0; font-size: 17px; }
.car-card .en { color: var(--muted); font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; }
.car-card .tags { margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap; }
.car-card .tags span {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(120, 160, 200, 0.16);
  color: #b9c8da;
}

.car-detail {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  padding: 16px 18px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px 20px;
  align-items: center;
}
.detail-stats { display: flex; flex-wrap: wrap; gap: 10px 22px; }
.stat { font-size: 13px; color: var(--muted); }
.stat b { display: block; color: var(--ink); font-size: 19px; font-weight: 700; }
.stat .bar { width: 120px; height: 5px; border-radius: 4px; background: rgba(255, 255, 255, 0.14); margin-top: 5px; }
.stat .bar i { display: block; height: 100%; border-radius: 4px; background: var(--accent); }
.detail-hint { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; color: var(--muted); font-size: 13px; }
.detail-hint b { color: var(--ink); }
.detail-hint span, .detail-hint .key-space, .detail-hint .key-r {
  padding: 4px 9px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  color: #cddbe9;
}
.key-space { border-color: rgba(55, 198, 255, 0.5) !important; color: var(--accent) !important; }
.key-r { color: var(--accent-2) !important; }
.pad-hint { margin-top: -4px; }
.pad-state { border-style: dashed; color: #7d8fa2 !important; }
.pad-state.on { border-style: solid; border-color: rgba(47, 227, 176, 0.55) !important; color: #2fe3b0 !important; }
.next-weather { grid-column: 1 / -1; margin: 0; color: var(--muted); font-size: 13px; }

.btn-primary {
  grid-row: span 2;
  padding: 15px 40px;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 3px;
  border: none;
  border-radius: 12px;
  color: #04121c;
  background: linear-gradient(135deg, #6ad8ff, #2f9bff);
  cursor: pointer;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost {
  padding: 13px 24px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  font-size: 15px;
  cursor: pointer;
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.07); }

/* ---------------- hud ---------------- */
.hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.hud-row { display: flex; gap: 10px; justify-content: space-between; }
.chip {
  font-size: 13px;
  padding: 7px 13px;
  border-radius: 999px;
  background: rgba(6, 12, 20, 0.62);
  border: 1px solid rgba(140, 180, 220, 0.2);
  color: #cfe0f2;
  letter-spacing: 0.4px;
}
.chip-progress { font-variant-numeric: tabular-nums; }

.nitro-gauge {
  position: absolute;
  left: 50%;
  bottom: 92px;
  transform: translateX(-50%);
  width: 260px;
  text-align: center;
}
.nitro-label {
  font-size: 11px;
  letter-spacing: 4px;
  color: var(--accent);
  margin-bottom: 5px;
}
.nitro-bar {
  height: 10px;
  border-radius: 6px;
  background: rgba(8, 16, 26, 0.7);
  border: 1px solid rgba(55, 198, 255, 0.35);
  overflow: hidden;
}
.nitro-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #1f7fff, #64e6ff, #ffffff);
  transition: width 0.1s linear;
}
.nitro-gauge.boosting .nitro-bar { box-shadow: 0 0 22px rgba(90, 220, 255, 0.85); }
.nitro-hint { margin-top: 5px; font-size: 11px; color: var(--muted); letter-spacing: 2px; }

.toast-layer {
  position: absolute;
  left: 50%;
  top: 22%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.toast {
  padding: 9px 20px;
  border-radius: 999px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 1px;
  background: rgba(6, 14, 24, 0.72);
  border: 1px solid rgba(55, 198, 255, 0.45);
  color: #bfeaff;
  animation: toastIn 0.24s ease-out, toastOut 0.5s ease-in 1.5s forwards;
}
.toast.warn { border-color: rgba(255, 138, 61, 0.55); color: #ffd0a8; }
.toast.gold { border-color: rgba(255, 214, 102, 0.6); color: #ffe9a8; }
@keyframes toastIn { from { opacity: 0; transform: translateY(14px) scale(0.94); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-16px); } }

.damage-flash {
  position: absolute;
  inset: 0;
  background: radial-gradient(120% 100% at 50% 50%, transparent 45%, rgba(255, 60, 40, 0.55));
  opacity: 0;
  transition: opacity 0.25s ease-out;
}
.damage-flash.on { opacity: 1; transition: opacity 0.05s; }

/* ---------------- result ---------------- */
.result-card {
  width: min(520px, 90vw);
  padding: 26px 28px;
  border-radius: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  text-align: center;
}
.result-card h2 { margin: 0 0 16px; font-size: 30px; letter-spacing: 3px; }
.result-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
.result-stats div {
  padding: 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  font-size: 13px;
  color: var(--muted);
}
.result-stats b { display: block; font-size: 22px; color: var(--ink); margin-top: 4px; font-variant-numeric: tabular-nums; }
.result-actions { display: flex; gap: 10px; justify-content: center; }

@media (max-width: 720px) {
  .car-detail { grid-template-columns: 1fr; }
  .btn-primary { grid-row: auto; width: 100%; }
  .nitro-gauge { width: 200px; bottom: 76px; }
}
