:root {
  --bg: rgba(8, 10, 22, 0.72);
  --bg-solid: #0a0c18;
  --line: rgba(0, 240, 255, 0.22);
  --cyan: #00f0ff;
  --pink: #ff2fd0;
  --gold: #ffd84a;
  --text: #dfe7ff;
  --muted: #8a93b8;
  --bad: #ff4d6d;
  --ok: #3dffa8;
  --mono: 'JetBrains Mono', 'SFMono-Regular', Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #05050b; color: var(--text); font-family: var(--mono); }
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#ui { position: fixed; inset: 0; pointer-events: none; }
#ui .ui, #ui button, #ui input { pointer-events: auto; }
body.clean .ui, body.clean .hud-banner { display: none !important; }

/* ---------- loading */
#loading { position: fixed; inset: 0; display: grid; place-content: center; text-align: center; gap: 10px; background: radial-gradient(circle at 50% 40%, #1a1440, #05050b 70%); z-index: 10; transition: opacity .7s; }
#loading.done { opacity: 0; pointer-events: none; }
#loading .logo { font-size: clamp(32px, 7vw, 64px); font-weight: 800; letter-spacing: .12em; background: linear-gradient(90deg, var(--cyan), var(--pink)); -webkit-background-clip: text; background-clip: text; color: transparent; }
#loading .sub { color: var(--muted); letter-spacing: .3em; font-size: 12px; text-transform: uppercase; }
#loading .msg { color: var(--muted); font-size: 12px; max-width: 80vw; }
.spinner { width: 34px; height: 34px; margin: 12px auto; border: 3px solid var(--line); border-top-color: var(--pink); border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- HUD top-left */
.hud-top { position: absolute; top: 14px; left: 16px; display: flex; flex-direction: column; gap: 8px; }
.brand { font-weight: 800; letter-spacing: .14em; font-size: 15px; background: linear-gradient(90deg, var(--cyan), var(--pink)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand small { display: block; font-size: 9px; letter-spacing: .3em; color: var(--muted); -webkit-text-fill-color: var(--muted); font-weight: 400; }
.hud-stats { display: flex; gap: 6px; }
.hud-stats div { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 5px 10px; backdrop-filter: blur(6px); min-width: 58px; }
.hud-stats label { display: block; font-size: 9px; color: var(--muted); letter-spacing: .15em; }
.hud-stats b { font-size: 15px; color: #fff; font-variant-numeric: tabular-nums; }

/* ---------- speed block (bottom-left) */
.hud-speed { position: absolute; left: 16px; bottom: 16px; width: 236px; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 8px; backdrop-filter: blur(6px); transition: box-shadow .2s; }
.hud-speed.boost { box-shadow: 0 0 24px rgba(255, 47, 208, .6); border-color: var(--pink); }
#hud-minimap { width: 100%; height: auto; display: block; border-radius: 6px; }
.speedo { display: flex; align-items: baseline; gap: 8px; margin-top: 4px; }
.speedo b { font-size: 34px; color: #fff; font-variant-numeric: tabular-nums; }
.speedo span { font-size: 10px; color: var(--muted); }
.nitro label { font-size: 9px; color: var(--muted); letter-spacing: .12em; }
.nitro .bar { height: 7px; background: rgba(255,255,255,.08); border-radius: 4px; overflow: hidden; margin-top: 3px; }
.nitro i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--cyan), var(--pink)); box-shadow: 0 0 10px var(--pink); }

.hud-help { position: absolute; left: 50%; transform: translateX(-50%); top: 12px; font-size: 10.5px; color: var(--muted); background: var(--bg); border: 1px solid var(--line); padding: 5px 12px; border-radius: 20px; white-space: nowrap; }
.hud-help b { color: var(--text); }
@media (max-width: 1180px) { .hud-help { display: none; } }

.hud-banner { position: absolute; top: 26%; left: 50%; transform: translate(-50%, -50%) scale(.8); font-size: clamp(22px, 4.5vw, 46px); font-weight: 900; letter-spacing: .12em; opacity: 0; text-shadow: 0 0 18px currentColor; transition: opacity .25s, transform .25s; white-space: nowrap; }
.hud-banner.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.toast { position: absolute; left: 50%; bottom: 50%; transform: translateX(-50%); background: rgba(0,0,0,.8); border: 1px solid var(--cyan); color: #fff; padding: 8px 16px; border-radius: 8px; font-size: 12px; opacity: 0; pointer-events: none; white-space: nowrap; max-width: 92vw; overflow: hidden; text-overflow: ellipsis; }
.toast.show { animation: toast 2.2s ease forwards; }
body.clean .toast.show { animation-duration: 1.3s; }
@keyframes toast { 0% { opacity: 0; transform: translate(-50%, 8px); } 10%, 70% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; } }

/* ---------- critic view bar (top-right) */
.critic-bar { position: absolute; top: 14px; right: 16px; display: flex; flex-direction: column; gap: 5px; width: 228px; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 8px; backdrop-filter: blur(6px); }
.critic-title { font-size: 9px; letter-spacing: .3em; color: var(--muted); padding: 0 2px 2px; }
.critic-btn { display: flex; gap: 8px; align-items: center; background: rgba(255,255,255,.04); color: var(--text); border: 1px solid transparent; border-radius: 7px; padding: 6px 8px; font: 11.5px var(--mono); cursor: pointer; text-align: left; }
.critic-btn:hover { border-color: var(--line); background: rgba(0,240,255,.08); }
.critic-btn.active { border-color: var(--cyan); background: rgba(0,240,255,.16); color: #fff; box-shadow: inset 0 0 12px rgba(0,240,255,.2); }
.critic-btn.wire.active { border-color: var(--bad); background: rgba(255,77,109,.16); }
.critic-btn .k { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 4px; background: rgba(255,255,255,.1); font-size: 10px; color: var(--gold); flex: none; }

/* ---------- diagnostics */
.diag { position: absolute; right: 16px; top: 262px; width: 228px; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; font-size: 10.5px; backdrop-filter: blur(6px); opacity: .8; }
.diag.emph { opacity: 1; border-color: var(--ok); box-shadow: 0 0 18px rgba(61,255,168,.25); }
.diag-title { font-size: 9px; letter-spacing: .25em; color: var(--muted); margin-bottom: 4px; }
.diag-row { display: flex; justify-content: space-between; gap: 6px; padding: 1.5px 0; }
.diag-row span { color: var(--muted); }
.diag-row b { font-weight: 600; color: var(--text); text-align: right; font-variant-numeric: tabular-nums; }
.diag-row b.ok { color: var(--ok); }
.diag-row b.bad { color: var(--bad); }

/* ---------- art director panel (bottom) */
.ad-panel { position: absolute; bottom: 16px; left: 268px; right: 16px; max-width: 980px; margin-left: auto; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px 10px; backdrop-filter: blur(8px); }
.ad-head { display: flex; justify-content: space-between; align-items: center; }
.ad-title { font-size: 10px; letter-spacing: .25em; color: var(--gold); }
.ad-collapse { background: none; border: 0; color: var(--muted); font-size: 16px; cursor: pointer; transition: transform .2s; }
.ad-panel.collapsed .ad-grid, .ad-panel.collapsed .ad-actions { display: none; }
.ad-panel.collapsed .ad-collapse { transform: rotate(180deg); }
.ad-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 3px 18px; margin: 6px 0 8px; }
.ad-row { display: grid; grid-template-columns: 118px 1fr 56px; align-items: center; gap: 8px; font-size: 11px; }
.ad-label { color: var(--text); }
.ad-val { color: var(--cyan); text-align: right; font-variant-numeric: tabular-nums; }
input[type=range] { -webkit-appearance: none; appearance: none; height: 4px; background: linear-gradient(90deg, rgba(0,240,255,.4), rgba(255,47,208,.4)); border-radius: 4px; outline: none; width: 100%; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 0 8px var(--cyan); cursor: pointer; }
input[type=range]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 0; box-shadow: 0 0 8px var(--cyan); cursor: pointer; }
.ad-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.ad-btn { background: rgba(255,255,255,.06); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 7px 12px; font: 11.5px var(--mono); cursor: pointer; }
.ad-btn:hover { background: rgba(0,240,255,.12); }
.ad-btn.primary { border-color: var(--cyan); color: #fff; background: rgba(0,240,255,.14); }
.ad-btn.ghost { border-color: transparent; color: var(--muted); }

/* ---------- touch controls */
.touch { display: none; position: absolute; left: 0; right: 0; bottom: 0; padding: 12px 16px; gap: 10px; align-items: flex-end; }
.touch .sp { flex: 1; }
.touch button { width: 64px; height: 64px; border-radius: 50%; border: 1px solid var(--line); background: rgba(10,12,30,.6); color: #fff; font-size: 20px; touch-action: none; user-select: none; }
.touch button.on { background: rgba(0,240,255,.35); }
@media (pointer: coarse) {
  .touch { display: flex; }
  .hud-speed { bottom: 96px; width: 170px; }
  .ad-panel { display: none; }
  .diag { display: none; }
}
@media (max-width: 760px) {
  .hud-top { left: 16px; right: 16px; }
  .hud-stats div { min-width: 0; padding: 4px 7px; }
  .critic-bar { top: 104px; width: 172px; padding: 6px; gap: 3px; }
  .critic-btn { font-size: 10px; padding: 4px 6px; }
  .ad-panel { left: 16px; bottom: 16px; max-height: 40vh; overflow: auto; }
  .hud-speed { display: none; }
  .diag { display: none; }
}
