@import url("../engine/overlay/hud.css");
:root {
  --bg: #e9edf1; --ink: #14202c; --ink-dim: rgba(20, 32, 44, .62); --line: rgba(20, 32, 44, .2);
  --surface: #f7f9fb; --field: #ffffff; --accent: #1f5f8b;
  --scene: #2b3746;
  box-sizing: border-box;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f151c; --ink: #e6ebf0; --ink-dim: rgba(230, 235, 240, .62); --line: rgba(230, 235, 240, .18);
    --surface: #161e27; --field: #0f151c; --accent: #7fb7e0;
  }
}
:root[data-theme="dark"] {
  --bg: #0f151c; --ink: #e6ebf0; --ink-dim: rgba(230, 235, 240, .62); --line: rgba(230, 235, 240, .18);
  --surface: #161e27; --field: #0f151c; --accent: #7fb7e0;
}
*, *::before, *::after { box-sizing: inherit; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; }

/* ---------- layout: battle beside the panel, stacked on phones ---------- */
.app { display: grid; gap: 12px; padding: 12px 16px 24px; max-width: 1500px; margin: 0 auto;
  grid-template-columns: minmax(0, 1fr); grid-template-areas: "top" "view" "panel"; }
@media (min-width: 960px) { .app { grid-template-columns: minmax(0, 1fr) 330px; grid-template-areas: "top top" "view panel"; align-items: start; } }
.top { grid-area: top; display: flex; align-items: baseline; gap: 14px; }
.top h1 { margin: 0; font-size: 20px; font-weight: 600; }
.home { color: var(--ink-dim); font-size: 14px; text-decoration: none; }
.home:hover { color: var(--ink); text-decoration: underline; }
.viewport { grid-area: view; position: relative; background: var(--scene); border-radius: 6px; overflow: hidden;
  height: min(62vh, 560px); min-height: 360px; }
@media (min-width: 960px) { .viewport { height: min(78vh, 760px); position: sticky; top: 12px; } }
#scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#scene:active { cursor: grabbing; }

/* ---------- embedded: the battle only ---------- */
body.embedded .app { padding: 0; display: block; max-width: none; }
body.embedded .top, body.embedded .panel { display: none; }
body.embedded .viewport { height: 100vh; min-height: 0; border-radius: 0; position: relative; top: 0; }

/* ---------- the panel ---------- */
.panel { grid-area: panel; display: grid; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 12px; }
.panel fieldset { border: 0; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; }
.panel legend { font-weight: 600; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-dim); margin-bottom: 4px; padding: 0; }
.panel label { display: grid; gap: 2px; font-size: 13px; color: var(--ink-dim); min-width: 0; }
.panel label.wide, .panel .wide { grid-column: 1 / -1; }
.panel label.check { display: flex; align-items: center; gap: 6px; color: var(--ink); }
.panel .models { display: flex; gap: 14px; flex-wrap: wrap; }
.panel .models label { display: flex; align-items: center; gap: 5px; color: var(--ink); font-size: 14px; }
.panel [hidden] { display: none !important; }
.panel select, .panel input[type="number"], .panel textarea {
  font: inherit; font-size: 14px; color: var(--ink); background: var(--field); border: 1px solid var(--line); border-radius: 4px; padding: 6px 8px; min-width: 0; width: 100%; }
.panel textarea { font: 12px/1.35 ui-monospace, Menlo, monospace; resize: vertical; }
.panel .seed { grid-template-columns: 1fr auto; }
.panel .view { grid-template-columns: 1fr; }
.panel button { font: inherit; font-size: 14px; color: var(--ink); background: var(--field); border: 1px solid var(--line); border-radius: 4px; padding: 8px 14px; cursor: pointer; }
.panel button:hover { border-color: var(--ink-dim); }
.panel button.primary { background: var(--accent); color: var(--surface); border-color: var(--accent); font-weight: 600; }
.panel .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.panel .note { margin: 0; font-size: 13px; color: var(--ink-dim); }
.panel .fight-plan { margin: 0; font-size: 13px; line-height: 1.45; padding: 8px 10px; border-left: 3px solid var(--accent); background: var(--field); border-radius: 0 4px 4px 0; }
.panel input:disabled { opacity: .6; }
.panel .warn { margin: 0; font-size: 13px; color: #b0462a; }
.map-picker { display: grid; gap: 6px; }
.mp-frame { position: relative; line-height: 0; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; background: #000; }
.mp-image { width: 100%; height: auto; image-rendering: pixelated; }
.mp-overlay { position: absolute; inset: 0; width: 100%; height: 100%; cursor: crosshair; }
.mp-near { fill: rgba(255, 255, 255, .12); stroke: rgba(255, 255, 255, .55); stroke-width: .8; }
.mp-att, .mp-def { fill: none; stroke-width: 2.2; }
.mp-att { stroke: #fff; }
.mp-def { stroke: #ffd24a; stroke-dasharray: 3 2; }
.mp-help { margin: 0; font-size: 12px; color: var(--ink-dim); }
.panel .spec summary { cursor: pointer; font-size: 13px; color: var(--ink-dim); }
.panel button:focus-visible, .panel select:focus-visible, .panel input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.panel .share { display: grid; gap: 8px; }
.panel .share summary { cursor: pointer; }
