:root {
  color-scheme: dark;
  --ink: #e8eef2;
  --accent: #4fc3ff;
  --panel: rgba(8, 12, 18, 0.55);
  --edge: rgba(120, 170, 210, 0.25);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; background: #05080c; }
body {
  font-family: "Avenir Next", "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
#app { position: fixed; inset: 0; }
#gl { display: block; width: 100%; height: 100%; }
.hidden { display: none !important; }

/* ---------- menu ---------- */
.overlay {
  position: absolute; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(120% 120% at 50% 0%, rgba(10, 20, 34, 0.25), rgba(3, 6, 10, 0.82));
  backdrop-filter: blur(2px);
}
.menu-inner { text-align: center; padding: 24px; }
.title {
  font-size: clamp(44px, 7vw, 84px); letter-spacing: 0.22em; font-weight: 800;
  background: linear-gradient(180deg, #ffffff, #9fd4ff 65%, #4a90c2);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 0 60px rgba(80, 160, 255, 0.25);
}
.subtitle { margin: 10px 0 34px; color: #9db4c4; letter-spacing: 0.3em; font-size: 13px; }
.cards { display: flex; gap: 22px; justify-content: center; flex-wrap: wrap; }
.card {
  width: 320px; border: 1px solid var(--edge); border-radius: 14px;
  background: var(--panel); overflow: hidden; cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
  text-align: left; color: var(--ink);
}
.card:hover { transform: translateY(-6px) scale(1.015); border-color: var(--accent); box-shadow: 0 18px 50px rgba(40, 130, 220, 0.28); }
.card canvas { display: block; width: 100%; height: 150px; }
.card .meta { padding: 14px 16px 16px; }
.card h3 { font-size: 18px; letter-spacing: 0.08em; }
.card p { font-size: 12px; color: #8fa6b6; margin-top: 6px; line-height: 1.5; }
.hint { margin-top: 34px; color: #6d8290; font-size: 12px; letter-spacing: 0.12em; }

/* ---------- HUD ---------- */
#hud { position: absolute; inset: 0; pointer-events: none; z-index: 10; }
#hud-track {
  position: absolute; top: 22px; left: 28px;
  font-size: 15px; letter-spacing: 0.28em; color: #cfe3ef;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
}
#hud-laps {
  position: absolute; top: 52px; left: 28px; font-variant-numeric: tabular-nums;
  background: var(--panel); border: 1px solid var(--edge); border-radius: 10px;
  padding: 10px 14px; min-width: 190px;
}
.lap-line { display: flex; justify-content: space-between; gap: 18px; line-height: 1.7; font-size: 13px; }
.lap-line .k { color: #7f97a8; letter-spacing: 0.1em; }
.lap-line .v { font-weight: 600; }
#lap-best.v { color: #ffd76a; }
#hud-speed {
  position: absolute; right: 30px; bottom: 26px; text-align: right;
  font-variant-numeric: tabular-nums; text-shadow: 0 2px 12px rgba(0, 0, 0, 0.65);
}
#hud-gear {
  font-size: 40px; font-weight: 800; color: var(--accent); line-height: 1;
  letter-spacing: 0.05em; text-shadow: 0 0 24px rgba(79, 195, 255, 0.55);
}
#hud-speed > div:last-child { font-size: 52px; font-weight: 800; line-height: 1.05; }
#hud-speed .unit { font-size: 14px; font-weight: 500; color: #9db4c4; margin-left: 6px; letter-spacing: 0.15em; }
#hud-hint {
  position: absolute; bottom: 22px; left: 50%; transform: translateX(-50%);
  font-size: 12px; color: #7e93a2; letter-spacing: 0.14em;
  background: var(--panel); padding: 6px 14px; border-radius: 8px; border: 1px solid var(--edge);
  opacity: 0.85;
}
#hud-debug {
  position: absolute; top: 22px; right: 28px; font-size: 11px; color: #8fd0a0;
  font-family: ui-monospace, "SF Mono", Menlo, monospace; text-align: right;
  background: rgba(0, 0, 0, 0.45); padding: 6px 10px; border-radius: 6px; line-height: 1.6;
}

#fatal {
  position: absolute; inset: 0; z-index: 40; display: flex;
  align-items: center; justify-content: center; padding: 40px;
  background: #0a0d12; color: #ff8080; font-family: ui-monospace, Menlo, monospace;
  font-size: 14px; white-space: pre-wrap; text-align: center;
}
