:root {
  --bg: #d9dde4;
  --bg-deep: #bcc3cf;
  --panel: #f5f7fb;
  --panel-soft: #edf1f8;
  --panel-strong: #e4e9f1;
  --panel-edge: #8792a4;
  --panel-edge-soft: #c2cad7;
  --line: rgba(78, 90, 111, 0.34);
  --line-strong: rgba(52, 61, 79, 0.62);
  --text: #273041;
  --muted: #647089;
  --accent: #54c8ff;
  --accent-soft: rgba(84, 200, 255, 0.2);
  --player: #57c6ff;
  --enemy: #9d5cff;
  --shadow: 0 16px 40px rgba(42, 51, 68, 0.22);
  --radius: 22px;
  --glow-a: rgba(87, 198, 255, 0.22);
  --glow-b: rgba(157, 92, 255, 0.18);
  --chrome-top: #f8fbff;
  --chrome-mid: #e2e8f1;
  --chrome-low: #cfd7e4;
}

body[data-skin="verdant"] {
  --bg: #0b0d10;
  --bg-deep: #040507;
  --panel: #1a1e1b;
  --panel-soft: #222824;
  --panel-strong: #111512;
  --panel-edge: #5b685b;
  --panel-edge-soft: #31382f;
  --line: rgba(150, 172, 151, 0.22);
  --line-strong: rgba(187, 206, 188, 0.28);
  --text: #dce5db;
  --muted: #93a191;
  --accent: #c9aa63;
  --accent-soft: rgba(201, 170, 99, 0.22);
  --player: #7ecf9f;
  --enemy: #c97a6a;
  --glow-a: rgba(95, 146, 104, 0.12);
  --glow-b: rgba(201, 170, 99, 0.08);
  --chrome-top: #596158;
  --chrome-mid: #303730;
  --chrome-low: #171b17;
}

body[data-skin="ember"] {
  --bg: #120907;
  --bg-deep: #050302;
  --panel: #231715;
  --panel-soft: #2c1d19;
  --panel-strong: #150c0b;
  --panel-edge: #77594a;
  --panel-edge-soft: #462d26;
  --line: rgba(198, 151, 127, 0.22);
  --line-strong: rgba(227, 190, 168, 0.28);
  --text: #f0ded6;
  --muted: #bb998e;
  --accent: #d7a15d;
  --accent-soft: rgba(215, 161, 93, 0.22);
  --player: #e2c47c;
  --enemy: #df7966;
  --glow-a: rgba(163, 96, 62, 0.12);
  --glow-b: rgba(215, 161, 93, 0.08);
  --chrome-top: #695249;
  --chrome-mid: #3a2723;
  --chrome-low: #19100f;
}

body[data-skin="marine"] {
  --bg: #d7dce5;
  --bg-deep: #bbc4d1;
  --panel: #f4f7fb;
  --panel-soft: #edf2f9;
  --panel-strong: #e2e8f2;
  --panel-edge: #8a94aa;
  --panel-edge-soft: #c3ccd9;
  --line: rgba(79, 90, 111, 0.34);
  --line-strong: rgba(54, 63, 81, 0.62);
  --text: #273143;
  --muted: #65728b;
  --accent: #56c7ff;
  --accent-soft: rgba(86, 199, 255, 0.22);
  --player: #56c7ff;
  --enemy: #9b5eff;
  --glow-a: rgba(86, 199, 255, 0.24);
  --glow-b: rgba(155, 94, 255, 0.2);
  --chrome-top: #f8fbff;
  --chrome-mid: #e2e8f1;
  --chrome-low: #cfd7e4;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  color: var(--text);
  font-family: "Trebuchet MS", "Avenir Next Rounded", "Arial Rounded MT Bold", sans-serif;
  background:
    radial-gradient(circle at top left, var(--glow-a), transparent 28%),
    radial-gradient(circle at bottom right, var(--glow-b), transparent 30%),
    linear-gradient(180deg, #f4f6fb 0%, var(--bg) 28%, var(--bg-deep) 100%);
}
body {
  position: relative;
  overflow-x: hidden;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(70, 92, 124, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(70, 92, 124, 0.04) 1px, transparent 1px);
  background-size: 32px 32px, 32px 32px;
  opacity: 0.42;
  pointer-events: none;
}
button, input, select { font: inherit; }
button { cursor: pointer; }
select, input {
  width: 100%;
  border-radius: 18px;
  border: 2px solid rgba(74, 86, 106, 0.28);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.92), rgba(222,229,238,0.92));
  color: var(--text);
  padding: 10px 12px;
  outline: none;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.72),
    0 4px 0 rgba(128, 138, 154, 0.34);
}
body[data-skin="ember"] select,
body[data-skin="ember"] input {
  background:
    linear-gradient(180deg, rgba(255,244,241,0.96), rgba(235,214,209,0.96));
}
body[data-skin="marine"] select,
body[data-skin="marine"] input {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.94), rgba(223,231,242,0.96));
}

.scene-glow {
  position: fixed;
  width: 42vw;
  height: 42vw;
  border-radius: 999px;
  filter: blur(64px);
  opacity: 0.55;
  pointer-events: none;
}
.glow-a { top: -8vw; left: -8vw; background: var(--glow-a); }
.glow-b { right: -10vw; bottom: -10vw; background: var(--glow-b); }

.shell {
  position: relative;
  max-width: 1460px;
  margin: 0 auto;
  padding: 16px 16px 22px;
}
.hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(300px, 1fr) minmax(0, 1.8fr);
  gap: 12px 18px;
  align-items: center;
  margin-bottom: 0;
  padding: 14px 18px 16px;
  border: 2px solid var(--line-strong);
  border-bottom: none;
  border-radius: 28px 28px 0 0;
  background:
    radial-gradient(circle at 18% 26%, rgba(86, 199, 255, 0.18), transparent 18%),
    radial-gradient(circle at 88% 24%, rgba(155, 94, 255, 0.16), transparent 18%),
    linear-gradient(180deg, rgba(255,255,255,0.95), rgba(224,231,241,0.95));
  box-shadow:
    inset 0 2px 0 rgba(255,255,255,0.88),
    0 8px 0 rgba(141, 151, 168, 0.36),
    var(--shadow);
}
.hero-copy {
  max-width: none;
  display: grid;
  gap: 4px;
}
.hero-side {
  display: grid;
  gap: 8px;
  min-width: 0;
}
.eyebrow,
.section-tag,
.menu-label {
  margin: 0;
  color: #5a6e92;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
}
.hero h1,
.battle-toolbar h2,
.panel-head h3,
.modal h2 {
  margin: 2px 0 0;
}
.subcopy,
.modal-copy,
.menu-copy,
.setting-note,
.menu-note {
  color: var(--muted);
  margin: 4px 0 0;
  line-height: 1.35;
}
.hero-stats {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}
.header-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.chip,
.metric,
.status-pill,
.menu-card,
.setting-card,
.footer-box {
  border: 2px solid rgba(64, 74, 92, 0.34);
  border-radius: 20px;
  padding: 10px 12px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.98), rgba(224,231,240,0.95));
  box-shadow:
    inset 0 2px 0 rgba(255,255,255,0.9),
    0 6px 0 rgba(153, 162, 179, 0.3);
}
.chip span,
.metric span,
.status-pill span {
  display: block;
  font-size: 0.66rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.16em;
}
.chip strong,
.metric strong,
.status-pill strong {
  display: block;
  margin-top: 5px;
  font-size: 0.98rem;
  letter-spacing: 0.05em;
}
.highlight strong { color: var(--accent); }
.layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
}
.battle-panel,
.panel {
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(255,255,255,0.02), transparent 20%), var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.battle-panel::before,
.panel::before,
.modal::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.04), transparent 18%),
    repeating-linear-gradient(90deg, rgba(255,255,255,0.015) 0 1px, transparent 1px 32px);
  pointer-events: none;
}
.battle-panel {
  padding: 12px 12px 10px;
  border-top: none;
  border-bottom: none;
  border-radius: 0;
  background:
    radial-gradient(circle at 8% 18%, rgba(86, 199, 255, 0.12), transparent 18%),
    radial-gradient(circle at 92% 20%, rgba(155, 94, 255, 0.12), transparent 18%),
    linear-gradient(180deg, rgba(255,255,255,0.9), rgba(219,227,238,0.95));
  box-shadow: none;
  border-left: 2px solid var(--line-strong);
  border-right: 2px solid var(--line-strong);
}
.panel {
  padding: 12px;
  border-radius: 24px;
  box-shadow:
    inset 0 2px 0 rgba(255,255,255,0.92),
    0 8px 0 rgba(150, 159, 176, 0.24);
}
.coach-panel {
  grid-area: coach;
  background:
    radial-gradient(circle at 12% 18%, rgba(86,199,255,0.18), transparent 18%),
    radial-gradient(circle at 88% 22%, rgba(155,94,255,0.12), transparent 18%),
    linear-gradient(180deg, rgba(255,255,255,0.98), rgba(225,233,244,0.96));
  border-color: rgba(94, 132, 196, 0.28);
}
.intel-panel {
  grid-area: intel;
  background:
    radial-gradient(circle at 22% 16%, rgba(86,199,255,0.2), transparent 24%),
    linear-gradient(180deg, rgba(244,249,255,0.98), rgba(221,232,248,0.96));
  border-color: rgba(87, 198, 255, 0.28);
}
.log-panel {
  grid-area: log;
  background:
    radial-gradient(circle at 78% 16%, rgba(155,94,255,0.2), transparent 24%),
    linear-gradient(180deg, rgba(250,244,255,0.98), rgba(235,224,248,0.96));
  border-color: rgba(155, 94, 255, 0.24);
}
.battle-toolbar,
.panel-head,
.modal-head {
  position: relative;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  z-index: 1;
}
.battle-toolbar {
  align-items: flex-end;
  flex-wrap: wrap;
  padding: 4px 2px 10px;
  border-bottom: 2px solid rgba(76, 90, 114, 0.14);
}
.toolbar-actions {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.toolbar-actions label {
  display: grid;
  gap: 4px;
}
.toolbar-actions span {
  font-size: 0.64rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}
.status-pill {
  min-width: 132px;
}
.phase-pill strong {
  color: #6f58d9;
  letter-spacing: 0.04em;
}

.primary,
.secondary,
.quick,
.ghost,
.seg-btn,
.skin-option {
  border: 1px solid transparent;
  border-radius: 18px;
  padding: 10px 14px;
  transition: transform 140ms ease, filter 140ms ease, border-color 140ms ease, background-color 140ms ease;
}
.primary {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.84), rgba(224,246,255,0.84)),
    linear-gradient(135deg, #8fe6ff, #54c8ff 60%, #60a8ff);
  color: #17324b;
  font-weight: 700;
  letter-spacing: 0.04em;
  border: 2px solid rgba(47, 82, 120, 0.26);
  box-shadow:
    inset 0 2px 0 rgba(255,255,255,0.82),
    0 6px 0 rgba(96, 162, 201, 0.36);
}
.secondary,
.quick,
.ghost,
.seg-btn,
.skin-option {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.98), rgba(222,229,239,0.96));
  color: var(--text);
  border: 2px solid rgba(82, 94, 116, 0.22);
  box-shadow:
    inset 0 2px 0 rgba(255,255,255,0.9),
    0 5px 0 rgba(152, 162, 179, 0.28);
}
body[data-skin="ember"] .secondary,
body[data-skin="ember"] .quick,
body[data-skin="ember"] .ghost,
body[data-skin="ember"] .seg-btn,
body[data-skin="ember"] .skin-option {
  background:
    linear-gradient(180deg, rgba(255,249,246,0.98), rgba(238,219,214,0.96));
}
body[data-skin="marine"] .secondary,
body[data-skin="marine"] .quick,
body[data-skin="marine"] .ghost,
body[data-skin="marine"] .seg-btn,
body[data-skin="marine"] .skin-option {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.98), rgba(222,229,239,0.96));
}
.quick.warn {
  background:
    linear-gradient(180deg, rgba(255,249,255,0.98), rgba(235,221,247,0.96));
  color: #69488e;
  border-color: rgba(155,94,255,0.28);
  box-shadow:
    inset 0 2px 0 rgba(255,255,255,0.92),
    0 5px 0 rgba(173, 143, 212, 0.24);
}
.primary:hover,
.secondary:hover,
.quick:hover,
.ghost:hover,
.seg-btn:hover,
.skin-option:hover {
  transform: translateY(-1px);
  filter: brightness(1.04);
}
.seg-btn.active,
.skin-option.active,
.secondary.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-soft), inset 0 0 0 1px rgba(255,255,255,0.04);
}
.icon-button { min-width: 92px; }
.wide-button { min-width: 118px; }
.hidden { display: none !important; }

.battle-stage {
  position: relative;
  margin-top: 10px;
  min-height: clamp(520px, 60vw, 780px);
  aspect-ratio: 1000 / 620;
  border-radius: 28px;
  overflow: hidden;
  border: 3px solid rgba(77, 90, 111, 0.26);
  background:
    radial-gradient(circle at 12% 18%, rgba(86,199,255,0.16), transparent 18%),
    radial-gradient(circle at 88% 16%, rgba(155,94,255,0.14), transparent 18%),
    linear-gradient(180deg, rgba(255,255,255,0.9), rgba(219,226,236,0.92));
  box-shadow:
    inset 0 2px 0 rgba(255,255,255,0.92),
    inset 0 0 0 8px rgba(246, 248, 252, 0.82),
    0 10px 0 rgba(153, 162, 179, 0.32),
    0 18px 30px rgba(69, 82, 104, 0.18);
}
.battle-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 46%, rgba(255,255,255,0.5), transparent 30%),
    linear-gradient(rgba(84, 116, 165, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(84, 116, 165, 0.06) 1px, transparent 1px);
  background-size: auto, 36px 36px, 36px 36px;
  opacity: 0.65;
  pointer-events: none;
}
.battle-stage::after {
  content: "";
  position: absolute;
  inset: 12px;
  border: 2px solid rgba(255,255,255,0.54);
  border-radius: 20px;
  pointer-events: none;
}
body[data-skin="ember"] .battle-stage {
  background:
    radial-gradient(circle at 16% 18%, rgba(255,173,128,0.18), transparent 20%),
    radial-gradient(circle at 84% 16%, rgba(197,99,88,0.16), transparent 18%),
    linear-gradient(180deg, rgba(255,247,244,0.92), rgba(237,220,215,0.94));
}
body[data-skin="marine"] .battle-stage {
  background:
    radial-gradient(circle at 14% 18%, rgba(86,199,255,0.16), transparent 18%),
    radial-gradient(circle at 86% 16%, rgba(155,94,255,0.16), transparent 18%),
    linear-gradient(180deg, rgba(255,255,255,0.92), rgba(219,226,236,0.94));
}
#battlefield { width: 100%; height: auto; display: block; }
.flash-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.flash {
  position: absolute;
  width: 120px;
  height: 120px;
  margin-left: -60px;
  margin-top: -60px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(255,210,125,0.34) 0%, rgba(242,126,99,0.18) 42%, transparent 72%);
  animation: blast 760ms ease-out forwards;
}
@keyframes blast {
  0% { transform: scale(0.4); opacity: 1; }
  100% { transform: scale(1.6); opacity: 0; }
}
.action-toast {
  position: absolute;
  right: 18px;
  top: 18px;
  max-width: 380px;
  padding: 14px 16px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(228,236,247,0.96));
  border: 2px solid rgba(88, 200, 255, 0.32);
  box-shadow: 0 12px 28px rgba(82, 107, 149, 0.16);
  transition: opacity 180ms ease, transform 180ms ease;
}
.action-toast.hidden {
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
}
.battle-footer {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}
.footer-box {
  min-height: 72px;
  background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(226,233,243,0.96));
}
.battle-footer .footer-box:first-child {
  border-color: rgba(87, 198, 255, 0.28);
}
.battle-footer .footer-box:last-child {
  border-color: rgba(155, 94, 255, 0.24);
  background: linear-gradient(180deg, rgba(252,247,255,0.98), rgba(234,224,247,0.96));
}
.footer-box span {
  display: block;
  font-size: 0.64rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #5d7091;
}
.footer-box p { margin: 6px 0 0; }
.sidebar {
  position: relative;
  display: grid;
  gap: 10px;
  grid-template-columns: 290px minmax(0, 1fr) 330px;
  grid-template-areas: "intel coach log";
  align-items: stretch;
  padding: 16px;
  border: 2px solid var(--line-strong);
  border-top: none;
  border-radius: 0 0 28px 28px;
  background:
    radial-gradient(circle at 12% 16%, rgba(86,199,255,0.16), transparent 16%),
    radial-gradient(circle at 88% 16%, rgba(155,94,255,0.12), transparent 16%),
    linear-gradient(180deg, rgba(255,255,255,0.96), rgba(223,230,240,0.96));
  box-shadow:
    inset 0 2px 0 rgba(255,255,255,0.92),
    0 12px 0 rgba(149, 159, 177, 0.26),
    0 22px 34px rgba(69, 82, 104, 0.16);
}
.sidebar::before {
  content: "";
  position: absolute;
  inset: 10px;
  border: 2px solid rgba(255,255,255,0.56);
  border-radius: 22px;
  pointer-events: none;
}
.compact { margin-bottom: 12px; }
.coach-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin: 14px 0;
}
.quick-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.stack {
  list-style: none;
  padding: 0;
  margin: 14px 0 0;
  display: grid;
  gap: 10px;
}
#guidanceList {
  max-height: 160px;
  overflow: auto;
  padding-right: 4px;
}
.logs {
  max-height: 320px;
  overflow: auto;
  padding-right: 4px;
}
.stack li {
  padding: 10px 12px;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(229,235,244,0.95));
  border: 2px solid rgba(96, 106, 126, 0.16);
}
#guidanceList li { border-left: 4px solid var(--accent); }
.logs li {
  border-left: 4px solid color-mix(in srgb, var(--player) 64%, transparent);
  line-height: 1.35;
}
.recap-card {
  margin-top: 18px;
  padding: 18px;
  background:
    radial-gradient(circle at 88% 18%, rgba(155,94,255,0.16), transparent 18%),
    linear-gradient(180deg, rgba(255,255,255,0.98), rgba(229,236,245,0.96));
}
.recap-card h3 { margin: 8px 0 0; }
.recap-list {
  margin-top: 14px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.recap-list li {
  min-height: 60px;
  border-left: 4px solid color-mix(in srgb, var(--accent) 56%, transparent);
}
.recap-list li.pending { opacity: 0.72; }
.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.intel-panel .metric-grid {
  grid-template-columns: 1fr;
}
.intel-panel .metric.wide,
.metric.wide { grid-column: span 1; }
.metric {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.98), rgba(228,235,244,0.96));
  border-left: 5px solid rgba(87, 198, 255, 0.42);
}
.intel-panel .metric:nth-child(2n) {
  border-left-color: rgba(155, 94, 255, 0.34);
}
.impact-card {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 18px;
  border: 2px solid rgba(87, 198, 255, 0.24);
  background:
    radial-gradient(circle at 12% 18%, rgba(87,198,255,0.16), transparent 18%),
    linear-gradient(180deg, rgba(255,255,255,0.98), rgba(225,233,243,0.96));
}
.impact-card span {
  display: block;
  font-size: 0.66rem;
  color: #57a5d7;
  text-transform: uppercase;
  letter-spacing: 0.16em;
}
.impact-card strong { display: block; margin-top: 8px; font-size: 1rem; }
.impact-card p { margin: 8px 0 0; color: var(--muted); font-size: 0.94rem; }

.panel-head {
  padding-bottom: 8px;
  border-bottom: 2px solid rgba(103, 116, 138, 0.12);
}
.panel-head h3,
.battle-toolbar h2,
.modal h2,
.hero h1 {
  letter-spacing: 0.03em;
}
.hero h1 {
  font-size: 1.22rem;
  text-shadow: 0 1px 0 rgba(255,255,255,0.72);
}
.subcopy {
  font-size: 0.78rem;
  max-width: 80ch;
}
.coach-panel::after,
.intel-panel::after,
.log-panel::after {
  content: "";
  position: absolute;
  right: 10px;
  top: 10px;
  width: 88px;
  height: 88px;
  pointer-events: none;
  opacity: 0.22;
}
.intel-panel::after {
  border-radius: 50%;
  border: 2px solid rgba(87,198,255,0.18);
  background:
    radial-gradient(circle at center, rgba(113,197,255,0.16), transparent 56%),
    linear-gradient(rgba(113,197,255,0.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(113,197,255,0.12) 1px, transparent 1px);
  background-size: auto, 14px 14px, 14px 14px;
}
.coach-panel::after {
  width: 108px;
  height: 72px;
  border-radius: 20px;
  border: 2px solid rgba(87,198,255,0.18);
  background:
    linear-gradient(rgba(87,198,255,0.14) 1px, transparent 1px),
    linear-gradient(90deg, rgba(87,198,255,0.14) 1px, transparent 1px);
  background-size: 18px 18px;
}
.log-panel::after {
  width: 110px;
  height: 78px;
  border-radius: 20px;
  border: 2px solid rgba(155,94,255,0.16);
  background:
    radial-gradient(circle at 70% 30%, rgba(155,94,255,0.2), transparent 24%),
    repeating-linear-gradient(180deg, rgba(155,94,255,0.12) 0 2px, transparent 2px 8px);
}

.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(3, 8, 7, 0.68);
  backdrop-filter: blur(12px);
  z-index: 20;
}
.overlay.hidden {
  opacity: 0;
  pointer-events: none;
}
.modal {
  position: relative;
  width: min(760px, calc(100vw - 32px));
  max-height: min(88vh, 980px);
  border-radius: 28px;
  border: 2px solid var(--line-strong);
  background:
    radial-gradient(circle at 14% 18%, rgba(87,198,255,0.18), transparent 18%),
    radial-gradient(circle at 86% 16%, rgba(155,94,255,0.12), transparent 18%),
    linear-gradient(180deg, rgba(255,255,255,0.98), rgba(224,231,241,0.96));
  box-shadow: 0 20px 42px rgba(69, 82, 104, 0.22);
  padding: 24px;
  overflow: auto;
}
.menu-modal { width: min(820px, calc(100vw - 32px)); }
.menu-grid,
.settings-list,
.skin-grid {
  display: grid;
  gap: 14px;
}
.menu-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 18px;
}
.settings-list {
  margin-top: 18px;
}
.setting-card,
.menu-card {
  position: relative;
}
.setting-card {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}
.setting-note,
.menu-note {
  font-size: 0.94rem;
}
.menu-points {
  margin: 14px 0 0;
  padding-left: 18px;
  color: var(--text);
  line-height: 1.6;
}
.menu-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  flex-wrap: wrap;
  margin-top: 20px;
}
.segmented {
  display: inline-flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.skin-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.skin-option {
  display: grid;
  gap: 10px;
  justify-items: start;
  min-height: 108px;
  text-align: left;
}
.skin-swatch {
  width: 100%;
  height: 46px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.1);
}
.swatch-verdant {
  background: linear-gradient(135deg, #f9fbff, #d8f0ff 54%, #8be1ff);
}
.swatch-ember {
  background: linear-gradient(135deg, #fff8f6, #ffd7cf 54%, #ffb38c);
}
.swatch-marine {
  background: linear-gradient(135deg, #fbfcff, #cfeeff 50%, #cdb3ff);
}

svg .lanePulse {
  stroke: rgba(173, 125, 255, 0.28);
  stroke-width: 14;
  stroke-linecap: round;
  stroke-dasharray: 20 22;
  animation: laneFlow 1.4s linear infinite;
}
@keyframes laneFlow {
  from { stroke-dashoffset: 0; }
  to { stroke-dashoffset: -42; }
}
svg .lane { stroke: rgba(120, 178, 244, 0.56); stroke-width: 8; stroke-linecap: round; }
svg .zoneShadow { fill: rgba(116,132,163,0.18); }
svg .zoneBody { transition: fill 160ms ease, stroke 160ms ease, opacity 160ms ease; }
svg .zoneInner { pointer-events: none; }
svg .zoneTerrain {
  fill: rgba(255,255,255,0.42);
  stroke: rgba(132, 150, 181, 0.18);
  stroke-width: 1;
}
svg .zoneLabel { font-size: 18px; fill: #30405a; font-weight: 700; letter-spacing: 0.04em; }
svg .zoneMeta { font-size: 13px; fill: #61708a; }
svg .zoneFort { font-size: 11px; fill: #4ebeff; letter-spacing: 0.04em; }
svg .zoneFortEnemy { fill: rgba(146, 96, 255, 0.88); }
svg .zoneBadge { filter: drop-shadow(0 0 8px rgba(0,0,0,0.35)); }
svg .zoneBadgeMark { opacity: 0.96; }
svg .zoneBadgeText {
  fill: rgba(72, 86, 111, 0.92);
  font-size: 12px;
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: middle;
}
svg .landmarkTerran {
  fill: rgba(87, 198, 255, 0.18);
  stroke: rgba(87, 198, 255, 0.44);
  stroke-width: 1;
}
svg .landmarkTerranLight {
  fill: rgba(255, 255, 255, 0.92);
}
svg .landmarkZerg {
  fill: rgba(155, 94, 255, 0.16);
  stroke: rgba(155, 94, 255, 0.4);
  stroke-width: 1;
}
svg .landmarkZergCore {
  fill: rgba(129, 255, 134, 0.82);
}
svg .landmarkCrystal {
  fill: rgba(115, 219, 255, 0.3);
  stroke: rgba(87, 198, 255, 0.54);
  stroke-width: 1;
}
svg .fogMask {
  fill: rgba(198, 206, 220, 0.58);
  stroke: rgba(148, 164, 190, 0.16);
  stroke-width: 1.4;
}
svg .fogLabel {
  fill: rgba(103, 118, 143, 0.78);
  font-size: 14px;
  letter-spacing: 0.12em;
}
svg .armyTray {
  fill: rgba(225, 244, 255, 0.96);
  stroke: rgba(87, 198, 255, 0.34);
  stroke-width: 1.6;
}
svg .armyTrayEnemy {
  fill: rgba(240, 226, 255, 0.96);
  stroke: rgba(155, 94, 255, 0.34);
}
svg .unitSprite,
svg .travelSprite,
svg .landmarkSprite,
svg .fortSprite {
  overflow: visible;
  transform-box: fill-box;
  transform-origin: center center;
  image-rendering: auto;
}
svg .unitSprite {
  filter: drop-shadow(0 8px 10px rgba(0, 0, 0, 0.34));
  animation: terranIdle 2.2s ease-in-out infinite;
}
svg .unitSpriteEnemy,
svg .travelSpriteEnemy,
svg .landmarkSpriteEnemy,
svg .fortSpriteEnemy {
  filter: drop-shadow(0 8px 10px rgba(95, 58, 156, 0.26));
}
svg .unitSpriteEnemy {
  animation: zergIdle 1.7s ease-in-out infinite;
}
svg .travelSprite {
  filter: drop-shadow(0 10px 12px rgba(0, 0, 0, 0.32));
  animation: terranGlide 1s ease-in-out infinite;
}
svg .travelSpriteEnemy {
  animation: zergDash 0.72s ease-in-out infinite;
}
svg .landmarkSprite {
  opacity: 0.98;
  animation: terranBaseHum 4.4s ease-in-out infinite;
}
svg .landmarkSpriteEnemy {
  animation: zergBaseThrob 2.9s ease-in-out infinite;
}
svg .fortSprite {
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.34));
  animation: bunkerScan 3.1s ease-in-out infinite;
}
svg .fortSpriteEnemy {
  animation: spinePulse 2.1s ease-in-out infinite;
}
svg .techSprite {
  filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.24));
  transform-box: fill-box;
  transform-origin: center center;
  animation: techHum 3.4s ease-in-out infinite;
}
svg .techSpriteEnemy {
  filter: drop-shadow(0 6px 8px rgba(95, 58, 156, 0.24));
  animation: techBrood 2.8s ease-in-out infinite;
}
svg .unitCountBadge,
svg .travelCountBadge,
svg .fortCountBadge {
  fill: rgba(255, 255, 255, 0.94);
  stroke: rgba(87, 198, 255, 0.82);
  stroke-width: 1.6;
}
svg .unitCountBadgeEnemy,
svg .travelCountBadgeEnemy,
svg .fortCountBadgeEnemy {
  stroke: rgba(155, 94, 255, 0.84);
}
svg .unitCountText,
svg .travelCountText,
svg .fortCountText {
  fill: #3a4660;
  font-size: 9px;
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: middle;
}
svg .unitRoleBadge {
  fill: rgba(255,255,255,0.96);
  stroke: rgba(87,198,255,0.82);
  stroke-width: 1.4;
}
svg .unitRoleBadgeEnemy {
  stroke: rgba(155,94,255,0.82);
}
svg .unitRoleText {
  fill: #42516b;
  font-size: 7px;
  font-weight: 800;
  text-anchor: middle;
  dominant-baseline: middle;
}
svg .creepAura {
  fill: rgba(196, 114, 255, 0.22);
  stroke: rgba(165, 101, 255, 0.52);
  stroke-width: 1.5;
  filter: drop-shadow(0 0 14px rgba(165, 101, 255, 0.22));
  animation: creepPulse 2.4s ease-in-out infinite;
}
svg .zoneCreep { font-size: 11px; fill: rgba(156, 96, 255, 0.92); letter-spacing: 0.04em; }
@keyframes creepPulse {
  0%, 100% { opacity: 0.42; }
  50% { opacity: 0.84; }
}
@keyframes terranIdle {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-1.8px) scale(1.03); }
}
@keyframes zergIdle {
  0%, 100% { transform: translateY(0) scale(1); }
  35% { transform: translate(-0.8px, -1.5px) rotate(-2deg) scale(1.04); }
  65% { transform: translate(0.8px, -0.5px) rotate(2deg) scale(0.98); }
}
@keyframes terranGlide {
  0%, 100% { transform: translateY(0) rotate(0deg) scale(1); }
  40% { transform: translateY(-2px) rotate(-2deg) scale(1.04); }
  70% { transform: translateY(1px) rotate(1deg) scale(0.99); }
}
@keyframes zergDash {
  0%, 100% { transform: translate(0, 0) scale(1); }
  30% { transform: translate(-1.2px, -1.5px) rotate(-3deg) scale(1.05); }
  60% { transform: translate(1.2px, 0.8px) rotate(2deg) scale(0.98); }
}
@keyframes terranBaseHum {
  0%, 100% { transform: translateY(0) scale(1); filter: drop-shadow(0 10px 14px rgba(0, 0, 0, 0.32)); }
  50% { transform: translateY(-1px) scale(1.02); filter: drop-shadow(0 12px 16px rgba(49, 209, 255, 0.18)); }
}
@keyframes zergBaseThrob {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 8px 12px rgba(95, 58, 156, 0.24)); }
  50% { transform: scale(1.04); filter: drop-shadow(0 10px 14px rgba(184, 91, 255, 0.26)); }
}
@keyframes bunkerScan {
  0%, 100% { transform: translateY(0); }
  45% { transform: translateY(-1px) rotate(-1deg); }
  70% { transform: translateY(0.4px) rotate(1deg); }
}
@keyframes spinePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}
@keyframes techHum {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-1px) scale(1.03); }
}
@keyframes techBrood {
  0%, 100% { transform: scale(1); }
  35% { transform: translateY(-1px) scale(1.02); }
  65% { transform: translateY(0.5px) scale(1.05); }
}
@keyframes travelDotPulse {
  0%, 100% { opacity: 0.72; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.08); }
}
@keyframes baseAuraPulse {
  0%, 100% { opacity: 0.3; transform: scaleX(1) scaleY(1); }
  50% { opacity: 0.55; transform: scaleX(1.08) scaleY(1.16); }
}
@keyframes combatPulse {
  0% { opacity: 0.75; transform: scale(0.65); }
  100% { opacity: 0; transform: scale(1.7); }
}
@keyframes combatSpark {
  0%, 100% { opacity: 0.4; transform: scale(0.95) rotate(0deg); }
  50% { opacity: 0.95; transform: scale(1.08) rotate(-2deg); }
}
svg .targetGlow { fill: rgba(86,199,255,0.14); stroke: rgba(86,199,255,0.8); stroke-width: 2; }
svg .scoutGlow { fill: rgba(155,94,255,0.12); stroke: rgba(155,94,255,0.7); stroke-width: 2; }
svg .baseBarBg { fill: rgba(255,255,255,0.38); }
svg .baseBarPlayer { fill: var(--player); }
svg .baseBarEnemy { fill: var(--enemy); }
svg .travelDot {
  filter: drop-shadow(0 0 8px rgba(110, 139, 188, 0.18));
  transform-box: fill-box;
  transform-origin: center center;
  animation: travelDotPulse 1s ease-in-out infinite;
}
svg .baseAura {
  fill: rgba(92, 212, 255, 0.2);
  stroke: rgba(92, 212, 255, 0.34);
  stroke-width: 1.5;
  filter: drop-shadow(0 0 12px rgba(92, 212, 255, 0.18));
  transform-box: fill-box;
  transform-origin: center center;
  animation: baseAuraPulse 3.8s ease-in-out infinite;
}
svg .baseAuraEnemy {
  fill: rgba(184, 91, 255, 0.18);
  stroke: rgba(184, 91, 255, 0.34);
  filter: drop-shadow(0 0 12px rgba(184, 91, 255, 0.18));
  animation-duration: 2.8s;
}
svg .combatPulse {
  fill: rgba(255, 201, 105, 0.2);
  stroke: rgba(255, 151, 66, 0.8);
  stroke-width: 1.8;
  transform-box: fill-box;
  transform-origin: center center;
  animation: combatPulse 1.1s ease-out infinite;
}
svg .combatPulseAlt {
  fill: rgba(255, 238, 186, 0.18);
  stroke: rgba(255, 232, 160, 0.9);
  animation-delay: 0.32s;
}
svg .combatSpark {
  fill: rgba(255, 230, 174, 0.88);
  stroke: rgba(255, 128, 64, 0.96);
  stroke-width: 1.2;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 7px rgba(255, 146, 77, 0.3));
  transform-box: fill-box;
  transform-origin: center center;
  animation: combatSpark 0.72s ease-in-out infinite;
}
svg .travelLabel { fill: #30405a; font-size: 12px; font-weight: 700; text-anchor: middle; dominant-baseline: middle; }
svg .glyphText {
  fill: #2b3752;
  font-size: 10px;
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: middle;
  paint-order: stroke;
  stroke: rgba(255,255,255,0.88);
  stroke-width: 2px;
}

@media (max-width: 1280px) {
  .hero {
    grid-template-columns: 1fr;
  }
  .hero-side {
    min-width: 100%;
  }
  .sidebar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-areas:
      "coach coach"
      "intel log";
  }
  .intel-panel .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 1160px) {
  .hero-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .sidebar {
    grid-template-columns: 1fr;
    grid-template-areas:
      "coach"
      "intel"
      "log";
  }
  .intel-panel .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 920px) {
  .hero { align-items: stretch; }
  .hero-side { min-width: 100%; }
  .hero-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .menu-grid { grid-template-columns: 1fr; }
  .skin-grid { grid-template-columns: 1fr; }
  .recap-list { grid-template-columns: 1fr; }
  .quick-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .setting-card { align-items: stretch; flex-direction: column; }
  .segmented { justify-content: flex-start; }
}
@media (max-width: 760px) {
  .shell { padding: 12px; }
  .hero { gap: 16px; margin-bottom: 16px; }
  .hero h1,
  .battle-toolbar h2,
  .panel-head h3,
  .modal h2 {
    font-size: clamp(1.2rem, 5vw, 1.7rem);
  }
  .subcopy,
  .modal-copy,
  .menu-copy,
  .setting-note,
  .menu-note,
  .footer-box p,
  .impact-card p {
    font-size: 0.92rem;
  }
  .hero-stats,
  .metric-grid,
  .intel-panel .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .quick-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .battle-footer,
  .coach-form {
    grid-template-columns: 1fr;
  }
  .metric.wide { grid-column: span 2; }
  .toolbar-actions,
  .menu-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .header-actions {
    flex-direction: row;
    align-items: stretch;
    justify-content: stretch;
  }
  .header-actions > * {
    flex: 1 1 0;
  }
  .battle-panel,
  .panel,
  .modal {
    padding: 14px;
    border-radius: 12px;
  }
  .battle-panel {
    border-radius: 0;
  }
  .sidebar {
    padding: 10px;
    border-radius: 0 0 14px 14px;
  }
  .battle-toolbar,
  .panel-head,
  .modal-head {
    gap: 10px;
    align-items: flex-start;
  }
  .toolbar-actions {
    width: 100%;
  }
  .toolbar-actions label {
    flex: 1 1 auto;
  }
  .status-pill {
    min-width: 0;
    width: 100%;
  }
  .battle-stage {
    min-height: clamp(280px, 66vw, 400px);
    border-radius: 18px;
  }
  .action-toast {
    left: 12px;
    right: 12px;
    top: 12px;
    max-width: none;
    padding: 12px 14px;
    font-size: 0.92rem;
  }
  .chip,
  .metric,
  .status-pill,
  .menu-card,
  .setting-card,
  .footer-box,
  .stack li {
    padding: 12px;
    border-radius: 8px;
  }
  .quick,
  .primary,
  .secondary,
  .ghost,
  .seg-btn,
  .skin-option,
  select,
  input {
    min-height: 46px;
  }
  .overlay {
    place-items: start center;
    padding: 10px;
  }
  .modal {
    width: min(100%, calc(100vw - 20px));
    max-height: calc(100dvh - 20px);
    margin-top: env(safe-area-inset-top, 0);
    margin-bottom: env(safe-area-inset-bottom, 0);
  }
  .segmented {
    width: 100%;
    justify-content: stretch;
  }
  .segmented > * {
    flex: 1 1 0;
  }
  .skin-option {
    min-height: 92px;
  }
}

@media (max-width: 480px) {
  .hero-stats,
  .quick-grid,
  .metric-grid,
  .intel-panel .metric-grid {
    grid-template-columns: 1fr;
  }
  .metric.wide {
    grid-column: span 1;
  }
  .battle-stage {
    min-height: clamp(220px, 64vw, 310px);
  }
  .menu-points {
    padding-left: 16px;
  }
}
