/* battle.css — playable battle HUD, CoH3-inspired war-film skin:
   smoked charcoal glass, brass/amber command accents, slab-serif display
   type, warm golden-hour grade over the battlefield canvas.
   Layout, selectors, and media queries match the pre-restyle structure so
   ui.js / input.js / main.js need no changes. */
:root {
  color-scheme: dark;
  --bg: #171209;
  --panel: #211913;
  --panel-2: #2b2117;
  --line: rgba(233, 214, 171, .17);
  --line-strong: rgba(233, 214, 171, .34);
  --text: #f0e7d2;
  --muted: #c2b294;
  --soft: #8f8166;
  --blue: #57a8ff;
  --green: #8ec573;
  --amber: #e0a44b;
  --red: #ff6a56;
  --brass: #c99b4e;
  --armor: #d8c481;
  --inf: #a8d58e;
  --rec: #82c6ff;
  --air: #c0b0f2;
  --aa: #7fd8c4;
  --arty: #e0a86d;
  --shadow: 0 20px 54px rgba(0, 0, 0, .5);
  --display: "Rockwell", "Roboto Slab", "Palatino", "Iowan Old Style", Georgia, serif;
  font-family: "Avenir Next", "Segoe UI", ui-sans-serif, system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
body { margin: 0; background: #120d06; color: var(--text); }
h1, h2, h3, h4, p { margin: 0; }
button { font: inherit; color: var(--text); border: 1px solid var(--line); border-radius: 4px; padding: 4px 9px; background: linear-gradient(180deg, rgba(240, 220, 180, .09), rgba(240, 220, 180, .04)); cursor: pointer; min-height: 28px; }
button:hover:not([disabled]) { background: linear-gradient(180deg, rgba(240, 220, 180, .16), rgba(240, 220, 180, .08)); border-color: var(--line-strong); }
button.primary { background: linear-gradient(180deg, #d8ab5c, #b18138); border-color: #e8c98c; color: #241a0b; font-weight: 800; text-shadow: 0 1px 0 rgba(255, 236, 190, .4); }
button.primary:hover:not([disabled]) { background: linear-gradient(180deg, #e5b968, #bd8c40); }
button.warning { border-color: rgba(224, 164, 75, .6); background: rgba(224, 164, 75, .15); color: #ffdda6; }
button.active { border-color: var(--brass); background: rgba(201, 155, 78, .24); color: #ffe9c2; }
button[disabled] { opacity: .45; cursor: not-allowed; }
a { color: var(--amber); }

.app { position: fixed; inset: 0; display: grid; grid-template-rows: auto minmax(0, 1fr); }

/* ---- top strip (single slim row) ---- */
.topbar { position: relative; display: flex; gap: 12px; align-items: center; padding: 5px 12px; height: 42px; background: linear-gradient(180deg, rgba(26, 19, 11, .98), rgba(19, 14, 8, .96)); border-bottom: 1px solid rgba(201, 155, 78, .35); box-shadow: 0 1px 0 rgba(0, 0, 0, .6); z-index: 40; }
.topbar .title { font-family: var(--display); font-size: .82rem; font-weight: 700; letter-spacing: .04em; color: #ffe9c2; white-space: nowrap; }
.topbar .title small { display: block; font-family: "Avenir Next", "Segoe UI", sans-serif; color: var(--soft); font-size: .56rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; line-height: 1.2; }
.chip { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--line); border-radius: 3px; padding: 2px 10px; font-size: .72rem; font-weight: 800; background: rgba(240, 220, 180, .05); white-space: nowrap; position: relative; }
.chip.phase { border-color: rgba(201, 155, 78, .55); color: #ffe9c2; letter-spacing: .04em; }
#hud-warnbar { display: none; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 2px; background: var(--amber); border-radius: 2px; }
.chip.clock { font-variant-numeric: tabular-nums; }
.chip.req { border-color: rgba(224, 164, 75, .5); color: #ffe9c2; }
.chip.req::before { content: '⬢'; color: var(--amber); }
.chip.perf { color: var(--soft); font-size: .62rem; font-weight: 700; font-variant-numeric: tabular-nums; opacity: .85; }
.chip.perf::before { content: '▮'; color: var(--soft); margin-right: 2px; }
.chip.perf.warn { border-color: rgba(255, 106, 86, .55); color: #ffb3a6; }
.scorewrap { display: flex; flex-direction: column; gap: 2px; min-width: 170px; }
.scorerow { display: grid; grid-template-columns: 34px 1fr 38px; gap: 6px; align-items: center; font-size: .6rem; font-weight: 800; letter-spacing: .05em; }
.scorerow .bar { height: 6px; border-radius: 2px; background: rgba(0, 0, 0, .45); overflow: hidden; border: 1px solid var(--line); }
.scorerow .bar i { display: block; height: 100%; }
.scorerow.player .bar i { background: linear-gradient(180deg, #79bcff, #3d8de2); }
.scorerow.enemy .bar i { background: linear-gradient(180deg, #ff8a76, #dd4c38); }
.scorerow .num { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.sysbtns { display: flex; gap: 6px; align-items: center; margin-left: auto; }
.sysbtns button { min-width: 34px; }
.save-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--soft); }
.save-dot.ok { background: var(--green); }
#menu-drop { display: none; position: absolute; top: 44px; right: 8px; background: var(--panel); border: 1px solid var(--line-strong); border-radius: 6px; padding: 6px; box-shadow: var(--shadow); z-index: 60; min-width: 150px; }
#menu-drop button { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 7px 10px; border-radius: 4px; }
#menu-drop button:hover { background: rgba(240, 220, 180, .1); }

/* ---- battlefield ---- */
.field { position: relative; overflow: hidden; background: #221b11; }
canvas.map { position: absolute; inset: 0; display: block; cursor: crosshair; touch-action: none; }

/* cinematic grade: warm sun wash + vignette + top haze, zero per-frame cost */
#cine-grade { position: absolute; inset: 0; z-index: 5; pointer-events: none;
  background:
    linear-gradient(180deg, rgba(255, 208, 138, .10), rgba(255, 208, 138, .02) 30%, transparent 45%),
    linear-gradient(0deg, rgba(24, 14, 5, .22), transparent 26%),
    radial-gradient(115% 95% at 50% 42%, transparent 52%, rgba(18, 10, 3, .42) 100%); }

.overlay-ui { position: absolute; z-index: 20; }

/* recovery / warning strip */
#recovery-strip { display: none; top: 10px; left: 50%; transform: translateX(-50%); background: rgba(255, 106, 86, .14); border: 1px solid rgba(255, 106, 86, .6); color: #ffb3a6; font-weight: 800; font-size: .74rem; letter-spacing: .05em; border-radius: 3px; padding: 4px 16px; pointer-events: none; }

/* unified banner — newsreel card */
#banner { display: none; top: 22%; left: 50%; transform: translate(-50%, -50%); background: rgba(23, 17, 10, .95); border: 1px solid rgba(201, 155, 78, .5); border-radius: 6px; padding: 16px 30px; text-align: center; box-shadow: var(--shadow); max-width: 520px; z-index: 45; pointer-events: none; }
#banner .eyebrow { color: var(--amber); font-size: .62rem; letter-spacing: .22em; text-transform: uppercase; font-weight: 900; }
#banner h2 { font-family: var(--display); color: #ffe9c2; font-size: 1.35rem; letter-spacing: .03em; margin: 5px 0 4px; }
#banner p { color: var(--muted); font-size: .74rem; }

/* ---- objectives rail (thin, right edge) ---- */
#objectives { top: 10px; right: 10px; width: 64px; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; }
.cp-pip { display: flex; flex-direction: column; align-items: center; gap: 1px; background: rgba(23, 17, 10, .88); border: 1px solid var(--line); border-radius: 5px; padding: 5px 4px; width: 100%; pointer-events: none; }
.cp-pip .diamond { width: 13px; height: 13px; transform: rotate(45deg); background: rgba(240, 220, 180, .22); border: 1.5px solid var(--line-strong); border-radius: 2px; }
.cp-pip.own .diamond { background: var(--blue); border-color: var(--blue); }
.cp-pip.foe .diamond { background: var(--red); border-color: var(--red); }
.cp-pip.contested .diamond { animation: pulse 1s infinite alternate; border-color: var(--amber); }
@keyframes pulse { from { box-shadow: 0 0 0 0 rgba(224, 164, 75, .6); } to { box-shadow: 0 0 0 5px rgba(224, 164, 75, 0); } }
.cp-pip .pip-id { font-size: .56rem; font-weight: 800; color: var(--muted); margin-top: 3px; }
.event-chip { background: rgba(224, 164, 75, .12); border: 1px solid rgba(224, 164, 75, .55); color: #ffe9c2; font-size: .56rem; font-weight: 800; border-radius: 5px; padding: 5px; text-align: center; width: 100%; line-height: 1.3; pointer-events: none; }
.event-chip small { color: var(--amber); font-weight: 700; }
.reward-chip { background: rgba(142, 197, 115, .12); border: 1px solid rgba(142, 197, 115, .5); color: #d2e8c2; font-size: .6rem; font-weight: 800; border-radius: 5px; padding: 3px 5px; width: 100%; text-align: center; pointer-events: none; }
.reward-chip.foe { background: rgba(255, 106, 86, .12); border-color: rgba(255, 106, 86, .5); color: #ffb3a6; }

/* ---- toasts + log ---- */
#toasts { top: 10px; right: 84px; width: 300px; display: flex; flex-direction: column; gap: 5px; pointer-events: none; }
.toast { background: rgba(23, 17, 10, .92); border: 1px solid var(--line); border-left: 3px solid var(--soft); border-radius: 4px; padding: 6px 9px; font-size: .66rem; color: var(--muted); line-height: 1.35; transition: opacity .5s; pointer-events: none; }
.toast b { color: var(--text); font-variant-numeric: tabular-nums; margin-right: 4px; }
.toast.alert { border-left-color: var(--amber); color: #ffdda6; }
.toast.bad { border-left-color: var(--red); color: #ffb3a6; }
.toast.good { border-left-color: var(--green); color: #d2e8c2; }
.toast.fade { opacity: 0; }
#btn-log { position: absolute; top: 10px; right: 84px; z-index: 21; min-height: 24px; font-size: .62rem; padding: 2px 8px; opacity: .8; }
#logdrawer { display: none; top: 44px; right: 84px; width: 340px; max-height: 46vh; overflow-y: auto; background: rgba(23, 17, 10, .95); border: 1px solid var(--line); border-radius: 6px; padding: 9px; }
#logdrawer h3 { font-size: .64rem; letter-spacing: .12em; text-transform: uppercase; color: var(--brass); margin-bottom: 5px; }
#logdrawer .report { font-size: .64rem; padding: 3px 2px; border-bottom: 1px solid rgba(240, 220, 180, .06); color: var(--muted); }
#logdrawer .report b { color: var(--text); margin-right: 4px; font-variant-numeric: tabular-nums; }
#logdrawer .report.alert { color: #ffdda6; }
#logdrawer .report.bad { color: #ffb3a6; }
#logdrawer .report.good { color: #d2e8c2; }

/* ---- deck bar (bottom center) ---- */
#deckbar { bottom: 10px; left: 50%; transform: translateX(-50%); width: min(760px, calc(100% - 620px)); min-width: 430px; background: rgba(23, 17, 10, .93); border: 1px solid var(--line); border-top-color: rgba(201, 155, 78, .4); border-radius: 7px; padding: 7px 9px; box-shadow: 0 10px 30px rgba(0, 0, 0, .45); }
#deckbar.collapsed { width: auto; min-width: 0; }
#deckbar .headrow { display: flex; align-items: center; gap: 8px; }
#deck-head-label { flex: 1; font-size: .62rem; letter-spacing: .1em; text-transform: uppercase; color: var(--brass); font-weight: 800; }
#deck-actions { display: flex; gap: 6px; }
#deck-actions button { min-height: 25px; font-size: .66rem; font-weight: 800; }
#deck-cards { display: flex; gap: 6px; margin-top: 7px; overflow-x: auto; padding-bottom: 2px; }
.deckcard { position: relative; flex: 0 0 108px; border: 1px solid var(--line); border-radius: 5px; background: linear-gradient(180deg, var(--panel-2), var(--panel)); cursor: pointer; padding: 5px 6px 5px 9px; font-size: .6rem; }
.deckcard:hover { border-color: var(--line-strong); }
.deckcard .tint { position: absolute; left: 0; top: 0; bottom: 0; width: 4px; border-radius: 5px 0 0 5px; }
.deckcard .thumb { display: block; height: 26px; margin: 1px auto 2px; image-rendering: auto; }
.deckcard .postglyph { display: block; text-align: center; font-size: 1.2rem; height: 26px; color: var(--brass); }
.deckcard .nm { display: block; font-weight: 800; color: #fff4dd; font-size: .62rem; line-height: 1.15; min-height: 2.2em; }
.deckcard .cost { color: var(--muted); font-variant-numeric: tabular-nums; }
.deckcard .lock { display: block; color: var(--amber); font-size: .54rem; line-height: 1.2; margin-top: 2px; }
.deckcard.locked { opacity: .55; }
.deckcard.wonder { border-color: rgba(216, 196, 129, .6); background: linear-gradient(180deg, rgba(216, 196, 129, .12), rgba(216, 196, 129, .04)); }
.deckcard.placed { outline: 2px solid rgba(142, 197, 115, .55); }
.deckcard.selected { outline: 2px solid var(--amber); }
.deck-empty { color: var(--soft); font-size: .68rem; padding: 8px; }
#btn-hq { position: absolute; left: -46px; bottom: 0; min-width: 38px; min-height: 38px; font-size: 1rem; }
#deck-toggle { min-width: 26px; min-height: 22px; padding: 0 6px; font-size: .7rem; }

/* ---- HQ flyout ---- */
#hqflyout { display: none; bottom: 64px; left: 50%; transform: translateX(-50%); width: 420px; background: rgba(23, 17, 10, .96); border: 1px solid var(--line-strong); border-radius: 7px; padding: 10px; box-shadow: var(--shadow); z-index: 30; }
#hqflyout h3 { font-size: .64rem; letter-spacing: .12em; text-transform: uppercase; color: var(--brass); margin-bottom: 6px; }
.post { display: grid; grid-template-columns: 1fr auto auto; gap: 3px 8px; align-items: center; border-bottom: 1px solid rgba(240, 220, 180, .07); padding: 5px 2px; }
.post .nm { font-size: .7rem; font-weight: 800; }
.post .st { font-size: .58rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; }
.post .st.built { color: var(--green); }
.post .st.building { color: var(--blue); }
.post .st.locked { color: var(--soft); }
.post .st.available { color: var(--amber); }
.post .st.damaged, .post .st.interrupted, .post .st.destroyed { color: var(--red); }
.post .meta { grid-column: 1 / -1; font-size: .58rem; color: var(--muted); }
.post .prog { grid-column: 1 / -1; height: 4px; border-radius: 2px; background: rgba(0, 0, 0, .45); overflow: hidden; }
.post .prog i { display: block; height: 100%; background: var(--blue); }
.post button { min-height: 22px; padding: 1px 8px; font-size: .6rem; font-weight: 800; }

/* ---- unit panel (bottom left, contextual) ---- */
#unitpanel { display: none; bottom: 10px; left: 10px; width: 285px; background: rgba(23, 17, 10, .93); border: 1px solid var(--line); border-top-color: rgba(201, 155, 78, .4); border-radius: 7px; padding: 9px; box-shadow: 0 10px 30px rgba(0, 0, 0, .45); }
.unit-head { display: flex; gap: 8px; align-items: center; }
.portrait { width: 52px; height: 38px; background: linear-gradient(180deg, #33271a, #241b10); border: 1px solid var(--line); border-radius: 4px; display: grid; place-items: center; }
.portrait .thumb { max-width: 46px; max-height: 32px; }
.unitname { font-family: var(--display); font-size: .8rem; font-weight: 700; color: #ffe9c2; }
.unitname small { color: var(--soft); font-weight: 600; font-family: "Avenir Next", "Segoe UI", sans-serif; }
.pills { display: flex; gap: 4px; margin-top: 3px; flex-wrap: wrap; }
.pill { font-size: .56rem; font-weight: 800; border: 1px solid var(--line); border-radius: 999px; padding: 1px 7px; color: var(--muted); }
.pill.sup-normal { color: var(--green); border-color: rgba(142, 197, 115, .4); }
.pill.sup-pressured { color: var(--amber); border-color: rgba(224, 164, 75, .4); }
.pill.sup-suppressed, .pill.sup-shaken { color: #f0a35e; border-color: rgba(224, 140, 93, .4); }
.pill.sup-pinned { color: var(--red); border-color: rgba(255, 106, 86, .5); }
.pill.mounted { color: var(--rec); }
.hpbar { height: 6px; border-radius: 3px; background: rgba(0, 0, 0, .45); overflow: hidden; margin: 7px 0 4px; border: 1px solid var(--line); }
.hpbar i { display: block; height: 100%; }
.statline { font-size: .62rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.unitrole { font-size: .6rem; color: var(--soft); margin-top: 4px; line-height: 1.35; max-height: 3.9em; overflow: hidden; }
.orderbtns { display: flex; gap: 4px; margin-top: 7px; }
.orderbtns button { min-width: 34px; min-height: 30px; font-size: .85rem; padding: 2px; }
.pendinghint { font-size: .6rem; color: var(--amber); margin-top: 4px; min-height: 12px; }

/* ---- AI spectator panel (draggable overlay) ---- */
#ai-panel { display: none; top: 52px; left: 10px; width: 330px; max-height: calc(100% - 130px); overflow-y: auto; background: rgba(23, 17, 10, .95); border: 1px solid var(--line-strong); border-radius: 7px; padding: 0 10px 10px; box-shadow: var(--shadow); z-index: 32; }
.ai-head { display: flex; justify-content: space-between; align-items: center; margin: 0 -10px; padding: 7px 10px; cursor: grab; border-bottom: 1px solid var(--line); background: rgba(201, 155, 78, .1); position: sticky; top: 0; z-index: 1; }
.ai-head:active { cursor: grabbing; }
.ai-head span { font-size: .66rem; letter-spacing: .12em; text-transform: uppercase; font-weight: 900; color: var(--brass); }
.ai-head button { min-height: 20px; min-width: 22px; padding: 0 5px; font-size: .68rem; }
#ai-panel h4 { font-size: .6rem; letter-spacing: .1em; text-transform: uppercase; color: var(--brass); margin: 9px 0 4px; }
.ai-chips { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 8px; }
.ai-chip { font-size: .56rem; font-weight: 800; border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px; color: var(--soft); }
.ai-chip.cur { color: #ffe9c2; border-color: var(--brass); background: rgba(201, 155, 78, .18); }
.ai-why { margin-top: 8px; border: 1px solid var(--line); border-radius: 5px; padding: 7px 8px; background: rgba(240, 220, 180, .04); }
.ai-reason { font-size: .62rem; color: var(--text); line-height: 1.4; margin-bottom: 5px; }
.ai-reason b { color: var(--soft); font-size: .56rem; text-transform: uppercase; letter-spacing: .05em; margin-right: 3px; }
.ai-tr { font-size: .6rem; padding: 2px 0 2px 8px; border-left: 2px solid var(--soft); margin: 4px 0; color: var(--muted); line-height: 1.35; }
.ai-tr b { margin-right: 5px; color: var(--muted); }
.ai-tr small { display: block; color: var(--soft); }
.ai-tr.met { border-left-color: var(--green); color: #d2e8c2; }
.ai-tr.met b { color: var(--green); }
.ai-logrow { font-size: .6rem; padding: 3px 2px; border-bottom: 1px solid rgba(240, 220, 180, .06); color: var(--muted); line-height: 1.3; }
.ai-logrow b { color: var(--text); margin-right: 4px; font-variant-numeric: tabular-nums; }
.ai-logrow small { display: block; color: var(--soft); }
.ai-logrow.state { color: #ffe9c2; }
.ai-logrow.deploy { color: #d2e8c2; }
.ai-logrow.build { color: #bcd8ff; }
.ai-logrow.fire { color: #ffdda6; }
.ai-unit { display: grid; grid-template-columns: 1fr 56px 76px 42px; gap: 6px; align-items: center; font-size: .58rem; padding: 2px 0; border-bottom: 1px solid rgba(240, 220, 180, .05); }
.ai-unit .nm { color: var(--text); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-unit .mi { color: var(--amber); font-weight: 800; }
.ai-unit .gl { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-unit .hp { height: 5px; border-radius: 3px; background: rgba(0, 0, 0, .45); overflow: hidden; }
.ai-unit .hp i { display: block; height: 100%; }
.ai-intel-head { cursor: pointer; user-select: none; }
.ai-intel-body { font-size: .6rem; color: var(--muted); line-height: 1.55; }
.ai-pill { margin-top: 7px; display: inline-block; font-size: .6rem; font-weight: 900; letter-spacing: .08em; border: 1px solid rgba(201, 155, 78, .55); color: #ffe9c2; border-radius: 999px; padding: 3px 10px; }
.ai-note { font-size: .6rem; color: var(--soft); font-weight: 700; align-self: center; }
.deckcard.readonly { cursor: default; }

/* ---- minimap ---- */
#minimap-wrap { bottom: 10px; right: 10px; background: rgba(23, 17, 10, .9); border: 1px solid rgba(201, 155, 78, .4); border-radius: 6px; padding: 5px; box-shadow: 0 10px 30px rgba(0, 0, 0, .45); }
#minimap { display: block; border-radius: 3px; cursor: pointer; touch-action: none; }

/* ---- help ---- */
#helpchip { top: 52px; left: 10px; font-size: .62rem; color: var(--soft); background: rgba(23, 17, 10, .88); border: 1px solid var(--line); border-radius: 5px; padding: 6px 10px; max-width: 330px; line-height: 1.45; pointer-events: none; }
#helpchip b { color: var(--muted); }

/* ---- modals + splash ---- */
.modal-back { position: fixed; inset: 0; background: rgba(8, 5, 2, .8); z-index: 70; display: none; align-items: center; justify-content: center; }
.modal { background: linear-gradient(180deg, #241b11, #1c150c); border: 1px solid rgba(201, 155, 78, .5); border-radius: 8px; padding: 26px 30px; max-width: 560px; width: calc(100% - 40px); box-shadow: var(--shadow); text-align: center; }
.modal h2 { font-family: var(--display); font-size: 1.8rem; letter-spacing: .06em; text-transform: uppercase; margin: 8px 0 6px; }
.modal h2.victory { color: var(--green); text-shadow: 0 0 24px rgba(142, 197, 115, .35); }
.modal h2.defeat { color: var(--red); text-shadow: 0 0 24px rgba(255, 106, 86, .3); }
.modal .eyebrow { color: var(--brass); font-size: .64rem; letter-spacing: .22em; text-transform: uppercase; font-weight: 900; }
.modal p { color: var(--muted); font-size: .8rem; line-height: 1.45; }
.modal .stats { display: flex; gap: 18px; justify-content: center; margin: 14px 0; font-size: .72rem; color: var(--muted); }
.modal .stats b { color: #ffe9c2; display: block; font-size: 1rem; font-variant-numeric: tabular-nums; }
.modal .btns { display: flex; gap: 8px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }
.modal .btns button { min-height: 38px; padding: 8px 16px; }
.modal .note { font-size: .6rem; color: var(--soft); margin-top: 10px; }

/* splash — golden-hour title card with letterbox bars */
.splash { position: fixed; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center; overflow-y: auto; background:
    radial-gradient(120% 80% at 50% 108%, rgba(214, 142, 62, .32), transparent 55%),
    radial-gradient(90% 60% at 72% 0%, rgba(120, 96, 60, .25), transparent 60%),
    linear-gradient(180deg, #241b10 0%, #1a1309 46%, #120d06 100%); }
.splash::before, .splash::after { content: ''; position: fixed; left: 0; right: 0; height: max(28px, 4vh); background: #060402; z-index: 1; }
.splash::before { top: 0; }
.splash::after { bottom: 0; }
.splash .inner { position: relative; z-index: 2; max-width: 640px; padding: 30px; text-align: center; }
.splash .eyebrow { color: var(--brass); font-weight: 800; letter-spacing: .24em; text-transform: uppercase; font-size: .68rem; }
.splash h1 { font-family: var(--display); color: #ffe9c2; font-size: clamp(1.7rem, 4.4vw, 2.7rem); letter-spacing: .08em; text-transform: uppercase; margin: 12px 0 4px; text-shadow: 0 2px 22px rgba(224, 164, 75, .25); }
.splash h1::after { content: ''; display: block; width: 120px; height: 2px; margin: 12px auto 0; background: linear-gradient(90deg, transparent, var(--brass), transparent); }
.splash p { color: var(--muted); font-size: .82rem; line-height: 1.55; }
.splash .planbox { text-align: left; margin: 16px auto; max-width: 500px; border: 1px solid var(--line); border-radius: 6px; padding: 12px 16px; background: rgba(240, 220, 180, .04); font-size: .74rem; color: var(--muted); }
.splash .planbox b { color: #ffe9c2; }
.splash textarea { width: 100%; min-height: 70px; margin-top: 8px; background: rgba(10, 7, 3, .86); color: var(--text); border: 1px solid var(--line); border-radius: 5px; padding: 8px; font-size: .68rem; resize: vertical; }
.splash .btns { display: flex; gap: 8px; justify-content: center; margin-top: 14px; flex-wrap: wrap; }
.splash .btns button { min-height: 42px; padding: 9px 18px; font-weight: 800; }
.splash .caveat { margin-top: 14px; font-size: .62rem; color: var(--soft); }

/* ---- mobile landscape: safe areas, compact HUD, touch targets ---- */
.topbar { padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }
#unitpanel { left: max(10px, env(safe-area-inset-left)); }
#minimap-wrap { right: max(10px, env(safe-area-inset-right)); }
#objectives { right: max(10px, env(safe-area-inset-right)); }

/* compact layout: phone landscape and short/narrow desktop windows */
@media (max-width: 1000px), (max-height: 500px) {
  .topbar { gap: 7px; }
  .topbar .title { display: none; }
  .chip { font-size: .62rem; padding: 2px 8px; }
  .chip.perf { display: none; }   /* diagnostic read-out yields topbar room on narrow layouts */
  .scorewrap { min-width: 118px; }
  #unitpanel { width: 210px; left: max(6px, env(safe-area-inset-left)); bottom: 6px; padding: 7px; }
  #unitpanel .unitrole { display: none; }
  #deckbar { left: 226px; right: 126px; transform: none; width: auto; min-width: 0; bottom: 6px; }
  #btn-hq { left: 0; top: -48px; bottom: auto; }
  #minimap-wrap { right: max(6px, env(safe-area-inset-right)); bottom: 6px; }
  #minimap { width: 108px; height: 108px; }
  #objectives { width: 50px; right: max(6px, env(safe-area-inset-right)); }
  .cp-pip .diamond { width: 11px; height: 11px; }
  #toasts { right: 64px; width: min(260px, 42vw); }
  #btn-log { right: 64px; }
  #logdrawer { right: 64px; width: min(340px, calc(100vw - 80px)); }
  #ai-panel { width: min(300px, calc(100vw - 140px)); }
  #hqflyout { width: min(420px, calc(100vw - 16px)); max-height: 62vh; overflow-y: auto; }
  #banner { max-width: min(520px, calc(100vw - 24px)); }
  #helpchip { max-width: min(330px, calc(100vw - 24px)); }
  #recovery-strip { max-width: calc(100vw - 24px); }
}

/* ---- touch control cluster (left edge, coarse-pointer devices only) ---- */
#touch-controls { display: none; left: max(6px, env(safe-area-inset-left)); top: 50%; transform: translateY(-50%); flex-direction: column; gap: 8px; }
#touch-controls button { min-width: 46px; min-height: 46px; font-size: 1.05rem; background: rgba(23, 17, 10, .88); }

/* touch targets: fingers need >=40px, key verbs 44px */
@media (pointer: coarse) {
  #touch-controls { display: flex; }
  .topbar { height: 48px; }
  .sysbtns button { min-width: 40px; min-height: 40px; }
  #menu-drop { top: 50px; }
  #menu-drop button { padding: 12px 14px; }
  .orderbtns button { min-width: 44px; min-height: 44px; font-size: 1rem; }
  #deck-actions button { min-height: 44px; }
  #deck-toggle { min-width: 40px; min-height: 40px; }
  .deckcard { flex: 0 0 116px; }
  .post button { min-height: 44px; }
  #btn-log { min-height: 40px; padding: 6px 12px; }
  #btn-hq { min-width: 44px; min-height: 44px; }
  .ai-head button { min-width: 36px; min-height: 36px; }
}

/* portrait-blocking overlay (phones only; desktop and tablets unaffected) */
#rotate-overlay { display: none; }
@media (orientation: portrait) and (pointer: coarse) and (max-width: 700px) {
  #rotate-overlay { display: flex; position: fixed; inset: 0; z-index: 100; background: #120d06;
    flex-direction: column; align-items: center; justify-content: center; gap: 10px; text-align: center; }
  #rotate-overlay .icon { font-size: 3rem; color: var(--amber); }
  #rotate-overlay p { color: var(--text); font-size: 1rem; }
  #rotate-overlay .sub { color: var(--muted); font-size: .8rem; }
}
