/* ─────────────────────────────────────────────────────────────────────────────
   Turbo TukTuk Drift 3D — CSS Stylesheet
   Neon Cyberpunk Indian Street Racing Theme
   ───────────────────────────────────────────────────────────────────────────── */

:root {
  --neon-cyan: #00f0ff;
  --neon-yellow: #ffd700;
  --neon-pink: #ff0055;
  --neon-green: #00ff66;
  --neon-purple: #9d00ff;
  --bg-dark: #06070d;
  --panel-bg: rgba(12, 16, 28, 0.85);
  --panel-border: rgba(0, 240, 255, 0.3);
  --font-family: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-dark);
  font-family: var(--font-family);
  color: #ffffff;
}

.game-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: radial-gradient(circle at center, #0d1326 0%, #04050a 100%);
}

/* ── Game Bar Header ──────────────────────────────────────────────────────── */
.game-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 48px;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: linear-gradient(180deg, rgba(6, 7, 13, 0.9) 0%, rgba(6, 7, 13, 0) 100%);
  pointer-events: auto;
}

.back-link {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--neon-cyan);
  text-decoration: none;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.5px;
  transition: transform 0.2s, color 0.2s;
}

.back-link:hover {
  color: #ffffff;
  transform: translateX(-2px);
}

.game-bar-title {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 1px;
  background: linear-gradient(90deg, var(--neon-yellow), var(--neon-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-transform: uppercase;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.player-pill {
  background: rgba(0, 240, 255, 0.1);
  border: 1px solid rgba(0, 240, 255, 0.3);
  border-radius: 12px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--neon-cyan);
}

.icon-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.icon-btn:hover {
  background: var(--neon-cyan);
  color: #000;
  border-color: var(--neon-cyan);
  box-shadow: 0 0 12px var(--neon-cyan);
}

.icon-btn .ic-sound-off { display: none; }
.icon-btn.muted .ic-sound-on { display: none; }
.icon-btn.muted .ic-sound-off { display: block; color: var(--neon-pink); }

/* ── Main Canvas Viewport ─────────────────────────────────────────────────── */
.game-wrap {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

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

/* ── HUD Layer ───────────────────────────────────────────────────────────── */
.hud {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 60px 20px 20px 20px;
  transition: opacity 0.3s ease;
}

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

.hud-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  width: 100%;
}

.hud-card {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(8px);
  border-radius: 12px;
  padding: 8px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

.hud-card .label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #8a99b5;
}

.hud-card .val {
  font-size: 22px;
  font-weight: 900;
  color: #fff;
  font-family: monospace;
}

.hud-card.score .val { color: var(--neon-yellow); }
.hud-card.timer .val { color: var(--neon-cyan); }

.hud-center-drift {
  position: absolute;
  top: 15%;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
}

.hud-center-drift.active {
  opacity: 1;
  transform: translateX(-50%) scale(1.05);
}

.drift-badge {
  font-size: 28px;
  font-weight: 900;
  font-style: italic;
  letter-spacing: 2px;
  color: var(--neon-yellow);
  text-shadow: 0 0 15px var(--neon-yellow), 0 0 30px #ff8c00;
  text-transform: uppercase;
}

.drift-combo {
  font-size: 18px;
  font-weight: 800;
  color: var(--neon-pink);
  text-shadow: 0 0 10px var(--neon-pink);
}

.near-miss-popup {
  position: absolute;
  top: 35%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.5);
  font-size: 24px;
  font-weight: 900;
  font-style: italic;
  color: var(--neon-green);
  text-shadow: 0 0 15px var(--neon-green);
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.near-miss-popup.show {
  opacity: 1;
  transform: translate(-50%, -60%) scale(1.2);
}

/* HUD Gauges at Bottom */
.hud-bottom-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  width: 100%;
}

.gauge-speed {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.speed-num {
  font-size: 48px;
  font-weight: 900;
  line-height: 1;
  font-style: italic;
  color: var(--neon-cyan);
  text-shadow: 0 0 15px rgba(0, 240, 255, 0.6);
}

.speed-unit {
  font-size: 11px;
  font-weight: 800;
  color: #8a99b5;
  letter-spacing: 1.5px;
}

.gauge-n2o {
  width: 180px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.n2o-label {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 800;
  color: var(--neon-purple);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.n2o-track {
  height: 14px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--panel-border);
  border-radius: 7px;
  overflow: hidden;
  position: relative;
}

.n2o-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--neon-purple), var(--neon-cyan));
  box-shadow: 0 0 12px var(--neon-cyan);
  transition: width 0.1s linear;
}

.n2o-fill.ready {
  background: linear-gradient(90deg, #ff0055, var(--neon-yellow));
  box-shadow: 0 0 18px var(--neon-yellow);
  animation: pulse-n2o 0.6s infinite alternate;
}

@keyframes pulse-n2o {
  0% { opacity: 0.8; }
  100% { opacity: 1; box-shadow: 0 0 25px var(--neon-pink); }
}

/* ── Mobile Touch Controls Overlay ───────────────────────────────────────── */
.touch-controls {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 20;
  pointer-events: none;
  display: none; /* Shown dynamically on touch devices */
}

.touch-controls.active {
  display: block;
}

.touch-btn-zone {
  pointer-events: auto;
  position: absolute;
  bottom: 24px;
  display: flex;
  gap: 16px;
}

.touch-btn-zone.left {
  left: 20px;
}

.touch-btn-zone.right {
  right: 20px;
}

.touch-btn {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: rgba(12, 16, 28, 0.7);
  border: 2px solid var(--neon-cyan);
  color: #fff;
  font-size: 24px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 15px rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
  active-state: scale(0.92);
}

.touch-btn:active, .touch-btn.pressed {
  background: var(--neon-cyan);
  color: #000;
  box-shadow: 0 0 20px var(--neon-cyan);
  transform: scale(0.92);
}

.touch-btn.drift-btn {
  border-color: var(--neon-yellow);
  width: 76px;
  height: 76px;
  font-size: 13px;
  letter-spacing: 1px;
  font-weight: 900;
  color: var(--neon-yellow);
  text-transform: uppercase;
}

.touch-btn.drift-btn:active, .touch-btn.drift-btn.pressed {
  background: var(--neon-yellow);
  color: #000;
  box-shadow: 0 0 20px var(--neon-yellow);
}

.touch-btn.n2o-btn {
  border-color: var(--neon-pink);
  width: 76px;
  height: 76px;
  font-size: 13px;
  letter-spacing: 1px;
  font-weight: 900;
  color: var(--neon-pink);
  text-transform: uppercase;
}

.touch-btn.n2o-btn:active, .touch-btn.n2o-btn.pressed {
  background: var(--neon-pink);
  color: #fff;
  box-shadow: 0 0 20px var(--neon-pink);
}

/* ── Modals & Screens (Title, Pause, Results) ───────────────────────────── */
.modal-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(4, 5, 10, 0.85);
  backdrop-filter: blur(12px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-screen.active {
  opacity: 1;
  pointer-events: auto;
}

.menu-card {
  width: 90%;
  max-width: 480px;
  background: rgba(12, 17, 30, 0.95);
  border: 1px solid var(--panel-border);
  box-shadow: 0 10px 40px rgba(0, 240, 255, 0.2);
  border-radius: 20px;
  padding: 32px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 20px;
  animation: card-appear 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes card-appear {
  0% { transform: scale(0.85); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.title-logo {
  font-size: 32px;
  font-weight: 900;
  font-style: italic;
  letter-spacing: 2px;
  text-transform: uppercase;
  background: linear-gradient(135deg, var(--neon-yellow) 0%, #ff8c00 50%, var(--neon-cyan) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 20px rgba(255, 215, 0, 0.3);
}

.subtitle {
  font-size: 13px;
  color: #8a99b5;
  margin-top: -10px;
}

.mode-selector {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mode-option {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 14px;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s ease;
}

.mode-option:hover, .mode-option.selected {
  background: rgba(0, 240, 255, 0.12);
  border-color: var(--neon-cyan);
  box-shadow: 0 0 15px rgba(0, 240, 255, 0.2);

}

.mode-name {
  font-size: 15px;
  font-weight: 800;
  color: var(--neon-yellow);
}

.mode-desc {
  font-size: 12px;
  color: #a0aec0;
  margin-top: 2px;
}

.btn-primary {
  width: 100%;
  height: 52px;
  background: linear-gradient(90deg, var(--neon-yellow), #ff8c00);
  border: none;
  border-radius: 14px;
  color: #000;
  font-size: 18px;
  font-weight: 900;
  font-style: italic;
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(255, 215, 0, 0.4);
  transition: all 0.2s ease;
}

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

.btn-secondary {
  width: 100%;
  height: 44px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: #fff;
}

/* Results Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.stat-box {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 10px;
}

.stat-box .title {
  font-size: 11px;
  color: #8a99b5;
  text-transform: uppercase;
}

.stat-box .number {
  font-size: 20px;
  font-weight: 800;
  color: var(--neon-cyan);
  margin-top: 2px;
}

/* Controls Hint Panel */
.controls-hint {
  font-size: 12px;
  color: #8a99b5;
  background: rgba(0,0,0,0.3);
  border-radius: 8px;
  padding: 8px;
  line-height: 1.4;
}

.controls-hint b {
  color: var(--neon-yellow);
}

/* Countdown Overlay */
.countdown-overlay {
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 80px;
  font-weight: 900;
  font-style: italic;
  color: var(--neon-yellow);
  text-shadow: 0 0 30px var(--neon-yellow);
  z-index: 40;
  opacity: 0;
  pointer-events: none;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.countdown-overlay.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1.2);
}

/* Responsive adjustments */
@media (max-width: 600px) {
  .game-bar-title { font-size: 13px; }
  .hud { padding: 52px 12px 12px 12px; }
  .hud-card { padding: 4px 10px; }
  .hud-card .val { font-size: 16px; }
  .speed-num { font-size: 36px; }
  .gauge-n2o { width: 130px; }
  .touch-btn { width: 56px; height: 56px; font-size: 20px; }
  .touch-btn.drift-btn, .touch-btn.n2o-btn { width: 64px; height: 64px; font-size: 11px; }
  .menu-card { padding: 20px 16px; }
  .title-logo { font-size: 24px; }
}
