/* =========================================
   1. DESIGN TOKENS & RESET
   ========================================= */
:root {
  /* Primary Colors (Unified) */
  --primary: #0f2bab;
  --primary-dark: #0a1f7d;
  --primary-light: #3a51c6;
  --primary-color: #0066cc; /* Kept for legacy JS/CSS compatibility */
  --secondary: #ff3b30;
  --secondary-color: #0077c2;
  --dark-blue: #1a3a8a;
  --dark-blue-hover: #0d2c6e;
  
  /* Status Colors */
  --success-color: #28a745;
  --warning-color: #ffc107;
  --error-color: #dc3545;
  
  /* Neutrals */
  --dark: #333333;
  --text-color: #333333;
  --light: #f8f9fa;
  --background-color: #f8f9fa;
  --gray: #6c757d;
  --gray-light: #e9ecef;
  --white: #ffffff;
  
  /* Shadows & Radii */
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.1);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 14px;
  
  /* Transitions */
  --transition-normal: all 0.2s ease;
}

*, *::before, *::after { box-sizing: border-box; }
body, html {
  height: 100%;
  margin: 0;
  padding: 0;
  font-family: 'Inter', 'Roboto', Arial, sans-serif;
  color: var(--text-color);
  background-color: var(--background-color);
  font-size: 16px;
  line-height: 1.5;
}

button, a, [role="button"], .map-button, .modal-button, .continue-btn, .audio-button, .btn {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* =========================================
   2. MAP CANVAS & CONTROLS
   ========================================= */
#map {
  position: fixed;
  inset: 0;
  z-index: 1;
  width: 100vw;
  height: 100vh; /* Fallback */
  height: 100dvh; /* Modern dynamic viewport */
  touch-action: pan-x pan-y pinch-zoom;
  -webkit-user-select: none;
  user-select: none;
  contain: layout paint;
  will-change: transform;
}

.map-controls {
  position: absolute;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 500;
}

.control-button {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background-color: var(--white);
  border: none;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-normal);
  color: var(--primary);
}

.control-button:hover { transform: scale(1.05); box-shadow: var(--shadow-lg); }
.control-button.active { background-color: var(--primary); color: var(--white); }

.map-buttons {
  position: fixed;
  bottom: 30px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-evenly;
  align-items: center;
  gap: 0.5rem;
  padding: 0 25px;
  z-index: 1000;
}

.map-button {
  background-color: var(--white);
  border: 1px solid var(--primary-color);
  border-radius: 50%;
  width: 60px;
  height: 60px;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: var(--shadow-md);
  font-size: 2rem;
  color: var(--primary-color);
  transition: all 0.3s ease;
}

.map-button:hover {
  background-color: var(--primary-color);
  color: var(--white);
  transform: scale(1.1);
}

/* =========================================
   3. MARKERS & CLUSTERS
   ========================================= */
.user-marker { z-index: 1000; }

.user-marker-icon {
  width: 22px;
  height: 22px;
  background: radial-gradient(circle, #dc3545 0%, #a71e2a 70%);
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
  transition: background-color 0.3s ease, box-shadow 0.3s ease;
  backface-visibility: hidden;
  position: relative;
}

/* Double pulse effect */
.user-marker-icon::before,
.user-marker-icon::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  background-color: rgba(255, 100, 100, 0.6);
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(1.5);
  z-index: -1;
}

.user-marker-icon::before { animation: pulse1 4.5s infinite; }
.user-marker-icon::after { animation: pulse2 4.5s infinite; animation-delay: 2.5s; }
.user-marker-icon.moving { animation: pulse 2s infinite; }

    .marker-cluster-custom {
      background-color: rgba(0, 100, 0, 0.6);
      border-radius: 50%;
      display: flex !important;
      align-items: center !important;
      justify-content: center !important;
      width: 40px;
      height: 40px;
    }

    .marker-cluster-custom div {
      background-color: rgba(47, 99, 47, 1);
      width: 30px;
      height: 30px;
      border-radius: 50%;
      display: flex !important;
      align-items: center !important;
      justify-content: center !important;
      margin: 0 !important; /* Crucial: overrides Leaflet's default 5px offset */
    }

    .marker-cluster-custom span {
      color: #ffffff;
      font-weight: 600;
      font-size: 12px;
      display: flex !important;
      align-items: center !important;
      justify-content: center !important;
      width: 100%;
      height: 100%;
      line-height: 30px; /* Fallback centering */
      text-align: center;
      margin: 0 !important;
    }

#accuracyIndicator {
  position: absolute;
  top: 10px;
  left: 10px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.8);
  box-shadow: var(--shadow-sm);
  z-index: 1000;
  transition: background-color 0.3s ease;
  contain: layout paint;
}

#accuracyIndicator.accuracy-high { background-color: #4CAF50; }
#accuracyIndicator.accuracy-medium { background-color: #FF9800; }
#accuracyIndicator.accuracy-low { background-color: #F44336; }

/* =========================================
   4. POPUPS & PINS
   ========================================= */
/* ── Popup Modal ── */
.popup-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 150ms ease-out;
}

.popup-container {
    background: white;
    border-radius: 12px;
    padding: 24px;
    width: 280px;
    max-width: 85%;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    text-align: center;
}

.popup-container h3 {
    margin: 0 0 12px 0;
    color: #1a1a1a;
    font-size: 18px;
    font-weight: 600;
}

.popup-container p {
    margin: 0 0 20px 0;
    color: #555;
    font-size: 15px;
    line-height: 1.5;
}

.popup-close-btn {
    display: block;
    width: 100%;
    padding: 14px 0;
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.popup-close-btn[data-type="info"]    { background: #2c5282; }
.popup-close-btn[data-type="success"] { background: #276749; }
.popup-close-btn[data-type="warning"] { background: #c05621; }
.popup-close-btn[data-type="error"]   { background: #c53030; }

/* ── Leaflet Popup ── */
.custom-popup .leaflet-popup-content-wrapper {
  padding: 0;
  overflow: hidden;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
}

.custom-popup .leaflet-popup-content {
  margin: 0;
  width: 280px !important;
}

.popup-content {
  text-align: center;
  background-color: white;
  border-radius: 12px;
  overflow: hidden;
  width: 100%;
}

.location-image {
  width: 100%;
  height: 200px;
  object-fit: cover;
  display: block;
}

.location-name {
  margin: 0;
  padding: 12px 16px;
  font-size: 18px;
  font-weight: 600;
  color: var(--dark);
}

.popup-buttons {
  display: flex;
  border-top: 1px solid var(--gray-light);
}

.popup-buttons .button {
  flex: 1;
  padding: 12px 0;
  font-size: 17px;
  font-weight: 500;
  color: white;
  border: none;
  cursor: pointer;
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.3s ease;
}

.button.route-button { background-color: #1b5e20 !important; }
.button.summary-button { background-color: #0f2bab !important; }
.button.route-button:hover { background-color: #0d3c12 !important; }
.button.summary-button:hover { background-color: #0a1f80 !important; }

.pin-head {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%) rotate(-45deg);
  width: 30px;
  height: 30px;
  border-radius: 50% 50% 50% 0;
  border: 3px solid white;
  box-shadow: var(--shadow-sm);
  background-color: #191970;
  transition: all 0.3s ease;
  overflow: hidden;
}

.pin-head:hover {
  transform: translateX(-50%) rotate(-45deg) scale(1.1);
  box-shadow: 0 0 15px var(--shadow-sm);
}

.pin-head::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(45deg);
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.8);
  background-color: rgba(245, 245, 245, 0.9);
  box-shadow: 0 0 2px rgba(0, 0, 0, 0.3);
}

.directions-link {
  display: inline-block;
  margin-top: 15px;
  padding: 10px 20px;
  background-color: #006400;
  color: white;
  border-radius: 25px;
  text-decoration: none;
  transition: all 0.3s ease;
  font-weight: 600;
  font-size: 1.1rem;
}

.directions-link:hover {
  background-color: #037f51;
  transform: translateY(-2px);
  box-shadow: 0 6px 8px var(--shadow-sm);
}

/* =========================================
   5. DISTANCE BOX & INDICATORS
   ========================================= */
#distanceBox {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1003;
  background: #fff;
  padding: 12px 24px;
  border-radius: 50px;
  font-weight: 600;
  font-size: 20px;
  text-align: center;
  min-width: 200px;
  box-shadow: var(--shadow-md);
  border: 3px solid var(--dark-blue);
  color: var(--dark-blue);
  transition: all 0.3s ease;
  opacity: 0;
  visibility: hidden;
  contain: layout paint;
}

#distanceBox.show { opacity: 1; visibility: visible; }
#distanceBox.proximity-close { background: linear-gradient(135deg, #28a745, #20c997); color: #fff; border-color: transparent; animation: pulse 1.5s infinite; }
#distanceBox.proximity-medium { background: linear-gradient(135deg, #ffc107, #fd7e14); color: #fff; border-color: transparent; }
#distanceBox.proximity-far { background: #fff; color: var(--dark-blue); border-color: var(--dark-blue); }

/* =========================================
   6. MODALS & OVERLAYS
   ========================================= */
/* Generic Modal */
.modal {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: none; /* Hidden by default, toggled via JS */
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.modal-content {
  background-color: var(--white);
  padding: 24px;
  border-radius: 12px;
  max-width: 90%;
  width: 320px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.modal-content h3 {
  margin: 0 0 16px 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--dark);
}

.modal-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 20px;
}

.modal-button, .modal-buttons button {
  padding: 12px;
  border-radius: 8px;
  border: none;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-normal);
  font-size: 16px;
}

.modal-button, #mapButton, #continueButton {
  background-color: var(--primary);
  color: var(--white);
}

.modal-button:hover, #mapButton:hover, #continueButton:hover {
  background-color: var(--primary-dark);
}

.modal-button.cancel, #cancelButton {
  background-color: var(--gray-light);
  color: var(--dark);
}

.modal-button.cancel:hover, #cancelButton:hover {
  background-color: var(--gray);
  color: var(--white);
}

.close {
  color: #aaa;
  float: right;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
}
.close:hover, .close:focus { color: black; text-decoration: none; }

/* Lochunt Container */
.lochunt-container {
  position: fixed;
  inset: 0;
  background: #ffffff;
  z-index: 2000;
  display: none;
  flex-direction: column;
  overflow-y: auto;
}

.lochunt-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

/* Additional Info */
.additional-info-container {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: white;
  padding: 30px;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  border: 2px solid var(--primary-color);
  width: 90%;
  max-width: 600px;
  z-index: 2001;
  font-size: 20px;
}

.additional-info-title { font-size: 18px; font-weight: 600; margin: 0 0 12px 0; color: var(--dark); }
.additional-info-text { font-size: 14px; line-height: 1.6; color: var(--dark); margin-bottom: 20px; }

.continue-button {
  display: block;
  width: 100%;
  padding: 12px;
  background-color: var(--primary);
  color: var(--white);
  border: none;
  border-radius: 8px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-normal);
}
.continue-button:hover { background-color: var(--primary-dark); }

/* Navigation Tips */
.navigation-tips {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: var(--white);
  padding: 24px;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  max-width: 90%;
  max-height: 80%;
  width: 400px;
  overflow-y: auto;
  display: none;
  z-index: 1500;
}

.navigation-tips h3 { font-size: 20px; font-weight: 600; margin: 0 0 12px 0; color: var(--dark); }
.navigation-tips ul { margin: 0; padding: 0 0 0 20px; }
.navigation-tips li { margin-bottom: 8px; font-size: 18px; color: var(--dark); }

.close-button {
  position: absolute;
  top: 8px;
  right: 8px;
  background: none;
  border: none;
  font-size: 16px;
  color: var(--gray);
  cursor: pointer;
}

/* Congratulations */
#congratulations {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.98);
  z-index: 3000;
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 30px;
  text-align: center;
}

#congratulations h2 { font-size: 32px; color: var(--primary-color); margin-bottom: 20px; }
#congratulations button {
  padding: 12px 24px;
  font-size: 18px;
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: 25px;
  cursor: pointer;
  transition: all 0.3s ease;
}
#congratulations button:hover { background-color: var(--primary-light); }

/* Summary Modal */
#summaryModal { display: none; }
.summary-content {
  background-color: var(--white);
  padding: 24px;
  border-radius: 12px;
  max-width: 90%;
  width: 400px;
  box-shadow: var(--shadow-lg);
}
.summary-heading { font-size: 20px; font-weight: 600; margin: 0 0 16px 0; color: var(--dark); }

/* =========================================
   7. LOADING, PRELOADERS & GPS STATES
   ========================================= */
/* Loading Message */
#loadingMessage {
  position: fixed;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background-image: url('https://mnthen.com/images/splash_screen.webp');
  background-size: cover;
  background-position: center;
  z-index: 10000;
  transition: opacity 0.5s ease;
}

#loadingMessage .loading-card {
  display: grid;
  grid-template-rows: auto auto 1fr auto auto;
  background-color: white;
  padding: 35px 30px;
  border-radius: 20px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35), 0 2px 10px rgba(0, 0, 0, 0.2);
  width: 450px;
  height: 500px;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.18);
}

#loadingMessage .loading-logo { width: 180px; height: auto; margin: 0 auto 25px; border-radius: 12px; object-fit: contain; filter: drop-shadow(0 4px 8px rgba(0, 40, 85, 0.2)); }
#loadingMessage .loading-title { margin: 0 0 8px 0; font-size: 22px; font-weight: 700; color: #002855; line-height: 1.2; letter-spacing: -0.02em; }
#loadingMessage .loading-subtitle { margin: 0 0 40px 0; font-size: 18px; font-weight: 500; color: #0066cc; line-height: 1.3; opacity: 0.9; }
#loadingMessage .loading-status { min-height: 60px; display: flex; align-items: center; justify-content: center; margin-bottom: 20px; }
#loadingMessage .loading-status p { margin: 0; font-size: 18px; font-weight: 500; color: #0077dd; animation: pulse 2s infinite; }
#loadingMessage .loading-progress-track { width: 100%; height: 10px; background-color: rgba(0, 51, 102, 0.08); border-radius: 10px; overflow: hidden; margin-bottom: 12px; box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.12); }
#loadingMessage .loading-progress-bar { height: 100%; width: 0%; background: linear-gradient(90deg, #0066cc, #0099ff, #00aaff, #0099ff, #0066cc); background-size: 200% auto; border-radius: 10px; transition: width 0.3s cubic-bezier(0.4, 0.0, 0.2, 1); box-shadow: 0 0 10px rgba(0, 120, 255, 0.6); animation: gradientShift 3s ease infinite; }
#loadingMessage .loading-note { min-height: 50px; display: flex; align-items: center; justify-content: center; }
#loadingMessage .loading-note p { margin: 0; font-size: 16px; color: #555; font-weight: 500; opacity: 0.8; }

/* Preloader */
#preloader {
  position: fixed;
  inset: 0;
  background-image: url('https://www.mnthen.com/images/header/mnthen_splash_page.webp'); 
  background-size: cover;
  background-position: center;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  color: white;
  font-family: 'Montserrat', sans-serif;
}

#preloader::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: -1;
}

.preloader-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 80%;
  text-align: center;
  padding: 40px;
  border-radius: 12px;
  background-color: rgba(20, 20, 20, 0.4);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

#preloader .logo { width: 140px; height: auto; margin-bottom: 25px; }
#preloader h1 { font-size: 48px; font-weight: 800; margin-bottom: 15px; color: #ffffff; }
#preloader h2 { font-size: 20px; font-weight: 400; margin-bottom: 40px; max-width: 700px; line-height: 1.5; color: rgba(255, 255, 255, 0.9); }
#preloader p { margin-top: 20px; font-size: 16px; color: rgba(255, 255, 255, 0.85); font-style: italic; font-weight: 600; }
#preloader .progress-container { width: 90%; max-width: 320px; height: 6px; background-color: rgba(255, 255, 255, 0.1); border-radius: 6px; margin-top: 30px; overflow: hidden; }
#preloader .progress-bar { height: 100%; background: #ffffff; width: 0; transition: width 0.4s ease; border-radius: 6px; }
#preloader .status-message { margin-top: 15px; font-size: 13px; color: rgba(255, 255, 255, 0.6); }

/* Stabilizing Modal */
.stabilizing-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: rgba(255, 255, 255, 0.95);
  padding: 24px;
  border-radius: 12px;
  z-index: 2000;
  text-align: center;
  box-shadow: var(--shadow-lg);
  max-width: 80%;
  width: 320px;
  opacity: 0;
  transition: opacity 0.3s ease-out;
  pointer-events: none;
  will-change: opacity;
}

.stabilizing-modal.visible { opacity: 1; pointer-events: auto; }
.stabilizing-modal h3 { margin: 12px 0; font-size: 18px; font-weight: 600; color: var(--dark); }
.stabilizing-modal p { margin-bottom: 0; font-size: 14px; color: var(--gray); line-height: 1.5; }

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(15, 43, 171, 0.2);
  border-top: 4px solid var(--primary);
  border-radius: 50%;
  margin: 0 auto 15px;
  animation: spin 1s linear infinite;
}

/* GPS Searching State */
.gps-loading-overlay, #gps-searching-indicator { display: none; }
body.gps-searching .gps-loading-overlay, body.gps-searching #gps-searching-indicator { display: block; }
body.gps-searching [data-disabled-during-gps-search] { pointer-events: none; opacity: 0.5; }

/* Geo Retry Modal */
.geo-retry-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100000;
}

.geo-retry-card {
  background: white;
  border-radius: var(--radius-md);
  padding: 28px 24px;
  width: 90%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
  text-align: center;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.geo-retry-title { font-size: 26px; margin: 0 0 6px 0; }
.geo-retry-text { margin: 16px 0; color: #4a5568; line-height: 1.5; font-size: 15px; }
.geo-retry-btn { background: #2c5282; color: white; border: none; padding: 14px 28px; border-radius: 8px; font-size: 17px; font-weight: 600; margin-top: 12px; cursor: pointer; width: 100%; }
.geo-retry-cancel { margin-top: 20px; background: none; border: none; color: #718096; font-size: 14px; cursor: pointer; }

/* =========================================
   8. PWA BANNERS
   ========================================= */
#pwaInstallBanner {
  position: fixed;
  inset: auto 20px 20px 20px;
  background: #fff;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(0, 0, 0, 0.05);
  padding: 20px;
  z-index: 2000;
  display: none;
  animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  border: 1px solid #e2e8f0;
  contain: layout paint;
}

#pwaInstallBanner.show { display: block; }
.banner-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 15px; }
.banner-title { display: flex; align-items: center; gap: 12px; }
.app-icon { width: 40px; height: 40px; border-radius: 10px; background-color: #2c5282; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 20px; flex-shrink: 0; }
#pwaInstallBanner h3 { margin: 0; color: #2d3748; font-size: 18px; font-weight: 600; }
.close-btn { background: #f7fafc; border: none; width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; color: #718096; font-size: 20px; transition: all 0.2s ease; flex-shrink: 0; }
.close-btn:hover { background: #edf2f7; color: #4a5568; }
.banner-content { margin-bottom: 20px; }
.banner-content p { margin: 0; color: #4a5568; line-height: 1.5; font-size: 15px; }
.pwa-ios-instructions { font-size: 14px !important; margin-top: 10px !important; }
.banner-actions { display: flex; justify-content: flex-end; gap: 12px; }
.cancel-btn { background: transparent; border: 1px solid #e2e8f0; border-radius: var(--radius-sm); padding: 10px 18px; font-size: 14px; font-weight: 500; cursor: pointer; color: #718096; transition: all 0.2s ease; }
.cancel-btn:hover { background: #f7fafc; border-color: #cbd5e0; }
.install-btn { background: #2c5282; color: #fff; border: none; border-radius: var(--radius-sm); padding: 10px 22px; font-size: 14px; font-weight: 600; cursor: pointer; transition: all 0.2s ease; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); position: relative; overflow: hidden; backface-visibility: hidden; }
.install-btn::before { content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent); transition: left 0.7s ease; }
.install-btn:hover { background: #1a3a8a; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15); transform: translateY(-1px); }
.install-btn:hover::before { left: 100%; }
.install-btn:active { transform: translateY(0); box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); }

.pwa-post-install-notice {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(100%);
  background: #1a1a1a;
  color: #f8f9fa;
  border-radius: var(--radius-lg);
  padding: 16px;
  width: 90%;
  max-width: 360px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  z-index: 10001;
  opacity: 0;
  visibility: hidden;
  transition: transform 0.3s ease-out, opacity 0.3s ease-out, visibility 0.3s;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.4;
  contain: layout paint;
}

.pwa-post-install-notice.show { transform: translateX(-50%) translateY(0); opacity: 1; visibility: visible; -webkit-overflow-scrolling: touch; }
.pwa-notice-content p:first-of-type { margin-top: 0; font-weight: 600; color: #66d9ef; }
.pwa-notice-content ol { margin: 10px 0 14px 18px; padding-left: 4px; }
.pwa-notice-content li { margin-bottom: 6px; }
.pwa-notice-button { background: #007bff; color: #fff; border: none; border-radius: var(--radius-sm); padding: 8px 16px; font-size: 14px; font-weight: 600; cursor: pointer; width: 100%; transition: background 0.2s; }
.pwa-notice-button:hover, .pwa-notice-button:focus-visible { background: #0056b3; outline: 2px solid #66d9ef; outline-offset: 2px; }

/* =========================================
   9. AUDIO PLAYER
   ========================================= */
.audio-player { width: 100%; max-width: 400px; margin: 20px auto; }
.audio-progress { width: 100%; margin-bottom: 10px; }
.progress { height: 8px; background-color: #d1d1d1; cursor: pointer; border-radius: 4px; }
.progress-bar { background-color: var(--primary-color); border-radius: 4px; }
.audio-time { display: flex; justify-content: space-between; font-size: 0.9rem; color: #666; margin-bottom: 10px; }
.audio-controls { display: flex; justify-content: space-between; align-items: center; font-size: 1.5rem; }
.audio-button {
  background-color: white;
  color: var(--primary-color);
  border: 2px solid var(--primary-color);
  border-radius: 50%;
  width: 55px;
  height: 55px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  z-index: 1111;
}
.audio-button:hover { background-color: var(--secondary-color); color: white; }

/* =========================================
   10. KEYFRAMES
   ========================================= */
@keyframes pulse { 0%, 100% { opacity: 0.8; } 50% { opacity: 1; } }
@keyframes pulse1 { 0% { transform: translate(-50%, -50%) scale(1.5); opacity: 0.8; } 100% { transform: translate(-50%, -50%) scale(3.5); opacity: 0; } }
@keyframes pulse2 { 0% { transform: translate(-50%, -50%) scale(1.5); opacity: 0.8; } 100% { transform: translate(-50%, -50%) scale(3.5); opacity: 0; } }
@keyframes slideUp { from { transform: translateY(100px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes gradientShift { 0%, 100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

.fade-in { animation: fadeIn 0.3s ease forwards; }
.fade-out { animation: fadeOut 0.3s ease forwards; }

/* =========================================
   11. UTILITIES & ACCESSIBILITY
   ========================================= */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.leaflet-marker-icon { transition: opacity 0.5s ease !important; }
.map-tiles { will-change: transform; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .user-marker-icon, .map-button, #distanceBox, #pwaInstallBanner, .fade-in, .fade-out, #loadingMessage .loading-status p, #loadingMessage .loading-progress-bar {
    transition: none !important;
    animation: none !important;
  }
}

/* =========================================
   12. RESPONSIVE
   ========================================= */
@media (min-width: 768px) {
  .modal-content { width: 400px; }
  .modal-buttons { flex-direction: row; justify-content: center; }
  .lochunt-content { max-width: 600px; }
  .lochunt-image { height: 300px; }
}

@media (max-width: 768px) {
  body, html { font-size: 18px; }
  #distanceBox { font-size: 1.3rem; padding: 6px 10px; top: 10px; right: 10px; }
  .map-buttons { bottom: 20px; }
  .map-button { width: 50px; height: 50px; font-size: 1.7rem; }
  .navigation-tips { max-width: 95%; padding: 20px; }
  #congratulations h2 { font-size: 24px; }
  #congratulations button { font-size: 16px; padding: 10px 20px; }
  .audio-player { max-width: 100%; }
  .lochunt-container img { height: 30vh; }
  .additional-info-container { width: 95%; padding: 20px; font-size: 16px; }
  
  #preloader h1 { font-size: 36px; }
  #preloader h2 { font-size: 18px; margin-bottom: 30px; }
  .preloader-content { padding: 30px; max-width: 90%; }
}

@media (max-width: 640px) {
  #pwaInstallBanner { inset: auto 15px 15px 15px; padding: 18px; }
  #pwaInstallBanner h3 { font-size: 16px; }
  .banner-content p { font-size: 14px; }
  .banner-actions { flex-direction: column-reverse; gap: 10px; }
  .cancel-btn, .install-btn { width: 100%; text-align: center; padding: 12px; }
}

@media (max-width: 500px) {
  #loadingMessage .loading-card { width: 85%; height: auto; min-height: 480px; padding: 25px 20px; }
  #preloader h1 { font-size: 30px; }
  #preloader h2 { font-size: 16px; }
  .preloader-content { padding: 20px; max-width: 95%; }
}

@media (max-width: 360px) {
  #accuracyIndicator { display: none; }
}

@supports (-webkit-touch-callout: none) {
  .map-button:active { background-color: white !important; color: var(--primary-color) !important; }
  #map, .lochunt-container { height: -webkit-fill-available; }
}

@supports not (height: 100dvh) {
  #map { height: 100vh; }
}
