:root {
  --parch: #f6ecd4; --parch-2: #eadbb8; --ink: #3b2a1c; --ink-soft: #6b5440; --accent: #c4552e; --sea: #1d9fb3;
  --font-story: 'Grandstander', 'Trebuchet MS', system-ui, sans-serif;   /* Trem's pick, Dec 3 */
  --font: var(--font-story);   /* the reading face: Settings > Font > Plain swaps it (html.plain, below) */
  /* LAYERS (correct by construction, row 26): every screen-level z-index comes from this list, lowest first.
     Inside one component only -1, 0 and 1 are used (its own little stack). tools/check/checks/layers.mjs holds it. */
  --z-scene-fx: 2;   /* the renderer's 2D overlay (main.js): letterbox bars, black fades, flashes */
  --z-hud: 3;        /* talk, the quest note, prompts, toasts, the battle UI: always above a fade */
  --z-controls: 5;   /* touch buttons */
  --z-menu: 5;       /* the menu */
  --z-title: 6;      /* the title screen */
  --z-tip: 7;        /* tip cards */
  --z-film: 50;      /* the opening film, above everything */
  /* TYPE (row 37): every font size comes from this scale, nothing smaller than 11 px. A new size is a design
     call: add it here, never inline. */
  /* TEXT SIZE (Dec 5): --ts is the player's choice in Menu > System > Settings (settings.js: 1, 1.15 or 1.3); every
     token scales with it, so every screen grows together. The canvas words (name tags, battle numbers) read it too. */
  --ts: 1;
  --fs-11: calc(11px * var(--ts)); --fs-12: calc(12px * var(--ts)); --fs-13: calc(13px * var(--ts)); --fs-14: calc(14px * var(--ts)); --fs-15: calc(15px * var(--ts)); --fs-16: calc(16px * var(--ts)); --fs-17: calc(17px * var(--ts)); --fs-18: calc(18px * var(--ts)); --fs-19: calc(19px * var(--ts)); --fs-20: calc(20px * var(--ts)); --fs-22: calc(22px * var(--ts)); --fs-24: calc(24px * var(--ts)); --fs-26: calc(26px * var(--ts)); --fs-30: calc(30px * var(--ts)); --fs-34: calc(34px * var(--ts)); --fs-38: calc(38px * var(--ts));
}
* { box-sizing: border-box; }
/* Settings > Font > Plain (menu UX chunk 3; src/shared/settings.js FONTS): the reading text turns to Atkinson
   Hyperlegible Next, drawn so look-alike letters differ (1 l I, 0 O, 5 S). Its small letters are 14% shorter than
   Grandstander's at one size, so size-adjust 112% makes them read alike while a line stays a little narrower (measured
   Dec 5: x-height .50 vs .58 of the size, a sample line 410 vs 469 px at 20 px). Self-hosted (OFL, assets/fonts):
   an unused @font-face is never fetched, so Storybook players never download it. Arrows it lacks fall back to
   Grandstander. Titles, names, ribbons, the title screen and words over heads (canvas, main.js uiFace) keep the
   storybook hand: the list below sets --font back inside them so everything they hold follows. */
@font-face { font-family: 'Atkinson Hyperlegible Next'; src: url('../../assets/fonts/AtkinsonHyperlegibleNext-v7-latin.woff2') format('woff2');
  font-weight: 200 800; font-style: normal; font-display: swap; size-adjust: 112%;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
html.plain { --font: 'Atkinson Hyperlegible Next', 'Grandstander', 'Trebuchet MS', system-ui, sans-serif; }
html.plain :is(.title, .rv-words, .pick, .qp-title, .cel-title, .end-card h1, .b-result-card h1, .mn-detail h2, .tip-body h2,
  .area-card, .mn-who b, .gear-stage-names b, .b-name, .b-cname, .b-insp-name, .b-order-label, .b-lv-ribbon, .b-lv-who, .b-lv-to, .mn-tabs) { --font: var(--font-story); font-family: var(--font-story); }
body { font-size: var(--fs-16); }   /* text with no size of its own grows with Settings > Text size too */
html, body { margin: 0; height: 100%; background: #1b2530; overflow: hidden; font-family: var(--font); color: var(--ink); font-variant-ligatures: none; font-variant-numeric: lining-nums; }
canvas#view { display: block; image-rendering: pixelated; image-rendering: crisp-edges; }
#loading { position: fixed; inset: 0; display: grid; place-items: center; color: var(--parch); font-size: var(--fs-20); letter-spacing: 1px; }
.hidden { display: none !important; }
/* z-index 3: above the renderer's 2D canvas (main.js overlay, z 2: letterbox bars, black fades, flashes). A fixed element is
   its own layer, so without this every line of talk sat under a scene's black fade (Trem, Dec 4: the dusk scene). */
#ui { position: fixed; inset: 0; pointer-events: none; z-index: var(--z-hud); }
#ui a { color: inherit; pointer-events: auto; }

.panel, .objective, .dialogue, .prompt, .toast, .end-card {
  background: var(--parch); border: 3px solid var(--ink); border-radius: 6px;
  box-shadow: inset 0 0 0 2px var(--parch-2), 0 4px 0 rgba(0,0,0,0.25);
}
/* the quest tracker (Trem, Dec 3: bigger and clearer): a hand-inked note like the tip cards, O hides it, J opens the
   story quest note; design/research/fonts-and-quest-tracker.md */
.objective { position: absolute; left: 14px; top: 14px; max-width: min(440px, calc(100vw - 28px)); font-size: var(--fs-19); line-height: 1.3;
  background: none; border: none; box-shadow: none; pointer-events: auto; cursor: pointer; transform: rotate(-0.4deg); }
.obj-paper { position: absolute; inset: 0; border: 3px solid var(--ink); border-radius: 8px 6px 9px 6px; filter: url(#pa-ink-edge);
  background: repeating-linear-gradient(118deg, transparent 0 6px, rgba(107, 84, 64, .07) 6px 7px), radial-gradient(120% 90% at 30% 20%, #fbf3df, var(--parch) 60%, #ead8b2);
  box-shadow: 0 4px 0 rgba(0, 0, 0, .25); }
.obj-body { position: relative; padding: 6px 16px 10px 12px; }
.obj-text { padding-left: 2px; }
.obj-label { font-size: var(--fs-15); text-transform: uppercase; letter-spacing: 1.5px; color: var(--accent); display: flex; align-items: center; gap: 7px; min-height: 30px; }
.obj-tab { position: absolute; left: 14px; top: 14px; padding: 4px 10px 5px 6px; font-size: var(--fs-15); color: var(--ink); background: var(--parch); border: 2px solid var(--ink);
  border-radius: 6px 5px 7px 4px; box-shadow: 0 3px 0 rgba(0, 0, 0, .25); pointer-events: auto; cursor: pointer; opacity: .9; }
.obj-tab kbd, .quest-peek kbd { position: relative; isolation: isolate; display: inline-block; min-width: 14px; padding: 0 6px 1px; margin-right: 3px; font: var(--fs-15) var(--font); color: var(--ink); text-align: center; }
.obj-tab kbd::before, .quest-peek kbd::before { content: ''; position: absolute; inset: 0; z-index: -1; background: #fbf4e2; border: 2px solid var(--ink); border-bottom-width: 4px; border-radius: 5px 4px 6px 4px; filter: url(#pa-ink-key); }
.quest-peek { position: absolute; left: 50%; top: 64px; transform: translateX(-50%); width: min(500px, calc(100vw - 32px)); }
.quest-peek:not(.hidden) .qp-card { animation: tipPop .32s cubic-bezier(.2, .9, .3, 1.25); }
.quest-peek.out { animation: tipOut .25s ease-in forwards; }
.qp-card { position: relative; transform: rotate(-0.6deg); }
.qp-body { position: relative; padding: 16px 26px 16px 24px; }
.qp-kind { display: flex; align-items: center; gap: 8px; font-size: var(--fs-15); letter-spacing: 1.6px; text-transform: uppercase; min-height: 30px; }
.qp-mark { flex: none; width: 30px; height: 30px; display: grid; place-items: center; } .qp-mark canvas { display: block; image-rendering: pixelated; } .qp-mark:empty { display: none; }
.qp-k.k-story { color: #9a6410; } .qp-k.k-side { color: #27587a; } .qp-k.k-party { color: #a03a5c; }
.qp-title { margin: 2px 0 6px; font-size: var(--fs-30); font-weight: normal; line-height: 1.1; }
.qp-text { margin: 0 0 12px; font-size: var(--fs-22); line-height: 1.35; }
.qp-keys { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: var(--fs-15); color: var(--ink-soft); }
.qp-keys i { font-style: normal; }
.quest-peek { pointer-events: auto; cursor: pointer; } .qp-toggle i { text-decoration: underline dotted; text-underline-offset: 3px; }
@media (pointer: coarse) {   /* touch: no keys to show; the note sits under the tracker; tap the tab or card to open it */
  .obj-tab kbd, .qp-keys kbd, .qp-close, .qp-all { display: none; }
  .quest-peek { top: 104px; }
}
/* the icons keep their own pixels (24 to 29 px), centred in a 30 px slot */
.obj-mark, .q-mark { flex: none; width: 30px; height: 30px; display: grid; place-items: center; }
.obj-mark canvas, .q-mark canvas { display: block; image-rendering: pixelated; }
.obj-mark:empty { display: none; }
/* quest type colours, darkened from the marker icons so the small label reads on parchment */
.obj-kind.k-story { color: #9a6410; } .obj-kind.k-side { color: #27587a; } .obj-kind.k-party { color: #a03a5c; }
.toasts { position: absolute; top: 62%; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; align-items: center; }
.toast { padding: 6px 14px; font-size: var(--fs-15); transition: opacity .5s, transform .5s; }
.toast.out { opacity: 0; transform: translateY(-8px); }
.prompt { position: absolute; left: 50%; bottom: 58px; transform: translateX(-50%); padding: 6px 12px; font-size: var(--fs-15); display: flex; gap: 8px; align-items: center; }
.key { background: var(--ink); color: var(--parch); border-radius: 3px; padding: 0 6px; font-size: var(--fs-14); }
/* pinned by ui.js (dialogue_pin.js): to the speaker, or to the bottom of the safe frame */
.dialogue { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); width: min(760px, calc(100vw - 32px)); min-height: 120px; padding: 14px 16px; display: flex; gap: 14px; pointer-events: auto; cursor: pointer; }
.portrait { flex: none; width: 90px; height: 90px; border: 3px solid var(--ink); border-radius: 4px; background: linear-gradient(#bfe3e8, #f2e3c2); display: grid; place-items: center; }
.portrait canvas { width: 84px; height: 84px; image-rendering: pixelated; }
.dlg-body { flex: 1; position: relative; }
.dlg-name { font-size: var(--fs-15); color: var(--accent); text-transform: uppercase; letter-spacing: 1.5px; margin-bottom: 4px; }
.dlg-text { font-size: var(--fs-19); line-height: 1.35; min-height: 52px; }
.dlg-next { position: absolute; right: 0; bottom: -4px; font-size: var(--fs-14); animation: bob 0.8s infinite alternate; }
@keyframes bob { to { transform: translateY(3px); } }
.dlg-choices { list-style: none; margin: 8px 0 0; padding: 0; }
/* a pinned page: ui.js sets left and top itself */
.dialogue.pinned { bottom: auto; transform: none; }
/* speech bubble: the same parchment box, over the person talking, tail pointing at them (ui.js placeBubble) */
.dialogue.bubble { bottom: auto; transform: none; width: min(430px, calc(100vw - 24px)); min-height: 0; padding: 10px 12px; gap: 10px; }
.dialogue.bubble .portrait { width: 60px; height: 60px; } .dialogue.bubble .portrait canvas { width: 56px; height: 56px; }
.dialogue.bubble .dlg-text { font-size: var(--fs-18); min-height: 0; }
.dlg-tail { display: none; }
.dialogue.bubble .dlg-tail { display: block; position: absolute; left: var(--tail, 50%); bottom: -14px; width: 0; height: 0; margin-left: -11px;
  border: 11px solid transparent; border-top: 13px solid var(--ink); border-bottom: 0; }
.dialogue.bubble .dlg-tail::after { content: ''; position: absolute; left: -8px; top: -14px; border: 8px solid transparent; border-top: 10px solid var(--parch); border-bottom: 0; }
.dialogue.bubble.below .dlg-tail { bottom: auto; top: -14px; border-top: 0; border-bottom: 13px solid var(--ink); }
.dialogue.bubble.below .dlg-tail::after { top: 4px; border-bottom: 10px solid var(--parch); border-top: 0; }
/* a party join: centred, pops in, sparkles either side, then lifts away */
.celebrate { position: absolute; inset: 0; display: grid; place-items: center; background: radial-gradient(closest-side, rgba(20,15,10,.28), transparent); }
.cel-wrap { display: flex; align-items: center; gap: 4px; }
.celebrate.roam { place-items: start center; padding-top: 19vh; background: none; pointer-events: none; }
.cel-box { display: flex; gap: 14px; align-items: center; padding: 14px 22px 14px 14px; background: var(--parch); border: 3px solid var(--ink); border-radius: 6px;
  box-shadow: inset 0 0 0 2px var(--parch-2), inset 0 0 0 5px #d9a441, 0 5px 0 rgba(0,0,0,0.3); }
.cel-face { width: 72px; height: 72px; border: 3px solid var(--ink); border-radius: 4px; background: linear-gradient(#f4d9e3, #f2e3c2); display: grid; place-items: center; }
.cel-face canvas { width: 66px; height: 66px; image-rendering: pixelated; }
.cel-title { font-size: var(--fs-30); line-height: 1.1; color: #8f2f52; }
.celebrate[data-kind="item"] .cel-title { color: #7a4f12; font-size: var(--fs-26); }
.celebrate[data-kind="quest"] .cel-title { color: #2f6b55; }
.celebrate[data-kind="item"] .cel-face, .celebrate[data-kind="quest"] .cel-face { background: linear-gradient(#fbefc9, #f2e3c2); }
.cel-sub { font-size: var(--fs-16); margin-top: 6px; color: var(--ink-soft); }
.cel-spark { width: 96px; height: 128px; image-rendering: pixelated; }
.celebrate.pop .cel-wrap { animation: celpop .32s cubic-bezier(.34,1.56,.64,1) both; }
.celebrate.out .cel-wrap { opacity: 0; transform: translateY(-14px); transition: opacity .4s, transform .4s; }
@keyframes celpop { from { opacity: 0; transform: scale(.7); } to { opacity: 1; transform: scale(1); } }
.dlg-choices li { position: relative; padding: 3px 8px 3px 18px; border-radius: 3px; cursor: pointer; font-size: var(--fs-17); }
.dlg-choices li.sel { background: var(--ink); color: var(--parch); }
.dlg-choices li .dlg-sub { display: block; font-size: var(--fs-15); opacity: .82; padding-top: 1px; font-variant-numeric: lining-nums tabular-nums; }

.quest { display: flex; align-items: center; gap: 6px; font-size: var(--fs-14); padding: 2px 0; }
.quest b { flex: 1; }
.quest span { color: var(--ink-soft); }
.q-completed span { color: #3d7a3a; }
.help { position: absolute; left: 16px; bottom: 10px; max-width: calc(100vw - 32px - 210px); color: var(--ink); font-size: var(--fs-14); line-height: 1.3; padding: 3px 10px 4px; background: rgba(246,236,212,.88); border: 2px solid var(--ink); border-radius: 5px; box-shadow: 0 2px 0 rgba(0,0,0,.25); }   /* a small paper strip, readable over any scene (Dec 5); clear of the corner map */
.dialogue:not(.hidden) ~ .help { visibility: hidden; }   /* while someone talks the box's own arrow says what to do; the strip would sit on the box's corner */
/* the plain box sits in the middle (Trem, Dec 5); on a window too narrow for it and the corner map side by side, the map
   steps aside while the box is up (the box is up to 760 px wide, the map 188 px, 16 px in from the edge) */
@media (max-width: 1180px) { .dialogue:not(.hidden):not(.bubble) ~ .automap { visibility: hidden; } }
.endscreen { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(20,15,10,0.55); pointer-events: auto; }
.end-card { padding: 22px 28px; text-align: center; max-width: 440px; }
.end-card h1 { margin: 0 0 8px; font-size: var(--fs-30); }
.perf { position: fixed; left: 16px; top: 90px; font: var(--fs-12) ui-monospace, monospace; color: #fff; background: rgba(0,0,0,.55); padding: 4px 8px; border-radius: 4px; }
.touch-act, .touch-inv { position: fixed; right: 24px; bottom: 170px; width: 64px; height: 64px; border-radius: 50%; border: 3px solid var(--ink); background: var(--parch); font: var(--fs-20) var(--font); z-index: var(--z-controls); }
.touch-inv { bottom: 250px; width: 52px; height: 52px; font-size: var(--fs-13); }
/* the lantern rituals (ritual_play.js): the touch button shows once one is learned; the ring hangs round the hero */
.touch-rite { display: none; position: fixed; right: 96px; bottom: 182px; width: 52px; height: 52px; border-radius: 50%; border: 3px solid var(--ink); background: var(--parch); font: var(--fs-13) var(--font); z-index: var(--z-controls); }
body.pa-rites .touch-rite { display: block; }
.help-rite { display: none; } body.pa-rites .help-rite { display: inline; }   /* the dance key joins the keys strip once a ritual is learned */
body.pa-scene .touch-rite, body.pa-paused .touch-rite { display: none; }
.rite-ring { position: absolute; left: 0; top: 0; width: 0; height: 0; pointer-events: none; }
.rite-ring.opening .rite-lamp img { animation: rite-in 160ms cubic-bezier(.3, 1.5, .5, 1) both; }
/* each lantern's place round the hero is set from his height on screen (ritual_play.js place()) */
.rite-lamp { position: absolute; left: 0; top: 0; width: 44px; height: 44px; padding: 0; border: 0; background: none; pointer-events: auto; cursor: pointer; }
.rite-lamp img { width: 44px; height: 44px; image-rendering: pixelated; display: block; filter: drop-shadow(0 2px 0 rgba(59, 42, 28, .45)); transition: transform 120ms ease-out; }
.rite-lamp.on img { transform: scale(1.18); filter: drop-shadow(0 0 6px rgba(255, 214, 120, .95)) drop-shadow(0 2px 0 rgba(59, 42, 28, .45)); }
.rite-lamp.dark img { filter: grayscale(1) brightness(.45) drop-shadow(0 2px 0 rgba(59, 42, 28, .45)); }
.rite-q { display: none; position: absolute; left: 0; right: 0; top: 12px; text-align: center; font: var(--fs-16) var(--font); color: #f6ecd4; text-shadow: 0 1px 0 var(--ink); }
.rite-lamp.dark .rite-q { display: block; }
.rite-name { position: absolute; left: 0; top: 0; transform: translateX(-50%); white-space: nowrap; padding: 3px 12px 4px; font-size: var(--fs-15); color: var(--ink); background: #f1e3c4; border: 2.5px solid var(--ink); border-radius: 8px 6px 9px 5px; }
.rite-name:empty { display: none; }
.rite-name b { font-weight: normal; color: var(--accent); }
#ui.in-battle .rite-ring, #ui.in-scene .rite-ring, #ui.paused .rite-ring { display: none !important; }
@keyframes rite-in { from { opacity: 0; scale: .4; } to { opacity: 1; scale: 1; } }   /* scale, not transform: the picked lantern's own transform stays */
@media (max-width: 600px) {
  .dlg-text { font-size: var(--fs-16); }
  .portrait { width: 64px; height: 64px; } .portrait canvas { width: 58px; height: 58px; }
  .help { display: none; }
  .cel-title { font-size: var(--fs-22); } .cel-spark { width: 48px; height: 64px; } .cel-face { width: 52px; height: 52px; } .cel-face canvas { width: 48px; height: 48px; }
}

/* ---------- battle ---------- */
#ui.in-battle .objective, #ui.in-battle .obj-tab, #ui.in-battle .quest-peek, #ui.in-battle .prompt, #ui.in-battle .toasts,#ui.in-battle .help, #ui.in-battle .menu, #ui.in-battle .automap { display: none !important; }
/* a mini-boss scene (boss_scene.js) clears the screen for the letterbox */
#ui.in-scene .objective, #ui.in-scene .obj-tab, #ui.in-scene .quest-peek, #ui.in-scene .prompt,#ui.in-scene .help, #ui.in-scene .automap { display: none !important; }
body.pa-scene .touch-act, body.pa-scene .touch-inv { display: none; }
.battle-ui { position: fixed; inset: 0; pointer-events: none; z-index: var(--z-hud); font-family: var(--font); color: var(--ink); }
.battle-ui .bar { position: relative; height: 8px; background: #2a1f17; border: 2px solid var(--ink); border-radius: 2px; overflow: hidden; }
.battle-ui .bar i { position: absolute; inset: 0 auto 0 0; background: linear-gradient(#8ff07a, #3fae3a); transition: width .35s; }
.battle-ui .bar.sp i { background: linear-gradient(#8fd3ff, #2f86d8); }
.b-order { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; padding: 6px 10px; background: var(--parch); border: 3px solid var(--ink); border-radius: 6px; box-shadow: inset 0 0 0 2px var(--parch-2), 0 4px 0 rgba(0,0,0,.3); }   /* parchment like every other panel (style board, Dec 2) */
.b-order-label { color: var(--ink-soft); font-size: var(--fs-13); line-height: 1.05; letter-spacing: .5px; text-transform: uppercase; text-align: center; writing-mode: vertical-rl; transform: rotate(180deg); }   /* two short lines so 13 px fits the bar's height (Dec 5) */
.b-chips { display: flex; gap: 6px; align-items: center; }
.b-chip { width: 40px; height: 40px; border-radius: 50%; overflow: hidden; border: 3px solid #2f7f8c; background: #dcebe4; flex: none; }
.b-chip.enemy { border-color: var(--accent); background: #f1d9c4; }
.b-chip canvas { width: 100%; height: 100%; image-rendering: pixelated; display: block; }
.b-chip.now { width: 54px; height: 54px; box-shadow: 0 0 0 3px #ffd23f, 0 0 12px 3px rgba(255,200,90,.6); }
.b-plate { position: absolute; right: 18px; top: 16px; text-align: right; padding: 8px 14px 10px; min-width: 200px; background: var(--parch); border: 3px solid var(--ink); border-radius: 6px; box-shadow: 0 4px 0 rgba(0,0,0,.3); transform: skewX(-6deg); }
.b-plate > * { transform: skewX(6deg); }
.b-plate .bar { margin-left: auto; }
/* a foe that is calmed, not killed (the Undertow): the bar is a lamp filling with gold from the left */
.b-plate .bar.lampfill { overflow: visible; height: 10px; background: #1c2530; margin-right: 22px; }
.b-plate .bar.lampfill i { background: linear-gradient(#ffe9a8, #f0a93a); box-shadow: 0 0 6px rgba(255, 200, 90, .55); border-radius: 1px; }
.b-plate .bar.lampfill.lit i { box-shadow: 0 0 10px rgba(255, 214, 120, .95); }
.b-plate .bar.lampfill .b-lampend { position: absolute; right: -26px; top: -10px; width: 26px !important; height: 26px !important; opacity: .55; filter: saturate(.4); transition: opacity .4s, filter .4s; }
.b-plate .bar.lampfill.lit .b-lampend { opacity: 1; filter: none; }
.b-lv { font-size: var(--fs-16); color: var(--accent); letter-spacing: 1px; }
.b-name { font-size: var(--fs-26); line-height: 1; margin: 2px 0 6px; letter-spacing: 1px; }
.b-chip { position: relative; overflow: visible; }
.b-chip > canvas:first-child { border-radius: 50%; }
.b-chip-mood { position: absolute; right: -8px; top: -10px; width: 18px !important; height: 18px !important; }
.b-mood { display: flex; align-items: center; justify-content: flex-end; gap: 4px; margin: 1px 0 3px; font-size: var(--fs-14); color: var(--ink); }
.b-mood canvas { image-rendering: pixelated; }
.b-mood span { padding: 0 6px; border-radius: 8px; background: color-mix(in srgb, var(--mc) 45%, transparent); }
.b-weak { display: flex; align-items: center; justify-content: flex-end; gap: 3px; margin-top: 5px; }
.b-weak-label { font-size: var(--fs-14); opacity: .8; margin-right: 3px; }
.b-tag { display: inline-flex; line-height: 0; }
.b-tag canvas { image-rendering: pixelated; }
.b-tag.locked { opacity: .55; }
.b-tag.unfound canvas { filter: sepia(1) saturate(3) hue-rotate(5deg) brightness(1.05); animation: tagGlow 1.6s ease-in-out infinite; }
@keyframes tagGlow { 50% { filter: sepia(1) saturate(4) brightness(1.25) drop-shadow(0 0 3px #ffd23f); } }
.b-tag.resisted canvas { filter: grayscale(1) brightness(.85); opacity: .6; }
.b-mood .b-pips { background: none; padding: 0 2px; display: inline-flex; gap: 1px; }
.b-mood .b-pips canvas { image-rendering: pixelated; animation: pipFlick 0.9s ease-in-out infinite alternate; transform-origin: 50% 100%; }
.b-mood .b-pips canvas:nth-child(2) { animation-delay: -.4s; }
@keyframes pipFlick { from { transform: scaleY(.92); } to { transform: scaleY(1.08); } }
@media (prefers-reduced-motion: reduce) { .b-mood .b-pips canvas { animation: none; } }
.b-tag.new { animation: tagPop .55s cubic-bezier(.3,1.6,.5,1) both; }
@keyframes tagPop { 0% { transform: scale(.2) rotate(-25deg); } 100% { transform: none; } }
.b-plate.mood-shift { animation: plateJolt .4s ease-out; }
@keyframes plateJolt { 0%, 100% { translate: 0 0; } 25% { translate: -4px 0; } 50% { translate: 3px 0; } 75% { translate: -2px 0; } }
@media (prefers-reduced-motion: reduce) { .b-tag.new, .b-plate.mood-shift, .b-tag.unfound canvas { animation: none; } }
.b-plate.targeted { outline: 3px solid #ffd23f; outline-offset: 2px; }
.b-msg { position: absolute; top: 92px; left: 50%; transform: translateX(-50%); padding: 5px 18px; font-size: var(--fs-22); color: var(--ink); background: var(--parch); border: 3px solid var(--ink); border-radius: 6px; box-shadow: 0 4px 0 rgba(0,0,0,.3); white-space: normal; text-align: center; text-wrap: balance; line-height: 1.25; width: max-content; max-width: min(760px, max(280px, calc(100vw - 500px))); }   /* long lines wrap in two, clear of the foe plate (never cut off with dots) */
/* the lamplight moment's name ribbon (battle_ui.js cutin, research/super-moves-staging.md): inked paper with a stripe of
   the member's colour, their face, their name and the move's; slides in, holds while the lamp gathers, slides on out */
/* battle_ui.js moves it each frame on the moment's clock (slide in, hold, slide on out) */
.b-cutin { --cut: #e8a93a; position: absolute; left: 0; top: 27%; display: flex; align-items: center; gap: 14px; padding: 9px 40px 9px 28px; opacity: 0; transform: translateX(-105%) skewX(-6deg); pointer-events: none; }
.b-cutin-paper { position: absolute; inset: 0; border: 3px solid var(--ink); border-left: none; border-radius: 0 10px 8px 0; filter: url(#pa-ink-edge);
  background: linear-gradient(90deg, var(--cut) 0 14px, var(--ink) 14px 17px, transparent 17px), repeating-linear-gradient(118deg, transparent 0 6px, rgba(107, 84, 64, .07) 6px 7px), radial-gradient(120% 90% at 30% 20%, #fbf3df, var(--parch) 60%, #ead8b2);
  box-shadow: 0 5px 0 rgba(0, 0, 0, .3); }
.b-cutin-face { position: relative; width: 64px; height: 64px; margin-left: 8px; border: 3px solid var(--ink); border-radius: 5px; background: radial-gradient(circle at 50% 60%, #fff4d6, var(--cut)); overflow: hidden; }
.b-cutin-face canvas { width: 100%; height: 100%; image-rendering: pixelated; display: block; }
.b-cutin-text { position: relative; line-height: 1.05; color: var(--ink); }
.b-cutin-who { font-size: var(--fs-17); color: var(--ink-soft); }
.b-cutin-name { font-size: var(--fs-38); letter-spacing: .5px; text-shadow: 2px 2px 0 var(--cut); }
.b-menu { position: absolute; left: 18px; bottom: 18px; width: 320px; padding: 10px 12px 8px; background: var(--parch); border: 3px solid var(--ink); border-radius: 6px; box-shadow: inset 0 0 0 2px var(--parch-2), 0 4px 0 rgba(0,0,0,.3); pointer-events: auto; }
.b-menu.nudge { animation: nudge .25s; }
@keyframes nudge { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.b-menu-title { font-size: var(--fs-16); color: var(--accent); text-transform: uppercase; letter-spacing: 1.5px; margin-bottom: 4px; cursor: pointer; }
.b-list { list-style: none; margin: 0; padding: 0; }
.b-list li { display: flex; justify-content: space-between; padding: 3px 8px 3px 22px; font-size: var(--fs-24); border-radius: 3px; cursor: pointer; position: relative; }
.b-list li em { font-style: normal; font-size: var(--fs-18); color: var(--ink-soft); align-self: center; }
.b-list li.off { color: #a89580; }
.b-list li.sel { background: var(--ink); color: var(--parch); }
.b-list li.sel em { color: var(--parch-2); }

@keyframes poke { to { left: 9px; } }
.b-scroll { text-align: center; font-size: var(--fs-13); height: 12px; line-height: 12px; color: var(--ink-soft); }
.b-desc { border-top: 2px dashed var(--parch-2); margin-top: 6px; padding-top: 6px; font-size: var(--fs-17); min-height: 36px; color: var(--ink-soft); }
.b-keys { font-size: var(--fs-14); color: var(--ink-soft); opacity: .8; margin-top: 2px; }
/* the lamp tab on the command list's right edge (Right: Activate Lamplight); cold until the lamp is full */
.b-lamptab { position: absolute; right: -27px; top: 50%; width: 30px; padding: 6px 0 4px; margin-top: -34px; display: flex; flex-direction: column; align-items: center; gap: 1px; background: var(--parch); border: 3px solid var(--ink); border-left: 0; border-radius: 0 6px 6px 0; box-shadow: 0 4px 0 rgba(0,0,0,.3); cursor: pointer; }
.b-lamptab.hidden { display: none; }
.b-lamptab-icon canvas, .b-lamptab-icon img { display: block; filter: grayscale(1) brightness(.75); opacity: .6; }
.b-lamptab-key { font-size: var(--fs-14); color: var(--ink-soft); opacity: .6; }
.b-lamptab.ready { background: #ffe9b0; animation: lamptab 1.6s ease-in-out infinite; }
.b-lamptab.ready .b-lamptab-icon canvas, .b-lamptab.ready .b-lamptab-icon img { filter: drop-shadow(0 0 4px rgba(255, 200, 90, .95)); opacity: 1; }
.b-lamptab.ready .b-lamptab-key { color: #a9560c; opacity: 1; }
@keyframes lamptab { 50% { box-shadow: 0 4px 0 rgba(0,0,0,.3), 0 0 14px rgba(255, 205, 110, .85); } }
.b-menu.lamp-menu { background: #fff1cf; }
.b-menu.lamp-menu .b-menu-title { color: #a9560c; }
/* the bag's two sides: Items and Weapons; the open one inked in */
.b-bagtab { display: inline-block; padding: 0 6px; margin-right: 4px; border-radius: 3px; color: var(--ink-soft); }
.b-bagtab.on { background: var(--ink); color: var(--parch); }
.b-cards { position: absolute; left: 348px; bottom: 18px; display: flex; gap: 8px; }
.b-card { display: flex; gap: 8px; width: 196px; padding: 7px 9px; background: var(--parch); border: 3px solid var(--ink); border-radius: 6px; box-shadow: 0 4px 0 rgba(0,0,0,.3); transition: transform .2s; }
.b-card.active { transform: translateY(-12px); border-color: #c4552e; box-shadow: 0 0 0 3px #ffd23f, 0 6px 0 rgba(0,0,0,.3); }
.b-card.targeted { box-shadow: 0 0 0 3px #7dff8a, 0 4px 0 rgba(0,0,0,.3); }
.b-card.ko { filter: grayscale(1) brightness(.75); }
.b-card.mid .hp i { background: linear-gradient(#ffe27a, #d9a22a); }
.b-card.low .hp i { background: linear-gradient(#ff9a7a, #d63a2a); }
.b-face { width: 52px; height: 52px; flex: none; border: 2px solid var(--ink); border-radius: 4px; background: linear-gradient(#bfe3e8, #f2e3c2); overflow: hidden; }
.b-face canvas { width: 100%; height: 100%; image-rendering: pixelated; display: block; }
.b-info { flex: 1; min-width: 0; }
/* Lamplight: the member's lamp hangs on the corner of their card. The lit lamp shows from the bottom up as it fills,
   flickers when full, and every lamp pulses together when the Beacon is ready */
.b-card { position: relative; }
.b-lamp { position: absolute; right: -12px; top: -22px; width: 36px; height: 36px; --fill: 0%; pointer-events: none; }
.b-lamp > * { position: absolute; left: 0; top: 0; width: 36px !important; height: 36px !important; image-rendering: pixelated; }
.b-lamp .cold { filter: grayscale(.85) brightness(.5); }
.b-lamp .lit { clip-path: inset(calc(6.25% + (100% - var(--fill)) * 0.875) 0 0 0); transition: clip-path .5s ease-out; }
.b-lamp.full .lit { filter: drop-shadow(0 0 5px #ffd98a) drop-shadow(0 0 2px #fff3c4); animation: lamp-flicker 1.2s steps(1) infinite; }
.b-lift { font-size: var(--fs-13); line-height: 1.1; letter-spacing: .02em; font-weight: 700; color: #7a4a12; background: #ffe9b0; border: 1.5px solid #3b2a1a; border-radius: 7px; padding: 2px 5px 1px; opacity: 0; transform: translateY(3px); transition: opacity .3s, transform .3s; pointer-events: none; white-space: nowrap; }
.b-lift.on { opacity: 1; transform: none; }
.b-lift.full { background: #ffd66e; }
/* buffs and debuffs with the turns left: a row of little tags over each party card, under the foe's card */
.b-fxrow { display: flex; flex-wrap: wrap; gap: 3px; pointer-events: none; }
.b-over { position: absolute; left: 6px; right: 26px; bottom: calc(100% + 3px); display: flex; flex-wrap: wrap-reverse; align-items: flex-end; gap: 3px; pointer-events: none; }
.b-over .b-fxrow { display: contents; }
.b-over .b-lift:not(.on) { display: none; }
.b-plate .b-fxrow { position: absolute; right: 4px; top: calc(100% + 6px); justify-content: flex-end; max-width: 260px; }
.b-fx { display: inline-flex; align-items: center; gap: 4px; padding: 1px 2px 1px 6px; font-size: var(--fs-13); line-height: 1.1; font-weight: 700; letter-spacing: .02em; white-space: nowrap; color: #2f5a1f; background: #e6f2c8; border: 1.5px solid #3b2a1a; border-radius: 7px; box-shadow: 0 2px 0 rgba(0,0,0,.25); animation: fx-in .3s ease-out; }
.b-fx b { display: inline-grid; place-items: center; min-width: 17px; height: 17px; padding: 0 3px; border-radius: 9px; background: #3b2a1a; color: var(--parch); font-size: var(--fs-13); }
.b-fx.bad { color: #6a2f6e; background: #ecd8f0; }
.b-fx:has(.b-fx-i) { gap: 1px; padding: 1px 3px 1px 1px; pointer-events: auto; cursor: help; }
.b-fx-i { display: block; image-rendering: pixelated; }
@keyframes fx-in { from { opacity: 0; transform: translateY(4px) scale(.9); } }
.b-lamp.up { animation: lamp-up .45s ease-out; }
.b-lamp.down { animation: lamp-down .6s ease-out; }
.b-lamp.beacon { animation: lamp-beacon .9s ease-in-out infinite; }
@keyframes lamp-flicker { 0%, 100% { opacity: 1; } 40% { opacity: .8; } 55% { opacity: 1; } 72% { opacity: .9; } }
@keyframes lamp-up { 0% { transform: scale(1); } 40% { transform: scale(1.4); } 100% { transform: scale(1); } }
@keyframes lamp-down { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-2px); } 45% { transform: translateX(2px); } 70% { transform: translateX(-1px); } }
@keyframes lamp-beacon { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.25); } }
@media (prefers-reduced-motion: reduce) { .b-lamp, .b-lamp.full .lit { animation: none !important; } }
.b-list li.lamp span { color: #a9560c; text-shadow: 0 0 6px rgba(255, 217, 138, .9); }
.b-list li.lamp.sel span { color: #ffe6a8; text-shadow: none; }
.b-cname { font-size: var(--fs-18); margin-bottom: 2px; white-space: nowrap; }
.b-cname.long { font-size: min(var(--fs-15), calc(var(--fs-15) * 1.15 / var(--ts))); }   /* a long hero name (up to 12 letters) stays inside its card (qa_ui): it grows with Text size up to Large, so four cards still fit the row */
.b-info { min-width: 0; }
.b-stat { display: grid; grid-template-columns: 22px 1fr 26px; align-items: center; gap: 4px; font-size: var(--fs-15); margin-top: 3px; }
.b-stat b { font-weight: 400; font-size: var(--fs-16); text-align: right; font-variant-numeric: lining-nums tabular-nums; }
.battle-ui.over .b-order, .battle-ui.over .b-msg { display: none; }
.b-result { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(10,8,20,.45); pointer-events: auto; }
.b-result-card { background: var(--parch); border: 3px solid var(--ink); border-radius: 6px; padding: 20px 26px; max-width: 420px; text-align: center; box-shadow: 0 6px 0 rgba(0,0,0,.35); }
.b-result-card h1 { margin: 0 0 8px; font-size: var(--fs-34); }
.b-result-card p { margin: 0 0 12px; font-size: var(--fs-19); line-height: 1.35; white-space: pre-line; }
.b-result-card .b-list li { justify-content: center; }
/* a friend's hint after a boss wipe (wipe_hints.js): their face and words, like a line of talk on the card */
.b-hint { display: flex; gap: 12px; align-items: flex-start; margin: 2px 0 14px; padding: 10px 12px; text-align: left; background: rgba(255, 250, 235, .55); border: 2px solid var(--ink); border-radius: 7px 5px 8px 6px; }
.b-hint-face { flex: none; width: 52px; height: 52px; border: 2.5px solid var(--ink); border-radius: 6px; overflow: hidden; background: var(--parch-2); }
.b-hint-face canvas { width: 100%; height: 100%; image-rendering: pixelated; display: block; }
.b-hint-who { font-size: var(--fs-15); color: var(--accent); margin-bottom: 2px; }
.b-hint-text { font-size: var(--fs-17); line-height: 1.4; color: var(--ink); }
.b-hint.thought .b-hint-text { font-style: italic; color: var(--ink-soft); }
.b-result-card:has(.b-hint:not(.hidden)) { max-width: 500px; }
/* level-ups (Trem, Dec 5; research/level-ups.md): one inked card per member per level, the cheering member left of it
   stays in view (the card sits right of centre, over where the foes stood), gold stars either side */
.b-level { position: absolute; inset: 0; display: grid; place-items: center end; padding-right: max(4vw, 24px); background: linear-gradient(90deg, transparent 30%, rgba(10,8,20,.42) 62%); pointer-events: auto; }
.b-lv-wrap { display: flex; align-items: center; gap: 0; }
.b-lv-spark { width: 72px; height: 96px; image-rendering: pixelated; pointer-events: none; }
.b-lv-card { position: relative; isolation: isolate; width: min(calc(360px * var(--ts)), calc(100vw - 24px)); padding: 26px 22px 14px; color: var(--ink); cursor: pointer; }
.b-lv-card::before { content: ''; position: absolute; inset: 0; z-index: -1; border: 3px solid var(--ink); border-radius: 9px 6px 10px 7px; filter: url(#pa-ink-edge);
  background: repeating-linear-gradient(118deg, transparent 0 6px, rgba(107, 84, 64, .07) 6px 7px), radial-gradient(120% 90% at 30% 20%, #fbf3df, var(--parch) 60%, #ead8b2);
  box-shadow: inset 0 0 0 3px var(--parch-2), inset 0 0 0 6px #d9a441, 0 6px 0 rgba(0,0,0,.32); }
.b-lv-card.pop { animation: b-lv-pop .38s cubic-bezier(.34,1.56,.64,1) both; }
@keyframes b-lv-pop { from { opacity: 0; transform: scale(.72) rotate(-2deg); } to { opacity: 1; transform: none; } }
.b-lv-ribbon { position: absolute; left: 50%; top: -17px; transform: translateX(-50%) rotate(-1.5deg); padding: 3px 26px 5px; font-size: var(--fs-22); line-height: 1.1; color: #fff7e2; white-space: nowrap;
  background: #b4473a; border: 2.5px solid var(--ink); border-radius: 4px 6px 3px 5px; box-shadow: 0 3px 0 rgba(0,0,0,.28); text-shadow: 0 2px 0 rgba(59,42,28,.55); }
.b-lv-head { display: flex; align-items: center; gap: 14px; margin-bottom: 10px; }
.b-lv-face { position: relative; flex: none; width: 76px; height: 76px; border: 3px solid var(--ink); border-radius: 7px 5px 8px 6px; background: radial-gradient(circle at 50% 40%, #fff3c8, #f4d9e3 70%, #efc6d4); display: grid; place-items: center; }
.b-lv-face .b-lv-pic { width: 64px; height: 64px; image-rendering: pixelated; }
.b-lv-mood { position: absolute; left: -26px; top: -28px; width: 50px; height: 50px; }
.b-lv-mood canvas { width: 50px !important; height: 50px !important; image-rendering: pixelated; animation: b-lv-sway 2.4s ease-in-out infinite; transform-origin: 50% 0; }
.battle-ui.leveling .b-plate, .battle-ui.leveling .b-order { visibility: hidden; }
@keyframes b-lv-sway { 0%, 100% { transform: rotate(-5deg); } 50% { transform: rotate(5deg); } }
.b-lv-title { min-width: 0; }
.b-lv-who { font-size: var(--fs-26); line-height: 1.1; overflow-wrap: anywhere; }
.b-lv-banner { font-size: var(--fs-20); color: var(--ink-soft); margin-top: 2px; white-space: nowrap; font-variant-numeric: lining-nums tabular-nums; }
.b-lv-from { color: var(--ink-soft); }
.b-lv-arrow { display: inline-block; margin: 0 6px; color: var(--ink-soft); }
.b-lv-to { display: inline-block; font-size: var(--fs-30); line-height: 1; color: #b4473a; }
.b-lv-card.pop .b-lv-to { animation: b-lv-num .5s .12s cubic-bezier(.34,1.8,.64,1) both; }
@keyframes b-lv-num { from { transform: scale(.3); opacity: 0; } to { transform: none; opacity: 1; } }
.b-lv-stats { display: grid; grid-template-columns: 1fr auto auto auto calc(44px * var(--ts)); column-gap: 8px; row-gap: 1px; padding: 6px 10px; border-top: 2px dashed rgba(59,42,28,.35); border-bottom: 2px dashed rgba(59,42,28,.35); font-variant-numeric: lining-nums tabular-nums; }
.b-lv-row { display: contents; }
.b-lv-row > span { font-size: var(--fs-18); line-height: 1.5; opacity: 0; transform: translateX(-6px); transition: opacity .18s, transform .18s; }
.b-lv-row.on > span { opacity: 1; transform: none; }
.b-lv-row.same.on > span { opacity: .5; }
.b-lv-k { text-align: left; }
.b-lv-old { text-align: right; color: var(--ink-soft); }
.b-lv-ar { text-align: center; color: var(--ink-soft); }
.b-lv-new { text-align: right; min-width: 3ch; }
.b-lv-gain { text-align: left; color: #2f7a43; }
.b-lv-row.done .b-lv-new { color: #2f7a43; }
.b-lv-row.done .b-lv-gain { animation: b-lv-gain .3s ease-out; }
@keyframes b-lv-gain { 0% { transform: scale(1.5); } 100% { transform: none; } }
.b-lv-skill { position: relative; margin: 12px -6px 2px; padding: 8px 12px 9px 14px; background: #fff3cf; border: 2.5px solid var(--ink); border-radius: 6px 8px 5px 7px; box-shadow: inset 4px 0 0 #d9a441; }
.b-lv-skill.pop { animation: b-lv-skill .42s cubic-bezier(.34,1.56,.64,1) both; }
@keyframes b-lv-skill { from { opacity: 0; transform: translateY(8px) scale(.9); } to { opacity: 1; transform: none; } }
.b-lv-skill-tag { font-size: var(--fs-14); color: #b4473a; letter-spacing: .04em; text-transform: uppercase; }
.b-lv-skill-name { font-size: var(--fs-22); line-height: 1.2; }
.b-lv-sp { font-size: var(--fs-15); color: var(--sea); margin-left: 4px; }
.b-lv-skill-desc { font-size: var(--fs-16); line-height: 1.35; color: var(--ink-soft); margin-top: 2px; }
.b-lv-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 10px; min-height: 24px; font-size: var(--fs-15); color: var(--ink-soft); }
.b-lv-keys { margin-left: auto; opacity: .35; transition: opacity .25s; white-space: nowrap; }
.b-lv-card.ready .b-lv-keys { opacity: 1; }
.b-lv-keys kbd { position: relative; isolation: isolate; display: inline-block; min-width: 14px; padding: 0 6px 1px; margin-right: 3px; font: var(--fs-15) var(--font); color: var(--ink); text-align: center; }
.b-lv-keys kbd::before { content: ''; position: absolute; inset: 0; z-index: -1; background: #fbf4e2; border: 2px solid var(--ink); border-bottom-width: 4px; border-radius: 5px 4px 6px 4px; filter: url(#pa-ink-key); }
@media (max-width: 760px), (max-height: 520px) {
  .b-level { place-items: center; padding-right: 0; background: rgba(10,8,20,.4); }
  .b-lv-spark { display: none; }
  .b-lv-card { width: min(calc(340px * var(--ts)), calc(100vw - 24px)); padding: 22px 16px 10px; }
  .b-lv-row > span { font-size: var(--fs-16); line-height: 1.35; }
}
@media (max-height: 520px) {
  .b-level { padding-top: 14px; }
  .b-lv-card { padding: 18px 14px 6px; }
  .b-lv-ribbon { top: -14px; font-size: var(--fs-18); padding: 2px 20px 3px; }
  .b-lv-head { gap: 12px; margin-bottom: 4px; }
  .b-lv-face { width: 54px; height: 54px; } .b-lv-face .b-lv-pic { width: 48px; height: 48px; }
  .b-lv-mood { left: -16px; top: -16px; width: 30px; height: 30px; } .b-lv-mood canvas { width: 30px !important; height: 30px !important; }
  .b-lv-who { font-size: var(--fs-20); } .b-lv-banner { font-size: var(--fs-16); } .b-lv-to { font-size: var(--fs-22); }
  .b-lv-stats { padding: 3px 8px; }
  .b-lv-row > span { font-size: var(--fs-15); line-height: 1.22; }
  .b-lv-skill { margin-top: 6px; padding: 4px 10px 5px 12px; }
  .b-lv-skill-tag { font-size: var(--fs-13); } .b-lv-skill-name { font-size: var(--fs-17); } .b-lv-skill-desc { font-size: var(--fs-14); line-height: 1.25; }
  .b-lv-foot { margin-top: 4px; min-height: 20px; font-size: var(--fs-13); }
}

@media (max-width: 1100px) { .b-msg { font-size: var(--fs-17); } }
@media (max-width: 640px) {
  .b-menu { width: calc(100vw - 32px); left: 16px; bottom: 12px; }
  .b-list li { font-size: var(--fs-17); }
  .b-cards { left: 16px; bottom: auto; top: 120px; }
  .b-card { width: 150px; padding: 4px 6px; } .b-face { width: 36px; height: 36px; }
  .b-plate { top: 70px; right: 16px; width: 190px; } .b-name { font-size: var(--fs-20); }
  .b-chip { width: 30px; height: 30px; } .b-chip.now { width: 40px; height: 40px; }
  .b-msg { top: auto; bottom: 280px; font-size: var(--fs-15); max-width: calc(100vw - 32px); }
}

/* ---------- pause menu, shop counter and title (menu.js, shop.js, title.js) ---------- */
#ui.paused .objective, #ui.paused .obj-tab, #ui.paused .quest-peek,#ui.paused .prompt, #ui.paused .help, #ui.paused .toasts { display: none !important; }
.menu, .title { position: absolute; inset: 0; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); place-items: center; padding: 16px; pointer-events: auto; background: rgba(20,15,10,.5); }
.menu { z-index: var(--z-menu); }
/* menu feel (v14, design/research/menus-and-saves.md): the card pops in fast, fades out faster, a new tab's page
   slides in a few pixels, the chosen row gets a pointing cursor that nudges like the classic gloved hand */
.menu.opening { animation: mnFade .14s ease-out; } .menu.opening .mn-card { animation: mnPop .14s cubic-bezier(.2,.9,.3,1.15); }
.menu.closing { animation: mnFade .11s ease-in reverse forwards; pointer-events: none; }
.mn-body.enter { animation: mnSlide .12s ease-out; }
@keyframes mnFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes mnPop { from { transform: scale(.965) translateY(6px); } to { transform: none; } }
@keyframes mnSlide { from { opacity: .4; transform: translateX(10px); } to { opacity: 1; transform: none; } } .title { z-index: var(--z-title); background: rgba(20,15,10,.55); }
.mn-card { width: min(max(980px, 68vw), 1280px, 100%); height: min(max(660px, 76vh), 860px, 100%);   /* grows on big windows (chunk 4): 1280 x 820 at 1920x1080, unchanged at 1280x720 and below */ display: flex; flex-direction: column; background: var(--parch); border: 3px solid var(--ink); border-radius: 6px; box-shadow: inset 0 0 0 2px var(--parch-2), 0 8px 0 rgba(0,0,0,.4); }
.mn-card.nudge { animation: nudge .18s; }
@keyframes nudge { 30% { transform: translateX(-5px); } 70% { transform: translateX(4px); } }
.mn-tabs { flex: none; display: flex; align-items: flex-end; gap: 4px; padding: 10px 12px 0; border-bottom: 3px solid var(--ink); background: var(--parch-2); border-radius: 3px 3px 0 0; }
.mn-tabs button { font: var(--fs-19) var(--font); color: var(--ink-soft); background: #e2d0a6; border: 3px solid var(--ink); border-bottom: none; border-radius: 6px 6px 0 0; padding: 5px 13px 4px; cursor: pointer; margin-bottom: -3px; position: relative; top: 3px; }
.mn-tabs button.on { background: var(--parch); color: var(--accent); top: 0; padding-bottom: 7px; }
.mn-tabs button:focus-visible { outline: 3px solid #ffd23f; outline-offset: 1px; }
.mn-tabs button.mn-x { margin-left: auto; align-self: center; border: none; background: none; color: var(--ink); font-size: var(--fs-22); padding: 4px 8px; top: 0; margin-bottom: 4px; }
.mn-tabs .mn-face { width: 44px; height: 44px; margin-bottom: 5px; }
.sh-title { display: flex; flex-direction: column; margin: 0 14px 6px 6px; line-height: 1.1; align-self: center; }
.sh-title b { font-size: var(--fs-22); font-weight: 600; } .sh-title em { font-style: normal; font-size: var(--fs-15); color: var(--accent); text-transform: uppercase; letter-spacing: 1.5px; }
.mn-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(230px, calc(340px * var(--ts))) minmax(0, 1fr); }   /* the list grows with the text size (Dec 5) */   /* 340: Grandstander is wider than Pixelify; item names fit */
.mn-col { min-width: 0; min-height: 0; overflow-y: auto; padding: 12px 14px; }
.mn-col + .mn-col { border-left: 2px dashed var(--parch-2); }
.mn-split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(calc(180px * var(--ts)), calc(220px * var(--ts))); gap: 16px; align-content: start; }
.mn-split > div { min-width: 0; }
.mn-side { border-left: 2px dashed var(--parch-2); padding-left: 16px; }
/* When the words grow (Larger text) the detail column has no room for a side column: the side notes go under the
   main column instead of squeezing it (chunk 3: at 130% "Harbour jacket" broke one letter a line). The query is in em
   of the column's own text, so it follows the text size: side by side from 34em (544 px at Normal; the column is ~606 px at Normal, ~555 at Large). */
.mn-split { container-type: inline-size; }
@container (max-width: 34em) {
  .mn-split > div { grid-column: 1 / -1; }
  .mn-split > .mn-side { border-left: none; padding-left: 0; border-top: 2px dashed var(--parch-2); padding-top: 10px; }
}
.mn-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.mn-list .mn-group { padding: 12px 10px 3px; font-size: var(--fs-15); color: var(--accent); text-transform: uppercase; letter-spacing: 1.5px; white-space: nowrap; border-bottom: 1.5px dashed var(--parch-2); }   /* Bag groups (chunk 4) */
.mn-list .mn-group:first-child { padding-top: 2px; }
.mn-row { display: flex; align-items: center; gap: 10px; padding: 5px 10px; border-radius: 4px; cursor: pointer; font-size: var(--fs-20); min-height: 40px; }
.mn-row em { font-style: normal; font-size: var(--fs-16); color: var(--ink-soft); white-space: nowrap; margin-left: auto; }
.mn-row.off .mn-name, .mn-row.off .mn-who b { color: #a89580; }
.mn-row.held { background: var(--parch-2); }
.mn-row { position: relative; transition: padding-left .08s ease-out; }
.mn-row.sel { background: var(--ink); color: var(--parch); padding-left: 22px; }
/* the hand-drawn glove (v16, Pixel Lab, assets/pixellab/ui/cursor_hand.png) points at the chosen row from just outside it */
.mn-row.sel::after, .way-list li.sel::before, .b-list li.sel::before, .tt-list li.sel::before, .dlg-choices li.sel::before { content: ''; position: absolute; left: -12px; top: 50%; width: 24px; height: 19px; margin-top: -10px; border: 0; background: var(--pic-hand) no-repeat; image-rendering: pixelated; filter: drop-shadow(1px 2px 0 rgba(0,0,0,.35)); animation: mnPoke .45s infinite alternate ease-in-out; z-index: 1; }
@keyframes mnPoke { from { transform: translateX(-3px); } to { transform: translateX(1px); } }
.mn-row.sel em, .mn-row.sel small, .mn-row.sel .mn-slot { color: var(--parch-2); }
.mn-row.sel.off .mn-name, .mn-row.sel.off .mn-who b { color: #cdbb9c; }
.mn-face { flex: none; width: 48px; height: 48px; border: 2px solid var(--ink); border-radius: 4px; background: linear-gradient(#bfe3e8, #f2e3c2); overflow: hidden; }
.mn-face canvas { width: 100%; height: 100%; image-rendering: pixelated; display: block; }
.mn-who { flex: 1; min-width: 0; display: grid; grid-template-columns: 1fr auto; column-gap: 8px; row-gap: 1px; align-items: center; }
.mn-who b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mn-who > em { font-size: var(--fs-15); color: var(--accent); margin-left: 0; }
.mn-who small { font-size: var(--fs-15); color: var(--ink-soft); white-space: nowrap; }
.mn-bar { display: block; height: 7px; background: #2a1f17; border: 1px solid var(--ink); border-radius: 2px; overflow: hidden; }
.mn-bar i { display: block; height: 100%; }
.mn-bar.hp i { background: linear-gradient(#8ff07a, #3fae3a); }
.mn-bar.sp i { background: linear-gradient(#8fd3ff, #2f86d8); }
.mn-bar.xp i { background: linear-gradient(#ffe08a, #e0a52f); }
.mn-bar.xp { background: #d9c79c; }
.mn-row.sel .mn-bar { border-color: var(--parch-2); }
.mn-icon { flex: none; width: 36px; height: 36px; display: grid; place-items: center; }
.mn-icon canvas { width: 36px; height: 36px; image-rendering: pixelated; display: block; }
.mn-icon.big { width: 52px; height: 52px; } .mn-icon.big canvas { width: 48px; height: 48px; }
/* Menu > Rituals (rituals.js): the drawn ritual lanterns, dark until learned */
.mn-rite { flex: none; width: 36px; height: 36px; image-rendering: pixelated; display: block; }
.mn-rite.big { width: 52px; height: 52px; }
.mn-rite.dark { filter: grayscale(1) brightness(.5); }
.mn-quote { font-style: italic; color: var(--ink-soft); border-left: 3px solid var(--parch-2); padding-left: 10px; }
.mn-mark { flex: none; width: 30px; height: 30px; display: grid; place-items: center; }
.mn-mark canvas { image-rendering: pixelated; display: block; }
.mn-name { flex: 1; min-width: 0; overflow-wrap: anywhere; line-height: 1.15; }   /* a long name wraps to a second line, never cut short with dots (Dec 5) */
.mn-name em { margin-left: 0; font-size: inherit; color: #a89580; }
.mn-slot { flex: none; width: calc(112px * var(--ts)); font-size: var(--fs-15); color: var(--accent); text-transform: uppercase; letter-spacing: 1px; }
.mn-detail h2 { margin: 0 0 6px; font-size: var(--fs-26); line-height: 1.1; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.mn-detail h2 small { font-size: var(--fs-17); font-weight: 400; color: var(--accent); }
.mn-detail h3 { margin: 12px 0 5px; font-size: var(--fs-16); font-weight: 400; text-transform: uppercase; letter-spacing: 1.5px; color: var(--accent); }
.mn-detail h3:first-child { margin-top: 0; }
.mn-detail h3 small { text-transform: none; letter-spacing: 0; color: var(--ink-soft); margin-left: 6px; }
.mn-detail p { margin: 0 0 8px; font-size: var(--fs-19); line-height: 1.35; }
.mn-detail p.mn-soft, .mn-soft { color: var(--ink-soft); font-size: var(--fs-17); }
.mn-empty { color: var(--ink-soft); font-size: var(--fs-18); padding: 6px 8px; list-style: none; }
.mn-detail p.mn-kind { font-size: var(--fs-15); text-transform: uppercase; letter-spacing: 1.5px; margin: 0 0 2px; }
.mn-kind.k-story { color: #9a6410; } .mn-kind.k-side { color: #27587a; } .mn-kind.k-party { color: #a03a5c; }
.mn-xp { margin: 6px 0 10px; } .mn-xp .mn-bar { height: 9px; } .mn-xp small { display: block; margin-top: 3px; font-size: var(--fs-16); color: var(--ink-soft); }
.mn-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; margin: 10px 0; }
.mn-stats div, .mn-worn div { display: flex; justify-content: space-between; gap: 8px; border-bottom: 1px dashed var(--parch-2); padding: 3px 0; font-size: var(--fs-18); }
.mn-stats span, .mn-worn span { color: var(--ink-soft); } .mn-stats b, .mn-worn b { font-weight: 400; }
.mn-worn b { text-align: right; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mn-worn em { font-style: normal; color: #a89580; }
.mn-cmps { margin: 8px 0 10px; border-top: 2px dashed var(--parch-2); padding-top: 6px; display: flex; flex-direction: column; gap: 1px; }
.mn-cmp { display: grid; grid-template-columns: minmax(0, 1fr) calc(50px * var(--ts)) calc(18px * var(--ts)) calc(50px * var(--ts)); gap: 4px; align-items: center; font-size: var(--fs-18); }
.mn-cmp span { color: var(--ink-soft); } .mn-cmp b { font-weight: 400; text-align: right; } .mn-cmp i { font-style: normal; font-size: var(--fs-14); text-align: center; color: #a89580; }
.mn-cmp.up b:last-child, .mn-cmp.up i { color: #2f8a2c; } .mn-cmp.down b:last-child, .mn-cmp.down i { color: #c4452e; }
.mn-foot { flex: none; display: flex; align-items: center; gap: 14px; padding: 6px 12px; border-top: 3px solid var(--ink); font-size: var(--fs-16); color: var(--ink-soft); background: var(--parch-2); border-radius: 0 0 3px 3px; }
.mn-note { flex: 1; min-width: 0; }
.mn-purse { display: flex; align-items: center; gap: 4px; color: var(--ink); font-size: var(--fs-20); }
.mn-purse .mn-icon, .mn-purse .mn-icon canvas { width: 24px; height: 24px; }
.mn-time { white-space: nowrap; }
.mn-code { width: 100%; min-height: 96px; margin: 8px 0; font: var(--fs-14) ui-monospace, monospace; background: #fffaf0; color: var(--ink); border: 2px solid var(--ink); border-radius: 4px; padding: 6px; resize: vertical; word-break: break-all; }
.mn-keys-list { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 8px 0; font-size: var(--fs-18); }
.mn-keys-list div { display: contents; }
.mn-keys-list b { font-weight: 400; background: var(--ink); color: var(--parch); border-radius: 3px; padding: 1px 7px; font-size: var(--fs-16); text-align: center; }
.mn-keys-list span { color: var(--ink-soft); }
.tt-card { width: min(460px, 100%); max-height: 100%; overflow: auto; background: var(--parch); border: 3px solid var(--ink); border-radius: 6px; box-shadow: inset 0 0 0 2px var(--parch-2), 0 8px 0 rgba(0,0,0,.4); padding: 22px 26px 16px; text-align: center; }
.tt-card h1 { margin: 0 0 4px; font-size: var(--fs-38); letter-spacing: .5px; } .tt-card p { margin: 0 0 12px; font-size: var(--fs-16); }
.tt-name { width: 100%; font: var(--fs-22) var(--font); text-align: center; color: var(--ink); background: #fffaf0; border: 3px solid var(--ink); border-radius: 4px; padding: 5px 8px; outline: none; margin-bottom: 8px; }
.tt-name:focus { box-shadow: 0 0 0 3px #ffd23f; }
.tt-card p.tt-soft { color: var(--ink-soft); font-size: var(--fs-14); margin-bottom: 8px; }
.tt-list { list-style: none; margin: 4px 0 8px; padding: 0; text-align: left; }
.tt-list li { padding: 5px 10px 5px 28px; border-radius: 4px; cursor: pointer; font-size: var(--fs-20); position: relative; }
.tt-list li small { display: block; font-size: var(--fs-14); color: var(--ink-soft); }
.tt-list li.sel { background: var(--ink); color: var(--parch); } .tt-list li.sel small { color: var(--parch-2); }
/* the title screen (title.js): painted key art covering the screen, the logo, a small menu card low in the middle */
.title { display: block; padding: 0; overflow: hidden; background: #120d09; }
.tt-stage { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); }
.tt-pan { position: absolute; inset: 0; transform-origin: 64% 70%; animation: ttPan 46s ease-in-out infinite alternate; }
.tt-bg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; user-select: none; }
/* the hand-drawn layer: the art through the game's own pen and pencil (sketch.js, hybrid), three boil frames at 8 a second */
.tt-ink { opacity: 0; animation: ttBoil .375s step-end infinite; }
/* the painted loop film (title.js): fades in over the still once it is actually playing; then the still's ink rests */
.tt-loop { opacity: 0; transition: opacity .4s; object-fit: cover; pointer-events: none; }
.tt-live .tt-loop { opacity: 1; } .tt-live .tt-ink { display: none; }
@keyframes ttBoil { 0% { opacity: 1; } 33.34% { opacity: 0; } }
.tt-fx { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.tt-fx-top { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
@keyframes ttPan { from { transform: scale(1); } to { transform: scale(1.045) translate(-0.6%, -0.4%); } }
.tt-glow { position: absolute; width: calc(var(--s) * 9%); aspect-ratio: 1; transform: translate(-50%, -50%); border-radius: 50%; pointer-events: none; mix-blend-mode: screen;
  background: radial-gradient(closest-side, rgba(255,214,140,.55), rgba(255,170,80,.22) 45%, rgba(255,150,60,0) 100%); animation: ttFlicker 3.4s ease-in-out infinite alternate; }
@keyframes ttFlicker { 0% { opacity: .55; } 30% { opacity: .9; } 55% { opacity: .7; } 80% { opacity: 1; } 100% { opacity: .62; } }
.tt-spark { position: absolute; width: 0.75%; aspect-ratio: 1; background: center / contain no-repeat; pointer-events: none; opacity: 0; filter: drop-shadow(0 0 4px rgba(255,190,90,.8)); animation: ttSpark 8.5s linear infinite; }
@keyframes ttSpark { 0% { opacity: 0; transform: translate(0, 0) scale(.6); } 12% { opacity: .95; } 50% { transform: translate(1.4vw, -7vh) scale(.9); } 80% { opacity: .5; } 100% { opacity: 0; transform: translate(-.6vw, -15vh) scale(.5); } }
/* a soft darkening low down so the menu card sits calmly on the hill, and at the top so the logo reads */
.tt-shade { position: absolute; inset: 0; pointer-events: none; background: linear-gradient(to bottom, rgba(30,18,8,.28), rgba(30,18,8,0) 34%, rgba(30,18,8,0) 62%, rgba(30,18,8,.38)); }
.tt-logo { position: absolute; left: 50%; top: 3vh; width: min(60vw, 820px, 95vh); transform: translateX(-50%); user-select: none; pointer-events: none; }
/* the card: centred under the logo, a hanging cloth tapestry in the area map's weave and vine border (Trem, Dec 4:
   "not sharply square: uneven, bent, folded, wavy, the cloth texture obvious"; then "still isnt hand drawn, it pops
   weirdly"). One painted cloth (wavy edges, a folded corner, creases, tassels) put through the game's own sprite pass
   (sketch.js layer 'over': pen contour + pencil, tools/title/sketch_still.js --mode sprite) in its 3 boil variants,
   which swap at the world's 8 a second like every drawn thing. 9-sliced at its gold rope (44/48/63/44 of 612 px),
   middle filled and stretched. No soft code shadow under it: the pen line holds it, as for every sprite */
/* centred on the page (Trem, Dec 4: "centered in the page"): its middle on the window's middle, but never up into
   the logo (whose letters end at 0.33 of its width below its top) */
.tt-menu { position: absolute; left: 0; right: 0; top: max(calc(3vh + min(60vw, 820px, 95vh) * 0.34 + 1vh), calc(50% - 80px)); display: flex; justify-content: center; padding: 0 12px; }
.title .tt-card { position: relative; width: min(420px, 100%); max-height: 52vh; padding: 8px 14px 4px; border-radius: 0; box-shadow: none;
  background: none; border-style: solid; border-width: 29px 32px 42px 29px;
  border-image: var(--pic-cloth1) 44 48 63 44 fill stretch; animation: ttCloth .375s step-end infinite; }
@keyframes ttCloth { 0% { border-image-source: var(--pic-cloth1); } 33.34% { border-image-source: var(--pic-cloth2); } 66.67% { border-image-source: var(--pic-cloth3); } }
.title .tt-card p { margin-bottom: 6px; color: #3a2414; }
.title .tt-list li { font-size: var(--fs-22); color: #3a2414; text-align: center; padding: 6px 10px; }
/* the chosen line: one painted sepia brush stroke laid on the linen (assets/title/card_wash.webp, fal), not a code shape */
.title .tt-list li.sel { background: var(--pic-wash) center / 100% 100% no-repeat; color: #fff4dc; text-shadow: 0 1px 0 #3a2414, 0 0 6px rgba(58,36,20,.8); }
.title .tt-list li.sel::before { left: 8%; }
.title .tt-card p.tt-soft { color: #6a4c32; }
/* the name page: the name is written in ink on the linen over a pencil line, with Begin beside it, so the card
   stays low enough to keep the party's faces clear */
.title .tt-namerow { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.title .tt-namerow .tt-list { flex: 0 0 auto; margin: 0; }
.title .tt-namerow .tt-list li { padding: 4px 22px 4px 34px; }
.title .tt-namerow .tt-list li.sel::before { left: 6px; }
.title .tt-name { flex: 1 1 auto; min-width: 0; margin: 0; padding: 2px 4px; background: transparent; border: 0; border-radius: 0; color: #2a180c;
  border-bottom: 2px solid rgba(58,36,20,.75); box-shadow: 0 3px 0 -1px rgba(58,36,20,.22); }
.title .tt-name:focus { box-shadow: 0 3px 0 -1px rgba(58,36,20,.22); border-bottom-color: #3a2414; }
.title .tt-name::selection { background: rgba(196,150,70,.45); color: #2a180c; }
/* the fade-in (Trem: "this should be a fade in"): the painting first, then the logo, then the menu */
.title.tt-in .tt-stage { animation: ttFadeArt 1.8s ease-out both; }
.title.tt-in .tt-shade { animation: ttFadeArt 1.8s ease-out both; }
.title.tt-in .tt-logo { animation: ttFadeLogo 1.7s cubic-bezier(.2,.7,.2,1) 1.1s both; }
.title.tt-in.tt-placed .tt-menu { animation: ttFadeMenu .9s ease-out 2.3s both; }
@keyframes ttFadeArt { from { opacity: 0; filter: brightness(.4); } to { opacity: 1; filter: none; } }
@keyframes ttFadeLogo { from { opacity: 0; transform: translate(-50%, 14px); filter: blur(3px); } to { opacity: 1; transform: translate(-50%, 0); filter: none; } }
/* the cloth unrolls down from its top edge, like a banner let fall, with a small sway as it settles */
@keyframes ttFadeMenu { 0% { opacity: 0; transform: perspective(700px) rotateX(-75deg); } 35% { opacity: 1; } 70% { transform: perspective(700px) rotateX(8deg); } 100% { opacity: 1; transform: none; } }
.tt-menu { transform-origin: 50% 0; }
/* the maker's mark, "by TriforceTrem" (Trem, Dec 5): his buzz-cut doodle, small and quaint, with just a thin cream
   outline hugging the drawing so the name reads on the dark bushes (Trem's pick of three takes, then "even smaller").
   It fades in with the menu card, not with the logo; the same corner and size at every window shape, as at 1280x720. */
.tt-mark { position: absolute; right: 14px; bottom: 9px; width: 85px; height: auto; display: block; pointer-events: none; user-select: none; }
.title.tt-in.tt-placed .tt-mark { animation: ttFadeMark .9s ease-out 2.3s both; }
.title.tt-in.tt-awake.tt-placed .tt-mark { animation: ttFadeMark 1s ease-out 2.15s both; }
@keyframes ttFadeMark { from { opacity: 0; filter: blur(2px); } to { opacity: 1; filter: none; } }
.title.tt-skip .tt-mark, .title.tt-in.tt-skip.tt-placed .tt-mark, .title.tt-in.tt-skip.tt-awake.tt-placed .tt-mark { animation: none; }
.title.tt-asleep .tt-mark { opacity: 0; animation: none; }
.title:not(.tt-placed) .tt-mark { visibility: hidden; }
/* the card waits, unseen, until it knows where the faces are, so it never jumps sideways after it shows */
.title:not(.tt-placed) .tt-menu { visibility: hidden; }
.title.tt-skip .tt-stage, .title.tt-skip .tt-shade, .title.tt-skip .tt-logo, .title.tt-skip .tt-menu, .title.tt-in.tt-skip.tt-placed .tt-menu { animation: none; }
/* The welcome beat before the menu (Trem, Dec 4): one line in the game's own hand over the painting, no box and
   no edges, the way the morning reveal writes to the player. Any click or key clears it, and that touch lets the
   theme play, so the music comes on with the logo and the menu. */
.tt-hello { position: absolute; left: 0; right: 0; top: 46%; margin: 0; text-align: center; pointer-events: none;
  font: var(--fs-38) var(--font); color: #fff6e2; text-shadow: 0 2px 0 #3a2414, 0 0 16px rgba(40,22,8,.85), 0 0 3px #3a2414;
  opacity: 0; animation: ttHello 1.4s ease-out .3s both; }
.tt-hello:empty { display: none; }
.tt-hello small { display: block; margin-top: 14px; font-size: var(--fs-15); color: #f1e0bb; letter-spacing: .04em;
  animation: ttHelloBreathe 3.6s ease-in-out 1.7s infinite both; }
/* Asleep: nothing arrives. The painting is held at dusk and still, its life and its film wait, and the logo and
   the menu are not there at all (Trem, Dec 5: the header and the rest should not start loading in until after
   the click). Awake: the world comes up first, then the logo, then the cloth, at a walking pace. */
.title.tt-asleep .tt-stage { animation: none; opacity: .34; filter: brightness(.5) saturate(.72); }
.title.tt-asleep .tt-shade { animation: none; }
.title.tt-asleep .tt-fx, .title.tt-asleep .tt-fx-top { opacity: 0; }
.title.tt-asleep .tt-pan, .title.tt-asleep .tt-ink, .title.tt-asleep .tt-glow, .title.tt-asleep .tt-spark { animation-play-state: paused; }
.title.tt-asleep .tt-logo, .title.tt-asleep .tt-menu { opacity: 0; animation: none; }
.title.tt-awake .tt-hello { animation: ttHelloOut .6s ease-in both; }
.title.tt-awake .tt-stage { animation: ttWakeArt 1.9s ease-out both; }
.title.tt-awake .tt-shade { animation: none; }   /* the vignette was already over the dusk painting: it stays put */
.title.tt-awake .tt-fx, .title.tt-awake .tt-fx-top { animation: ttWakeLife 1.4s ease-out 1s both; }
.title.tt-awake .tt-logo { animation: ttFadeLogo 1.6s cubic-bezier(.2,.7,.2,1) 1.05s both; }
.title.tt-in.tt-awake.tt-placed .tt-menu { animation: ttFadeMenu 1s ease-out 2.15s both; }
.title.tt-skip.tt-awake .tt-stage, .title.tt-skip.tt-awake .tt-fx, .title.tt-skip.tt-awake .tt-fx-top,
.title.tt-skip.tt-awake .tt-logo, .title.tt-in.tt-skip.tt-awake.tt-placed .tt-menu, .title.tt-skip .tt-hello { animation: none; }
@keyframes ttHello { from { opacity: 0; transform: translateY(10px); filter: blur(2px); } to { opacity: 1; transform: none; filter: none; } }
@keyframes ttHelloOut { from { opacity: 1; } to { opacity: 0; transform: translateY(-8px); } }
@keyframes ttHelloBreathe { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }
@keyframes ttWakeArt { from { opacity: .34; filter: brightness(.5) saturate(.72); } to { opacity: 1; filter: none; } }
@keyframes ttWakeLife { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .tt-hello small { animation: none; opacity: .9; } }
/* the morning title reveal (reveal.js): painted sky that slides up off the town, then the logo and a welcome */
.reveal { position: absolute; inset: 0; z-index: var(--z-title); pointer-events: none; overflow: hidden; }
.rv-sky { position: absolute; left: 0; right: 0; top: 0; height: 130%; will-change: transform; }
.rv-sky img { width: 100%; height: 100%; object-fit: cover; object-position: center top; display: block; }
.rv-words { --lw: min(48vw, 640px, 80vh); position: absolute; left: 0; right: 0; top: 3vh; height: 50vh; }
.rv-logo { position: absolute; left: 50%; top: 0; width: var(--lw); opacity: 0; }
.rv-hello { position: absolute; left: 0; right: 0; top: calc(var(--lw) * 0.36); margin: 0; text-align: center; opacity: 0;
  font: var(--fs-26, 26px) var(--font); color: #fff6e2; text-shadow: 0 2px 0 #3a2414, 0 0 12px rgba(40,22,8,.75), 0 0 2px #3a2414; }
.rv-hello small { display: block; margin-top: 2px; font-size: var(--fs-16); color: #f6e6c4; }
@media (max-height: 520px) { .tt-logo { width: min(38vw, 80vh, 480px); top: 2vh; } .tt-menu { top: max(calc(2vh + min(38vw, 80vh, 480px) * 0.36), calc(50% - 60px)); } .title .tt-card { width: min(300px, 100%); max-height: 62vh; border-width: 22px 24px 32px 22px; } .title .tt-list li { font-size: var(--fs-18); padding: 3px 8px; } }

@keyframes poke { to { left: 12px; } }
@media (max-width: 640px) {
  .menu, .title { padding: 6px; }
  .mn-card { height: 100%; } .mn-tabs { padding: 6px 4px 0; gap: 1px; overflow-x: auto; } .mn-tabs button { font-size: var(--fs-11); padding: 4px 3px 3px; border-width: 2px; } .mn-tabs button.mn-x { padding: 4px 6px; }
  .mn-body { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(120px, 40%) minmax(0, 1fr); } .mn-col + .mn-col { border-left: none; border-top: 2px dashed var(--parch-2); }
  .mn-split { grid-template-columns: minmax(0, 1fr); } .mn-side { border-left: none; padding-left: 0; }
  .mn-foot { font-size: var(--fs-11); gap: 8px; } .mn-row { font-size: var(--fs-16); }
  .tt-card h1 { font-size: var(--fs-30); }
}
/* the touch buttons step aside while a card is up: every row on the card answers to a tap */
body.pa-paused .touch-act, body.pa-paused .touch-inv { display: none; }
@media (prefers-reduced-motion: reduce) { .tt-pan, .tt-spark, .tt-glow, .title .tt-card, .mn-card.nudge, .tt-list li.sel::before, .mn-row.sel::after, .menu.opening, .menu.opening .mn-card, .mn-body.enter { animation: none; } }

/* v16.1: the storm-dream film before a new game. Black card, the film letterboxed in it, a quiet Skip in the corner
   that shows only after a first key or click. */
.intro { position: fixed; inset: 0; z-index: var(--z-film); background: #000; display: flex; align-items: center; justify-content: center; transition: opacity .8s ease; }
.intro.ending { opacity: 0; pointer-events: none; }
.intro video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.intro-skip { position: absolute; right: max(20px, env(safe-area-inset-right)); bottom: max(18px, env(safe-area-inset-bottom)); font: inherit; font-family: var(--font); font-size: var(--fs-15);
  color: #f3e9d2; background: rgba(20, 16, 12, .55); border: 1px solid rgba(243, 233, 210, .35); border-radius: 999px; padding: 6px 14px; cursor: pointer;
  opacity: 0; transform: translateY(4px); transition: opacity .25s ease, transform .25s ease; pointer-events: none; }
.intro-skip.show { opacity: .9; transform: none; pointer-events: auto; }
/* a slow connection waiting on the film: the film's own first frame is already showing, and this says, quietly,
   that the rest of it is on its way (download size chunk 4) */
.intro-wait { position: absolute; left: 50%; bottom: 14%; transform: translateX(-50%); font-family: var(--font); font-size: var(--fs-15);
  color: rgba(243, 233, 210, .88); text-shadow: 0 1px 3px rgba(0, 0, 0, .8); letter-spacing: .02em; pointer-events: none;
  opacity: 0; transition: opacity .6s ease; }
.intro.waiting .intro-wait { opacity: 1; animation: intro-breathe 2.6s ease-in-out infinite; }
@keyframes intro-breathe { 0%, 100% { opacity: .78; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .intro.waiting .intro-wait { animation: none; } }

/* v16.3: the gear tab shows the character, full figure, in what they wear (and tries the highlighted piece on).
   Dec 4: a living stage (gear_stage.js), the battle idle with the weapon in hand; one figure per member (Dec 5) */
.mn-figure { display: flex; justify-content: center; align-items: flex-end; margin-top: 10px; }
.mn-figure-img { height: 170px; width: auto; image-rendering: pixelated; }
/* the canvas's width is written on it (gear_stage.js); a narrow column squeezes width and height together, never one way */
.gear-stage { display: block; max-width: 100%; height: auto; image-rendering: pixelated; }
.mn-arrow { font-style: normal; font-size: var(--fs-14); margin-left: auto; }
/* the first-equip lesson's next step (Trem, Dec 5): an inked note in the accent colour, gently breathing */
.mn-guide { margin: 0 0 10px; padding: 6px 10px; border: 2px solid var(--accent); border-radius: 7px 5px 8px 5px; color: var(--accent);
  background: rgba(196, 85, 46, .07); font-size: var(--fs-16, 16px); animation: mnGuide 2.4s ease-in-out infinite; }
@keyframes mnGuide { 0%, 100% { opacity: .86; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .mn-guide { animation: none; } }
.mn-arrow.up { color: #3f8a3a; } .mn-arrow.down { color: #b0463a; }
/* Settings (Dec 5): the value sits to the right; volumes show as ten small inked pips, filled up to the level */
.mn-settings .mn-slot { width: calc(150px * var(--ts)); white-space: nowrap; }   /* "BATTLE RATE" on one line in either face */
.mn-settings .mn-name { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.mn-settings .mn-val { white-space: nowrap; font-variant-numeric: lining-nums tabular-nums; }
/* Controllers (menu UX chunk 5): while a pad is in use every key cap becomes a round button cap in the same ink
   (keys.js prints the pad's buttons then); Controls keeps its Key cells as key caps either way */
html.pad-in kbd:not(.key)::before, kbd.pad::before { border-radius: 999px; border-bottom-width: 3px; }
html.pad-in kbd:not(.key), kbd.pad { min-width: 1.3em; }
html.pad-in .mn-keys-list b { border-radius: 999px; }
/* Menu > System > Controls: one grid, the action then Key, Other key and Pad (qa_ui ALIGN measures it) */
.mn-ctl-head, .mn-controls .mn-row:not(.mn-ctl-reset) { display: grid; grid-template-columns: calc(150px * var(--ts)) minmax(0, .85fr) minmax(0, .95fr) minmax(0, 1.2fr); gap: 8px; align-items: center; }   /* the Pad column is the widest: "Options", "Select" */
.mn-ctl-head { padding: 0 10px 4px; position: sticky; top: -12px; z-index: 1; background: var(--parch); }   /* the column names stay up while the list scrolls (.mn-col's 12 px padding) */
.mn-ctl-head .mn-ctl { font-size: var(--fs-15); color: var(--accent); text-transform: uppercase; letter-spacing: 1px; white-space: nowrap; }
.mn-ctl-head .mn-slot { font-size: var(--fs-16); letter-spacing: 1.5px; }   /* the page's heading rides on the column names (one line that stays up) */
.mn-controls .mn-slot { width: auto; white-space: nowrap; }
.mn-controls .mn-row { scroll-margin-top: calc(34px * var(--ts)); }   /* a row the cursor brings in stops below the column names */
.mn-ctl { min-width: 0; text-align: center; }
.mn-ctl i { font-style: normal; color: var(--ink-soft); }
.mn-row.sel .mn-ctl i { color: var(--parch-2); }
.mn-controls kbd { position: relative; isolation: isolate; display: inline-block; min-width: 1.3em; padding: 2px 8px 5px; line-height: 1.1; font: var(--fs-16)/1.1 var(--font); color: var(--ink); text-align: center; white-space: nowrap; }
.mn-controls kbd::before { content: ''; position: absolute; inset: 0; z-index: -1; background: #fbf4e2; border: 2px solid var(--ink); border-bottom-width: 4px; border-radius: 5px 4px 6px 4px; filter: url(#pa-ink-key); }
.mn-controls kbd.pad::before { border-radius: 999px; border-bottom-width: 3px; }
.mn-ctl.on kbd::before { background: #ffd23f; }   /* the chosen cell: lamp gold */
.mn-ctl.wait kbd::before { background: #ffd23f; animation: ctlWait .5s ease-in-out infinite alternate; }
@keyframes ctlWait { from { opacity: 1; } to { opacity: .45; } }
.mn-ctl.fixed kbd { opacity: .6; }   /* the d-pad always moves */
@media (prefers-reduced-motion: reduce) { .mn-ctl.wait kbd::before { animation: none; } }
.mn-vol { display: inline-flex; gap: 3px; } .mn-vol i { width: 7px; height: 14px; border: 1.5px solid currentColor; border-radius: 2px; opacity: .55; }
.mn-vol i.on { background: currentColor; opacity: 1; }
.mn-row.sel .mn-arrow.up { color: #9fe08f; } .mn-row.sel .mn-arrow.down { color: #ff9a8a; }
/* the shop tries a piece on everyone who can wear it (Dragon Quest's shop line-up), each figure at its Gear page size
   with its name in a row whose columns are the canvas's columns (Trem, Dec 5: the figure looked small and the name
   sat off to one side; the old short-window rule squeezed the canvas one way only) */
.sh-try { margin: 8px 0 2px; }
/* the shop's list holds short rows (icon, name, price), so at bigger text it grows less than the menu's lists and
   gives the try-on the room: a line-up of four at Larger text on a 1024 x 576 window still stands at the Gear page's
   size (340 px at Normal, as the menu; 364 at Larger, where long names take two lines) */
.shop .mn-body { grid-template-columns: minmax(220px, calc(340px + (var(--ts) - 1) * 80px)) minmax(0, 1fr); }
.gear-stage-wrap { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }   /* a too-wide line-up stands in rows */
.gear-stage-row { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; max-width: 100%; }   /* a canvas and its names share one width */
.gear-stage-measure { position: absolute; left: 0; top: 0; height: 0; overflow: hidden; visibility: hidden; pointer-events: none; }
.gear-stage-names { display: grid; max-width: 100%; text-align: center; font-size: var(--fs-15); }
.gear-stage-names b { min-width: 0; overflow-wrap: break-word; }
/* the shop's questions (Trem, Dec 5): "Are you sure?" then "Equip it now?" on a pinned paper note in the list's place,
   so the stat change and the try-on stay in view; the answers are a menu list with the pointing hand */
.sh-ask { position: relative; margin: 6px 4px 8px 8px; }
.sh-ask-body { position: relative; padding: 16px 16px 14px 18px; }
.sh-ask-body h3 { margin: 0 0 6px; font-size: var(--fs-16); font-weight: 400; text-transform: uppercase; letter-spacing: 1.5px; color: var(--accent); white-space: nowrap; }
.sh-ask-body p { margin: 0 0 6px; }
.sh-ask-list { margin-top: 10px; }
.sh-who { display: flex; flex-direction: column; gap: 1px; }
.sh-no-face { visibility: hidden; }   /* "Not now": a face-sized space, so its words start where the names do */
.sh-who small { font-size: var(--fs-15); color: var(--ink-soft); }
/* On a short window the stat change comes straight after the item's own words, before its type line and the bag count,
   so what the player decides on stays in view at every text size and in either face (chunk 3: Larger + Plain at
   1024x576 pushed "Strike twice" below the fold). */
@media (max-height: 660px) {
  .shop .mn-detail { display: flex; flex-direction: column; }
  .shop .mn-detail > * { flex: none; order: 2; }
  .shop .mn-detail > h2, .shop .mn-detail > h2 + p { order: 0; }
  .shop .mn-detail > h3, .shop .mn-detail > .mn-cmps { order: 1; }
}

/* remembered weaknesses (Dec 3): known from an earlier fight but not open yet, painted under a seal */
.b-tag.sealed { position: relative; }
.b-tag.sealed canvas { filter: grayscale(.55) brightness(.8); opacity: .7; }
.b-tag.sealed::after { content: ''; position: absolute; right: -1px; bottom: -1px; width: 7px; height: 7px; border-radius: 50%; background: #7a5a3a; border: 1px solid var(--ink); }
.b-plate { cursor: pointer; pointer-events: auto; }

/* Inspect: the bestiary card over the battle (scan-and-bestiary.md) */
.b-inspect { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(10,8,20,.35); pointer-events: auto; }
.b-insp-card { background: var(--parch); border: 3px solid var(--ink); border-radius: 6px; padding: 14px 18px 10px; width: min(460px, calc(100vw - 32px)); max-height: calc(100vh - 40px); overflow-y: auto; box-shadow: 0 6px 0 rgba(0,0,0,.35); color: var(--ink); animation: inspIn .22s cubic-bezier(.3,1.4,.5,1) both; }
@keyframes inspIn { from { transform: translateY(10px) scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .b-insp-card { animation: none; } }
.b-insp-head { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.b-insp-face { width: 64px; height: 64px; image-rendering: pixelated; border: 2px solid var(--ink); border-radius: 4px; background: rgba(0,0,0,.08); }
.b-insp-name { font-size: var(--fs-24); letter-spacing: .5px; }
.b-insp-sub { font-size: var(--fs-14); opacity: .75; }
.b-insp-card p { margin: 4px 0 8px; font-size: var(--fs-15); line-height: 1.35; }
.b-insp-lore { font-style: italic; }
.b-insp-lore.locked { opacity: .6; }
.b-insp-note { font-size: var(--fs-14) !important; padding: 4px 8px; border-left: 3px solid #d9a441; background: rgba(217,164,65,.12); }
/* Elowen's note on the Inspect card (bestiary_notes.js): her hand, a slate-blue margin like her shawl */
.b-insp-elowen { font-size: var(--fs-14) !important; padding: 4px 8px; border-left: 3px solid #5b7da8; background: rgba(91,125,168,.12); }
.b-insp-elowen b { font-weight: normal; color: #3f5f8a; margin-right: 4px; }
.b-insp-elowen i { display: block; margin-top: 2px; }
.b-insp-hint { font-size: var(--fs-14) !important; opacity: .75; margin-top: 2px !important; }
.b-insp-label { font-size: var(--fs-14); opacity: .7; margin-right: 6px; min-width: 52px; display: inline-block; }
.b-insp-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 6px; }
.b-insp-weak { display: inline-flex; align-items: center; gap: 3px; font-size: var(--fs-14); }
.b-insp-weak em { font-style: normal; }
.b-insp-weak canvas { image-rendering: pixelated; }
.b-insp-weak.unknown { opacity: .55; }
.b-insp-weak.sealed canvas, .b-insp-weak.resisted canvas { filter: grayscale(.6) brightness(.85); }
.b-insp-moods { margin-top: 8px; display: grid; gap: 4px; }
.b-insp-mood { display: flex; align-items: flex-start; gap: 6px; font-size: var(--fs-14); line-height: 1.3; padding: 3px 6px; border-radius: 6px; background: color-mix(in srgb, var(--mc, #e8d9b0) 22%, transparent); }
.b-insp-mood canvas { image-rendering: pixelated; flex: none; }
.b-insp-mood b i { font-style: normal; font-size: var(--fs-13); padding: 0 5px; margin-left: 4px; border-radius: 6px; background: var(--ink); color: var(--parch); }
.b-insp-mood small { display: block; font-size: var(--fs-13); opacity: .8; }
.b-insp-mood.now { outline: 2px solid color-mix(in srgb, var(--mc) 70%, var(--ink)); }
.b-insp-mood.unknown { opacity: .6; background: rgba(0,0,0,.05); }
.b-insp-close { margin-top: 8px; text-align: center; cursor: pointer; }
.battle-ui { font-variant-ligatures: none; }   /* the pixel font draws "fi" as one odd glyph */
/* the area map (automap.js): a scrap of parchment in the corner that inks itself in, and the Map tab's sheet */
.automap { position: absolute; right: 16px; bottom: 16px; width: 188px; padding: 5px 5px 2px; margin: 0; font: inherit; color: var(--ink); cursor: pointer; pointer-events: auto;
  background: var(--parch); border: 3px solid var(--ink); border-radius: 6px; box-shadow: inset 0 0 0 2px var(--parch-2), 0 4px 0 rgba(0,0,0,.25); transform: rotate(-1.2deg); }
.automap.hidden { display: none; }
.automap canvas { display: block; width: 100%; height: auto; background: #e9dcc0; border-radius: 3px; }
.automap span { display: block; text-align: center; font-size: var(--fs-14); line-height: 1.4; }
.automap small { display: block; text-align: center; font-size: var(--fs-13); line-height: 1.3; color: var(--ink-soft); letter-spacing: .5px; }
#ui.paused .automap { display: none !important; }
.mn-mapcol { display: flex; flex-direction: column; }
.mn-mapcv { flex: 1; min-height: 0; width: 100%; height: 100%; font-family: var(--font); }
.mn-legend { margin-top: 14px; font-size: var(--fs-15) !important; line-height: 1.7 !important; }
.mn-legend .lg { display: inline-flex; align-items: flex-end; justify-content: center; width: 26px; height: 28px; margin: 0 3px 0 10px; vertical-align: -6px; object-fit: contain; image-rendering: pixelated; }
.mn-legend .lgi { display: flex; align-items: center; gap: 8px; line-height: 1.35; margin: 4px 0; }
.mn-legend .lg { flex: none; margin: 0 !important; }
.mn-legend .lg canvas, .mn-legend .lg .mn-figure-img { width: auto !important; height: 100% !important; max-width: 100%; image-rendering: pixelated; }
@media (max-width: 760px) { .automap { width: 124px; right: 8px; bottom: 8px; } .automap span { font-size: var(--fs-11); } }
/* the Skills tab's road ahead (design/research/skill-roadmap.md): element icons, future skills, the party's elements */
.mn-weak { flex: none; width: 22px; height: 22px; display: grid; place-items: center; }
.mn-weak canvas { image-rendering: pixelated; display: block; }
.mn-row.mn-later em { color: var(--accent); }
.mn-row.sel.mn-later em { color: var(--parch-2); }
.mn-detail p.mn-next { margin: -2px 0 6px; }
.mn-next b { color: var(--ink); font-weight: 600; }
.mn-elem { display: flex; gap: 8px; align-items: flex-start; padding: 4px 0; border-bottom: 1px dashed var(--parch-2); }
.mn-elem .mn-weak { margin-top: 2px; }
.mn-elem b { display: block; font-weight: 600; font-size: var(--fs-17); }
.mn-elem small { display: block; font-size: var(--fs-15); color: var(--ink-soft); line-height: 1.3; }

/* ---------- tips and tutorials (tutorial.js, Trem Dec 3) ----------
   A parchment note pinned in the middle of the screen: the edge is a hand-inked line (an SVG wobble, #pa-ink-edge),
   the paper carries a faint pencil lay at the world's slant (the "/" of sketch.js), a Pixel Lab picture sits in an
   inked roundel like a pin, and keys are drawn as little inked keycaps. */
/* the talk log (talk_log.js, menu UX chunk 4): a paper of what was said, newest at the bottom, scrolls inside */
.talklog { position: fixed; inset: 0; z-index: var(--z-menu); display: grid; place-items: center; padding: 16px; background: rgba(20, 16, 12, .32); pointer-events: auto; }
.talklog.hidden { display: none; }
.tl-card { position: relative; width: min(calc(620px * var(--ts)), calc(100vw - 32px)); transform: rotate(-0.4deg); color: var(--ink); }
.tl-body { position: relative; padding: 20px 26px 14px 28px; display: flex; flex-direction: column; max-height: calc(100vh - 48px); }
.tl-body h2 { margin: 0 0 8px; font-size: var(--fs-24); font-weight: normal; font-family: var(--font-story); }
.tl-list { list-style: none; margin: 0; padding: 0 6px 0 0; overflow-y: auto; min-height: 0; flex: 1 1 auto; max-height: calc(min(560px, 100vh - 150px)); }
.tl-list li { display: flex; flex-direction: column; padding: 7px 0 8px; border-bottom: 1.5px dashed rgba(107, 84, 64, .3); }
.tl-list li:last-child { border-bottom: none; }
.tl-who { font-size: var(--fs-15); color: var(--accent); text-transform: uppercase; letter-spacing: 1.5px; }
.tl-text { font-size: var(--fs-18); line-height: 1.35; }
.tl-aside .tl-text { font-style: italic; color: var(--ink-soft); }
.tl-you .tl-who { color: var(--sea); }
.tl-keys { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 10px; font-size: var(--fs-15); color: var(--ink-soft); }
.tl-keys kbd { position: relative; isolation: isolate; display: inline-block; min-width: 14px; padding: 0 6px 1px; font: var(--fs-15) var(--font); color: var(--ink); text-align: center; }
.tl-keys kbd::before { content: ''; position: absolute; inset: 0; z-index: -1; background: #fbf4e2; border: 2px solid var(--ink); border-bottom-width: 4px; border-radius: 5px 4px 6px 4px; filter: url(#pa-ink-key); }
.tip { position: fixed; inset: 0; z-index: var(--z-tip); display: grid; place-items: center; padding: 16px; background: rgba(20, 16, 12, .28); }
.tip.hidden { display: none; }
.tip.pop .tip-card { animation: tipPop .32s cubic-bezier(.2, .9, .3, 1.25); }
.tip.out { animation: tipOut .2s ease-in forwards; }
@keyframes tipPop { from { opacity: 0; transform: translateY(14px) rotate(-3deg) scale(.92); } }
@keyframes tipOut { to { opacity: 0; } }
.tip-card { position: relative; width: min(calc(520px * var(--ts)), calc(100vw - 32px)); transform: rotate(-0.6deg); color: var(--ink); }
/* a short window (1024x576) or big text: the note gets wider rather than taller, and as a last resort its words
   scroll inside the paper, so "got it" is never off the screen (Dec 5) */
@media (max-height: 660px) { .tip-card { width: min(calc(640px * var(--ts)), calc(100vw - 32px)); } .tip-card .tip-rows { row-gap: 6px; } .tip-card .tip-body { padding-top: 16px; padding-bottom: 12px; } }
.tip-paper { position: absolute; inset: 0; border: 3px solid var(--ink); border-radius: 9px 7px 10px 6px; filter: url(#pa-ink-edge);
  background: repeating-linear-gradient(118deg, transparent 0 6px, rgba(107, 84, 64, .07) 6px 7px), radial-gradient(120% 90% at 30% 20%, #fbf3df, var(--parch) 60%, #ead8b2);
  box-shadow: 0 6px 0 rgba(0, 0, 0, .28); }
.tip-paper::after { content: ''; position: absolute; inset: 6px; border: 1.5px solid rgba(107, 84, 64, .45); border-radius: 6px 8px 5px 9px; }
.tip-pin { position: absolute; left: -20px; top: -24px; width: 66px; height: 66px; display: grid; place-items: center; z-index: 1; transform: rotate(-6deg); }
.tip-pin::before { content: ''; position: absolute; inset: 0; border-radius: 50%; border: 3px solid var(--ink); background: radial-gradient(circle at 35% 30%, #fff6dc, #e8c98a); filter: url(#pa-ink-edge); box-shadow: 0 3px 0 rgba(0, 0, 0, .25); }
.tip-pic { position: relative; max-width: 50px; max-height: 50px; image-rendering: pixelated; }
.tip-body { position: relative; padding: 22px 28px 18px 30px; max-height: calc(100vh - 40px); overflow-y: auto; }
.tip-pin + .tip-body { padding-left: 56px; }
.tip-kicker { font-size: var(--fs-14); letter-spacing: 1.6px; text-transform: uppercase; color: var(--accent); }
.tip-body h2 { margin: 2px 0 10px; font-size: var(--fs-24); font-weight: normal; }
/* ALIGNED BY CONSTRUCTION (Trem, Dec 5: "A full lamp" sat far right of the other rows): the rows are one grid, so
   every label shares one column and every row's words start at one left edge, whatever the label holds (words,
   keycaps or both). The label column is as wide as the widest label, up to a third of the note. tools/qa_ui.cjs measures it. */
.tip-rows { list-style: none; margin: 0; padding: 0; font-size: var(--fs-17); line-height: 1.4; display: grid; grid-template-columns: fit-content(34%) minmax(0, 1fr); gap: 9px 12px; align-items: baseline; }
.tip-rows li { margin: 0; grid-column: 1 / -1; }
.tip-rows li.tip-key { display: contents; }
.tip-keys { display: inline-flex; flex-wrap: wrap; gap: 3px; align-items: center; }
.tip-keys i, .tip-ok i { font-style: normal; color: var(--ink-soft); font-size: var(--fs-14); padding: 0 3px; }
.tip-rows b { font-weight: normal; color: var(--accent); }
.tip kbd, .mn-help kbd { position: relative; isolation: isolate; display: inline-block; min-width: 14px; padding: 0 6px 1px; font: var(--fs-15) var(--font); color: var(--ink); text-align: center; }
.tip kbd::before, .mn-help kbd::before { content: ''; position: absolute; inset: 0; z-index: -1; background: #fbf4e2; border: 2px solid var(--ink); border-bottom-width: 4px; border-radius: 5px 4px 6px 4px; filter: url(#pa-ink-key); }
.tip-q { font-size: var(--fs-18); margin: 0 0 12px; }
.tip-ok { margin-top: 6px; text-align: right; font-size: var(--fs-15); color: var(--ink-soft); animation: tipNudge 1.6s ease-in-out infinite; }
@keyframes tipNudge { 50% { transform: translateX(3px); } }
.tip-ask { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: var(--fs-18); }
.tip-ask li { padding: 4px 12px; border-radius: 4px; cursor: pointer; }
.tip-ask li.sel { background: var(--ink); color: var(--parch); }
.tip-ask li.sel::before { content: '▸ '; }
.mn-help .tip-rows { font-size: var(--fs-18); }
@media (max-width: 560px) { .tip-rows { grid-template-columns: minmax(0, 1fr); row-gap: 2px; } .tip-keys { min-width: 0; } .tip-body h2 { font-size: var(--fs-22); } }

/* the waylamp's card (waycard.js, Trem Dec 4): a small inked note at the lamp, each awake town shown by its own
   painting from the tapestry map, framed in ink like a pinned picture; the drawn hand points at the choice */
.way { position: absolute; inset: 0; display: grid; place-items: end center; padding: 16px 16px 44px; pointer-events: auto; background: rgba(20, 16, 12, .22); }
.way.pop .way-card { animation: tipPop .32s cubic-bezier(.2, .9, .3, 1.25); }
.way-card { position: relative; width: min(560px, calc(100vw - 32px)); transform: rotate(-0.5deg); color: var(--ink); }
.way-body { position: relative; padding: 18px 26px 14px 28px; }
.way-head { font-size: var(--fs-15); letter-spacing: 1.6px; text-transform: uppercase; color: #9a6410; }
.way-line { margin: 4px 0 12px; font-size: var(--fs-20); line-height: 1.3; }
.way-list { list-style: none; margin: 0; padding: 0 0 0 14px; display: flex; flex-wrap: wrap; gap: 14px 22px; align-items: flex-end; }
.way-list li { position: relative; cursor: pointer; }
.way-town { display: grid; justify-items: center; gap: 4px; }
.way-pic { display: block; width: 204px; height: 144px; border: 3px solid var(--ink); border-radius: 6px 4px 7px 5px; background: #e8dcc0 center / cover no-repeat; filter: url(#pa-ink-edge); box-shadow: 0 3px 0 rgba(0, 0, 0, .25); }
.way-town.sel .way-pic { box-shadow: 0 0 0 3px #f2c35a, 0 3px 0 rgba(0, 0, 0, .25); }
.way-name { font-size: var(--fs-18); }
.way-stay { font-size: var(--fs-18); padding: 4px 8px; align-self: center; color: var(--ink-soft); }
.way-stay.sel { color: var(--ink); }
.way-list li.sel::before { left: -20px; top: 50%; }
.way-town.sel::before { top: 72px; }
.way-keys { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 12px 0 0; font-size: var(--fs-15); color: var(--ink-soft); }
.way-keys i { font-style: normal; }
.way kbd { position: relative; isolation: isolate; display: inline-block; min-width: 14px; padding: 0 6px 1px; margin-right: 3px; font: var(--fs-15) var(--font); color: var(--ink); text-align: center; }
.way kbd::before { content: ''; position: absolute; inset: 0; z-index: -1; background: #fbf4e2; border: 2px solid var(--ink); border-bottom-width: 4px; border-radius: 5px 4px 6px 4px; filter: url(#pa-ink-key); }
@media (pointer: coarse) { .way-keys { display: none; } }

/* coach lines (coach.js): one small inked note over the hero's head that teaches a control by doing; never a pop-up */
.coach { position: absolute; left: 0; top: 0; pointer-events: none; max-width: min(420px, 80vw); will-change: transform, opacity; }
.coach-paper { position: absolute; inset: 0; border: 2.5px solid var(--ink); border-radius: 8px 6px 9px 5px; filter: url(#pa-ink-edge);
  background: repeating-linear-gradient(118deg, transparent 0 6px, rgba(107, 84, 64, .07) 6px 7px), radial-gradient(120% 90% at 30% 20%, #fbf3df, var(--parch) 60%, #ead8b2);
  box-shadow: 0 4px 0 rgba(0, 0, 0, .25); }
.coach-paper::after { content: ''; position: absolute; left: var(--tail, 50%); bottom: -9px; width: 14px; height: 14px; margin-left: -7px; background: #f1e3c4;
  border-right: 2.5px solid var(--ink); border-bottom: 2.5px solid var(--ink); transform: rotate(45deg); }
.coach-text { position: relative; padding: 7px 14px 8px; font-size: var(--fs-15); line-height: 1.5; color: var(--ink); text-align: center; white-space: nowrap; }
.coach-text i { font-style: normal; color: var(--ink-soft); font-size: var(--fs-14); padding: 0 2px; }
.coach-text b { font-weight: normal; color: var(--accent); }
.coach kbd { position: relative; isolation: isolate; display: inline-block; min-width: 14px; padding: 0 6px 1px; margin-right: 3px; font: var(--fs-15) var(--font); color: var(--ink); text-align: center; }
.coach kbd::before { content: ''; position: absolute; inset: 0; z-index: -1; background: #fbf4e2; border: 2px solid var(--ink); border-bottom-width: 4px; border-radius: 5px 4px 6px 4px; filter: url(#pa-ink-key); }
#ui.in-battle .coach, #ui.in-scene .coach, #ui.paused .coach { display: none !important; }
/* the guided first fight (battle.js guideLine): the same inked note, pinned over the command list */
.b-guide { position: absolute; left: -3px; bottom: calc(100% + 16px); width: max-content; max-width: min(460px, calc(100vw - 36px)); pointer-events: none; }
.b-guide-paper { position: absolute; inset: 0; border: 2.5px solid var(--ink); border-radius: 8px 6px 9px 5px; filter: url(#pa-ink-edge);
  background: repeating-linear-gradient(118deg, transparent 0 6px, rgba(107, 84, 64, .07) 6px 7px), radial-gradient(120% 90% at 30% 20%, #fbf3df, var(--parch) 60%, #ead8b2);
  box-shadow: 0 4px 0 rgba(0, 0, 0, .25); }
.b-guide-paper::after { content: ''; position: absolute; left: 34px; bottom: -9px; width: 14px; height: 14px; background: #f1e3c4; border-right: 2.5px solid var(--ink); border-bottom: 2.5px solid var(--ink); transform: rotate(45deg); }
.b-guide-text { position: relative; padding: 7px 14px 8px; font-size: var(--fs-17); line-height: 1.45; color: var(--ink); }
.b-guide-text b { font-weight: normal; color: var(--accent); }
.b-guide kbd { position: relative; isolation: isolate; display: inline-block; min-width: 14px; padding: 0 6px 1px; margin-right: 3px; font: var(--fs-15) var(--font); color: var(--ink); text-align: center; }
.b-guide kbd::before { content: ''; position: absolute; inset: 0; z-index: -1; background: #fbf4e2; border: 2px solid var(--ink); border-bottom-width: 4px; border-radius: 5px 4px 6px 4px; filter: url(#pa-ink-key); }
.b-guide.pop { animation: b-guide-pop .28s ease-out; }
@keyframes b-guide-pop { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
/* short screens (phones on their side): above the menu it would cover the turn order, so it sits beside the menu, past the lamp tab, tail pointing left */
@media (max-height: 520px) {
  .b-guide { left: calc(100% + 44px); bottom: auto; top: 58px; max-width: 268px; width: max-content; }
  .b-guide-text { font-size: var(--fs-15); padding: 6px 12px 7px; }
  .b-guide-paper::after { left: -9px; bottom: auto; top: 16px; border-right: 0; border-bottom: 2.5px solid var(--ink); border-left: 2.5px solid var(--ink); }
}

/* an area's first look (area_intro.js): the place name on an inked parchment ribbon, unrolled at the top centre,
   held a few seconds, rolled away. Under the scene bars' reach and clear of the quest note and the corner tag. */
.area-card { position: absolute; left: 50%; top: 13%; transform: translateX(-50%); pointer-events: none; }
.area-card-ribbon { position: relative; min-width: 300px; padding: 0 34px; clip-path: inset(0 50% 0 50%); }
.area-card-ribbon .obj-paper { box-shadow: 0 5px 0 rgba(0, 0, 0, .25); }
.area-card-body { position: relative; padding: 9px 0 10px; text-align: center; color: var(--ink); }
.area-card-name { font-size: var(--fs-30); line-height: 1.1; letter-spacing: 1px; }
.area-card-sub { margin-top: 3px; font-size: var(--fs-15); color: var(--ink-soft); font-style: italic; }
.area-card-body::before, .area-card-body::after { content: ''; position: absolute; top: 50%; width: 22px; border-top: 2.5px solid var(--ink); opacity: .55; }
.area-card-body::before { left: -28px; } .area-card-body::after { right: -28px; }
.area-card.in .area-card-ribbon { animation: area-unroll .7s cubic-bezier(.3, .8, .3, 1) forwards; }
.area-card.out .area-card-ribbon { animation: area-roll .6s ease-in forwards; }
@keyframes area-unroll { from { clip-path: inset(0 50% 0 50%); } to { clip-path: inset(-12px -12px -12px -12px); } }
@keyframes area-roll { from { clip-path: inset(-12px -12px -12px -12px); opacity: 1; } to { clip-path: inset(0 50% 0 50%); opacity: 0; } }
@media (max-height: 520px) { .area-card { top: 9%; } .area-card-name { font-size: var(--fs-24); } .area-card-ribbon { min-width: 240px; } }
