/* Map chrome matches main tracker theme; canvas map palette stays game-like */
:root,
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1115;
  --bg0: #0f1115;
  --panel: #181c24;
  --panel2: #1c212b;
  --text: #eef1f6;
  --muted: #9aa3b2;
  --accent: #5b8def;
  --accent-dim: #3d6fd4;
  --accent-glow: rgba(91, 141, 239, 0.18);
  --accent-text: #ffffff;
  --ember: #e07a4a;
  --frost: #7ec8e3;
  --green: #1e2a38;
  --grid: rgba(91, 141, 239, 0.16);
  --city: #d0ddd6;
  --shield: #3ecf8e;
  --resource: #e0a04a;
  --monster: #e06a5c;
  --boss: #e08a6a;
  --fort: #6ab0a0;
  --building: #4a9ecc;
  --trap: #f0a060;
  --border: #2a3140;
  --chip: #222836;
  --input-bg: #0f131a;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  --legend-w: 220px;
  font-family: "Segoe UI", system-ui, sans-serif;
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f5f7;
  --bg0: #f4f5f7;
  --panel: #ffffff;
  --panel2: #f8f9fb;
  --text: #151921;
  --muted: #5c6575;
  --accent: #3b6fd9;
  --accent-dim: #2f5bb8;
  --accent-glow: rgba(59, 111, 217, 0.14);
  --accent-text: #ffffff;
  --ember: #c86a2a;
  --frost: #3a8fb5;
  --green: #e8eef8;
  --grid: rgba(59, 111, 217, 0.12);
  --city: #2a3344;
  --shield: #1fa86a;
  --resource: #c8862a;
  --monster: #d14b3d;
  --boss: #c86a4a;
  --fort: #3a8a7a;
  --building: #3a7aac;
  --trap: #c87a30;
  --border: #e2e6ee;
  --chip: #eef1f6;
  --input-bg: #ffffff;
  --shadow: 0 6px 20px rgba(20, 28, 45, 0.08);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  transition: background 0.2s ease, color 0.2s ease;
}

.map-app {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* —— Kingdom picker landing —— */
.map-picker {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg);
}
.map-picker[hidden] { display: none !important; }
.map-picker-header {
  padding: 18px 20px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
  justify-content: space-between;
}
.map-picker-header .left {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: baseline;
}
.map-picker-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.map-picker-header h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.map-picker-lead {
  margin: 0;
  flex: 1 1 100%;
  color: var(--muted);
  font-size: 0.9rem;
  max-width: 52ch;
  line-height: 1.45;
}
.map-picker-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 20px 20px;
  max-width: 920px;
  width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
}
.map-picker-form {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.map-picker-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}
.map-picker-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.map-picker-row input {
  flex: 1;
  min-width: 120px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 1rem;
  font-weight: 600;
}
.map-picker-row input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.theme-toggle {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}
.theme-toggle:hover {
  border-color: var(--accent);
  background: var(--chip);
}
[data-theme="dark"] .theme-icon-moon { display: none; }
[data-theme="light"] .theme-icon-sun { display: none; }

/* Update Map button + banner */
.btn-update-map {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  padding: 7px 12px;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  min-width: 7.5rem;
  line-height: 1.15;
}
.btn-update-map:hover:not(:disabled) {
  filter: brightness(1.06);
}
.btn-update-map:disabled {
  cursor: not-allowed;
  opacity: 0.92;
}
.btn-update-map .btn-update-label {
  font-size: 0.88rem;
}
.btn-update-map .btn-update-sub {
  font-size: 0.68rem;
  font-weight: 600;
  opacity: 0.9;
}
.btn-update-map.is-cooldown {
  background: var(--panel);
  color: var(--muted);
  border-color: var(--border);
}
.btn-update-map.is-queued {
  background: var(--panel);
  color: var(--accent);
  border-color: var(--accent);
}
.btn-update-map.is-busy {
  background: color-mix(in srgb, var(--accent) 85%, #000);
}
.btn-update-map.is-disabled {
  background: var(--chip);
  color: var(--muted);
  border-color: var(--border);
}
.map-update-banner {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 16px 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.map-update-banner[hidden] { display: none !important; }
.map-update-banner-copy {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.88rem;
  font-weight: 600;
}
.map-update-pct {
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 700;
}
.map-update-track {
  height: 6px;
  border-radius: 999px;
  background: var(--chip);
  border: 1px solid var(--border);
  overflow: hidden;
}
.map-update-track[hidden] { display: none !important; }
.map-update-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: var(--accent);
  transition: width 0.35s ease;
}
.map-update-track.is-indeterminate .map-update-fill {
  width: 35% !important;
  animation: map-indeterminate 1.2s ease-in-out infinite;
}
.map-picker-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}
.map-picker-toolbar input {
  flex: 1;
  min-width: 160px;
  background: #0c1411;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 0.88rem;
}
.map-picker-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
  align-content: start;
  padding-bottom: 8px;
  scrollbar-width: thin;
}
.map-picker-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.12s;
  box-shadow: var(--shadow);
}
.map-picker-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}
.map-picker-card .k-id {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}
.map-picker-card .k-meta {
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.35;
}
.map-picker-card .k-rank {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.map-picker-empty {
  grid-column: 1 / -1;
  padding: 32px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

/* —— Map view shell —— */
.map-view {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
}
.map-view[hidden] { display: none !important; }

.btn-text {
  background: transparent;
  border: 0;
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 4px 0;
  cursor: pointer;
}

.map-header {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.map-header h1 {
  margin: 0;
  font-size: 1.15rem;
  display: inline;
}
.map-header .left { display: flex; flex-wrap: wrap; gap: 10px; align-items: baseline; }
.map-header .right { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.back {
  color: var(--accent);
  text-decoration: none;
  font-size: .9rem;
}
.meta { color: var(--muted); font-size: .82rem; }

.focus-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .02em;
  background: linear-gradient(135deg, rgba(61,190,154,.22), rgba(224,122,74,.18));
  border: 1px solid rgba(61, 190, 154, 0.45);
  color: #d8f5ea;
}
.focus-pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.kid-box {
  display: flex;
  gap: 6px;
  align-items: center;
  font-size: .85rem;
  color: var(--muted);
}
.kid-box input {
  width: 64px;
  background: #0c1018;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 8px;
}

button, .primary, .secondary {
  border: 0;
  border-radius: 8px;
  padding: 8px 12px;
  font-weight: 600;
  cursor: pointer;
  color: var(--accent-text);
  font-family: inherit;
}
.primary { background: var(--accent); color: var(--accent-text); }
.secondary {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
}
.secondary:hover { border-color: var(--accent); color: var(--accent); }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.shield-filter {
  display: inline-flex;
  gap: 4px;
  padding: 3px;
  border-radius: 999px;
  background: #0c1411;
  border: 1px solid var(--border);
}
.shield-chip {
  border: 0;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.78rem;
  font-weight: 700;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.shield-chip:hover {
  color: var(--text);
}
.shield-chip.active {
  background: linear-gradient(135deg, rgba(61, 190, 154, 0.35), rgba(94, 234, 212, 0.2));
  color: #d8f5ea;
  box-shadow: 0 0 0 1px rgba(61, 190, 154, 0.35);
}
.shield-chip[data-shield="shield"].active {
  background: linear-gradient(135deg, rgba(94, 234, 212, 0.35), rgba(45, 212, 191, 0.18));
  color: #99f6e4;
}
.shield-chip[data-shield="noshield"].active {
  background: linear-gradient(135deg, rgba(224, 122, 74, 0.3), rgba(248, 113, 113, 0.15));
  color: #fecaca;
}
.zoom-btns {
  display: flex;
  gap: 6px;
}
.zoom-btns button {
  width: 34px;
  height: 34px;
  padding: 0;
  background: #1c2535;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.map-stage {
  position: relative;
  overflow: hidden;
  background: #1a2420;
  cursor: grab;
  touch-action: none;
}
.map-stage:active { cursor: grabbing; }
.map-stage.loading { cursor: wait; }
.map-stage.aiming { cursor: crosshair; }
#mapCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* —— Alliance legend (Ember Frost) —— */
.alliance-legend {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 6;
  width: var(--legend-w);
  max-height: min(70vh, 520px);
  display: flex;
  flex-direction: column;
  background: linear-gradient(165deg, rgba(18, 32, 28, 0.94), rgba(12, 20, 18, 0.96));
  border: 1px solid rgba(61, 190, 154, 0.28);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0,0,0,.45), inset 0 1px 0 rgba(126, 200, 227, 0.08);
  backdrop-filter: blur(8px);
  overflow: hidden;
}
.alliance-legend.collapsed {
  width: auto;
  max-height: none;
}
.alliance-legend.collapsed .legend-list,
.alliance-legend.collapsed .legend-sub {
  display: none;
}
.alliance-legend.collapsed .legend-title::after {
  content: " · open";
  font-weight: 500;
  color: var(--muted);
  font-size: .72rem;
}
.legend-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px 6px;
  border-bottom: 1px solid rgba(42, 64, 56, 0.8);
}
.legend-title {
  font-size: .82rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: #c8e6da;
}
.legend-sub {
  font-size: .7rem;
  color: var(--muted);
  margin-top: 2px;
}
.legend-toggle {
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 8px;
  background: #1a2a24;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
}
.legend-search {
  margin: 8px 10px 4px;
  background: #0c1411;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: .78rem;
}
.legend-list {
  overflow-y: auto;
  padding: 4px 6px 8px;
  flex: 1;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.legend-item {
  display: grid;
  grid-template-columns: 12px 1fr auto;
  gap: 8px;
  align-items: center;
  width: 100%;
  padding: 6px 8px;
  margin: 2px 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: .78rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
}
.legend-item:hover {
  background: rgba(61, 190, 154, 0.1);
  border-color: rgba(61, 190, 154, 0.2);
}
.legend-item.active {
  background: linear-gradient(90deg, rgba(61, 190, 154, 0.18), rgba(224, 122, 74, 0.1));
  border-color: rgba(61, 190, 154, 0.45);
  box-shadow: 0 0 0 1px rgba(61, 190, 154, 0.12);
}
.legend-item .swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0,0,0,.35);
}
.legend-item .tag {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
  letter-spacing: .02em;
}
.legend-item .cnt {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: .72rem;
}
.legend-empty {
  padding: 12px 10px;
  color: var(--muted);
  font-size: .78rem;
  text-align: center;
}

/* —— Game-style map search FAB + panel (left) —— */
.map-search-fab {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 7;
  width: 48px;
  height: 48px;
  border: 1px solid rgba(61, 190, 154, 0.4);
  border-radius: 14px;
  background: linear-gradient(160deg, rgba(22, 36, 30, 0.95), rgba(12, 18, 16, 0.98));
  color: #d8f5ea;
  box-shadow: 0 10px 28px rgba(0,0,0,.4);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.map-search-fab:hover,
.map-search-fab.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(61, 190, 154, 0.25), 0 12px 32px rgba(0,0,0,.45);
}
.map-search-fab-icon {
  font-size: 1.45rem;
  line-height: 1;
  font-weight: 600;
}
.map-search-panel {
  position: absolute;
  top: 14px;
  left: 70px;
  z-index: 7;
  width: min(300px, calc(100vw - 100px));
  max-height: min(62vh, 480px);
  display: flex;
  flex-direction: column;
  background: linear-gradient(165deg, rgba(18, 28, 24, 0.97), rgba(10, 16, 14, 0.98));
  border: 1px solid rgba(61, 190, 154, 0.35);
  border-radius: 16px;
  box-shadow: 0 16px 48px rgba(0,0,0,.5);
  backdrop-filter: blur(10px);
  overflow: hidden;
}
.map-search-panel[hidden] { display: none !important; }
.map-search-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 10px 6px;
  border-bottom: 1px solid rgba(42, 64, 56, 0.85);
}
.map-search-tabs {
  display: flex;
  gap: 4px;
}
.map-search-tab {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: .78rem;
  font-weight: 700;
  cursor: pointer;
}
.map-search-tab.active {
  background: rgba(61, 190, 154, 0.18);
  border-color: rgba(61, 190, 154, 0.45);
  color: #d8f5ea;
}
.map-search-close {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0;
}
.map-search-input {
  margin: 10px 12px 6px;
  background: #0c1411;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: .9rem;
}
.map-search-input:focus {
  outline: none;
  border-color: rgba(61, 190, 154, 0.55);
}
.map-search-results {
  overflow-y: auto;
  padding: 4px 8px 10px;
  flex: 1;
  scrollbar-width: thin;
}
.map-search-row {
  display: grid;
  grid-template-columns: 12px 1fr;
  gap: 2px 10px;
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  padding: 8px 10px;
  margin: 2px 0;
  cursor: pointer;
}
.map-search-row:hover {
  background: rgba(61, 190, 154, 0.1);
  border-color: rgba(61, 190, 154, 0.25);
}
.map-search-row .swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-top: 4px;
  grid-row: span 2;
}
.map-search-row .main {
  font-weight: 700;
  font-size: .86rem;
}
.map-search-row .main em {
  font-style: normal;
  color: var(--muted);
  font-weight: 600;
}
.map-search-row .meta {
  font-size: .72rem;
  color: var(--muted);
}
.map-search-empty {
  padding: 18px 12px;
  text-align: center;
  color: var(--muted);
  font-size: .82rem;
}

/* Terrain key */
.terrain-key {
  position: absolute;
  left: 12px;
  bottom: 40px;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(8, 14, 12, 0.72);
  border: 1px solid var(--border);
  font-size: .68rem;
  color: var(--muted);
  pointer-events: none;
}
.terrain-key .tk {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.terrain-key i {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  border: 1px solid rgba(255,255,255,0.15);
}
.terrain-key .fertile i { background: #1a4a32; }
.terrain-key .plains i { background: #2d5a3c; }
.terrain-key .ice i { background: #4a5560; }
.terrain-key .capital i {
  background: linear-gradient(135deg, #c9a227, #e8d48b);
  border-radius: 50%;
}

.map-overlay {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 14, 12, 0.72);
  backdrop-filter: blur(2px);
  pointer-events: none;
}
.map-overlay[hidden] { display: none !important; }
.map-overlay-card {
  min-width: min(320px, 88vw);
  max-width: 420px;
  padding: 22px 24px;
  border-radius: 16px;
  background: linear-gradient(160deg, #172620, #101a17);
  border: 1px solid var(--border);
  box-shadow: 0 16px 48px rgba(0,0,0,.45);
  text-align: center;
}
.map-spinner {
  width: 36px;
  height: 36px;
  margin: 0 auto 14px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: map-spin 0.75s linear infinite;
}
.map-spinner.hidden { display: none; }
@keyframes map-spin { to { transform: rotate(360deg); } }
.map-overlay-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 6px;
}
.map-overlay-detail {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}
.map-progress {
  margin-top: 14px;
  height: 6px;
  border-radius: 999px;
  background: #0c1411;
  overflow: hidden;
  border: 1px solid var(--border);
}
.map-progress-bar {
  height: 100%;
  width: 18%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), #6ee7b7);
  animation: map-indeterminate 1.2s ease-in-out infinite;
}
@keyframes map-indeterminate {
  0% { transform: translateX(-120%); width: 30%; }
  50% { width: 45%; }
  100% { transform: translateX(320%); width: 30%; }
}
button:disabled { opacity: 0.55; cursor: not-allowed; }

.hint-float {
  position: absolute;
  left: 12px;
  bottom: 12px;
  background: rgba(0,0,0,.45);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: .75rem;
  color: var(--muted);
  pointer-events: none;
  max-width: calc(100% - var(--legend-w) - 40px);
}

.popup {
  position: absolute;
  z-index: 5;
  min-width: 200px;
  max-width: 280px;
  background: #141b28;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  box-shadow: 0 12px 40px rgba(0,0,0,.5);
  pointer-events: auto;
}
.popup h3 {
  margin: 0 0 6px;
  font-size: 1rem;
}
.popup .row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: .82rem;
  padding: 3px 0;
  color: var(--muted);
}
.popup .row b { color: var(--text); font-weight: 600; }
.popup .tags { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0; }
.popup .tag {
  background: #1e332c;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: .72rem;
  color: #9ee6c8;
}
.popup .tag.shield { background: rgba(94,234,212,.15); color: var(--shield); }
.popup-skin {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0 4px;
  padding: 6px 8px;
  border-radius: 10px;
  background: rgba(0,0,0,0.28);
  border: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--muted);
}
.popup-skin img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  border-radius: 8px;
  background: rgba(0,0,0,0.25);
}
.popup-skin span {
  color: var(--text);
  font-weight: 600;
}
.popup .tag.trap { background: rgba(240,160,96,.18); color: var(--trap); }
.popup .tag.building { background: rgba(74,158,204,.18); color: #8ec8e8; }
.popup a {
  display: inline-block;
  margin-top: 8px;
  color: var(--frost);
  font-size: .85rem;
}
.popup .close {
  position: absolute;
  top: 6px; right: 8px;
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 2px 6px;
}

.map-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 14px;
  font-size: .78rem;
  color: var(--muted);
  background: var(--panel);
  border-top: 1px solid var(--border);
}

@media (max-width: 720px) {
  .map-picker-header,
  .map-picker-body {
    padding-left: 12px;
    padding-right: 12px;
  }
  .map-picker-list {
    grid-template-columns: 1fr 1fr;
  }
  .map-header {
    padding: 8px 10px;
    gap: 8px;
  }
  .shield-filter {
    order: 1;
    width: 100%;
    justify-content: stretch;
  }
  .shield-chip {
    flex: 1;
    text-align: center;
  }
  .map-header h1 {
    font-size: 1rem;
  }
  .map-header .left,
  .map-header .right {
    width: 100%;
  }
  .map-header .right {
    justify-content: flex-start;
  }
  .toolbar {
    padding: 8px 10px;
    gap: 8px;
  }
  .alliance-legend {
    top: auto;
    bottom: 8px;
    right: 8px;
    left: auto;
    width: min(200px, 46vw);
    max-height: 32vh;
  }
  .alliance-legend.collapsed {
    width: auto;
  }
  .map-search-fab {
    top: 8px;
    left: 8px;
    width: 44px;
    height: 44px;
  }
  .map-search-panel {
    top: 56px;
    left: 8px;
    right: 8px;
    width: auto;
    max-height: 48vh;
  }
  .terrain-key {
    left: 8px;
    bottom: 8px;
    max-width: calc(100% - 16px);
  }
  .hint-float {
    display: none;
  }
  .popup {
    max-width: min(280px, calc(100vw - 24px));
  }
  .map-footer {
    flex-wrap: wrap;
    padding: 6px 10px;
    font-size: 0.72rem;
  }
}
