* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #05020c;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Space Grotesk", sans-serif;
  color: #f3e8ff;
}

#game-container {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
}

#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
  background: #070314;
}

/* 2026 CYBERPUNK GLASSMORPHIC HUD */
#hud {
  position: absolute;
  top: 14px;
  left: 14px;
  right: 14px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
  z-index: 10;
  gap: 12px;
}

.hud-left, .hud-right {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.hud-center {
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* HUD Cards */
.hud-card {
  background: rgba(13, 6, 28, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(168, 85, 247, 0.35);
  border-radius: 12px;
  padding: 10px 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6), 0 0 16px rgba(168, 85, 247, 0.15);
  min-width: 140px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.hud-tag {
  font-size: 10px;
  font-weight: 800;
  color: #a855f7;
  letter-spacing: 1.2px;
  text-transform: uppercase;
}

.multiplier-badge {
  background: linear-gradient(135deg, #c026d3, #7e22ce);
  color: #ffffff;
  font-size: 11px;
  font-weight: 900;
  padding: 2px 8px;
  border-radius: 20px;
  box-shadow: 0 0 8px rgba(192, 38, 211, 0.6);
  letter-spacing: 0.5px;
  transition: transform 0.15s ease, background 0.3s ease;
}

.multiplier-badge.flame {
  background: linear-gradient(135deg, #f97316, #ef4444);
  box-shadow: 0 0 14px rgba(249, 115, 22, 0.9);
  animation: pulseFlame 0.4s infinite alternate;
}

@keyframes pulseFlame {
  from { transform: scale(1); }
  to { transform: scale(1.1); }
}

.score-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.score-counter {
  font-size: 24px;
  font-weight: 900;
  color: #ffffff;
  font-family: "Space Grotesk", monospace, sans-serif;
  letter-spacing: 0.5px;
  text-shadow: 0 0 10px rgba(192, 132, 252, 0.5);
}

.score-pts {
  font-size: 11px;
  font-weight: 700;
  color: #a855f7;
}

/* Combo Progress Bar */
.combo-bar-track {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  margin-top: 6px;
  overflow: hidden;
}

.combo-bar-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #a855f7, #ec4899);
  border-radius: 2px;
  transition: width 0.1s linear;
}

/* Drift Rating Announcements */
#drift-grade-container {
  min-height: 32px;
  display: flex;
  align-items: center;
}

.drift-grade {
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  font-style: italic;
  opacity: 0;
  transform: scale(0.7) translateY(10px);
  transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.drift-grade.show {
  opacity: 1;
  transform: scale(1) translateY(0);
}

.drift-grade.grade-nice {
  color: #38bdf8;
  text-shadow: 0 0 12px rgba(56, 189, 248, 0.8);
}

.drift-grade.grade-great {
  color: #a855f7;
  text-shadow: 0 0 14px rgba(168, 85, 247, 0.8);
}

.drift-grade.grade-sick {
  color: #ec4899;
  text-shadow: 0 0 16px rgba(236, 72, 153, 0.9);
}

.drift-grade.grade-legend {
  color: #fbbf24;
  text-shadow: 0 0 20px rgba(251, 191, 36, 1);
}

/* HUD Center Timer */
.timer-pill {
  background: rgba(13, 6, 28, 0.75);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(168, 85, 247, 0.35);
  border-radius: 20px;
  padding: 6px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.pill-label {
  font-size: 9px;
  font-weight: 800;
  color: #c084fc;
  letter-spacing: 1px;
}

.pill-val {
  font-size: 16px;
  font-weight: 900;
  color: #ffffff;
  font-family: monospace;
}

/* Gauge Cluster */
.gauge-card {
  text-align: right;
  min-width: 150px;
}

.speed-row {
  display: flex;
  justify-content: flex-end;
  align-items: baseline;
  gap: 4px;
}

.speed-num {
  font-size: 26px;
  font-weight: 900;
  color: #ffffff;
  font-family: monospace;
  text-shadow: 0 0 12px rgba(56, 189, 248, 0.6);
}

.speed-unit {
  font-size: 11px;
  font-weight: 700;
  color: #38bdf8;
}

.telemetry-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 6px 0;
}

.telemetry-item {
  display: flex;
  flex-direction: column;
}

.telemetry-label {
  font-size: 9px;
  font-weight: 700;
  color: #94a3b8;
}

.telemetry-val {
  font-size: 13px;
  font-weight: 800;
  color: #f1f5f9;
  font-family: monospace;
}

/* Nitro Gauge */
.nitro-container {
  margin-top: 6px;
}

.nitro-label-row {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  font-weight: 800;
  color: #38bdf8;
  margin-bottom: 3px;
}

.nitro-track {
  width: 100%;
  height: 5px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  overflow: hidden;
}

.nitro-fill {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #0284c7, #38bdf8, #67e8f9);
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.8);
  border-radius: 3px;
  transition: width 0.08s linear;
}

/* Mini-Map Card */
.minimap-card {
  align-self: flex-end;
  background: rgba(13, 6, 28, 0.85);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(168, 85, 247, 0.35);
  border-radius: 10px;
  padding: 4px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
  width: 128px;
  height: 98px;
  display: flex;
  justify-content: center;
  align-items: center;
}

#minimap-canvas {
  width: 120px;
  height: 90px;
  border-radius: 6px;
}

/* OVERLAYS */
.overlay {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(17, 7, 36, 0.92) 0%, rgba(5, 2, 14, 0.98) 100%);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  transition: opacity 0.25s ease;
}

.overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.menu-card {
  background: rgba(21, 10, 42, 0.88);
  border: 1px solid rgba(192, 132, 252, 0.3);
  border-radius: 20px;
  padding: 28px 24px;
  max-width: 480px;
  width: 92%;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8), 0 0 30px rgba(168, 85, 247, 0.25);
  position: relative;
  overflow: hidden;
}

.menu-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, #c084fc, #38bdf8, transparent);
}

.neon-glow-badge {
  display: inline-block;
  padding: 4px 14px;
  background: rgba(168, 85, 247, 0.15);
  border: 1px solid #c084fc;
  color: #e9d5ff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.5px;
  border-radius: 30px;
  margin-bottom: 12px;
  box-shadow: 0 0 12px rgba(192, 132, 252, 0.3);
}

.menu-title {
  font-size: 32px;
  font-weight: 900;
  letter-spacing: 1px;
  color: #ffffff;
  margin-bottom: 4px;
  text-shadow: 0 0 16px rgba(192, 132, 252, 0.7);
}

.menu-tagline {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: #38bdf8;
  margin-bottom: 12px;
}

.menu-subtitle {
  font-size: 13px;
  line-height: 1.5;
  color: #d8b4fe;
  margin-bottom: 20px;
}

.controls-guide {
  background: rgba(12, 5, 28, 0.7);
  border: 1px solid rgba(168, 85, 247, 0.2);
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 22px;
  display: flex;
  justify-content: space-around;
  gap: 16px;
  text-align: left;
}

.guide-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.guide-item {
  color: #e9d5ff;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.key-pill {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 6px;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 800;
  color: #ffffff;
  font-family: monospace;
}

.btn {
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 1px;
  cursor: pointer;
  padding: 14px 28px;
  transition: all 0.2s ease;
  width: 100%;
}

.btn-primary {
  background: linear-gradient(135deg, #a855f7 0%, #7e22ce 50%, #6b21a8 100%);
  color: #ffffff;
  box-shadow: 0 4px 20px rgba(168, 85, 247, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 26px rgba(168, 85, 247, 0.6);
}

.btn-primary:active {
  transform: translateY(1px);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #e2e8f0;
  margin-top: 10px;
}

.pause-actions, .gameover-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 18px 0 24px;
}

.stat-box {
  background: rgba(12, 5, 28, 0.65);
  border: 1px solid rgba(168, 85, 247, 0.25);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-label {
  font-size: 9px;
  font-weight: 700;
  color: #a855f7;
  letter-spacing: 0.8px;
}

.stat-val {
  font-size: 20px;
  font-weight: 900;
  color: #ffffff;
  font-family: monospace;
  margin-top: 4px;
}

.stat-val.highlight {
  color: #38bdf8;
  font-size: 24px;
  text-shadow: 0 0 12px rgba(56, 189, 248, 0.6);
}

/* 2026 RESPONSIVE MOBILE TOUCH CONTROLS */
.touch-controls {
  position: absolute;
  bottom: 16px;
  left: 16px;
  right: 16px;
  display: none;
  justify-content: space-between;
  align-items: flex-end;
  pointer-events: none;
  z-index: 20;
}

@media (pointer: coarse), (max-width: 820px) {
  .touch-controls {
    display: flex;
  }
}

.touch-left-cluster, .touch-right-cluster {
  display: flex;
  gap: 10px;
  pointer-events: auto;
}

.touch-right-cluster {
  align-items: flex-end;
}

.touch-btn {
  background: rgba(22, 11, 46, 0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(168, 85, 247, 0.45);
  color: #ffffff;
  border-radius: 16px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
  transition: transform 0.08s ease, background 0.08s ease;
}

.touch-btn:active {
  transform: scale(0.92);
  background: rgba(168, 85, 247, 0.4);
}

.steer-btn {
  width: 60px;
  height: 60px;
  font-size: 22px;
}

.gas-btn {
  width: 68px;
  height: 68px;
  background: rgba(16, 185, 129, 0.25);
  border-color: rgba(16, 185, 129, 0.6);
  font-size: 13px;
  letter-spacing: 0.5px;
}

.gas-btn:active {
  background: rgba(16, 185, 129, 0.5);
}

.brake-btn {
  width: 54px;
  height: 54px;
  background: rgba(239, 68, 68, 0.25);
  border-color: rgba(239, 68, 68, 0.6);
  font-size: 11px;
}

.brake-btn:active {
  background: rgba(239, 68, 68, 0.5);
}

.ebrake-btn {
  width: 58px;
  height: 54px;
  background: rgba(234, 179, 8, 0.25);
  border-color: rgba(234, 179, 8, 0.6);
  font-size: 10px;
}

.ebrake-btn:active {
  background: rgba(234, 179, 8, 0.5);
}

.nitro-btn {
  width: 50px;
  height: 50px;
  background: rgba(56, 189, 248, 0.25);
  border-color: rgba(56, 189, 248, 0.6);
  font-size: 11px;
}

.nitro-btn:active {
  background: rgba(56, 189, 248, 0.6);
}

/* Pause decorative HUD motion with the round, without freezing overlay transitions. */
body:has(#pause-overlay:not(.hidden)) *,
body:has(#pause-overlay:not(.hidden)) *::before,
body:has(#pause-overlay:not(.hidden)) *::after {
  animation-play-state: paused;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; }
}
