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

body, html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: #0d111a;
  overscroll-behavior: none;
}

.screen {
  position: fixed;
  inset: 0;
  display: none;
}

.screen.active {
  display: block;
}

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

/* ============================================================================
   PANTALLA DE GARAJE (RESPONSIVA PARA CELULAR Y PC)
   ============================================================================ */
.game-title-banner {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
  text-align: center;
  z-index: 5;
  width: 100%;
}

.game-title-banner h1 {
  font-size: clamp(28px, 6vw, 54px);
  font-weight: 900;
  letter-spacing: 3px;
  text-transform: uppercase;
  background: linear-gradient(180deg, #ffffff 15%, #ffbe0b 85%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.8));
}

.garage-overlay {
  position: absolute;
  bottom: max(16px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 94vw;
  max-width: 620px;
  pointer-events: none;
  z-index: 5;
}

.selector-bar {
  pointer-events: auto;
  background: rgba(15, 22, 38, 0.78);
  backdrop-filter: blur(10px);
  border: 2px solid rgba(255, 255, 255, 0.24);
  border-radius: 22px;
  padding: 8px 14px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.45);
}

.model-btn {
  width: 76px;
  height: 48px;
  border-radius: 14px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s ease, border-color 0.15s ease, background 0.15s ease;
}

.model-btn.active {
  border-color: #ffbe0b;
  background: rgba(255, 190, 11, 0.32);
  transform: scale(1.08);
}

.color-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.45);
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.15s ease;
}

.color-btn.active {
  border-color: #ffffff;
  transform: scale(1.22);
  box-shadow: 0 0 14px rgba(255, 255, 255, 0.95);
}

.play-btn {
  pointer-events: auto;
  width: 148px;
  height: 64px;
  border-radius: 32px;
  border: none;
  background: linear-gradient(135deg, #38b000 0%, #70e000 100%);
  box-shadow: 0 6px 0 #237000, 0 14px 28px rgba(56, 176, 0, 0.5);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.play-btn:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #237000;
}

/* ============================================================================
   HUD DE JUEGO LIMPIO + MENÚ DESPLEGABLE
   ============================================================================ */
.hud-top {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: max(12px, env(safe-area-inset-left));
  right: max(12px, env(safe-area-inset-right));
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
  z-index: 20;
}

.gear-selector {
  pointer-events: auto;
  display: flex;
  background: rgba(15, 22, 38, 0.78);
  backdrop-filter: blur(8px);
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 18px;
  padding: 4px;
  gap: 6px;
}

.gear-btn {
  width: 44px;
  height: 44px;
  border-radius: 13px;
  border: none;
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  font-size: 21px;
  font-weight: 900;
  cursor: pointer;
}

.gear-btn.active[data-gear="1"] {
  background: #38b000;
  box-shadow: 0 0 12px rgba(56, 176, 0, 0.75);
}

.gear-btn.active[data-gear="2"] {
  background: #ffbe0b;
  color: #111111;
  box-shadow: 0 0 12px rgba(255, 190, 11, 0.75);
}

.gear-btn.active[data-gear="3"] {
  background: #e61938;
  box-shadow: 0 0 12px rgba(230, 25, 56, 0.85);
}

/* BOTÓN DE MENÚ DESPLEGABLE */
.menu-wrapper {
  pointer-events: auto;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.hud-menu-btn {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  background: rgba(15, 22, 38, 0.8);
  backdrop-filter: blur(8px);
  color: #ffffff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hud-menu-btn.open {
  border-color: #ffbe0b;
  background: rgba(30, 42, 70, 0.95);
}

.dropdown-menu {
  margin-top: 8px;
  background: rgba(15, 22, 38, 0.9);
  backdrop-filter: blur(12px);
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-radius: 20px;
  padding: 10px;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.6);
}

.dropdown-menu.open {
  display: flex;
}

.dropdown-stars {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #ffffff;
  font-size: 20px;
  font-weight: 800;
  padding: 4px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.18);
  width: 100%;
  justify-content: center;
}

.dropdown-item-btn {
  width: 52px;
  height: 52px;
  border-radius: 15px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dropdown-item-btn.active {
  border-color: #70e000;
  background: rgba(56, 176, 0, 0.72);
}

/* ============================================================================
   BOTONES LATERALES DE GIRO AL 50% DE ALTURA DE PANTALLA
   ============================================================================ */
.side-steer-btn {
  position: fixed;
  top: 25vh;
  height: 50vh;
  width: clamp(64px, 14vw, 110px);
  background: rgba(15, 22, 38, 0.34);
  border: 2px solid rgba(255, 255, 255, 0.28);
  color: rgba(255, 255, 255, 0.9);
  font-size: clamp(28px, 5vw, 42px);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 15;
  transition: background 0.1s ease, transform 0.08s ease;
}

.side-left {
  left: 0;
  border-left: none;
  border-radius: 0 28px 28px 0;
  padding-left: env(safe-area-inset-left);
}

.side-right {
  right: 0;
  border-right: none;
  border-radius: 28px 0 0 28px;
  padding-right: env(safe-area-inset-right);
}

.side-steer-btn:active,
.side-steer-btn.pressed {
  background: rgba(0, 180, 216, 0.55);
  border-color: #90e0ef;
  color: #ffffff;
}

/* ============================================================================
   COMANDOS INFERIORES DE DESPLAZAMIENTO (FRENO, BOCINA, NITRO, ACELERAR)
   ============================================================================ */
.hud-bottom {
  position: fixed;
  bottom: max(12px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 2.5vw, 20px);
  z-index: 18;
  width: auto;
  max-width: 96vw;
}

.action-btn {
  width: clamp(58px, 15vw, 76px);
  height: clamp(58px, 15vw, 76px);
  border-radius: 22px;
  border: 3px solid rgba(255, 255, 255, 0.4);
  color: #ffffff;
  font-size: clamp(24px, 5vw, 32px);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
}

.action-btn:active,
.action-btn.pressed {
  transform: scale(0.92);
  filter: brightness(1.25);
}

.brake-btn {
  background: rgba(230, 25, 56, 0.82);
  border-color: #ff8fa3;
}

.horn-btn {
  background: rgba(0, 150, 199, 0.85);
  border-color: #90e0ef;
}

.nitro-btn {
  background: rgba(247, 127, 0, 0.88);
  border-color: #ffbe0b;
}

.gas-btn {
  background: rgba(56, 176, 0, 0.85);
  border-color: #80ed99;
}

/* AJUSTES PARA TELÉFONOS EN HORIZONTAL (LANDSCAPE) */
@media (max-height: 480px) {
  .garage-overlay {
    bottom: 8px;
    gap: 6px;
  }
  .selector-bar {
    padding: 5px 10px;
    gap: 6px;
  }
  .model-btn {
    width: 62px;
    height: 38px;
  }
  .color-btn {
    width: 28px;
    height: 28px;
  }
  .play-btn {
    width: 124px;
    height: 48px;
  }
  .side-steer-btn {
    top: 22vh;
    height: 50vh;
  }
  .action-btn {
    width: 54px;
    height: 54px;
    border-radius: 16px;
  }
}
