/* EYE · map — the common operating picture.
 * Colour = affiliation: friendly blue for every Blue state, red for Red.
 * Status lives in rings, bars and badges — never in a frame's colour. */

/* ─── Leaflet chrome ──────────────────────────────────────────────────────── */
#map.leaflet-container { background: #070a0e; font-family: var(--sans); outline: none; }
#map.leaflet-container:focus-visible { outline: 2px solid var(--blue); outline-offset: -2px; }
#map .leaflet-control-container .leaflet-bottom.leaflet-right {
  bottom: var(--safe-bottom); right: var(--safe-right);
  transition: right var(--t-med) var(--ease), bottom var(--t-med) var(--ease);
}
#map .leaflet-control-attribution {
  background: rgba(11, 15, 20, 0.72) !important; color: var(--muted) !important;
  font: 400 9.5px/1.5 var(--sans) !important; padding: 1px 7px !important;
  border-radius: 5px 0 0 0; margin: 0 !important;
}
#map .leaflet-control-attribution a { color: var(--ink-2) !important; }

/* Basemaps */
.map-tiles--imagery { filter: brightness(0.6) saturate(0.55) contrast(1.1); }
.basemap-osm .map-tiles--osm { filter: invert(1) hue-rotate(180deg) brightness(0.9) contrast(0.9) saturate(0.6); }
.map-places--dark { opacity: 0.55; }
.map-places--imagery { opacity: 0.7; }

/* Threat-zone fills: one translucent group so overlapping zones show the max. */
.map-pane-zonefill { opacity: 0.3; }
.map-pane-zonefill path { mix-blend-mode: lighten; }
#map.hide-threats .leaflet-zonesFill-pane,
#map.hide-threats .leaflet-zonesLine-pane { display: none; }
#map.hide-units .leaflet-units-pane { display: none; }
#map .map-zhit { cursor: pointer; }

/* Trails dim when something is selected */
#map.has-selection .map-trail:not(.is-sel) { opacity: 0.3; }
#map.has-selection .map-route { opacity: 0.4; }

/* Selection brackets (white corners — blue is the friendly colour) */
.map-brackets, .map-u.is-selected .map-u__body::after, .map-bm.is-selected .map-b__pos::after {
  --b: linear-gradient(var(--select), var(--select));
  background:
    var(--b) left top / 7px 1.5px no-repeat, var(--b) left top / 1.5px 7px no-repeat,
    var(--b) right top / 7px 1.5px no-repeat, var(--b) right top / 1.5px 7px no-repeat,
    var(--b) left bottom / 7px 1.5px no-repeat, var(--b) left bottom / 1.5px 7px no-repeat,
    var(--b) right bottom / 7px 1.5px no-repeat, var(--b) right bottom / 1.5px 7px no-repeat;
}

/* ─── Map labels (halo for legibility on any basemap) ─────────────────────── */
.map-lbl {
  position: absolute; white-space: nowrap; pointer-events: none;
  color: var(--ink);
  text-shadow: 0 0 2px var(--halo), 0 0 3px var(--halo), 0 0 5px var(--halo), 1px 1px 0 var(--halo), -1px -1px 0 var(--halo), 1px -1px 0 var(--halo), -1px 1px 0 var(--halo);
}

/* ─── Units ───────────────────────────────────────────────────────────────── */
.map-um { overflow: visible; }
.map-u { position: absolute; left: 0; top: 0; }
.map-u__body {
  position: absolute; left: 0; top: 0;
  display: grid; place-items: center;
  transform: translate(calc(-50% + var(--fx, 0px)), calc(-50% + var(--fy, 0px)));
  transition: transform 180ms var(--ease), opacity 160ms var(--ease);
  cursor: pointer;
}
.map-u__frame { display: block; overflow: visible; }
.map-u__shape { fill: var(--friendly-fill); stroke: var(--friendly); stroke-width: 1.5; }
.map-u__mark { font: 600 8.5px/1 var(--mono); fill: var(--friendly); letter-spacing: 0; }
.map-u__mark.is-2 { font-size: 7px; }
.map-u__x { stroke: var(--red); stroke-width: 1.75; stroke-linecap: round; display: none; }
.map-u--sea .map-u__shape { stroke: #6cc9ff; }
.map-u--sea .map-u__mark { fill: #6cc9ff; }

/* Airborne: brighter frame + direction-of-movement line */
.map-u.is-moving .map-u__shape { stroke: #8cc4ff; stroke-width: 1.75; }
.map-u.is-moving .map-u__frame { filter: drop-shadow(0 0 3px rgba(88, 166, 255, 0.55)); }
.map-u__hdg {
  position: absolute; left: 50%; top: 50%;
  width: 2px; height: 24px; margin-left: -1px;
  transform-origin: 50% 100%;
  transform: translateY(-100%) rotate(var(--hdg, 0deg));
  background: linear-gradient(to top, transparent 0 11px, #8cc4ff 11px);
  border-radius: 1px;
  display: none;
}
.map-u.is-moving .map-u__hdg { display: block; }

/* Condition: amber bar = damaged / awaiting parts */
.map-u__cond {
  position: absolute; left: 50%; top: calc(50% + 11px);
  width: 14px; height: 3px; margin-left: -7px;
  background: var(--amber-2); border-radius: 2px;
  box-shadow: 0 0 0 1px var(--halo);
  display: none;
}
.map-u.is-damaged .map-u__cond { display: block; }

/* Destroyed: grey frame + red ✕, left where it was lost */
.map-u.is-wreck .map-u__shape { stroke: var(--wreck); fill: #14181e; }
.map-u.is-wreck .map-u__mark { fill: var(--wreck); }
.map-u.is-wreck .map-u__x { display: inline; }
.map-u.is-wreck .map-u__body { cursor: help; }
#map.hide-wrecks .map-u.is-wreck { display: none; }

/* Sheltered: a revetment arch over the frame */
.map-u.is-sheltered .map-u__body::before {
  content: ''; position: absolute; left: -4px; right: -4px; top: -5px; height: 12px;
  border: 1.5px solid var(--ink-2); border-bottom: 0; border-radius: 6px 6px 0 0;
  opacity: 0.85;
}

/* In a collapsed base stack */
.map-u.is-stacked .map-u__body {
  opacity: 0; pointer-events: none;
  transform: translate(calc(-50% + var(--fx, 0px)), calc(-50% + var(--fy, 0px))) scale(0.35);
}
.map-u.is-polar { display: none; }

/* Selection, inbound, hover */
.map-u.is-selected .map-u__body::after { content: ''; position: absolute; inset: -7px; pointer-events: none; }
.map-u.is-selected .map-u__shape { stroke: #ffffff; }
.map-u.is-inbound .map-u__shape { stroke: #c6e0ff; }
.map-u.is-hovered .map-u__frame { filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.75)); }
#map.has-selection .map-u:not(.is-selected):not(.is-inbound):not(.is-hovered) .map-u__body { opacity: 0.55; }
#map.has-selection .map-u.is-stacked:not(.is-selected) .map-u__body { opacity: 0; }

/* Unit labels: callsign + (zoom ≥ 6) a data line; placed by slot */
.map-u__lbl {
  font: 600 10.5px/1.15 var(--mono); letter-spacing: 0.06em;
  left: calc(100% + 7px); top: 50%; transform: translateY(-50%);
}
.map-u__lbl small { display: none; font: 500 9.5px/1.2 var(--mono); letter-spacing: 0.03em; color: var(--ink-2); }
#map.z-hi .map-u.is-moving .map-u__lbl small:not(:empty) { display: block; }
.map-u[data-slot='l'] .map-u__lbl { left: auto; right: calc(100% + 7px); text-align: right; }
.map-u[data-slot='t'] .map-u__lbl { left: 50%; top: auto; bottom: calc(100% + 7px); transform: translateX(-50%); text-align: center; }
.map-u[data-slot='b'] .map-u__lbl { left: 50%; top: calc(100% + 7px); transform: translateX(-50%); text-align: center; }
.map-u.label-off .map-u__lbl { display: none; }
.map-u.is-wreck .map-u__lbl b { color: var(--muted); text-decoration: line-through; text-decoration-color: rgba(248, 81, 73, 0.7); }

/* ─── Bases ───────────────────────────────────────────────────────────────── */
.map-bm { overflow: visible; }
.map-b { position: absolute; left: 0; top: 0; }
.map-b__pos { position: absolute; left: 0; top: 0; transform: translate(var(--bx, 0px), var(--by, 0px)); transition: transform 200ms var(--ease); cursor: pointer; }
.map-b__leader, .map-b__spokes { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
.map-b__leader line { stroke: var(--ink-2); stroke-width: 1; opacity: 0.55; }
.map-b__leader circle { fill: var(--ink-2); opacity: 0.8; }
.map-b__spokes line { stroke: var(--friendly); stroke-width: 1; opacity: 0.35; }
.map-b__slot { fill: none; stroke: var(--line-strong); stroke-width: 1; stroke-dasharray: 2 2; }

.map-b__glyph {
  position: absolute; left: -9px; top: -9px; width: 18px; height: 18px;
  border-radius: 5px; background: var(--friendly-fill);
  border: 1.5px solid var(--friendly);
  box-shadow: 0 0 0 1.5px var(--halo), 0 2px 8px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}
.map-b.is-fob .map-b__glyph { left: -10px; top: -10px; width: 20px; height: 20px; border-radius: 2px; border-width: 2px; }
.map-b__rwy { position: absolute; left: 3px; right: 3px; top: 50%; height: 3px; margin-top: -1.5px; background: rgba(88, 166, 255, 0.22); border-radius: 1px; overflow: hidden; }
.map-b__rwy > span { display: block; height: 100%; background: var(--friendly); border-radius: 1px; }
.map-b__rwy.tone-warn > span { background: var(--warn); }
.map-b__rwy.tone-bad > span { background: var(--bad); }
.map-b__craters i { position: absolute; top: 50%; width: 1.5px; height: 8px; margin-top: -4px; background: var(--red); box-shadow: 0 0 0 0.5px var(--halo); }
.map-b.is-severe .map-b__glyph::after {
  content: ''; position: absolute; inset: 0;
  background: repeating-linear-gradient(45deg, rgba(198, 224, 255, 0.55) 0 1.5px, transparent 1.5px 4px);
  animation: map-fade-in 600ms var(--ease);
}
.map-b.is-ghost .map-b__glyph { border-style: dashed; background: transparent; opacity: 0.75; }
.map-b.is-ghost .map-b__lbl em { font-style: normal; color: var(--amber-2); font-size: 9.5px; }

/* FOB readiness ring: arc length = readiness */
.map-b__ring { position: absolute; left: -17px; top: -17px; overflow: visible; pointer-events: none; }
.map-b__ringtrack { fill: none; stroke: rgba(160, 190, 220, 0.2); stroke-width: 2.5; }
.map-b__ringarc { fill: none; stroke-width: 2.5; stroke-linecap: round; transition: stroke-dasharray 300ms var(--ease); }
.map-b__ringarc.tone-good { stroke: var(--good); }
.map-b__ringarc.tone-warn { stroke: var(--warn); }
.map-b__ringarc.tone-bad { stroke: var(--bad); }
.map-b__ringarc.tone-muted { stroke: var(--muted); }

/* Stack badge (aircraft on the ramp) */
.map-b__stack {
  position: absolute; left: 11px; top: -24px;
  display: inline-flex; align-items: center; gap: 4px;
  height: 16px; padding: 0 5px;
  border-radius: 8px; background: rgba(11, 15, 20, 0.9); border: 1px solid var(--line-2);
  font: 600 9.5px/1 var(--mono); color: var(--ink); white-space: nowrap;
  pointer-events: none;
}
.map-b__stack b { font-weight: 700; }
.map-b__pips { display: inline-flex; gap: 2px; }
.map-b__pips i { font-style: normal; font-size: 8.5px; color: var(--friendly); }
.map-b__ships { color: #6cc9ff; }
.map-b__wrecks { color: var(--red); }
.map-b.is-fanned .map-b__stack { opacity: 0.4; }

/* Status badges */
.map-b__badges { position: absolute; left: 13px; top: 5px; display: inline-flex; gap: 3px; pointer-events: none; }
.map-b.is-fob .map-b__badges { left: 15px; }
.map-bdg {
  display: inline-flex; align-items: center; gap: 2px;
  height: 13px; padding: 0 3px; border-radius: 3px;
  font: 700 8.5px/1 var(--mono); letter-spacing: 0.02em; white-space: nowrap;
  background: rgba(11, 15, 20, 0.9); border: 1px solid var(--line-2); color: var(--ink-2);
}
.map-bdg svg { width: 9px; height: 9px; }
.map-bdg--wx { color: var(--amber-2); border-color: rgba(227, 179, 65, 0.5); }
.map-bdg--deg { color: var(--muted); }
.map-bdg--mog { color: var(--amber-2); border-color: rgba(227, 179, 65, 0.5); }
.map-bdg--int { color: var(--blue-2); border-color: rgba(88, 166, 255, 0.45); }
.map-bdg--crater { color: #ff8b84; border-color: rgba(248, 81, 73, 0.45); }
.map-bdg--plan { color: #ff8b84; border-color: rgba(248, 81, 73, 0.45); }
.map-bdg--reach { color: var(--good); border-color: rgba(63, 185, 80, 0.5); }
.map-bdg--strip { color: var(--amber-2); border-color: rgba(227, 179, 65, 0.5); }

/* Base labels */
.map-b__lbl { left: 50%; top: 15px; transform: translateX(-50%); font: 500 11px/1.2 var(--sans); letter-spacing: 0.01em; color: var(--ink-2); }
.map-b.is-fob .map-b__lbl { font-weight: 600; color: var(--ink); top: 17px; }
.map-bm[data-slot='t'] .map-b__lbl { top: auto; bottom: 16px; }
.map-bm[data-slot='r'] .map-b__lbl { left: 16px; top: 50%; transform: translateY(-50%); }
.map-bm[data-slot='l'] .map-b__lbl { left: auto; right: 16px; top: 50%; transform: translateY(-50%); }
.map-bm.label-off .map-b__lbl { display: none; }

/* Planned-strike countdown (last hour, umpire view) */
.map-b__reticle {
  position: absolute; left: -21px; top: -21px; width: 42px; height: 42px;
  border: 1.5px dashed var(--red); border-radius: 50%;
  animation: map-spin 8s linear infinite; pointer-events: none;
}
.map-b__cd {
  position: absolute; left: 50%; top: -40px; transform: translateX(-50%);
  font: 700 9px/1 var(--mono); letter-spacing: 0.06em; color: #ff8b84; white-space: nowrap;
  text-shadow: 0 0 3px var(--halo), 0 0 5px var(--halo);
  pointer-events: none;
}

/* Selection, hover, strike target */
.map-bm.is-selected .map-b__pos::after { content: ''; position: absolute; left: -17px; top: -17px; width: 34px; height: 34px; pointer-events: none; }
.map-bm.is-selected .map-b__glyph { border-color: #ffffff; }
.map-bm.is-hovered .map-b__glyph { box-shadow: 0 0 0 1.5px var(--halo), 0 0 10px rgba(255, 255, 255, 0.6); }
.map-bm.is-strike-target .map-b__pos::before {
  content: ''; position: absolute; left: -22px; top: -22px; width: 44px; height: 44px;
  border-radius: 50%; border: 2px solid var(--red); opacity: 0.85;
  animation: map-pulse 1.6s var(--ease) infinite;
}
#map.has-selection .map-bm:not(.is-selected):not(.is-hovered) .map-b__pos { opacity: 0.78; }

/* ─── Threat zones ────────────────────────────────────────────────────────── */
.map-zm, .map-zc { overflow: visible; }
.map-z { position: absolute; left: 0; top: 0; transform: translate(-50%, -100%) translateY(-5px); }
.map-z__chip {
  display: inline-flex; align-items: center; gap: 5px;
  height: 19px; padding: 0 8px; border-radius: 10px;
  background: rgba(36, 10, 10, 0.86); border: 1px solid rgba(248, 81, 73, 0.55);
  font: 600 9.5px/1 var(--mono); letter-spacing: 0.06em; color: #ffb3ad; white-space: nowrap;
  cursor: pointer; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
}
.map-z__chip b { color: #ffffff; font-weight: 700; }
.map-z__sep { color: rgba(255, 179, 173, 0.5); }
.map-z__arrow { color: var(--blue-2); padding: 0 1px; }
.map-z__sead { width: 22px; height: 3px; border-radius: 2px; background: rgba(248, 81, 73, 0.28); overflow: hidden; }
.map-z__sead > span { display: block; height: 100%; background: var(--friendly); }
.map-z.is-selected .map-z__chip, .map-zm.is-hovered .map-z__chip { border-color: #ffffff; color: #ffffff; }
.map-zc__plus {
  position: absolute; left: -5px; top: -5px; width: 10px; height: 10px; opacity: 0.85;
  background:
    linear-gradient(var(--hostile), var(--hostile)) center / 10px 1.5px no-repeat,
    linear-gradient(var(--hostile), var(--hostile)) center / 1.5px 10px no-repeat;
}

/* ─── Rings, air bridge, measure, pick ────────────────────────────────────── */
.map-ringlbl, .map-bridge-tag, .map-mlbl, .map-ghost { overflow: visible; }
.map-ringlbl span {
  position: absolute; left: 0; top: 0; transform: translate(-50%, -100%) translateY(-3px);
  font: 700 9px/1 var(--mono); letter-spacing: 0.08em; color: #8cc4ff; white-space: nowrap;
  text-shadow: 0 0 3px var(--halo), 0 0 5px var(--halo), 1px 1px 0 var(--halo);
}
.map-ringlbl__t--reach { color: #ffffff !important; }
.map-bridge-tag span {
  position: absolute; transform: translate(-50%, -50%);
  font: 600 9px/1 var(--mono); color: #8cc4ff; white-space: nowrap;
  background: rgba(11, 15, 20, 0.85); border: 1px solid var(--line); border-radius: 3px; padding: 2px 4px;
}
.map-mlbl span {
  position: absolute; left: 8px; top: -9px; white-space: nowrap;
  font: 600 10px/1 var(--mono); color: #ffffff; background: rgba(11, 15, 20, 0.9);
  border: 1px solid var(--line-strong); border-radius: 4px; padding: 3px 5px;
}
.map-mlbl b { color: var(--blue-2); font-weight: 700; }
.map-ghost__x {
  position: absolute; left: -9px; top: -9px; width: 18px; height: 18px;
  background:
    linear-gradient(#fff, #fff) center / 18px 1.5px no-repeat,
    linear-gradient(#fff, #fff) center / 1.5px 18px no-repeat;
  filter: drop-shadow(0 0 2px #000);
}
.map-ghost__ll {
  position: absolute; left: 12px; top: 10px; white-space: nowrap;
  font: 600 10px/1 var(--mono); color: #fff; background: rgba(11, 15, 20, 0.9);
  border: 1px solid var(--line-strong); border-radius: 4px; padding: 3px 5px;
}
#map.picking, #map.picking .leaflet-interactive, #map.is-measuring, #map.is-measuring .leaflet-interactive { cursor: crosshair !important; }
#map.picking .leaflet-marker-icon, #map.picking path.leaflet-interactive { pointer-events: none !important; }

/* ─── Event effects (screen-space; never animated in metres) ──────────────── */
.map-fxm { overflow: visible; }
.fx { position: absolute; left: 0; top: 0; transform: translate(var(--bx, 0px), var(--by, 0px)); pointer-events: none; }
.fx-ring {
  position: absolute; left: -70px; top: -70px; width: 140px; height: 140px;
  border-radius: 50%; border: 2px solid #ff7b50; opacity: 0;
  animation: fx-ring 900ms cubic-bezier(0.1, 0.6, 0.3, 1) forwards;
}
.fx-core {
  position: absolute; left: -7px; top: -7px; width: 14px; height: 14px; border-radius: 50%;
  background: #ffffff; box-shadow: 0 0 14px 5px rgba(255, 123, 80, 0.9);
  animation: fx-flash 360ms ease-out forwards;
}
.fx-lbl {
  position: absolute; left: 14px; top: -26px; white-space: nowrap;
  font: 700 10px/1 var(--mono); letter-spacing: 0.08em; color: #ffb08f;
  text-shadow: 0 0 3px var(--halo), 0 0 6px var(--halo), 1px 1px 0 var(--halo);
  animation: fx-lbl 1400ms ease-out forwards;
}
.fx--miss .fx-core { background: var(--amber-2); box-shadow: 0 0 10px 3px rgba(227, 179, 65, 0.55); animation-duration: 700ms; }
.fx--miss .fx-lbl { color: var(--amber-2); }
.fx--shield .fx-core { left: -20px; top: -20px; width: 40px; height: 40px; background: transparent; border: 2px solid var(--blue-2); box-shadow: 0 0 12px rgba(88, 166, 255, 0.7); animation: fx-shield 1100ms ease-out forwards; }
.fx--shield .fx-lbl { color: var(--blue-2); top: 12px; }
.fx--loss .fx-core { left: -22px; top: -22px; width: 44px; height: 44px; background: transparent; border: 2px solid #fff; box-shadow: none; animation: fx-collapse 900ms ease-in forwards; }
.fx--delivery .fx-core { display: none; }
.fx--delivery .fx-lbl { left: -10px; top: -30px; color: #8cc4ff; font-size: 9.5px; animation: fx-float 1700ms ease-out forwards; }
.fx--divert .fx-core { background: var(--amber-2); box-shadow: 0 0 8px 2px rgba(227, 179, 65, 0.6); width: 10px; height: 10px; left: -5px; top: -5px; }
.fx--divert .fx-lbl { color: var(--amber-2); }
.fx--esc .fx-core { left: -24px; top: -24px; width: 48px; height: 48px; background: transparent; border: 2px dashed var(--red); box-shadow: none; animation: fx-esc 1300ms ease-out forwards; }
.fx--esc .fx-lbl { color: #ff8b84; }
.fx.is-still .fx-ring { display: none; }
.fx.is-still .fx-core, .fx.is-still .fx-lbl { animation: none; opacity: 1; }

@keyframes fx-ring { 0% { transform: scale(0.05); opacity: 0.95; } 65% { opacity: 0.45; } 100% { transform: scale(1); opacity: 0; } }
@keyframes fx-flash { 0% { transform: scale(0.3); opacity: 1; } 100% { transform: scale(1.6); opacity: 0; } }
@keyframes fx-lbl { 0% { opacity: 0; transform: translateY(4px); } 12% { opacity: 1; transform: none; } 80% { opacity: 1; } 100% { opacity: 0; } }
@keyframes fx-float { 0% { opacity: 0; transform: translateY(6px); } 15% { opacity: 1; } 100% { opacity: 0; transform: translateY(-16px); } }
@keyframes fx-shield { 0% { transform: scale(0.6); opacity: 0; } 30% { opacity: 1; } 100% { transform: scale(1.15); opacity: 0; } }
@keyframes fx-collapse { 0% { transform: scale(1.6); opacity: 0; border-color: #fff; } 40% { opacity: 1; } 100% { transform: scale(0.2); opacity: 0; border-color: var(--red); } }
@keyframes fx-esc { 0% { transform: scale(0.7) rotate(0deg); opacity: 0; } 30% { opacity: 1; } 100% { transform: scale(1.25) rotate(90deg); opacity: 0; } }
@keyframes map-spin { to { transform: rotate(360deg); } }
@keyframes map-pulse { 0%, 100% { transform: scale(0.92); opacity: 0.9; } 50% { transform: scale(1.08); opacity: 0.45; } }
@keyframes map-fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ─── Overlay tools (#mapUi) — inside the safe frame ──────────────────────── */
#mapControls {
  position: fixed;
  top: calc(var(--safe-top) + var(--gap));
  right: calc(var(--safe-right) + var(--gap));
  display: flex; flex-direction: column; gap: 6px;
  transition: right var(--t-med) var(--ease), top var(--t-med) var(--ease);
}
.map-ctl__grp { display: flex; flex-direction: column; padding: 2px; border-radius: 8px; }
.map-ctl__b {
  width: 32px; height: 32px; display: grid; place-items: center;
  color: var(--ink-2); border-radius: 6px;
  transition: background var(--t-fast), color var(--t-fast);
}
.map-ctl__b:hover { background: var(--bg-3); color: var(--ink); }
.map-ctl__b.is-on, .map-ctl__b[aria-pressed='true'], .map-ctl__b[aria-expanded='true'] { background: var(--blue-a); color: var(--blue-2); }
.map-ctl__b svg { width: 16px; height: 16px; }

.map-readout {
  position: fixed;
  left: calc(var(--safe-left) + var(--gap) + 2px);
  bottom: calc(var(--safe-bottom) + var(--gap));
  display: flex; flex-direction: column; gap: 4px;
  pointer-events: none !important;
  transition: left var(--t-med) var(--ease), bottom var(--t-med) var(--ease);
}
.map-scale { display: flex; align-items: center; gap: 7px; }
.map-scale__bar { display: block; height: 6px; border: 1.5px solid var(--ink-2); border-top: 0; min-width: 20px; box-shadow: 0 1px 0 var(--halo); }
.map-scale__lbl, .map-coords {
  font: 500 10px/1.2 var(--mono); letter-spacing: 0.04em; color: var(--ink-2); white-space: pre;
  text-shadow: 0 0 2px var(--halo), 0 0 4px var(--halo), 1px 1px 0 var(--halo);
}
.map-coords { color: var(--ink); min-height: 12px; }

.map-hint {
  position: fixed;
  left: calc((var(--safe-left) + 100vw - var(--safe-right)) / 2);
  bottom: calc(var(--safe-bottom) + var(--gap) + 30px);
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px;
  padding: 7px 12px; font-size: var(--fs-sm); color: var(--ink); white-space: nowrap;
}
.map-hint svg { color: var(--blue-2); flex: none; }

.map-edge {
  position: fixed; left: 0; top: 0;
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 9px 0 6px;
  font: 600 10px/1 var(--mono); letter-spacing: 0.06em; color: var(--ink);
  border-radius: 13px; cursor: pointer;
}
.map-edge:hover { border-color: var(--line-strong); background: var(--bg-3); }
.map-edge__arrow { display: grid; place-items: center; color: var(--blue-2); }
.map-edge__d { color: var(--muted); }
.map-polar { position: fixed; left: 0; top: 0; pointer-events: none !important; }
.map-polar__u {
  position: fixed; left: 0; top: 0; display: inline-flex; align-items: center; gap: 4px;
  height: 20px; padding: 0 7px; border-radius: 10px;
  font: 600 9.5px/1 var(--mono); letter-spacing: 0.06em; color: #8cc4ff; white-space: nowrap;
}

/* Hover card */
.map-hc {
  position: fixed; left: 0; top: 0; width: 256px; padding: 10px 12px;
  pointer-events: none !important; z-index: 2;
  font-size: var(--fs-sm);
}
.map-hc__h { display: flex; align-items: center; gap: 8px; }
.map-hc__t { flex: 1; min-width: 0; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.map-hc__s { margin-top: 2px; color: var(--muted); font-size: var(--fs-xs); line-height: 1.4; }
.map-hc__stats { margin-top: 8px; }
.map-hc__stats dd.tone-amber { color: var(--amber-2); }
.map-hc__stats dd.tone-good { color: var(--good); }
.map-hc__stats dd.tone-warn { color: var(--warn); }
.map-hc__stats dd.tone-bad { color: var(--bad); }
.map-hc__hint { margin-top: 8px; font: 500 9.5px/1 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); }

/* ─── Popovers: layers, key, context menu ─────────────────────────────────── */
.map-pop { padding: 10px; }
.map-lyr { width: 260px; display: flex; flex-direction: column; gap: 8px; }
.map-lyr__head { display: flex; align-items: center; justify-content: space-between; margin-top: 2px; }
.map-lyr__kbd { text-transform: none; letter-spacing: 0; color: var(--faint); }
.map-lyr__list { display: flex; flex-direction: column; }
.map-lyr__row {
  display: flex; align-items: center; gap: 9px; padding: 5px 6px; border-radius: var(--r-sm);
  color: var(--ink-2); font-size: var(--fs-sm); cursor: pointer; user-select: none;
}
.map-lyr__row:hover { background: var(--bg-3); color: var(--ink); }
.map-lyr__row input { accent-color: var(--blue); width: 14px; height: 14px; }
.map-lyr__name { flex: 1; }
.map-lyr__key { margin-top: 2px; justify-content: flex-start; text-transform: none; letter-spacing: 0; font-family: var(--sans); font-size: var(--fs-sm); }
.map-sw { width: 24px; display: grid; place-items: center; flex: none; }
.map-sw svg, .map-key svg { overflow: visible; }
.ks-air { fill: var(--friendly-fill); stroke: var(--friendly); stroke-width: 1.5; }
.ks-mark { font: 600 8.5px/1 var(--mono); fill: var(--friendly); }
.ks-lbl { fill: none; stroke: var(--ink-2); stroke-width: 1; }
.ks-trail { fill: none; stroke: var(--friendly); stroke-width: 2; opacity: 0.7; }
.ks-route { fill: none; stroke: var(--friendly); stroke-width: 1.5; stroke-dasharray: 3 3; }
.ks-wp { fill: none; stroke: var(--friendly); stroke-width: 1.2; }
.ks-zone { fill: rgba(224, 69, 61, 0.25); stroke: var(--hostile); stroke-width: 1.5; }
.ks-ring { fill: rgba(88, 166, 255, 0.08); stroke: var(--friendly); stroke-width: 1.2; stroke-dasharray: 2 3; }
.ks-fx { fill: none; stroke: #ff7b50; stroke-width: 1.5; }
.ks-fx2 { fill: #fff; }
.ks-wreck { fill: #14181e; stroke: var(--wreck); stroke-width: 1.5; }
.ks-x { stroke: var(--red); stroke-width: 1.6; stroke-linecap: round; }
.ks-bridge { fill: none; stroke: var(--friendly); stroke-width: 3.5; opacity: 0.5; stroke-linecap: round; }
.ks-place { font: 500 9px var(--sans); fill: var(--muted); }

.map-pop--key { padding: 14px 16px; }
.map-key { width: min(640px, calc(100vw - 120px)); }
.map-key__head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.map-key__sub { color: var(--faint); font-size: var(--fs-xs); }
.map-key__grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.map-key__h { font: 600 var(--fs-xs)/1.2 var(--mono); letter-spacing: var(--track); text-transform: uppercase; color: var(--ink-2); margin-bottom: 8px; }
.map-key__row { display: flex; align-items: center; gap: 9px; margin-bottom: 7px; font-size: var(--fs-xs); color: var(--ink-2); line-height: 1.35; }
.map-key__row > :first-child { flex: none; }
.map-key__u { width: 22px; height: 18px; }
.map-key__u.is-wreck .ks-air { stroke: var(--wreck); fill: #14181e; }
.map-key__hdg { width: 22px; height: 2px; background: linear-gradient(to right, transparent 0 6px, #8cc4ff 6px); border-radius: 1px; }
.map-key__cond { width: 14px; height: 3px; margin: 0 4px; background: var(--amber-2); border-radius: 2px; }
.map-key__brk { width: 16px; height: 9px; margin: 0 3px; border: 1.5px solid var(--ink-2); border-bottom: 0; border-radius: 5px 5px 0 0; }
.map-key__hub, .map-key__fob { width: 18px; height: 18px; margin: 0 2px; border: 1.5px solid var(--friendly); background: var(--friendly-fill); border-radius: 5px; position: relative; }
.map-key__fob { border-radius: 2px; border-width: 2px; box-shadow: 0 0 0 3px var(--bg-2), 0 0 0 5px var(--good); }
.map-key__rwy { width: 22px; height: 4px; background: rgba(88, 166, 255, 0.22); border-radius: 1px; position: relative; overflow: hidden; }
.map-key__rwy i { position: absolute; left: 0; top: 0; bottom: 0; width: 60%; background: var(--friendly); }
.map-key__rwy::after { content: ''; position: absolute; left: 70%; top: -2px; width: 1.5px; height: 8px; background: var(--red); }
.map-key__badge { font: 700 8.5px/1 var(--mono); padding: 2px 4px; border-radius: 3px; border: 1px solid var(--line-2); color: var(--ink); background: rgba(11, 15, 20, 0.9); }
.map-key__badge.is-amber, .map-key__badge.is-wx { color: var(--amber-2); border-color: rgba(227, 179, 65, 0.5); }
.map-key__badge.is-int { color: var(--blue-2); border-color: rgba(88, 166, 255, 0.45); }
.map-key__zone { width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid var(--hostile); background: radial-gradient(circle, rgba(224, 69, 61, 0.55) 0 30%, rgba(158, 43, 37, 0.35) 30% 62%, rgba(92, 26, 23, 0.3) 62%); }
.map-key__zone.is-sead { border-style: dashed; opacity: 0.8; }
.map-key__fx { width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid #ff7b50; box-shadow: inset 0 0 0 5px rgba(255, 123, 80, 0.15); }
.map-key__ring { width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid var(--friendly); }
.map-key__ring.is-isr { border-style: dotted; }
.map-key__ring.is-tkr { border-style: dashed; display: inline-block; width: 12px; height: 12px; vertical-align: middle; }
.map-key__ring.is-reach { border: 1.5px dashed #ffffff; opacity: 0.7; }
.map-key__trail { width: 22px; height: 3px; border-radius: 2px; background: linear-gradient(to right, rgba(88, 166, 255, 0.1), rgba(88, 166, 255, 0.7)); }
.map-key__foot { margin-top: 6px; padding-top: 10px; border-top: 1px solid var(--line); color: var(--muted); font-size: var(--fs-xs); }
.map-ctx { min-width: 200px; }

@media (max-width: 1023px) {
  .map-key__grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  .map-u__body, .map-b__pos { transition: none; }
  .map-b__reticle, .map-bm.is-strike-target .map-b__pos::before { animation: none; }
}
