/* CSS Design System - Apex Velocity: Neon Highway */

:root {
  --bg-dark: #090a12;
  --bg-card: rgba(18, 20, 36, 0.75);
  --bg-card-hover: rgba(28, 31, 56, 0.85);
  --primary-neon: #00f0ff;
  --secondary-neon: #ff0055;
  --accent-yellow: #ffb700;
  --accent-green: #00ff66;
  --text-main: #ffffff;
  --text-dim: #94a3b8;
  --border-glow: rgba(0, 240, 255, 0.3);
  --font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

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

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

/* App Container */
#game-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  background: radial-gradient(circle at center, #181b36 0%, #080910 100%);
}

canvas#gameCanvas {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

/* Glassmorphism Panels */
.glass-panel {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5), inset 0 0 15px rgba(0, 240, 255, 0.05);
  border-radius: 16px;
}

/* Overlay Base */
.overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 10;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.hidden {
  opacity: 0 !important;
  pointer-events: none !important;
  visibility: hidden !important;
}

/* Main Menu */
.menu-card {
  width: 90%;
  max-width: 800px;
  padding: 40px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 24px;
  animation: floatIn 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes floatIn {
  from { transform: translateY(30px) scale(0.95); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

.logo-container {
  margin-bottom: 8px;
}

.game-title {
  font-size: 3.5rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 3px;
  background: linear-gradient(135deg, #00f0ff 0%, #ff0055 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 30px rgba(0, 240, 255, 0.4);
}

.game-subtitle {
  font-size: 1.1rem;
  color: var(--text-dim);
  letter-spacing: 4px;
  text-transform: uppercase;
  margin-top: -6px;
}

.scenario-box {
  background: rgba(0, 0, 0, 0.3);
  padding: 16px 20px;
  border-radius: 12px;
  border-left: 4px solid var(--primary-neon);
  text-align: left;
  font-size: 0.95rem;
  line-height: 1.5;
  color: #cbd5e1;
}

.scenario-box h3 {
  color: var(--primary-neon);
  font-size: 1.05rem;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.menu-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 10px;
}

/* Custom Buttons */
.btn {
  padding: 16px 28px;
  font-size: 1.1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  position: relative;
  overflow: hidden;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary-neon), #0088ff);
  color: #000;
  box-shadow: 0 4px 20px rgba(0, 240, 255, 0.4);
}

.btn-primary:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 8px 30px rgba(0, 240, 255, 0.7);
}

.btn-secondary {
  background: linear-gradient(135deg, var(--secondary-neon), #b3003b);
  color: #fff;
  box-shadow: 0 4px 20px rgba(255, 0, 85, 0.4);
}

.btn-secondary:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 8px 30px rgba(255, 0, 85, 0.7);
}

.btn-outline {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-outline:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: var(--primary-neon);
  transform: translateY(-2px);
}

/* Garage Overlay */
.garage-card {
  width: 90%;
  max-width: 950px;
  height: 85vh;
  padding: 30px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.garage-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  padding-bottom: 15px;
}

.garage-title {
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary-neon);
}

.currency-badge {
  background: rgba(255, 183, 0, 0.15);
  border: 1px solid var(--accent-yellow);
  color: var(--accent-yellow);
  padding: 8px 18px;
  border-radius: 20px;
  font-weight: 800;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.garage-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  flex: 1;
  overflow: hidden;
}

@media (max-width: 768px) {
  .garage-body {
    grid-template-columns: 1fr;
    overflow-y: auto;
  }
}

.car-preview-box {
  background: rgba(0, 0, 0, 0.4);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  position: relative;
}

#carCanvasPreview {
  width: 100%;
  max-height: 240px;
}

.car-selector {
  display: flex;
  gap: 12px;
  margin-top: 15px;
  width: 100%;
  justify-content: center;
}

.car-tab {
  padding: 8px 16px;
  border-radius: 8px;
  background: rgba(255,255,255,0.05);
  cursor: pointer;
  font-weight: 600;
  border: 1px solid transparent;
  transition: all 0.2s;
}

.car-tab.active {
  background: rgba(0, 240, 255, 0.2);
  border-color: var(--primary-neon);
  color: var(--primary-neon);
}

.upgrades-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  justify-content: center;
}

.upgrade-row {
  background: rgba(255,255,255,0.03);
  padding: 14px 18px;
  border-radius: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.upgrade-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.upgrade-title {
  font-weight: 700;
  font-size: 1rem;
}

.upgrade-bar-bg {
  height: 8px;
  width: 80%;
  background: rgba(255,255,255,0.1);
  border-radius: 4px;
  overflow: hidden;
}

.upgrade-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-neon), var(--accent-green));
  width: 0%;
  transition: width 0.3s ease;
}

/* In-Game 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: 20px 24px;
}

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

.hud-stat-box {
  background: rgba(10, 12, 24, 0.85);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(0, 240, 255, 0.3);
  padding: 10px 20px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.hud-val {
  font-size: 1.5rem;
  font-weight: 800;
  color: #fff;
  font-family: monospace;
}

.hud-lbl {
  font-size: 0.75rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.hud-bottom {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 115px; /* Ample clearance above touch controls bar */
}

/* Gauge Cluster */
.gauge-cluster {
  display: flex;
  align-items: flex-end;
  gap: 20px;
}

.speedometer {
  background: rgba(10, 12, 24, 0.92);
  border: 2px solid var(--primary-neon);
  padding: 12px 24px;
  border-radius: 18px;
  text-align: center;
  box-shadow: 0 0 25px rgba(0, 240, 255, 0.35);
  backdrop-filter: blur(12px);
  min-width: 130px;
}

.speed-num {
  font-size: 3.2rem;
  font-weight: 900;
  line-height: 1;
  color: var(--primary-neon);
  text-shadow: 0 0 18px rgba(0, 240, 255, 0.6);
  font-family: 'Impact', sans-serif;
}

.speed-unit {
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--text-dim);
  letter-spacing: 2px;
}

.nitro-container {
  width: 220px;
  background: rgba(10, 12, 24, 0.92);
  border: 1px solid rgba(255, 0, 85, 0.5);
  padding: 12px 14px;
  border-radius: 16px;
  box-shadow: 0 0 22px rgba(255, 0, 85, 0.3);
  backdrop-filter: blur(12px);
}

.nitro-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  font-weight: 800;
  margin-bottom: 6px;
  color: var(--secondary-neon);
  letter-spacing: 1px;
}

.nitro-bar-outer {
  height: 14px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 7px;
  overflow: hidden;
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.nitro-bar-inner {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #ff0055, #ffb700, #00f0ff);
  box-shadow: 0 0 12px #ff0055;
  transition: width 0.1s linear;
}

/* Combo/Alert Overlay */
#alert-banner {
  position: absolute;
  top: 25%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  opacity: 0;
  font-size: 2.8rem;
  font-weight: 900;
  color: var(--accent-yellow);
  text-shadow: 0 0 25px rgba(255, 183, 0, 0.9);
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  text-transform: uppercase;
  letter-spacing: 3px;
  pointer-events: none;
  z-index: 8;
}

#alert-banner.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* Touch Controls */
#touch-controls {
  position: absolute;
  bottom: 16px;
  left: 0;
  width: 100%;
  padding: 0 20px;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
  z-index: 10;
  box-sizing: border-box;
}

.touch-steer,
.touch-actions {
  display: flex;
  gap: 12px;
  pointer-events: auto;
}

.touch-btn {
  width: 72px;
  height: 72px;
  position: relative;
  border-radius: 50%;
  background: rgba(10, 14, 26, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 2px solid rgba(0, 240, 255, 0.55);
  color: white;
  font-size: 1.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.65), 0 0 10px rgba(0, 240, 255, 0.2);
  transition: transform 0.08s ease, background 0.08s ease, border-color 0.08s ease;
}

.touch-btn::after {
  content: '';
  position: absolute;
  top: -12px;
  bottom: -12px;
  left: -12px;
  right: -12px;
  border-radius: 50%;
}

.touch-btn:active,
.touch-btn.active {
  transform: scale(0.92);
  background: rgba(0, 240, 255, 0.45);
  border-color: #ffffff;
  box-shadow: 0 0 20px rgba(0, 240, 255, 0.8);
}
