/* ============================================================
   NEON GRID — HUD / overlays
   ============================================================ */
:root {
  --bg: #0a0d13;
  --panel: rgba(12, 16, 24, 0.55);
  --panel-brd: rgba(140, 190, 255, 0.14);
  --txt: #dfe8f5;
  --dim: #7d8ca3;
  --acc: #4fd1ff;
  --acc2: #ff2d55;
  --good: #3ddc97;
  --warn: #ffd166;
  --font: "SF Mono", "JetBrains Mono", "Fira Code", ui-monospace, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%; height: 100%;
  background: var(--bg);
  color: var(--txt);
  font-family: var(--font);
  overflow: hidden;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

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

.hidden { display: none !important; }

/* ---------------- HUD ---------------- */
#hud {
  position: absolute; inset: 0;
  pointer-events: none;
  font-size: 11px;
  letter-spacing: 0.04em;
}

.panel {
  position: absolute;
  background: var(--panel);
  border: 1px solid var(--panel-brd);
  border-radius: 10px;
  backdrop-filter: blur(9px) saturate(1.2);
  -webkit-backdrop-filter: blur(9px) saturate(1.2);
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.35);
  padding: 10px 12px;
}

.topleft { top: 12px; left: 12px; min-width: 168px; }

.district {
  font-size: 12px; font-weight: 700; color: var(--acc);
  letter-spacing: 0.16em; margin-bottom: 8px;
  text-shadow: 0 0 14px rgba(79, 209, 255, 0.45);
  white-space: nowrap;
}

/* the road you are currently on, coloured to match the minimap */
.roadtag {
  display: inline-block; margin-bottom: 8px; padding: 2px 8px;
  border: 1px solid var(--panel-brd); border-radius: 999px;
  font-size: 9px; letter-spacing: 0.18em; color: var(--dim);
  background: rgba(255, 255, 255, 0.04);
}
.roadtag span { color: var(--txt); }

.stats { display: grid; grid-template-columns: 1fr; gap: 2px; }
.stats > div { display: flex; justify-content: space-between; gap: 14px; }
.stats i { font-style: normal; color: var(--dim); }
.stats b { font-weight: 600; color: var(--txt); font-variant-numeric: tabular-nums; }

.topright { top: 12px; right: 12px; }
.helpkeys { color: var(--dim); line-height: 1.85; white-space: nowrap; }
.helpkeys kbd {
  display: inline-block; padding: 0 4px; margin-right: 2px;
  border: 1px solid rgba(160, 200, 255, 0.2); border-radius: 4px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--txt); font-size: 10px; font-family: inherit;
}

/* ---------------- speedometer ---------------- */
.speedo {
  position: absolute; bottom: 8px; left: 50%;
  transform: translateX(-50%);
  width: 250px; text-align: center;
  filter: drop-shadow(0 6px 20px rgba(0, 0, 0, 0.5));
}
.speedo svg { width: 250px; height: 146px; overflow: visible; }
.rpm-track { fill: none; stroke: rgba(150, 190, 240, 0.16); stroke-width: 9; stroke-linecap: round; }
.rpm-fill  { fill: none; stroke: url(#rpmGrad); stroke-width: 9; stroke-linecap: round; }
.ticks line { stroke: rgba(190, 220, 255, 0.45); stroke-width: 2; }
.ticks line.major { stroke: rgba(230, 245, 255, 0.8); stroke-width: 2.5; }
.ticks text { fill: var(--dim); font-size: 9px; font-family: var(--font); text-anchor: middle; }

.readout { margin-top: -34px; }
.speed b {
  font-size: 44px; font-weight: 700; line-height: 0.9;
  font-variant-numeric: tabular-nums; letter-spacing: -0.02em;
}
.speed span { font-size: 11px; color: var(--dim); margin-left: 5px; letter-spacing: 0.12em; }
.gearline { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 6px; }
.gear {
  display: inline-block; min-width: 26px; padding: 1px 6px;
  border: 1px solid rgba(160, 200, 255, 0.25); border-radius: 5px;
  font-size: 13px; font-weight: 700; color: var(--acc);
}
.damage { display: flex; align-items: center; gap: 6px; }
.damage i { font-style: normal; font-size: 9px; color: var(--dim); letter-spacing: 0.12em; }
.bar { width: 84px; height: 6px; border-radius: 4px; background: rgba(255, 255, 255, 0.09); overflow: hidden; }
.bar .fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--good), var(--warn), var(--acc2)); transition: width 0.15s linear; }

/* ---------------- minimap ---------------- */
.mapwrap { bottom: 12px; right: 12px; padding: 8px; }
#minimap { display: block; width: 162px; height: 162px; border-radius: 6px; }
.maptitle { margin-top: 6px; text-align: center; font-size: 9px; color: var(--dim); letter-spacing: 0.2em; }

/* ---------------- toast ---------------- */
#toast {
  position: absolute; top: 76px; left: 50%; transform: translateX(-50%);
  padding: 8px 18px; border-radius: 999px;
  background: rgba(12, 18, 28, 0.72); border: 1px solid var(--panel-brd);
  backdrop-filter: blur(8px);
  font-size: 12px; letter-spacing: 0.1em; opacity: 0;
  transition: opacity 0.35s ease; white-space: nowrap;
}
#toast.show { opacity: 1; }

/* ---------------- overlays ---------------- */
.overlay {
  position: absolute; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 40%, rgba(18, 28, 46, 0.86), rgba(4, 6, 10, 0.95));
  backdrop-filter: blur(6px);
}
.ovcard {
  text-align: center; padding: 34px 40px; max-width: 560px;
  border: 1px solid var(--panel-brd); border-radius: 16px;
  background: rgba(10, 14, 22, 0.6);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.6);
}
.ovcard.small { padding: 26px 34px; }
.ovcard h1 {
  font-size: 52px; letter-spacing: 0.14em; font-weight: 800;
  background: linear-gradient(92deg, #4fd1ff, #b06cff 55%, #ff2d55);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 26px rgba(79, 209, 255, 0.3));
}
.ovcard h2 { font-size: 22px; letter-spacing: 0.2em; margin-bottom: 18px; }
.tag { color: var(--dim); margin: 6px 0 22px; font-size: 12px; letter-spacing: 0.06em; }

.ctrlgrid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 7px 22px;
  margin-bottom: 22px; font-size: 11px; color: var(--dim); text-align: left;
}
.ctrlgrid kbd, .optrow kbd {
  display: inline-block; min-width: 20px; text-align: center;
  padding: 2px 5px; margin-right: 4px;
  border: 1px solid rgba(160, 200, 255, 0.22); border-radius: 4px;
  background: rgba(255, 255, 255, 0.05); color: var(--txt); font-size: 10px;
}

.optrow { display: flex; gap: 18px; justify-content: center; margin-bottom: 22px; }
.optrow label { font-size: 10px; color: var(--dim); letter-spacing: 0.14em; display: block; }
select {
  margin-top: 5px; display: block; background: #10151f; color: var(--txt);
  border: 1px solid var(--panel-brd); border-radius: 6px;
  padding: 6px 10px; font-family: inherit; font-size: 11px; cursor: pointer;
}

.cta {
  display: block; width: 100%; padding: 13px 0; margin-bottom: 10px;
  font-family: inherit; font-size: 14px; font-weight: 700; letter-spacing: 0.24em;
  color: #04121a; cursor: pointer; border: 0; border-radius: 10px;
  background: linear-gradient(92deg, #4fd1ff, #7ee7ff);
  box-shadow: 0 10px 30px rgba(79, 209, 255, 0.25);
  transition: transform 0.12s ease, box-shadow 0.2s ease, filter 0.2s;
}
.cta:hover { transform: translateY(-1px); filter: brightness(1.08); }
.cta:active { transform: translateY(1px); }
.cta.ghost {
  background: transparent; color: var(--txt);
  border: 1px solid var(--panel-brd); box-shadow: none; font-size: 11px; padding: 9px 0;
}
.tiny { font-size: 10px; color: var(--dim); letter-spacing: 0.12em; margin-top: 4px; }

/* ---------------- touch ---------------- */
#touch { position: absolute; inset: 0; z-index: 15; pointer-events: none; }
#touch .tleft, #touch .tright {
  position: absolute; bottom: 26px; display: flex; gap: 12px; pointer-events: auto;
}
#touch .tleft { left: 18px; }
#touch .tright { right: 18px; align-items: flex-end; }
.tbtn {
  width: 74px; height: 74px; border-radius: 50%;
  background: rgba(16, 22, 34, 0.6); border: 1px solid rgba(140, 190, 255, 0.22);
  color: var(--txt); font-family: inherit; font-size: 11px; letter-spacing: 0.06em;
  backdrop-filter: blur(6px); cursor: pointer;
}
.tbtn.big { width: 92px; height: 92px; font-size: 13px; font-weight: 700; }
.tbtn:active { background: rgba(79, 209, 255, 0.28); }

@media (max-width: 760px) {
  .topright, .mapwrap { display: none; }
  .speedo { transform: translateX(-50%) scale(0.8); transform-origin: bottom center; }
}