/* ===================================================================   Thrones — parchment theme.
   Warm off-white panels over the map, deep ink text, aged-gold accents.
   Faction colours are reserved for ownership and never used as chrome.
   ========================================================================== */

:root {
  --parchment: #f2e7cd;
  --parchment-2: #e9dcbe;
  --parchment-3: #ddcda8;
  --ink: #2b2318;
  --ink-soft: #5b4e3a;
  --ink-faint: #857553;
  --gold: #a8842c;
  --gold-bright: #d7a73f;
  --sea: #1d2f3d;
  --sea-deep: #14212c;
  --bad: #a33326;
  --warn: #b8791f;
  --good: #4f7a44;
  --rule: rgba(43, 35, 24, 0.18);
  --rule-strong: rgba(43, 35, 24, 0.34);
  --panel-shadow: 0 10px 30px rgba(10, 16, 22, 0.42);
  /* The plot picker's clearance above the control panel. It was read as
     `var(--tree-gap, 10px)` and defined nowhere in the repo, so the fallback was
     the only value it ever had — a knob that looked adjustable and was not. */
  --tree-gap: 10px;
  --radius: 10px;
  --radius-sm: 6px;
  --topbar-h: 52px;
  /* The stockpile strip. It is three rows deep now — disc, stock, rate — so its
     height is the sum of its parts rather than a round number: padding, the
     disc, the figure and the rate. `--chrome-top` is computed from it, so the
     camera's clear band, the right rail and the Treasury popover all follow it
     without a second edit; the one thing to keep true is that `--resource-h`
     and `--resource-disc` move together, which is what the compact block in
     "stockpile tiers" does. */
  --resource-disc: 42px;
  --resource-tile-w: 60px;
  --resource-h: 86px;
  /* Width of the docked right rail. `--col-w` is what render/stage.js reads to
     work out how much of the viewport the chrome is standing on, so it tracks
     the rail only while the rail is docked and falls to 0 once it is a drawer. */
  --rail-w: 320px;
  --col-w: var(--rail-w);
  /* What the camera in render/stage.js must keep clear on each side. There is no
     left column any more, so the map is only pushed in from the right. */
  --inset-left: 8px;
  --inset-right: calc(var(--col-w) + 16px);
  /* Height of the bottom command bar. It floats over the map exactly as a Total
     War command bar does, so it is deliberately not part of --col-w's story.
     It grew by one row when the army pane gained the formation picker: stance
     and formation are two controls a player compares side by side, and a
     picker you have to scroll to find is not a picker. */
  --cmd-h: 252px;
  /* **What the command bar owns at the foot of the screen**, and the one figure
     every layer that floats over the map keeps clear of. `--cmd-own` is the
     bar's footprint — its height, the 8 px it stands off the floor, and an 8 px
     gap; `--cmd-clear` is that figure after the clamp in the touch block far
     below, and it is the one the layers read.

     **It exists because `--cmd-h` is not the bar's height, and six layers
     believed it was.** The toasts, the battle prompts, the attack card, the
     battle report, the decision cards and the war plan each wrote their own
     `var(--cmd-h) + 16px`. On a desktop that is near enough true. On a phone it
     is not: `--cmd-h` is 168 there and an unfolded bar is
     `min(62vh, 100dvh - var(--chrome-top) - 16px)`, measured at **523 px on a
     390x844 screen, y 313..836** — so each of them reserved 184 px for a bar
     that owned 539, and laid its card inside it. Measured with a decision card
     up: the pane switch, Plan, the clear button and the fold button all
     hit-tested into the card, and the fold button is the one control that gives
     the screen back.

     **Not `--inset-bottom`**, which answers a different question — how much map
     the camera draws — and deliberately under-reserves when the bar is folded so
     the map gets the room back. This one is read by CSS alone, so unlike that
     one it may be a `calc()`: nothing in `stage.js` sees it, and the
     unresolved-custom-property trap noted there does not apply. The default is
     the arithmetic all six carried before, so the desktop does not move. */
  --cmd-own: calc(var(--cmd-h) + 16px);
  --cmd-clear: var(--cmd-own);
  /* Top of the free map band: below the top bar and the stockpile strip. */
  --chrome-top: calc(8px + var(--topbar-h) + 6px + var(--resource-h) + 6px);
  --font-head: 'Cinzel', 'Palatino Linotype', Georgia, serif;
  --font-body: 'Inter', 'Segoe UI', system-ui, sans-serif;

  /* The three painted interface surfaces (docs/ART.md), or `none` when they are
     not installed. `ui/uiAssets.js` points these at real files only after the
     server's manifest has said the files exist — a `url()` written here would be
     fetched whether or not there is anything at the end of it, and a stylesheet
     404 is a red line in the console that no fallback can take back. */
  --paper-texture: none;
  --paper-edge: none;
  --banner-cloth: none;
  /* One entry per layer of `--paper`. The grain multiplies into the warm tone
     under it instead of covering it, so an installed near-white paper darkens
     and textures the parchment rather than bleaching it. A `none` layer blends
     with nothing, so this is inert when the file is absent. */
  --paper-blend: normal, normal, normal, normal, multiply, normal;

  /* Parchment: the painted grain when there is one, under the same highlight,
     fibre and tone gradients as before. The gradients stay because they are what
     gives a panel its light — a lit top-left corner and a shaded bottom-right —
     and a flat repeating tile has none of that. The texture only replaces the
     bottom layer, the flat paper the gradients were sitting on. */
  --paper:
    radial-gradient(120% 90% at 12% 4%, rgba(255, 252, 240, 0.9), rgba(255, 252, 240, 0) 60%),
    radial-gradient(90% 80% at 92% 96%, rgba(159, 128, 74, 0.22), rgba(159, 128, 74, 0) 62%),
    repeating-linear-gradient(92deg, rgba(150, 122, 72, 0.045) 0 2px, rgba(150, 122, 72, 0) 2px 5px),
    repeating-linear-gradient(4deg, rgba(120, 96, 56, 0.035) 0 3px, rgba(120, 96, 56, 0) 3px 7px),
    var(--paper-texture),
    linear-gradient(168deg, var(--parchment) 0%, var(--parchment-2) 68%, var(--parchment-3) 100%);
}

* { box-sizing: border-box; }

/* A long press opens a card's details; it must not select text, raise the
   magnifier, or zoom the page (the player, 8 November 2026; ui/touchGuards.js
   is the half CSS cannot do). `pan-x pan-y` leaves scrolling and takes the
   browser's pinch and double-tap zoom. */
@media (pointer: coarse) {
  html, body { touch-action: pan-x pan-y; }
  body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
  body :is(input, textarea, select, [contenteditable="true"]) { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
}

html, body {
  margin: 0;
  /* **`dvh`, because iOS moves the goalposts.** `100%` resolves against the
     initial containing block, which with `viewport-fit=cover` does not track
     Safari's collapsing toolbar — so the page is laid out for one height while
     the player is looking at another, and the difference shows as a band of
     `--sea-deep` under the game with nothing in it. A real iPhone reported it as
     "unused gap at the bottom"; it does not reproduce under emulation, because
     headless Chromium has no toolbar to collapse. `100%` stays as the fallback
     for anything without `dvh`. */
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background: var(--sea-deep);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: var(--font-head);
  font-weight: 700;
  letter-spacing: 0.01em;
  margin: 0;
}

/* `clip`, not `hidden`: the chronicle rail parks 388 px off the right edge, and a
   `hidden` box can still be scrolled by script or focus, which carried the menu and
   then the battle 331 px sideways (TODO §100). */
#app { position: relative; width: 100%; height: 100%; height: 100dvh; overflow: clip; }

.map-root {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(120% 100% at 50% 0%, #24394a 0%, var(--sea) 45%, var(--sea-deep) 100%);
}
.map-root canvas {
  display: block;
  /*
   * **The browser must not take the gestures the map needs.** Without this a
   * pinch zooms the *page* rather than the map, a double tap zooms the page too,
   * and a one-finger drag scrolls instead of panning or aiming a march — the
   * game's own handlers never see any of it. `none` hands every touch to the
   * canvas, which is what `render/stage.js` wires the recogniser for.
   */
  touch-action: none;
  /* A press-and-hold on a canvas otherwise raises the platform's text-selection
     or callout menu over the map, which is exactly the gesture long-press-to-
     order needs. */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
/* The campaign's battle view wants the same for the same reasons. The
   standalone sandbox has its own stylesheet and gets it there. */
.bv-canvas {
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* ---------- shared atoms -------------------------------------------------- */

.muted { color: var(--ink-faint); }
.small { font-size: 12px; }
.right { text-align: right; }
.center { justify-content: center; }
.pad { padding: 10px 12px; }
.label { font-size: 11px; letter-spacing: 0.09em; text-transform: uppercase; color: var(--ink-faint); }
.text-bad { color: var(--bad); }
.text-good { color: var(--good); }

.btn {
  font: 500 13px/1 var(--font-body);
  color: var(--ink);
  background: linear-gradient(180deg, rgba(255, 253, 245, 0.92), rgba(226, 212, 181, 0.92));
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  cursor: pointer;
  transition: background 120ms ease, transform 80ms ease, box-shadow 120ms ease;
}
.btn:hover:not(:disabled) { background: linear-gradient(180deg, #fffdf4, #e6d6ac); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-small { padding: 5px 9px; font-size: 12px; }
.btn-primary {
  background: linear-gradient(180deg, var(--gold-bright), #b98d2c);
  border-color: #7d5f18;
  color: #221a08;
  font-weight: 600;
}
.btn-primary:hover:not(:disabled) { background: linear-gradient(180deg, #e6b94f, #c39730); }
.btn-danger { color: #6d1d13; border-color: rgba(163, 51, 38, 0.5); }
.btn-icon { padding: 6px 9px; font-size: 14px; line-height: 1; }
/* Music off: the button stays legible but plainly not lit. */
.btn-icon.is-off { opacity: 0.5; }
.btn-icon:disabled { opacity: 0.35; cursor: default; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-soft); }
.btn-ghost:hover { background: rgba(43, 35, 24, 0.08); }
.btn.is-active { background: linear-gradient(180deg, #cdb47a, #b79a58); border-color: #7d5f18; }

.chip-btn {
  font: 500 12px/1 var(--font-body);
  color: var(--ink-soft);
  background: rgba(255, 253, 245, 0.5);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 5px 10px;
  cursor: pointer;
}
.chip-btn:hover:not(:disabled) { background: rgba(255, 253, 245, 0.9); }
.chip-btn.is-active { background: var(--gold-bright); border-color: #7d5f18; color: #221a08; font-weight: 600; }
.chip-btn:disabled { opacity: 0.45; cursor: not-allowed; }

.link-btn {
  background: none;
  border: 0;
  padding: 2px 0;
  font: 500 13px/1.4 var(--font-body);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}
.link-btn:hover { color: var(--gold); }

:where(.btn, .chip-btn, .link-btn, .input, .faction-card, .army-row, select, input):focus-visible {
  outline: 2px solid var(--gold-bright);
  outline-offset: 2px;
}

.input {
  font: 400 13px/1.3 var(--font-body);
  color: var(--ink);
  background: rgba(255, 253, 245, 0.86);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-sm);
  padding: 7px 9px;
  min-width: 0;
}
.input:disabled { opacity: 0.55; }
.input-count { width: 64px; }

.tag {
  display: inline-block;
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(43, 35, 24, 0.1);
  color: var(--ink-soft);
  vertical-align: middle;
}
.tag-public, .tag-host { background: rgba(168, 132, 44, 0.24); color: #6a5010; }
.tag-running, .tag-ready { background: rgba(79, 122, 68, 0.22); color: #2f5127; }
.tag-lobby { background: rgba(29, 47, 61, 0.14); color: #2c4356; }
.tag-duel { background: rgba(196, 84, 60, 0.3); color: #f3d2c4; }
.tag-bad, .tag-finished { background: rgba(163, 51, 38, 0.18); color: #7b2519; }
.tag-warn { background: rgba(184, 121, 31, 0.2); color: #7a4f0d; }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; vertical-align: middle; }

.shield { display: block; flex: none; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.25)); }

/* The painted crest (docs/ART.md), sized into exactly the box the inline shield
   would have taken so the two are interchangeable. The image file is a 128px
   square with the shield drawn 118px tall inside it, so it is oversized by that
   ratio and centred: what matches the vector shield is the drawn shield, not the
   file's transparent margins.

   The ring is the point of the wrapper. The crest art has its field colour baked
   in and cannot follow the server if a faction's colour is retuned, so the one
   thing that must agree with the map — `PLAYER_DEFINITIONS[id].color`, arriving
   on `--faction` — is drawn here rather than trusted to the image. */
.crest {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  overflow: visible;
  /* Four one-pixel offsets trace the shield's own silhouette in the faction's
     colour — a border cannot, because the silhouette is not a rectangle. */
  filter:
    drop-shadow(1px 0 0 var(--crest-ring, var(--faction, #8a8375)))
    drop-shadow(-1px 0 0 var(--crest-ring, var(--faction, #8a8375)))
    drop-shadow(0 1px 0 var(--crest-ring, var(--faction, #8a8375)))
    drop-shadow(0 -1px 0 var(--crest-ring, var(--faction, #8a8375)))
    drop-shadow(0 1px 1.5px rgba(0, 0, 0, 0.38));
}
/* On a surface that is already the faction's colour — the top bar's banner — a
   ring in that same colour says nothing and the crest sinks into its
   background. There the rim is the ink that colour was chosen to carry. */
.faction-banner .crest { --crest-ring: var(--faction-ink, #fdf6e4); }
.crest img {
  /* The painted crests are 115px of a 128px canvas, so 115/128 x 111.3% = 100%:
     the shield fills its box exactly. The old 108.5% was calibrated against the
     six-faction art, which was 118 of 128, and left the new set at 97.5%. */
  height: 111.3%;
  width: auto;
  max-width: none;
  display: block;
}

.kv { display: flex; justify-content: space-between; gap: 12px; padding: 2px 0; font-size: 13px; }
.kv-k { color: var(--ink-faint); }
.kv-v { font-weight: 500; text-align: right; }

.meter { margin: 8px 0; }
.meter-head { display: flex; justify-content: space-between; font-size: 11px; color: var(--ink-faint); letter-spacing: 0.05em; text-transform: uppercase; }
.meter-track { height: 7px; border-radius: 4px; background: rgba(43, 35, 24, 0.14); overflow: hidden; margin-top: 3px; }
.meter-fill { height: 100%; background: var(--ink-soft); transition: width 240ms ease; }
.meter-good .meter-fill { background: linear-gradient(90deg, #6d9a5c, var(--good)); }
.meter-warn .meter-fill { background: linear-gradient(90deg, #d9a94d, var(--warn)); }
.meter-bad .meter-fill { background: linear-gradient(90deg, #c8563f, var(--bad)); }

.empty { padding: 18px 14px; text-align: center; }
.empty-title { font-family: var(--font-head); margin: 0 0 4px; }
.empty-hint { margin: 0; font-size: 12px; color: var(--ink-faint); }

.hint { font-size: 12px; color: var(--ink-faint); margin: 6px 0 0; }

.chips { display: flex; flex-wrap: wrap; gap: 5px; }

/* A fact badge: a figure and the word for it, with the sentence it replaced in
   its tooltip. The Overview tray used to be four paragraphs of prose about
   forage, pacification, river crossings and the country; each is now one badge
   whose number is the whole of the point. */
.facts { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 4px; }
.fact {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: rgba(255, 253, 245, 0.5);
  font-size: 10.5px;
  line-height: 1.5;
  color: var(--ink-soft);
  white-space: nowrap;
  cursor: help;
}
.fact b { font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.fact-good { background: rgba(79, 122, 68, 0.14); border-color: rgba(79, 122, 68, 0.34); }
.fact-good b { color: #2f5127; }
.fact-warn { background: rgba(184, 121, 31, 0.14); border-color: rgba(184, 121, 31, 0.34); }
.fact-warn b { color: #7a4f0d; }
.fact-bad { background: rgba(163, 51, 38, 0.13); border-color: rgba(163, 51, 38, 0.34); }
.fact-bad b { color: #7b2519; }
.fact-river { background: rgba(44, 96, 114, 0.13); border-color: rgba(44, 96, 114, 0.34); }
/* A wave, so a river badge is not read as a place with a percentage on it. */
.fact-river::before { content: '≈'; color: #2c6072; font-size: 11px; line-height: 1; }
.fact-river b { color: #1d5e72; }
.fact-river.is-bridged { border-style: dashed; }
/* A climb out of this province (climbs.js). Earth rather than the river's
   water-blue, and a caret rather than a wave, so the two obstacle badges on the
   same road row cannot be mistaken for each other at a glance. */
.fact-climb { background: rgba(122, 79, 13, 0.13); border-color: rgba(122, 79, 13, 0.34); }
.fact-climb::before { content: '^'; color: #7a4f0d; font-size: 11px; line-height: 1; }
.fact-climb b { color: #7a4f0d; }
.chip {
  font-size: 11px;
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(43, 35, 24, 0.07);
  border: 1px solid var(--rule);
}
.chip-good { background: rgba(79, 122, 68, 0.16); border-color: rgba(79, 122, 68, 0.32); }

.row-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; align-items: center; }

.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { padding: 6px 8px; border-bottom: 1px solid var(--rule); text-align: left; }
.table thead th {
  font: 600 11px/1 var(--font-body);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.table tbody tr:hover { background: rgba(168, 132, 44, 0.09); }

/* ---------- panels -------------------------------------------------------- */

.panel, .card, .overlay-card, .lobby-scroll, .toast {
  background-image: var(--paper);
  background-blend-mode: var(--paper-blend);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  box-shadow: var(--panel-shadow);
}

.panel { display: flex; flex-direction: column; overflow: hidden; min-height: 0; }
.panel[hidden] { display: none; }

.panel-head {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px 8px;
  border-bottom: 1px solid var(--rule);
  background: linear-gradient(180deg, rgba(255, 252, 240, 0.7), rgba(255, 252, 240, 0));
}
/* `panel-edge.png` is a worn deckled paper edge, repeated along the one border
   inside a panel that the eye actually follows: under its heading. It is laid
   over the hairline rule rather than replacing it, so with no file installed the
   strip is empty and the rule is exactly what it was. Out of the flow, so it
   costs no height either way, and `aria-hidden` by construction. */
.panel-head::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 7px;
  pointer-events: none;
  background-image: var(--paper-edge);
  background-size: auto 100%;
  background-repeat: repeat-x;
  opacity: 0.5;
}
.panel-head h3 { font-size: 16px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.section { padding: 8px 0; border-top: 1px solid var(--rule); }
.section:first-child { border-top: 0; padding-top: 0; }
.section-title {
  font: 600 11px/1 var(--font-body);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 6px;
}
.section-alarm { background: rgba(163, 51, 38, 0.08); border-radius: var(--radius-sm); padding: 8px; }

.owner-chip {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--faction) 26%, transparent);
  border: 1px solid var(--faction);
  color: var(--ink);
  white-space: nowrap;
}

/* ---------- topbar -------------------------------------------------------- */

.topbar {
  position: absolute;
  top: 8px;
  left: 8px;
  right: 8px;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 10px;
  background-image: var(--paper);
  background-blend-mode: var(--paper-blend);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  box-shadow: var(--panel-shadow);
  z-index: 30;
}
.topbar[hidden] { display: none; }
/* Nothing in the bar may push a neighbour out of the bar: every group shrinks,
   every group clips, and the drop order below decides what goes first. */
.topbar { flex-wrap: nowrap; overflow: hidden; }
.topbar-left { display: flex; align-items: center; gap: 10px; flex: 1 1 auto; min-width: 0; overflow: hidden; }
.topbar-center { display: flex; align-items: center; gap: 10px; flex: 0 1 auto; min-width: 0; overflow: hidden; }
.topbar-right { display: flex; align-items: center; gap: 5px; flex: 0 0 auto; justify-content: flex-end; }

/* The faction banner: a solid block of your own colour, not a tinted chip, so
   "which one am I" is answered from the corner of the eye. */
.faction-banner {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4px 14px 4px 8px;
  border-radius: var(--radius-sm);
  /* `banner-cloth.png` is plain undyed cloth with no device on it, which is
     exactly what a per-faction tint wants: multiplied over the faction's own
     colour it dyes the cloth, so the weave and the fold shadows show through
     without shifting the hue. The colour is still the server's and still the
     background-colour, so with no file installed this is the solid block it
     always was. */
  background-color: var(--faction, #6c655a);
  background-image: var(--banner-cloth);
  background-size: auto 100%;
  background-repeat: repeat-x;
  background-blend-mode: multiply;
  color: var(--faction-ink, #fdf6e4);
  border: 1px solid rgba(24, 19, 12, 0.45);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16), 0 1px 4px rgba(12, 9, 5, 0.28);
  max-width: clamp(112px, 24vw, 290px);
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
}
.faction-banner.is-spectator {
  background: repeating-linear-gradient(135deg, #6c655a, #6c655a 6px, #5f594f 6px, #5f594f 12px);
  background-blend-mode: normal;
  color: #fdf6e4;
}
.faction-banner-text { display: flex; flex-direction: column; line-height: 1.18; min-width: 0; }
.faction-banner-text strong {
  font-family: var(--font-head);
  font-size: 14px;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.faction-banner-sub {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  opacity: 0.86;
}
.faction-banner .shield { filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.4)); }
.faction-banner-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }


/* The diplomacy rail: every other power, your standing with it, and the two
   numbers the rules turn on (opinion and war weariness). It replaced the powers
   legend and inherited its geometry, which was hard won:

   With eighteen powers plus "Unclaimed" the list is nineteen rows — taller than
   the whole rail at 720px — so this is the panel that gives way. The head stays
   put, the list scrolls inside its own box, and the chronicle above and the
   minimap below keep their space. It used to be `flex: none`, which pushed the
   minimap off the bottom of the screen the moment the roster grew. */
.drail-head { padding: 5px 8px; flex: none; display: flex; align-items: center; gap: 6px; }
.drail-head h3 { font-size: 13px; }
.drail-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 8px;
  background: var(--danger, #b03a2e);
  color: #fff;
}
.drail-list {
  list-style: none;
  margin: 0;
  padding: 4px 6px 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 0;
  flex: 1 1 auto;
  max-height: clamp(120px, 38vh, 440px);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.drail-row { border-radius: 3px; }
.drail-row.rel-you { background: rgba(47, 111, 181, 0.16); font-weight: 600; }
.drail-row.rel-war { background: rgba(176, 58, 46, 0.13); }
.drail-row.rel-ally { background: rgba(47, 158, 119, 0.13); }
.drail-row.is-out { opacity: 0.45; }
.drail-row.is-out .drail-name { text-decoration: line-through; }
/* The key row is not a faction and is not clickable, so it carries the padding
   the button would have given it. */
.drail-row.is-key { display: flex; align-items: center; gap: 6px; padding: 2px 3px; }
.drail-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  font-size: 11.5px;
  color: inherit;
  text-align: left;
  background: none;
  border: 0;
  padding: 2px 3px;
  border-radius: 3px;
  cursor: pointer;
}
.drail-btn:hover { background: rgba(0, 0, 0, 0.07); }
.drail-btn:focus-visible { outline: 2px solid var(--accent, #2f6fb5); outline-offset: -2px; }
.drail-swatch {
  flex: none;
  width: 20px;
  height: 14px;
  border-radius: 3px;
  background: var(--swatch, #8a8375);
  border: 1px solid rgba(30, 24, 14, 0.45);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.drail-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drail-name-wide { color: var(--ink-faint); }
.drail-crown { color: #b8912f; margin-left: 3px; }
/* Automatic trade is distinct from the negotiated treaty marks beside it. */
.drail-trade { color: #4f7a4a; margin-left: 3px; }
.drail-fear { margin-left: 3px; font-weight: 700; }
.drail-fear.is-uneasy { color: #a0782c; }
.drail-fear.is-afraid,
.drail-fear.is-coalition { color: #a8392c; }
.drail-coalition { margin: 2px 8px 4px; padding: 3px 6px; border-left: 3px solid #a8392c; font-size: 11px; line-height: 1.3; color: #6e2219; background: rgba(168, 57, 44, 0.08); }
.drail-treaty {
  display: inline-block;
  margin-left: 3px;
  padding: 0 3px;
  border: 1px solid rgba(47, 111, 181, 0.4);
  border-radius: 3px;
  color: var(--ink-soft);
  font-size: 9px;
  line-height: 1.25;
  vertical-align: middle;
}
.drail-requests {
  list-style: none;
  margin: 0;
  padding: 2px 6px 5px;
  display: grid;
  gap: 4px;
  flex: none;
  max-height: 24vh;
  overflow-y: auto;
  border-bottom: 1px solid var(--line, rgba(0, 0, 0, 0.15));
}
.drail-request {
  display: grid;
  gap: 3px;
  padding: 4px 5px;
  border-radius: 3px;
  background: rgba(176, 58, 46, 0.09);
  font-size: 10.5px;
  line-height: 1.25;
}
.drail-request small { color: var(--ink-soft); }
.drail-request-detail {
  color: var(--ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.drail-request-actions { display: flex; flex-wrap: wrap; gap: 4px; }
.drail-request-actions button {
  padding: 2px 5px;
  border: 1px solid var(--line, #8a8375);
  border-radius: 3px;
  background: var(--paper, #f6f1e7);
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.drail-request-actions button:hover { border-color: var(--accent, #2f6fb5); }
.drail-request-actions button:focus-visible { outline: 2px solid var(--accent, #2f6fb5); }
.drail-rel { flex: none; display: inline-flex; align-items: center; color: var(--ink-soft); }
/* Opinion is the number a player compares across rows, so it is tabular and a
   fixed width: ragged digits cannot be scanned down a column. */
.drail-op {
  flex: none;
  width: 30px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-size: 10.5px;
  color: var(--ink-soft);
}
.drail-op.is-warm { color: #2f9e77; }
.drail-op.is-cold { color: #b03a2e; }
.drail-status {
  flex: none;
  width: 34px;
  text-align: right;
  font-size: 10px;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
  position: relative;
}
.drail-status.is-urgent { color: var(--danger, #b03a2e); font-weight: 700; }
.drail-status.is-muted { opacity: 0.55; }
.drail-status.is-restive { color: var(--danger, #b03a2e); }
/* War weariness rides under its own row as a hairline, because it is a trend and
   not a reading: what matters is that it is growing and roughly how far along. */
.drail-weary {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -2px;
  height: 2px;
  border-radius: 1px;
  background: linear-gradient(to right, currentColor var(--w, 0%), transparent var(--w, 0%));
  opacity: 0.7;
}
/* A spectator's seat picker. Eighteen crests are wider than the top bar's left
   third, and this used to be `overflow: hidden`, which silently made the last
   several factions unclaimable. It scrolls sideways instead: a seat the player
   cannot reach is a seat they do not have. */
.seat-picker {
  display: flex;
  gap: 3px;
  flex: 0 1 auto;
  min-width: 0;
  max-width: 46vw;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  padding-bottom: 1px;
}
.seat-picker .seat-btn { flex: none; }
.seat-btn {
  padding: 2px 4px;
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  background: rgba(255, 253, 245, 0.5);
  cursor: pointer;
  line-height: 0;
}
.seat-btn:hover { background: rgba(168, 132, 44, 0.22); }


.calendar { display: flex; align-items: baseline; gap: 8px; flex: none; white-space: nowrap; }
.calendar-season { font-size: 16px; }
.calendar-date { font-family: var(--font-head); font-size: 16px; white-space: nowrap; }

.speed { display: flex; flex: none; border: 1px solid var(--rule-strong); border-radius: var(--radius-sm); overflow: hidden; }
.speed-btn {
  font: 500 12px/1 var(--font-body);
  padding: 6px 10px;
  border: 0;
  border-right: 1px solid var(--rule);
  background: rgba(255, 253, 245, 0.55);
  color: var(--ink-soft);
  cursor: pointer;
}
.speed-btn:last-child { border-right: 0; }
.speed-btn:hover:not(:disabled) { background: rgba(255, 253, 245, 0.95); }
.speed-btn.is-active { background: var(--gold-bright); color: #221a08; font-weight: 700; }
.speed-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--rule);
  background: rgba(255, 253, 245, 0.5);
}

/* ---------- resource bar -------------------------------------------------- */

/* Fourteen goods will never fit as fourteen labelled figures. The strip carries
   the ones a player watches — gold and grain, then the building materials — and
   drops whole tiers as the window narrows. Nothing is ever hidden outright: the
   "Treasury" button opens all fourteen with labels and income.

   Each good is a *tile*, three rows deep: a framed disc with the good's own mark
   in it, the stock in bold, and the signed rate under that. The mark is the
   label — there is no name on a tile, because fourteen names at a size that fits
   a 60px column is fourteen lines of small caps and no picture, which is the
   arrangement this replaced. See the head of ui/resources.js. */
.resource-bar {
  position: absolute;
  top: calc(8px + var(--topbar-h) + 6px);
  left: 8px;
  right: 8px;
  height: var(--resource-h);
  display: flex;
  gap: 2px;
  align-items: center;
  /* The right end used to reserve `--fab-w` for a floating exchange toggle. Both
     are gone (September 2026): the exchange is a tab of the Market screen, and
     the button sat `hidden` in index.html with no CSS anywhere while
     `ui/playerTrade.js` un-hid it whenever a game was running — an unstyled
     default button waiting to drop into this strip's flow. The reserve was 140px
     of dead space besides. */
  padding: 0 8px 0 6px;
  background-image: var(--paper);
  background-blend-mode: var(--paper-blend);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  box-shadow: var(--panel-shadow);
  /* Never a scrollbar: what does not fit is dropped by tier, not scrolled to. */
  overflow: hidden;
  z-index: 25;
}
.resource-bar[hidden] { display: none; }
.resource {
  /* Grows to share out the slack, never shrinks, and stops well short of a
     column so wide the discs stop reading as a row. Shrinking is what the tier
     ladder is for: a good that will not fit is dropped where the player can see
     it has gone, not squeezed until its figure is unreadable. */
  flex: 1 0 var(--resource-tile-w);
  min-width: var(--resource-tile-w);
  max-width: calc(var(--resource-tile-w) + 24px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 4px 1px 3px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: none;
  font-family: var(--font-body);
  color: var(--ink);
  cursor: pointer;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
}
.resource:hover { background: rgba(168, 132, 44, 0.14); }
.resource:hover .resource-disc { border-color: var(--gold); }

/* The disc. Parchment, not gunmetal: the reference's dark slate would be a hole
   punched in a paper bar. It is an *object* all the same — a ring of ink, a
   bevel lit from the top-left and shaded at the bottom-right in the same
   direction as every painted asset on the map (docs/ART.md), and a face a shade
   deeper than the bar so the mark inside has something to sit on. */
.resource-disc {
  width: var(--resource-disc);
  height: var(--resource-disc);
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--rule-strong);
  background: radial-gradient(80% 80% at 32% 26%, rgba(255, 252, 240, 0.95), rgba(221, 205, 168, 0.75) 78%);
  box-shadow:
    inset 0 1px 1px rgba(255, 252, 240, 0.9),
    inset 0 -2px 3px rgba(120, 96, 56, 0.28),
    0 1px 1px rgba(43, 35, 24, 0.16);
}
.resource-disc .r-icon { vertical-align: 0; display: block; }

/* A drawn good rather than a glyph: keep it on the text baseline and out of the
   dimming the glyphs get, since it carries its own colour. */
.r-icon { vertical-align: -0.15em; }
.resource-disc:has(.r-icon) { opacity: 1; }

/* ---- chrome icons (ui/uiIcons.js) --------------------------------------- */
/* A flat silhouette painted as a mask over `currentColor`, never as an <img>.
   The colour of every one of these carries state — a top bar button darkens
   when active and reddens at war, a diplomacy cell is coloured by the relation,
   a chronicle row by its category — and an <img> would paint the same brown
   pixels in all of them and throw that state away. The mask keeps the artwork's
   alpha and lets the existing colour rules go on working untouched. */
/* The leadership mark beside a cost (ui/directArmyCards.js leadershipMark). */
.leadership-mark { display: inline-flex; vertical-align: -2px; margin-right: 3px; }
.leadership-mark .ui-icon { background-color: #8f6b17; }
/* Gold (player, 8 November 2026): the darker gold on parchment, the bright one on the dark decks. */
.direct-company-offer .leadership-mark .ui-icon { background-color: var(--gold-bright); }
.ui-icon {
  display: inline-block;
  vertical-align: -0.15em;
  flex: none;
  background-color: currentColor;
  -webkit-mask-image: var(--ui-icon);
  mask-image: var(--ui-icon);
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
}
/* The fallback path: the emoji the icon replaces, when the file is not on disk.
   Named so it can be styled apart from a drawn icon, and so a glyph in the
   markup is findable. */
.ui-glyph { display: inline-block; line-height: 1; }
.resource-amount {
  font: 700 15px/1.1 var(--font-body);
  font-variant-numeric: tabular-nums;
  margin-top: 3px;
}
.resource-delta {
  font: 500 9.5px/1.1 var(--font-body);
  font-variant-numeric: tabular-nums;
  color: var(--ink-faint);
  letter-spacing: 0.01em;
}
.resource-delta.is-up { color: var(--good); }
.resource-delta.is-down { color: var(--bad); }
/* Standing still is a dash, not a nought: a zero in the slot a live figure uses
   reads as a measurement rather than as nothing happening. */
.resource-delta.is-flat { opacity: 0.5; }
/* Keep the unit attached to each live rate; the zero state is a plain dash. */
.resource-per { font-size: 8px; opacity: 0.72; margin-left: 0.5px; }

/* The name is not drawn on the tile — the mark is the label. The node stays in
   the markup because it is the tooltip's and the screen reader's copy of the
   good's name, and because the Treasury list is one `resourceLabel` call away. */
.resource-label {
  display: none;
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

/* Empty. Colour alone would leave a good at zero and falling saying it twice in
   red and not once in shape, so the disc loses its face and the figure gets an
   ink rule under it. */
.resource.is-zero .resource-amount {
  color: var(--ink-faint);
  border-bottom: 1.5px solid var(--rule-strong);
}
.resource.is-zero .resource-disc {
  background: rgba(221, 205, 168, 0.32);
  box-shadow: inset 0 1px 2px rgba(120, 96, 56, 0.3);
}
.resource.is-zero .r-icon { opacity: 0.45; }
/* Low: a few units left of a good that is not yet gone. Colour is the whole
   signal a player asked for here, so it is the figure that takes it and the
   disc's ring that confirms it — the tile keeps its face, which is what
   separates "nearly out" from `is-zero`'s "out". `LOW_STOCK`, ui/resources.js. */
.resource.is-low .resource-amount { color: var(--bad); }
.resource.is-low .resource-disc { border-color: rgba(163, 51, 38, 0.45); }
/* Empty *and* being spent: the one the player must not miss. */
.resource.is-needed {
  border-color: rgba(163, 51, 38, 0.55);
  background: rgba(163, 51, 38, 0.12);
}
.resource.is-needed .resource-amount { color: var(--bad); border-bottom-color: rgba(163, 51, 38, 0.6); }
.resource.is-needed .resource-disc { border-color: rgba(163, 51, 38, 0.5); }
.resource.is-needed .r-icon { opacity: 0.8; }

.resource-note { align-self: center; color: var(--ink-faint); font-size: 12px; padding-left: 4px; }
.resource-sep { flex: none; width: 1px; align-self: stretch; margin: 7px 3px; background: var(--rule); }
/* Taxation popover; navigation.css anchors it beside the left rail. */
.stores-pop {
  position: absolute;
  top: calc(var(--chrome-top) + 2px);
  /* Clears the docked rail, so the full stockpile never covers the chronicle. */
  right: calc(var(--col-w) + 16px);
  width: min(340px, calc(100vw - 24px));
  max-height: min(60vh, 520px);
  overflow-y: auto;
  z-index: 45;
  padding: 8px 10px 10px;
}
.stores-pop[hidden] { display: none; }
.stores-head { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 2px; }
.stores-title { flex: 1; min-width: 0; }
.stores-head h3 { margin-bottom: 0; font-size: 15px; }
.stores-title span {
  display: block;
  margin-top: 1px;
  color: var(--ink-faint);
  font: 600 9px/1.2 var(--font-body);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.treasury-vignette {
  position: relative;
  flex: none;
  height: 76px;
  margin: 0 -2px 2px;
  overflow: hidden;
  border-bottom: 1px solid rgba(92, 70, 37, 0.18);
}
.treasury-vignette::after {
  content: '';
  position: absolute;
  inset: auto 3% -1px;
  height: 22px;
  pointer-events: none;
  background: radial-gradient(ellipse at center, rgba(78, 56, 27, 0.16), transparent 72%);
  filter: blur(5px);
}
.treasury-vignette img {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: saturate(0.78) sepia(0.08) contrast(0.96);
}

/* ---------- right rail ---------------------------------------------------- */

.column {
  position: absolute;
  top: var(--chrome-top);
  bottom: 8px;
  width: var(--rail-w);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 35;
  pointer-events: none;
}
.column > * { pointer-events: auto; }
.column-right { right: 8px; }

#logPanel { flex: 1 1 auto; min-height: 140px; }

/* ---------- command bar --------------------------------------------------- *
   One horizontal structure for all four selections — a city, a castle, one of
   your armies, and something you do not own. Left: who it is. Middle: its
   figures, laid out across rather than down. Right: its actions, grouped under
   tabs so a fifteen-building catalogue never becomes a scrolling column.
   -------------------------------------------------------------------------- */

.command-bar {
  position: absolute;
  bottom: 8px;
  left: 8px;
  /* The layer reaches the right rail rather than stopping at its content: the
     control panel is centred in what is left over after the information card,
     and centring needs both edges. */
  right: calc(var(--col-w) + 16px);
  max-height: calc(var(--cmd-h) + 34px);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
  z-index: 28;
  /*
   * The bar is not a surface any more, it is a layer with two cards in it: a
   * dark information card at the left and a light control panel beside it.
   * Nothing here is painted, and the layer lets the pointer through to the map
   * everywhere a card is not.
   */
  pointer-events: none;
}
.command-bar > * { pointer-events: auto; }
.command-bar[hidden] { display: none; }

.cmd-switch {
  /* The same width as the information card under it, so the left-hand side of
     the bar is one column and not two boxes of different sizes — and pinned to
     that card's top edge rather than sitting in the flow above the whole row,
     which left a short card floating well below it. */
  position: absolute;
  left: 0;
  bottom: calc(var(--cmd-info-h, 200px) + 5px);
  width: 492px;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  flex: none;
  padding: 3px 4px 3px 6px;
  border-radius: 999px;
  background: rgba(22, 19, 13, 0.82);
  backdrop-filter: blur(8px);
  box-shadow: 0 6px 18px rgba(10, 16, 22, 0.35);
}
.cmd-switch-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: 600 12px/1 var(--font-head);
  letter-spacing: 0.05em;
  padding: 5px 11px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: none;
  color: rgba(239, 230, 207, 0.6);
  cursor: pointer;
  max-width: 42vw;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.cmd-switch-btn:hover { background: rgba(239, 230, 207, 0.1); color: #efe6cf; }
.cmd-switch-btn.is-active {
  background: rgba(215, 167, 63, 0.22);
  border-color: rgba(215, 167, 63, 0.7);
  color: #efe6cf;
}
.cmd-switch .cmd-switch-hint { color: rgba(239, 230, 207, 0.7); }
.cmd-switch .cmd-switch-hint:hover { background: rgba(239, 230, 207, 0.12); color: #efe6cf; }
.cmd-switch-hint { margin-left: auto; }

/* Use the selector's existing footprint, sharing spare space between tabs. */
#commandTabs .cmd-switch-btn {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  max-width: none;
  padding-left: 32px;
  padding-right: 7px;
  gap: 4px;
}
#commandTabs .cmd-switch-hint { margin-left: 0; flex-shrink: 0; }
.cmd-switch-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmd-switch-visual { position: absolute; left: 6px; top: 50%; transform: translateY(-50%); width: 22px; height: 22px; display: grid; place-items: center; font-size: 19px; }
.cmd-switch-visual img { width: 100%; height: 100%; object-fit: contain; }
#commandTabs .cmd-switch-btn > .muted { flex-shrink: 0; }

.cmd-panes { flex: 0 1 auto; min-height: 0; width: 100%; display: flex; }
/*
 * Two columns: the information card takes the width it needs at the left, and
 * the control panel is centred in the rest — the space between that card and
 * the right rail — rather than shoved against it. Bottoms align.
 */
.cmd-pane {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: end;
  /* No gap: the centring is what sets the space on either side of the panel,
     and a gap here would make the left one wider than the right by its width. */
  gap: 0;
  padding: 0;
}
.cmd-pane > .cmd-act { justify-self: center; }
/* Both cards stand on the floor of the bar. The information card is only as
   tall as its content, so it grows upward from that edge and the switch pill
   above it is pinned to its top (see `--cmd-info-h`). */
.cmd-pane > .cmd-info { align-self: end; }
.cmd-pane[hidden] { display: none; }
/* --- the information card ------------------------------------------------ *
   Dark glass, light ink: who it is and its figures. It is the quiet half.
   -------------------------------------------------------------------------- */
.cmd-info {
  --ink: #efe6cf;
  /*
   * Width is fixed — the control panel is centred in what is left over, and a
   * card that breathed would slide the panel about. Height is *not*: the card
   * grows to its own content and stops at the bar's ceiling. Both cards hang
   * from the same bottom edge, so a short one crops its empty half upward and
   * the panel beside it does not move a pixel.
   */
  width: 492px;
  max-height: var(--cmd-h);
  --ink-soft: rgba(239, 230, 207, 0.82);
  --ink-faint: rgba(239, 230, 207, 0.55);
  --rule: rgba(239, 230, 207, 0.14);
  --rule-strong: rgba(239, 230, 207, 0.28);
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0;
  height: auto;
  padding: 9px 11px 10px;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(30, 26, 18, 0.97), rgba(16, 14, 9, 0.98));
  backdrop-filter: blur(10px);
  border: 1px solid rgba(239, 230, 207, 0.12);
  box-shadow: 0 12px 30px rgba(10, 16, 22, 0.45), inset 0 1px 0 rgba(255, 253, 245, 0.08);
  color: var(--ink);
}
/* The identity and the ledger side by side; the seam gets the width under both,
   which is where the empty half of the card was. */
.cmd-info-top { display: flex; align-items: stretch; gap: 10px; min-height: 0; flex: 0 1 auto; }
/* Narrower here than the pane default: the name ellipses, and the 22 px it
   gives back is what lets the card lose its empty right-hand margin. */
.cmd-info .cmd-id { width: 150px; padding-right: 9px; }
.cmd-info .cmd-stats { border-right: 0; padding-right: 0; }
.cmd-info .owner-chip { color: #fff; background: color-mix(in srgb, var(--faction) 40%, transparent); }
.cmd-info .cmd-pill { background: rgba(239, 230, 207, 0.08); color: var(--ink-soft); }
.cmd-info .cmd-pill-go { background: rgba(215, 167, 63, 0.22); border-color: rgba(215, 167, 63, 0.5); color: #ffe6a8; }
.cmd-info .cmd-pill-bad { background: rgba(255, 122, 77, 0.18); border-color: rgba(255, 122, 77, 0.45); color: #ffb39a; }
.cmd-info .cmd-pill-warn { background: rgba(215, 167, 63, 0.16); border-color: rgba(215, 167, 63, 0.4); color: #f0cf7a; }
.cmd-info .cmd-unit { background: rgba(239, 230, 207, 0.08); border-color: var(--rule); }
.cmd-info .cmd-unit-total { background: rgba(239, 230, 207, 0.14); }
.cmd-info .cmd-gauge-track,
.cmd-info .comp-bar { background: rgba(0, 0, 0, 0.45); }
.cmd-info .cmd-gauge.meter-warn small { color: #f0cf7a; }
.cmd-info .cmd-gauge.meter-bad small,
.cmd-info .stat-alarm .stat-v { color: #ff9a7a; }
.cmd-info .stat-alarm { background: rgba(255, 122, 77, 0.12); border-left-color: #ff7a4d; }
.cmd-info .text-bad { color: #ff9a7a; }
/* Less prose: the ground sentence is two lines and faint; the rest is in its tooltip. */
.cmd-info .cmd-id-sub { -webkit-line-clamp: 2; font-size: 10.5px; color: var(--ink-faint); }
/* The Overview facts, condensed, under the ledger: the ground, the country,
   what this place sells and what it made last tick. They qualify the figures
   above them, so they live with the figures and not in the control panel. */
.cmd-seam {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 3px 4px;
  margin-top: 7px;
  padding-top: 7px;
  border-top: 1px solid var(--rule);
}
/* Each group flows into the row rather than claiming one of its own: four
   near-empty lines wasted the height that pushed the last of them off the card. */
.cmd-seam > .facts,
.cmd-seam > .chips { flex: 0 1 auto; }
.cmd-info .fact { background: rgba(239, 230, 207, 0.08); border-color: var(--rule); color: var(--ink-soft); }
.cmd-info .fact b { color: var(--ink); }
.cmd-info .fact-good { background: rgba(168, 224, 122, 0.14); border-color: rgba(168, 224, 122, 0.32); }
.cmd-info .fact-good b { color: #b6e88f; }
.cmd-info .fact-warn { background: rgba(215, 167, 63, 0.16); border-color: rgba(215, 167, 63, 0.36); }
.cmd-info .fact-warn b { color: #f0cf7a; }
.cmd-info .fact-bad { background: rgba(255, 122, 77, 0.15); border-color: rgba(255, 122, 77, 0.38); }
.cmd-info .fact-bad b { color: #ff9a7a; }
.cmd-info .fact-river { background: rgba(159, 214, 224, 0.14); border-color: rgba(159, 214, 224, 0.34); }
.cmd-info .fact-river b { color: #9fd6e0; }
.cmd-info .fact-river::before { color: #9fd6e0; }
.cmd-info .fact-climb { background: rgba(215, 167, 63, 0.14); border-color: rgba(215, 167, 63, 0.34); }
.cmd-info .fact-climb b { color: #e0c07a; }
.cmd-info .fact-climb::before { color: #e0c07a; }
.cmd-info .chip { background: rgba(239, 230, 207, 0.08); border-color: var(--rule); color: var(--ink-soft); }
.cmd-info .chip-good { background: rgba(168, 224, 122, 0.14); border-color: rgba(168, 224, 122, 0.3); color: #cbe9b0; }
/* Icon and figure only: the name is the tooltip, because six goods will not fit
   a 468 px card with their words on. */
.chips-tight { gap: 3px; }
.chips-tight .chip {
  gap: 3px;
  padding: 1px 6px;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  cursor: help;
}

/* --- the control panel --------------------------------------------------- *
   Light, cool, frosted: the tabs and the tray. It is the half you press.
   -------------------------------------------------------------------------- */
.cmd-act {
  /*
   * A fixed shape. The panel is the thing the player aims at, and a control
   * that changes size and position every time a tab is pressed is a control
   * you have to find again each time. Width and height are constant across
   * every tab and every selection; the tray inside scrolls when a tab has
   * more than fits, which is the honest trade for a still target.
   */
  flex: 0 0 auto;
  width: min(660px, calc(100vw - var(--col-w) - 644px));
  min-width: 400px;
  /*
   * The height is the tallest tray *this selection* can show, published as
   * `--cmd-panel-h` by `ui/commandbar.js`, and never more than the bar's
   * ceiling. Fixed at the ceiling it left a small army's Orders tray sitting
   * above 89 px of nothing; sized to the current tab it would jump under the
   * pointer every time a tab was pressed, which is the thing the fixed height
   * was for. Per selection is the setting that has neither fault.
   */
  height: var(--cmd-panel-h, var(--cmd-h));
  max-height: var(--cmd-h);
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 10px 10px;
  border-radius: 12px;
  /*
   * Warm ivory, not the cold near-white it was. The panel has to read as a
   * different material from the dark information card beside it without
   * leaving the game's palette: the top is lit, the foot settles into the
   * parchment family, and a hairline of gold along the top edge ties it to
   * the buttons it holds.
   */
  /*
   * Aged paper, not office white: the same grain and fibre layers the rest of
   * the interface is painted on (`--paper`), over a warmer and slightly deeper
   * tone than a plain panel, with a gold rule inside the edge. A control
   * surface has to read as a different material from the dark card beside it
   * without leaving the period the map is drawn in.
   */
  background-image:
    radial-gradient(120% 90% at 14% 2%, rgba(255, 251, 236, 0.75), rgba(255, 251, 236, 0) 58%),
    radial-gradient(95% 85% at 90% 98%, rgba(122, 92, 44, 0.2), rgba(122, 92, 44, 0) 60%),
    repeating-linear-gradient(92deg, rgba(140, 112, 62, 0.06) 0 2px, rgba(140, 112, 62, 0) 2px 5px),
    repeating-linear-gradient(4deg, rgba(112, 88, 48, 0.05) 0 3px, rgba(112, 88, 48, 0) 3px 7px),
    var(--paper-texture),
    linear-gradient(168deg, rgba(240, 229, 203, 0.99), rgba(230, 216, 185, 0.99) 60%, rgba(219, 202, 167, 0.99));
  background-blend-mode: var(--paper-blend);
  backdrop-filter: blur(10px) saturate(1.05);
  border: 1px solid rgba(63, 48, 25, 0.42);
  box-shadow:
    0 14px 32px rgba(10, 16, 22, 0.34),
    inset 0 1px 0 rgba(255, 252, 240, 0.6),
    inset 0 0 0 1px rgba(150, 116, 44, 0.28),
    inset 0 -14px 26px -14px rgba(94, 70, 32, 0.3);
}
/* The tab row sits in a shallow well, so the tabs read as part of the panel
   rather than as chips floating on it. */
/* **The panel is the plot picker's containing block, and that is load-bearing.**
   `.plot-tree` opens *upward*, out over the map, from a `.slot-top` that lives
   inside `.cmd-tray` — and `.cmd-tray` is `overflow-y: auto`. A box positioned
   against an ancestor *inside* a scroller is clipped by that scroller, so the
   picker laid out correctly at its full size and was painted nowhere: measured
   at 1280x720, the tree's own centre hit-tested to `CANVAS`, on every one of
   its three variants (walls, roads, an empty plot). Positioning it against the
   panel instead puts its containing block *above* the clip, which is why the
   panel is `relative` and `.slot-top` is `static`. */
.cmd-act { overflow: visible; position: relative; }
.cmd-act > .cmd-seg {
  background: rgba(43, 35, 24, 0.08);
  border-color: rgba(43, 35, 24, 0.14);
  box-shadow: inset 0 1px 2px rgba(43, 35, 24, 0.1);
}
/* The sticky rack band needs an opaque ground of its own, and it has to be the
   panel's own tone at that height rather than a flat parchment. */
.cmd-act .slot-top { background: linear-gradient(180deg, rgba(238, 227, 201, 0.99), rgba(233, 220, 190, 0.99)); }
/* Explanations step back; buttons and figures step forward. */
.cmd-tray-note { font-size: 10.5px; line-height: 1.35; color: var(--ink-faint); }
/* The rebel-town note (`ui/province.js rebelBlock`). Only the modifier is
   styled, not `.tray-note` itself: that base class is already in the markup of
   the village block and has never had a rule, so giving it one would change a
   panel nobody asked to change. Amber rather than red — a town in revolt
   against you is bad news carrying good news, and the point of the block is the
   good half. */
.tray-note.is-warn {
  border-left: 2px solid rgba(215, 167, 63, 0.55);
  background: rgba(215, 167, 63, 0.09);
  border-radius: var(--radius-sm);
  padding: 7px 9px;
  font-size: 11.5px;
  line-height: 1.4;
}

/* --- identity ------------------------------------------------------------- */

.cmd-id {
  flex: 0 0 auto;
  width: 172px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-right: 10px;
  border-right: 1px solid var(--rule);
}
.cmd-kind {
  font-size: 9.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.cmd-id h3 {
  font-size: 16px;
  line-height: 1.15;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cmd-id .owner-chip { align-self: flex-start; max-width: 100%; overflow: hidden; text-overflow: ellipsis; font-size: 10px; padding: 2px 7px; }
/* Where it is and what state it is in, as pills: one glance, no prose. The
   sentence behind each pill is its tooltip. */
.cmd-pills { display: flex; flex-wrap: wrap; gap: 3px; }
.cmd-pill {
  display: inline-block;
  max-width: 100%;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--rule);
  background: rgba(255, 253, 245, 0.45);
  font-size: 10.5px;
  line-height: 1.3;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cmd-pill-go { border-color: rgba(168, 132, 44, 0.5); background: rgba(168, 132, 44, 0.16); color: var(--ink); }
.cmd-pill-bad { border-color: rgba(163, 51, 38, 0.4); background: rgba(163, 51, 38, 0.12); color: #7b2519; font-weight: 600; }
.cmd-pill-warn { border-color: rgba(184, 121, 31, 0.4); background: rgba(184, 121, 31, 0.14); color: #7a4f0d; }
.cmd-id-sub {
  margin: 0;
  font-size: 11px;
  line-height: 1.3;
  color: var(--ink-soft);
  overflow: hidden;
  display: -webkit-box;
  /*
   * Five, not three: the terrain sentence now says something about the going,
   * the cover, the cavalry, the bowmen, the siege train and the output, and at
   * three lines a mountain province was cut off mid-clause. The identity column
   * has the height — the name, the owner chip and this add up to about half the
   * bar even at five lines.
   */
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
}
.cmd-id-sub em { color: var(--ink-faint); }

/* --- figures -------------------------------------------------------------- */

.cmd-stats {
  flex: 0 1 auto;
  min-width: 0;
  /* A column: the ledger, then the alarms, then the condensed facts under it.
     Laid as a wrapping row these sat *beside* the figures and were clipped by
     the card's fixed width. */
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  padding-right: 10px;
  border-right: 1px solid var(--rule);
  overflow: hidden;
}
/* The figures never shrink: the actions column beside them is the one that
   flexes, and a squeezed unit count is a wrong unit count. */
#armyPanel .cmd-stats { flex: 0 0 auto; max-width: 300px; }
.cmd-figures { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.stat { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.stat-k {
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
  white-space: nowrap;
}
.stat-v { font: 600 16px/1.15 var(--font-body); font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat-v small { font-size: 11px; font-weight: 400; color: var(--ink-faint); }
.stat-alarm { padding: 2px 7px; border-radius: var(--radius-sm); background: rgba(163, 51, 38, 0.12); }
.stat-alarm .stat-v { color: var(--bad); }
/* The army pane's figures are a ledger, not a row of headline numbers. */
#armyPanel .stat-k,
#provincePanel .stat-k { font-size: 9.5px; letter-spacing: 0.09em; }
#armyPanel .stat-v,
#provincePanel .stat-v { font-size: 12.5px; line-height: 1.2; }
#provincePanel .cmd-stats { flex: 0 0 auto; }
.cmd-kv-province { align-content: start; }
#armyPanel .stat-alarm { flex: 1 1 100%; padding: 3px 8px; background: rgba(163, 51, 38, 0.1); border-left: 2px solid var(--bad); }
#armyPanel .stat-alarm .stat-v { font-weight: 500; white-space: normal; font-size: 11px; }

/* Unit counts read across, not down: an icon and a figure per arm, the name
   in the tooltip, and the total at the end of the row. */
.cmd-units { display: flex; gap: 3px; flex-wrap: nowrap; }
.cmd-unit {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 7px 3px 5px;
  border-radius: var(--radius-sm);
  background: rgba(255, 253, 245, 0.5);
  border: 1px solid var(--rule);
}
.cmd-unit.is-empty { opacity: 0.4; }
.cmd-unit .unit-icon { display: block; line-height: 1; }
.cmd-unit .unit-count { display: block; font: 600 13px/1 var(--font-body); font-variant-numeric: tabular-nums; }
.cmd-unit .unit-label { display: none; }
.cmd-unit-total { background: rgba(43, 35, 24, 0.08); border-color: transparent; gap: 3px; }
.cmd-unit-total .unit-label { display: block; font-size: 10px; color: var(--ink-faint); }

/* Facts as a two-column ledger: label, value; the two gauges are values too. */
.cmd-kv {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 2px 10px;
  align-items: center;
  margin-top: 2px;
}
.cmd-kv .stat-k { line-height: 1.5; }
.cmd-kv .stat-v { overflow: hidden; text-overflow: ellipsis; }
.cmd-gauge { display: inline-flex; align-items: center; gap: 6px; }
.cmd-gauge-track {
  display: block;
  flex: 0 0 auto;
  width: 72px;
  height: 5px;
  border-radius: 3px;
  background: rgba(43, 35, 24, 0.14);
  overflow: hidden;
}
.cmd-gauge-track .meter-fill { display: block; height: 100%; }
.cmd-gauge small { color: var(--ink-faint); font-weight: 400; }
.cmd-gauge.meter-bad small { color: var(--bad); font-weight: 600; }
.cmd-gauge.meter-warn small { color: #7a4f0d; }

/* Unit icons: an inline SVG placeholder, or the real image once one is dropped
   into public/assets (docs/ART.md). Both sit on the text baseline the same way. */
.unit-icon { display: inline-flex; align-items: center; justify-content: center; }
.unit-svg,
.unit-art { display: block; vertical-align: middle; }
.unit-art { object-fit: contain; }

/* Composition: what the army is made of, as one bar. The same cue the map token
   carries, so the pane and the token teach each other. */
.comp-bar {
  display: flex;
  gap: 1px;
  width: 100%;
  min-width: 76px;
  height: 3px;
  margin: 0;
  border-radius: 2px;
  overflow: hidden;
  background: rgba(43, 35, 24, 0.28);
}
.comp-seg { display: block; height: 100%; min-width: 2px; }

/* --- actions -------------------------------------------------------------- */

.cmd-tabbar { display: flex; flex-wrap: wrap; gap: 4px; flex: none; }
/* One control, four faces: the tab in use is the filled segment. */
.cmd-seg {
  display: inline-flex;
  align-self: flex-start;
  gap: 0;
  padding: 2px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: rgba(43, 35, 24, 0.06);
}
.cmd-seg-btn {
  padding: 4px 11px;
  border: 0;
  border-radius: 999px;
  background: none;
  font: 500 11.5px/1 var(--font-body);
  letter-spacing: 0.02em;
  color: var(--ink-soft);
  cursor: pointer;
  white-space: nowrap;
}
.cmd-seg-btn:hover { color: var(--ink); background: rgba(255, 253, 245, 0.6); }
.cmd-seg-btn.is-active { background: var(--gold-bright); color: #221a08; font-weight: 600; box-shadow: 0 1px 2px rgba(43, 35, 24, 0.2); }
.cmd-seg-btn:focus-visible { outline: 2px solid var(--gold-bright); outline-offset: 1px; }
/*
 * The tray does not scroll. A fixed panel with a scrollbar in it is a panel
 * that hides half its own content; where a tray has more to offer than fits —
 * the buildings for an empty plot — it opens a tree that floats above the
 * panel instead of growing inside it.
 */
.cmd-tray {
  /* Sized by its content, not stretched to the panel: its natural height is
     what `commandbar.js` measures to decide the panel's. */
  flex: 0 1 auto;
  min-height: 0;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 6px;
  /*
   * **It scrolls.** This was `overflow: visible` while the comment on `.cmd-act`
   * promised "the tray inside scrolls when a tab has more than fits", and the
   * measurement in TODO §16 is what that cost: the Recruit tray wants 489 px in
   * a 161 px window and the Orders tray 221 px, so everything below the fold was
   * drawn **over the map with no background behind it**. The calling picker is
   * folded shut by default only because opening it adds 202 px to a tray that
   * was already spilling.
   *
   * Safe against the measurement it feeds: `commandbar.js` sizes the panel from
   * `tray.scrollHeight`, which is the content's full height whatever the
   * overflow is set to — so the panel still grows to fit a tray that can fit,
   * and only a tray past the bar's `--cmd-h` ceiling scrolls.
   */
  overflow-y: auto;
  overflow-x: hidden;
  /* A gutter that does not appear and disappear as tabs change, which would
     reflow the tray under the pointer. */
  scrollbar-gutter: stable;
}
/* A tray that is one sentence — "Spectators cannot conduct diplomacy" — would
   otherwise sit in the top-left corner of a fixed-height card under an acre of
   nothing. Centred, the card reads as a deliberate answer rather than a panel
   that failed to load. */
.cmd-tray:has(> .cmd-tray-note:only-child) {
  place-content: center;
  text-align: center;
}
.cmd-tray:has(> .cmd-tray-note:only-child) .cmd-tray-note { flex-basis: auto; max-width: 34ch; font-size: 12px; }
.cmd-tray-block { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cmd-tray-block > .label { font-size: 9.5px; letter-spacing: 0.1em; }
.cmd-tray .hint { margin: 0; }
.cmd-tray-note { flex-basis: 100%; margin: 0; font-size: 11px; color: var(--ink-faint); }

/* ---------- the march queue ----------------------------------------------
 * The ordered stops of a march, numbered to match the badges on the map, with
 * the three things that can be done to a stop on the right of its row: move it
 * earlier, move it later, drop it and everything after it.
 *
 * The rows are buttons rather than a drag list on purpose (see ui/army.js):
 * this tray is rebuilt from innerHTML every tick while an army is marching, so
 * a dragged row is pulled out from under the pointer, and arrows are the only
 * version that answers the keyboard as well as the mouse.
 */
.march-queue {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 236px;
  /* Eight stops is the server's cap, and eight rows do not fit the command bar
     on a 720px screen. The list keeps its own height instead of being squeezed
     by the tray (`flex: 0 0 auto`) and scrolls past five, which is the most the
     shortest supported panel has room for. */
  flex: 0 0 auto;
  max-height: 104px;
  overflow-y: auto;
}
.march-stop {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 5px;
  padding: 0 3px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: rgba(255, 253, 245, 0.4);
  font-size: 11.5px;
}
.march-stop.is-next { border-color: rgba(168, 132, 44, 0.55); background: rgba(255, 233, 168, 0.28); }
.march-stop-no {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font: 700 9.5px/1 var(--font-body);
  color: #241c11;
  background: #ffe9a8;
  border: 1px solid rgba(36, 28, 17, 0.75);
}
.march-stop.is-last .march-stop-no { border-width: 2px; }
.march-stop-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.march-stop-eta { font-size: 10.5px; color: var(--ink-faint); white-space: nowrap; }
/* How much of the ETA beside it is climbing (climbs.js). Deliberately quiet —
   it is an explanation of the number in front of it, not a second number. */
.march-stop-climb { color: #e0c07a; opacity: 0.85; }
.march-stop-acts { display: flex; gap: 2px; }
.march-stop-acts .icon-btn {
  width: 17px;
  height: 17px;
  padding: 0;
  display: grid;
  place-items: center;
  font-size: 10px;
  line-height: 1;
  border: 1px solid var(--rule);
  border-radius: 3px;
  background: rgba(255, 253, 245, 0.6);
  color: var(--ink-soft);
  cursor: pointer;
}
.march-stop-acts .icon-btn:hover:not([disabled]) { border-color: var(--gold); color: var(--ink); }
.march-stop-acts .icon-btn[disabled] { opacity: 0.35; cursor: default; }
.march-stop-acts .icon-btn-bad:hover:not([disabled]) { border-color: var(--bad); color: var(--bad); }
.cmd-hint { margin: 3px 0 0; font-size: 10.5px; color: var(--ink-faint); max-width: 40ch; }
.cmd-hint kbd { padding: 1px 4px; font-size: 10px; }

/* A tile: the command bar's unit of action. Buildings, roads and unit types all
   use it, so the four selection cases share one visual grammar. */
.tile {
  flex: 0 0 auto;
  width: 152px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 6px 5px;
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  background: rgba(255, 253, 245, 0.45);
}
.tile.is-blocked { opacity: 0.66; }
.tile-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.tile-name {
  font-family: var(--font-head);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tile-name.link-btn { padding: 0; font-family: var(--font-head); font-weight: 700; font-size: 12px; }
.tile-cost {
  flex: 1;
  min-width: 0;
  font-size: 10px;
  line-height: 1.2;
  color: var(--ink-soft);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.tile-foot { display: flex; align-items: center; justify-content: space-between; gap: 5px; }

.tag-river { background: rgba(44, 96, 114, 0.16); color: #1d5e72; }
.tag-climb { background: rgba(122, 79, 13, 0.16); color: #7a4f0d; }

.tile .btn-small { flex: none; padding: 2px 7px; font-size: 11px; }

.pips { display: inline-flex; gap: 3px; flex: none; }
.pip { width: 6px; height: 6px; border-radius: 2px; background: rgba(43, 35, 24, 0.16); }
.pip.is-on { background: var(--gold); }

/* The unit picker: four tiles in place of the native <select> the recruit form
   used to carry. An <option> cannot hold an image, which is why the unit art
   specified in docs/ART.md never reached the one screen where the player picks
   an arm. Four fixed choices, all worth seeing at once, so they are laid out
   rather than hidden behind a control that has to be opened. */
.recruit-pick {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  width: 100%;
  margin-bottom: 6px;
}
.recruit-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 5px 3px 4px;
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.16);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  /* The selected tile gains a 2px gold rule; reserving it on every tile keeps
     the row from shifting by a pixel each time the choice changes. */
  box-shadow: inset 0 0 0 2px transparent;
  transition: background 0.12s ease, box-shadow 0.12s ease;
}
.recruit-tile:hover { background: rgba(255, 255, 255, 0.3); }
.recruit-tile:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
.recruit-tile.is-on {
  background: rgba(168, 132, 44, 0.16);
  box-shadow: inset 0 0 0 2px var(--gold);
}
/* A unit still behind research: shown, greyed, and a door to the Academy. */
.recruit-tile.is-locked { opacity: 0.55; filter: saturate(0.3); border-style: dashed; }
.recruit-tile.is-locked .tile-lock { font-size: 9px; white-space: normal; text-align: center; }
/* The drawing is the point of the tile, so it gets the room; the arm's own ink
   tints the SVG fallback and leaves a real PNG untouched. */
.recruit-tile .tile-art { display: block; line-height: 0; }
.recruit-tile .tile-art img,
.recruit-tile .tile-art svg { display: block; }
.recruit-tile .tile-name {
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1.1;
  text-align: center;
  /* Long arm names must not widen a column and break the four-up grid. */
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.recruit-tile .tile-stat {
  font-size: 9.5px;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.recruit-tile .tile-slash { opacity: 0.5; }
.recruit-tile .tile-gold { opacity: 0.85; }
/* Below the panel's narrow breakpoint four columns leave no room for a name, so
   the tiles fall to two rows rather than shrinking past legibility. */
@media (max-width: 1100px) {
  .recruit-pick { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.recruit { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
/* "Max 34" is a number as much as a button: it says what the province can raise
   today before it is pressed. */
.btn-max { flex: none; font-variant-numeric: tabular-nums; }
.recruit .input { flex: 0 1 160px; }
.recruit .input-count { flex: none; }

/* ---------- army bits ----------------------------------------------------- */

.split-form { display: flex; flex-wrap: wrap; gap: 6px; align-items: end; }
.split-field { display: flex; flex-direction: column; gap: 2px; font-size: 11px; color: var(--ink-faint); }
.split-field .input-count { width: 62px; }
/* The split checklist (`ui/army.js splitTray`): one row per precondition, a
   tick when it is met and the button that meets it when it is not. */
.split-steps { list-style: none; margin: 0 0 6px; padding: 0; display: flex; flex-direction: column; gap: 4px; counter-reset: split-step; }
.split-step { display: flex; align-items: center; gap: 6px; font-size: 12px; counter-increment: split-step; }
.split-step-text { flex: 1 1 auto; min-width: 0; }
.split-step .btn { flex: 0 0 auto; }
.split-tick {
  flex: 0 0 18px; height: 18px; border-radius: 50%; display: grid; place-items: center;
  font-size: 11px; font-weight: 700; border: 1.5px solid var(--ink-faint); color: var(--ink-faint);
}
.split-tick:empty::before { content: counter(split-step); }
.split-step.is-done .split-tick { background: var(--good); border-color: var(--good); color: #fff; }
.split-go { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 6px 0 2px; font-size: 12px; }

/* The roster reads across the tray like everything else in the bar: a name over
   its place, the figure and the composition beside it, tags after. */
.army-list {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1 1 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(196px, 1fr));
  gap: 4px;
}
.army-row {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  background: rgba(255, 253, 245, 0.45);
  cursor: pointer;
  font: 500 12px/1.2 var(--font-body);
  color: var(--ink);
  text-align: left;
  min-width: 0;
}
.army-row:hover { background: rgba(168, 132, 44, 0.14); }
.army-row.is-active { border-color: var(--gold); background: rgba(168, 132, 44, 0.2); box-shadow: inset 2px 0 0 var(--gold); }
.army-row-id { flex: 1 1 calc(100% - 48px); min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.army-row-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.army-row-where { color: var(--ink-faint); font-size: 10.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.army-row-fig { flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.army-row-count { font-weight: 700; font-variant-numeric: tabular-nums; }
.army-row .comp-bar { width: 40px; min-width: 40px; }
.army-row .tag { flex: 0 1 auto; max-width: 100%; white-space: normal; overflow-wrap: anywhere; font-size: 9px; padding: 1px 5px; }

/* Composition and shape on the command bar's own tab, for picking one host of two. */

/* ---------- log ----------------------------------------------------------- */

.log-filters { display: flex; flex-wrap: wrap; gap: 3px; }
.log-feed {
  flex: 1;
  overflow-y: auto;
  padding: 6px 8px;
  min-height: 0;
  scrollbar-width: thin;
}
.log-line {
  display: grid;
  grid-template-columns: 18px 1fr auto;
  gap: 6px;
  align-items: baseline;
  padding: 3px 0;
  border-bottom: 1px dashed rgba(43, 35, 24, 0.1);
  font-size: 12px;
}
.log-icon { opacity: 0.7; }
.log-tick { font-size: 10px; color: var(--ink-faint); }
.log-new { display: inline-block; padding: 1px 4px; border-radius: 3px; background: #8c3027; color: #fff8e8; font-size: 10px; font-weight: 700; }
.log-report { padding: 0; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; text-decoration: underline dotted; }
.log-location { display: block; padding: 4px 6px; margin-top: 3px; border: 1px solid var(--rule); border-radius: 3px; background: transparent; color: var(--ink-soft); font: inherit; font-size: 11px; cursor: pointer; }
.log-location:focus-visible, .log-report:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
@media (pointer: coarse) { .log-location, .log-report { min-height: 40px; } }
/* A chronicle line the server hung a battle card on is a <button>, so it has to
   be talked back out of looking like one: the row keeps the grid, the type and
   the dashed rule of every other line, and says it can be opened only under the
   cursor. The report used to open itself over the middle of the map, which is
   why it now waits to be asked. */
button.log-line {
  width: 100%;
  border: 0;
  border-bottom: 1px dashed rgba(43, 35, 24, 0.1);
  background: none;
  font: inherit;
  font-size: 12px;
  color: inherit;
  text-align: left;
}
.log-openable { cursor: pointer; }
.log-openable:hover, .log-openable:focus-visible {
  background: rgba(43, 35, 24, 0.06);
}
.log-openable .log-text { text-decoration: underline dotted rgba(43, 35, 24, 0.35); }
/* Where the chronicle is not continuous in time (ui/chronicleModel.js
   chronicleGaps). A centred rule rather than another line of prose: it is a
   break in the record, and it should read as one at a glance without competing
   with the entries either side of it. */
.log-gap {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 5px 0 3px;
  font-size: 10px;
  font-style: italic;
  letter-spacing: 0.04em;
  color: var(--ink-faint);
  text-transform: lowercase;
}
.log-gap::before, .log-gap::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(43, 35, 24, 0.16);
}
.log-battle .log-text, .log-siege .log-text { color: #7b2519; }
.log-diplomacy .log-text { color: #2c4356; }
.log-system .log-text { font-weight: 600; }
.log-chat .log-text { color: #4a3d78; }

.chat-form { display: flex; gap: 5px; padding: 7px 8px; border-top: 1px solid var(--rule); }
/* **`min-width: 0`, or the box will not shrink.** A flex item defaults to
   `min-width: auto`, and an `<input>`'s intrinsic width is its `size` — about
   180 px — so `flex: 1` could grow it and never shrink it. In a 340 px drawer
   that put the chat box and its Send button at x 859 and x 1124 on an 844 px
   screen. It was invisible until the column stopped being `overflow: hidden`,
   which is the usual way this fault is found: it was always overflowing, and
   something above it was always throwing the overflow away. */
.chat-form .input { flex: 1 1 0; min-width: 0; }

/* ---------- overlays ------------------------------------------------------ */

.overlay {
  position: absolute;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 24px;
}
.overlay[hidden] { display: none; }
/* The direct-battle muster table opens from the lobby too, and the lobby is
   z-index 80: without this the overlay laid out perfectly and appeared not to
   (`.battle-root` at 120 still covers everything once the fight starts). */
.overlay-front { z-index: 90; }
#directPanel { position: fixed; grid-template-columns: minmax(0, 1fr); overflow: hidden; }
/* Direct battles: shared parchment desk, numeric solo setup and company warbands. */
.overlay-card.direct-card { width: min(1540px, calc(100vw - 32px)); max-height: 95dvh; border: 1px solid var(--gold); }
.direct-card .direct-head { padding: 18px 24px; background: var(--sea-deep); color: var(--parchment); border-bottom: 2px solid var(--gold); }
.direct-head h2 { font-size: 23px; letter-spacing: 0.04em; }
.direct-head .btn { background: rgba(242, 231, 205, 0.06); color: var(--parchment); border-color: rgba(242, 231, 205, 0.25); }
.direct-head .btn:hover { background: rgba(242, 231, 205, 0.12); }
.direct-insignia { display: grid; place-items: center; flex: 0 0 44px; height: 44px; color: var(--gold-bright); border: 1px solid rgba(215, 167, 63, 0.45); }
.direct-card .overlay-body { padding: 22px 24px; }
.direct-card .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.direct-card .field { min-width: 0; gap: 6px; color: var(--ink-soft); }
.direct-card .input { width: 100%; min-width: 0; min-height: 44px; background: rgba(255, 253, 245, 0.55); border-color: var(--rule-strong); }
.direct-card .input:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.direct-join { border-left: 1px solid var(--rule); padding-left: 22px; }
.direct-card .card-foot { gap: 10px; flex-wrap: wrap; padding-top: 14px; border-top: 1px solid var(--rule); }
.direct-card .btn-primary { min-width: 160px; min-height: 44px; }
.direct-invite { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 24px; padding: 16px; background: rgba(168, 132, 44, 0.1); border: 1px solid var(--rule-strong); }
.direct-status { padding: 12px 14px; border-left: 3px solid var(--gold); background: rgba(168, 132, 44, 0.1); font-size: 13px; }
.direct-muster-budget { position: sticky; top: -22px; z-index: 2; padding: 10px; margin-bottom: 14px; background: var(--parchment-2); border: 1px solid var(--rule); }
.direct-muster-budget p { margin: 2px 0; font-size: 12px; }
.direct-muster-budget progress { display: block; width: 100%; height: 8px; margin: 8px 0; accent-color: var(--good); }
.direct-muster-budget[data-over="true"] { color: var(--bad); }
.direct-card [data-direct-error]:empty { display: none; }
.direct-army-builder h4 { margin: 20px 0 10px; font: 14px var(--font-head); }
.direct-catalog.ub { position: static; display: grid; grid-template-columns: repeat(auto-fit, minmax(86px, 1fr)); gap: 10px; padding: 14px; margin-bottom: 14px; background: var(--sea-deep); pointer-events: auto; }
.direct-company-offer { display: flex; align-items: center; flex-direction: column; gap: 7px; min-width: 0; text-align: center; font-size: 11px; }
.direct-company-offer > small { color: var(--gold-bright); }
.direct-catalog .ub-card > * { pointer-events: none; }
.direct-army-builder .ub-card { cursor: grab; min-height: 69.3px; }
.direct-warband.ub { position: static; display: block; pointer-events: auto; min-height: 105px; padding: 12px; background: var(--sea-deep); border: 2px dashed var(--gold); }
.direct-warband .ub-cards { justify-content: flex-start; min-height: 80px; }
.direct-warband .ub-card { cursor: pointer; }
/* A muster card shows the troop's name and soldiers where the battle's bars go
   (5 November 2026); the battle bar hides names on a phone, the muster does not. */
.ub-card.is-muster .ub-name, .ub-card.is-muster:is([data-general='general'], [data-general='king']) .ub-name { display: block; }
.ub-card.is-muster .ub-strength { display: inline-flex; align-items: center; justify-content: center; gap: 2px; }
.ub-soldier { flex: none; opacity: 0.85; }
/* With no bars at the foot, the picture and its name sit together in the middle. */
.ub-card.is-muster { justify-content: center; gap: 3px; }
.ub-card.is-muster .ub-body { flex: 0 0 auto; }
.direct-remove-drop { padding: 14px; border: 1px dashed var(--ink-faint); text-align: center; font-size: 12px; }
.direct-remove-drop.is-dragover, .direct-warband.is-dragover { outline: 3px solid var(--gold); }
.direct-upgrades { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 20px; padding: 16px; border: 1px solid var(--rule-strong); }
.direct-upgrades h4, .direct-upgrades > p { grid-column: 1 / -1; margin: 0; }
.direct-perk-card { display: flex; flex-direction: column; gap: 9px; min-width: 0; padding: 12px; border: 1px solid var(--rule-strong); background: rgba(255, 253, 245, 0.35); }
.direct-perk-card[data-active="true"] { border-color: var(--gold); background: rgba(168, 132, 44, 0.12); }
.direct-perk-heading { display: flex; align-items: center; gap: 8px; color: var(--ink-soft); font: 12px var(--font-head); }
.direct-perk-heading svg { flex-shrink: 0; }
.direct-perk-bonus { font: 24px var(--font-head); color: var(--ink); }
.direct-perk-pips { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 3px; }
.direct-perk-pips i { height: 7px; border: 1px solid var(--rule-strong); background: rgba(43, 35, 24, 0.07); }
.direct-perk-pips i[data-active="true"] { border-color: var(--gold); background: var(--gold); }
.direct-perk-level { display: flex; align-items: center; justify-content: space-between; gap: 6px; font-size: 11px; }
.direct-perk-card > small { font-size: 10px; line-height: 1.4; color: var(--ink-soft); }
.direct-perk-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin-top: auto; }
.direct-perk-actions .btn { padding: 6px 4px; min-height: 44px; min-width: 0; font-size: 11px; }
.direct-perk-actions [data-perk-action="add"]:not(:disabled) { border-color: var(--gold); background: rgba(168, 132, 44, 0.2); }
.direct-perk-hint:empty { display: none; }
/* Friend muster: catalogue left, assembled company bar right; seats show readiness only. */
.overlay-card.direct-friend-card { width: min(1380px, calc(100vw - 32px)); }
.direct-friend-card .direct-head { padding: 12px 18px; }
.direct-friend-card .overlay-body { padding: 12px 18px 16px; min-height: 0; }
.direct-friend-toolbar { display: grid; grid-template-columns: minmax(0, 1fr) minmax(140px, 220px) auto auto; gap: 14px; align-items: center; padding: 10px 18px; border-bottom: 1px solid var(--rule); background: var(--parchment-2); }
.direct-friend-toolbar .direct-field-visuals { margin: 0; min-width: 0; }
/* The room's top bar, one line and one type scale (player, 4 November 2026). Every
   item is 38 px tall; labels are 11 px small caps, values 13 px. */
.direct-friend-toolbar { align-items: center; }
.direct-friend-toolbar .direct-owner-field.field { margin: 0; min-width: 0; flex-direction: row; align-items: center; gap: 8px; }
.direct-friend-toolbar .direct-owner-field > span,
.direct-friend-toolbar .direct-map-summary > :not(.btn),
.direct-friend-toolbar .direct-seat-status > div > span { font: 11px var(--font-head); letter-spacing: 0.05em; color: var(--ink-soft); white-space: nowrap; }
.direct-friend-toolbar .direct-owner-field .input { min-height: 38px; height: 38px; padding: 0 10px; font-size: 13px; }
.direct-friend-toolbar .btn, .direct-invite-details > summary { min-height: 38px; height: 38px; display: inline-flex; align-items: center; padding: 0 14px; font-size: 13px; box-sizing: border-box; }
.direct-friend-toolbar .direct-seat-status strong { font-size: 13px; line-height: 1.15; }
.direct-invite-details > summary { list-style: none; gap: 6px; white-space: nowrap; }
.direct-invite-details > summary::-webkit-details-marker { display: none; }
.direct-invite-details > summary strong { letter-spacing: 0.08em; }
/* The invite-or-join box: two stacked sections. */
.direct-invite-details .direct-invite { gap: 0; padding: 0; }
.direct-invite > section { display: grid; gap: 8px; padding: 14px 16px; }
.direct-invite > section + section { border-top: 1px solid var(--rule); }
.direct-invite h6 { margin: 0; font: 12px var(--font-head); letter-spacing: 0.06em; color: var(--ink); }
.direct-invite .btn { justify-self: start; }
.direct-invite .direct-join { border-left: 0; padding-left: 16px; }
/* Below 900 px the Invite-or-join button can sit in the left column, and a box anchored to
   its right edge ran off the left of the screen (Join at x -123 on a 390 px phone). Pin it
   between the screen edges instead; with top: auto it keeps the place under its button. */
@media (max-width: 900px) {
  .direct-invite-details .direct-invite { position: fixed; top: auto; left: 8px; right: 8px; width: auto; max-width: none; }
}
/* The host types the room's budget straight into the total. */
.direct-friend-card .direct-muster-budget p { display: flex; flex-wrap: wrap; align-items: center; gap: 0; white-space: pre-wrap; min-width: 0; }
.direct-friend-card .direct-muster-budget .direct-budget-input { margin-left: 4px; }
.direct-card .input.direct-budget-input { display: inline-block; width: 78px; min-width: 78px; min-height: 28px; height: 28px; padding: 0 6px; font-weight: 700; font-size: 13px; text-align: right; }
.direct-muster-problem { margin: 10px 0 0; font-size: 12px; color: var(--danger, #9b2c1f); }
.direct-muster-problem:empty { display: none; }
/* The company and commander hover box (player, 3 November 2026): skills and stat bars. */
.direct-hovercard { position: fixed; z-index: 1000; width: min(300px, calc(100vw - 16px)); padding: 10px 12px; pointer-events: none;
  background: #17140f; color: #efe6cf; border: 1px solid var(--gold); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45); font-size: 12px; line-height: 1.35; }
.direct-hovercard header { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.direct-hovercard header strong { font: 14px var(--font-head); color: #f3d98f; }
.direct-hovercard header span { font-size: 11px; color: #c9bd9f; white-space: nowrap; }
.direct-hovercard p { margin: 4px 0; }
.direct-hovercard h6 { margin: 8px 0 4px; font: 11px var(--font-head); color: #f3d98f; }
.direct-hovercard .dh-national { color: #f3d98f; font-size: 11px; }
.direct-hovercard .dh-note { color: #c9bd9f; font-size: 11px; }
.direct-hovercard .dh-blocked { color: #ff9b85; }
.direct-hovercard .dh-stats { display: grid; gap: 3px; margin: 6px 0; }
.dh-stat { display: grid; grid-template-columns: 104px minmax(0, 1fr) 54px; align-items: center; gap: 6px; font-size: 11px; }
.dh-stat i { display: block; height: 7px; background: rgba(255, 255, 255, 0.12); }
.dh-stat b { display: block; height: 100%; background: linear-gradient(90deg, #b8902e, #f3d98f); }
.dh-stat em { font-style: normal; text-align: right; color: #c9bd9f; font-variant-numeric: tabular-nums; }
.direct-hovercard ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.direct-hovercard li { border-left: 2px solid var(--gold); padding-left: 7px; }
.direct-hovercard li strong { display: block; }
.direct-hovercard li small { color: #c9bd9f; }
.direct-friend-toolbar .direct-map-summary { padding: 0; border: 0; background: none; font-size: 12px; gap: 10px; }
.direct-friend-toolbar .direct-map-summary .btn { margin-left: 8px; }
.direct-seat-status { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 12px; }
.direct-seat-status > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.direct-seat-status strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 160px; }
.direct-ready-dot { display: grid; place-items: center; flex: 0 0 26px; height: 26px; border-radius: 50%; background: rgba(43, 35, 24, 0.1); color: var(--ink-faint); }
.direct-seat-status[data-friend-ready="true"] .direct-ready-dot { background: var(--good); color: white; }
.direct-seat-status[data-friend-ready="true"] > div > span { color: var(--good); font-weight: 700; }
/* 2v2 (13 Nov 2026): the mode switch and the four seats, each in its shade of the side's hue. */
.direct-mode { display: flex; gap: 4px; }
.direct-mode .btn.is-active { background: var(--ink); color: var(--parchment); }
.direct-teams { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 10px; }
.direct-team { flex: 1 1 220px; min-width: 0; list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.direct-team-name { font: 12px var(--font-head); color: var(--ink-faint); }
.direct-team-vs { font: 12px var(--font-head); color: var(--ink-faint); }
.direct-team-seat { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 5px 8px; font-size: 12px; border: 1px solid var(--rule-strong); border-left: 6px solid var(--seat); }
.direct-team-seat.is-mine { box-shadow: inset 0 0 0 2px var(--seat); font-weight: 700; }
.direct-team-seat > div { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.direct-team-seat strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.direct-team-swatch { flex: 0 0 14px; height: 14px; border-radius: 50%; background: var(--seat); border: 1px solid rgba(14, 12, 16, 0.8); }
.direct-invite-details { position: relative; font-size: 12px; }
.direct-invite-details > summary { cursor: pointer; padding: 12px; border: 1px solid var(--rule-strong); }
.direct-invite-details .direct-invite { position: absolute; top: 100%; right: 0; z-index: 5; width: min(440px, 85vw); grid-template-columns: minmax(0, 1fr); background: var(--parchment); box-shadow: var(--panel-shadow); }
.direct-friend-card .direct-muster-budget { position: static; display: grid; grid-template-columns: auto minmax(80px, 1fr) auto; gap: 14px; align-items: center; padding: 8px 10px; margin-bottom: 10px; }
.direct-friend-card .direct-muster-budget progress { margin: 0; }
.direct-army-builder { display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); gap: 18px; margin-top: 12px; }
.direct-selection-panel, .direct-warband-panel { min-width: 0; }
.direct-selection-panel { border-right: 1px solid var(--rule-strong); padding-right: 18px; }
.direct-army-builder h4 { margin: 0 0 8px; }
.direct-army-builder h5 { font: 12px var(--font-head); margin: 12px 0 6px; }
.direct-army-builder .direct-catalog { grid-template-columns: repeat(auto-fit, minmax(68px, 1fr)); gap: 8px 5px; padding: 10px 6px; margin-bottom: 8px; }
.direct-company-offer { gap: 4px; font-size: 10px; }
.direct-company-offer.is-national .ub-card { outline: 2px solid var(--gold); outline-offset: 1px; }
.direct-national-note { color: var(--gold); font-size: 10px; line-height: 1.2; text-align: center; }
.direct-company-offer.is-blocked { opacity: 0.55; }
.direct-warband-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.direct-warband-heading .btn { font-size: 11px; min-height: 36px; }
.direct-warband .ub-cards { max-height: 250px; overflow-y: auto; }
/* **The friend muster may scroll** (player, 8 November 2026), so it must look
   like it does: content that silently continues below the fold is how the
   country-specific unit went unseen (3 November). Show the bar, keep its gutter. */
#directPanel .overlay-body, .direct-warband .ub-cards, .direct-map-body {
  scrollbar-width: auto;
  scrollbar-color: #a9945a rgba(11, 29, 38, 0.35);
  scrollbar-gutter: stable;
}
.direct-remove-drop { padding: 10px; margin: 8px 0; font-size: 11px; }
.direct-upgrades { margin-top: 12px; padding: 12px; gap: 8px; }
.direct-friend-footer { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 18px; border-top: 1px solid var(--rule-strong); background: var(--parchment-2); }
.direct-friend-footer .direct-status { margin: 0; padding: 5px 10px; background: none; font-size: 12px; }
.direct-friend-footer .card-foot { flex-shrink: 0; margin: 0; padding: 0; border: 0; }
.direct-friend-footer .is-ready { background: var(--good); color: white; border-color: var(--good); }
@media (max-width: 800px) {
  .direct-army-builder { grid-template-columns: minmax(0, 1fr); }
  .direct-selection-panel { padding: 0; border-right: 0; border-bottom: 1px solid var(--rule); }
  .direct-friend-footer { flex-wrap: wrap; }
}
.direct-field-visuals { margin-bottom: 18px; }
.direct-map-summary { display: flex; align-items: center; gap: 16px; padding: 14px 18px; background: rgba(168, 132, 44, 0.1); border: 1px solid var(--rule-strong); }
.direct-map-summary .btn { margin-left: auto; }
/* Game settings behind the cog beside × (13 Nov 2026): over the card, under the map picker. */
.direct-settings { position: fixed; inset: 0; z-index: 3; display: grid; place-items: center; padding: 20px; background: rgba(10, 16, 22, 0.6); }
.direct-settings[hidden] { display: none; }
.direct-settings-window { width: min(560px, 100%); display: grid; box-shadow: var(--panel-shadow); }
.direct-cog { font-size: 20px; line-height: 1; }
.direct-settings-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; background: var(--parchment); border-bottom: 1px solid var(--rule-strong); }
.direct-settings-head h3 { margin: 0; }
.direct-settings-body { display: grid; gap: 14px; padding: 14px 16px; max-height: calc(100dvh - 120px); overflow-y: auto; background: var(--parchment); box-shadow: var(--panel-shadow); }
.direct-settings-body section { display: grid; gap: 8px; }
.direct-settings-body h4 { margin: 0; font: 13px var(--font-head); }
.direct-settings-row { display: flex; flex-wrap: wrap; gap: 6px; }
.direct-settings-read { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 0; font-size: 13px; }
.direct-settings-read dt { color: var(--ink-faint); }
.direct-settings-read dd { margin: 0; font-weight: 700; }
.direct-map-picker { position: fixed; inset: 0; z-index: 4; display: grid; place-items: center; padding: 20px; }
.direct-map-picker[hidden], .direct-card [data-field-settings][hidden] { display: none; }
.direct-map-backdrop { position: absolute; inset: 0; background: rgba(10, 16, 22, 0.85); }
.direct-map-window { position: relative; display: flex; flex-direction: column; width: min(1280px, 100%); max-height: 94dvh; overflow: hidden; background: var(--parchment); border: 1px solid var(--gold); box-shadow: var(--panel-shadow); }
.direct-map-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 20px; background: var(--sea-deep); color: var(--parchment); }
.direct-map-body { overflow-y: auto; padding: 18px; }
.direct-map-body > canvas { display: block; width: 100%; height: auto; max-height: 420px; object-fit: contain; background: var(--sea-deep); }
.direct-map-body > p { font-size: 12px; }
/* Ground, weather, walls, seed (and a friend host's leadership) on one row, so the gallery stays in view. */
.direct-map-body [data-field-settings] { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.direct-map-gallery { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin-top: 18px; }
.direct-map-tile { padding: 0; overflow: hidden; min-width: 0; border: 1px solid var(--rule-strong); background: var(--parchment-2); cursor: pointer; color: var(--ink); font: 12px var(--font-body); }
.direct-map-tile canvas { display: block; width: 100%; height: auto; background: var(--sea-deep); }
.direct-map-tile > span { display: block; padding: 8px 4px; }
.direct-map-tile[aria-pressed="true"] { outline: 2px solid var(--gold); background: var(--sea-deep); color: var(--parchment); }
@media (max-width: 620px) {
  #directPanel { padding: 0; }
  .overlay-card.direct-card { width: 100%; height: 100dvh; max-height: 100dvh; border-radius: 0; }
  .direct-card .direct-head { padding: 12px; gap: 8px; }
  .direct-head .btn-icon { min-width: 44px; }
  .direct-head h2 { font-size: 17px; letter-spacing: 0; }
  .direct-insignia { display: none; }
  .direct-card .overlay-body { padding: 18px 14px; }
  .direct-invite { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .direct-join { border-left: 0; border-top: 1px solid var(--rule); padding: 16px 0 0; }
  .direct-card .btn { min-height: 44px; }
  .direct-muster-budget { top: -18px; }
  .direct-upgrades { grid-template-columns: minmax(0, 1fr); }
  .overlay-card.direct-friend-card { width: 100%; }
  .direct-friend-toolbar { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 8px 12px; gap: 8px; }
  .direct-invite-details > summary { font-size: 11px; padding: 8px; }
  .direct-invite-details summary strong { display: block; margin-top: 3px; letter-spacing: 0.06em; }
  .direct-friend-toolbar .direct-field-visuals { grid-column: 1 / -1; }
  .direct-friend-toolbar .direct-map-summary { flex-wrap: nowrap; }
  .direct-friend-toolbar .direct-map-summary .btn { width: auto; margin-left: auto; flex-shrink: 0; }
  .direct-friend-card .direct-muster-budget { gap: 8px; grid-template-columns: auto auto; }
  .direct-friend-card .direct-muster-budget progress { grid-column: 1 / -1; grid-row: 2; }
  .direct-friend-card .overlay-body { padding: 10px 12px; }
  .direct-friend-footer { padding: 8px 12px; gap: 8px; }
  .direct-friend-footer .card-foot { width: 100%; justify-content: flex-end; }
  .direct-friend-footer .btn-primary { min-width: 120px; }
  .direct-warband-heading .btn { min-height: 44px; }
  .direct-perk-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 10px; padding: 10px; }
  .direct-perk-heading { grid-column: 1; grid-row: 1; }
  .direct-perk-bonus { grid-column: 2; grid-row: 1; font-size: 22px; }
  .direct-perk-pips { grid-column: 1; grid-row: 2; align-self: center; }
  .direct-perk-level { grid-column: 2; grid-row: 2; }
  .direct-perk-level > span { display: none; }
  .direct-perk-card > small { grid-column: 1 / -1; }
  .direct-perk-actions { grid-column: 1 / -1; }
  .direct-map-picker { padding: 0; }
  .direct-map-window { height: 100dvh; max-height: 100dvh; }
  .direct-map-gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .direct-map-summary { flex-wrap: wrap; gap: 10px; }
  .direct-map-summary .btn { width: 100%; margin: 0; }
}
.overlay-backdrop { position: absolute; inset: 0; background: rgba(10, 16, 22, 0.55); backdrop-filter: blur(2px); }
.overlay-card {
  position: relative;
  width: min(720px, 100%);
  max-height: min(84vh, 760px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.overlay-wide { width: min(940px, 100%); }
.overlay-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--rule);
}
.overlay-head h2 { flex: 1; font-size: 20px; }
.overlay-body { overflow-y: auto; padding: 14px 16px 18px; }

/* diplomacy */
/* There is no relation matrix. Eighteen powers made it a 21-column table that
   had to scroll sideways inside the overlay, and nine cells in ten said "peace".
   The overlay is three lists now — your own standing, the pairs that are not at
   peace, and the league table — and all three fit the card's width, so nothing
   here scrolls but the body and the league table's own box. */
.faction-inline { display: inline-flex; align-items: center; gap: 6px; }
.rel-war { background: rgba(163, 51, 38, 0.14); }
.rel-peace { background: rgba(79, 122, 68, 0.1); }
.rel-alliance { background: rgba(168, 132, 44, 0.18); }
.is-out { opacity: 0.5; }

/* Your standing: one row per power, the ones that press you at the top. The
   grid is name / state / why / orders, and it stacks under 720 px. */
.diplo-rows { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.diplo-row {
  display: grid;
  grid-template-columns: minmax(120px, 1.1fr) auto minmax(150px, 1.5fr) auto;
  align-items: center;
  gap: 6px 12px;
  padding: 7px 10px;
  border: 1px solid var(--rule);
  border-left: 4px solid transparent;
  border-radius: var(--radius-sm);
  background: rgba(255, 253, 245, 0.42);
}
.diplo-row.rel-war { border-left-color: #a33326; background: rgba(163, 51, 38, 0.07); }
.diplo-row.rel-alliance { border-left-color: #1e6f52; background: rgba(30, 111, 82, 0.07); }
.diplo-row.rel-peace { border-left-color: var(--rule); background: rgba(255, 253, 245, 0.42); }
.diplo-row-who { display: flex; align-items: center; gap: 6px; min-width: 0; font-weight: 600; }
.diplo-why { font-size: 11.5px; color: var(--ink-soft); }
.diplo-flag {
  align-self: flex-start;
  font-size: 10.5px;
  padding: 0 5px;
  border-radius: 8px;
  color: var(--ink-soft);
}
.diplo-offer { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 5px; font-size: 11.5px; }
/* The ledger is about the pact, not about one column of the row, so it sits
   under all four (ui/pactLedger.js). */
.diplo-row-ledger { grid-column: 1 / -1; }
/* The mark is what has just moved, and it is shape first: ▲ warmer, ▼ colder,
   ◆ an offer on the table. Colour only confirms it. */
.diplo-shift { font-size: 11px; white-space: nowrap; color: var(--ink-soft); }
.diplo-shift.shift-up { color: #1e6f52; }
.diplo-shift.shift-down { color: #a33326; }


/* The wars and the alliances: each pair once, and only when it is not peace.
   `.diplo-duo` and not `.diplo-pair` — that name is the composer's
   amount-plus-unit field and was here first. */
.diplo-pairs { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 10px 18px; }
.diplo-pairs-head {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
}
.diplo-pairs-head.rel-war { color: #7d2418; }
.diplo-pairs-head.rel-alliance { color: #145a41; }
.diplo-duo-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.diplo-duo {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 3px 7px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  background: transparent;
}
.diplo-duo.is-mine { font-weight: 600; }
.diplo-duo.is-mine.rel-war { background: rgba(163, 51, 38, 0.12); }
.diplo-duo.is-mine.rel-alliance { background: rgba(30, 111, 82, 0.12); }
.diplo-duo-mark { display: inline-flex; opacity: 0.85; }
.diplo-duo-mark .ui-icon, .diplo-pairs-head .ui-icon { background-color: currentColor; }


@media (max-width: 720px) {
  .diplo-row { grid-template-columns: 1fr; }
}

/* trade pact ledger (ui/pactLedger.js) — the books of a standing barter */
.pact-ledger {
  margin-top: 8px;
  padding: 7px 9px;
  border: 1px solid var(--rule);
  border-left: 3px solid var(--good);
  border-radius: var(--radius-sm);
  background: rgba(79, 122, 68, 0.08);
}
.pact-ledger.is-empty { border-left-color: var(--rule); background: rgba(0, 0, 0, 0.03); }
.pact-ledger p { margin: 4px 0 0; }
.pl-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.pl-title { font-weight: 700; font-size: 0.85rem; letter-spacing: 0.02em; }
.pl-figures { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 4px 14px; margin-top: 4px; }
.pl-figure { display: flex; flex-direction: column; line-height: 1.15; }
.pl-value { font-size: 1.15rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.pl-value.pl-small { font-size: 0.95rem; }
.pl-up { color: var(--good); }
.pl-down { color: var(--bad); }
.pl-trend {
  align-self: center;
  padding: 1px 6px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
/* The tray's one-line form: the command bar's panel is a fixed height and does
   not scroll, so the books there are a strip, not a card. */
.pact-ledger.is-strip {
  flex-basis: 100%;
  margin: 0;
  padding: 3px 7px;
  line-height: 1.35;
  background: rgba(79, 122, 68, 0.1);
}
.pact-ledger.is-strip.is-empty { background: rgba(0, 0, 0, 0.04); border-left-color: var(--rule); }
.pact-ledger.is-strip .pl-value { font-size: 1em; }
.pl-flow { display: flex; flex-direction: column; gap: 2px; margin-top: 5px; font-size: 0.82rem; }
.pl-flow > div { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pl-good { display: inline-flex; align-items: center; gap: 3px; font-variant-numeric: tabular-nums; }
.pl-note { max-width: 52ch; }

.proposal-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.proposal {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 7px 9px;
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  background: rgba(168, 132, 44, 0.12);
}

/* The ?perf diagnostic readout (ui/perfReadout.js): over everything, under no
   finger — it must never cost the tap it is there to explain. */
.perf-readout {
  position: fixed;
  top: 4px;
  left: 4px;
  z-index: 200;
  padding: 3px 7px;
  border-radius: var(--radius-sm);
  background: rgba(20, 14, 6, 0.78);
  color: #f3e8cd;
  font: 600 11px/1.4 ui-monospace, monospace;
  pointer-events: none;
}

/* victory */
.victory-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid color-mix(in srgb, var(--faction) 55%, transparent);
  background: color-mix(in srgb, var(--faction) 14%, transparent);
  margin-bottom: 14px;
}
.victory-banner h3 { font-size: 22px; }
.victory-banner p { margin: 2px 0 0; color: var(--ink-soft); }
.standings .is-winner { background: rgba(168, 132, 44, 0.16); font-weight: 600; }
.chart { margin: 16px 0 6px; }
.chart-grid { stroke: rgba(43, 35, 24, 0.14); stroke-width: 1; }
.chart-axis { stroke: rgba(43, 35, 24, 0.35); stroke-width: 1; }
.chart-label { font-size: 10px; fill: var(--ink-faint); font-family: var(--font-body); }
.legend { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; font-size: 12px; margin-top: 6px; }
.legend-item { display: inline-flex; align-items: center; gap: 5px; }
.legend-item i { width: 12px; height: 3px; border-radius: 2px; }

/* help */
.help-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 22px; align-items: start; }
.help-section { break-inside: avoid; margin-bottom: 12px; }
.help-section h3 { font-size: 14px; margin-bottom: 3px; }
.help-section p { margin: 0; font-size: 12.5px; color: var(--ink-soft); }
.help-keys { border-top: 1px solid var(--rule); margin-top: 10px; padding-top: 10px; }
.help-keys h3 { font-size: 14px; margin-bottom: 6px; }
.help-keys dl { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 4px 18px; margin: 0; }
.help-keys dl > div { display: flex; gap: 10px; align-items: baseline; }
.help-keys dt { flex: none; }
.help-keys dd { margin: 0; font-size: 12px; color: var(--ink-soft); }
kbd {
  font: 600 11px/1 var(--font-body);
  padding: 3px 6px;
  border-radius: 4px;
  background: rgba(43, 35, 24, 0.1);
  border: 1px solid var(--rule-strong);
  border-bottom-width: 2px;
}

/* ---------- lobby --------------------------------------------------------- */

.lobby {
  position: absolute;
  inset: 0;
  z-index: 80;
  overflow-y: auto;
  padding: 26px 20px 40px;
  background:
    radial-gradient(90% 70% at 50% 0%, rgba(48, 74, 94, 0.9), rgba(14, 22, 30, 0.97) 70%),
    var(--sea-deep);
}
.lobby[hidden], .lobby.is-hidden { display: none; }
.lobby-scroll { width: min(1040px, 100%); margin: 0 auto; padding: 22px 26px 26px; }
@media (max-width: 480px) {
  /* A phone's lobby is the page: give its parchment the full available area
     instead of keeping an empty dark frame around a narrower floating card. */
  .lobby { padding: 0; }
  .lobby-scroll { width: 100%; min-height: 100dvh; border-radius: 0; }
  .lobby [data-rooms] { min-width: 0; overflow-x: auto; }
}
.lobby-head { border-bottom: 1px solid var(--rule); padding-bottom: 14px; margin-bottom: 16px; }
.lobby-title { font-size: 34px; letter-spacing: 0.02em; }
.lobby-identity { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.lobby-identity label { font-size: 12px; color: var(--ink-faint); }
.lobby-identity .input { width: 190px; }
.lobby-conn { font-size: 12px; color: var(--ink-faint); }
.lobby-conn.is-on { color: var(--good); }
.lobby-conn.is-off { color: var(--bad); }
.lobby-body { display: flex; flex-direction: column; gap: 14px; }
.lobby-body > div { display: flex; flex-direction: column; gap: 14px; }

.card { padding: 14px 16px; box-shadow: none; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.card-head h2 { flex: 1; font-size: 18px; }
.card-actions { display: flex; gap: 6px; align-items: center; }
.card-foot { margin-top: 12px; display: flex; justify-content: flex-end; }
.room-name { font-weight: 600; margin-right: 6px; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.field { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--ink-faint); }
.field-check { flex-direction: row; align-items: center; gap: 7px; }

.faction-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; margin: 10px 0 4px; }
.faction-card {
  display: flex;
  flex-direction: column;
  gap: 7px;
  text-align: left;
  padding: 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--rule-strong);
  border-left: 4px solid var(--faction);
  background: rgba(255, 253, 245, 0.45);
  cursor: pointer;
  font-family: var(--font-body);
  color: var(--ink);
  transition: transform 100ms ease, box-shadow 120ms ease, background 120ms ease;
}
.faction-card:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(10, 16, 22, 0.2); background: rgba(255, 253, 245, 0.75); }
.faction-card:disabled { cursor: not-allowed; opacity: 0.6; }
.faction-card.is-mine { background: color-mix(in srgb, var(--faction) 20%, rgba(255, 253, 245, 0.6)); box-shadow: inset 0 0 0 1px var(--faction); }
.faction-card-head { display: flex; gap: 9px; align-items: center; }
.faction-vignette { display: block; width: 100%; height: auto; max-height: 96px; object-fit: contain; margin-bottom: 6px; pointer-events: none; }
.faction-card-head > div { display: flex; flex-direction: column; }
.faction-name { font-family: var(--font-head); font-weight: 700; font-size: 14px; }
.faction-capital { font-size: 11px; color: var(--ink-faint); }
.faction-perk { margin: 0; font-size: 12px; color: var(--ink-soft); flex: 1; }
/* What only this faction can do, and the weakness a rival plays against (docs/DESIGN.md §17). */
.faction-identity { margin: 6px 0 0; font-size: 11.5px; color: var(--ink-soft); }
.faction-weakness { margin: 4px 0 0; font-size: 11.5px; color: var(--ink-faint, var(--ink-soft)); opacity: 0.9; }
.faction-card-foot { display: flex; justify-content: space-between; align-items: center; gap: 6px; flex-wrap: wrap; }
.faction-occupant { font-size: 11px; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink-faint); }

/* The theatres. Eighteen seats are grouped by where on the map they sit, and
   the chip row narrows to one group. It is a filter and never a page: the lobby
   scrolls, "All" is the state it opens in, and no card is ever unreachable. */
.theatre-bar { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 6px; }
.theatre-chip { font-size: 12px; }
.theatre-count { color: var(--ink-faint); font-variant-numeric: tabular-nums; margin-left: 3px; }
.theatre-chip.is-active .theatre-count { color: inherit; opacity: 0.7; }
.theatre-note { margin: 0 0 4px; }
.theatre-scope { margin: 0 0 4px; color: var(--ink); }
.theatre { margin-top: 6px; }
.theatre-head {
  font-family: var(--font-head);
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
  border-bottom: 1px solid var(--rule);
  padding-bottom: 3px;
  margin: 0;
}
.theatre-hint { text-transform: none; letter-spacing: 0; font-family: var(--font-body); font-size: 11px; opacity: 0.75; }
.theatre .faction-grid { margin-top: 8px; }

/* Old quarrels are an antipathy, not a war, so they are drawn in the quiet ink
   and never in the war colour. The label says which, and the tooltip says it
   again in full. */
.faction-rivals { margin: 0; font-size: 11px; color: var(--ink-faint); line-height: 1.35; }
.faction-rivals-label {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 10px;
  opacity: 0.8;
  margin-right: 3px;
}
.faction-diff { font-size: 11px; color: var(--ink-faint); white-space: nowrap; }
.faction-diff b { font-weight: 700; color: var(--ink-soft); }
/* The words are the balance harness's, not ours (`startDifficulty`), so the
   colour is keyed off the vocabulary it actually uses and any word it invents
   later simply lands on the neutral ink rather than on a wrong colour. */
.faction-diff.is-easy b, .faction-diff.is-easier b { color: var(--good); }
.faction-diff.is-hard b, .faction-diff.is-harder b, .faction-diff.is-challenging b { color: var(--bad); }
.faction-diff.is-unset b { opacity: 0.6; }

.lobby-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.spectators { display: flex; gap: 10px; align-items: baseline; margin-top: 10px; font-size: 12px; }

/* ---------- toasts -------------------------------------------------------- */

.toasts {
  position: absolute;
  right: calc(var(--col-w) + 24px);
  bottom: var(--cmd-clear);
  /* Notifications stay sharp and dismissible above campaign modal backdrops. */
  z-index: 95;
  display: flex;
  flex-direction: column;
  gap: 7px;
  align-items: flex-end;
  pointer-events: none;
  max-width: min(380px, 60vw);
}
/* With nothing selected there is no command bar, and the stack used to keep
   its 228 px of clearance anyway, so announcements arrived at the right-hand
   middle of the screen. They start from the bottom-right corner now, and rise
   above the bar only while it is up. Not on a touch screen: there the stack
   spans both edges (the coarse-pointer block below) and would land on the
   minimap. */
@media (pointer: fine) {
  #app:has(> #commandBar[hidden]) > .toasts { bottom: max(var(--dispatch-bottom), var(--guide-clear, 0px)); }
}
.toast {
  pointer-events: auto;
  padding: 9px 13px;
  font-size: 13px;
  border-left: 4px solid var(--ink-soft);
  cursor: pointer;
  opacity: 0;
  transform: translateX(14px);
  transition: opacity 200ms ease, transform 200ms ease;
}
.toast.is-in { opacity: 1; transform: none; }
.toast .toast-dismiss, .toast .toast-news { pointer-events: auto; }
.toast.is-out { opacity: 0; transform: translateX(14px); transition: opacity 700ms ease, transform 700ms ease; pointer-events: none; }
.toast-error { border-left-color: var(--bad); }
.toast-war { border-left-color: #7b2519; }
.toast-good { border-left-color: var(--good); }
.toast-info { border-left-color: var(--gold); }

.boot-error {
  position: absolute;
  inset: auto 16px 16px 16px;
  z-index: 100;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: #7b2519;
  color: #ffeede;
  font-weight: 500;
}
.boot-error[hidden] { display: none; }

/* ---------- responsive ---------------------------------------------------- *
   Two ordered sequences.

   Stockpile tiers, widest first: gold and grain are always on the strip, then
   the building materials, then the everyday goods, then the luxuries. Whatever
   the strip drops is still one click away under "Treasury".

   Top bar drop order: room name → pace note and tick → map-mode caption → the
   Leave caption → the connection caption. The faction banner and the connection
   state are the last two things standing, as the brief asks.
   -------------------------------------------------------------------------- */

/* --- stockpile tiers ------------------------------------------------------ */
/* A tile is `--resource-tile-w` plus a 2px gap, and the strip also carries 14px
   of padding, the `/ec` legend and the Treasury button. Each step below is the
   width at which the next tier's tiles stop fitting that sum, so the strip loses
   whole tiers from its tail and never scrolls and never wraps.

   The rate is no longer dropped before the tier is. It used to go for every
   non-gold good below 1500px, which left eleven figures on screen with no
   indication which way any of them was moving — the single thing the tile
   exists to say. A good that will not fit is now removed outright, where the
   player can see it is missing and open Treasury, rather than half-shown. */
/* Compact, on either axis. Narrow: a smaller disc and a narrower column buy back
   two tiers' worth of width before anything has to be dropped. **Short**: the
   strip is the one piece of chrome that grew in this redesign, and on a laptop
   it is competing with the map for the same pixels — the old "short windows"
   rule took `--resource-h` to 42, which a disc cannot live in, so the strip has
   to answer a short window by shrinking rather than by clipping. It is one
   block rather than two because the tile must never be sized on one axis and
   spaced on the other. */
@media (max-width: 1059px), (max-height: 860px) {
  :root {
    --resource-disc: 34px;
    --resource-tile-w: 52px;
    --resource-h: 72px;
  }
  .resource { padding: 3px 1px 2px; gap: 0; }
  .resource-amount { font-size: 13px; margin-top: 1px; }
  .resource-delta { font-size: 9px; }
}
/* **The tier ladder is stated once, in `navigation.css`, against the strip the
   campaign HUD actually leaves it.** The four rules that stood here —
   869/709/549/389 — were measured for a strip that owned its whole row, and
   from the day `navigation.css` gained `#campaignHud #resourceBar .resource
   { display: flex }` they were out-specified and hid nothing at any width. The
   tile widths they were derived from still hold and are what the live ladder is
   built on: the compact tile is 52px plus a 2px gap, so eleven need about 686px
   of strip by that reckoning and 680px measured in the browser. */

/* --- top bar -------------------------------------------------------------- */
@media (max-width: 1379px) {
  .calendar-tick { display: none; }
}
@media (max-width: 1239px) {
  .topbar { gap: 8px; padding: 0 8px; }
  .topbar-right { gap: 3px; }
  .topbar-right .btn-icon { padding: 6px; }
}
@media (max-width: 1099px) {
  :root { --topbar-h: 46px; --rail-w: 300px; }
  /* The crest goes, not the numbers: the swatch beside it already identifies
     the faction and carries the map-key duty, while opinion and the war clock
     are the reason this panel exists. */
  .drail-btn .shield { display: none; }
  .help-columns { grid-template-columns: minmax(0, 1fr); }
  .lobby-scroll { padding: 16px; }
  .lobby-title { font-size: 26px; }
}
@media (max-width: 959px) {
  .speed-btn { padding: 5px 7px; }
  .calendar-date { font-size: 14px; }
  .pill { padding: 4px 7px; }
}

/* --- the right rail becomes a drawer -------------------------------------- *
   Below 1280 the chronicle, the powers legend and the minimap stop competing
   with the map for permanent space: they slide in over it from the right and
   `--col-w` falls to zero, so the camera fits the map to the whole width. */
@media (max-width: 1279px) {
  :root { --col-w: 0px; --rail-w: min(340px, 92vw); }
  .column-right {
    transform: translateX(calc(100% + 14px));
    transition: transform 180ms ease;
    box-shadow: none;
  }
  body.chronicle-open .column-right { transform: none; }
  /* With the drawer out, the command bar gives it the ground rather than
     disappearing behind it. */
  body.chronicle-open .command-bar { max-width: calc(100% - var(--rail-w) - 24px); }
  body.chronicle-open .toasts { right: calc(var(--rail-w) + 24px); }
}

/* --- short windows -------------------------------------------------------- */
/* `--resource-h` used to be squeezed to 42px here. It is set by the compact
   block in "stockpile tiers" instead, which this query is one half of: a bar
   with a disc in it cannot be 42px tall, and a height set here would have won
   on specificity and clipped the discs out of their own tiles. */
@media (max-height: 860px) {
  :root { --cmd-h: 230px; }
}
@media (max-height: 720px) {
  :root { --cmd-h: 212px; }
}

/* --- narrow: the top bar has to choose what it is for ---------------------
   Measured on a 390 px phone: `.topbar-right`'s nine icon buttons take **301 of
   the bar's 372 px** and `.topbar-right` is `flex: 0 0 auto`, so it never gives
   any of it back. `.topbar-center` was left **29 px for 345 px of content**
   (calendar 209 + speed 126) with `overflow: hidden` and nothing scrolling it —
   so **pause, 1x, 2x and 4x were all unreachable in a real-time game**, and the
   faction banner was clipped to 10 px beside them.

   The speed control never shrinks, because stopping the clock is the one thing
   a player must always be able to do. The calendar gives way first — the date
   is a reference, not a control. The nine icons shrink and scroll: they are map
   modes, help, music and the like, and a scroll to reach the music button is a
   fair price for a pause button that works. */
@media (max-width: 860px) {
  .topbar-center {
    flex: 1 1 auto;
    min-width: 0;
  }
  .topbar-center .calendar {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
  }
  .topbar-center .speed { flex: 0 0 auto; }
  .topbar-right {
    flex: 0 1 auto;
    min-width: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    /* **`flex-end` plus an overflow is unreachable content, not a scroller.**
       The base rule packs these icons to the right, which is right while there
       is spare room and is a trap once there is not: an over-full flex line
       with `justify-content: flex-end` overflows past its **start** edge, and a
       scroller cannot reach a negative scroll offset. Measured at 390x844 on a
       real-phone profile: `.topbar-right` was 135 px wide holding 294 px of
       icons, and reported `scrollWidth === clientWidth === 135` — no scrollbar,
       no scrollable range, and the chronicle, map-mode, diplomacy and market
       buttons laid out at x 79..237, clipped away by this element's own
       `overflow-x` and hit-testing to the speed button behind them. That is
       exactly the four buttons a player on an iPhone reported missing.
       Packing to the start puts the overflow on the end, where the scroll is. */
    justify-content: flex-start;
  }
  .topbar-left { flex: 0 1 auto; }
}

/* --- narrow: the command bar takes the whole width ------------------------ */
@media (max-width: 1023px) {
  .cmd-act { width: min(560px, calc(100vw - 500px)); }
  .cmd-info,
  .cmd-switch { width: 420px; }
  .cmd-id { width: 148px; }
  .tile { width: 146px; }
  .cmd-stats { gap: 3px 9px; }
  .cmd-unit { min-width: 44px; }
  .cmd-gauge-track { width: 56px; }
}
@media (max-width: 739px) {
  /* **This block used to do nothing it said.** `.cmd-pane` is a *grid*
     (`grid-template-columns: auto minmax(0, 1fr)` above), and `flex-wrap` on a
     grid container and `flex` on a grid item are both inert. So `.cmd-info`
     kept the whole `auto` track and `.cmd-act` got the `minmax(0, 1fr)`
     remainder — measured at **22x212 on a 390 px phone**, holding 134x210 of
     content, with its Build / Levy / Taxes tabs rendering at x 377..495 on a
     390 px screen and no scrollable ancestor. The economy was unreachable on a
     phone in either orientation, and the rule that was supposed to prevent it
     had been inert since it was written.

     One column, so the card and the control panel stack instead of competing
     for a row that is not wide enough for either. */
  .cmd-pane {
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
  }
  .cmd-info,
  .cmd-switch { width: 100%; }
  /* The controls are what a phone came for; the figures are a reference. Cap
     the card and let it scroll rather than letting it push the panel out. */
  .cmd-info {
    max-height: 38%;
    overflow-y: auto;
  }
  .cmd-act {
    width: 100%;
    min-width: 0;
    height: auto;
    justify-self: stretch;
  }
  .cmd-id-sub { -webkit-line-clamp: 1; }
}

/* ---------- live campaign progress --------------------------------------- */

.progress-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin-bottom: 14px; }
.progress-card { border: 1px solid var(--rule); border-radius: var(--radius-sm); padding: 9px 10px 7px; background: rgba(255, 253, 245, 0.42); }
/* Faction goals (docs/DESIGN.md §8.1): what decides the campaign at the clock,
   so the card spans the row above the conquest paths, its goals on one line. */
.progress-goals { grid-column: 1 / -1; }
.goal-list { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 4px 0 2px; padding: 0; list-style: none; font-size: 13px; }
.goal-list .is-met { color: var(--good, #3f6b2a); font-weight: 600; }
.goal-list .is-open { color: var(--ink-faint); }
.progress-card > strong { display: block; margin-top: 3px; font-family: var(--font-head); font-size: 15px; }
.progress-card .meter { margin-bottom: 0; }
.progress-standings .is-you { background: rgba(168, 132, 44, 0.18); }
.progress-standings [data-out="1"] { opacity: 0.52; }
/* The Academy's frame (technology.css `.research-window`): parchment board on
   the left, the dark `.perk-detail` side panel with the chart on the right. */
#progressRoot { --modal-pad: clamp(20px, 5vmin, 56px); padding: var(--modal-pad); }
.progress-layout { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 18px; }
.progress-board {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  padding: 14px 16px;
  color: #453b29;
  background: radial-gradient(ellipse at 50% 45%, #f5ecd4, #d7c5a0);
  border: 1px solid #a9945a;
  border-radius: 3px;
  box-shadow: inset 0 0 40px #93794d22;
}
.progress-board .progress-standings { margin-bottom: 0; }
/* Ten powers on one page: the frame is a fixed height and pages, not scrolls. */
.progress-board .progress-standings :is(th, td) { padding-top: 3px; padding-bottom: 3px; }
.progress-board .progress-card { padding: 7px 10px 5px; }
.progress-board .progress-summary { margin: 0 0 10px; color: var(--ink-soft); font-size: 14px; text-align: left; }
.progress-leader strong { display: inline-flex; align-items: center; gap: 6px; }
.progress-leader small { margin-left: 2px; }
.progress-board .progress-cards { margin-bottom: 10px; }
.research-window .progress-board .meter-head { color: var(--ink-soft); }
.progress-side { display: flex; flex-direction: column; gap: 10px; overflow: hidden; }
.progress-side .progress-chart { margin: 0; padding: 8px 0 0; }
.progress-side .progress-chart svg { display: block; height: auto; }
.progress-side .chart-grid { stroke: rgba(233, 221, 195, 0.16); }
.progress-side .chart-label { fill: #a6b0a9; }
.progress-side .legend { gap: 6px 12px; color: #e9ddc3; font-size: 11.5px; }
.progress-side .legend-item i { height: 4px; width: 14px; }
.research-window .progress-side .progress-note { margin: 0; padding-top: 10px; border-top: 1px solid #a9945a33; color: #d7c999; font-size: 12px; line-height: 1.55; text-align: left; }
.progress-side .progress-fog { color: #a6b0a9; }
.research-window .progress-side .muted { margin: 0; }

@media (max-width: 600px) { #progressRoot { --modal-pad: 6px; } }
@media (max-width: 900px) {
  .progress-layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; gap: 10px; }
  .progress-side { max-height: 34dvh; gap: 6px; padding: 10px 12px; }
  .progress-side .progress-chart svg { max-height: 16dvh; }
  .progress-side .progress-fog { display: none; }
}

@media (max-width: 780px) {
  .progress-cards { grid-template-columns: 1fr; }
  .progress-standings th:nth-child(4), .progress-standings td:nth-child(4) { display: none; }
}

/* ===================================================================   Campaign battles: the prompt cards, and the tactical view.
   The prompts are parchment like the rest of the chrome. The view is not — it
   is a different place, dark so the field's own colours (docs/BATTLE.md) are
   the brightest thing on the screen, with parchment only on the strip that
   ties it back to the campaign.
   ========================================================================== */

.battle-prompts {
  position: absolute;
  top: var(--chrome-top);
  left: 8px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 296px;
  max-height: calc(100% - var(--chrome-top) - var(--cmd-clear));
  overflow-y: auto;
  pointer-events: none;
}
.battle-prompts[hidden] { display: none; }

.bp-card {
  pointer-events: auto;
  background: var(--paper);
  background-blend-mode: var(--paper-blend);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  box-shadow: var(--panel-shadow);
  padding: 9px 10px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
/* A decision has a deadline, so it says so with a gold edge; the rest do not. */
.bp-decide { border-left: 4px solid var(--gold-bright); }
/* A battle at the walls is said in words in the note; the card only tints. */
.bp-card.is-walled { background-color: rgba(163, 51, 38, 0.05); }

/* A siege is not a question, so it carries no gold edge — but it is the slowest
   thing on the map and the one a player most often loses track of, so it keeps a
   card of its own here for as long as it runs. */
.bp-siege { border-left: 4px solid var(--rule-strong); }
.bp-siege.is-stalled { border-left-color: var(--warn); }
.bp-siege.is-breached { border-left-color: var(--bad); }
.bp-siege-bar {
  height: 6px;
  border-radius: 4px;
  background: rgba(43, 35, 24, 0.14);
  overflow: hidden;
}
.bp-siege-bar > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #6d9a5c, var(--good));
  transition: width 240ms ease;
}
.bp-siege.is-stalled .bp-siege-bar > span { background: linear-gradient(90deg, #d9a94d, var(--warn)); }
.bp-siege.is-breached .bp-siege-bar > span { background: linear-gradient(90deg, #c8563f, var(--bad)); }

.bp-head { display: flex; align-items: baseline; gap: 8px; }
.bp-place { font-family: var(--font-head); font-size: 15px; flex: 1; text-align: left; min-width: 0; }
.bp-clock {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--ink-soft);
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(168, 132, 44, 0.18);
}
.bp-clock.is-urgent { color: #7b2519; background: rgba(163, 51, 38, 0.2); }

.bp-sides { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 6px; }
.bp-vs { font-size: 11px; color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.06em; }
.bp-side { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.bp-owner {
  font-size: 12px;
  font-weight: 600;
  color: var(--faction, var(--ink));
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bp-total { font-size: 17px; font-family: var(--font-head); line-height: 1; }
.bp-arms { display: flex; flex-wrap: wrap; gap: 5px; font-size: 11px; color: var(--ink-soft); }
.bp-arm { display: inline-flex; align-items: center; gap: 2px; font-variant-numeric: tabular-nums; }
.bp-note { margin: 0; font-size: 11.5px; color: var(--ink-soft); }
.bp-actions { display: flex; gap: 6px; }
.bp-actions .btn { flex: 1; }

/* ---- the view ---------------------------------------------------------- */

.battle-root {
  position: absolute;
  inset: 0;
  z-index: 120;
  display: flex;
  flex-direction: column;
  background: #14120c;
  color: #efe6cf;
  font-size: 13px;
}
.battle-root[hidden] { display: none; }

.sound-toggle { flex-shrink: 0; white-space: nowrap; }
/* One size for the small menu controls (Sign in, Mute, Fullscreen, EN/TR). */
.account-signin, .sound-toggle, .fullscreen-toggle, .lang-switch {
  box-sizing: border-box; height: 40px; min-height: 40px; border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; justify-content: center;
}
.account-signin, .sound-toggle, .fullscreen-toggle { padding: 0 14px; font: 500 13px/1 var(--font-body); white-space: nowrap; }
/* The language switch (i18n/index.js): two letters per language, the chosen
   one inked in. It sits beside Mute in the lobby and in the campaign menu. */
.lobby-toggles { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.lang-switch { display: inline-flex; flex-shrink: 0; border: 1px solid var(--rule-strong); border-radius: var(--radius-sm); overflow: hidden; }
.lang-btn {
  min-width: 40px;
  height: 100%;
  padding: 0 10px;
  font: 600 13px/1 var(--font-body);
  letter-spacing: 0.06em;
  color: inherit;
  background: transparent;
  border: 0;
  opacity: 0.72;
  cursor: pointer;
}
.lang-btn:hover { opacity: 1; }
.lang-btn + .lang-btn { border-left: 1px solid var(--rule-strong); }
/* Gold reads as "chosen" on the dark lobby and on the parchment menu alike. */
.lang-btn.is-active { color: var(--ink); background: var(--gold-bright); opacity: 1; cursor: default; }
.lang-btn:focus-visible { outline: 2px solid var(--gold-bright); outline-offset: -2px; }
.hud-menu-lang { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.hud-menu-lang .lang-btn { min-height: 34px; }
/* The map underneath keeps running; it simply must not be reachable. */
body.battle-open .command-bar,
body.battle-open .battle-prompts { pointer-events: none; }

.bv-strip {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 14px;
  background: var(--paper);
  background-blend-mode: var(--paper-blend);
  color: var(--ink);
  border-bottom: 2px solid rgba(0, 0, 0, 0.5);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
}
.bv-when, .bv-place { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.bv-when strong, .bv-place strong { font-family: var(--font-head); font-size: 15px; }
.bv-when span, .bv-place span { font-size: 11px; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.bv-when .bv-clock-warn { color: #e0b04a; font-style: normal; font-weight: 700; }

.bv-armies { display: flex; align-items: center; gap: 10px; }
.bv-army { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; gap: 0 6px; align-items: center; }
.bv-swatch {
  grid-row: span 2;
  width: 11px;
  height: 11px;
  border-radius: 3px;
  background: var(--mark);
  border: 1px solid rgba(0, 0, 0, 0.45);
}
.bv-army-name { font-weight: 600; font-size: 13px; }
.bv-army-role { font-size: 10.5px; color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.05em; }
.bv-versus { font-size: 11px; color: var(--ink-faint); }
/* The eye's two views. Pressed means the oblique one, which is also the one the
   view opens in, so the lit state is the resting state and the plain button is
   the deliberate choice — the opposite of most toggles, and right here, because
   the label changes with it and says which view you are in rather than which one
   the button would give you. */
.bv-angled.is-on { border-color: var(--gold); color: var(--gold); }
.bv-speed { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-soft); }
.bv-speed .input { padding: 4px 6px; }

.bv-body { flex: 1; display: flex; min-height: 0; }
.bv-field {
  flex: 1;
  min-width: 0;
  /* The positioning box for the unit bar, which floats over the bottom of the
     field rather than taking a row of its own (public/battle/ui/unitBar.css). */
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Letterboxing: the field keeps its aspect, the bars are the ground it is on. */
  background: radial-gradient(120% 100% at 50% 0%, #221f16, #0d0c08);
  overflow: hidden;
}
.bv-canvas { display: block; cursor: crosshair; box-shadow: 0 0 40px rgba(0, 0, 0, 0.7); }
/* The `?battledebug` meter (battleView.js `perfOn`): one line of figures over
   the field's top-left, out of the way of every control, for reading frame
   cost off a real device. */
.bv-perf {
  position: absolute;
  top: 6px;
  left: 8px;
  z-index: 3;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  background: rgba(10, 9, 6, 0.72);
  color: #cfe8b8;
  font: 500 11px/1.5 var(--font-body);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

.bv-result {
  position: absolute;
  z-index: 50;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 9, 6, 0.66);
  backdrop-filter: blur(2px);
}
.bv-result[hidden] { display: none; }
.bv-result-card {
  width: min(520px, 92vw);
  background: var(--paper);
  background-blend-mode: var(--paper-blend);
  color: var(--ink);
  border: 1px solid var(--rule-strong);
  border-top: 4px solid var(--ink-faint);
  border-radius: var(--radius);
  box-shadow: var(--panel-shadow);
  padding: 18px 20px;
}
.bv-result-card.is-won { border-top-color: var(--good); }
.bv-result-card.is-lost { border-top-color: var(--bad); }
.bv-result-card h2 { font-family: var(--font-head); font-size: 22px; margin: 0 0 6px; }
.bv-result-summary { margin: 0 0 12px; color: var(--ink-soft); }
.bv-result-tactic { margin: 6px 0; font-size: 12px; line-height: 1.4; }
.bv-result-table { width: 100%; border-collapse: collapse; margin-bottom: 10px; }
.bv-result-table th, .bv-result-table td { padding: 5px 4px; border-bottom: 1px solid var(--rule); }
.bv-result-table thead th { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-faint); }
.bv-result-table .right { text-align: right; font-variant-numeric: tabular-nums; }
.bv-result-table .bv-swatch { display: inline-block; vertical-align: middle; margin-right: 5px; }

/* Narrow windows: the strip wraps rather than crushing its parts. */
@media (max-width: 1180px) {
  .bv-strip { flex-wrap: wrap; gap: 6px 12px; }
  .bv-when, .bv-place, .bv-armies, .bv-speed, .bv-leave { flex-shrink: 0; }
  .bv-body { flex-direction: column; }
  .bv-field { min-height: 0; }
  .battle-prompts { width: 250px; }
}

/* The long form of the leave button is the desktop's; the phone gets the short
   one. `battleView.js` writes both and this picks. */
.bv-leave-short { display: none; }

/* **A battle on a phone held upright.** A player on a real iPhone reported the
   header printed over itself, a battlefield the size of a postage stamp and a
   wall of text under it. Measured at 390x844 on the phone profile, all of it
   true and worse than it reads:

   * `.bv-strip` is `flex-wrap: nowrap`, so it crushed rather than wrapped:
     `.bv-when` and `.bv-place` both computed **0 px wide** with `min-width: 0`,
     and their text spilled out of boxes that no longer existed — which is the
     date printed over the province name. The strip's content measured 622 px in
     a 390 px box, and **Angled, Recentre and the leave button all laid out past
     the right edge** at x 376..622: unreachable, including the only way out of
     a battle.
   * The field was **390x309** of an 844 px screen while `.bv-hud` under it took
     **410** — half the screen of text, 237 px of which was mouse-only prose
     (`battleView.js commandingNote`, now swapped on `coarsePointer()`).
   * `.ub-commands` floated **156x250 over the field**, a third of it, and with
     `.ub-btn-label` hidden below 1100 px it read as a semi-transparent overlay
     of `A D S R F E` and `1 2 3` — a keyboard hint, to a player with no
     keyboard.

   Two rows for the strip, the hud's prose cut to gestures, and the unit bar
   flattened into a band along the foot of the field instead of a slab across
   its flank. */
@media (max-width: 480px) {
  .bv-strip {
    flex-wrap: wrap;
    gap: 6px 10px;
    padding: 6px 10px;
  }
  /* Row one is who and the way out; row two is the pace and the eye. The
     campaign date and the two sides both say things the screen already says —
     the date is on the map behind this overlay and the sides are the meters,
     which give the same two names with their strength and morale under them. */
  .bv-when,
  .bv-armies { display: none; }
  /* **The place name takes the whole first row, by a basis of `100%` rather
     than by growing into it.** A flex line breaks on an item's *hypothetical*
     main size, so `flex: 1 1 auto` here filled row one and then pushed the pace,
     the two eye buttons and the leave button onto a row each: measured, a
     147 px strip in three rows, taller than the 125 px crush it replaced. Named
     as a full row, it is one row, and the four controls share the second. */
  .bv-place { flex: 1 0 100%; }
  .bv-place strong,
  .bv-place span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .bv-speed .input { min-width: 0; }
  .bv-angled,
  .bv-recentre,
  .bv-leave { flex: 0 1 auto; }
  .bv-leave-long { display: none; }
  .bv-leave-short { display: inline; }
}

/* The unit bar's own phone layout is in `public/battle/ui/unitBar.css`, which is
   the one stylesheet both battle surfaces load. */

/* The battle block at the head of a province's Overview tray. */
.cmd-battle {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 7px 8px;
  margin-bottom: 6px;
  border: 1px solid var(--rule-strong);
  border-left: 4px solid var(--bad);
  border-radius: var(--radius-sm);
  background: rgba(163, 51, 38, 0.07);
}
.cmd-battle .bp-total { font-size: 15px; }
.cmd-battle .cmd-tray-note { margin: 0; }

/* Second line of a battle toast: the figures under the sentence. */
.toast-sub {
  display: block;
  margin-top: 2px;
  font-size: 11.5px;
  opacity: 0.8;
  font-variant-numeric: tabular-nums;
}

/* ====================================================================   Buildings, the muster, the siege and province-pane diplomacy
   ====================================================================   Four additions to the command bar, all of them answering the same complaint:
   the pane held the numbers but not the reasons. What a building buys, what an
   order actually costs in total, what a siege is doing, and where a faction
   stands with you were each one hover or one modal away from being read. */

/* --- the slot rack -------------------------------------------------------- */
/* A province holds as many buildings as its population allows (DESIGN §6.5), and
   the build tray is that rack: one card per slot, side by side, each either a
   building that stands there or an empty plot. The flat wall of fifteen tiles it
   replaced showed everything the game has and nothing about what this town has
   room for. Choosing what fills a plot happens under the rack, in two steps —
   benefit, then building — so nothing stacks. */
/* The rack is the index of the province, so it stays put while the options for
   the open slot scroll under it. The command bar is only ~130 px tall and the
   picker's tiles are taller than that on their own; without this the rack
   scrolled away the moment a slot was chosen and the player lost the thing they
   were choosing for. The band needs an opaque ground of its own — the bar behind
   it is a gradient, not a flat colour. */
.slot-top {
  /* Never shrinks: `anchorTree` measures a popover's offset against this band,
     so a band narrower than the panel pins the popover to the wrong place. */
  flex: 0 0 100%;
  min-width: 0;
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--parchment);
  box-shadow: 0 3px 6px -4px rgba(10, 16, 22, 0.5);
}
/* The plaque: the settlement's name on a dark band over its row of plots, the
   tier and head-count beside it, and a roundel at the end saying how many plots
   are taken. The rack under it is the index of the province and stays put
   while the picker scrolls beneath. */
.slot-plaque {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 5px;
  padding: 3px 4px 3px 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(43, 35, 24, 0.82), rgba(43, 35, 24, 0.62) 60%, rgba(43, 35, 24, 0.3));
  color: var(--parchment);
  box-shadow: inset 0 1px 0 rgba(255, 253, 245, 0.18), 0 1px 2px rgba(10, 16, 22, 0.3);
}
.slot-plaque-name {
  font: 700 12px/1 var(--font-head);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.slot-plaque .slot-why { flex: 1; min-width: 0; color: rgba(242, 231, 205, 0.7); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slot-roundel {
  flex: none;
  display: inline-flex;
  align-items: baseline;
  justify-content: center;
  min-width: 24px;
  height: 20px;
  padding: 0 7px;
  border-radius: 999px;
  border: 1px solid rgba(214, 176, 74, 0.7);
  background: rgba(214, 176, 74, 0.22);
  color: #ffe6a8;
  font: 700 11px/20px var(--font-body);
  font-variant-numeric: tabular-nums;
}
.slot-roundel small { font-size: 9px; font-weight: 400; opacity: 0.75; }
.slot-why { font-size: 11px; color: var(--ink-faint); }

/*
 * The plots wrap. A great city has a dozen of them and a single row ran off
 * the right edge of the panel and out from under its own border; wrapped, the
 * whole holding is one shape you read at a glance and nothing leaves the card.
 * The cards are narrow enough that eight fit a row, so even twelve plots plus
 * walls and roads is two rows.
 */
.slot-rack {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 1px 0 5px;
  border-bottom: 1px solid var(--rule);
  /* **The rack sticks; the band it sits in does not.** `.slot-top` used to carry
     this, and `f12355a` had to make it `position: static` so the plot picker's
     containing block would climb above `.cmd-tray`'s clip — which silently took
     the stickiness with it, on every device. The band's own comment says what
     that costs: "the rack scrolled away the moment a slot was chosen and the
     player lost the thing they were choosing for."
     Moving it down one level gives both: the rack is not the picker's
     containing block, so making it sticky changes nothing about where the
     picker opens, and the tray still scrolls under a rack that stays put. */
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--parchment);
}
.cmd-act .slot-rack {
  background: linear-gradient(180deg, rgba(238, 227, 201, 0.99), rgba(233, 220, 190, 0.99));
}
/* A plot is a picture card: the building's device in a framed picture, tinted
   by what kind of building it is, the name under it and the level as pips.
   Narrow on purpose — nine plots have to read side by side. */
.slot {
  --plot: rgba(43, 35, 24, 0.3);
  flex: none;
  position: relative;
  width: 68px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 3px 3px 4px;
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  background: rgba(255, 252, 240, 0.5);
  color: var(--ink-soft);
  font: inherit;
  cursor: pointer;
}
.slot:hover { background: rgba(168, 132, 44, 0.16); }
/* Not yours: the rack still reads, but a gold dashed "Empty plot" on a province
   you do not hold is an invitation to press something that cannot be pressed.
   The panel already says why in words; this stops the card arguing with it. */
.slot-top.is-locked .slot { opacity: 0.55; }
.slot-top.is-locked .slot-empty { border-style: solid; }
.slot.is-active {
  border-color: var(--gold);
  background: rgba(168, 132, 44, 0.16);
  box-shadow: 0 0 0 1px var(--gold);
}
.slot-pic {
  width: 100%;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  border: 1px solid var(--plot);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--plot) 30%, transparent), color-mix(in srgb, var(--plot) 8%, transparent)),
    rgba(255, 253, 245, 0.5);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px rgba(255, 253, 245, 0.35);
}
.slot.is-built .slot-pic { color: #5a4210; }
.slot[data-category='growth'] { --plot: #4f7a44; }
.slot[data-category='wealth'] { --plot: #b8862c; }
.slot[data-category='military'] { --plot: #a33326; }
.slot[data-category='defence'] { --plot: #55606b; }
.slot[data-category='works'] { --plot: #2c6072; }
.slot-empty {
  border-style: dashed;
  background: none;
  color: var(--ink-faint);
}
.slot-empty .slot-pic { border-style: dashed; background: none; box-shadow: none; }
.slot-plus {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid var(--rule-strong);
  font-size: 15px;
  line-height: 1;
  color: var(--ink-faint);
}
.slot-empty:hover .slot-plus,
.slot-empty.is-active .slot-plus { border-color: var(--gold); color: var(--ink); background: rgba(168, 132, 44, 0.2); }
.slot-walls,
.slot-roads { background: rgba(43, 35, 24, 0.02); }
/* Roads carry a fraction rather than pips: a province has as many roads as it
   has neighbours, and five pips per road would not fit a 70 px card. */
.slot-frac { font: 700 10px/1 var(--font-body); font-variant-numeric: tabular-nums; color: var(--ink); }
.slot-frac small { font-weight: 400; font-size: 9px; color: var(--ink-faint); }
/* Rising: dotted frame, days left as the tag, the picture ghosted until it stands. */
.slot.is-rising { border-style: dotted; }
.slot.is-rising .slot-pic { opacity: 0.55; }
.slot-name {
  font-size: 10px;
  line-height: 1.15;
  text-align: center;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* "no slot" on the walls card and the days left on one that is rising. */
.slot-tag {
  position: absolute;
  top: -1px;
  right: 3px;
  padding: 0 4px;
  border-radius: 0 0 3px 3px;
  font-size: 8.5px;
  letter-spacing: 0.02em;
  background: rgba(43, 35, 24, 0.75);
  color: var(--parchment);
  z-index: 1;
}
.slot .pips { gap: 2px; }
.slot .pip { width: 7px; height: 5px; }

/* --- the roads plot ------------------------------------------------------ *
   A province's roads are one holding. The head raises every road that can be
   raised in a single press with the whole bill on it; the list under it is
   one dense row per neighbour for the times you want only one of them.
   -------------------------------------------------------------------------- */
.roadwork-head { display: flex; align-items: center; gap: 8px; }
.roadwork-bill { font-size: 10.5px; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.roadlist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.roadrow {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto minmax(72px, auto) auto;
  align-items: center;
  gap: 7px;
  padding: 2px 4px;
  border-radius: var(--radius-sm);
  font-size: 11px;
}
.roadrow:nth-child(odd) { background: rgba(43, 35, 24, 0.045); }
.roadrow.is-blocked { opacity: 0.55; }
.roadrow-name { font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.roadrow-cost { font-size: 10px; color: var(--ink-faint); text-align: right; font-variant-numeric: tabular-nums; }
.roadrow .fact { padding: 0 6px; font-size: 9.5px; }
.roadrow .btn-small { padding: 2px 8px; font-size: 10.5px; }

/* --- the plot tree ------------------------------------------------------- *
   Clicking an empty plot opens this from the card itself: the benefits down
   the left, the buildings of the open benefit down the right. It floats over
   the panel — `--tree-left` puts it under its own plot, `--tree-point` puts
   the little pointer on that plot's centre — so choosing what to raise never
   scrolls anything.
   -------------------------------------------------------------------------- */
/* **Static on purpose.** This was `relative`, which made the band the plot
   picker's containing block — and the band is inside `.cmd-tray`'s scroller, so
   the picker was clipped out of existence. The picker anchors to `.cmd-act`
   now; see the note there. (The `sticky` this overrides, from the band's own
   rule above, has never taken effect for the same reason it was overridden.) */
.slot-top { position: static; }
.plot-tree {
  position: absolute;
  /* Upward, and measured against the panel rather than the rack: the panel sits
     on the floor of the screen, so a tree hanging below its own plot opens off
     the bottom of the window; above the panel it floats over the map, which is
     the only free space there is. `100%` is the panel's height now, so the gap
     is a plain constant and no longer has to be computed in JS. */
  bottom: calc(100% + var(--tree-gap, 10px));
  left: var(--tree-left, 0px);
  z-index: 6;
  display: grid;
  grid-template-columns: 148px minmax(210px, 1fr);
  width: 408px;
  padding: 5px;
  gap: 5px;
  border-radius: 10px;
  border: 1px solid rgba(63, 48, 25, 0.45);
  background-image: var(--paper);
  background-blend-mode: var(--paper-blend);
  box-shadow: 0 14px 30px rgba(10, 16, 22, 0.38), inset 0 0 0 1px rgba(150, 116, 44, 0.25);
}
/* **No wider than its panel on a narrow phone.** At 320 px the 408 px tree ran
   to x 411 of a 320 px screen, and its buildings were off the glass
   (18 November 2026, `check-campaign-guide.mjs`). It is positioned against the
   panel, so `100%` is the panel's width; the category column narrows with it. */
@media (max-width: 440px) {
  .plot-tree { width: 100%; grid-template-columns: minmax(96px, 38%) minmax(0, 1fr); }
}
/* The pointer, on the plot the tree belongs to. */
.plot-tree::before {
  content: '';
  position: absolute;
  bottom: -6px;
  left: calc(var(--tree-point, 40px) - 6px);
  border: 6px solid transparent;
  border-bottom: 0;
  border-top-color: #e9dcbe;
  filter: drop-shadow(0 1px 0 rgba(43, 35, 24, 0.24));
}
.tree-branches { display: flex; flex-direction: column; gap: 2px; }
.branch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 5px 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--ink-soft);
  font: 600 11px/1.2 var(--font-body);
  text-align: left;
  cursor: pointer;
}
.branch:hover { background: rgba(43, 35, 24, 0.07); color: var(--ink); }
.branch.is-open { background: var(--gold-bright); color: #221a08; }
.branch-art { width: 32px; height: 32px; flex: 0 0 32px; object-fit: contain; }
.branch-name { flex: 1; }
.branch-count { font-size: 9.5px; opacity: 0.7; font-variant-numeric: tabular-nums; }
.tree-leaves {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-left: 5px;
  border-left: 1px solid var(--rule);
}
/* Two lines, not three columns: the name and its price were fighting for the
   same 200 px and the name always lost. */
.leaf {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 2px 7px;
  padding: 4px 6px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--ink);
  font: 500 11.5px/1.2 var(--font-body);
  text-align: left;
  cursor: pointer;
}
.leaf:hover:not(:disabled) { background: rgba(168, 132, 44, 0.16); border-color: var(--gold); }
.leaf:disabled { opacity: 0.45; cursor: not-allowed; }
.leaf-pic { grid-row: span 2; display: flex; color: var(--ink-soft); line-height: 0; }
.leaf-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leaf-cost {
  font-size: 9.5px;
  line-height: 1.2;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.leaf:disabled .leaf-cost { color: var(--bad); }
.leaf.is-blocked .leaf-cost { color: var(--bad); }
.leaf[data-act="buildRequirement"] .leaf-cost { text-decoration: underline; text-underline-offset: 2px; }
.plot-tree.pick-card.requirement-card { max-height: min(480px, 65vh); overflow-y: auto; }
.requirement-card h3 { margin: 8px 0 4px; }

/* Walls and an already-built plot open in the same floating popover, but they
   are a single building tile rather than two columns of branches and leaves, so
   like the roads list they override the tree's grid. The tile brings its own
   width; the popover is only its frame. */
.plot-tree.pick-card {
  display: block;
  width: auto;
  min-width: 232px;
  max-width: 320px;
  padding: 7px 8px 8px;
  overflow: visible;
}
.plot-tree.pick-card .tile,
.plot-tree.pick-card .tile-building {
  width: auto;
  border: 0;
  background: none;
  padding: 0;
  box-shadow: none;
}
.plot-tree.pick-card .facts { margin-bottom: 5px; }

/* The roads popover is the same floating object as the plot tree and opens from
   the same rack, but it is one column of rows rather than two of branches and
   leaves — so it overrides the tree's grid rather than inheriting it. */
.plot-tree.roadwork {
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: 372px;
  padding: 7px 8px 8px;
  /* No scrollbar. Six neighbours is the most any province has — a head, six
     rows and the note come to about 250 px, and the popover opens upward into
     roughly 500 px of map — so it never needs one. */
  overflow: visible;
}

/* --- a building tile ----------------------------------------------------- */
/* Wider than the road and unit tiles because it now carries its effects as
   sentences; the icon takes the place of the second read of the name. */
.tile-building { width: 214px; gap: 4px; }
.b-badge {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--rule);
  background: rgba(43, 35, 24, 0.05);
  color: var(--ink-soft);
}
/* A building that already stands here is inked in gold rather than grey, so the
   tray says what the province *has* at a glance and not only what it may buy. */
.b-badge.is-built {
  color: #7a5a17;
  border-color: rgba(176, 137, 44, 0.55);
  background: rgba(214, 176, 74, 0.16);
}
.b-icon { display: block; }
.b-effects {
  list-style: none;
  margin: 1px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 10.5px;
  line-height: 1.3;
  color: var(--ink-soft);
}
.b-effects li { display: flex; gap: 4px; align-items: baseline; }
/* How far the effect reaches. "+12% gold here" and "+3% margin across the realm"
   are not the same purchase and must not read as the same line. */
.b-scope {
  flex: none;
  font-size: 8.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0 3px;
  border-radius: 2px;
  background: rgba(43, 35, 24, 0.1);
  color: var(--ink-soft);
}
.b-scope-faction { background: rgba(176, 137, 44, 0.22); color: #6f5314; }
.b-scope-army { background: rgba(70, 96, 122, 0.18); color: #33506b; }

/* --- the recruit bill ---------------------------------------------------- */
/* The three figures an order needs before it is given: what leaves the treasury
   in total, what it takes out of the province's manpower, and how long the men
   take to drill. Tabular numerals so the column lines up as the count changes. */
.recruit-bill {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.bill-row { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.bill-k { color: var(--ink-soft); }
.bill-v { text-align: right; font-weight: 600; }
.bill-v small { font-weight: 400; color: var(--ink-soft); }

/* --- the three drill bands ------------------------------------------------
   The rate a muster runs at depends on where the host is standing (city,
   hamlet, road — docs/DESIGN.md 6.6). All three are listed with the number each
   is worth today and the one in force is marked, because a muster that takes
   fifty days instead of eight is not something a longer progress bar teaches. */
.muster-bands {
  margin-top: 8px;
  border-top: 1px solid var(--rule);
  padding-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.muster-bands .bill-row.is-on {
  background: rgba(168, 132, 44, 0.12);
  border-left: 2px solid var(--gold);
  padding-left: 5px;
  margin-left: -7px;
  border-radius: 2px;
}
.muster-bands .bill-row.is-on .bill-k,
.muster-bands .bill-row.is-on .bill-v { color: var(--ink); }

/* --- the muster queue ---------------------------------------------------- */
.muster-queue { margin-top: 8px; border-top: 1px solid var(--rule); padding-top: 6px; }
.muster-queue ul { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.muster {
  display: grid;
  grid-template-columns: minmax(84px, auto) auto 1fr auto;
  align-items: center;
  gap: 8px;
  font-size: 11px;
}
.muster-count { font-variant-numeric: tabular-nums; color: var(--ink-soft); }
.muster-count strong { color: var(--ink); font-size: 12px; }
/* The order at the head of the queue is the one actually being drilled; the rest
   are waiting their turn, and saying so is the point of a queue. */
.muster:not(.is-drilling) { opacity: 0.62; }
.muster .meter { min-width: 90px; }

/* --- the siege card ------------------------------------------------------ */
.cmd-siege {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 7px 8px;
  margin-bottom: 6px;
  border: 1px solid var(--rule-strong);
  border-left: 4px solid #8a6a1f;
  border-radius: var(--radius-sm);
  background: rgba(176, 137, 44, 0.09);
}
.cmd-siege.is-stalled { border-left-color: var(--warn, #b8862c); }
.cmd-siege.is-breached { border-left-color: var(--bad); background: rgba(163, 51, 38, 0.1); }
.cmd-siege .cmd-tray-note { margin: 0; }
.cmd-siege .cmd-tray-note.muted { opacity: 0.75; font-style: italic; }
.siege-sides { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 6px; }
.cmd-siege .bp-total { font-size: 15px; }

/* --- diplomacy on the province pane -------------------------------------- */
.diplo-inline { display: flex; flex-direction: column; gap: 7px; }
.diplo-inline-head { display: flex; align-items: center; gap: 8px; }
.diplo-inline-head > span { display: flex; flex-direction: column; min-width: 0; }
.rel-badge {
  margin-left: auto;
  flex: none;
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--rule);
}
.rel-badge.rel-war { background: rgba(163, 51, 38, 0.16); color: #7d2418; border-color: rgba(163, 51, 38, 0.4); }
.rel-badge.rel-peace { background: rgba(43, 35, 24, 0.07); color: var(--ink-soft); }
.rel-badge.rel-alliance { background: rgba(30, 111, 82, 0.15); color: #145a41; border-color: rgba(30, 111, 82, 0.4); }
/* The dot on the closed Diplomacy tab: the standing, before the tab is opened. */
.rel-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 5px;
  border-radius: 50%;
  vertical-align: baseline;
  background: var(--ink-soft);
}
.rel-dot.rel-war { background: #a33326; }
.rel-dot.rel-peace { background: #9a9384; }
.rel-dot.rel-alliance { background: #1e6f52; }

/* The count on the diplomacy flag: proposals awaiting your answer if there are
   any, otherwise the number of wars you are in. The ring goes red while you are
   at war, because that is a state and not an event and the log scrolls away. */
.btn-icon { position: relative; }
.btn-icon.is-atwar { border-color: rgba(163, 51, 38, 0.65); box-shadow: inset 0 0 0 1px rgba(163, 51, 38, 0.3); }
.btn-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 15px;
  height: 15px;
  padding: 0 3px;
  border-radius: 999px;
  background: #6b6255;
  color: #fff;
  font-size: 9.5px;
  font-weight: 700;
  line-height: 15px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.btn-badge.is-urgent { background: #a33326; }

/* The protector line reads like the quarrels line, in the alliance ink. */
.faction-protector { margin: 0; font-size: 11px; color: var(--ink-faint); line-height: 1.35; }
.faction-protector-label {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 10px;
  opacity: 0.8;
  margin-right: 3px;
}
.faction-protector-label { color: var(--relation-alliance, #6f9f6a); }

/* ---- taxation (docs/DESIGN.md §6.7) --------------------------------------
   One self-contained block at the foot of the file, shared by the province
   panel's Taxes tray and the realm dial in the Treasury popover. The two draw the
   same four cards, so they share one rule set rather than two that drift. */
.text-warn { color: var(--warn); }

.tax-tray {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 6px;
  margin: 4px 0 8px;
}
.tax-tier {
  display: flex;
  flex-direction: column;
  gap: 3px;
  text-align: left;
  padding: 7px 9px;
  border: 1px solid var(--rule, rgba(0, 0, 0, 0.18));
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.04);
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.tax-tier:hover:not(:disabled) { background: rgba(255, 255, 255, 0.1); }
/* The province's tax tray: one row per tier so all four, the realm line and the
   revolt warning fit one page (it paged 1 / 3 at 1280x720). The realm tray in
   Treasury keeps its cards. */
.tax-tray:has(> .tax-row) { grid-template-columns: 1fr; gap: 3px; margin: 2px 0 4px; }
.tax-row {
  display: grid;
  grid-template-columns: minmax(64px, 1.1fr) minmax(58px, 1fr) minmax(52px, 0.9fr) minmax(70px, 1fr);
  align-items: center;
  gap: 6px;
  padding: 3px 7px;
  font-size: 11.5px;
  line-height: 1.25;
}
.tax-row .tax-name { font-size: 12px; white-space: nowrap; }
.tax-row > * { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tax-source { margin: 2px 0 0; font-size: 11px; }
.tax-source .btn { margin-left: 4px; padding: 1px 6px; }
.tax-tier:disabled { cursor: default; opacity: 0.55; }
.tax-tier.is-active {
  border-color: var(--good);
  box-shadow: inset 0 0 0 1px var(--good);
  background: rgba(79, 122, 68, 0.12);
}
.tax-name { font-weight: 600; font-size: 13px; }
.tax-name small { font-weight: 400; opacity: 0.7; }
/* The card's own scope — the same gesture sets one town's rate here and the
   whole realm's in Stores, and the two cards were identical (TODO §26). The
   receipt already says whose rate changed; the card now says it first. */
.tax-name .tax-scope {
  float: right;
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.tax-figures { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 11px; }
.tax-gold { color: var(--gold-ink, #8a6a1f); }
.tax-growth { color: var(--ink-faint); }
.tax-blurb { font-size: 11px; color: var(--ink-faint); line-height: 1.35; }

/* Heavier rates read hotter, so the rack is legible before it is read. */
.tax-heavy .tax-unrest { color: var(--warn); }
.tax-punitive { border-color: rgba(163, 51, 38, 0.45); }
.tax-punitive .tax-unrest { color: var(--bad); font-weight: 600; }
.tax-light .tax-unrest { color: var(--good); }

/* The warning a province gets before it rises. Deliberately the loudest card in
   the tray: a rebellion nobody saw coming is the most expensive surprise here. */
.tax-alarm {
  border: 1px solid var(--bad);
  border-left-width: 3px;
  border-radius: 4px;
  background: rgba(163, 51, 38, 0.1);
  padding: 8px 10px;
  margin-bottom: 8px;
}
.tax-alarm h4 { margin: 0 0 4px; font-size: 13px; color: var(--bad); }
.tax-alarm p { margin: 0 0 4px; font-size: 12px; }
.tax-alarm .btn { margin-top: 2px; }

.stores-tax { margin: 10px 0 4px; }
.stores-tax h4 { margin: 0 0 4px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; opacity: 0.75; }
.tax-tray-realm { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
/* --- The town charter (ui/province.js `charterCard`, docs/DESIGN.md §5.2) ---
   A hamlet's panel has to answer three questions before the order is given: how
   far it has grown, what it becomes, and what its town gives up for it. The bar
   is the first, the prose the second, and the sentence about the parent the
   third — which is the one a player must not discover afterwards. */
.charter-card { margin-top: 6px; padding: 8px 9px; border: 1px solid rgba(168, 132, 44, 0.35); border-radius: 4px; background: rgba(168, 132, 44, 0.06); }
.charter-card.is-ready { border-color: var(--gold); background: rgba(215, 167, 63, 0.12); }
.charter-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 11.5px; margin-bottom: 5px; }
.charter-head span { color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.charter-bar { height: 4px; border-radius: 2px; background: rgba(43, 35, 24, 0.14); overflow: hidden; }
.charter-bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), var(--gold-bright)); }
.charter-card p { margin: 6px 0 0; font-size: 10.5px; line-height: 1.4; color: var(--ink-faint); }
.charter-card .btn { margin-top: 7px; width: 100%; }
.charter-blocked { font-style: italic; }

/* ---------- the fog (render/fog.js, server/game/fog.js) -------------------- */

/* The note over a province the player cannot see into. Set apart from the card
   it sits on, because every number under it is a memory rather than a report. */
.cmd-fog-note {
  margin: 0 0 8px;
  padding: 6px 8px;
  font-size: 10.5px;
  line-height: 1.45;
  font-style: italic;
  color: var(--ink-faint);
  border-left: 2px solid rgba(143, 160, 173, 0.6);
  background: rgba(143, 160, 173, 0.12);
  border-radius: 3px;
}
.cmd-unexplored .cmd-fog-note { margin: 8px 0 0; }
/* No faction holds it as far as we know, so the chip carries no faction colour. */
.owner-chip-unknown {
  background: rgba(143, 160, 173, 0.18);
  border: 1px dashed rgba(143, 160, 173, 0.7);
  color: var(--ink-faint);
}
.cmd-info .owner-chip-unknown { color: var(--ink-soft); background: rgba(143, 160, 173, 0.2); }
/* Why the tallies on the progress card are short: they count what the player
   can see, and saying so is cheaper than a player counting cities by hand. */
.progress-fog {
  margin: 6px 0 0;
  font-size: 10.5px;
  line-height: 1.45;
  font-style: italic;
  color: var(--ink-faint);
}
/* ==== chapters ==== */
/* The campaign chapter, beside the calendar (docs/DESIGN.md §15). A small
   capped caption in the chapter's own tint; the tooltip carries the rest. */
.calendar-chapter {
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid rgba(107, 98, 85, 0.45);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft, #6b6255);
  background: rgba(255, 255, 255, 0.35);
  cursor: help;
  white-space: nowrap;
}
.calendar-chapter.chapter-opening { border-color: rgba(30, 111, 82, 0.55); color: #1e6f52; }
.calendar-chapter.chapter-rivalries { border-color: rgba(154, 118, 30, 0.6); color: #8a6a12; }
.calendar-chapter.chapter-crisis { border-color: rgba(163, 51, 38, 0.6); color: #a33326; }
.calendar-chapter.chapter-endgame {
  border-color: rgba(40, 32, 24, 0.7);
  color: #fff;
  background: #3a3028;
}

/* A chapter turning is a banner, not a line: wider, darker, gilt edge. */
.toast.toast-chapter {
  border-left: 4px solid #c9a227;
  background: #2f2822;
  color: #f4ecd8;
  max-width: 420px;
}
.toast.toast-chapter .toast-text { font-weight: 700; }
.toast.toast-chapter .toast-sub { color: #d9cfb8; }
/* ==== chronicle, advice, market ==== */
/* The exchange toggle that used to float over the strip's right end is gone;
   the exchange is a tab of the Market screen now. */
.resource-bar { padding-right: 8px; }
.log-faction {
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  background: rgba(255, 253, 245, 0.7);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 11px;
  padding: 2px 6px;
  max-width: 120px;
}
.advice-actions { display: inline-flex; gap: 6px; white-space: nowrap; opacity: 0.55; }
.advice-actions .link-btn { font-size: 11px; }
.advice-muted-row { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.advice-muted { font-size: 10.5px; }
.market-tabs { display: inline-flex; gap: 4px; }
.market-tab { position: relative; }
.market-tab .btn-badge[hidden] { display: none; }
/* ==== treaties ==============================================================
   The diplomacy panel's second half: how a faction remembers you (a word, never
   a number), the agreements running now, the answers other courts sent back,
   and the composer that writes a new offer. docs/DESIGN.md §13.
   ========================================================================== */

.attitude { font-weight: 600; text-transform: lowercase; }
.attitude-hostile { color: var(--bad); }
.attitude-wary { color: var(--warn); }
.attitude-neutral { color: var(--ink-faint); }
.attitude-friendly { color: var(--good); }
.attitude-trusted { color: var(--good); text-decoration: underline dotted; }

.treaty-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.treaty {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  padding: 6px 9px;
  border: 1px solid var(--rule);
  border-left: 3px solid var(--gold);
  border-radius: var(--radius-sm);
  background: rgba(255, 253, 245, 0.4);
  font-size: 12px;
}
/* Kinds that can pull you into a war are marked in the colour of one. */
.treaty-defensive_alliance, .treaty-joint_war { border-left-color: var(--bad); }
.treaty-head { display: flex; align-items: baseline; gap: 6px; }
.treaty-terms { color: var(--ink-soft); font-style: italic; }
.treaty-left { margin-left: auto; color: var(--ink-faint); font-variant-numeric: tabular-nums; white-space: nowrap; }
.treaty-call { flex-basis: 100%; color: var(--bad); font-weight: 600; }

/* An answer to an offer of ours, in the other court's own words. */
.diplo-replies { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
.diplo-replies li { padding-left: 10px; border-left: 2px solid var(--rule-strong); color: var(--ink-soft); }
.diplo-replies .is-yes { border-left-color: var(--good); }
.diplo-replies .is-no { border-left-color: var(--bad); }
.diplo-replies .quote { color: var(--ink); font-style: italic; }

.diplo-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 12px; }
.diplo-field { display: flex; flex-direction: column; gap: 3px; font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-faint); }
.diplo-field select, .diplo-field input {
  font: inherit;
  font-size: 12.5px;
  letter-spacing: normal;
  text-transform: none;
  color: var(--ink);
  padding: 4px 6px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-sm);
  background: rgba(255, 253, 245, 0.7);
}
.diplo-field input[type="number"] { width: 82px; font-variant-numeric: tabular-nums; }
.diplo-pair { display: flex; gap: 5px; }
/* ==== combat intel ==== */
/* The attack confirmation card (DESIGN §14, `ui/attackPreview.js`) and the
   account of a battle already fought (`ui/battleCard.js`). Both sit above the
   map and clear of the command bar; neither is an `.overlay`, because the
   campaign keeps ticking under them and Escape must reach the march arming. */

.attack-preview {
  position: absolute;
  right: 8px;
  top: var(--chrome-top);
  z-index: 62;
  width: 330px;
  max-height: calc(100% - var(--chrome-top) - var(--cmd-clear));
  overflow-y: auto;
}
.attack-preview[hidden] { display: none; }

.ap-card {
  background: var(--paper);
  background-blend-mode: var(--paper-blend);
  border: 1px solid var(--rule-strong);
  border-left: 4px solid var(--ink-faint);
  border-radius: var(--radius);
  box-shadow: var(--panel-shadow);
  padding: 10px 11px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ap-card.ap-good { border-left-color: var(--good); }
.ap-card.ap-warn { border-left-color: var(--warn); }
.ap-card.ap-bad { border-left-color: var(--bad); }

.ap-head { display: flex; align-items: baseline; gap: 8px; }
.ap-head h3 { margin: 0; font-size: 15px; flex: 1; }

.ap-sides { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; }
.ap-side { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.ap-side-them { text-align: right; align-items: flex-end; }
.ap-who {
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--faction, var(--ink-soft));
  font-weight: 700;
}
.ap-total { font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; }
.ap-arms { display: flex; flex-wrap: wrap; gap: 5px; font-size: 11px; color: var(--ink-soft); }
.ap-arm { display: inline-flex; align-items: center; gap: 2px; font-variant-numeric: tabular-nums; }

/* The band is the one thing a player should be able to read without stopping. */
.ap-odds { text-align: center; padding: 2px 6px; border-radius: var(--radius-sm); background: rgba(43, 35, 24, 0.07); }
.ap-band { display: block; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; font-weight: 700; }
.ap-ratio { display: block; font-size: 12px; font-variant-numeric: tabular-nums; color: var(--ink-soft); }
.ap-good .ap-band { color: var(--good); }
.ap-warn .ap-band { color: var(--warn); }
.ap-bad .ap-band { color: var(--bad); }

.ap-blurb { margin: 0; font-size: 12px; color: var(--ink-soft); }
.ap-facts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.ap-facts li { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; }
.ap-facts span { color: var(--ink-faint); }

.ap-modrow { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ap-mods ul { list-style: none; margin: 2px 0 0; padding: 0; }
.ap-mod { display: flex; justify-content: space-between; gap: 6px; font-size: 11px; line-height: 1.45; }
.ap-mod.is-good .ap-mod-v { color: var(--good); }
.ap-mod.is-bad .ap-mod-v { color: var(--bad); }
.ap-mod span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ap-mod-v { font-variant-numeric: tabular-nums; flex: none; }

.ap-reinf ul { list-style: none; margin: 2px 0 0; padding: 0; }
.ap-reinf li { display: flex; justify-content: space-between; gap: 6px; font-size: 11.5px; }
.ap-reinf-who { color: var(--faction, var(--ink-soft)); font-weight: 700; }
.ap-note { margin: 3px 0 0; font-size: 11px; color: var(--bad); }
.ap-actions { display: flex; gap: 6px; }

/* ---- the battle card and its banner ---- */

.battle-card-root { position: absolute; inset: 0; z-index: 74; pointer-events: none; }
.battle-card-root[hidden] { display: none; }

.bc-card {
  pointer-events: auto;
  position: absolute;
  left: 50%;
  /* Two pixels inside the shared clearance, which is where this card has
     always sat; it is the only one of the six that did not use the same 16. */
  bottom: calc(var(--cmd-clear) - 2px);
  transform: translateX(-50%);
  width: min(560px, calc(100% - 24px));
  background: var(--paper);
  background-blend-mode: var(--paper-blend);
  border: 1px solid var(--rule-strong);
  border-top: 4px solid var(--ink-faint);
  border-radius: var(--radius);
  box-shadow: var(--panel-shadow);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.bc-card.bc-win { border-top-color: var(--good); }
.bc-card.bc-loss { border-top-color: var(--bad); }
.bc-card.bc-draw { border-top-color: var(--gold); }

.bc-head { display: flex; align-items: baseline; gap: 8px; }
.bc-head h3 { margin: 0; font-size: 16px; flex: 1; }
.bc-why { margin: 0; font-size: 13px; line-height: 1.5; }

.bc-sides { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: start; }
.bc-vs { align-self: center; font-size: 12px; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.bc-who { font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--faction, var(--ink-soft)); font-weight: 700; }
.bc-arms { list-style: none; margin: 4px 0 0; padding: 0; }
.bc-arms li { display: grid; grid-template-columns: 16px 1fr auto auto; gap: 5px; font-size: 11.5px; align-items: center; }
.bc-arm-k { color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bc-arm-v, .bc-arm-l { font-variant-numeric: tabular-nums; }
.bc-arm-l.is-loss { color: var(--bad); }
.bc-side-foot { margin-top: 5px; display: flex; flex-direction: column; gap: 1px; font-size: 11.5px; color: var(--ink-soft); }

.bc-modrow { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.bc-mods { list-style: none; margin: 2px 0 0; padding: 0; }
.bc-mods li { display: flex; justify-content: space-between; gap: 6px; font-size: 11px; line-height: 1.45; }
.bc-mods li span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bc-mods li.is-good span:last-child { color: var(--good); }
.bc-mods li.is-bad span:last-child { color: var(--bad); }

@media (max-width: 900px) {
  .attack-preview { width: calc(100% - 16px); }
  .ap-modrow, .bc-modrow { grid-template-columns: 1fr; }
}

/* ==== decisions ==== */
/* The cards that ask a question (ui/decisions.js). Top centre of the map,
   clear of the battle prompts on the left and the chronicle on the right;
   the map underneath stays live, and a card folds to a pill. */
.decisions {
  position: absolute;
  top: var(--chrome-top);
  left: 50%;
  transform: translateX(-50%);
  z-index: 61;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(380px, calc(100% - 640px));
  min-width: 300px;
  max-height: calc(100% - var(--chrome-top) - var(--cmd-clear));
  overflow-y: auto;
  pointer-events: none;
}
.decisions[hidden] { display: none; }
.dc-card {
  pointer-events: auto;
  background: var(--paper);
  background-blend-mode: var(--paper-blend);
  border: 1px solid var(--rule-strong);
  border-left: 4px solid var(--gold-bright);
  border-radius: var(--radius);
  box-shadow: var(--panel-shadow);
  padding: 9px 10px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.dc-card.is-folded { padding: 0; border-left-width: 1px; }
.dc-head { display: flex; align-items: flex-start; gap: 8px; }
.dc-title { margin: 0; flex: 1; font-family: var(--font-head); font-size: 15px; line-height: 1.2; }
.dc-fold { flex: 0 0 auto; padding: 0 6px; line-height: 1.2; }
.dc-text { margin: 0; font-size: 12px; line-height: 1.4; color: var(--ink-soft); }
.dc-options { display: flex; flex-direction: column; gap: 5px; }
.dc-option {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
  text-align: left;
  padding: 6px 8px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  background: rgba(255, 250, 235, 0.55);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}
.dc-option:hover { border-color: var(--gold-bright); background: rgba(168, 132, 44, 0.12); }
.dc-option.is-default { border-style: dashed; }
.dc-option-label { display: flex; align-items: baseline; gap: 6px; font-weight: 600; font-size: 12.5px; }
.dc-default { margin-left: auto; font-weight: 400; }
.dc-option-summary { font-size: 11.5px; color: var(--ink-soft); line-height: 1.35; }
.dc-foot { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.dc-place { font-size: 12px; }
.dc-clock {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 11px;
  color: var(--ink-soft);
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(168, 132, 44, 0.18);
  white-space: nowrap;
}
.dc-clock.is-urgent { color: #7b2519; background: rgba(163, 51, 38, 0.2); }
body.battle-open .decisions { pointer-events: none; }
@media (max-width: 1100px) {
  .decisions { left: auto; right: 8px; transform: none; width: 300px; }
}
/* ==== client gaps ==== */
/* The recruit tile picker: one tile per arm in place of the <select> that could
   not carry the unit art. A radio group — the chosen tile is the one Tab lands
   on, the arrows walk the row. */

.recruit-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 0;
  padding: 5px 4px 4px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-sm);
  background: rgba(255, 250, 236, 0.35);
  color: var(--ink);
  font: inherit;
  font-size: 11px;
  line-height: 1.2;
  cursor: pointer;
}
.recruit-tile:hover { background: rgba(255, 250, 236, 0.6); }
.recruit-tile:focus-visible { outline: 2px solid var(--gold-bright); outline-offset: 1px; }
.recruit-tile.is-selected {
  border-color: var(--gold);
  background: rgba(168, 132, 44, 0.16);
  box-shadow: inset 0 0 0 1px var(--gold);
}
.muster-arm .unit-icon { display: inline-block; vertical-align: -3px; line-height: 0; }

/* ==== war planning ====
   The draft of orders (docs/DESIGN.md §16, ui/warPlan.js). It sits on the left,
   opposite the attack card on the right, because both can be up at once and the
   plan is a list you read down while the map is the thing you point at.
   ========================================================================== */

.war-plan {
  position: absolute;
  left: 8px;
  top: var(--chrome-top);
  z-index: 62;
  width: 340px;
  max-height: calc(100% - var(--chrome-top) - var(--cmd-clear));
  overflow-y: auto;
}
.war-plan[hidden] { display: none; }

.wp-panel {
  background: var(--paper);
  background-blend-mode: var(--paper-blend);
  border: 1px solid var(--rule-strong);
  border-left: 4px solid var(--gold);
  border-radius: var(--radius);
  box-shadow: var(--panel-shadow);
  padding: 10px 11px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.wp-head { display: flex; align-items: center; gap: 8px; }
.wp-head h3 { margin: 0; font-size: 15px; flex: 1; font-family: var(--font-head); }
.wp-head .tag.is-active { border-color: var(--gold); color: var(--gold); }
.wp-blurb { margin: 0; font-size: 11px; line-height: 1.45; color: var(--ink-soft); }

.wp-empty { padding: 10px 4px; font-size: 12px; line-height: 1.5; }
.wp-empty p { margin: 0 0 6px; }

.wp-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }

.wp-order {
  border: 1px solid var(--rule);
  border-left: 3px solid var(--ink-faint);
  border-radius: var(--radius-sm);
  padding: 6px 7px;
  background: rgba(255, 255, 255, 0.22);
}
.wp-order.wp-warn { border-left-color: var(--warn); }
.wp-order.wp-bad { border-left-color: var(--bad); }
.wp-order.is-retargeting { outline: 1px dashed var(--gold); }

.wp-order-head { display: flex; align-items: center; gap: 6px; }
.wp-num {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--parchment-3);
  border: 1px solid var(--rule-strong);
  font-size: 11px;
  font-weight: 700;
  display: grid;
  place-items: center;
}
.wp-title {
  flex: 1;
  min-width: 0;
  text-align: left;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  color: inherit;
  font: inherit;
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}
.wp-title strong { font-size: 12px; }
.wp-title span { font-size: 11px; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; }
.wp-tools { display: flex; gap: 1px; }
.wp-tools .btn { padding: 1px 4px; font-size: 12px; line-height: 1.1; }

.wp-facts { list-style: none; margin: 5px 0 0; padding: 0; display: grid; gap: 2px; font-size: 11px; }
.wp-facts li { display: flex; justify-content: space-between; gap: 8px; }
.wp-facts span { color: var(--ink-soft); }
.wp-good { color: var(--good); }
.wp-warn { color: var(--warn); }
.wp-bad { color: var(--bad); }

.wp-flag { margin: 4px 0 0; font-size: 11px; line-height: 1.4; }
.wp-note { margin: 4px 0 0; font-size: 11px; color: var(--gold); font-style: italic; }
.wp-summary { margin: 0; font-size: 11px; font-weight: 600; }

.wp-report { border-top: 1px solid var(--rule); padding-top: 6px; }
.wp-report ul { list-style: none; margin: 3px 0 0; padding: 0; font-size: 11px; display: grid; gap: 2px; }

.wp-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.wp-actions .btn-primary { flex: 1; }


body.battle-open .war-plan { display: none; }
@media (max-width: 1100px) {
  .war-plan { width: 300px; }
}

/* ==== comeback ==== */
/* **The block folds.** Drawn in full it runs about 950 px of a 2 280 px body and
   pushes the country list — the panel's spine — below it, which on a phone is
   two full screens down (TODO §6). A `<details>` costs a summary row instead,
   and keeps `docs/CLIENT.md`'s contract on the panel's order, which a reorder
   would have broken. The element lives in the panel's once-per-opening shell,
   not in the markup the clock rewrites, so the player's open/closed state
   survives a render; `diplomacy.js` decides `open` once per opening. */
.comeback-fold > summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
  /* The same 44 px floor every other control takes on a coarse pointer: a
     summary is a button in everything but name. */
  min-height: 44px;
  font-weight: 600;
  font-size: 12.5px;
  color: var(--ink);
}
.comeback-fold > summary::-webkit-details-marker { display: none; }
.comeback-fold > summary::before {
  content: '▸';
  color: var(--ink-faint);
  transition: transform 120ms ease;
}
.comeback-fold[open] > summary::before { transform: rotate(90deg); }

/* The comeback tools (docs/DESIGN.md §18). A closed tool is drawn, not hidden:
   the reason it is shut is the part the player has to be able to read. */
.comeback-standing {
  margin: 0 0 8px;
  font-size: 12px;
  color: var(--text-dim, #9aa3ad);
}
.comeback-standing.is-behind {
  color: var(--text, #e6e8ea);
  border-left: 3px solid var(--bad, #c05a4a);
  padding-left: 8px;
}
.comeback-list {
  display: grid;
  gap: 8px;
}
.comeback-item {
  border: 1px solid var(--line, #2a2f36);
  border-radius: 6px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.02);
}
.comeback-item.is-closed {
  opacity: 0.62;
}
.comeback-item.is-sworn {
  border-color: var(--warn, #c8a24a);
}
.comeback-item-head {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: space-between;
  margin-bottom: 4px;
}
.comeback-item p {
  margin: 0 0 6px;
}
.comeback-item .tag-open {
  color: var(--good, #6fae6a);
  border-color: currentColor;
}
.comeback-item .tag-shut {
  color: var(--text-dim, #9aa3ad);
}
.comeback-why {
  margin: 4px 0 0;
  font-style: italic;
}
.comeback-vassals,
.comeback-debts {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--text-dim, #9aa3ad);
}
.comeback-debts {
  padding-left: 18px;
}
/* The two blocks in the province command bar. */
.comeback-block {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed var(--line, #2a2f36);
}
.comeback-block.is-closed {
  opacity: 0.62;
}
.comeback-block .label {
  display: block;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim, #9aa3ad);
  margin-bottom: 4px;
}

/* The row the diplomacy rail sent you to. A ring rather than a fill: the row
   colours in this overlay already mean a relation, and a second meaning on the
   same surface would be read as one. */
.diplo-row.is-focused {
  outline: 2px solid var(--accent, #2f6fb5);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Standing on a diplomacy action card: their regard for you, and your weariness
   in the war with them. Tabular so the numbers can be compared down the column,
   and coloured only at the ends — a court at -4 is not "cold", it is indifferent,
   and colouring it would say something the number does not. */
.diplo-op { font-variant-numeric: tabular-nums; }
.diplo-op.is-warm { color: #2f9e77; }
.diplo-op.is-cold { color: #b03a2e; }

/* ==========================================================================
   The diplomacy country list (September 2026)
   --------------------------------------------------------------------------
   ONE APPENDED BLOCK, deliberately contiguous and at the foot of the file: the
   top bar's styles were being rewritten in this same file on another branch at
   the time, and two edits interleaved through 3 700 lines is how a merge goes
   wrong. Nothing above this line was reformatted or moved.

   The panel's spine is now a single scrolling list of every living power, one
   row each, with everything knowable about them on the row and every order at
   the right-hand end of it. The rules that matter:

   * `.diplo-head` and `.diplo-grid` share one column template, declared once as
     `--diplo-cols`. A header caret that does not sit over its own cell is worse
     than no header at all, so there is exactly one definition of the columns.
   * The toolbar is written once per opening and the rows are rewritten by the
     clock, which is why the search field is in `.diplo-controls` and never in
     `.diplo-host-rows` — an innerHTML rebuild under the pointer eats keystrokes
     (docs/CLIENT.md, the march queue's drag-reorder).
   * No new artwork and no colour emoji. The carets, the pressing dot and the
     switches are drawn with type and CSS; the relation icons are the same
     `currentColor` masks `ui/uiIcons.js` already serves.
   ========================================================================== */

/* Nine columns are wider than the 940 px `overlay-wide`, and this is the only
   overlay that needs them, so the width is widened here rather than on the
   shared class every other overlay uses. */
.overlay-diplomacy { width: min(1180px, 100%); }

.diplo-countries { --diplo-cols: 3.2rem 2rem minmax(8rem, 1.1fr) 7.6rem 4rem 4.6rem 4.4rem 4rem minmax(19rem, 1.4fr); }

.diplo-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 12px;
  padding: 6px 0 8px;
}
.diplo-search { flex: 1 1 12rem; min-width: 9rem; display: flex; }
.diplo-search input {
  width: 100%;
  padding: 4px 8px;
  font: inherit;
  font-size: 12px;
  color: var(--ink);
  background: rgba(255, 253, 245, 0.6);
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
}
.diplo-filter { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--ink-soft); }
.diplo-filter select { font: inherit; font-size: 11.5px; padding: 3px 5px; }
/* A toggle, drawn rather than imported: a pill that slides. Kenney and
   Game-icons were both checked first and neither ships a switch that belongs on
   parchment — a two-pseudo-element CSS pill costs nothing and inherits the
   theme, so nothing was added to `public/assets` for this. */
.diplo-switch { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--ink-soft); cursor: pointer; }
.diplo-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.diplo-switch > span { position: relative; padding-left: 30px; }
.diplo-switch > span::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  width: 24px;
  height: 13px;
  margin-top: -7px;
  border: 1px solid var(--rule);
  border-radius: 7px;
  background: rgba(43, 35, 24, 0.08);
  transition: background 120ms ease;
}
.diplo-switch > span::after {
  content: '';
  position: absolute;
  left: 2px;
  top: 50%;
  width: 9px;
  height: 9px;
  margin-top: -5px;
  border-radius: 50%;
  background: var(--ink-faint);
  transition: transform 120ms ease, background 120ms ease;
}
.diplo-switch input:checked + span::before { background: rgba(168, 132, 44, 0.28); border-color: var(--gold); }
.diplo-switch input:checked + span::after { transform: translateX(11px); background: var(--gold); }
.diplo-switch input:focus-visible + span::before { outline: 2px solid var(--gold-bright); outline-offset: 1px; }
.diplo-count { margin-left: auto; white-space: nowrap; }

/* The header strip. Each cell is a button so the keyboard can reach a sort, and
   the caret is a `·` when the column is not the active one — a column with no
   mark at all does not read as sortable. */
.diplo-head {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 4px 10px;
  border-bottom: 1px solid var(--rule);
  background: var(--parchment-2);
}
.diplo-col {
  display: flex;
  align-items: center;
  gap: 3px;
  min-width: 0;
  padding: 0;
  font: inherit;
  font-size: 10.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-faint);
  background: none;
  border: 0;
  text-align: left;
}
button.diplo-col { cursor: pointer; }
button.diplo-col:hover { color: var(--ink); }
button.diplo-col.is-sorted { color: var(--ink); font-weight: 600; }
.diplo-caret { font-size: 8px; opacity: 0.75; }
.diplo-col-provinces, .diplo-col-score, .diplo-col-border { justify-content: flex-end; }

/* The row. `.diplo-row` was a four-column grid of its own; the grid moved
   inside it, so the row itself is now a block with up to three stacked lines:
   the grid, the reasons under it, and the pact ledger under that. */
.diplo-countries .diplo-row { display: block; padding: 5px 10px; }
.diplo-grid {
  display: grid;
  grid-template-columns: var(--diplo-cols);
  align-items: center;
  gap: 4px 10px;
}
.diplo-cell { min-width: 0; font-size: 12px; }
.diplo-cell-standing { display: flex; align-items: center; gap: 4px; min-height: 18px; }
.diplo-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-faint); }
.diplo-dot.rel-war { background: #a33326; }
.diplo-dot.rel-alliance { background: #1e6f52; }
.diplo-dot.rel-peace { background: var(--gold); }
.diplo-cell-rank { text-align: right; font-size: 11px; font-variant-numeric: tabular-nums; }
.diplo-cell-num { text-align: right; font-variant-numeric: tabular-nums; }
.diplo-cell-who { display: flex; align-items: center; gap: 7px; cursor: pointer; }
/* The circular arms badge the reference leads each row with — the same
   `heraldry.js` shield, in a ring of the faction's own colour. The shield is
   kept rather than replaced by a round flag: it is this game's own device
   family, and a flag roundel is a different application's iconography
   (docs/ART.md). */
.diplo-badge {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  overflow: hidden;
  border: 1.5px solid var(--faction, var(--rule));
  background: rgba(255, 253, 245, 0.75);
  box-shadow: inset 0 0 0 1px rgba(255, 253, 245, 0.6);
}
.diplo-badge svg { width: 18px; height: 18px; display: block; }
.diplo-power-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-size: 11.5px;
}
.diplo-cell-relation .rel-badge { max-width: 100%; }
/* After elimination the relation is a thing that *was* true, so it is drawn
   flat: the war red would say the campaign is still yours. */
.rel-badge.is-past { background: rgba(43, 35, 24, 0.06); color: var(--ink-faint); border-color: var(--rule); }
.tag-human { background: rgba(36, 95, 158, 0.14); }
.diplo-cell-orders { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.diplo-cell-orders .row-actions { justify-content: flex-end; flex-wrap: wrap; gap: 3px; }
.diplo-row-under {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 3px 8px;
  padding-left: calc(3.2rem + 2rem + 20px);
  line-height: 1.3;
}
.diplo-countries .diplo-row-ledger { padding-left: calc(3.2rem + 2rem + 20px); }
/* One scroller, not two. The list was given its own `max-height` first and it
   put a second scrollbar half a centimetre from the overlay's own, with the
   sticky header stuck to the inner box rather than to the top of the panel.
   The list scrolls with the body instead and the header rides the body's top,
   which is what the reference does and is one fewer thing to aim at. */
.diplo-countries .diplo-rows { gap: 3px; }
.diplo-standings { margin: 6px 0 0; }

/* Under about 1 040 px the nine columns stop fitting, so the row becomes two
   stacked lines and the header strip — which can only lie at that width — is
   dropped. The toolbar stays: the search and the filters are still the way
   through a seventeen-row list on a small window. */
@media (max-width: 1040px) {
  .diplo-head { display: none; }
  .diplo-grid { grid-template-columns: 2rem minmax(7rem, 1fr) 7.4rem 3.4rem 3.4rem 3.4rem 3.4rem; }
  .diplo-cell-standing { display: none; }
  .diplo-cell-orders { grid-column: 1 / -1; align-items: flex-start; }
  .diplo-cell-orders .row-actions { justify-content: flex-start; }
  .diplo-row-under, .diplo-countries .diplo-row-ledger { padding-left: 0; }
}

/* A label that is read aloud and never drawn: the search box's own name, which
   a placeholder cannot supply to a screen reader. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- commander callings (docs/DESIGN.md §4.4) ---------------------- */

/* Twelve callings, so three columns rather than the recruit picker's four: each
   tile has to carry two lines of effect text as well as a name, and at four up
   the numbers wrapped mid-word. The grid scrolls rather than growing the tray —
   the hire block sits above the recruit bill and must not push it off-screen. */
.commander-pick {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  width: 100%;
  margin: 4px 0 6px;
  max-height: 190px;
  overflow-y: auto;
}
.commander-tile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 5px 6px;
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.16);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  /* Reserved so choosing does not shift the grid, as on the recruit tiles. */
  box-shadow: inset 0 0 0 2px transparent;
  transition: background 0.12s ease, box-shadow 0.12s ease;
}
.commander-tile:hover { background: rgba(255, 255, 255, 0.3); }
.commander-tile:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
.commander-tile.is-on {
  background: rgba(168, 132, 44, 0.16);
  box-shadow: inset 0 0 0 2px var(--gold);
}
.commander-tile .commander-name {
  font-size: 11px;
  font-weight: 600;
  line-height: 1.15;
}
.commander-tile .commander-effect {
  font-size: 9.5px;
  line-height: 1.25;
  opacity: 0.75;
}

/* The officer's own card in the army pane: what this man is worth, as opposed
   to what a calling is worth in the abstract. */
.commander-card {
  margin-top: 6px;
  padding: 4px 7px 5px;
  border-radius: var(--radius-sm);
  /* Inside the dark identity card, so it lifts off the ground rather than
     sitting on a light one: a border here read as a second panel edge. */
  background: rgba(255, 255, 255, 0.07);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}
.commander-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
  font-size: 11px;
}
.commander-card-head .commander-calling { font-weight: 600; }
.commander-lines {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 8px;
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
  font-size: 10px;
}
.commander-lines li { white-space: nowrap; }
/* Closed, the picker is one row naming the calling and what it is worth. */
.commander-chosen { align-items: baseline; gap: 8px; }

/* News and Diplomacy share the game's parchment, ink and heraldic accents. */
#logPanel, #diplomacyRail {
  background: var(--paper);
  border: 1px solid var(--rule-strong);
  box-shadow: 0 8px 22px rgba(31, 22, 12, 0.27);
  color: var(--ink);
}
#logPanel { min-height: 230px; }
#logPanel [hidden], #diplomacyRail [hidden] { display: none !important; }
.news-head, .drail-head {
  background: linear-gradient(180deg, #513b29, #382819);
  color: #f6e8c8;
  border-bottom: 1px solid #816747;
}
.news-head { display: flex; align-items: center; gap: 7px; padding: 7px 8px; }
.news-head h3 { font: 700 14px/1.2 var(--font-head); letter-spacing: .04em; }
.panel-fold-toggle {
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid #a9874b;
  border-radius: 4px;
  background: #513b29;
  color: #fff4d7;
  font: 700 18px/1 var(--font-body);
  cursor: pointer;
}
.panel-fold-toggle:hover { background: #755a34; }
.panel-fold-toggle:focus-visible { outline: 2px solid #d0a848; outline-offset: 2px; }
#logPanel.panel-folded, #diplomacyRail.panel-folded {
  flex: 0 0 auto;
  min-height: 0;
  height: auto;
}
.panel-folded > :not(.panel-head), .panel-folded .news-views { display: none; }
.news-views { display: flex; margin-left: auto; gap: 2px; }
.news-views button {
  padding: 3px 7px; border: 1px solid transparent; border-radius: 3px;
  background: transparent; color: #e0cda9; font: 600 10px var(--font-body); cursor: pointer;
}
.news-views button.is-active { color: #fff4d7; background: #755a34; border-color: #a9874b; }
.news-views button:focus-visible, .news-category:focus-visible, .news-attention button:focus-visible {
  outline: 2px solid #d0a848; outline-offset: 1px;
}
.news-tools { padding: 7px 8px; border-bottom: 1px solid var(--rule); }
.log-filters { align-items: center; }
.news-category, #logPanel .log-faction {
  max-width: 100%; min-width: 0; border: 1px solid var(--rule-strong); border-radius: 3px;
  padding: 3px 5px; background: #f8efd9; color: var(--ink); font: 10px var(--font-body);
}
#logPanel .log-faction { flex: 1 1 76px; }
#logPanel .chip-btn.is-active { background: #e4d0a3; border-color: #a8842c; color: #4b361b; }
.news-attention { flex: 0 0 auto; max-height: min(174px, 26vh); overflow-y: auto; padding: 7px 8px; border-bottom: 1px solid var(--rule-strong); }
.news-attention-head { display: flex; justify-content: space-between; gap: 8px; color: #5b3f22; font: 700 10px var(--font-head); letter-spacing: .04em; }
.news-attention-head span { color: #7b4b20; font-variant-numeric: tabular-nums; }
.news-clear { margin: 6px 0 1px; font-size: 11px; color: var(--ink-soft); }
.news-attention-item { display: flex; align-items: center; gap: 6px; border-left: 3px solid var(--gold); padding: 5px 0 5px 7px; margin-top: 5px; background: rgba(255,249,229,.62); font-size: 10.5px; line-height: 1.3; }
.news-attention-item.is-decision, .news-attention-item.is-offer { border-left-color: #b37b32; }
.news-attention-item.is-event { border-left-color: #a6413a; }
.news-attention-copy { flex: 1; min-width: 0; }
.news-attention-copy small { display: block; margin-top: 2px; color: var(--ink-soft); }
.news-attention-item > button { flex: none; padding: 3px 5px; border: 1px solid var(--gold); border-radius: 3px; background: #f5e7c4; color: #513819; font: 600 10px var(--font-body); cursor: pointer; }
.news-attention .advice-actions { flex: none; }
#logPanel .log-feed { background: rgba(255,248,226,.32); }
#logPanel .log-line { padding: 6px 2px; border-bottom: 1px solid var(--rule); line-height: 1.35; }
#logPanel .log-tick { color: var(--ink-faint); font-variant-numeric: tabular-nums; }
#logPanel .log-gap { color: var(--ink-faint); }
#logPanel .chat-form { background: var(--parchment-2); }
#diplomacyRail .drail-head h3 { font: 700 14px var(--font-head); letter-spacing: .04em; }
#diplomacyRail .drail-badge { background: #9b6124; }
#diplomacyRail .drail-requests { max-height: min(166px, 23vh); padding: 6px; border-bottom-color: var(--rule-strong); }
#diplomacyRail .drail-request { gap: 3px; padding: 6px; border: 1px solid #cbb68a; border-left: 3px solid var(--gold); border-radius: 3px; background: #f8edcf; }
.drail-request-kicker { color: #95612d; font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.drail-request-title { font-size: 11px; }
#diplomacyRail .drail-request-detail { font-size: 10px; white-space: normal; }
#diplomacyRail .drail-request-actions button:first-child { background: #75552b; border-color: #75552b; color: #fff4d7; }
#diplomacyRail .drail-list { min-height: 82px; max-height: none; }
#diplomacyRail .drail-row { border-bottom: 1px solid var(--rule); }
#diplomacyRail .drail-row.rel-you { background: rgba(168,132,44,.15); }
#diplomacyRail .drail-row.rel-ally { background: rgba(79,122,68,.13); }
#diplomacyRail .drail-btn { min-height: 25px; }
#diplomacyRail .drail-treaty { color: #57421e; background: #ead9ac; border-color: #b89c5d; font-weight: 700; }
.overlay-diplomacy { background: var(--paper); color: var(--ink); }
.overlay-diplomacy .overlay-head { background: linear-gradient(180deg, #513b29, #382819); color: #f6e8c8; }
.overlay-diplomacy .overlay-head h2 { font-family: var(--font-head); font-size: 18px; letter-spacing: .04em; }
.overlay-diplomacy .overlay-head [data-act="close"] { color: #f6e8c8; }
.diplo-overview { margin: 0 0 5px; border: 1px solid var(--rule-strong); border-radius: 3px; background: rgba(255,247,225,.52); }
.diplo-overview summary { display: flex; gap: 6px; align-items: center; padding: 8px 10px; cursor: pointer; color: #543a20; font: 600 11px var(--font-head); }
.diplo-overview summary:hover { background: #e8d8b4; }
.diplo-overview summary:focus-visible { outline: 2px solid #9c7235; }
.diplo-overview summary strong { font-variant-numeric: tabular-nums; }
.diplo-overview > .section { margin: 0 8px 8px; }
.diplo-requests-heading { margin: 0; padding: 8px 10px; color: #543a20; font: 600 11px var(--font-head); }
.diplo-request { align-items: start; flex-wrap: wrap; gap: 6px 10px; padding: 7px 8px; }
.diplo-request-copy { flex: 1 1 200px; min-width: 0; font-size: 12px; overflow-wrap: anywhere; }
.diplo-request-facts { margin: 3px 0 0; padding-left: 16px; font-size: 11px; line-height: 1.4; }
.diplo-request > .row-actions { flex: 0 0 auto; gap: 4px; }
@media (pointer: coarse) {
  .diplo-request .btn { min-height: 44px; min-width: 44px; }
}
.diplo-countries { --diplo-cols: 2.1rem 1.5rem minmax(8rem,1.2fr) 7rem 3rem 3.4rem 3.4rem 3rem minmax(8rem,1fr); }
.diplo-countries .diplo-row { padding: 7px 9px; background: rgba(255,249,232,.72); border: 1px solid var(--rule); border-left: 3px solid transparent; }
.diplo-countries .diplo-row.rel-war { border-left-color: #ac4f45; }
.diplo-countries .diplo-row.rel-ally { border-left-color: #397d65; }
.diplo-countries .diplo-row.is-pressing { background: #f4e8c9; }
.diplo-countries .diplo-row.is-expanded { border-color: #a8842c; box-shadow: 0 2px 7px rgba(55, 37, 16, .14); }
.diplo-cell-orders { flex-direction: row; align-items: center; justify-content: flex-end; }
.diplo-pending { color: #a36322; font-size: 10px; font-weight: 700; white-space: nowrap; }
.diplo-expand { padding: 4px 6px; border: 1px solid var(--rule-strong); border-radius: 3px; background: #eadbb7; color: var(--ink); font: 600 10px var(--font-body); cursor: pointer; white-space: nowrap; }
.diplo-expand:hover { background: #ddc994; }
.diplo-expand:focus-visible { outline: 2px solid #a87936; }
.diplo-row-detail { display: grid; gap: 6px; margin-top: 7px; padding: 8px 10px; border-top: 1px solid var(--rule); background: rgba(226,207,164,.25); }
.diplo-active-term { font-size: 11px; color: var(--ink-soft); }
.dc-card.is-focused { outline: 2px solid #bc8b3b; outline-offset: 2px; }
.diplo-row-detail .diplo-row-under, .diplo-countries .diplo-row-detail .diplo-row-ledger { padding-left: 0; }
.diplo-row-detail .diplo-offer { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.diplo-row-actions { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 6px 0 2px; padding: 6px 0 0; border-top: 1px solid var(--rule); }
.diplo-action-group { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 7px; }
.diplo-action-group > span:first-child { color: #76562b; font: 700 10px var(--font-head); white-space: nowrap; }
.diplo-action-group .row-actions { display: flex; flex-wrap: wrap; gap: 4px; }
.diplo-action-group .btn { background: #f2e5c7; border-color: #bca879; color: #3f2c17; }
.diplo-action-group .btn:hover:not(:disabled) { background: #e6d2a2; border-color: var(--gold); }
.diplo-action-group .btn-danger { background: #8b3b2b; border-color: #72291d; color: #fff1d5; }
.diplo-row-offers { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; padding: 6px 8px; border-left: 3px solid var(--gold); background: #f5e4b9; }
.diplo-row-offers .diplo-offer { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
@media (max-width: 1040px) {
  .diplo-countries .diplo-grid { grid-template-columns: 1.5rem minmax(7rem,1fr) 6.5rem 3rem 3rem 3rem 3rem; }
  .diplo-countries .diplo-cell-orders { justify-content: flex-start; }
}
@media (max-width: 700px) {
  .overlay-diplomacy { width: 100%; }
  .diplo-countries .diplo-grid { grid-template-columns: 1.5rem minmax(6rem,1fr) auto; }
  .diplo-countries .diplo-cell-num, .diplo-countries .diplo-cell-kind { display: none; }
  .diplo-countries .diplo-cell-orders { grid-column: 1 / -1; }
}

/* ===========================================================================
   Touch
   ===========================================================================

   Everything here is behind `pointer: coarse`, so a mouse sees none of it and
   the desktop layout this file spends two thousand lines getting right is not
   touched at all.

   **The measurement that prompted it**, taken on an emulated Pixel 7 with the
   browser driver: 39 controls were under 44 px on a side — `speed-btn` at
   35x22, `drail-btn`, `chip-btn`, the chronicle filters, the faction banner.
   44 px is the size both Apple and Google publish as the smallest reliable
   target, and below it a thumb hits the control beside the one it meant.

   `min-height` and padding rather than fixed sizes: the point is a floor under
   the target, not a new layout. */
@media (pointer: coarse) {
  .news-views button,
  #diplomacyRail .drail-btn {
    min-height: 44px;
  }
  .news-views button { min-width: 44px; }
  /* One floor for every ordinary control. `min-width` is deliberately *not*
     applied to everything — a row of four speed buttons at 44 px wide each
     would not fit a 390 px phone — so height carries most of the target and the
     narrow ones get padding instead. */
  .btn,
  .chip-btn,
  .icon-btn,
  .drail-btn,
  .speed-btn,
  .link-btn,
  .cmd-seg-btn,
  .cmd-switch-btn,
  /* The plot picker's own rows. They measured ~26 px and ~28 px and were never
     in this list — under the gate's own 40 px thumb rule, which never catches
     them because nothing in the phone pass ever opens the picker. */
  .branch,
  .leaf,
  /* A chip that *does* something is a control; a chip that only says something
     is a badge, and forcing 44 px on the badges would push the figures apart
     for nothing. `.chip[data-act]` is the distinction the markup already makes.
     Measured at 33x15 — TODO §22 listed it and the gate could not see it,
     because the card it lives in was collapsed to 0 px tall until this pass
     un-collapsed it. */
  .chip[data-act],
  .log-faction,
  select.input,
  select,
  input.input {
    min-height: 44px;
  }

  .btn,
  .chip-btn,
  .drail-btn,
  .cmd-seg-btn,
  .cmd-switch-btn {
    padding-left: 12px;
    padding-right: 12px;
  }

  /* The chronicle's dismiss ×: a lone glyph in a `.link-btn`, measured **7 px
     wide** (TODO §22's named casualty, finally caught when the thumb check
     grew a width floor). Only this one — the other `.link-btn`s are text
     links whose words are their width, and padding them all would shift the
     cards they sit in. */
  .link-btn[data-act='dismiss'] {
    min-width: 28px;
    text-align: center;
  }

  /* **The speed buttons take the height and nothing else, and that is measured.**
     They sit four-across inside `.topbar-right`, which is 301 px on a 412 px
     phone. A `min-width: 40px` here — which this block used to carry — made
     `.speed` 162 px with its right edge at 420: past the bar's own right edge of
     395, and past the screen. `#topbar` is `overflow-x: hidden`, so nothing
     scrolled and nothing looked broken; the **4× button was simply clipped off
     and could not be pressed**. Their natural width is about 28 px, which fits,
     and 44 px of height is already a comfortable target for a control a thumb
     hits square on. Caught by "turning the phone on its side", which was written
     to check rotation and found this in portrait on its first run. */

  /* **The province figures were unreachable, not merely tight.** On a narrow
     screen `.cmd-info` is capped at 46 % of the bar, which on a 412x839 phone
     leaves `.cmd-stats` 27 px to show 137 px of content — Population, Wealth,
     Walls and Militia are in the page and cannot be seen or got at, because
     `.cmd-stats` is `overflow: hidden` and no ancestor scrolls. Clipping the
     card's empty half upward is the intended behaviour and stays; clipping the
     numbers the player is reading is not. Scrolling them is the smallest change
     that makes them reachable, and it decides nothing about what a phone layout
     should eventually be (TODO §21). */
  .cmd-stats {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Square controls can afford both. */
  .icon-btn {
    min-width: 44px;
  }

  /* **A checkbox is a control, and the floor above cannot see it.** The floor
     is written as `input.input`, which wants the class every text field and
     select in the room form carries; `fillWithAi` and `fogOfWar` are bare
     `<input type="checkbox">` and measured **13x13 in a 19 px label row**,
     beside `.input`s of 282x44 in the same grid — `difficulty`,
     `conquestShare`, `timeLimit`. Fog of war is a rules setting and this is the
     first screen a host ever sees.

     **The label is the target, not the box.** `<label class="field
     field-check">` wraps its input, so a tap anywhere along the row toggles it;
     flooring the row makes the target the whole 282 px of it rather than a
     13 px square. The box grows to 22 px so that it reads as a control beside
     12 px type — a 44 px painted checkbox next to one line of text looks like a
     mistake, and the height is not what a thumb was missing. */
  .field-check {
    min-height: 44px;
    cursor: pointer;
  }
  .field-check input[type="checkbox"] {
    flex: 0 0 auto;
    width: 22px;
    height: 22px;
    margin: 0;
  }

  /* **It was not the right trade, and that is measured.** This block used to
     say the chips wrapping onto more rows "is what the extra height costs and is
     the right trade". At 844x390 with the drawer open it cost **212 px of
     `.panel-head`** — ten chips over five rows — inside a `#logPanel` that is
     **140 px tall**, with a 102 px advice block under it and a 59 px chat row
     below that. The chronicle feed was left **12 px holding 103**, and the
     panel is `overflow: hidden`, so 245 px of it was not scrolled past, it was
     gone. Every filter chip, the faction picker and the chat controls
     hit-tested **off screen**.

     One row that scrolls sideways instead. A filter strip is a list of equals
     and the player reads along it; the stockpile's "never scrolls sideways"
     rule is about a strip whose *tail* carries meaning, which this one's does
     not. */
  .log-filters {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    row-gap: 3px;
  }
  .log-filters > * { flex: 0 0 auto; }
  .panel-head { flex-wrap: wrap; }
  /* The drawer is the chronicle's whole reason for opening, so let it have the
     column and scroll the column instead of squeezing the panel to its floor. */
  /* Vertically only. Setting `overflow-y` alone computes `overflow-x: auto` as
     well — the two cannot disagree when one is `visible` — and a rail that
     scrolls sideways is a rail with something laid out off its edge. */
  .column { overflow-y: auto; overflow-x: hidden; }
  #logPanel { flex: 1 0 auto; min-height: 220px; }

  /* A tap has no hover, so the two states must not look different — a control
     that only shows it is pressable on hover looks dead on a phone. */
  .btn:hover,
  .chip-btn:hover,
  .icon-btn:hover {
    filter: none;
  }

  /* The News attention controls must remain visible without hover. */
  .advice-actions { opacity: 1; }
  /* Keep the action below its sentence in a narrow drawer. */
  .news-attention-item.is-advice { flex-wrap: wrap; }
  .news-attention-item.is-advice .news-attention-copy { flex: 1 1 100%; }
  .news-attention-item.is-advice .advice-actions { flex: 0 0 auto; margin-left: auto; }

  /* Scrollable panes get momentum, or a list feels stuck on iOS. */
  .cmd-tray,
  .panel,
  .overlay-body,
  .stores-pop {
    -webkit-overflow-scrolling: touch;
  }
}

/* **`--inset-bottom` was read by the camera and defined by nobody.**
   `render/stage.js panelInsets()` reads it with a fallback of 10 px, so the
   camera reserved **10 px** at the foot of the screen while the command bar
   stood 212 px tall. Measured at 390x664: the map was fitted into a box running
   to y 654 and landed at 289..503 — **151 px of bare desk above it** and its
   bottom 63 px hidden under the bar. That is the wooden band a player reported.

   Defined for touch only, and deliberately not globally. On a desktop the bar
   *is* meant to float over the map — the same idiom Total War uses, recorded at
   `--cmd-h` — and giving the camera the true inset there would shrink the map
   from 552 px of height to 294. The fold releases it again: a folded bar is
   only its identity strip, so the camera gets the room back. */
/* **Literal pixels, not `calc(var(--cmd-h) + 16px)`, and that is not a style
   preference.** `stage.js px()` reads the variable with `getComputedStyle`, and
   a custom property comes back **unresolved** — the string `calc(var(--cmd-h) +
   16px)`, not `228px` — so `parseFloat` gave `NaN` and the camera silently used
   its 10 px fallback. The landscape value worked and portrait did not, which is
   how it was caught: one was a literal and the other was arithmetic. Each figure
   below is its own `--cmd-h` plus the bar's 16 px of margin. */
/* **On `:root`, not `body`.** `panelInsets()` reads
   `getComputedStyle(document.documentElement)`, and a custom property set on
   `body` does not reach its own ancestor — so a `body` rule here is read by
   nothing at all. Caught by measuring twice and seeing portrait refuse to move. */
@media (pointer: coarse) {
  :root { --inset-bottom: 268px; }
}
@media (pointer: coarse) and (max-height: 860px) {
  :root { --inset-bottom: 246px; }
}
@media (pointer: coarse) and (max-height: 720px) {
  :root { --inset-bottom: 228px; }
}
/* Short screens default to folded, and a folded bar is only its identity strip —
   about 420 px wide in the corner of a 915 px screen. Reserving its full height
   costs more than it buys: **landscape is height-limited**, so 66 px here shrank
   the fitted map from 481x284 to 389x230 (36 % of the screen to 24 %) to avoid an
   overlap that was not happening. Measured at 12 px: map 481x284, and its bottom
   edge still clears the strip by 6 px. */
@media (pointer: coarse) and (max-height: 560px) {
  :root { --inset-bottom: 12px; }
}

/* **The same bar, measured for the layers that float over it rather than for
   the camera.** Every figure here is `--cmd-own`: the bar's height, plus the
   8 px it stands off the floor, plus an 8 px gap. See the note on `--cmd-own`
   at the top of this file for what went wrong without it.

   `--cmd-clear` then clamps that, and the clamp is not decoration. Landscape
   unfolded is the case that needs it: `body.short-viewport:not(.cmd-folded)
   .command-bar` is `82vh`, which on a 412 px screen is 338 px and leaves the
   band between `--chrome-top` and the bar **negative**. Every top-anchored card
   would compute `max-height: 0` and its contents would be unreachable rather
   than merely overlapped — a strictly worse fault than the one being fixed.
   120 px is a card's head and a button, scrolled. The clamp lives here behind
   `pointer: coarse` rather than on `:root`, because a short *desktop* window
   would otherwise move, and this pass is not allowed to move the desktop. */
@media (pointer: coarse) {
  :root { --cmd-clear: min(var(--cmd-own), calc(100dvh - var(--chrome-top) - 120px)); }
  /* Nothing is selected, so there is no bar at all — `.command-bar` is `hidden`
     and paints nothing. A toast belongs at the foot of the screen then and a
     card may have the whole band, which is the state a phone is in for most of
     a game. The desktop keeps its reservation whether or not the bar is up;
     changing that is a desktop move, and this is a touch fix. */
  :root { --cmd-own: 16px; }
  /* Folded — the default a phone gets — the bar is its switch pill and nothing
     else. `.cmd-panes` is `display: none`, so `commandbar.js measureCard()`
     publishes `--cmd-info-h: 0px` and the pill sits 5 px above the bar's floor.
     Measured at 390x844: the pill is 50 px tall, y 781..831, so it reaches 63 px
     above the floor. This is the 66 px the toast strip used to be anchored at by
     hand, with the gap made honest. */
  /* Startup fallback only; commandBar.js measures the drawn controls and
     publishes --cmd-own on :root as soon as they are laid out. */
  :root:has(#commandBar:not([hidden])) { --cmd-own: 71px; }
  /* Unfolded, the bar is a sheet and the map waits; the layers wait with it.
     **These two expressions are `.command-bar`'s own ceilings, further down this
     file, and must be changed in the same edit as those.** A layer sized against
     a stale copy of them is the whole fault this variable exists to end. */
  :root:has(#commandBar:not([hidden])):has(body.short-viewport:not(.cmd-folded)) {
    --cmd-own: calc(82vh + 16px);
  }
  :root:has(#commandBar:not([hidden])):has(body.narrow-viewport:not(.cmd-folded)) {
    --cmd-own: calc(min(62vh, 100dvh - var(--chrome-top) - 16px) + 16px);
  }
  :root:has(#commandBar:not([hidden])):has(body.narrow-viewport:not(.cmd-folded)):has(.plot-tree) {
    --cmd-own: calc(min(78vh, 100dvh - var(--chrome-top) - 16px) + 16px);
  }
  /* A short narrow phone (320x568) unfolds as far as the chrome allows, picker or not: see the bar's own rule. */
  @media (max-height: 640px) {
    :root:has(#commandBar:not([hidden])):has(body.narrow-viewport:not(.cmd-folded)),
    :root:has(#commandBar:not([hidden])):has(body.narrow-viewport:not(.cmd-folded)):has(.plot-tree) {
      --cmd-own: calc(min(82vh, 100dvh - var(--chrome-top) - 16px) + 16px);
    }
  }
}

/* **A phone held upright: the chrome was sized for a desktop's width, not its
   own.** Measured at 412x839 before this: the top bar took 46 px, the stockpile
   strip **72 px** and the command bar **264 px** — 382 px of a 839 px screen,
   with the map the 435 px band between them.

   The strip is the waste. Its three rows — disc, stock, rate — are a desktop
   luxury, and at 412 px wide every tier above the first is already hidden by
   the ladder above, so the strip was 72 px tall to show *two goods*. The same
   26 px disc and 44 px row that landscape has used since the fold went in
   carries them exactly as well. `--cmd-h` takes landscape's 168 too: a tray
   that wants more scrolls, which is what `.cmd-tray` is for.

   Keyed on **width**, because that is what portrait is. The height ladder
   (`860 / 720 / 560`) cannot see it — 839 px is a tall screen by every one of
   those tests, which is why portrait never moved while landscape was fixed
   twice.

   Each `--inset-bottom` is its own `--cmd-h` plus the bar's 16 px of margin,
   written as a literal for the reason the note above gives: `stage.js px()`
   cannot resolve a `calc()` and falls back to 10 px in silence. */
@media (pointer: coarse) and (max-width: 480px) {
  :root {
    /* Two rows, and the second one is the only reason the screens below are
       reachable at all — see the `.topbar-right` block under this one. 44 px a
       row (the tap floor) plus the 4 px between them, plus the bar's own border:
       at 92 it was 2 px short of its own content (`clientHeight` 90 against
       `scrollHeight` 92 under `overflow: hidden`) and shaved the second row. */
    --topbar-h: 96px;
    --resource-disc: 26px;
    /* **44 was copied from landscape, where it never fitted either.** The tile
       is four rows — disc, amount, rate, name — and wants 56 px; measured at
       390x844 the strip gave it 42 (`scrollHeight` 50 against `clientHeight`
       42), and `overflow: hidden` sliced the rate line in half. That is what the
       phone showed: "390" over a half-height "-2/ec". The `max-height: 560px`
       block's own comment calls the three rows "a luxury" and promises "one row
       of figures" — but it only ever changed the height and never dropped a row.
       Drop the name, which the disc already draws, and give the rest room. */
    --resource-h: 62px;
    --cmd-h: 168px;
    --inset-bottom: 184px;
  }
  /* The disc is the good's name, drawn. `Stores` still opens the full picture. */
  .resource-label { display: none; }

  /* **An overlay on a phone is the screen, not a card on it.** Photographed at
     390x844: every overlay — Diplomacy, Market, Campaign, How to play — is a
     card inset by `.overlay`'s 24 px padding with ~65 px of map showing above
     and below it, and its content clipped inside that. On a screen this size
     the frame is the expensive part and it buys nothing: there is no "behind"
     worth seeing while you are reading the market. */
  .overlay { padding: 0; }
  .overlay-card,
  .overlay-wide {
    width: 100%;
    max-width: none;
    height: 100dvh;
    max-height: none;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
  }
  /* **A table on a phone is scaled to fit, not scrolled to.** The first answer
     here was `min-width: max-content` and a sideways scroll, and the phone
     showed why that is not good enough: scrolled right, the market lost its
     *Resource* column off the left and still cut the Buy button off the right,
     so every row was seven numbers belonging to a good you could no longer see.
     A table you have to scroll in two directions is a table you cannot read.

     So: smaller type, tighter cells, and drop the one column that is a
     reference rather than a decision. `overflow-x: auto` stays as a safety net
     for anything that still will not fit, but nothing should need it. */
  .overlay-body { overflow-x: auto; }
  .table { font-size: 11px; }
  .table th,
  .table td { padding: 5px 4px; }
  .table thead th { font-size: 9.5px; letter-spacing: 0.04em; }

  /* **The country list is nine columns, and it wraps rather than shrinks.**
     `--diplo-cols` is 56.8rem of minimums — about 909 px — and the 1040 px
     block already cuts it to seven at ~480 px, which is still wider than the
     358 a 390 px phone gives an overlay. Photographed from the device, the
     names were sheared off the left ("YZANTI…", "AMLUKS", "ULGARIA") while the
     order buttons ran off the right: a row you must scroll in two directions to
     read, with the one column that says *who* the row is about the first to go.

     A grid cannot fit what does not fit, so on a phone the row stops being a
     grid. Flex-wrapped, the name takes its own line, the relation and the
     figures follow on the next, and the orders keep the full-width line the
     1040 px block already gives them. Nothing is dropped and nothing is
     sheared. */
  .diplo-grid {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 8px;
  }
  .diplo-cell-who { flex: 1 1 100%; }
  .diplo-cell-relation { flex: 0 1 auto; }
  .diplo-cell-rank,
  .diplo-cell-num { flex: 0 0 auto; text-align: left; }
  .diplo-cell-orders { flex: 1 1 100%; align-items: flex-start; }
  .diplo-cell-orders .row-actions { justify-content: flex-start; }
  /* The toolbar's own controls, so the filter is not a select reading "lation". */
  .diplo-search { flex: 1 1 100%; }
  .diplo-filter select { max-width: 9rem; }

  /* **The identity card ran off the right edge.** `.cmd-info-top` is a row —
     the name beside the figures — and on a 366 px card the figures were cut
     mid-word: "COMMANDER Roger of Barcelon", "WALLS 2 harbour 4" with the
     militia line gone. Stack them; the card already scrolls for the rest. */
  .cmd-info-top { flex-wrap: wrap; }
  .cmd-info .cmd-id,
  .cmd-info .cmd-stats {
    width: 100%;
    flex: 0 0 100%;
  }
  .cmd-info .cmd-stats {
    padding-right: 0;
    border-right: 0;
  }

  /* **The picker stops floating.** It opens upward out of `.cmd-act`, which is
     right on a desktop where there is a map's worth of room above the bar and
     the popover reads as belonging to the plot it came from. On a phone it
     landed at **y 419 of an 844 px screen** — a 372x240 card in the middle of
     the map, a quarter of the screen away from the panel that opened it, which
     the player reported as "the building section is staying floated at the
     middle of screen". In the flow it is simply the next thing under the rack,
     inside the tray that already scrolls. */
  .plot-tree,
  .plot-tree.pick-card,
  .plot-tree.roadwork {
    position: static;
    width: 100%;
    min-width: 0;
    max-width: none;
    margin-top: 6px;
  }
  /* **Branches beside their buildings, not above them.** Stacked into one column
     the picker was 381 px tall — five headings, then the buildings under them —
     so choosing meant scrolling past the list to see what was in it. The desktop
     two-column shape keeps 126px for painted category emblems and labels;
     the building list takes the remaining width without widening the sheet. */
  .plot-tree { grid-template-columns: 126px minmax(0, 1fr); }
  .branch-art { width: 24px; height: 24px; flex-basis: 24px; }
  .tree-branches { gap: 3px; }
  .branch { padding: 5px 6px; }
  .branch-name { font-size: 10.5px; }
  /* A pointer with nothing left to point at. */
  .plot-tree::before { display: none; }
  /* **And the rack stops sticking here, because the two cannot both be had.**
     A sticky rack is opaque and sits at `z-index: 2` so the tray scrolls under
     it — which is the point on a desktop, where the picker is a popover over the
     map and never passes beneath. In the flow the picker *does* pass beneath,
     and the rack paints over the thing the player just opened: measured, the
     picker's own top hit-tested to `slot-pic`. Desktop keeps the sticky rack and
     the floating popover; a phone keeps the in-flow picker and a rack that
     scrolls with it. */
  .slot-rack { position: static; }
  /* **The identity card was showing 19 px of its own 77.** `.cmd-info` is capped
     at `38%` of the pane by the `max-width: 739px` block, and a percentage of a
     pane that is now correctly short is very little indeed — the province name,
     its kind and its figures came out as a black strip with one clipped line in
     it. A percentage cannot know how much is inside; a length can be chosen for
     the two lines that matter, and it already scrolls for the rest. */
  /* 74 was chosen when the sheet was 258 px and every pixel was contested. With
     the bar at 62vh unfolded there is room, and 74 was costing the whole point
     of the card: stacked, the name block filled it and the figures — strength,
     commander, stance, walls, militia — were all below the fold of a box too
     short to scroll comfortably. Photographed: "ARMY / ARAGON HOST / Aragon"
     and nothing else.

     **168 then fixed the army pane and left the province pane with the same
     fault**, because the province's `.cmd-id` is the taller of the two: 14
     (eyebrow) + 18 (name) + 21 (owner) + 44 (the army chips, at the tap floor
     §25 moved up into the identity block) + 28 (terrain sentence) + gaps = 140.
     Measured at 412x839, Barcelona selected, bar unfolded: `.cmd-info` was
     166 client over 364 of content, with `.cmd-stats` starting at y 614 against
     a card bottom of 622 — so **8 px of a 137 px ledger**. Population, Wealth,
     Walls and Unrest were present and invisible, which is the fault of the 74
     era wearing different clothes.

     260 is not a guess: `.command-bar` is capped at 62vh = 520 px and was using
     432, so the slack was 88 px and 260 spends exactly it. Measured after:
     card 258, `.cmd-stats` at y 513 with 113 of its 137 px on screen and the
     rest clipped — which is the right affordance, a clipped row says "scroll
     me" where an empty box says nothing. `.cmd-act` 203 -> 199 and the tray
     127 -> 123, so the controls are untouched. The cost is 88 px of map, which
     the fold button returns in one tap. */
  .cmd-info { max-height: 260px; }
  /* The terrain sentence goes to one line here: it scrolls to 41 px against the
     28 shown, and its content is restated as the Forage badge in the seam
     below, so the second line buys nothing the player cannot already read. */
  .cmd-info .cmd-id-sub { -webkit-line-clamp: 1; }
  /* **And its children were shrinking to nothing inside it.** `.cmd-info-top` is
     `flex: 0 1 auto; min-height: 0`, so against a capped column it does the
     obedient thing and collapses: measured `.cmd-id` and `.cmd-stats` at
     **0 px tall holding 28 px and 137 px of content**. The card was the right
     height and empty. They keep their size now and the card scrolls, which is
     what its `overflow-y: auto` was already there for. */
  .cmd-info-top { flex: 0 0 auto; }
  /* Folded, the bar is only its identity strip, so the camera gets the room
     back — the same trade landscape makes at `max-height: 560px`. `:has()` on
     the root rather than a `body` rule, because `panelInsets()` reads
     `document.documentElement` and a variable set on `body` never reaches it. */
  :root:has(body.cmd-folded) { --inset-bottom: 12px; }
  body.cmd-folded .command-bar { max-height: none; }

  /* **Upright, the bar's own icons do not fit on one line and never will.**
     A player on a real iPhone reported that diplomacy, the market, the campaign
     progress and the chronicle "are simply not reachable" — and they were not.
     Measured at 390x844: the row wants the crest (50), the calendar, the speed
     control (124) and nine icons (294) — 470 px of content on a 374 px line, so
     `.topbar-right` was squeezed to 135 px and clipped its own first four
     children. The horizontal scroll a previous pass added could not save them
     (see the `max-width: 860px` block: the overflow was on the unreachable
     side), and even fixed it hides half the game behind a gesture with no
     scrollbar to advertise it. Those screens are most of the game.

     So the icons get a line of their own. It costs 48 px of a 844 px screen —
     the map band goes 527 -> 479 px, 62 % to 57 % — which is the right trade
     for four screens that were unreachable. Landscape is untouched: it is
     height-limited and 915 px wide, where the single row already fits. */
  .topbar {
    flex-wrap: wrap;
    align-content: center;
    row-gap: 4px;
  }
  /* **A flex line breaks on the item's *hypothetical* size, not its shrunk
     one**, so `flex: 0 1 auto` here put the banner and the calendar on two
     lines of their own: measured, the first attempt laid out three rows in a
     92 px bar, the crest at y -15 and the icons at y 81..125, all of it clipped
     by the bar's own `overflow: hidden` and hit-testing to `CANVAS`. A basis of
     `0` (with the `min-width: 0` the base rules already carry) makes both
     groups zero-wide for the line-breaking step, so they share row one and
     shrink into it instead of wrapping out of it. The 1:3 split is measured:
     the calendar and the speed control want ~230 px of the 362 available, and
     the banner reads fine in the ~90 px that leaves — it had 50 px before. */
  .topbar-left { flex: 1 1 0; min-height: 44px; }
  .topbar-center { flex: 3 1 0; min-height: 44px; }
  .topbar-right {
    /* `100%` forces the wrap, so the icons are always the second line rather
       than trailing whatever fitted on the first. */
    flex: 1 0 100%;
    /* Nine icons of ~30 px across 370 px: spread them, so a thumb has ~12 px of
       clear paper on each side instead of the 3 px the packed row gave. With
       more icons than fit this packs to the start and scrolls, like `flex-start`
       — it can never overflow to the unreachable side. */
    justify-content: space-between;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* **A notch and a home indicator take real pixels, and nothing here knew.**
   `public/` had no `env(safe-area-inset-*)` anywhere, so on any phone with a
   cutout the top bar ran under it and the command bar ran under the home
   indicator — the bar a player drags upward to leave the app, directly over the
   control they press most.

   Only the *positioning* takes the inset. `--topbar-h`, `--resource-h` and
   `--inset-bottom` stay literal lengths, because `stage.js px()` reads them
   through `getComputedStyle` and a custom property comes back **unresolved** —
   an `env()` or a `calc()` in one of those would give `parseFloat` a string and
   the camera would fall back to its default in silence. That fault has already
   been paid for once in this file; see the note on `--inset-bottom`.

   The fallbacks are `0px`, so on every screen without a cutout — including the
   headless Chromium the gate runs in, which reports zero for all four — this
   block computes to exactly the 8 px that was there before. It therefore cannot
   be proved by `check:browser`, and is not meant to be: it is the one change in
   this pass that needs a real phone to see. */
@media (pointer: coarse) {
  .topbar {
    top: calc(8px + env(safe-area-inset-top, 0px));
    left: calc(8px + env(safe-area-inset-left, 0px));
    right: calc(8px + env(safe-area-inset-right, 0px));
  }
  .resource-bar {
    top: calc(8px + var(--topbar-h) + 6px + env(safe-area-inset-top, 0px));
    left: calc(8px + env(safe-area-inset-left, 0px));
    right: calc(8px + env(safe-area-inset-right, 0px));
  }
  .command-bar {
    bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    left: calc(8px + env(safe-area-inset-left, 0px));
    right: calc(var(--col-w) + 16px + env(safe-area-inset-right, 0px));
  }
}

/* **Toasts on a phone are a strip, not a stack of slabs.**
   Measured at 390x664 with five realistic march and battle messages: the stack
   was 234x373 — 56 % of the screen's height, covering **41 % of the whole
   drawn map** — with each message wrapping to four lines, and `.toast` computes
   `pointer-events: auto`, so a tap meant for the board landed on a notification.
   A player reported it as "the notifications are capturing the whole screen".

   Anchored above the command strip, two lines each, and only the two most
   recent: a phone has no room to be told six things at once, and the older ones
   are in the chronicle. */
@media (pointer: coarse) {
  /* The drawer-dodge above this media query still wins on `right`:
     `body.chronicle-open .toasts` is (0,2,1) against this rule's (0,1,0), and it
     resolves to `right: calc(var(--rail-w) + 24px)` = 364px on a 412px screen.
     With `left: 8px` now anchoring the other edge the stack is no longer pushed
     off the screen, but it is crushed — measured at **40px wide** with the
     chronicle open, each notification a 40px column. The drawer does not need
     dodging any more, because the stack is bounded by both edges. */
  body.chronicle-open .toasts {
    right: 8px;
  }

  .toasts {
    left: 8px;
    right: 8px;
    /* Clear of the command bar — whatever height it is at the time — and of
       the home indicator under it. This was a hand-written 66 px, which clears
       the **folded** strip and nothing more. Unfolded the bar runs y 313..836 on
       a 390x844 phone and the toast strip landed at y 729..778, *inside* it:
       measured, all five `[data-act="formation"]` buttons at y 753 hit-tested to
       `div.toast.toast-info`, and in the same sweep with no toast up all five
       were reachable. TODO §22 already fixed this exact fault once — "toasts
       swallowed taps meant for the map" — and the new anchor brought it back,
       which is the argument for a shared figure over a local one. */
    bottom: calc(var(--cmd-clear) + env(safe-area-inset-bottom, 0px));
    max-width: none;
    align-items: stretch;
    gap: 5px;
  }
  .toast {
    font-size: 12px;
    padding: 6px 10px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .toasts .toast:nth-last-child(n + 3) { display: none; }
  /* **And a notification never takes a tap on a phone, wherever it lands.**
     Anchoring the strip above the bar answers the bar; it does not answer the
     decision card or the battle prompt the strip may now float over, and this
     fault has shipped twice already through a changed anchor. `.toast` is
     `pointer-events: auto` for one reason — tap to dismiss — and that is a
     convenience weighed against an order the player is trying to give. Six
     seconds, two at a time, and the chronicle keeps the text. The lost
     affordance is recorded in TODO §23. */
  .toast { pointer-events: none; }
}

/* **Two cards that arrive unbidden, on a screen with room for one.**
   `.battle-prompts` is 250 px at `left: 8px` and `.decisions` 300 px at
   `right: 8px`; on a 390 px phone that is x 8..258 against x 82..382, and they
   overlap across x 82..258 for their whole height with the decision card on
   top (z-index 61 against 60). Measured with both up: `Fight it` (centre x 77)
   was reachable and **`Auto-resolve` (centre x 192) hit-tested
   `span.dc-option-summary`** — so of the two answers to a battle, the one that
   does *not* pull the player out of the campaign was the one they could not
   give, and the province link went the same way. Neither card leaves the screen
   except by being answered.

   They cannot sit side by side at this width, so they take opposite ends of the
   free band: the prompts keep the top, the decision cards hang just above the
   command bar — which also puts the card that must be answered within a thumb's
   reach rather than at the far end of the screen. With both up they take half
   the band each and scroll for the rest. That costs nothing in the folded state
   a phone is normally in — the band is 600 px at 390x844 and the two cards want
   about 150 and 261 — and it is the honest answer in the unfolded one, where
   the player has deliberately given the bar 62 % of the screen and the way back
   (the ▾ button) is now reachable. */
@media (pointer: coarse) and (max-width: 480px) {
  .decisions {
    top: auto;
    bottom: var(--cmd-clear);
  }
  .battle-prompts:has(~ .decisions:not([hidden])),
  .battle-prompts:not([hidden]) ~ .decisions {
    max-height: calc((100% - var(--chrome-top) - var(--cmd-clear) - 8px) / 2);
  }
}

/* Tap-to-read tooltips (public/js/ui/touchTips.js).
   Only ever built on a coarse pointer, but the rules are unconditional: a
   media query here would hide the box from the one browser check that proves
   it exists, and `check-css.mjs` would then read the whole block as dead. */
.touch-tip {
  position: fixed;
  z-index: 400;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: var(--parchment);
  color: var(--ink);
  border: 1px solid var(--rule-strong);
  box-shadow: var(--panel-shadow);
  font-size: 14px;
  line-height: 1.35;
  max-width: min(320px, calc(100vw - 16px));
  /* The box is tappable so it can be dismissed, but it must never swallow the
     tap that was meant for the map underneath it. */
  pointer-events: auto;
  opacity: 0;
  transition: opacity 140ms ease;
}
.touch-tip.is-in { opacity: 1; }

/* --- a phone held sideways ------------------------------------------------
   Measured on a 1000x405 landscape viewport, which is what a phone in landscape
   gives a page: top bar 46 px, stockpile strip 72 px, command bar **212 px** —
   81 % chrome, and **15 % of the map visible**. A player reported it as "the
   sections are covering the whole screen", which is exactly right.

   The detail panes fold away below 560 px of height and the identity strip
   stays: it already names the province, the host, its arms and its strength,
   which is what a player reads *between* orders. The panes are what they open to
   give one. `commandbar.js` owns the class, because a fold has a state a media
   query cannot hold. */
body.short-viewport.cmd-folded .cmd-panes,
body.narrow-viewport.cmd-folded .cmd-panes { display: none; }
/* A phone on its side has 390 px of height. The advice block is 102 px of it,
   above the feed it is advising about — and the feed is the thing the drawer was
   opened for. It stays in portrait, where there is room for both. */
@media (pointer: coarse) and (max-height: 560px) {
  #logPanel .advice { display: none; }
}

/* **Unfolded on a short screen, the bar is a sheet and the map waits.**
   Landscape is 915 px *wide*, so the `max-width: 739px` block that stacks the
   pane into one column never applied there — its constraint is height, and that
   is what `short-viewport` keys on. Measured before this: `.cmd-act` was
   413x24 holding 58 px of content, with Build / Levy / Taxes at y 392..436 on a
   412 px screen — offscreen and unreachable — and `.cmd-tray` was 393x0, a
   scroller with no height to scroll in. Folding gave the map back; unfolding
   gave a 24 px sliver, so there was no way to issue an economic order in
   landscape at all.

   Unfolding is a deliberate act: the player has asked for the controls, so give
   them real room and let the sheet scroll. Covering the map while an order is
   being given is what every phone interface does. */
body.short-viewport:not(.cmd-folded) .cmd-pane,
body.narrow-viewport:not(.cmd-folded) .cmd-pane {
  grid-template-columns: minmax(0, 1fr);
  gap: 6px;
}
body.short-viewport:not(.cmd-folded) .command-bar { max-height: 82vh; }
body.short-viewport:not(.cmd-folded) .cmd-panes {
  max-height: 76vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
body.short-viewport:not(.cmd-folded) .cmd-info,
body.short-viewport:not(.cmd-folded) .cmd-act,
body.short-viewport:not(.cmd-folded) .cmd-id {
  width: 100%;
  height: auto;
  max-height: none;
}
body.short-viewport:not(.cmd-folded) .cmd-tray { max-height: none; }
/* **The switch pill belongs in the flow once the bar is a sheet.**
   It is `position: absolute; bottom: calc(var(--cmd-info-h) + 5px)` — pinned to
   the top edge of the information card, which is right when the card and the
   control panel sit side by side and the pill has the card's own column to
   itself. Stacked into one column it lands *on* the panel instead: measured at
   412x839 unfolded, the pill occupied y 755..805 inside a panel running
   629..831, and because `#commandTabs` precedes `.cmd-panes` in the document
   the panel paints over it. The fold button hit-tested to `slot-rack` — so the
   tabs, Plan, the clear button and the only way to put the bar down were all
   buried under the build rack, and the way back was *not* on screen after all.
   Static, it is simply the sheet's first row, which is where a sheet's handle
   goes. */
body.short-viewport:not(.cmd-folded) .cmd-switch,
body.narrow-viewport:not(.cmd-folded) .cmd-switch {
  position: static;
  width: 100%;
}
/* **And a pill in the flow is ~50 px the column did not have before.**
   `.command-bar` is capped at `calc(var(--cmd-h) + 34px)` — 202 px on a phone —
   and that 34 px was the allowance for a switch that took *no* flow height at
   all, because it was absolutely positioned. Making it static (the rule above,
   which is what stopped the tabs being buried under the build rack) added its
   height to the column without giving the column any more room, and nothing
   below it was allowed to shrink: `.cmd-pane` has no `min-height: 0`, so it
   floors at its content, and `.cmd-act` keeps `max-height: var(--cmd-h)` = 168
   where only ~147 px is left.

   Measured at 390x844: `.cmd-act` ran **y 716..884 on an 844 px screen** and the
   build slots sat at **y 813**, their centres past the bottom edge — so a player
   could see the Build tab, and the plots they were meant to press did not exist
   on screen. That is the "Built is still not clickable" the phone reported, and
   it is a regression this bar introduced, not an old fault.

   The budget stays what it was — `--cmd-h` is supposed to mean "this is how
   tall the bar gets", and the switch is part of the bar now — so the panel
   takes what is left and its tray scrolls, which is what `.cmd-tray` is for. */
body.short-viewport:not(.cmd-folded) .cmd-pane,
body.narrow-viewport:not(.cmd-folded) .cmd-pane {
  min-height: 0;
  /* **Name the rows, or the grid overflows upward onto the switch.** Stacked
     into one column the pane is two rows — the identity card, then the control
     panel — and their natural heights (74 + 168) do not fit the 203 px the
     panes get. `.cmd-pane` is `align-items: end`, which is right on a desktop
     where the two cards sit side by side and their bottoms must line up; with
     the content taller than the box it means the overflow goes *up*. Measured
     at 390x844: `.cmd-info` started at **y 588 inside a `.cmd-panes` that starts
     at 633**, laying the card over the switch pill, and the fold button —
     44x44, freshly made visible — hit-tested to `cmd-info-top`. The one control
     that gives the map back was behind the card describing the province.

     `auto minmax(0, 1fr)` gives the card what it needs and the panel what is
     left, and the panel's tray scrolls, which is what it is for. */
  grid-template-rows: auto minmax(0, 1fr);
  align-items: stretch;
}
body.short-viewport:not(.cmd-folded) .cmd-act,
body.narrow-viewport:not(.cmd-folded) .cmd-act {
  min-height: 0;
}
/* The cap itself is the thing that was wrong, so fix the cap. `--cmd-h` means
   "how tall the *panel* gets" everywhere else in this file, and the bar's
   allowance has to carry the switch on top of it now. A percentage here does
   not work and was tried: `max-height: 100%` on a grid item whose track has no
   definite height resolves against nothing and the panel grew to 203. */
/* **Unfolded, the bar is a sheet and the map waits** — the same trade landscape
   already makes. Folded is the default and gives the map 73 % of an 844 px
   screen; unfolding is a deliberate act, so give the controls real room rather
   than a sliver. At `--cmd-h + 90` (258 px, about 31vh) the panel got 123 px
   once the identity card had taken its 74, and the build rack landed at
   **y 810..879 with its cards' centres at 844** — the exact edge of the screen,
   so a plot could not be pressed to open a picker at all. */
body.narrow-viewport:not(.cmd-folded) .command-bar {
  /* **Clamped to the room below the chrome, not to a fraction of the screen.**
     A bare `62vh` is measured from the bottom, so on a shorter viewport — a
     phone with Safari's toolbar showing, which is most of the time — the bar's
     *top* climbs above `--chrome-top`. `.topbar` is `z-index: 30` and
     `.command-bar` is 28, so it does not merely overlap the stockpile strip, it
     goes **behind** it: the switch pill, and with it the fold button and the way
     out, vanish under the top bar. Reported from the phone as "there is no fold
     down button", with the stockpile strip missing from the same screenshot.
     It does not reproduce under emulation at 844 px, where 78vh happens to land
     exactly on `--chrome-top`. */
  max-height: min(62vh, calc(100dvh - var(--chrome-top) - 16px));
}
/* **The panel grows only while a picker is open.** In the flow the plot picker
   is 381 px tall, and the tray it sits in is 92 px on a phone — so choosing a
   building meant scrolling a sliver. Giving the bar that room permanently would
   take it from the map for the whole game, when it is wanted for the few seconds
   somebody is choosing. `:has()` makes the panel answer the content: open a
   picker and the sheet grows, close it and the map comes back. The stylesheet
   already uses `:has()` for `.cmd-tray`, so this is the file's own idiom. */
body.narrow-viewport:not(.cmd-folded) .command-bar:has(.plot-tree) {
  max-height: min(78vh, calc(100dvh - var(--chrome-top) - 16px));
}
/* **A short narrow phone unfolds as far as the chrome allows, picker or not.**
   At 320x568, 62vh is 352 px: the identity card took 140 and the tab bar 45,
   leaving the tray 60 px for a Levy & commanders page of 134 + a 24 px pager,
   so the Hire button sat below the pane's clipped foot (check-map-events.mjs,
   7 November 2026). 82vh is the short-viewport sheet's own figure; here the
   chrome clamp binds first, at 432 px. Folded is still the phone default, so
   the map loses nothing until the player opens the bar. `--cmd-own` near the
   top of this file carries the same expression. */
@media (max-height: 640px) {
  body.narrow-viewport:not(.cmd-folded) .command-bar,
  body.narrow-viewport:not(.cmd-folded) .command-bar:has(.plot-tree) {
    max-height: min(82vh, calc(100dvh - var(--chrome-top) - 16px));
  }
}
/* **The panel takes the sheet, whatever tray is in it.** This was
   `:has(.plot-tree)` — written for the build picker, which was the tray in front
   of me at the time — and every other tall tray kept the 168 px `--cmd-h` cap
   while the grid track offered more. Photographed: the Muster tray showed the
   top of two recruit cards and nothing else, and TODO §16 already recorded that
   tray wanting **489 px in a 161 px window**. Unfolding is a deliberate act; the
   sheet is the answer to it, and the tray inside scrolls for the rest. */
body.narrow-viewport:not(.cmd-folded) .cmd-act { max-height: none; }
/* **The tray got 79 px and the card kept 260, and the player pressed the tab.**
   The grid above gives the identity card its full `auto` height (capped 260)
   and the control panel only the remainder: measured at 412x839 with Muster
   open, the sheet was 520 — switch 56, card 260, tab rack 94 — leaving the
   tray a **79 px window holding 579 px of content**. It scrolled, technically;
   what the phone showed was the top sliver of two recruit cards at the foot of
   the screen, reported as "the menu is stuck at the bottom and I can't see
   it". Pressing a control tab is asking for the controls, so when the two
   cannot both fit it is the card — a reference, already a scroller — that
   yields, not the tray the player just opened.

   Flex, because a grid cannot shrink an `auto` row below its content and flex
   shrinks both in proportion: the card's floor keeps the name and the first
   figures on screen and it scrolls for the rest. Measured after, same screen:
   card 260 -> 139 (scrolling its 287), panel 199 -> 320, the tray window
   79 -> 200 — more than the 161 the desktop gives this same tray (TODO §16).
   A short tray is untouched: no deficit, nothing shrinks. */
/* `:not([hidden])`, and it is not decoration: this rule outranks
   `.cmd-pane[hidden] { display: none }`, so a bare `.cmd-pane` here resurrected
   the hidden pane — measured, both panes at 194 px in a 388 px row, and the
   tab rack wrapped to four rows in the half that was visible. */
body.narrow-viewport:not(.cmd-folded) .cmd-pane:not([hidden]) {
  display: flex;
  flex-direction: column;
}
body.narrow-viewport:not(.cmd-folded) .cmd-pane > .cmd-info {
  /* The card gives way first (shrink 100 against the controls' 1). Shrinking in
     proportion, at 320x568 the card kept 140 and the tray got 60 px for a Levy
     & commanders page of 134 + a 24 px pager: the Hire button sat below the
     pane's clipped foot (check-map-events.mjs, 7 November 2026). */
  flex: 0 100 auto;
  /* Two lines of identity — eyebrow, name, the owner chip — so the card never
     vanishes entirely under a tall tray. */
  min-height: 96px;
}
body.narrow-viewport:not(.cmd-folded) .cmd-pane > .cmd-act {
  flex: 1 1 auto;
  min-height: 0;
}
/* The fold button is meaningless anywhere the panes are always shown — and it
   was `display: none` in portrait, which is the one shape that most needed it:
   a 412 px screen carried 382 px of chrome and offered nothing to press. */
.cmd-switch-fold { display: none; }
body.short-viewport .cmd-switch-fold,
body.narrow-viewport .cmd-switch-fold {
  display: inline-flex;
  /* **It was invisible, and that is measurable rather than a matter of taste.**
     `.cmd-switch` is `rgba(22, 19, 13, 0.82)` — near black — and this button
     inherited `rgb(91, 78, 58)`, a dark brown, at a 14 px glyph. The one control
     that gives the map back was a brown triangle on a black bar, and the player
     reported it as "opening and closing the building section is too small, not
     visible". Same ink as the rest of the pill, a bigger glyph, and a chip
     behind it so it reads as a control and not as punctuation. */
  align-items: center;
  justify-content: center;
  min-width: 44px;
  font-size: 20px;
  line-height: 1;
  color: #efe6cf;
  background: rgba(215, 167, 63, 0.22);
  border: 1px solid rgba(215, 167, 63, 0.7);
  border-radius: 999px;
}
body.short-viewport .cmd-switch-fold::before,
body.narrow-viewport .cmd-switch-fold::before { content: '▾'; }
body.short-viewport.cmd-folded .cmd-switch-fold::before,
body.narrow-viewport.cmd-folded .cmd-switch-fold::before { content: '▴'; }

@media (max-height: 560px) {
  /* The stockpile strip is the other big band, and on a short screen its three
     rows — disc, stock, rate — are a luxury. One row of figures keeps the
     information and gives back about half the height. `Stores` still opens the
     full picture. */
  :root {
    --resource-disc: 26px;
    --resource-h: 44px;
    --cmd-h: 168px;
  }
  /* Folded, the bar is only its strip, so it must not reserve the panes' room. */
  body.cmd-folded .command-bar { max-height: none; }
}

/* **The battle sheet's grab handle.** It steps the docked unit bar between its
   two heights (`battleView.js` DETENTS) and is the sheet's own top edge. The
   hud that used to fold into a third, taller detent is painted on the field
   now (`public/battle/ui/battleHud.css`). */
.bv-grab { display: none; }
@media (max-width: 480px) {
  .bv-grab {
    display: block;
    flex: 0 0 auto;
    align-self: center;
    width: 64px;
    min-height: 22px;
    margin: 0 0 -4px;
    padding: 0;
    border: 0;
    background: none;
    cursor: pointer;
  }
  .bv-grab::before {
    content: '';
    display: block;
    width: 44px;
    height: 4px;
    margin: 9px auto;
    border-radius: 999px;
    background: rgba(239, 230, 207, 0.5);
  }
}
/* A small explicit target dismisses a touch toast; its body still passes taps. */
.toast { position: relative; padding-right: 48px; }
.toast-dismiss {
  position: absolute;
  top: 0;
  right: 0;
  width: 40px;
  height: 40px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 20px;
  cursor: pointer;
  pointer-events: auto;
}
.toast-dismiss:focus-visible { outline: 2px solid currentColor; outline-offset: -4px; }
:root .is-order-pending { opacity: 0.65; cursor: progress; }
.order-progress {
  padding: 4px 8px;
  font-size: 12px;
  color: var(--ink, #44392c);
  background: var(--parchment, #f2e7cd);
  border-radius: 4px;
}
.order-progress:empty { display: none; }
canvas[data-order-cursor="crosshair"] { cursor: crosshair !important; }
canvas[data-order-cursor="cell"] { cursor: cell !important; }
canvas[data-order-cursor="not-allowed"] { cursor: not-allowed !important; }
canvas[data-order-cursor="grabbing"] { cursor: grabbing !important; }

/* Bandit camp and neutral-town buyout section of the province panel (ui/camps.js, DESIGN §23). */
.camp-card { margin: 0 0 10px; padding: 10px 12px; border: 1px solid var(--line, #b99958); border-radius: 8px; background: rgba(255, 248, 230, 0.5); }
.camp-card h4 { margin: 0 0 4px; font-size: 13px; }
.camp-card p { margin: 4px 0; }
.camp-card .btn { margin-top: 6px; }

/* Categorised realm stock ledger and ration sliders. */
.stores-pop { width: min(760px, calc(100vw - 90px)); }
.resource-ledger { padding: 12px; }
.resource-ledger-head, .resource-ledger-row { display: grid; grid-template-columns: minmax(105px, 1.2fr) minmax(50px, .6fr) minmax(65px, .7fr) minmax(170px, 1.6fr); gap: 10px; align-items: center; }
.resource-ledger-head { color: var(--ink-faint); font-size: 11px; padding: 8px 0; }
.resource-ledger h4 { margin: 12px 0 0; padding: 9px; background: var(--parchment-3); color: var(--ink); text-transform: uppercase; letter-spacing: .06em; }
.resource-ledger-row { padding: 9px 0; border-bottom: 1px solid #ffffff18; font-size: 12px; }
.resource-ledger-row > span:first-child { display: flex; align-items: center; gap: 6px; }
.ration-control { display: grid; grid-template-columns: minmax(70px, 1fr) 36px; align-items: center; gap: 6px; }
.ration-control input { width: 100%; min-height: 44px; accent-color: #c9a65c; touch-action: none; }
.ration-control small { grid-column: 1 / -1; }
.study-materials { display: grid; gap: 7px; margin: 12px 0; padding: 10px; background: #ffffff08; border: 1px solid #ffffff18; }
.study-materials > span { display: flex; align-items: center; gap: 6px; font-size: 12px; }
@media (max-width: 600px) {
  .stores-pop { width: calc(100vw - 70px); }
  .resource-ledger-head { display: none; }
  .resource-ledger-row { grid-template-columns: minmax(80px, 1fr) auto auto; gap: 6px; }
  .ration-control { grid-column: 1 / -1; }
  .resource-ledger-row > .muted { grid-column: 1 / -1; }
}

.stores-pop .stores-head { position: sticky; top: -8px; background: var(--parchment); z-index: 2; padding: 8px 0; }
.stores-pop.is-taxation { width: min(500px, calc(100vw - 70px)); }
.campaign-nav-visible .stores-pop.is-taxation { width: min(500px, calc(100vw - var(--inset-left) - 12px)); }
.is-taxation .tax-tray-realm { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.is-taxation .tax-tier { min-height: 64px; padding: 5px 7px; }
.is-taxation .tax-figures { gap: 2px 6px; line-height: 1.3; }
.is-taxation .stores-tax > .hint { margin: 6px 0 0; }
.is-taxation .tax-scope { display: none; }
.is-taxation .treasury-vignette { display: none; }
.treasury-balance, .treasury-balance > span:first-child { display: flex; align-items: center; gap: 8px; }
.treasury-balance { justify-content: space-between; flex-wrap: wrap; padding: 8px 0; border-bottom: 1px solid var(--ink-faint); }
@media (max-width: 600px) {
  .campaign-nav-visible .stores-pop.is-taxation { left: 12px; width: calc(100vw - 24px); }
  .is-taxation .stores-head > button { min-height: 44px; min-width: 44px; }
}

/* A centred diplomatic ledger, with dispatches and powers on facing pages. It
   sits over the blurred map with a margin, like the Market and Technology
   windows, rather than filling the screen. */
#diplomacyPanel.chancery-modal { --modal-pad: clamp(20px, 5vmin, 56px); padding: var(--modal-pad); z-index: 75; }
#diplomacyPanel.chancery-modal .overlay-diplomacy { position: relative; inset: auto; transform: none; width: min(1520px, 100%); height: min(860px, calc(100dvh - 2 * var(--modal-pad))); max-height: none; display: flex; flex-direction: column; overflow: hidden; }
.chancery-modal .overlay-head { flex-shrink: 0; }
#diplomacyPanel.chancery-modal .chancery-spread { display: grid; grid-template-columns: minmax(320px, .8fr) minmax(0, 1.2fr); gap: 0; padding: 0; min-height: 0; flex: 1; overflow: hidden; }
.chancery-desk, .chancery-modal .diplo-countries { padding: 20px; overflow-y: auto; min-width: 0; min-height: 0; margin: 0; overscroll-behavior: contain; color: var(--ink); background: var(--paper); }
.chancery-desk { border-right: 1px solid var(--rule-strong); }
.overlay-diplomacy .chancery-spread :is(h3, h4) { color: var(--ink); }
.overlay-diplomacy .chancery-spread .muted { color: var(--ink-soft); }
.overlay-diplomacy .dispatch-kicker { color: #c8ad73; font-size: 10px; font-weight: 600; letter-spacing: .14em; }
.chancery-desk .diplo-compose { margin-top: 0; }
.messenger-ledger { padding: 12px; border: 1px solid var(--rule-strong); background: #ead9af; margin-bottom: 18px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
.messenger-ledger p { margin: 5px 0 0; }
.dispatch-warning { color: #8a291f; }
.chancery-modal .diplo-grid { grid-template-columns: 52px 24px minmax(95px, 1.5fr) minmax(85px, 1fr) 65px 48px 58px 46px minmax(90px, 1fr); }
.chancery-modal .diplo-row-actions { flex-wrap: wrap; }
@media (max-width: 1280px) {
  /* A laptop at Windows display scaling (1920 at 150 %, 1366 at 125 %) is
     1280 CSS px or less. It keeps the facing pages, with the compact rows. */
  .chancery-modal .diplo-head, .chancery-modal .diplo-cell-standing { display: none; }
  .chancery-modal .diplo-cell-orders { grid-column: 1 / -1; }
  .chancery-modal .diplo-grid { grid-template-columns: 24px minmax(95px, 1fr) 100px 65px 48px 58px 46px; }
}
.chancery-tabs { display: none; }
@media (max-width: 900px) {
  /* One continuous sheet on narrow screens, with no nested page cuts. */
  #diplomacyPanel.chancery-modal .chancery-spread {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: max-content max-content;
    align-content: start;
    overflow-y: auto;
  }
  .chancery-desk, .chancery-modal .diplo-countries { overflow: visible; }
  .chancery-desk { border-right: 0; border-bottom: 1px solid var(--rule-strong); }
}
@media (max-width: 600px) {
  #diplomacyPanel.chancery-modal { --modal-pad: 6px; }
  /* Three tabs, not one 4,700 px sheet (player's playtest, 8 November 2026). */
  .chancery-tabs { display: flex; flex: 0 0 auto; gap: 4px; padding: 6px 6px 0; border-bottom: 1px solid var(--rule-strong); }
  .chancery-tab { flex: 1 1 0; min-width: 0; min-height: 44px; padding: 4px; border: 0; border-bottom: 3px solid transparent; background: none; color: var(--ink-soft); font: inherit; font-weight: 600; cursor: pointer; }
  .chancery-tab.is-on { border-bottom-color: var(--gold, #c9a14a); color: var(--ink); }
  .chancery-spread[data-tab='dispatch'] :is(.diplo-host-treaties, .diplo-host-pairs, .comeback-fold, .diplo-countries),
  .chancery-spread[data-tab='powers'] .chancery-desk,
  .chancery-spread[data-tab='agreements'] :is(.diplo-compose, .diplo-host-inbox, .diplo-countries) { display: none; }
  .chancery-spread[data-tab] .chancery-desk { border-bottom: 0; }
  .chancery-desk, .chancery-modal .diplo-countries { padding: 12px; }
  .chancery-modal .diplo-grid:not(.diplo-head) { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; }
  .chancery-modal .diplo-cell-num, .chancery-modal .diplo-cell-kind { display: none; }
  .chancery-modal .diplo-cell-orders { grid-column: 1 / -1; }
}

#diplomacyPanel.chancery-modal .overlay-backdrop { opacity: 1; }

.chancery-modal .diplo-col { white-space: normal; overflow-wrap: anywhere; }

/* --- pages instead of scrollbars (ui/fitPages.js) ----------------------- *
   Nothing in the game scrolls (CLAUDE.md, 17 October 2026). A box that does
   not fit shows one page of its children and this bar at its foot. */
.fit-off { display: none !important; }
.fit-pager {
  flex: 0 0 auto;
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 4px;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
}
.fit-pager[hidden] { display: none; }
.fit-pager-count { white-space: nowrap; }
.fit-pager .chip-btn { min-height: 24px; min-width: 30px; padding: 0 8px; line-height: 1; }
/* On the dark card the bar sits in the top-right corner, beside the kind and
   the name, so a 138 px phone card does not give a row of itself to it. */
.cmd-pane > .cmd-info { position: relative; }
.cmd-info > .fit-pager { position: absolute; top: 5px; right: 7px; margin: 0; z-index: 1; }
.lobby .fit-pager { color: #e9ddc3; }
.lobby .fit-pager .chip-btn { background: #26383f; border-color: #a9945a77; color: #e9ddc3; }
.cmd-info .fit-pager .chip-btn { background: rgba(30, 26, 18, 0.9); border-color: var(--rule-strong); color: var(--ink); }
@media (pointer: coarse) {
  .fit-pager .chip-btn { min-height: 44px; min-width: 44px; }
}
/* **The muster board fits the tray instead of scrolling it.** Ten arms as
   upright tiles took three 70 px rows of a 179 px tray (515 px of content in
   all at 1366x768), so the Muster button sat two scrolls below the arm it
   recruits. Laid on their side — the drawing beside the name — a tile is about
   36 px tall and five go across, so the whole board and its button share the
   first page; the bill and the notes page after it. */
.recruit-pick .recruit-tile {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: auto auto;
  column-gap: 5px;
  row-gap: 0;
  align-items: center;
  justify-items: start;
  padding: 3px 5px;
  text-align: left;
}
/* The name takes the tile's whole width on top — "Almogavars" is 69 px and
   would not fit beside the drawing — and the drawing and the figures share the
   line under it. */
.recruit-pick .recruit-tile { grid-template-areas: "name name" "art stat"; }
.recruit-pick .recruit-tile .tile-name { grid-area: name; text-align: left; max-width: 100%; }
.recruit-pick .recruit-tile .tile-art { grid-area: art; }
.recruit-pick .recruit-tile .tile-stat { grid-area: stat; }
.recruit-pick .recruit-tile .tile-art img,
.recruit-pick .recruit-tile .tile-art svg { width: 22px; height: 22px; }
/* The price is the figure the player picks by; it wraps rather than ellipses. */
.recruit-pick .recruit-tile .tile-stat { text-align: left; white-space: normal; line-height: 1.15; }
.recruit-pick .recruit-tile.is-locked .tile-lock { text-align: left; line-height: 1.1; }
@media (min-width: 1101px) {
  .recruit-pick { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
/* **The army card is two columns again.** Six unit chips came to 307 px in
   the figures' 300, so `.cmd-info-top` wrapped the figures under the name and
   the card needed 321 px of its 228 (1366x768). Four pixels off each chip's
   padding and one off its gap give them back, and the name and the figures sit
   side by side as they were drawn to. */
.cmd-info .cmd-units { gap: 2px; }
.cmd-info .cmd-unit { gap: 3px; padding: 3px 5px 3px 4px; }

/* Recruitment choices and their live bill share one board, without page cuts.
   Match the ancestor cap to the expanded panel: a286px command bar containing
   a480px auto-sized grid row put the queue below the viewport, beyond its own
   scroll range. The narrow/short sheet rules retain their stronger bounds. */
.command-bar:has(.muster-board) { max-height: min(65dvh, 480px); }
.cmd-pane:has(.muster-board) { min-height: 0; grid-template-rows: minmax(0, 1fr); }
/* **No scrollbar, and the whole column** (the player, 1 November 2026): the
   board was capped at 860 px and centred, so with a muster forming the queue
   sat squeezed at the right with free map between it and the information card,
   and the tray scrolled. The panel now stretches across the whole column beside
   the card, the queue takes a column of its own beside the bill (below), and
   the tray does not scroll. */
.cmd-tray:has(.muster-board) { overflow: visible; scrollbar-gutter: auto; }
.cmd-act:has(.muster-board) { width: auto; min-width: 0; height: auto; max-height: min(65dvh, 480px); }
.cmd-pane > .cmd-act:has(.muster-board) { justify-self: stretch; margin-left: 8px; }
@media (min-width: 701px) {
  /* Picker across the top; count, presets and bill on the left; the musters
     forming on the right, beside them rather than under them. */
  .muster-board:has(> .muster-queue) { grid-template-columns: minmax(0, 1.6fr) minmax(220px, 1fr); }
  .muster-board:has(> .muster-queue) > .muster-summary,
  .muster-board:has(> .muster-queue) > .muster-details { grid-column: 1; }
  .muster-board:has(> .muster-queue) > .muster-queue { grid-column: 2; grid-row: 2 / span 2; margin-top: 0; border-top: 0; padding-top: 0; border-left: 1px solid var(--rule); padding-left: 10px; }
  .muster-board:has(> .muster-queue) .muster { grid-template-columns: minmax(0, 1fr) auto auto; grid-template-areas: "arm count act" "bar bar bar"; row-gap: 2px; }
  .muster-board:has(> .muster-queue) .muster > .muster-arm { grid-area: arm; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .muster-board:has(> .muster-queue) .muster > .muster-count { grid-area: count; }
  .muster-board:has(> .muster-queue) .muster > .meter { grid-area: bar; min-width: 0; }
  .muster-board:has(> .muster-queue) .muster > .btn { grid-area: act; }
}
.muster-board { display: grid; width: 100%; min-width: 0; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: 8px 14px; align-items: start; }
/* **Five across, two down** (the player, 1 November 2026). Every realm offers
   exactly ten arms — the nine common ones and its own signature — so the picker
   is one 5x2 block across the board's whole width, with the count, Max, Muster
   and the 10/20/50/100 presets under it. Was three across in half the board:
   four rows, 178 px at 1280x720; now two rows of about 44 px. */
.muster-board > .recruit-pick { grid-column: 1 / -1; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 3px; margin: 0; }
.muster-board > .recruit-pick .recruit-tile { padding: 2px 4px; }
.muster-board > .recruit-pick .recruit-tile .tile-name { font-size: 10px; }
.muster-board > .recruit-pick .recruit-tile .tile-stat { font-size: 9px; }
.muster-board > .recruit-pick .recruit-tile .tile-art img,
.muster-board > .recruit-pick .recruit-tile .tile-art svg { width: 18px; height: 18px; }
.muster-summary { min-width: 0; }
/* The bill sits to the right of the count, the Muster button and the presets,
   in the room that stood empty there, rather than under them — so the board is
   shorter instead of longer (the player's call, 1 November 2026). Stacked again
   on a phone, below. */
.muster-board > .muster-summary {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
  column-gap: 16px;
  align-items: start;
}
.muster-board > .muster-summary > * { grid-column: 1; }
.muster-board > .muster-summary > .recruit-bill { grid-column: 2; grid-row: 1 / span 6; margin-top: 0; }
.muster-summary .recruit { gap: 5px; }
.muster-controls .input-count { width: 64px; min-width: 0; }
.muster-controls .btn-primary { flex: 1; }
.muster-presets { margin-top: 5px; }
.muster-presets .btn { flex: 1; min-width: 0; }
.muster-summary .recruit-bill { padding: 6px 0; border-block: 1px solid var(--rule); line-height: 1.3; }
.muster-summary .bill-k { flex-shrink: 0; }
.muster-summary .bill-v { overflow-wrap: anywhere; }
.muster-reason { margin: 4px 0 0; font-size: 11px; }
.muster-details { grid-column: 1 / -1; }
.muster-details > summary { cursor: pointer; color: var(--ink-soft); font-size: 11px; padding: 4px 0; }
@media (max-width: 700px) {
  .muster-board { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .muster-board > .muster-summary { grid-template-columns: minmax(0, 1fr); }
  .muster-board > .muster-summary > .recruit-bill { grid-column: 1; grid-row: auto; margin-top: 6px; }
  /* A phone tile is ~68 px wide: the drawing, the name and the figures stack
     rather than share a line too narrow for any of them. */
  .muster-board > .recruit-pick .recruit-tile { grid-template-areas: "art" "name" "stat"; grid-template-columns: minmax(0, 1fr); justify-items: center; padding: 3px 2px; }
  .muster-board > .recruit-pick .recruit-tile .tile-name,
  .muster-board > .recruit-pick .recruit-tile .tile-stat,
  .muster-board > .recruit-pick .recruit-tile.is-locked .tile-lock { text-align: center; font-size: 9px; }
  .muster-board > .recruit-pick .recruit-tile .tile-name { font-size: 9px; letter-spacing: 0; }
  /* "Needs Crossbow Workshops" took three lines and pushed the presets under
     the sheet's floor; two lines and the tooltip carry it. */
  .muster-board > .recruit-pick .recruit-tile.is-locked .tile-lock { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
  .muster-board { gap: 6px; }
  .muster-presets { margin-top: 4px; }
  /* The phone sheet gave the muster 117 px under the army card (390x844), so
     the board scrolled 424 px in it. The card is the host's own figures, not
     the muster's; on this tab it steps aside and the board has the sheet. */
  .cmd-pane:has(.muster-board) > .cmd-info { display: none; }
}
@media (pointer: coarse) {
  .muster-board button, .muster-board input, .muster-details > summary { min-height: 44px; }
}

/* Report a bug (ui/bugReport.js). Above every screen, the battle view (120) and
   the lobby included, because F8 opens it from all of them. Nothing in it
   scrolls: the three text boxes give up height first, and on a short window the
   two side-by-side ones and the thumbnails shrink until the card fits. */
.bug-report {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
}
.bug-report[hidden] { display: none; }
.bug-card {
  width: min(760px, 100%);
  height: min(100%, 620px);
  max-height: none;
}
.bug-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 16px;
  overflow: hidden;
}
.bug-field { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.bug-field > span, .bug-shots-head > span:first-child {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
/* Only the text boxes give: every other row keeps its own height, so a short
   window takes lines from the boxes rather than laying rows over each other. */
.bug-body > * { flex-shrink: 0; }
.bug-field textarea { resize: none; flex: 1 1 auto; min-height: 2.6em; font: 13px/1.4 var(--font-body); }
/* The floor is a label and two lines: a textarea's own minimum is its `rows`,
   which would stop it shrinking at all. */
.bug-body > .bug-grow, .bug-body > .bug-row:has(.bug-grow) { flex: 1 1 auto; min-height: 52px; }
.bug-row > .bug-grow { min-height: 52px; }
.bug-body > .bug-grow { flex-grow: 2; }
.bug-grow textarea { min-height: 0; height: 0; }
.bug-row { display: flex; gap: 10px; }
.bug-row > .bug-field { flex: 1 1 0; }
.bug-row-top > .bug-title { flex-grow: 2.2; }
.bug-shots-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px; }
.bug-shot-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.bug-shot-actions .btn { padding: 5px 9px; font-size: 12px; }
.bug-shots { list-style: none; margin: 0; padding: 0; display: flex; gap: 8px; flex: 0 0 auto; }
.bug-shot { position: relative; width: 132px; aspect-ratio: 16 / 10; flex: 0 1 132px; min-width: 0; }
.bug-shot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-sm);
  background: var(--sea-deep);
}
.bug-shot-drop {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: rgba(20, 33, 44, 0.82);
  color: var(--parchment);
  font-size: 11px;
  cursor: pointer;
}
.bug-shot-empty { font-size: 12px; color: var(--ink-faint); padding: 6px 0; }
.bug-check { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink-soft); }
.bug-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid var(--rule);
}
.bug-status { flex: 1; min-width: 0; font-size: 12px; color: var(--ink-soft); }
.bug-status[data-tone="bad"] { color: var(--bad); }
.bug-card .btn-primary { background: linear-gradient(180deg, #d9b45a, #b48a2c); border-color: #8d6a1e; color: #1d160b; font-weight: 600; }
.menu-report-bug {
  background: none;
  border: 0;
  padding: 0;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-decoration: underline;
  cursor: pointer;
}
@media (max-width: 620px) {
  .bug-row { flex-direction: column; gap: 6px; }
  .bug-row > .bug-field { flex: 0 0 auto; }
  .bug-row > .bug-grow { flex: 1 1 auto; }
  /* Stacked, that row holds two boxes, so its floor is two. */
  .bug-body > .bug-row:has(.bug-grow) { min-height: 110px; }
  .bug-card { height: min(100%, 760px); }
  .bug-row-top { display: grid; grid-template-columns: 1fr 1fr; }
  .bug-row-top > .bug-title { grid-column: 1 / -1; }
  .bug-body { padding: 8px 12px; gap: 6px; }
  .bug-shot { flex-basis: 96px; }
  .bug-status { display: none; }
  .bug-foot { justify-content: flex-end; padding: 8px 12px; }
}
@media (max-height: 520px) {
  .bug-body { gap: 4px; padding-top: 6px; padding-bottom: 6px; }
  .bug-row, .bug-row-top { display: flex; flex-direction: row; }
  .bug-row > .bug-field { flex: 1 1 0; }
  .bug-shot { flex-basis: 72px; }
  .bug-field > span { font-size: 10px; }
  .bug-card .overlay-head { padding-top: 6px; padding-bottom: 6px; }
  .bug-check { font-size: 11.5px; }
}
/* A phone on its side: the screenshot buttons go beside the thumbnails' label
   and the thumbnails shrink, which is what the text boxes need to keep two lines. */
@media (max-height: 400px) {
  .bug-body { gap: 3px; }
  .bug-field textarea { padding-top: 4px; padding-bottom: 4px; }
  .bug-shot-actions .btn { padding: 3px 8px; font-size: 11.5px; }
  .bug-shot { flex-basis: 54px; }
  .bug-foot { padding-top: 5px; padding-bottom: 5px; }
  .bug-status { font-size: 11px; }
}

/* Orders stays one compact sheet. Optional route/commander editors open above
   it, keeping the everyday buttons and current status together. */
.cmd-tray.orders-sheet { display: flex; flex-direction: column; flex-wrap: nowrap; gap: 7px; overflow: visible; padding: 8px 10px; }
.orders-sheet .orders-actions { flex: 0 0 auto; margin: 0; gap: 5px; }
.orders-sheet .cmd-tray-note { flex-basis: auto; margin: 0; font-size: 11px; line-height: 1.35; }
.orders-menus { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.orders-menus .cmd-hint { margin: 0; font-size: 10px; }
.orders-menu > summary { cursor: pointer; padding: 4px 7px; border: 1px solid var(--rule-strong); border-radius: 4px; font-size: 11px; }
.orders-popover { position: absolute; z-index: 75; right: 0; bottom: calc(100% + 12px); width: min(480px, calc(100vw - 24px)); padding: 12px; box-sizing: border-box; background: var(--paper); color: var(--ink); border: 1px solid var(--rule-strong); border-radius: 8px; box-shadow: 0 5px 20px #0005; }
.orders-popover .march-queue { margin: 4px 0; }
@media (pointer: coarse) { .orders-menu > summary { min-height: 36px; display: flex; align-items: center; } }

.orders-status { display: grid; grid-template-columns: 1fr; gap: 3px; font-size: 11px; }
.orders-status > small { font-size: 10px; color: var(--ink-soft); }
.orders-status[data-status="battle"] > strong { color: var(--bad); }
.orders-gauge { display: grid; grid-template-columns: 90px minmax(60px, 1fr) 65px; align-items: center; gap: 6px; font-size: 10px; }
.orders-gauge progress { width: 100%; height: 9px; accent-color: #527a55; }
.orders-gauge b { text-align: right; font-weight: 500; }

/* A continuing campaign battle: strength and losses, both falling tick by tick (DESIGN §4.3). */
.bp-fight { display: grid; gap: 3px; padding: 6px 0; border-block: 1px solid var(--rule); }
.bp-fight-row { display: grid; grid-template-columns: minmax(0, 1fr) 4.5em 4.5em; align-items: baseline; gap: 6px; font-variant-numeric: tabular-nums; }
.bp-fight-row > :not(:first-child) { text-align: right; }
.bp-fight-row .bp-owner { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bp-fight-key { font-size: 10px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .04em; }
.bp-retreat-confirm { display: grid; gap: 7px; border-top: 1px solid var(--rule); padding-top: 7px; }
.bp-retreat-confirm[hidden] { display: none; }

/* Settlement outcomes share the command tray on desktop and phones. */
.settlement-controls { display: grid; gap: 8px; min-width: 0; }
.settlement-controls p { margin: 0; }
.settlement-controls label { display: grid; gap: 4px; min-width: 0; }
.settlement-controls select { width: 100%; min-width: 0; }
.settlement-choices { display: flex; flex-wrap: wrap; gap: 8px; }
.settlement-choices button { min-height: 44px; flex: 1 1 70px; }
.settlement-choices button[aria-pressed="true"] { outline: 2px solid #b99b65; outline-offset: -2px; }

/* Every host uses the same compact reference card; commander profiles and
   detailed bonuses live beside their controls in the Orders menus. */
#armyPanel .cmd-info .cmd-kind { display: none; }
#armyPanel .cmd-info .cmd-id { padding-bottom: 0; }
#armyPanel .cmd-info .cmd-id h3 { margin-bottom: 4px; }
#armyPanel .cmd-info .cmd-pills { display: inline-flex; margin-top: 0; }
#armyPanel .army-personnel { margin: 0; font-size: 10px; color: var(--ink-soft); }
#armyPanel .army-details p { margin: 8px 0 0; font-size: 11px; }
#armyPanel .army-details .stat-v { white-space: normal; }
#armyPanel .orders-popover .commander-card { margin: 6px 0 8px; background: rgba(43, 35, 24, 0.06); }
#armyPanel > .cmd-info { max-height: min(260px, 40dvh); flex: 0 0 auto; }
#armyPanel .cmd-info .cmd-id { display: flex; flex-direction: row; flex-wrap: wrap; align-items: center; align-content: start; gap: 0 5px; }
#armyPanel .cmd-info .cmd-id h3 { flex: 1 0 100%; }
#armyPanel .cmd-info-top { flex-direction: column; gap: 6px; }
#armyPanel .cmd-info .cmd-id,
#armyPanel .cmd-info .cmd-stats { width: 100%; max-width: 100%; flex: 0 0 auto; }
#armyPanel .cmd-info .cmd-stats { padding-right: 0; }
/* Forming troops share the existing army ledger's height; long queues scroll
   inside their own section without moving the card or the orders tray. */
#armyPanel .army-ledger { position: relative; min-width: 0; }
#armyPanel .army-ledger.has-musters { padding-right: 126px; }
#armyPanel .army-ledger.has-musters > .cmd-kv .stat-v { min-width: 0; white-space: nowrap; }
#armyPanel .army-ledger.has-musters .cmd-gauge-track { flex-shrink: 1; min-width: 10px; }
#armyPanel .army-ledger > .muster-queue { position: absolute; inset: 0 0 0 auto; width: 116px; box-sizing: border-box; margin: 0; padding: 0 0 0 8px; border-top: 0; border-left: 1px solid var(--rule); overflow-y: auto; overflow-x: hidden; scrollbar-width: thin; }
#armyPanel .muster-queue > .label { display: block; font-size: 9px; line-height: 1.2; }
#armyPanel .muster-queue .muster { grid-template-columns: minmax(0, 1fr) auto; gap: 2px 4px; padding-bottom: 4px; border-bottom: 1px solid var(--rule); }
#armyPanel .muster-queue .muster-arm { grid-column: 1 / -1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#armyPanel .muster-queue .muster-count { font-size: 10px; }
#armyPanel .muster-queue .meter { grid-column: 1 / -1; grid-row: 3; min-width: 0; margin: 0; }
#armyPanel .muster-queue .btn { padding: 2px 4px; min-width: 0; font-size: 9px; color: var(--ink); background: rgba(239, 230, 207, 0.1); border-color: var(--rule-strong); }
#armyPanel .muster-queue .meter-track { background: rgba(239, 230, 207, 0.16); }
/* The open army reference takes foreground over rail buttons crossing its
   footprint; the rest of the command layer still lets map presses through.
   The province pane too: at 320x568 the rail's Chronicle button sat over its
   Build tab and took the press (check-map-events.mjs, 7 November 2026). */
#commandBar:has(#armyPanel:not([hidden])),
#commandBar:has(#provincePanel:not([hidden])) { z-index: 66; }

/* Dispatches sit near the top; army meetings use a compact corner prompt. */
#decisionRoot.decisions {
  position: absolute; inset: 0; width: auto; min-width: 0; max-height: none;
  transform: none; overflow: visible; display: block; z-index: 71;
}
/* Diplomacy stays open after declaring war. Its opaque backdrop is at 75;
   diplomatic dispatches must appear above it to show the declaration at once. */
#decisionRoot:has([data-diplomatic-dispatch]) { z-index: 80; }
.dc-stage { position: absolute; inset: var(--chrome-top) 76px 16px; display: grid; place-items: start center; padding-top: 12px; box-sizing: border-box; pointer-events: none; }
.dc-stage .dc-card { width: min(500px, 100%); max-height: 100%; box-sizing: border-box; overflow-y: auto; padding: 0 18px 15px; gap: 11px; border: 1px solid #b99a57; border-radius: 14px; box-shadow: 0 15px 55px #0007; }
.dc-art { position: relative; flex: 0 0 auto; height: clamp(100px, 20vh, 190px); margin: 0 -18px 3px; background: linear-gradient(135deg, #615d46, #273b3c); overflow: hidden; }
.dc-art img { position: absolute; width: 100%; height: 100%; object-fit: cover; z-index: 1; }
.dc-art::after { content: ''; position: absolute; inset: 0; background: linear-gradient(transparent 55%, #162322b8); z-index: 2; }
.dc-art-symbol { position: absolute; inset: 0; display: grid; place-items: center; font-size: 64px; color: #d9bd7b; }
.dc-art-caption { position: absolute; bottom: 12px; left: 18px; color: #fff0cf; text-transform: uppercase; letter-spacing: .16em; font-size: 10px; z-index: 3; }
.dc-stage .dc-title { font-size: 21px; line-height: 1.2; }
.dc-stage .dc-text { font-size: 13px; line-height: 1.55; }
.dc-terms { margin: 0; padding-left: 18px; font-size: 13px; line-height: 1.5; }
.dc-stage .dc-option { padding: 10px 12px; min-height: 48px; }
.dc-stage .dc-fold { min-width: 34px; min-height: 34px; border: 1px solid var(--rule); border-radius: 50%; }
.dc-stage .dc-foot { flex-wrap: wrap; }
.dc-rail { position: absolute; right: calc(12px + env(safe-area-inset-right, 0px)); top: calc(var(--chrome-top) + 55px); bottom: 190px; display: flex; flex-direction: column; align-items: center; gap: 12px; overflow-y: auto; overflow-x: hidden; width: 64px; padding: 5px; pointer-events: none; scrollbar-width: thin; }
.dc-orb { position: relative; pointer-events: auto; flex: 0 0 auto; width: 54px; height: 54px; padding: 0; border: 2px solid #bd9d57; border-radius: 50%; background: #273b3c; color: #f4dca5; cursor: pointer; box-shadow: 0 3px 10px #0007; }
.dc-orb-art { position: absolute; inset: 0; overflow: hidden; border-radius: inherit; display: grid; place-items: center; font-size: 28px; }
.dc-orb-art img { position: absolute; width: 100%; height: 100%; object-fit: cover; z-index: 1; }
.dc-orb-days { position: absolute; bottom: -5px; left: 50%; transform: translateX(-50%); background: #f2e1b8; color: #40351e; border: 1px solid #ad8a44; border-radius: 10px; padding: 1px 5px; font: 700 10px var(--font-body); z-index: 2; white-space: nowrap; }
.dc-orb.is-urgent { border-color: #b94832; }
.dc-orb.is-urgent .dc-orb-days { background: #8c3326; color: #fff3d9; }
.dc-orb:focus-visible, .dc-fold:focus-visible, .dc-option:focus-visible { outline: 3px solid #e7b84a; outline-offset: 3px; }
body.battle-open #decisionRoot { display: none; }
/* The open battle is opaque and covers the whole window, but the map's canvas
   under it is still a layer the compositor keeps and blends
   on every battle frame — GPU work a phone pays for in heat. Hidden once the
   battle's fade-in (240 ms) has finished, so the fade still shows the map;
   `visibility` keeps their layout, so nothing resizes on the way back. */
body.battle-open #mapRoot { visibility: hidden; transition: visibility 0s 240ms; }
@media (max-width: 600px) {
  .dc-stage { inset: calc(var(--chrome-top) + 4px) 64px 10px 8px; }
  .dc-stage .dc-card { padding: 0 11px 12px; gap: 8px; }
  .dc-art { margin-left: -11px; margin-right: -11px; height: 110px; }
  .dc-stage .dc-title { font-size: 17px; }
  .dc-stage .dc-text { font-size: 12px; }
  .dc-option-label { flex-wrap: wrap; }
  .dc-rail { right: 1px; width: 54px; }
  .dc-orb { width: 46px; height: 46px; }
  .dc-clock { white-space: normal; }
}


/* The plan starts beyond the navigation rail, so every row can be pressed. */
.campaign-nav-visible .war-plan {
  left: calc(var(--inset-left) + 8px);
  width: min(340px, calc(100% - var(--inset-left) - 20px));
  z-index: 67;
}

/* Dispatches rise from just above the bottom-right Tutorial button, regardless
   of command-panel height, minimap visibility, or the News drawer. */
#app > #toastRoot.toasts {
  --dispatch-bottom: calc(56px + env(safe-area-inset-bottom, 0px));
  left: auto;
  right: calc(12px + env(safe-area-inset-right, 0px));
  /* `--guide-clear` is the tutorial card's reach up from the bottom edge
     (ui/campaignGuide.js), set only while the card is open: the stack starts
     above it rather than on its buttons (TODO §79). */
  bottom: max(var(--dispatch-bottom), var(--guide-clear, 0px));
  width: min(360px, calc(100vw - 24px));
  max-width: none;
  align-items: stretch;
}
@media (max-width: 700px) {
  #app > #toastRoot.toasts { right: calc(7px + env(safe-area-inset-right, 0px)); }
}
@media (pointer: coarse) {
  #app > #toastRoot.toasts { --dispatch-bottom: calc(64px + env(safe-area-inset-bottom, 0px)); bottom: max(var(--dispatch-bottom), var(--guide-clear, 0px)); }
}
@media (prefers-reduced-motion: reduce) {
  .toast.is-out { transform: none; transition: opacity 700ms ease; }
}
/* On a phone an open decision card (a head-on road meeting, an event) is the
   question on screen, and the dispatch stack rising above the tutorial card ran
   across it: two toasts at y 308..471 over a card at 138..694, 390x844 (TODO §88).
   The stack goes under the card while one is open. It never takes a tap there
   anyway, and every dispatch is also in News. */
@media (pointer: coarse) {
  #app:has(> #decisionRoot :is(.dc-stage, .dc-meetings) > .dc-card) > #toastRoot.toasts { z-index: 60; }
}

.dc-meetings { position: absolute; top: calc(var(--chrome-top) + 12px); right: 84px; width: min(310px, calc(100% - 96px)); max-height: calc(100% - var(--chrome-top) - 32px); overflow-y: auto; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.dc-meeting { padding: 10px 12px; border-left-width: 2px; }
.dc-meeting .dc-title { font-size: 14px; }
.dc-meeting .dc-options { flex-direction: row; flex-wrap: wrap; }
.dc-meeting .dc-option { flex: 1; min-height: 44px; }
.dc-meeting .dc-option-summary { font-size: 10px; }
.dc-meeting .dc-option-label { flex-wrap: wrap; }
.dc-meeting .dc-foot { flex-wrap: wrap; }
.dc-meeting .dc-clock { white-space: normal; }
.settlement-victory {
  position: fixed;
  z-index: 2200;
  top: 20%;
  left: 50%;
  transform: translateX(-50%);
  width: min(560px, calc(100vw - 24px));
  box-sizing: border-box;
  max-height: 70vh;
  overflow: auto;
  padding: 20px;
  border: 2px solid #b99658;
  border-radius: 8px;
  background: #211c17;
  color: #f3e6ca;
  box-shadow: 0 12px 60px #000b;
}
.settlement-victory[hidden] { display: none; }
.settlement-victory h2 { margin: 0 0 10px; }
.settlement-victory .settlement-choices { display: flex; flex-wrap: wrap; gap: 8px; }
.settlement-victory button {
  flex: 1 1 130px;
  padding: 12px;
  min-height: 64px;
  border: 1px solid #c7a568;
  border-radius: 4px;
  background: #ecdbb4;
  color: #211c17;
  cursor: pointer;
}
.settlement-victory button:hover, .settlement-victory button:focus-visible { outline: 2px solid #edc677; background: #fff0cc; }
.settlement-victory button:disabled { opacity: .5; cursor: default; }
.settlement-victory button span { display: block; margin-top: 6px; font-size: 12px; }

/* ---------- screen transitions --------------------------------------------- */

/* The lobby, the battle view and the overlays fade in when they are shown and
   out when they are hidden, instead of cutting. `hidden` still means
   display: none; `allow-discrete` keeps the element drawn for the fade out, and
   `@starting-style` gives the fade in its first frame. The fade is on the
   persistent container and follows only the `hidden` flag, so a panel
   rebuilding its contents (they all rewrite their innerHTML) does not replay
   it — which is why the card inside is not animated as well — and
   a hidden element takes no pointer while it fades, so nothing waits on it. */
.lobby, .overlay, .battle-root {
  transition: opacity 240ms ease-out, display 240ms allow-discrete, visibility 240ms allow-discrete;
}
:is(.lobby.is-hidden, .lobby[hidden], .overlay[hidden], .battle-root[hidden]) { opacity: 0; pointer-events: none; }
@starting-style {
  :is(.lobby, .overlay, .battle-root):not([hidden], .is-hidden) { opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .lobby, .overlay, .battle-root { transition: none; }
}

/* ---------- battle: settings behind a cog, not a bar across the top ------
   The strip of place, sides, mute, pace, Angled, Recentre and Leave took
   61 px of a 768 px iPad and two rows of a phone (player, 6 November 2026:
   "covers most portion of the screen"). It is a panel behind a see-through
   cog at the field's top-right (where How to command was) now; Angled and Recentre are in the navigation
   panel (`.bi-nav`, inputControls.css). `battleView.js` `setSettingsOpen`. */
.battle-root .bv-gear {
  /* The button is the 44 px touch target and is itself invisible; the ring is
     a 34 px circle drawn on ::before and the glyph is centred in both by grid
     (player, 6 November 2026: off-centre, and the ring too wide). */
  position: absolute; z-index: 60;
  top: calc(4px + env(safe-area-inset-top, 0px)); right: calc(4px + env(safe-area-inset-right, 0px));
  display: grid; place-items: center; width: 44px; height: 44px; padding: 0;
  border: 0; border-radius: 50%; background: none;
  color: #efe6cf; cursor: pointer; touch-action: none;
}
/* The scaled landscape desktop draws this 44 px button at about 24 real px: reach further into the corner's free side. */
html.landscape-scaled .battle-root .bv-gear { width: 72px; height: 72px; }
.battle-root .bv-gear::before {
  content: ''; grid-area: 1 / 1; width: 34px; height: 34px; box-sizing: border-box; border-radius: 50%;
  border: 1px solid rgba(232, 217, 175, 0.35); background: rgba(16, 15, 10, 0.32);
}
.battle-root .bv-gear svg { grid-area: 1 / 1; position: relative; width: 22px; height: 22px; fill: currentColor; opacity: 0.9; }
.battle-root .bv-gear:hover::before, .battle-root .bv-gear[aria-expanded='true']::before { background: rgba(16, 15, 10, 0.7); border-color: #d7b368; }
.battle-root .bv-gear:focus-visible { outline: 2px solid #edc46e; outline-offset: -3px; }
.battle-root .bv-strip.bv-settings {
  position: absolute; z-index: 61;
  top: calc(52px + env(safe-area-inset-top, 0px)); right: calc(8px + env(safe-area-inset-right, 0px));
  width: min(300px, calc(100vw - 16px)); box-sizing: border-box;
  flex-direction: column; flex-wrap: nowrap; align-items: stretch; gap: 10px;
  padding: 12px; border: 1px solid var(--rule-strong); border-radius: 10px;
}
.battle-root .bv-strip.bv-settings[hidden] { display: none; }
.battle-root .bv-settings .bv-when, .battle-root .bv-settings .bv-armies { display: flex; }
.battle-root .bv-settings .bv-armies { flex-wrap: wrap; gap: 6px 12px; }
.battle-root .bv-settings .bv-place { flex: none; }
.battle-root .bv-settings .bv-speed { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.battle-root .bv-settings .btn { min-height: 44px; width: 100%; }
/* The guide is in the settings; the HUD's own corner button would be a second copy. */
.battle-root .bh-help { display: none; }

/* **The view group: Angled, Recentre, Pan at the field's top left**, half
   see-through so the ground shows through it (player, 6 November 2026).
   `battleView.js` builds it; Pan toggles the controller's pan mode. */
.battle-root .bv-camera {
  position: absolute; z-index: 32;
  /* Under the strength bar, whose side names reach the left on an iPad. */
  top: calc(48px + env(safe-area-inset-top, 0px)); left: calc(6px + env(safe-area-inset-left, 0px));
  display: flex; gap: 4px;
}
.battle-root .bv-cam-btn {
  display: inline-flex; align-items: center; gap: 4px; min-height: 36px; padding: 0 9px;
  border: 1px solid rgba(232, 217, 175, 0.35); border-radius: 18px;
  background: rgba(16, 15, 10, 0.45); color: #efe6cf;
  font: 600 11px/1 Inter, system-ui, sans-serif; cursor: pointer; touch-action: manipulation;
}
.battle-root .bv-cam-btn svg { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linejoin: round; stroke-linecap: round; }
.battle-root .bv-cam-btn[aria-pressed='true'] { border-color: #d7b368; color: #ffe6a6; background: rgba(78, 58, 16, 0.6); }
.battle-root .bv-cam-btn:focus-visible { outline: 2px solid #edc46e; outline-offset: 2px; }
/* On a narrow phone the group is icons only. */
@media (max-width: 600px) {
  .battle-root .bv-cam-btn { width: 40px; min-height: 40px; padding: 0; justify-content: center; border-radius: 50%; }
  .battle-root .bv-cam-btn span { display: none; }
  .battle-root .bv-cam-btn svg { width: 18px; height: 18px; }
}

/* **The settings panel sized for its words** (player, 6 November 2026:
   "re-arrange its buttons, they are too large for a short text"): two
   columns of compact buttons, Leave across the foot. */
.battle-root .bv-strip.bv-settings { width: min(260px, calc(100vw - 16px)); gap: 8px; padding: 10px; display: grid; grid-template-columns: 1fr 1fr; }
.battle-root .bv-strip.bv-settings[hidden] { display: none; }
.battle-root .bv-settings .bv-when, .battle-root .bv-settings .bv-place,
.battle-root .bv-settings .bv-armies, .battle-root .bv-settings .bv-speed,
.battle-root .bv-settings .bv-leave { grid-column: 1 / -1; }
.battle-root .bv-settings .btn { min-height: 36px; padding: 4px 8px; font-size: 12px; }
.battle-root .bv-settings .bv-speed select { min-height: 36px; padding: 2px 6px; }
/* Pace under the sides, then the four short buttons as a 2x2, Leave last. */
.battle-root .bv-settings .bv-speed { order: 1; }
.battle-root .bv-settings .btn { order: 2; }
.battle-root .bv-settings .bv-leave { order: 3; }

/* ---- Real-device playtest, 8 November 2026 ------------------------------- */

/* iPad, 1366x992. The city card clamped its terrain text to two lines (28 px of
   82) and a finger's taller controls pushed the Orders tray's last row, the
   commander and Army details, off the foot of the screen at the 252 px cap. A
   tablet has the height to spare; a card that hangs from the floor grows up. */
@media (min-width: 1000px) and (min-height: 700px) {
  .cmd-info .cmd-id-sub { display: block; -webkit-line-clamp: none; line-clamp: none; max-height: none; overflow: visible; }
}
@media (pointer: coarse) and (min-width: 1000px) and (min-height: 700px) {
  :root { --cmd-h: 320px; }
}

/* A tab's name takes two lines rather than an ellipsis on a touch screen. */
@media (pointer: coarse) {
  .cmd-switch-name { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; white-space: normal; line-height: 1.1; }
}

/* Phone: the Orders tray keeps its last row reachable and says that it scrolls
   (a shadow at whichever edge has more), as CLAUDE.md asks of any scroller. The
   popovers stay unclipped: their containing block is `.cmd-act`, outside this. */
body.narrow-viewport:not(.cmd-folded) .cmd-tray.orders-sheet,
body.short-viewport:not(.cmd-folded) .cmd-tray.orders-sheet {
  overflow-y: auto; min-height: 0;
  background:
    linear-gradient(rgba(236, 225, 199, 1) 30%, rgba(236, 225, 199, 0)) top / 100% 24px no-repeat local,
    linear-gradient(rgba(236, 225, 199, 0), rgba(236, 225, 199, 1) 70%) bottom / 100% 24px no-repeat local,
    radial-gradient(farthest-side at 50% 0, rgba(43, 35, 24, 0.35), transparent) top / 100% 8px no-repeat scroll,
    radial-gradient(farthest-side at 50% 100%, rgba(43, 35, 24, 0.35), transparent) bottom / 100% 8px no-repeat scroll;
}
@media (max-width: 480px) {
  /* What a phone clipped to one line, or set below reading size. */
  .slot-plaque .slot-why { white-space: normal; }
  .muster-board > .recruit-pick .recruit-tile .tile-name { white-space: normal; overflow-wrap: anywhere; line-height: 1.05; font-size: 10.5px; }
  .muster-board > .recruit-pick .recruit-tile.is-locked .tile-lock { -webkit-line-clamp: 3; line-clamp: 3; font-size: 10px; }
  .cmd-tray-note, .orders-sheet .cmd-tray-note, .orders-menus .cmd-hint { font-size: 12px; }
}

/* The army's Orders got 117 px of an open bar because the tabs wrapped to two
   rows (94 px) and the stats ran one to a line (156 px). */
@media (max-width: 480px) {
  #armyPanel .cmd-tabbar.cmd-seg, #provincePanel .cmd-tabbar.cmd-seg { gap: 0; padding: 2px; }
  #armyPanel .cmd-tabbar.cmd-seg > *, #provincePanel .cmd-tabbar.cmd-seg > * { padding: 5px 6px; font-size: 11px; min-height: 40px; }
  #armyPanel .cmd-info .cmd-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 10px; max-width: none; width: 100%; }
  #armyPanel .cmd-info .cmd-stats > * { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; }
  #armyPanel .cmd-info .cmd-stats .stat-v { white-space: normal; overflow: visible; }
}

/* Touch targets a finger misses: a wider hit area, without moving the layout. */
@media (pointer: coarse) {
  .perk-orb, .diplo-expand, .tax-tier { position: relative; }
  .perk-orb::after, .diplo-expand::after, .tax-tier::after { content: ''; position: absolute; inset: -7px; }
}

/* ---- Skills in motion (js/ui/skillsGuide.js): the battle skills animated, a row per troop ---- */
.direct-head .direct-help-open, .direct-head .direct-settings-open, .direct-head [data-act="close"] {
  width: 36px; height: 36px; padding: 0; display: inline-flex; align-items: center; justify-content: center; font-size: 20px; line-height: 1;
}
.direct-help-open .direct-cog { font-family: var(--font-head); font-weight: 700; }
.direct-demo-open .direct-cog { font-size: 15px; }
.sg-root { position: fixed; inset: 0; z-index: 9000; overflow-y: auto; background: radial-gradient(ellipse at top, #22201a, #0f0e09 60%); color: #e8dcbc; font-family: var(--font-body); }
.sg-sheet { position: relative; min-height: 100%; }
.sg-close { position: fixed; top: 12px; right: 16px; z-index: 1; width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; font-size: 20px; line-height: 1; border-radius: 6px; border: 1px solid rgba(242, 231, 205, 0.25); background: rgba(242, 231, 205, 0.06); color: #e8dcbc; cursor: pointer; }
.sg-close:hover { background: rgba(242, 231, 205, 0.14); }
.sg-header { padding: 28px 60px 8px; text-align: center; }
.sg-header h2 { font-family: var(--font-head); font-weight: 600; letter-spacing: 0.18em; margin: 0; font-size: clamp(20px, 4vw, 34px); color: #d7a73f; }
.sg-header p { color: #9c8f6e; margin: 6px 0 0; font-size: 13px; }
.sg-reel { max-width: 1400px; margin: 0 auto; padding: 16px; display: flex; flex-direction: column; gap: 22px; }
.sg-row { display: grid; grid-template-columns: 240px 1fr; gap: 16px; padding-top: 18px; border-top: 1px solid #3a3424; }
.sg-unit h3 { margin: 0 0 6px; font-family: var(--font-head); font-size: 19px; letter-spacing: 0.08em; color: #d7a73f; }
.sg-unit p, .sg-meta p { margin: 6px 0 0; font-size: 12px; line-height: 1.45; color: #c9bd9c; }
.sg-root .sg-s { color: #5fd83f; }
.sg-root .sg-w { color: #ef8ab8; }
.sg-skills { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.sg-card { background: #1b1a12; border: 1px solid #3a3424; border-radius: 10px; overflow: hidden; transition: transform 0.25s, border-color 0.25s, box-shadow 0.25s; }
.sg-card:hover { transform: translateY(-3px); border-color: #d7a73f; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); }
.sg-card canvas { display: block; width: 100%; aspect-ratio: 320 / 200; cursor: ew-resize; }
.sg-bar { height: 2px; background: #2b271c; }
.sg-bar i { display: block; height: 100%; width: 0; background: #d7a73f; }
.sg-meta { padding: 10px 12px 12px; }
.sg-meta h4 { margin: 0; font-family: var(--font-head); font-size: 15px; letter-spacing: 0.08em; display: flex; justify-content: space-between; gap: 8px; align-items: baseline; color: #e8dcbc; }
.sg-meta h4 small { font-family: var(--font-body); font-size: 10px; letter-spacing: 0.1em; color: #9c8f6e; text-transform: uppercase; }
.sg-section { grid-column: 1 / -1; font-family: var(--font-head); font-weight: 600; letter-spacing: 0.16em; text-align: center; color: #d7a73f; font-size: clamp(16px, 3vw, 24px); margin: 28px 0 0; padding-top: 20px; border-top: 1px solid rgba(215, 167, 63, 0.3); }
.sg-section-note { grid-column: 1 / -1; text-align: center; color: #9c8f6e; font-size: 13px; margin: 6px 0 4px; }
@media (max-width: 720px) {
  .sg-row { grid-template-columns: 1fr; }
  .sg-skills { grid-template-columns: 1fr; }
  .sg-header { padding: 22px 56px 6px; }
}
.sg-unit-card { margin-bottom: 10px; pointer-events: none; }

/* **The muster panel is the size of the others** (player, 21 November 2026:
   "the muster panel same size as split, disband, merge … put the units on the
   left, stacked, and the muster buttons with the cost on the right"). It was
   512 x 296 against their 512 x 212 (1280 x 720), because the board lifted the
   panel's caps and laid the picker across the top. On a desktop the board is
   now two columns inside the shared panel: the ten arms stacked on the left in
   two columns of five rows, and count, Max, Muster, the presets and the bill on
   the right. Phones keep their stacked board (max-width 700 px, above). */
@media (min-width: 701px) {
  .command-bar:has(.muster-board) { max-height: none; }
  .cmd-tray:has(.muster-board) { overflow: auto; }
  .cmd-act:has(.muster-board) { width: min(660px, calc(100vw - var(--col-w) - 644px)); min-width: 400px; height: var(--cmd-panel-h, var(--cmd-h)); max-height: var(--cmd-h); }
  .cmd-pane > .cmd-act:has(.muster-board) { justify-self: center; margin-left: 0; }
  .muster-board,
  .muster-board:has(> .muster-queue) { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 4px 10px; }
  .muster-board > .recruit-pick { grid-column: 1; grid-row: 1 / span 3; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-flow: row; gap: 1px 2px; }
  .muster-board > .recruit-pick .recruit-tile { display: grid; grid-template-columns: 16px minmax(0, 1fr); grid-template-areas: "art name" "art stat"; column-gap: 4px; align-items: center; justify-items: start; padding: 0 4px; min-height: 0; text-align: left; }
  .muster-board > .recruit-pick .recruit-tile .tile-art { grid-area: art; }
  .muster-board > .recruit-pick .recruit-tile .tile-art img,
  .muster-board > .recruit-pick .recruit-tile .tile-art svg { width: 16px; height: 16px; }
  .muster-board > .recruit-pick .recruit-tile .tile-name { grid-area: name; font-size: 10px; line-height: 1.05; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .muster-board > .recruit-pick .recruit-tile .tile-stat { grid-area: stat; font-size: 9px; line-height: 1.05; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  .muster-board > .muster-summary,
  .muster-board:has(> .muster-queue) > .muster-summary { grid-column: 2; grid-row: 1; display: block; }
  .muster-board > .muster-summary .recruit-bill { margin-top: 2px; padding: 2px 0; line-height: 1.2; font-size: 11px; }
  .muster-board > .muster-summary .muster-presets { margin-top: 3px; }
  .muster-board > .muster-summary .muster-presets .btn { padding-block: 1px; }
  .muster-board > .muster-summary .muster-reason { margin-top: 2px; font-size: 10px; line-height: 1.2; }
  .muster-board > .muster-details,
  .muster-board:has(> .muster-queue) > .muster-details { grid-column: 2; grid-row: 2; }
  .muster-board > .muster-details > summary { padding: 0; }
  .muster-board:has(> .muster-queue) > .muster-queue { grid-column: 2; grid-row: 3; border-left: 0; padding-left: 0; border-top: 1px solid var(--rule); padding-top: 3px; }
}
