body.map-fullscreen-active { overflow: hidden; }
body.map-fullscreen-active .app-navigation { display: none !important; }

body.map-fullscreen-active #screen-map.app-screen.active-screen {
  display: flex !important;
  position: fixed !important;
  inset: 0 !important;
  left: 0 !important;
  transform: none !important;
  width: 100vw !important;
  height: 100dvh !important;
  z-index: 2500 !important;
  margin: 0 !important;
  padding: 0 !important;
  max-width: none !important;
  max-height: none !important;
}

#screen-map.active-screen { animation: mapScreenFadeIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
#screen-map.closing-screen { animation: mapScreenSlideOut 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
@keyframes mapScreenFadeIn {
  0% { opacity: 0; transform: translateX(-50%) translateY(6px); }
  100% { opacity: 1; transform: translateX(-50%) translateY(0); }
}
@keyframes mapScreenSlideOut {
  0% { opacity: 1; transform: translateX(-50%) translateX(0) scale(1); }
  100% { opacity: 0; transform: translateX(-50%) translateX(30px) scale(0.98); }
}

.map-screen-wrapper {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  z-index: 2000;
  overflow: hidden;
  background: var(--bg-color);
  touch-action: none;
}

.map-brand-header {
  position: absolute; top: max(16px, env(safe-area-inset-top)); left: 16px; right: 16px; z-index: 2600;
  display: flex; align-items: center; gap: 10px; pointer-events: none;
  color: var(--text-primary); font-family: 'Poppins', sans-serif; font-size: 16px; font-weight: 700;
}
.map-brand-header span:first-of-type { letter-spacing: 0.5px; }
.map-header-status { margin-left: auto; color: var(--text-secondary); font-size: 11px; font-weight: 600; }

#mapbox-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
#mapbox-canvas .maplibregl-ctrl-logo, #mapbox-canvas .maplibregl-ctrl-attrib { opacity: 0.55; }

.map-rain-layer { position: absolute; inset: 0; z-index: 2100; overflow: hidden; opacity: 0; pointer-events: none; transition: opacity 0.5s ease; }
.map-rain-layer.active { opacity: 0.6; }
.map-rain-drop { position: absolute; top: -12%; width: 1px; height: 22px; background: rgba(120, 170, 255, 0.55); transform: rotate(16deg); animation: mapRainFall linear infinite; }
@keyframes mapRainFall { from { translate: 0 -12vh; } to { translate: -12vw 112vh; } }

#map-back-btn {
  position: relative; z-index: 2600; pointer-events: auto;
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--border-color); background: var(--card-bg);
  color: var(--text-primary); font-size: 18px; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 22px rgba(0,0,0,0.1); cursor: pointer;
  flex-shrink: 0; transition: transform 0.15s ease;
}
#map-back-btn:active { transform: scale(0.92); }

.map-search-pill-container {
  position: absolute; top: max(16px, env(safe-area-inset-top)); left: 68px; right: 16px; z-index: 2550;
}
.map-search-pill {
  display: flex; align-items: center; gap: 8px; background: var(--card-bg);
  border-radius: 9999px; padding: 0 16px; height: 44px; box-shadow: 0 8px 22px rgba(0,0,0,0.1);
  border: 1px solid var(--border-color);
}
.map-search-pill i { color: var(--text-secondary); font-size: 15px; flex-shrink: 0; }
.map-search-pill input {
  flex: 1; background: transparent; border: none; outline: none; color: var(--text-primary);
  font-family: 'Poppins', sans-serif; font-size: 13px; font-weight: 500;
}
.map-search-pill input::placeholder { color: var(--text-secondary); }

.map-place-poi-marker {
  width: 32px; height: 32px; border-radius: 50%; background: var(--card-bg); border: 2px solid var(--user-accent, var(--text-primary));
  display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 12px rgba(0,0,0,0.2); cursor: pointer;
}
.map-place-poi-marker i { font-size: 15px; color: var(--user-accent, var(--text-primary)); }
.map-place-poi-marker.visited { background: var(--user-accent, var(--text-primary)); }
.map-place-poi-marker.visited i { color: #ffffff; }

.map-note-dot-marker {
  width: 16px; height: 16px; border-radius: 50%; background: #ff9500; border: 2px solid var(--card-bg);
  box-shadow: 0 2px 8px rgba(0,0,0,0.25); cursor: pointer;
}

.map-place-rating {
  display: flex; align-items: center; gap: 4px; margin-top: 4px;
}
.map-place-rating .star-icon { font-size: 13px; color: var(--border-color); }
.map-place-rating .star-icon.filled { color: #ff9500; }
.map-place-rating .star-icon.interactive { cursor: pointer; }
.map-place-rating .rating-count { font-size: 10.5px; color: var(--text-secondary); margin-left: 4px; }

.map-status-pill {
  position: absolute; top: calc(max(16px, env(safe-area-inset-top)) + 56px); left: 50%; z-index: 2550; transform: translateX(-50%);
  display: flex; align-items: center; gap: 7px; color: var(--text-primary);
  font: 600 11px 'Poppins', sans-serif; pointer-events: none;
  background: var(--card-bg);
  padding: 6px 14px; border-radius: 9999px; border: 1px solid var(--border-color);
  box-shadow: 0 6px 16px rgba(0,0,0,0.08);
}
.map-status-dot { width: 7px; height: 7px; border-radius: 50%; background: #34c759; flex-shrink: 0; }
.map-status-dot.tracking { animation: mapStatusPulse 1.6s ease-in-out infinite; }
@keyframes mapStatusPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(52,199,89,0.55); }
  70% { box-shadow: 0 0 0 6px rgba(52,199,89,0); }
}
.map-status-pill.night .map-status-dot { background: var(--text-secondary); }
.map-status-pill.night .map-status-dot.tracking { animation: none; }
.map-night-layer, .map-color-grade { display: none; }

.map-search-results {
  margin-top: 8px; background: var(--card-bg);
  border-radius: 20px; overflow: hidden; max-height: 0; opacity: 0; pointer-events: none;
  transition: max-height 0.25s ease, opacity 0.2s ease; border: 1px solid var(--border-color);
  box-shadow: 0 10px 26px rgba(0,0,0,0.1);
}
.map-search-results.visible { max-height: 260px; overflow-y: auto; opacity: 1; pointer-events: auto; }
.map-search-result-row {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; cursor: pointer;
  border-bottom: 1px solid var(--border-color);
}
.map-search-result-row:last-child { border-bottom: none; }
.map-search-result-row:active { background: var(--subtle-bg); }
.map-search-result-row i { color: var(--text-secondary); font-size: 15px; flex-shrink: 0; }
.map-search-result-name { color: var(--text-primary); font-size: 12.5px; font-weight: 600; font-family: 'Poppins', sans-serif; }
.map-search-result-tag { color: var(--text-secondary); font-size: 10.5px; margin-top: 1px; }

.map-category-bar {
  display: flex; align-items: center; gap: 8px; overflow-x: auto; margin-top: 14px; padding: 2px 0 4px;
  padding-right: 56px; scrollbar-width: none;
  -webkit-mask-image: linear-gradient(to right, #000 0%, #000 82%, transparent 100%);
  mask-image: linear-gradient(to right, #000 0%, #000 82%, transparent 100%);
}
.map-category-bar::-webkit-scrollbar { display: none; }
.map-category-chip {
  flex-shrink: 0; display: flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 15px;
  border-radius: 9999px; border: 1px solid var(--border-color); background: var(--card-bg);
  color: var(--text-primary); font-family: 'Poppins', sans-serif; font-size: 12px; font-weight: 600;
  line-height: 1; cursor: pointer; box-shadow: 0 6px 16px rgba(0,0,0,0.08); transition: transform 0.15s ease, background 0.2s ease, color 0.2s ease;
}
.map-category-chip span { display: inline-flex; align-items: center; }
.map-category-chip:active { transform: scale(0.95); }
.map-category-chip i { font-size: 14px; color: var(--cat-color, var(--user-accent)); display: inline-flex; }
.map-category-chip.active { background: var(--cat-color, var(--user-accent)); color: #ffffff; border-color: transparent; }
.map-category-chip.active i { color: #ffffff; }

.map-category-info {
  margin-top: 8px; padding: 8px 12px; border-radius: 14px; background: var(--card-bg);
  border: 1px solid var(--border-color); font-size: 11.5px; line-height: 1.4; color: var(--text-secondary);
  max-height: 0; opacity: 0; overflow: hidden; pointer-events: none;
  transition: max-height 0.25s ease, opacity 0.2s ease, margin-top 0.25s ease;
}
.map-category-info.visible { max-height: 80px; opacity: 1; margin-top: 8px; }
.map-category-info b { color: var(--text-primary); }
.map-category-info .ddg-credit { display: block; margin-top: 3px; font-size: 9.5px; opacity: 0.7; }

.map-poi-marker {
  width: 30px; height: 30px; border-radius: 50%; background: var(--poi-color, var(--user-accent));
  display: flex; align-items: center; justify-content: center; color: #ffffff; font-size: 14px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.3); border: 2px solid #ffffff; cursor: pointer;
}

.map-note-dot {
  width: 14px; height: 14px; border-radius: 50%; background: var(--user-accent, #ff9500);
  border: 2px solid #ffffff; box-shadow: 0 2px 6px rgba(0,0,0,0.3); cursor: pointer;
}

.map-place-rating { display: flex; gap: 3px; margin-top: 4px; }
.map-place-rating i { font-size: 13px; color: #ffb400; cursor: pointer; transition: transform 0.1s ease; }
.map-place-rating i:active { transform: scale(1.3); }

.map-tool-cluster {
  position: absolute; top: calc(max(16px, env(safe-area-inset-top)) + 56px); right: 16px; z-index: 2550;
  display: flex; flex-direction: column; gap: 10px;
  transition: transform 220ms cubic-bezier(0.16, 1, 0.3, 1), opacity 220ms ease;
  will-change: transform, opacity;
}
.map-tool-cluster.tool-cluster-docked {
  transform: translateX(calc(100% - 18px)) scale(0.94);
  opacity: 0.82;
}
.map-tool-cluster.tool-cluster-docked:hover,
.map-tool-cluster.tool-cluster-docked:focus-within {
  transform: translateX(0) scale(0.94);
  opacity: 1;
}
.map-tool-btn {
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--border-color);
  background: var(--card-bg);
  color: var(--text-primary); font-size: 17px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; box-shadow: 0 6px 16px rgba(0,0,0,0.08); transition: transform 0.15s ease, background 0.2s ease, color 0.2s ease;
  position: relative;
}
.map-tool-btn:active { transform: scale(0.92); }
.map-tool-btn.active { background: var(--user-accent, var(--text-primary)); color: #ffffff; border-color: transparent; }
#map-route-log-btn.active { animation: mapStatusPulse 1.6s ease-in-out infinite; }
.map-tool-btn.disabled-tool { opacity: 0.35; pointer-events: none; }
.map-tool-btn.advanced-map-tool { display: none; }
.map-tool-btn.advanced-map-tool.available { display: flex; }

.map-tool-btn#map-locate-btn.tracking-live::after {
  content: "";
  position: absolute; top: 3px; right: 3px; width: 8px; height: 8px; border-radius: 50%;
  background: #34c759; border: 2px solid var(--card-bg);
  animation: mapStatusPulse 1.6s ease-in-out infinite;
}

.map-pin-marker { font-size: 26px; color: var(--user-accent, #ff3b30); filter: drop-shadow(0 3px 6px rgba(0,0,0,0.3)); cursor: pointer; }

.map-user-dot-wrapper {
  width: 46px; height: 46px; display: flex; align-items: center; justify-content: center; position: relative;
}
.map-user-accuracy-ring {
  position: absolute; border-radius: 50%; background: rgba(10,132,255,0.15);
  border: 1px solid rgba(10,132,255,0.3); transition: width 0.4s ease, height 0.4s ease;
}
.map-user-dot {
  width: 18px; height: 18px; border-radius: 50%; background: var(--user-accent, #0a84ff); border: 3px solid var(--card-bg);
  box-shadow: 0 0 0 4px rgba(10,132,255,0.3); position: relative; z-index: 1;
}
.map-user-dot.stale { background: var(--text-secondary); box-shadow: 0 0 0 4px rgba(142,142,147,0.25); }
.map-user-heading {
  position: absolute; width: 0; height: 0; z-index: 2;
  border-left: 6px solid transparent; border-right: 6px solid transparent;
  border-bottom: 14px solid var(--user-accent, #0a84ff);
  opacity: 0.9;
  transform-origin: 50% 100%;
  top: -8px; left: 50%; margin-left: -6px;
  display: none;
}
.map-user-heading.visible { display: block; }

.map-weather-pill {
  position: absolute; bottom: max(28px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%) translateY(20px);
  z-index: 2550; display: flex; align-items: center; gap: 10px;
  background: var(--card-bg);
  border-radius: 9999px; padding: 8px 18px; border: 1px solid var(--border-color);
  opacity: 0; pointer-events: none; transition: opacity 0.25s ease, transform 0.25s ease;
  box-shadow: 0 8px 22px rgba(0,0,0,0.1); max-width: 90vw;
}
.map-weather-pill.visible { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
.map-weather-pill i { font-size: 15px; color: var(--user-accent, var(--text-primary)); flex-shrink: 0; }
.map-weather-pill span { color: var(--text-primary); font-size: 12px; font-weight: 600; font-family: 'Poppins', sans-serif; white-space: nowrap; }
.map-weather-pill .pill-sep { width: 3px; height: 3px; border-radius: 50%; background: var(--text-secondary); opacity: 0.5; flex-shrink: 0; }

.map-place-panel {
  position: absolute; left: 12px; right: 12px; bottom: 90px; z-index: 2560;
  background: var(--card-bg);
  border-radius: 26px; padding: 16px; border: 1px solid var(--border-color);
  box-shadow: 0 14px 34px rgba(0,0,0,0.14);
  transform: translateY(30px); opacity: 0; pointer-events: none; transition: all 0.3s cubic-bezier(0.16,1,0.3,1);
}
.map-place-panel.visible { transform: translateY(0); opacity: 1; pointer-events: auto; }
.map-place-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.map-place-name { color: var(--text-primary); font-weight: 700; font-size: 15px; font-family: 'Poppins', sans-serif; }
.map-place-coords { color: var(--text-secondary); font-size: 11px; margin-top: 2px; }
.map-place-info { color: var(--text-secondary); font-size: 11px; margin-top: 3px; }
.map-place-header-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.map-place-toggle, .map-place-close {
  width: 28px; height: 28px; border-radius: 50%; background: var(--subtle-bg); border: none;
  color: var(--text-primary); flex-shrink: 0; cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: transform 0.2s ease;
}
.map-place-toggle[aria-expanded="true"] { transform: rotate(180deg); }

.map-place-drawer {
  max-height: 0; overflow: hidden; opacity: 0; transition: max-height 0.3s ease, opacity 0.25s ease, margin 0.3s ease;
}
.map-place-drawer.open { max-height: 220px; opacity: 1; margin-top: 10px; }
.map-place-stat {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 7px 0; border-bottom: 1px solid var(--border-color);
  font-family: 'Poppins', sans-serif;
}
.map-place-stat:last-child { border-bottom: none; }
.map-place-stat span { color: var(--text-secondary); font-size: 11px; font-weight: 500; display: flex; align-items: center; gap: 6px; }
.map-place-stat span i { font-size: 13px; color: var(--user-accent, var(--text-primary)); }
.map-place-stat strong { color: var(--text-primary); font-size: 12px; font-weight: 600; text-align: right; }

.map-place-note {
  width: 100%; margin-top: 10px; background: var(--subtle-bg); border: 1px solid var(--border-color);
  border-radius: 16px; padding: 10px 12px; color: var(--text-primary); font-family: 'Poppins', sans-serif; font-size: 12.5px;
  min-height: 54px; resize: none; outline: none;
}
.map-place-note::placeholder { color: var(--text-secondary); }
.map-place-actions { display: flex; gap: 8px; margin-top: 10px; }
.map-place-btn {
  flex: 1; height: 40px; border-radius: 9999px; border: none; cursor: pointer;
  font-family: 'Poppins', sans-serif; font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; gap: 6px;
  transition: transform 0.15s ease;
}
.map-place-btn:active { transform: scale(0.96); }
.map-place-btn i { font-size: 14px; }
.map-place-btn.primary { background: var(--user-accent, var(--text-primary)); color: #ffffff; }
.map-place-btn.secondary { background: var(--subtle-bg); color: var(--text-primary); }
.map-place-btn.route { background: #34c759; color: #ffffff; }

.map-disabled-panel {
  position: fixed; inset: 0; z-index: 2100; display: none; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; background: var(--bg-color); color: var(--text-primary); text-align: center; padding: 40px;
}
.map-disabled-panel i { font-size: 40px; color: var(--text-secondary); }
.map-disabled-panel h3 { font-family: 'Poppins', sans-serif; font-size: 16px; margin: 0; }
.map-disabled-panel p { font-size: 12.5px; color: var(--text-secondary); max-width: 280px; margin: 0; }

.zydox-toast {
  position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%) translateY(20px); z-index: 5000;
  background: var(--card-bg); color: var(--text-primary); padding: 10px 18px; border-radius: 9999px; font-size: 12.5px;
  font-family: 'Poppins', sans-serif; font-weight: 600; opacity: 0; pointer-events: none; transition: all 0.3s ease;
  max-width: 85vw; text-align: center; box-shadow: 0 10px 26px rgba(0,0,0,0.14);
  border: 1px solid var(--border-color);
  display: flex; align-items: center; gap: 8px;
}
.zydox-toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
.zydox-toast i { font-size: 14px; flex-shrink: 0; color: var(--user-accent, var(--text-primary)); }
.zydox-toast-action {
  border: none; background: transparent; color: var(--user-accent, #0a84ff); font-weight: 700;
  font-size: 12.5px; font-family: 'Poppins', sans-serif; cursor: pointer; padding: 2px 0 2px 10px;
  margin-left: 2px; border-left: 1px solid var(--border-color); flex-shrink: 0;
}
.zydox-toast-action:active { opacity: 0.6; }

.zydox-confetti-layer { position: fixed; inset: 0; z-index: 6000; pointer-events: none; overflow: hidden; }
.zydox-confetti-piece {
  position: absolute; width: 7px; height: 10px; border-radius: 2px; opacity: 0;
  transform: translate(-50%, -50%) rotate(0deg);
  animation: zydoxConfettiBurst 900ms cubic-bezier(0.2, 0.8, 0.3, 1) forwards;
}
@keyframes zydoxConfettiBurst {
  0% { opacity: 1; transform: translate(-50%, -50%) rotate(0deg); }
  100% { opacity: 0; transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) rotate(var(--rot)); }
}

@media (min-width: 700px) {
  .map-brand-header { top: 22px; left: 28px; right: 28px; font-size: 18px; }
  .map-search-pill-container { top: 0; left: 0; right: 0; }
  .map-tool-cluster { top: 92px; right: 28px; }
  .map-place-panel { left: auto; right: 28px; bottom: 28px; width: min(430px, calc(100vw - 56px)); }
  .map-weather-pill { bottom: 28px; left: 28px; transform: translateY(20px); }
  .map-weather-pill.visible { transform: translateY(0); }
  .map-status-pill { top: 22px; right: 28px; left: auto; transform: none; }
}

html.zydox-low-power .map-place-panel,
html.zydox-low-power .map-weather-pill,
html.zydox-low-power .zydox-toast {
  transition-duration: 0.15s;
}
html.zydox-low-power .map-tool-btn,
html.zydox-low-power .map-place-btn,
html.zydox-low-power .map-place-toggle,
html.zydox-low-power #map-back-btn {
  transition: none;
}

@media (prefers-reduced-motion: reduce) {
  .map-tool-btn, .map-weather-pill, .map-place-panel, .zydox-toast, .map-rain-layer, .map-status-dot { transition: none; animation: none; }
  .map-rain-drop { animation: none; display: none; }
}
