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

body {
  background: radial-gradient(circle at center, #181d29 0%, #0b0d13 100%);
  color: #fff;
  font-family: 'Rajdhani', sans-serif;
  height: 100vh;
  height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  /* iPad: no pinch-zoom, double-tap zoom, rubber-band scrolling or long-press menus */
  position: fixed;
  inset: 0;
  touch-action: none;
  overscroll-behavior: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

#game-container {
  position: relative;
  flex-shrink: 0;
  transform-origin: center center;
  width: 600px;
  height: 700px;
  box-shadow: 0 0 60px rgba(0, 220, 255, 0.35), 0 25px 70px rgba(0, 0, 0, 0.95);
  border-radius: 20px;
  overflow: hidden;
  border: 2px solid rgba(0, 229, 255, 0.4);
  background-color: #0b0f17;
}

/* Subtle corner neon highlights */
#game-container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, #00f0ff, transparent);
  z-index: 15;
  pointer-events: none;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  filter: contrast(105%) saturate(110%);
}

/* ================= HUD ================= */
#hud {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
  z-index: 10;
}

.hud-panel {
  background: linear-gradient(135deg, rgba(14, 21, 35, 0.9) 0%, rgba(8, 12, 22, 0.95) 100%);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(0, 229, 255, 0.4);
  border-radius: 12px;
  padding: 9px 14px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

/* Top-Left Gas Bar */
.gas-panel {
  width: 190px;
}

.hud-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: 'Orbitron', monospace;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: #00e5ff;
  margin-bottom: 5px;
}

.gas-icon {
  font-size: 14px;
  margin-right: 4px;
}

.gas-timer {
  font-size: 11px;
  color: #8fa0be;
  font-weight: 500;
  background: rgba(0, 0, 0, 0.4);
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.gas-bar-container {
  position: relative;
  width: 100%;
  height: 16px;
  background: #0f1621;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #1e3048;
}

.gas-bar-fill {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #ff3366 0%, #ffbb00 35%, #00ffaa 75%, #00f0ff 100%);
  background-size: 200% 100%;
  border-radius: 7px;
  transition: width 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), filter 0.3s ease;
  box-shadow: 0 0 12px rgba(0, 255, 170, 0.6);
}

.gas-bar-glare {
  position: absolute;
  top: 1px;
  left: 3px;
  right: 3px;
  height: 4px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.6), transparent);
  border-radius: 4px;
  pointer-events: none;
}

.gas-markers {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: space-between;
  padding: 0 25%;
  pointer-events: none;
}

.gas-markers span {
  width: 1px;
  height: 100%;
  background: rgba(0, 0, 0, 0.4);
}

.nitro-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}

.nitro-label {
  font-family: 'Orbitron', monospace;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #3fd0ff;
  white-space: nowrap;
}

.nitro-bar-container {
  flex: 1;
  height: 8px;
  background: #0f1621;
  border: 1px solid #1e3048;
  border-radius: 5px;
  overflow: hidden;
}

.nitro-bar-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #7a5cff, #3fd0ff);
  box-shadow: 0 0 10px rgba(63, 208, 255, 0.8);
  transition: width 0.15s linear;
}

.gas-warning-text {
  display: none;
  font-family: 'Orbitron', monospace;
  font-size: 10px;
  font-weight: 900;
  color: #ff3366;
  text-align: center;
  margin-top: 4px;
  animation: blink 0.5s infinite alternate;
  letter-spacing: 1px;
}

.gas-warning-text.active {
  display: block;
}

@keyframes blink {
  from { opacity: 0.3; }
  to { opacity: 1; }
}

/* Score Panel */
.score-panel {
  text-align: right;
  min-width: 130px;
}

.score-item {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.score-item:not(:last-child) {
  margin-bottom: 5px;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.score-label {
  font-size: 10px;
  letter-spacing: 2px;
  color: #8fa0be;
  font-weight: 700;
}

.score-value {
  font-family: 'Orbitron', monospace;
  font-size: 17px;
  font-weight: 800;
  color: #00f0ff;
  text-shadow: 0 0 12px rgba(0, 240, 255, 0.6);
}

.speed-value {
  font-family: 'Orbitron', monospace;
  color: #ffb703;
  font-size: 14px;
  font-weight: 800;
  text-shadow: 0 0 10px rgba(255, 183, 3, 0.5);
}

/* ================= SOUND BUTTON (main menu) ================= */
.btn.btn-small {
  font-size: 11px;
  letter-spacing: 1px;
  padding: 9px 8px;
}

.menu-row {
  display: flex;
  gap: 10px;
}

.menu-row .btn {
  flex: 1;
  white-space: nowrap;
}

/* ================= PAUSE ================= */
.game-over-box.pause-box {
  border-color: #00e5ff;
  box-shadow: 0 0 40px rgba(0, 229, 255, 0.35);
}

.pause-box .menu-buttons {
  margin: 0 auto;
}

.game-over-title.pause-title {
  color: #00e5ff;
  text-shadow: 0 0 20px rgba(0, 229, 255, 0.8);
}

/* ================= TOAST MESSAGE ================= */
.toast {
  position: absolute;
  top: 90px;
  left: 50%;
  transform: translateX(-50%) scale(0.8);
  background: linear-gradient(135deg, rgba(0, 255, 170, 0.95), rgba(0, 220, 255, 0.95));
  color: #050a14;
  font-family: 'Orbitron', monospace;
  font-weight: 900;
  font-size: 18px;
  letter-spacing: 2.5px;
  padding: 10px 24px;
  border-radius: 30px;
  box-shadow: 0 0 35px rgba(0, 255, 170, 0.9), inset 0 1px 0 rgba(255, 255, 255, 0.8);
  pointer-events: none;
  opacity: 0;
  transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.25s ease;
  z-index: 50;
  border: 1px solid #ffffff;
}

.toast.show {
  transform: translateX(-50%) scale(1);
  opacity: 1;
}

/* ================= OVERLAYS (MENU, MODAL, GAMEOVER) ================= */
.overlay-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at center, rgba(14, 20, 33, 0.94) 0%, rgba(6, 8, 14, 0.97) 100%);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.overlay-screen.active {
  opacity: 1;
  pointer-events: all;
}

/* Main Menu */
.menu-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 85%;
  text-align: center;
}

.title-container {
  margin-bottom: 12px;
}

.game-title {
  font-family: 'Orbitron', sans-serif;
  font-size: 48px;
  font-weight: 900;
  letter-spacing: 4px;
  color: #ffffff;
  text-shadow: 0 0 20px rgba(0, 220, 255, 0.7), 0 0 40px rgba(255, 0, 85, 0.5);
  margin-bottom: 0px;
  transform: skew(-5deg);
}

.accent-text {
  color: #ff0055;
  text-shadow: 0 0 20px rgba(255, 0, 85, 0.9);
}

.game-tagline {
  font-size: 13px;
  letter-spacing: 6px;
  color: #00e5ff;
  font-weight: 700;
  text-transform: uppercase;
}

.menu-car-preview {
  margin: 6px 0 14px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: radial-gradient(circle, rgba(0, 220, 255, 0.15) 0%, rgba(10, 16, 28, 0.6) 70%, transparent 100%);
  padding: 14px 20px;
  border-radius: 16px;
  border: 1px solid rgba(0, 229, 255, 0.25);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5), inset 0 0 20px rgba(0, 229, 255, 0.1);
}

.selected-color-name {
  font-family: 'Orbitron', monospace;
  font-size: 14px;
  color: #00e5ff;
  letter-spacing: 2px;
  margin-top: 8px;
  font-weight: 800;
  text-shadow: 0 0 12px rgba(0, 229, 255, 0.7);
}

.menu-color-chips {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  justify-content: center;
  flex-wrap: wrap;
  max-width: 260px;
}

.menu-chip {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.3);
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), border-color 0.2s, box-shadow 0.2s;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
}

.menu-chip:hover {
  transform: scale(1.25);
  border-color: #ffffff;
}

.menu-chip.active {
  transform: scale(1.35);
  border-color: #00ffff;
  box-shadow: 0 0 16px #00ffff;
}

.color-badge {
  display: inline-block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid #ffffff;
  margin-left: 6px;
  box-shadow: 0 0 8px currentColor;
  transition: background-color 0.25s, transform 0.25s;
}

.car-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 16px;
  margin-top: 10px;
  width: 260px;
}

.car-stat {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.car-stat-label {
  font-size: 10px;
  letter-spacing: 1px;
  color: #8fa0be;
  font-weight: 700;
}

.car-stat-bars {
  display: flex;
  gap: 2px;
}

.stat-pip {
  width: 9px;
  height: 6px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.12);
}

.stat-pip.on {
  background: #00e5ff;
  box-shadow: 0 0 6px rgba(0, 229, 255, 0.6);
}

.type-badge {
  font-size: 10px;
  white-space: nowrap;
  letter-spacing: 1px;
  color: #00e5ff;
  background: rgba(0, 229, 255, 0.12);
  border: 1px solid rgba(0, 229, 255, 0.4);
  border-radius: 6px;
  padding: 3px 7px;
  margin-left: 4px;
}

.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 280px;
  margin-left: auto;
  margin-right: auto;
}

.btn {
  font-family: 'Orbitron', sans-serif;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 2px;
  padding: 14px 20px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  outline: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: all 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  text-transform: uppercase;
}

.btn span {
  white-space: nowrap;
}

.btn-icon {
  font-size: 18px;
}

.btn-primary {
  background: linear-gradient(135deg, #00d2ff 0%, #0066ff 100%);
  color: #ffffff;
  box-shadow: 0 4px 20px rgba(0, 150, 255, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.btn-primary:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 6px 25px rgba(0, 180, 255, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

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

.btn-secondary {
  background: rgba(25, 34, 52, 0.85);
  color: #e0e8ff;
  border: 1px solid rgba(0, 220, 255, 0.35);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

.btn-secondary:hover {
  background: rgba(35, 48, 72, 0.95);
  border-color: #00e5ff;
  color: #fff;
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 6px 20px rgba(0, 220, 255, 0.25);
}

.controls-hint {
  margin-top: 14px;
  font-size: 13px;
  color: #7b8fa7;
  letter-spacing: 1px;
}

.controls-hint strong {
  color: #00e5ff;
  background: rgba(0, 220, 255, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
}

/* ================= COLOR MODAL ================= */
.modal-box {
  background: #0f1624;
  border: 2px solid #00d2ff;
  border-radius: 16px;
  padding: 25px 25px;
  width: 90%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: 0 0 40px rgba(0, 210, 255, 0.3);
}

.modal-title {
  font-family: 'Orbitron', sans-serif;
  font-size: 20px;
  letter-spacing: 2px;
  color: #ffffff;
  margin-bottom: 15px;
  text-shadow: 0 0 10px rgba(0, 210, 255, 0.5);
}

.color-preview-box {
  margin-bottom: 20px;
  background: radial-gradient(circle, rgba(0, 220, 255, 0.1) 0%, transparent 70%);
  padding: 5px;
}

.color-options-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  width: 100%;
  margin-bottom: 24px;
}

.color-chip {
  aspect-ratio: 1;
  border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
  position: relative;
}

.color-chip:hover {
  transform: scale(1.08);
  border-color: #ffffff;
}

.color-chip.selected {
  border-color: #00ffff;
  box-shadow: 0 0 15px #00ffff;
  transform: scale(1.1);
}

.color-chip.selected::after {
  content: '✓';
  color: #fff;
  font-weight: 900;
  font-size: 16px;
  text-shadow: 0 0 4px #000, 0 0 8px #000;
}

.btn-modal-done {
  width: 100%;
}

/* ================= GAME OVER SCREEN ================= */
.game-over-box {
  background: #0f1624;
  border: 2px solid #ff0055;
  border-radius: 16px;
  padding: 30px 25px;
  width: 88%;
  max-width: 380px;
  text-align: center;
  box-shadow: 0 0 40px rgba(255, 0, 85, 0.4);
}

.game-over-title {
  font-family: 'Orbitron', sans-serif;
  font-size: 32px;
  font-weight: 900;
  letter-spacing: 3px;
  color: #ff3366;
  text-shadow: 0 0 20px rgba(255, 51, 102, 0.8);
  margin-bottom: 6px;
}

.game-over-reason {
  font-size: 14px;
  color: #a4b4c8;
  margin-bottom: 22px;
  letter-spacing: 1px;
}

.stat-summary {
  background: rgba(20, 28, 44, 0.7);
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 14px 18px;
  margin-bottom: 24px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  color: #8da1bc;
  padding: 6px 0;
}

.stat-row:not(:last-child) {
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.stat-highlight {
  font-family: 'Orbitron', monospace;
  font-size: 16px;
  font-weight: 700;
  color: #00e5ff;
}

/* ================= TOUCH CONTROLS (for mobile or mouse tap) ================= */
/* Full-screen layer split into 5 equal columns; each column is one button's
   hit area (handled in game.js). The visible circles sit at hand-grip height. */
#touch-controls {
  position: absolute;
  inset: 0;
  display: none;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: 1fr auto 22%; /* buttons ~22% up from the bottom edge */
  justify-items: center;
  align-items: center;
  z-index: 20;
  touch-action: none;
}

.touch-btn {
  grid-row: 2;
  pointer-events: none;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(0, 220, 255, 0.18);
  border: 2px solid rgba(0, 220, 255, 0.55);
  color: #fff;
  font-size: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.08s ease, background 0.08s ease;
}

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

.touch-btn.pressed {
  background: rgba(0, 220, 255, 0.5);
  transform: scale(0.92);
}

/* Phones and touch tablets (iPad) */
@media (max-width: 600px), (hover: none) and (pointer: coarse) {
  #touch-controls {
    display: grid;
  }
}

/* Phones: edge-to-edge, no rounded frame */
#game-container.fullscreen {
  border: none;
  border-radius: 0;
  box-shadow: none;
}
