/* =============================================================================
   OVERDRIVE CITY - VIRTUAL TOUCH CONTROLS (MOBILE & TABLET HUD)
   High-performance Glassmorphic touch interface for Android APK & Mobile Web
   ============================================================================= */

#touch-controls-hud {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 500;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  font-family: 'JetBrains Mono', 'Segoe UI', system-ui, sans-serif;
  display: none; /* Managed dynamically by VirtualTouchControls */
}

#touch-controls-hud.active {
  display: block;
}

/* =============================================================================
   1. LEFT ZONE: FLOATING ANALOG JOYSTICK
   ============================================================================= */

#touch-joystick-zone {
  position: absolute;
  bottom: 24px;
  left: 24px;
  width: 170px;
  height: 170px;
  pointer-events: auto;
  touch-action: none;
}

.touch-joystick-base {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(15, 23, 42, 0.45) 0%, rgba(15, 23, 42, 0.75) 100%);
  border: 2px solid rgba(0, 240, 255, 0.4);
  box-shadow: 0 0 20px rgba(0, 240, 255, 0.2), inset 0 0 15px rgba(0, 240, 255, 0.15);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.touch-joystick-base.active {
  border-color: rgba(0, 240, 255, 0.85);
  box-shadow: 0 0 25px rgba(0, 240, 255, 0.45), inset 0 0 20px rgba(0, 240, 255, 0.3);
}

.touch-joystick-cross {
  position: absolute;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.touch-joystick-cross::before,
.touch-joystick-cross::after {
  content: '';
  position: absolute;
  background: rgba(255, 255, 255, 0.15);
}

.touch-joystick-cross::before {
  top: 50%;
  left: 15%;
  right: 15%;
  height: 1px;
}

.touch-joystick-cross::after {
  left: 50%;
  top: 15%;
  bottom: 15%;
  width: 1px;
}

.touch-joystick-stick {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 56px;
  height: 56px;
  margin-top: -28px;
  margin-left: -28px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #38bdf8 0%, #0284c7 60%, #0369a1 100%);
  border: 2px solid #e0f2fe;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6), 0 0 16px rgba(56, 189, 248, 0.6);
  pointer-events: none;
  transform: translate(0px, 0px);
  will-change: transform;
}

/* =============================================================================
   2. RIGHT ZONE: ACTION CLUSTER & PEDALS
   ============================================================================= */

#touch-actions-cluster {
  position: absolute;
  bottom: 24px;
  right: 24px;
  pointer-events: auto;
  touch-action: none;
  display: flex;
  align-items: flex-end;
  gap: 16px;
}

/* Common Round Action Buttons */
.touch-btn {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 20px;
  color: #ffffff;
  border: 2px solid rgba(255, 255, 255, 0.25);
  background: rgba(15, 23, 42, 0.7);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  cursor: pointer;
  user-select: none;
  touch-action: none;
  transition: transform 0.08s ease, filter 0.08s ease, background 0.08s ease;
}

.touch-btn:active,
.touch-btn.active {
  transform: scale(0.92);
  filter: brightness(1.3);
}

.touch-btn-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  margin-top: 2px;
  letter-spacing: 0.5px;
  opacity: 0.85;
}

/* Mode-Specific Color Themes */
.touch-btn-gas {
  width: 72px;
  height: 104px;
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(34, 197, 94, 0.4) 0%, rgba(21, 128, 61, 0.8) 100%);
  border-color: #4ade80;
  box-shadow: 0 4px 16px rgba(34, 197, 94, 0.4), inset 0 2px 8px rgba(255, 255, 255, 0.3);
}

.touch-btn-gas:active,
.touch-btn-gas.active {
  background: linear-gradient(180deg, rgba(34, 197, 94, 0.7) 0%, rgba(21, 128, 61, 0.95) 100%);
  box-shadow: 0 0 24px rgba(74, 222, 128, 0.7);
}

.touch-btn-brake {
  width: 72px;
  height: 84px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(239, 68, 68, 0.4) 0%, rgba(185, 28, 28, 0.8) 100%);
  border-color: #f87171;
  box-shadow: 0 4px 16px rgba(239, 68, 68, 0.4), inset 0 2px 8px rgba(255, 255, 255, 0.3);
}

.touch-btn-brake:active,
.touch-btn-brake.active {
  background: linear-gradient(180deg, rgba(239, 68, 68, 0.7) 0%, rgba(185, 28, 28, 0.95) 100%);
  box-shadow: 0 0 24px rgba(248, 113, 113, 0.7);
}

.touch-btn-handbrake {
  width: 58px;
  height: 58px;
  background: rgba(245, 158, 11, 0.4);
  border-color: #fbbf24;
}

.touch-btn-handbrake:active,
.touch-btn-handbrake.active {
  background: rgba(245, 158, 11, 0.8);
  box-shadow: 0 0 20px rgba(251, 191, 36, 0.6);
}

.touch-btn-interact {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.45) 0%, rgba(3, 105, 161, 0.8) 100%);
  border-color: #38bdf8;
  box-shadow: 0 4px 16px rgba(56, 189, 248, 0.35);
}

.touch-btn-interact:active,
.touch-btn-interact.active {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.85) 0%, rgba(3, 105, 161, 1) 100%);
  box-shadow: 0 0 20px rgba(56, 189, 248, 0.7);
}

.touch-btn-sprint {
  background: rgba(16, 185, 129, 0.4);
  border-color: #34d399;
}

.touch-btn-sprint.active {
  background: rgba(16, 185, 129, 0.85);
  box-shadow: 0 0 20px rgba(52, 211, 153, 0.7);
}

.touch-btn-jump {
  background: rgba(99, 102, 241, 0.4);
  border-color: #818cf8;
}

.touch-btn-jump:active,
.touch-btn-jump.active {
  background: rgba(99, 102, 241, 0.85);
  box-shadow: 0 0 20px rgba(129, 140, 248, 0.7);
}

.touch-btn-fire {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.45) 0%, rgba(153, 27, 27, 0.8) 100%);
  border-color: #ef4444;
}

.touch-btn-fire:active,
.touch-btn-fire.active {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.85) 0%, rgba(153, 27, 27, 1) 100%);
  box-shadow: 0 0 22px rgba(239, 68, 68, 0.75);
}

/* Secondary Actions Bar (Horn, Headlights, Radio) */
.touch-secondary-row {
  position: absolute;
  top: -64px;
  right: 0;
  display: flex;
  gap: 12px;
}

.touch-btn-small {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 16px;
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.3);
}

/* =============================================================================
   3. TOP / CAMERA QUICK ORBIT BUTTONS
   ============================================================================= */

#touch-camera-orbit-bar {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 14px;
  pointer-events: auto;
  touch-action: none;
}

.touch-orbit-btn {
  width: 46px;
  height: 40px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(0, 240, 255, 0.35);
  color: #38bdf8;
  font-size: 18px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  cursor: pointer;
  transition: transform 0.08s ease, background 0.08s ease;
}

.touch-orbit-btn:active {
  transform: scale(0.9);
  background: rgba(0, 240, 255, 0.3);
}

/* Responsive Scaling for smaller phone screens */
@media (max-width: 768px) {
  #touch-joystick-zone {
    bottom: 16px;
    left: 16px;
    width: 150px;
    height: 150px;
  }
  .touch-joystick-base {
    width: 120px;
    height: 120px;
  }
  .touch-joystick-stick {
    width: 48px;
    height: 48px;
    margin-top: -24px;
    margin-left: -24px;
  }
  #touch-actions-cluster {
    bottom: 16px;
    right: 16px;
    gap: 10px;
  }
  .touch-btn-gas {
    width: 64px;
    height: 94px;
  }
  .touch-btn-brake {
    width: 64px;
    height: 76px;
  }
}
