/* ============================================
   NEON DRIFT — Retro-Futuristic Racing Styles
   ============================================ */

:root {
  --bg:        #0A0A0F;
  --bg2:       #12121A;
  --neon-org:  #FF6B2B;
  --neon-cyan: #00F5FF;
  --neon-pink: #FF3CAC;
  --neon-yel:  #FFE600;
  --road:      #1A1A2A;
  --road-line: #00F5FF;
  --text:      #E8E4DF;
  --dim:       #6B6B80;
  --font-hud:  'Orbitron', monospace;
  --font-mono: 'Share Tech Mono', monospace;
}

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

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

/* ── BACKGROUND ── */
.bg-grid {
  position: fixed; inset: 0; z-index: 0;
  background-image:
    linear-gradient(rgba(0,245,255,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,245,255,0.04) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
}

.bg-stars {
  position: fixed; inset: 0; z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.star {
  position: absolute;
  width: 2px; height: 2px;
  background: white;
  border-radius: 50%;
  opacity: 0;
  animation: twinkle var(--dur, 3s) var(--delay, 0s) infinite;
}

@keyframes twinkle {
  0%, 100% { opacity: 0; }
  50% { opacity: var(--bright, 0.6); }
}

/* ── GAME WRAPPER ── */
.game-wrapper {
  position: relative; z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100vh;
  padding: 8px 12px;
  gap: 6px;
}

/* ── HUD ── */
.hud {
  width: 100%;
  max-width: 520px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.hud-top {
  padding: 4px 0;
  border-bottom: 1px solid rgba(0,245,255,0.15);
}

.hud-bottom {
  padding: 4px 0;
  border-top: 1px solid rgba(0,245,255,0.15);
  justify-content: center;
}

.hud-block {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 90px;
}

.hud-right { align-items: flex-end; }

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

.hud-value {
  font-family: var(--font-hud);
  font-size: 18px;
  font-weight: 700;
  color: var(--neon-cyan);
  text-shadow: 0 0 10px var(--neon-cyan), 0 0 20px rgba(0,245,255,0.4);
  letter-spacing: 2px;
}

.hud-center-logo {
  font-family: var(--font-hud);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 4px;
  color: var(--neon-org);
  text-shadow: 0 0 12px var(--neon-org), 0 0 24px rgba(255,107,43,0.5);
  text-align: center;
  line-height: 1.1;
}

.hud-center-logo span {
  display: block;
  color: var(--neon-pink);
  text-shadow: 0 0 12px var(--neon-pink);
  font-size: 10px;
  letter-spacing: 8px;
}

.control-hint {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--dim);
  letter-spacing: 1px;
}

.mobile-hint { display: none; }

kbd {
  display: inline-block;
  padding: 1px 5px;
  border: 1px solid var(--dim);
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--neon-cyan);
  border-color: rgba(0,245,255,0.3);
}

/* ── CANVAS CONTAINER ── */
.canvas-container {
  position: relative;
  flex: 1;
  width: 100%;
  max-width: 420px;
  min-height: 0;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

#gameCanvas {
  display: block;
  border: 1px solid rgba(0,245,255,0.2);
  box-shadow:
    0 0 30px rgba(0,245,255,0.08),
    0 0 60px rgba(255,107,43,0.05),
    inset 0 0 30px rgba(0,0,0,0.5);
  background: var(--road);
}

/* ── SPEED METER ── */
.speed-meter {
  position: absolute;
  right: 8px;
  bottom: 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
}

.speed-label {
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 2px;
  color: var(--dim);
}

.speed-value {
  font-family: var(--font-hud);
  font-size: 22px;
  font-weight: 900;
  color: var(--neon-yel);
  text-shadow: 0 0 10px var(--neon-yel), 0 0 20px rgba(255,230,0,0.4);
  line-height: 1;
  min-width: 50px;
  text-align: right;
}

.speed-bar-track {
  width: 50px;
  height: 4px;
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
  overflow: hidden;
}

.speed-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--neon-cyan), var(--neon-yel));
  border-radius: 2px;
  transition: width 0.2s ease;
  box-shadow: 0 0 6px var(--neon-yel);
}

/* ── LIVES ── */
.lives-display {
  position: absolute;
  left: 8px;
  bottom: 12px;
  display: flex;
  gap: 5px;
}

.life-icon {
  font-size: 14px;
  color: var(--neon-org);
  text-shadow: 0 0 8px var(--neon-org);
  transition: all 0.3s;
}

.life-icon.lost {
  color: rgba(255,107,43,0.15);
  text-shadow: none;
}

/* ── LEVEL BADGE ── */
.level-badge {
  position: absolute;
  left: 8px;
  top: 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--neon-pink);
  text-shadow: 0 0 8px var(--neon-pink);
  background: rgba(255,60,172,0.08);
  border: 1px solid rgba(255,60,172,0.25);
  padding: 3px 8px;
  border-radius: 3px;
}

/* ── SCREENS ── */
.screen {
  position: fixed; inset: 0; z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10,10,15,0.92);
  backdrop-filter: blur(8px);
}

.screen.hidden { display: none; }

.screen-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
  padding: 40px 32px;
  border: 1px solid rgba(0,245,255,0.2);
  background: rgba(18,18,26,0.9);
  box-shadow:
    0 0 40px rgba(0,245,255,0.08),
    0 0 80px rgba(255,107,43,0.05);
  max-width: 380px;
  width: 90%;
}

.screen-logo {
  font-family: var(--font-hud);
  font-size: 52px;
  font-weight: 900;
  line-height: 0.9;
  color: var(--neon-org);
  text-shadow: 0 0 20px var(--neon-org), 0 0 40px rgba(255,107,43,0.5);
  letter-spacing: 6px;
}

.screen-logo span {
  display: block;
  font-size: 28px;
  color: var(--neon-cyan);
  text-shadow: 0 0 16px var(--neon-cyan);
  letter-spacing: 14px;
  margin-top: 4px;
}

.screen-sub {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 5px;
  color: var(--dim);
}

.screen-divider {
  width: 100%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--neon-cyan), transparent);
  opacity: 0.3;
}

.screen-instructions {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text);
  letter-spacing: 1px;
  opacity: 0.7;
}

.screen-tip {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--dim);
  letter-spacing: 1px;
}

.btn-start {
  font-family: var(--font-hud);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 4px;
  color: var(--bg);
  background: var(--neon-cyan);
  border: none;
  padding: 14px 36px;
  cursor: pointer;
  clip-path: polygon(8px 0%, 100% 0%, calc(100% - 8px) 100%, 0% 100%);
  transition: all 0.2s;
  text-shadow: none;
  box-shadow: 0 0 20px rgba(0,245,255,0.4);
  animation: pulse-btn 2s ease-in-out infinite;
}

@keyframes pulse-btn {
  0%, 100% { box-shadow: 0 0 20px rgba(0,245,255,0.4); }
  50% { box-shadow: 0 0 35px rgba(0,245,255,0.7), 0 0 60px rgba(0,245,255,0.3); }
}

.btn-start:hover {
  background: var(--neon-org);
  box-shadow: 0 0 30px rgba(255,107,43,0.6);
  transform: scale(1.04);
  animation: none;
}

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

/* ── GAME OVER SCREEN ── */
.crash-title {
  font-family: var(--font-hud);
  font-size: 56px;
  font-weight: 900;
  color: var(--neon-pink);
  text-shadow: 0 0 20px var(--neon-pink), 0 0 40px rgba(255,60,172,0.5);
  letter-spacing: 6px;
  animation: glitch 0.5s steps(2) 3;
}

@keyframes glitch {
  0%   { transform: translate(0); }
  25%  { transform: translate(-4px, 2px); clip-path: inset(20% 0 60% 0); }
  50%  { transform: translate(4px, -2px); clip-path: inset(60% 0 20% 0); }
  75%  { transform: translate(-2px, 0); }
  100% { transform: translate(0); }
}

.result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 24px;
  width: 100%;
}

.result-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px;
  border: 1px solid rgba(0,245,255,0.1);
  background: rgba(0,245,255,0.03);
}

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

.result-val {
  font-family: var(--font-hud);
  font-size: 20px;
  font-weight: 700;
  color: var(--neon-cyan);
  text-shadow: 0 0 8px var(--neon-cyan);
}

/* ── LEVEL UP SCREEN ── */
.level-up-inner {
  gap: 8px;
  border-color: rgba(255,230,0,0.3);
  box-shadow: 0 0 40px rgba(255,230,0,0.1);
}

.level-up-text {
  font-family: var(--font-hud);
  font-size: 32px;
  font-weight: 900;
  letter-spacing: 6px;
  color: var(--neon-yel);
  text-shadow: 0 0 20px var(--neon-yel);
  animation: zoom-in 0.4s cubic-bezier(0.34,1.56,0.64,1);
}

.level-up-num {
  font-family: var(--font-hud);
  font-size: 80px;
  font-weight: 900;
  color: var(--neon-org);
  text-shadow: 0 0 30px var(--neon-org), 0 0 60px rgba(255,107,43,0.4);
  line-height: 1;
  animation: zoom-in 0.5s 0.1s cubic-bezier(0.34,1.56,0.64,1) both;
}

.level-up-sub {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 4px;
  color: var(--dim);
}

@keyframes zoom-in {
  from { transform: scale(0.3); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

/* ── MOBILE CONTROLS ── */
.mobile-controls {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 50;
  padding: 12px 20px 20px;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(transparent, rgba(10,10,15,0.8));
}

.mob-btn {
  font-family: var(--font-hud);
  font-size: 20px;
  color: var(--neon-cyan);
  background: rgba(0,245,255,0.08);
  border: 1px solid rgba(0,245,255,0.25);
  width: 70px; height: 56px;
  border-radius: 6px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.1s;
  display: flex; align-items: center; justify-content: center;
}

.mob-btn:active { background: rgba(0,245,255,0.2); }

.mob-boost {
  color: var(--neon-org);
  border-color: rgba(255,107,43,0.3);
  background: rgba(255,107,43,0.08);
  width: 80px;
}

/* ── FLASH OVERLAY ── */
.flash-overlay {
  position: fixed; inset: 0; z-index: 200;
  pointer-events: none;
  opacity: 0;
  background: var(--neon-pink);
  transition: opacity 0.05s;
}

.flash-overlay.active { opacity: 0.25; }

/* ── RESPONSIVE ── */
@media (max-width: 540px) {
  .hud-center-logo { font-size: 11px; }
  .hud-value { font-size: 15px; }
  .control-hint { display: none; }
  .mobile-hint { display: block; }
  .mobile-controls { display: flex; }
  .game-wrapper { padding: 6px 8px 80px; }
}

@media (max-height: 600px) {
  .game-wrapper { padding: 4px 8px; gap: 3px; }
  .hud-value { font-size: 14px; }
}