/* Traffic Dodge 3D - Styles (Step 5 polished) */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: #000;
  overflow: hidden;
  font-family: 'Segoe UI', 'PingFang SC', sans-serif;
  color: #fff;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

#gameContainer {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
}
#gameContainer canvas { display: block; width: 100%; height: 100%; }

/* ─── HUD ─── */
#hud {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  pointer-events: none;
  padding: 10px 16px 0;
}
#hud.hidden { display: none; }

.hud-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.hud-top {
  background: linear-gradient(180deg, rgba(0,0,0,0.55) 0%, transparent 100%);
  padding: 8px 12px;
  border-radius: 0 0 10px 10px;
}

.hud-item { display: flex; flex-direction: column; align-items: center; gap: 1px; }
.hud-label { font-size: 10px; color: rgba(255,255,255,0.5); text-transform: uppercase; letter-spacing: 1px; }
.hud-value { font-size: 20px; font-weight: bold; }
.hud-score { color: #4ecca3; text-shadow: 0 0 8px rgba(78,204,163,0.4); }
.hud-stage { color: #ffd700; text-shadow: 0 0 8px rgba(255,215,0,0.4); }
.hud-speed { color: #ff6b6b; text-shadow: 0 0 8px rgba(255,107,107,0.4); }
.hud-bolt { color: #ffd700; text-shadow: 0 0 8px rgba(255,215,0,0.4); }
.hud-bolt.rush-active { animation: boltBlink 0.4s infinite; }
@keyframes boltBlink {
  0%, 100% { opacity: 1; text-shadow: 0 0 16px rgba(255,215,0,0.9); }
  50% { opacity: 0.3; }
}

/* Timer bar */
.hud-timer-wrap {
  position: relative;
  height: 18px;
  margin-top: 6px;
  background: rgba(0,0,0,0.4);
  border-radius: 9px;
  overflow: hidden;
}
.hud-timer-bar {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #ff4444, #ffaa00, #44ff44);
  border-radius: 9px;
  transition: width 0.3s linear;
}
.hud-timer-text {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 11px;
  font-weight: bold;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}

/* Progress bar */
.hud-progress-wrap {
  position: relative;
  height: 10px;
  margin-top: 4px;
  background: rgba(0,0,0,0.3);
  border-radius: 5px;
  overflow: hidden;
}
.hud-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #4ecca3, #45b08c);
  border-radius: 5px;
  transition: width 0.2s linear;
}
.hud-progress-text {
  position: absolute;
  top: 50%; right: 8px;
  transform: translateY(-50%);
  font-size: 8px;
  font-weight: bold;
  color: rgba(255,255,255,0.7);
}

/* ─── Helicopter warning ─── */
#heliWarning {
  position: fixed;
  top: 80px; left: 50%;
  transform: translateX(-50%);
  z-index: 160;
  font-size: 22px;
  font-weight: bold;
  color: #ff4444;
  text-shadow: 0 0 12px rgba(255,68,68,0.8), 0 2px 4px rgba(0,0,0,0.6);
  text-align: center;
  pointer-events: none;
  animation: heliWarnBlink 0.6s ease-in-out infinite;
  white-space: nowrap;
}
#heliWarning.hidden { display: none; }
@keyframes heliWarnBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ─── Speed vignette overlay ─── */
#speedVignette {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(0,0,0,0.3) 100%);
  opacity: 0;
  pointer-events: none;
  z-index: 85;
  transition: opacity 0.15s;
}

/* ─── Flash overlay ─── */
#flashOverlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: red;
  opacity: 0;
  pointer-events: none;
  z-index: 90;
  transition: opacity 0.1s;
}

/* ─── Stage banner ─── */
#stageBanner {
  position: fixed;
  top: 18%; left: 50%;
  transform: translate(-50%, -50%);
  z-index: 180;
  font-size: 48px;
  font-weight: bold;
  color: #ffd700;
  text-shadow: 0 0 30px rgba(255,215,0,0.6), 0 4px 8px rgba(0,0,0,0.5);
  text-align: center;
  pointer-events: none;
  animation: bannerPop 0.4s ease-out;
}
#stageBanner.hidden { display: none; }

@keyframes bannerPop {
  0% { transform: translate(-50%, -50%) scale(0.3); opacity: 0; }
  60% { transform: translate(-50%, -50%) scale(1.15); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

/* ─── Overlay ─── */
#overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.85);
  z-index: 200;
  padding: 20px;
  overflow-y: auto;
}
#overlay.hidden { display: none; }

.ov-title {
  font-size: 48px;
  font-weight: bold;
  color: #4ecca3;
  text-shadow: 0 0 30px rgba(78,204,163,0.5);
  margin-bottom: 4px;
  text-align: center;
}
.ov-subtitle {
  font-size: 15px;
  color: rgba(255,255,255,0.6);
  margin-bottom: 16px;
  text-align: center;
  line-height: 1.6;
  max-width: 400px;
}

/* Records on start screen */
.ov-records {
  display: flex;
  gap: 24px;
  margin-bottom: 22px;
  flex-wrap: wrap;
  justify-content: center;
}
.ov-rec-item {
  font-size: 14px;
  color: rgba(255,255,255,0.7);
  background: rgba(255,255,255,0.08);
  padding: 6px 14px;
  border-radius: 16px;
}
.ov-rec-item b {
  color: #ffd700;
}

.ov-score { font-size: 32px; color: #ffd700; margin-bottom: 8px; }
.ov-record { font-size: 20px; color: #ff6b6b; margin-bottom: 20px; animation: pulse 1s infinite; }

/* New record highlight animation */
.ov-record-anim {
  animation: recordGlow 1.2s ease-in-out infinite;
}
@keyframes recordGlow {
  0%, 100% { opacity: 1; text-shadow: 0 0 8px rgba(255,107,107,0.5); transform: scale(1); }
  50% { opacity: 0.7; text-shadow: 0 0 24px rgba(255,215,0,0.8); transform: scale(1.08); }
}

/* Game over stats grid */
.ov-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 24px;
  margin-bottom: 22px;
  text-align: left;
}
.ov-stat-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: rgba(255,255,255,0.75);
  background: rgba(255,255,255,0.06);
  padding: 6px 12px;
  border-radius: 8px;
}
.ov-stat-icon { font-size: 18px; }

.ov-stats {
  display: flex; gap: 30px; margin-bottom: 25px;
  font-size: 15px; color: rgba(255,255,255,0.7);
}
.ov-btn {
  padding: 14px 50px;
  font-size: 18px; font-weight: bold;
  background: #4ecca3; color: #1a1a2e;
  border: none; border-radius: 30px;
  cursor: pointer; margin: 8px;
  transition: transform 0.2s, box-shadow 0.2s;
  min-width: 200px;
}
.ov-btn:hover { transform: scale(1.05); box-shadow: 0 0 20px rgba(78,204,163,0.4); }
.ov-btn.secondary { background: rgba(255,255,255,0.15); color: #fff; }
.ov-btn.secondary:hover { background: rgba(255,255,255,0.25); }

.ov-controls {
  display: flex; gap: 16px; margin-top: 18px;
  flex-wrap: wrap; justify-content: center;
}
.ov-ctrl {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: rgba(255,255,255,0.5);
  background: rgba(255,255,255,0.06);
  padding: 5px 10px;
  border-radius: 12px;
}
.ov-ctrl-icon { font-size: 16px; }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

/* Pause button */
#pauseBtn {
  position: fixed; top: 12px; right: 12px;
  width: 44px; height: 44px;
  border: none; border-radius: 50%;
  background: rgba(0,0,0,0.5); color: #fff;
  font-size: 20px; cursor: pointer; z-index: 150;
  backdrop-filter: blur(5px);
}
#pauseBtn.hidden { display: none; }

/* Mute button */
#muteBtn {
  position: fixed; top: 12px; right: 64px;
  width: 44px; height: 44px;
  border: none; border-radius: 50%;
  background: rgba(0,0,0,0.5); color: #fff;
  font-size: 20px; cursor: pointer; z-index: 150;
  backdrop-filter: blur(5px);
  transition: transform 0.15s;
}
#muteBtn:hover { transform: scale(1.1); }

/* Responsive */
@media (max-width: 600px) {
  .ov-title { font-size: 32px; }
  .ov-subtitle { font-size: 13px; }
  .ov-btn { padding: 12px 35px; font-size: 16px; min-width: 160px; }
  .hud-value { font-size: 16px; }
  #hud { padding: 6px 8px 0; }
  #stageBanner { font-size: 36px; }
  .ov-stats-grid { grid-template-columns: 1fr; gap: 6px; }
  .ov-controls { gap: 8px; }
  .ov-ctrl { font-size: 11px; padding: 4px 8px; }
  .ov-records { gap: 12px; }
  .ov-rec-item { font-size: 12px; padding: 4px 10px; }
  #muteBtn { right: 60px; width: 38px; height: 38px; font-size: 18px; }
  #pauseBtn { width: 38px; height: 38px; font-size: 18px; }
}
