/* Custom Outdoor Styles */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;600;700;800&display=swap');

html, body {
  overflow-x: hidden !important;
  width: 100% !important;
  max-width: 100vw !important;
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-overflow-scrolling: touch;
}

#mobileBottomNav {
  padding-bottom: calc(0.5rem + env(safe-area-inset-bottom, 0px)) !important;
}

code, .font-mono {
  font-family: 'JetBrains Mono', monospace;
}

/* Custom Leaflet Map styling */
.leaflet-container {
  background-color: #0b1120 !important;
  font-family: inherit;
}

.leaflet-popup-content-wrapper {
  background: #0f172a !important;
  color: #f1f5f9 !important;
  border: 1px solid #334155 !important;
  border-radius: 16px !important;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5) !important;
  padding: 4px !important;
  max-width: min(290px, calc(100vw - 32px)) !important;
}

.leaflet-popup-tip {
  background: #0f172a !important;
  border: 1px solid #334155 !important;
}

.leaflet-popup-content {
  margin: 10px 12px !important;
  line-height: 1.4 !important;
  max-width: 270px !important;
}

/* Camp Marker Pin */
.camp-marker-pin {
  width: 36px;
  height: 36px;
  border-radius: 50% 50% 50% 0;
  background: #059669;
  position: absolute;
  transform: rotate(-45deg);
  left: 50%;
  top: 50%;
  margin: -20px 0 0 -20px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(5, 150, 105, 0.5);
  border: 2px solid #ffffff;
  transition: transform 0.2s ease;
}
.camp-marker-pin span {
  transform: rotate(45deg);
  font-size: 16px;
}
.camp-marker-pin:hover {
  transform: rotate(-45deg) scale(1.15);
}

/* Waypoint Marker Pins */
.waypoint-pin {
  width: 34px;
  height: 34px;
  border-radius: 50% 50% 50% 0;
  position: absolute;
  transform: rotate(-45deg);
  left: 50%;
  top: 50%;
  margin: -17px 0 0 -17px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #ffffff;
  transition: transform 0.2s ease;
  box-shadow: 0 4px 12px rgba(0,0,0,0.6);
}
.waypoint-pin span {
  transform: rotate(45deg);
  font-size: 15px;
}
.waypoint-pin:hover {
  transform: rotate(-45deg) scale(1.2);
}

.wp-water {
  background: linear-gradient(135deg, #0284c7, #0369a1);
  box-shadow: 0 0 12px rgba(2, 132, 199, 0.6);
}
.wp-shelter {
  background: linear-gradient(135deg, #d97706, #b45309);
  box-shadow: 0 0 12px rgba(217, 119, 6, 0.6);
}
.wp-signal {
  background: linear-gradient(135deg, #9333ea, #7e22ce);
  box-shadow: 0 0 12px rgba(147, 51, 234, 0.6);
}
.wp-danger {
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  box-shadow: 0 0 12px rgba(220, 38, 38, 0.7);
}

/* Buddy Marker Pin */
.buddy-marker-pin {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 3px solid #a855f7;
  box-shadow: 0 0 15px rgba(168, 85, 247, 0.6);
  background-size: cover;
  background-position: center;
  position: relative;
  cursor: pointer;
  transition: transform 0.2s ease;
}
.buddy-marker-pin:hover {
  transform: scale(1.2);
}
.buddy-marker-online {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 12px;
  height: 12px;
  background-color: #22c55e;
  border: 2px solid #0f172a;
  border-radius: 50%;
}

/* SOS Pulsing Marker */
.sos-marker-pin {
  width: 32px;
  height: 32px;
  background: #dc2626;
  border-radius: 50%;
  animation: sosPulse 1.5s infinite;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}

@keyframes sosPulse {
  0% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.8); }
  70% { box-shadow: 0 0 0 22px rgba(220, 38, 38, 0); }
  100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); }
}

.sos-pulse {
  animation: pulseButton 2s infinite ease-in-out;
}

@keyframes pulseButton {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
  50% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
}

/* ================= COMPASS & ALTIMETER HUD STYLES ================= */
.compass-dial {
  transition: transform 0.15s cubic-bezier(0.25, 1, 0.5, 1);
  will-change: transform;
}

/* ================= OLED ULTRA BATTERY SAVER & TACTICAL NIGHT STYLES ================= */
body.oled-battery-saver {
  background-color: #000000 !important;
  color: #fca5a5 !important;
}

body.oled-battery-saver #appBody,
body.oled-battery-saver header,
body.oled-battery-saver aside,
body.oled-battery-saver nav,
body.oled-battery-saver #mobileBottomNav,
body.oled-battery-saver [id^="modal"] > div {
  background: #000000 !important;
  background-color: #000000 !important;
  border-color: #450a0a !important;
  box-shadow: none !important;
}

body.oled-battery-saver .leaflet-container {
  background: #000000 !important;
  filter: invert(100%) hue-rotate(180deg) brightness(40%) contrast(150%) grayscale(100%) !important;
}

body.oled-battery-saver .bg-slate-900,
body.oled-battery-saver .bg-slate-950,
body.oled-battery-saver .bg-slate-900\/90,
body.oled-battery-saver .bg-slate-900\/80,
body.oled-battery-saver .bg-slate-950\/80 {
  background-color: #000000 !important;
  border-color: #450a0a !important;
}

body.oled-battery-saver .text-white,
body.oled-battery-saver .text-slate-100,
body.oled-battery-saver .text-slate-200 {
  color: #fecaca !important;
}

body.oled-battery-saver .text-slate-300,
body.oled-battery-saver .text-slate-400 {
  color: #f87171 !important;
}

body.oled-battery-saver .text-amber-400,
body.oled-battery-saver .text-amber-300 {
  color: #fbbf24 !important;
}

body.oled-battery-saver * {
  text-shadow: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

/* Tactical HUD Fullscreen Minimalist Display */
#tacticalAlpineHudOverlay {
  background-color: #000000 !important;
}

#tacticalAlpineHudOverlay.hud-theme-amber {
  color: #fef3c7;
}

#tacticalAlpineHudOverlay.hud-theme-amber .hud-accent-text {
  color: #f59e0b !important;
}

#tacticalAlpineHudOverlay.hud-theme-amber .hud-card {
  background-color: #000000 !important;
  border-color: #78350f !important;
}

#tacticalAlpineHudOverlay.hud-theme-red {
  color: #fee2e2;
}

#tacticalAlpineHudOverlay.hud-theme-red .hud-accent-text {
  color: #ef4444 !important;
}

#tacticalAlpineHudOverlay.hud-theme-red .hud-card {
  background-color: #000000 !important;
  border-color: #7f1d1d !important;
}

.night-mode {
  filter: sepia(100%) hue-rotate(-50deg) saturate(600%) contrast(1.1) brightness(0.9);
}

.night-mode .leaflet-container {
  filter: invert(1) hue-rotate(180deg) brightness(0.7) sepia(100%) hue-rotate(-50deg) saturate(500%);
}

/* Scrollbar styles */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: #090d16;
}
::-webkit-scrollbar-thumb {
  background: #1e293b;
  border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
  background: #334155;
}

/* Tactical Military Digital Walkie Talkie Styles */
.tactical-radio-casing {
  background: radial-gradient(ellipse at top, #1e293b 0%, #0f172a 45%, #020617 100%);
  border: 3px solid #334155;
  box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.1), 0 25px 50px -12px rgba(0, 0, 0, 0.9);
}

.tactical-lcd {
  background: #04120a;
  border: 2px solid #064e3b;
  box-shadow: inset 0 4px 12px rgba(0, 0, 0, 0.9), 0 0 15px rgba(16, 185, 129, 0.15);
  position: relative;
  overflow: hidden;
}

.tactical-lcd::before {
  content: " ";
  display: block;
  position: absolute;
  top: 0; left: 0; bottom: 0; right: 0;
  background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%);
  background-size: 100% 3px;
  z-index: 2;
  pointer-events: none;
  opacity: 0.6;
}

.allen-bolt {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #475569;
  border: 1px solid #1e293b;
  position: relative;
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.4), 0 1px 2px rgba(0,0,0,0.8);
}
.allen-bolt::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 2px;
  height: 2px;
  background: #0f172a;
}

.tactical-btn {
  background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
  border: 1px solid #334155;
  box-shadow: 0 3px 0 #020617, 0 4px 6px rgba(0, 0, 0, 0.4);
  transition: all 0.08s ease;
}
.tactical-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #020617, 0 2px 4px rgba(0, 0, 0, 0.4);
}

.tactical-knurl {
  background-image: radial-gradient(#334155 15%, transparent 16%), radial-gradient(#1e293b 15%, transparent 16%);
  background-size: 6px 6px;
  background-position: 0 0, 3px 3px;
}

/* ================= ULTRA-TACTICAL PROFESSIONAL PTT STYLES ================= */
.tactical-ptt-housing {
  background: radial-gradient(circle at 50% 0%, #151f32 0%, #080d16 100%);
  border: 2px solid #334155;
  box-shadow: inset 0 2px 6px rgba(255, 255, 255, 0.08), inset 0 -4px 12px rgba(0, 0, 0, 0.9), 0 10px 25px rgba(0, 0, 0, 0.8);
  position: relative;
}

.tactical-hazard-stripes {
  background: repeating-linear-gradient(
    -45deg,
    #f59e0b,
    #f59e0b 6px,
    #0f172a 6px,
    #0f172a 12px
  );
  opacity: 0.85;
}

.ptt-hinge-pin {
  width: 10px;
  height: 24px;
  background: linear-gradient(90deg, #334155 0%, #64748b 50%, #1e293b 100%);
  border: 1px solid #0f172a;
  border-radius: 3px;
  box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.4), 0 2px 4px rgba(0, 0, 0, 0.7);
}

.tactical-ptt-lever {
  background: linear-gradient(180deg, #273549 0%, #172133 45%, #0a101d 100%);
  border: 2px solid #4b5d78;
  border-bottom: 3px solid #1e293b;
  box-shadow: 
    0 10px 0 #020617,
    0 16px 24px rgba(0, 0, 0, 0.85),
    inset 0 2px 3px rgba(255, 255, 255, 0.25),
    inset 0 -3px 6px rgba(0, 0, 0, 0.6);
  transition: all 0.08s cubic-bezier(0.2, 0.8, 0.2, 1);
  user-select: none;
  cursor: pointer;
  position: relative;
}

.tactical-ptt-lever:hover {
  background: linear-gradient(180deg, #334661 0%, #1e2b42 45%, #0d1526 100%);
  border-color: #64748b;
}

.tactical-ptt-lever:active, .tactical-ptt-lever.is-transmitting {
  transform: translateY(8px) scale(0.99);
  box-shadow: 
    0 2px 0 #020617,
    0 4px 12px rgba(239, 68, 68, 0.6),
    inset 0 4px 12px rgba(0, 0, 0, 0.85),
    inset 0 0 25px rgba(239, 68, 68, 0.35);
  border-color: #ef4444 !important;
}

.tactical-rubber-ribs {
  background: repeating-linear-gradient(
    180deg,
    #2a3b53,
    #2a3b53 5px,
    #0b121e 5px,
    #0b121e 10px
  );
  border-radius: 8px;
  border: 1px solid #1e293b;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.85), 0 1px 2px rgba(255,255,255,0.15);
}

.ptt-tx-glow {
  box-shadow: 0 0 40px rgba(239, 68, 68, 0.8), inset 0 0 20px rgba(239, 68, 68, 0.5) !important;
}

.ptt-armed-glow {
  box-shadow: 0 0 20px rgba(245, 158, 11, 0.25);
}

@keyframes pttPulseWave {
  0% { transform: scale(0.98); opacity: 0.9; }
  100% { transform: scale(1.35); opacity: 0; }
}

.ptt-pulse-ring {
  animation: pttPulseWave 1s infinite ease-out;
}

/* Strobe flash for live transmission */
@keyframes txStrobe {
  0%, 100% { opacity: 1; filter: drop-shadow(0 0 10px #ef4444); }
  50% { opacity: 0.5; filter: drop-shadow(0 0 2px #b91c1c); }
}

.tx-strobe-indicator {
  animation: txStrobe 0.7s infinite ease-in-out;
}

/* ================= MOBILE HANDHELD TACTICAL RADIO OPTIMIZATIONS ================= */
@media (max-width: 640px) {
  #sidebar.mobile-handheld-radio {
    width: 100% !important;
    height: 100% !important;
    position: absolute !important;
    top: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 45 !important;
    background: #020617 !important;
  }

  #sidebar.mobile-handheld-radio .tactical-radio-casing {
    border-radius: 1.75rem;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.95);
    margin: 0.5rem;
  }

  #sidebar.mobile-handheld-radio .tactical-ptt-lever {
    padding-top: 1.5rem !important;
    padding-bottom: 1.5rem !important;
  }

  /* Prevent browser text callout & pull-to-refresh on PTT hold */
  .tactical-ptt-lever {
    touch-action: none !important;
    -webkit-touch-callout: none !important;
    -webkit-user-select: none !important;
    user-select: none !important;
  }
}

.layer-opt {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: space-between !important;
  width: 100% !important;
  flex-shrink: 0 !important;
  min-height: 52px !important;
  margin-bottom: 6px !important;
  position: static !important;
  box-sizing: border-box !important;
}

.layer-opt.active {
  background: #1e293b !important;
  border-color: rgba(52, 211, 153, 0.4) !important;
  color: #34d399 !important;
}

/* User High-Accuracy GPS Glowing Beacon */
.user-pulse-marker {
  position: relative;
  width: 28px;
  height: 28px;
}
.user-beacon-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 14px;
  height: 14px;
  background: #0284c7;
  border: 3px solid #ffffff;
  border-radius: 50%;
  box-shadow: 0 0 14px #38bdf8;
  z-index: 2;
}
.user-beacon-ring {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px solid #38bdf8;
  background: rgba(56, 189, 248, 0.2);
  animation: pulseBeaconRing 2s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
  z-index: 1;
}
@keyframes pulseBeaconRing {
  0% { transform: scale(0.6); opacity: 1; }
  100% { transform: scale(2.4); opacity: 0; }
}

/* Tactical Waypoint Pins */
.waypoint-pin {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #090e17;
  border: 2px solid #38bdf8;
  box-shadow: 0 4px 12px rgba(0,0,0,0.6);
  font-size: 15px;
  transition: transform 0.2s;
}
.waypoint-pin:hover {
  transform: scale(1.15);
}
.wp-water { border-color: #38bdf8; box-shadow: 0 0 10px rgba(56,189,248,0.5); }
.wp-camp { border-color: #10b981; box-shadow: 0 0 10px rgba(16,185,129,0.5); }
.wp-shelter { border-color: #f59e0b; box-shadow: 0 0 10px rgba(245,158,11,0.5); }
.wp-signal { border-color: #a855f7; box-shadow: 0 0 10px rgba(168,85,247,0.5); }
.wp-danger { border-color: #ef4444; box-shadow: 0 0 12px rgba(239,68,68,0.7); animation: pingSlow 2.5s infinite; }
.wp-bear { border-color: #ea580c; background: #431407; box-shadow: 0 0 12px rgba(234,88,12,0.8); }
.wp-wolf { border-color: #dc2626; background: #450a0a; box-shadow: 0 0 12px rgba(220,38,38,0.8); }
.wp-boar { border-color: #d97706; background: #451a03; box-shadow: 0 0 12px rgba(217,119,6,0.8); }
@keyframes pingSlow {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; transform: scale(1.08); }
}

#map {
  position: relative !important;
  z-index: 0 !important;
}

#googleSearchContainer {
  z-index: 30 !important;
}

.absolute.top-4.left-4 {
  z-index: 30 !important;
}

#googleSearchResults, #googleSearchSuggestions {
  box-shadow: 0 20px 35px -5px rgba(0, 0, 0, 0.9), 0 10px 15px -5px rgba(0, 0, 0, 0.7);
}

.google-target-marker {
  pointer-events: auto !important;
}

/* Ensure Top Navigation Header & Dropdowns Float Reliably Above All Map Overlays */
header {
  position: relative;
  z-index: 60 !important;
}

/* Ensure All Dialog Modals Float Above Header */
[id^="modal"], .fixed.z-50 {
  z-index: 100 !important;
}

#sunsetAlertBanner, #addPinNoticeBanner {
  z-index: 35 !important;
}

#alpineToolsDropdown {
  background: #020617 !important;
  border: 1.5px solid #334155 !important;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.95) !important;
  z-index: 70 !important;
}

/* ================= 18. MOBILE OUTDOOR ACCESSIBILITY & FONT OVERHAUL ================= */
@media (max-width: 1023px) {
  #sidebar {
    z-index: 45 !important;
    width: 100% !important;
    max-width: 100vw !important;
    left: 0 !important;
    right: 0 !important;
    padding-top: max(2.2rem, env(safe-area-inset-top, 32px)) !important;
  }

  #sidebar.translate-x-full {
    transform: translateX(100%) !important;
    pointer-events: none !important;
    visibility: hidden !important;
  }

  #sidebar.translate-x-0 {
    transform: translateX(0) !important;
    pointer-events: auto !important;
    visibility: visible !important;
  }

  #btnSidebarEdgeToggle {
    display: none !important;
  }

  #sidebarScrollContainer {
    padding-bottom: 5.5rem !important; /* Ensure clear visibility above mobile bottom dock */
  }
}

/* ================= 18. NARROW MOBILE & RESPONSIVE SCALING ARCHITECTURE ================= */

/* Global Anti-Collision & Safe Word Wrap */
* {
  box-sizing: border-box;
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Badges & Tags Protection: Keep compact and prevent line breaks */
.badge-tag, [class*="rounded-full"][class*="uppercase"] {
  white-space: nowrap !important;
  flex-shrink: 0 !important;
}

/* Modals global base responsive rules */
[id^="modal"] {
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}

[id^="modal"] > div {
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease;
  width: 100%;
}

@media (max-width: 768px) {
  /* High contrast outdoor text colors without breaking layout scale */
  .text-slate-400 {
    color: #cbd5e1 !important;
  }
  .text-slate-500 {
    color: #94a3b8 !important;
  }

  /* Compass & Radio display font scales */
  #compassHeadingDegrees {
    font-size: 2.25rem !important;
    font-weight: 900 !important;
    letter-spacing: 0.05em !important;
  }
  #compassHeadingCardinal {
    font-size: 0.85rem !important;
    letter-spacing: 0.08em !important;
  }
  #altitudeValue, #compassAltitudeMeters {
    font-size: 2.25rem !important;
    font-weight: 900 !important;
  }
  #radioFreqBig {
    font-size: 2rem !important;
    font-weight: 900 !important;
  }
}

/* Mobile Screens (<= 640px) */
@media (max-width: 640px) {
  /* Prevent horizontal scrollbars and layout shifting */
  html, body {
    overflow-x: hidden !important;
    width: 100% !important;
    max-width: 100vw !important;
    position: relative;
    touch-action: pan-x pan-y;
  }

  /* Modals: Clean centered popup with balanced safe margins */
  [id^="modal"] {
    padding: 0.5rem !important;
    align-items: center !important;
    justify-content: center !important;
  }

  [id^="modal"] > div {
    width: calc(100vw - 1rem) !important;
    max-width: calc(100vw - 1rem) !important;
    max-height: 86vh !important;
    border-radius: 1.25rem !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    margin: auto !important;
  }

  [id^="modal"] .p-4, [id^="modal"] .p-5, [id^="modal"] .p-6 {
    padding: 0.65rem 0.75rem !important;
  }

  [id^="modal"] h3, [id^="modal"] h4 {
    font-size: 0.88rem !important;
    line-height: 1.25 !important;
  }

  /* Modal body scroll area */
  [id^="modal"] .overflow-y-auto {
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior: contain !important;
  }

  /* Bottom Sheets & Floating Cards */
  #targetNavBottomSheet {
    width: calc(100% - 1rem) !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    bottom: calc(4.25rem + env(safe-area-inset-bottom, 0px)) !important;
    padding: 0.75rem !important;
    border-radius: 1.25rem !important;
    gap: 0.5rem !important;
    max-height: 60vh !important;
    overflow-y: auto !important;
  }

  #friendNavHudBar {
    width: calc(100% - 1rem) !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    bottom: calc(4.25rem + env(safe-area-inset-bottom, 0px)) !important;
    padding: 0.5rem 0.75rem !important;
    border-radius: 1rem !important;
  }

  #alpineToolsDropdown {
    left: 0.5rem !important;
    right: 0.5rem !important;
    top: calc(3.6rem + env(safe-area-inset-top, 0px)) !important;
    max-width: calc(100vw - 1rem) !important;
    max-height: 68vh !important;
    padding: 0.5rem !important;
    border-radius: 1.25rem !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

  #layerMenuCard {
    width: 100% !important;
    max-width: calc(100vw - 1rem) !important;
    border-radius: 1.25rem !important;
  }

  #gpsTrackRecorderBar {
    width: calc(100% - 1rem) !important;
    left: 0.5rem !important;
    right: 0.5rem !important;
    top: calc(3.8rem + env(safe-area-inset-top, 0px)) !important;
    padding: 0.6rem !important;
    border-radius: 1rem !important;
  }

  #mapRadarPlayer {
    width: calc(100% - 1rem) !important;
    left: 0.5rem !important;
    bottom: calc(4.25rem + env(safe-area-inset-bottom, 0px)) !important;
    padding: 0.6rem !important;
    border-radius: 1rem !important;
  }

  #googleSearchContainer {
    left: 3.5rem !important;
    width: calc(100% - 4rem) !important;
    max-width: none !important;
  }

  #googleSearchSuggestions {
    max-height: 25vh !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

  #googleSearchResults {
    max-height: 45vh !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

  /* Compact Top Header on Mobile with Safe Area insets */
  header {
    height: auto !important;
    min-height: 3.6rem !important;
    padding-top: max(0.5rem, env(safe-area-inset-top, 0px)) !important;
    padding-bottom: 0.5rem !important;
    padding-left: max(0.5rem, env(safe-area-inset-left, 0px)) !important;
    padding-right: max(0.5rem, env(safe-area-inset-right, 0px)) !important;
  }

  /* Compact Bottom Navigation Dock on Mobile */
  #mobileBottomNav {
    padding-top: 0.25rem !important;
    padding-bottom: calc(0.35rem + env(safe-area-inset-bottom, 0px)) !important;
    padding-left: 0.25rem !important;
    padding-right: 0.25rem !important;
  }

  #mobileBottomNav button {
    padding: 0.15rem !important;
    gap: 0.15rem !important;
  }

  #mobileBottomNav button div {
    width: 2.15rem !important;
    height: 2.15rem !important;
  }

  #mobileBottomNav button span {
    font-size: 0.68rem !important;
    font-weight: 800 !important;
  }
}

/* Narrow & Ultra-Compact Mobile Screens (<= 400px - e.g. iPhone SE, Galaxy A, standard Android) */
@media (max-width: 400px) {
  /* Scale typography down proportionally so texts fit inside cards */
  .text-xs {
    font-size: 0.72rem !important; /* ~11.5px */
    line-height: 1.3 !important;
  }

  .text-sm {
    font-size: 0.82rem !important; /* ~13px */
    line-height: 1.35 !important;
  }

  .text-base {
    font-size: 0.95rem !important; /* ~15px */
  }

  .text-\[9px\] {
    font-size: 8.5px !important;
    padding-left: 0.35rem !important;
    padding-right: 0.35rem !important;
  }

  .text-\[10px\] {
    font-size: 9.5px !important;
  }

  .text-\[11px\] {
    font-size: 10.5px !important;
  }

  /* Metric grids: prevent breaking or squishing */
  #targetNavBottomSheet .grid-cols-3 {
    gap: 0.25rem !important;
    padding: 0.35rem !important;
  }

  #targetNavBottomSheet .grid-cols-3 strong {
    font-size: 0.78rem !important;
  }

  #targetNavBottomSheet .grid-cols-3 span {
    font-size: 0.58rem !important;
    letter-spacing: -0.2px !important;
  }

  /* Mode buttons on target sheet */
  #targetNavBottomSheet #btnRouteModeTrail,
  #targetNavBottomSheet #btnRouteModeDirect {
    padding: 0.35rem 0.25rem !important;
    font-size: 0.68rem !important;
    white-space: nowrap !important;
  }

  /* Profile modal stats: 4-col to 2x2 grid if < 380px */
  #modalProfile .grid-cols-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 0.35rem !important;
  }

  /* Header elements scale */
  #btnHeaderWeather {
    padding: 0.25rem 0.4rem !important;
    font-size: 0.7rem !important;
    gap: 0.25rem !important;
  }
  
  #btnHeaderWeather #headerWeatherTemp {
    font-size: 0.72rem !important;
  }

  #btnAlpineTools {
    padding: 0.25rem 0.4rem !important;
  }

  #btnLargeTextToggle, #btnAlpineHudToggle {
    width: 1.85rem !important;
    height: 1.85rem !important;
  }
}

/* ================= EXPLICIT LARGE TEXT MODE (Aa+ TOGGLE) ================= */
body.large-text-mode {
  font-size: 110% !important;
}

body.large-text-mode .text-\[8px\], 
body.large-text-mode .text-\[9px\], 
body.large-text-mode .text-\[10px\] {
  font-size: 13px !important;
  line-height: 1.4 !important;
  font-weight: 700 !important;
}

body.large-text-mode .text-\[11px\], 
body.large-text-mode .text-xs {
  font-size: 15px !important;
  line-height: 1.45 !important;
  font-weight: 700 !important;
}

body.large-text-mode .text-sm {
  font-size: 17px !important;
  font-weight: 700 !important;
}

body.large-text-mode .text-base {
  font-size: 19px !important;
}

body.large-text-mode .text-slate-400,
body.large-text-mode .text-slate-500 {
  color: #f1f5f9 !important; /* High contrast pure white text */
}

body.large-text-mode #compassHeadingDegrees {
  font-size: 3.25rem !important;
}

body.large-text-mode #compassHeadingCardinal {
  font-size: 1.15rem !important;
}

body.large-text-mode #radioFreqBig {
  font-size: 2.4rem !important;
}

@media (max-width: 640px) {
  body.large-text-mode #radioFreqBig {
    font-size: 1.55rem !important;
    letter-spacing: -0.5px !important;
  }
}

body.large-text-mode #altitudeValue {
  font-size: 3.25rem !important;
}

/* ================= LAPTOP & DESKTOP COCKPIT OPTIMIZATIONS ================= */
@media (min-width: 1024px) {
  #sidebar {
    width: 420px;
    box-shadow: -10px 0 35px rgba(0, 0, 0, 0.6) !important;
  }
}

@media (min-width: 1440px) {
  #sidebar {
    width: 460px;
  }
}

@media (min-width: 768px) and (max-width: 1023px) {
  #sidebar {
    width: 380px;
    max-width: 85vw;
  }
}

#btnSidebarEdgeToggle {
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: -6px 0 20px rgba(0, 0, 0, 0.6);
}

#btnSidebarEdgeToggle:hover {
  background-color: #020617;
  border-color: #38bdf8;
  transform: translateY(-50%) scale(1.05);
}

body.large-text-mode #mobileBottomNav button span {
  font-size: 0.85rem !important;
  font-weight: 900 !important;
}
