/**
 * Neon Racer - Complete CSS Stylesheet
 * Theme: Neon night racing - TRON meets OutRun
 * Features: Animations, responsive design, mobile controls, HUD styling
 */

/* === LOCAL FONT STACK === */
:root {
  --racing-font: "Segoe UI", "Arial Black", "Trebuchet MS", monospace;
}

/* === RESET & BASE === */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0A0A1A;
  font-family: var(--racing-font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  -webkit-touch-callout: none;
}

/* Prevent pull-to-refresh on mobile */
html {
  overscroll-behavior: none;
}

/* === GAME CONTAINER === */
#game-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, #0D0D24 0%, #0A0A1A 50%, #050510 100%);
  overflow: hidden;
  z-index: 1;
}

/* Subtle animated grid background on container */
#game-container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background:
    linear-gradient(rgba(0, 229, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 229, 255, 0.03) 1px, transparent 1px);
  background-size: 50px 50px;
  animation: grid-scroll 20s linear infinite;
  pointer-events: none;
  z-index: 0;
}

@keyframes grid-scroll {
  0% {
    transform: translateY(0);
  }
  100% {
    transform: translateY(50px);
  }
}

/* === CANVAS === */
#gameCanvas {
  display: block;
  /* JS resizeCanvas() sets style.width/height — these are defaults only */
  width: auto;
  height: auto;
  image-rendering: auto;
}

/* Desktop: add border and shadow */
@media (min-width: 768px) {
  #gameCanvas {
    border: 2px solid rgba(0, 229, 255, 0.3);
    border-radius: 4px;
    box-shadow:
      0 0 20px rgba(0, 229, 255, 0.15),
      0 0 60px rgba(0, 229, 255, 0.05),
      inset 0 0 20px rgba(0, 0, 0, 0.3);
  }
}

/* Mobile: no border, full bleed feel */
@media (max-width: 767px) {
  #start-screen{justify-content:flex-start;padding:calc(76px + env(safe-area-inset-top,0px)) 14px calc(24px + env(safe-area-inset-bottom,0px));scrollbar-width:thin}
  #start-screen .game-title{font-size:clamp(34px,11vw,50px);letter-spacing:5px}
  #start-screen .controls-hint{font-size:12px;line-height:1.55;max-width:330px;margin-top:16px}
  #gameCanvas {
    border: none;
    border-radius: 0;
    box-shadow: none;
  }
}

/* Canvas neon pulse animation */
#gameCanvas.active {
  animation: neon-border-pulse 2s ease-in-out infinite;
}

@keyframes neon-border-pulse {
  0%, 100% {
    border-color: rgba(0, 229, 255, 0.3);
    box-shadow:
      0 0 20px rgba(0, 229, 255, 0.15),
      0 0 60px rgba(0, 229, 255, 0.05),
      inset 0 0 20px rgba(0, 0, 0, 0.3);
  }
  50% {
    border-color: rgba(0, 229, 255, 0.6);
    box-shadow:
      0 0 30px rgba(0, 229, 255, 0.3),
      0 0 80px rgba(0, 229, 255, 0.1),
      inset 0 0 20px rgba(0, 0, 0, 0.3);
  }
}

/* === START / MENU SCREEN === */
#start-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10;
  background: rgba(10, 10, 30, 0.85);
  backdrop-filter: blur(4px);
  transition: opacity 0.5s ease;
  overflow-y: auto;
  padding: 20px 0;
}

#start-screen.active {
  display: flex;
}

#start-screen .game-title {
  font-family: var(--racing-font);
  font-size: clamp(36px, 8vw, 72px);
  font-weight: 900;
  color: #FFFFFF;
  text-align: center;
  letter-spacing: 8px;
  animation: neon-pulse 2s ease-in-out infinite;
  margin-bottom: 10px;
}

#start-screen .game-subtitle {
  font-family: var(--racing-font);
  font-size: clamp(14px, 2.5vw, 22px);
  font-weight: 400;
  color: rgba(0, 229, 255, 0.8);
  text-align: center;
  letter-spacing: 4px;
  margin-bottom: 20px;
}

#start-screen .start-prompt {
  font-family: var(--racing-font);
  font-size: clamp(14px, 2.2vw, 20px);
  font-weight: 600;
  color: #FFFFFF;
  text-align: center;
  animation: blink 1.5s ease-in-out infinite;
  cursor: pointer;
  padding: 15px 30px;
  border: 2px solid rgba(0, 229, 255, 0.4);
  border-radius: 8px;
  background: rgba(0, 229, 255, 0.05);
  transition: all 0.3s ease;
}

#start-screen .start-prompt:hover {
  background: rgba(0, 229, 255, 0.15);
  border-color: rgba(0, 229, 255, 0.8);
  box-shadow: 0 0 20px rgba(0, 229, 255, 0.3);
}

#start-screen .menu-stats {
  font-family: var(--racing-font);
  font-size: clamp(12px, 2vw, 16px);
  color: rgba(255, 255, 255, 0.5);
  margin-bottom: 12px;
  text-align: center;
}

#start-screen .menu-stats p {
  margin: 4px 0;
}

/* === DAILY CHALLENGE BANNER === */
.daily-banner {
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.15), rgba(255, 140, 0, 0.1));
  border: 1px solid rgba(255, 215, 0, 0.4);
  border-radius: 8px;
  padding: 8px 16px;
  margin-bottom: 12px;
  text-align: center;
  animation: glow-pulse 3s ease-in-out infinite;
}

.daily-banner .daily-label {
  font-family: var(--racing-font);
  font-size: clamp(10px, 1.5vw, 12px);
  font-weight: 700;
  color: #FFD700;
  letter-spacing: 3px;
  text-transform: uppercase;
}

.daily-banner .daily-target {
  font-family: var(--racing-font);
  font-size: clamp(14px, 2vw, 18px);
  font-weight: 600;
  color: #FFFFFF;
  margin-top: 2px;
}

.daily-banner .daily-status {
  font-family: var(--racing-font);
  font-size: clamp(11px, 1.5vw, 13px);
  color: #76FF03;
  margin-top: 2px;
}

.daily-banner .daily-status.completed {
  color: #76FF03;
}

/* === MODE BUTTONS === */
.mode-btn-group {
  display: flex;
  flex-direction: row;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.mode-btn {
  font-family: var(--racing-font);
  font-size: clamp(10px, 1.5vw, 13px);
  font-weight: 600;
  color: rgba(0, 229, 255, 0.8);
  text-align: center;
  letter-spacing: 1px;
  padding: 8px 16px;
  border: 1.5px solid rgba(0, 229, 255, 0.4);
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  transition: all 0.25s ease;
  text-transform: uppercase;
  pointer-events: auto;
}

.mode-btn:hover {
  background: rgba(0, 229, 255, 0.1);
  border-color: rgba(0, 229, 255, 0.7);
  transform: translateY(-1px);
}

.mode-btn.selected {
  background: rgba(0, 229, 255, 0.2);
  border-color: rgba(0, 229, 255, 0.9);
  color: #FFFFFF;
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.25);
}
button:focus-visible,a:focus-visible{outline:3px solid #ffeb3b;outline-offset:3px}

/* The public start screen has one straightforward endless run. */
.legacy-mode-ui { display: none !important; }

/* Daily challenge button */
.daily-btn {
  border-color: rgba(255, 215, 0, 0.5) !important;
  color: rgba(255, 215, 0, 0.9) !important;
  background: rgba(255, 215, 0, 0.08) !important;
  margin-top: 6px !important;
}

.daily-btn:hover {
  background: rgba(255, 215, 0, 0.18) !important;
  border-color: rgba(255, 215, 0, 0.8) !important;
  box-shadow: 0 0 15px rgba(255, 215, 0, 0.2) !important;
}

/* === STATS PANEL === */
.stats-panel {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 10px 14px;
  margin-top: 12px;
  margin-bottom: 12px;
  text-align: center;
  max-width: 90vw;
  cursor: pointer;
  transition: background 0.2s ease;
}

.stats-panel:hover {
  background: rgba(0, 0, 0, 0.4);
}

.stats-panel .stats-row {
  font-family: var(--racing-font);
  font-size: clamp(10px, 1.4vw, 12px);
  color: rgba(255, 255, 255, 0.55);
  margin: 3px 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 14px;
}

.stats-panel .stats-row span {
  white-space: nowrap;
}

.stats-panel .stats-toggle {
  font-family: var(--racing-font);
  font-size: clamp(9px, 1.2vw, 11px);
  color: rgba(0, 229, 255, 0.5);
  margin-top: 6px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* === ACHIEVEMENT GRID === */
.achievement-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 8px;
  margin-bottom: 12px;
  max-width: 320px;
  width: 90vw;
}

.achievement-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px 6px;
  border-radius: 6px;
  border: 1px solid;
  transition: all 0.3s ease;
  text-align: center;
}

.achievement-badge .ach-icon {
  font-size: clamp(18px, 3vw, 24px);
  margin-bottom: 4px;
}

.achievement-badge .ach-name {
  font-family: var(--racing-font);
  font-size: clamp(9px, 1.2vw, 11px);
  font-weight: 600;
  letter-spacing: 0.5px;
}

.achievement-badge.unlocked {
  background: rgba(255, 215, 0, 0.12);
  border-color: rgba(255, 215, 0, 0.5);
  color: #FFD700;
  animation: ach-unlock 0.6s ease forwards;
}

.achievement-badge.locked {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.3);
  filter: grayscale(0.8);
}

@keyframes ach-unlock {
  0% {
    transform: scale(0.8);
    opacity: 0;
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* === CONTROLS HINT === */
#start-screen .controls-hint {
  font-family: var(--racing-font);
  font-size: clamp(10px, 1.5vw, 14px);
  font-weight: 400;
  color: rgba(255, 255, 255, 0.35);
  text-align: center;
  margin-top: 20px;
  line-height: 2;
}

.key {
  display: inline-block;
  padding: 2px 8px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.85em;
  font-weight: 600;
  margin: 0 2px;
}

/* === GAME OVER SCREEN === */
#game-over-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10;
  background: rgba(5, 5, 15, 0.9);
  backdrop-filter: blur(6px);
  animation: fade-in 0.5s ease;
  overflow-y: auto;
  padding: 20px 0;
}

#game-over-screen.active {
  display: flex;
}

#game-over-screen .game-over-title {
  font-family: var(--racing-font);
  font-size: clamp(28px, 6vw, 56px);
  font-weight: 900;
  color: #FF1744;
  text-align: center;
  animation: shake 0.5s ease;
  text-shadow: 0 0 30px rgba(255, 23, 68, 0.6);
  margin-bottom: 8px;
  line-height: 1.2;
}

/* New best badge */
.new-best-badge {
  font-family: var(--racing-font);
  font-size: clamp(12px, 2vw, 16px);
  font-weight: 700;
  color: #FFD700;
  background: rgba(255, 215, 0, 0.15);
  border: 1px solid rgba(255, 215, 0, 0.4);
  border-radius: 20px;
  padding: 4px 14px;
  margin-bottom: 12px;
  animation: glow-pulse 1.5s ease-in-out infinite;
  letter-spacing: 2px;
  text-transform: uppercase;
}

#game-over-screen .final-stats {
  font-family: var(--racing-font);
  margin-bottom: 16px;
  animation: slide-up 0.8s ease;
}

#game-over-screen .stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 260px;
  max-width: 80vw;
  margin: 0 auto;
  padding: 6px 0;
  font-size: clamp(14px, 2.5vw, 20px);
}

#game-over-screen .stat-label {
  color: rgba(255, 255, 255, 0.55);
  font-weight: 400;
}

#game-over-screen .stat-value {
  color: #FFFFFF;
  font-weight: 700;
}

#game-over-screen .stat-value.new-record {
  color: #FFD700;
  animation: glow-pulse 1s ease-in-out infinite;
}

/* New achievements on game over */
.new-achievements {
  margin-bottom: 12px;
  animation: slide-up 0.8s ease 0.2s both;
  text-align: center;
}

.new-ach-title {
  font-family: var(--racing-font);
  font-size: clamp(12px, 2vw, 16px);
  font-weight: 700;
  color: #FFD700;
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.new-ach-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}

.new-ach-item {
  font-family: var(--racing-font);
  font-size: clamp(11px, 1.8vw, 14px);
  color: #FFD700;
  background: rgba(255, 215, 0, 0.12);
  border: 1px solid rgba(255, 215, 0, 0.35);
  border-radius: 6px;
  padding: 4px 10px;
  animation: ach-unlock 0.5s ease forwards;
}

.new-ach-icon {
  margin-right: 4px;
}

/* Try This Next tip */
.try-next-tip {
  font-family: var(--racing-font);
  font-size: clamp(11px, 1.8vw, 14px);
  font-style: italic;
  color: rgba(0, 229, 255, 0.7);
  text-align: center;
  max-width: 320px;
  margin: 0 auto 12px;
  padding: 0 12px;
  line-height: 1.5;
}

/* Game over stats row */
.game-over-stats-row {
  font-family: var(--racing-font);
  font-size: clamp(10px, 1.5vw, 12px);
  color: rgba(255, 255, 255, 0.4);
  text-align: center;
  margin-bottom: 14px;
  letter-spacing: 1px;
}

#game-over-screen .neon-btn {
  margin-top: 6px;
}

/* === PAUSE SCREEN === */
#pause-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10;
  background: rgba(5, 5, 15, 0.75);
  backdrop-filter: blur(4px);
  animation: fade-in 0.3s ease;
}

#pause-overlay.active {
  display: flex;
}

#pause-screen .pause-title {
  font-family: var(--racing-font);
  font-size: clamp(32px, 6vw, 56px);
  font-weight: 900;
  color: #FFFFFF;
  text-align: center;
  text-shadow: 0 0 25px rgba(0, 229, 255, 0.6);
  margin-bottom: 30px;
}

#pause-overlay .neon-btn {
  margin: 8px 0;
}

/* === NEON BUTTONS === */
.neon-btn {
  font-family: var(--racing-font);
  font-size: clamp(14px, 2.2vw, 20px);
  font-weight: 700;
  color: #FFFFFF;
  text-align: center;
  letter-spacing: 3px;
  padding: 14px 36px;
  border: 2px solid rgba(0, 229, 255, 0.5);
  border-radius: 8px;
  background: rgba(0, 229, 255, 0.08);
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: uppercase;
  pointer-events: auto;
  margin: 8px 0;
}

.neon-btn:hover {
  background: rgba(0, 229, 255, 0.2);
  border-color: rgba(0, 229, 255, 0.9);
  box-shadow:
    0 0 15px rgba(0, 229, 255, 0.3),
    0 0 30px rgba(0, 229, 255, 0.15),
    inset 0 0 15px rgba(0, 229, 255, 0.1);
  transform: scale(1.05);
}

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

.neon-btn.secondary {
  border-color: rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.05);
}

.neon-btn.secondary:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.6);
  box-shadow:
    0 0 15px rgba(255, 255, 255, 0.15),
    inset 0 0 15px rgba(255, 255, 255, 0.05);
}

/* === SCREEN CONTENT === */
.screen-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* === HUD OVERLAYS (HTML-based fallback/enhancement) === */
#hud {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
  display: none;
}

#hud.active {
  display: block;
}

/* A small, explicit exit sits above the driving line instead of floating over
   the car or touch controls. It is only present while the HUD is active. */
.in-game-menu {
  position: absolute;
  top: 70px;
  left: 12px;
  z-index: 2;
  min-height: 32px;
  padding: 6px 10px;
  border: 1px solid rgba(0, 229, 255, .52);
  border-radius: 999px;
  background: rgba(6, 14, 34, .84);
  color: #d9fbff;
  font-family: var(--racing-font);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .7px;
  pointer-events: auto;
  touch-action: manipulation;
}
.in-game-menu:hover { transform: none; background: rgba(0, 229, 255, .18); opacity: 1; }

/* Keep the road and car unobstructed with a compact, non-overlapping HUD. */
.hud-top-left,
.hud-top-center,
.hud-top-right,
.hud-speedometer {
  position: absolute;
  z-index: 1;
  font-family: var(--racing-font);
  color: #FFFFFF;
  text-shadow: 0 0 12px rgba(0, 229, 255, 0.6);
}
.hud-top-left { top: 14px; left: 14px; }
.hud-top-center { top: 14px; left: 50%; transform: translateX(-50%); text-align: center; }
.hud-top-right { top: 14px; right: 14px; text-align: right; }
.hud-speedometer { top: 60px; right: 14px; min-width: 76px; text-align: right; }
.hud-label { color: rgba(0, 229, 255, 0.72); font-size: 10px; font-weight: 800; letter-spacing: 1px; }
.hud-value { font-size: clamp(16px, 3vw, 25px); font-weight: 800; }
.hud-speedometer .hud-speed { position: static; font-size: clamp(20px, 4vw, 32px); }
.speed-gauge { height: 4px; width: 76px; margin: 3px 0 2px auto; overflow: hidden; border-radius: 999px; background: rgba(255,255,255,.18); }
.speed-bar { height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, #00E5FF, #2979FF); }

.hud-score {
  position: absolute;
  top: 15px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--racing-font);
  font-size: clamp(20px, 3.5vw, 32px);
  font-weight: 700;
  color: #FFFFFF;
  text-shadow: 0 0 15px rgba(0, 229, 255, 0.8);
  text-align: center;
}

.hud-highscore {
  position: absolute;
  top: 12px;
  left: 15px;
  font-family: var(--racing-font);
  font-size: clamp(10px, 1.5vw, 14px);
  font-weight: 600;
  color: #FFD700;
  text-shadow: 0 0 8px rgba(255, 215, 0, 0.5);
}

/* Mode label in HUD */
.hud-mode {
  position: absolute;
  top: 34px;
  left: 15px;
  font-family: var(--racing-font);
  font-size: clamp(8px, 1.2vw, 11px);
  font-weight: 600;
  color: rgba(0, 229, 255, 0.6);
  letter-spacing: 1px;
}

/* Timer for Time Attack */
.hud-timer {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--racing-font);
  font-size: clamp(24px, 4vw, 36px);
  font-weight: 800;
  color: #FF1744;
  text-shadow: 0 0 15px rgba(255, 23, 68, 0.6);
  text-align: center;
}

.hud-score-label {
  position: absolute;
  top: 52px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--racing-font);
  font-size: clamp(10px, 1.5vw, 12px);
  font-weight: 600;
  color: rgba(255, 255, 255, 0.5);
  letter-spacing: 2px;
}

.hud-speed {
  position: absolute;
  bottom: 20px;
  right: 20px;
  font-family: var(--racing-font);
  font-size: clamp(24px, 4vw, 40px);
  font-weight: 800;
  color: #FFFFFF;
  text-shadow: 0 0 12px rgba(0, 229, 255, 0.6);
}

.hud-speed::after {
  content: ' KM/H';
  font-size: 0.5em;
  color: rgba(0, 229, 255, 0.6);
}

.hud-nearmiss {
  position: absolute;
  top: 35%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--racing-font);
  font-size: clamp(18px, 3.5vw, 30px);
  font-weight: 800;
  color: #FFD700;
  text-shadow: 0 0 20px rgba(255, 215, 0, 0.8);
  animation: nearmiss-pop 1s ease forwards;
  pointer-events: none;
}

@keyframes nearmiss-pop {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  50% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.2);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -60%) scale(1);
  }
}

/* === MOBILE CONTROLS === */
#mobile-controls {
  position: fixed;
  bottom: max(12px, env(safe-area-inset-bottom));
  left: 12px;
  width: 152px;
  display: none;
  justify-content: space-between;
  padding: 0;
  z-index: 20;
  pointer-events: none;
}

#mobile-controls.visible {
  display: flex;
}

.mobile-btn {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: rgba(0, 229, 255, 0.12);
  border: 2px solid rgba(0, 229, 255, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  cursor: pointer;
  transition: all 0.15s ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.mobile-btn:active,
.mobile-btn.active {
  background: rgba(0, 229, 255, 0.3);
  border-color: rgba(0, 229, 255, 0.8);
  box-shadow: 0 0 20px rgba(0, 229, 255, 0.4);
  transform: scale(1.1);
}

.mobile-btn svg {
  width: 32px;
  height: 32px;
  fill: rgba(0, 229, 255, 0.7);
}

.mobile-btn:active svg,
.mobile-btn.active svg {
  fill: rgba(0, 229, 255, 1);
}

/* Brake & Boost buttons */
#brake-btn {
  position: fixed;
  bottom: max(12px, env(safe-area-inset-bottom));
  right: 82px;
  width: 64px;
  height: 64px;
  border-radius: 16px;
  background: rgba(255, 60, 60, 0.12);
  border: 2px solid rgba(255, 60, 60, 0.35);
  display: none;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  cursor: pointer;
  z-index: 8;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: all 0.15s ease;
}

#brake-btn.visible {
  display: flex;
}

#brake-btn:active,
#brake-btn.active {
  background: rgba(255, 60, 60, 0.35);
  border-color: rgba(255, 60, 60, 0.9);
  box-shadow: 0 0 25px rgba(255, 60, 60, 0.5);
  transform: scale(1.1);
}

#brake-btn {
  font-family: var(--racing-font);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .8px;
  color: rgba(255, 60, 60, 0.8);
}

#brake-btn:active {
  color: #FF3C3C;
}

#boost-btn {
  position: fixed;
  bottom: max(12px, env(safe-area-inset-bottom));
  right: 12px;
  width: 64px;
  height: 64px;
  border-radius: 16px;
  background: rgba(255, 215, 0, 0.12);
  border: 2px solid rgba(255, 215, 0, 0.35);
  display: none;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  cursor: pointer;
  z-index: 8;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: all 0.15s ease;
}

#boost-btn.visible {
  display: flex;
}

#boost-btn:active,
#boost-btn.active {
  background: rgba(255, 215, 0, 0.35);
  border-color: rgba(255, 215, 0, 0.9);
  box-shadow: 0 0 25px rgba(255, 215, 0, 0.5);
  transform: scale(1.1);
}

#boost-btn {
  font-family: var(--racing-font);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .8px;
  color: rgba(255, 215, 0, 0.8);
}

#boost-btn:active {
  color: #FFD700;
}

/* === KEYFRAME ANIMATIONS === */

/* Neon text glow pulse */
@keyframes neon-pulse {
  0%, 100% {
    text-shadow:
      0 0 10px rgba(0, 229, 255, 0.6),
      0 0 30px rgba(0, 229, 255, 0.4),
      0 0 60px rgba(0, 229, 255, 0.2);
  }
  50% {
    text-shadow:
      0 0 20px rgba(0, 229, 255, 1),
      0 0 50px rgba(0, 229, 255, 0.6),
      0 0 90px rgba(0, 229, 255, 0.3);
  }
}

/* Blinking text */
@keyframes blink {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.3;
  }
}

/* Fade in */
@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Slide up with fade */
@keyframes slide-up {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Screen shake for crash */
@keyframes shake {
  0%, 100% {
    transform: translateX(0);
  }
  10% {
    transform: translateX(-8px) translateY(4px);
  }
  20% {
    transform: translateX(8px) translateY(-4px);
  }
  30% {
    transform: translateX(-6px) translateY(3px);
  }
  40% {
    transform: translateX(6px) translateY(-2px);
  }
  50% {
    transform: translateX(-4px);
  }
  60% {
    transform: translateX(4px);
  }
  70% {
    transform: translateX(-2px);
  }
  80% {
    transform: translateX(2px);
  }
}

/* Button glow pulse */
@keyframes glow-pulse {
  0%, 100% {
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
  }
  50% {
    box-shadow: 0 0 25px rgba(255, 215, 0, 0.6);
    text-shadow: 0 0 25px rgba(255, 215, 0, 0.9);
  }
}

/* Count-up animation for score */
@keyframes count-up {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* === RESPONSIVE DESIGN === */
/* Canvas sizing is handled by JS resizeCanvas() — these are supplement rules */

/* Desktop: larger border */
@media (min-width: 1024px) {
  #gameCanvas {
    border-width: 3px;
  }
}

/* Mobile: no border/radius, full bleed */
@media (max-width: 767px) {
  #gameCanvas {
    border: none;
    border-radius: 0;
    box-shadow: none;
  }

  .mobile-btn {
    width: 70px;
    height: 70px;
  }

  .mobile-btn svg {
    width: 28px;
    height: 28px;
  }

  #boost-btn {
    width: 60px;
    height: 60px;
  }

  #brake-btn { right: 76px; width: 60px; height: 60px; }
  .hud-speedometer { top: 58px; right: 12px; }

  /* Mode buttons stack on very small screens */
  .mode-btn-group {
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 200px;
  }

  .mode-btn {
    width: 100%;
    padding: 10px;
  }

  .stats-panel .stats-row {
    flex-direction: column;
    gap: 4px;
  }

  .achievement-grid {
    grid-template-columns: repeat(2, 1fr);
    max-width: 260px;
  }
}

/* Small phones: 2-column achievements */
@media (max-width: 360px) {
  .achievement-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

#orientation-warning {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #0A0A1A;
  z-index: 100;
  padding: 20px;
}

#orientation-warning .rotate-icon {
  font-size: 60px;
  margin-bottom: 20px;
  animation: rotate-hint 2s ease-in-out infinite;
  color: rgba(0, 229, 255, 0.7);
}

#orientation-warning .rotate-text {
  font-family: var(--racing-font);
  font-size: clamp(14px, 4vw, 20px);
  font-weight: 600;
  color: #FFFFFF;
  text-align: center;
  text-shadow: 0 0 15px rgba(0, 229, 255, 0.5);
}

@keyframes rotate-hint {
  0%, 100% {
    transform: rotate(0deg);
  }
  25% {
    transform: rotate(-90deg);
  }
  75% {
    transform: rotate(-90deg);
  }
}

/* === TOUCH DEVICE DETECTION === */
@media (hover: none) and (pointer: coarse) {
  body {
    cursor: none;
  }

  #mobile-controls.visible {
    display: flex;
  }

  #boost-btn.visible {
    display: flex;
  }
}

/* === REDUCED MOTION === */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  #game-container::before {
    animation: none;
  }
}

/* === LOADING SCREEN === */
#loading-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
  background: #0A0A1A;
}

#loading-screen.hidden {
  display: none;
}

.loading-spinner {
  width: 60px;
  height: 60px;
  border: 3px solid rgba(0, 229, 255, 0.15);
  border-top-color: #00E5FF;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 20px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-text {
  font-family: var(--racing-font);
  font-size: 14px;
  font-weight: 500;
  color: rgba(0, 229, 255, 0.7);
  letter-spacing: 3px;
  animation: blink 1.5s ease-in-out infinite;
}

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}
