/* ===== DRIFT RACER - STYLES ===== */

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

:root {
  --accent: #ff4500;
  --accent2: #ff8c00;
  --neon: #00f5ff;
  --neon2: #7b2fff;
  --bg-dark: #0a0a0f;
  --bg-card: rgba(255,255,255,0.04);
  --text: #ffffff;
  --text-dim: rgba(255,255,255,0.5);
  --glass: rgba(255,255,255,0.06);
  --glass-border: rgba(255,255,255,0.12);
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-dark);
  font-family: 'Inter', sans-serif;
  color: var(--text);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#app {
  width: 100vw;
  height: 100vh;
  position: relative;
  overflow: hidden;
}

/* ===== GAME CANVAS ===== */
#game-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  cursor: none;
}

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

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

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

.hud-value {
  font-family: 'Orbitron', monospace;
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  text-shadow: 0 0 20px rgba(255, 69, 0, 0.8);
  letter-spacing: 1px;
}

#hud-center .hud-value {
  font-size: 18px;
  color: var(--neon);
  text-shadow: 0 0 20px rgba(0, 245, 255, 0.8);
}

/* ===== SPEEDOMETER ===== */
#speedometer {
  position: absolute;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 20;
  pointer-events: none;
}

#gauge-canvas {
  filter: drop-shadow(0 0 10px rgba(255, 69, 0, 0.5));
}

#speed-value {
  font-family: 'Orbitron', monospace;
  font-size: 28px;
  font-weight: 900;
  color: var(--text);
  text-shadow: 0 0 15px rgba(255, 140, 0, 0.8);
  margin-top: -40px;
  position: relative;
  z-index: 1;
}

#speed-unit {
  font-family: 'Orbitron', monospace;
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 2px;
  margin-top: 4px;
}

/* ===== DRIFT METER ===== */
#drift-meter-container {
  position: absolute;
  bottom: 20px;
  left: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  z-index: 20;
  pointer-events: none;
  min-width: 60px;
}

#drift-bar-bg {
  width: 12px;
  height: 100px;
  background: rgba(255,255,255,0.1);
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.15);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

#drift-bar {
  width: 100%;
  height: 0%;
  background: linear-gradient(to top, var(--accent), var(--accent2), #ffff00);
  border-radius: 6px;
  transition: height 0.1s ease, background 0.2s ease;
  box-shadow: 0 0 10px var(--accent);
}

#drift-score {
  font-family: 'Orbitron', monospace;
  font-size: 11px;
  color: var(--accent2);
  text-shadow: 0 0 8px var(--accent);
}

/* ===== MINI MAP ===== */
#minimap-container {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  pointer-events: none;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--glass-border);
  box-shadow: 0 0 20px rgba(0,0,0,0.5);
  background: rgba(0,0,0,0.5);
}

#minimap {
  display: block;
}

/* ===== JOYSTICK ZONE ===== */
#joystick-zone {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  cursor: none;
}

#joystick-hint {
  position: absolute;
  bottom: 140px;
  left: 50%;
  transform: translateX(-50%);
  opacity: 0.4;
  animation: pulse-hint 2s ease-in-out infinite;
  pointer-events: none;
}

@keyframes pulse-hint {
  0%, 100% { opacity: 0.3; transform: translateX(-50%) scale(1); }
  50% { opacity: 0.6; transform: translateX(-50%) scale(1.05); }
}

/* ===== START SCREEN ===== */
#start-screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  background: radial-gradient(ellipse at center, rgba(123,47,255,0.15) 0%, rgba(10,10,15,0.97) 70%);
  backdrop-filter: blur(2px);
}

#start-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  max-width: 420px;
  width: 90%;
  padding: 40px 32px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  box-shadow: 0 8px 64px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.08);
}

#logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
}

.logo-drift {
  font-family: 'Orbitron', monospace;
  font-size: 56px;
  font-weight: 900;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent2) 50%, #ffff00 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 8px;
  text-shadow: none;
  filter: drop-shadow(0 0 30px rgba(255,69,0,0.6));
}

.logo-racer {
  font-family: 'Orbitron', monospace;
  font-size: 20px;
  font-weight: 400;
  color: var(--neon);
  letter-spacing: 16px;
  text-shadow: 0 0 20px rgba(0,245,255,0.6);
}

#start-subtitle {
  font-size: 13px;
  color: var(--text-dim);
  text-align: center;
  line-height: 1.6;
}

#controls-info {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  background: rgba(0,0,0,0.3);
  border-radius: 16px;
  padding: 16px;
}

.control-item {
  display: flex;
  align-items: center;
  gap: 14px;
}

.control-icon {
  font-size: 28px;
  min-width: 40px;
  text-align: center;
}

.control-text {
  font-size: 12px;
  line-height: 1.5;
}

.control-text strong {
  color: var(--neon);
  font-weight: 600;
}

.control-text span {
  color: var(--text-dim);
}

/* ===== BUTTONS ===== */
#start-btn, #restart-btn {
  position: relative;
  padding: 16px 48px;
  font-family: 'Orbitron', monospace;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 4px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent) 0%, var(--neon2) 100%);
  border: none;
  border-radius: 50px;
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 4px 24px rgba(255,69,0,0.4), 0 0 60px rgba(255,69,0,0.1);
}

#start-btn:hover, #restart-btn:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 8px 32px rgba(255,69,0,0.6), 0 0 80px rgba(255,69,0,0.2);
}

#start-btn:active, #restart-btn:active {
  transform: scale(0.98);
}

.btn-glow {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 30%, rgba(255,255,255,0.2) 50%, transparent 70%);
  transform: translateX(-100%);
  animation: btn-shine 3s ease-in-out infinite;
}

@keyframes btn-shine {
  0%, 100% { transform: translateX(-100%); }
  40%, 60% { transform: translateX(100%); }
}

/* ===== LEADERBOARD ===== */
#best-times-panel {
  width: 100%;
  background: rgba(0,0,0,0.3);
  border-radius: 12px;
  padding: 14px;
}

.panel-title {
  font-family: 'Orbitron', monospace;
  font-size: 10px;
  letter-spacing: 4px;
  color: var(--neon);
  text-align: center;
  margin-bottom: 10px;
}

#leaderboard {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.lb-entry {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(255,255,255,0.04);
}

.lb-rank {
  font-family: 'Orbitron', monospace;
  font-size: 11px;
  color: var(--accent2);
  min-width: 24px;
}

.lb-time {
  font-family: 'Orbitron', monospace;
  font-size: 13px;
  color: var(--text);
}

.lb-empty {
  color: var(--text-dim);
  font-size: 12px;
  text-align: center;
  padding: 8px;
}

/* ===== FINISH SCREEN ===== */
#finish-screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  background: radial-gradient(ellipse at center, rgba(255,69,0,0.1) 0%, rgba(10,10,15,0.95) 70%);
  backdrop-filter: blur(4px);
}

#finish-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  max-width: 420px;
  width: 90%;
  padding: 40px 32px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  box-shadow: 0 8px 64px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.08);
}

#finish-title {
  font-family: 'Orbitron', monospace;
  font-size: 24px;
  font-weight: 900;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 4px;
  text-align: center;
}

#finish-time-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.finish-label {
  font-family: 'Orbitron', monospace;
  font-size: 10px;
  letter-spacing: 4px;
  color: var(--text-dim);
}

.finish-value {
  font-family: 'Orbitron', monospace;
  font-size: 40px;
  font-weight: 900;
  color: var(--neon);
  text-shadow: 0 0 30px rgba(0,245,255,0.8);
}

#finish-record {
  font-family: 'Orbitron', monospace;
  font-size: 16px;
  color: #ffd700;
  text-shadow: 0 0 20px rgba(255,215,0,0.8);
  animation: record-pulse 0.8s ease-in-out infinite alternate;
}

@keyframes record-pulse {
  from { transform: scale(1); }
  to { transform: scale(1.05); }
}

#lap-times-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.lap-entry {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  background: rgba(255,255,255,0.04);
  border-radius: 8px;
  font-family: 'Orbitron', monospace;
  font-size: 13px;
}

.lap-entry.best-lap {
  background: rgba(255,215,0,0.08);
  border: 1px solid rgba(255,215,0,0.2);
  color: #ffd700;
}

/* ===== COUNTDOWN ===== */
#countdown {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 90;
  pointer-events: none;
}

#countdown-number {
  font-family: 'Orbitron', monospace;
  font-size: 160px;
  font-weight: 900;
  animation: countdown-pop 0.8s ease-out forwards;
}

@keyframes countdown-pop {
  0% { transform: scale(0.5); opacity: 0; }
  50% { transform: scale(1.1); opacity: 1; }
  80% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.5); opacity: 0; }
}

/* ===== CRASH FLASH ===== */
#crash-flash {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  opacity: 0;
  background: radial-gradient(ellipse at center, rgba(255,69,0,0.4) 0%, transparent 70%);
  transition: opacity 0.05s;
}

#crash-flash.active {
  opacity: 1;
}

/* ===== DRIFT COMBO ===== */
#drift-combo {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 60;
  pointer-events: none;
}

#drift-combo-text {
  font-family: 'Orbitron', monospace;
  font-size: 32px;
  font-weight: 900;
  background: linear-gradient(135deg, var(--accent), var(--accent2), #ffff00);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: none;
  filter: drop-shadow(0 0 20px rgba(255,140,0,0.8));
  animation: combo-pop 0.6s ease-out forwards;
}

@keyframes combo-pop {
  0% { transform: scale(0.5) rotate(-10deg); opacity: 0; }
  40% { transform: scale(1.3) rotate(3deg); opacity: 1; }
  70% { transform: scale(1) rotate(0deg); opacity: 1; }
  100% { transform: scale(1.2) rotate(0deg); opacity: 0; }
}

/* ===== UTILITIES ===== */
.hidden {
  display: none !important;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 480px) {
  .logo-drift {
    font-size: 40px;
    letter-spacing: 4px;
  }
  .logo-racer {
    font-size: 16px;
    letter-spacing: 10px;
  }
  #start-btn, #restart-btn {
    padding: 14px 32px;
    font-size: 12px;
  }
  .hud-value {
    font-size: 18px;
  }
  #speed-value {
    font-size: 22px;
  }
  #gauge-canvas {
    width: 90px;
    height: 90px;
  }
}
