* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
}

html, body {
  width: 100vw;
  height: 100vh;
  margin: 0;
  padding: 0;
  background-color: #000;
  color: #fff;
  font-family: 'Press Start 2P', monospace, sans-serif;
  overflow: hidden;
}

#game-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  margin: 0;
  padding: 0;
  background-color: #06040d;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

#game-viewport {
  position: relative;
  height: 100%;
  max-height: 100vh;
  max-width: 100vw;
  aspect-ratio: 16 / 9;
  width: auto;
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.95);
  background: #000;
  overflow: hidden;
}

#canvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  object-fit: contain;
}

/* Arcade HUD */
#hud {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 16px 20px;
}

.hud-box {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

#hud-top {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  width: 100%;
  padding: 10px 18px;
}

.hud-left-group {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.hud-controls-group {
  display: flex;
  gap: 10px;
  align-items: center;
}

.hud-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: rgba(10, 5, 25, 0.65);
  padding: 8px 14px;
  border: 2px solid #00f0ff;
  border-radius: 6px;
  box-shadow: inset 0 0 10px rgba(0, 240, 255, 0.2);
}

.hud-item.score-box-large {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  border: none !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  padding: 0 !important;
  min-width: auto !important;
  text-align: left;
}

#hud-score,
.score-value-large {
  font-family: 'Teko', 'Impact', sans-serif !important;
  font-size: 68px !important;
  font-weight: 700 !important;
  color: #ffffff !important;
  line-height: 0.8 !important;
  letter-spacing: 2px !important;
  text-shadow: 
    0 4px 10px rgba(0, 0, 0, 0.95),
    0 0 16px rgba(0, 0, 0, 0.9),
    2px 2px 0 #000,
    -2px -2px 0 #000,
    2px -2px 0 #000,
    -2px 2px 0 #000,
    0 2px 0 #000,
    0 -2px 0 #000,
    2px 0 0 #000,
    -2px 0 0 #000 !important;
}

.score-box-large .hud-label {
  font-family: 'Press Start 2P', sans-serif !important;
  font-size: 9px !important;
  color: #ffffff !important;
  opacity: 0.9 !important;
  letter-spacing: 2px !important;
  margin-top: 4px !important;
  text-shadow: 
    0 2px 4px rgba(0, 0, 0, 0.95),
    1px 1px 0 #000,
    -1px -1px 0 #000,
    1px -1px 0 #000,
    -1px 1px 0 #000 !important;
}

.hud-item.stage-box,
#hud-stage-box {
  position: absolute;
  right: 18px;
  top: 10px;
  left: auto;
  transform: none;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: flex-start;
  border: none !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  padding: 0 !important;
  min-width: auto !important;
  text-align: right;
  gap: 3px;
}

.stage-box .hud-label {
  font-family: 'Press Start 2P', sans-serif !important;
  font-size: 9px !important;
  color: #ffffff !important;
  opacity: 0.9 !important;
  letter-spacing: 2px !important;
  margin-top: 4px !important;
  text-align: right;
  text-shadow: 
    0 2px 4px rgba(0, 0, 0, 0.95),
    1px 1px 0 #000,
    -1px -1px 0 #000,
    1px -1px 0 #000,
    -1px 1px 0 #000 !important;
}

#hud-stage,
.stage-value-large {
  font-family: 'Teko', 'Impact', sans-serif !important;
  font-size: 68px !important;
  font-weight: 700 !important;
  color: #ffffff !important;
  line-height: 0.8 !important;
  letter-spacing: 2px !important;
  text-align: right;
  text-shadow: 
    0 4px 10px rgba(0, 0, 0, 0.95),
    0 0 16px rgba(0, 0, 0, 0.9),
    2px 2px 0 #000,
    -2px -2px 0 #000,
    2px -2px 0 #000,
    -2px 2px 0 #000,
    0 2px 0 #000,
    0 -2px 0 #000,
    2px 0 0 #000,
    -2px 0 0 #000 !important;
}

#hud-stage.hidden,
#hud-giro-label.hidden,
#hud-stage-box.traffic-mode #hud-stage,
#hud-stage-box.traffic-mode #hud-giro-label {
  display: none !important;
}

#hud-stage-box.traffic-mode {
  justify-content: center !important;
  height: 34px !important;
}

#hud-stage-name {
  font-family: 'Press Start 2P', sans-serif;
  font-size: 8px;
  color: #00f0ff;
  letter-spacing: 1px;
  text-align: right;
  text-shadow: 
    0 0 8px rgba(0, 240, 255, 0.85),
    1px 1px 0 #000,
    -1px -1px 0 #000,
    1px -1px 0 #000,
    -1px 1px 0 #000 !important;
  white-space: nowrap;
}

#hud-stage-box.traffic-mode #hud-stage-name,
#hud-stage-name.traffic-stage-name {
  font-family: 'Teko', 'Impact', sans-serif !important;
  font-size: 26px !important;
  font-weight: 700 !important;
  color: #00f0ff !important;
  line-height: 34px !important;
  height: 34px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: flex-end !important;
  letter-spacing: 1.5px !important;
  margin-top: 0 !important;
  text-shadow: 
    0 3px 6px rgba(0, 0, 0, 0.95),
    2px 2px 0 #000,
    -2px -2px 0 #000,
    2px -2px 0 #000,
    -2px 2px 0 #000 !important;
}

.hud-item.time-box-center,
#hud-time-box {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: none !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  padding: 0 !important;
  min-width: auto !important;
  text-align: center;
}

#hud-time,
.time-value-large {
  font-family: 'Teko', 'Impact', sans-serif !important;
  font-size: 72px !important;
  font-weight: 700 !important;
  color: #ffffff !important;
  line-height: 0.8 !important;
  letter-spacing: 2px !important;
  text-shadow: 
    0 4px 10px rgba(0, 0, 0, 0.95),
    0 0 16px rgba(0, 0, 0, 0.9),
    2px 2px 0 #000,
    -2px -2px 0 #000,
    2px -2px 0 #000,
    -2px 2px 0 #000,
    0 2px 0 #000,
    0 -2px 0 #000,
    2px 0 0 #000,
    -2px 0 0 #000 !important;
}

.time-box-center .hud-label {
  font-family: 'Press Start 2P', sans-serif !important;
  font-size: 9px !important;
  color: #ffffff !important;
  opacity: 0.9 !important;
  letter-spacing: 2px !important;
  margin-top: 4px !important;
  text-shadow: 
    0 2px 4px rgba(0, 0, 0, 0.95),
    1px 1px 0 #000,
    -1px -1px 0 #000,
    1px -1px 0 #000,
    -1px 1px 0 #000 !important;
}

.hud-item.time-box-center.danger #hud-time,
.hud-item.time-box-center.danger .time-value-large {
  color: #ff0044 !important;
  text-shadow: 
    0 0 30px #ff0044,
    0 4px 10px rgba(0, 0, 0, 0.95),
    2px 2px 0 #000,
    -2px -2px 0 #000,
    2px -2px 0 #000,
    -2px 2px 0 #000 !important;
  animation: pulse-danger 0.5s infinite alternate;
}

.hud-label {
  font-size: 10px;
  color: #ffdd00;
  letter-spacing: 1px;
}

.hud-value {
  font-size: 14px;
  color: #ffffff;
}

.hud-sub {
  font-size: 8px;
  color: #00f0ff;
  margin-top: 2px;
}


.hud-item.armor-box {
  border-color: #00ff88;
  box-shadow: inset 0 0 10px rgba(0, 255, 136, 0.25);
  min-width: 130px;
}

.armor-pips {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-top: 2px;
}

.armor-pip {
  width: 26px;
  height: 12px;
  background: #182028;
  border: 1px solid #2b3a4a;
  border-radius: 2px;
  box-shadow: inset 0 0 4px rgba(0, 0, 0, 0.8);
  transition: background 0.2s, box-shadow 0.2s;
}

.armor-pip.active {
  background: linear-gradient(180deg, #00ff88 0%, #00aa55 100%);
  border-color: #88ffbb;
  box-shadow: 0 0 10px rgba(0, 255, 136, 0.8), inset 0 1px 2px #ffffff;
}

.armor-pip.active.warning, .armor-pip.warning {
  background: linear-gradient(180deg, #ffcc00 0%, #cc8800 100%);
  border-color: #ffee77;
  box-shadow: 0 0 10px rgba(255, 204, 0, 0.8), inset 0 1px 2px #ffffff;
}

.armor-pip.active.danger, .armor-pip.danger {
  background: linear-gradient(180deg, #ff0044 0%, #bb002f 100%);
  border-color: #ff88aa;
  box-shadow: 0 0 12px rgba(255, 0, 68, 0.9), inset 0 1px 2px #ffffff;
  animation: pulse-danger 0.4s infinite alternate;
}

/* Bottom HUD (Speedometer, Gear & Turbo Boost) */
#hud-bottom {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  width: 100%;
}

.speedo-container {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 14px;
  background: transparent !important;
  border: none !important;
  border-radius: 0 !important;
  padding: 0 !important;
  box-shadow: none !important;
}

#tachometer-canvas {
  width: 116px;
  height: 116px;
  display: block;
}

.speedo-digital {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  min-width: 110px;
}

.speed-row {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 6px;
  font-family: 'Teko', sans-serif;
  line-height: 1;
}

#speed-value {
  font-size: 56px;
  font-weight: 700;
  color: #ffff00;
  text-shadow: 0 0 15px rgba(255, 255, 0, 0.8), 2px 2px 0 #000;
}

.speed-unit {
  font-size: 20px;
  color: #ff6600;
  letter-spacing: 1px;
}

.speedo-bar-container {
  width: 100%;
  height: 10px;
  background: #201a35;
  border-radius: 4px;
  overflow: hidden;
  margin-top: 4px;
  border: 1px solid #4a3e75;
}

#speedo-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #00ff88 0%, #ffff00 65%, #ff0044 100%);
  transition: width 0.05s linear;
  box-shadow: 0 0 8px rgba(255, 255, 0, 0.5);
}

.hud-bottom-right-group {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.hud-bottom-right-group #hud-armor-box {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(10, 5, 25, 0.80);
  border: 2px solid #00ff88;
  border-radius: 8px;
  padding: 6px 14px;
  box-shadow: inset 0 0 10px rgba(0, 255, 136, 0.25), 0 4px 12px rgba(0, 0, 0, 0.7);
  width: 100%;
  box-sizing: border-box;
}

.hud-bottom-right-group #hud-armor-box .hud-label {
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  color: #00ff88;
  letter-spacing: 1.5px;
  text-shadow: 0 0 8px rgba(0, 255, 136, 0.8);
  margin: 0;
}

/* Bottom Right Turbo Boost Container */
.turbo-container {
  display: flex;
  flex-direction: column;
  background: rgba(10, 5, 25, 0.80);
  border: 2px solid #00f0ff;
  border-radius: 8px;
  padding: 10px 16px;
  box-shadow: inset 0 0 12px rgba(0, 240, 255, 0.3), 0 4px 15px rgba(0, 0, 0, 0.8);
  min-width: 230px;
  transition: border-color 0.25s, box-shadow 0.25s;
}

.turbo-container.ready {
  border-color: #ff007f;
  box-shadow: 0 0 22px rgba(255, 0, 127, 0.85), inset 0 0 14px rgba(255, 0, 127, 0.4);
  animation: pulse-turbo 0.45s infinite alternate;
}

@keyframes pulse-turbo {
  from {
    border-color: #ff007f;
    box-shadow: 0 0 12px #ff007f, inset 0 0 8px rgba(255, 0, 127, 0.3);
  }
  to {
    border-color: #ffff00;
    box-shadow: 0 0 28px #ff007f, 0 0 15px #ffff00, inset 0 0 20px rgba(255, 0, 127, 0.6);
  }
}

.turbo-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.turbo-title {
  font-size: 10px;
  color: #00f0ff;
  letter-spacing: 1px;
}

.turbo-container.ready .turbo-title {
  color: #ffff00;
  text-shadow: 0 0 8px #ffff00;
}

.turbo-val {
  font-family: 'Teko', sans-serif;
  font-size: 34px;
  font-weight: 700;
  color: #00f0ff;
  line-height: 1;
  text-shadow: 0 0 10px #00f0ff;
}

.turbo-container.ready .turbo-val {
  color: #ff007f;
  text-shadow: 0 0 12px #ff007f, 0 0 25px rgba(255, 0, 127, 0.8);
}

.turbo-bar-container {
  width: 100%;
  height: 10px;
  background: #201a35;
  border-radius: 4px;
  overflow: hidden;
  margin-top: 4px;
  border: 1px solid #4a3e75;
}

#turbo-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #00f0ff 0%, #0088ff 50%, #ff007f 100%);
  transition: width 0.08s linear;
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.7);
}

.turbo-container.ready #turbo-bar {
  background: linear-gradient(90deg, #ff007f 0%, #ffcc00 100%);
  box-shadow: 0 0 14px rgba(255, 0, 127, 0.9);
}

.turbo-hint {
  font-size: 7.5px;
  color: #00f0ff;
  margin-top: 5px;
  text-align: center;
  letter-spacing: 0.5px;
  line-height: 1.3;
}

.turbo-container.ready .turbo-hint {
  color: #ffdd00;
  font-weight: bold;
  text-shadow: 0 0 8px #ffdd00;
  letter-spacing: 1px;
}

/* Start, Goal & Pause Overlays */
#overlay-start, #overlay-goal, #overlay-pause {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(2, 45, 80, 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 90;
  transition: opacity 0.3s ease;
}

.hidden,
#overlay-start.hidden, #overlay-timeout.hidden, #overlay-goal.hidden, #overlay-gameover.hidden, #overlay-pause.hidden, #overlay-leaderboard.hidden {
  display: none !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* ==========================================================
   UNIFIED RETRO CYBER ARCADE PANELS & OVERLAYS
   ========================================================== */
.menu-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: clamp(380px, 86vw, 640px);
  max-width: 95vw;
  max-height: 94vh;
  overflow: hidden;
  background: rgba(255, 252, 246, 0.95);
  border: 2.5px solid #00b4d8;
  border-radius: 14px;
  padding: clamp(14px, 2.6vh, 22px) clamp(16px, 2.8vw, 26px);
  box-shadow: 
    0 12px 35px rgba(0, 70, 140, 0.20),
    0 4px 12px rgba(0, 0, 0, 0.08),
    inset 0 0 20px rgba(255, 255, 255, 0.9),
    0 0 20px rgba(0, 180, 216, 0.25);
  text-align: center;
  box-sizing: border-box;
  animation: menu-panel-pop 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}

@keyframes menu-panel-pop {
  0% {
    transform: scale(0.92) translateY(8px);
    opacity: 0;
  }
  100% {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

.menu-header {
  margin-bottom: clamp(6px, 1.2vh, 12px);
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  width: 100%;
}

.menu-logo-img {
  height: clamp(115px, 24vh, 165px);
  width: auto;
  aspect-ratio: 810 / 292;
  max-width: 92%;
  object-fit: contain;
  margin: 0 auto;
  display: block;
  filter: drop-shadow(0 6px 18px rgba(230, 80, 0, 0.42));
  animation: logo-shimmer-float 3s ease-in-out infinite alternate;
}

@keyframes logo-shimmer-float {
  0% {
    transform: translateY(0);
  }
  100% {
    transform: translateY(-4px);
  }
}

/* Title with Specular Shimmer Reflection and Breathing Glow */
.menu-title {
  position: relative;
  display: inline-block;
  font-family: 'Press Start 2P', monospace, sans-serif;
  font-size: clamp(20px, 3.5vw, 32px);
  font-weight: 900;
  letter-spacing: 3px;
  margin: 0 0 4px 0;
  text-align: center;
  background: linear-gradient(
    115deg,
    #ff3838 0%,
    #ff793f 35%,
    #ffb142 65%,
    #fffa65 100%
  );
  background-size: 260% 100%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: title-shimmer 3s ease-in-out infinite, title-breathe 2.5s ease-in-out infinite alternate;
  filter: drop-shadow(0 2px 8px rgba(235, 77, 75, 0.35)) drop-shadow(0 4px 16px rgba(255, 177, 66, 0.25));
}

@keyframes title-shimmer {
  0% {
    background-position: 140% 0;
  }
  50%, 100% {
    background-position: -140% 0;
  }
}

@keyframes title-breathe {
  0% {
    transform: scale(1);
    filter: drop-shadow(0 2px 8px rgba(235, 77, 75, 0.35)) drop-shadow(0 4px 16px rgba(255, 177, 66, 0.25));
  }
  100% {
    transform: scale(1.02);
    filter: drop-shadow(0 3px 12px rgba(235, 77, 75, 0.50)) drop-shadow(0 6px 22px rgba(255, 177, 66, 0.40));
  }
}

.menu-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  gap: clamp(10px, 1.8vh, 16px);
}

.menu-view.hidden {
  display: none !important;
}

.submenu-title {
  font-family: 'Press Start 2P', sans-serif;
  font-size: clamp(13px, 2vw, 16px);
  color: #e63946;
  margin: 0 0 10px 0;
  letter-spacing: 1.5px;
  text-align: center;
  text-shadow: 0 1px 3px rgba(230, 57, 70, 0.25);
}

/* ==========================================================
   INTERACTIVE MENU BUTTONS WITH SELECTION & ARROW ANIMATIONS
   ========================================================== */
.menu-btn {
  position: relative;
  font-family: 'Press Start 2P', monospace, sans-serif;
  font-size: clamp(10.5px, 1.6vw, 13px);
  color: #023e8a;
  background: #ffffff;
  border: 2px solid #00b4d8;
  border-radius: 9px;
  padding: clamp(9px, 1.4vh, 12px) 18px;
  width: clamp(260px, 55vw, 360px);
  max-width: 95%;
  min-height: clamp(38px, 5.8vh, 44px);
  cursor: pointer;
  letter-spacing: 1.2px;
  text-align: center;
  transition: all 0.18s cubic-bezier(0.2, 0.8, 0.25, 1);
  box-sizing: border-box;
  box-shadow: 0 4px 12px rgba(0, 180, 216, 0.18), 0 1px 3px rgba(0, 0, 0, 0.06);
  user-select: none;
  outline: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auto-accel-btn {
  font-size: clamp(9.5px, 1.35vw, 11px);
  letter-spacing: 0.8px;
  white-space: nowrap;
  padding: clamp(9px, 1.4vh, 12px) 16px;
  min-height: clamp(38px, 5.8vh, 44px);
  color: #023e8a;
  border: 2px solid #00b4d8;
  background: #ffffff;
}

.auto-accel-btn::before {
  left: 16px;
}

.auto-accel-btn::after {
  right: 16px;
}

/* Retro Pointer Arrows (► and ◄) on Selection / Hover */
.menu-btn::before {
  content: '►';
  position: absolute;
  left: 16px;
  opacity: 0;
  transform: translateX(-8px);
  transition: opacity 0.18s ease, transform 0.18s cubic-bezier(0.18, 0.89, 0.32, 1.28);
  font-size: 15px;
}

.menu-btn::after {
  content: '◄';
  position: absolute;
  right: 16px;
  opacity: 0;
  transform: translateX(8px);
  transition: opacity 0.18s ease, transform 0.18s cubic-bezier(0.18, 0.89, 0.32, 1.28);
  font-size: 15px;
}

.menu-btn:hover::before,
.menu-btn:focus::before,
.menu-btn:active::before,
.menu-btn.keyboard-selected::before {
  opacity: 1;
  transform: translateX(0);
  animation: pointer-bounce-left 0.65s infinite alternate ease-in-out;
}

.menu-btn:hover::after,
.menu-btn:focus::after,
.menu-btn:active::after,
.menu-btn.keyboard-selected::after {
  opacity: 1;
  transform: translateX(0);
  animation: pointer-bounce-right 0.65s infinite alternate ease-in-out;
}

@keyframes pointer-bounce-left {
  from { transform: translateX(0); }
  to { transform: translateX(-4px); }
}

@keyframes pointer-bounce-right {
  from { transform: translateX(0); }
  to { transform: translateX(4px); }
}

.menu-btn:hover,
.menu-btn:focus,
.menu-btn:active,
.menu-btn.keyboard-selected {
  transform: scale(0.97) translateY(1px);
  color: #ffffff;
  border-color: #0077b6;
  background: #0096c7;
  box-shadow: 0 0 22px rgba(0, 180, 216, 0.85), inset 0 0 10px rgba(255, 255, 255, 0.5);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

.menu-btn.primary-btn {
  color: #ffffff;
  border-color: #2ed573;
  background: linear-gradient(180deg, #10b981 0%, #059669 100%);
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.40);
  text-shadow: 0 1px 2px rgba(4, 120, 87, 0.60);
}

.menu-btn.primary-btn:hover,
.menu-btn.primary-btn:focus,
.menu-btn.primary-btn:active,
.menu-btn.primary-btn.keyboard-selected {
  color: #ffffff;
  background: linear-gradient(180deg, #059669 0%, #047857 100%);
  border-color: #a7f3d0;
  box-shadow: 0 0 26px rgba(16, 185, 129, 0.90), inset 0 0 10px rgba(255, 255, 255, 0.4);
  text-shadow: none;
}

.menu-btn.traffic-btn {
  color: #ffffff;
  border-color: #f39c12;
  background: linear-gradient(180deg, #f39c12 0%, #d35400 100%);
  box-shadow: 0 4px 15px rgba(243, 156, 18, 0.40);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.menu-btn.traffic-btn:hover,
.menu-btn.traffic-btn:focus,
.menu-btn.traffic-btn:active,
.menu-btn.traffic-btn.keyboard-selected {
  color: #ffffff;
  background: linear-gradient(180deg, #e67e22 0%, #c0392b 100%);
  border-color: #ffeaa7;
  box-shadow: 0 0 26px rgba(230, 126, 34, 0.90), inset 0 0 10px rgba(255, 255, 255, 0.4);
}
.menu-btn.leaderboard-btn {
  color: #ffffff;
  border-color: #f1c40f;
  background: linear-gradient(180deg, #f39c12 0%, #d35400 100%);
  box-shadow: 0 4px 14px rgba(243, 156, 18, 0.35);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.menu-btn.leaderboard-btn:hover,
.menu-btn.leaderboard-btn:focus,
.menu-btn.leaderboard-btn:active,
.menu-btn.leaderboard-btn.keyboard-selected {
  color: #ffffff;
  background: linear-gradient(180deg, #f1c40f 0%, #e67e22 100%);
  border-color: #ffffff;
  box-shadow: 0 0 28px rgba(241, 196, 15, 0.95), inset 0 0 10px rgba(255, 255, 255, 0.4);
}

.menu-btn.exit-btn {
  color: #ffffff;
  border-color: #ff7675;
  background: #d63031;
  box-shadow: 0 4px 14px rgba(214, 48, 49, 0.35);
  text-shadow: none;
}

.menu-btn.exit-btn:hover,
.menu-btn.exit-btn:focus,
.menu-btn.exit-btn:active,
.menu-btn.exit-btn.keyboard-selected {
  color: #ffffff;
  background: #ff2244;
  border-color: #ffffff;
  box-shadow: 0 0 28px rgba(255, 34, 68, 1.0);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

.menu-btn.back-btn {
  font-size: clamp(10.5px, 1.6vw, 13px);
  padding: clamp(9px, 1.4vh, 12px) 18px;
  min-height: clamp(38px, 5.8vh, 44px);
  width: clamp(260px, 55vw, 360px);
  color: #023e8a;
  border-color: #00b4d8;
  background: #ffffff;
  box-shadow: 0 4px 12px rgba(0, 180, 216, 0.18);
  text-shadow: none;
}

.menu-btn.back-btn:hover,
.menu-btn.back-btn:focus,
.menu-btn.back-btn:active,
.menu-btn.back-btn.keyboard-selected {
  color: #ffffff;
  background: #0096c7;
  border-color: #caf0f8;
  box-shadow: 0 0 20px rgba(0, 180, 216, 0.85);
  text-shadow: none;
}

.overlay-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin-top: 18px;
}

/* ==========================================================
   TIME OUT OVERLAY
   ========================================================== */
.timeout-panel {
  width: clamp(380px, 86vw, 560px);
  background: rgba(255, 252, 246, 0.96) !important;
  border: 2.5px solid #ff9f1a;
  border-radius: 14px;
  box-shadow: 0 12px 35px rgba(255, 159, 26, 0.25), 0 4px 12px rgba(0, 0, 0, 0.08);
}

.timeout-title {
  position: relative;
  display: inline-block;
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(28px, 4.5vw, 42px);
  letter-spacing: 3px;
  margin: 0 0 12px 0;
  text-align: center;
  line-height: 1.2;
  background: linear-gradient(115deg, #ff3838 0%, #ff9f1a 50%, #ffcc00 100%);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: title-shimmer 2.5s ease-in-out infinite;
  filter: drop-shadow(0 2px 8px rgba(255, 159, 26, 0.4));
}

.timeout-gameover {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(14px, 2.5vw, 20px);
  color: #d63031;
  letter-spacing: 3px;
  margin: 0 0 10px 0;
  text-align: center;
}

.timeout-hint {
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  color: #0077b6;
  margin-top: 14px;
  letter-spacing: 1px;
  animation: blink 1.4s infinite;
}

/* ==========================================================
   GAME OVER PANEL (CRASH)
   ========================================================== */
.gameover-panel {
  width: clamp(380px, 86vw, 560px);
  background: rgba(255, 252, 246, 0.96) !important;
  border: 2.5px solid #d63031;
  border-radius: 14px;
  box-shadow: 0 12px 35px rgba(214, 48, 49, 0.25), 0 4px 12px rgba(0, 0, 0, 0.08);
}

.white-cross {
  font-size: 32px;
  color: #d63031;
  margin-bottom: 4px;
}

.death-quote {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(16px, 2.8vw, 22px);
  color: #d63031;
  letter-spacing: 2px;
  margin: 6px 0;
}

.restart-hint {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(8px, 1.2vw, 10px);
  color: #555555;
  margin-bottom: 12px;
}

.gameover-stats {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-bottom: 12px;
}

.stat-col {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-val {
  font-family: 'Teko', sans-serif;
  font-size: 26px;
  font-weight: bold;
  color: #023e8a;
}

.stat-lbl {
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  color: #0077b6;
}

.key-restart-hint {
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  color: #0077b6;
  margin-top: 12px;
  animation: blink 1.4s infinite;
}

/* ==========================================================
   VICTORY OVERLAY PANEL
   ========================================================== */
.victory-panel {
  width: clamp(480px, 88vw, 680px);
  max-width: 95vw;
  max-height: 94vh;
  overflow-y: auto;
  background: rgba(255, 252, 246, 0.96) !important;
  border: 2.5px solid #10b981;
  border-radius: 14px;
  box-shadow: 0 12px 35px rgba(16, 185, 129, 0.25), 0 4px 12px rgba(0, 0, 0, 0.08);
  padding: clamp(14px, 2.5vh, 24px) clamp(18px, 3vw, 32px);
}

.victory-title {
  position: relative;
  display: inline-block;
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(20px, 3.2vw, 32px) !important;
  letter-spacing: 2px !important;
  margin: 0 0 10px 0 !important;
  text-align: center;
  width: 100%;
  white-space: nowrap;
  line-height: 1.2;
  background: linear-gradient(115deg, #059669 0%, #10b981 50%, #34d399 100%);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: title-shimmer 2.8s ease-in-out infinite;
  filter: drop-shadow(0 2px 6px rgba(16, 185, 129, 0.35));
}

.victory-subtitle {
  color: #0077b6;
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(9px, 1.3vw, 11px);
  letter-spacing: 1.2px;
  line-height: 1.5;
  text-align: center;
  margin: 0 0 14px 0;
  width: 100%;
}

.victory-stats {
  width: 100%;
  max-width: 500px;
  margin: 0 auto 10px auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.94);
  padding: 16px 22px;
  border-radius: 9px;
  border: 1.5px solid #10b981;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.15);
  box-sizing: border-box;
}

.victory-row {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  font-size: clamp(9.5px, 1.4vw, 11.5px);
  letter-spacing: 1px;
  line-height: 1.4;
  gap: 12px;
  text-align: center;
}

.victory-label {
  color: #023e8a;
  font-weight: normal;
  white-space: nowrap;
  text-align: right;
  flex: 1;
}

.victory-val {
  color: #e67e22;
  font-weight: bold;
  text-align: left;
  flex: 1;
  white-space: nowrap;
}

.victory-val.bonus-val {
  color: #10b981;
}

.victory-separator {
  width: 90%;
  height: 1px;
  background: linear-gradient(90deg, transparent, #10b981, transparent);
  margin: 4px auto;
  opacity: 0.7;
}

.victory-row.total-row {
  padding-top: 4px;
  font-size: clamp(10.5px, 1.6vw, 13px);
}

.victory-val.total-val {
  color: #0077b6;
  font-size: clamp(13px, 1.8vw, 16px);
}

.victory-timer-wrap {
  width: 100%;
  max-width: 440px;
  margin: 14px auto 4px auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.victory-timer-track {
  width: 100%;
  height: 8px;
  background: #caf0f8;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid #00b4d8;
}

.victory-timer-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #10b981, #00b4d8, #e67e22);
  border-radius: 4px;
  transition: width 0.08s linear;
}

.victory-redirect-hint {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(7.5px, 1.1vw, 9px);
  color: #0077b6;
  letter-spacing: 1.2px;
  margin: 0;
  animation: blink 1.2s infinite;
}

/* ==========================================================
   ARCADE LEADERBOARD OVERLAY PANEL
   ========================================================== */
#overlay-leaderboard {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(2, 45, 80, 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  transition: opacity 0.3s ease;
}

.leaderboard-panel {
  width: clamp(440px, 88vw, 620px);
  max-width: 95vw;
  max-height: 94vh;
  overflow: hidden;
  border: 2.5px solid #00b4d8;
  border-radius: 14px;
  padding: clamp(12px, 2.2vh, 18px) clamp(12px, 2.2vw, 20px);
  background: rgba(255, 252, 246, 0.96) !important;
  box-shadow: 0 12px 35px rgba(0, 70, 140, 0.20), 0 4px 12px rgba(0, 0, 0, 0.08), inset 0 0 20px rgba(255, 255, 255, 0.9), 0 0 20px rgba(0, 180, 216, 0.25);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  box-sizing: border-box;
}

.leaderboard-title {
  position: relative;
  display: inline-block;
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(14px, 2.2vw, 18px) !important;
  letter-spacing: 1.5px !important;
  margin: 0 0 2px 0 !important;
  text-align: center;
  width: 100%;
  white-space: nowrap;
  background: linear-gradient(115deg, #e67e22 0%, #ff4757 50%, #00b4d8 100%);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: title-shimmer 2.8s ease-in-out infinite;
  filter: drop-shadow(0 2px 6px rgba(230, 126, 34, 0.35));
}

.leaderboard-subtitle {
  color: #0077b6;
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(7.5px, 1.1vw, 9px);
  letter-spacing: 1px;
  line-height: 1.2;
  text-align: center;
  margin: 0 0 5px 0;
  width: 100%;
}

.leaderboard-entry-box {
  width: 100%;
  max-width: 460px;
  background: linear-gradient(135deg, rgba(255, 234, 167, 0.40), rgba(202, 240, 248, 0.50));
  border: 1.5px solid #00b4d8;
  border-radius: 8px;
  padding: 4px 10px;
  margin-bottom: 5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  box-shadow: 0 2px 10px rgba(0, 180, 216, 0.15);
  box-sizing: border-box;
}

.entry-badge {
  font-family: 'Press Start 2P', monospace;
  font-size: 7.5px;
  color: #e67e22;
  letter-spacing: 1px;
  font-weight: bold;
  animation: blink 1.2s infinite;
}

.entry-prompt {
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  color: #023e8a;
  letter-spacing: 0.8px;
  margin: 0;
  text-align: center;
}

.entry-slots-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 1px 0;
  position: relative;
}

.entry-slots {
  display: flex;
  gap: 6px;
  cursor: pointer;
}

.initial-slot {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: 28px;
  height: 30px;
  font-family: 'Press Start 2P', monospace;
  font-size: 14px;
  color: #023e8a;
  background: #ffffff;
  border: 1.5px solid #00b4d8;
  border-radius: 4px;
  box-shadow: 0 2px 4px rgba(0, 180, 216, 0.15);
  transition: all 0.2s ease;
  user-select: none;
}

.initial-slot.active {
  border-color: #ff4757;
  color: #ff4757;
  background: #fff5f5;
  box-shadow: 0 0 10px rgba(255, 71, 87, 0.4);
}

.initials-hidden-input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

.submit-initials-btn {
  font-size: 7.5px !important;
  padding: 4px 8px !important;
  min-width: 60px !important;
  height: 30px !important;
  color: #ffffff !important;
  border-color: #10b981 !important;
  background: #10b981 !important;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3) !important;
}

.submit-initials-btn:hover {
  background: #059669 !important;
}

.entry-hint {
  font-family: 'Press Start 2P', monospace;
  font-size: 6.5px;
  color: #666666;
  letter-spacing: 0.6px;
  margin: 0;
  text-align: center;
}

.leaderboard-feedback-msg {
  font-family: 'Press Start 2P', monospace;
  font-size: 7.5px;
  color: #10b981;
  margin: 2px 0 4px 0;
  text-align: center;
  letter-spacing: 0.8px;
}

.leaderboard-table-container {
  width: 100%;
  max-width: 480px;
  background: rgba(255, 255, 255, 0.94);
  border: 1.5px solid #bde0fe;
  border-radius: 8px;
  padding: 4px 8px;
  box-shadow: 0 2px 8px rgba(0, 119, 182, 0.08);
  box-sizing: border-box;
  margin: 4px 0;
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
}

.leaderboard-table th {
  font-family: 'Press Start 2P', monospace;
  font-size: 7.5px;
  color: #0077b6;
  padding: 5px 6px;
  border-bottom: 1.5px solid #bde0fe;
  letter-spacing: 1px;
}

.leaderboard-table td {
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  padding: 4px 6px;
  color: #023e8a;
  border-bottom: 1px solid #edf2f7;
}

.leaderboard-row.player-entry {
  background: #fff3bf;
  animation: playerRowPulse 1.2s infinite alternate ease-in-out;
}

@keyframes playerRowPulse {
  0% { box-shadow: 0 0 6px rgba(243, 156, 18, 0.4); }
  100% { box-shadow: 0 0 12px rgba(243, 156, 18, 0.8); }
}

.leaderboard-row.player-entry td {
  color: #d35400;
  font-weight: bold;
}

.leaderboard-row.empty-slot {
  opacity: 0.4;
}

.leaderboard-tabs {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
  margin-bottom: 2px;
}

.menu-btn.leaderboard-mode-btn {
  flex: 1;
  max-width: 220px;
  padding: 8px 10px;
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(8px, 1.2vw, 9.5px);
  letter-spacing: 0.5px;
  background: #ffffff;
  color: #0077b6;
  border: 2px solid #bde0fe;
  border-radius: 8px;
  box-shadow: 0 3px 8px rgba(0, 119, 182, 0.12);
  transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
  cursor: pointer;
  margin: 0;
}

.menu-btn.leaderboard-mode-btn:hover,
.menu-btn.leaderboard-mode-btn:focus,
.menu-btn.leaderboard-mode-btn.keyboard-selected {
  border-color: #00b4d8;
  color: #023e8a;
  background: #f0f9ff;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 180, 216, 0.35);
}

.menu-btn.leaderboard-mode-btn.active {
  background: linear-gradient(180deg, #ff793f 0%, #d63031 100%);
  color: #ffffff;
  border-color: #fffa65;
  box-shadow: 0 0 16px rgba(255, 121, 63, 0.7), inset 0 0 6px rgba(255, 255, 255, 0.4);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  transform: translateY(-1px);
}

.menu-btn.leaderboard-mode-btn.active:hover,
.menu-btn.leaderboard-mode-btn.active.keyboard-selected {
  background: linear-gradient(180deg, #ff9f1a 0%, #e17055 100%);
  border-color: #ffffff;
  box-shadow: 0 0 20px rgba(255, 159, 26, 0.9), inset 0 0 8px rgba(255, 255, 255, 0.5);
}

.leaderboard-actions {
  width: 100%;
  max-width: 440px;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 8px;
}

.leaderboard-actions .menu-btn {
  flex: 1;
  max-width: 200px;
  margin: 0;
}

/* ==========================================================
   OPTIONS VIEW STYLING
   ========================================================== */
#menu-view-options {
  gap: clamp(9px, 1.6vh, 14px);
}

#menu-view-options .submenu-title {
  position: relative;
  display: inline-block;
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(16px, 2.8vw, 22px);
  font-weight: 900;
  letter-spacing: 2.5px;
  margin: 0 0 clamp(8px, 1.4vh, 12px) 0;
  text-align: center;
  background: linear-gradient(180deg, #ff3838 0%, #ff9f1a 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 2px 6px rgba(255, 159, 26, 0.35));
}

.options-group {
  width: clamp(260px, 55vw, 360px);
  max-width: 95%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 2px;
  background: rgba(255, 255, 255, 0.92);
  border: 2px solid #00b4d8;
  border-radius: 9px;
  padding: clamp(8px, 1.3vh, 11px) clamp(12px, 2vw, 16px);
  box-sizing: border-box;
  box-shadow: 0 4px 12px rgba(0, 180, 216, 0.18), 0 1px 3px rgba(0, 0, 0, 0.06);
}

#menu-view-options .menu-btn {
  width: clamp(260px, 55vw, 360px);
  max-width: 95%;
  min-height: clamp(38px, 5.8vh, 44px);
  padding: clamp(9px, 1.4vh, 12px) 18px;
  font-size: clamp(9px, 1.3vw, 11.5px);
  white-space: nowrap;
}

.options-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.opt-label {
  font-family: 'Press Start 2P', sans-serif;
  font-size: 8.5px;
  color: #023e8a;
  white-space: nowrap;
  letter-spacing: 0.8px;
  width: 130px;
  min-width: 130px;
  flex-shrink: 0;
  text-align: left;
  text-shadow: none;
}

.slider-wrap {
  flex: 1;
  display: flex;
  align-items: center;
}

.opt-val {
  font-family: 'Teko', sans-serif;
  font-size: 22px;
  font-weight: 700;
  color: #ff4757;
  width: 44px;
  min-width: 44px;
  flex-shrink: 0;
  text-align: right;
  line-height: 1;
}

/* Audio Controls in Start Screen & Pause */
.audio-controls-panel {
  width: clamp(260px, 55vw, 360px);
  max-width: 95%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: clamp(10px, 1.8vh, 16px);
  background: rgba(255, 255, 255, 0.90);
  padding: clamp(8px, 1.3vh, 11px) clamp(12px, 2vw, 16px);
  border-radius: 9px;
  border: 1.5px solid #00b4d8;
  box-shadow: 0 4px 14px rgba(0, 180, 216, 0.15);
  box-sizing: border-box;
}

.volume-control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.vol-label {
  font-family: 'Press Start 2P', monospace;
  font-size: 8.5px;
  color: #023e8a;
  width: 105px;
  min-width: 105px;
  flex-shrink: 0;
  text-align: left;
  letter-spacing: 0.8px;
  text-shadow: none;
}

.vol-slider-wrap {
  flex: 1;
  display: flex;
  align-items: center;
}

.retro-slider {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 10px;
  background: #caf0f8;
  border-radius: 5px;
  outline: none;
  border: 1.5px solid #00b4d8;
  cursor: pointer;
  transition: box-shadow 0.2s;
}

.retro-slider:hover,
.retro-slider:focus {
  box-shadow: 0 0 10px rgba(0, 180, 216, 0.5);
}

.retro-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: #ff4757;
  border: 2px solid #ffffff;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(255, 71, 87, 0.5);
  transition: transform 0.1s, background-color 0.1s;
}

.retro-slider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
  background: #ff6b81;
}

.retro-slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: #ff4757;
  border: 2px solid #ffffff;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(255, 71, 87, 0.5);
}

.vol-value {
  font-family: 'Teko', sans-serif;
  font-size: 22px;
  font-weight: 700;
  color: #ff4757;
  min-width: 44px;
  text-align: right;
  line-height: 1;
}

/* Controls & Tips Styling */
#menu-view-controls {
  max-height: 88vh;
  overflow-y: auto;
  gap: clamp(6px, 1.2vh, 8px);
  padding: 4px 6px;
}

.controls-list {
  width: 100%;
  max-width: 460px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: rgba(255, 255, 255, 0.94);
  border: 1.5px solid #bde0fe;
  border-radius: 8px;
  padding: 8px 14px;
  box-sizing: border-box;
  box-shadow: 0 2px 8px rgba(0, 119, 182, 0.08);
}

.ctrl-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.ctrl-key {
  font-family: 'Press Start 2P', sans-serif;
  font-size: 8.5px;
  background: #ffbe76;
  color: #000000;
  padding: 3px 6px;
  border-radius: 4px;
  white-space: nowrap;
  letter-spacing: 0.5px;
  font-weight: bold;
}

.ctrl-desc {
  font-family: 'Press Start 2P', sans-serif;
  font-size: 8px;
  color: #023e8a;
  text-align: right;
  font-weight: bold;
}

.tips-box {
  width: 100%;
  max-width: 460px;
  background: rgba(255, 255, 255, 0.94);
  border-left: 4px solid #ff9f1a;
  border-radius: 6px;
  padding: 8px 12px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 5px;
  box-sizing: border-box;
  box-shadow: 0 2px 8px rgba(0, 119, 182, 0.08);
}

.tip-line {
  font-family: 'Press Start 2P', sans-serif;
  font-size: 7.5px;
  color: #333333;
  line-height: 1.5;
  margin: 0;
}

.tip-line strong {
  color: #e67e22;
}

.exit-message {
  font-family: 'Press Start 2P', sans-serif;
  font-size: 9.5px;
  color: #023e8a;
  line-height: 1.8;
  margin: 14px 0 20px 0;
}

.press-key-hint {
  font-size: 8px;
  color: #0077b6;
  margin-top: 14px;
  animation: blink 1.2s infinite;
}

/* ==========================================================
   PAUSE OVERLAY PANEL
   ========================================================== */
.pause-panel {
  width: clamp(380px, 86vw, 560px);
  background: rgba(255, 252, 246, 0.96) !important;
  border: 2.5px solid #00b4d8;
  border-radius: 14px;
  box-shadow: 0 12px 35px rgba(0, 70, 140, 0.20), 0 4px 12px rgba(0, 0, 0, 0.08);
}

.pause-title {
  position: relative;
  display: inline-block;
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(24px, 4vw, 36px);
  letter-spacing: 3px;
  margin: 0 0 6px 0;
  text-align: center;
  background: linear-gradient(115deg, #ff3838 0%, #ff793f 50%, #fffa65 100%);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: title-shimmer 3s ease-in-out infinite;
  filter: drop-shadow(0 2px 8px rgba(235, 77, 75, 0.35));
}

.pause-subtitle {
  color: #0077b6;
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(8px, 1.2vw, 10px);
  letter-spacing: 1px;
  margin: 0 0 14px 0;
  text-align: center;
}


/* ========================================================
   ARCADE COUNTDOWN OVERLAY (3 - 2 - 1 - VIAAAAAAAAAA!)
   ======================================================== */
#overlay-countdown {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 25;
  pointer-events: none;
  background: transparent !important;
  opacity: 1;
  transition: opacity 0.25s ease;
}

#overlay-countdown.hidden {
  display: none !important;
  opacity: 0 !important;
  pointer-events: none;
}

.countdown-panel {
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
}

#countdown-text {
  font-family: 'Press Start 2P', monospace;
  font-size: 130px;
  font-weight: 900;
  letter-spacing: 4px;
  display: inline-block;
  transform-origin: center center;
}

/* Number 3 - Blazing Neon Yellow */
#countdown-text.count-3 {
  color: #ffea00;
  text-shadow: 
    0 0 20px #ffea00,
    0 0 50px #ffaa00,
    0 0 90px #ff6600,
    6px 6px 0px #884400;
}

/* Number 2 - Electric Arcade Cyan */
#countdown-text.count-2 {
  color: #00f0ff;
  text-shadow: 
    0 0 20px #00f0ff,
    0 0 50px #00aaff,
    0 0 90px #0055ff,
    6px 6px 0px #003388;
}

/* Number 1 - Hot Arcade Magenta / Coral Red */
#countdown-text.count-1 {
  color: #ff2266;
  text-shadow: 
    0 0 20px #ff2266,
    0 0 50px #ff0055,
    0 0 90px #bb0033,
    6px 6px 0px #660011;
}

/* GO! - Massive Screaming Lime Green Arcade Text */
#countdown-text.count-go {
  font-size: 140px;
  color: #39ff14;
  letter-spacing: 6px;
  text-transform: uppercase;
  white-space: nowrap;
  text-shadow: 
    0 0 35px #39ff14,
    0 0 80px #00ee11,
    0 0 130px #008800,
    7px 7px 0px #004400;
}

/* Energetic punchy pop animation when each number appears */
.countdown-pop {
  animation: countdown-pop-anim 0.85s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes countdown-pop-anim {
  0% {
    transform: scale(2.0);
    opacity: 0;
    filter: brightness(2.5);
  }
  25% {
    transform: scale(0.95);
    opacity: 1;
    filter: brightness(1.6);
  }
  40% {
    transform: scale(1.05);
    opacity: 1;
    filter: brightness(1.2);
  }
  60% {
    transform: scale(1);
    opacity: 1;
    filter: brightness(1);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ========================================================
   ARCADE LOSS SPLASH OVERLAYS (TIME IS UP & GAME OVER)
   ======================================================== */
.loss-splash {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.65) !important;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex !important;
  justify-content: center;
  align-items: center;
  z-index: 95;
  cursor: pointer;
  user-select: none;
  animation: lossFadeIn 0.3s ease-out forwards;
}

.loss-splash.hidden {
  display: none !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

@keyframes lossFadeIn {
  from {
    background: rgba(0, 0, 0, 0);
  }
  to {
    background: rgba(0, 0, 0, 0.65);
  }
}

.loss-splash-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  pointer-events: none;
}

.loss-splash-title {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(26px, 6vw, 54px);
  color: #ff0044;
  letter-spacing: clamp(3px, 0.8vw, 6px);
  margin: 0;
  text-transform: uppercase;
  text-shadow:
    0 0 15px rgba(255, 0, 68, 0.95),
    0 0 35px rgba(255, 0, 68, 0.75),
    0 0 65px rgba(255, 0, 68, 0.45),
    4px 4px 0 #000,
    -3px -3px 0 #000;
  animation: lossPulse 1.2s ease-in-out infinite alternate, lossPop 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes lossPop {
  0% {
    transform: scale(0.65);
    opacity: 0;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes lossPulse {
  0% {
    text-shadow:
      0 0 15px rgba(255, 0, 68, 0.95),
      0 0 35px rgba(255, 0, 68, 0.75),
      4px 4px 0 #000;
    transform: scale(1);
  }
  100% {
    text-shadow:
      0 0 25px rgba(255, 60, 110, 1),
      0 0 55px rgba(255, 0, 68, 0.9),
      0 0 90px rgba(255, 0, 68, 0.55),
      4px 4px 0 #000;
    transform: scale(1.05);
  }
}

/* ==========================================================
   STAGE TRANSITION ANNOUNCEMENT BANNER
   ========================================================== */
.stage-transition-banner {
  position: absolute;
  top: 104px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 80;
  pointer-events: none;
  width: auto;
  max-width: 92%;
  box-sizing: border-box;
  animation: banner-pop 0.5s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

.stage-transition-banner.hidden {
  display: none !important;
}

@keyframes banner-pop {
  0% { transform: translateX(-50%) scale(0.85); opacity: 0; }
  100% { transform: translateX(-50%) scale(1); opacity: 1; }
}

.stage-banner-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(4, 8, 24, 0.94);
  border: 2px solid #00f0ff;
  box-shadow: 0 0 25px rgba(0, 240, 255, 0.6), inset 0 0 15px rgba(0, 240, 255, 0.2);
  border-radius: 12px;
  padding: 12px clamp(16px, 3vw, 32px);
  width: max-content;
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

.stage-banner-badge {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(11px, 1.4vw, 15px);
  color: #ffea00;
  text-shadow: 0 0 12px #ffea00, 0 0 24px rgba(255, 234, 0, 0.6);
  letter-spacing: 1px;
  white-space: nowrap;
  text-align: center;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}

.stage-banner-title {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(8.5px, 1.05vw, 12px);
  color: #00f0ff;
  text-shadow: 0 0 10px #00f0ff;
  letter-spacing: 0.8px;
  white-space: nowrap;
  text-align: center;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}

/* ==========================================================
   PAUSE OVERLAY MODAL
   ========================================================== */
.pause-panel {
  border: 2px solid #00f0ff;
  box-shadow: 0 0 35px rgba(0, 240, 255, 0.45), 0 16px 45px rgba(0, 0, 0, 0.95), inset 0 0 20px rgba(0, 240, 255, 0.12);
  max-width: 520px;
}

.pause-title {
  position: relative;
  display: inline-block;
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(26px, 3.8vw, 34px);
  font-weight: 900;
  letter-spacing: 4px;
  margin: 0 0 10px 0;
  text-align: center;
  background: linear-gradient(115deg, #00f0ff 0%, #ffffff 50%, #00f0ff 100%);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: title-shimmer 2.8s ease-in-out infinite;
  filter: drop-shadow(0 0 16px rgba(0, 240, 255, 0.8));
}

.pause-subtitle {
  color: #ffcc00;
  font-size: 9px;
  margin-bottom: 20px;
  letter-spacing: 1px;
  text-shadow: 0 0 8px rgba(255, 204, 0, 0.6);
}

#btn-pause-auto-accel {
  margin: 14px auto 16px auto;
  display: block;
}

/* ==========================================================
   TRAFFIC MODE CSS & HUD COMPONENTS
   ========================================================== */

/* Traffic Mode Button (Modalità Traffico) */
.menu-btn.traffic-btn {
  color: #ffcc00;
  border-color: #e6a100;
  background: #241a05;
}

.menu-btn.traffic-btn:hover,
.menu-btn.traffic-btn.selected,
.menu-btn.traffic-btn:focus-visible {
  color: #000000;
  background: #ffcc00;
  border-color: #ffffff;
  box-shadow: 0 0 26px rgba(255, 204, 0, 0.9), inset 0 0 8px rgba(255, 255, 255, 0.6);
  text-shadow: none;
}

/* HUD Distance Box (Centered in Traffic Mode) */
#hud-distance-box {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: none !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  padding: 0 !important;
  min-width: auto !important;
  text-align: center;
}

#hud-distance-box.hidden {
  display: none !important;
}

.distance-value-large {
  font-family: 'Teko', 'Impact', sans-serif !important;
  font-size: 72px !important;
  font-weight: 700 !important;
  color: #00f0ff !important;
  line-height: 0.8 !important;
  letter-spacing: 2px !important;
  text-shadow: 
    0 4px 10px rgba(0, 0, 0, 0.95),
    0 0 16px rgba(0, 240, 255, 0.75),
    2px 2px 0 #000,
    -2px -2px 0 #000,
    2px -2px 0 #000,
    -2px 2px 0 #000,
    0 2px 0 #000,
    0 -2px 0 #000,
    2px 0 0 #000,
    -2px 0 0 #000 !important;
}


/* Near Miss Floating Arcade Popup */
.near-miss-popup {
  position: absolute;
  top: 180px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 85;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: rgba(10, 15, 35, 0.94);
  border: 2px solid #ffea00;
  box-shadow: 0 0 30px rgba(255, 234, 0, 0.75), 0 0 15px rgba(0, 240, 255, 0.5), inset 0 0 15px rgba(255, 234, 0, 0.25);
  border-radius: 10px;
  padding: 8px 22px;
  transition: opacity 0.3s ease;
}

.near-miss-popup.hidden {
  display: none !important;
}

.near-miss-popup.pop-anim {
  animation: near-miss-burst 0.45s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards;
}

@keyframes near-miss-burst {
  0% { transform: translateX(-50%) scale(0.65); opacity: 0; }
  60% { transform: translateX(-50%) scale(1.15); opacity: 1; }
  100% { transform: translateX(-50%) scale(1); opacity: 1; }
}

.near-miss-title {
  font-family: 'Press Start 2P', monospace;
  font-size: 14px;
  font-weight: bold;
  color: #ffea00;
  text-shadow: 0 0 12px #ffea00, 0 0 24px rgba(255, 234, 0, 0.9);
  letter-spacing: 2px;
}

.near-miss-sub {
  font-family: 'Press Start 2P', monospace;
  font-size: 8.5px;
  color: #00f0ff;
  text-shadow: 0 0 8px #00f0ff;
  letter-spacing: 1px;
}

/* Gameover Stats Panel (Traffic Mode) */
.gameover-stats {
  display: flex;
  gap: 22px;
  justify-content: center;
  align-items: center;
  margin: 10px 0 20px 0;
  padding: 10px 18px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(0, 240, 255, 0.4);
  border-radius: 8px;
  box-shadow: 0 0 16px rgba(0, 240, 255, 0.18);
}

.gameover-stats.hidden {
  display: none !important;
}

.stat-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.stat-val {
  font-family: 'Teko', 'Impact', sans-serif;
  font-size: 32px;
  font-weight: 700;
  color: #00f0ff;
  line-height: 1;
  text-shadow: 0 0 10px rgba(0, 240, 255, 0.7);
}

.stat-lbl {
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  color: #a0aab8;
  letter-spacing: 1px;
}

