/* ============================================
   NEON DRIFT — Retro-Futuristic Arcade Racer
   Volcanic Glass Palette + Orbitron Typography
   ============================================ */

:root {
  --bg:         #0a0a0f;
  --bg2:        #12121a;
  --surface:    #1a1a2e;
  --cyan:       #00f5ff;
  --magenta:    #ff00ff;
  --orange:     #ff6b2b;
  --yellow:     #ffe600;
  --white:      #e8e8f0;
  --dim:        #4a4a6a;
  --road-dark:  #0d0d1a;
  --road-mid:   #141428;
  --road-light: #1e1e3c;

  --font-display: 'Orbitron', monospace;
  --font-mono:    'Share Tech Mono', monospace;

  --glow-cyan:    0 0 8px #00f5ff, 0 0 20px #00f5ff44, 0 0 40px #00f5ff22;
  --glow-magenta: 0 0 8px #ff00ff, 0 0 20px #ff00ff44, 0 0 40px #ff00ff22;
  --glow-orange:  0 0 8px #ff6b2b, 0 0 20px #ff6b2b44, 0 0 40px #ff6b2b22;
}

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

html, body {
  width: 100%; height: 100%;
  background: var(--bg);
  overflow: hidden;
  font-family: var(--font-display);
  color: var(--white);
  user-select: none;
}

/* ── SCANLINES & VIGNETTE ── */
.scanlines {
  position: fixed; inset: 0; z-index: 100;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent 3px,
    rgba(0,0,0,0.18) 3px,
    rgba(0,0,0,0.18) 4px
  );
}

.vignette {
  position: fixed; inset: 0; z-index: 99;
  pointer-events: none;
  background: radial-gradient(ellipse at center,
    transparent 50%,
    rgba(0,0,0,0.75) 100%
  );
}

/* ── GAME WRAPPER ── */
#game-wrapper {
  position: relative;
  width: 100vw; height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── SCREENS ── */
.screen {
  position: absolute; inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}
.screen.active {
  opacity: 1;
  pointer-events: all;
}

.screen-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  text-align: center;
  z-index: 10;
}

/* ── START SCREEN ── */
#start-screen {
  background:
    radial-gradient(ellipse 80% 60% at 50% 40%, rgba(0,245,255,0.04) 0%, transparent 70%),
    radial-gradient(ellipse 60% 40% at 50% 80%, rgba(255,0,255,0.04) 0%, transparent 70%),
    var(--bg);
}

.logo-container { display: flex; flex-direction: column; align-items: center; gap: 6px; }

.logo-sub {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 6px;
  color: var(--cyan);
  text-shadow: var(--glow-cyan);
  opacity: 0.8;
}

.logo-title {
  font-size: clamp(56px, 10vw, 96px);
  font-weight: 900;
  line-height: 0.9;
  letter-spacing: -2px;
  color: var(--white);
  text-shadow: 0 0 30px rgba(232,232,240,0.3);
}

.logo-accent {
  color: var(--cyan);
  text-shadow: var(--glow-cyan);
  display: block;
}

.logo-tagline {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 4px;
  color: var(--magenta);
  text-shadow: var(--glow-magenta);
  margin-top: 8px;
}

/* Controls */
.start-controls {
  display: flex;
  gap: 24px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(0,245,255,0.15);
  border-radius: 4px;
  padding: 16px 28px;
}

.control-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.key {
  font-family: var(--font-mono);
  font-size: 18px;
  color: var(--cyan);
  text-shadow: var(--glow-cyan);
  background: rgba(0,245,255,0.08);
  border: 1px solid rgba(0,245,255,0.3);
  border-radius: 4px;
  padding: 4px 10px;
  min-width: 44px;
  text-align: center;
}

.key-label {
  font-size: 9px;
  letter-spacing: 2px;
  color: var(--dim);
}

/* Neon Button */
.neon-btn {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 4px;
  color: var(--bg);
  background: var(--cyan);
  border: none;
  border-radius: 2px;
  padding: 14px 40px;
  cursor: pointer;
  box-shadow: var(--glow-cyan);
  transition: all 0.15s ease;
  text-transform: uppercase;
  animation: pulse-btn 2s ease-in-out infinite;
}

.neon-btn:hover {
  background: var(--white);
  box-shadow: 0 0 20px #fff, 0 0 40px var(--cyan);
  transform: scale(1.04);
}

.neon-btn:active { transform: scale(0.97); }

.neon-btn.secondary {
  background: transparent;
  color: var(--magenta);
  border: 1px solid var(--magenta);
  box-shadow: var(--glow-magenta);
  animation: none;
}

.neon-btn.secondary:hover {
  background: var(--magenta);
  color: var(--bg);
}

@keyframes pulse-btn {
  0%, 100% { box-shadow: var(--glow-cyan); }
  50% { box-shadow: 0 0 16px #00f5ff, 0 0 40px #00f5ff88, 0 0 80px #00f5ff44; }
}

.high-score-display {
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 3px;
  color: var(--yellow);
  text-shadow: 0 0 8px var(--yellow);
}

/* ── HUD ── */
#hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 16px 24px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.7) 0%, transparent 100%);
  pointer-events: none;
}

.hud-left, .hud-right, .hud-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.hud-label {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 3px;
  color: var(--dim);
}

.hud-value {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--cyan);
  text-shadow: var(--glow-cyan);
}

/* Speed bar */
.speed-bar-container {
  width: 120px;
  height: 6px;
  background: rgba(255,255,255,0.08);
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid rgba(0,245,255,0.2);
}

.speed-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(to right, var(--cyan), var(--magenta));
  border-radius: 3px;
  transition: width 0.1s ease;
  box-shadow: 0 0 8px var(--cyan);
}

/* Lives */
.lives-container {
  display: flex;
  gap: 6px;
}

.life-icon {
  width: 14px; height: 14px;
  background: var(--orange);
  clip-path: polygon(50% 0%, 100% 38%, 82% 100%, 50% 80%, 18% 100%, 0% 38%);
  box-shadow: var(--glow-orange);
  transition: all 0.3s ease;
}

.life-icon.lost {
  background: var(--dim);
  box-shadow: none;
  opacity: 0.3;
}

/* ── CANVAS ── */
#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

#game-screen {
  background: var(--bg);
}

/* ── LEVEL BANNER ── */
.level-banner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: clamp(32px, 6vw, 64px);
  font-weight: 900;
  letter-spacing: 8px;
  color: var(--yellow);
  text-shadow: 0 0 20px var(--yellow), 0 0 60px var(--yellow);
  z-index: 30;
  pointer-events: none;
  animation: banner-pop 1.8s ease forwards;
}

.level-banner.hidden { display: none; }

@keyframes banner-pop {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
  20%  { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
  70%  { opacity: 1; transform: translate(-50%, -50%) scale(1.0); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.0); }
}

/* ── BOOST INDICATOR ── */
.boost-indicator {
  position: absolute;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 14px;
  letter-spacing: 4px;
  color: var(--yellow);
  text-shadow: 0 0 12px var(--yellow);
  z-index: 30;
  pointer-events: none;
  animation: boost-flash 0.3s ease infinite alternate;
}

.boost-indicator.hidden { display: none; }

@keyframes boost-flash {
  from { opacity: 0.6; }
  to   { opacity: 1; }
}

/* ── GAME OVER SCREEN ── */
#gameover-screen {
  background:
    radial-gradient(ellipse 80% 60% at 50% 40%, rgba(255,0,255,0.05) 0%, transparent 70%),
    var(--bg);
}

.gameover-title {
  font-size: clamp(52px, 9vw, 88px);
  font-weight: 900;
  line-height: 0.9;
  letter-spacing: -2px;
  color: var(--white);
}

.result-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 280px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,0,255,0.2);
  border-radius: 4px;
  padding: 20px 28px;
}

.result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  padding-bottom: 8px;
}

.result-row:last-child { border-bottom: none; padding-bottom: 0; }

.result-label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 3px;
  color: var(--dim);
}

.result-value {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--cyan);
  text-shadow: var(--glow-cyan);
}

.new-record {
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 3px;
  color: var(--yellow);
  text-shadow: 0 0 12px var(--yellow);
  animation: pulse-btn 1s ease-in-out infinite;
}

.new-record.hidden { display: none; }

/* ── SCREEN SHAKE ── */
@keyframes shake {
  0%   { transform: translate(0,0) rotate(0deg); }
  15%  { transform: translate(-6px, 4px) rotate(-0.5deg); }
  30%  { transform: translate(6px, -4px) rotate(0.5deg); }
  45%  { transform: translate(-4px, 6px) rotate(-0.3deg); }
  60%  { transform: translate(4px, -2px) rotate(0.3deg); }
  75%  { transform: translate(-2px, 4px) rotate(-0.2deg); }
  100% { transform: translate(0,0) rotate(0deg); }
}

.shake { animation: shake 0.4s ease; }

/* ── RESPONSIVE ── */
@media (max-width: 600px) {
  .start-controls { gap: 14px; padding: 12px 16px; }
  .key { font-size: 14px; padding: 3px 8px; min-width: 36px; }
  #hud { padding: 10px 14px; }
  .hud-value { font-size: 16px; }
  .speed-bar-container { width: 80px; }
}