.map-page .site-header { position: relative; min-height: 0; }
.map-page .header-inner { display: flex; grid-template-rows: none; width: min(1440px, calc(100% - 40px)); min-height: 76px; }
.map-dex-nav { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.map-dex-nav a { padding: 7px 12px; border-radius: 20px; color: var(--header-text); font-size: .85rem; text-decoration: none; }
.map-dex-nav a[aria-current], .map-dex-nav a:hover { background: #ffffff20; }
.map-main { width: min(1440px, calc(100% - 40px)); margin: 30px auto 24px; }
.map-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.map-heading h1 { margin: 0; font-size: clamp(1.7rem, 3vw, 2.4rem); }
.map-back { min-height: 46px; padding: 10px 20px; font-size: .9rem; font-weight: 800; white-space: nowrap; }
.map-species { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; padding: 12px 16px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface-raised); }
.map-species[hidden], .map-species [hidden] { display: none; }
.map-species-image { width: 88px; height: 88px; flex: 0 0 auto; object-fit: contain; border-radius: 12px; background: var(--accent-soft); }
.map-species-copy { flex: 1; min-width: 0; }
.map-species h2 { margin: 0; font-size: 1.2rem; overflow-wrap: anywhere; }
.map-species p { margin: 4px 0 0; font-size: .83rem; line-height: 1.5; overflow-wrap: anywhere; }
#mapSpeciesStatus { color: var(--text-secondary); }
.map-species-fill { fill: #ffd13b; fill-opacity: .5; stroke: #fff2ac; stroke-width: 4; stroke-linejoin: round; vector-effect: non-scaling-stroke; filter: drop-shadow(0 0 1.5px #5b4112); }
.map-explorer { --map-height: clamp(430px, 72vh, 850px); display: grid; gap: 18px; }
.map-explorer.has-residents { grid-template-columns: minmax(0, 1fr) 390px; }
.map-frame { overflow: hidden; border: 1px solid var(--border-strong); border-radius: 20px; background: var(--surface-raised); box-shadow: var(--shadow-soft); }
.map-viewport { position: relative; height: var(--map-height); overflow: hidden; background: #6e9fab; }
#zoneMap { width: 100%; height: 100%; max-width: none; touch-action: none; cursor: grab; user-select: none; }
#zoneMap.is-dragging { cursor: grabbing; }
#zoneMap:focus-visible { outline: 3px solid var(--accent); outline-offset: -4px; }
.map-region { fill: transparent; stroke: #fff1ad90; stroke-width: 1; vector-effect: non-scaling-stroke; stroke-linejoin: round; cursor: pointer; }
.map-region[hidden], .map-label[hidden], #mapHighlight[hidden] { display: none; }
.map-highlight-halo { fill: none; stroke: #675128; stroke-width: 7; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.map-highlight-fill { fill: #ffd13b; fill-opacity: .5; stroke: #fff2ac; stroke-width: 4; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.map-species-fill, .map-highlight-fill { animation: map-zone-pulse 1.2s ease-in-out infinite; }
@keyframes map-zone-pulse {
  0%, 100% { fill-opacity: .12; stroke: #f5c746; stroke-width: 2.5; }
  45%, 60% { fill-opacity: .7; stroke: #fff4bd; stroke-width: 4; }
}
@media (prefers-reduced-motion: reduce) {
  .map-species-fill, .map-highlight-fill { animation: none; }
}
.map-label { fill: #fffce9; stroke: #3f4e38bb; stroke-width: calc(var(--map-unit, 5) * 3px); paint-order: stroke fill; text-anchor: middle; font-family: var(--font-body); font-weight: 800; font-size: calc(var(--map-unit, 5) * 11px); pointer-events: none; }
.map-label.is-active { fill: #fff3b2; }
.map-label.is-habitat { fill: #fff3b2; }
.map-zoom { position: absolute; top: 14px; right: 14px; display: grid; gap: 1px; border: 1px solid var(--border-strong); border-radius: 12px; overflow: hidden; box-shadow: 0 2px 10px #17383426; }
.map-zoom button { width: 42px; height: 42px; border: 0; background: var(--surface-raised); color: var(--text); font-size: 1.35rem; font-weight: 800; }
.map-zoom button:hover { background: var(--accent-soft); }
.map-zoom button:focus-visible { outline-offset: -4px; }
.map-zoom button:disabled { opacity: .55; cursor: default; }
.map-scale { position: absolute; bottom: 12px; right: 14px; border-radius: 7px; background: #244d60c9; color: #fff; padding: 3px 8px; font-size: .73rem; font-variant-numeric: tabular-nums; pointer-events: none; }
.map-loading { position: absolute; top: 45%; left: 50%; max-width: 90%; transform: translate(-50%,-50%); margin: 0; padding: 14px 20px; border-radius: 12px; background: var(--surface-raised); color: var(--text); text-align: center; box-shadow: var(--shadow-soft); }
.map-selection { min-height: 73px; display: flex; align-items: center; justify-content: space-between; gap: 8px 20px; padding: 14px 20px; }
.map-selection > div { display: grid; gap: 2px; }
.map-selection strong { font-size: 1.04rem; color: var(--accent-strong); }
.map-selection span { font-size: .8rem; color: var(--text-secondary); }
.map-residents { min-width: 0; height: calc(var(--map-height) + 75px); display: flex; flex-direction: column; border: 1px solid var(--border-strong); border-radius: 20px; background: var(--surface-raised); overflow: hidden; }
.map-residents[hidden], .map-residents [hidden], .map-residents-link[hidden] { display: none; }
.map-residents-heading { padding: 16px 18px; border-bottom: 1px solid var(--border); }
.map-residents-heading h2 { margin: 0; font-size: 1.35rem; line-height: 1.25; }
.map-residents-heading p { margin: 6px 0 0; color: var(--text-secondary); font-size: .8rem; line-height: 1.5; }
#mapResidentsRetry { margin-top: 12px; }
.map-residents-content { min-height: 0; overflow-y: auto; scrollbar-width: thin; padding: 0 10px 10px; }
.map-residents-group h3 { margin: 16px 8px 6px; color: var(--accent-strong); font-size: .88rem; }
.map-residents-list { list-style: none; padding: 0; margin: 0; }
.map-residents-list > li + li { border-top: 1px solid var(--border); }
.map-resident { display: grid; grid-template-columns: 72px minmax(0, 1fr); align-items: center; gap: 12px; padding: 12px 8px; border-radius: 10px; color: var(--text); text-decoration: none; }
.map-resident:hover, .map-resident:focus-visible { background: var(--accent-soft); }
.map-resident:hover h4, .map-resident:focus-visible h4 { text-decoration: underline; text-underline-offset: 3px; }
.map-resident-image { display: block; width: 72px; height: 72px; object-fit: contain; border-radius: 10px; background: var(--accent-soft); }
.map-resident-copy { min-width: 0; display: grid; gap: 5px; }
.map-resident h4 { margin: 0 0 2px; font-family: var(--font-body); font-size: .92rem; font-weight: 800; line-height: 1.35; overflow-wrap: anywhere; }
.map-resident .condition-row { gap: 4px; }
.map-resident .condition-pill { min-height: 24px; padding: 3px 7px; font-size: .68rem; line-height: 1.35; }
.map-resident-event { margin: 0; color: var(--text-secondary); font-size: .69rem; line-height: 1.4; }
.map-resident-location { margin: 0; color: var(--text-secondary); font-size: .73rem; line-height: 1.4; }
.map-residents-link { display: none; flex: 0 0 auto; min-height: 44px; max-width: 45%; padding: 6px 10px; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--accent-soft); color: var(--accent-strong); font-size: .77rem; font-weight: 800; }
.map-instructions { margin: 12px 4px 0; color: var(--text-muted); font-size: .8rem; line-height: 1.6; }
@media (max-width: 1000px) {
  .map-explorer.has-residents { grid-template-columns: minmax(0, 1fr); }
  .map-residents { height: auto; scroll-margin-top: 16px; }
  .map-residents-content { overflow: visible; }
  .map-residents-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }
  .map-residents-link { display: block; }
}
@media (max-width: 650px) {
  .map-main { width: calc(100% - 24px); margin-top: 20px; }
  .map-page .header-inner { min-height: 64px; gap: 10px; }
  .map-dex-nav { display: none; }
  .map-page .theme-toggle { margin-left: auto; }
  .map-heading { align-items: start; flex-direction: column-reverse; gap: 14px; }
  .map-heading h1 { font-size: 1.8rem; }
  .map-back { width: 100%; }
  .map-species { padding: 10px 12px; gap: 12px; }
  .map-species-image { width: 72px; height: 72px; }
  .map-explorer { --map-height: clamp(360px, 60vh, 660px); }
  .map-frame, .map-residents { border-radius: 14px; }
  .map-selection { padding: 12px; align-items: start; min-height: 86px; }
  .map-selection span { font-size: .73rem; }
}
