/* LONGBOX — newsprint page, thick ink panels, comic lettering.
   Palette: ink #111111 · newsprint #F2E6CC · deep space #12152B · starburst #FFD23F · laser cyan #2EC4F1 · hero magenta #EE3E7B · villain violet #8A48A0 */
:root {
  --ink: #111111; --paper: #F2E6CC; --space: #12152B; --yellow: #FFD23F; --cyan: #2EC4F1; --magenta: #EE3E7B; --violet: #8A48A0;
  --paper-light: #F8F1E1; --radio: #E3F1F7; --orange: #F58A2A;
  --hud-h: 54px;
  --f-title: 'Bangers', 'Impact', 'Arial Black', sans-serif;
  --f-balloon: 'Shantell Sans', 'Comic Sans MS', 'Marker Felt', sans-serif;
  --f-cap: 'Kalam', 'Segoe Print', 'Bradley Hand', cursive;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--paper); color: var(--ink); overflow: hidden; }
body { font-family: var(--f-cap); -webkit-font-smoothing: antialiased; user-select: none; }
body::after { /* light paper grain over everything */
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 900; opacity: .22; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .35  0 0 0 0 .27  0 0 0 0 .14  0 0 0 .9 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}
button { font: inherit; color: inherit; cursor: pointer; }
kbd { font-family: var(--f-cap); font-weight: 700; background: var(--ink); color: var(--paper); border-radius: 4px; padding: 0 5px; font-size: .85em; }
.hidden { display: none !important; }

#page { position: fixed; inset: 0; padding: 16px; }
.screen { position: absolute; inset: 16px; display: grid; gap: 18px; }

/* ---------- panels: thick wobbly ink border ---------- */
.panel {
  position: relative; background: var(--paper-light); border-radius: 5px 11px 6px 10px / 9px 5px 11px 6px; overflow: hidden;
}
.panel::after {
  content: ''; position: absolute; inset: 0; border: 6px solid var(--ink); border-radius: inherit; pointer-events: none; z-index: 60; filter: url(#rough);
}

/* ---------- caption box ---------- */
.caption {
  position: absolute; background: var(--yellow); color: var(--ink); border: 3px solid var(--ink); padding: .38em .9em; z-index: 20;
  font-family: var(--f-cap); font-weight: 700; font-size: clamp(14px, 1.55vw, 24px); text-transform: uppercase; font-style: italic; letter-spacing: .01em;
  box-shadow: 5px 5px 0 rgba(17,17,17,.9); transform: rotate(-1.1deg); filter: url(#rough-sm); max-width: 70%;
}
.caption.big { position: static; display: inline-block; font-size: 32px; }
#loading { position: fixed; inset: 0; z-index: 800; background: var(--paper); display: grid; place-items: center; transition: opacity .5s; }
#loading.gone { opacity: 0; pointer-events: none; }

/* ---------- buttons ---------- */
.btn {
  font-family: var(--f-title); font-size: clamp(22px, 2.5vw, 38px); letter-spacing: .02em; color: var(--ink); border: 4px solid var(--ink); border-radius: 3px 7px 4px 6px;
  padding: .12em .5em .02em; box-shadow: 6px 6px 0 var(--ink); transform: rotate(-1.4deg); transition: transform .08s, box-shadow .08s; line-height: 1.15; filter: url(#rough-sm);
}
.btn:hover:not(:disabled) { transform: translate(-1px, -2px) rotate(-.6deg); box-shadow: 8px 8px 0 var(--ink); }
.btn:active:not(:disabled) { transform: translate(5px, 5px) rotate(0); box-shadow: 1px 1px 0 var(--ink); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-magenta { background: var(--magenta); } .btn-yellow { background: var(--yellow); } .btn-cyan { background: var(--cyan); } .btn-plain { background: var(--paper-light); }
.btn.big { font-size: clamp(36px, 4.5vw, 64px); padding: .1em .55em 0; }
.btn.sm { font-size: clamp(16px, 1.7vw, 26px); box-shadow: 4px 4px 0 var(--ink); border-width: 3px; }
.mini-btn { font-family: var(--f-cap); font-weight: 700; border: 3px solid var(--ink); background: var(--yellow); border-radius: 6px; padding: .2em .6em; box-shadow: 3px 3px 0 var(--ink); }
.mini-btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }

/* ================= COVER ================= */
#cover { grid-template-rows: auto minmax(0, 1fr) auto; grid-template-columns: minmax(0, 1fr); max-width: 1180px; margin: 0 auto; width: 100%; gap: 14px; }
.cover-top { display: grid; grid-template-columns: minmax(90px, 160px) 1fr minmax(90px, 150px); gap: 14px; align-items: stretch; }
.logo-box { background: var(--yellow); border: 4px solid var(--ink); font-family: var(--f-title); font-size: clamp(22px, 3.2vw, 44px); line-height: .9; text-align: center; padding: .25em .2em .15em; transform: rotate(-1.5deg); box-shadow: 4px 4px 0 var(--ink); filter: url(#rough-sm); }
.logo-box span { font-size: .62em; letter-spacing: .08em; }
.presents { background: var(--ink); color: var(--paper); font-family: var(--f-title); letter-spacing: .35em; font-size: clamp(24px, 3.4vw, 46px); display: grid; place-items: center; border-radius: 6px; filter: url(#rough-sm); }
.issue-box { border: 4px solid var(--ink); background: var(--paper-light); text-align: center; font-family: var(--f-title); line-height: .9; padding: .15em; transform: rotate(1deg); filter: url(#rough-sm); display: grid; place-items: center; }
.issue-box small { font-family: var(--f-cap); font-style: italic; font-size: clamp(13px, 1.4vw, 20px); } .issue-box b { font-size: clamp(34px, 4.8vw, 66px); }
#cover-art { background: var(--space); }
#cover-stage, #stage { position: absolute; inset: 0; }
#cover-stage canvas, #stage canvas { display: block; width: 100%; height: 100%; }
.title-logo {
  position: absolute; left: 50%; top: 3%; transform: translateX(-50%) rotate(-2deg); margin: 0; z-index: 20; white-space: nowrap;
  font-family: var(--f-title); font-weight: 400; font-size: clamp(64px, 12.5vw, 188px); line-height: .95; letter-spacing: .01em;
  filter: drop-shadow(7px 7px 0 var(--magenta)); pointer-events: none;
}
.tl-back { display: block; -webkit-text-stroke: .11em var(--ink); color: var(--ink); }
.tl-front { position: absolute; left: 0; top: 0; display: block; color: transparent;
  background: linear-gradient(#fff6c4 0%, #f8d160 38%, #e79a1e 52%, #ffd76a 70%, #f0b030 100%); -webkit-background-clip: text; background-clip: text; }
.subtitle {
  position: absolute; left: 50%; top: calc(3% + clamp(64px, 12.5vw, 188px) * .98); transform: translateX(-42%) rotate(-1.3deg); z-index: 20; background: var(--paper); border: 3px solid var(--ink);
  font-family: var(--f-cap); font-style: italic; font-weight: 700; font-size: clamp(17px, 2.6vw, 38px); letter-spacing: .08em; padding: .15em 1em; box-shadow: 4px 4px 0 var(--ink);
}
.cover-cap { left: 3%; bottom: 5%; }
#cover-sfx { position: absolute; inset: 0; pointer-events: none; z-index: 25; overflow: hidden; }
.cover-bottom { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 18px; align-items: center; }
.blurb { background: #fff; border: 4px solid var(--ink); padding: .7em 1.1em; font-family: var(--f-balloon); font-weight: 600; font-size: clamp(14px, 1.6vw, 22px); line-height: 1.35; filter: url(#rough-sm); }
.blurb p { margin: 0 0 .5em; }
.credits { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 18px; font-family: var(--f-cap); font-size: clamp(12px, 1.15vw, 16px); }
.credits span { opacity: .8; font-weight: 400; }
.credits a { color: inherit; }
.shoplink { font-weight: 700; color: #b3153f; text-decoration: underline wavy; text-underline-offset: 3px; }
.shoplink:hover { color: var(--ink); background: var(--yellow); }
.end-shop { margin: 16px 0 0; font-family: var(--f-balloon); font-weight: 600; font-size: clamp(12px, 1.2vw, 17px); }
.seedrow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-family: var(--f-cap); font-weight: 700; font-size: clamp(13px, 1.3vw, 18px); }
.seed-input {
  font-family: var(--f-cap); font-weight: 700; font-size: 1.05em; letter-spacing: .08em; color: var(--yellow); background: var(--ink); border: 3px solid var(--ink); border-radius: 6px; padding: .2em .6em; width: 21ch; outline: none; text-transform: uppercase;
}
.seed-input:focus { box-shadow: 0 0 0 3px var(--cyan); }
.seed-input.big { font-size: clamp(17px, 1.9vw, 34px); letter-spacing: .04em; width: 100%; min-width: 0; padding-inline: .4em; }

/* ================= COMBAT PAGE ================= */
#game { grid-template-columns: minmax(0, 1.95fr) minmax(340px, 1fr); }
#main-panel { background: var(--space); min-height: 0; cursor: crosshair; }
#main-panel.busy { cursor: progress; }
#stage { bottom: var(--hud-h); }
#balloons, #sfx-layer, #momentum, #flash, #plot-help, #alert-balloon { pointer-events: none; }
#balloons, #sfx-layer, #flash { position: absolute; inset: 0 0 var(--hud-h) 0; z-index: 15; overflow: hidden; }
#sfx-layer { z-index: 25; }
#flash { background: #fff; opacity: 0; z-index: 30; }
#flash.pop { animation: flash .38s ease-out; }
@keyframes flash { 0% { opacity: .85; } 100% { opacity: 0; } }
#caption { left: 3.2%; top: 4%; }
#plot-help { position: absolute; left: 50%; bottom: calc(var(--hud-h) + 10px); transform: translateX(-50%); z-index: 18; background: rgba(17,17,17,.72); color: var(--paper); padding: .25em .9em; border-radius: 99px; font-size: clamp(11px, 1vw, 15px); white-space: nowrap; transition: opacity .4s; }
#plot-help.faded { opacity: 0; }

#hud { position: absolute; left: 0; right: 0; bottom: 0; height: var(--hud-h); background: var(--ink); display: flex; align-items: center; gap: clamp(14px, 2.4vw, 40px); padding: 0 22px; z-index: 40; color: var(--paper); font-family: var(--f-cap); font-weight: 700; }
.hud-item { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.hud-label { font-style: italic; letter-spacing: .05em; font-size: clamp(13px, 1.3vw, 19px); }
.hud-val { font-size: clamp(13px, 1.3vw, 19px); }
.hud-val.warn { color: var(--orange); }
.hud-seed { opacity: .75; }
.hud-tools { margin-left: auto; gap: 8px; }
.hud-btn { font-family: var(--f-cap); font-weight: 700; font-size: clamp(11px, 1vw, 14px); color: var(--paper); background: transparent; border: 2px solid var(--paper); border-radius: 99px; padding: .05em .7em .12em; text-decoration: none; white-space: nowrap; line-height: 1.3; }
.hud-btn:hover { background: var(--yellow); color: var(--ink); border-color: var(--yellow); }
.hud-btn.off { opacity: .5; text-decoration: line-through; }
.mini-btn.off { background: var(--paper); opacity: .8; }
@media (max-width: 1500px) { .hud-seed { display: none; } }
/* a narrower panel: the HUD bar takes two rows rather than losing anything (the 3D view and its overlays all follow --hud-h) */
@media (max-width: 1320px) {
  :root { --hud-h: 82px; }
  #hud { flex-wrap: wrap; align-content: center; row-gap: 4px; column-gap: 22px; padding: 4px 18px; }
  .hud-tools { margin-left: 0; }
}
.bar { display: inline-block; width: clamp(80px, 12vw, 190px); height: 20px; border: 3px solid var(--paper); border-radius: 9px; overflow: hidden; background: #000; position: relative; }
.bar i { position: absolute; left: 0; top: 0; bottom: 0; width: 100%; transition: width .35s; }
.bar-hull i { background: repeating-linear-gradient(45deg, var(--magenta) 0 6px, #ff7aa4 6px 9px); }
.bar-solar i { background: repeating-linear-gradient(45deg, var(--yellow) 0 6px, #ffe58a 6px 9px); }
.bar-shield i { background: repeating-linear-gradient(45deg, var(--cyan) 0 6px, #8fe0ff 6px 9px); }
.bar.sm { width: 100%; height: 14px; border-width: 2px; border-color: var(--ink); border-radius: 7px; background: #fff; }
#turn-banner { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%) rotate(-2deg); z-index: 35; font-family: var(--f-title); font-size: clamp(40px, 7vw, 110px); color: var(--yellow); -webkit-text-stroke: 6px var(--ink); paint-order: stroke fill; filter: drop-shadow(6px 6px 0 var(--magenta)); animation: banner 1.7s forwards; pointer-events: none; white-space: nowrap; }
@keyframes banner { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.3) rotate(-8deg); } 14% { opacity: 1; transform: translate(-50%, -50%) scale(1.15) rotate(-2deg); } 24% { transform: translate(-50%, -50%) scale(1) rotate(-2deg); } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -50%) scale(1.05) rotate(-2deg); } }

/* momentum label hanging off the drift arrow */
.momentum { position: absolute; z-index: 22; background: var(--ink); color: var(--yellow); font-family: var(--f-cap); font-weight: 700; font-style: italic; font-size: clamp(13px, 1.35vw, 20px); padding: .12em .7em .18em; border-radius: 4px; white-space: nowrap; border: 2px solid rgba(255,210,63,.5); box-shadow: 3px 3px 0 rgba(0,0,0,.4); }
.momentum small { color: var(--paper); font-weight: 400; margin-left: .6em; font-style: normal; }

/* white warning balloon (the sector map's "night side" call-out) */
.alert-balloon {
  position: absolute; left: 3.2%; bottom: calc(var(--hud-h) + 46px); z-index: 24; max-width: min(62%, 640px); background: #fff; border: 3px solid var(--ink); border-radius: 18px 26px 16px 22px / 22px 16px 26px 18px;
  padding: .55em 1.1em; font-family: var(--f-balloon); font-weight: 700; font-size: clamp(13px, 1.35vw, 20px); line-height: 1.3; box-shadow: 4px 4px 0 rgba(17,17,17,.85); animation: balloonIn .3s cubic-bezier(.2,1.6,.4,1) both;
}
#system-balloon { left: 4%; right: 4%; bottom: 14px; max-width: none; }

/* ---------- speech balloons ---------- */
.balloon { position: absolute; font-family: var(--f-balloon); font-weight: 600; color: var(--ink); text-align: center; font-size: clamp(12px, 1.15vw, 18px); line-height: 1.28; animation: balloonIn .28s cubic-bezier(.2,1.6,.4,1) both; transition: opacity .35s, transform .35s; }
.balloon.out { opacity: 0; transform: translateY(8px) scale(.94); }
@keyframes balloonIn { from { opacity: 0; transform: scale(.4) translateY(10px); } to { opacity: 1; transform: none; } }
.balloon .who { display: block; font-family: var(--f-cap); font-style: italic; font-size: .82em; font-weight: 700; opacity: .8; text-transform: uppercase; letter-spacing: .04em; margin-bottom: .1em; }
.balloon-crew { max-width: min(330px, 38%); }
.balloon-crew .body { background: #fff; border: 3px solid var(--ink); border-radius: 50% / 48%; padding: 1em 1.5em; filter: url(#rough-sm); box-shadow: 3px 3px 0 rgba(0,0,0,.35); }
.balloon .tail { position: absolute; width: 28px; height: 32px; background: var(--ink); clip-path: polygon(0 0, 100% 0, 0% 100%); bottom: -26px; left: 22%; }
.balloon .tail::after { content: ''; position: absolute; inset: 0; transform: translate(4px, -4px) scale(.74); transform-origin: 0 0; background: #fff; clip-path: polygon(0 0, 100% 0, 0% 100%); }
.balloon-crew.flip .tail { left: auto; right: 22%; transform: scaleX(-1); }
.balloon-crew.below .tail { bottom: auto; top: -26px; transform: scaleY(-1); }
.balloon-crew.below.flip .tail { transform: scale(-1, -1); }
.balloon-radio { max-width: min(380px, 42%); background: var(--radio); border: 3px dashed var(--ink); border-radius: 26px; padding: .6em 1.1em .5em; text-align: left; box-shadow: 3px 3px 0 rgba(0,0,0,.3); }
.balloon-radio .age { display: block; font-family: var(--f-cap); font-weight: 400; font-size: .88em; opacity: .85; margin-top: .25em; }
.balloon-radio.villain { background: #ecdcf2; }
.balloon-alarm { width: min(340px, 42%); min-height: 90px; display: grid; place-items: center; padding: 1.4em 1.8em; }
.balloon-alarm svg { position: absolute; inset: -10px; width: calc(100% + 20px); height: calc(100% + 20px); overflow: visible; filter: drop-shadow(4px 4px 0 rgba(0,0,0,.45)); }
.balloon-alarm span { position: relative; font-weight: 800; font-size: 1.05em; }

/* ---------- SFX lettering ---------- */
.sfx {
  position: absolute; font-family: var(--f-title); line-height: .85; white-space: nowrap; pointer-events: none; transform-origin: 50% 60%;
  -webkit-text-stroke: .13em var(--ink); paint-order: stroke fill; letter-spacing: .02em;
  filter: drop-shadow(.07em .07em 0 var(--sh, var(--magenta))); animation: sfxPop 1.45s cubic-bezier(.2,1.7,.4,1) forwards;
}
@keyframes sfxPop { 0% { transform: translate(-50%, -50%) scale(.1) rotate(var(--rot, -6deg)); opacity: 0; } 12% { transform: translate(-50%, -50%) scale(1.28) rotate(var(--rot, -6deg)); opacity: 1; } 22% { transform: translate(-50%, -50%) scale(1) rotate(var(--rot, -6deg)); } 72% { opacity: 1; } 100% { transform: translate(-50%, -62%) scale(1.06) rotate(var(--rot, -6deg)); opacity: 0; } }

/* ================= SIDE COLUMN ================= */
#side { display: flex; flex-direction: column; gap: 14px; min-height: 0; overflow-x: hidden; overflow-y: auto; scrollbar-width: thin; }   /* last resort on a very short window: the column scrolls rather than hiding the target ship */
.comms-panel { background: var(--radio); flex: 0 1 auto; max-height: 40%; min-height: 0; display: flex; flex-direction: column; padding: 14px 16px 12px; }   /* never more than 40% of the column: the ships below always get the rest */
.chip { display: inline-block; background: var(--ink); color: var(--cyan); font-family: var(--f-cap); font-style: italic; font-weight: 700; font-size: clamp(11px, min(1.2vw, 2vh), 18px); padding: .08em .8em .14em; border-radius: 6px; margin-bottom: 8px; }
#comms-incoming { flex: 0 1 auto; min-height: 0; overflow: hidden; }
#comms-orders { flex: 0 0 auto; }
#comms-incoming .msg { background: var(--radio); border: 3px dashed var(--ink); border-radius: 26px; padding: .5em 1em; font-family: var(--f-balloon); font-weight: 700; font-size: clamp(11px, min(1.2vw, 2vh), 18px); line-height: 1.28; margin-bottom: 6px; animation: balloonIn .3s both; }
#comms-incoming .msg.old { opacity: .6; font-size: .8em; padding: .12em .8em; border-width: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 4px; }
#comms-incoming .msg.old .age { display: none; }
#comms-incoming .msg.villain { background: #ecdcf2; }
#comms-incoming .msg .age { display: block; font-family: var(--f-cap); font-weight: 400; font-size: .88em; }
#comms-incoming .static { font-family: var(--f-cap); font-style: italic; opacity: .6; padding: .4em .2em; }
.order-row { margin-top: 6px; font-family: var(--f-cap); font-weight: 700; font-size: clamp(11px, min(1.2vw, 2vh), 18px); }
.order-row .row { display: flex; justify-content: space-between; }
.order-row .track { height: 20px; border: 3px solid var(--ink); border-radius: 10px; background: #fff; overflow: hidden; margin-top: 3px; }
.order-row .track i { display: block; height: 100%; width: 0; background: repeating-linear-gradient(45deg, var(--cyan) 0 7px, #7fdcff 7px 11px); transition: width .12s linear; }
.order-row.done .track, .order-row.done .note { display: none; }   /* a delivered order shrinks to one line */
.order-row.done .track i { width: 100% !important; background: repeating-linear-gradient(45deg, #66c985 0 7px, #9be0b0 7px 11px); }
.order-row .note { font-weight: 400; font-style: italic; opacity: .8; font-size: .9em; }

.status-panel { flex: 1 1 0; min-height: min(330px, 56vh); padding: 12px 18px 12px; display: flex; flex-direction: column; background: #fff; }
.status-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.status-head h2 { margin: 0; font-family: var(--f-title); font-weight: 400; font-size: clamp(18px, min(2.2vw, 3.8vh), 34px); letter-spacing: .01em; line-height: 1; }
.target-head { margin-top: 8px; }
.villain { color: var(--violet); }
.nick { font-family: var(--f-cap); font-style: italic; font-size: .5em; color: #6a5a78; white-space: nowrap; }
.tag { font-family: var(--f-cap); font-weight: 700; font-size: clamp(11px, 1.05vw, 16px); padding: .05em .7em .1em; border-radius: 8px; border: 2px solid var(--ink); white-space: nowrap; }
.tag-ok { background: #d8f3de; } .tag-bad { background: var(--magenta); color: var(--ink); transform: rotate(-2deg); } .tag-aim { background: var(--cyan); }
.cut { flex: 1 1 0; min-height: 56px; margin: 2px 0; }
.cut svg { width: 100%; height: 100%; display: block; overflow: visible; }
.status-lines { font-family: var(--f-balloon); font-weight: 600; font-size: clamp(10.5px, min(1.05vw, 1.9vh), 15px); line-height: 1.32; min-height: 3.9em; }
.status-lines div { margin-bottom: 1px; }
.status-lines .bad { color: #b3153f; }
.enemy-bars { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 4px; }
.mini-bar { display: grid; grid-template-columns: auto 1fr auto; gap: 6px; align-items: center; font-family: var(--f-cap); font-weight: 700; font-size: clamp(11px, 1vw, 15px); }

/* cutaway rooms */
.room { cursor: default; transition: filter .15s; }
.room .shape { stroke: var(--ink); stroke-width: 3.2; stroke-linejoin: round; }
.room text { font-family: var(--f-cap); font-weight: 700; font-size: 15px; fill: var(--ink); text-anchor: middle; pointer-events: none; }
.room .pct { font-family: var(--f-title); font-size: 17px; fill: var(--ink); stroke: #fff; stroke-width: 3.5px; paint-order: stroke fill; display: none; }
.cut-enemy .room { cursor: pointer; }
.cut-enemy .room:hover .shape { filter: brightness(1.12); }
.cut-enemy .pct { display: block; }
.room.sel .shape { stroke: var(--cyan); }
.selring { fill: none; stroke: none; pointer-events: none; }
.room.sel .selring { stroke: var(--cyan); stroke-width: 5.5; stroke-dasharray: 9 5; animation: marching .8s linear infinite; }
@keyframes marching { to { stroke-dashoffset: -14; } }
.room.hit .shape { animation: roomHit .5s; }
@keyframes roomHit { 0% { filter: brightness(3); } 100% { filter: none; } }
.room .dmg { pointer-events: none; }

/* ---------- action buttons ---------- */
#actions { display: grid; grid-template-columns: 1fr 1.25fr 1.2fr; gap: 12px; padding: 4px 8px 8px 4px; }
#actions .btn { font-size: clamp(20px, 2.1vw, 34px); padding-inline: .25em; white-space: nowrap; }
#btn-fire.busy { animation: pulse .8s infinite alternate; }
@keyframes pulse { to { transform: rotate(-1.4deg) scale(1.04); } }

/* ---------- popovers ---------- */
.popover { position: fixed; z-index: 500; background: var(--paper-light); border: 4px solid var(--ink); border-radius: 8px 14px 8px 12px; box-shadow: 7px 7px 0 var(--ink); padding: 8px; display: grid; gap: 6px; min-width: 300px; max-width: 380px; animation: balloonIn .2s both; }
.pop-btn { text-align: left; background: #fff; border: 3px solid var(--ink); border-radius: 8px; padding: .35em .8em .4em; display: grid; gap: 0; transition: transform .08s; }
.pop-btn b { font-family: var(--f-title); font-weight: 400; font-size: 22px; letter-spacing: .03em; }
.pop-btn small { font-family: var(--f-cap); font-weight: 400; font-size: 14px; opacity: .85; }
.pop-btn:hover { background: var(--yellow); transform: translateX(3px); }
.pop-btn:disabled { opacity: .4; cursor: not-allowed; }
.pop-btn.order b { color: #0b5a7a; }

/* ================= SECTOR MAP ================= */
#map-screen { grid-template-columns: minmax(0, 1.95fr) minmax(340px, 1fr); }
#map-panel { background: var(--space); } #map-panel canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: pointer; }
#map-caption { left: 3%; top: 4%; }
#map-side { display: grid; grid-template-rows: minmax(0, 1fr) auto; gap: 14px; min-height: 0; }
#system-card { background: var(--space); } #system-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
#seed-panel { padding: 14px 18px 16px; background: #fff; }
.seed-label { font-family: var(--f-cap); font-style: italic; font-weight: 700; font-size: clamp(14px, 1.3vw, 19px); margin-bottom: 4px; }
.seed-line { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; }
.seed-help { font-family: var(--f-balloon); font-weight: 600; font-size: clamp(11px, 1.05vw, 15px); margin: 8px 0 10px; }
.seed-buttons { display: flex; gap: 10px; flex-wrap: wrap; }

/* ================= END CARD ================= */
#end-card { position: fixed; inset: 0; z-index: 400; background: rgba(17,17,17,.55); display: grid; place-items: center; animation: fadein .4s both; }
@keyframes fadein { from { opacity: 0; } }
.end-panel { background: var(--paper-light); padding: 26px 34px 28px; text-align: center; max-width: min(720px, 92vw); transform: rotate(-.8deg); box-shadow: 10px 10px 0 var(--ink); overflow: visible; }
.end-title { font-family: var(--f-title); font-size: clamp(44px, 7vw, 100px); line-height: .95; color: var(--yellow); -webkit-text-stroke: .1em var(--ink); paint-order: stroke fill; filter: drop-shadow(.06em .06em 0 var(--magenta)); }
.end-panel .caption { position: static; display: inline-block; margin: 14px 0 12px; max-width: 100%; }
.end-stats { font-family: var(--f-balloon); font-weight: 600; font-size: clamp(13px, 1.3vw, 19px); display: grid; grid-template-columns: repeat(3, auto); gap: 6px 22px; justify-content: center; margin-bottom: 18px; }
.end-stats b { font-family: var(--f-title); font-weight: 400; font-size: 1.9em; display: block; line-height: 1; }
.end-buttons { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; }

/* ================= small screens ================= */
@media (max-width: 1000px) {
  html, body { overflow: auto; }
  #page { position: static; min-height: 100%; }
  .screen { position: static; }
  #game, #map-screen { grid-template-columns: 1fr; }
  #main-panel { height: 66vh; min-height: 420px; }
  #map-panel { height: 60vh; }
  #system-card { height: 280px; }
  .status-panel { min-height: 520px; }
  #cover { height: auto; }
  #cover-art { height: 62vh; }
}

/* ================= MISSION BRIEFING (a comic page over the left of the stage; the ships stay in view on the right) ================= */
#briefing { position: absolute; inset: 0 0 var(--hud-h) 0; z-index: 45; display: flex; align-items: center; justify-content: flex-start; padding: 3% 3% 3% 3.2%;
  background: linear-gradient(90deg, rgba(8,10,28,.78) 0%, rgba(8,10,28,.5) 55%, rgba(8,10,28,0) 82%); animation: fadein .35s both; }
.brief-card { width: min(50%, 560px); max-height: 100%; overflow: auto; background: var(--paper-light); padding: 16px 20px 14px; transform: rotate(-.6deg); box-shadow: 8px 8px 0 rgba(0,0,0,.5); display: flex; flex-direction: column; gap: 8px; }
.brief-head { display: flex; justify-content: space-between; font-family: var(--f-cap); font-style: italic; font-weight: 700; font-size: clamp(11px, 1vw, 15px); opacity: .75; }
.brief-title { margin: 0; font-family: var(--f-title); font-weight: 400; font-size: clamp(24px, 3vw, 44px); line-height: 1; letter-spacing: .01em; }
.brief-caption { position: static; display: block; max-width: 100%; transform: none; font-size: clamp(11px, min(1.2vw, 2vh), 18px); text-transform: none; font-style: normal; line-height: 1.3; box-shadow: 4px 4px 0 rgba(17,17,17,.9); filter: none; }
.brief-lines { display: flex; flex-direction: column; gap: 10px; margin: 4px 0; }
.bline { font-family: var(--f-balloon); font-weight: 600; font-size: clamp(12px, 1.15vw, 17px); line-height: 1.3; position: relative; animation: balloonIn .3s both; }
.bline .who { display: block; font-family: var(--f-cap); font-style: italic; font-size: .82em; font-weight: 700; opacity: .8; text-transform: uppercase; letter-spacing: .04em; }
.bline .age { display: block; font-family: var(--f-cap); font-weight: 400; font-size: .86em; opacity: .85; margin-top: .2em; }
.bline-crew { background: #fff; border: 3px solid var(--ink); border-radius: 26px / 22px; padding: .6em 1.1em; margin-right: 12%; }
.bline-radio { background: var(--radio); border: 3px dashed var(--ink); border-radius: 22px; padding: .55em 1.1em; margin-left: 6%; }
.bline-villain { background: #ecdcf2; border: 3px dashed #4a2a66; border-radius: 22px; padding: .55em 1.1em; margin-left: 12%; }
.bline-crew::after { content: ''; position: absolute; left: 18%; bottom: -13px; width: 18px; height: 16px; background: var(--ink); clip-path: polygon(0 0, 100% 0, 0 100%); }
.brief-foot { display: flex; justify-content: space-between; gap: 12px; margin-top: 2px; }
.end-story { font-family: var(--f-balloon); font-weight: 600; font-size: clamp(13px, 1.25vw, 18px); line-height: 1.4; max-width: 56ch; margin: 0 auto 14px; }
#comms-incoming .mission { font-family: var(--f-cap); font-weight: 700; font-size: clamp(12px, 1.15vw, 17px); line-height: 1.3; padding: .2em .1em .3em; }
#comms-incoming .mission b { color: #b3153f; font-style: italic; }
@media (max-width: 1000px) { .brief-card { width: 94%; } }
.hidden { display: none !important; }
#main-panel.briefing-on :is(#caption, #momentum, #plot-help, #alert-balloon, #balloons, #sfx-layer) { visibility: hidden; }
