@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=Rajdhani:wght@500;700&display=swap');

:root {
  --bg-color: #0b0c10;
  --panel-bg: rgba(26, 26, 36, 0.75);
  --primary-glow: #00ffcc;
  --secondary-glow: #ff007f;
  --danger-glow: #ff3333;
  --text-primary: #f5f6f8;
  --text-muted: #8b949e;
  --accent-gold: #ffcc00;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-color);
  color: var(--text-primary);
  font-family: 'Rajdhani', sans-serif;
}

body {
  display: flex;
  justify-content: center;
  align-items: center;
}

/* ── Game Container ─────────────────────────────── */
#game-container {
  position: relative;
  width: 100vw;
  height: 100dvh;
  background: #000;
  overflow: hidden;
}



canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* ── Generic ──────────────────────────────────── */
.hidden {
  display: none !important;
  opacity: 0;
  pointer-events: none;
}

h1, h2, h3 {
  font-family: 'Orbitron', sans-serif;
  text-transform: uppercase;
  letter-spacing: 2px;
}

/* ── Overlay (menus) ────────────────────────────── */
.overlay {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, rgba(16,16,24,0.4) 0%, rgba(5,5,8,0.95) 100%);
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  z-index: 10;
  backdrop-filter: blur(8px);
  overflow-y: auto;
  /* Add safe-area top padding to prevent mobile browser URL/tab bars from covering the header */
  padding: calc(env(safe-area-inset-top, 12px) + 24px) 12px 24px;
  touch-action: auto;
}

/* ── Garage Header ─────────────────────────────── */
.garage-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 96%;
  margin-bottom: 6px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  padding-bottom: 5px;
  flex-wrap: wrap;
  gap: 4px;
}

.game-title {
  font-size: clamp(1.4rem, 4.5vw, 2.5rem);
  font-family: 'Orbitron', sans-serif;
  color: #fff;
  text-shadow: 0 0 15px var(--primary-glow);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.badge-3d {
  font-size: clamp(0.7rem, 2vw, 1rem);
  background: linear-gradient(135deg, #00ffcc, #ff007f);
  color: #000;
  padding: 2px 5px;
  border-radius: 4px;
  font-weight: 900;
}

h1 {
  font-size: clamp(1.2rem, 4.5vw, 3rem);
  font-weight: 900;
  color: #fff;
  text-shadow: 0 0 10px var(--primary-glow), 0 0 20px var(--primary-glow);
  margin-bottom: 10px;
}

h2 {
  font-size: clamp(1rem, 3.5vw, 2rem);
  color: var(--secondary-glow);
  text-shadow: 0 0 10px rgba(255,0,127,0.5);
  margin-bottom: 8px;
}

/* ── Tabs ─────────────────────────────────────── */
.garage-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.garage-tab-btn {
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  font-size: clamp(0.85rem, 2.5vw, 1.1rem);
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.15);
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: 30px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.garage-tab-btn.active {
  background: rgba(0,255,204,0.15);
  border-color: var(--primary-glow);
  color: #fff;
  box-shadow: 0 0 10px rgba(0,255,204,0.3);
}

/* ── Showroom / Garage cards ───────────────────── */
.showroom-panel {
  width: 100%;
  display: flex;
  justify-content: center;
}

.garage-container {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  width: 98%;
  justify-content: center;
  flex-wrap: wrap;
  padding: 4px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.garage-container::-webkit-scrollbar {
  display: none;
}

.garage-card {
  background: rgba(14, 16, 22, 0.95); /* Darker and less transparent for bolder contrast */
  border: 2px solid rgba(255, 255, 255, 0.18); /* Thicker border */
  border-radius: 12px;
  padding: 10px 8px;
  min-width: 90px;
  width: clamp(105px, 24vw, 170px);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
}

.garage-card:active {
  transform: scale(0.95);
  border-color: var(--primary-glow);
  box-shadow: 0 0 16px rgba(0, 255, 204, 0.5);
}

.garage-card.selected {
  border-color: var(--primary-glow);
  background: rgba(0, 255, 204, 0.22); /* Darker neon overlay */
  box-shadow: 0 0 25px rgba(0, 255, 204, 0.6); /* Bolder selected glow */
}

.garage-card.locked {
  opacity: 0.5;
  filter: grayscale(0.95);
  border-color: rgba(255, 255, 255, 0.08);
}

.vehicle-icon { font-size: clamp(1.3rem, 4.5vw, 2.2rem); margin-bottom: 4px; }
.vehicle-name { font-weight: 900; font-size: clamp(0.9rem, 2.8vw, 1.25rem); margin-bottom: 2px; color: #fff; letter-spacing: 0.5px; }
.vehicle-desc { font-size: clamp(0.75rem, 2.2vw, 0.95rem); color: var(--text-muted); height: 38px; overflow: hidden; margin-bottom: 4px; }
.vehicle-price { font-size: clamp(0.85rem, 2.2vw, 1.1rem); color: var(--accent-gold); font-weight: 700; }

/* ── Controls hint (hidden on touch) ──────────── */
.controls-hint-bar {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: clamp(0.55rem, 1.8vw, 0.8rem);
  color: var(--text-muted);
  margin-bottom: 8px;
  text-align: center;
}

@media (hover: none) and (pointer: coarse) {
  .controls-hint-bar { display: none; }
}

/* ── Buttons ───────────────────────────────────── */
.btn-hero {
  font-family: 'Orbitron', sans-serif;
  font-size: clamp(1.1rem, 3.8vw, 1.6rem);
  font-weight: 900;
  padding: clamp(9px,2.8vw,14px) clamp(20px,7vw,45px);
  background: linear-gradient(135deg, #00ffcc, #0099ff);
  color: #000;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 2px;
  box-shadow: 0 0 28px rgba(0,255,204,0.6);
  transition: transform 0.15s;
  margin-top: 4px;
}

.btn-hero:active { transform: scale(0.94); }

.btn {
  font-family: 'Orbitron', sans-serif;
  font-size: clamp(0.75rem, 2.8vw, 1.1rem);
  font-weight: 700;
  padding: clamp(7px,2.2vw,12px) clamp(16px,4.5vw,30px);
  background: transparent;
  color: #fff;
  border: 2px solid var(--primary-glow);
  border-radius: 4px;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 1px;
  transition: all 0.2s ease;
}

.btn:active { background: var(--primary-glow); color: var(--bg-color); }

.btn-secondary { border-color: var(--secondary-glow); }
.btn-secondary:active { background: var(--secondary-glow); color: #fff; }

/* ── Gift count ────────────────────────────────── */
.total-gifts {
  font-size: clamp(1.1rem, 3.5vw, 1.6rem);
  color: var(--accent-gold);
  font-weight: 700;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 5px;
}

/* ── HUD ───────────────────────────────────────── */
#hud {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 6px);
  left: calc(env(safe-area-inset-left, 0px) + 6px);
  right: calc(env(safe-area-inset-right, 0px) + 6px);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
  z-index: 5;
  font-family: 'Orbitron', sans-serif;
  gap: 4px;
}

.hud-panel {
  background: rgba(16,16,24,0.75);
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.1);
  backdrop-filter: blur(4px);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.hud-item { font-size: clamp(0.5rem, 1.8vw, 0.9rem); font-weight: 700; }
.hud-label { color: var(--text-muted); font-size: clamp(0.4rem, 1.3vw, 0.65rem); display: block; }
.hud-value { color: #fff; }

#shield-bar-container {
  width: clamp(40px, 10vw, 90px);
  height: 4px;
  background: rgba(255,255,255,0.2);
  border-radius: 3px;
  margin-top: 3px;
  overflow: hidden;
}

#shield-bar { height: 100%; width: 100%; background: var(--primary-glow); transition: width 0.2s ease; }

/* ── Old FIRE hud button (hidden on mobile — replaced by mc-fire) ── */
.shoot-hud-btn {
  position: absolute;
  bottom: clamp(10px, 3vw, 22px);
  right: clamp(10px, 3vw, 22px);
  background: linear-gradient(135deg, #ff0055, #ff5500);
  border: 2px solid #fff;
  color: #fff;
  font-family: 'Orbitron', sans-serif;
  font-weight: 900;
  font-size: clamp(0.75rem, 2.5vw, 1rem);
  padding: clamp(8px,2.5vw,11px) clamp(14px,4vw,20px);
  border-radius: 50px;
  box-shadow: 0 0 18px rgba(255,0,85,0.6);
  cursor: pointer;
  pointer-events: auto;
  z-index: 25;
  transition: transform 0.1s, box-shadow 0.1s;
  min-width: 60px;
  min-height: 44px;
}

.shoot-hud-btn:active {
  transform: scale(0.9);
  box-shadow: 0 0 28px rgba(255,255,0,0.8);
}

@media (hover: none) and (pointer: coarse) {
  /* hide the old floating fire btn on touch — it's now in mc controls */
  .shoot-hud-btn { display: none; }
}

/* ═══════════════════════════════════════════════════
   MOBILE CONTROLS  — compact D-pad style
   Works in BOTH portrait and landscape on phones
   ═══════════════════════════════════════════════════ */
#mobile-controls {
  display: none;                 /* JS enables on touch devices */
  position: absolute;
  bottom: 25px;
  left: 0;
  right: 0;
  background: transparent;
  border-top: none;
  z-index: 50;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  gap: 8px;
  pointer-events: none; /* Let touches pass through the gaps to the canvas */
}


/* D-pad button base */
.mc-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.3);
  background: rgba(255,255,255,0.08);
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
  pointer-events: auto;
  transition: background 0.1s, transform 0.08s;
  -webkit-user-select: none;
  user-select: none;
  flex-shrink: 0;
}

.mc-btn:active,
.mc-btn.pressed {
  background: rgba(0,255,204,0.28);
  border-color: var(--primary-glow);
  transform: scale(0.88);
}

/* ── Left cluster: ◀ steer-left + ▶ steer-right ── */
#mc-steer {
  display: flex;
  gap: 10px;
  align-items: center;
}

/* ── Centre: JUMP and SLIDE stacked ── */
#mc-center {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
}

/* Jump button slightly bigger */
#mc-jump {
  width: 52px;
  height: 52px;
  font-size: 1.25rem;
  border-color: rgba(0,255,204,0.5);
  background: rgba(0,255,204,0.1);
}

/* ── Right: FIRE button ── */
#mc-fire {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  font-size: 0.65rem;
  font-family: 'Orbitron', sans-serif;
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1.2;
  text-align: center;
  background: linear-gradient(135deg, #ff0055, #ff5500);
  border: 2px solid #fff;
  color: #fff;
  box-shadow: 0 0 16px rgba(255,0,85,0.55);
}

#mc-fire:active, #mc-fire.pressed {
  background: linear-gradient(135deg, #ff5500, #ffcc00);
  transform: scale(0.85);
  box-shadow: 0 0 24px rgba(255,200,0,0.9);
}

/* ── Level-up banner ───────────────────────────── */
.level-banner {
  position: absolute;
  top: 30%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0,0,0,0.85);
  border: 3px solid var(--primary-glow);
  box-shadow: 0 0 40px var(--primary-glow);
  padding: clamp(10px,3.5vw,20px) clamp(16px,5vw,40px);
  border-radius: 12px;
  text-align: center;
  z-index: 30;
  pointer-events: none;
  animation: bannerPulse 0.5s ease-in-out infinite alternate;
}

#level-up-title {
  font-family: 'Orbitron', sans-serif;
  font-size: clamp(1rem, 3.5vw, 2.2rem);
  font-weight: 900;
  color: var(--primary-glow);
}

#level-up-desc {
  font-family: 'Rajdhani', sans-serif;
  font-size: clamp(0.8rem, 2.8vw, 1.3rem);
  color: #fff;
}

@keyframes bannerPulse {
  from { transform: translate(-50%, -50%) scale(1); }
  to   { transform: translate(-50%, -50%) scale(1.05); }
}

/* ── Game-over ─────────────────────────────────── */
#game-over {
  justify-content: center;
  padding: calc(env(safe-area-inset-top, 16px) + 24px) 24px calc(env(safe-area-inset-bottom, 16px) + 24px);
  gap: 12px;
}
#game-over h1 { font-size: clamp(1.8rem, 7vw, 4rem); margin-bottom: 4px; }

/* ── Portrait-Mode Layout Tuning ─────────────────── */
@media (orientation: portrait) {
  .overlay {
    justify-content: flex-start;
    gap: clamp(10px, 2.5vh, 20px);
    padding: calc(env(safe-area-inset-top, 30px) + 30px) 16px calc(env(safe-area-inset-bottom, 16px) + 16px);
  }

  .garage-header {
    flex-direction: column;
    align-items: center;
    text-align: center;
    border-bottom: none;
    gap: 4px;
    margin-bottom: 2px;
  }

  .garage-tabs {
    width: 100%;
    margin-bottom: 2px;
  }

  .showroom-panel {
    display: flex;
    align-items: center;
    width: 100%;
  }

  .garage-container {
    flex-wrap: wrap; /* Turn horizontal scrolling list into a grid */
    justify-content: center;
    overflow: visible;
    max-height: none;
    gap: 10px;
    padding: 4px;
  }

  .garage-card {
    width: calc(50% - 6px); /* Perfect 2-column grid layout */
    min-width: unset;
    padding: 10px 8px;
    border-radius: 12px;
  }

  .vehicle-desc {
    height: auto;
    max-height: 36px;
    margin-bottom: 6px;
  }

  .btn-hero {
    width: 90%;
    max-width: 280px;
    margin-top: 4px;
  }
}
