/* ==========================================================================
   RUTA SEGURA — Estilos del HUD Panorámico Moderno (css/hud.css)
   Fiel a Need for Speed Payback (Imagen 1) y Unbound (Imagen 3):
   - Lienzo panorámico 3D 100% fullscreen sin barra lateral
   - Velocímetro / Tacómetro circular digital (Bottom-Right)
   - Minimapa / Radar circular de curva (Bottom-Left)
   - Tabla de posiciones flotante de cristal esmerilado (Top-Left)
   - Superposición estroboscópica policial de Barranquilla
   - Precargador Retro 8-bit
   ========================================================================== */

#screenGame {
  position: relative;
  width: 100%;
  height: 100%;
  display: block;
  overflow: hidden;
  background: #000000;
}

.stage-container {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

#gameCanvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

/* ==========================================================================
   1. DOCK SUPERIOR ESTRUCTURADO (TOP-BAR ~16-20%)
   ========================================================================== */
.hud-top-dock {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: calc(8px + env(safe-area-inset-top, 0px)) 16px 8px 16px;
  background: linear-gradient(180deg, rgba(8, 9, 12, 0.96) 0%, rgba(18, 21, 29, 0.85) 80%, transparent 100%);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 2px solid rgba(255, 208, 0, 0.35);
  pointer-events: auto;
}

.hud-top-pos {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.hud-top-status {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(18, 21, 29, 0.88);
  padding: 4px 12px;
  border-radius: 14px;
  border: 1px solid rgba(255, 208, 0, 0.25);
  font-size: 11px;
}

.damage-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(8, 9, 12, 0.85);
  padding: 3px 8px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.damage-icon {
  font-size: 11px;
}

.damage-bar-wrap {
  width: 48px;
  height: 6px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  overflow: hidden;
}

.damage-bar-fill {
  height: 100%;
  background: #10b981;
  border-radius: 4px;
  transition: width 0.3s ease, background-color 0.3s ease;
}

#hudDamageValue {
  font-size: 11px;
  font-weight: 800;
  color: #ffd000;
  min-width: 26px;
  text-align: right;
}

.hud-top-dock .hud-touch-quickbar {
  position: static;
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: auto;
}

/* ==========================================================================
   1.1 TABLA DE POSICIONES FLOTANTE DE RIVALES (DESPLEGABLE / DESKTOP)
   ========================================================================== */
.hud-floating-leaderboard {
  position: absolute;
  top: calc(64px + env(safe-area-inset-top, 0px));
  left: 16px;
  width: 260px;
  background: rgba(11, 15, 23, 0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 10px 12px;
  color: #f8fafc;
  z-index: 45;
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.6);
  pointer-events: auto;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.hud-floating-leaderboard.hidden-mobile {
  display: none;
}

.leaderboard-pos-row {
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 10px;
  margin-bottom: 10px;
}

.pos-badge {
  font-size: 32px;
  font-weight: 900;
  color: var(--primary-yellow);
  line-height: 1;
  font-family: var(--font-mono);
}

.pos-badge small {
  font-size: 14px;
  color: var(--text-muted);
}

.leaderboard-meta {
  flex: 1;
}

.track-title-hud {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: #ffffff;
  text-transform: uppercase;
}

.track-dist-hud {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-blue);
  font-family: var(--font-mono);
}

.btn-pause-floating {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-pause-floating:hover {
  background: rgba(255, 208, 0, 0.25);
  border-color: var(--primary-yellow);
  color: var(--primary-yellow);
  transform: scale(1.05);
}

.leaderboard-racers-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
  max-height: 110px;
  overflow: hidden;
}

.racer-entry {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  padding: 3px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.04);
}

.racer-entry.is-player {
  background: rgba(255, 208, 0, 0.18);
  border-left: 3px solid var(--primary-yellow);
  font-weight: 800;
  color: #fff;
}

.leaderboard-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 8px;
}

.fines-badge b {
  color: var(--accent-red);
}

.token-badge b {
  color: var(--primary-yellow);
}

/* ==========================================================================
   2. DOCK INFERIOR ESTRUCTURADO (~30-35% ZONA DE CONTROLES Y MINI-RELOJES)
   ========================================================================== */
.hud-bottom-dock {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 40;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 0 18px calc(14px + env(safe-area-inset-bottom, 0px)) 18px;
  box-sizing: border-box;
  pointer-events: none;
}

.dock-left-zone {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  pointer-events: auto;
}

.dock-center-gap {
  flex: 1;
  min-width: 60px;
  pointer-events: none;
}

.dock-right-zone {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  pointer-events: auto;
}

.dock-pedals-wrap {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  pointer-events: auto;
}

/* 2.1 RADAR CIRCULAR MINIMAPA */
.hud-radar-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  filter: drop-shadow(0 12px 28px rgba(0, 0, 0, 0.7));
  pointer-events: none;
}

#hudRadarCanvas {
  width: 170px;
  height: 170px;
  display: block;
}

.radar-tag {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: #94a3b8;
  margin-top: 3px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
}

/* 2.2 VELOCÍMETRO CIRCULAR MODERNO */
.hud-gauges-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  filter: drop-shadow(0 14px 32px rgba(0, 0, 0, 0.75));
  pointer-events: none;
}

#hudGaugesCanvas {
  width: 200px;
  height: 200px;
  display: block;
}

/* ==========================================================================
   4. SUPERPOSICIÓN ESTROBOSCÓPICA POLICIAL DE BARRANQUILLA
   ========================================================================== */
.police-strobe-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 35;
  box-shadow: 
    inset 0 0 90px rgba(30, 58, 138, 0.85),
    inset 0 0 140px rgba(250, 204, 21, 0.75);
  animation: policeStrobePulse 0.18s infinite alternate;
}

@keyframes policeStrobePulse {
  0% {
    box-shadow: 
      inset 0 0 100px rgba(30, 58, 138, 0.95),
      inset 0 0 150px rgba(250, 204, 21, 0.2);
  }
  100% {
    box-shadow: 
      inset 0 0 40px rgba(30, 58, 138, 0.2),
      inset 0 0 120px rgba(250, 204, 21, 0.95);
  }
}

/* ==========================================================================
   5. ALERTAS FLOTANTES PEDAGÓGICAS Y DETENCIÓN PARE
   ========================================================================== */
.hud-notice {
  position: absolute;
  top: calc(66px + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, rgba(24, 30, 44, 0.96) 0%, rgba(12, 16, 26, 0.96) 100%);
  border: 1.5px solid var(--primary-yellow);
  color: #f8fafc;
  padding: 8px 22px;
  border-radius: 9999px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.3px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.75), 0 0 18px rgba(255, 208, 0, 0.25);
  z-index: 9999;
  text-align: center;
  max-width: 92%;
  width: max-content;
  pointer-events: none;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  animation: androidToastIn 0.24s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes androidToastIn {
  from {
    opacity: 0;
    transform: translate(-50%, -18px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0) scale(1.0);
  }
}

.hud-slipstream {
  position: absolute;
  top: calc(112px + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(90deg, #0284c7, #00e5ff);
  color: #000;
  font-weight: 900;
  font-size: 12px;
  padding: 6px 18px;
  border-radius: 20px;
  box-shadow: 0 0 18px rgba(0, 229, 255, 0.6);
  z-index: 38;
  letter-spacing: 1px;
}

.pare-progress-box {
  position: absolute;
  top: calc(150px + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.94);
  border: 2px solid #ef4444;
  border-radius: 12px;
  padding: 10px 22px;
  text-align: center;
  z-index: 45;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.7), 0 0 24px rgba(239, 68, 68, 0.35);
}

.pare-progress-title {
  color: #ef4444;
  font-weight: 900;
  font-size: 13px;
  letter-spacing: 1px;
  margin-bottom: 6px;
}

.pare-progress-bar {
  width: 220px;
  height: 10px;
  background: #1e293b;
  border-radius: 5px;
  overflow: hidden;
  margin: 0 auto 6px auto;
}

.pare-progress-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #ef4444, #22c55e);
  transition: width 0.08s linear;
}

.pare-progress-text {
  font-size: 11px;
  font-weight: 800;
  color: #cbd5e1;
  font-family: var(--font-mono);
}

.countdown-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(0, 0, 0, 0.35);
  z-index: 50;
  pointer-events: none;
}

.countdown-number {
  font-size: 140px;
  font-weight: 900;
  color: var(--primary-yellow);
  text-shadow: 0 10px 40px rgba(0, 0, 0, 0.9), 0 0 30px rgba(255, 208, 0, 0.7);
  animation: countdownPop 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes countdownPop {
  0% { transform: scale(0.3); opacity: 0; }
  50% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

.speed-lines-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 15;
}

/* ==========================================================================
   6. PRECARGADOR RETRO 8-BIT
   ========================================================================== */
.retro-preloader {
  display: flex;
  justify-content: center;
  align-items: center;
  background: #090d16;
  padding: 24px;
}

.preloader-content {
  width: min(90%, 540px);
  background: #111827;
  border: 3px solid var(--primary-yellow);
  border-radius: 12px;
  padding: 32px 28px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8), 0 0 25px rgba(255, 208, 0, 0.2);
}

.preloader-badge {
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 2px;
  color: var(--primary-yellow);
  margin-bottom: 16px;
}

.pixel-car-anim {
  font-size: 48px;
  margin-bottom: 12px;
  animation: carBounce 0.4s infinite alternate ease-in-out;
}

@keyframes carBounce {
  from { transform: translateY(0); }
  to { transform: translateY(-8px); }
}

.preloader-title {
  font-size: 24px;
  font-weight: 900;
  color: #fff;
  letter-spacing: 1px;
  margin-bottom: 18px;
}

.preloader-bar-box {
  width: 100%;
  height: 14px;
  background: #1f2937;
  border: 2px solid #374151;
  border-radius: 7px;
  overflow: hidden;
  margin-bottom: 14px;
}

.preloader-bar-fill {
  width: 0%;
  height: 100%;
  background: repeating-linear-gradient(
    45deg,
    var(--primary-yellow),
    var(--primary-yellow) 10px,
    #f59e0b 10px,
    #f59e0b 20px
  );
  transition: width 0.15s ease-out;
}

.preloader-status {
  font-size: 11px;
  font-weight: 700;
  color: #94a3b8;
  font-family: var(--font-mono);
  margin-bottom: 20px;
}

.preloader-tip-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 10px 14px;
  text-align: left;
  font-size: 12px;
  color: #cbd5e1;
}

.tip-icon {
  font-size: 20px;
}

/* ==========================================================================
   INSIGNIA DE MANDO BLUETOOTH CONECTADO (Xbox / PlayStation)
   ========================================================================== */
.hud-gamepad-badge {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.90);
  border: 1px solid #38bdf8;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 6px 18px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #f8fafc;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
  z-index: 60;
  box-shadow: 0 4px 20px rgba(56, 189, 248, 0.4);
  animation: gamepadBadgePop 0.3s ease-out;
  pointer-events: none;
}

@keyframes gamepadBadgePop {
  0% { transform: translateX(-50%) translateY(-20px) scale(0.8); opacity: 0; }
  100% { transform: translateX(-50%) translateY(0) scale(1); opacity: 1; }
}

.gamepad-badge-icon {
  font-size: 16px;
  animation: gamepadIconPulse 1.2s infinite alternate;
}

@keyframes gamepadIconPulse {
  0% { transform: scale(1); }
  100% { transform: scale(1.25); filter: drop-shadow(0 0 6px #38bdf8); }
}

/* ==========================================================================
   BARRA RÁPIDA DE ACCIONES TÁCTILES (MÓVIL / TABLET)
   ========================================================================== */
.hud-touch-quickbar {
  position: absolute;
  top: 14px;
  right: 18px;
  display: flex;
  gap: 8px;
  z-index: 50;
  pointer-events: auto;
}

.btn-touch-pill {
  background: rgba(15, 23, 42, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #ffffff;
  font-family: var(--font-main);
  font-size: 11px;
  font-weight: 800;
  padding: 6px 12px;
  border-radius: 16px;
  backdrop-filter: blur(8px);
  cursor: pointer;
  touch-action: manipulation;
  transition: all 0.15s ease;
  user-select: none;
  -webkit-user-select: none;
}

.btn-touch-pill:active, .btn-touch-pill.active {
  background: var(--primary-yellow);
  color: #0b0f17;
  border-color: var(--primary-yellow);
  transform: scale(0.96);
  box-shadow: 0 0 14px rgba(255, 208, 0, 0.6);
}

/* ==========================================================================
   CONTROLES TÁCTILES EN PANTALLA (Teléfonos y Tabletas)
   ========================================================================== */
.touch-controls-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 45;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 20px 24px calc(20px + env(safe-area-inset-bottom, 0px)) 24px;
  box-sizing: border-box;
}

.touch-zone {
  pointer-events: auto;
  display: flex;
  align-items: flex-end;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

/* 1. JOYSTICK VIRTUAL ANALÓGICO */
.virtual-joystick {
  width: 140px;
  height: 140px;
  position: relative;
  touch-action: none;
}

.joystick-base {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(15, 23, 42, 0.6) 0%, rgba(15, 23, 42, 0.85) 100%);
  border: 2px solid rgba(56, 189, 248, 0.45);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6), inset 0 0 20px rgba(56, 189, 248, 0.2);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  position: relative;
  overflow: hidden;
}

.joystick-knob {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #38bdf8 0%, #0284c7 60%, #0369a1 100%);
  border: 2px solid #bae6fd;
  box-shadow: 0 4px 18px rgba(2, 132, 199, 0.7), inset 0 2px 6px rgba(255, 255, 255, 0.6);
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  cursor: grab;
  transition: box-shadow 0.15s;
  pointer-events: none;
}

.virtual-joystick.active .joystick-knob {
  box-shadow: 0 0 25px #38bdf8, inset 0 2px 10px #ffffff;
}

.knob-inner {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.35);
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.joystick-guides {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 12px;
  pointer-events: none;
}

.j-guide {
  font-size: 13px;
  font-weight: 900;
  color: rgba(56, 189, 248, 0.5);
}

/* 2. BOTONES DE DIRECCIÓN ALTERNATIVOS ARCADE (FLECHAS) */
.touch-steer-buttons {
  display: flex;
  gap: 12px;
}

.btn-touch-action {
  width: 72px;
  height: 72px;
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.85);
  border: 2px solid rgba(56, 189, 248, 0.6);
  color: #38bdf8;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6), inset 0 0 12px rgba(56, 189, 248, 0.15);
  backdrop-filter: blur(8px);
  transition: all 0.1s ease;
}

.btn-touch-action:active, .btn-touch-action.active {
  background: #38bdf8;
  color: #0b0f17;
  border-color: #ffffff;
  transform: scale(0.92);
  box-shadow: 0 0 28px rgba(56, 189, 248, 0.8);
}

.touch-arrow {
  font-size: 24px;
  font-weight: 900;
  line-height: 1;
}

.btn-touch-action small {
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 1px;
  margin-top: 2px;
}

/* 3. PEDALES DEPORTIVOS DE ACELERACIÓN Y FRENO */
.touch-right-zone {
  display: flex;
  gap: 16px;
  align-items: flex-end;
}

.btn-touch-pedal {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  border-radius: 14px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.7);
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  padding: 10px 8px;
  transition: all 0.1s ease;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.pedal-ribs {
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: 70%;
}

.pedal-ribs span {
  display: block;
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 2px;
}

.pedal-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.pedal-icon {
  font-size: 18px;
  line-height: 1;
}

.pedal-label b {
  font-size: 11px;
  letter-spacing: 1px;
  font-weight: 900;
}

/* Pedal de Freno Deportivo */
.btn-pedal-brake {
  width: 76px;
  height: 96px;
  background: linear-gradient(180deg, rgba(185, 28, 28, 0.85) 0%, rgba(127, 29, 29, 0.95) 100%);
  border: 2px solid #ef4444;
  color: #ffffff;
  box-shadow: 0 8px 25px rgba(239, 68, 68, 0.45);
}

.btn-pedal-brake:active, .btn-pedal-brake.active {
  background: #ef4444;
  color: #0b0f17;
  border-color: #ffffff;
  transform: translateY(4px) scale(0.95);
  box-shadow: 0 0 35px rgba(239, 68, 68, 0.9);
}

/* Pedal de Acelerador Deportivo */
.btn-pedal-gas {
  width: 74px;
  height: 120px;
  background: linear-gradient(180deg, rgba(21, 128, 61, 0.85) 0%, rgba(20, 83, 45, 0.95) 100%);
  border: 2px solid #22c55e;
  color: #ffffff;
  box-shadow: 0 8px 25px rgba(34, 197, 94, 0.45);
}

.btn-pedal-gas:active, .btn-pedal-gas.active {
  background: #22c55e;
  color: #0b0f17;
  border-color: #ffffff;
  transform: translateY(6px) scale(0.95);
  box-shadow: 0 0 35px rgba(34, 197, 94, 0.9);
}

/* ==========================================================================
   REORGANIZACIÓN RESPONSIVA DEL HUD EN MÓVILES Y TABLETAS
   ========================================================================== */

/* Tabletas (<= 1024px) */
@media (max-width: 1024px) {
  .hud-top-dock {
    padding: calc(6px + env(safe-area-inset-top, 0px)) 12px 6px 12px;
  }
  .pos-badge {
    font-size: 26px;
  }
  .hud-top-status {
    padding: 3px 10px;
    font-size: 10px;
  }
  .hud-bottom-dock {
    padding: 0 14px calc(10px + env(safe-area-inset-bottom, 0px)) 14px;
  }
  #hudRadarCanvas {
    width: 125px;
    height: 125px;
  }
  #hudGaugesCanvas {
    width: 155px;
    height: 155px;
  }
  .virtual-joystick {
    width: 125px;
    height: 125px;
  }
  .joystick-knob {
    width: 52px;
    height: 52px;
  }
  .btn-pedal-brake {
    width: 64px;
    height: 80px;
  }
  .btn-pedal-gas {
    width: 64px;
    height: 98px;
  }
}

/* Teléfonos Móviles en Vertical (<= 768px): 20% Top, 50% Centro Libre, 35% Bottom */
@media (max-width: 768px) {
  .hud-top-dock {
    padding: calc(6px + env(safe-area-inset-top, 0px)) 10px 5px 10px;
    gap: 8px;
  }

  .pos-badge {
    font-size: 20px;
  }
  .pos-badge small {
    font-size: 10px;
  }
  .track-title-hud {
    font-size: 10px;
  }
  .track-dist-hud {
    font-size: 9px;
  }

  .hud-top-status {
    padding: 2px 8px;
    font-size: 9px;
    gap: 6px;
    border-radius: 8px;
  }

  .btn-touch-pill {
    padding: 3px 7px;
    font-size: 9px;
    border-radius: 10px;
  }

  .btn-pause-floating {
    padding: 3px 7px;
    font-size: 11px;
    border-radius: 6px;
  }

  /* La lista de rivales queda oculta por defecto para no tapar el cielo ni la vía */
  .hud-floating-leaderboard {
    display: none;
    top: calc(52px + env(safe-area-inset-top, 0px));
    left: 8px;
    width: 220px;
    padding: 6px 8px;
    max-height: 140px;
  }

  .hud-floating-leaderboard.open-mobile {
    display: block;
    animation: fadeInDown 0.2s ease;
  }

  /* Notificaciones centradas justo bajo el dock superior */
  .hud-notice {
    font-size: 11px;
    padding: 6px 12px;
    top: calc(56px + env(safe-area-inset-top, 0px));
    max-width: 90vw;
  }

  .hud-slipstream {
    font-size: 11px;
    padding: 4px 12px;
    top: calc(90px + env(safe-area-inset-top, 0px));
  }

  .pare-progress-box {
    top: calc(96px + env(safe-area-inset-top, 0px));
    width: min(260px, 88vw);
    padding: 8px 12px;
  }

  /* Dock Inferior: Mini radar, mini tacómetro y controles sin tocar el centro */
  .hud-bottom-dock {
    padding: 0 8px calc(8px + env(safe-area-inset-bottom, 0px)) 8px;
    gap: 4px;
  }

  .dock-center-gap {
    flex: 1;
    min-width: 40px; /* Pasillo limpio para el auto */
  }

  #hudRadarCanvas {
    width: 85px;
    height: 85px;
  }
  .radar-tag {
    font-size: 7px;
    margin-top: 1px;
  }

  #hudGaugesCanvas {
    width: 95px;
    height: 95px;
  }

  .virtual-joystick {
    width: 105px;
    height: 105px;
  }
  .joystick-knob {
    width: 44px;
    height: 44px;
  }
  .btn-touch-action {
    width: 48px;
    height: 48px;
  }
  .touch-arrow {
    font-size: 16px;
  }

  .dock-pedals-wrap {
    gap: 6px;
  }
  .btn-pedal-brake {
    width: 54px;
    height: 72px;
  }
  .btn-pedal-gas {
    width: 54px;
    height: 88px;
  }
}

/* Teléfonos en Orientación Horizontal (Landscape: altura <= 520px) */
@media (max-height: 520px) and (orientation: landscape) {
  .hud-top-dock {
    padding: 4px 12px;
  }
  .pos-badge {
    font-size: 18px;
  }
  .hud-top-status {
    padding: 2px 6px;
    font-size: 9px;
  }
  .btn-touch-pill {
    padding: 2px 6px;
    font-size: 9px;
  }

  .hud-floating-leaderboard {
    display: none;
  }

  .hud-bottom-dock {
    padding: 0 10px calc(4px + env(safe-area-inset-bottom, 0px)) 10px;
  }

  #hudRadarCanvas {
    width: 75px;
    height: 75px;
  }
  .radar-tag {
    display: none;
  }

  #hudGaugesCanvas {
    width: 85px;
    height: 85px;
  }

  .virtual-joystick {
    width: 95px;
    height: 95px;
  }
  .joystick-knob {
    width: 40px;
    height: 40px;
  }

  .dock-pedals-wrap {
    gap: 6px;
  }
  .btn-pedal-brake {
    width: 52px;
    height: 64px;
  }
  .btn-pedal-gas {
    width: 50px;
    height: 78px;
  }
}

/* ==========================================================================
   BARRA DE PROGRESO DE CARRERA ESTILO MARIO KART 64
   ========================================================================== */
.race-progress-bar {
  position: absolute;
  top: calc(80px + env(safe-area-inset-top, 0px));
  right: 14px;
  width: 32px;
  height: 240px;
  background: rgba(11, 15, 23, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 16px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
  z-index: 900;
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.race-flag-finish, .race-flag-start {
  font-size: 13px;
  line-height: 1;
}

.race-track-slot {
  position: relative;
  width: 6px;
  height: 180px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 3px;
}

.race-track-line {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 0%;
  background: linear-gradient(to top, #ffd000, #00e5ff);
  border-radius: 3px;
  box-shadow: 0 0 8px #ffd000;
  transition: height 0.1s linear;
}

.race-marker-player {
  position: absolute;
  left: 50%;
  transform: translate(-50%, 50%);
  bottom: 0%;
  font-size: 16px;
  filter: drop-shadow(0 0 6px #ffd000);
  transition: bottom 0.1s linear;
  z-index: 3;
}

.race-rival-dot {
  position: absolute;
  left: 50%;
  transform: translate(-50%, 50%);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1.5px solid #0f172a;
  box-shadow: 0 0 4px rgba(255, 255, 255, 0.8);
  transition: bottom 0.2s linear;
  z-index: 2;
}

/* ==========================================================================
   BANNER DE CARTAS DE SITUACIÓN VIAL ESTILO MONOPOLY
   ========================================================================== */
.monopoly-card-banner {
  position: absolute;
  top: calc(78px + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  width: min(90vw, 440px);
  background: rgba(15, 23, 42, 0.95);
  border: 2px solid #ffd000;
  border-radius: 14px;
  padding: 12px 16px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.8), 0 0 20px rgba(255, 208, 0, 0.4);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 9990;
  animation: monopolySlideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes monopolySlideIn {
  from {
    opacity: 0;
    transform: translate(-50%, -20px) scale(0.92);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
  }
}

.monopoly-card-badge {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: #ffd000;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.monopoly-card-body {
  display: flex;
  gap: 12px;
  align-items: center;
}

.monopoly-card-icon {
  font-size: 32px;
  flex-shrink: 0;
  filter: drop-shadow(0 0 8px rgba(255, 208, 0, 0.6));
}

.monopoly-card-title {
  font-size: 14px;
  font-weight: 800;
  color: #ffffff;
  margin-bottom: 2px;
  line-height: 1.2;
}

.monopoly-card-text {
  font-size: 12px;
  color: #cbd5e1;
  line-height: 1.35;
}

