/* Kurukshetra: A Life — base styles.
   Direction: an old Indian manuscript folio. A deep madder-red ground printed with a faint gold
   lotus buti (block-print), warm red-brown panels, gold torana fringes where a painting meets its
   text, and a double-ruled frame around the canon panel. Panels are separated by tone steps and
   the gold ornaments, never by shadows at rest. One saffron accent for what you can do; gold for
   the duty meters and the ornaments. Freshly written letters sparkle red-gold, then settle to ivory.
   Display face for names and titles, one text face for the rest. */
:root {
  --ground: #2a120f;     /* madder red, as on Kalamkari cloth and temple flags */
  --ground-rgb: 42, 18, 15;
  --surface: #371a15;    /* the folio */
  --surface-rgb: 55, 26, 21;
  --raised: #47241d;     /* a choice, a card */
  --hover: #562e25;
  --ink: #f7ead3;
  --muted: #e0c7a6;      /* 9.8:1 on surface */
  --faint: #c3a585;      /* 6.8:1 on surface */
  --fresh-ink: #ff6a3d;  /* wet ink: a sparkling red-gold that settles to ivory */
  --accent: #f0943f;     /* saffron: actions and the current selection */
  --accent-ink: #1a1208;
  --data: #e2b55a;       /* gold: the duty meters and the ornaments */
  --gold-line: rgba(226, 181, 90, 0.42);
  --track: #64382d;
  --negative: #ff8a6e;
  --positive: #7fcfa6;
  --check: #a9bdf0;
  /* Devanagari falls through to Tiro (display) and Mukta (text): the Latin faces have no Hindi glyphs. */
  --display: "Cormorant Garamond", "Tiro Devanagari Hindi", "Iowan Old Style", Georgia, serif;
  --text: "Alegreya Sans", "Mukta", "Gill Sans", "Segoe UI", sans-serif;
  --r-card: 8px;
  --r-control: 6px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { background: var(--ground); }
/* The block-printed ground: madder red with a faint gold lotus buti. */
body { background: var(--ground) url("buti.svg") 0 0 / 88px 88px repeat; color: var(--ink); margin: 0; }
body {
  font-family: var(--text); font-size: 17px; line-height: 1.55;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 16px 48px;
  min-height: 100vh; min-height: 100svh;
}
body.big-text { font-size: 19px; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

/* Shell: wordmark, where you are in your life, three plain links. */
.app { max-width: 1200px; margin: 0 auto; display: grid; gap: 16px; }
header.top { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 20px; padding-bottom: 4px; }
.brand { font-family: var(--display); font-weight: 700; font-size: 26px; line-height: 1.1; color: var(--ink); display: inline-flex; align-items: center; gap: 10px; }
.brand::before { content: ""; width: 30px; height: 30px; flex: none; background: url("../icons/icon-192.png") center / contain no-repeat; }
.where { font-size: 15px; color: var(--muted); font-variant-numeric: tabular-nums; flex: 1 1 260px; min-width: 0; }
.where b { color: var(--ink); font-weight: 700; margin-right: 10px; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav button, .ghost {
  font-size: 15px; color: var(--muted); background: transparent; border: 0; border-radius: var(--r-control);
  padding: 6px 12px; cursor: pointer; min-height: 36px;
}
.nav button:hover, .ghost:hover { color: var(--ink); background: var(--raised); }

.game { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.game.wide { grid-template-columns: minmax(0, 1fr); }
@media (max-width: 880px) { .game { grid-template-columns: minmax(0, 1fr); } }

/* The leaf: painting on top, story and choices below. */
.leaf { position: relative; background: var(--surface); border-radius: var(--r-card); overflow: hidden; min-width: 0; }
.plate { position: relative; min-height: 132px; background: var(--field, #3a2a1c); display: flex; align-items: flex-end; }
.plate.painted { aspect-ratio: 3 / 1; min-height: 190px; max-width: 100%; background: var(--img) center 40% / cover no-repeat, var(--raised); }
.plate.painted.tall { aspect-ratio: 5 / 2; }
/* A neutral scrim so the caption reads over any painting (the one allowed blend). */
.plate.painted::before { content: ""; position: absolute; inset: 0; background: linear-gradient(to top, rgba(var(--surface-rgb), 0.97), rgba(var(--surface-rgb), 0) 55%); } /* taste-skill-ignore: neutral scrim under text on a picture */
.plate .cap { position: relative; z-index: 1; padding: 0 26px 16px; display: grid; gap: 2px; color: var(--ink); width: 100%; }
.plate .cap b { font-family: var(--display); font-size: clamp(26px, 4.4vw, 44px); font-weight: 700; line-height: 1.02; letter-spacing: -0.01em; }
.plate .cap small { font-size: 15px; color: var(--muted); max-width: 56ch; }
.plate .cap .kind { font-size: 14px; color: var(--muted); }
.plate .cap .kind.canon { color: var(--data); }
.plate .cap .kind.war { color: var(--negative); }
:where(html:not(.calm)) .plate.painted { animation: drift 26s ease-in-out infinite alternate; }
@keyframes drift { from { background-position: center 36%, 0 0; } to { background-position: center 48%, 0 0; } }

/* A torana fringe where the painting meets the text, as on a manuscript folio. */
/* A torana fringe where the painting meets the text, as on a manuscript folio. */
.text { padding: 34px 26px 28px; display: grid; gap: 16px; background: url("torana.svg") 0 0 / 28px 16px repeat-x; }
@media (max-width: 520px) { .text { padding: 30px 16px 24px; } .plate .cap { padding: 0 16px 14px; } }
.text h1 { font-family: var(--display); font-weight: 700; font-size: clamp(28px, 3.4vw, 36px); line-height: 1.08; letter-spacing: -0.01em; margin: 0; text-wrap: balance; }
.text p { margin: 0; max-width: 66ch; }
.lbl { font-family: var(--display); font-size: 22px; font-weight: 700; line-height: 1.15; color: var(--ink); }
/* The canon panel: framed by a double gold rule, like the border of a manuscript page. */
.witness { background: var(--raised); border: 1px solid var(--gold-line); outline: 1px solid rgba(226, 181, 90, 0.2); outline-offset: -6px; border-radius: var(--r-card); padding: 18px 20px; color: var(--ink); display: grid; gap: 10px; }
.witness .lbl { color: var(--data); font-size: 20px; }
.speech { font-family: var(--display); font-size: 24px; line-height: 1.28; font-weight: 600; color: var(--ink); max-width: 58ch; }
.memory { font-size: 16px; color: var(--accent); font-style: italic; }
.curse { font-size: 16px; color: var(--negative); }
.aside { font-size: 16px; color: var(--muted); }
.result { background: var(--raised); border-radius: var(--r-card); padding: 14px 16px; display: grid; gap: 6px; }
.result .roll { font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.result .roll b.pass { color: var(--positive); } .result .roll b.fail { color: var(--negative); }

/* Choices: filled rows, a tone step on hover, the key number quiet beside them. */
.choices { display: grid; gap: 8px; margin-top: 2px; }
.choice {
  width: 100%; text-align: left; display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 3px 12px; align-items: start;
  background: var(--raised); border: 0; border-radius: var(--r-card); padding: 14px 16px;
  cursor: pointer; min-height: 56px; transition: background-color 0.15s, transform 0.15s;
}
/* Thumbnails: portraits are round, emblems sit free, cards are small paintings. */
.thumb { display: block; flex: none; background: var(--img) center 20% / cover no-repeat; }
.thumb.face { width: 52px; height: 52px; border-radius: 50%; box-shadow: 0 0 0 2px var(--gold-line); } /* taste-skill-ignore: gold ring around a portrait */
.thumb.emblem { width: 60px; height: 60px; background-size: contain; background-position: center; }
.thumb.card { width: 104px; aspect-ratio: 4 / 3; border-radius: var(--r-control); background-position: center; }
.choice.has-img { grid-template-columns: 22px auto minmax(0, 1fr); align-items: center; }
.choice.has-img .k, .choice.has-img .thumb { grid-row: span 2; }
.choice.has-img .t { align-self: end; }
.choice.has-img .fx { align-self: start; grid-column: 3; }
.choice.has-img .thumb.face { width: 60px; height: 60px; }
.said.with-face { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 14px; align-items: start; }
.said.with-face .thumb.face { width: 64px; height: 64px; }
.choice:hover:not(:disabled) { background: var(--hover); transform: translateX(3px); }
.choice:active:not(:disabled) { transform: translateX(1px); }
.choice .k { grid-row: span 2; color: var(--faint); font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; padding-top: 1px; }
.choice .t { font-weight: 700; font-size: 18px; line-height: 1.35; }
.choice .fx { font-size: 14.5px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 2px 14px; }
.fx .up { color: var(--positive); } .fx .down { color: var(--negative); } .fx .vow { color: var(--accent); }
.fx .danger { font-weight: 700; } /* a perilous choice: failing out of your depth can mean death or a cell */
.fx .check { color: var(--check); } .fx .combat { color: var(--negative); font-weight: 700; }
.choice:disabled { cursor: not-allowed; background: transparent; }
.choice:disabled .t { color: var(--faint); }
.choice.picked { background: var(--hover); cursor: default; }
.choice.picked .k { color: var(--accent); }
.cta { font-weight: 700; font-size: 17px; color: var(--accent-ink); background: var(--accent); border: 0; border-radius: var(--r-control); padding: 12px 24px; min-height: 48px; cursor: pointer; justify-self: start; transition: transform 0.12s, background-color 0.15s; }
.cta:hover { background: #f6a65c; }
.cta:active { transform: translateY(1px); }
.cta.secondary { background: var(--raised); color: var(--ink); }
.cta.secondary:hover { background: var(--hover); }
.hint { font-size: 14px; color: var(--faint); margin: 0; }
@media (pointer: coarse) { .choice .k, .hint { display: none; } .choice { grid-template-columns: minmax(0, 1fr); } .choice.has-img { grid-template-columns: auto minmax(0, 1fr); } .choice.has-img .fx { grid-column: 2; } }
@media (max-width: 520px) { .thumb.card { width: 84px; } .choice.has-img .thumb.face { width: 52px; height: 52px; } .thumb.emblem { width: 52px; height: 52px; } }

/* Staged reveal (U.stage): parts wait hidden, then rise in one after another. */
.staged { opacity: 0; transform: translateY(14px); }
.staged.shown { opacity: 1; transform: none; transition: opacity 0.55s ease, transform 0.6s cubic-bezier(.2, .7, .2, 1); }
.staged.shown.now { transition-duration: 0.2s; }
/* The quill: written lines appear letter by letter, each letter wet gold before it dries to ink. */
.staged.write { transform: none; }
.writing .ch { opacity: 0; }
.writing .ch.on, .ch.on { opacity: 1; }
/* Fresh ink sparkles red-gold, then settles to ivory. */
.writing .ch.on { animation: ink 1.6s ease-out; }
@keyframes ink {
  0% { color: var(--fresh-ink); text-shadow: 0 0 6px rgba(255, 70, 40, 0.9), 0 0 1px #fff2b8; } /* taste-skill-ignore: wet-ink glow, transient */
  25% { color: #ff8a4c; text-shadow: 0 0 4px rgba(255, 120, 60, 0.6), 1px -1px 0 rgba(255, 230, 150, 0.7); } /* taste-skill-ignore: wet-ink glow, transient */
  55% { color: #f3c9a0; text-shadow: 0 0 2px rgba(255, 120, 60, 0.25); } /* taste-skill-ignore: wet-ink glow, transient */
  100% { text-shadow: none; } /* taste-skill-ignore: wet-ink glow, transient */
}
.witness, .result, .telling, .text, .hero-copy, .life-head { position: relative; }
.quill { position: absolute; left: 0; top: 0; width: 46px; height: 92px; pointer-events: none; z-index: 3; opacity: 0; transition: opacity 0.3s ease; filter: drop-shadow(1px 2px 2px rgba(0, 0, 0, 0.45)); } /* taste-skill-ignore: the pen floats above the page */
.quill.on { opacity: 1; }
.quill svg { width: 100%; height: 100%; display: block; transform-origin: 6% 97%; animation: scribble 0.32s ease-in-out infinite alternate; }
@keyframes scribble { from { transform: rotate(-4deg) translateY(1px); } to { transform: rotate(3deg) translateY(-1px); } }
/* The painting opens like temple doors, then its caption rises. */
.plate.staged { opacity: 1; transform: none; clip-path: inset(0 50% 0 50%); }
.plate.staged.shown { clip-path: inset(0 0 0 0); transition: clip-path 0.9s cubic-bezier(.65, 0, .35, 1); }
.plate.staged .cap { opacity: 0; transform: translateY(10px); }
.plate.staged.shown .cap { opacity: 1; transform: none; transition: opacity 0.6s ease 0.6s, transform 0.6s ease 0.6s; }
/* The canon frame draws in: the box appears, then its lines. */
.witness.staged { transform: scale(0.985); }
/* Choices slide in from the left. */
.choice.staged:not(.shown) { transform: translateX(-18px); } /* (once shown, .staged.shown sets it back: the cards sat 18 px left, cut by the screen's edge on a phone) */
/* Choosing: the picked card glows gold, the others fall away. */
.choice.chosen { background: var(--hover); box-shadow: 0 0 0 1px var(--data), 0 0 22px rgba(226, 181, 90, 0.35); transition: box-shadow 0.3s, background-color 0.3s; } /* taste-skill-ignore: selection glow, transient */
.choice.dismiss { opacity: 0; transform: translateX(14px); transition: opacity 0.35s ease, transform 0.35s ease; pointer-events: none; }
/* Battle: hits shake the card, damage floats up; healing glows. */
.unit { position: relative; }
.unit.hit { animation: shake 0.42s cubic-bezier(.36, .07, .19, .97); }
.unit.healed { animation: glow 0.8s ease; }
@keyframes shake { 20%, 60% { transform: translateX(-5px); } 40%, 80% { transform: translateX(5px); } }
@keyframes glow { 40% { background-color: #2f4a37; } }
.dmg { position: absolute; right: 14px; top: -16px; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6); font-weight: 700; font-size: 18px; pointer-events: none; animation: float 1.1s ease-out forwards; } /* taste-skill-ignore: transient damage number over a card */
.dmg.down { color: var(--negative); } .dmg.up { color: var(--positive); }
@keyframes float { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(-26px); } }
.blog li.fresh { animation: logIn 0.5s ease both; }
@keyframes logIn { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; transform: none; } }
/* Duty meters: a pip that changes pulses. */
.pips i.flash, .pips i.lost { animation: pip 0.9s ease 2; }
@keyframes pip { 50% { transform: scaleY(1.9); } }
html.calm * { transition: none !important; animation: none !important; }
/* Calm motion: hover nudges stay put (without their transition, a pointer resting on the edge pixel set them flickering). */
html.calm .choice:hover:not(:disabled), html.calm .choices.grid .choice.tile:hover:not(:disabled), html.calm .origin:hover, html.calm .pick:hover, html.calm .pr-tile:hover:not(:disabled) { transform: none; }

/* Hindi: Devanagari needs more line room for its vowel signs, and Tiro has a single weight, so
   no faux bold; its letters sit larger than Cormorant's, so the biggest display sizes step down. */
html[lang="hi"] body { line-height: 1.72; font-synthesis: none; }
html[lang="hi"] .text h1 { line-height: 1.28; }
html[lang="hi"] .plate .cap b { font-size: clamp(24px, 3.8vw, 38px); line-height: 1.22; }
html[lang="hi"] .lbl, html[lang="hi"] .brand { line-height: 1.4; }
html[lang="hi"] .speech { font-size: 21px; line-height: 1.6; }
html[lang="hi"] .choice .t { line-height: 1.5; }

/* ---------- In the story: the painting fills the screen, the page lies over it ----------
   The top bar is one slim row: where you are in your life on the left, then Character, Journal,
   Map, Menu and your Standing as icon buttons (with their names beside them on wide screens).
   The page is only as tall as what it holds, so the painting shows above it; when the story is
   long, the story scrolls inside the page and the choices stay fixed at its foot.
   Safe areas (the notch, the home bar) come through variables, so the layout tests can stand in
   for a real phone's insets. */
:root { --sat: env(safe-area-inset-top, 0px); --sar: env(safe-area-inset-right, 0px); --sab: env(safe-area-inset-bottom, 0px); --sal: env(safe-area-inset-left, 0px); --vh: 100vh; }
@supports (height: 100dvh) { :root { --vh: 100dvh; } }
.backdrop { position: fixed; inset: 0; z-index: 0; display: none; background: var(--ground); overflow: hidden; }
body.inscene .backdrop { display: block; }
/* Two layers cross-fade. In each, a blurred fill of the painting, and the painting itself in a box
   that U.fitBackdrop places: filling the screen, or whole above the page, zooming between the two. */
.backdrop .bdl { position: absolute; inset: 0; opacity: 0; transition: opacity 0.9s ease; }
.backdrop .bdl.on { opacity: 1; }
.backdrop .bd { position: absolute; inset: 0; background-size: cover; background-repeat: no-repeat; transition: filter 0.8s ease, transform 0.8s ease; }
.backdrop .bd.flat { filter: blur(3px) brightness(0.6) saturate(0.9); transform: scale(1.06); } /* an older 3:1 painting, softened behind the page */
.backdrop.fitted .bd { filter: blur(9px) brightness(0.55) saturate(0.9); transform: scale(1.08); } /* the glow around a painting shown whole */
.backdrop .pic { position: absolute; left: 0; top: 0; width: 100%; height: 100%; background: center / 100% 100% no-repeat; overflow: hidden;
  transition: left 0.85s cubic-bezier(.3, .7, .2, 1), top 0.85s cubic-bezier(.3, .7, .2, 1), width 0.85s cubic-bezier(.3, .7, .2, 1), height 0.85s cubic-bezier(.3, .7, .2, 1), box-shadow 0.85s ease; }
.backdrop .pic.now { transition: none; }
.backdrop.fitted .pic { box-shadow: 0 10px 40px rgba(0, 0, 0, 0.55); } /* taste-skill-ignore: the painting lifts off its glow */
/* An older 3:1 painting is only shown sharp when it can be seen whole. */
.backdrop:not(.fitted) .bdl[data-flat="1"] .pic { opacity: 0; }
.backdrop .pic video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 0.9s ease; }
.backdrop .pic video.on { opacity: 1; }
/* The top bar's shade is only needed while the painting fills the screen. */
.backdrop.fitted::after { opacity: 0.55; }
/* See the painting whole: the page slides away; a tap anywhere, or the button, brings it back. */
.view-full { position: fixed; z-index: 30; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; padding: 0; cursor: pointer;
  color: var(--ink); background: rgba(var(--surface-rgb), 0.72); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); border: 1px solid var(--gold-line); transition: top 0.85s cubic-bezier(.3, .7, .2, 1), left 0.85s cubic-bezier(.3, .7, .2, 1), opacity 0.3s; }
.view-full svg, .view-back svg { width: 20px; height: 20px; color: var(--data); }
body.beating .view-full { opacity: 0; pointer-events: none; }
.view-back { position: fixed; z-index: 30; left: 50%; bottom: max(14px, var(--sab)); transform: translateX(-50%); display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 8px 18px 8px 14px; border-radius: 999px; cursor: pointer;
  font-size: 15px; color: var(--ink); background: rgba(var(--surface-rgb), 0.88); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border: 1px solid var(--gold-line); animation: pagein 0.3s ease; }
body.viewing .leaf { transform: translateY(calc(100% + 40px)) !important; opacity: 0; pointer-events: none; transition: transform 0.55s cubic-bezier(.4, 0, .2, 1), opacity 0.4s ease 0.15s; animation: none !important; }
body.inscene:not(.viewing) .leaf { transition: transform 0.5s cubic-bezier(.2, .7, .2, 1), opacity 0.3s ease; }
body.viewing .ledger { display: none; }
.backdrop::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(to bottom, rgba(var(--ground-rgb), 0.62), rgba(var(--ground-rgb), 0) 16%, rgba(var(--ground-rgb), 0) 52%, rgba(var(--ground-rgb), 0.45)); } /* taste-skill-ignore: keeps the top bar legible over any painting */
.stagefx { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
/* The dynamic viewport height follows Safari's and Chrome's toolbars as they show and hide. */
body.inscene { padding: 0; overflow: hidden; height: var(--vh); background: var(--ground); }
body.inscene .app { position: relative; z-index: 1; max-width: none; height: var(--vh); display: grid; grid-template-rows: auto minmax(0, 1fr); gap: 0;
  padding: max(8px, var(--sat)) max(16px, var(--sar)) max(14px, var(--sab)) max(16px, var(--sal)); }
body.inscene header.top { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 8px 12px; padding: 2px 0 10px; }
body.inscene .brand { display: none; }
body.inscene .where { grid-column: 1; flex: none; min-width: 0; color: var(--ink); text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8); line-height: 1.3; } /* taste-skill-ignore: text over a painting */
body.inscene .where b { display: block; font-family: var(--display); font-size: 19px; }
body.inscene .where b, body.inscene .where span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.inscene .where span { display: block; }
body.inscene .nav { grid-column: 2; justify-self: center; flex-wrap: nowrap; background: rgba(var(--surface-rgb), 0.82); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border: 1px solid var(--gold-line); border-radius: 999px; padding: 3px; }
.nav button { display: inline-flex; align-items: center; gap: 7px; }
.nav .ico { width: 18px; height: 18px; flex: none; color: var(--data); }
body.inscene .nav button { border-radius: 999px; padding: 6px 14px 6px 11px; color: var(--ink); }
.standing { grid-column: 3; justify-self: end; display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 6px 14px 6px 10px; border-radius: 999px; cursor: pointer;
  color: var(--ink); background: rgba(var(--surface-rgb), 0.82); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border: 1px solid var(--gold-line); font-size: 15px; }
.standing svg { width: 22px; height: 22px; color: var(--data); flex: none; }
.standing[aria-expanded="true"] { background: var(--hover); }
body.inscene .game { display: flex; align-items: flex-end; justify-content: center; min-height: 0; height: 100%; }
body.inscene .leaf { width: min(800px, 100%); max-height: 100%; overflow: auto; background: rgba(var(--surface-rgb), 0.94); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--gold-line); border-radius: 14px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55); animation: pagein 0.45s cubic-bezier(.2, .7, .2, 1); } /* taste-skill-ignore: the page floats over the painting */
@keyframes pagein { from { opacity: 0; transform: translateY(24px); } }
.pagehead { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 14px; padding: 16px 26px 4px; }
.pagehead .kind { font-size: 12.5px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); }
.pagehead .kind.canon { color: var(--data); }
.pagehead .kind.war { color: var(--negative); }
.pagehead b { flex-basis: 100%; font-family: var(--display); font-size: 28px; line-height: 1.1; }
.pagehead small { font-size: 14px; color: var(--faint); }
/* The page fits what it holds. The story gives way first (it scrolls); the choices never do. */
.leaf.split { display: flex; flex-direction: column; overflow: hidden; }
body.inscene .leaf.split { height: auto; max-height: min(100%, 900px); }
.leaf.split > .pagehead { flex: none; }
.leaf.split .text { flex: 0 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 0; padding: 0; background-position: 0 2px; }
.split .story { flex: 0 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 22px 26px 18px; display: grid; align-content: start; gap: 16px; scrollbar-width: thin; }
.split .story:focus { outline: none; }
.split .story .choice.picked { min-height: 0; }
.split .actions { flex: none; max-height: calc(var(--vh) * 0.5); overflow-y: auto; overscroll-behavior: contain; padding: 12px 26px 18px; border-top: 1px solid var(--gold-line); display: grid; grid-template-columns: minmax(0, 1fr); align-content: start; gap: 8px; background: rgba(var(--surface-rgb), 0.6); }
.split .actions .hint:empty { display: none; }
.split .actions:empty { display: none; }
.leaf.split.testing .story, .leaf.split.testing .pagehead { display: none; }
.leaf.split.testing .actions { flex: 1 1 auto; max-height: none; border-top: 0; padding-top: 18px; }
body.inscene .ledger { position: fixed; z-index: 40; top: calc(max(8px, var(--sat)) + 58px); right: max(16px, var(--sar)); width: min(380px, calc(100vw - 32px)); max-height: calc(var(--vh) - max(8px, var(--sat)) - 78px); overflow: auto;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55); border: 1px solid var(--gold-line); animation: pagein 0.25s ease; } /* taste-skill-ignore: a panel that opens over the page */
.floats { position: fixed; z-index: 39; top: calc(max(8px, var(--sat)) + 54px); right: max(20px, var(--sar)); display: grid; gap: 6px; justify-items: end; pointer-events: none; }
.float { font-size: 14px; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: rgba(var(--surface-rgb), 0.95); border: 1px solid var(--gold-line); opacity: 0; animation: floatup 3s ease forwards; }
.float.up { color: var(--positive); } .float.down { color: var(--negative); }
@keyframes floatup { 0% { opacity: 0; transform: translateY(8px); } 12% { opacity: 1; transform: none; } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(-14px); } }
@media (max-height: 760px) { .split .story { padding: 16px 22px 12px; gap: 12px; } .pagehead { padding: 12px 22px 2px; } .split .actions { padding: 10px 22px 14px; } }

/* Small screens (phones in either direction, small tablets in landscape): one slim row of icons. */
@media (max-width: 720px), (max-height: 520px) {
  body.inscene .app { padding-top: max(6px, var(--sat)); }
  body.inscene header.top { grid-template-columns: minmax(0, 1fr) auto auto; gap: 6px; padding: 0 0 6px; min-height: 44px; }
  body.inscene .where { font-size: 12px; line-height: 1.25; }
  body.inscene .where b { font-size: 15px; line-height: 1.2; }
  body.inscene .nav { grid-row: 1; grid-column: 2; justify-self: end; gap: 0; padding: 2px; }
  body.inscene .nav button { width: 40px; height: 40px; min-height: 40px; padding: 0; justify-content: center; }
  body.inscene .nav .lbl-t { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .nav .ico { width: 21px; height: 21px; }
  .standing { grid-column: 3; grid-row: 1; width: 44px; height: 44px; min-height: 44px; padding: 0; justify-content: center; }
  .standing #standing-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .floats { top: calc(max(6px, var(--sat)) + 50px); right: max(12px, var(--sar)); }
  .float { font-size: 13px; }
  /* Smaller type, so a scene and its choices fit one screen. */
  .split .story { font-size: 15.5px; line-height: 1.5; }
  body.big-text .split .story { font-size: 17.5px; }
  .split .story .speech { font-size: 19px; }
  .split .story .aside, .split .story .memory, .split .story .curse { font-size: 14.5px; }
  .witness { padding: 12px 14px; gap: 8px; }
  .witness .lbl { font-size: 17px; }
  .pagehead { padding: 10px 16px 2px; }
  .pagehead b, .pagehead h1 { font-size: 20px; }
  .pagehead .kind { font-size: 11px; }
  .pagehead small { font-size: 12.5px; }
  .split .story { padding: 12px 16px 10px; gap: 10px; }
  .split .actions { padding: 8px 10px max(10px, var(--sab)); gap: 6px; }
  .split .actions .choice { min-height: 44px; padding: 8px 12px; gap: 1px 10px; }
  .split .actions .choice .t { font-size: 15px; line-height: 1.3; }
  .split .actions .choice .fx { font-size: 12.5px; gap: 2px 10px; }
  .split .actions .choice.has-img .thumb.face, .split .actions .choice .thumb.card { width: 38px; height: 38px; aspect-ratio: auto; border-radius: 50%; }
  .split .actions .choice .thumb.emblem { width: 38px; height: 38px; }
  .split .actions .cta { font-size: 15.5px; min-height: 44px; padding: 10px 20px; }
  html[lang="hi"] .split .story { line-height: 1.65; }
  html[lang="hi"] .split .actions .choice .t { line-height: 1.42; }
}
/* Phones upright: the page rises from the bottom edge like a sheet, at most about 85% of the screen. */
@media (max-width: 720px) and (min-height: 521px) {
  body.inscene .app { padding-bottom: 0; }
  body.inscene .leaf { width: calc(100% + max(16px, var(--sal)) + max(16px, var(--sar))); margin: 0 calc(-1 * max(16px, var(--sar))) 0 calc(-1 * max(16px, var(--sal))); border-radius: 18px 18px 0 0; border-bottom: 0; animation: sheet 0.5s cubic-bezier(.2, .7, .2, 1) both; }
  body.inscene .leaf.split { max-height: min(100%, calc(var(--vh) * 0.86)); }
  @keyframes sheet { from { transform: translateY(100%); } }
  /* Newer iPhone Safari floats its address bar over the page: the screen goes on below the height the
     app is given (100dvh). The story sheet is carried on to the true bottom edge with a strip of its
     own colour, so no band of painting shows beneath it. */
  @supports (height: 100lvh) {
    body.inscene:has(#leaf.split:not(.testing):not(.fighting):not(.journeying))::after { content: ""; position: fixed; left: 0; right: 0; bottom: 0; z-index: 0; height: max(0px, calc(100lvh - 100dvh)); background: rgba(var(--surface-rgb), 0.94); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); pointer-events: none; }
  }
  body.inscene .ledger { top: auto; bottom: 0; right: 0; left: 0; width: 100%; max-height: calc(var(--vh) * 0.8); border-radius: 18px 18px 0 0; padding-bottom: max(16px, var(--sab)); }
}
/* Phones on their side: the painting on the left, the page on the right, side by side. */
@media (orientation: landscape) and (max-height: 520px) {
  body.inscene .app { padding-bottom: max(8px, var(--sab)); }
  body.inscene .game { justify-content: flex-end; align-items: flex-end; }
  body.inscene .leaf { width: min(56%, 560px); margin: 0; border-radius: 14px; animation: sidein 0.45s cubic-bezier(.2, .7, .2, 1) both; }
  body.inscene .leaf.split { max-height: 100%; }
  body.inscene .leaf.split.testing, body.inscene .leaf.fighting, body.inscene .leaf.journeying { width: 100%; }
  .split .actions { max-height: calc(var(--vh) * 0.46); }
  .split .story { min-height: 96px; }
  @keyframes sidein { from { opacity: 0; transform: translateX(28px); } }
}
/* A way closed by two failed tests: struck through, with the reason beneath. */
.choice.crossed { opacity: 1; }
.choice.crossed .t { text-decoration: line-through; text-decoration-thickness: 2px; text-decoration-color: rgba(200, 71, 31, .85); color: var(--muted); }
.choice.crossed .fx .down { font-style: italic; }
.loopnote { border-left: 3px solid var(--gold); padding-left: 10px; }

/* The signs at the right of a choice card (the card has no effect line): a bow for a fight, a skull
   or bars for a danger to your life or freedom, a vow's emblem. One size, centred, beside the text. */
.choice.has-marks { grid-template-columns: 22px minmax(0, 1fr) auto; }
.choice.has-img.has-marks { grid-template-columns: 22px auto minmax(0, 1fr) auto; }
.choice .marks { grid-column: -2 / -1; grid-row: 1; align-self: center; display: flex; align-items: center; gap: 6px; }
.choice .mark { display: block; flex: none; width: 22px; height: 22px; color: var(--muted); }
.choice .mark svg { display: block; width: 100%; height: 100%; }
.choice .mark.death, .choice .mark.cell { color: var(--negative); }
.choice .mark.friend, .choice .mark.astra { color: var(--negative); }
/* A vow this choice would break: its emblem, dimmed and struck through in red. */
.choice .thumb.emblem.mark.breakvow { position: relative; filter: grayscale(.5) brightness(.85); }
.choice .thumb.emblem.mark.breakvow::after { content: ""; position: absolute; left: -2px; right: -2px; top: 50%; height: 2.5px; background: var(--negative); transform: rotate(-40deg); border-radius: 2px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .35); }
.choice .thumb.emblem.mark, .split .actions .choice .thumb.emblem.mark { width: 26px; height: 26px; }
.choice:not(.has-fx) .k, .choice:not(.has-fx) .thumb { grid-row: auto; }
.choice:not(.has-fx) .t { align-self: center; }
@media (pointer: coarse) {
  .choice.has-marks { grid-template-columns: minmax(0, 1fr) auto; }
  .choice.has-img.has-marks { grid-template-columns: auto minmax(0, 1fr) auto; }
}
/* A scene with `grid`: the choices are large pictures with a short label under each (the weapons). */
.choices.grid { grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); }
@media (max-width: 720px) { .choices.grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.choices.grid .choice.tile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; text-align: center; position: relative; min-height: 0; padding: 10px 8px 9px; }
.choices.grid .choice.tile .k { position: absolute; top: 6px; left: 10px; }
/* Stars on the picture of what suits you best: tiny, gold, at the top right corner of the tile. */
.choices.grid .choice.tile .stars { position: absolute; top: 6px; right: 8px; display: flex; gap: 1px; pointer-events: none; }
.choices.grid .choice.tile .stars svg { width: 11px; height: 11px; fill: #f2c25a; stroke: #6b4612; stroke-width: 1.2; stroke-linejoin: round; filter: drop-shadow(0 0 2px rgba(255, 196, 90, .55)); }
@media (max-width: 720px) { .choices.grid .choice.tile .stars { top: 5px; right: 6px; } .choices.grid .choice.tile .stars svg { width: 10px; height: 10px; } }
.choices.grid .choice.tile .thumb.emblem, .split .actions .choices.grid .choice.tile .thumb.emblem { width: 76px; height: 76px; }
.leaf .choices.grid .choice.tile .t { font-size: 15.5px; line-height: 1.2; }
.leaf .choices.grid .choice.tile .sub { font-size: 13px; line-height: 1.15; color: var(--muted); }
/* Tiles with a line under the name (the paths and their weapons): names level across a row, and on a phone a
   smaller picture, so the seven still fit an iPhone 15 without scrolling. */
.choices.grid .choice.tile.has-sub { justify-content: flex-start; }
@media (max-width: 720px) { .choices.grid .choice.tile.has-sub .thumb.emblem, .split .actions .choices.grid .choice.tile.has-sub .thumb.emblem { width: 46px; height: 46px; } }
.choices.grid .choice.tile:hover:not(:disabled) { transform: translateY(-2px); }
@media (max-width: 720px) { .choices.grid .choice.tile .thumb.emblem, .split .actions .choices.grid .choice.tile .thumb.emblem { width: 58px; height: 58px; } .choices.grid .choice.tile { padding: 8px 6px 7px; gap: 2px; } }
/* The frame-rate counter (Menu: Show frame rate) */
.fps-meter { position: fixed; z-index: 9999; left: calc(6px + env(safe-area-inset-left, 0px)); bottom: calc(6px + env(safe-area-inset-bottom, 0px)); padding: 3px 7px; border-radius: 6px; background: rgba(0, 0, 0, .72); color: #9fe39a; font: 700 12px/1.2 ui-monospace, Menlo, monospace; pointer-events: none; }
.fps-meter.bad { color: #ff9a7a; }

/* A field event drawn across the field (Build D, row 38; ui/fx.js U.fieldFx): over the painting, under the figures and the lines. */
.field-fx { position: absolute; inset: 0; z-index: 0; pointer-events: none; }
.field-fx canvas { width: 100%; height: 100%; display: block; }
