/* ─── reset ─────────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: #000;
  overflow: hidden;
  font-family: 'Orbitron', 'Courier New', monospace;
  color: #0f0;
}

/* ─── Babylon canvas ───────────────────────────────────── */
#renderCanvas {
  width: 100vw;
  height: 100vh;
  display: block;
  touch-action: none;
  outline: none;
}

/* ─── HUD ──────────────────────────────────────────────── */
#hud {
  position: fixed;
  top: 0; left: 0; right: 0;
  display: none;                /* shown when playing */
  justify-content: space-between;
  align-items: flex-start;
  padding: 14px 22px;
  pointer-events: none;
  z-index: 10;
  font-size: 13px;
  letter-spacing: 1px;
  text-shadow: 0 0 6px #0f0;
}
#hudLeft, #hudRight { display: flex; flex-direction: column; gap: 5px; min-width: 120px; }
#hudRight { text-align: right; }

#hudCenter {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.hud-label { opacity: 0.55; font-size: 10px; }

/* ── Color-coded velocity values ── */
.hud-val { transition: color 0.15s; }
.hud-val.safe   { color: #0f0; text-shadow: 0 0 6px #0f0; }
.hud-val.warn   { color: #fa0; text-shadow: 0 0 8px #fa0; }
.hud-val.danger { color: #f44; text-shadow: 0 0 10px #f44; }

/* ── DANGER warning ── */
#dangerWarning {
  font-size: clamp(14px, 2.5vw, 22px);
  font-weight: 900;
  letter-spacing: 4px;
  color: #f44;
  text-shadow: 0 0 20px #f44, 0 0 40px #f00;
  display: none;
  animation: dangerPulse 0.35s step-end infinite;
}
@keyframes dangerPulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

/* ── Lives display ── */
#livesDisplay {
  font-size: 18px;
  letter-spacing: 6px;
  color: #5ef;
  text-shadow: 0 0 10px #5ef;
}

/* fuel bar */
#fuelBar {
  width: 120px; height: 8px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(0,255,0,0.3);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 2px;
}
#fuelFill {
  height: 100%;
  width: 100%;
  background: #0f0;
  transition: width 0.2s, background 0.3s;
  border-radius: 2px;
}

/* ─── Overlays ─────────────────────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.82);
  z-index: 20;
  text-align: center;
  gap: 16px;
}

.overlay h1 {
  font-size: clamp(28px, 6vw, 56px);
  color: #0f0;
  text-shadow: 0 0 20px #0f0, 0 0 40px #090;
  letter-spacing: 6px;
}
.overlay h2 {
  font-size: clamp(22px, 4vw, 40px);
  letter-spacing: 3px;
  text-shadow: 0 0 12px currentColor;
}
.overlay h2.crash { color: #f44; text-shadow: 0 0 18px #f44; }

.gameover-title {
  font-size: clamp(36px, 8vw, 72px) !important;
  color: #f44 !important;
  text-shadow: 0 0 30px #f44, 0 0 60px #f00 !important;
  letter-spacing: 8px !important;
  animation: gameoverFlicker 1.2s ease-in-out infinite alternate;
}
@keyframes gameoverFlicker {
  0%   { opacity: 0.85; text-shadow: 0 0 20px #f44, 0 0 40px #f00; }
  100% { opacity: 1;    text-shadow: 0 0 40px #f44, 0 0 80px #f00, 0 0 120px #800; }
}

.overlay p {
  font-size: 14px;
  opacity: 0.8;
  max-width: 480px;
  line-height: 1.6;
}

.overlay .instructions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 8px 0;
  font-size: 13px;
  opacity: 0.7;
}

.overlay button {
  margin-top: 18px;
  padding: 12px 32px;
  font-family: inherit;
  font-size: 15px;
  letter-spacing: 2px;
  color: #0f0;
  background: transparent;
  border: 1.5px solid #0f0;
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s;
  text-transform: uppercase;
}
.overlay button:hover,
.overlay button:focus {
  background: rgba(0, 255, 0, 0.1);
  box-shadow: 0 0 18px rgba(0, 255, 0, 0.35);
  outline: none;
}

#resultOverlay { display: none; }

/* ── Bonus life flash ── */
.bonus-life-flash { animation: bonusFlash 1s ease-out forwards; }
@keyframes bonusFlash {
  0%   { color: #ff0; text-shadow: 0 0 30px #ff0; }
  100% { color: #5ef; text-shadow: 0 0 10px #5ef; }
}

/* scanline effect */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0,0,0,0.06) 2px,
    rgba(0,0,0,0.06) 4px
  );
  pointer-events: none;
  z-index: 100;
}

/* ─── Mobile helpers ───────────────────────────────────── */
@media (max-width: 640px) {
  #hud { font-size: 11px; padding: 8px 12px; }
  #fuelBar { width: 80px; }
  #dangerWarning { font-size: 14px; }
}

/* ── High Score UI ────────────────────────────────────────────────── */
#initials-box {
  background: rgba(0, 0, 0, 0.9); border: 2px solid #5ef; padding: 40px; border-radius: 8px;
  box-shadow: 0 0 30px #5ef; z-index: 30; pointer-events: auto;
}
#initials-box h2 {
  color: #5ef; font-size: 28px; text-shadow: 0 0 15px #5ef; margin-top: 0; margin-bottom: 20px; text-align: center;
}
.initials-input { display: flex; gap: 15px; justify-content: center; margin-bottom: 30px; }
.initial-slot { 
  width: 45px; height: 55px; border-bottom: 4px solid #fff; 
  font-size: 45px; color: #fff; text-align: center; line-height: 55px;
  text-transform: uppercase; text-shadow: 0 0 10px #fff;
}
.initial-slot.filled { border-bottom-color: #3f3; color: #3f3; text-shadow: 0 0 15px #3f3; }
.initial-slot.active { border-bottom-color: #f0f; animation: blink 1s step-end infinite; }

#high-scores {
  background: rgba(0, 20, 0, 0.85); border: 2px solid #3f3; padding: 25px 35px; border-radius: 8px;
  box-shadow: 0 0 25px #3f3; z-index: 30; min-width: 320px; max-width: 420px; pointer-events: auto;
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
}
#hs-title { 
  color: #3f3; font-size: 22px; letter-spacing: 4px; border-bottom: 1px solid #3f3; 
  padding-bottom: 10px; margin-bottom: 15px; text-shadow: 0 0 10px #3f3; text-align: center; font-weight: bold;
}
.score-row { 
  display: flex; justify-content: space-between; width: 100%; font-size: 20px; color: #aaa; 
  opacity: 0; animation: fadein 0.5s forwards; margin-bottom: 8px; gap: 12px;
}
.score-row.top { color: #ff0; text-shadow: 0 0 15px #ff0; font-size: 24px; font-weight: bold; }
.score-rank { width: 45px; color: #3f3; flex-shrink: 0; }
.score-name { flex-grow: 1; text-align: center; letter-spacing: 2px;}
.score-val { color: #fff; width: 80px; text-align: right; flex-shrink: 0; }

@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0} }
@keyframes fadein { to { opacity: 1; } }
