:root {
  --orange: #f47b1e;
  --sky: #87d3f2;
  --dark: #2a1a0e;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%; height: 100%; overflow: hidden; background: var(--sky); }
body { font-family: 'Bricolage Grotesque', sans-serif; -webkit-tap-highlight-color: transparent; touch-action: none; }
#scene-container { position: fixed; inset: 0; }
canvas { display: block; }

.hidden { display: none !important; }

/* ---------- HUD ---------- */
#hud {
  position: fixed; top: 0; left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 16px 20px; pointer-events: none; z-index: 5;
}
.label {
  font-family: 'JetBrains Mono', monospace; font-size: 11px; letter-spacing: 2px;
  color: #fff; opacity: 0.85; text-shadow: 0 2px 0 rgba(0,0,0,0.3);
}
#score, #hi {
  font-size: 42px; font-weight: 800; color: #fff; line-height: 1;
  text-shadow: 0 3px 0 var(--dark), 0 0 12px rgba(255,180,0,0.4);
}
#hi { font-size: 30px; color: #ffe08a; }
#hi-box { text-align: right; }
#right-box {
  text-align: center;
  font-family: 'JetBrains Mono', monospace;
}
#coins {
  font-size: 24px; font-weight: 700; color: #fff;
  text-shadow: 0 2px 0 var(--dark);
}
#speed {
  margin-top: 4px; font-size: 13px; color: #ffd9a0;
  text-shadow: 0 1px 0 var(--dark);
}

/* ---------- Overlays ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 20;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 30%, rgba(255,220,150,0.25), rgba(20,40,60,0.75));
  backdrop-filter: blur(3px);
  padding: 24px;
}
.panel {
  background: linear-gradient(160deg, #ffb347, #f47b1e);
  border: 6px solid var(--dark);
  border-radius: 26px;
  padding: 34px 30px 30px;
  text-align: center;
  max-width: 420px; width: 100%;
  box-shadow: 0 14px 0 rgba(0,0,0,0.35), inset 0 0 0 3px rgba(255,255,255,0.25);
  animation: pop 0.4s cubic-bezier(0.2,1.4,0.4,1) both;
}
@keyframes pop { from { transform: scale(0.7) translateY(20px); opacity: 0; } }

.panel h1 {
  font-size: 46px; font-weight: 800; line-height: 0.9; color: #fff;
  letter-spacing: -1px;
  text-shadow: 0 4px 0 var(--dark), 0 0 20px rgba(0,0,0,0.3);
  margin-bottom: 14px;
}
.panel h1 span { display: block; color: #fff65a; font-size: 58px; }
.panel h1.wipeout { color: #fff; font-size: 54px; animation: wob 0.5s ease-in-out infinite alternate; }
@keyframes wob { from { transform: rotate(-3deg); } to { transform: rotate(3deg); } }

.tag { color: var(--dark); font-weight: 700; font-size: 16px; margin-bottom: 18px; }

.controls-hint {
  display: flex; flex-direction: column; gap: 6px;
  background: rgba(42,26,14,0.85); border-radius: 14px;
  padding: 12px 14px; margin-bottom: 20px;
  font-family: 'JetBrains Mono', monospace; font-size: 12px; color: #ffe6c2;
}

button {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 22px; font-weight: 800; letter-spacing: 1px;
  color: var(--dark); background: #fff65a;
  border: 4px solid var(--dark); border-radius: 16px;
  padding: 16px 34px; cursor: pointer;
  box-shadow: 0 6px 0 var(--dark);
  transition: transform 0.08s, box-shadow 0.08s;
}
button:active { transform: translateY(5px); box-shadow: 0 1px 0 var(--dark); }
button:hover { background: #fffb8a; }

.best-line { margin-top: 16px; color: var(--dark); font-weight: 700; }
.final {
  display: flex; gap: 26px; justify-content: center; margin-bottom: 16px;
  color: #fff; font-size: 20px; font-weight: 700; text-shadow: 0 2px 0 var(--dark);
}
.final b { display: block; font-size: 36px; color: #fff65a; }
.newbest {
  color: #fff; font-size: 22px; font-weight: 800; margin-bottom: 16px;
  animation: pulse 0.6s ease-in-out infinite alternate;
  text-shadow: 0 2px 0 var(--dark);
}
@keyframes pulse { from { transform: scale(1); } to { transform: scale(1.12); } }

footer {
  margin-top: 22px; z-index: 21;
}
footer a {
  color: rgba(255,255,255,0.85); font-family: 'JetBrains Mono', monospace;
  font-size: 12px; text-decoration: none; letter-spacing: 1px;
  border-bottom: 1px dashed rgba(255,255,255,0.5); padding-bottom: 2px;
}
footer a:hover { color: #fff; }

@media (max-width: 480px) {
  .panel h1 { font-size: 38px; }
  .panel h1 span { font-size: 48px; }
  #score { font-size: 34px; }
}