* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #07090c; color: #f2f2f2;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; user-select: none; -webkit-user-select: none; touch-action: none; }
#game canvas { display: block; }

#hud { position: fixed; inset: 0; pointer-events: none; text-shadow: 0 1px 3px rgba(0,0,0,.7); }
#top-left { position: absolute; top: 18px; left: 22px; }
#zone { font-size: 22px; font-weight: 700; letter-spacing: .02em; }
#zone.flash { animation: flash 2.5s ease-out; }
@keyframes flash { 0% { opacity: 0; transform: translateY(-6px); } 15% { opacity: 1; transform: none; } }
#clock { font-size: 15px; opacity: .85; margin-top: 2px; font-variant-numeric: tabular-nums; }
#top-right { position: absolute; top: 18px; right: 22px; text-align: right; }
#money { font-size: 24px; font-weight: 700; color: #8fe39a; font-variant-numeric: tabular-nums; }
#fps { font-size: 11px; opacity: .5; }

#minimap { position: absolute; left: 22px; bottom: 22px; width: 180px; height: 180px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,.75); box-shadow: 0 4px 18px rgba(0,0,0,.5); }

#dash { position: absolute; right: 28px; bottom: 26px; width: 230px; text-align: right; }
#speed-wrap { line-height: 1; }
#speed { font-size: 64px; font-weight: 800; font-style: italic; font-variant-numeric: tabular-nums; }
.unit { font-size: 15px; margin-left: 6px; opacity: .8; }
#gear-wrap { margin: 4px 0 8px; }
#gear { font-size: 30px; font-weight: 800; color: #ffd24a; }
#gear-mode { font-size: 11px; margin-left: 8px; opacity: .7; letter-spacing: .1em; }
.bar { height: 8px; background: rgba(255,255,255,.18); border-radius: 4px; overflow: hidden; margin-top: 6px; }
#rpm-fill { height: 100%; width: 0; background: linear-gradient(90deg, #4ad3ff, #ffe14a); }
#rpm-fill.red { background: linear-gradient(90deg, #ffb14a, #ff3b3b); }
#nitro-fill { height: 100%; width: 100%; background: linear-gradient(90deg, #3a6bff, #b04aff); }

#toast { position: absolute; top: 22%; left: 50%; transform: translateX(-50%); padding: 10px 18px; border-radius: 8px;
  background: rgba(0,0,0,.55); font-size: 16px; opacity: 0; transition: opacity .3s; }
#toast.show { opacity: 1; }

#help { position: fixed; top: 70px; left: 22px; padding: 14px 18px; border-radius: 10px; background: rgba(8,10,14,.82);
  display: none; font-size: 14px; }
#help.open { display: block; }
#help h2 { margin: 0 0 8px; font-size: 16px; }
#help dl { display: grid; grid-template-columns: auto auto; gap: 4px 16px; margin: 0; }
#help dt { font-weight: 700; color: #ffd24a; }
#help dd { margin: 0; }

#loading { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 40%, #1d2633, #07090c 70%); transition: opacity .6s; z-index: 10; text-align: center; padding: 20px; }
#loading.hidden { opacity: 0; pointer-events: none; }
#loading h1 { font-size: clamp(40px, 8vw, 84px); font-style: italic; font-weight: 900; margin: 0 0 18px; letter-spacing: -.02em;
  background: linear-gradient(90deg, #ffd24a, #ff5a3c); -webkit-background-clip: text; background-clip: text; color: transparent; }
#loading-status { font-size: 18px; }
body.ready #loading-status { animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .45; } }
.hint { opacity: .6; font-size: 14px; }
#loading-spinner { width: 36px; height: 36px; border: 4px solid rgba(255,255,255,.2); border-top-color: #ffd24a; border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

#touch { display: none; }
@media (pointer: coarse) {
  #touch { display: block; }
  #touch .pad { position: fixed; bottom: 20px; display: flex; gap: 12px; align-items: flex-end; }
  #touch .left { left: 20px; }
  #touch .right { right: 20px; flex-wrap: wrap; justify-content: flex-end; max-width: 300px; }
  #touch button { width: 74px; height: 74px; border-radius: 50%; border: 2px solid rgba(255,255,255,.5); background: rgba(0,0,0,.35);
    color: #fff; font-weight: 800; font-size: 14px; touch-action: none; }
  #touch button.small { width: 56px; height: 56px; font-size: 12px; }
  #touch button.gas { width: 90px; height: 90px; background: rgba(40,160,70,.45); }
  #touch button.on { background: rgba(255,210,74,.55); }
  #minimap { width: 120px; height: 120px; top: 60px; left: 16px; bottom: auto; }
  #dash { bottom: auto; top: 16px; right: 16px; width: 170px; }
  #top-right { top: auto; bottom: 200px; }
  #speed { font-size: 44px; }
}
