*, *::before, *::after { box-sizing: border-box; }
:root {
  --bg: rgb(16,12,9); --card: rgb(36,32,21); --card-hi: rgb(48,44,29); --well: rgb(24,20,12);
  --border: rgb(60,54,35); --border-gold: rgb(150,118,48);
  --gold: rgb(214,180,110); --tan: rgb(200,186,144); --muted: rgb(180,162,118); --dim: rgb(162,146,100);
  --green: rgb(136,168,92); --amber: rgb(214,164,70); --red: rgb(247,101,62); --purple: rgb(166,122,196);
  --btn: rgb(52,42,26); --btn-ok: rgb(40,50,26); --ok-fg: rgb(158,196,104); --btn-no: rgb(56,26,18); --no-fg: rgb(224,112,80);
  --bevel-l: rgb(96,86,54); --bevel-d: rgb(7,5,3); --outline: rgb(0,0,0); --brown: rgb(104,70,34);
  --serif: 'Alegreya', Georgia, 'Times New Roman', serif;
  --sans: 'Alegreya Sans', 'Gill Sans', 'Trebuchet MS', system-ui, sans-serif;
}
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--tan); font: 20px/1.35 var(--sans); }
/* 100vh first as the fallback for a browser with no dvh support; 100dvh
   after it wins wherever it is supported, so the app shrinks with the
   on-screen chrome (Safari's URL bar) instead of being covered by it. The
   safe-area padding then reserves the home-indicator strip - .cta-row's own
   margin-top: auto (.pane) keeps it pinned just above that padding, not
   past it. */
/* position: relative anchors .scrim's inset:0 to the app, not the viewport -
   same visual result at this size (.app already fills the viewport) but the
   correct containing block regardless. */
#app, .app { position: relative; width: 100vw; height: 100vh; height: 100dvh; overflow: hidden; display: flex; flex-direction: column; padding-bottom: env(safe-area-inset-bottom); }
.body-row { flex: 1 1 0; min-height: 0; display: flex; overflow: hidden; }
.display { font: 600 34px/1.1 var(--serif); color: var(--gold); }
.body { font: 20px/1.35 var(--sans); color: var(--tan); margin: 0; text-wrap: pretty; }
.body.secondary { font-size: 18px; color: var(--muted); }
/* A quest's own loss condition, paired under its advance sentence (the quest
   sheet's condition-stage row, sheet_quest.js) - the same red the cta-no/
   is-danger treatments already use for "this goes badly". */
.body.no { color: var(--no-fg); }
.label { font: 700 13px/1 var(--sans); letter-spacing: .09em; text-transform: uppercase; color: var(--dim); }
/* A set/expansion icon (Task 5, seticon.js): sized inline by the caller's
   style="width/height" (18-22px everywhere it appears), img filling that box
   until it 404s - app.js's one delegated `error` listener adds is-missing,
   which is what actually swaps the vector for the diamond glyph. Never both
   at once. */
.seticon { display: inline-flex; align-items: center; justify-content: center; flex: none; }
.seticon img { width: 100%; height: 100%; display: block; }
.seticon-fallback { font-style: normal; font-size: 13px; line-height: 1; color: var(--dim); }
.seticon.is-missing img { display: none; }
.seticon:not(.is-missing) .seticon-fallback { display: none; }
/* A card thumbnail (Task 6, cardimage.js): the printed art at 96px wide in a
   5:7 card aspect, with the card's name as its caption. The caption is not
   decoration - when there is no art (no pinned imagePrefix, an offline
   reload with a cold cache, a 404) it is ALL there is, so it is BODY, and
   app.js's delegated `error` listener adds .is-missing here exactly as it
   does for .seticon above. The --well ground is what the box shows while the
   picture is still arriving, so a list of rows does not reflow as they land. */
.card-frame { width: 96px; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.card-frame img { width: 100%; aspect-ratio: 5/7; object-fit: cover;
  background: var(--well); border-radius: 4px; display: block; }
.card-frame.is-missing img { display: none; }
/* The caption is a card NAME - a player reads it as a name, so it is BODY at
   the tablet's own 20px (CLAUDE.md iron rule 3b). It carried a font-size:
   18px override until the M5 final review; 18 is .secondary's size, and
   "running out of room is never a reason to shrink text". */
.num { font-family: var(--sans); font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; color: var(--gold); }
.num-26 { font-size: 26px } .num-34 { font-size: 34px } .num-36 { font-size: 36px } .num-40 { font-size: 40px } .num-48 { font-size: 48px } .num-56 { font-size: 56px } .num-64 { font-size: 64px } .num-84 { font-size: 84px }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation;
  -webkit-tap-highlight-color: transparent; user-select: none; }
/* Press feedback: every button here is beveled light-top/left, dark-bottom/
   right at rest (see .chip/.cta/.step below) - invert that on press so the
   surface reads as pushed in, plus a 1px nudge toward the surface. Generic
   on the element, not a per-component class, so it covers every button
   (chip, cta, step, the new-game scenario-row) for free. */
button:active { border-top-color: var(--bevel-d); border-left-color: var(--bevel-d);
  border-bottom-color: var(--bevel-l); border-right-color: var(--bevel-l);
  transform: translateY(1px); }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 0 14px; background: var(--btn);
  border: 1px solid var(--bevel-l); border-bottom-color: var(--bevel-d); border-right-color: var(--bevel-d);
  border-radius: 6px; font: 700 13px/1 var(--sans); letter-spacing: .08em; text-transform: uppercase; white-space: nowrap; }
.chip-gold { color: var(--gold) } .chip-tan { color: var(--tan) } .chip-amber { color: var(--amber) }
.cta { display: flex; align-items: center; justify-content: center; height: 64px; padding: 0 24px; border-radius: 8px;
  border: 1px solid; border-bottom: 3px solid var(--bevel-d); font: 600 22px/1 var(--sans); white-space: nowrap; }
.cta.grow { flex: 1 1 0 } .cta-ok { background: var(--btn-ok); color: var(--ok-fg); border-color: var(--green) }
.cta-skip { background: var(--card); color: var(--amber); border-color: var(--amber) }
.cta-plain { background: var(--btn); color: var(--tan); border-color: var(--bevel-l) }
.cta-no { background: var(--btn-no); color: var(--no-fg); border-color: var(--red) }
.step { width: 64px; height: 52px; background: var(--btn); border: 1px solid var(--bevel-l); border-bottom-color: var(--bevel-d); border-right-color: var(--bevel-d); border-radius: 6px; font-size: 30px; color: var(--tan); }
.step-sm { width: 44px; height: 44px; font-size: 22px; }
/* A stepper that cannot act (allocator +/- at its cap, docs/tablet/js/pane.js's
   allocStep()) renders as this instead of .step: same footprint, no bevel,
   no background, dim glyph - and it is a <span>, never a <button>, so it is
   not a tap target at all. */
.step-off { display: inline-flex; align-items: center; justify-content: center; background: transparent; border: 1px solid transparent; color: var(--dim); }
.band { display: flex; gap: 16px; align-items: center; padding: 10px 12px 10px 18px; background: var(--card); border: 1px solid var(--border); border-left: 6px solid; border-radius: 6px; }
.band-framework { border-left-color: var(--red) } .band-window { border-left-color: var(--green) } .band-tip { border-left-color: var(--gold) }
.band-text { display: flex; flex-direction: column; gap: 6px; min-width: 0; flex: 1 1 0 }
/* The band's own "Rules §n ›" chip (Task 3, milestone 5) is the last child
   of .band-text's column - without this it inherits that column's default
   align-items: stretch and blows up to the full width of the band, looking
   like a second CTA instead of a chip. Same fix .esheet-choice > .cta
   already applies to a button inside a column flex for the same reason. */
.band-text > .chip { align-self: flex-start; }
.counter { display: flex; flex-direction: column; gap: 10px; padding: 12px 16px; background: var(--card); border: 1px solid var(--border); border-radius: 8px; flex: 1 1 0; min-width: 0 }
.counter-row { display: flex; align-items: center; justify-content: space-between; gap: 12px }
.counter-value { display: flex; align-items: center; gap: 14px }
/* gap/padding trimmed by 2px each when the log block's header row grew to
   44px (milestone 4's "Open ›"): the rail is a fixed-height column that
   CLIPS (overflow: hidden), and the thing at the bottom edge to lose is the
   view prompt. 12px back across the three zones, 20px more out of the log
   block's own spacing below - the block keeps all four rows. */
.zone { display: flex; flex-direction: column; gap: 6px; padding: 8px 10px 8px; border: 1px solid var(--border); border-top: 3px solid; border-radius: 8px; min-width: 0 }
/* min-height: the spec allows a 30-36px header chip (the "Edit ->" chip
   below) only inside a row that is itself >=44px tall - the row carries the
   tap-target floor, not the chip (review finding I4). */
.zone-head { display: flex; align-items: center; gap: 8px; min-height: 44px } .zone-head .label { color: var(--gold) }
/* The zone's one tap target (milestone 3): "Edit ›", pushed to the header's
   far right. */
.zone-head .chip { margin-left: auto }
.zone-gold { border-top-color: var(--gold) } .zone-green { border-top-color: var(--green) } .zone-outline { border-top-color: var(--outline) }
.ground-card { background: var(--card) } .ground-well { background: var(--well) }

/* Transport strip (Task 3): one segment per phase, one tick per flow view. */
.strip { height: 96px; display: flex; align-items: stretch; gap: 8px; padding: 12px 18px; background: var(--well); border-bottom: 1px solid var(--border); overflow: hidden; }
/* `.round` was a single flex column (ROUND label, then the round-row). The
   replay transport (Task 2, milestone 4) adds two more children - the
   button row and its "Step n/N" readout - and there is no headroom to just
   stack them underneath: `.strip`'s content box is 96 - 2*12(padding) =
   72px tall, and a naive four-row stack (13 + 44 + 44 + 13, plus three 4px
   gaps) comes to 126px. So this is a 2x2 grid instead of a column: column 1
   keeps the existing ROUND label over the round-row, column 2 puts the new
   readout over the transport row - two 13px LABEL rows side by side on top,
   two 44px rows (round-row's own min-height, .tbtn's own height) side by
   side underneath. That is 13 + 4(row-gap) + 44 = 61px, inside the 72px
   budget with room to spare - `align-content: center` centers the block in
   the leftover 11px, same job `justify-content: center` did on the old flex
   column. Nothing about the strip's own 96px/12px padding changes; the fit
   is entirely this rule's doing, at the cost of `.round` growing wider
   (flex: 0 0 auto already lets the segs give up the width). */
.round { display: grid; grid-template-columns: auto auto; grid-template-rows: auto auto;
  align-items: center; align-content: center; column-gap: 16px; row-gap: 4px;
  flex: 0 0 auto; padding: 0 14px 0 0; }
/* The ROUND label is column 1/row 1; :first-child picks it out from
   .transport-readout, the grid's OTHER .label (column 2/row 1) - that one
   places itself, below. */
.round > .label:first-child { grid-column: 1; grid-row: 1; }
/* The round number and the "Menu ›" chip (milestone 3) share one row rather
   than stacking a third line under ROUND/num - the strip is only 96px tall.
   min-height: same reasoning as .zone-head above (review finding I4) - the
   "Menu ›" chip is 30px, so the row it sits in is the thing that has to
   clear the 44px tap-target floor. Column 1/row 2 in `.round`'s grid. */
.round-row { display: flex; align-items: center; gap: 8px; min-height: 44px; grid-column: 1; grid-row: 2; }
/* The transport (Task 2): ⏮ ◀ ▶ ⏭ (primitives.js's transportButton()) -
   bevelled like .chip when canUndo()/canRedo() says the direction is live,
   unbevelled and dimmed (`.is-off`, a <span>, not a <button> - nothing for
   app.js's data-act delegation to catch) when it is not. Glyph-only, so
   min-width rather than width - a floor, not a fixed box. Column 2/row 2,
   beside round-row. */
.transport { display: flex; align-items: center; gap: 6px; grid-column: 2; grid-row: 2; }
.tbtn { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; height: 44px;
  background: var(--btn); border: 1px solid var(--bevel-l); border-bottom-color: var(--bevel-d); border-right-color: var(--bevel-d);
  border-radius: 6px; font-size: 20px; color: var(--tan); }
.tbtn.is-off { background: transparent; border-color: transparent; box-shadow: none; color: var(--dim); opacity: .4; }
/* "Step n/N" - column 2/row 1, above .transport. */
.transport-readout { white-space: nowrap; grid-column: 2; grid-row: 1; }
.seg { position: relative; display: flex; flex-direction: column; justify-content: center; gap: 8px; flex: 1 1 0; min-width: 0; padding: 8px 10px; background: var(--card); border: 1px solid var(--border); border-radius: 8px; }
.seg.is-skippable { background: var(--card-hi); border-color: var(--amber); }
.phase-name { font: 600 18px/1 var(--serif); color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seg:has(.tick.is-done) .phase-name { color: var(--tan); }
.seg:has(.tick.is-current) .phase-name { color: var(--gold); }
.seg.is-skippable .phase-name { color: var(--amber); }
.tick-row { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; }
.skip-note { position: absolute; top: 4px; right: 8px; font: 700 13px/1 var(--sans); letter-spacing: .06em; text-transform: uppercase; color: var(--amber); }
.log-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--btn); color: var(--tan); font: 700 13px/1 var(--sans); font-variant-numeric: tabular-nums; }
.tick { position: relative; display: inline-block; flex: 0 0 auto; }
.tick-framework { width: 22px; height: 22px; border-radius: 2px; background: var(--dim); }
.tick-framework.is-done, .tick-framework.is-current { background: var(--red); }
.tick-window { width: 12px; height: 12px; border-radius: 50%; align-self: center; background: var(--dim); }
.tick-window.is-done, .tick-window.is-current { background: var(--green); }
.playhead { position: absolute; top: -9px; left: 50%; transform: translateX(-50%); width: 0; height: 0; border-left: 5px solid transparent; border-right: 5px solid transparent; border-top: 6px solid var(--gold); }
/* A tick a real delta entered this round (strip.js's renderTick, via
   game.deltaIndexForView) is a rewind target - wrapped in this transparent,
   borderless button rather than restyling the tick itself, so is-done/
   is-current/is-future stay exactly the visual states they always were;
   only the gold outline on :active marks this one as tappable. */
.tick-btn { height: 44px; min-width: 28px; padding: 0 3px; background: transparent; border: 0;
  display: inline-flex; align-items: center; justify-content: center; }
.tick-btn:active .tick { outline: 2px solid var(--gold); }

/* The rail (Task 4): three read-only zones + the log block, pinned bottom. */
.column { width: 324px; display: flex; flex-direction: column; gap: 8px; padding: 12px; background: var(--well); border-right: 1px solid var(--border); overflow: hidden; }
.player-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.player-cell { display: flex; flex-direction: column; gap: 4px; padding: 8px; background: var(--card-hi); border-radius: 6px; min-width: 0; }
.player-cell.is-eliminated { opacity: .6; }
.player-label { display: flex; align-items: center; gap: 4px; }
.player-label.is-first { color: var(--gold); }
.flag { font-size: 13px; color: var(--gold); }
.player-threat { display: flex; align-items: center; gap: 6px; }
.bar { height: 3px; border-radius: 2px; background: var(--gold); }
.bar.bar-danger { background: var(--red); }
.player-stats { display: flex; align-items: center; gap: 12px; }
.stat { display: flex; align-items: center; gap: 4px; }
.stat.is-dim { opacity: .45; }
.player-elim { font: 700 13px/1 var(--sans); letter-spacing: .06em; text-transform: uppercase; color: var(--red); }

.pill { display: flex; flex-direction: column; gap: 4px; padding: 8px 10px; background: var(--card); border: 1px solid var(--border); border-radius: 6px; min-width: 0; }
.pill-dashed { border-style: dashed; background: transparent; }
.pill-compact { flex-direction: column; align-items: flex-start; gap: 4px; padding: 8px; min-width: 0; }
/* flex-start, not space-between: the stage pill (rail.js) now leads with the
   scenario's set icon (Task 5) and the two must sit together at the start of
   the row, not pushed to opposite ends - the header carried only the one
   label span before, so this was invisible until the icon landed. */
.pill-head { display: flex; align-items: center; justify-content: flex-start; gap: 8px; }
.pill-stat { display: flex; align-items: center; gap: 6px; }
.pill-sep { color: var(--dim); }
.pill-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Three stacked pills (caption over icon+number) side by side - a grid, not
   a row, so a long caption ("Locations") never pushes into its neighbor's
   icon at the rail's 324px width. */
.staging-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }

/* gap/padding are tight on purpose: the header row went from a bare 13px
   LABEL to a 44px row when "Open ›" landed in it (milestone 4), and the rail
   is a fixed 1024px column with three sized zones above. The block keeps its
   four rows and its view prompt - the 31px the header cost is paid back out
   of this block's own spacing and .column's gap, not out of a row.

   And it is the column's one flexible member (milestone 4 fix wave): the
   three zones are sized by their content, so on a crowded rail - three
   players, an eliminated one, a stage name AND an active location - the
   column ran 63px over at 1366x1024 and .column's overflow:hidden cut off
   exactly the bottom, which is the prompt row naming the current view.
   min-height:0 is what lets this block shrink below its content (a flex
   item's default min-height:auto forbade it, which is why the column
   overflowed instead), and .log-rows-clip absorbs every pixel of that
   shrink: the block goes 188 -> 125px and its rows area 109 -> 46px.

   Shrink-only (0 1) with the margin still pinning it, NOT grow-and-shrink:
   growing would fill the slack an uncrowded rail has, which measures 146px
   with 2 players and no location - a gap between this block's header and the
   lines it names, and its rule line drifting up under STAGING. The ruling
   asked for the flexible member; the grow half of it buys nothing here,
   because there is nothing above the rows that wants the space. */
.log-block { margin-top: auto; flex: 0 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 4px; padding-top: 4px; border-top: 1px solid var(--border); }
/* The block's name plus its one tap target, "Open ›" (milestone 4). Same
   shape and same reason as .zone-head above: a 30px header-nav chip is
   allowed only inside a row that itself clears the 44px floor. */
.log-head-row { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; min-height: 44px; }
.log-head-row .chip { margin-left: auto; }
/* rail.js always renders four rows; this decides how many are SEEN. It
   clips from the top - flex-end keeps the newest rows and the prompt row
   glued to the bottom of the block - so what a crowded rail costs is the
   oldest line, which is also the least useful one. */
.log-rows-clip { flex: 1 1 auto; min-height: 0; overflow: hidden;
  display: flex; flex-direction: column; justify-content: flex-end; gap: 4px; }
.log-row { flex: 0 0 auto; display: flex; gap: 8px; align-items: baseline; }
.log-time { flex: 0 0 auto; width: 44px; font: 600 13px/1 var(--sans); font-variant-numeric: tabular-nums; color: var(--dim); }
.log-text { flex: 1 1 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 18px; color: var(--muted); }
.log-prompt { flex: 0 0 auto; font: 600 18px/1.2 var(--serif); color: var(--gold); }
/* A line the replay cursor has stepped back past - the same greying the log
   screen's own rows use, so the two surfaces agree at a glance. */
.log-row.is-undone { opacity: .45; }

/* The Game Log screen (milestone 4, Task 3). Two columns: the rows and their
   transport on the left, the explainer plus the per-round index on the right.
   The right column is reference text read WHILE choosing a line, which is
   exactly what a modal could not be. 360px because the explainer's three
   sentences want ~45 characters a line at BODY. */
.logscreen { display: grid; grid-template-columns: 1fr 360px; grid-template-rows: auto 1fr;
  height: 100%; min-height: 0; overflow: hidden; }
.log-head { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between;
  gap: 16px; min-height: 44px; padding: 12px 20px; background: var(--well); border-bottom: 1px solid var(--border); }
.log-main { min-width: 0; min-height: 0; display: flex; flex-direction: column; gap: 12px; padding: 14px 20px 16px; }
.filter-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
/* The one scrolling region on the screen; app.js scrolls it to the selected
   row (or the bottom) after every render. */
.log-rows { flex: 1 1 0; min-height: 0; overflow-y: auto; margin: 0; padding: 0; list-style: none;
  display: flex; flex-direction: column; gap: 4px; }
.log-rows > li { list-style: none; }
/* stamp | time | message. The two fixed columns are the widest each can be
   ("R12.6.1" at LABEL, "12:04" tabular) so the message column's left edge
   never moves as the round rolls over. */
.log-line { display: grid; grid-template-columns: 72px 56px 1fr; gap: 10px; align-items: center;
  width: 100%; min-height: 44px; padding: 0 12px; text-align: left; border-radius: 6px; }
/* Bevelled = tappable, the same rule .scenario-row follows: only a row that
   is a rewind target is a button, and only a button is bevelled. */
button.log-line { background: var(--btn); border: 1px solid var(--bevel-l);
  border-bottom-color: var(--bevel-d); border-right-color: var(--bevel-d); }
.log-line .log-stamp { color: var(--dim); }
/* .log-time is the rail block's 44px-wide flex cell; inside the grid the
   track sets the width. */
.log-line .log-time { width: auto; }
.log-line .log-msg { min-width: 0; font-size: 18px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-line.is-undone { opacity: .45; }
.log-line.is-sel { box-shadow: inset 0 0 0 2px var(--gold); }
.log-foot { display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding-top: 12px; border-top: 1px solid var(--border); }
/* .transport/.transport-readout are the strip's own (they carry grid-column/
   grid-row for .round's 2x2 grid, inert in this flex row). The readout is
   pushed away from the six controls, and the two footer actions to the far
   right. */
.log-foot .transport-readout { margin-right: auto; }
.log-side { grid-column: 2; min-height: 0; overflow-y: auto; padding: 16px;
  border-left: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; }
.log-side .label { color: var(--gold); }
.round-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
/* The gold CTA (the log screen's "Rewind to selected line"): gold ink on the
   button ground, the same pair .chip-gold already ships. Its off state is a
   <span> with no data-act at all - see screen_log.js. */
.cta-gold { background: var(--btn); color: var(--gold); border-color: var(--border-gold); }
.cta.is-off { opacity: .4; }
/* The export sheet's text box: readonly, selectable, and scrollable on its
   own so a 200-line log never stretches the sheet past its max-height. */
.export-text { width: 100%; font: 18px/1.35 var(--sans); color: var(--tan); background: var(--well);
  border: 1px solid var(--border); border-radius: 6px; padding: 10px 12px; resize: none; }

/* The phase panes (Task 5): one view per <main class="pane">, a common
   title row, and a bottom-pinned cta-row shared by every view. */
.pane { flex: 1 1 0; display: flex; flex-direction: column; gap: 12px; padding: 14px 18px 16px; min-width: 0; overflow-y: auto; }
.cta-row { display: flex; gap: 12px; margin-top: auto; }
.pane.gameover { align-items: center; justify-content: center; text-align: center; gap: 16px; }
/* .cta-row's margin-top: auto pins it to the pane's bottom edge, which
   overrides .pane.gameover's own justify-content: center above it - zero it
   out here so the game-over CTA centres with the rest of the pane. */
.pane.gameover .cta-row { margin-top: 0; }
.center { text-align: center; }

/* The loop diagram (loops.js): numbered gold-circle rungs joined by a 2px
   connector, a green 9px dot on any rung that opens an action window. */
.loop { display: flex; flex-direction: column; gap: 10px; }
.loop-rungs { display: flex; flex-direction: column; }
.loop-rung { position: relative; display: flex; gap: 14px; padding-bottom: 16px; }
.loop-rung:last-child { padding-bottom: 0; }
.loop-rung:not(:last-child)::before { content: ""; position: absolute; left: 13px; top: 28px; bottom: 0; width: 2px; background: var(--border-gold); }
.loop-num { flex: 0 0 auto; width: 28px; height: 28px; border-radius: 50%; background: var(--gold); color: var(--bg); display: flex; align-items: center; justify-content: center; font: 700 13px/1 var(--sans); }
.loop-rung-body { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 4px; padding-top: 3px; }
/* First text line + its window dot share a row; the sub-clause (if any)
   sits below, per loop-rung-body's own column stack. */
.loop-rung-line { display: flex; align-items: center; gap: 8px; }
.loop-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--green); flex: 0 0 auto; }
.loop-exit { padding-left: 42px; }
.loop-legend { display: flex; align-items: center; gap: 8px; }

/* An icons_svg.js glyph inlined mid-sentence (quest_resolution's fail line):
   the glyph's own style="display:block" would otherwise break the paragraph
   flow, so wrap it in an inline-flex box - flex items are blockified
   regardless of their own display, so display:block causes no line break
   once it is one. */
.icon-inline { display: inline-flex; align-items: center; vertical-align: -4px; }

/* A quoted/computed preview block: printed card text (Quest Setup) or a
   computed preview (the staging "without actions" line, the enc_checks
   "Checks made" / skip-offer pair). Amber border marks a promoted offer. */
.well { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px; background: var(--well); border: 1px solid var(--border); border-radius: 8px; }
.well-amber { border-color: var(--amber); }

/* Generic two-up row (quest_staging's counters, enc_checks's summary pair). */
.two-col { display: flex; gap: 12px; align-items: flex-start; }
.two-col > * { flex: 1 1 0; min-width: 0; }

/* Quest resolution's progress allocator. */
.alloc { display: flex; flex-direction: column; gap: 10px; }
.alloc-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; background: var(--card); border: 1px solid var(--border); border-radius: 8px; }
.alloc-row-locked { opacity: .85; }
.alloc-label { flex: 1 1 0; min-width: 0; }
.alloc-value { display: flex; align-items: center; gap: 10px; }

/* combat_enemy's engaged steppers: a 4-up grid, one cell per player. */
.eng-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.eng-cell { display: flex; flex-direction: column; gap: 6px; padding: 10px; background: var(--card); border: 1px solid var(--border); border-radius: 8px; }
.eng-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.eng-value { display: flex; align-items: center; gap: 8px; }

/* The new-game / picker screen at tablet density (Task 2, milestone 6):
   three independently-scrolling columns - Players, Cycles, Scenarios -
   instead of the phone-era stacked sections (docs/tablet/js/newgame.js). */
.newgame { gap: 20px; }
.newgame-grid { display: grid; grid-template-columns: 300px 320px 1fr; gap: 18px; height: 100%; }
/* min-height: 0 is load-bearing on a grid/flex item that must itself scroll -
   without it the column refuses to shrink below its content's natural
   height and the grid just grows past the pane instead of clipping each
   column to its own scrollbar. */
.newgame-col { display: flex; flex-direction: column; gap: 10px; overflow-y: auto; min-height: 0; }
.player-chips { display: flex; gap: 10px; }
/* Player-count chips are single digits in an otherwise ALL-CAPS chip row -
   without a floor they pinch down to the glyph's own width and read as a
   different, smaller control than every other chip on the screen. */
.chip-square { min-width: 56px; }
.threat-row { display: flex; gap: 12px; flex-wrap: wrap; }
/* The Official/Community toggle heading the Cycles column. */
.source-toggle { display: flex; gap: 10px; }
.cycle-list { display: flex; flex-direction: column; gap: 8px; }
/* A cycle name is BODY (a name a player reads), its scenario count/year is
   LABEL (dense tabular metadata) - same distinction .scenario-row draws
   below. Bevelled and full-width like every other tappable row on this
   screen; .is-selected swaps the bevel for the card_hi/gold treatment
   .locpick-row's own selected state uses. */
.cycle-row { display: flex; align-items: center; justify-content: space-between;
  gap: 12px; width: 100%; min-height: 56px; padding: 8px 16px; text-align: left;
  background: var(--btn); border: 1px solid var(--bevel-l); border-bottom-color: var(--bevel-d); border-right-color: var(--bevel-d);
  border-radius: 6px; }
.cycle-row.is-selected { background: var(--card-hi); border-color: var(--gold); }
.scenario-list { display: flex; flex-direction: column; gap: 8px; }
/* A scenario name is BODY (a name a player reads), not a chip's ALL-CAPS
   LABEL - so the row is its own beveled, full-width button (same raised
   look as .chip, just left-aligned and roomy enough for its set icon, a
   two-line name + pack, and its stage count) rather than a chip glued to a
   separate label span. */
.scenario-row { display: flex; flex-direction: column; align-items: flex-start; justify-content: center;
  gap: 2px; width: 100%; min-height: 56px; padding: 8px 16px; text-align: left;
  background: var(--btn); border: 1px solid var(--bevel-l); border-bottom-color: var(--bevel-d); border-right-color: var(--bevel-d);
  border-radius: 6px; }
.scenario-head { display: flex; align-items: center; gap: 8px; }

/* The sheet framework (milestone 3, Task 2): a modal overlay - .scrim covers
   the app, .sheet is the panel itself. Every sheet's own content (title,
   rows, footer) stacks with the flex column below; sheets.js's data-stop
   marks the .sheet element so a tap on its body never bubbles to the
   scrim's data-act="sheet_close" (see app.js's click delegation). */
.scrim { position: absolute; inset: 0; background: rgba(0,0,0,.66); display: flex; align-items: center; justify-content: center; }
.sheet { width: 1160px; max-height: 920px; overflow: auto; padding: 20px 24px 22px; background: var(--bg); border: 1px solid var(--border-gold); border-radius: 12px; box-shadow: 0 24px 60px rgba(0,0,0,.6);
  display: flex; flex-direction: column; gap: 16px; }

/* The players sheet: the everyone-at-once chip row, then one row per player
   (id + distance to elimination, threat/willpower/engaged stepper blocks). */
.psheet-everyone { display: flex; gap: 12px; }
.psheet-list { display: flex; flex-direction: column; gap: 10px; }
.psheet-row { display: flex; align-items: center; gap: 16px; padding: 10px 14px; background: var(--card); border: 1px solid var(--border); border-radius: 8px; }
.psheet-row-elim { justify-content: space-between; }
.psheet-id { display: flex; flex-direction: column; gap: 2px; width: 130px; flex: 0 0 auto; }
.psheet-threat { display: flex; align-items: center; justify-content: center; gap: 8px; flex: 1 1 0; }
.psheet-will, .psheet-eng { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.psheet-val { display: flex; align-items: center; gap: 6px; min-width: 56px; justify-content: center; }
/* Overrides .body.secondary's muted colour once a player is within 10 of
   elimination - same threshold the rail's .bar-danger already uses. */
.is-danger { color: var(--red); }

/* The staging editor: threat (±5/±1), enemies (±1), locations (±1). */
.ssheet-rows { display: flex; flex-direction: column; gap: 10px; }
.ssheet-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 14px; background: var(--card); border: 1px solid var(--border); border-radius: 8px; }
.ssheet-controls { display: flex; align-items: center; gap: 8px; }
.ssheet-val { display: flex; align-items: center; gap: 6px; min-width: 56px; justify-content: center; }

/* The elimination sheet (Task 3): three choices, each its own card - confirm,
   avert, or correct the level via a stepper cluster + Set. */
.esheet-choices { display: flex; flex-direction: column; gap: 14px; }
.esheet-choice { display: flex; flex-direction: column; gap: 8px; padding: 12px 16px; background: var(--card); border: 1px solid var(--border); border-radius: 8px; }
/* Direct-child combinator, not a bare descendant one: this must land on the
   confirm/avert choices' own top-level cta (so it doesn't stretch full-width
   in a column flex), and must NOT reach into the third choice's nested Set
   button - that one is a flex item of .esheet-lvl (a row), and align-self
   set there would fight that row's own align-items:center and knock Set out
   of line with the stepper buttons beside it. */
.esheet-choice > .cta { align-self: flex-start; }
/* The Eliminate choice's own "Rules · Player Elimination ›" chip (Task 3,
   milestone 5) is the same column-flex child as its .cta sibling above, and
   needs the same fix for the same reason. */
.esheet-choice > .chip { align-self: flex-start; }
.esheet-lvl { display: flex; align-items: center; gap: 8px; }
.esheet-lvl-val { display: flex; align-items: center; justify-content: center; min-width: 64px; }

/* The quest sheet (Task 4): one card per entity (the quest, each active
   location, each side quest) - a name line, a stack of labelled stepper
   rows (progress/points/threat, plus a location's printed-X count when it
   has one), and, for a location, its three ways to leave. */
.qsheet-list { display: flex; flex-direction: column; gap: 14px; }
.qsheet-section { margin-top: 2px; }
.qsheet-group { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; background: var(--card); border: 1px solid var(--border); border-radius: 8px; }
.qsheet-name { display: flex; flex-direction: column; gap: 2px; }
/* The quest group's own "Stage n" line, with its set icon (Task 5) sharing
   a row - same shape as .pill-head, kept separate since a qsheet-name is not
   a pill. */
.qsheet-name-head { display: flex; align-items: center; gap: 8px; }
.qsheet-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.qsheet-controls { display: flex; align-items: center; gap: 8px; }
.qsheet-val { display: flex; align-items: center; gap: 6px; min-width: 56px; justify-content: center; }
.qsheet-actions, .qsheet-add { display: flex; gap: 10px; flex-wrap: wrap; }

/* The location picker (Task 5): rows grouped by encounter set, bevelled
   like .scenario-row (a name a player reads, plus its threat/quest-points
   pair) rather than a chip glued to a label - see sheet_locpick.js's locRow
   comment. .is-selected swaps the bevel for the same card_hi/gold treatment
   .seg.is-skippable and .locpick-row's own selected state share elsewhere. */
.locpick-list { display: flex; flex-direction: column; gap: 14px; }
.locpick-group { display: flex; flex-direction: column; gap: 8px; }
/* The group header: the set's icon (Task 5) beside its LABEL name, replacing
   the bare .label div the header used to be (sheet_locpick.js's renderList). */
.locpick-group-head { display: flex; align-items: center; gap: 8px; }
.locpick-row { display: flex; align-items: center; justify-content: space-between;
  gap: 16px; width: 100%; min-height: 56px; padding: 8px 16px; text-align: left;
  background: var(--btn); border: 1px solid var(--bevel-l); border-bottom-color: var(--bevel-d); border-right-color: var(--bevel-d);
  border-radius: 6px; }
.locpick-row.is-selected { background: var(--card-hi); border-color: var(--gold); }
/* Inside a picker row the frame lays out sideways: the 96px thumbnail is the
   row's leading column and the caption - the location's name and its printed
   threat/quest points - is the rest of the line. Only the ARRANGEMENT
   changes; the thumbnail keeps its 96px width and 5:7 card aspect. When the
   art is missing the img is hidden and the caption alone carries the row,
   which still clears the 56px floor above. */
.locpick-row .card-frame { width: auto; flex: 1 1 auto; flex-direction: row;
  align-items: center; gap: 16px; }
.locpick-row .card-frame img { width: 96px; flex: none; }
.locpick-row .card-frame figcaption { flex: 1 1 auto; }
.locpick-manual { display: flex; flex-direction: column; gap: 10px; }

/* The side-quest picker (Task 6): a sphere list, then that sphere's quests -
   rows are bevelled the same way as .scenario-row/.locpick-row (a name a
   player reads, plus its count/points as BODY secondary) rather than a
   chip's ALL-CAPS LABEL (design system rule 3b covers sphere names and side
   quest names alike). Unlike .locpick-row's single flex line, .sqpick-row is
   a column: a side quest's own printed text, when the catalog has one,
   stacks as a second BODY secondary line below its name/points row. */
.sqpick-list { display: flex; flex-direction: column; gap: 10px; }
.sqpick-row { display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
  width: 100%; min-height: 56px; padding: 8px 16px; text-align: left;
  background: var(--btn); border: 1px solid var(--bevel-l); border-bottom-color: var(--bevel-d); border-right-color: var(--bevel-d);
  border-radius: 6px; }
.sqpick-row-head { display: flex; align-items: center; justify-content: space-between; width: 100%; gap: 12px; }
.sqpick-row.is-selected { background: var(--card-hi); border-color: var(--gold); }
/* This sheet scrolls (like every other milestone-3 sheet) but still pages -
   CLAUDE.md rule 3b's "page it" is the prescribed move for a list that can
   run long, not a viewport limit the way the twin's fixed canvas needed. */
.sqpick-pager { display: flex; align-items: center; gap: 12px; }

/* The resolution sheet (Task 7): one step at a time, so there is no list to
   style - just the two blocks the reveal step needs (a face's printed text
   under its own LABEL caption) and the fork's pickable rows, bevelled like
   .locpick-row/.sqpick-row because they are the same thing: a card name a
   player reads, plus what it costs, as one tap target. Card text prints in
   full - the sheet scrolls (.sheet's own overflow), which is why this one
   has no line budget where the canvas modal needs one. */
.rsheet-faces { display: flex; flex-direction: column; gap: 12px; }
.rsheet-face { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px;
  background: var(--card); border: 1px solid var(--border); border-left: 6px solid var(--border-gold); border-radius: 6px; }
.rsheet-branch { display: flex; flex-direction: column; gap: 10px; }
.rsheet-row { display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
  width: 100%; min-height: 56px; padding: 8px 16px; text-align: left;
  background: var(--btn); border: 1px solid var(--bevel-l); border-bottom-color: var(--bevel-d); border-right-color: var(--bevel-d);
  border-radius: 6px; }
.rsheet-row-head { display: flex; align-items: center; justify-content: space-between; width: 100%; gap: 12px; }
/* No .is-selected rule: the branch step only exists while nothing is picked
   yet (review finding 4), so a row here is never the selected one. The
   Randomize chip's wrapper is .rsheet-*, not .qsheet-add - same flex-wrap
   values, moved into this file's own namespace (review finding 5). */
.rsheet-dice { display: flex; gap: 10px; flex-wrap: wrap; }

/* The sailing test sheet (Task 8): SailingModal's own wheel-count stepper
   (docs/js/screens.js) centred between a -/+ pair, with a LABEL/BODY pair
   above it for the current heading and another below the sub-line for the
   RESULT preview - the same LABEL-caption-then-BODY-value shape every other
   sheet uses (.esheet-lvl-val, .qsheet-val), just centred rather than
   trailing a row since there is no row label to sit beside here. */
.sailsheet-heading { display: flex; flex-direction: column; gap: 4px; }
.sailsheet-stepper { display: flex; align-items: center; justify-content: center; gap: 16px; }
.sailsheet-val { display: flex; align-items: center; gap: 10px; min-width: 72px; justify-content: center; }

/* The Rules modal (Task 3, milestone 5): the official excerpt's own
   paragraphs, this tracker's one-line summary (reusing the same band copy
   pane.js already shows, never re-worded), and a Related row of prev/next +
   see-also chips. .rules-section reuses .qsheet-section's spacing verbatim -
   same LABEL-then-content stacking, different sheet. */
.rules-section { margin-top: 2px; }
.rules-body p.body { margin: 0 0 12px }
.rules-body p.body:last-child { margin-bottom: 0 }
.rules-related { display: flex; flex-wrap: wrap; gap: 8px; }
/* .cta is a <button> everywhere else; this sheet's "Open the rulebook page"
   footer link is a real <a> (a new tab, not an app act) wearing the same
   class. Anchors default to inline, which .cta's own height:64px cannot
   center content inside on its own - inline-flex fixes that without
   touching the button rule at all. */
a.cta { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }

/* The Notes panel (Task 4, milestone 5, pane.js's renderNotesPanel) and the
   Notes sheet it opens into (sheet_notes.js): the scenario's own tips.json
   tips, in the tracker's own distilled words. Card ground with a gold left
   edge - the same border-left: 6px solid var(--border-gold) treatment
   .rsheet-face already uses for "this block is quoted, not authored here".
   Tips are sentences (CLAUDE.md's "if a player reads it as a sentence... it
   is BODY"), so each line is li.body at .body's own 20px. It used to carry a
   font-size: 18px override "matching .body.secondary" - which is exactly the
   shrink iron rule 3b forbids (18px is .secondary, chrome, not prose), and
   the M5 final review called it. Say less or page it, never shrink it. */
.notes { display: flex; flex-direction: column; gap: 12px; padding: 12px 14px;
  background: var(--card); border: 1px solid var(--border); border-left: 6px solid var(--border-gold); border-radius: 6px; }
.notes-head { display: flex; align-items: center; gap: 10px; }
.notes ul, .notes-group ul { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.notes-foot { display: flex; gap: 10px; flex-wrap: wrap; }
/* .chip is a <button> everywhere else; the Source link (panel and sheet
   alike) is a real <a> (a new tab, not an app act) wearing the same class.
   .chip's own display:inline-flex/align-items:center already fit an anchor
   with no override needed (unlike a.cta above, which has to flip .cta's
   block-level display:flex) - text-decoration and a floor are the only new
   rules, since anchors underline by default and carry no height of their
   own the way chip()'s inline style="height:44px" gives a <button>. */
a.chip { text-decoration: none; min-height: 44px; }

/* The Notes sheet (Task 4, milestone 5): "More notes ›" - every tip group
   for the current scenario, General first then each stage in numeric order
   (notes.js's allNotes()). One .notes-group per scope, same list-plus-
   source shape as the panel above, just without its 3-item cap or its own
   card border - the sheet's .sheet already frames the whole thing. */
.notes-group { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.notes-group:last-child { margin-bottom: 0; }

/* The Scenario overview (Task 3, milestone 6): everything the players decide
   before setup, and the same page again read-only mid-game (the QUEST zone's
   stage pill). Two columns - the scenario itself on the left (60%: header,
   difficulty, sets to gather, stages, cards), the context beside it on the
   right (40%: shared sets, notes) - with the footer CTAs spanning both. The
   split is 3fr/2fr rather than percentages so the gap comes out of the two
   tracks instead of overflowing them; minmax(0, ...) is what lets a long set
   name or a wide card grid shrink instead of pushing the grid wider than the
   pane. .pane already scrolls (overflow-y: auto), so this screen inherits it
   rather than opening a second scrolling region. */
.overview { gap: 16px; }
.ov-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  gap: 24px; align-items: start; }
.ov-main, .ov-side { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.ov-head { display: flex; align-items: center; gap: 14px; }
.ov-head-text { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ov-section { display: flex; flex-direction: column; gap: 10px; }
.ov-ladder { display: flex; gap: 10px; flex-wrap: wrap; }
/* The read-only variant's difficulty: what the players already committed to,
   so there is nothing to tap. No bevel - bevelled means tappable, this
   client's one chrome rule - just the gold outline a chip-gold would have
   had, at the same 44px so the row does not jump between the two variants. */
.ov-badge { display: inline-flex; align-items: center; align-self: flex-start;
  height: 44px; padding: 0 14px; color: var(--gold);
  border: 1px solid var(--border-gold); border-radius: 6px; }
.ov-sets { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 10px; }
.ov-set { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ov-stages { display: flex; flex-direction: column; gap: 8px; }
.ov-stage { display: flex; flex-direction: column; gap: 4px; padding: 10px 14px;
  background: var(--card); border: 1px solid var(--border); border-radius: 8px; }
/* A branch stage's alternatives, stacked under the one "Stage n" label: each
   is a separate card the quest deck might turn up, so each gets its own name
   and its own points, separated rather than run together. */
.ov-alt { display: flex; flex-direction: column; gap: 4px; padding-top: 8px;
  border-top: 1px solid var(--border); }
.ov-alt:first-of-type { padding-top: 0; border-top: 0; }
.ov-types { display: flex; flex-direction: column; gap: 16px; }
.ov-type { display: flex; flex-direction: column; gap: 8px; }
/* The card grid: .card-frame's thumbnails (cardimage.js), wrapped. The
   caption under each is the card's name plus everything it prints, which is
   a much longer line than the picker's - at .card-frame's own 96px
   "engagement 25" alone wrapped onto three lines, so the frame is widened
   here (the picture keeps its 5:7 aspect either way). Tops aligned so a
   caption that still runs long does not shove its neighbours down. */
.ov-cards { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-start; }
.ov-cards .card-frame { width: 150px; }
.ov-chips { display: flex; flex-wrap: wrap; gap: 10px; }
/* A shared set: icon + name, chip-shaped but not a chip - same no-bevel rule
   as .ov-badge above, because there is nothing to tap. */
.ov-chip { display: inline-flex; align-items: center; gap: 8px; height: 44px;
  padding: 0 12px; background: var(--card); border: 1px solid var(--border);
  border-radius: 8px; min-width: 0; }
/* The footer spans both columns and sticks to the bottom of the scroll: on
   a screen this long (a scenario with 30 cards runs well past one viewport)
   Begin setup would otherwise be a scroll away from the ladder that decides
   what it starts. The --bg ground is what keeps the cards from showing
   through it as they pass under - and the -16px/16px pair is .pane's own
   bottom padding: sticky bottoms out at the padding box, so at bottom: 0 a
   16px band of card art still scrolled past underneath the buttons. */
.ov-foot { grid-column: 1 / -1; position: sticky; bottom: -16px;
  padding: 12px 0 16px; background: var(--bg); }
/* The rail's stage pill name is the way into the read-only overview
   (open_overview), so it is a real button and takes the bevel and the 44px
   floor with it. It keeps .pill-name's single-line ellipsis: the pill is
   324px of rail, not a place for a wrapping title. */
.pill-name-btn { display: flex; align-items: center; width: 100%; min-height: 44px;
  padding: 0 8px; text-align: left; background: var(--btn);
  border: 1px solid var(--bevel-l); border-bottom-color: var(--bevel-d);
  border-right-color: var(--bevel-d); border-radius: 6px; }
