:root {
  --rust: #b5522a;
  --fire1: #ffd24a;
  --fire2: #f2711c;
  --fire3: #c0281b;
  --ink: #2a1408;
  --panel: rgba(30, 16, 8, 0.72);
  --cream: #fff3dc;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #c9a46a; font-family: 'Rajdhani', system-ui, sans-serif; color: var(--cream); user-select: none; }
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }

/* ---------- HUD */
#hud { position: fixed; inset: 0; pointer-events: none; }
.panel { background: var(--panel); border: 2px solid rgba(255, 210, 74, 0.35); border-radius: 10px; padding: 8px 14px; backdrop-filter: blur(3px); }
#hud-left { position: absolute; top: 14px; left: 14px; min-width: 150px; }
.driver { font-family: 'Bungee', sans-serif; font-size: 13px; letter-spacing: 2px; color: var(--fire1); }
#timer { font-family: 'Bungee', sans-serif; font-size: 40px; line-height: 1.05; }
#timer.warn { color: #ff5a3c; animation: pulse 0.5s ease-in-out infinite alternate; }
@keyframes pulse { to { transform: scale(1.07); } }
#stats { font-size: 15px; opacity: 0.9; }
#arrow-wrap { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 2px; }
#arrow { width: 44px; height: 44px; filter: drop-shadow(0 2px 2px rgba(0,0,0,.5)); }
#dist { font-family: 'Bungee', sans-serif; font-size: 14px; background: var(--panel); padding: 2px 10px; border-radius: 6px; }
#minimap { position: absolute; top: 14px; right: 14px; width: 180px; height: 180px; border-radius: 50%; box-shadow: 0 0 0 3px rgba(255,210,74,.5), 0 4px 14px rgba(0,0,0,.4); }
#hud-bottom { position: absolute; bottom: 14px; left: 14px; display: flex; flex-direction: column; gap: 4px; min-width: 170px; }
#speed { font-family: 'Bungee', sans-serif; font-size: 34px; line-height: 1; }
#speed small { font-family: 'Rajdhani'; font-size: 14px; margin-left: 6px; opacity: .8; }
#health { position: relative; height: 16px; margin-top: 6px; background: rgba(255,255,255,.15); border-radius: 5px; overflow: hidden; }
#health-fill { height: 100%; width: 100%; background: #6fd04a; transition: width .2s; }
#health-fill.mid { background: #e8b83a; }
#health-fill.low { background: #e5432c; animation: pulse 0.4s ease-in-out infinite alternate; }
#health-val { position: absolute; inset: 0; text-align: center; font-family: 'Bungee', sans-serif; font-size: 11px; line-height: 16px; color: #fff; text-shadow: 0 1px 0 #000; }
#health.hit { animation: hit .3s; }
@keyframes hit { 0%, 60% { box-shadow: inset 0 0 0 2px #ff3a1a; } 100% { box-shadow: none; } }
#nitro { height: 10px; background: rgba(255,255,255,.15); border-radius: 5px; overflow: hidden; }
#nitro-fill { height: 100%; width: 100%; background: linear-gradient(90deg, var(--fire3), var(--fire2), var(--fire1)); }
.nitro-label { font-size: 12px; letter-spacing: 1px; opacity: .75; }
#seed-tag { position: absolute; bottom: 14px; right: 14px; font-size: 13px; opacity: .8; background: var(--panel); padding: 3px 10px; border-radius: 6px; }
#toast { position: absolute; top: 34%; left: 50%; transform: translate(-50%, -50%); font-family: 'Bungee', sans-serif; font-size: 26px; color: var(--fire1); text-shadow: 0 3px 0 var(--ink), 0 0 12px rgba(0,0,0,.5); opacity: 0; transition: opacity .25s; white-space: nowrap; }
#toast.show { opacity: 1; }

#bubble { position: fixed; transform: translate(-50%, -100%); background: #fff; color: #222; font-weight: 700; font-size: 20px; padding: 10px 16px; border-radius: 16px; border: 3px solid #222; white-space: nowrap; pointer-events: none; animation: pop .25s ease-out; }
#bubble::after { content: ''; position: absolute; left: 50%; bottom: -14px; transform: translateX(-50%); border: 9px solid transparent; border-top-color: #222; }
@keyframes pop { from { transform: translate(-50%, -100%) scale(.4); } }

#countdown { position: fixed; top: 40%; left: 50%; transform: translate(-50%, -50%); font-family: 'Bungee', sans-serif; font-size: 120px; color: var(--fire1); text-shadow: 0 6px 0 var(--fire3), 0 10px 20px rgba(0,0,0,.4); pointer-events: none; }
#countdown.tick { animation: tick .6s ease-out; }
@keyframes tick { from { transform: translate(-50%, -50%) scale(1.8); opacity: 0; } 30% { opacity: 1; } }

/* ---------- screens */
.screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px; background: radial-gradient(ellipse at center, rgba(40,18,6,.35), rgba(40,18,6,.75)); }
#title.screen { background: linear-gradient(180deg, rgba(40,18,6,.15), rgba(40,18,6,.55)); }
.card { background: rgba(30, 14, 6, 0.86); border: 3px solid var(--rust); border-radius: 16px; padding: 26px 30px; max-width: 560px; width: 100%; text-align: center; box-shadow: 0 16px 40px rgba(0,0,0,.45); }
.logo { display: flex; flex-direction: column; line-height: .95; margin-bottom: 10px; }
.logo span { font-family: 'Bungee', sans-serif; background: linear-gradient(180deg, var(--fire1), var(--fire2) 55%, var(--fire3)); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 4px 0 var(--ink)); }
.logo .l1 { font-size: clamp(30px, 8vw, 54px); }
.logo .l2 { font-size: clamp(38px, 11vw, 72px); letter-spacing: 2px; }
.tag { font-size: 18px; margin: 6px 0 16px; }
h2 { font-family: 'Bungee', sans-serif; font-size: 40px; margin: 0 0 10px; }
h2.bad { color: #ff6a4a; }
h2.good { color: var(--fire1); }
.row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 10px 0; }
.row.small { font-size: 16px; align-items: center; }
button { font-family: 'Bungee', sans-serif; cursor: pointer; border: none; border-radius: 10px; color: var(--ink); transition: transform .08s; }
button:hover { transform: translateY(-2px); }
button:active { transform: translateY(1px); }
button.big { font-size: 22px; padding: 14px 30px; background: linear-gradient(180deg, var(--fire1), var(--fire2)); box-shadow: 0 5px 0 var(--fire3); }
button.ghost { font-size: 14px; padding: 9px 16px; background: rgba(255,243,220,.12); color: var(--cream); border: 2px solid rgba(255,243,220,.3); }
input { font-family: 'Rajdhani'; font-size: 16px; width: 120px; padding: 6px 8px; border-radius: 6px; border: 2px solid rgba(255,243,220,.3); background: rgba(0,0,0,.3); color: var(--cream); }
.controls { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 16px; text-align: left; font-size: 15px; margin-top: 16px; opacity: .9; }
kbd { display: inline-block; font-family: 'Rajdhani'; font-weight: 700; font-size: 12px; min-width: 22px; text-align: center; padding: 1px 5px; margin-right: 3px; border-radius: 4px; background: var(--cream); color: var(--ink); box-shadow: 0 2px 0 #9a8060; }
blockquote { font-size: 30px; font-weight: 700; margin: 10px 0 0; color: #fff; }
.by { font-size: 16px; opacity: .75; margin-bottom: 10px; }
#over-reason { opacity: .85; }
#stars { font-size: 44px; color: var(--fire1); letter-spacing: 6px; }
#win-stats { font-size: 18px; line-height: 1.5; margin: 8px 0; }

@media (max-width: 640px) {
  #minimap { width: 110px; height: 110px; }
  #timer { font-size: 30px; }
  .controls { grid-template-columns: 1fr; }
  #countdown { font-size: 80px; }
}
