:root {
  --bg: #14161d;
  --panel: rgba(22, 24, 32, 0.94);
  --panel-2: rgba(36, 40, 52, 0.96);
  --line: rgba(255, 255, 255, 0.09);
  --text: #eef1f5;
  --muted: #9ba4b4;
  --accent: #38d4ff;
  --accent-ink: #062330;
  --danger: #ff5a6e;
  --good: #7ee08a;
  --warn: #ffc457;
  --radius: 14px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --g-fiber: #3fd8a6; --g-stone: #c9c1b4; --g-ore: #ff8a3d; --g-crystal: #b98cff; --g-alloy: #8ec3e6; --g-chip: #c8f05a;
  --g-crude: #b08a6e; --g-fuel: #ff5c8a; --g-cement: #a9b4c2; --g-asphalt: #6b7280; --g-ammo: #e8c39e; --g-uranium: #9dff3a; --g-fissile: #e6ff4a;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none; touch-action: none; user-select: none; -webkit-user-select: none;
  -webkit-touch-callout: none; /* no Copy / Save image bubble on a long press (iOS) */
}
[hidden] { display: none !important; }
canvas#game { position: fixed; inset: 0; display: block; touch-action: none; }
button { font: inherit; color: inherit; cursor: pointer; }
#hud small, #screen-pause small, #screen-stats small, #screen-boost small, #screen-help small { font-size: 12px; } /* (nothing in a game is set smaller than 12 px) */

/* ---------- top bar ---------- */
#topbar {
  position: fixed; top: 0; left: 0; right: 0;
  padding: calc(var(--safe-t) + 6px) calc(var(--safe-r) + 8px) 0 calc(var(--safe-l) + 8px);
  display: flex; flex-direction: column; gap: 6px; pointer-events: none; z-index: 5;
}
#topbar > * { pointer-events: auto; }
/* Installed on iPhone the page can run under the status bar: keep that strip solid (on every
   screen), not the map seen through it. On other devices the inset is 0 and this draws nothing. */
body::before {
  content: ''; position: fixed; left: 0; right: 0; top: 0; height: var(--safe-t); background: #0b0c10;
  pointer-events: none; z-index: 100;
}
.goods { display: grid; grid-template-columns: repeat(var(--goods-cols, 7), 1fr); gap: 4px; }
.res-chip {
  display: flex; align-items: center; justify-content: center; gap: 5px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 5px 4px; font-weight: 700; font-variant-numeric: tabular-nums; font-size: 14px; min-width: 0;
}
.goods.two-rows { gap: 3px; }
.goods.two-rows .res-chip { padding: 3px 4px; font-size: 13px; border-radius: 8px; }
.res-chip.flash { animation: flash 0.6s; }
.res-chip { cursor: default; }
#good-tip {
  position: fixed; z-index: 19; max-width: 230px; pointer-events: none;
  background: #0d0f15; border: 1px solid rgba(255, 255, 255, 0.16); border-radius: 10px; padding: 7px 10px;
  font-size: 13px; line-height: 1.35; box-shadow: 0 8px 22px rgba(0, 0, 0, 0.5);
}
#good-tip b { font-size: 14px; }
#good-tip em { font-style: normal; color: var(--muted); font-variant-numeric: tabular-nums; }
#good-tip span { display: block; color: #c9d0db; margin-top: 2px; }
@keyframes flash { from { background: rgba(126, 224, 138, 0.35); } }
.gi { width: 12px; height: 12px; border-radius: 3px; flex: none; box-shadow: inset 0 -2px 0 rgba(0,0,0,0.25); }
/* A cost inside a sentence (the Viaduct and Ropeway prompts): icon, amount and name, kept together. */
.cost-inline > span { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; font-weight: 600; }
.cost-inline .gi { display: inline-block; }
.cost-inline .short { color: var(--danger); }
.gi.fiber { background: var(--g-fiber); border-radius: 50% 50% 50% 0; }
.gi.stone { background: var(--g-stone); }
.gi.ore { background: var(--g-ore); clip-path: polygon(15% 30%, 50% 0, 100% 25%, 85% 85%, 25% 100%); border-radius: 0; }
.gi.crystal { background: var(--g-crystal); clip-path: polygon(50% 0, 100% 40%, 50% 100%, 0 40%); border-radius: 0; }
.gi.alloy { background: var(--g-alloy); border-radius: 2px; height: 8px; }
.gi.crude { background: #2a211b; border: 2px solid var(--g-crude); border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%; width: 11px; height: 12px; }
.gi.fuel { background: var(--g-fuel); border-radius: 3px 3px 2px 2px; width: 10px; height: 13px; box-shadow: inset 0 3px 0 rgba(255,255,255,0.35); }
.gi.cement { background: var(--g-cement); border-radius: 2px; width: 12px; height: 10px; box-shadow: inset 0 -3px 0 rgba(0,0,0,0.2); }
.gi.asphalt { background: #2a2d33; border: 2px solid var(--g-asphalt); border-radius: 3px; width: 12px; height: 10px; }
.gi.ammo { width: 12px; height: 12px; border-radius: 0; box-shadow: none;
  background: linear-gradient(90deg, var(--g-ammo) 0 3px, transparent 3px 4.5px, var(--g-ammo) 4.5px 7.5px, transparent 7.5px 9px, var(--g-ammo) 9px 12px);
  clip-path: polygon(0 25%, 12.5% 0, 25% 25%, 37.5% 0, 50% 25%, 62.5% 0, 75% 25%, 87.5% 0, 100% 25%, 100% 100%, 0 100%); }
.gi.uranium { background: var(--g-uranium); clip-path: polygon(50% 0, 80% 35%, 70% 100%, 30% 100%, 20% 35%); border-radius: 0; box-shadow: 0 0 6px var(--g-uranium); }
.gi.fissile { background: radial-gradient(circle, #ffffff 0 22%, var(--g-fissile) 24% 60%, #7fa21a 62%); border-radius: 50%; box-shadow: 0 0 6px var(--g-fissile); }
.gi.warhead { background: #ffcf4a; clip-path: polygon(50% 0, 85% 30%, 85% 100%, 15% 100%, 15% 30%); border-radius: 0; }
.gi.chip { background: var(--g-chip); border-radius: 2px; outline: 2px dotted var(--g-chip); outline-offset: 1px; width: 9px; height: 9px; }
.toprow { display: flex; gap: 6px; }
.chip {
  display: flex; align-items: center; gap: 6px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 5px 9px; font-weight: 600; font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap;
}
#pop { flex: 1; min-width: 0; overflow: hidden; }
.chip-btn { min-width: 44px; justify-content: center; }
.chip-btn:active, .btn:active, .tool:active { transform: scale(0.96); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.objective {
  align-self: flex-start; max-width: 100%; text-align: left; background: #12303a;
  border: 1px solid rgba(56, 212, 255, 0.45); border-radius: 10px; padding: 6px 10px; font-size: 13px; color: #d9f6ff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}
.objective b { color: var(--accent); }
/* The goal card and, beside it, the button that brings back the messages that have gone by. */
.objrow { align-self: flex-start; max-width: 100%; display: flex; align-items: flex-start; gap: 6px; }
.objrow .objective { align-self: auto; min-width: 0; }
.msgs-btn { flex: none; min-height: 32px; padding: 5px 8px; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3); }
/* Planet event under way (or coming): name, countdown, what it does; the trader's deal. */
.event-card {
  align-self: flex-start; max-width: min(100%, 420px); background: #2a2216; border: 1px solid rgba(255, 196, 120, 0.45);
  border-radius: 10px; padding: 6px 10px; font-size: 13px; color: #ffeedd; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
  display: flex; flex-direction: column; gap: 3px;
}
.event-card.trader { background: #10303a; border-color: rgba(127, 227, 255, 0.5); color: #dff8ff; }
/* A nuclear missile on its way: countdown and the Evacuate button. */
.event-card.nuke { background: #2a1214; border-color: rgba(255, 90, 90, 0.7); color: #ffe4e4; animation: nukepulse 1s ease-in-out infinite alternate; }
.event-card.nuke.safe { animation: none; border-color: rgba(157, 255, 58, 0.55); }
@keyframes nukepulse { from { box-shadow: 0 0 6px rgba(255, 60, 60, 0.35); } to { box-shadow: 0 0 18px rgba(255, 60, 60, 0.75); } }
@media (prefers-reduced-motion: reduce) { .event-card.nuke { animation: none; } }
.event-card .ev-head { display: flex; align-items: center; gap: 7px; }
.event-card .ev-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; box-shadow: 0 0 8px currentColor; }
.event-card .ev-time { margin-left: auto; font-variant-numeric: tabular-nums; opacity: 0.85; font-weight: 700; }
.event-card .ev-desc { opacity: 0.9; line-height: 1.3; }
.event-card .ev-cargo { font-size: 11.5px; font-style: italic; opacity: 0.7; line-height: 1.3; contain: inline-size; } /* (the Wren's out-of-date cargo list: it wraps
   inside the width the name and the deal give the card, never widening it) */
.event-card .ev-deal { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.event-card .ev-deal .gi { vertical-align: -3px; }
.event-card .btn { padding: 4px 12px; }
/* How the game is won, if not by capture (Domination): where each colony stands, and the countdown. */
/* The win card folded under the Goal chip: a dot per Uplink (or your land share) and the time. */
#objective .win-mini { display: inline-flex; align-items: center; gap: 4px; margin-left: 6px; font-variant-numeric: tabular-nums; }
#objective .win-mini i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; box-shadow: 0 0 0 1.5px rgba(255, 255, 255, 0.85) inset; }
#objective .win-mini i.free { box-shadow: 0 0 0 1.5px rgba(223, 239, 255, 0.8) inset; }
.event-card.win-card { background: #14202e; border-color: rgba(127, 200, 255, 0.4); color: #e2f1ff; min-width: min(100%, 260px); cursor: pointer; }
.event-card.win-card.mine { border-color: rgba(91, 224, 108, 0.65); }
.event-card.win-card.theirs { border-color: rgba(255, 90, 110, 0.75); }
.win-rows { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 3px 8px; font-size: 12px; }
.win-rows .wn { opacity: 0.92; white-space: nowrap; }
.win-rows .wp { font-variant-numeric: tabular-nums; font-weight: 700; text-align: right; }
.win-bar { position: relative; height: 8px; border-radius: 4px; background: rgba(255, 255, 255, 0.1); }
.win-bar i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; background: var(--c); }
.win-bar b { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; background: #fff; opacity: 0.8; border-radius: 1px; }
.win-note { font-size: 12px; opacity: 0.75; }
.up-dots { display: flex; gap: 6px; }
.up-dots i { width: 14px; height: 14px; border-radius: 50%; background: var(--c); border: 2px solid rgba(255, 255, 255, 0.85); box-sizing: border-box; }
.up-dots i.free { background: transparent; border-color: rgba(255, 255, 255, 0.5); }
.up-dots i.jam { animation: upjam 0.5s steps(2) infinite; }
@keyframes upjam { 50% { background: transparent; } }
@media (prefers-reduced-motion: reduce) { .up-dots i.jam { animation: none; } }
/* Research Lab panel */
.research-now { margin-bottom: 8px; }
.research-now .kv { align-items: center; }
.tech-list { display: flex; flex-direction: column; gap: 6px; }
.tech { border: 1px solid var(--line); border-radius: 10px; padding: 7px 10px; background: rgba(255, 255, 255, 0.03); }
.tech.done { opacity: 0.6; }
.tech.now { border-color: var(--accent); }
.tech-head { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; }
.tech-head span { color: var(--muted); font-variant-numeric: tabular-nums; }
.tech p { margin: 3px 0 0; font-size: 13px; line-height: 1.35; color: #c9cfdb; }
.tech-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px; }
.tech-foot .bcost { display: flex; gap: 8px; font-size: 13px; font-weight: 700; }
.tech-foot .bcost span { display: inline-flex; align-items: center; gap: 3px; }
.tech-foot .bcost .short { color: #ff8a8a; }
.objective.small { opacity: 0.85; }

/* ---------- minimap ---------- */
.minimap {
  position: fixed; right: calc(var(--safe-r) + 8px); top: calc(var(--safe-t) + 96px); z-index: 5;
  border: 1px solid rgba(255, 255, 255, 0.2); border-radius: 10px; overflow: hidden; background: #0c0d11;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45); touch-action: none;
}
.minimap canvas { display: block; touch-action: none; cursor: crosshair; }
.mm-hide {
  position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; padding: 0; border-radius: 7px; border: 0;
  background: rgba(14, 15, 20, 0.72); color: var(--text); display: grid; place-items: center;
}
.mm-show { position: fixed; right: calc(var(--safe-r) + 8px); top: calc(var(--safe-t) + 96px); z-index: 5; min-height: 36px; }
/* Under a finger the minimap's close button hangs under it as a tab, 44 px to press. On the minimap itself, sized
   for a finger, it took the taps meant for the map beneath (the top right corner, where a rival's base often is). */
@media (pointer: coarse) {
  .minimap { overflow: visible; }
  .minimap canvas { border-radius: 9px; }
  .mm-hide { top: calc(100% + 1px); right: 8px; width: 44px; height: 24px; border-radius: 0 0 10px 10px;
    background: #0c0d11; border: 1px solid rgba(255, 255, 255, 0.2); border-top: 0; box-shadow: 0 6px 12px rgba(0, 0, 0, 0.35); }
  .mm-hide::after { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 44px; }
  .mm-show { min-width: 44px; min-height: 44px; }
}
body.mm-on .objrow { margin-right: calc(var(--mm-w, 100px) + 8px); }
body.mm-off .objrow { margin-right: 54px; }
@media (max-width: 999px) {
  body.mm-on .event-card { margin-right: calc(var(--mm-w, 100px) + 8px); } /* (an event's card keeps clear of the minimap, as the goal card does) */
  body.mm-on #toasts { left: calc(var(--safe-l) + 8px); right: calc(var(--safe-r) + var(--mm-w, 100px) + 16px); width: auto; transform: none; }
}

/* ---------- toasts ---------- */
#toasts {
  position: fixed; left: 50%; transform: translateX(-50%); top: calc(var(--safe-t) + 150px);
  width: min(94vw, 460px); display: flex; flex-direction: column; gap: 5px; z-index: 6; pointer-events: none;
}
/* A message lets taps through to the map under it; only its Go chip (there when it has a place to show) takes them. */
.toast {
  pointer-events: none; display: flex; align-items: center; gap: 8px; background: #252a36; border: 1px solid var(--line); border-left: 4px solid var(--accent);
  border-radius: 10px; padding: 6px 10px; font-size: 13px; text-align: left; box-shadow: 0 6px 20px rgba(0,0,0,0.35); animation: toastIn 0.25s;
}
.toast.bad { border-left-color: var(--danger); }
.toast.good { border-left-color: var(--good); }
.toast.warn { border-left-color: var(--warn); }
/* A building of yours destroyed: red, bold, and it stays a while (tap it to look). */
.toast.lost { border-left-color: var(--danger); background: #3a2026; border-color: rgba(255, 90, 110, 0.45); font-weight: 700; }
.toast.lost::before { content: '\26A0\FE0E  '; color: var(--danger); }
.toast.out { opacity: 0; transition: opacity 0.4s; }
/* The story's lines: the narrator (your Command AI's log) and a rival's voice. Quiet: italic, a muted edge. */
.toast.narr, .toast.voice { font-style: italic; color: #cfd6e2; background: #1f232d; }
.toast.narr { border-left-color: #8c96a8; }
.toast.voice { border-left-color: #b98cff; }
.msg-row.narr span:nth-child(2), .msg-row.voice span:nth-child(2) { font-style: italic; }
.toast > span { flex: 1 1 auto; min-width: 0; }
.toast-go { pointer-events: auto; flex: none; align-self: stretch; min-width: 44px; min-height: 30px; margin: -3px -6px -3px 0; padding: 0 10px;
  border: 1px solid rgba(56, 212, 255, 0.5); border-radius: 8px; background: rgba(56, 212, 255, 0.12); color: var(--accent); font-weight: 700; }
/* The message list (the button beside the goal card). */
.msg-list { display: flex; flex-direction: column; }
.msg-row { display: grid; grid-template-columns: 44px 1fr auto; gap: 8px; align-items: center; padding: 8px 0 8px 8px; border-top: 1px solid var(--line);
  border-left: 3px solid var(--accent); font-size: 14px; }
.msg-row.bad, .msg-row.lost { border-left-color: var(--danger); } .msg-row.good { border-left-color: var(--good); } .msg-row.warn { border-left-color: var(--warn); }
.msg-row .msg-t { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.msg-row .btn { min-width: 44px; }
/* The building the goal card asks for, pinned at the top of the Build list whichever tab is showing. */
.bcard.next { grid-column: 1 / -1; border-color: rgba(56, 212, 255, 0.6); background: rgba(56, 212, 255, 0.08); }
.bcard.next .bhave::before { content: 'Next step · '; color: var(--accent); font-weight: 700; }
@keyframes toastIn { from { transform: translateY(-8px); opacity: 0; } }

/* ---------- the briefing at the start of a game ---------- */
.briefing {
  position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center;
  padding: calc(var(--safe-t) + 12px) calc(var(--safe-r) + 12px) calc(var(--safe-b) + 12px) calc(var(--safe-l) + 12px);
  background: rgba(6, 9, 14, 0.55); cursor: pointer; animation: toastIn 0.25s;
}
.briefing[hidden] { display: none; }
.br-card {
  width: min(100%, 520px); max-height: 100%; display: flex; flex-direction: column; gap: 10px;
  background: #1d2230; border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px 12px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5);
}
.br-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; font-size: 16px; }
.br-state { font-size: 12px; color: var(--muted, #9aa3b5); text-transform: uppercase; letter-spacing: 0.08em; }
.br-narr { margin: 0; font-size: 13px; font-style: italic; line-height: 1.4; color: var(--muted, #9aa3b5); }
.br-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 7px; min-height: 0; }
.br-list li { background: #252a36; border-left: 4px solid var(--accent); border-radius: 8px; padding: 7px 10px; font-size: 13.5px; line-height: 1.4; }
.br-list li.warn { border-left-color: var(--warn); }
.br-list li.bad { border-left-color: var(--danger); }
.br-list li.good { border-left-color: var(--good); }
.br-foot { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--muted, #9aa3b5); }
.br-foot > span:first-child { flex: none; font-weight: 600; color: var(--accent); }
.br-bar { flex: 1; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.br-bar i { display: block; height: 100%; width: 100%; background: var(--accent); }

/* ---------- bottom bar ---------- */
#bottombar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  padding: 8px calc(var(--safe-r) + 8px) calc(var(--safe-b) + 8px) calc(var(--safe-l) + 8px);
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
  background: linear-gradient(to top, rgba(14, 15, 20, 0.85), rgba(14, 15, 20, 0));
}
#bottombar.three { grid-template-columns: repeat(3, 1fr); }
.tool {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px 7px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); font-size: 12px; font-weight: 600;
}
.tool svg { width: 24px; height: 24px; }
.tool kbd, .seg kbd, .bcard kbd, #banner-traffic kbd, #banner-route kbd { display: none; }
kbd {
  display: inline-block; min-width: 1.5em; padding: 0 5px; border-radius: 5px; border: 1px solid rgba(255,255,255,0.25);
  border-bottom-width: 2px; font: 600 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; text-align: center; color: var(--text);
}
.tool.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* ---------- banner (placement / path / attack modes) ---------- */
#banner {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--safe-b) + 84px); z-index: 7;
  width: min(94vw, 460px); background: #252a36; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 12px; box-shadow: 0 8px 28px rgba(0,0,0,0.45);
}
#banner-text { font-size: 14px; margin-bottom: 8px; }
#banner-text .err { color: var(--danger); }
#banner-text .keep-all { display: flex; align-items: center; gap: 8px; margin-top: 8px; color: var(--muted); font-size: 13px; }
#banner-text .keep-all .seg button { padding: 4px 12px; }
#banner-text #strike-kind button { flex: none; white-space: nowrap; } /* the bomber's payload: Bomb or Napalm */
#banner-text .ok { color: var(--good); }
.banner-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.banner-actions .road-seg { flex: 1 1 100%; }
#banner-traffic.on, #banner-route.on { background: var(--accent); color: var(--accent-ink); }
.banner-actions .road-seg button { padding: 7px 4px; }
/* The Paths tools wrap onto a second row instead of running off the side (the page can't be swiped
   sideways: touches go to the map). */
.banner-actions .road-seg { flex-wrap: wrap; }
.banner-actions .road-seg button { flex: 1 0 auto; min-width: 64px; }
.banner-actions .btn { flex: 1; }

/* ---------- bottom sheet ---------- */
/* A panel opens at half height, so the map (and what the panel is about) stays in view above it; its grab
   handle takes it to full height or down to its title strip (setSheetSize). Lists and charts open full. The
   body scrolls inside; the handle and the close button stay put. */
#sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 8; max-height: 46vh; max-height: 46dvh; display: flex; flex-direction: column;
  background: #181a22; border-top: 1px solid var(--line); border-radius: 18px 18px 0 0;
  box-shadow: 0 -10px 40px rgba(0,0,0,0.5); animation: sheetIn 0.22s ease-out;
}
/* (dvh: the height that is really showing. A phone browser's vh counts the space under its own bars; vh stays as
   the fallback for browsers without dvh.) Full height reaches up to the goods and the clock, which stay in view. */
#sheet.full { max-height: calc(100vh - var(--hud-top, 130px)); max-height: calc(100dvh - var(--hud-top, 130px)); }
#sheet.peek { max-height: 80px; }
#sheet-body {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; touch-action: pan-y; overscroll-behavior: contain;
  padding: 2px calc(var(--safe-r) + 14px) calc(var(--safe-b) + 16px) calc(var(--safe-l) + 14px);
}
#sheet.peek #sheet-body { overflow: hidden; }
.sheet-grab { flex: none; position: relative; height: 22px; padding: 0; border: 0; background: none; touch-action: none; cursor: ns-resize; }
.sheet-grab::before { content: ''; position: absolute; left: 50%; top: 9px; width: 40px; height: 5px; margin-left: -20px; border-radius: 3px; background: rgba(255, 255, 255, 0.28); }
/* 44 px to take hold of: the strip, and as much again above the panel's edge. */
.sheet-grab::after { content: ''; position: absolute; left: 0; right: 0; top: -22px; bottom: 0; }
@keyframes sheetIn { from { transform: translateY(30px); opacity: 0.4; } }
@media (min-width: 700px) { #sheet { left: 50%; right: auto; width: 520px; transform: translateX(-50%); animation: none; } }
/* While a panel is open across the bottom the goal card steps aside: the map between the two is what's left to see. */
@media (max-width: 999px), (max-height: 519px) { body.sheet-open .objrow { display: none; } }
.sheet-close {
  position: absolute; top: 12px; right: calc(var(--safe-r) + 10px); width: 36px; height: 36px; border-radius: 50%;
  background: #262933; border: 0; display: grid; place-items: center; z-index: 1;
}
.sheet-title { display: flex; align-items: center; gap: 10px; margin: 0 40px 6px 0; }
.sheet-title img { width: 46px; height: 46px; }
.sheet-title h3 { margin: 0; font-size: 18px; }
.sheet-title .owner { font-size: 12px; color: var(--muted); font-weight: 600; }
.desc { color: var(--muted); margin: 0 0 10px; font-size: 14px; }
/* A panel's line of flavour (FLAVOR): one quiet line at the foot, below everything useful. */
.flavor { margin: 12px 0 2px; font-size: 12px; font-style: italic; line-height: 1.35; color: var(--muted); opacity: 0.8; }
.flavor.clock { margin: 2px 0 0; } /* (the Command Base's Arrival clock, under its name) */
.status { font-weight: 600; margin: 6px 0 10px; }
.kv { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-top: 1px solid var(--line); font-size: 14px; }
.trade-row { align-items: center; }
.trade-row small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.trade-row.on > span { color: var(--accent); }
.kv span:last-child { font-weight: 600; text-align: right; }
.bar { height: 8px; border-radius: 4px; background: rgba(255,255,255,0.08); overflow: hidden; margin: 4px 0 10px; }
.bar > div { height: 100%; background: var(--accent); }
.bar.armor > div { background: var(--warn); }
.goodlist { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 10px; }
.gtag {
  display: inline-flex; align-items: center; gap: 5px; padding: 4px 8px; border-radius: 8px; font-size: 13px; font-weight: 600;
  background: rgba(255,255,255,0.06); font-variant-numeric: tabular-nums;
}
.gtag.short { color: var(--danger); }
.gtag.toggle { border: 1px solid var(--line); }
.gtag.toggle b { font-variant-numeric: tabular-nums; }
.gtag.toggle.off { opacity: 0.4; text-decoration: line-through; }
.hint { color: var(--muted); font-size: 13px; margin: 6px 0 4px; }
.label-note { text-transform: none; letter-spacing: 0; font-weight: 500; margin-left: 6px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.actions .btn { flex: 1 1 auto; }
.section-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 10px 0 2px; font-weight: 700; }

/* build menu */
.build-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-top: 8px; }
.build-grid .bcard[hidden] { display: none; }
/* Build menu tabs (All, Gather, Make, Move, Defend), each with how many buildings it holds. */
.build-tabs { margin-top: 6px; overflow-x: auto; scrollbar-width: none; }
.build-tabs::-webkit-scrollbar { display: none; }
.build-tabs button { white-space: nowrap; padding: 8px 10px; display: inline-flex; align-items: center; justify-content: center; gap: 5px; }
.build-tabs .n { font-size: 12px; font-weight: 700; opacity: 0.65; background: rgba(255,255,255,0.08); border-radius: 8px; padding: 1px 6px; }
@media (max-width: 480px) { .build-tabs button { padding: 8px 4px; font-size: 13px; } .build-tabs .n { display: none; } }
.bcard {
  display: grid; grid-template-columns: 44px 1fr; gap: 2px 8px; align-items: center; text-align: left;
  background: rgba(255,255,255,0.04); border: 1px solid var(--line); border-radius: 12px; padding: 8px;
}
.bcard img { width: 44px; height: 44px; grid-row: span 2; }
.bcard.roads svg { width: 44px; height: 44px; grid-row: span 2; padding: 6px; color: var(--accent); }
.bcard.roads { border-style: dashed; }
.bcard .bname { font-weight: 700; font-size: 14px; line-height: 1.15; }
.bcard .bcost { display: flex; gap: 6px; flex-wrap: wrap; font-size: 12px; font-weight: 600; }
.bcard .bcost span { display: inline-flex; align-items: center; gap: 3px; }
.bcard .bcost .short { color: var(--danger); }
.bcard .bhave { grid-column: 2; font-size: 12px; color: var(--muted); font-weight: 600; min-height: 15px; }
.bcard .bhave.some { color: var(--accent); }
.bcard { grid-template-rows: auto auto auto; }
.bcard img { grid-row: span 3; }
.bcard:disabled { opacity: 0.45; }

/* ---------- buttons ---------- */
.btn {
  border: 1px solid var(--line); background: rgba(255,255,255,0.07); border-radius: 12px; padding: 10px 14px; font-weight: 700;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { background: rgba(255, 90, 110, 0.15); color: #ffb3bd; border-color: rgba(255, 90, 110, 0.4); }
.btn.big { width: 100%; padding: 14px; font-size: 16px; margin-top: 8px; }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: 0.45; }
.stepper { display: flex; align-items: center; gap: 10px; margin: 6px 0; }
.order-row { display: grid; grid-template-columns: 30px 1fr 56px 56px 64px; align-items: center; gap: 8px; margin: 6px 0; font-weight: 700; font-size: 16px; border-radius: 10px; }
.order-row.yard-row { grid-template-columns: 1fr 56px 56px 64px; }
.order-row.next { background: rgba(56, 212, 255, 0.08); box-shadow: inset 0 0 0 1px rgba(56, 212, 255, 0.35); }
.order-move { display: flex; flex-direction: column; gap: 2px; }
.order-row .order-move .btn { padding: 1px 0; font-size: 11px; line-height: 1.2; min-height: 0; }
.order-move .btn:disabled { opacity: 0.25; }
.order-row small { display: block; font-size: 13px; font-weight: 600; color: var(--accent); font-variant-numeric: tabular-nums; }
.order-row .btn { padding: 10px 0; font-size: 16px; }
.bar.battery { height: 6px; }
.stepper .btn { width: 48px; font-size: 20px; padding: 6px 0; }
.stepper .n { min-width: 40px; text-align: center; font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }

.seg { display: flex; background: rgba(255,255,255,0.06); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { flex: 1; border: 0; background: transparent; padding: 9px 6px; border-radius: 9px; font-weight: 700; color: var(--muted); }
.seg button.on { background: var(--panel-2); color: var(--text); box-shadow: 0 1px 0 rgba(255,255,255,0.08) inset; }
.seg button:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---------- full screens ---------- */
.screen {
  position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; overflow-y: auto; touch-action: pan-y;
  padding: calc(var(--safe-t) + 16px) 16px calc(var(--safe-b) + 16px);
  background: radial-gradient(ellipse at 50% 30%, rgba(20, 22, 29, 0.35), rgba(10, 11, 15, 0.82));
}
#screen-pause, #screen-help, #screen-over { z-index: 30; background: rgba(10, 11, 15, 0.78); }
#screen-stats { z-index: 40; background: rgba(10, 11, 15, 0.86); }
.card.missions-card { width: min(100%, 560px); background: #161820; }
#screen-missions { z-index: 25; background: rgba(10, 11, 15, 0.9); }
.ms-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.ms-item { display: grid; grid-template-columns: 34px 1fr; gap: 2px 10px; align-items: center; text-align: left; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,0.04); }
.ms-item:disabled { opacity: 0.45; cursor: default; }
.ms-num { grid-row: span 2; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-weight: 800;
  background: var(--panel-2); color: var(--accent); }
.ms-name { font-weight: 700; font-size: 15px; }
.ms-meta { font-size: 12px; color: var(--muted); }
.ms-done { color: var(--good); font-weight: 700; }
.ms-goals { margin: 8px 0; padding-left: 20px; color: #d3d9e2; }
.ms-goals li { margin: 3px 0; }
  background: rgba(255,255,255,0.06); border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
.code-box { margin: 10px 0; padding: 10px 12px; border-radius: 12px; border: 1px dashed rgba(56,212,255,0.5); background: rgba(56,212,255,0.06); font-size: 14px; }
.code-box b { font-size: 20px; letter-spacing: 0.12em; color: var(--accent); }
.obj-goals { margin: 2px 0 0; padding: 0; list-style: none; }
.obj-goals li { margin: 1px 0; }
.obj-goals li.done { color: var(--good); }
.card.stats-card { width: min(100%, 620px); background: #161820; }
.stats-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.stats-head h2 { margin: 0; }
.stat-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0 4px; }
.stat-tile { background: rgba(255,255,255,0.04); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; }
.stat-tile span { display: block; font-size: 12px; color: var(--muted); }
.stat-tile b { display: block; font-size: 20px; font-weight: 700; }
.chart-block { margin-top: 16px; }
.chart-block h3 { margin: 0 0 2px; font-size: 15px; color: var(--text); }
.chart-block .sub { margin: 0 0 6px; font-size: 13px; color: var(--muted); }
canvas.chart { display: block; width: 100%; height: 170px; touch-action: pan-y; }
.chart-legend { display: flex; gap: 14px; font-size: 13px; color: var(--muted); margin: 2px 0 4px; }
.chart-legend i { display: inline-block; width: 12px; height: 4px; border-radius: 2px; margin-right: 6px; vertical-align: 3px; }
.pick-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 6px; }
.pick-row button { border: 1px solid var(--line); background: rgba(255,255,255,0.04); border-radius: 999px; padding: 5px 10px; font-size: 13px; display: inline-flex; align-items: center; gap: 5px; color: var(--muted); }
.pick-row button.on { background: var(--panel-2); color: var(--text); border-color: rgba(255,255,255,0.3); }
.hbars { display: flex; flex-direction: column; gap: 2px; }
.hbar { display: grid; grid-template-columns: 9.5em 1fr; align-items: center; gap: 8px; border: 0; background: none; padding: 5px 4px; border-radius: 8px; text-align: left; }
.hbar.on { background: rgba(255,255,255,0.06); }
.hb-label { font-size: 13px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hb-label small { color: var(--muted); }
.hb-track { position: relative; height: 12px; }
.hb-track i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 0 4px 4px 0; }
.hb-track b { position: absolute; top: 50%; transform: translate(6px, -50%); font-size: 12px; font-weight: 700; color: var(--text); }
.spark { margin: 2px 0 6px; }
.spark svg { display: block; width: 100%; height: 26px; }
.spark span { font-size: 12px; color: var(--muted); }
.card {
  width: min(100%, 420px); background: var(--panel); border: 1px solid var(--line); border-radius: 20px;
  padding: 22px 20px; box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.card h2 { margin: 0 0 8px; font-size: 24px; }
.logo {
  margin: 0; font-size: clamp(34px, 11vw, 46px); letter-spacing: 0.08em; font-weight: 900; text-align: center;
  background: linear-gradient(180deg, #ffffff, var(--accent)); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.tagline { text-align: center; color: var(--muted); margin: 4px 0 14px; }
.mode-desc { color: var(--muted); font-size: 13px; margin: 8px 2px 0; min-height: 36px; }
.seed { font-variant-numeric: tabular-nums; font-weight: 700; }
.sliders { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.slider-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px 10px; font-size: 14px; }
.slider-row output { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--accent); }
.slider-row input { grid-column: 1 / -1; width: 100%; height: 28px; margin: 0; accent-color: var(--accent); touch-action: pan-x; }
.help-card { width: min(100%, 560px); max-height: calc(100vh - 32px); display: flex; flex-direction: column; }
/* (The visible height on a phone: dvh leaves out the browser's bars, and the safe areas the screen's padding keeps
   clear are taken off too, so the button at the bottom is never under the home bar.) */
@supports (height: 100dvh) {
  .help-card { max-height: calc(100dvh - var(--safe-t) - var(--safe-b) - 32px); }
}
.help-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; touch-action: pan-y; padding-right: 4px; }
.help-card > .btn, .help-card > .stats-head { flex-shrink: 0; }
/* The Missions detail view's Start button: below the scrolling part, always on screen. */
.ms-foot { flex-shrink: 0; }
.ms-foot[hidden] { display: none; }
.help-body h3 { margin: 14px 0 4px; font-size: 16px; color: var(--accent); }
/* How to play under a finger (helpForTouch): the touch controls first, and no key names (the keyboard and mouse
   paragraphs, and brackets that only name keys, are marked .keys). */
.touch-card { border: 1px solid rgba(255, 107, 74, 0.45); border-radius: 12px; background: rgba(255, 107, 74, 0.08); padding: 2px 12px 8px; margin-bottom: 8px; }
.touch-card h3 { margin-top: 10px; }
.touch-card .chain li { margin: 4px 0; }
.touch-card .hint { margin: 4px 0 0; }
@media (pointer: coarse) { .help-body .keys { display: none; } }
/* On a phone the How to play card's title and button are compact, so the text has the height; held on its side the
   card takes the whole width and the touch card's lines sit in two columns, so it shows on one screen. */
@media (max-width: 699px) and (min-height: 520px), (orientation: landscape) and (max-height: 519px) {
  #screen-help .help-card { padding: 12px 16px; }
  #screen-help .help-card h2 { font-size: 18px; margin: 0 0 4px; }
  #screen-help .help-card .btn.big { padding: 9px; margin-top: 6px; font-size: 15px; }
}
@media (orientation: landscape) and (max-height: 519px) {
  #screen-help { padding: calc(var(--safe-t) + 8px) calc(var(--safe-r) + 8px) calc(var(--safe-b) + 8px) calc(var(--safe-l) + 8px); }
  #screen-help .help-card { width: 100%; max-height: calc(100vh - 16px); max-height: calc(100dvh - 16px - var(--safe-t) - var(--safe-b)); }
  .touch-card { position: relative; } .touch-card h3 { margin: 8px 0 2px; } .touch-card .hint { position: absolute; top: 10px; right: 12px; margin: 0; }
  .touch-card .chain { columns: 2; column-gap: 28px; margin: 2px 0; } .touch-card .chain li { break-inside: avoid; margin: 2px 0; }
}
.help-body p { margin: 4px 0; color: #d3d9e2; }
.chain { margin: 4px 0; padding-left: 18px; color: #d3d9e2; }
.chain li { margin: 3px 0; }
i.g { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin: 0 4px 0 2px; vertical-align: -1px; }
i.g.fiber { background: var(--g-fiber); } i.g.stone { background: var(--g-stone); } i.g.ore { background: var(--g-ore); }
i.g.crystal { background: var(--g-crystal); } i.g.alloy { background: var(--g-alloy); } i.g.chip { background: var(--g-chip); }
i.g.crude { background: var(--g-crude); } i.g.fuel { background: var(--g-fuel); }
i.g.cement { background: var(--g-cement); } i.g.asphalt { background: var(--g-asphalt); } i.g.ammo { background: var(--g-ammo); }
i.g.uranium { background: var(--g-uranium); } i.g.fissile { background: var(--g-fissile); }
.o-log { margin: -4px 0 8px; font-size: 13px; font-style: italic; color: var(--muted); }
.stats { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; margin: 10px 0; font-size: 14px; }
.stats span:nth-child(odd) { color: var(--muted); }
.stats span:nth-child(even) { font-weight: 700; text-align: right; }

/* ---------- stock limit ---------- */
.limit-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 4px 0; font-size: 14px; }
.limit-row .stepper { margin: 0; }
.limit-row .hint { margin: 0; flex: 1; }
.limit-row .btn.small { flex: none; }

/* ---------- roads ---------- */
.road-warn {
  margin: 8px 0 4px; padding: 9px 11px; border-radius: 12px; font-size: 14px; color: #ffd9de;
  background: rgba(224, 71, 92, 0.14); border: 1px solid rgba(224, 71, 92, 0.45);
}
.road-warn b { color: #ffb3bd; }
.road-warn.paving { color: #ffe9b8; background: rgba(255, 196, 87, 0.12); border-color: rgba(255, 196, 87, 0.45); }
.road-warn.paving b { color: var(--warn); }
.road-warn .btn { display: block; width: 100%; margin-top: 8px; }
.road-warn .err { display: block; margin-top: 6px; color: var(--danger); font-size: 13px; }
.kv .ok, .status .ok { color: var(--good); }
.objective .err { color: #ff9aa8; font-weight: 700; }
@media (max-width: 499px) { #pop .wide { display: none; } }

/* ---------- widescreen (desktop, laptop, landscape tablet) ---------- */
@media (min-width: 1000px) and (min-height: 520px) {
  /* One compact top row: goods on the left, colony, clock, speed and pause on the right. */
  #topbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "goods row" "obj obj";
    align-items: start; gap: 8px 10px; padding-top: calc(var(--safe-t) + 8px); }
  .goods, .goods.two-rows { grid-area: goods; display: flex; flex-wrap: wrap; gap: 4px; }
  .res-chip, .goods.two-rows .res-chip { min-width: 62px; padding: 6px 10px; font-size: 14px; border-radius: 10px; }
  .toprow { grid-area: row; }
  #pop { flex: none; }
  .objrow { grid-area: obj; justify-self: start; }
  /* An event's card and the Domination or Uplinks card each on a row of their own (side by side, the event's was
     squeezed into a narrow column beside the other). */
  #topbar > .event-card { grid-column: 1 / -1; justify-self: start; }
  .objective { max-width: 560px; font-size: 14px; padding: 7px 12px; }
  body.mm-on .objrow, body.mm-off .objrow { margin-right: 0; }
  .minimap { right: calc(var(--safe-r) + 12px); }
  #toasts { top: auto; width: 440px; left: 50%; transform: translateX(-50%); }

  /* Tools: a small dock at the bottom centre, with their keyboard keys. */
  #bottombar { left: 50%; right: auto; transform: translateX(-50%); width: auto; display: flex; gap: 8px; background: none;
    padding: 0 0 calc(var(--safe-b) + 14px); }
  .tool { flex-direction: row; gap: 8px; padding: 10px 16px; font-size: 15px; min-width: 128px; justify-content: center;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35); }
  .tool svg { width: 20px; height: 20px; }
  .tool kbd { display: inline-block; margin-left: 2px; opacity: 0.7; }
  .tool.on kbd { border-color: rgba(6, 35, 48, 0.4); color: var(--accent-ink); }
  .seg kbd { display: inline-block; margin-left: 6px; opacity: 0.6; font-size: 11px; }
  .build-tabs kbd { margin-left: 0; }
  .build-tabs .n { display: none; } /* room for the tab keys: all five tabs fit */
  .build-tabs button { padding: 8px 3px; gap: 4px; font-size: 13.5px; flex: 1 1 auto; min-width: 0; }
  .build-tabs kbd { font-size: 10px; padding: 0 4px; }
  #sheet button[data-key]::after { content: attr(data-key); display: inline-block; margin-left: 8px; padding: 0 5px; font: 600 11px/16px ui-monospace, monospace;
    border: 1px solid rgba(255, 255, 255, 0.25); border-radius: 4px; opacity: 0.65; vertical-align: 1px; }
  .bcard { position: relative; }
  .bcard kbd { display: inline-block; position: absolute; top: 6px; left: 6px; opacity: 0.75; font-size: 11px; }
  #banner-traffic kbd, #banner-route kbd { display: inline-block; margin-left: 6px; opacity: 0.6; font-size: 11px; }
  .tool:hover { border-color: rgba(255, 255, 255, 0.25); }
  /* With a panel open on the right, the dock and messages centre on the map that's left. */
  body.sheet-open #bottombar, body.sheet-open #toasts { left: calc((100% - 444px) / 2); }

  /* Panels dock on the right instead of covering the middle of the map. */
  #sheet, #sheet.full, #sheet.peek { left: auto; right: calc(var(--safe-r) + 12px); top: var(--hud-top, 70px); bottom: calc(var(--safe-b) + 14px);
    width: 420px; max-height: none; transform: none; border: 1px solid var(--line); border-radius: 16px;
    overflow: hidden; animation: panelIn 0.18s ease-out; }
  #sheet-body, #sheet.peek #sheet-body { padding: 14px 16px 16px; overflow-y: auto; }
  .sheet-grab { display: none; }
  @keyframes panelIn { from { transform: translateX(24px); opacity: 0.4; } }
  .sheet-close { top: 10px; right: 10px; }
  .build-grid { grid-template-columns: repeat(2, 1fr); }
  #banner { bottom: calc(var(--safe-b) + 80px); width: 600px; }

  .help-card { width: min(100%, 780px); }
  .card.stats-card { width: min(100%, 860px); }
  .card.missions-card { width: min(100%, 680px); }
  .btn:hover:not(:disabled), .chip-btn:hover, .seg button:hover:not(.on) { filter: brightness(1.15); }
}
/* A very wide screen: the Build list is three cards across in a wider panel (the whole list in about one screen at 1080p). */
@media (min-width: 1600px) and (min-height: 520px) {
  body.sheet-build #sheet { width: 620px; }
  body.sheet-build .build-grid { grid-template-columns: repeat(3, 1fr); }
  body.sheet-build #bottombar, body.sheet-build #toasts { left: calc((100% - 644px) / 2); }
}
@media (pointer: fine) { body.mode-road canvas#game, body.mode-place canvas#game, body.mode-attack canvas#game, body.mode-aim canvas#game, body.mode-land canvas#game, body.mode-airdrop canvas#game { cursor: crosshair; } }
/* Aiming a Missile Silo: keep the map clear to tap. */
body.mode-aim .objrow, body.mode-land .objrow, body.mode-airdrop .objrow { display: none; }
.air-drops { display: flex; flex-wrap: wrap; gap: 6px; }
.air-drops .btn { flex: 1 1 auto; }
.air-drops .cost-inline { display: block; font-size: 0.85em; opacity: 0.85; }

/* Depot supply orders */
.keep-list { display: flex; flex-direction: column; gap: 5px; margin: 4px 0 6px; }
.keep-cell { display: grid; grid-template-columns: 1fr 64px 52px 52px; align-items: center; gap: 6px; padding: 3px 4px 3px 10px;
  border: 1px solid var(--line); border-radius: 10px; font-size: 14px; font-weight: 600; }
.keep-cell .kname { display: flex; align-items: center; gap: 6px; min-width: 0; white-space: nowrap; }
.keep-cell .btn { padding: 7px 0; font-size: 14px; min-height: 0; }
.keep-cell .n { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.keep-cell.on { border-color: var(--accent); }
.keep-cell.on .n { color: var(--text); }
.keep-cell.on.short .n { color: var(--warn); }
.traffic-key { display: block; margin-top: 4px; color: var(--muted); }
.traffic-key b { color: var(--text); }
.tk { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin: 0 3px 0 6px; vertical-align: -1px; }
.tk.q { background: #3ddc84; } .tk.b { background: #ffd23d; } .tk.p { background: #ff4b4b; }

/* Game speed menu */
.speed-menu { position: fixed; z-index: 30; display: flex; flex-direction: column; gap: 3px; padding: 5px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 26px rgba(0,0,0,0.5); }
.speed-menu button { border: 0; background: transparent; color: var(--text); font-weight: 700; font-size: 15px;
  padding: 9px 18px; border-radius: 8px; font-variant-numeric: tabular-nums; text-align: center; min-width: 84px; }
.speed-menu button.on { background: var(--accent); color: var(--accent-ink); }
#btn-speed.slow { color: var(--good); }
#btn-speed.fast { color: var(--warn); }

/* Desktop: selected warbots and hover tips */
.selbar { position: fixed; z-index: 16; left: 16px; bottom: calc(var(--safe-b) + 84px); max-width: 360px;
  background: var(--panel); border: 1px solid rgba(125, 255, 160, 0.45); border-radius: 12px; padding: 9px 40px 9px 12px;
  font-size: 13px; line-height: 1.4; box-shadow: 0 8px 22px rgba(0, 0, 0, 0.45); }
.selbar b { color: #7dffa0; }
.selbar .hint { display: block; color: var(--muted); margin-top: 3px; }
.selbar .err { color: var(--danger); }
.selbar .muted { color: var(--muted); }
.selbar #selbar-group { margin-top: 6px; }
/* Control groups: a chip for each, above the selection bar */
.groupbar { position: fixed; z-index: 16; left: 16px; bottom: calc(var(--safe-b) + 84px); display: flex; flex-wrap: wrap; gap: 6px; max-width: min(560px, calc(100vw - 32px)); pointer-events: none; }
.groupbar[hidden] { display: none; }
.gchip { pointer-events: auto; display: inline-flex; align-items: center; gap: 6px; padding: 4px 9px 4px 4px; border-radius: 9px; font: 600 12px/1.2 inherit;
  color: #e8eef6; background: var(--panel); border: 1px solid rgba(255, 255, 255, 0.14); box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4); cursor: pointer; }
.gchip kbd { display: inline-grid; place-items: center; min-width: 18px; height: 18px; border-radius: 5px; background: rgba(255, 255, 255, 0.12); font: 700 11px/1 inherit; }
.gchip.on { border-color: rgba(125, 255, 160, 0.7); color: #7dffa0; }
.gchip.on kbd { background: rgba(125, 255, 160, 0.25); }
.gchip:hover { border-color: rgba(255, 255, 255, 0.3); }
.selbar #selbar-clear { position: absolute; top: 6px; right: 6px; padding: 4px 8px; min-height: 0; }
/* What's selected, a line of what they're doing, then the tools: under a finger All in view, Whole army, Box,
   Info, Recycle (and Undo just after an order), with a mouse Recycle and Save as group only and the right-click hint
   above them; with Torches selected, Scorch the earth either way. Under a finger the bar runs the width of the screen,
   with the close button beside the title. */
.selbar .sel-tools { display: flex; gap: 6px; margin-top: 6px; overflow-x: auto; touch-action: pan-x; scrollbar-width: none; }
.selbar .sel-tools::-webkit-scrollbar { display: none; }
.selbar .sel-tools .btn { flex: none; white-space: nowrap; }
.selbar:not(.touch) .sel-tools > :not(#selbar-group):not(#sel-recycle):not(#sel-undo):not(#sel-scorch) { display: none; }
.selbar .sel-tools #selbar-group { margin-top: 0; }
.selbar .ok { color: var(--good); }
.selbar.touch { left: calc(var(--safe-l) + 8px); right: calc(var(--safe-r) + 8px); max-width: 520px; padding: 8px 10px 9px 12px; }
.selbar.touch .sel-top { display: flex; align-items: center; gap: 6px; }
.selbar.touch .sel-text { flex: 1 1 auto; min-width: 0; }
.selbar.touch .sel-mouse { display: none; }
.selbar.touch #sel-status { margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.selbar.touch #selbar-clear { position: static; flex: none; width: 44px; height: 44px; padding: 0; }
.selbar #sel-box.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
/* Where panels cover the bottom of the screen the bar steps aside for them (and taps are then not orders: selBarShowing),
   and so do the control-group chips, for a panel or a mode's banner. */
@media (max-width: 999px), (max-height: 519px) { body.sheet-open .selbar.touch, body.sheet-open .groupbar, body.mode-on .groupbar { display: none; } }
.map-tip { position: fixed; z-index: 18; pointer-events: none; max-width: 260px;
  background: #0d0f15; border: 1px solid rgba(255, 255, 255, 0.16); border-radius: 10px; padding: 7px 10px;
  font-size: 13px; line-height: 1.35; box-shadow: 0 8px 22px rgba(0, 0, 0, 0.5); }
.map-tip b { display: block; font-size: 14px; }
.map-tip em { display: block; font-style: normal; color: var(--muted); }
.pop-btn { cursor: pointer; }
.pop-row span:last-child { text-align: right; color: var(--muted); font-size: 13px; }
.pop-row b { color: var(--text); }

/* Paths: the banner sits at the top so it never covers where you're drawing, and the plan buttons
   sit three to a row (Undo, Clear, Build), then Traffic map and Done. */
body.mode-road #banner { top: calc(var(--hud-top, 64px) + 6px); bottom: auto; }
body.mode-road .objrow { display: none; }
.banner-actions .btn { flex: 1 1 28%; }
#banner-text details.how { margin-top: 4px; color: var(--muted); font-size: 13px; }
#banner-text details.how summary { cursor: pointer; color: var(--accent); font-weight: 600; font-size: 13px; }
#banner-ok:disabled { opacity: 0.45; }
@media (max-width: 699px) {
  body.mode-road #banner { padding: 8px 10px; }
  body.mode-road #banner-text { font-size: 13px; margin-bottom: 6px; line-height: 1.35; }
  body.mode-road .banner-actions { gap: 6px; }
  body.mode-road .banner-actions .btn { padding: 8px 6px; font-size: 14px; min-height: 0; }
  body.mode-road .banner-actions .road-seg button { padding: 6px 2px; font-size: 13px; flex: 1 0 calc(25% - 3px); min-width: 0; }
}
/* ---------- a phone on its side ----------
   The tools are a rail down the left edge, panels a column down the right, the goods one row across the top,
   a mode's banner and the selection bar a box at the bottom left beside the rail, messages at the bottom right.
   (It had the upright layout squeezed into a third of the height: a quarter to a third of the screen was map.) */
@media (orientation: landscape) and (max-height: 519px) {
  :root { --rail: calc(var(--safe-l) + 60px); --col: min(48vw, calc(400px + var(--safe-r))); }
  #topbar { gap: 4px; padding-top: calc(var(--safe-t) + 4px); }
  .goods, .goods.two-rows { grid-template-columns: repeat(var(--goods-n, 14), 1fr); gap: 3px; }
  .res-chip, .goods.two-rows .res-chip { padding: 2px; font-size: 12px; gap: 3px; min-height: 26px; border-radius: 8px; }
  .toprow .chip { min-height: 36px; padding: 3px 9px; }
  .objective { padding: 5px 9px; }
  /* Tools: a rail down the left edge. */
  #bottombar, #bottombar.three { left: 0; right: auto; bottom: 0; width: var(--rail); grid-template-columns: 1fr; gap: 5px;
    padding: 6px 6px calc(var(--safe-b) + 6px) calc(var(--safe-l) + 6px); background: linear-gradient(to right, rgba(14, 15, 20, 0.85), rgba(14, 15, 20, 0)); }
  .tool { padding: 4px 2px 3px; min-height: 44px; gap: 0; }
  .tool svg { width: 20px; height: 20px; }
  .event-card { margin-left: var(--rail); } /* (beside the top of the rail, not over it) */
  /* Panels: a column down the right, under the top bar (no handle: it's as tall as it can be). */
  #sheet, #sheet.full, #sheet.peek { left: auto; right: 0; top: var(--hud-top, 70px); bottom: 0; width: var(--col); max-height: none; transform: none;
    border-top: 0; border-left: 1px solid var(--line); border-radius: 14px 0 0 0; overflow: hidden; animation: none; }
  #sheet-body, #sheet.peek #sheet-body { padding: 10px calc(var(--safe-r) + 12px) calc(var(--safe-b) + 12px) 12px; overflow-y: auto; }
  .sheet-grab { display: none; }
  .sheet-close { top: 6px; }
  .build-grid { grid-template-columns: repeat(2, 1fr); }
  /* A mode's banner, and the selection bar: a box at the bottom left, beside the rail. */
  #banner, body.mode-road #banner { left: calc(var(--rail) + 2px); right: auto; top: auto; bottom: calc(var(--safe-b) + 6px); width: min(54vw, 440px);
    transform: none; padding: 8px 10px; }
  #banner-text { font-size: 13px; margin-bottom: 6px; line-height: 1.35; }
  #banner-text .keep-all { margin-top: 5px; }
  .banner-actions .btn { min-height: 40px; padding: 7px 10px; }
  .selbar.touch { left: calc(var(--rail) + 2px); right: auto; bottom: calc(var(--safe-b) + 6px); width: min(54vw, 440px); max-width: none; }
  body.mode-on .selbar.touch { display: none; }
  .groupbar { left: calc(var(--rail) + 2px); bottom: calc(var(--safe-b) + 6px); }
  .mp-banner { bottom: calc(var(--safe-b) + 6px); left: calc(50% + var(--rail) / 2); }
  /* Messages: the bottom right corner (beside the panel, when one is open). */
  #toasts, body.mm-on #toasts { top: auto !important; bottom: calc(var(--safe-b) + 6px); left: auto; right: calc(var(--safe-r) + 8px); width: min(34vw, 320px); transform: none; }
  body.sheet-open #toasts { right: calc(var(--col) + 8px); }
  #toasts .toast:not(:last-child) { display: none; } /* (the newest only: two long ones reached up to the minimap) */
}
/* ---------- phones held upright: a mode's banner is docked across the bottom, in the bottom bar's place ----------
   Its Cancel or Done leads back to the tools. In Paths the banner used to sit at the top, where it hid the first
   rows of the map and the minimap. The selection bar is docked the same way while warbots are selected (✕ brings
   the tools back), and a mode's banner takes that place in turn. */
@media (max-width: 699px) and (min-height: 520px) {
  body.mode-on #bottombar, body.sel-on #bottombar { display: none; }
  .selbar.touch { left: 0; right: 0; bottom: 0; max-width: none; border-radius: 16px 16px 0 0; border-width: 1px 0 0;
    padding: 8px calc(var(--safe-r) + 10px) calc(var(--safe-b) + 10px) calc(var(--safe-l) + 12px); }
  body.mode-on .selbar.touch { display: none; }
  body.mode-on #banner, body.mode-road #banner {
    left: 0; right: 0; top: auto; bottom: 0; width: auto; transform: none; border-radius: 16px 16px 0 0; border-width: 1px 0 0;
    padding: 10px calc(var(--safe-r) + 10px) calc(var(--safe-b) + 10px) calc(var(--safe-l) + 10px);
  }
}
/* The Paths banner's insides where it is a dock or a box (an upright phone, or one on its side): the status up
   to three lines, the tools one row to swipe along with Route to and Traffic at its end, Undo, Clear, Build and
   Done in the row below, and How it works as a tab on its top edge that opens as a card over the map. */
@media (max-width: 699px) and (min-height: 520px), (orientation: landscape) and (max-height: 519px) {
  body.mode-road #banner { padding-top: 8px; }
  body.mode-road #banner-text { margin-bottom: 6px; }
  body.mode-road .rb-line { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; }
  body.mode-road .rb-line .btn { padding: 4px 10px; margin-top: 4px; }
  body.mode-road .banner-actions { display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto auto; gap: 6px; }
  body.mode-road .banner-actions .road-seg { grid-column: 1 / 4; grid-row: 1; min-width: 0; flex-wrap: nowrap; overflow-x: auto; touch-action: pan-x;
    overscroll-behavior: contain; scrollbar-width: none; }
  body.mode-road .banner-actions .road-seg::-webkit-scrollbar { display: none; }
  /* More tools beyond an edge: that edge fades out (segEdges), so a swipe along the row is the obvious thing to try. */
  body.mode-road .banner-actions .road-seg.more-r { -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 34px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 34px), transparent); }
  body.mode-road .banner-actions .road-seg.more-l { -webkit-mask-image: linear-gradient(90deg, transparent, #000 34px); mask-image: linear-gradient(90deg, transparent, #000 34px); }
  body.mode-road .banner-actions .road-seg.more-l.more-r { -webkit-mask-image: linear-gradient(90deg, transparent, #000 34px, #000 calc(100% - 34px), transparent); mask-image: linear-gradient(90deg, transparent, #000 34px, #000 calc(100% - 34px), transparent); }
  body.mode-road .banner-actions .road-seg button { flex: 0 0 auto; min-width: 44px; min-height: 44px; padding: 6px 9px; font-size: 13px; }
  body.mode-road #banner-route { grid-column: 4; grid-row: 1; }
  body.mode-road #banner-traffic { grid-column: 5; grid-row: 1; }
  body.mode-road #banner-traffic .wide { display: none; }
  body.mode-road #banner-undo { grid-column: 1; grid-row: 2; }
  body.mode-road #banner-clear { grid-column: 2; grid-row: 2; }
  body.mode-road #banner-ok { grid-column: 3; grid-row: 2; }
  body.mode-road #banner-cancel { grid-column: 4 / 6; grid-row: 2; min-width: 76px; }
  body.mode-road .banner-actions .btn { min-height: 44px; padding: 8px 12px; font-size: 14px; }
  /* With nothing sketched there is no second row: Route to, Traffic and Done sit at the end of the tools' row. */
  body.mode-road #banner.noplan .banner-actions { grid-template-columns: minmax(0, 1fr) auto auto auto auto; }
  body.mode-road #banner.noplan .road-seg { grid-column: 1; }
  body.mode-road #banner.noplan #banner-undo { grid-column: 2; grid-row: 1; }
  body.mode-road #banner.noplan #banner-route { grid-column: 3; }
  body.mode-road #banner.noplan #banner-traffic { grid-column: 4; }
  body.mode-road #banner.noplan #banner-cancel { grid-column: 5; grid-row: 1; min-width: 60px; }
  /* How it works: a tab on the banner's top edge; open, a card over the map above the banner. */
  body.mode-road #banner-text details.how { position: absolute; right: calc(var(--safe-r) + 8px); bottom: 100%; margin: 0; }
  body.mode-road #banner-text details.how summary { list-style: none; padding: 6px 12px; min-height: 32px; border-radius: 10px 10px 0 0;
    background: #252a36; border: 1px solid var(--line); border-bottom: 0; position: relative; }
  body.mode-road #banner-text details.how summary::-webkit-details-marker { display: none; }
  body.mode-road #banner-text details.how summary::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 44px; }
  body.mode-road #banner-text details.how[open] { left: calc(var(--safe-l) + 8px); margin-bottom: 6px; padding: 0 12px 10px; max-height: 46vh; max-height: 46dvh; overflow-y: auto;
    touch-action: pan-y; background: #252a36; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45); color: #c9d0db; }
  body.mode-road #banner-text details.how[open] summary { position: sticky; top: 0; margin: 0 -12px 4px; border: 0; border-radius: 12px 12px 0 0; }
  body.mode-road #banner-text details.how[open] summary::before { content: '✕'; float: right; color: var(--text); }
}
@media (orientation: landscape) and (max-height: 519px) {
  body.mode-road #banner-text details.how[open] { left: 0; max-height: calc(100vh - 215px); max-height: calc(100dvh - 215px); }
}
/* ---------- touch: controls sized for a finger (44 px), where a mouse gets the compact ones ----------
   Every button, choice and switch in a game is a full 44 px to press: panels' buttons and choices, the Build tabs,
   the goods a storage keeps, supply steppers, the Foundry's order arrows (side by side), the speed menu, the
   selection bar's tools, the sliders and Statistics. (The goods counters in the top bar stay 32 px high, wide and
   well apart: taller, their two rows would take that much off the map.) */
@media (pointer: coarse) {
  #hud .btn, #hud .seg button, #hud .chips button, #hud .gtag.toggle, #hud .stepper .btn, #hud .keep-cell .btn, .objective.small,
  .speed-menu button, .pick-row button, .hbar, .stats-head .btn, #screen-pause .btn, #screen-help .btn, #screen-lore .btn, #screen-feedback .btn,
  #screen-feedback .seg button { min-height: 44px; }
  .sheet-close { width: 44px; height: 44px; margin: -4px -4px 0 0; }
  .sheet-title { margin-right: 46px; }
  .order-row { grid-template-columns: 92px 1fr 48px 48px 58px; gap: 6px; font-size: 15px; }
  .order-move { flex-direction: row; gap: 4px; }
  .order-row .order-move .btn { width: 44px; min-height: 44px; padding: 0; font-size: 14px; }
  .pick-row button { padding: 5px 14px; }
  #hud .gtag.toggle { padding: 4px 12px; }
  #banner-text .keep-all .seg button { min-width: 44px; padding: 4px 10px; }
  .event-card .btn { padding: 4px 14px; }
  .msgs-btn, .toast-go { min-width: 44px; min-height: 44px; }
  .gchip { min-height: 44px; padding-right: 12px; }
  #screen-pause .slider-row input { height: 44px; }
  .help-toc a { display: inline-flex; align-items: center; min-height: 44px; }
}
/* The top bar grows only where there's height for it (not on a phone held sideways). */
@media (pointer: coarse) and (min-height: 520px) {
  .toprow .chip { min-height: 44px; }
  .res-chip, .goods.two-rows .res-chip { min-height: 32px; }
}
/* How it works in a banner that isn't docked (tablets): the line is as it was, with 44 px round it to tap. */
@media (pointer: coarse) and (min-width: 700px) {
  #banner-text details.how summary { position: relative; }
  #banner-text details.how summary::after { content: ''; position: absolute; left: 0; right: 0; top: -18px; bottom: -8px; }
}
.btn.danger-glow { background: #ff4b4b; color: #fff; border-color: #ff7a7a; box-shadow: 0 0 16px rgba(255, 75, 75, 0.45); }
.btn.danger-glow:disabled { background: rgba(255, 75, 75, 0.25); box-shadow: none; color: #ffc9cf; }

/* Goods panel */
.goods-pick { display: flex; flex-wrap: nowrap; overflow-x: auto; gap: 6px; padding-bottom: 4px; margin: 2px 0 8px; scrollbar-width: thin; }
.goods-pick button { flex: none; }
.gs-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 8px 0 10px; }
.gs-stats div { background: rgba(255,255,255,0.05); border-radius: 10px; padding: 8px 6px; text-align: center; }
.gs-stats b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.gs-stats b.up { color: var(--good); } .gs-stats b.down { color: var(--danger); }
.gs-stats span { font-size: 12px; color: var(--muted); }
.gs-alert { border-radius: 10px; padding: 8px 10px; margin: 6px 0; font-size: 13px; }
.gs-alert.bad { background: rgba(255,90,110,0.14); color: #ffc0c8; }
.gs-alert.warn { background: rgba(255,196,87,0.14); color: #ffe1a6; }
.gs-alert.good { background: rgba(126,224,138,0.12); color: #c9f5cf; }
.gtag small { color: var(--muted); font-weight: 600; margin-left: 4px; }
canvas.chart.small { height: 110px; }

/* sound volume sliders in the pause menu */
.boost-row { text-align: left; padding: 8px 10px; margin: 8px 0; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,0.03); }
.boost-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.boost-head .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.boost-head small { margin-left: auto; color: var(--muted); }
.boost-btns { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 6px; }
.boost-you { border-color: rgba(56,212,255,0.45); }
.ban-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ban-chip.on { background: rgba(255,90,110,0.16); border-color: rgba(255,90,110,0.7); color: #ffb3bd; }
.ban-row .hint { margin: 6px 0 0; }
.boost-btns .btn { padding-left: 4px; padding-right: 4px; }
.sound-sliders { display: grid; gap: 6px; margin-top: 8px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,0.03); text-align: left; }
/* The Army panel (Q): order buttons in a grid, and list rows with their buttons on the right. */
.army-cmds { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 8px 0 4px; }
.army-cmds .btn { padding: 10px 6px; }
.army-row { align-items: center; gap: 6px 8px; flex-wrap: wrap; }
.army-row > span:last-child { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; flex: 0 1 auto; margin-left: auto; }
.army-row > span:first-child { flex: 1 1 160px; min-width: 0; }
#ar-tabs { margin-bottom: 8px; }

/* ---------- main menu: Home, Customise (the new-game setup) and the map type / biome pickers ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { border: 1px solid rgba(255,255,255,0.1); background: rgba(255,255,255,0.05); color: var(--muted); padding: 8px 12px; border-radius: 999px; font-weight: 700; font-size: 14px; }
.chips button.on { background: var(--panel-2); color: var(--text); border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
#screen-menu button:focus-visible, .m-picker button:focus-visible, .m-pick:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#screen-menu .seg button:focus-visible { outline-offset: -2px; }
.menu-card { width: min(100%, 404px); padding: 26px 22px 18px; display: flex; flex-direction: column; }
.m-home { display: flex; flex-direction: column; }
.menu-card .tagline { margin: 2px 0 20px; }
.m-cont { margin: 0 0 10px; background: rgba(56, 212, 255, 0.09); border-color: rgba(56, 212, 255, 0.45); color: #c4f1ff; }
.m-go { display: flex; flex-direction: column; }
#m-new { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 0; font-size: 17px; letter-spacing: 0.02em;
  box-shadow: 0 8px 26px rgba(56, 212, 255, 0.22); }
.m-sum { margin: 9px 4px 0; text-align: center; font-size: 13px; line-height: 1.35; color: var(--muted); text-wrap: balance; }
.m-sum .sum-main { display: block; color: #c3cad6; font-weight: 600; }
.m-sum .sum-extra { display: block; font-size: 12px; margin-top: 1px; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
.m-home-foot { display: flex; flex-direction: column; }
.m-cust { display: flex; align-items: center; justify-content: center; gap: 9px; margin-top: 14px; }
.m-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 10px; margin-top: 12px; }
.m-links button { position: relative; border: 0; background: none; color: var(--muted); font-weight: 650; font-size: 13.5px; padding: 6px 6px; border-radius: 8px; }
.m-links button + button:not(.m-pill)::before { content: ''; position: absolute; left: -7px; top: 50%; width: 3px; height: 3px; margin-top: -1.5px; border-radius: 50%; background: rgba(255, 255, 255, 0.22); }
.m-links button:hover { color: var(--text); }
#m-import-msg { text-align: center; }

/* Customise: a header, the scrolling settings, and Start in a bar that stays in view. */
#screen-menu.is-setup { padding: calc(var(--safe-t) + 8px) calc(var(--safe-r) + 8px) calc(var(--safe-b) + 8px) calc(var(--safe-l) + 8px); }
.menu-card.is-setup { width: min(100%, 620px); padding: 0; overflow: hidden;
  height: calc(100vh - 16px - var(--safe-t) - var(--safe-b)); height: calc(100dvh - 16px - var(--safe-t) - var(--safe-b)); }
.m-setup { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
.m-head { display: flex; align-items: center; gap: 8px; padding: 10px 14px 9px 10px; border-bottom: 1px solid var(--line); flex: none; }
.menu-card .m-head h2 { margin: 0; font-size: 17px; }
.m-back { display: inline-flex; align-items: center; gap: 3px; padding: 6px 10px 6px 6px; border-color: transparent; }
.m-back:hover { background: rgba(255, 255, 255, 0.06); }
.m-head-logo { margin-left: auto; font-weight: 900; letter-spacing: 0.16em; font-size: 12px; color: transparent; opacity: 0.85;
  background: linear-gradient(180deg, #ffffff, var(--accent)); -webkit-background-clip: text; background-clip: text; }
.m-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; display: grid; gap: 12px; padding: 12px; align-content: start; }
.menu-card.is-setup .m-go { flex: none; flex-direction: row; align-items: center; gap: 12px; padding: 10px 12px; border-top: 1px solid var(--line); background: rgba(12, 13, 18, 0.55); }
.menu-card.is-setup .m-sum { order: -1; flex: 1; min-width: 0; margin: 0; text-align: left; font-size: 12.5px; }
.menu-card.is-setup .m-sum .sum-main { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; text-wrap: pretty; }
.menu-card.is-setup .m-sum .sum-extra { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-card.is-setup #m-new { width: auto; flex: none; min-width: 132px; padding: 12px 20px; font-size: 16px; }

/* The planet: its preview, seed and saved planets (a strip on top on a phone, a column on a big screen). */
.m-planet { display: grid; grid-template-columns: 118px minmax(0, 1fr); gap: 12px; align-items: start; }
.pv { position: relative; height: 148px; border-radius: 12px; overflow: hidden; border: 1px solid rgba(255, 255, 255, 0.07);
  background: radial-gradient(ellipse at 50% 35%, #1b2030, #0b0c11 78%); }
.pv canvas { display: block; width: 100%; height: 100%; transition: opacity 0.18s; }
.pv.busy canvas { opacity: 0.55; }
.pv-random { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 10px; text-align: center; color: var(--muted); font-size: 12px; line-height: 1.3; }
.pv-random b { font-size: 40px; line-height: 1; color: var(--text); font-weight: 900; text-shadow: 0 0 18px rgba(56, 212, 255, 0.5); }
.pv-side { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.seed-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.seed-txt { display: flex; flex-direction: column; min-width: 0; }
.seed-txt .seed { font-size: 15px; }
.seed-txt small { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.seed-btns { display: flex; gap: 6px; }
.seed-btns .btn { padding: 6px 11px; }
.planets { display: flex; flex-direction: column; gap: 3px; max-height: 118px; overflow-y: auto; touch-action: pan-y; overscroll-behavior: contain; }
.planets .planets-title { font-size: 11.5px; color: var(--muted); font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; margin: 2px 0 2px; }
.planets .planets-title small { font-weight: 700; opacity: 0.7; margin-left: 3px; }
.planet-row { display: flex; align-items: stretch; gap: 3px; }
.planet-row .use { flex: 1; min-width: 0; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.3; font-size: 12.5px; font-weight: 600; padding: 5px 8px; border-color: rgba(255, 255, 255, 0.07); }
.planet-row .use span { color: var(--muted); font-weight: 500; }
.planet-row .use.on { outline: 2px solid var(--accent); outline-offset: -2px; }
.planet-row .del { flex: none; width: 30px; padding: 0; font-size: 17px; border-color: transparent; color: var(--muted); }

/* Settings: Match, Planet, Rules. A row is a label and its control; the line under them describes. */
.m-sets { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.m-sec { display: flex; flex-direction: column; gap: 5px; padding: 10px 12px 8px; border-radius: 14px; background: rgba(255, 255, 255, 0.025); border: 1px solid rgba(255, 255, 255, 0.06); min-width: 0; }
.menu-card .m-sec h3 { margin: 0 0 2px; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); font-weight: 800; }
.m-row { display: grid; grid-template-columns: 86px minmax(0, 1fr); align-items: center; gap: 10px; min-height: 38px; }
.m-row[hidden] { display: none; }
.m-rl { font-size: 13.5px; font-weight: 700; color: #d4dae4; line-height: 1.15; }
.m-val { display: block; margin-top: 2px; font-size: 11.5px; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
.m-row .seg { padding: 2px; gap: 2px; border-radius: 10px; min-width: 0; }
/* (each choice as wide as its label needs, so a long one like Domination isn't cut short on a phone) */
.m-row .seg button { flex: 1 1 auto; padding-left: 4px; padding-right: 4px; }
.m-row .seg button { min-width: 0; padding: 7px 4px; border-radius: 8px; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-chips { gap: 4px; }
.m-chips button { padding: 5px 10px; font-size: 13px; }
.m-info { margin: 2px 2px 0; min-height: 2.8em; font-size: 12.5px; line-height: 1.4; color: var(--muted);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.m-note { margin: 0 2px; font-size: 12.5px; line-height: 1.35; color: var(--warn); }
/* Terrain and Resources: a level meter, one bar per step. */
.seg.lv button { display: flex; align-items: flex-end; justify-content: center; height: 34px; padding: 6px 0 7px; }
.seg.lv button i { display: block; width: 9px; border-radius: 2px; background: rgba(255, 255, 255, 0.16); transition: background 0.12s; }
.seg.lv button.lit i { background: rgba(56, 212, 255, 0.5); }
.seg.lv button.on i { background: var(--accent); box-shadow: 0 0 8px rgba(56, 212, 255, 0.45); }
.seg.lv button:hover:not(.on) i { background: rgba(255, 255, 255, 0.35); }
/* Map type and Biome: the choice, with a thumbnail; it opens the picker. */
.m-pick { display: flex; align-items: center; gap: 10px; width: 100%; min-width: 0; min-height: 44px; padding: 4px 10px 4px 4px; text-align: left;
  border-radius: 10px; border: 1px solid rgba(255, 255, 255, 0.1); background: rgba(255, 255, 255, 0.05); color: var(--text); }
.m-pick:hover { border-color: rgba(255, 255, 255, 0.24); background: rgba(255, 255, 255, 0.08); }
.m-pick-thumb { width: 36px; height: 36px; flex: none; border-radius: 7px; display: block; }
.m-pick-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.m-pick-name { font-weight: 800; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-pick-meta { font-size: 11.5px; font-weight: 600; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-pick-meta:empty { display: none; }
.m-pick-chev { margin-left: auto; flex: none; color: var(--muted); }
/* Rules: switches as chips, and the time of day. */
.tchips { display: flex; flex-wrap: wrap; gap: 6px; padding: 2px 0 4px; }
.tchip { display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px 7px 9px; border-radius: 999px; cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.1); background: rgba(255, 255, 255, 0.04); color: var(--muted); font-weight: 700; font-size: 13.5px; transition: background 0.12s, border-color 0.12s, color 0.12s; }
.tchip[hidden] { display: none; }
.tchip:hover { border-color: rgba(255, 255, 255, 0.25); }
.tchip.on { color: var(--text); border-color: rgba(56, 212, 255, 0.55); background: rgba(56, 212, 255, 0.1); }
.tchip.na { opacity: 0.45; cursor: default; } /* (the Murmur on Lunar: none live there) */
.tchip .tchip-sub { font-size: 0.85em; font-weight: 500; opacity: 0.75; } /* (what an option's name means, beside it: the Murmur are creatures) */
.tchip.na input { cursor: default; }
.tchip input { appearance: none; -webkit-appearance: none; margin: 0; width: 16px; height: 16px; flex: none; border-radius: 50%; cursor: pointer;
  border: 2px solid rgba(255, 255, 255, 0.3); display: grid; place-items: center; }
.tchip input:checked { background: var(--accent); border-color: var(--accent); }
.tchip input:checked::after { content: ''; width: 6px; height: 3px; margin-top: -2px; border-left: 2px solid var(--accent-ink); border-bottom: 2px solid var(--accent-ink); transform: rotate(-45deg); }
.tchip:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.tchip input:focus { outline: none; }
.m-rules-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; }
.m-rules-row .tchips { padding: 0; }
.m-tod { display: flex; align-items: center; gap: 10px; min-height: 38px; }
.m-tod .m-rl { white-space: nowrap; }
.tod-seg { flex: none; padding: 2px; gap: 2px; border-radius: 10px; }
.tod-seg button { padding: 6px 13px; border-radius: 8px; font-size: 13.5px; }

/* A big screen: the planet on the left, settings on the right; wider still, Match beside Planet. */
@media (min-width: 900px) and (min-height: 600px) {
  .menu-card.is-setup { width: min(100%, 1120px); height: auto; max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px - var(--safe-t) - var(--safe-b)); }
  #screen-menu.is-setup { padding: calc(var(--safe-t) + 16px) 16px calc(var(--safe-b) + 16px); }
  .m-head { padding: 12px 18px 11px 12px; }
  .menu-card .m-head h2 { font-size: 18px; }
  .m-body { grid-template-columns: minmax(250px, 31%) minmax(0, 1fr); gap: 18px; padding: 16px 18px; }
  .m-planet { grid-template-columns: 1fr; position: sticky; top: 0; align-self: start; gap: 10px; }
  .pv { height: clamp(260px, 42vh, 380px); }
  .planets { max-height: 200px; }
  .menu-card.is-setup .m-go { padding: 12px 18px; }
  .menu-card.is-setup .m-sum { font-size: 13px; }
  .menu-card.is-setup #m-new { min-width: 180px; }
}
@media (min-width: 1180px) and (min-height: 600px) {
  .m-body { grid-template-columns: minmax(240px, 26%) minmax(0, 1fr); }
  .m-sets { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; align-items: stretch; }
  .m-rules { grid-column: 1 / -1; }
  .m-row { grid-template-columns: 80px minmax(0, 1fr); gap: 8px; }
  .m-sec .m-info { margin-top: auto; }
}
/* A phone on its side: a slimmer header and planet strip. */
@media (max-height: 500px) {
  .m-head { padding: 6px 12px 5px 8px; }
  .m-body { padding: 10px 12px; }
  .pv { height: 112px; }
  .m-planet { grid-template-columns: 96px minmax(0, 1fr); }
  .menu-card.is-setup .m-go { padding: 8px 12px; }
  .menu-card.is-setup #m-new { padding: 10px 18px; }
  .menu-card:not(.is-setup) { padding: 14px 20px 12px; }
  .menu-card .tagline { margin-bottom: 10px; }
  .m-cust { margin-top: 10px; }
  .m-links { margin-top: 6px; }
}
@media (max-height: 500px) and (min-width: 700px) {
  .menu-card.is-setup { width: min(100%, 1000px); }
  .m-body { grid-template-columns: 200px minmax(0, 1fr); gap: 12px; }
  .m-planet { grid-template-columns: 1fr; gap: 8px; position: sticky; top: 0; align-self: start; }
  .pv { height: 112px; }
  .planets { max-height: 64px; }
}
@media (max-width: 420px) {
  .m-row { grid-template-columns: 78px minmax(0, 1fr); gap: 8px; }
  .m-row .seg button { font-size: 13px; padding: 7px 2px; }
}
/* The narrowest phones (an original iPhone SE: 320 px): each label above its choices, so they get the whole width. */
@media (max-width: 359px) {
  .m-row { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .m-row .seg button { font-size: 13px; }
}

/* The pickers: a centred panel of cards; on a phone, a sheet from the bottom. */
.m-picker { position: fixed; inset: 0; z-index: 26; display: grid; place-items: center; padding: 24px; background: rgba(6, 7, 10, 0.62); animation: pickFade 0.15s ease-out; }
@keyframes pickFade { from { opacity: 0; } }
.m-picker-sheet { width: min(100%, 920px); max-height: min(86vh, 900px); display: flex; flex-direction: column; overflow: hidden;
  background: #161820; border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6); animation: pickIn 0.18s ease-out; }
@keyframes pickIn { from { transform: translateY(10px) scale(0.985); opacity: 0.5; } }
.m-picker.bio .m-picker-sheet { width: min(100%, 860px); }
.m-picker-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px 10px 20px; border-bottom: 1px solid var(--line); flex: none; }
.m-picker-head h2 { margin: 0; font-size: 18px; }
.m-picker-head .sheet-close { position: static; flex: none; }
.m-picker-body { overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; padding: 14px 16px 18px; }
.pgroup h3 { margin: 16px 2px 8px; font-size: 11.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); font-weight: 800; }
.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; }
.pcard { display: grid; grid-template-columns: 58px minmax(0, 1fr); gap: 11px; align-items: start; padding: 8px; text-align: left; color: var(--text);
  border-radius: 12px; border: 1px solid rgba(255, 255, 255, 0.08); background: rgba(255, 255, 255, 0.035); transition: background 0.12s, border-color 0.12s; }
.pcard:hover { border-color: rgba(255, 255, 255, 0.24); background: rgba(255, 255, 255, 0.065); }
.pcard[aria-current] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; background: rgba(56, 212, 255, 0.08); }
.pc-thumb { width: 58px; height: 74px; display: block; border-radius: 8px; }
.pc-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; padding-top: 1px; }
.pc-name { font-weight: 800; font-size: 14.5px; line-height: 1.2; }
.pc-badges { display: flex; flex-wrap: wrap; gap: 4px; }
.badge { font-size: 10.5px; font-weight: 800; letter-spacing: 0.02em; padding: 1px 6px; border-radius: 6px; background: rgba(255, 255, 255, 0.08); color: #c9d0db; }
.badge.ffa { background: rgba(126, 224, 138, 0.14); color: #a9ecb2; }
.badge.naval { background: rgba(56, 212, 255, 0.14); color: #a3e7ff; }
.pc-blurb { font-size: 12.5px; line-height: 1.35; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.m-picker.bio .pgrid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.m-picker.bio .pcard { grid-template-columns: minmax(0, 1fr); gap: 4px; padding: 6px 6px 9px; }
.m-picker.bio .pc-name, .m-picker.bio .pc-blurb { padding: 0 4px; }
.m-picker.bio .pc-name { margin-top: 4px; }
.pc-swatch { width: 100%; height: 96px; display: block; border-radius: 8px; }
@media (max-width: 699px), (max-height: 500px) {
  .m-picker { place-items: end stretch; padding: calc(var(--safe-t) + 20px) 0 0; }
  .m-picker-sheet, .m-picker.bio .m-picker-sheet { width: 100%; max-height: 100%; border-radius: 18px 18px 0 0; border-bottom: 0; padding-bottom: var(--safe-b); animation: sheetIn 0.22s ease-out; }
  .m-picker-sheet::before { content: ''; flex: none; width: 38px; height: 4px; border-radius: 2px; margin: 7px auto -3px; background: rgba(255, 255, 255, 0.2); }
  .m-picker-head { padding: 6px 10px 8px 16px; }
  .m-picker-body { padding: 10px 12px 16px; }
  .pgrid { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
  .m-picker.bio .pgrid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
  .pc-swatch { height: 84px; }
}
@media (prefers-reduced-motion: reduce) { .m-picker, .m-picker-sheet { animation: none; } }

/* ------------------------------------------------------------------ multiplayer: lobby and in-game banner */
.card.mp-card { width: min(100%, 440px); min-width: 0; display: flex; flex-direction: column; gap: 10px; background: #161820; }
.mp-view .btn.big { margin-top: 0; }
.mp-head { display: flex; align-items: center; gap: 10px; }
.mp-head h2 { margin: 0; font-size: 22px; }
.mp-view { display: flex; flex-direction: column; gap: 10px; }
.mp-field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.mp-field input, .mp-join input {
  font: inherit; font-size: 17px; color: var(--text); background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; min-height: 44px; user-select: text; -webkit-user-select: text; touch-action: auto;
}
.mp-field input:focus, .mp-join input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.mp-join { display: flex; gap: 8px; }
.mp-join .btn.big { width: auto; flex: none; padding: 0 24px; }
.mp-join input { flex: 1; width: 0; min-width: 0; text-transform: uppercase; letter-spacing: 0.3em; font-weight: 700; text-align: center; }
.mp-or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.mp-or::before, .mp-or::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.mp-msg { min-height: 1.2em; margin: 0; font-size: 14px; color: var(--warn); }
.mp-msg.ok { color: var(--good); }
.mp-codebox { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); }
.mp-codelbl { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 700; }
.mp-code { flex: 1; font-size: 30px; letter-spacing: 0.22em; color: var(--accent); font-variant-numeric: tabular-nums; user-select: text; -webkit-user-select: text; }
.mp-players { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.mp-players li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; background: var(--panel-2); min-height: 44px; }
.mp-players .dot { width: 14px; height: 14px; border-radius: 50%; flex: none; box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.35); }
.mp-players .nm { flex: 1; font-weight: 600; }
.mp-players small { color: var(--muted); }
.mp-players li.off { opacity: 0.55; }
.mp-players li.ai .nm { font-weight: 400; color: var(--muted); }
/* A computer's doctrine in the lobby: the host picks it (a dropdown), the others see it; the line under the list says
   how the one last picked or pointed at plays. */
.mp-players .mp-doc { flex: none; max-width: 46%; -webkit-appearance: none; appearance: none; margin: 0; padding: 5px 22px 5px 10px; border-radius: 999px; border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23aab2c0' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 8px center / 10px 7px;
  color: var(--text); font-family: inherit; font-size: 13px; font-weight: 700; cursor: pointer; text-overflow: ellipsis; }
.mp-players .mp-doc:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.mp-players .mp-doc option { background: #1b1e27; color: #e8ecf2; }
.mp-players .mp-docname { color: var(--text); font-weight: 700; }
.mp-docnote { margin: 0; font-size: 12.5px; line-height: 1.4; color: var(--muted); }
.mp-docnote[hidden] { display: none; }
.mp-docnote b { color: #d4dae4; }
.mp-docnote .mp-docwho { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; color: var(--muted); }
.mp-sum { margin: 0; font-size: 14px; color: var(--text); }
.mp-banner {
  position: fixed; z-index: 30; left: 50%; transform: translateX(-50%); bottom: calc(var(--safe-b) + 108px);
  display: flex; align-items: center; gap: 10px; max-width: calc(100% - 32px); padding: 8px 14px; border-radius: 999px;
  background: rgba(20, 22, 30, 0.92); border: 1px solid var(--line); box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35); font-size: 14px;
  pointer-events: auto;
}
#mp-banner-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.mp-banner .btn { flex: none; }
.mp-banner.wait #mp-banner-text::before { content: ''; display: inline-block; width: 10px; height: 10px; margin-right: 8px; border-radius: 50%; border: 2px solid var(--warn); border-right-color: transparent; vertical-align: -1px; animation: mpspin 0.9s linear infinite; }
@keyframes mpspin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .mp-banner.wait #mp-banner-text::before { animation: none; } }
#screen-mp { z-index: 25; background: rgba(10, 11, 15, 0.72); }
.mp-players li.mp-team { background: none; min-height: 0; padding: 6px 2px 0; font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 700; justify-content: space-between; }
.mp-players li.mp-team small { text-transform: none; letter-spacing: 0; font-weight: 400; }
.mp-players li.mp-swap { cursor: pointer; }
.mp-players li.mp-swap:hover { outline: 1px solid var(--line); }

/* ---- Missions as the tutorial: chapters, the next mission, the next goal's hint and the buttons it needs ---- */
.ms-chapter { margin: 14px 2px 0; }
.ms-chapter:first-child { margin-top: 2px; }
.ms-item.next { border-color: rgba(56,212,255,0.6); background: rgba(56,212,255,0.08); }
.ms-up { color: var(--accent); }
.obj-goals li.now { color: var(--text); font-weight: 700; }
.obj-hint { margin-top: 4px; padding-top: 4px; border-top: 1px solid var(--line); color: #cfe9f5; font-size: 0.95em; line-height: 1.3; }
.obj-hint kbd, .help-body kbd { display: inline-block; min-width: 1.4em; padding: 0 4px; border: 1px solid var(--line); border-bottom-width: 2px;
  border-radius: 5px; background: rgba(255,255,255,0.06); font: 600 0.85em/1.4 ui-monospace, monospace; text-align: center; color: var(--text); }
.tut-glow { position: relative; animation: tutglow 1.4s ease-in-out infinite; z-index: 1; }
@keyframes tutglow {
  0%, 100% { box-shadow: 0 0 0 2px rgba(56,212,255,0.85), 0 0 10px 2px rgba(56,212,255,0.35); }
  50% { box-shadow: 0 0 0 3px rgba(56,212,255,1), 0 0 22px 6px rgba(56,212,255,0.55); }
}

/* ---- How to play: contents with jump links ---- */
.help-toc { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 6px; }
.help-toc a { padding: 5px 10px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,0.04);
  color: var(--text); font-size: 13px; text-decoration: none; }
.help-toc a:hover { border-color: rgba(56,212,255,0.6); }
.help-body section { scroll-margin-top: 6px; }
.help-top { display: inline-block; margin: 6px 0 2px; font-size: 12px; color: var(--muted); text-decoration: none; }
.help-top:hover { color: var(--accent); }
/* One section at a time: a bar above the text that doesn't scroll away, and Previous / Next at the section's end. */
.help-nav { display: flex; align-items: center; gap: 6px; margin: 2px 0 8px; flex-shrink: 0; }
.help-nav select { flex: 1 1 auto; width: 0; min-width: 0; height: 36px; /* (width 0: the longest title mustn't widen the card) */ padding: 0 8px; border: 1px solid var(--line); border-radius: 10px;
  background: rgba(255,255,255,0.05); color: var(--text); font: inherit; font-size: 14px; }
.help-nav select option { background: #14213d; color: #f1e4d3; }
.help-nav .btn { flex-shrink: 0; min-width: 40px; height: 36px; padding: 0 12px; }
.help-nav .btn:disabled { opacity: 0.35; }
.help-body section .help-top { display: none; } /* (the bar and the footer do its job now) */
.help-pager { display: flex; gap: 8px; margin: 16px 0 6px; }
.help-pager .btn { flex: 1 1 0; width: 0; min-width: 0; white-space: normal; line-height: 1.25; padding: 9px 10px; font-size: 14px; }
@media (max-width: 420px) { .help-nav .pn-prev, .help-nav .pn-next { display: none; } } /* (a phone: the picker gets the room; Previous / Next are at the end) */
.help-pager .fp-next { text-align: right; }

/* ---- The menus in the app icon's colours: midnight navy, coral and cream (icons/icon.svg) ---- */
#screen-menu, .m-picker, #screen-missions, #screen-help, #screen-lore, #screen-feedback {
  --accent: #ff6b4a;          /* the planet's coral */
  --accent-ink: #14213d;      /* navy text on coral */
  --panel: rgba(17, 27, 51, 0.95);
  --panel-2: rgba(30, 44, 78, 0.96);
  --line: rgba(241, 228, 211, 0.12);
  --text: #f4ece2;            /* the ring's cream */
  --muted: #b9ad9f;
}
#screen-menu { background: radial-gradient(ellipse at 50% 28%, rgba(20, 33, 61, 0.35), rgba(8, 12, 24, 0.86)); }
.menu-card, #screen-missions .card, #screen-help .card, #screen-lore .card { background: var(--panel); border-color: rgba(241, 228, 211, 0.14); }
.m-icon { display: block; width: 84px; height: 84px; margin: -4px auto 10px; border-radius: 20px; box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(241, 228, 211, 0.12); }
#screen-menu .logo, .menu-card .m-head-logo { background: linear-gradient(180deg, #fff6ec 10%, #ffb08f 60%, #ff6b4a); -webkit-background-clip: text; background-clip: text; color: transparent; }
#screen-menu .tagline { color: #d9c9b6; letter-spacing: 0.04em; }
#m-new { box-shadow: 0 8px 26px rgba(255, 107, 74, 0.28); }
#screen-menu .btn.primary:hover { filter: brightness(1.06); }
#screen-menu .m-cust { background: rgba(20, 33, 61, 0.72); border-color: rgba(241, 228, 211, 0.16); color: var(--text); }
#screen-menu .m-cust:hover { border-color: rgba(255, 107, 74, 0.55); }
#screen-menu .m-cont { background: rgba(255, 107, 74, 0.1); border-color: rgba(255, 107, 74, 0.5); color: #ffd9cc; }
#screen-menu .m-sum .sum-main { color: #e6d9c8; }
#screen-menu .m-links button:hover { color: #ffb08f; }
/* The Lore guide's and Send feedback's buttons: small pills at the end of the links, kept together (they take a line of
   their own when the links fill theirs). */
.m-links .m-pills { display: inline-flex; flex-wrap: wrap; justify-content: center; gap: 6px 8px; margin-left: 4px; }
.m-links .m-pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px 4px 9px; border-radius: 999px;
  border: 1px solid rgba(241, 228, 211, 0.14); background: rgba(20, 33, 61, 0.5); font-size: 13px; letter-spacing: 0.02em; }
.m-links .m-pill svg { color: #ff8a66; }
#screen-menu .m-links .m-pill:hover { color: #ffb08f; border-color: rgba(255, 107, 74, 0.45); }
#screen-missions .help-body h3, #screen-help .help-body h3, #screen-lore .help-body h3 { color: #ff8a66; }

/* ---- The app icon, animated (tools/icon-animated.py): the planet turns, the stars twinkle ---- */
.ai-spin { animation: aiSpin 70s linear infinite; }
@keyframes aiSpin { from { transform: translateX(0); } to { transform: translateX(600px); } }
.ai-tw { animation: aiTwinkle 3.4s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.ai-tw-big { animation-name: aiTwinkleBig; animation-duration: 4.2s; }
@keyframes aiTwinkle { 0%, 100% { opacity: 0.85; } 50% { opacity: 0.2; } }
@keyframes aiTwinkleBig { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.35; transform: scale(0.55); } }
@media (prefers-reduced-motion: reduce) { .ai-spin, .ai-tw { animation: none; } }

/* ---- The loading screen: navy, the turning icon, the name, a short bar; fades out when the game is ready ---- */
#splash { position: fixed; inset: 0; z-index: 200; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  background: radial-gradient(ellipse at 50% 42%, #1c2d52 0%, #14213d 45%, #0a1122 100%); transition: opacity 0.45s ease; }
#splash.done { opacity: 0; pointer-events: none; }
.splash-icon { width: min(34vw, 150px); height: min(34vw, 150px); border-radius: 22%; box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(241, 228, 211, 0.12);
  animation: splashIn 0.6s cubic-bezier(.2, .8, .2, 1) both; }
.splash-word { font: 900 clamp(26px, 8vw, 38px)/1 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; letter-spacing: 0.12em;
  background: linear-gradient(180deg, #fff6ec 10%, #ffb08f 60%, #ff6b4a); -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: splashIn 0.6s 0.12s cubic-bezier(.2, .8, .2, 1) both; }
.splash-bar { width: min(46vw, 180px); height: 4px; border-radius: 4px; background: rgba(241, 228, 211, 0.12); overflow: hidden; }
.splash-line { margin: 4px 0 0; padding: 0 24px; max-width: 30em; text-align: center; font: italic 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: rgba(241, 228, 211, 0.72); animation: splashIn 0.6s 0.3s cubic-bezier(.2, .8, .2, 1) both; }
.splash-bar i { display: block; height: 100%; width: 0; border-radius: 4px; background: linear-gradient(90deg, #ff6b4a, #ffb08f); animation: splashBar 1.1s ease-out forwards; }
@keyframes splashIn { from { opacity: 0; transform: translateY(10px) scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes splashBar { to { width: 100%; } }
/* the line under the Victory buttons: what the chosen victory means (lined up with the buttons, under the label column) */
.m-vnote { margin: -4px 0 6px 96px; font-size: 12.5px; line-height: 1.35; color: var(--muted); text-wrap: pretty; }
@media (max-width: 420px) { .m-vnote { margin-left: 86px; } }
@media (max-width: 359px) { .m-vnote { margin-left: 2px; } }
/* Rival doctrine: the line under the doctrines says in depth how the one under the mouse (or focused, or last picked)
   plays; it keeps the height of the longest (sizeInfoLines), so nothing below it moves. The section's full width. */
.m-vnote.m-docnote { margin: 0 2px 4px; }
.m-docnote b { color: #d4dae4; font-weight: 700; }
.m-docnote i { color: #c4cad4; }
/* How it plays / Less (a touch screen; the lobby's line): a small link-like button after the text. */
.m-docmore { display: inline; margin: 0 0 0 2px; padding: 2px 6px; border: 1px solid rgba(56, 212, 255, 0.35); border-radius: 999px; background: rgba(56, 212, 255, 0.08);
  color: var(--accent); font: inherit; font-size: 12px; font-weight: 700; line-height: 1.3; cursor: pointer; white-space: nowrap; }
.m-docmore:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
/* A doctrine chip being looked at (a first tap on a touch screen, while the rivals have their own): a second tap gives it to them all. */
.m-chips button.peek { color: var(--text); border-style: dashed; border-color: var(--accent); }
/* Each rival (three or four players): a dropdown for each computer player, behind its colour (on a phone, its own picker). */
.m-seats { display: flex; flex-wrap: wrap; gap: 4px; min-width: 0; }
.m-seat { position: relative; display: flex; align-items: center; flex: 1 1 88px; min-width: 0; max-width: 150px; }
@media (max-width: 520px) { .m-seat { flex: 0 1 calc(50% - 2px); max-width: none; } } /* (a phone: two a row, all the same width) */
.m-seat[hidden] { display: none; }
.m-seat .dot { position: absolute; left: 9px; top: 50%; width: 10px; height: 10px; margin-top: -5px; border-radius: 50%; pointer-events: none; box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.35); }
.m-seat select { width: 100%; min-width: 0; -webkit-appearance: none; appearance: none; margin: 0; padding: 5px 20px 5px 25px; border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 999px;
  background: rgba(255, 255, 255, 0.05) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23aab2c0' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 8px center / 10px 7px;
  color: var(--text); font-family: inherit; font-size: 13px; font-weight: 700; line-height: 1.3; cursor: pointer; text-overflow: ellipsis; }
.m-seat select:hover { border-color: rgba(255, 255, 255, 0.22); }
.m-seat select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.m-seat select option { background: #1b1e27; color: #e8ecf2; }

/* A link dressed as a button (the illustrated manual, on the How to play screen). */
a.btn { display: block; text-align: center; text-decoration: none; color: inherit; }
/* The overlays are dialogs: opening one puts the keyboard focus on it (Tab then walks its buttons), with no ring round the whole screen. */
.screen:focus { outline: none; }

/* ---- Lore: the colony's archive (#screen-lore, openLore in js/ui.js), paged like the How to play ---- */
#screen-lore { z-index: 30; background: radial-gradient(ellipse at 50% 18%, rgba(28, 45, 82, 0.9), rgba(6, 10, 22, 0.96)); }
.lore-card { --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace; height: min(calc(100vh - 32px), 1000px); } /* (always its full height: the card doesn't jump from page to page) */
@supports (height: 100dvh) { .lore-card { height: min(calc(100dvh - var(--safe-t) - var(--safe-b) - 32px), 1000px); } }
.lore-head { align-items: flex-start; margin-bottom: 8px; }
@media (max-width: 420px) { .lore-kicker span { display: none; } } /* (a phone: one line) */
.lore-kicker { margin: 2px 0 0; font: 600 11px/1.3 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.lore-body h4 { margin: 16px 0 4px; font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; color: #ffb08f; }
.lore-body p, .lore-body li { line-height: 1.5; }
.lore-body q { display: block; quotes: none; margin: 3px 0; padding-left: 10px; border-left: 2px solid rgba(255, 107, 74, 0.55); font: 12.5px/1.45 var(--mono); color: #ffd9cc; }
.lore-fig { margin: 4px 0 12px; }
.lore-fig img { display: block; width: 100%; height: auto; border-radius: 12px; background: #0a1225; }
.lore-fig figcaption { margin-top: 5px; font-size: 12px; font-style: italic; color: var(--muted); }
.lore-hero img { aspect-ratio: 16 / 9; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(241, 228, 211, 0.1); }
.lore-plate svg { display: block; width: 100%; height: auto; border-radius: 14px; box-shadow: 0 0 0 1px rgba(241, 228, 211, 0.1); }
.lp-label text { font: 700 12.5px system-ui, sans-serif; letter-spacing: 0.12em; fill: #f4ece2; }
.lp-small text { font: 600 11px system-ui, sans-serif; }
@media (max-width: 699px) { .lp-label text { font-size: 17px; } .lp-small text { font-size: 15px; } } /* (the plate is drawn smaller on a phone) */
.lore-body p.lore-log { margin: 10px 0; padding: 2px 0 2px 10px; border-left: 2px solid var(--accent); font: 12.5px/1.5 var(--mono); color: #ffd9cc; }
.lore-def { margin: 12px 0; padding: 10px 14px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255, 255, 255, 0.03); }
.lore-def dt { font: 700 19px/1.2 Georgia, "Times New Roman", serif; color: var(--text); }
.lore-def dt small { font: italic 400 13px Georgia, serif; color: var(--muted); }
.lore-def dd { margin: 6px 0 0; color: #d3d9e2; }
.lore-redact { font-style: italic; color: var(--muted); }
.lore-toc { margin-top: 14px; }
/* The Arrival clock: a timeline down the page, Arrival Day ringed, now lit. */
.lore-time { position: relative; list-style: none; margin: 12px 0 6px; padding: 0; }
.lore-time::before { content: ''; position: absolute; left: 76px; top: 10px; bottom: 14px; width: 2px; background: linear-gradient(rgba(241, 228, 211, 0.14), rgba(241, 228, 211, 0.3) 70%, rgba(255, 107, 74, 0.8)); }
.lore-time li { position: relative; display: grid; grid-template-columns: 62px 1fr; gap: 0 30px; padding: 5px 0; }
.lore-time li::before { content: ''; position: absolute; left: 71px; top: 9px; width: 12px; height: 12px; border-radius: 50%; background: #1e2c4e; border: 2px solid rgba(241, 228, 211, 0.55); }
.lt-when { text-align: right; font: 11.5px/1.3 var(--mono); color: var(--muted); }
.lt-when b { display: block; font-size: 15px; color: var(--text); }
.lore-time p { margin: 0; }
.lore-note { display: block; margin-top: 2px; font: 12px/1.4 var(--mono); color: #b9ad9f; }
.lore-time .lt-zero::before { left: 68px; top: 6px; width: 18px; height: 18px; background: #0c1529; border: 3px solid var(--accent); }
.lt-zero .lt-when b, .lt-now .lt-when b { color: var(--accent); }
.lore-time .lt-now::before { background: var(--accent); border-color: #ffd9cc; box-shadow: 0 0 0 5px rgba(255, 107, 74, 0.22); animation: lorePulse 2.6s ease-in-out infinite; }
@keyframes lorePulse { 50% { box-shadow: 0 0 0 9px rgba(255, 107, 74, 0.05); } }
@media (prefers-reduced-motion: reduce) { .lore-time .lt-now::before { animation: none; } }
/* Regions: survey shots from the game's own ground. */
.lore-regions { list-style: none; margin: 10px 0; padding: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 700px) { .lore-regions { grid-template-columns: repeat(5, 1fr); } }
.lore-regions li { overflow: hidden; padding-bottom: 8px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255, 255, 255, 0.03); }
.lore-regions img, .lr-void { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; object-fit: cover; background: #0a1225; }
.lore-regions b { display: block; margin: 7px 10px 0; font-size: 14px; }
.lore-regions small { display: block; margin: 0 10px; font-size: 12px; color: #ffb08f; }
.lore-regions p { margin: 4px 10px 0; font-size: 12.5px; line-height: 1.4; color: #c9cfd8; }
.lr-void { display: grid; place-items: center; background: repeating-linear-gradient(135deg, #0a0f1e 0 9px, #10172b 9px 18px); }
.lr-void i { padding: 4px 8px; border: 1px dashed rgba(179, 107, 255, 0.5); border-radius: 6px; font: 700 10.5px var(--mono); font-style: normal; letter-spacing: 0.2em; color: #a993cf; }
/* The four vanguards: Accord-issued emblems, one to four bars. */
.lore-calls { list-style: none; margin: 10px 0; padding: 0; display: grid; gap: 8px; }
@media (min-width: 700px) { .lore-calls { grid-template-columns: 1fr 1fr; } }
.lore-calls li { display: flex; align-items: flex-start; gap: 12px; padding: 10px 12px; border: 1px solid color-mix(in srgb, var(--c) 35%, transparent); border-radius: 12px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--c) 13%, transparent), rgba(255, 255, 255, 0.02)); }
.lore-emb { flex: 0 0 52px; width: 52px; height: 52px; }
.e-hex { fill: color-mix(in srgb, var(--c) 14%, #0c1529); stroke: var(--c); stroke-width: 2.5; stroke-linejoin: round; }
.e-pl, .e-bars rect { fill: var(--c); }
.e-ring { fill: none; stroke: #f4ece2; stroke-width: 2.4; }
.lore-calls b { font-size: 15px; letter-spacing: 0.12em; color: var(--c); }
.lore-calls small { display: block; font-size: 12px; color: var(--muted); }
.lore-calls p { margin: 4px 0 0; font-size: 13.5px; }
.lore-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; max-width: 440px; margin-inline: auto; }
.lore-pair img { aspect-ratio: 1; background: radial-gradient(circle at 50% 58%, #26324d, #0c1529 70%); }
.lore-pair figcaption { grid-column: 1 / -1; text-align: center; }
/* The doctrines and the Research Lab's table. */
.lore-docs { display: grid; gap: 8px; margin: 10px 0; }
@media (min-width: 700px) { .lore-docs { grid-template-columns: 1fr 1fr; } }
.lore-doc { padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255, 255, 255, 0.03); }
.lore-doc b { font-size: 15px; }
.lore-doc small { margin-left: 7px; font-size: 11.5px; letter-spacing: 0.08em; text-transform: uppercase; color: #ffb08f; }
.lore-doc p { margin: 4px 0 6px; font-size: 13.5px; }
.lore-doc q.ld-last { color: var(--muted); border-left-color: rgba(241, 228, 211, 0.25); }
.lore-table { width: 100%; margin: 8px 0; border-collapse: collapse; font-size: 13.5px; }
.lore-table th { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.lore-table td { padding: 7px 8px; border-bottom: 1px solid rgba(241, 228, 211, 0.06); vertical-align: top; color: #d3d9e2; }
.lore-table td:first-child { width: 27%; color: #ffb08f; }
.lore-table td:nth-child(2) { width: 25%; color: var(--text); }
/* Neutral ground, and the Wren's cargo lists on cream paper. */
.lore-items { display: grid; gap: 10px; margin: 10px 0; }
.lore-item { display: grid; grid-template-columns: 96px 1fr; gap: 12px; align-items: start; padding: 8px 10px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255, 255, 255, 0.03); }
.lore-item img { width: 96px; height: 96px; object-fit: contain; border-radius: 10px; background: radial-gradient(circle at 50% 55%, #1d2a48, #0a1225 72%); }
@media (min-width: 700px) { .lore-item { grid-template-columns: 128px 1fr; } .lore-item img { width: 128px; height: 128px; } }
.lore-item b { font-size: 15px; }
.lore-item p { margin: 3px 0 6px; font-size: 13.5px; }
.lore-manifest { margin: 14px 0 4px; padding: 12px 16px; border-radius: 6px; background: #efe3d1; color: #2b2219; font: 12.5px/1.55 var(--mono);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.4); transform: rotate(-0.6deg); }
.lore-manifest .lm-head { text-transform: uppercase; margin: 0 0 6px; padding-bottom: 6px; border-bottom: 1px dashed rgba(43, 34, 25, 0.4); font-weight: 800; letter-spacing: 0.06em; color: #2b2219; }
.lore-manifest p.lm-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0 12px; }
.lore-manifest .lm-head span { font-weight: 600; color: #8f3524; }
.lore-manifest ol { margin: 0; padding-left: 2.2em; list-style: decimal-leading-zero; color: #2b2219; }
.lore-manifest li { line-height: 1.5; }
.lore-manifest .lm-foot { margin: 8px 0 0; text-align: right; font-weight: 700; color: #a3361f; }
/* The Murmur: two classes met in raids, three only sighted, and the Deep, never seen. */
.lore-mur { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 10px 0; }
@media (min-width: 700px) { .lore-mur { grid-template-columns: repeat(3, 1fr); } }
.lore-mur figure { margin: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: #0b1428; }
.lore-mur img, .lore-mur .lr-void { display: block; width: 100%; height: auto; aspect-ratio: 4 / 3; object-fit: cover; background: radial-gradient(ellipse at 50% 62%, #233256, #0b1428 72%); }
.lore-mur .lr-deep { position: relative; display: grid; place-items: start center; padding-top: 10px; }
.lr-deep svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.lr-deep i { position: relative; }
.lore-mur .lr-void { background: radial-gradient(ellipse at 50% 80%, rgba(179, 107, 255, 0.18), transparent 60%), repeating-linear-gradient(135deg, #0a0f1e 0 9px, #10172b 9px 18px); }
.lore-mur figcaption { padding: 6px 10px 9px; font-size: 12.5px; line-height: 1.4; color: #c9cfd8; }
.lore-mur figcaption b { display: block; font-size: 14.5px; color: var(--text); }
.lore-mur figcaption small { display: block; margin-bottom: 3px; font: 600 10.5px var(--mono); letter-spacing: 0.1em; text-transform: uppercase; color: #c7a6ff; }
.lore-open { margin: 14px 0 4px; padding: 10px 12px; border: 1px dashed rgba(179, 107, 255, 0.5); border-radius: 10px; background: rgba(179, 107, 255, 0.07); }
/* Accord standards: the field manual. */
.lore-std { display: grid; grid-template-columns: 9.5em 1fr; gap: 7px 14px; margin: 10px 0; }
.lore-std dt { font-size: 13.5px; font-weight: 700; color: #ffb08f; }
.lore-std dd { margin: 0; font-size: 13.5px; color: #d3d9e2; }
@media (max-width: 480px) { .lore-std { grid-template-columns: 1fr; gap: 0; } .lore-std dd { margin-bottom: 8px; } }
/* Your colony: its log, and the Arrival clock on the Command Base's panel. */
.lore-loglines { list-style: none; margin: 10px 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #070c19; font: 12.5px/1.5 var(--mono); color: #cfe9f3; }
.lore-loglines li { display: grid; grid-template-columns: 6.6em 1fr; gap: 10px; padding: 3px 0; }
.lore-loglines span { padding-top: 1px; font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; color: #6f86a8; }
.lore-base { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: center; max-width: 520px; margin-inline: auto; }
.lore-base img { aspect-ratio: 1; background: radial-gradient(circle at 50% 56%, #16244a, #070c19 70%); }
.lore-clock { padding: 12px 14px; border: 1px solid rgba(56, 212, 255, 0.3); border-radius: 12px; background: #070c19; font-family: var(--mono); color: #9fe9ff; text-shadow: 0 0 8px rgba(56, 212, 255, 0.45); }
.lore-clock small { display: block; font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; color: #6f9fb8; text-shadow: none; }
.lore-clock b { display: block; margin-bottom: 8px; font-size: 30px; line-height: 1.1; }
.lore-clock b span { margin-left: 4px; font-size: 13px; }
.lore-clock em { font-style: normal; font-size: 13px; color: #cfe9f3; }
.lore-body p.lore-end { margin: 18px 0 6px; text-align: center; font-style: italic; color: var(--muted); }
/* On a phone the card's title is compact, so the pages have the height (as the How to play's). */
@media (max-width: 699px) and (min-height: 520px), (orientation: landscape) and (max-height: 519px) {
  #screen-lore .help-card { padding: 12px 16px; }
  #screen-lore .help-card h2 { font-size: 18px; }
}
@media (orientation: landscape) and (max-height: 519px) {
  #screen-lore { padding: calc(var(--safe-t) + 8px) calc(var(--safe-r) + 8px) calc(var(--safe-b) + 8px) calc(var(--safe-l) + 8px); }
  #screen-lore .help-card { width: 100%; height: calc(100vh - 16px); height: calc(100dvh - 16px - var(--safe-t) - var(--safe-b)); max-height: none; }
}

/* ---- Send feedback (#screen-feedback, js/feedback.js): in the menus' colours, from the main menu or over the pause menu ---- */
#screen-feedback { z-index: 35; background: radial-gradient(ellipse at 50% 28%, rgba(20, 33, 61, 0.55), rgba(8, 12, 24, 0.9)); }
#screen-feedback .fb-card { width: min(100%, 480px); min-width: 0; display: flex; flex-direction: column; gap: 14px;
  background: #111b33; border-color: rgba(241, 228, 211, 0.14); } /* (solid: the pause menu's buttons don't show through) */
.fb-form { margin: 0; min-width: 0; }
#fb-form > * + * { margin-top: 14px; } /* (margins, not a gap: the message line, empty, takes no room and stays a live region) */
.fb-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.fb-lbl { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 2px 10px; font-size: 13px; font-weight: 700; color: var(--muted); }
.fb-lbl small { font-size: 12px; font-weight: 500; }
.fb-count { font-variant-numeric: tabular-nums; }
.fb-count.near { color: var(--warn); }
.fb-type button { padding: 9px 4px; min-width: 0; }
.fb-field textarea, .fb-field input {
  display: block; width: 100%; min-width: 0; margin: 0; font: inherit; font-size: 16px; line-height: 1.45; color: var(--text);
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  user-select: text; -webkit-user-select: text; touch-action: auto; -webkit-touch-callout: default;
}
.fb-field textarea { min-height: 132px; max-height: 50vh; resize: vertical; }
.fb-field input { min-height: 44px; }
.fb-field textarea::placeholder, .fb-field input::placeholder { color: var(--muted); opacity: 0.75; }
.fb-field textarea:focus, .fb-field input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.fb-field textarea[readonly], .fb-field input[readonly] { opacity: 0.7; }
#screen-feedback button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#screen-feedback .seg button:focus-visible { outline-offset: -2px; }
.fb-check { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px;
  background: rgba(255, 255, 255, 0.03); font-size: 14px; font-weight: 650; cursor: pointer; }
.fb-check input { flex: none; width: 20px; height: 20px; margin: 0; accent-color: var(--accent); }
.fb-check small { display: block; margin-top: 2px; font-size: 12.5px; font-weight: 500; color: var(--muted); }
.fb-what { margin: 0; font-size: 12.5px; line-height: 1.45; color: var(--muted); }
.fb-msg { margin: 0; font-size: 14px; line-height: 1.4; color: var(--warn); }
.fb-msg.bad { padding: 9px 12px; border-radius: 10px; color: #ffd0c4; background: rgba(255, 90, 110, 0.1); border: 1px solid rgba(255, 90, 110, 0.35); }
#fb-form > .fb-msg:empty { margin-top: 0; }
.fb-done .btn.big { margin-top: 0; }
.fb-hp { position: absolute; left: -10000px; top: 0; width: 1px; height: 1px; overflow: hidden; }
.fb-done { display: flex; flex-direction: column; gap: 14px; }
.fb-thanks { margin: 4px 0 0; font-size: 17px; font-weight: 650; line-height: 1.4; color: var(--text); }
