@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=VT323&family=Rajdhani:wght@600;700&display=swap');

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

html, body {
  background: #0f0a0d;
  color: #fff;
  font-family: 'Rajdhani', sans-serif;
  overflow: hidden;
  position: fixed;
  width: 100%;
  height: 100%;
  touch-action: none;
  overscroll-behavior: none;
  -webkit-overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

#game-container {
  position: relative;
  width: 100vw;
  width: 100dvw;
  height: 100vh;
  height: 100dvh;
  max-width: 100%;
  max-height: 100%;
  background: #1a0e08;
  overflow: hidden;
  touch-action: none;
  overscroll-behavior: none;
  -webkit-overscroll-behavior: none;
}

canvas#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  touch-action: none;
  overscroll-behavior: none;
}

/* CRT Scanline Filter (Toggleable) */
.crt-overlay {
  pointer-events: none;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.03), rgba(0, 255, 0, 0.01), rgba(0, 0, 255, 0.03));
  background-size: 100% 3px, 6px 100%;
  z-index: 50;
  opacity: 0.7;
}

/* Sleek Ultra-Slim Top Status Bar */
#top-hud {
  position: absolute;
  top: 10px;
  left: 12px;
  right: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
  z-index: 70;
}

.compact-status-pill {
  background: rgba(18, 12, 10, 0.9);
  border: 2px solid #e05e26;
  border-radius: 10px;
  padding: 6px 12px;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.6);
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  pointer-events: auto;
  white-space: nowrap;
}

.hud-label {
  color: #ffaa33;
  font-size: 7px;
}

.hud-sep {
  color: #665544;
}

.font-gold {
  color: #ffcc00;
  font-weight: bold;
}

.font-cyan {
  color: #38bdf8;
}

.font-amber {
  color: #fb923c;
}

.hud-actions-cluster {
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
}

.menu-toggle-btn {
  background: rgba(22, 16, 14, 0.92);
  border: 2px solid #ff7700;
  border-radius: 12px;
  padding: 6px 12px;
  color: #ffffff;
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
  transition: all 0.15s ease;
  user-select: none;
  -webkit-user-select: none;
}

.menu-toggle-btn:hover, .menu-toggle-btn:active {
  background: #ff6600;
  color: #fff;
  transform: scale(1.05);
}

/* Compact Speedometer & Fuel HUD (Top-Left) */
#vehicle-gauges {
  position: absolute;
  top: 48px;
  left: 12px;
  background: rgba(15, 10, 8, 0.88);
  border: 2px solid #d4501a;
  border-radius: 10px;
  padding: 5px 8px;
  z-index: 60;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.7);
  width: 106px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: 'Press Start 2P', monospace;
  pointer-events: none;
}

.speed-cluster {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 44px;
}

.speed-val {
  font-size: 16px;
  color: #ffffff;
  text-shadow: 1px 1px 0 #d4501a;
  line-height: 1;
}

.speed-unit {
  font-size: 6px;
  color: #ffbb77;
  margin-top: 2px;
}

.mini-bars-cluster {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 48px;
}

.mini-bar-row {
  display: flex;
  align-items: center;
  gap: 3px;
}

.mini-bar-icon {
  font-size: 8px;
  line-height: 1;
}

.mini-bar-bg {
  flex: 1;
  height: 5px;
  background: #2b170f;
  border: 1px solid #7a3a1f;
  border-radius: 2px;
  overflow: hidden;
}

.gauge-fill-fuel {
  height: 100%;
  background: linear-gradient(90deg, #ff4444, #ffbb00, #44ff55);
  width: 100%;
  transition: width 0.2s;
}

.gauge-fill-temp {
  height: 100%;
  background: linear-gradient(90deg, #4488ff, #ffbb00, #ff2222);
  width: 45%;
  transition: width 0.2s;
}

/* St. George Event Banner Alert */
#event-banner {
  position: absolute;
  top: 140px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(90deg, rgba(230, 40, 20, 0.95), rgba(255, 120, 0, 0.95));
  border: 3px solid #fff;
  border-radius: 8px;
  padding: 8px 20px;
  color: #fff;
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  text-align: center;
  box-shadow: 0 0 20px rgba(255, 100, 0, 0.8);
  z-index: 65;
  display: none;
  max-width: 88vw;
  animation: pulse-banner 1.5s infinite alternate;
}

@keyframes pulse-banner {
  from { transform: translateX(-50%) scale(1); }
  to { transform: translateX(-50%) scale(1.04); }
}

/* DixieDash Dasher Smartphone Dock (Right side) */
#phone-dock {
  position: absolute;
  top: 20px;
  right: 20px;
  bottom: 20px;
  width: 320px;
  background: #111418;
  border: 4px solid #333a44;
  border-radius: 28px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.9), 0 0 0 2px #556272;
  z-index: 95;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

#phone-dock.minimized {
  display: none !important;
  pointer-events: none !important;
  visibility: hidden !important;
}

/* Pulsing Top Dasher Phone Pill (Docked on LEFT side under gauges - NEVER covers minimap!) */
#phone-dock.minimized + #phone-minimized-pill,
#phone-minimized-pill.active-pulsing {
  display: flex !important;
}

#phone-minimized-pill {
  display: none;
  position: absolute;
  top: 92px;
  left: 12px;
  right: auto;
  z-index: 85;
  background: linear-gradient(135deg, #e62e00, #ff6600);
  border: 2px solid #ffcc00;
  border-radius: 20px;
  padding: 8px 14px;
  color: #ffffff;
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  cursor: pointer;
  align-items: center;
  gap: 8px;
  box-shadow: 0 0 16px rgba(255, 102, 0, 0.8), 0 4px 10px rgba(0, 0, 0, 0.6);
  animation: pulsePhoneGlow 1.6s infinite ease-in-out;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  transition: transform 0.15s ease, filter 0.15s ease;
}

#phone-minimized-pill:hover, #phone-minimized-pill:active {
  transform: scale(1.08);
  filter: brightness(1.2);
}

.pill-pulse-dot {
  width: 8px;
  height: 8px;
  background: #22c55e;
  border-radius: 50%;
  box-shadow: 0 0 8px #22c55e;
  animation: blinkDot 1s infinite;
}

.pill-icon {
  font-size: 13px;
}

.pill-title {
  font-size: 8px;
  color: #ffffff;
  text-shadow: 1px 1px 0 #000;
}

.pill-badge {
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.4);
  padding: 3px 6px;
  border-radius: 8px;
  font-size: 7px;
  color: #ffdd44;
}

@keyframes pulsePhoneGlow {
  0% {
    transform: scale(1);
    box-shadow: 0 0 12px rgba(255, 102, 0, 0.7);
  }
  50% {
    transform: scale(1.06);
    box-shadow: 0 0 24px rgba(255, 153, 0, 1), 0 0 0 4px rgba(255, 102, 0, 0.35);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 12px rgba(255, 102, 0, 0.7);
  }
}

@keyframes blinkDot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

#phone-minimized-pill.offer-alert {
  background: linear-gradient(135deg, #10b981, #059669);
  border-color: #6ee7b7;
  animation: pulseOfferGlow 0.8s infinite ease-in-out;
}

@keyframes pulseOfferGlow {
  0% {
    transform: scale(1);
    box-shadow: 0 0 14px rgba(16, 185, 129, 0.9);
  }
  50% {
    transform: scale(1.1);
    box-shadow: 0 0 28px rgba(52, 211, 153, 1), 0 0 0 6px rgba(16, 185, 129, 0.4);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 14px rgba(16, 185, 129, 0.9);
  }
}

/* Sleek Floating Quick Offer Toast (Non-Intrusive Arcade Bar) */
#offer-toast {
  position: absolute;
  top: 48px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 18, 24, 0.96);
  border: 2px solid #10b981;
  border-radius: 24px;
  padding: 6px 14px;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.85), 0 0 18px rgba(16, 185, 129, 0.5);
  z-index: 75;
  user-select: none;
  -webkit-user-select: none;
  animation: slideToastDown 0.25s ease-out;
  max-width: 90vw;
  pointer-events: auto;
}

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

.toast-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast-bell-icon {
  font-size: 14px;
  animation: ringBell 1s infinite alternate ease-in-out;
}

@keyframes ringBell {
  from { transform: rotate(-12deg); }
  to { transform: rotate(12deg); }
}

.toast-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.toast-store {
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  color: #ffaa33;
  letter-spacing: 0.5px;
}

.toast-meta {
  font-family: 'Press Start 2P', monospace;
  font-size: 7.5px;
  color: #cbd5e1;
  display: flex;
  align-items: center;
  gap: 5px;
}

.toast-payout-tag {
  color: #4ade80;
  font-weight: bold;
}

.toast-timer-tag {
  color: #facc15;
}

.toast-dot {
  color: #64748b;
  font-size: 6px;
}

.toast-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.toast-btn {
  border: none;
  border-radius: 12px;
  padding: 6px 11px;
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  font-weight: bold;
  cursor: pointer;
  transition: transform 0.1s ease, filter 0.1s ease;
  user-select: none;
  -webkit-user-select: none;
}

.toast-btn:active {
  transform: scale(0.92);
}

.toast-btn-accept {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #ffffff;
  border: 1.5px solid #6ee7b7;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.5);
}

.toast-btn-view {
  background: #334155;
  color: #e2e8f0;
  border: 1.5px solid #475569;
}

.toast-btn-dismiss {
  background: transparent;
  color: #94a3b8;
  border: 1px solid #475569;
  padding: 5px 7px;
  border-radius: 50%;
  line-height: 1;
}

.toast-btn-dismiss:hover {
  color: #ffffff;
  border-color: #ef4444;
}

.phone-notch {
  height: 22px;
  background: #000;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0 16px;
  color: #889;
  font-size: 10px;
  font-family: 'Press Start 2P', monospace;
}

.notch-camera {
  width: 8px;
  height: 8px;
  background: #222;
  border-radius: 50%;
  border: 1px solid #444;
}

.phone-screen {
  flex: 1;
  background: #1a1e24;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  position: relative;
  scrollbar-width: thin;
  scrollbar-color: #e05e26 #1a1e24;
}

/* App Header */
.app-header {
  background: linear-gradient(135deg, #e62e00, #ff6600);
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #fff;
}

.app-brand {
  font-family: 'Press Start 2P', monospace;
  font-size: 12px;
  letter-spacing: -0.5px;
  text-shadow: 1px 1px 0 #000;
}

.app-brand span {
  color: #fffb00;
}

.phone-toggle-btn {
  background: linear-gradient(180deg, #dc2626, #991b1b);
  border: 2px solid #fecaca;
  color: #fff;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 9px;
  font-family: 'Press Start 2P', monospace;
  font-weight: bold;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.5);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  position: relative;
  z-index: 110;
  pointer-events: auto;
  transition: transform 0.1s ease, filter 0.1s ease;
}

.phone-toggle-btn:active {
  transform: scale(0.93);
  filter: brightness(1.2);
}

/* Active Order & GPS Card */
.order-card {
  margin: 10px;
  background: #232933;
  border: 2px solid #3d4757;
  border-radius: 12px;
  padding: 12px;
}

.order-badge-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.order-status-badge {
  background: #ff5500;
  color: #fff;
  font-size: 9px;
  font-family: 'Press Start 2P', monospace;
  padding: 3px 6px;
  border-radius: 4px;
}

.order-payout {
  font-size: 18px;
  font-weight: 700;
  color: #44ff88;
}

.restaurant-title {
  font-size: 16px;
  font-weight: 700;
  color: #ffaa44;
  margin-bottom: 2px;
}

.restaurant-tagline {
  font-size: 11px;
  color: #aab;
  margin-bottom: 8px;
  font-style: italic;
}

.order-items-list {
  background: #191e25;
  border-radius: 6px;
  padding: 8px;
  font-size: 12px;
  color: #ddd;
  margin-bottom: 10px;
}

.order-item-line {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
}

.customer-info-box {
  background: #17212d;
  border-left: 3px solid #3399ff;
  padding: 8px;
  margin-bottom: 10px;
  font-size: 12px;
  border-radius: 0 6px 6px 0;
}

.customer-name {
  color: #66b2ff;
  font-weight: bold;
}

.customer-instructions {
  color: #ffdd99;
  margin-top: 4px;
  font-size: 11px;
  line-height: 1.3;
}

/* Action Buttons inside Phone */
.phone-action-btn {
  width: 100%;
  background: linear-gradient(180deg, #ff6600, #cc3300);
  border: none;
  border-radius: 8px;
  color: #fff;
  padding: 12px;
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(255, 68, 0, 0.4);
  transition: transform 0.1s, filter 0.1s;
  text-align: center;
}

.phone-action-btn:hover {
  filter: brightness(1.15);
}

.phone-action-btn:active {
  transform: translateY(2px);
}

.phone-action-btn.secondary {
  background: #394252;
  box-shadow: none;
  margin-top: 6px;
  font-size: 9px;
  padding: 8px;
}

.phone-action-btn.success {
  background: linear-gradient(180deg, #28a745, #1e7e34);
  box-shadow: 0 4px 10px rgba(40, 167, 69, 0.4);
}

/* Dasher Stats Summary Tab */
.driver-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 10px;
}

.stat-cell {
  background: #232933;
  border-radius: 8px;
  padding: 8px;
  text-align: center;
  border: 1px solid #343d4d;
}

.stat-cell .label {
  font-size: 9px;
  color: #8899aa;
  margin-bottom: 4px;
  font-family: 'Press Start 2P', monospace;
}

.stat-cell .val {
  font-size: 16px;
  font-weight: bold;
  color: #ffffff;
}

.stat-cell .val.green { color: #55ff88; }
.stat-cell .val.orange { color: #ffaa33; }

/* Modal Dialogs (Drop-off Photo, Title Screen, Marathon Alert) */
.game-modal {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  padding: max(8px, env(safe-area-inset-top, 8px)) max(8px, env(safe-area-inset-right, 8px)) max(8px, env(safe-area-inset-bottom, 8px)) max(8px, env(safe-area-inset-left, 8px));
  background: rgba(10, 6, 5, 0.88);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  justify-content: center;
  align-items: center;
}

.modal-content-box {
  background: #181216;
  border: 4px solid #ff5500;
  border-radius: 16px;
  box-shadow: 0 0 30px rgba(255, 85, 0, 0.5);
  max-width: 680px;
  width: 92%;
  max-height: calc(100vh - 20px);
  max-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 16px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  padding: 20px;
  text-align: center;
  color: #fff;
  position: relative;
}

.modal-header-img {
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  border-radius: 10px;
  border: 2px solid #553322;
  margin-bottom: 16px;
}

.modal-title {
  font-family: 'Press Start 2P', monospace;
  font-size: 18px;
  color: #ff9933;
  margin-bottom: 12px;
  text-shadow: 2px 2px 0 #000;
}

.modal-subtitle {
  font-size: 15px;
  color: #ccc;
  margin-bottom: 18px;
  line-height: 1.4;
}

.btn-arcade {
  background: linear-gradient(180deg, #ff6600, #bb2200);
  border: 3px solid #ffcc66;
  border-radius: 8px;
  padding: 12px 28px;
  color: #fff;
  font-family: 'Press Start 2P', monospace;
  font-size: 13px;
  cursor: pointer;
  box-shadow: 0 5px 0 #661100, 0 8px 20px rgba(0,0,0,0.7);
  transition: transform 0.1s, filter 0.1s;
  display: inline-block;
  margin: 6px;
}

.btn-arcade:hover {
  filter: brightness(1.2);
}

.btn-arcade:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 #661100;
}

.btn-arcade.blue {
  background: linear-gradient(180deg, #0088ff, #0044aa);
  border-color: #66ccff;
  box-shadow: 0 5px 0 #002266, 0 8px 20px rgba(0,0,0,0.7);
}

.btn-arcade.green {
  background: linear-gradient(180deg, #00cc44, #007722);
  border-color: #88ff99;
  box-shadow: 0 5px 0 #004411, 0 8px 20px rgba(0,0,0,0.7);
}

/* Minimap Container (Docked Top-Right) */
#minimap-container {
  position: absolute;
  top: 48px;
  right: 12px;
  width: 105px;
  height: 105px;
  z-index: 60;
  pointer-events: auto;
}

#minimap-canvas {
  display: block;
  width: 105px;
  height: 105px;
  background: rgba(15, 10, 15, 0.92);
  border: 2px solid #ff6600;
  border-radius: 10px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.75);
}

/* Dashboard Settings Modal (Submenu for Radio, Controls, Map Legend) */
.menu-modal-card {
  max-width: 520px;
  width: 92%;
  max-height: 85vh;
  overflow-y: auto;
  text-align: left;
  background: #141014;
  border: 3px solid #ff6600;
  border-radius: 16px;
  box-shadow: 0 0 35px rgba(255, 102, 0, 0.6);
  padding: 18px 20px;
  color: #fff;
  font-family: 'Rajdhani', sans-serif;
}

.menu-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px dashed #44281a;
  padding-bottom: 10px;
  margin-bottom: 14px;
}

.modal-close-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #fff;
  border-radius: 6px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
}

.modal-close-btn:hover {
  background: #ff4400;
}

.menu-modal-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 16px;
}

.menu-section {
  background: #1c1518;
  border: 1.5px solid #3d2822;
  border-radius: 10px;
  padding: 12px;
}

.menu-section-title {
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  color: #ffaa33;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Radio Submenu Controls */
.radio-controls-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.radio-ctrl-btn {
  background: #2a1c22;
  border: 1.5px solid #ff7700;
  color: #fff;
  border-radius: 6px;
  padding: 6px 10px;
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  cursor: pointer;
  flex: 1;
  text-align: center;
  transition: all 0.15s ease;
}

.radio-ctrl-btn:hover, .radio-ctrl-btn:active {
  background: #ff6600;
  color: #fff;
}

.radio-ctrl-btn.play-btn {
  background: linear-gradient(180deg, #10b981, #047857);
  border-color: #6ee7b7;
}

.radio-ctrl-btn.mute-btn {
  background: #334155;
  border-color: #94a3b8;
}

.radio-track-name {
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  color: #67e8f9;
  background: #0f0a0d;
  padding: 6px 8px;
  border-radius: 4px;
  border: 1px solid #2d1e24;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Controls Options Grid */
.menu-btn-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.menu-opt-btn {
  background: #231b20;
  border: 1.5px solid #ffaa44;
  color: #fff;
  border-radius: 6px;
  padding: 8px 10px;
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  cursor: pointer;
  text-align: center;
  line-height: 1.4;
  transition: all 0.15s ease;
}

.menu-opt-btn:hover, .menu-opt-btn:active {
  background: #ff7700;
}

/* Map Legend Grid */
.legend-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  font-size: 13px;
  color: #ddd;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #140e12;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid #2c1a20;
}

.legend-icon {
  font-size: 16px;
}


/* On-Screen Mobile Touch Controls (D-Pad & Pedals) */
#touch-controls {
  display: none;
  position: absolute;
  bottom: 12px;
  left: 0;
  right: 0;
  padding: 0 16px;
  justify-content: space-between;
  align-items: flex-end;
  pointer-events: none;
  z-index: 80;
  touch-action: none;
}

body.touch-active #touch-controls {
  display: flex;
}

@media (max-width: 1024px) {
  #touch-controls {
    display: flex;
  }
}

@media (pointer: coarse) {
  #touch-controls {
    display: flex;
  }
}

/* Left Cluster: Virtual Steering Wheel & Tilt Steer */
.touch-cluster-left {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: auto;
}

.touch-aux-pill {
  background: rgba(18, 12, 10, 0.88);
  border: 1.5px solid #ffaa33;
  border-radius: 12px;
  padding: 4px 10px;
  color: #ffffff;
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.6);
  transition: all 0.15s ease;
}

.touch-aux-pill.tilt-active {
  background: linear-gradient(135deg, #059669, #10b981);
  border-color: #6ee7b7;
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.8);
}

.steering-wheel-wrapper {
  position: relative;
  width: 154px;
  height: 164px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  overscroll-behavior: none;
  -webkit-overscroll-behavior: none;
}

.virtual-steering-wheel {
  width: 144px;
  height: 144px;
  flex-shrink: 0;
  border-radius: 50%;
  position: relative;
  background: radial-gradient(circle at 50% 50%, #221e1a 38%, #0d0c0a 100%);
  border: 12px solid #2b2520;
  box-shadow: 
    0 10px 28px rgba(0, 0, 0, 0.9),
    inset 0 2px 4px rgba(255, 255, 255, 0.3),
    inset 0 -4px 8px rgba(0, 0, 0, 0.95),
    0 0 0 3px #483d35;
  transform-origin: center center;
  transition: transform 0.04s ease-out;
  cursor: grab;
  touch-action: none;
  overscroll-behavior: none;
  -webkit-overscroll-behavior: none;
}

.virtual-steering-wheel:active {
  cursor: grabbing;
}

/* Wheel Grip Highlights & Notches */
.wheel-grip-notch {
  position: absolute;
  background: #ff7700;
  border-radius: 4px;
}
.wheel-grip-notch.top {
  top: 2px;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 5px;
  background: #e05e26;
  box-shadow: 0 0 8px rgba(224, 94, 38, 0.85);
}
.wheel-grip-notch.left {
  left: 2px;
  top: 50%;
  transform: translateY(-50%);
  width: 5px;
  height: 18px;
  background: #554a44;
}
.wheel-grip-notch.right {
  right: 2px;
  top: 50%;
  transform: translateY(-50%);
  width: 5px;
  height: 18px;
  background: #554a44;
}

/* Chrome Spokes */
.wheel-spoke {
  position: absolute;
  background: linear-gradient(180deg, #94a3b8, #475569);
  box-shadow: 0 1px 2px rgba(0,0,0,0.6);
}
.wheel-spoke.spoke-l {
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 12px;
  border-radius: 4px;
}
.wheel-spoke.spoke-r {
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 12px;
  border-radius: 4px;
}
.wheel-spoke.spoke-b {
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: 12px;
  height: 34px;
  border-radius: 4px;
}

/* Center Horn Hub */
.wheel-center-hub {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: radial-gradient(circle, #ea580c 0%, #9a3412 85%, #431407 100%);
  border: 2.5px solid #fdba74;
  box-shadow: 0 4px 12px rgba(0,0,0,0.85), inset 0 2px 2px rgba(255,255,255,0.45);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  z-index: 5;
}

.wheel-center-hub:active {
  transform: translate(-50%, -50%) scale(0.92);
  background: #ea580c;
  box-shadow: 0 2px 4px rgba(0,0,0,0.9);
}

.hub-horn-icon {
  font-size: 13px;
  line-height: 1;
}

.hub-horn-text {
  font-family: 'Press Start 2P', monospace;
  font-size: 5px;
  color: #fed7aa;
  margin-top: 1px;
}

.wheel-steer-hints {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 0 6px;
  margin-top: 2px;
  font-family: 'Press Start 2P', monospace;
  font-size: 6px;
  color: #94a3b8;
  opacity: 0.75;
  pointer-events: none;
}

/* Right Cluster: Ergonomic Pedals & Drift */
.touch-cluster-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  pointer-events: auto;
}

.drift-btn {
  width: 62px;
  height: 38px;
  font-size: 8px;
  border-color: #a855f7;
  background: linear-gradient(145deg, #3b0764, #1e1b4b);
  border-radius: 10px;
  margin-right: 72px; /* positioned ergonomically right above the brake pedal */
  color: #fff;
  font-family: 'Press Start 2P', monospace;
  font-weight: bold;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.6);
  transition: transform 0.08s ease;
}

.drift-btn:active, .drift-btn.active {
  background: #9333ea;
  border-color: #d8b4fe;
  transform: scale(0.92);
}

.touch-pedals-cluster {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.touch-btn {
  color: #ffffff;
  font-family: 'Press Start 2P', monospace;
  font-weight: bold;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  cursor: pointer;
  transition: transform 0.08s ease;
}

.brake-pedal {
  width: 62px;
  height: 76px;
  border-radius: 12px;
  border: 2.5px solid #ef4444;
  background: linear-gradient(180deg, #dc2626, #7f1d1d);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.7), inset 0 2px 0 rgba(255, 255, 255, 0.25);
}

.brake-pedal:active, .brake-pedal.active {
  background: #ef4444;
  border-color: #fca5a5;
  transform: scale(0.93);
}

.gas-pedal {
  width: 68px;
  height: 90px;
  border-radius: 14px;
  border: 2.5px solid #10b981;
  background: linear-gradient(180deg, #059669, #064e3b);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.75), inset 0 2px 0 rgba(255, 255, 255, 0.3);
}

.gas-pedal:active, .gas-pedal.active {
  background: #10b981;
  border-color: #6ee7b7;
  transform: scale(0.93);
}

.pedal-icon {
  font-size: 14px;
  margin-bottom: 2px;
}

.pedal-label {
  font-size: 7px;
  line-height: 1.2;
}

/* Mobile Responsiveness for Small Screens / Smartphones */
@media (max-width: 900px) {
  #top-hud {
    top: 6px;
    left: 8px;
    right: 8px;
    flex-wrap: nowrap;
  }

  .compact-status-pill {
    padding: 5px 8px;
    font-size: 8px;
    gap: 5px;
  }

  .hud-label {
    display: none;
  }

  #vehicle-gauges {
    top: 44px;
    left: 8px;
    width: 96px;
    height: 34px;
    padding: 3px 6px;
  }

  .speed-val {
    font-size: 14px;
  }

  /* Dock phone minimized pill on LEFT under vehicle gauges - 100% away from minimap */
  #phone-minimized-pill {
    top: 84px;
    left: 8px;
    right: auto;
    padding: 5px 9px;
    font-size: 7px;
  }

  #minimap-container {
    top: 44px;
    right: 8px;
    width: 96px;
    height: 96px;
  }

  #minimap-canvas {
    width: 96px;
    height: 96px;
  }

  #event-banner {
    top: 142px;
    left: 50%;
    transform: translateX(-50%);
    width: 86vw;
    max-width: 330px;
    font-size: 8px;
    padding: 6px 12px;
  }

  .phone-pulsing-btn {
    padding: 5px 8px;
    font-size: 7px;
  }

  .menu-toggle-btn {
    padding: 5px 8px;
    font-size: 7px;
  }

  /* Smartphone Centered Modal on Mobile */
  #phone-dock {
    position: fixed;
    top: 50%;
    left: 50%;
    right: auto;
    bottom: auto;
    transform: translate(-50%, -50%);
    width: calc(100vw - 32px);
    max-width: 360px;
    height: 75vh;
    max-height: 520px;
    z-index: 100;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.95), 0 0 0 9999px rgba(0, 0, 0, 0.65);
    border-radius: 20px;
  }

  #phone-dock.minimized {
    display: none !important;
    pointer-events: none !important;
    visibility: hidden !important;
  }

  /* On-Screen Touch Driving Controls (Bottom) */
  #touch-controls {
    bottom: 8px;
    left: 8px;
    right: 8px;
    padding: 0;
  }

  .steering-wheel-wrapper {
    width: 152px;
    height: 152px;
  }

  .virtual-steering-wheel {
    width: 146px;
    height: 146px;
  }

  .gas-pedal {
    width: 64px;
    height: 84px;
  }

  .brake-pedal {
    width: 58px;
    height: 72px;
  }

  .drift-btn {
    width: 58px;
    height: 36px;
    margin-right: 66px;
  }
}

/* Horizontal Phone Optimization (Landscape Mode) */
@media (orientation: landscape) and (max-height: 650px), (orientation: landscape) and (max-width: 1024px) {
  #top-hud {
    top: 4px;
    left: 8px;
    right: 8px;
  }

  .compact-status-pill {
    padding: 3px 8px;
    font-size: 7px;
  }

  #vehicle-gauges {
    top: 34px;
    left: 8px;
    width: 86px;
    height: 30px;
    padding: 2px 4px;
  }

  .speed-val {
    font-size: 12px;
  }

  /* In horizontal mode: dock minimized phone pill on left below speedometer */
  #phone-minimized-pill {
    top: 68px;
    left: 8px;
    right: auto;
    padding: 4px 8px;
    font-size: 6.5px;
  }

  /* Minimap remains cleanly on top-right */
  #minimap-container {
    top: 34px;
    right: 8px;
    width: 80px;
    height: 80px;
  }

  #minimap-canvas {
    width: 80px;
    height: 80px;
  }

  #event-banner {
    top: 100px;
    font-size: 7px;
    padding: 4px 10px;
    max-width: 55vw;
  }

  /* Compact Landscape Offer Toast */
  #offer-toast {
    top: 36px;
    padding: 4px 10px;
    gap: 8px;
    border-radius: 18px;
  }

  .toast-store {
    font-size: 7px;
  }

  .toast-meta {
    font-size: 6.5px;
  }

  .toast-btn {
    padding: 4px 8px;
    font-size: 6.5px;
  }

  /* Phone modal fits horizontal viewport without cropping headers */
  #phone-dock {
    position: fixed;
    top: 6px;
    bottom: 6px;
    left: 50%;
    transform: translateX(-50%);
    width: min(520px, calc(100vw - 20px));
    height: calc(100vh - 12px);
    max-height: calc(100vh - 12px);
    z-index: 95;
    border-radius: 16px;
  }

  .phone-notch {
    display: none !important;
  }

  .app-header {
    padding: 6px 12px;
  }

  .phone-toggle-btn {
    padding: 8px 16px;
    font-size: 9px;
    min-height: 38px;
    position: relative;
    z-index: 110;
    pointer-events: auto;
  }

  #touch-controls {
    bottom: 4px;
    left: 8px;
    right: 8px;
  }

  .steering-wheel-wrapper {
    width: 148px;
    height: 148px;
  }

  .virtual-steering-wheel {
    width: 142px;
    height: 142px;
  }

  .gas-pedal {
    width: 66px;
    height: 80px;
  }

  .brake-pedal {
    width: 58px;
    height: 68px;
  }

  .drift-btn {
    width: 56px;
    height: 34px;
    margin-right: 62px;
  }
}

/* ============================================================================
   3-LEVEL DRIVING CONTROL DIFFICULTY SELECTOR & INTERACTIVE SPEED GEAR BAR
   ============================================================================ */

.drive-mode-hud-btn {
  border-color: #10b981;
  background: rgba(12, 24, 18, 0.92);
}

.drive-mode-hud-btn.mode-normal {
  border-color: #f59e0b;
  background: rgba(28, 20, 10, 0.92);
}

.drive-mode-hud-btn.mode-hard {
  border-color: #ef4444;
  background: rgba(28, 12, 12, 0.92);
}

.title-difficulty-box {
  background: #140f12;
  border: 2px solid #ff6600;
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 12px;
  text-align: left;
}

.title-diff-heading {
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  color: #ffcc44;
  margin-bottom: 8px;
  text-align: center;
}

.difficulty-selector-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.difficulty-selector-grid.compact {
  gap: 6px;
}

.diff-card-btn {
  background: #1e161a;
  border: 2px solid #47333b;
  border-radius: 10px;
  padding: 8px 9px;
  color: #e2e8f0;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  gap: 4px;
  transition: all 0.15s ease;
  font-family: 'Rajdhani', sans-serif;
}

.diff-card-btn:hover {
  border-color: #ff9933;
  background: #281d22;
}

.diff-card-btn.active {
  background: linear-gradient(180deg, #162c22 0%, #0d1b15 100%);
  border-color: #10b981;
  box-shadow: 0 0 14px rgba(16, 185, 129, 0.45), inset 0 0 8px rgba(16, 185, 129, 0.2);
}

#title-diff-normal.active, #menu-diff-normal.active {
  background: linear-gradient(180deg, #2d2210 0%, #1a1409 100%);
  border-color: #f59e0b;
  box-shadow: 0 0 14px rgba(245, 158, 11, 0.45);
}

#title-diff-hard.active, #menu-diff-hard.active {
  background: linear-gradient(180deg, #2d1212 0%, #1a0a0a 100%);
  border-color: #ef4444;
  box-shadow: 0 0 14px rgba(239, 68, 68, 0.45);
}

.diff-badge {
  font-family: 'Press Start 2P', monospace;
  font-size: 6px;
  padding: 3px 5px;
  border-radius: 4px;
  background: #334155;
  color: #fff;
}

.diff-badge.easy { background: #059669; color: #d1fae5; }
.diff-badge.normal { background: #d97706; color: #fef3c7; }
.diff-badge.hard { background: #dc2626; color: #fee2e2; }

.diff-title {
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  color: #ffffff;
  margin-top: 2px;
}

.diff-desc {
  font-size: 11px;
  color: #cbd5e1;
  line-height: 1.25;
}

/* Interactive Speed Gear Bar (Bottom-Center HUD) */
.speed-gear-bar-hud {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(14, 11, 14, 0.94);
  border: 2.5px solid #10b981;
  border-radius: 16px;
  padding: 7px 12px;
  z-index: 82;
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: min(460px, calc(100vw - 24px));
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.85), 0 0 16px rgba(16, 185, 129, 0.35);
  pointer-events: auto;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  transition: border-color 0.2s ease, opacity 0.2s ease;
}

.speed-gear-bar-hud.mode-normal {
  border-color: #f59e0b;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.85), 0 0 14px rgba(245, 158, 11, 0.3);
}

.speed-gear-bar-hud.mode-hard {
  display: none;
}

.gear-bar-top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

.gear-mode-pill, .gear-steer-pill {
  background: #1e293b;
  border: 1.5px solid #34d399;
  border-radius: 8px;
  padding: 3px 7px;
  color: #ecfdf5;
  font-family: 'Press Start 2P', monospace;
  font-size: 6.5px;
  cursor: pointer;
  transition: all 0.12s ease;
  white-space: nowrap;
}

.gear-steer-pill {
  border-color: #38bdf8;
  color: #e0f2fe;
}

.gear-mode-pill:hover, .gear-steer-pill:hover {
  filter: brightness(1.2);
}

.gear-readout-tag {
  font-family: 'Press Start 2P', monospace;
  font-size: 7.5px;
  color: #fde047;
  white-space: nowrap;
  margin-left: auto;
}

.gear-bar-controls-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.gear-step-btn {
  width: 32px;
  height: 36px;
  border-radius: 8px;
  border: 2px solid #64748b;
  background: linear-gradient(180deg, #334155, #1e293b);
  color: #ffffff;
  font-family: 'Press Start 2P', monospace;
  font-size: 13px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.gear-step-btn:active {
  transform: scale(0.92);
  background: #10b981;
  border-color: #a7f3d0;
}

.gear-slots-track {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
  flex: 1;
}

.gear-slot-btn {
  height: 36px;
  border-radius: 8px;
  border: 1.5px solid #334155;
  background: #181f29;
  color: #94a3b8;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 2px;
  transition: all 0.1s ease;
}

.gear-slot-btn .gear-key {
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  color: #e2e8f0;
  line-height: 1.1;
}

.gear-slot-btn .gear-sub {
  font-family: 'Rajdhani', sans-serif;
  font-size: 9.5px;
  font-weight: 700;
  color: #94a3b8;
  line-height: 1;
  margin-top: 2px;
}

.gear-slot-btn.active {
  transform: translateY(-1px);
  color: #ffffff;
  border-width: 2px;
}

.gear-slot-btn.gear-rev.active {
  background: linear-gradient(180deg, #991b1b, #450a0a);
  border-color: #f87171;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.6);
}

.gear-slot-btn.gear-stop.active {
  background: linear-gradient(180deg, #475569, #1e293b);
  border-color: #cbd5e1;
  box-shadow: 0 0 8px rgba(148, 163, 184, 0.5);
}

.gear-slot-btn.gear-1.active {
  background: linear-gradient(180deg, #0284c7, #0c4a6e);
  border-color: #38bdf8;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.65);
}

.gear-slot-btn.gear-2.active {
  background: linear-gradient(180deg, #059669, #064e3b);
  border-color: #34d399;
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.75);
}

.gear-slot-btn.gear-3.active {
  background: linear-gradient(180deg, #d97706, #78350f);
  border-color: #fbbf24;
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.75);
}

.gear-slot-btn.gear-4.active {
  background: linear-gradient(180deg, #ea580c, #7c2d12);
  border-color: #fb923c;
  box-shadow: 0 0 14px rgba(249, 115, 22, 0.85);
}

.gear-slot-btn.active .gear-key,
.gear-slot-btn.active .gear-sub {
  color: #ffffff;
}

.gear-meter-strip {
  width: 100%;
  height: 5px;
  background: #1e293b;
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid #334155;
}

.gear-meter-fill {
  height: 100%;
  background: linear-gradient(90deg, #38bdf8 0%, #10b981 45%, #f59e0b 78%, #ef4444 100%);
  width: 0%;
  transition: width 0.12s ease-out;
}

.gear-bar-hint {
  font-family: 'Press Start 2P', monospace;
  font-size: 5.8px;
  color: #94a3b8;
  text-align: center;
  letter-spacing: 0.2px;
}

.title-controls-guide {
  background: #231610;
  border: 1px dashed #e65100;
  border-radius: 8px;
  padding: 9px 12px;
  margin-bottom: 12px;
  font-size: 11.5px;
  text-align: left;
  line-height: 1.45;
}

.title-controls-guide .guide-heading {
  color: #ffaa33;
  font-weight: bold;
  margin-bottom: 2px;
}

.ios-install-pill {
  display: inline-block;
  margin-top: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.16);
  border: 1px solid #10b981;
  color: #6ee7b7;
  font-size: 11.5px;
  font-weight: 700;
  text-decoration: none;
  line-height: 1.2;
}

@media (max-width: 900px) {
  .difficulty-selector-grid {
    grid-template-columns: 1fr;
  }

  .modal-header-img {
    max-height: 110px;
    margin-bottom: 8px;
  }

  .speed-gear-bar-hud {
    bottom: calc(184px + env(safe-area-inset-bottom, 0px));
    width: min(390px, calc(100vw - 12px));
    padding: 5px 7px;
  }

  .gear-mode-pill, .gear-steer-pill {
    font-size: 5.5px;
    padding: 3px 5px;
  }

  .gear-readout-tag {
    font-size: 6.5px;
  }

  .gear-bar-hint {
    display: none;
  }
}

/* iPhone & Compact Mobile Screen Optimization — Guarantees Title Screen & HUD fit 100% with zero stretching */
@media (max-width: 640px), (max-height: 760px) {
  #top-hud {
    top: max(6px, calc(env(safe-area-inset-top, 0px) + 2px));
    left: 6px;
    right: 6px;
    gap: 4px;
  }

  .compact-status-pill {
    padding: 4px 7px;
    font-size: 7px;
    gap: 4px;
    border-radius: 8px;
  }

  .hud-actions-cluster {
    gap: 4px;
  }

  .hud-mode-prefix {
    display: none;
  }

  .menu-toggle-btn {
    padding: 5px 7px;
    font-size: 6.5px;
    border-radius: 8px;
  }

  #vehicle-gauges {
    top: calc(max(6px, calc(env(safe-area-inset-top, 0px) + 2px)) + 32px);
    left: 6px;
  }

  #phone-minimized-pill {
    top: calc(max(6px, calc(env(safe-area-inset-top, 0px) + 2px)) + 70px);
    left: 6px;
  }

  #minimap-container {
    top: calc(max(6px, calc(env(safe-area-inset-top, 0px) + 2px)) + 32px);
    right: 6px;
    width: 88px;
    height: 88px;
  }

  #minimap-canvas {
    width: 88px;
    height: 88px;
  }

  #touch-controls {
    bottom: max(6px, env(safe-area-inset-bottom, 6px));
    left: 6px;
    right: 6px;
  }

  /* Compact Single-Screen Title Modal on iPhone Portrait */
  #title-modal .modal-content-box {
    width: min(96vw, 440px);
    padding: 12px 12px;
    border-width: 3px;
    border-radius: 14px;
  }

  #title-modal .modal-header-img {
    max-height: 74px;
    margin-bottom: 6px;
    border-radius: 8px;
  }

  #title-modal .modal-title {
    font-size: clamp(10.5px, 3.1vw, 13.5px);
    line-height: 1.3;
    margin-bottom: 4px;
  }

  #title-modal .modal-subtitle {
    font-size: 12px;
    line-height: 1.25;
    margin-bottom: 7px;
  }

  #title-modal .title-difficulty-box {
    padding: 7px 8px;
    margin-bottom: 7px;
    border-radius: 10px;
  }

  #title-modal .title-diff-heading {
    font-size: 7px;
    margin-bottom: 5px;
  }

  #title-modal .difficulty-selector-grid {
    gap: 5px;
  }

  #title-modal .diff-card-btn {
    padding: 5px 8px;
    gap: 2px;
    border-radius: 8px;
  }

  #title-modal .diff-badge {
    font-size: 5.5px;
    padding: 2px 4px;
  }

  #title-modal .diff-title {
    font-size: 7.5px;
    margin-top: 1px;
  }

  #title-modal .diff-desc {
    font-size: 10.5px;
    line-height: 1.18;
  }

  #title-modal .title-controls-guide {
    padding: 6px 8px;
    margin-bottom: 8px;
    font-size: 10.5px;
    line-height: 1.28;
  }

  #title-modal .title-controls-guide .guide-extra-line {
    display: none;
  }

  #title-modal .start-shift-btn {
    width: 100%;
    margin: 0;
    padding: 11px 10px;
    font-size: 10px;
    border-radius: 8px;
  }
}

@media (orientation: landscape) and (max-width: 1024px) {
  .speed-gear-bar-hud {
    bottom: max(6px, env(safe-area-inset-bottom, 6px));
    width: min(350px, calc(100vw - 340px));
    padding: 4px 8px;
  }

  .gear-slot-btn {
    height: 30px;
  }

  .gear-step-btn {
    width: 26px;
    height: 30px;
    font-size: 11px;
  }

  .gear-bar-hint {
    display: none;
  }

  /* Compact Landscape Title Modal so all 3 difficulty options + Start button fit in 375px-430px height */
  #title-modal .modal-content-box {
    width: min(94vw, 660px);
    padding: 10px 14px;
  }

  #title-modal .modal-header-img {
    display: none;
  }

  #title-modal .modal-subtitle {
    margin-bottom: 6px;
    font-size: 11.5px;
  }

  #title-modal .difficulty-selector-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }

  #title-modal .title-controls-guide {
    padding: 5px 8px;
    margin-bottom: 6px;
    font-size: 10px;
  }
}

/* =========================================================================
   REAL-WORLD ST. GEORGE GPS & STREET ADDRESS HUD PILL + DIRECTORY
   ========================================================================= */
.gps-address-hud-pill {
  position: absolute;
  top: calc(96px + env(safe-area-inset-top, 0px));
  left: max(10px, env(safe-area-inset-left, 10px));
  background: rgba(15, 23, 42, 0.90);
  border: 1.5px solid #38bdf8;
  border-radius: 10px;
  padding: 5px 9px;
  z-index: 42;
  max-width: 255px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  transition: transform 0.12s ease, border-color 0.15s ease;
}

.gps-address-hud-pill:hover {
  border-color: #fbbf24;
  transform: translateY(-1px);
}

.gps-hud-title-row {
  display: flex;
  align-items: center;
  gap: 5px;
}

.gps-pin-dot {
  font-size: 10px;
}

.gps-poi-name {
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  color: #fde047;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gps-poi-addr {
  font-size: 10px;
  color: #bae6fd;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
}

.real-world-dir-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 6px;
  max-height: 185px;
  overflow-y: auto;
  padding: 4px;
  background: rgba(9, 13, 22, 0.75);
  border: 1px solid #334155;
  border-radius: 8px;
}

.rw-dir-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 8px;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
  color: #f8fafc;
  transition: border-color 0.12s ease, background 0.12s ease;
}

.rw-dir-item:hover {
  border-color: #38bdf8;
  background: #0f172a;
}

.rw-dir-sprite {
  width: 28px;
  height: 28px;
  object-fit: contain;
  image-rendering: pixelated;
  flex-shrink: 0;
}

.rw-dir-info {
  flex: 1;
  min-width: 0;
}

.rw-dir-title {
  font-family: 'Press Start 2P', monospace;
  font-size: 6.5px;
  color: #fde047;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rw-dir-addr {
  font-size: 9.5px;
  color: #93c5fd;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 600px) and (orientation: portrait) {
  .gps-address-hud-pill {
    top: calc(88px + env(safe-area-inset-top, 0px));
    max-width: 195px;
    padding: 4px 7px;
  }
  .gps-poi-name {
    font-size: 6px;
  }
  .gps-poi-addr {
    font-size: 9px;
  }
}
