/* Fonts built into the game (art/fonts; SIL Open Font License and Apache 2.0, licences beside them). */
@font-face { font-family: "Saira Stencil One"; src: url("art/fonts/saira-stencil-one.woff") format("woff"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Barlow Condensed"; src: url("art/fonts/barlow-condensed-500.woff") format("woff"); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: "Barlow Condensed"; src: url("art/fonts/barlow-condensed-600.woff") format("woff"); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: "Barlow Condensed"; src: url("art/fonts/barlow-condensed-700.woff") format("woff"); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: "Barlow"; src: url("art/fonts/barlow-400.woff") format("woff"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Barlow"; src: url("art/fonts/barlow-500.woff") format("woff"); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: "Barlow"; src: url("art/fonts/barlow-600.woff") format("woff"); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: "Special Elite"; src: url("art/fonts/special-elite.woff") format("woff"); font-weight: 400; font-style: normal; font-display: swap; }

/* Breakthrough. A staff officer's kit: olive-drab chrome, stencilled titles, signal-amber for "act now". */
:root {
  --bg: #1d2118; --panel: #292e21; --panel2: #333a29; --line: #485036; --ink: #ece7d2; --muted: #a8a78b;
  --accent: #e0b13a; --accent-ink: #231d08; --danger: #de6a4f; --ok: #9cbb72; --paper: #d8cfb2;
  --display: "Saira Stencil One", "Arial Black", Impact, sans-serif;
  --ui: "Barlow Condensed", "Arial Narrow", system-ui, sans-serif;
  --body: "Barlow", system-ui, sans-serif;
  /* the kit's lobby and chat */
  --kit-bg: var(--panel); --kit-ink: var(--ink); --kit-muted: var(--muted); --kit-line: var(--line); --kit-accent: var(--accent);
  --kit-p0: #4f7bd0; --kit-p1: #7d8a92; --kit-p2: #c8443a; --kit-p3: #c9a23a;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 16px/1.5 var(--body); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; font-weight: 400; }
button, input, select { font: 600 16px/1.2 var(--ui); color: var(--ink); background: var(--panel2); border: 1px solid var(--line); border-radius: 4px; padding: 9px 14px; letter-spacing: .02em; }
button { cursor: pointer; }
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: .45; cursor: default; }
button:focus-visible, input:focus-visible, select:focus-visible, .map-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.primary:hover:not(:disabled) { background: #f0c450; }
.big { font-size: 20px; padding: 12px 22px; }
.quiet { background: transparent; border-color: transparent; color: var(--muted); }
.quiet:hover { color: var(--ink); }
.error { color: var(--danger); min-height: 1.5em; margin: 6px 0 0; font-family: var(--ui); font-size: 17px; }
.error.toast { position: absolute; z-index: 7; top: 10px; left: 50%; transform: translateX(-50%); max-width: calc(100% - 24px); min-height: 0; margin: 0;
  padding: 6px 14px; background: #15180f; border: 1px solid var(--danger); border-radius: 4px; box-shadow: 0 6px 16px rgba(0,0,0,.45); pointer-events: none; text-align: center; }
.error.toast:empty { display: none; }
.muted { color: var(--muted); }
.stencil { font-family: var(--display); font-size: 34px; letter-spacing: .02em; }
.screen { min-height: 100%; }

/* ---------------- title */
#title { position: relative; overflow: hidden; }
#titleMap { position: fixed; inset: 0; width: 100%; height: 100%; opacity: .26; filter: saturate(.7); pointer-events: none; }
#title::after { content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(180deg, rgba(29,33,24,.05) 0, rgba(29,33,24,.25) 240px, rgba(29,33,24,.86) 520px, rgba(29,33,24,.94) 100%),
              linear-gradient(90deg, rgba(29,33,24,.55) 0%, rgba(29,33,24,.15) 60%, rgba(29,33,24,0) 100%); }
.title-inner { position: relative; z-index: 1; max-width: 1120px; margin: 0 auto; padding: 40px 24px 60px; }
.brand h1 { font-family: var(--display); font-size: clamp(54px, 10vw, 128px); line-height: .9; color: var(--paper); letter-spacing: .01em;
  text-shadow: 0 2px 0 rgba(0,0,0,.35); }
.brand p { font-family: var(--ui); font-size: 22px; color: var(--muted); margin: 12px 0 34px; max-width: 34em; }
.setup { max-width: 880px; }
.setup-bar { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 24px; }
.setup-btn { display: grid; gap: 3px; align-content: start; text-align: left; padding: 12px 16px; background: rgba(41,46,33,.9); }
.setup-btn b { font: 700 19px var(--ui); color: var(--paper); }
.setup-btn b::after { content: " ›"; color: var(--accent); }
.setup-btn small { color: var(--muted); font: 500 14px/1.3 var(--body); }
.setup-btn:hover { border-color: var(--accent); }
.setup h2 .h-hint { display: block; margin-top: 2px; font: 500 14px var(--body); color: var(--muted); }
.launch { margin-top: 24px; padding: 16px 18px; background: rgba(41,46,33,.92); border: 1px solid var(--line); border-radius: 6px; scroll-margin-bottom: 24px; }
.launch-map { margin: 0; color: var(--muted); font: 500 16px var(--ui); }
.launch-map b { color: var(--paper); font-size: 19px; }
.launch .go { margin-top: 12px; }
.launch.flash { animation: launch-flash 1.1s ease-out; }
@keyframes launch-flash { 0% { box-shadow: 0 0 0 3px var(--accent); border-color: var(--accent); } 100% { box-shadow: 0 0 0 0 transparent; } }
.dlg-body { padding: 16px; display: grid; gap: 14px; }
.dlg-foot { display: flex; justify-content: flex-end; }
.setup h2 { font-family: var(--ui); font-weight: 700; font-size: 22px; color: var(--paper); margin: 0 0 10px; }
.map-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.map-group { grid-column: 1 / -1; font: 700 18px var(--ui); color: var(--paper); margin: 10px 0 0; }
.map-group small { display: block; font: 500 14px var(--body); color: var(--muted); }
.map-card { display: grid; grid-template-columns: 76px 1fr; gap: 10px; align-items: center; text-align: left; padding: 8px; background: rgba(41,46,33,.85); }
.map-card canvas { width: 76px; height: 54px; border-radius: 2px; image-rendering: pixelated; background: #3a4a52; }
.map-card b { display: block; font-size: 18px; }
.map-card small { display: block; color: var(--muted); font: 500 14px/1.25 var(--body); }
.map-card[aria-checked="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: rgba(60,58,30,.9); }
.rules-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 18px; }
.rules-grid label, .namebox { display: flex; justify-content: space-between; align-items: center; gap: 10px; color: var(--muted); font-family: var(--ui); font-size: 17px; }
.rules-grid label.check { justify-content: flex-start; }
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); padding: 0; }
.seat-list { display: grid; gap: 8px; }
.seat { display: grid; grid-template-columns: 10px 64px minmax(0, 1fr); gap: 12px; padding: 10px 12px 10px 0; background: rgba(41,46,33,.85); border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.seat .stripe { background: var(--c); }
.seat .seat-main { display: grid; gap: 6px; min-width: 0; }
.seat .seat-row { display: flex; gap: 8px; flex-wrap: wrap; }
.seat select { flex: 1 1 150px; min-width: 0; max-width: 100%; padding: 7px 10px; }
.seat p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.35; }
.seat.off { opacity: .5; }
.seat.off p { display: none; }
.namebox { margin: 14px 0 0; }
.namebox input { flex: 1; max-width: 240px; }
.go { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.online { margin-top: 26px; }
.online-row { display: flex; gap: 8px; flex-wrap: wrap; }
#joinForm { display: flex; gap: 6px; }
#joinForm input { width: 120px; text-transform: uppercase; letter-spacing: .15em; }

/* ---------------- lobby, handoff */
#lobbyScreen, #handoff { display: grid; place-items: start center; padding: 40px 16px; }
.lobby-wrap { width: min(640px, 100%); display: grid; gap: 14px; }
.handoff-card, .over-card { width: min(460px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 28px; text-align: center; display: grid; gap: 12px; justify-items: center; }
#handoff { place-items: center; min-height: 100vh; }
#handoffText, #overTitle { font-family: var(--display); font-size: 34px; line-height: 1.05; }
.flag { width: 72px; height: 48px; border-radius: 3px; background: var(--c, var(--line)); box-shadow: inset 0 -8px 0 rgba(0,0,0,.25); display: grid; place-items: center; font: 700 18px var(--ui); color: #fff; letter-spacing: .04em; }

/* ---------------- battle */
#play { display: grid; grid-template-rows: auto 1fr; grid-template-columns: minmax(0, 1fr); height: 100vh; height: 100dvh; }
#play > * { min-width: 0; }
.bar { display: flex; align-items: center; gap: 14px; padding: 8px 12px; background: var(--panel); border-bottom: 1px solid var(--line); min-height: 64px; }
.day { font-family: var(--display); font-size: 24px; color: var(--paper); white-space: nowrap; }
.armies { display: flex; gap: 8px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.army { display: grid; grid-template-columns: 6px 44px auto; gap: 8px; align-items: center; padding: 4px 10px 4px 0; border: 1px solid transparent; border-radius: 4px; background: var(--panel2); min-width: 0; white-space: nowrap; }
.army .stripe { align-self: stretch; background: var(--c); border-radius: 4px 0 0 4px; }
.army.now { border-color: var(--accent); }
.army.dead { opacity: .4; text-decoration: line-through; }
.army .who { font: 700 16px/1.1 var(--ui); }
.army .who .ally { font: 600 11px/1 var(--ui); text-transform: uppercase; letter-spacing: .06em; opacity: .7; margin-left: 4px; }
.army .co { font: 500 13px/1.1 var(--ui); color: var(--muted); }
.army .nums { font: 600 14px/1.1 var(--ui); color: var(--paper); display: flex; gap: 10px; margin-top: 2px; }
.meter { position: relative; height: 6px; width: 120px; background: #1b1e15; border-radius: 3px; margin-top: 4px; overflow: hidden; }
.meter i { position: absolute; inset: 0 auto 0 0; background: var(--c); }
.meter b { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--panel2); }
.meter.full i { background: var(--accent); }
.army .active { color: var(--accent); font: 700 13px var(--ui); }
.bar-actions { display: flex; gap: 8px; align-items: center; }
.powers { display: flex; gap: 6px; }
.powers button { background: #3d3618; border-color: var(--accent); color: var(--accent); }
.clock { font: 600 16px var(--ui); color: var(--muted); font-variant-numeric: tabular-nums; }
.clock.low { color: var(--danger); }
#endTurn.armed { background: var(--danger); border-color: var(--danger); color: #fff; }

.field { display: grid; grid-template-columns: minmax(0, 1fr) 300px; min-height: 0; }
.map-area { position: relative; min-height: 0; min-width: 0; display: grid; }
.map-wrap { overflow: auto; min-height: 0; min-width: 0; display: grid; place-items: safe center; overscroll-behavior: contain; background:
  repeating-linear-gradient(45deg, #22271c 0 10px, #20241a 10px 20px); }
.zoom { display: flex; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.zoom button { flex: 1; min-width: 36px; height: 36px; padding: 0; border: 0; border-radius: 0; background: var(--panel); color: var(--paper); font: 700 22px/1 var(--ui); display: grid; place-items: center; }
.zoom button:hover:not(:disabled) { background: var(--panel2); color: var(--accent); }
.zoom button:disabled { opacity: .35; }
.map-stage { position: relative; margin: 4px; box-shadow: 0 0 0 3px #15180f, 0 0 0 4px #3e4630, 0 18px 40px rgba(0,0,0,.45); }
#map { display: block; cursor: pointer; touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
#map.panning { cursor: grabbing; }
.side { border-left: 1px solid var(--line); background: var(--panel); padding: 14px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; min-height: 0; }
.side > * { flex-shrink: 0; }
.side h3 { font: 700 18px var(--ui); color: var(--paper); margin-top: 8px; }
.info { min-height: 148px; }
.info .card { display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 10px; align-items: start; padding: 10px; background: var(--panel2); border-radius: 4px; margin-bottom: 8px; }
.info .card.unit { border-left: 4px solid var(--c); }
.info .card .body { min-width: 0; }
.meter-row { display: grid; grid-template-columns: 62px minmax(0, 1fr) 26px; align-items: center; gap: 8px; margin-top: 5px; font: 600 15px var(--ui); }
.meter-row em { font-style: normal; color: var(--muted); font-weight: 500; font-size: 14px; }
.meter-row strong { text-align: right; color: var(--paper); font-variant-numeric: tabular-nums; }
.pips { display: grid; grid-template-columns: repeat(10, 1fr); gap: 2px; }
.pips i { height: 8px; border-radius: 1px; background: #1b1e15; }
.pips i.on { background: var(--ok); }
.pips.low i.on { background: var(--danger); }
.pips.capt i.on { background: var(--accent); }
.gauge { position: relative; height: 8px; border-radius: 2px; background: #1b1e15; overflow: hidden; }
.gauge i { position: absolute; inset: 0 auto 0 0; background: #8fa3b8; }
.gauge.low i { background: var(--danger); }
.info .vs { margin: 6px 0 0; font-size: 14px; line-height: 1.35; color: var(--ink); }
.vs em { font-style: normal; color: var(--muted); font: 600 13px var(--ui); text-transform: uppercase; letter-spacing: .04em; margin-right: 4px; }
.info .status { margin: 6px 0 0; font: 600 14px var(--ui); color: var(--accent); }
.stars .dim { color: #3a3f2e; }
.info .card.terrain { grid-template-columns: 1fr; }
.info .card b { font: 700 18px/1.1 var(--ui); display: block; }
.info .card small { color: var(--muted); font-size: 14px; display: block; }
.info .stats-row { display: flex; gap: 12px; font: 600 15px var(--ui); color: var(--paper); margin-top: 4px; flex-wrap: wrap; }
.info .stats-row span em { font-style: normal; color: var(--muted); font-weight: 500; }
.info .hint { color: var(--muted); font-size: 14px; line-height: 1.4; }
.stars { color: var(--accent); letter-spacing: 1px; }
.log { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 14px; line-height: 1.35; color: var(--muted); }
.log li { padding-left: 10px; border-left: 3px solid var(--c, var(--line)); }
.log li.new { color: var(--ink); }

.cmd-menu { position: absolute; z-index: 5; display: grid; min-width: 128px; background: var(--panel); border: 1px solid var(--accent); border-radius: 4px; box-shadow: 0 10px 24px rgba(0,0,0,.45); overflow: hidden; }
.cmd-menu button { border: 0; border-radius: 0; background: transparent; text-align: left; padding: 9px 14px; font-size: 17px; }
.cmd-menu button:hover, .cmd-menu button:focus-visible { background: var(--accent); color: var(--accent-ink); outline: none; }
.cmd-menu button + button { border-top: 1px solid var(--line); }
.cmd-menu .cancel { color: var(--muted); }
.cmd-menu.targets { min-width: 200px; }
.cmd-menu .target { display: grid; gap: 1px; padding: 8px 14px; }
.cmd-menu .target b { font: 700 16px var(--ui); }
.cmd-menu .target .deal { color: var(--ok); font: 600 14px var(--ui); }
.cmd-menu .target .take { color: var(--danger); font: 600 14px var(--ui); }
.cmd-menu .target.on, .cmd-menu .target:hover, .cmd-menu .target:focus-visible { background: var(--panel2); color: var(--ink); box-shadow: inset 3px 0 0 var(--accent); }
.tip.mini { padding: 1px 6px; font-size: 13px; transform: translate(-50%, -100%); z-index: 6; }
.tip { position: absolute; z-index: 6; pointer-events: none; background: #15180f; border: 1px solid var(--line); border-radius: 4px; padding: 6px 10px; font: 600 15px/1.25 var(--ui); white-space: nowrap; }
.tip .deal { color: var(--ok); } .tip .take { color: var(--danger); }

.banner { position: fixed; left: 0; right: 0; top: 40%; z-index: 20; pointer-events: none; text-align: center; transform: translateX(-110%); }
.banner.show { animation: sweep 1.5s cubic-bezier(.2,.8,.2,1) forwards; }
.banner span { display: inline-block; max-width: 92vw; padding: 10px 40px 12px; background: var(--c, var(--panel)); color: #fff; font-family: var(--display); font-size: clamp(28px, 5vw, 52px); box-shadow: 0 10px 30px rgba(0,0,0,.4); text-shadow: 0 2px 0 rgba(0,0,0,.3); }
.banner small { display: block; font: 600 18px var(--ui); opacity: .9; text-shadow: none; }
@keyframes sweep { 0% { transform: translateX(-110%); } 22% { transform: translateX(0); } 74% { transform: translateX(0); opacity: 1; } 100% { transform: translateX(110%); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .banner.show { animation: fade 1.4s forwards; transform: none; } @keyframes fade { 0%, 80% { opacity: 1; } 100% { opacity: 0; } } }

.dlg { background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: 0; width: min(620px, calc(100vw - 32px)); max-height: calc(100vh - 48px); }
.dlg.small { width: min(340px, calc(100vw - 32px)); }
.dlg::backdrop { background: rgba(10,12,8,.6); }
.dlg header { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); }
.dlg header h2 { font-family: var(--display); font-size: 26px; flex: 1; }
.funds { font: 700 18px var(--ui); color: var(--accent); }
.build-list { display: grid; padding: 8px; gap: 4px; }
.build-item { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; gap: 12px; align-items: center; text-align: left; padding: 8px 10px; background: transparent; border: 1px solid transparent; border-radius: 4px; }
.build-item:hover:not(:disabled), .build-item:focus-visible { background: var(--panel2); border-color: var(--accent); outline: none; }
.build-item:disabled { opacity: 1; cursor: not-allowed; }
.build-item:disabled > canvas, .build-item:disabled .what { opacity: .42; filter: grayscale(.6); }
.build-item b { display: block; font-size: 18px; }
.build-item small { display: block; font: 500 14px var(--body); color: var(--muted); }
.build-item .chips { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0 2px; }
.build-item .chips i { font: 600 12px var(--ui); font-style: normal; color: var(--paper); background: #1b1e15; border-radius: 3px; padding: 1px 6px; }
.build-item .vs { margin-top: 2px; color: var(--ink); }
.vs.weak em { color: #c9694c; }
.build-item .price { font: 700 18px var(--ui); color: var(--paper); text-align: right; white-space: nowrap; }
.build-item .price small { font: 500 12px var(--ui); color: var(--muted); }
.build-item:disabled .price { color: var(--muted); }
.build-item:disabled .price small { color: var(--danger); }
.menu-list { display: grid; gap: 8px; padding: 16px; }
.help { padding: 6px 18px 16px; font-size: 15px; line-height: 1.55; max-width: 64ch; }
.help b { font-family: var(--ui); font-size: 17px; color: var(--paper); }

.over { position: fixed; inset: 0; z-index: 15; display: grid; place-items: center; background: rgba(10,12,8,.6); padding: 16px; }
.stats { border-collapse: collapse; font: 600 16px var(--ui); width: 100%; }
.stats th, .stats td { padding: 5px 8px; text-align: right; border-bottom: 1px solid var(--line); }
.stats th:first-child, .stats td:first-child { text-align: left; }
.stats th { color: var(--muted); font-weight: 500; }
.row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }

@media (max-width: 520px) {
  .title-inner { padding: 24px 16px 40px; }
  .map-list, .rules-grid { grid-template-columns: 1fr; }
  .setup-bar { gap: 8px; }
  .namebox { flex-wrap: wrap; }
  .setup-btn { padding: 10px 12px; }
}

/* battle close-up */
.clash { position: fixed; inset: 0; z-index: 25; display: grid; place-items: center; background: rgba(12,14,9,.35); cursor: pointer; animation: clash-in .18s ease-out; }
.clash[hidden] { display: none; }
.clash.out { opacity: 0; transition: opacity .16s; }
.clash canvas { width: min(720px, calc(100vw - 32px)); aspect-ratio: 720 / 300; height: auto; border: 3px solid #1f2118; border-radius: 6px; box-shadow: 0 16px 40px rgba(0,0,0,.55); background: #1f2118; }
.clash p { position: absolute; bottom: 14%; margin: 0; font: 600 13px var(--ui); color: #f4f1e4; opacity: .7; }
@keyframes clash-in { from { opacity: 0; } }

/* commander portraits */
.army .face { width: 44px; height: 44px; border-radius: 4px; object-fit: cover; border: 2px solid var(--c); background: #2a2d22; }
.seat .portrait { width: 64px; height: 64px; border-radius: 4px; object-fit: cover; border: 2px solid var(--c); align-self: start; }
.seat.off .portrait { filter: grayscale(1); }
.banner span { display: inline-flex; align-items: center; gap: 18px; text-align: left; }
.banner em { font-style: normal; }
.banner .bface { width: clamp(64px, 9vw, 104px); height: clamp(64px, 9vw, 104px); border-radius: 6px; border: 3px solid rgba(255,255,255,.85); object-fit: cover; box-shadow: 0 4px 12px rgba(0,0,0,.4); }

/* ---------------- compact battle screen: phones and small tablets, either way up.
   Only the essentials stay on screen; the Intel button (ⓘ) slides in the rest. */
.intel-btn, .intel-head, .army-intel-h, .army-intel { display: none; }
@media (max-width: 900px), (max-height: 560px) {
  .bar { min-height: 0; gap: 8px; padding: 4px max(8px, env(safe-area-inset-right)) 4px max(8px, env(safe-area-inset-left)); flex-wrap: nowrap; }
  .day { font-size: 18px; }
  .armies { gap: 4px; }
  .bar .army { grid-template-columns: 4px 28px auto; gap: 5px; padding: 2px 8px 2px 0; }
  .bar .army .face { width: 28px; height: 28px; border-width: 1px; }
  .bar .army .who, .bar .army .co, .bar .army .meter, .bar .army .nums span:not(.funds-n):not(.shape) { display: none; }
  .bar .army .nums { margin: 0; font-size: 14px; }
  .bar-actions { gap: 4px; margin-left: auto; }
  .bar-actions button { padding: 7px 12px; font-size: 16px; }
  .powers button { padding: 6px 10px; font-size: 14px; }
  .intel-btn { display: inline-grid; place-items: center; font-size: 20px; }
  #play.intel-open .intel-btn { color: var(--accent); border-color: var(--accent); }

  #play { overflow: hidden; }
  .field { position: relative; overflow: hidden; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
  .side { position: absolute; z-index: 9; top: 0; right: 0; bottom: 0; width: min(340px, 88vw); max-height: none;
    padding: 0 12px max(12px, env(safe-area-inset-bottom)); border-left: 1px solid var(--line); border-top: 0;
    box-shadow: -12px 0 30px rgba(0,0,0,.5); transform: translateX(105%); visibility: hidden;
    transition: transform .22s ease, visibility 0s linear .22s; }
  #play.intel-open .side { transform: none; visibility: visible; transition: transform .22s ease; }
  .intel-head { display: flex; align-items: center; position: sticky; top: 0; z-index: 1; background: var(--panel); padding: 8px 0 6px; margin: 0 -2px; }
  .intel-head h2 { flex: 1; font-family: var(--display); font-size: 22px; }
  .army-intel-h, .army-intel { display: block; }
  .info { min-height: 0; }
  .intel-army { margin-bottom: 10px; }
  .intel-army .army { display: grid; width: 100%; }
  .intel-army .co-text { margin: 4px 0 0; font-size: 13px; line-height: 1.35; color: var(--muted); }
  .intel-army .co-text b { color: var(--paper); font-family: var(--ui); }
  .build-item { grid-template-columns: 44px minmax(0, 1fr) auto; gap: 8px; padding: 6px; }
  .build-item > canvas { width: 44px !important; height: 44px !important; }
}
/* Phones held upright: the panel comes up from the bottom instead. */
@media (max-width: 600px) and (orientation: portrait) {
  .side { top: auto; left: 0; width: auto; height: min(64vh, 560px); border-left: 0; border-top: 1px solid var(--line);
    border-radius: 10px 10px 0 0; box-shadow: 0 -12px 30px rgba(0,0,0,.5); transform: translateY(105%); }
  .info .card { grid-template-columns: 44px minmax(0, 1fr); padding: 8px; }
  .info .card canvas { width: 44px !important; height: 44px !important; }
}
/* Short screens (landscape phones): a smaller zoom pad, so it covers less of the map. */
@media (max-height: 560px) {
}
/* Narrow phones upright: army chips show the army colour and funds only. */
@media (max-width: 440px) {
  .bar .army { grid-template-columns: 4px auto; padding: 5px 8px 5px 0; }
  .bar .army .face { display: none; }
  .day { font-size: 17px; }
  .bar-actions button { padding: 7px 10px; }
}

/* Army cards in the Armies window on phones: smaller portrait, the two menus one above the other. */
@media (max-width: 520px) {
  .seat { grid-template-columns: 6px 48px minmax(0, 1fr); gap: 10px; }
  .seat .portrait { width: 48px; height: 48px; }
  .seat .seat-row { flex-direction: column; }
  .seat select { flex: none; width: 100%; }
}

/* ---------------- landscape: the top bar leaves the top, so the map gets the full height.
   Big screens: the bar joins the side panel in one column. Phones: a narrow strip of its own.
   #play.bar-right / not: which side (battle menu: "Side bar"). */
@media (orientation: landscape) {
  .bar { flex-direction: column; align-items: stretch; flex-wrap: nowrap; min-height: 0; padding: 12px 10px; gap: 10px;
    overflow-y: auto; overscroll-behavior: contain; }
  .armies { flex: 0 0 auto; flex-direction: column; overflow: visible; }
  .bar .army { width: 100%; white-space: normal; }
  .bar-actions { margin: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 6px; align-items: stretch; }
  .bar-actions .clock, .bar-actions .powers { grid-column: 1 / -1; }
  .bar-actions .clock:empty, .bar-actions .powers:empty { display: none; }
  .powers { flex-direction: column; }
}
/* Big landscape screens: one column with the bar on top and the details and dispatches under it. */
@media (orientation: landscape) and (min-width: 901px) and (min-height: 561px) {
  #play { grid-template-rows: auto minmax(0, 1fr); }
  #play.bar-right { grid-template-columns: minmax(0, 1fr) 300px; }
  #play:not(.bar-right) { grid-template-columns: 300px minmax(0, 1fr); }
  .field { display: contents; }
  .map-area { grid-row: 1 / 3; }
  #play.bar-right .map-area { grid-column: 1; }
  #play:not(.bar-right) .map-area { grid-column: 2; }
  .bar, .side { grid-column: auto; background: var(--panel); }
  #play.bar-right .bar, #play.bar-right .side { grid-column: 2; border-left: 1px solid var(--line); border-right: 0; }
  #play:not(.bar-right) .bar, #play:not(.bar-right) .side { grid-column: 1; border-right: 1px solid var(--line); border-left: 0; }
  .bar { grid-row: 1; border-bottom: 1px solid var(--line); overflow: visible; }
  .side { grid-row: 2; }
}
/* Landscape phones: a narrow strip of its own beside the map. */
@media (orientation: landscape) and (max-height: 560px) {
  #play { grid-template-rows: minmax(0, 1fr); }
  #play.bar-right { grid-template-columns: minmax(0, 1fr) auto; }
  #play:not(.bar-right) { grid-template-columns: auto minmax(0, 1fr); }
  #play.bar-right .bar { order: 2; border-left: 1px solid var(--line); border-right: 0;
    padding: 6px max(6px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) 6px; }
  .bar { width: 108px; gap: 6px; border-bottom: 0; border-right: 1px solid var(--line);
    padding: 6px 6px max(6px, env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left)); }
  .bar-actions { margin-top: auto; grid-template-columns: 1fr 1fr; gap: 4px; }
  .day { font-size: 15px; text-align: center; white-space: normal; line-height: 1.1; }
  .armies { gap: 4px; }
  .bar .army { grid-template-columns: 3px 24px minmax(0, 1fr); gap: 4px; padding: 3px 4px 3px 0; }
  .bar .army .face { width: 24px; height: 24px; }
  .bar .army .nums { font-size: 12px; }
  .bar-actions #endTurn { grid-column: 1 / -1; padding: 8px 4px; font-size: 15px; line-height: 1.1; white-space: normal; }
  .bar-actions .intel-btn, .bar-actions #menuBtn { padding: 6px 0; }
  .powers button { font-size: 12px; padding: 5px 4px; white-space: normal; }
}

/* ---------------- zoom buttons live in the bar (landscape); in portrait, pinch and the battle menu's "Fit" do the job. */
@media (orientation: portrait) { .zoom { display: none; } }
@media (orientation: landscape) { .bar-actions .zoom { grid-column: 1 / -1; } }
@media (orientation: landscape) and (max-height: 560px) { .zoom button { min-width: 0; height: 32px; font-size: 18px; } }

/* ---------------- the short readout on phones and tablets (the full one is behind ⓘ) */
.mini { display: none; }
@media (max-width: 900px), (max-height: 560px) {
  .mini { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; min-width: 0; cursor: pointer; font: 600 13px/1.2 var(--ui); color: var(--paper); }
  .mini .mini-hint { color: var(--muted); font-weight: 500; }
  .mini b { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
  .mini-unit { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; min-width: 0; padding-left: 6px; border-left: 3px solid var(--c); }
  .mini-unit canvas { flex: none; }
  .mini .chips { display: inline-flex; flex-wrap: wrap; gap: 3px; }
  .mini i { font-style: normal; background: #1b1e15; border-radius: 3px; padding: 1px 5px; font-weight: 600; color: var(--paper); white-space: nowrap; }
  .mini i.low { color: #fff; background: var(--danger); }
  .mini i.capt { color: var(--accent-ink); background: var(--accent); }
  .mini-ter { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; }
  .mini .stars { font-size: 11px; letter-spacing: 0; }
}
/* Upright: a second row under the top bar. */
@media (max-width: 900px) and (orientation: portrait) {
  .bar { flex-wrap: wrap; row-gap: 4px; }
}
/* Landscape phones: in the strip, between the armies and End turn. */
@media (orientation: landscape) and (max-height: 560px) {
  .mini { flex-direction: column; align-items: stretch; gap: 4px; padding: 5px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); font-size: 12px; }
  .mini-unit, .mini-ter { flex-direction: column; align-items: flex-start; }
  .mini-unit canvas { width: 24px !important; height: 24px !important; }
  .mini b { max-width: 100%; }
}

/* ---------------- Stage 1 tools */
.tools { display: flex; gap: 6px; flex-wrap: wrap; }
.tool { padding: 6px 10px; font: 600 14px var(--ui); background: var(--panel2); border: 1px solid var(--line); color: var(--paper); }
.tool:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.tool[aria-pressed="true"] { color: #fff; background: #7a2a1a; border-color: #e0603c; }
.tool:disabled { opacity: .4; }
#skipBtn { color: var(--accent); border-color: var(--accent); }
#endTurn .left { display: inline-grid; place-items: center; min-width: 1.5em; height: 1.5em; margin-left: 6px; padding: 0 4px; border-radius: 99px;
  background: var(--accent-ink); color: var(--accent); font: 700 13px/1 var(--ui); vertical-align: 1px; }
.build-item.again { border-color: var(--line); background: rgba(224,177,58,.08); }
.again-tag { display: block; font: 700 11px var(--ui); font-style: normal; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); }
.report { position: absolute; z-index: 7; top: 12px; left: 12px; max-width: min(300px, calc(100% - 24px)); padding: 10px 14px; background: rgba(21,24,15,.95);
  border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 4px; box-shadow: 0 10px 24px rgba(0,0,0,.5);
  font: 500 14px/1.35 var(--ui); color: var(--ink); cursor: pointer; opacity: 0; transform: translateY(-6px); transition: opacity .25s, transform .25s; }
.report.show { opacity: 1; transform: none; }
.report p { margin: 0; }
.report .report-h { font: 700 12px var(--ui); text-transform: uppercase; letter-spacing: .08em; color: var(--accent); margin-bottom: 3px; }
.report b { color: var(--ok); }
.report .cost { color: var(--muted); }
.report .warn { color: #f0b860; }
.report .bad { color: var(--danger); }
.report .funds-now { margin-top: 4px; color: var(--muted); font-size: 13px; }
@media (prefers-reduced-motion: reduce) { .report { transition: none; transform: none; } }
/* where the tools sit in each layout */
@media (orientation: landscape) { .tools { flex-direction: column; } .tool { width: 100%; } }
@media (orientation: landscape) and (max-height: 560px) { .tool { padding: 5px 2px; font-size: 12px; } }
.info-row { display: contents; }
@media (max-width: 900px) and (orientation: portrait) {
  /* second row: the readout, with Next and Danger beside it */
  .info-row { display: flex; order: 10; flex: 1 0 100%; align-items: center; gap: 8px; border-top: 1px solid var(--line); padding-top: 5px; }
  .info-row .mini { flex: 1 1 0; border-top: 0; padding-top: 0; order: 0; }
  .tools { flex: 0 0 auto; flex-wrap: nowrap; }
  .tool { padding: 4px 8px; font-size: 12px; }
}
@media (max-width: 440px) and (orientation: portrait) {
  #endTurn .wt { display: none; }
  #nextBtn, #dangerBtn { font-size: 0; }
  #nextBtn::after { content: "Next"; font-size: 12px; } #dangerBtn::after { content: "Danger"; font-size: 12px; }
}
/* Landscape phones: everything must fit the strip; the readout gives way first, End turn always shows. */
@media (orientation: landscape) and (max-height: 560px) {
  .bar { overflow: hidden; }
  .bar > * { flex-shrink: 0; }
  .bar > .mini { flex: 1 1 auto; min-height: 0; overflow: hidden; flex-direction: row; flex-wrap: wrap; align-content: flex-start; }
  .mini-unit, .mini-ter { flex-direction: row; flex-wrap: wrap; }
  .tools { flex-direction: row; gap: 4px; }
  .tools .tool { flex: 1 1 0; width: auto; padding: 5px 0; }
  #nextBtn, #dangerBtn, #skipBtn { font-size: 0; }
  #nextBtn::after { content: "Next"; font-size: 12px; } #dangerBtn::after { content: "Danger"; font-size: 12px; } #skipBtn::after { content: "Skip ››"; font-size: 12px; }
  #endTurn .wt { display: none; }
}

/* ---------------- Stage 2: feel */
.map-stage.shake { animation: shake .32s ease-out; }
.map-stage.shake.big { animation: shake-big .45s ease-out; }
@keyframes shake { 20% { transform: translate(-3px, 1px); } 40% { transform: translate(3px, -2px); } 60% { transform: translate(-2px, 1px); } 80% { transform: translate(1px, 0); } }
@keyframes shake-big { 15% { transform: translate(-6px, 2px); } 30% { transform: translate(5px, -4px); } 45% { transform: translate(-4px, 3px); } 60% { transform: translate(3px, -1px); } 80% { transform: translate(-1px, 1px); } }
@media (prefers-reduced-motion: reduce) { .map-stage.shake, .map-stage.shake.big { animation: none; } }
.army .nums .shape { color: var(--c); margin-right: -6px; font-size: .85em; }
.bar .army .nums span.shape { display: inline; }
.coach { position: absolute; z-index: 8; left: 50%; bottom: 14px; transform: translateX(-50%); width: min(440px, calc(100% - 24px)); display: flex; gap: 12px; align-items: center;
  padding: 10px 12px 10px 14px; background: rgba(21,24,15,.96); border: 1px solid var(--accent); border-radius: 6px; box-shadow: 0 12px 28px rgba(0,0,0,.55);
  font: 500 15px/1.35 var(--body); color: var(--ink); }
.coach.show { animation: coach-in .3s ease-out; }
.coach p { margin: 0; flex: 1; }
.coach button { flex: none; padding: 6px 12px; }
@keyframes coach-in { from { opacity: 0; transform: translate(-50%, 8px); } }
@media (prefers-reduced-motion: reduce) { .coach.show { animation: none; } }

/* ---------------- Stage 3: the field HQ look (art/ui) */
.insignia { display: inline-block; vertical-align: -2px; margin-right: 5px; flex: none; filter: drop-shadow(0 1px 1px rgba(0,0,0,.45)); }
.flag .insignia { margin: 0; vertical-align: middle; }
.banner small .insignia { vertical-align: -3px; }

/* canvas-textured panels, map-paper dispatches and dialogs */
.bar, .side, .dlg, .setup-btn, .launch, .handoff-card, .over-card {
  background-image: linear-gradient(rgba(33,37,26,.9), rgba(33,37,26,.9)), url("art/ui/canvas.webp");
  background-size: auto, 320px 320px;
}
.dlg header { background-image: linear-gradient(rgba(40,45,31,.93), rgba(40,45,31,.93)), url("art/ui/canvas.webp"); background-size: auto, 320px 320px; }
.side h3, .dlg header h2, .setup h2, .launch .online h2 { font-family: var(--display); font-weight: 400; letter-spacing: .03em; }
.side h3 { font-size: 20px; color: var(--accent); text-transform: uppercase; }
.log { background: url("art/ui/paper.webp") center / 360px 360px; color: #2b2a1f; padding: 8px 10px; border-radius: 2px;
  box-shadow: inset 0 0 0 1px rgba(60,50,30,.35), 0 3px 8px rgba(0,0,0,.35); font-family: "Special Elite", "Courier New", monospace; font-size: 13.5px; }
.log li { color: #4a4636; border-left-color: rgba(70,60,40,.35); }
.log li.new { color: #1f1d14; }
.report { font-family: "Special Elite", "Courier New", monospace; background: url("art/ui/paper.webp") center / 300px 300px; color: #26241a; border-left-color: #8a2a1a; }
.report .report-h { color: #8a2a1a; font-family: var(--ui); }
.report b { color: #1f5a1f; } .report .cost, .report .funds-now { color: #5a5444; } .report .warn { color: #8a5a00; } .report .bad { color: #a01f14; }
.coach { font-family: var(--body); }
/* Basic Training: the coach card, the squares it rings on the map (drawn in app.js) and the bar buttons it points at */
.coach.training { width: min(520px, calc(100% - 20px)); align-items: flex-end; border-color: #ffd86e; box-shadow: 0 12px 28px rgba(0,0,0,.55), 0 0 0 1px rgba(255,216,110,.25); }
.coach.training.top { bottom: auto; top: 12px; }
.coach.training.top.show { animation-name: coach-in-top; }
@keyframes coach-in-top { from { opacity: 0; transform: translate(-50%, -8px); } }
.coach-body { flex: 1; min-width: 0; }
.coach-head { display: block; margin-bottom: 3px; font: 600 12px/1.2 var(--ui); letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.coach.training p b { color: #ffe08a; font-weight: 600; }
.coach-btns { display: flex; gap: 6px; align-items: center; flex: none; }
.coach .coach-btns button { min-height: 36px; }
.coach .coach-x { padding: 6px 9px; }
.coach-glow { position: relative; animation: coach-glow 1.2s ease-in-out infinite; outline: 2px solid #ffd86e; outline-offset: 2px; }
@keyframes coach-glow { 50% { outline-color: rgba(255,216,110,.25); box-shadow: 0 0 14px rgba(255,216,110,.55); } }
@media (prefers-reduced-motion: reduce) { .coach-glow { animation: none; } }
@media (max-width: 560px) {
  .coach.training { flex-direction: column; align-items: stretch; gap: 8px; font-size: 14px; }
  .coach-btns { justify-content: flex-end; }
}
/* the way into Basic Training on the title screen */
.training-cta { margin: 14px 0 22px; display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 8px 16px; background: rgba(21,24,15,.78);
  border: 1px solid rgba(224,177,58,.7); border-radius: 4px; color: var(--ink); font: 500 15px/1.2 var(--body); cursor: pointer; }
.training-cta b { color: var(--accent); font-family: var(--ui); font-weight: 600; letter-spacing: .02em; }
.training-cta:hover, .training-cta:focus-visible { background: rgba(40,45,31,.92); border-color: var(--accent); }

/* title: painted key art behind the heading */
#title { background: #1d2116; }
#title::before { content: ""; position: absolute; inset: 0 0 auto 0; height: min(62vh, 560px); z-index: 0; pointer-events: none;
  background: linear-gradient(180deg, rgba(29,33,22,.15) 0%, rgba(29,33,22,.35) 55%, #1d2116 100%), url("art/ui/title.webp") center 35% / cover no-repeat; }
#title { position: relative; }
#titleMap { display: none; }   /* the painted key art replaces the faint map */
.brand h1 { text-shadow: 0 3px 0 rgba(0,0,0,.45), 0 10px 30px rgba(0,0,0,.55); }
.brand p { color: #e6e0c8; text-shadow: 0 2px 8px rgba(0,0,0,.8); }

/* victory and defeat */
.over-card { padding-top: 0; overflow: hidden; }
.over-art { width: calc(100% + 56px); margin: 0 -28px 4px; aspect-ratio: 16 / 9; background: #2a2d22 center / cover no-repeat;
  -webkit-mask-image: linear-gradient(#000 70%, transparent); mask-image: linear-gradient(#000 70%, transparent); }
.over-card .flag { margin-top: -34px; position: relative; }

/* commander power cut-in */
.cutin { position: fixed; inset: 0; z-index: 30; display: grid; align-items: center; cursor: pointer;
  background: radial-gradient(ellipse at center, rgba(0,0,0,.15), rgba(0,0,0,.6)); }
.cutin[hidden] { display: none; }
.cutin-band { position: relative; height: min(46vh, 340px); display: flex; align-items: center; gap: clamp(12px, 3vw, 40px);
  padding: 0 clamp(16px, 6vw, 90px); overflow: hidden;
  background: linear-gradient(100deg, var(--d) 0%, var(--c) 55%, var(--d) 100%);
  box-shadow: 0 0 0 3px rgba(0,0,0,.35), 0 20px 50px rgba(0,0,0,.6); transform: skewY(-4deg); }
.cutin-band::after { content: ""; position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(-60deg, rgba(255,255,255,.07) 0 14px, transparent 14px 34px); }
.cutin-frame { position: relative; z-index: 1; height: 118%; aspect-ratio: 4 / 5; flex: none; transform: skewY(4deg) skewX(-8deg); overflow: hidden;
  border: 4px solid #f4f1e4; box-shadow: 0 10px 30px rgba(0,0,0,.55); background: #3a3d33; }
.cutin-frame img { width: 100%; height: 100%; object-fit: cover; transform: skewX(8deg) scale(1.12); }
.cutin-text { position: relative; z-index: 1; display: grid; gap: 4px; color: #fff; transform: skewY(4deg); min-width: 0; }
.cutin-text em { font: 400 clamp(34px, 7vw, 86px)/0.95 var(--display); font-style: normal; text-shadow: 0 4px 0 rgba(0,0,0,.35), 0 10px 26px rgba(0,0,0,.5); }
.cutin-text small { font: 600 clamp(15px, 2vw, 22px) var(--ui); opacity: .92; }
.cutin.show .cutin-band { animation: cutin-band .45s cubic-bezier(.2,.9,.2,1) both, cutin-out .35s ease-in 1.95s forwards; }
.cutin.show .cutin-frame { animation: cutin-face .55s .08s cubic-bezier(.2,.9,.2,1) both; }
.cutin.show .cutin-text { animation: cutin-word .5s .2s cubic-bezier(.2,.9,.2,1) both; }
@keyframes cutin-band { from { transform: skewY(-4deg) translateX(-105%); } }
@keyframes cutin-face { from { transform: skewY(4deg) skewX(-8deg) translateX(-140%); } }
@keyframes cutin-word { from { opacity: 0; transform: skewY(4deg) translateX(80px); } }
@keyframes cutin-out { to { transform: skewY(-4deg) translateX(105%); } }
@media (prefers-reduced-motion: reduce) {
  .cutin.show .cutin-band, .cutin.show .cutin-frame, .cutin.show .cutin-text { animation: none; }
}
@media (max-height: 560px) { .cutin-band { height: 58vh; } }

/* the cut-in on narrow upright screens: a smaller portrait so the power's name fits beside it */
@media (orientation: portrait) and (max-width: 700px) {
  .cutin-band { height: 210px; gap: 14px; padding: 0 14px; }
  .cutin-frame { height: 112%; max-width: 42vw; }
  .cutin-text em { font-size: clamp(26px, 8.5vw, 44px); overflow-wrap: anywhere; }
  .cutin-text small { font-size: 14px; }
  .cutin-text .insignia { width: 30px; height: 30px; }
}

/* ---------------- Stage 4: battle report */
.over { overflow-y: auto; }
.over-card { width: min(600px, 100%); max-height: calc(100dvh - 32px); overflow-y: auto; }
.report-chart { width: 100%; text-align: left; }
.chart-tabs { display: inline-flex; gap: 2px; padding: 2px; background: #1b1e15; border-radius: 5px; }
.chart-tabs button { padding: 4px 12px; border: 0; background: transparent; font: 600 14px var(--ui); color: var(--muted); }
.chart-tabs button[aria-selected="true"] { background: var(--panel2); color: var(--paper); box-shadow: inset 0 -2px 0 var(--accent); }
.chart-note { margin: 6px 0 2px; font: 500 13px var(--ui); color: var(--muted); }
.chart-box { position: relative; }
.chart { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid { stroke: rgba(230,224,200,.10); stroke-width: 1; }
.chart .tick { fill: var(--muted); font: 500 11px var(--ui); }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .marks > * { stroke: var(--panel); stroke-width: 1.5; }
.chart .end { fill: var(--ink); font: 600 12px var(--ui); }
.chart .end .sh { font-size: 11px; }
.chart .cross { stroke: rgba(230,224,200,.45); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .hit { fill: transparent; cursor: crosshair; touch-action: pan-y; }
.chart-tip { position: absolute; top: 6px; z-index: 2; min-width: 130px; padding: 6px 9px; background: rgba(18,20,14,.96); border: 1px solid var(--line);
  border-radius: 4px; box-shadow: 0 6px 16px rgba(0,0,0,.45); font: 500 13px/1.35 var(--ui); color: var(--ink); pointer-events: none; display: grid; }
.chart-tip b { color: var(--paper); margin-bottom: 2px; }
.chart-tip span { display: flex; gap: 6px; align-items: baseline; }
.chart-tip i { font-style: normal; font-size: 11px; }
.chart-tip em { font-style: normal; margin-left: auto; padding-left: 10px; font-weight: 700; color: var(--paper); font-variant-numeric: tabular-nums; }
.chart-empty { color: var(--muted); font: 500 14px var(--ui); margin: 4px 0; }
.stats .shape { font-size: .8em; }
@media (max-width: 520px) { .stats { font-size: 13px; } .stats th, .stats td { padding: 4px 4px; } .over-card { padding: 0 14px 16px; } .over-art { width: calc(100% + 28px); margin: 0 -14px 4px; } }

/* ---------------- Stage 5: replays */
#play.replaying #endTurn, #play.replaying .tools, #play.replaying .powers, #play.replaying #nextBtn { display: none; }
.replay-bar { position: absolute; z-index: 8; left: 50%; bottom: 12px; transform: translateX(-50%); width: min(640px, calc(100% - 16px));
  display: flex; align-items: center; gap: 6px; padding: 6px 8px; background: rgba(21,24,15,.95); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 10px 26px rgba(0,0,0,.55); }
.replay-bar[hidden] { display: none; }
.replay-bar button { flex: none; min-width: 38px; height: 36px; padding: 0 8px; font: 700 15px var(--ui); }
.replay-bar input[type=range] { flex: 1; min-width: 60px; accent-color: var(--accent); }
.rp-where { flex: none; font: 600 13px var(--ui); color: var(--muted); white-space: nowrap; min-width: 0; overflow: hidden; text-overflow: ellipsis; max-width: 30%; }
@media (max-width: 520px) { .rp-where { display: none; } #rpStart { display: none; } .replay-bar button { min-width: 34px; padding: 0 6px; } }
.replay-list { display: grid; gap: 6px; }
.replay-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; gap: 6px; align-items: center; padding: 8px 10px; background: var(--panel2); border-radius: 4px; }
.replay-row b { display: block; font: 700 16px var(--ui); color: var(--paper); }
.replay-row small { display: block; color: var(--muted); font: 500 13px/1.3 var(--ui); }
.replay-row button { padding: 5px 10px; }
.file-btn { display: inline-flex; align-items: center; gap: 8px; color: var(--accent); font: 600 15px var(--ui); cursor: pointer; }
.file-btn input { font-size: 13px; color: var(--muted); max-width: 100%; }
.muted.small, .small { font-size: 14px; margin: 0; }
#replaysBtn { margin-left: auto; }
#play.replaying #mapWrap { padding-bottom: 64px; }

/* ---------------- Stage 5: campaign */
.mode-tabs { display: inline-flex; margin-bottom: 16px; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: rgba(33,37,26,.9); }
.mode-tabs button { border: 0; border-radius: 0; padding: 10px 22px; font: 700 19px var(--ui); background: transparent; color: var(--muted); }
.mode-tabs button[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); }
.mode-tabs button + button { border-left: 1px solid var(--line); }
.camp-head { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.camp-head p { margin: 0; }
.camp-diff { font: 600 16px var(--ui); color: var(--paper); display: flex; gap: 8px; align-items: center; }
.campaign { margin-bottom: 18px; }
.campaign .map-group { margin: 6px 0 10px; }
.campaign .map-group small { display: block; font: 500 14px var(--body); color: var(--muted); margin-top: 2px; }
.mission-card { position: relative; }
.mission-card.locked { opacity: .55; cursor: not-allowed; }
.mission-card.locked canvas { filter: grayscale(1) brightness(.7); }
.mission-card .rank, .mission-card .lock { position: absolute; top: 6px; right: 8px; font: 400 22px/1 var(--display); font-style: normal; }
.mission-card .stars { display: block; font-size: 12px; margin: 1px 0 2px; }
#briefStars:empty { display: none; }
.r-S { color: #f2c94c; } .r-A { color: #b9d48a; } .r-B { color: #c9c3a8; }
.camp-go { margin-top: 6px; }
.camp-go:not(:has(button:not([hidden]))) { display: none; }

/* briefing */
#briefing { background: #1d2116; }
.brief-wrap { max-width: 1180px; margin: 0 auto; padding: 22px 20px 40px; }
.brief-head { margin-bottom: 14px; }
.brief-kicker { margin: 0; font: 700 14px var(--ui); letter-spacing: .12em; text-transform: uppercase; color: var(--accent); }
.brief-head h2 { margin: 2px 0 0; color: var(--paper); font-size: clamp(30px, 5vw, 48px); line-height: 1; }
.brief-place { margin: 6px 0 0; color: var(--muted); font: 500 16px var(--ui); }
.brief-body { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(300px, 1fr); gap: 20px; align-items: start; }
.brief-map { background: #14170f; border: 1px solid var(--line); border-radius: 4px; padding: 6px; overflow: auto; display: grid; place-items: center; }
.brief-map canvas { display: block; max-width: 100%; height: auto !important; }
.brief-side { display: grid; gap: 14px; min-width: 0; }
.brief-sides { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.brief-co { display: flex; gap: 10px; align-items: center; padding: 8px; background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--c); border-radius: 4px; min-width: 0; }
.brief-co .portrait { width: 52px; height: 52px; border-radius: 3px; object-fit: cover; flex: none; }
.brief-co span { display: grid; min-width: 0; }
.brief-co b { font: 700 16px/1.15 var(--ui); color: var(--paper); }
.brief-co small { color: var(--muted); font: 500 13px/1.3 var(--ui); }
.brief-co small .insignia { vertical-align: -3px; }
.dispatch { background: url("art/ui/paper.webp") center / 380px 380px; color: #26241a; border-radius: 2px; padding: 12px 14px; display: grid; gap: 12px;
  box-shadow: inset 0 0 0 1px rgba(60,50,30,.35), 0 4px 12px rgba(0,0,0,.4); font-family: "Special Elite", "Courier New", monospace; font-size: 15px; line-height: 1.45; }
.dispatch.small { font-size: 14px; padding: 10px 12px; gap: 10px; text-align: left; }
.dispatch:empty { display: none; }
.dispatch-line { display: grid; grid-template-columns: 44px 1fr; gap: 10px; align-items: start; animation: line-in .5s ease-out both; }
.dispatch-line .dface { width: 44px; height: 44px; border-radius: 3px; object-fit: cover; border: 2px solid var(--c); filter: sepia(.25); }
.dispatch-line p { margin: 0; }
.dispatch-line b { display: block; font: 700 13px var(--ui); letter-spacing: .06em; text-transform: uppercase; color: #6b2416; margin-bottom: 1px; }
.dispatch .camp-done { margin: 0; font: 400 20px var(--display); color: #6b2416; text-align: center; }
@keyframes line-in { from { opacity: 0; transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) { .dispatch-line { animation: none; } }
.brief-orders { background: var(--panel); border: 1px solid var(--line); border-radius: 4px; padding: 10px 14px; }
.brief-orders h3 { margin: 0 0 6px; font: 700 18px var(--ui); color: var(--paper); }
.goal-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.goal-list li { display: grid; grid-template-columns: 20px 1fr; gap: 6px; font: 500 16px/1.3 var(--body); }
.goal-list li.muted { font-size: 14px; }
.goal-list .gm { color: var(--accent); font-weight: 700; text-align: center; }
.goal-list li.done .gm { color: var(--ok); } .goal-list li.failed .gm { color: var(--danger); }
.goal-list li.done { color: var(--ok); }
.goal-list em { font-style: normal; color: var(--paper); font-weight: 600; white-space: nowrap; }
.brief-go { display: flex; gap: 10px; flex-wrap: wrap; }
@media (max-width: 860px) {
  .brief-body { grid-template-columns: 1fr; }
  .brief-wrap { padding: 16px 12px 32px; }
}
@media (max-width: 420px) { .brief-sides { grid-template-columns: 1fr; } }

/* objectives tag on the map */
.goal-pill { position: absolute; z-index: 6; top: 10px; right: 12px; max-width: calc(100% - 24px); padding: 6px 12px; border-radius: 999px;
  background: rgba(21,24,15,.92); border: 1px solid var(--accent); color: var(--paper); font: 600 15px var(--ui); box-shadow: 0 4px 12px rgba(0,0,0,.4);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.goal-pill b { color: var(--accent); }
.goal-pill .pill-dl { color: var(--muted); }
.goal-pill[hidden] { display: none; }
#play.replaying .goal-pill { display: none; }

/* end of a mission */
.over-mission { width: 100%; display: grid; gap: 10px; justify-items: center; }
.over-mission[hidden] { display: none; }
.rank-stamp { display: grid; justify-items: center; }
.rank-stamp:empty { display: none; }
.rank-stamp span { font: 400 64px/1 var(--display); transform: rotate(-8deg); padding: 2px 18px; border: 4px solid currentColor; border-radius: 6px; animation: stamp .45s cubic-bezier(.2,1.6,.4,1) both; }
.rank-stamp small { margin-top: 6px; color: var(--muted); font: 600 14px var(--ui); }
@keyframes stamp { from { transform: rotate(-8deg) scale(2.2); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .rank-stamp span { animation: none; } }
.over-card .row { flex-wrap: wrap; justify-content: center; }
@media (max-height: 500px) { .over-art { aspect-ratio: 16 / 5; } .goal-pill { font-size: 13px; padding: 4px 10px; top: 6px; } }
.dispatch .muted { color: #4a4436; margin: 0; font-family: inherit; }

/* ---------------- Stage 5: map editor */
.map-item { position: relative; display: grid; }
.map-item .map-card { padding-right: 64px; }
.map-edit { position: absolute; top: 50%; right: 8px; transform: translateY(-50%); padding: 6px 10px; font-size: 14px; border: 1px solid var(--line); background: var(--panel); }
.new-map { border-style: dashed; }
.new-map .plus { width: 76px; height: 54px; display: grid; place-items: center; font: 400 34px/1 var(--display); color: var(--accent); border: 1px dashed var(--line); border-radius: 2px; }
#editor { display: flex; flex-direction: column; height: 100dvh; min-height: 0; background: #1a1e14; }
#editor[hidden] { display: none; }
.ed-bar { display: flex; gap: 8px; align-items: center; padding: 8px 10px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.ed-bar #edName { flex: 1 1 160px; min-width: 0; font: 700 18px var(--ui); }
.ed-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.ed-actions button { padding: 8px 12px; }
.ed-main { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 330px; }
.ed-wrap { overflow: auto; min-height: 0; padding: 6px; display: grid; place-items: center; background: #14170f; }
.ed-wrap canvas { display: block; box-shadow: 0 0 0 3px #2b301f, 0 6px 20px rgba(0,0,0,.5); }
.ed-tools { border-left: 1px solid var(--line); overflow-y: auto; padding: 10px; display: grid; gap: 10px; align-content: start; grid-auto-rows: max-content; }
.ed-tabs { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.ed-tabs button { border: 0; border-radius: 0; padding: 8px 4px; background: transparent; color: var(--muted); }
.ed-tabs button[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); }
.ed-palette { display: grid; grid-template-columns: repeat(auto-fill, minmax(66px, 1fr)); gap: 6px; }
.ed-item { display: grid; justify-items: center; gap: 3px; padding: 5px 2px; background: var(--panel); }
.ed-item canvas { border-radius: 3px; }
.ed-item small { font: 500 12px/1.1 var(--ui); color: var(--muted); text-align: center; }
.ed-item[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: rgba(60,58,30,.9); }
.ed-item[aria-pressed="true"] small { color: var(--paper); }
.ed-owners { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.ed-owners[hidden] { display: none; }
.ed-label { font: 600 14px var(--ui); color: var(--muted); margin-right: 2px; }
.ed-owner { padding: 5px 9px; font-size: 14px; border-left: 4px solid var(--c); }
.ed-owner i { font-style: normal; color: var(--c); margin-right: 4px; }
.ed-owner[aria-pressed="true"] { border-color: var(--accent); border-left-color: var(--c); background: rgba(60,58,30,.9); }
.ed-toolrow { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.ed-toolrow button { padding: 7px 6px; font-size: 15px; }
.ed-toolrow button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.ed-row { display: flex; gap: 8px; align-items: end; justify-content: space-between; flex-wrap: wrap; }
.ed-sym { display: grid; gap: 3px; font: 600 14px var(--ui); color: var(--muted); flex: 1; min-width: 0; }
.ed-sym select { width: 100%; }
.ed-zoom { width: 96px; }
.ed-status { margin: 0; display: grid; gap: 2px; font: 500 14px/1.3 var(--ui); color: var(--muted); }
.ed-warn { color: #f0b860; } .ed-ok { color: var(--ok); }
.ed-toast { position: fixed; z-index: 20; left: 50%; bottom: 18px; transform: translateX(-50%); margin: 0; padding: 8px 16px; background: #15180f; border: 1px solid var(--accent); border-radius: 4px; box-shadow: 0 6px 16px rgba(0,0,0,.45); }
.ed-toast[hidden] { display: none; }
.ed-h3 { margin: 6px 0 0; font: 700 18px var(--ui); color: var(--paper); }
#edCode { width: 100%; font: 500 13px/1.3 ui-monospace, monospace; resize: vertical; }
.ed-share { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.danger-btn { color: var(--danger); border-color: var(--danger); background: transparent; }
@media (max-width: 760px) and (orientation: portrait) {
  .ed-main { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; }
  .ed-tools { border-left: 0; border-top: 1px solid var(--line); max-height: 44dvh; padding: 8px; gap: 8px; }
  .ed-palette { grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); }
  .ed-toolrow { grid-template-columns: repeat(4, 1fr); }
  .ed-toolrow button { font-size: 13px; padding: 7px 2px; }
  .ed-actions button { padding: 7px 9px; }
}
@media (max-height: 560px) and (orientation: landscape) {
  .ed-main { grid-template-columns: minmax(0, 1fr) 290px; }
  .ed-bar { padding: 4px 8px; flex-wrap: nowrap; }
  .ed-actions button { padding: 6px 9px; font-size: 14px; }
  .ed-bar #edName { font-size: 15px; padding: 6px 8px; }
  .ed-tools { padding: 6px; gap: 6px; }
  .ed-palette { grid-template-columns: repeat(auto-fill, minmax(54px, 1fr)); }
}
.ed-share .file-btn { padding: 9px 14px; border: 1px solid var(--line); border-radius: 4px; background: var(--panel2); color: var(--ink); }
.ed-share .file-btn input { display: none; }

/* the way home to punatic.org: under the setup on the title screen, and beside the buttons on the end screen */
.home-row { margin: 22px 0 8px; }
.home-link { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 9px 14px; box-sizing: border-box;
  font: 600 16px/1.2 var(--ui); letter-spacing: .02em; color: var(--ink); text-decoration: none;
  background: rgba(33,37,26,.82); border: 1px solid var(--line); border-radius: 4px; }
.home-link:hover, .home-link:focus-visible { border-color: var(--accent); color: var(--accent); }
.home-row .home-link { color: #d8d2bb; }
