:root {
  --bg-dark: #070b14;
  --bg-panel: rgba(13, 20, 34, 0.94);
  --bg-card: rgba(22, 33, 54, 0.85);
  --border: rgba(56, 189, 248, 0.24);
  --border-strong: rgba(56, 189, 248, 0.55);
  --text-main: #e2e8f0;
  --text-muted: #94a3b8;
  --accent: #38bdf8;
  --green: #10b981;
  --yellow: #eab308;
  --orange: #f97316;
  --red: #ef4444;
  --purple: #a855f7;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  width: 100%; height: 100%; overflow: hidden;
  background: var(--bg-dark); color: var(--text-main);
  font-family: "Microsoft JhengHei", "PingFang TC", "Noto Sans TC", system-ui, -apple-system, sans-serif;
  font-size: 13px;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: rgba(15, 23, 42, 0.6); }
::-webkit-scrollbar-thumb { background: rgba(56, 189, 248, 0.35); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(56, 189, 248, 0.6); }

#app { display: flex; flex-direction: column; width: 100vw; height: 100vh; }

/* Top Command Bar */
#topbar {
  height: 60px; flex-shrink: 0;
  background: linear-gradient(90deg, #09101f 0%, #0f1b30 50%, #09101f 100%);
  border-bottom: 1px solid var(--border-strong);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 12px; gap: 8px; z-index: 1000;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
}

.brand { display: flex; align-items: center; gap: 9px; min-width: 220px; }
.brand-badge {
  width: 34px; height: 34px; border-radius: 8px;
  background: linear-gradient(135deg, #0284c7, #dc2626);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; box-shadow: 0 0 12px rgba(239, 68, 68, 0.45);
  border: 1px solid rgba(255,255,255,0.25); flex-shrink: 0;
}
.brand-title { font-weight: 700; font-size: 13.5px; letter-spacing: 0.4px; color: #f8fafc; }
.brand-sub { font-size: 11px; color: var(--accent); display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }

.alert-pill { padding: 1px 5px; border-radius: 4px; font-weight: 700; font-size: 10px; text-transform: uppercase; }
.alert-1 { background: rgba(16, 185, 129, 0.2); color: #34d399; border: 1px solid #10b981; }
.alert-2 { background: rgba(234, 179, 8, 0.2); color: #facc15; border: 1px solid #eab308; }
.alert-3 { background: rgba(249, 115, 22, 0.25); color: #fb923c; border: 1px solid #f97316; }
.alert-4 {
  position: relative;
  background: rgba(239, 68, 68, 0.3); color: #f87171; border: 1px solid #ef4444;
}
.alert-4::after {
  content: ""; position: absolute; inset: -1px; border-radius: inherit; pointer-events: none;
  box-shadow: 0 0 10px 2px rgba(239, 68, 68, 0.85);
  opacity: 0; will-change: opacity;
  animation: pulseGlowOpacity 1.8s ease-in-out infinite;
}

/* GPU-Composited Glow Pulse (zero main-thread box-shadow repaints) */
@keyframes pulseGlowOpacity {
  0%, 100% { opacity: 0; }
  50% { opacity: 1; }
}
@keyframes fadeSlide {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.resources-bar { display: flex; align-items: center; gap: 6px; flex-wrap: nowrap; overflow-x: auto; }
.res-pill {
  background: rgba(15, 23, 42, 0.85); border: 1px solid var(--border);
  border-radius: 6px; padding: 4px 8px; display: flex; flex-direction: column; min-width: 84px;
  transition: border-color 0.2s;
}
.res-pill.danger-warn { position: relative; border-color: #ef4444; background: rgba(127, 29, 29, 0.48); }
.res-pill.danger-warn::after {
  content: ""; position: absolute; inset: -1px; border-radius: inherit; pointer-events: none;
  box-shadow: 0 0 10px 2px rgba(239, 68, 68, 0.85);
  opacity: 0; will-change: opacity;
  animation: pulseGlowOpacity 1.8s ease-in-out infinite;
}
.res-pill.danger-warn .res-val { color: #f87171; }
.res-label { font-size: 10px; color: var(--text-muted); display: flex; justify-content: space-between; gap: 4px; white-space: nowrap; }
.res-val { font-size: 13px; font-weight: 700; color: #f8fafc; display: flex; align-items: baseline; gap: 4px; }
.res-delta { font-size: 10px; font-weight: 600; }
.delta-pos { color: #34d399; }
.delta-neg { color: #f87171; }
.morale-crit-tag {
  font-size: 9.5px; color: #fecaca; background: rgba(185, 28, 28, 0.85);
  border: 1px solid #f87171; border-radius: 3px; padding: 0 3px; font-weight: 800;
}

.top-actions { display: flex; align-items: center; gap: 5px; flex-shrink: 0; }
.btn {
  border: 1px solid var(--border); background: var(--bg-card); color: var(--text-main);
  padding: 6px 8px; border-radius: 6px; cursor: pointer; font-weight: 600;
  font-size: 12px; display: inline-flex; align-items: center; gap: 4px;
  transition: all 0.15s ease; white-space: nowrap; font-family: inherit;
}
.btn:hover:not(:disabled) { border-color: var(--accent); background: rgba(56, 189, 248, 0.16); transform: translateY(-1px); }
.btn:disabled { opacity: 0.58; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, #0284c7, #0369a1); border-color: #38bdf8; color: #fff; }
.btn-primary:hover:not(:disabled) { background: linear-gradient(135deg, #0ea5e9, #0284c7); }
.btn-endturn {
  background: linear-gradient(135deg, #d97706, #b45309); border-color: #fbbf24; color: #fff;
  padding: 7px 11px; font-size: 12.5px; box-shadow: 0 0 14px rgba(245, 158, 11, 0.35);
}
.btn-endturn:hover:not(:disabled) { background: linear-gradient(135deg, #f59e0b, #d97706); }
.btn-danger { background: rgba(185, 28, 28, 0.45); border-color: #ef4444; color: #fecaca; }
.btn-danger:hover:not(:disabled) { background: rgba(220, 38, 38, 0.7); }
.btn-success { background: rgba(6, 95, 70, 0.55); border-color: #10b981; color: #a7f3d0; }
.btn-success:hover:not(:disabled) { background: rgba(16, 185, 129, 0.75); color: #fff; }
.btn-warn { background: rgba(180, 83, 9, 0.45); border-color: #f59e0b; color: #fde68a; }
.btn-warn:hover:not(:disabled) { background: rgba(217, 119, 6, 0.7); color: #fff; }
.btn-sm { padding: 4px 8px; font-size: 11px; }
.btn.is-recruit-ready {
  border-color: #fbbf24;
  background: linear-gradient(135deg, rgba(234, 179, 8, 0.55), rgba(217, 119, 6, 0.65));
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
.btn.is-recruit-ready:hover:not(:disabled) {
  border-color: #fde047;
  background: linear-gradient(135deg, rgba(234, 179, 8, 0.72), rgba(217, 119, 6, 0.8));
}
.btn.is-order-free-ready {
  border-color: #34d399;
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.58), rgba(16, 185, 129, 0.68));
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.48), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
.btn.is-order-free-ready:hover:not(:disabled) {
  border-color: #6ee7b7;
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.76), rgba(16, 185, 129, 0.84));
}

/* PC Topbar Hamburger Dropdown Menu */
.top-menu-wrap { position: relative; display: inline-flex; align-items: center; }
.btn-menu-toggle { justify-content: center; min-width: 34px; height: 30px; padding: 6px 9px; }
.btn-menu-toggle.active { border-color: var(--accent); background: rgba(56, 189, 248, 0.22); color: #fff; }
.top-menu-bars {
  display: inline-flex; flex-direction: column; justify-content: space-between;
  width: 14px; height: 12px; pointer-events: none;
}
.top-menu-bars span {
  display: block; width: 100%; height: 2px; border-radius: 2px; background: currentColor;
}
.top-dropdown-menu {
  position: absolute; top: calc(100% + 6px); right: 0; min-width: 176px;
  background: rgba(11, 18, 32, 0.98); border: 1px solid var(--border-strong);
  border-radius: 9px; padding: 5px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.8), 0 0 16px rgba(56, 189, 248, 0.18);
  backdrop-filter: blur(10px); display: none; flex-direction: column; gap: 3px; z-index: 1200;
}
.top-dropdown-menu.show { display: flex; animation: fadeSlide 0.14s ease; }
.top-menu-item {
  width: 100%; border: 1px solid transparent; background: transparent; color: var(--text-main);
  padding: 8px 10px; border-radius: 6px; cursor: pointer; font-family: inherit;
  font-size: 12.5px; font-weight: 600; display: flex; align-items: center;
  justify-content: space-between; gap: 10px; text-align: left; white-space: nowrap;
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease;
}
.top-menu-item:hover { background: rgba(56, 189, 248, 0.16); border-color: rgba(56, 189, 248, 0.35); color: #fff; }
.top-menu-badge {
  font-size: 11px; font-weight: 700; color: #fbbf24;
  background: rgba(251, 191, 36, 0.14); border: 1px solid rgba(251, 191, 36, 0.35);
  padding: 1px 6px; border-radius: 99px;
}
.top-menu-divider { height: 1px; background: rgba(148, 163, 184, 0.18); margin: 2px 4px; }
.top-menu-item.danger { color: #fca5a5; }
.top-menu-item.danger:hover { background: rgba(185, 28, 28, 0.38); border-color: rgba(239, 68, 68, 0.55); color: #fecaca; }

/* Main Workspace */
#workspace { flex: 1; display: flex; position: relative; overflow: hidden; }
#map-container { flex: 1; position: relative; background: #111a2e; }
#map { width: 100%; height: 100%; background: #111a2e; }

/* Helicopter / Airdrop Map Targeting Mode */
#map-container.heli-targeting-mode #map,
#map-container.heli-targeting-mode .leaflet-interactive { cursor: crosshair !important; }
#map-container.heli-targeting-mode .unit-marker-wrapper,
#map-container.heli-targeting-mode .boss-marker-wrapper,
#map-container.heli-targeting-mode .bridge-marker-root { pointer-events: none !important; opacity: 0.72; }
#map-container.heli-targeting-mode .bridge-map-badge { pointer-events: none !important; }

#targeting-preview-hud {
  position: absolute; top: 48px; left: 50%; transform: translateX(-50%); z-index: 930;
  background: rgba(9, 16, 31, 0.96); border: 1.5px solid #38bdf8;
  border-radius: 99px; padding: 6px 16px; font-size: 12px; font-weight: 600; color: #f8fafc;
  box-shadow: 0 6px 22px rgba(0,0,0,0.75); backdrop-filter: blur(8px);
  display: none; align-items: center; gap: 8px; pointer-events: none; white-space: nowrap;
}

#targeting-corner-hud {
  position: absolute; bottom: 16px; right: 16px; z-index: 940;
  background: rgba(10, 17, 32, 0.96); border: 1.5px solid #38bdf8;
  border-radius: 10px; padding: 10px 13px; width: 270px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.85), 0 0 18px rgba(56, 189, 248, 0.35);
  backdrop-filter: blur(10px);
  display: none; flex-direction: column; gap: 7px;
  animation: fadeSlide 0.16s ease;
}
.t-corner-head { display: flex; justify-content: space-between; align-items: center; gap: 6px; font-weight: 800; font-size: 12.5px; color: #f8fafc; }
.t-corner-desc { font-size: 11px; color: #cbd5e1; line-height: 1.45; }
.t-corner-cost { font-size: 11px; color: #fbbf24; font-weight: 700; }

/* Map Controls Overlay (Top-Left) */
#map-hud-tl {
  position: absolute; top: 12px; left: 12px; z-index: 800;
  background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 12px; width: 274px;
  backdrop-filter: blur(8px); box-shadow: 0 8px 24px rgba(0,0,0,0.55);
  display: flex; flex-direction: column; gap: 8px;
  transition: width 0.2s ease, padding 0.2s ease;
  max-height: calc(100% - 210px);
  overflow-y: auto;
  contain: layout style;
}
#map-hud-tl.collapsed { width: auto; padding: 6px 10px; }
#map-hud-tl.collapsed .hud-body { display: none; }
.hud-title {
  font-size: 11px; font-weight: 700; color: var(--accent);
  text-transform: uppercase; letter-spacing: 0.6px;
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.hud-body { display: flex; flex-direction: column; gap: 8px; }
select.tactical-select {
  width: 100%; background: #0f172a; color: #f8fafc;
  border: 1px solid var(--border); border-radius: 5px;
  padding: 5px 8px; font-size: 12px; font-family: inherit; outline: none;
}
select.tactical-select:focus { border-color: var(--accent); }
select.tactical-select optgroup { background: #09101f; color: #38bdf8; font-weight: 700; font-style: normal; }
select.tactical-select option { background: #0f172a; color: #f8fafc; font-weight: 500; }

.slider-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 11px; color: var(--text-muted); }
.slider-row input[type=range] { flex: 1; accent-color: var(--accent); cursor: pointer; }
.toggle-row { display: flex; gap: 8px; flex-wrap: wrap; font-size: 11px; }
.toggle-chip { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; color: var(--text-muted); user-select: none; }
.toggle-chip input { accent-color: var(--accent); cursor: pointer; }

.legend-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px 8px;
  padding-top: 6px; border-top: 1px solid rgba(148, 163, 184, 0.15);
  font-size: 10px; color: #cbd5e1;
}
.legend-item { display: flex; align-items: center; gap: 5px; }
.legend-dot { width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; border: 1px solid rgba(255,255,255,0.3); }

.basemap-credit {
  font-size: 9.5px;
  color: #64748b;
  border-top: 1px dashed rgba(148, 163, 184, 0.16);
  padding-top: 4px;
  line-height: 1.35;
}
.basemap-credit a { color: #7dd3fc; text-decoration: none; }

/* Weather & Threat Pill */
#map-top-hud {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 800;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none;
}
#weather-hud {
  background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: 99px; padding: 5px 14px; font-size: 11.5px;
  backdrop-filter: blur(8px); box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  display: flex; align-items: center; pointer-events: auto; white-space: nowrap;
}
.boss-hud-pill {
  position: relative;
  background: rgba(127, 29, 29, 0.9); border: 1px solid #f43f5e;
  color: #fecdd3; border-radius: 99px; padding: 4px 12px;
  font-size: 11.5px; font-weight: 800; cursor: pointer; white-space: nowrap;
  backdrop-filter: blur(8px);
  display: none; align-items: center;
  pointer-events: auto;
}
.boss-hud-pill::after {
  content: ""; position: absolute; inset: -1px; border-radius: inherit; pointer-events: none;
  box-shadow: 0 0 10px 2px rgba(239, 68, 68, 0.85);
  opacity: 0; will-change: opacity;
  animation: pulseGlowOpacity 1.5s ease-in-out infinite;
}
.boss-hud-pill:hover { filter: brightness(1.2); }
#map-container.heli-targeting-mode #ui-boss-pill { display: none !important; }

#drag-hint-hud {
  position: absolute; top: 48px; left: 50%; transform: translateX(-50%); z-index: 920;
  background: rgba(9, 16, 31, 0.96); border: 1.5px solid #38bdf8;
  border-radius: 99px; padding: 6px 16px; font-size: 12px; font-weight: 600; color: #f8fafc;
  box-shadow: 0 6px 22px rgba(0,0,0,0.75); backdrop-filter: blur(8px);
  display: none; align-items: center; gap: 8px; pointer-events: none; white-space: nowrap;
}

/* Bottom-Right Idle Jump & Bottom-Left Tactical Status HUD */
#unit-dock {
  position: absolute; bottom: 14px; right: 14px; z-index: 910;
  pointer-events: none; display: flex; flex-direction: column;
  align-items: stretch; gap: 7px; width: 242px;
}
#map-container.heli-targeting-mode #unit-dock,
#map-container.heli-targeting-mode #pc-hud-card { display: none; }

.pc-hud-card {
  position: absolute; bottom: 14px; left: 12px; z-index: 910; width: 242px;
  pointer-events: auto;
  background: rgba(11, 18, 32, 0.94);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 9px 10px 10px;
  display: flex; flex-direction: column; gap: 7px;
  backdrop-filter: blur(10px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
  contain: layout style;
}
.pc-hud-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding-bottom: 5px;
  border-bottom: 1px solid rgba(56, 189, 248, 0.18);
}
.pc-hud-title {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 800; color: #38bdf8; letter-spacing: 0.5px;
}
.pc-hud-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #fbbf24; box-shadow: 0 0 8px rgba(251, 191, 36, 0.85);
}
.pc-hud-dot.is-clear { background: #34d399; box-shadow: 0 0 8px rgba(52, 211, 153, 0.85); }
.pc-hud-dot.is-danger { position: relative; background: #ef4444; box-shadow: 0 0 8px rgba(239, 68, 68, 0.95); }
.pc-hud-dot.is-danger::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  box-shadow: 0 0 10px 2px rgba(239, 68, 68, 0.85);
  opacity: 0; will-change: opacity;
  animation: pulseGlowOpacity 1.4s ease-in-out infinite;
}

.pc-hud-badge {
  font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 4px;
  background: rgba(251, 191, 36, 0.16); color: #fde68a;
  border: 1px solid rgba(251, 191, 36, 0.4);
}
.pc-hud-badge.is-clear {
  background: rgba(16, 185, 129, 0.18); color: #6ee7b7;
  border-color: rgba(16, 185, 129, 0.45);
}
.pc-hud-badge.is-danger {
  background: rgba(220, 38, 38, 0.25); color: #fecaca;
  border-color: rgba(248, 113, 113, 0.65);
}

.pc-kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.pc-kpi-cell {
  background: rgba(7, 11, 20, 0.78);
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-left: 2.5px solid #64748b;
  border-radius: 6px;
  padding: 6px 8px;
  display: flex; flex-direction: column; gap: 2px;
  min-width: 0;
  overflow: hidden;
}
.pc-kpi-label { font-size: 10px; color: var(--text-muted); font-weight: 600; white-space: nowrap; }
.pc-kpi-val {
  font-size: 16px; font-weight: 800; line-height: 1.15; color: #f8fafc;
  font-variant-numeric: tabular-nums;
  display: flex; align-items: baseline; gap: 3px;
  white-space: nowrap;
}
.pc-kpi-unit { font-size: 10.5px; font-weight: 600; color: var(--text-muted); }

.pc-kpi-cell.is-blue { border-left-color: #38bdf8; }
.pc-kpi-cell.is-amber { border-left-color: #fbbf24; }
.pc-kpi-cell.is-amber .pc-kpi-val { color: #fde68a; }
.pc-kpi-cell.is-green { border-left-color: #10b981; }
.pc-kpi-cell.is-green .pc-kpi-val { color: #6ee7b7; }
.pc-kpi-cell.is-danger { border-left-color: #f97316; background: rgba(124, 45, 18, 0.28); }
.pc-kpi-cell.is-danger .pc-kpi-val { color: #fdba74; }
.pc-kpi-cell.is-slate { border-left-color: #64748b; }
.pc-kpi-cell.is-slate .pc-kpi-val { color: #cbd5e1; }
.pc-kpi-cell.is-red { border-left-color: #ef4444; background: rgba(127, 29, 29, 0.28); }
.pc-kpi-cell.is-red .pc-kpi-val { color: #fca5a5; }
.pc-kpi-cell.is-gold { border-left-color: #f59e0b; }
.pc-kpi-cell.is-gold .pc-kpi-val { color: #fcd34d; }

.pc-hud-fx {
  font-size: 10.5px; font-weight: 700; color: #7dd3fc;
  background: rgba(56, 189, 248, 0.1); border: 1px solid rgba(56, 189, 248, 0.22);
  border-radius: 5px; padding: 3px 7px; justify-content: center;
}

.pc-idle-btn {
  pointer-events: auto; width: 100%; justify-content: center;
  padding: 9px 12px; font-size: 12.5px; font-weight: 800; border-radius: 6px;
  background: linear-gradient(135deg, #d97706, #b45309);
  border-color: #fbbf24; color: #fff;
  box-shadow: none;
}
.pc-idle-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  border-color: #fde047;
}
.pc-idle-btn.is-danger {
  position: relative;
  background: linear-gradient(135deg, #dc2626, #c2410c);
  border-color: #fb923c; color: #fff;
}
.pc-idle-btn.is-danger::after {
  content: ""; position: absolute; inset: -1px; border-radius: inherit; pointer-events: none;
  box-shadow: 0 0 10px 2px rgba(249, 115, 22, 0.85);
  opacity: 0; will-change: opacity;
  animation: pulseGlowOpacity 1.6s ease-in-out infinite;
}
.pc-idle-btn.is-danger:hover:not(:disabled) {
  background: linear-gradient(135deg, #ef4444, #ea580c);
  border-color: #fdba74;
}
.pc-idle-btn.is-clear {
  background: linear-gradient(135deg, rgba(6, 95, 70, 0.92), rgba(4, 120, 87, 0.92));
  border-color: #34d399; color: #d1fae5;
  box-shadow: none;
}
.pc-idle-btn.is-clear:hover:not(:disabled) {
  background: linear-gradient(135deg, #059669, #047857);
  border-color: #6ee7b7;
}
.pc-recall-btn {
  pointer-events: auto; width: 100%; justify-content: center;
  padding: 7px 12px; font-size: 12px; font-weight: 800; border-radius: 6px;
  background: rgba(15, 23, 42, 0.94);
  border-color: rgba(248, 113, 113, 0.72); color: #fecaca;
  backdrop-filter: blur(8px);
}
.pc-recall-btn:hover:not(:disabled) {
  background: rgba(185, 28, 28, 0.85);
  border-color: #fca5a5; color: #fff;
}
.track-tag { font-size: 9px; padding: 0 4px; border-radius: 3px; font-weight: 700; }
.track-reg { background: rgba(56, 189, 248, 0.18); color: #7dd3fc; border: 1px solid rgba(56, 189, 248, 0.4); }
.track-mil { background: rgba(168, 85, 247, 0.2); color: #d8b4fe; border: 1px solid rgba(168, 85, 247, 0.45); }
.track-ext { background: rgba(16, 185, 129, 0.18); color: #6ee7b7; border: 1px solid rgba(16, 185, 129, 0.45); }

/* XP Badges & Bars */
.xp-pill {
  font-size: 10px; font-weight: 700; padding: 1px 5px; border-radius: 4px;
  background: rgba(56, 189, 248, 0.15); color: #7dd3fc;
  border: 1px solid rgba(56, 189, 248, 0.35); white-space: nowrap;
}
.xp-pill.is-max {
  background: rgba(245, 158, 11, 0.18); color: #fcd34d;
  border-color: rgba(245, 158, 11, 0.5);
}
.xp-prog-wrap { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.xp-prog-bg {
  flex: 1; max-width: 180px; height: 5px;
  background: rgba(255, 255, 255, 0.1); border-radius: 99px; overflow: hidden;
}
.xp-prog-fill {
  height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, #38bdf8, #818cf8);
  transition: width 0.25s ease;
}
.xp-prog-fill.is-max { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.tip-xp-bar {
  height: 3.5px; background: rgba(255, 255, 255, 0.14);
  border-radius: 2px; overflow: hidden; margin: 3px 0;
}
.tip-xp-fill {
  height: 100%; border-radius: 2px;
  background: linear-gradient(90deg, #38bdf8, #818cf8);
}
.tip-xp-fill.is-max { background: linear-gradient(90deg, #f59e0b, #fbbf24); }

/* Draggable Unit Map Tokens */
.unit-marker-wrapper { background: transparent !important; border: none !important; overflow: visible !important; }
.unit-marker-wrapper:hover { z-index: 1500 !important; }
.unit-marker-wrapper.is-dragging { z-index: 2000 !important; }
.unit-marker-wrapper.is-pending-drop { z-index: 1800 !important; }

.unit-token {
  position: relative; width: 44px; height: 44px; border-radius: 12px;
  background: linear-gradient(145deg, #16223a 0%, #09101f 100%);
  border: 2.5px solid #fbbf24;
  box-shadow: 0 4px 12px rgba(0,0,0,0.85), 0 0 10px rgba(251, 191, 36, 0.38);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  cursor: grab; user-select: none;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.unit-token.is-assigned { border-color: #10b981; box-shadow: 0 4px 12px rgba(0,0,0,0.85), 0 0 10px rgba(16, 185, 129, 0.42); }
.unit-token.is-stranded-danger { border-color: #f97316; }
.unit-token.is-stranded-danger::after {
  content: ""; position: absolute; inset: -2px; border-radius: inherit; pointer-events: none;
  z-index: -1;
  box-shadow: 0 0 10px 2px rgba(249, 115, 22, 0.85);
  opacity: 0; will-change: opacity;
  animation: pulseGlowOpacity 1.6s ease-in-out infinite;
}
.unit-token.is-militia { background: linear-gradient(145deg, #27193f 0%, #110b1f 100%); }
.unit-token.is-critical { border-color: #ef4444 !important; background: linear-gradient(145deg, #450a0a 0%, #1c0808 100%); }
.unit-token.is-critical::after {
  content: ""; position: absolute; inset: -2px; border-radius: inherit; pointer-events: none;
  z-index: -1;
  box-shadow: 0 0 10px 2px rgba(239, 68, 68, 0.85);
  opacity: 0; will-change: opacity;
  animation: pulseGlowOpacity 1.4s ease-in-out infinite;
}
.unit-token.is-selected-unit { box-shadow: 0 0 0 2px #ffffff, 0 0 16px rgba(56, 189, 248, 0.9); }
.unit-marker-wrapper:hover .unit-token { transform: scale(1.13); border-color: #ffffff; }
.unit-marker-wrapper.is-dragging .unit-token { cursor: grabbing; transform: scale(1.18); border-color: #38bdf8; box-shadow: 0 12px 26px rgba(0,0,0,0.85), 0 0 18px rgba(56, 189, 248, 0.85); }
.unit-marker-wrapper.is-pending-drop .unit-token { transform: scale(1.15); border-color: #38bdf8; box-shadow: 0 0 0 2px rgba(255,255,255,0.6), 0 0 18px rgba(56, 189, 248, 0.95); }

.unit-token-badge {
  position: absolute; top: -7px; right: -7px; z-index: 2; width: 22px; height: 22px; border-radius: 50%;
  background: linear-gradient(145deg, #16223a 0%, #09101f 100%);
  border: 2px solid; border-color: inherit; color: #fff;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
  font-size: 11px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 5px rgba(0,0,0,0.7); pointer-events: none;
}
.unit-token.is-militia .unit-token-badge {
  background: linear-gradient(145deg, #27193f 0%, #110b1f 100%);
}
.unit-token.is-critical .unit-token-badge {
  background: linear-gradient(145deg, #450a0a 0%, #1c0808 100%);
}
.unit-token-icon { font-size: 19px; line-height: 1; margin-top: -2px; pointer-events: none; }
.unit-token-tag { font-size: 9px; font-weight: 800; color: #e2e8f0; line-height: 1; margin-top: 2px; letter-spacing: 0.3px; text-shadow: 0 1px 2px #000; pointer-events: none; }
.unit-token-hp { position: absolute; bottom: 2px; left: 5px; right: 5px; height: 3.5px; background: rgba(0,0,0,0.7); border-radius: 2px; overflow: hidden; pointer-events: none; }
.unit-token-hp-fill { height: 100%; border-radius: 2px; }

/* Boss Threat Map Tokens */
.boss-marker-wrapper { background: transparent !important; border: none !important; overflow: visible !important; }
.boss-marker-wrapper:hover { z-index: 1650 !important; }
.boss-token {
  position: relative; width: 48px; height: 48px; border-radius: 14px;
  background: linear-gradient(145deg, #581c87 0%, #7f1d1d 55%, #1a050b 100%);
  border: 2.5px solid #f43f5e; outline: 1.5px solid rgba(232, 121, 249, 0.8);
  box-shadow: 0 4px 14px rgba(0,0,0,0.9), 0 0 10px rgba(239, 68, 68, 0.65);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  cursor: pointer; user-select: none; transition: transform 0.15s ease;
}
.boss-token::after {
  content: ""; position: absolute; inset: -3px; border-radius: inherit; pointer-events: none;
  z-index: -1;
  box-shadow: 0 4px 18px rgba(0,0,0,0.95), 0 0 18px rgba(239, 68, 68, 0.95), 0 0 14px 3px rgba(168, 85, 247, 0.75);
  opacity: 0; will-change: opacity;
  animation: pulseGlowOpacity 1.6s ease-in-out infinite;
}
.boss-marker-wrapper:hover .boss-token { transform: scale(1.15); border-color: #ffffff; }
.boss-token-badge {
  position: absolute; top: -7px; right: -8px; z-index: 2; padding: 1px 4px; border-radius: 5px;
  background: #dc2626; border: 1.5px solid #fef2f2; color: #fff; font-size: 8.5px; font-weight: 900;
  letter-spacing: 0.4px; box-shadow: 0 2px 6px rgba(0,0,0,0.85); pointer-events: none;
}
.boss-token-icon { font-size: 20px; line-height: 1; margin-top: -2px; pointer-events: none; filter: drop-shadow(0 1px 3px rgba(0,0,0,0.9)); }
.boss-token-tag { font-size: 9px; font-weight: 900; color: #fecdd3; line-height: 1; margin-top: 2px; letter-spacing: 0.3px; text-shadow: 0 1px 3px #000; pointer-events: none; }
.boss-token-hp { position: absolute; bottom: 2.5px; left: 5px; right: 5px; height: 4px; background: rgba(0,0,0,0.8); border-radius: 2px; overflow: hidden; pointer-events: none; }
.boss-token-hp-fill { height: 100%; border-radius: 2px; background: linear-gradient(90deg, #ef4444, #f43f5e, #e879f9); }

.unit-hover-tip, .boss-hover-tip {
  display: none; position: absolute; bottom: calc(100% + 9px); left: 50%; transform: translateX(-50%);
  background: rgba(9, 16, 31, 0.97); border: 1px solid var(--border-strong);
  border-radius: 6px; padding: 6px 9px; font-size: 11px; color: #f8fafc;
  white-space: nowrap; pointer-events: none; z-index: 2100;
  box-shadow: 0 6px 18px rgba(0,0,0,0.85); line-height: 1.45; text-align: center;
}
.boss-hover-tip { border-color: #f43f5e; background: rgba(24, 9, 20, 0.97); }
.unit-marker-wrapper:hover .unit-hover-tip,
.boss-marker-wrapper:hover .boss-hover-tip { display: block; }
.unit-marker-wrapper.is-dragging .unit-hover-tip,
.unit-marker-wrapper.is-pending-drop .unit-hover-tip,
#map-container.heli-targeting-mode .unit-hover-tip,
#map-container.heli-targeting-mode .boss-hover-tip { display: none !important; }

/* Floating Action Menu */
#unit-action-menu {
  position: absolute; z-index: 950; width: min(350px, calc(100% - 24px)); max-height: calc(100% - 24px);
  background: rgba(10, 17, 32, 0.97); border: 1.5px solid rgba(56, 189, 248, 0.72);
  border-radius: 10px; box-shadow: 0 14px 36px rgba(0, 0, 0, 0.85), 0 0 22px rgba(56, 189, 248, 0.25);
  backdrop-filter: blur(10px); display: none; flex-direction: column; overflow: hidden;
  animation: fadeSlide 0.16s ease;
}
.uam-head { padding: 9px 11px; background: rgba(15, 23, 42, 0.92); border-bottom: 1px solid rgba(56, 189, 248, 0.25); display: flex; flex-direction: column; gap: 4px; flex-shrink: 0; max-height: 46vh; overflow-y: auto; }
.uam-unit-title { font-weight: 800; font-size: 12.5px; color: #f8fafc; display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.uam-unit-stats { font-size: 11px; color: #cbd5e1; line-height: 1.45; display: flex; flex-direction: column; gap: 2px; }
.uam-stats-row { display: flex; justify-content: space-between; align-items: center; gap: 6px; flex-wrap: wrap; }
.uam-fix-btn { padding: 2px 7px; font-size: 10.5px; line-height: 1.25; flex-shrink: 0; }
.uam-unit-bio {
  background: rgba(9, 16, 31, 0.65);
  border: 1px solid rgba(56, 189, 248, 0.16);
  border-radius: 6px;
  padding: 5px 7px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.uam-unit-role { font-size: 11px; font-weight: 700; color: #38bdf8; line-height: 1.35; }
.uam-unit-desc { font-size: 10.5px; color: #cbd5e1; line-height: 1.45; }
.uam-target-sub { font-size: 11px; color: #38bdf8; display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.uam-warn-note { font-size: 10.5px; color: #fbbf24; font-weight: 600; margin-top: 2px; }
.uam-danger-note { font-size: 10.5px; color: #fca5a5; font-weight: 700; margin-top: 2px; }
.uam-crit-note { font-size: 10.5px; color: #fecaca; background: rgba(185, 28, 28, 0.45); border: 1px solid #ef4444; border-radius: 4px; padding: 3px 6px; font-weight: 700; margin-top: 3px; }
.uam-boss-note { font-size: 10.5px; color: #fecdd3; background: rgba(136, 19, 55, 0.65); border: 1px solid #f43f5e; border-radius: 4px; padding: 4px 6px; font-weight: 700; margin-top: 3px; line-height: 1.35; }
.uam-shield-note { font-size: 10.5px; color: #34d399; font-weight: 600; margin-top: 2px; }
.uam-proj-note { font-size: 10.5px; color: #bae6fd; background: rgba(14, 116, 144, 0.28); border-left: 2px solid #38bdf8; padding: 3px 6px; border-radius: 3px; margin-top: 3px; }
.uam-list { padding: 8px; display: flex; flex-direction: column; gap: 5px; overflow-y: auto; flex: 1; min-height: 0; }
.uam-btn {
  width: 100%; text-align: left; font-family: inherit;
  background: rgba(22, 33, 54, 0.88); border: 1px solid rgba(56, 189, 248, 0.28);
  border-radius: 7px; padding: 7px 9px; cursor: pointer; color: var(--text-main);
  transition: all 0.14s ease; display: flex; flex-direction: column; gap: 3px; flex-shrink: 0;
}
.uam-btn:hover:not(:disabled) { border-color: #38bdf8; background: rgba(14, 116, 144, 0.36); transform: translateX(2px); }
.uam-btn:disabled { opacity: 0.58; cursor: not-allowed; }
.uam-btn-top { display: flex; justify-content: space-between; align-items: center; gap: 6px; font-weight: 700; font-size: 12px; color: #f8fafc; }
.uam-cost { font-size: 11px; color: #fbbf24; font-weight: 700; white-space: nowrap; }
.uam-btn-prev { font-size: 10.5px; color: #bae6fd; line-height: 1.35; }
.uam-foot { padding: 7px 8px; border-top: 1px solid rgba(148, 163, 184, 0.18); background: rgba(9, 16, 31, 0.9); display: flex; gap: 6px; flex-shrink: 0; }

/* Right Tactical Sidebar */
#sidebar {
  width: 410px; flex-shrink: 0; background: var(--bg-panel);
  border-left: 1px solid var(--border-strong);
  display: flex; flex-direction: column; z-index: 900;
  box-shadow: -6px 0 24px rgba(0, 0, 0, 0.5);
}
.sidebar-tabs { display: flex; border-bottom: 1px solid var(--border); background: #09101f; flex-shrink: 0; }
.stab { flex: 1; padding: 9px 6px; text-align: center; cursor: pointer; font-weight: 700; font-size: 12px; color: var(--text-muted); border-bottom: 2px solid transparent; transition: all 0.15s; }
.stab:hover { color: #f8fafc; }
.stab.active { color: var(--accent); border-bottom-color: var(--accent); background: rgba(56,189,248,0.08); }

#sidebar-body {
  flex: 1; min-height: 0; overflow-y: auto; padding: 12px;
  display: flex; flex-direction: column; gap: 10px;
  contain: layout style;
}
#sidebar-body > * { flex-shrink: 0; }

.panel-box { background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.boss-panel-card { background: linear-gradient(145deg, rgba(88, 28, 135, 0.35), rgba(127, 29, 29, 0.42)); border: 1.5px solid #f43f5e; border-radius: 8px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.panel-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.sector-title { font-size: 16px; font-weight: 800; color: #f8fafc; }
.sector-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.status-badge { padding: 3px 8px; border-radius: 99px; font-size: 11px; font-weight: 700; white-space: nowrap; }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.stat-cell { background: rgba(10, 16, 29, 0.65); border: 1px solid rgba(148,163,184,0.14); border-radius: 6px; padding: 6px 8px; }
.stat-cell-label { font-size: 10px; color: var(--text-muted); }
.stat-cell-val { font-size: 13px; font-weight: 700; margin-top: 2px; }

.prog-bg { height: 7px; background: rgba(255,255,255,0.1); border-radius: 4px; overflow: hidden; margin-top: 4px; }
.prog-fill { height: 100%; transition: width 0.3s ease; }

.mission-card { background: rgba(11, 18, 32, 0.78); border: 1px solid rgba(56, 189, 248, 0.22); border-radius: 7px; padding: 8px 10px; display: flex; flex-direction: column; gap: 5px; }
.mission-head { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.mission-name { font-weight: 700; font-size: 12.5px; color: #f1f5f9; }
.mission-name.is-exhausted,
.uam-btn-top.is-exhausted > span:first-child { color: #f472b6; }
.mission-cost { font-size: 11px; color: #fbbf24; font-weight: 600; white-space: nowrap; }
.mission-desc { font-size: 11px; color: var(--text-muted); line-height: 1.4; }
.mission-preview { font-size: 11px; color: #bae6fd; background: rgba(14, 116, 144, 0.22); border-left: 2px solid #38bdf8; padding: 4px 7px; border-radius: 3px; line-height: 1.45; }
.mission-controls { display: flex; gap: 6px; align-items: center; margin-top: 2px; }

.bridge-row {
  display: flex; justify-content: space-between; align-items: center; gap: 6px;
  padding: 6px 8px; background: rgba(11,18,32,0.75); border-radius: 6px;
  border: 1px solid rgba(148,163,184,0.15); font-size: 11.5px;
  transition: border-color 0.2s, box-shadow 0.2s;
  content-visibility: auto;
  contain-intrinsic-size: auto 62px;
}
.bridge-row.bridge-highlight {
  position: relative;
  border-color: #38bdf8; background: rgba(14, 116, 144, 0.25);
}
.bridge-row.bridge-highlight::after {
  content: ""; position: absolute; inset: -1px; border-radius: inherit; pointer-events: none;
  box-shadow: 0 0 14px 3px rgba(56, 189, 248, 0.85);
  opacity: 0; will-change: opacity;
  animation: pulseGlowOpacity 1.3s ease 2;
}
.facility-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.fac-card {
  background: rgba(11, 18, 32, 0.82);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.fac-card.built {
  border-color: #10b981;
  background: rgba(16, 185, 129, 0.12);
}

/* 資源不足需求數字紅色提示 */
.res-lack {
  color: #ff5c5c;
  font-weight: 800;
  background: transparent;
  border: none;
  padding: 0;
}
.btn .res-lack {
  color: #ff6b6b;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.85);
}
.fac-head { display: flex; flex-direction: column; gap: 3px; }
.fac-name { font-weight: 700; font-size: 12px; color: #f8fafc; line-height: 1.35; }
.fac-cost { font-size: 11px; color: #fbbf24; font-weight: 600; line-height: 1.3; }
.fac-built-tag { font-size: 11px; color: #34d399; font-weight: 700; line-height: 1.3; }
.fac-desc { font-size: 11px; color: #cbd5e1; line-height: 1.45; }
.fac-build-btn { margin-top: auto; }

/* Log Feed */
.log-entry {
  padding: 6px 8px; border-radius: 5px; font-size: 11.5px; line-height: 1.48;
  background: rgba(15, 23, 42, 0.72); border-left: 3px solid #64748b;
  content-visibility: auto;
  contain-intrinsic-size: auto 44px;
}
.log-info { border-left-color: #38bdf8; }
.log-good { border-left-color: #10b981; background: rgba(16, 185, 129, 0.08); }
.log-warn { border-left-color: #f59e0b; background: rgba(245, 158, 11, 0.08); }
.log-bad { border-left-color: #ef4444; background: rgba(239, 68, 68, 0.1); }
.log-day { font-size: 10px; color: var(--text-muted); font-weight: 700; margin-right: 4px; }

/* Leaflet custom labels */
.sector-label { background: transparent; border: none; box-shadow: none; pointer-events: none; }
.sector-tag { display: inline-flex; flex-direction: column; align-items: center; transform: translate(-50%, -50%); text-align: center; text-shadow: 0 1px 3px #000, 0 0 6px #000, 0 0 2px #000; white-space: nowrap; }
.sector-tag-feats { display: inline-flex; align-items: center; justify-content: center; gap: 2px; font-size: 11px; line-height: 1.1; background: rgba(7, 11, 20, 0.76); border: 1px solid rgba(255, 255, 255, 0.22); border-radius: 4px; padding: 1px 4px; margin-bottom: 1px; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.75); }
.sector-tag-name { position: relative; font-size: 11px; font-weight: 700; color: #f8fafc; letter-spacing: 0.3px; }
.sector-metro-tag {
  position: absolute;
  left: calc(100% + 3px);
  top: 50%;
  transform: translateY(-50%);
  font-size: 10.5px;
  line-height: 1;
  pointer-events: none;
}
.sector-tag-metro-solo { display: inline-flex; align-items: center; justify-content: center; margin-top: 1px; }
.sector-tag-metro-solo .sector-metro-tag { position: static; transform: none; }
.sector-tag-pct { font-size: 10px; font-weight: 800; padding: 0 4px; border-radius: 3px; background: rgba(7, 11, 20, 0.82); border: 1px solid rgba(255,255,255,0.2); margin-top: 1px; }
.sector-tag-res {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 10.5px;
  line-height: 1;
  margin-top: 2px;
  pointer-events: none;
}
.horde-flash {
  position: relative;
  font-size: 10px; font-weight: 800; color: #fecaca;
  background: rgba(185, 28, 28, 0.92); border: 1px solid #f87171;
  padding: 0 5px; border-radius: 4px; margin-bottom: 2px;
}
.horde-flash::after {
  content: ""; position: absolute; inset: -1px; border-radius: inherit; pointer-events: none;
  box-shadow: 0 0 10px 2px rgba(239, 68, 68, 0.85);
  opacity: 0; will-change: opacity;
  animation: pulseGlowOpacity 1.1s ease-in-out infinite;
}
.horde-gather-flash {
  position: relative;
  font-size: 10px; font-weight: 800; color: #fef3c7;
  background: rgba(180, 83, 9, 0.94); border: 1px solid #fbbf24;
  padding: 0 5px; border-radius: 4px; margin-bottom: 2px;
}
.horde-gather-flash::after {
  content: ""; position: absolute; inset: -1px; border-radius: inherit; pointer-events: none;
  box-shadow: 0 0 10px 2px rgba(249, 115, 22, 0.85);
  opacity: 0; will-change: opacity;
  animation: pulseGlowOpacity 1.2s ease-in-out infinite;
}
.bridge-marker-root { position: relative; width: 0; height: 0; overflow: visible; }
.bridge-arrows-svg { position: absolute; left: -90px; top: -60px; width: 180px; height: 120px; pointer-events: none; overflow: visible; }
.bridge-map-badge {
  position: absolute; left: 0; top: 0; transform: translate(-50%, -50%);
  display: inline-flex; align-items: center; gap: 3px; width: max-content;
  background: transparent; border: none; box-shadow: none; padding: 1px 3px;
  font-size: 10px; font-weight: 700; letter-spacing: 0.3px; white-space: nowrap;
  text-shadow: 0 1px 3px #000, 0 0 6px #000, 0 0 2px #000;
  cursor: pointer; transition: transform 0.14s ease, filter 0.14s ease;
}
.bridge-marker-root:hover .bridge-map-badge { filter: brightness(1.22); transform: translate(-50%, -50%) scale(1.06); }

/* Modals */
.modal-backdrop { position: fixed; inset: 0; background: rgba(4, 8, 16, 0.78); backdrop-filter: blur(5px); z-index: 2000; display: none; align-items: center; justify-content: center; padding: 16px; }
.modal-backdrop.show { display: flex; }
.modal-card { background: #0d1526; border: 1px solid var(--border-strong); border-radius: 12px; max-width: 820px; width: 100%; max-height: 90vh; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8); }
.modal-head { padding: 13px 18px; background: #09101f; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; flex-shrink: 0; }
.modal-title { font-size: 16px; font-weight: 800; color: #f8fafc; display: flex; align-items: center; gap: 8px; }
.modal-body {
  padding: 16px 18px; overflow-y: auto; display: flex; flex-direction: column;
  gap: 12px; flex: 1; min-height: 0; contain: layout style;
}
.modal-body > * { flex-shrink: 0; }
.modal-foot { padding: 12px 18px; background: #09101f; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; flex-shrink: 0; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 10px; }
.choice-card { background: rgba(22, 33, 54, 0.8); border: 1px solid var(--border); border-radius: 8px; padding: 12px; cursor: pointer; transition: all 0.15s; display: flex; flex-direction: column; gap: 5px; }
.choice-card:hover:not(:disabled) { border-color: var(--accent); background: rgba(56,189,248,0.12); }
.choice-card:disabled { opacity: 0.45; cursor: not-allowed; }
.choice-card.selected { border-color: #38bdf8; box-shadow: 0 0 12px rgba(56,189,248,0.35); background: rgba(14,116,144,0.3); }

.milestone-card {
  background: rgba(15, 23, 42, 0.85); border: 1px solid var(--border);
  border-radius: 8px; padding: 12px; display: flex; flex-direction: column; gap: 6px;
  content-visibility: auto;
  contain-intrinsic-size: auto 92px;
}
.milestone-card.done { border-color: #10b981; background: rgba(16, 185, 129, 0.12); }

.briefing-strip { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; background: rgba(15, 23, 42, 0.78); border: 1px solid var(--border); border-radius: 7px; padding: 8px 12px; font-size: 12px; color: #cbd5e1; }
.briefing-delta-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(105px, 1fr)); gap: 6px; }
.briefing-list { display: flex; flex-direction: column; gap: 6px; }
.heal-chip-wrap { display: flex; flex-wrap: wrap; gap: 6px; }
.heal-chip { font-size: 11.5px; padding: 4px 9px; border-radius: 99px; background: rgba(16, 185, 129, 0.12); border: 1px solid rgba(16, 185, 129, 0.4); color: #d1fae5; }

.aar-section { background: rgba(15, 23, 42, 0.82); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.aar-sec-title { font-size: 12.5px; font-weight: 800; color: #38bdf8; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid rgba(56, 189, 248, 0.2); padding-bottom: 4px; }
.aar-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.grade-badge { padding: 3px 12px; border-radius: 99px; font-weight: 900; font-size: 13px; letter-spacing: 0.6px; }

/* Toast */
#toast-container { position: fixed; top: 70px; left: 50%; transform: translateX(-50%); z-index: 2500; display: flex; flex-direction: column; gap: 6px; pointer-events: none; }
.toast { background: rgba(13, 21, 38, 0.96); border: 1px solid var(--accent); color: #f8fafc; padding: 8px 14px; border-radius: 7px; font-weight: 600; box-shadow: 0 6px 20px rgba(0,0,0,0.65); animation: fadeSlide 0.25s ease; }

@media (max-width: 1240px) {
  #sidebar { width: 350px; }
  .brand { min-width: 170px; }
  #weather-hud { display: none; }
}
@media (max-width: 1080px) {
  #targeting-corner-hud { bottom: 60px; right: 12px; }
}
@media (max-width: 820px) {
  #workspace { flex-direction: column; }
  #sidebar { width: 100%; height: 43vh; border-left: none; border-top: 1px solid var(--border-strong); }
  #map-hud-tl { width: 210px; padding: 8px; }
  .brand-sub { display: none; }
  .aar-grid-3 { grid-template-columns: 1fr 1fr; }
}

.ico-inv { display: inline-block; line-height: 1; vertical-align: -0.04em; }
.ico-inv-man { filter: invert(1) hue-rotate(180deg) brightness(1.18); }
.ico-inv-spider { filter: invert(1) brightness(1.2) drop-shadow(0 1px 2px rgba(0, 0, 0, 0.92)); }
.ico-inv-banshee { filter: grayscale(1) brightness(1.35) contrast(1.2) drop-shadow(0 0 1px rgba(186, 230, 253, 0.85)); }
.ico-inv-cross {
  color: #ef4444;
  font-weight: 900;
  text-shadow: 0 0 2px rgba(255, 255, 255, 0.35), 0 1px 2px rgba(0, 0, 0, 0.95);
  background: #fff;
  border-radius: 2px;
  padding: 0 1px;
}

/* Help Manual Unified Styles */
.help-section {
  background: rgba(15, 23, 42, 0.82);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.help-title {
  font-size: 13.5px;
  font-weight: 800;
  color: #38bdf8;
  padding-bottom: 5px;
  border-bottom: 1px solid rgba(56, 189, 248, 0.22);
}
.help-list, .help-sublist {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12.5px;
  line-height: 1.6;
  color: #cbd5e1;
}
.help-sublist {
  margin-top: 4px;
  padding-left: 12px;
  border-left: 2px solid rgba(56, 189, 248, 0.25);
  gap: 4px;
}
.help-list strong { color: #f8fafc; font-weight: 700; }
.help-key { color: #fbbf24; font-weight: 700; }
.help-subkey { color: #fde68a; font-weight: 700; }
.help-foot-note {
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  color: #94a3b8;
}

/* Debug Cheat Mode & God-Mode FX */
.btn-cheat {
  background: linear-gradient(135deg, rgba(126, 34, 206, 0.72), rgba(217, 119, 6, 0.72));
  border-color: #fbbf24;
  color: #fef3c7;
  box-shadow: 0 0 12px rgba(251, 191, 36, 0.35);
}
.btn-cheat:hover:not(:disabled) {
  border-color: #fde047;
  background: linear-gradient(135deg, rgba(147, 51, 234, 0.88), rgba(245, 158, 11, 0.88));
}

.cheat-end-badge {
  padding: 3px 10px;
  border-radius: 99px;
  font-weight: 800;
  font-size: 12px;
  color: #fecdd3;
  background: linear-gradient(135deg, rgba(153, 27, 27, 0.82), rgba(107, 33, 168, 0.82));
  border: 1px solid #f43f5e;
  box-shadow: 0 0 12px rgba(244, 63, 94, 0.35);
}

.cheat-section {
  background: rgba(15, 23, 42, 0.84);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.cheat-sec-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-weight: 800;
  font-size: 12.5px;
  color: #38bdf8;
}
.cheat-res-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}
.cheat-two-col {
  display: grid;
  grid-template-columns: 1.3fr 0.7fr;
  gap: 6px;
}
.cheat-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 11px;
  color: #cbd5e1;
}
.cheat-input, .cheat-mini-input {
  width: 100%;
  background: #09101f;
  color: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 5px 7px;
  font-size: 12px;
  font-weight: 700;
  font-family: inherit;
  outline: none;
}
.cheat-input:focus, .cheat-mini-input:focus { border-color: #fbbf24; }
.cheat-mini-input { width: 58px; text-align: center; padding: 3px 4px; }

.cheat-step-list { display: flex; flex-direction: column; gap: 6px; }
.cheat-step-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  background: rgba(9, 16, 31, 0.72);
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 6px;
  padding: 6px 8px;
}
.cheat-step-label { font-size: 12px; font-weight: 700; color: #f8fafc; }
.cheat-step-ctrls { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }

/* 「現在你就是上帝了」半透明遮罩＋純文字特效 */
.godmode-fx {
  position: fixed;
  inset: 0;
  z-index: 3500;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: rgba(4, 8, 16, 0.72);
  backdrop-filter: blur(4px);
  animation: godmodeBackdropIn 0.25s ease;
  transition: opacity 0.4s ease;
}
.godmode-fx.is-fading { opacity: 0; }
.godmode-card {
  position: relative;
  text-align: center;
  padding: 20px 28px;
  animation: godmodeTextIn 0.65s cubic-bezier(0.22, 1.35, 0.36, 1) forwards;
}
.godmode-sub {
  font-size: clamp(10px, 2.4vw, 14px);
  font-weight: 800;
  letter-spacing: 3px;
  color: #e9d5ff;
  text-shadow: 0 0 12px rgba(192, 132, 252, 0.95), 0 2px 8px #000, 0 0 4px #000;
  margin-bottom: 8px;
}
.godmode-title {
  font-size: clamp(32px, 7vw, 72px);
  font-weight: 900;
  letter-spacing: 4px;
  line-height: 1.15;
  background: linear-gradient(180deg, #ffffff 0%, #fef08a 42%, #f59e0b 78%, #fde047 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 16px rgba(251, 191, 36, 0.95)) drop-shadow(0 0 32px rgba(168, 85, 247, 0.85)) drop-shadow(0 4px 10px rgba(0, 0, 0, 0.98));
}
.godmode-desc {
  margin-top: 10px;
  font-size: clamp(11px, 2.6vw, 15px);
  font-weight: 700;
  color: #fef3c7;
  text-shadow: 0 2px 8px #000, 0 0 6px #000, 0 0 12px rgba(251, 191, 36, 0.8);
}

@keyframes godmodeTextIn {
  0% { opacity: 0; transform: scale(0.35) rotate(-3deg); }
  65% { opacity: 1; transform: scale(1.1) rotate(1deg); }
  100% { opacity: 1; transform: scale(1) rotate(0deg); }
}

@keyframes godmodeBackdropIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* End-Game MVP Top 3 Podium */
.mvp-podium-box {
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 7px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.mvp-podium-head {
  font-size: 12px;
  color: #fcd34d;
  display: flex;
  align-items: center;
  gap: 6px;
}
.mvp-podium-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.mvp-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 10px;
  padding: 6px 9px;
  border-radius: 6px;
  font-size: 11.5px;
  background: rgba(15, 23, 42, 0.78);
  border: 1px solid rgba(148, 163, 184, 0.22);
}
.mvp-row.mvp-rank-1 {
  background: linear-gradient(90deg, rgba(245, 158, 11, 0.20), rgba(15, 23, 42, 0.85));
  border-color: rgba(251, 191, 36, 0.65);
}
.mvp-row.mvp-rank-2 {
  background: linear-gradient(90deg, rgba(148, 163, 184, 0.16), rgba(15, 23, 42, 0.82));
  border-color: rgba(203, 213, 225, 0.45);
}
.mvp-row.mvp-rank-3 {
  background: linear-gradient(90deg, rgba(217, 119, 6, 0.15), rgba(15, 23, 42, 0.82));
  border-color: rgba(251, 146, 60, 0.42);
}
.mvp-row-left {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  min-width: 0;
}
.mvp-medal { font-size: 14px; line-height: 1; }
.mvp-rank-label {
  font-size: 10px;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  color: #e2e8f0;
  white-space: nowrap;
}
.mvp-rank-1 .mvp-rank-label { background: rgba(251, 191, 36, 0.22); color: #fde68a; }
.mvp-rank-2 .mvp-rank-label { background: rgba(203, 213, 225, 0.18); color: #f1f5f9; }
.mvp-rank-3 .mvp-rank-label { background: rgba(251, 146, 60, 0.20); color: #fed7aa; }
.mvp-unit-name { font-weight: 700; color: #f8fafc; }
.mvp-status-tag {
  font-size: 10px;
  font-weight: 700;
  padding: 0 5px;
  border-radius: 4px;
  white-space: nowrap;
}
.mvp-status-tag.is-kia {
  background: rgba(185, 28, 28, 0.55);
  border: 1px solid rgba(248, 113, 113, 0.6);
  color: #fecaca;
}
.mvp-status-tag.is-disbanded {
  background: rgba(71, 85, 105, 0.55);
  border: 1px solid rgba(148, 163, 184, 0.45);
  color: #cbd5e1;
}
.mvp-row-stats {
  display: flex;
  align-items: center;
  gap: 5px;
  color: #cbd5e1;
  font-size: 11.5px;
  white-space: nowrap;
}
.mvp-kills { color: #fbbf24; font-weight: 700; }
.mvp-xp { color: #7dd3fc; font-size: 10.5px; }

/* Tactical Confirmation Modal */
#confirm-modal { z-index: 2200; }
.confirm-card { max-width: 470px; }
.confirm-card.tone-danger {
  border-color: rgba(239, 68, 68, 0.72);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.85), 0 0 22px rgba(239, 68, 68, 0.2);
}
.confirm-card.tone-warn {
  border-color: rgba(245, 158, 11, 0.72);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.85), 0 0 22px rgba(245, 158, 11, 0.18);
}
.confirm-msg { font-size: 13.5px; line-height: 1.65; color: #f8fafc; }
.confirm-note {
  font-size: 12px; line-height: 1.55; color: #cbd5e1;
  background: rgba(15, 23, 42, 0.82); border: 1px solid var(--border);
  border-left: 3px solid var(--accent); border-radius: 6px; padding: 8px 10px;
}
.confirm-note.is-danger {
  color: #fecaca; background: rgba(127, 29, 29, 0.28);
  border-color: rgba(239, 68, 68, 0.55); border-left-color: #ef4444;
}
.confirm-note.is-warn {
  color: #fde68a; background: rgba(180, 83, 9, 0.22);
  border-color: rgba(245, 158, 11, 0.5); border-left-color: #f59e0b;
}
.confirm-note.is-good {
  color: #d1fae5; background: rgba(6, 95, 70, 0.25);
  border-color: rgba(16, 185, 129, 0.45); border-left-color: #10b981;
}

/* Recruit Unit Stats Row */
.recruit-stats-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin: 2px 0 3px;
}
.recruit-stat-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 5px;
  background: rgba(10, 16, 29, 0.78);
  border: 1px solid rgba(148, 163, 184, 0.25);
  color: #cbd5e1;
}
.recruit-stat-chip.is-atk { border-color: rgba(249, 115, 22, 0.4); }
.recruit-stat-chip.is-atk strong { color: #fb923c; }
.recruit-stat-chip.is-def { border-color: rgba(56, 189, 248, 0.4); }
.recruit-stat-chip.is-def strong { color: #7dd3fc; }

/* Boss 3-Column Stat Grid */
.boss-stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.boss-stat-cell {
  background: rgba(15, 10, 22, 0.62);
  border: 1px solid rgba(244, 63, 94, 0.28);
  border-radius: 6px;
  padding: 5px 7px;
  text-align: center;
}
.boss-stat-label {
  font-size: 10px;
  color: #fda4af;
  white-space: nowrap;
}
.boss-stat-val {
  font-size: 13px;
  font-weight: 800;
  color: #fecdd3;
  margin-top: 2px;
}

.log-subline {
  display: block;
  margin-top: 3px;
  padding-left: 9px;
  border-left: 2px solid rgba(148, 163, 184, 0.28);
  color: #cbd5e1;
  font-size: 11px;
  line-height: 1.45;
}

.ent-sector { color: #e9d5ff; font-weight: 700; }
.ent-unit   { color: #7dd3fc; font-weight: 700; }
.ent-bridge { color: #e9d5ff; font-weight: 700; }
.ent-boss   { color: #fb7185; font-weight: 700; }

.briefing-callout {
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 11.5px;
  line-height: 1.55;
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.briefing-callout.is-weather {
  background: rgba(14, 116, 144, 0.22);
  border: 1px solid rgba(56, 189, 248, 0.48);
}
.briefing-callout.is-weather-warn {
  background: rgba(180, 83, 9, 0.24);
  border: 1px solid rgba(245, 158, 11, 0.62);
}
.briefing-callout.is-satellite {
  background: rgba(180, 83, 9, 0.22);
  border: 1px solid rgba(245, 158, 11, 0.5);
}
.briefing-callout.is-milestone {
  background: linear-gradient(135deg, rgba(6, 95, 70, 0.36), rgba(180, 83, 9, 0.24));
  border: 1.5px solid rgba(251, 191, 36, 0.72);
  box-shadow: 0 0 14px rgba(245, 158, 11, 0.18);
}

.briefing-log-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}
.briefing-log-text { flex: 1; min-width: 0; }
.briefing-loc-btn { flex-shrink: 0; margin-top: 1px; }

/* Start Modal Difficulty Detail Box */
.diff-detail-box {
  margin-top: 8px;
  background: rgba(15, 23, 42, 0.84);
  border: 1px solid var(--border);
  border-left: 3px solid #38bdf8;
  border-radius: 7px;
  padding: 9px 11px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.diff-detail-box.tone-normal {
  border-left-color: #10b981;
}
.diff-detail-box.tone-hard {
  border-left-color: #f59e0b;
  background: rgba(120, 53, 15, 0.16);
}
.diff-detail-box.tone-nightmare {
  border-left-color: #ef4444;
  background: rgba(127, 29, 29, 0.2);
}
.diff-detail-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 800;
  color: #f8fafc;
}
.diff-detail-tag {
  font-size: 10.5px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 99px;
  background: rgba(56, 189, 248, 0.14);
  color: #7dd3fc;
  border: 1px solid rgba(56, 189, 248, 0.35);
}
.diff-detail-box.tone-normal .diff-detail-tag {
  background: rgba(16, 185, 129, 0.16);
  color: #6ee7b7;
  border-color: rgba(16, 185, 129, 0.45);
}
.diff-detail-box.tone-hard .diff-detail-tag {
  background: rgba(245, 158, 11, 0.18);
  color: #fde68a;
  border-color: rgba(245, 158, 11, 0.45);
}
.diff-detail-box.tone-nightmare .diff-detail-tag {
  background: rgba(239, 68, 68, 0.22);
  color: #fecaca;
  border-color: rgba(239, 68, 68, 0.55);
}
.diff-detail-list {
  margin: 0;
  padding-left: 16px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 11.5px;
  line-height: 1.5;
  color: #cbd5e1;
}
.diff-detail-list strong {
  color: #f8fafc;
}