:root {
  --primary-red: #ff3366;
  --primary-blue: #00d2ff;
  --bg-dark: #0f1423;
  --card-bg: rgba(20, 27, 45, 0.9);
  --glass-border: rgba(255, 255, 255, 0.15);
  --accent-yellow: #ffe600;
  --accent-green: #00ff88;
  --text-light: #f3f4f6;
  --font-game: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

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

html {
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #ff3366 #0f172a;
}

body {
  background-color: var(--bg-dark);
  font-family: var(--font-game);
  color: var(--text-light);
  min-height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  scrollbar-width: thin;
  scrollbar-color: #ff3366 #0f172a;
}

#game-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  background: radial-gradient(circle at center, #18223c 0%, #0a0d18 100%);
}

#gameCanvas {
  display: block;
  width: 100vw;
  height: 100vh;
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
}

/* Glowing Neon Split-Screen Divider */
.split-divider-3d {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 100vh;
  background: linear-gradient(180deg, #ff3366 0%, #ffe600 50%, #00d2ff 100%);
  box-shadow: 0 0 15px rgba(255, 230, 0, 0.8), 0 0 30px rgba(0, 210, 255, 0.6);
  z-index: 20;
  pointer-events: none;
}

/* =================================================== */
/* 0. THANH CUỘN TÙY BIẾN PHONG CÁCH NEON (CUSTOM SCROLLBAR) */
/* =================================================== */
::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.9);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #ff3366 0%, #ff007f 50%, #ffe600 100%);
  border-radius: 8px;
  border: 2px solid rgba(15, 23, 42, 0.8);
  box-shadow: 0 0 12px rgba(255, 51, 102, 0.8);
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #ffe600 0%, #ff3366 100%);
  box-shadow: 0 0 16px rgba(255, 230, 0, 1);
}

/* Glassmorphism Menus & Modals */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(8, 12, 22, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  z-index: 100;
  overflow-y: auto !important;
  overflow-x: hidden;
  padding: 30px 15px;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: #ff3366 #0f172a;
}

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

.modal-content {
  background: var(--card-bg);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  padding: 28px 36px;
  text-align: center;
  max-width: 880px;
  width: 95%;
  margin: auto 0;
  max-height: 86vh;
  overflow-y: auto !important;
  overflow-x: hidden;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: #ffe600 rgba(15, 23, 42, 0.9);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8), 0 0 30px rgba(0, 210, 255, 0.3);
  animation: modalPop 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes modalPop {
  0% { transform: scale(0.88); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.game-title {
  font-size: 2.6rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 2px;
  background: linear-gradient(135deg, #ff3366 0%, #ffe600 50%, #00d2ff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 6px;
  text-shadow: 0 4px 20px rgba(255, 51, 102, 0.4);
}

.game-subtitle {
  font-size: 1.05rem;
  color: #94a3b8;
  margin-bottom: 22px;
}

/* Player Customization Cards */
.players-setup {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 22px;
}

.player-card {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 14px;
  padding: 18px;
  border-top: 4px solid var(--primary-red);
  text-align: left;
}

.player-card.p2 {
  border-top-color: var(--primary-blue);
}

.player-card h3 {
  font-size: 1.3rem;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.player-card.p1 h3 { color: var(--primary-red); }
.player-card.p2 h3 { color: var(--primary-blue); }

.control-guide {
  font-size: 0.95rem;
  color: #cbd5e1;
  line-height: 1.7;
}

.key-badge {
  display: inline-block;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 6px;
  padding: 2px 8px;
  font-weight: bold;
  font-size: 0.82rem;
  color: #fff;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.5);
  margin: 1px;
}

/* Settings Selection */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
  margin-bottom: 25px;
}

.setting-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
}

.setting-item label {
  font-size: 0.95rem;
  font-weight: 600;
  color: #e2e8f0;
}

.select-custom {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  padding: 10px 14px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 1rem;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.select-custom:focus {
  border-color: var(--primary-blue);
  box-shadow: 0 0 10px rgba(0, 210, 255, 0.4);
}

/* Buttons */
.btn-primary {
  background: linear-gradient(135deg, #ff3366, #ff6b3d);
  color: white;
  border: none;
  padding: 14px 42px;
  font-size: 1.25rem;
  font-weight: bold;
  letter-spacing: 1px;
  text-transform: uppercase;
  border-radius: 50px;
  cursor: pointer;
  box-shadow: 0 6px 25px rgba(255, 51, 102, 0.5);
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.2s;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(255, 51, 102, 0.7);
  filter: brightness(1.1);
}

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

.btn-secondary {
  background: rgba(255, 255, 255, 0.12);
  color: #f1f5f9;
  border: 1px solid rgba(255, 255, 255, 0.25);
  padding: 12px 28px;
  font-size: 1.1rem;
  font-weight: 600;
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.22);
  transform: translateY(-2px);
}

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

.player-hud {
  background: rgba(15, 20, 35, 0.88);
  backdrop-filter: blur(8px);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 12px 20px;
  min-width: 220px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.player-hud.p1 { border-left: 5px solid var(--primary-red); }
.player-hud.p2 { border-right: 5px solid var(--primary-blue); text-align: right; }

.hud-name {
  font-size: 1.15rem;
  font-weight: bold;
  margin-bottom: 4px;
}

.player-hud.p1 .hud-name { color: var(--primary-red); }
.player-hud.p2 .hud-name { color: var(--primary-blue); }

.hud-stat {
  font-size: 0.95rem;
  color: #cbd5e1;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0;
}

.player-hud.p2 .hud-stat {
  justify-content: flex-end;
}

.nitro-bar-container {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 6px;
}

.nitro-bar-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #ff9900, #ffe600);
  border-radius: 4px;
  transition: width 0.1s linear;
}

.player-hud.p2 .nitro-bar-fill {
  background: linear-gradient(90deg, #00d2ff, #00ffaa);
}

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

.race-timer {
  background: rgba(0, 0, 0, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.25);
  padding: 6px 20px;
  border-radius: 20px;
  font-size: 1.3rem;
  font-weight: bold;
  letter-spacing: 2px;
  color: #ffe600;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

.hud-buttons {
  pointer-events: auto;
  display: flex;
  gap: 8px;
}

.icon-btn {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: white;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: background 0.2s, transform 0.1s;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.05);
}

/* Winner Banner */
.winner-trophy {
  font-size: 4.5rem;
  margin-bottom: 8px;
  animation: trophyBounce 1s infinite alternate ease-in-out;
}

@keyframes trophyBounce {
  0% { transform: translateY(0) scale(1); }
  100% { transform: translateY(-8px) scale(1.06); }
}

.winner-title {
  font-size: 2.2rem;
  font-weight: 900;
  margin-bottom: 12px;
}

.winner-stats {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 15px;
  margin: 15px 0 25px 0;
  display: flex;
  justify-content: space-around;
}

.winner-stat-val {
  font-size: 1.4rem;
  font-weight: bold;
  color: var(--accent-yellow);
}

.winner-stat-lbl {
  font-size: 0.85rem;
  color: #94a3b8;
}

.action-buttons {
  display: flex;
  gap: 15px;
  justify-content: center;
}

/* Countdown Overlay */
#countdown-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 7.5rem;
  font-weight: 900;
  color: #ffe600;
  text-shadow: 0 0 35px rgba(255, 230, 0, 0.8), 0 0 70px rgba(255, 51, 102, 0.6);
  pointer-events: none;
  z-index: 50;
  opacity: 0;
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.2s ease;
}

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

/* Mini instructions banner at bottom */
.bottom-hints {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.6);
  background: rgba(0, 0, 0, 0.6);
  padding: 5px 15px;
  border-radius: 12px;
  pointer-events: none;
}

/* =================================================== */
/* 5. GARA & CỬA HÀNG MUA XE (CAR DEALERSHIP CSS)     */
/* =================================================== */
.garage-section {
  margin: 18px 0;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  padding: 16px;
}

.garage-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: #ffe600;
  margin-bottom: 12px;
  text-align: center;
  text-transform: uppercase;
}

.garage-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
}

.garage-player-col {
  background: rgba(255, 255, 255, 0.03);
  border-radius: 12px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.garage-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-weight: bold;
}

.money-badge {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.95rem;
  font-weight: 900;
.garage-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 260px;
  overflow-y: auto;
  padding-right: 6px;
  scrollbar-width: thin;
  scrollbar-color: #00d2ff rgba(15, 23, 42, 0.8);
}

.garage-list::-webkit-scrollbar {
  width: 8px;
}
.garage-list::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.8);
  border-radius: 6px;
}
.garage-list::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #00d2ff, #0077ff);
  border-radius: 6px;
  box-shadow: 0 0 8px rgba(0, 210, 255, 0.6);
}

.shop-car-card {
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 10px;
  transition: all 0.2s ease;
  text-align: left;
}

.shop-car-card:hover {
  background: rgba(51, 65, 85, 0.7);
  border-color: rgba(255, 255, 255, 0.25);
}

.shop-car-card.equipped {
  border-color: #10b981;
  background: rgba(16, 185, 129, 0.12);
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.3);
}

.shop-car-card h4 {
  font-size: 1.05rem;
  margin-bottom: 3px;
  color: #f8fafc;
}

.car-desc {
  font-size: 0.8rem;
  color: #94a3b8;
  margin-bottom: 6px;
}

.car-stats-mini {
  font-size: 0.8rem;
  color: #cbd5e1;
  margin-bottom: 8px;
}

.shop-card-action {
  display: flex;
  justify-content: flex-end;
}

.btn-buy {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff;
  border: none;
  padding: 5px 12px;
  border-radius: 6px;
  font-weight: bold;
  font-size: 0.85rem;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.btn-buy:hover {
  transform: scale(1.05);
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.5);
}

.btn-equip {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 5px 12px;
  border-radius: 6px;
  font-weight: bold;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

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

.badge-equipped {
  font-size: 0.8rem;
  font-weight: 900;
  color: #10b981;
  padding: 4px 8px;
  background: rgba(16, 185, 129, 0.15);
  border-radius: 4px;
}

/* Responsive adjust */
@media (max-width: 900px) {
  .players-setup, .garage-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .modal-content {
    padding: 20px;
    max-height: 90vh;
    overflow-y: auto;
  }
  .game-title {
    font-size: 1.8rem;
  }
  .player-hud {
    min-width: 130px;
    padding: 8px 12px;
    font-size: 0.85rem;
  }
}
