/* Cuthbert — the web beta's ink and paper.
   A gloomy Edwardian park, drawn in pen: warm paper going grey at the edges (it is always dusk), near-black ink,
   faded oxblood for danger and Composure, dusty slate for Puff. One shared wobble filter (#ink, in index.html)
   roughens borders and icons; text itself is never filtered. */

/* ---------- Figures ----------
   IM Fell English has only old-style figures, in which a 0 is a small round o ("10" reads as "1o"). Wherever the
   display face sets a digit, EB Garamond's lining figures stand in: "Fell Figures" covers the digits alone
   (unicode-range) and comes first in --face-display. The two files are EB Garamond cut down to 0-9, under the
   SIL Open Font License (the licence and copyright travel inside the files). */
@font-face {
    font-family: "Fell Figures";
    src: url("../fonts/garamond-figures.woff2") format("woff2");
    font-style: normal;
    font-weight: 400 800;
    font-display: swap;
    unicode-range: U+0030-0039;
}
@font-face {
    font-family: "Fell Figures";
    src: url("../fonts/garamond-figures-italic.woff2") format("woff2");
    font-style: italic;
    font-weight: 400;
    font-display: swap;
    unicode-range: U+0030-0039;
}

/* ---------- Tokens ---------- */
:root {
    --paper: #e4ddca;
    --paper-light: #eee8d8;
    --paper-deep: #cfc5ad;
    --paper-shade: #b9ae95;
    --ink: #1f1b16;
    --ink-soft: #3a332b;
    --ink-faded: #5a5246;
    --oxblood: #7a2b24;
    --oxblood-wash: #b98a7e;
    --slate: #4b5f70;
    --slate-wash: #9aa8b0;
    --fog-ink: #b9ad92;        /* faded ink for unexplored ground */
    --fog-paper: #cbbd9c;      /* the darker paper under the hatched shroud */
    --velvet: #5a2330;         /* the cabinet's tray lining */
    --velvet-deep: #2b0f16;
    --gilt: #b08a3c;           /* the tray's gilt edge and the chosen hollow's ring */
    --victorian-green: #5b7a58; /* a muted, Brunswick-ish green: the band round our hero on the map */

    --rule: 1.5px;
    --rule-fine: 1px;
    --gap-1: 0.25rem;
    --gap-2: 0.5rem;
    --gap-3: 0.75rem;
    --gap-4: 1rem;
    --gap-5: 1.5rem;
    --gap-6: 2.25rem;
    --gap-7: 3.5rem;

    --face-display: "Fell Figures", "IM Fell English", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
    --face-text: "EB Garamond", Garamond, "Iowan Old Style", "Palatino Linotype", Georgia, serif;

    --step--1: 0.875rem;
    --step-0: 1.0625rem;
    --step-1: 1.25rem;
    --step-2: 1.5rem;
    --step-3: 2rem;

    --target: 44px;
    --ease-ink: cubic-bezier(.3, .7, .2, 1);
    color-scheme: light;
}

/* ---------- Page ---------- */
*, *::before, *::after { box-sizing: border-box; }

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

html, body {
    margin: 0;
    min-height: 100%;
}

body {
    min-height: 100vh;
    min-height: 100dvh;
    color: var(--ink);
    font-family: var(--face-text);
    font-size: var(--step-0);
    line-height: 1.5;
    font-feature-settings: "kern", "liga", "onum";
    /* Paper lit from above, darkening to the corners: dusk. */
    background-color: var(--paper);
    background-image:
        radial-gradient(120% 90% at 50% 20%, transparent 40%, rgba(70, 58, 40, 0.16) 80%, rgba(45, 38, 30, 0.32) 100%),
        radial-gradient(70% 55% at 50% 30%, var(--paper-light) 0%, transparent 70%);
    background-attachment: fixed;
}

.ink-defs, .icon-sprite {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

.paper-grain {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 50;
    opacity: 0.32;
    mix-blend-mode: multiply;
}

::selection { background: var(--ink); color: var(--paper-light); }

h1, h2, h3 {
    font-family: var(--face-display);
    font-weight: 400;
    line-height: 1.15;
    margin: 0;
}

p { margin: 0; }

em { font-style: italic; }

kbd, code {
    font-family: var(--face-text);
    font-size: 0.9em;
    padding: 0 0.3em;
    border: var(--rule-fine) solid var(--ink-faded);
    border-radius: 3px;
    background: var(--paper-light);
}

code { border-style: dotted; }

:focus-visible {
    outline: 2px solid var(--ink);
    outline-offset: 3px;
}

.skip-link {
    position: absolute;
    left: var(--gap-4);
    top: -100px;
    z-index: 100;
    padding: var(--gap-2) var(--gap-4);
    background: var(--ink);
    color: var(--paper-light);
}

.skip-link:focus { top: var(--gap-2); }

/* ---------- Waking (before .NET is ready) ---------- */
.waking {
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    place-content: center;
    gap: var(--gap-3);
    text-align: center;
    padding: var(--gap-4);
}

.waking-title {
    font-family: var(--face-display);
    font-size: clamp(3rem, 12vw, 5rem);
    line-height: 1;
}

.waking-line {
    font-family: var(--face-display);
    font-style: italic;
    color: var(--ink-faded);
}

.waking-line .loading-progress-text::after {
    content: " " var(--blazor-load-percentage-text, "");
}

.boot-error { color: var(--oxblood); max-width: 32rem; }

/* ---------- Ink buttons ---------- */
.ink-btn {
    position: relative;
    isolation: isolate;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--gap-2);
    min-height: var(--target);
    padding: 0.45rem 1.25rem 0.5rem;
    border: 0;
    background: none;
    color: var(--ink);
    font: inherit;
    font-size: var(--step-0);
    line-height: 1.2;
    text-align: center;
    cursor: pointer;
    touch-action: manipulation;
    transition: transform 120ms var(--ease-ink), color 120ms;
}

/* The drawn border/slab sits behind the label and is roughened by the ink filter. */
.ink-btn::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    border: var(--rule) solid var(--ink);
    border-radius: 2px 3px 2px 4px;
    filter: url(#ink);
    transition: background-color 120ms, box-shadow 120ms;
}

.ink-btn--primary { color: var(--paper-light); font-weight: 500; letter-spacing: 0.01em; }
.ink-btn--primary::before { background: var(--ink); box-shadow: 2px 3px 0 var(--paper-shade); }
.ink-btn--primary:hover::before { background: var(--ink-soft); }

.ink-btn--secondary::before { background: rgba(238, 232, 216, 0.55); }
.ink-btn--secondary:hover::before { background: var(--paper-light); box-shadow: 2px 2px 0 var(--paper-shade); }

.ink-btn--quiet {
    padding-inline: 0.25rem;
    font-style: italic;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.22em;
    text-decoration-color: var(--ink-faded);
}
.ink-btn--quiet::before { border-color: transparent; }
.ink-btn--quiet:hover { text-decoration-color: var(--ink); text-decoration-thickness: 2px; }

.ink-btn:active:not(:disabled) { transform: translate(1px, 1px); }

.ink-btn:disabled {
    cursor: not-allowed;
    color: var(--ink-faded);
}
.ink-btn:disabled::before {
    border-style: dashed;
    border-color: var(--ink-faded);
    background: transparent;
    box-shadow: none;
}

/* ---------- Cards and notices ---------- */
.card {
    position: relative;
    isolation: isolate;
    padding: var(--gap-5);
}

.card::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: rgba(238, 232, 216, 0.72);
    border: var(--rule) solid var(--ink);
    box-shadow: 3px 4px 0 rgba(31, 27, 22, 0.12);
    filter: url(#ink);
}

.card__title {
    font-size: var(--step-2);
    margin-bottom: var(--gap-3);
}

.notice {
    margin-block: var(--gap-3);
    padding-left: var(--gap-3);
    border-left: 3px solid var(--oxblood);
    color: var(--oxblood);
    font-style: italic;
}

/* Back from a lost fight: the news, plainly, above the park until the player acts again. */
.sent-back {
    margin-block: var(--gap-3);
    padding: var(--gap-3) var(--gap-4);
    border: 1px solid var(--oxblood);
    border-left-width: 4px;
    background: var(--paper-light);
    scroll-margin-top: var(--gap-3);
}
.sent-back__kicker { font-family: var(--face-display); font-size: var(--step-2); color: var(--oxblood); }
.sent-back__then { margin-top: var(--gap-2); font-style: italic; color: var(--ink-faded); }

/* ---------- Stat bars ---------- */
.stat-bar {
    display: grid;
    grid-template-columns: minmax(5.5em, auto) 1fr auto;
    align-items: center;
    gap: var(--gap-3);
    font-size: var(--step--1);
}

.stat-bar__label { font-variant: small-caps; letter-spacing: 0.04em; }

.stat-bar__track {
    position: relative;
    height: 0.8rem;
    border: var(--rule-fine) solid var(--ink);
    background: var(--paper-light);
    filter: url(#ink);
}

.stat-bar__fill {
    position: absolute;
    inset: 0 auto 0 0;
    background-color: var(--ink);
    /* Hatched, not flat: it is drawn, after all. */
    background-image: repeating-linear-gradient(-55deg, transparent 0 2px, rgba(238, 232, 216, 0.28) 2px 3px);
    transition: width 300ms var(--ease-ink);
}

.stat-bar--oxblood .stat-bar__fill { background-color: var(--oxblood); }
.stat-bar--slate .stat-bar__fill { background-color: var(--slate); }

.stat-bar__value { font-variant-numeric: lining-nums tabular-nums; min-width: 3.2em; text-align: right; }
.stat-bar__max { color: var(--ink-faded); }

/* ---------- Dice ---------- */
.dice {
    display: inline-flex;
    align-items: center;
    gap: var(--gap-3);
}

.dice__face {
    width: 3.25rem;
    height: 3.25rem;
    flex: none;
    overflow: visible;
}

.dice__outline {
    fill: var(--paper-light);
    stroke: var(--ink);
    stroke-width: 2;
    stroke-linejoin: round;
    filter: url(#ink);
}

.dice__facets {
    fill: none;
    stroke: var(--ink-faded);
    stroke-width: 1;
    stroke-linejoin: round;
}

.dice__num {
    font-family: var(--face-display);
    font-size: 15px;
    fill: var(--ink);
    font-variant-numeric: lining-nums;
}

.dice--rolling .dice__face { animation: dice-tumble 400ms linear infinite; }
.dice--rolling .dice__num { fill: var(--ink-faded); }

.dice--bold .dice__outline { stroke-width: 3.2; }
.dice--bold .dice__num { font-weight: 700; font-size: 17px; paint-order: stroke; stroke: var(--ink); stroke-width: 0.6px; }

.dice--grim .dice__outline { stroke: var(--oxblood); fill: #e8d8cc; }
.dice--grim .dice__facets { stroke: var(--oxblood-wash); }
.dice--grim .dice__num { fill: var(--oxblood); }

.dice__detail {
    font-variant: small-caps;
    letter-spacing: 0.03em;
    font-variant-numeric: lining-nums;
}

@keyframes dice-tumble {
    0% { transform: rotate(0deg); }
    25% { transform: rotate(14deg) translateY(-2px); }
    50% { transform: rotate(-8deg); }
    75% { transform: rotate(10deg) translateY(-1px); }
    100% { transform: rotate(0deg); }
}

/* ---------- Narration log ---------- */
.log {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: var(--gap-2) var(--gap-1) var(--gap-4);
    font-family: var(--face-display);
    font-size: 1.06rem;
    line-height: 1.5;
    scrollbar-width: thin;
    scrollbar-color: var(--ink-faded) transparent;
}

.log__empty { color: var(--ink-faded); font-style: italic; }

.log__line { margin: 0 0 0.45em; transition: color 400ms; }
.log__line + .log__line--narration { text-indent: 1.2em; }
.log__line--dice {
    font-family: var(--face-text);
    font-variant: small-caps;
    font-variant-numeric: lining-nums;
    letter-spacing: 0.03em;
    font-size: 0.98rem;
    color: var(--ink-soft);
    padding-left: 1.2em;
}
.log__line--note { font-family: var(--face-text); font-style: italic; color: var(--ink-faded); }
/* Older lines fade by ink, not by opacity, so even the faintest stays above 4.5:1 against the paper (5.7:1). */
.log__line--older { color: var(--ink-soft); }
.log__line--old { color: var(--ink-faded); }

.log__line:last-child { animation: line-arrives 500ms var(--ease-ink); }

@keyframes line-arrives {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: none; }
}

/* ---------- Icons ---------- */
.icon {
    width: 1.5em;
    height: 1.5em;
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    filter: url(#ink);
    vertical-align: middle;
}

/* ---------- Modal ---------- */
.modal-scrim {
    position: fixed;
    inset: 0;
    z-index: 60;
    background: rgba(31, 27, 22, 0.45);
    animation: fade-in 180ms ease-out;
}

.modal {
    position: fixed;
    z-index: 61;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(36rem, calc(100vw - 2rem));
    max-height: calc(100dvh - 2rem);
    overflow: auto;
    padding: var(--gap-5) var(--gap-5) var(--gap-5);
    background: var(--paper-light);
    border: var(--rule) solid var(--ink);
    box-shadow: 6px 8px 0 rgba(31, 27, 22, 0.25);
    animation: modal-in 220ms var(--ease-ink);
}

.modal:focus { outline: none; }

.modal__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--gap-4);
    padding-bottom: var(--gap-3);
    margin-bottom: var(--gap-4);
    border-bottom: var(--rule-fine) solid var(--ink);
}

.modal__title { font-size: var(--step-3); }

.modal__close {
    flex: none;
    width: var(--target);
    height: var(--target);
    margin: -0.4rem -0.6rem 0 0;
    display: grid;
    place-items: center;
    border: 0;
    background: none;
    color: var(--ink);
    cursor: pointer;
}

.modal__close svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; filter: url(#ink); }

.modal__actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: var(--gap-3);
    margin-top: var(--gap-5);
}

@keyframes fade-in { from { opacity: 0; } }
@keyframes modal-in { from { opacity: 0; transform: translate(-50%, calc(-50% + 10px)); } }

/* How to play */
.how-to {
    margin: 0;
    padding-left: 1.6em;
    display: grid;
    gap: var(--gap-2);
}

.how-to__aside { margin: var(--gap-3, 1rem) 0 0.25rem; font-family: var(--face-display); font-style: italic; font-weight: normal; }
.how-to--plain { list-style: disc; padding-left: 1.4em; }
.how-to.how-to--plain li::marker { font-style: normal; }
.how-to-page > p { margin: 0 0 var(--gap-2); }
.how-to-page > .how-to__aside:first-child { margin-top: 0; }
.how-to__more { margin-top: var(--gap-3, 1rem); border-top: var(--rule-fine) solid var(--ink-faded); padding-top: var(--gap-2); }
.how-to__more > summary { cursor: pointer; font-family: var(--face-display); font-style: italic; margin-bottom: var(--gap-2); }
.how-to li::marker { font-family: var(--face-display); font-style: italic; color: var(--ink-faded); }

.small-print {
    margin-top: var(--gap-4);
    padding-top: var(--gap-3);
    border-top: var(--rule-fine) solid var(--paper-shade);
    font-size: var(--step--1);
    color: var(--ink-faded);
}
.small-print + .small-print { margin-top: var(--gap-2); padding-top: 0; border-top: 0; }
.small-print code { white-space: nowrap; }

/* ---------- Choices (radio groups) and fields ---------- */
.choice {
    border: 0;
    margin: 0;
    padding: 0;
    display: grid;
    gap: var(--gap-2);
}

.choice legend {
    padding: 0;
    margin-bottom: var(--gap-2);
    font-variant: small-caps;
    letter-spacing: 0.05em;
}

.choice__option {
    position: relative;
    display: grid;
    grid-template-columns: auto 1fr;
    column-gap: var(--gap-3);
    align-items: baseline;
    min-height: var(--target);
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    isolation: isolate;
}

.choice__option::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    border: var(--rule-fine) solid var(--ink-faded);
    filter: url(#ink);
}

.choice__option:has(input:checked)::before { border: 2px solid var(--ink); background: var(--paper-light); }
.choice__option:has(input:focus-visible) { outline: 2px solid var(--ink); outline-offset: 3px; }

.choice__option input {
    position: absolute;
    opacity: 0;
    inset: 0;
    margin: 0;
    cursor: pointer;
}

.choice__name { font-family: var(--face-display); font-size: var(--step-1); }
.choice__note { font-size: var(--step--1); font-style: italic; color: var(--ink-faded); }

/* A checked option gets a small inked tick-mark before its name. */
.choice__name::before {
    content: "";
    display: inline-block;
    width: 0.62em;
    height: 0.62em;
    margin-right: 0.45em;
    border: 1.5px solid var(--ink);
    border-radius: 50%;
    vertical-align: 0.02em;
}
.choice__option:has(input:checked) .choice__name::before { background: var(--ink); box-shadow: inset 0 0 0 2px var(--paper-light); }

.choice--row { grid-template-columns: repeat(3, 1fr); }
.choice--pair { grid-template-columns: repeat(2, 1fr); }
.choice--row legend { grid-column: 1 / -1; }
.choice--row .choice__option { grid-template-columns: 1fr; text-align: center; padding-block: 0.6rem; }

.field { display: grid; gap: var(--gap-1); }

.field__label {
    font-variant: small-caps;
    letter-spacing: 0.05em;
}

.field__input {
    width: 100%;
    min-height: var(--target);
    padding: 0.4rem 0.1rem;
    border: 0;
    border-bottom: var(--rule) solid var(--ink);
    border-radius: 0;
    background: transparent;
    color: var(--ink);
    font: inherit;
    font-size: var(--step-1);
    font-family: var(--face-display);
}

.field__input::placeholder { color: var(--ink-faded); font-style: italic; opacity: 1; font-size: var(--step-0); }

.field__input:focus-visible { outline: none; border-bottom-width: 3px; background: rgba(238, 232, 216, 0.6); }



.field__hint { font-size: var(--step--1); color: var(--ink-faded); font-style: italic; }

/* ---------- Title page: a book's opening spread ---------- */
.spread {
    display: grid;
    grid-template-columns: 1fr;
    max-width: 70rem;
    margin: 0 auto;
    padding: var(--gap-5) var(--gap-4) var(--gap-6);
    gap: var(--gap-6);
}

.spread__verso {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.vignette {
    margin: 0 0 var(--gap-4);
    width: min(100%, 30rem);
}

/* The picture brings its own ruled border, and its paper is transparent: the page's own paper shows through. */
.vignette img {
    display: block;
    width: 100%;
    height: auto;
}

.vignette figcaption {
    margin-top: var(--gap-3);
    font-family: var(--face-display);
    font-style: italic;
    font-size: var(--step--1);
    color: var(--ink-faded);
}

.title {
    font-size: clamp(3.6rem, 19vw, 7rem);
    line-height: 0.95;
    letter-spacing: 0.01em;
    margin-top: var(--gap-3);
}

.subtitle {
    position: relative;
    margin-top: var(--gap-3);
    max-width: 22em;
    text-wrap: balance;
    font-family: var(--face-display);
    font-style: italic;
    font-size: var(--step-1);
    line-height: 1.35;
    color: var(--ink-soft);
}

/* A short inked rule with a lozenge under the subtitle. */
.subtitle::after {
    content: "";
    display: block;
    width: 8rem;
    height: 1px;
    margin: var(--gap-5) auto var(--gap-2);
    background: linear-gradient(to right, transparent, var(--ink) 20%, var(--ink) 80%, transparent);
}

.subtitle::before {
    content: "";
    position: absolute;
    left: 50%;
    bottom: calc(var(--gap-2) - 3.5px);
    width: 7px;
    height: 7px;
    background: var(--ink);
    box-shadow: 0 0 0 3px var(--paper);
    transform: translateX(-50%) rotate(45deg);
}

.spread__recto {
    display: grid;
    align-content: start;
    gap: var(--gap-5);
    max-width: 30rem;
    width: 100%;
    margin: 0 auto;
}

.title-block {
    display: grid;
    gap: var(--gap-4);
    justify-items: start;
}

.title-block > .field, .title-block > .choice, .title-block > .title-block__go { width: 100%; }

.title-block__heading {
    font-size: var(--step-3);
}

.title-block__text { color: var(--ink-soft); margin-top: calc(var(--gap-3) * -1); }

.title-block__row { display: flex; flex-wrap: wrap; gap: var(--gap-2) var(--gap-3); }

.title-block--heroes {
    padding-bottom: var(--gap-5);
    border-bottom: var(--rule-fine) solid var(--ink);
}

/* The heroes: a card each, the most recent first and ringed. The card is one button (on a phone, all of it); on wider
   pages it ends in a drawn Continue. Forget sits quietly beside it. */
.slots {
    display: grid;
    gap: var(--gap-3);
    width: 100%;
    margin: 0;
    padding: 0;
    list-style: none;
}

.slot {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    background: var(--paper-light);
    border: var(--rule-fine) solid var(--ink-faded);
}

.slot--recent { outline: 2px solid var(--ink); outline-offset: -1px; }
.slot--broken { grid-template-columns: 1fr; }

.slot__go {
    display: grid;
    grid-template-columns: 56px 1fr auto;
    gap: var(--gap-3);
    align-items: center;
    width: 100%;
    min-height: var(--target);
    padding: var(--gap-2) var(--gap-3);
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    text-align: left;
}
button.slot__go { cursor: pointer; touch-action: manipulation; }
button.slot__go:hover .slot__name { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
button.slot__go:active:not(:disabled) .slot__continue { transform: translate(1px, 1px); }
div.slot__go { grid-template-columns: 56px 1fr; }

.slot .slot__portrait {
    display: block;
    width: 56px;
    height: 56px;
    border: 3px double var(--ink);
    border-radius: 50%;
    object-fit: cover;
    background: var(--paper-deep);
}

.slot__text { display: grid; gap: 1px; min-width: 0; }
.slot__name { font-size: var(--step-1); font-weight: 500; line-height: 1.2; }
.slot__title { font-size: var(--step--1); font-weight: 400; color: var(--ink-faded); }
.slot__meta, .slot__marbles { font-size: var(--step--1); line-height: 1.3; color: var(--ink-faded); }
.slot__continue { font-size: var(--step--1); }

.slot__forget {
    align-self: stretch;
    min-width: var(--target);
    min-height: var(--target);
    padding: 0 var(--gap-3);
    border: 0;
    background: none;
    color: var(--ink-faded);
    font: inherit;
    font-size: var(--step--1);
    font-style: italic;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.22em;
    cursor: pointer;
    touch-action: manipulation;
}
.slot__forget:hover { color: var(--ink); }

.slot__trouble { display: grid; gap: var(--gap-2); padding: 0 var(--gap-3) var(--gap-3); }
.slot__notice { color: var(--oxblood); font-style: italic; }
.slot__why { font-size: var(--step--1); color: var(--ink-faded); }

.slots__new {
    width: 100%;
    min-height: var(--target);
    padding: var(--gap-3);
    border: var(--rule-fine) dashed var(--ink-faded);
    background: none;
    color: var(--ink-faded);
    font: inherit;
    font-style: italic;
    text-align: center;
}
button.slots__new {
    cursor: pointer; touch-action: manipulation;
    /* A way in, not a note: full ink, upright, a size up, on a paler ground inside a firmer dashed line. */
    color: var(--ink); font-family: var(--face-display); font-style: normal; font-size: var(--step-1);
    border: var(--rule) dashed var(--ink-soft); background: rgba(238, 232, 216, 0.6);
}
.slots__waiting { margin-top: var(--gap-3); display: flex; flex-wrap: wrap; gap: var(--gap-2); align-items: center; color: var(--ink-faded); font-style: italic; }
.slots__waiting p { margin: 0; flex: 1 1 14rem; }
button.slots__new:hover, .slots__new[aria-expanded="true"] { color: var(--ink); border-color: var(--ink); border-style: solid; background: var(--paper-light); }

@media (max-width: 40rem) {
    .slot__go, div.slot__go { grid-template-columns: 48px 1fr; }
    .slot .slot__portrait { width: 48px; height: 48px; }
    .slot__continue { display: none; }
}


.title-links { margin-top: calc(var(--gap-3) * -1); }

.beta-note {
    padding-top: var(--gap-3);
    border-top: var(--rule-fine) solid var(--paper-shade);
    font-size: var(--step--1);
    color: var(--ink-faded);
}

.beta-note__build {
    margin-top: var(--gap-2);
    font-variant: small-caps;
    letter-spacing: 0.04em;
}
.beta-note__sha {
    font-variant: normal;
    font-variant-numeric: lining-nums;
    letter-spacing: 0.02em;
    user-select: all;
}

.beta-note::before {
    content: "A beta edition";
    display: block;
    margin-bottom: var(--gap-1);
    font-variant: small-caps;
    letter-spacing: 0.06em;
    color: var(--ink-soft);
}

@media (min-width: 900px) {
    .spread {
        grid-template-columns: 1fr 1fr;
        align-items: center;
        gap: 0;
        min-height: 100vh;
        min-height: 100dvh;
        padding-block: var(--gap-6);
    }

    .spread__verso, .spread__recto { padding: var(--gap-6) var(--gap-7); }
    .spread__recto { max-width: none; }

    /* The gutter: a faint fold between the pages. */
    .spread__verso {
        position: relative;
        align-self: stretch;
        justify-content: center;
    }
    .spread__verso::after {
        content: "";
        position: absolute;
        right: -1px;
        top: 6%;
        bottom: 6%;
        width: 60px;
        background: linear-gradient(to right, transparent, rgba(45, 38, 30, 0.07) 85%, rgba(45, 38, 30, 0.13));
        border-right: var(--rule-fine) solid rgba(31, 27, 22, 0.18);
        pointer-events: none;
    }
}

/* ---------- The game shell ---------- */
.game {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

.game__bar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: var(--gap-4);
    padding: var(--gap-2) var(--gap-4);
    background: rgba(228, 221, 202, 0.94);
    border-bottom: var(--rule-fine) solid var(--ink);
    box-shadow: 0 3px 0 rgba(31, 27, 22, 0.06);
}

.game__mark { font-family: var(--face-display); font-size: var(--step-2); line-height: 1; }
.game__where { font-style: italic; color: var(--ink-faded); font-size: var(--step--1); margin-right: auto; }

.game__body {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
    max-width: 84rem;
    margin: 0 auto;
}

.game__screen {
    min-width: 0;
    padding: var(--gap-5) var(--gap-4) var(--gap-7);
}

@media (min-width: 900px) {
    .game__screen { padding: var(--gap-6) var(--gap-6) var(--gap-6); }
}

/* ---------- Menu ---------- */
.menu { position: relative; }

.menu__button {
    display: inline-flex;
    align-items: center;
    gap: var(--gap-2);
    min-height: var(--target);
    min-width: var(--target);
    padding: 0 var(--gap-3);
    border: var(--rule-fine) solid transparent;
    background: none;
    color: var(--ink);
    font: inherit;
    cursor: pointer;
}

.menu__button:hover, .menu__button[aria-expanded="true"] { border-color: var(--ink); background: var(--paper-light); }

.menu__scrim { position: fixed; inset: 0; z-index: 40; }

.menu__list {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    z-index: 41;
    min-width: 13rem;
    margin: 0;
    padding: var(--gap-2) 0;
    list-style: none;
    background: var(--paper-light);
    border: var(--rule) solid var(--ink);
    box-shadow: 4px 5px 0 rgba(31, 27, 22, 0.2);
    animation: fade-in 120ms ease-out;
}

.menu__list button {
    display: block;
    width: 100%;
    min-height: var(--target);
    padding: 0 var(--gap-4);
    border: 0;
    background: none;
    color: var(--ink);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.menu__list button:hover, .menu__list button:focus-visible { background: var(--paper-deep); outline-offset: -3px; }
.menu__sep { border-top: var(--rule-fine) solid var(--paper-shade); margin-top: var(--gap-2); padding-top: var(--gap-2); }
.menu__build {
    padding: var(--gap-2) var(--gap-4) 0;
    font-size: var(--step--1);
    font-variant: small-caps;
    letter-spacing: 0.04em;
    color: var(--ink-faded);
}

/* ---------- Plain actions ---------- */
.action-list {
    display: flex;
    flex-wrap: wrap;
    gap: var(--gap-3);
}

/* ---------- Toast ---------- */
.toast-host {
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(4.5rem + env(safe-area-inset-bottom));
    z-index: 70;
    display: flex;
    justify-content: center;
    pointer-events: none;
}

.toast {
    max-width: min(36rem, calc(100vw - 2rem));
    text-align: center;
    padding: 0.55rem 1.4rem;
    background: var(--ink);
    color: var(--paper-light);
    font-family: var(--face-display);
    font-style: italic;
    font-size: var(--step-1);
    box-shadow: 3px 4px 0 rgba(31, 27, 22, 0.25);
    animation: toast-in 220ms var(--ease-ink);
}

@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

@media (min-width: 900px) { .toast-host { bottom: var(--gap-6); } }

/* ---------- Blazor's own error strip ---------- */
#blazor-error-ui {
    display: none;
    position: fixed;
    left: 0;
    bottom: 0;
    z-index: 1000;
    width: 100%;
    padding: 0.7rem 3rem 0.8rem 1.25rem;
    background: var(--oxblood);
    color: var(--paper-light);
    font-family: var(--face-display);
}

#blazor-error-ui a { color: inherit; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 1rem; top: 0.6rem; font-size: 1.4rem; }

.blazor-error-boundary { background: var(--oxblood); padding: 1rem; color: var(--paper-light); }
.blazor-error-boundary::after { content: "Something went wrong here."; }

/* ---------- Less motion, when asked ---------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 1ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 1ms !important;
    }
}

/* ---------- Creation and nursery screens ---------- */
.screen { max-width: 62rem; margin: 0 auto; }

.screen__head { margin-bottom: var(--gap-5); }
.screen__title { font-size: clamp(2.1rem, 7vw, 3rem); }
.screen__lede { margin-top: var(--gap-2); max-width: 36rem; font-family: var(--face-display); font-style: italic; font-size: var(--step-1); color: var(--ink-soft); line-height: 1.35; }

.ink-btn--big { min-height: 3.4rem; padding-inline: 2.25rem; font-family: var(--face-display); font-size: var(--step-2); }

/* A toddler on paper. */
.toddler { display: grid; gap: var(--gap-4); }
/* The wrapper round everything below the stats keeps the same spacing between its parts as the card itself. */
.toddler__more[open] { display: grid; gap: var(--gap-4); }
.toddler__more--folds[open] > .toddler__more-line { margin-bottom: calc(var(--gap-4) * -1 + var(--gap-1)); }
.toddler__stats { display: grid; gap: var(--gap-2); }

.stat-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: var(--gap-3); min-height: 1.75rem; }
.stat-row:not(:has(> :nth-child(2))) { grid-template-columns: 1fr; }
.stat-row .stat-bar { grid-template-columns: 5.4rem 1fr 3.2rem; }

.derived { display: flex; flex-wrap: wrap; gap: var(--gap-2) var(--gap-5); margin: 0; padding: var(--gap-2) 0; border-block: var(--rule-fine) solid var(--paper-shade); font-size: var(--step--1); }
.derived div { display: flex; gap: var(--gap-2); align-items: baseline; }
.derived dt { font-variant: small-caps; letter-spacing: 0.04em; color: var(--ink-soft); }
.derived dd { margin: 0; font-family: var(--face-display); font-size: var(--step-1); font-variant-numeric: lining-nums; }
.satchel__load { margin: 0 0 var(--gap-2); font-size: var(--step--1); color: var(--ink-soft); }
.satchel__load strong { font-family: var(--face-display); font-size: var(--step-1); font-weight: 400; color: var(--ink); font-variant-numeric: lining-nums; }
.satchel__load--heavy strong { color: var(--oxblood); }
.stall__purse { margin: 0 0 var(--gap-2); font-size: var(--step--1); color: var(--ink-soft); }
.stall__purse strong { font-family: var(--face-display); font-size: var(--step-1); font-weight: 400; color: var(--ink); font-variant-numeric: lining-nums; }

.part-title { font-size: var(--step-0); font-family: var(--face-text); font-variant: small-caps; letter-spacing: 0.06em; color: var(--ink-soft); margin-bottom: var(--gap-1); border-bottom: var(--rule-fine) dotted var(--ink-faded); }

.facts { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--gap-2); }
.facts li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 var(--gap-3); }
.facts__name { font-family: var(--face-display); font-size: var(--step-0); }
.facts__text { font-size: var(--step--1); color: var(--ink-soft); font-style: italic; }
.facts__effect { font-size: var(--step--1); font-variant: small-caps; letter-spacing: 0.04em; font-variant-numeric: lining-nums; color: var(--oxblood); }
.facts__slot { flex: 0 0 4rem; font-variant: small-caps; letter-spacing: 0.05em; font-size: var(--step--1); color: var(--ink-faded); }
.facts__none { font-style: italic; color: var(--ink-faded); font-size: var(--step--1); }
.facts--gear li { display: grid; grid-template-columns: 3.6rem 2.5rem 1fr auto; align-items: center; column-gap: var(--gap-3); row-gap: 0; }
.facts--gear .facts__slot { grid-column: 1; grid-row: 1 / span 2; flex: none; }
.facts--gear .facts__figure { grid-column: 2; grid-row: 1 / span 2; width: 2.5rem; height: 2.5rem; }
.facts--gear .facts__name, .facts--gear .facts__none { grid-column: 3; }
.facts--gear .facts__text { grid-column: 3; }
.facts--gear li > .chip { grid-column: 4; grid-row: 1 / span 2; }

/* Candidate cards. */
.cands { display: grid; grid-template-columns: 1fr; gap: var(--gap-5); align-items: start; }

.cand { cursor: pointer; transition: transform 160ms var(--ease-ink); }
.cand:hover:not(.cand--off) { transform: translateY(-2px); }
.cand--off { cursor: default; }
.cand .card { padding: var(--gap-4) var(--gap-4) var(--gap-4); }
.cand:hover:not(.cand--off) .card::before { background: rgba(244, 239, 224, 0.92); box-shadow: 4px 6px 0 rgba(31, 27, 22, 0.16); }
.cand--standard .card::before { border-style: double; border-width: 4px; }

.cand__kicker { font-variant: small-caps; letter-spacing: 0.08em; font-size: var(--step--1); color: var(--ink-faded); }
.cand__name { display: flex; align-items: center; gap: var(--gap-2); font-size: var(--step-3); margin-bottom: var(--gap-3); }
.cand__icon { width: 1.3em; height: 1.3em; color: var(--ink-soft); }
.cand__pron { font-family: var(--face-text); font-style: italic; font-size: var(--step--1); color: var(--ink-faded); align-self: flex-end; padding-bottom: 0.35em; }
.cand__choose { margin-top: var(--gap-4); display: grid; }

/* Bonus points. */
.bonus { max-width: 40rem; }
.bonus__remaining { display: flex; align-items: center; gap: var(--gap-4); margin-bottom: var(--gap-4); }
.bonus__count { font-family: var(--face-display); font-size: var(--step-1); font-variant-numeric: lining-nums; }
.bonus__count strong { font-size: var(--step-3); font-weight: 400; margin-right: 0.15em; }
.bonus__finish { margin-top: var(--gap-5); display: flex; justify-content: flex-end; }
.pips { display: inline-flex; gap: var(--gap-2); }
.pip { width: 1.1rem; height: 1.1rem; border: 2px solid var(--ink); border-radius: 50%; filter: url(#ink); }
.pip--full { background: var(--ink); box-shadow: inset 0 0 0 2px var(--paper-light); }

.plus, .chip {
    position: relative;
    isolation: isolate;
    min-height: var(--target);
    border: 0;
    background: none;
    color: var(--ink);
    font: inherit;
    cursor: pointer;
    touch-action: manipulation;
}
.plus::before, .chip::before { content: ""; position: absolute; inset: 0.3rem 0; z-index: -1; border: var(--rule) solid var(--ink); border-radius: 2px 3px 2px 4px; background: rgba(238, 232, 216, 0.55); filter: url(#ink); }
.plus { width: var(--target); font-family: var(--face-display); font-size: 1.6rem; line-height: 1; }
.plus::before { inset: 0.15rem; }
.chip { min-width: 4.2rem; padding: 0 var(--gap-3); font-size: var(--step--1); font-variant: small-caps; letter-spacing: 0.05em; }
.plus:hover:not(:disabled)::before, .chip:hover:not(:disabled)::before { background: var(--ink); }
.plus:hover:not(:disabled), .chip:hover:not(:disabled) { color: var(--paper-light); }
.plus:active:not(:disabled), .chip:active:not(:disabled) { transform: translate(1px, 1px); }
.plus:disabled, .chip:disabled { cursor: not-allowed; color: var(--ink-faded); }
.plus:disabled::before, .chip:disabled::before { border-style: dashed; border-color: var(--ink-faded); background: transparent; }

/* Nursery. */
/* One column, no wider than the face-off, inside the page's gilt frame: the title with its scrolls and crest, the hero's
   card, any lesson on offer, the folds (each in its own frame), the way out. */
.screen--nursery {
    max-width: 54rem; display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--gap-5);
    border: 80px solid transparent; border-image: var(--page-frame) 198 stretch;
    padding: 0 0 var(--gap-2);
}
.screen--nursery > .screen__head { margin-bottom: 0; }
.nursery__head { display: grid; justify-items: center; text-align: center; gap: var(--gap-2); }
.nursery__head .screen__lede { margin: 0 auto; }
.nursery__titleline { display: flex; align-items: center; justify-content: center; gap: var(--gap-3); }
.nursery__scroll { width: clamp(3.5rem, 12vw, 6rem); height: auto; }
.nursery__crest { display: flex; align-items: flex-end; justify-content: center; gap: var(--gap-1); }
.nursery__horse { width: clamp(6rem, 22vw, 8.5rem); height: auto; }
.nursery__laurel { width: clamp(2.6rem, 9vw, 4.2rem); height: auto; }
.nursery__rule { display: block; width: 100%; height: auto; }

/* A frame drawn from the section borders: the hero's card and every fold. */
.framed { border-style: solid; border-color: transparent; border-width: 26px 15px; border-image: var(--section-frame) 76 44 stretch; }

.hero { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--gap-4); padding: 0 var(--gap-3); }
.hero__top { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: var(--gap-4); }
.hero .hero__portrait { width: clamp(5.5rem, 24vw, 8.5rem); height: auto; aspect-ratio: 1; object-fit: cover; }
.hero__rank { display: grid; gap: var(--gap-1); min-width: 0; }
.hero__rank .rank__title { font-size: clamp(1.5rem, 5vw, var(--step-3)); line-height: 1.1; }
.hero__rank .rank__note { margin: 0; }
.hero__rank .stat-bar { grid-template-columns: 5.4rem 1fr 3.2rem; }
.hero__strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 0; border-top: var(--rule-fine) solid var(--paper-shade); padding-top: var(--gap-3); }
.hero__strip div { display: grid; justify-items: center; gap: 0; padding-inline: var(--gap-1); }
.hero__strip div + div { border-left: var(--rule-fine) dotted var(--ink-faded); }
.hero__strip dt { font-variant: small-caps; letter-spacing: 0.05em; font-size: var(--step--1); color: var(--ink-soft); }
.hero__strip dd { margin: 0; font-family: var(--face-display); font-size: var(--step-2); font-variant-numeric: lining-nums; line-height: 1.1; }
.hero__of { font-size: var(--step-0); color: var(--ink-faded); }
.hero__treasure { color: var(--oxblood); }

/* The folds: each framed, a heading that opens it. */
.folds { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--gap-2); }
.fold__head { display: grid; grid-template-columns: 3.25rem minmax(0, 1fr) auto; align-items: center; gap: var(--gap-3); min-height: var(--target); padding: var(--gap-1) var(--gap-2); cursor: pointer; list-style: none; }
.fold__head::-webkit-details-marker { display: none; }
summary.fold__head:hover { background: rgba(238, 232, 216, 0.55); }
summary.fold__head:focus-visible { outline: 2px solid var(--slate); outline-offset: -2px; }
.fold__icon { width: 3.25rem; height: 2.6rem; object-fit: contain; }
.fold__titles { display: grid; min-width: 0; }
.fold__title { font-family: var(--face-display); font-size: var(--step-1); line-height: 1.2; }
.fold__note { font-size: var(--step--1); font-style: italic; color: var(--ink-faded); font-variant-numeric: lining-nums; }
.fold__mark { width: 0.6rem; height: 0.6rem; margin-right: var(--gap-2); border-right: 2px solid var(--ink-soft); border-bottom: 2px solid var(--ink-soft); transform: rotate(-45deg); transition: transform 160ms var(--ease-ink); }
.fold[open] > .fold__head .fold__mark { transform: rotate(45deg); }
.fold__body { padding: var(--gap-2) var(--gap-2) var(--gap-2) calc(3.25rem + var(--gap-3) + var(--gap-2)); }
.fold__body .toddler__stats { max-width: 28rem; }
.fold--cabinet .fold__head { cursor: default; }
.fold--cabinet .cabinet-btn { justify-self: end; }

/* The difficulty's heading between two short rules. */
.difficulty__legend { display: flex; align-items: center; justify-content: center; gap: var(--gap-3); width: 100%; text-align: center; }
.difficulty__legend img { flex: 1 1 0; min-width: 1.5rem; max-width: 10rem; height: auto; }
.go { justify-items: center; text-align: center; }
/* On a narrow screen the hero's card stacks: the portrait over the name, the four figures two by two. */
@media (max-width: 480px) {
    .hero__top { grid-template-columns: minmax(0, 1fr); justify-items: center; text-align: center; gap: var(--gap-2); }
    .hero__rank { justify-items: center; width: 100%; }
    .hero__rank .stat-bar { width: 100%; grid-template-columns: auto 1fr auto; }
    .hero__strip { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: var(--gap-3); }
    .hero__strip div:nth-child(3) { border-left: 0; }
    .nursery__titleline { gap: var(--gap-1); }
    .nursery__titleline .screen__title { font-size: clamp(1.7rem, 8vw, 2.1rem); }
    .nursery__scroll { width: clamp(2.2rem, 11vw, 3.5rem); }
    .nursery__go .choice--row { grid-template-columns: minmax(0, 1fr); }
    /* A thing's buttons go beneath its words, the picture beside them. */
    .fold__body .line { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: var(--gap-3); row-gap: var(--gap-1); }
    .fold__body .line__buttons { grid-column: 2; justify-self: end; }
    .difficulty__legend span { white-space: nowrap; }
    .difficulty__legend img { min-width: 0.5rem; }
}
.line__name--none { font-style: italic; color: var(--ink-faded); font-size: var(--step-0); }
@media (max-width: 640px) {
    .screen--nursery { border-width: 30px; padding: 0; gap: var(--gap-4); }
    .framed { border-width: 20px 11px; }
    .hero { padding: 0 var(--gap-1); }
    .fold__head { padding-inline: var(--gap-1); grid-template-columns: 2.6rem minmax(0, 1fr) auto; }
    .fold__icon { width: 2.6rem; height: 2.1rem; }
    .fold__body { padding: var(--gap-1); }
    .hero__strip dd { font-size: var(--step-1); }
}

.rank { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 var(--gap-3); margin-bottom: var(--gap-3); }
.rank__level { font-variant: small-caps; letter-spacing: 0.08em; color: var(--ink-faded); }
.rank__title { font-size: var(--step-3); }
.rank__note { margin: var(--gap-1) 0 var(--gap-4); font-size: var(--step--1); font-style: italic; color: var(--ink-faded); }
.rank .rank__title { flex: 1 1 100%; order: 2; }
.rank .rank__level { order: 1; flex: 1 1 100%; }

.panel .card__title { font-size: var(--step-2); }
.panel__note { font-size: var(--step--1); font-style: italic; color: var(--ink-faded); margin: calc(var(--gap-2) * -1) 0 var(--gap-3); font-variant-numeric: lining-nums; }
.panel__empty { font-style: italic; color: var(--ink-faded); padding: var(--gap-2) 0; }
.panel--offer::before { content: none; }
.panel--offer .card__title { color: var(--oxblood); }

.lines { list-style: none; margin: 0; padding: 0; }
.line { display: flex; align-items: center; justify-content: space-between; gap: var(--gap-3); padding: var(--gap-2) 0; border-top: var(--rule-fine) dotted var(--ink-faded); }
.line:first-child { border-top: 0; }
.line__text { display: grid; min-width: 0; }
.line__name { font-family: var(--face-display); font-size: var(--step-1); line-height: 1.2; }
.line__note { font-size: var(--step--1); font-style: italic; color: var(--ink-soft); }
.line__buttons { display: flex; align-items: center; gap: var(--gap-2); flex: none; }
/* A thing's figure, small, wherever things are listed; with none drawn, an empty space of the same size. */
.item-figure { display: block; flex: none; object-fit: contain; }
.line__figure { width: 2.75rem; height: 2.75rem; }
.line__figure ~ .line__text { flex: 1 1 auto; }
@media (max-width: 640px) { .line__figure { width: 2.25rem; height: 2.25rem; } }

.price { font-family: var(--face-display); font-size: var(--step-1); font-variant-numeric: lining-nums; white-space: nowrap; }
.price__unit { font-family: var(--face-text); font-size: var(--step--1); font-style: italic; color: var(--ink-faded); }
.price--dear { color: var(--oxblood); }

.nursery__go { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--gap-5); }
.nursery__go .difficulty { min-width: 0; }
.difficulty .choice__option--off { opacity: 0.55; }
.go { display: grid; justify-items: start; gap: var(--gap-2); }
.go .ink-btn { width: 100%; }
.go__why { font-style: italic; color: var(--oxblood); }

@media (min-width: 700px) {
    .cands { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1200px) {
    .cands { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- The park ---------- */
.park { display: grid; gap: var(--gap-3); max-width: 72rem; margin: 0 auto; }

/* The board, with the errand rail beside it (above it, as a row, on a narrow screen). */
.park__field { display: grid; gap: var(--gap-3); min-width: 0; }
.park__field > .park__map { min-width: 0; }

/* The map, and the satchel when it is open: laid over the map, at least as tall as it, growing past it only if need be. */
.park__map { position: relative; }
.park__over {
    position: absolute; top: 0; left: 0; width: 100%; min-height: 100%; z-index: 20;
    display: grid; align-content: start; gap: var(--gap-2);
    padding: var(--gap-3) var(--gap-4);
    border: var(--rule) solid var(--ink);
    background: var(--paper-light);
    box-shadow: 3px 4px 0 rgba(31, 27, 22, 0.16);
    animation: fade-in 140ms ease-out;
    scroll-margin-top: 4.5rem;   /* clear of the top bar when it is brought into view */
}
.park__over-head { display: flex; align-items: center; justify-content: space-between; gap: var(--gap-3); }
.park__over-title { font-size: var(--step-2); }
.park__over .satchel { padding: 0; border: 0; background: none; box-shadow: none; animation: none; }
/* Kept short, so it covers the map without running past it: an empty slot is one slim line, and on a wider screen what
   he wears and what he carries stand side by side. */
.park__over .satchel { grid-template-columns: minmax(0, 1fr); column-gap: var(--gap-5); }
.park__over .satchel__load { grid-column: 1 / -1; margin: 0; }
.park__over .line { padding-block: 0.3rem; }
.park__over .line:has(.item-figure--none) { padding-block: 0.15rem; min-height: 0; }
.park__over .line:has(.item-figure--none) .line__figure { height: 1.4rem; }
.park__over .chip { white-space: nowrap; }
@media (min-width: 700px) {
    .park__over .satchel { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
    /* The map runs to the screen's edges on a phone; so does the satchel over it. */
    .park__over { left: calc(var(--gap-4) * -1 + 2px); width: calc(100% + 2 * (var(--gap-4) - 2px)); padding-inline: var(--gap-3); }
}
@media (min-width: 900px) {
    .park__field { grid-template-columns: minmax(0, 1fr) 8rem; align-items: start; }
    .park__field > .rail { order: 2; }
}

.rail { display: flex; flex-wrap: wrap; gap: var(--gap-2) var(--gap-5); align-items: flex-start; }
.rail__part { display: grid; gap: var(--gap-1); align-content: start; }
.rail__heading { font-family: var(--face-text); font-size: var(--step--1); font-weight: normal; font-variant: small-caps;
    letter-spacing: 0.06em; color: var(--ink-faded); margin: 0; }
.rail__slots, .rail__hands { display: flex; flex-wrap: wrap; gap: 0.3rem; list-style: none; margin: 0; padding: 0; }
.rail__slot, .rail__held { display: grid; place-items: center; width: 2.6rem; height: 2.6rem; border-radius: 50%;
    border: var(--rule-fine) solid var(--ink); background: var(--paper-light); }
.rail__figure { width: 85%; height: 85%; object-fit: contain; }
.rail__word { font-size: 0.6rem; text-align: center; }
.rail__slot--waiting { border-style: dashed; border-color: var(--ink-faded); background: transparent; }
.rail__slot--waiting .rail__figure, .rail__slot--waiting .rail__word { opacity: 0.22; filter: grayscale(1); }
.rail__slot--carried { border: 2px solid var(--slate); box-shadow: 0 0 0 2px rgba(74, 90, 110, 0.18); }
.rail__slot--found { border-color: var(--ink-faded); }
.rail__icon { width: 70%; height: 70%; color: var(--ink); }
.rail__slot--done { border-color: var(--ink); box-shadow: 1px 2px 0 rgba(31, 27, 22, 0.18); }
.rail__count { margin: 0; font-size: var(--step--1); color: var(--ink-soft); }
.rail__empty { margin: 0; font-style: italic; color: var(--ink-faded); font-size: var(--step--1); }
@media (min-width: 900px) {
    .rail { flex-direction: column; gap: var(--gap-5); padding-top: var(--gap-1); }
}
@media (max-width: 40rem) {
    /* On a phone every line counts: smaller pieces, and what is held needs no caption under its picture. */
    .rail__slot, .rail__held { width: 2.1rem; height: 2.1rem; }
    .rail__count--held { display: none; }
}

/* Top bar: quest and difficulty, the clock, the two bars, then facts and badges. */
.topbar { display: grid; gap: var(--gap-2); }
.topbar__head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--gap-3); }
.topbar__quest { font-size: clamp(1.35rem, 4.6vw, 2rem); }
.topbar__difficulty { font-size: var(--step--1); font-variant: small-caps; letter-spacing: 0.06em; color: var(--ink-faded); white-space: nowrap; }
.topbar__bars { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap-2) var(--gap-5); }

.clock {
    display: grid;
    grid-template-columns: minmax(5.5em, auto) 1fr auto;
    align-items: center;
    gap: var(--gap-3);
    font-size: var(--step--1);
}
.clock__label { font-variant: small-caps; letter-spacing: 0.04em; }
.clock__track {
    position: relative;
    height: 0.8rem;
    border: var(--rule-fine) solid var(--ink);
    background: var(--paper-light);
}
.clock__fill {
    position: absolute;
    inset: 0 auto 0 0;
    background-color: var(--ink-soft);
    background-image: repeating-linear-gradient(-55deg, transparent 0 2px, rgba(238, 232, 216, 0.28) 2px 3px);
    transition: width 300ms var(--ease-ink);
}
/* Past par, the overrun is drawn in oxblood. */
.clock__over {
    position: absolute;
    top: 0;
    bottom: 0;
    background-color: var(--oxblood);
    background-image: repeating-linear-gradient(-55deg, transparent 0 2px, rgba(238, 232, 216, 0.3) 2px 3px);
}
/* Par: a tall inked tick through the track, labelled above it. */
.clock__par { position: absolute; top: -0.3rem; bottom: -0.3rem; width: 0; border-left: 2px solid var(--ink); }
.clock__par-label {
    position: absolute;
    bottom: calc(100% + 1px);
    left: 0;
    transform: translateX(-50%);
    font-size: 0.72rem;
    line-height: 1;
    font-style: italic;
    white-space: nowrap;
    color: var(--ink-soft);
    font-variant-numeric: lining-nums;
}
.clock__value { font-variant-numeric: lining-nums tabular-nums; min-width: 3.2em; text-align: right; white-space: nowrap; }
.clock__max { color: var(--ink-faded); }
.clock { padding-top: 0.55rem; }

.topbar__facts:not(:has(li)) { display: none; }   /* no badges today: no empty row */
.topbar__facts { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--gap-1) var(--gap-4); font-size: var(--step--1); }
.fact { display: inline-flex; align-items: baseline; gap: 0.4em; }
.fact__label { font-variant: small-caps; letter-spacing: 0.04em; color: var(--ink-soft); }
.fact__value { font-family: var(--face-display); font-size: var(--step-0); font-variant-numeric: lining-nums; }
.fact__value--none { font-style: italic; color: var(--ink-faded); }
.fact__note { font-style: italic; color: var(--ink-faded); font-variant-numeric: lining-nums; }
.badge {
    padding: 0 0.55em;
    border: var(--rule-fine) solid var(--ink);
    border-radius: 2px 3px 2px 4px;
    font-variant: small-caps;
    letter-spacing: 0.04em;
    font-variant-numeric: lining-nums;
    background: var(--paper-light);
}
.badge--grim { color: var(--oxblood); border-color: var(--oxblood); }
.badge--boon { color: var(--slate); border-color: var(--slate); }

/* The board: paper with a double inked frame, scaled to fit. */
.park__board {
    position: relative;
    padding: 0.35rem;
    border: var(--rule) solid var(--ink);
    outline: var(--rule-fine) solid var(--ink);
    outline-offset: 3px;
    /* Dusk: the light goes first at the edges of the park. */
    background:
        radial-gradient(120% 95% at 50% 42%, rgba(244, 239, 224, 0.75) 35%, rgba(185, 174, 149, 0.35) 78%, rgba(70, 58, 40, 0.28) 100%),
        var(--paper);
}
/* The compass rose: inked into the frame's top-right corner, over the paper, never in the way of a tap. */
.compass {
    position: absolute;
    top: 0.45rem;
    right: 0.45rem;
    width: 44px;
    height: 44px;
    pointer-events: none;
}
/* Phones: small, faint, and tucked into the very corner of the frame, so it hides no token on the top-right hex. */
@media (max-width: 640px) {
    .compass { top: -0.1rem; right: -0.1rem; width: 26px; height: 26px; opacity: 0.6; }
}
.compass__ring, .compass__ticks, .compass__needle { filter: url(#ink); }
.compass__ring { fill: none; stroke: var(--ink-soft); stroke-width: 1.1; }
.compass__ticks { stroke: var(--ink-soft); stroke-width: 1.1; stroke-linecap: round; }
.compass__needle--north { fill: var(--ink); }
.compass__needle--south { fill: none; stroke: var(--ink); stroke-width: 1; stroke-linejoin: round; }
.compass__pin { fill: var(--paper-light); stroke: var(--ink); stroke-width: 0.8; }
.compass__n { font-family: var(--face-display); font-size: 9px; fill: var(--ink); }
.board {
    display: block;
    width: 100%;
    height: auto;
    max-height: calc(100dvh - 24rem);   /* room above for the top bar, below for the stage and what can be done here */
    margin: 0 auto;
    min-height: 12rem;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.board__ground { filter: url(#ink); }
.hex { fill: rgba(238, 232, 216, 0.45); stroke: var(--ink-faded); stroke-width: 1.1; stroke-linejoin: round; }
.hex--obstacle { fill: var(--paper-deep); stroke: var(--ink); stroke-width: 1.6; }
.hex--goosepatch { fill: rgba(205, 192, 162, 0.7); }
.hex--start, .hex--goal { stroke: var(--ink); stroke-width: 1.6; }
/* The brush pile and the fort, ringed in bright green: where the day's carrying starts and ends. */
.board__marks { pointer-events: none; }
.hex__mark { fill: none; stroke: #2ecc40; stroke-width: 2.6; stroke-linejoin: round; }
.hex__hatch { fill: url(#board-hatch); stroke: none; }
/* Over a drawn tile only the outline is inked; obstacles keep their heavier rim. */
.hex--tiled { fill: transparent; }

/* ---------- Unexplored ground (a foggy day): three looks, chosen in Settings ---------- */
.hex--unexplored { fill: none; stroke: none; }
.fog--ghost .hex--unexplored { stroke: var(--fog-ink); stroke-width: 0.7; stroke-dasharray: 2 3; }
.fog--pencil .hex--unexplored { fill: url(#pencil); stroke: var(--fog-ink); stroke-width: 0.5; }
.fog--shroud .hex--unexplored { fill: var(--fog-paper); stroke: var(--fog-paper); stroke-width: 1.1; }
.hex__fog-hatch { fill: url(#hatch); stroke: none; opacity: 0.55; pointer-events: none; }
/* A hex coming out of the fog: its tile fades in. */
.board--foggy .board__tiles image.tile--new { animation: fog-lift 400ms ease-out; }
@keyframes fog-lift { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
    .board--foggy .board__tiles image.tile--new { animation: none; }
}
.board--still .board__tiles image { animation: none; }
.hex--goosepatch.hex--tiled { fill: rgba(150, 128, 88, 0.28); }   /* lawn under a goose: trodden darker, and stippled */
.board__tiles, .board__lower { pointer-events: none; }
/* The nanny's eye: lightened ground, and a dashed slate rim where her sight ends. */
.board__nanny { pointer-events: none; }
.nanny__wash { fill: var(--paper-light); fill-opacity: 0.38; stroke: none; }
.nanny { pointer-events: none; }   /* she sits on hexes he may step to: taps go through her */
.nanny__ring { fill: none; stroke: var(--slate); stroke-width: 2.6; }
.nanny__halo { stroke: var(--slate); }
.nanny__rim { fill: none; stroke: var(--slate); stroke-width: 3; stroke-dasharray: 7 4; stroke-linecap: round; pointer-events: none; }
.hex__stipple { fill: url(#board-stipple); stroke: none; opacity: 0.85; }

/* Within a step: a faint wash and a dashed rim; darker on hover, darkest when pressed. */
.step { cursor: pointer; outline: none; }
/* The whole hex takes the tap (about 42×48px in the closer view), not just the wash inside it. */
.step__hit { fill: transparent; stroke: none; pointer-events: all; }
.step__wash { fill: var(--ink); fill-opacity: 0.2; stroke: var(--ink); stroke-width: 1.9; stroke-dasharray: 5 3.5; stroke-opacity: 0.8; transition: fill-opacity 120ms; }
.step:hover .step__wash { fill-opacity: 0.3; stroke-dasharray: none; stroke-width: 2.2; }
.step:active .step__wash { fill-opacity: 0.4; }
.step:focus-visible .step__wash { stroke-width: 3; stroke-dasharray: none; fill-opacity: 0.22; }
.step__key { font-family: var(--face-text); font-style: italic; font-size: 11px; fill: var(--ink-soft); pointer-events: none; }
.board--busy .step { cursor: progress; }
@media (hover: none) { .step__key { display: none; } }

.board__things { pointer-events: none; }
.terrain { fill: none; stroke: var(--ink); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; color: var(--ink); }
.terrain--under { stroke: var(--ink-faded); color: var(--ink-faded); opacity: 0.55; }
.terrain-figure { filter: drop-shadow(1px 2px 0 rgba(31, 27, 22, 0.18)); }
/* Someone standing at the gate or the site: the place steps back so they read over it. */
.terrain-figure--under { opacity: 0.6; }

.token { color: var(--ink); }
.token__disc { fill: var(--paper-light); stroke: var(--ink-faded); stroke-width: 0.8; }
.token__icon { fill: none; stroke: currentColor; stroke-width: 2.1; stroke-linecap: round; stroke-linejoin: round; filter: url(#ink); }
/* The toddler is the one inverted token: paper on an ink disc, ringed, so the eye finds him first. */
.token--toddler { color: var(--paper-light); }
.token--toddler .token__disc { fill: var(--ink); stroke: var(--ink); stroke-width: 1; }
/* A thick ink ring with a paper gap inside it: unmistakable at any size. */
.token__halo { fill: var(--paper-light); stroke: var(--ink); stroke-width: 3; }
.token--toddler .token__halo { fill: var(--victorian-green); }
.token--toddler .token__icon { stroke-width: 2.3; filter: none; }
.token__cameo-ring { fill: none; stroke: var(--ink); stroke-width: 2.4; }
.token--rival .token__cameo-ring { stroke: var(--oxblood); stroke-width: 2.6; }
.token--rival { color: var(--oxblood); }
.token--rival .token__disc { stroke: var(--oxblood); stroke-width: 1.2; }
.token__badge { fill: var(--oxblood); stroke: var(--paper-light); stroke-width: 1.2; }
.token__letter { fill: var(--paper-light); font-family: var(--face-display); font-weight: 400; paint-order: stroke; stroke: var(--paper-light); stroke-width: 0.5px; }
.token--unknown .token__disc { fill: none; stroke: none; }
.token--decoy { color: var(--ink-faded); }
/* A drawn figure stands on the ground itself, with a faint shadow to lift it off the tile. */
.token__figure, .ground-item--figure { filter: drop-shadow(1px 2px 0 rgba(31, 27, 22, 0.18)); }
.token__more { font-family: var(--face-text); font-size: 10px; fill: var(--ink); }

/* Unknown shapes: a slow shimmer of wet ink. Still when motion is unwanted. */
.token--unknown .token__icon { transform-box: fill-box; transform-origin: center; animation: blot-shimmer 3.1s ease-in-out infinite; }
.board--still .token--unknown .token__icon { animation: none; }
@keyframes blot-shimmer {
    0%, 100% { opacity: 1; transform: scale(1) rotate(0deg); }
    40% { opacity: 0.72; transform: scale(1.05, 0.97) rotate(-3deg); }
    70% { opacity: 0.9; transform: scale(0.97, 1.04) rotate(2deg); }
}

/* Hidden fittings he knows of: a glimpse is a pale, blurred shape in the grass; the nanny's mark is plainer, ringed. */
.board__fittings { pointer-events: none; }
.fitting--glimpsed { opacity: 0.35; filter: blur(1.2px) sepia(0.4); }
.fitting--marked { opacity: 0.7; }
.fitting--inked { fill: none; stroke: var(--ink); stroke-width: 2.6; stroke-linecap: round; }
.fitting__ring { fill: none; stroke: var(--ink-faded); stroke-width: 2; stroke-dasharray: 5 4; stroke-linecap: round; }
.ground-item { fill: none; stroke: var(--ink); stroke-width: 2.6; stroke-linecap: round; filter: url(#ink); }
.ground-item__count { font-family: var(--face-text); font-size: 10px; fill: var(--ink); }

/* Where he stands: contextual actions, then the satchel and key toggles. */
.park__here { display: flex; flex-wrap: wrap; align-items: center; gap: var(--gap-2) var(--gap-3); }
.park__here-label { font-variant: small-caps; letter-spacing: 0.06em; color: var(--ink-faded); }
.park__here-none { font-style: italic; color: var(--ink-faded); font-size: var(--step--1); }
.ink-btn--here { padding: 0.2rem 1rem; gap: var(--gap-2); }
/* A thing's picture, its name (with the key, where there is one) and a second line of what it gives or weighs. */
.here__figure { width: 2rem; height: 2rem; margin-left: -0.35rem; }
.here__text { display: inline-flex; flex-direction: column; align-items: flex-start; line-height: 1.15; }
.here__name { display: inline-flex; align-items: baseline; }
.here__note { font-family: var(--face-text); font-size: var(--step--1); font-style: italic; opacity: 0.85; white-space: nowrap; font-variant-numeric: lining-nums; }
/* Too puffed to step: Rest flashes red twice. */
.ink-btn--nudge { animation: nudge 1.2s ease-in-out 2 both; }
@keyframes nudge {
    0%, 100% { background: var(--paper-light); color: var(--ink); border-color: var(--ink); }
    40%, 60% { background: var(--oxblood); color: var(--paper-light); border-color: var(--oxblood); }
}
.park__tools { display: inline-flex; gap: var(--gap-2); margin-left: auto; }
.tool {
    display: inline-flex;
    align-items: center;
    gap: var(--gap-1);
    min-height: var(--target);
    padding: 0 var(--gap-3);
    border: var(--rule-fine) solid transparent;
    background: none;
    color: var(--ink);
    font: inherit;
    font-variant: small-caps;
    letter-spacing: 0.04em;
    cursor: pointer;
}
.tool:hover, .tool--open { border-color: var(--ink); background: var(--paper-light); }
.tool__key { display: inline-grid; place-items: center; width: 1.3em; height: 1.3em; border: 1.5px solid var(--ink); border-radius: 50%; font-family: var(--face-display); font-variant: normal; line-height: 1; }

.satchel, .legend {
    padding: var(--gap-3) var(--gap-4);
    border: var(--rule-fine) solid var(--ink);
    background: var(--paper-light);
    box-shadow: 3px 4px 0 rgba(31, 27, 22, 0.12);
    animation: fade-in 140ms ease-out;
}
.satchel { display: grid; gap: var(--gap-3); }
.satchel__part .line__text:has(.satchel__slot) { grid-template-columns: 4.2rem 1fr; column-gap: var(--gap-2); align-items: baseline; }
.satchel__part .line__text:has(.satchel__slot) .line__note:last-child:not(:nth-child(2)) { grid-column: 2; }
.satchel__slot { font-variant: small-caps; letter-spacing: 0.05em; font-size: var(--step--1); color: var(--ink-faded); }

.legend__list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: var(--gap-1) var(--gap-4); }
.legend__entry { display: flex; align-items: center; gap: var(--gap-2); min-height: 2rem; font-size: var(--step--1); }
.legend__mark { position: relative; flex: none; display: grid; place-items: center; width: 1.9rem; height: 1.9rem; }
.legend__mark .icon { width: 1.5rem; height: 1.5rem; }
.legend__mark--rival { color: var(--oxblood); }
.legend__mark--decoy { color: var(--ink-faded); }
.legend__mark--nanny { border: 2px dashed var(--slate); background: var(--paper-light); clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%); }
.legend__letter { position: absolute; right: -0.15rem; bottom: -0.1rem; display: grid; place-items: center; width: 0.95rem; height: 0.95rem; border-radius: 50%; background: var(--oxblood); color: var(--paper-light); font-family: var(--face-display); font-size: 0.7rem; line-height: 1; }
.legend__mark--step { border: 1.4px dashed var(--ink); background: rgba(31, 27, 22, 0.1); clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%); }
.legend__mark--patch { background: radial-gradient(circle at 30% 30%, var(--ink) 0 1.2px, transparent 1.6px) 0 0 / 6px 6px, #ddd3bb; clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%); }
.legend__mark--unexplored { border: 1.4px dashed var(--fog-ink); background: var(--fog-paper); clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%); }
.fog--ghost .legend__mark--unexplored { background: transparent; }
.fog--pencil .legend__mark--unexplored { background: repeating-linear-gradient(60deg, rgba(90, 80, 66, 0.38) 0 0.6px, transparent 0.6px 4px); border-width: 1px; }
.legend__mark--obstacle { background: repeating-linear-gradient(38deg, var(--ink) 0 1px, transparent 1px 5px), repeating-linear-gradient(-52deg, var(--ink) 0 1px, transparent 1px 5px), var(--paper-deep); clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%); }

/* Phones: a closer view of the park that scrolls sideways, centred on the toddler; hexes 41px across, just over the 40px a finger needs. */
.park__zoom { display: inline-flex; }
/* A computer's closer view: hexes at a comfortable size, the frame scrolling both ways inside the room the fitted board had. */
.park__board--close { overflow: auto; max-height: calc(100dvh - 24rem); min-height: 12rem; overscroll-behavior: contain; scrollbar-width: thin; }
.park__board--close .board { width: calc(var(--board-cols) * 47px); max-width: none; max-height: none; }
/* The zoom's + and − are what a player looks for: large, heavy, in a heavier ring. */
.tool__key--zoom { width: 1.9rem; height: 1.9rem; border-width: 2.5px; }
.tool__key--zoom svg { width: 1.35rem; height: 1.35rem; stroke: currentColor; stroke-width: 3.4; stroke-linecap: round; }

/* The glass: an emoji, so no ring round it. */
.tool__key--glass { border: 0; width: auto; font-size: 1.25em; }

/* Looking through the glass: every hex answers a tap, and the pointer is a magnifying glass. */
.look__hit { fill: transparent; stroke: none; pointer-events: all;
    cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='32' height='32'><text x='0' y='24' font-size='24'>🔍</text></svg>") 10 10, zoom-in; }
.look__hit:hover { fill: rgba(31, 27, 22, 0.1); }
.board--inspecting { outline: 2px dashed var(--ink-faded); outline-offset: -2px; }

.park__keys { font-size: var(--step--1); color: var(--ink-faded); font-style: italic; }
@media (hover: none) { .park__keys { display: none; } }

@media (max-width: 640px) {
    .park { gap: var(--gap-2); }
    /* Phones: the board runs to the edges; the bars stack their labels over the tracks. */
    .park__board { margin-inline: calc(var(--gap-4) * -1 + 2px); padding: 2px; outline: none; border-inline: 0; }
    .board { max-height: none; }
    .topbar__bars .stat-bar, .clock { grid-template-columns: 1fr auto; row-gap: 0.15rem; column-gap: var(--gap-2); }
    .topbar__bars .stat-bar__track, .clock__track { grid-column: 1 / -1; grid-row: 2; }
    .clock__label, .topbar__bars .stat-bar__label { grid-row: 1; }
    .clock__value, .topbar__bars .stat-bar__value { grid-row: 1; min-width: 0; }
    .clock__track, .topbar__bars .stat-bar__track { height: 0.6rem; }
    .clock { padding-top: 0; }
    .clock__par-label { bottom: auto; top: calc(100% + 1px); }
    .clock { padding-bottom: 0.7rem; }
    .topbar__facts { gap: 0 var(--gap-3); }
    .game__screen:has(.park) { padding-top: var(--gap-3); }
    .park__board--close { overflow: visible; overflow-x: auto; max-height: none; overscroll-behavior: auto; overscroll-behavior-x: contain; }
}
@media (hover: none) { .legend__keys { display: none; } }

/* A short screen (a phone on its side): the board takes the whole height under the top bar, and the errand above it
   scrolls away; 24rem kept for the rest would leave the board no room at all. */
@media (max-height: 560px) and (orientation: landscape) {
    .board { max-height: calc(100dvh - 4.5rem); min-height: 0; }
    /* The closer view on its side: the frame takes that same height and scrolls inside it. */
    .park__board--close { max-height: calc(100dvh - 4.5rem); min-height: 0; }
}

/* ---------- The park on a phone ----------
   Played on a phone, what is watched every step (the clock, Composure, Puff, the errand counted out and what is in hand)
   and what is tapped every step (Rest, Pick up, Put down) must all be in sight with the map. The top bar shrinks to a
   strip, the errand rail rides inside it in short form, and in portrait the strip is pinned above the map and the buttons
   below it; on its side, the strip and the buttons stand in a column beside the map. */
.topbar .rail--compact { display: none; }   /* the short rail lives in the park's strip, and only on a phone */

@media (max-width: 640px), (max-height: 560px) and (orientation: landscape) {
    .park .topbar { gap: 0.3rem; }
    .park .topbar__difficulty { display: none; }
    .park .topbar__quest { font-size: var(--step-1); line-height: 1.15; }
    .park .topbar__errand { font-size: var(--step--1); line-height: 1.25; }
    /* The clock on one line: the par tick stays on the track, the words for par and tea go (both are read out still). */
    .park .clock { grid-template-columns: auto minmax(0, 1fr) auto; padding: 0; row-gap: 0; }
    .park .clock__track, .park .clock__label, .park .clock__value { grid-column: auto; grid-row: auto; }
    .park .clock__par-label, .park .clock__max { display: none; }
    .park .topbar__bars { column-gap: var(--gap-4); }
    .park .topbar__bars .stat-bar { grid-template-columns: minmax(0, 1fr) auto; row-gap: 0.15rem; column-gap: var(--gap-2); }
    .park .topbar__bars .stat-bar__track { grid-column: 1 / -1; grid-row: 2; height: 0.6rem; }
    .park .topbar__bars .stat-bar__label, .park .topbar__bars .stat-bar__value { grid-row: 1; min-width: 0; }
    .park .clock__track { height: 0.6rem; }
    /* The errand in short form: the pieces with their count, then what is in hand after a fine rule. */
    .park .topbar .rail--compact { display: flex; flex-wrap: nowrap; align-items: center; gap: var(--gap-3); }
    .park__field > .rail { display: none; }
    .rail--compact .rail__heading, .rail--compact .rail__count--held, .rail--compact .rail__empty { display: none; }
    .rail--compact .rail__part { display: flex; align-items: center; gap: var(--gap-2); min-width: 0; }
    .rail--compact .rail__part:has(.rail__hands) { padding-left: var(--gap-3); border-left: var(--rule-fine) solid var(--ink-faded); }
    .rail--compact .rail__part:not(:has(.rail__slots, .rail__hands)) { display: none; }
    .rail--compact .rail__slots, .rail--compact .rail__hands { flex-wrap: nowrap; gap: 0.2rem; }
    .rail--compact .rail__slot, .rail--compact .rail__held { width: 1.9rem; height: 1.9rem; }
    .rail--compact .rail__count { line-height: 1.2; }
    .rail--compact.rail--search .rail__count { display: none; }   /* a search's count is the strip's own errand line, word for word */
    .park .topbar__facts { font-size: 0.8rem; }
    /* The marbles are a tool under the map here, as the rail beside it is hidden. */
    .park .cabinet-tool { display: inline-flex; }
}

@media (max-width: 640px) {
    /* The site's own bar scrolls away; the strip takes its place at the top. */
    .game:has(.park) .game__bar { position: static; }
    .game__screen:has(.park) { padding-bottom: 0; }
    .park .topbar {
        position: sticky; top: 0; z-index: 25;
        margin-inline: calc(var(--gap-4) * -1); padding: var(--gap-2) var(--gap-4);
        background: rgba(228, 221, 202, 0.97);
        border-bottom: var(--rule-fine) solid var(--ink);
        box-shadow: 0 3px 0 rgba(31, 27, 22, 0.06);
    }
    /* What can be done here, and the tools, pinned under the map. */
    .park__here {
        position: sticky; bottom: 0; z-index: 25;
        margin-inline: calc(var(--gap-4) * -1);
        padding: var(--gap-2) var(--gap-4) calc(var(--gap-1) + env(safe-area-inset-bottom, 0px));
        row-gap: var(--gap-1);
        background: rgba(228, 221, 202, 0.97);
        border-top: var(--rule-fine) solid var(--ink);
        box-shadow: 0 -3px 0 rgba(31, 27, 22, 0.06);
    }
    /* The tools: each mark beside its word, one slim row. */
    .park .park__tools .tool { flex-direction: row; gap: var(--gap-1); min-height: 40px; padding: 0 2px; }
    /* The pack covers the map exactly and scrolls inside itself, never under the pinned buttons. */
    .park__over { min-height: 0; height: 100%; overflow-y: auto; overscroll-behavior: contain; }
}

/* A phone on its side: the map down the left, the strip, the buttons and the tools in a column on the right. The last row
   is the flexible one, so the map's height falls there and the column keeps its own short rows. */
@media (max-height: 560px) and (orientation: landscape) {
    .park {
        grid-template-columns: minmax(0, 1fr) minmax(14rem, 19rem);
        grid-template-rows: repeat(7, auto) 1fr;
        column-gap: var(--gap-4); row-gap: 0; align-items: start; max-width: none;
    }
    .park > * { grid-column: 2; min-width: 0; margin-bottom: var(--gap-3); }
    .park .topbar .rail--compact { flex-wrap: wrap; row-gap: var(--gap-2); gap: var(--gap-2); }
    .park .rail--compact .rail__slot, .park .rail--compact .rail__held { width: 1.7rem; height: 1.7rem; }
    .park .rail--compact .rail__part:has(.rail__hands) { padding-left: var(--gap-2); }
    .park .topbar__quest { font-size: var(--step-0); }
    .park .topbar__errand { line-height: 1.2; }
    .game:has(.park) .game__bar { position: static; padding-block: 0; }
    .park__here { column-gap: var(--gap-2); }
    .park__field { display: contents; }
    .park__field > .park__map { grid-column: 1; grid-row: 1 / -1; }
    .board { max-height: calc(100svh - 6rem); }
    .park__over { min-height: 0; height: 100%; overflow-y: auto; overscroll-behavior: contain; }
    .park__over .satchel { grid-template-columns: minmax(0, 1fr); }
    .park__tools { display: flex; flex-wrap: wrap; flex: 1 1 100%; margin-left: 0; gap: var(--gap-1); }
    .park__tools .tool { padding: 0 var(--gap-2); }
    .game__screen:has(.park) { padding-top: var(--gap-2); padding-bottom: var(--gap-2); }
}

/* ---------- Playback ---------- */
/* While turns play out, one clear layer over everything takes any tap as "hurry on". */
.playback-skip {
    position: fixed;
    inset: 0;
    z-index: 45;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.playback-skip__hint {
    position: fixed;
    left: 50%;
    top: 4.6rem;   /* just under the game bar, clear of the board's dice tray and the phone's narration sheet */
    transform: translateX(-50%);
    padding: 0.2rem 0.9rem;
    background: rgba(238, 232, 216, 0.88);
    border: var(--rule-fine) solid var(--ink-faded);
    font-style: italic;
    font-size: var(--step--1);
    color: var(--ink-soft);
    white-space: nowrap;
    pointer-events: none;
    animation: fade-in 300ms 600ms both;   /* only for turns long enough to want it */
}

/* The toddler lands on each hex of a hop or a forced run; two names so every new hop restarts it. */
.token--hop-a, .token--hop-b { transform-box: fill-box; transform-origin: 50% 90%; }
.token--hop-a { animation: token-hop-a 180ms var(--ease-ink); }
.token--hop-b { animation: token-hop-b 180ms var(--ease-ink); }
.board--still .token--hop-a, .board--still .token--hop-b { animation: none; }
@keyframes token-hop-a { from { transform: translateY(-5px) scale(1.06, 0.94); } }
@keyframes token-hop-b { from { transform: translateY(-5px) scale(1.06, 0.94); } }

/* The last die rolled, in the board's corner, for a moment after it settles. */
.dice-tray {
    position: absolute;
    right: var(--gap-2);
    bottom: var(--gap-2);
    z-index: 2;
    max-width: calc(100% - 2 * var(--gap-2));
    padding: 0.2rem 0.75rem 0.2rem 0.3rem;
    background: rgba(238, 232, 216, 0.94);
    border: var(--rule-fine) solid var(--ink);
    box-shadow: 2px 3px 0 rgba(31, 27, 22, 0.14);
    font-size: var(--step--1);
    animation: fade-in 160ms ease-out;
}
.dice-tray .dice__face { width: 2.6rem; height: 2.6rem; }

/* ---------- Encounter ---------- */
.encounter { display: grid; gap: var(--gap-3); max-width: 64rem; margin: 0 auto; }
.encounter__stage { position: relative; display: grid; }
.encounter__stage > * { grid-area: 1 / 1; }
.encounter__board::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: rgba(31, 27, 22, 0);
    transition: background-color 300ms ease-out;
}
.encounter__board--dim::after { background: rgba(31, 27, 22, 0.42); }
.encounter__board--dim .board { filter: saturate(0.6); }

.encounter__card {
    position: relative;
    isolation: isolate;
    z-index: 3;
    align-self: center;
    justify-self: center;
    width: min(25rem, calc(100% - 2 * var(--gap-4)));   /* under half the board, so he stays in view beside it */
    margin-block: var(--gap-4);
    padding: var(--gap-5) var(--gap-5) var(--gap-5);
    animation: encounter-in 260ms var(--ease-ink);
}
.encounter__card::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: var(--paper-light);
    border: var(--rule) solid var(--ink);
    outline: var(--rule-fine) solid var(--ink);
    outline-offset: -6px;
    box-shadow: 6px 8px 0 rgba(31, 27, 22, 0.3);
    filter: url(#ink);
}
.encounter__card--right { justify-self: end; margin-right: var(--gap-4); }
.encounter__card--left { justify-self: start; margin-left: var(--gap-4); }
@keyframes encounter-in { from { opacity: 0; transform: translateY(14px); } }

.encounter__kicker { font-variant: small-caps; letter-spacing: 0.08em; color: var(--oxblood); }
.encounter__who { display: flex; align-items: center; gap: var(--gap-3); margin-top: var(--gap-1); }
.encounter__mark {
    position: relative;
    flex: none;
    display: grid;
    place-items: center;
    width: 3.6rem;
    height: 3.6rem;
    border: var(--rule) solid var(--oxblood);
    border-radius: 50%;
    background: var(--paper);
    color: var(--oxblood);
}
.encounter__mark .icon { width: 2.5rem; height: 2.5rem; }
.encounter__letter {
    position: absolute;
    right: -0.25rem;
    bottom: -0.15rem;
    display: grid;
    place-items: center;
    width: 1.35rem;
    height: 1.35rem;
    border-radius: 50%;
    background: var(--oxblood);
    color: var(--paper-light);
    font-family: var(--face-display);
    font-size: 0.85rem;
    line-height: 1;
}
.encounter__name { font-size: var(--step-3); }
.encounter__type { font-style: italic; color: var(--ink-faded); }
.encounter__line {
    margin-top: var(--gap-4);
    padding-top: var(--gap-3);
    border-top: var(--rule-fine) solid var(--ink-faded);
    font-family: var(--face-display);
    font-size: var(--step-1);
    line-height: 1.35;
}
.encounter__card--caught .encounter__kicker { color: var(--oxblood); font-family: var(--face-display); font-size: var(--step-3); }
.encounter__then { margin-top: var(--gap-3); font-style: italic; color: var(--ink-faded); }
.encounter__choices { display: grid; gap: var(--gap-2); margin-top: var(--gap-5); }
.encounter__fight { min-height: 3.2rem; font-family: var(--face-display); font-size: var(--step-2); }
.encounter__or { margin-top: var(--gap-2); font-style: italic; font-size: var(--step--1); color: var(--ink-faded); text-align: center; }
.encounter__offer-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--gap-2); align-items: stretch; }
.encounter__offer-label { grid-column: 1 / -1; font-variant: small-caps; letter-spacing: 0.06em; font-size: var(--step--1); color: var(--ink-faded); }
.encounter__select {
    min-width: 0;
    min-height: var(--target);
    padding: 0 2.2rem 0 var(--gap-3);
    font: inherit;
    font-variant-numeric: lining-nums tabular-nums;
    color: var(--ink);
    background:
        linear-gradient(45deg, transparent 50%, var(--ink) 50%) right 1.1rem center / 0.4rem 0.4rem no-repeat,
        linear-gradient(-45deg, transparent 50%, var(--ink) 50%) right 0.7rem center / 0.4rem 0.4rem no-repeat,
        var(--paper-light);
    border: var(--rule-fine) solid var(--ink);
    border-radius: 0;
    appearance: none;
    cursor: pointer;
}
.encounter__select:disabled { color: var(--ink-faded); cursor: default; }
.encounter__offer { justify-content: space-between; gap: var(--gap-2); }
.encounter__chance {
    flex: none;
    font-variant-numeric: lining-nums tabular-nums;
    font-variant-caps: small-caps;
    padding-left: var(--gap-2);
    border-left: var(--rule-fine) solid var(--ink-faded);
}

@media (max-width: 640px) {
    .encounter { gap: var(--gap-2); }
    .encounter__board { margin-inline: calc(var(--gap-4) * -1 + 2px); padding: 2px; outline: none; border-inline: 0; }
    /* Phones: the card rises over the lower part of the park rather than hiding all of it. */
    .encounter__stage > * { grid-area: auto; }
    .encounter__card, .encounter__card--left, .encounter__card--right { width: 100%; margin: -3.5rem 0 0; padding: var(--gap-4); }
    .game__screen:has(.encounter) { padding-top: var(--gap-3); }
}

/* ---------- Melee (the face-off) ---------- */
.melee { display: grid; gap: var(--gap-4); max-width: 60rem; margin: 0 auto; }
.melee__head { text-align: center; }
.melee__kicker { font-variant: small-caps; letter-spacing: 0.08em; color: var(--oxblood); }
.melee__round { font-size: clamp(1.6rem, 5vw, 2.25rem); font-variant-numeric: lining-nums; }

/* Two fighters squared up, the dice between their portraits; beneath, each one's bars, AC and weapon in two columns. The
   fighter sections are display: contents, so their parts sit straight in the stage's grid: six columns, the figures on
   two each at the sides, the tray on the middle two, and each side's stats on half the width. */
.melee__stage {
    position: relative;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr)) repeat(2, minmax(0, 1.45fr)) repeat(2, minmax(0, 1fr));
    column-gap: var(--gap-3);
    align-items: start;
    width: 100%;
    max-width: 46rem;
    margin: 0 auto;
    padding-bottom: var(--gap-3);
    border-bottom: var(--rule-fine) solid var(--ink-faded);
}
.melee__stage .fighter { display: contents; }
.fighter--player > * { grid-column: 1 / 3; }
.fighter--opponent > * { grid-column: 5 / 7; }
.melee__stage .fighter__turn { grid-row: 1; }
.melee__stage .fighter__figure { grid-row: 2; justify-self: center; width: min(100%, 10.5rem); height: auto; aspect-ratio: 3 / 4; }
.melee__stage .fighter__figure:has(.fighter__portrait) { aspect-ratio: 1; }
.melee__stage .fighter__portrait { margin-bottom: 0; }
.melee__stage .fighter__name { grid-row: 3; }
.melee__stage .fighter__what { grid-row: 4; }
.fighter--player > .fighter__bars, .fighter--player > .fighter__facts, .fighter--player > .fighter__effects { grid-column: 1 / 4; }
.fighter--opponent > .fighter__bars, .fighter--opponent > .fighter__facts, .fighter--opponent > .fighter__effects {
    grid-column: 4 / 7;
    padding-left: var(--gap-3);
    border-left: var(--rule-fine) solid var(--ink-faded);
}
.melee__stage .fighter__bars { grid-row: 5; margin-top: 0; padding-top: var(--gap-4); }
.melee__stage .fighter__facts { grid-row: 6; margin-top: 0; padding-top: var(--gap-2); justify-content: flex-start; }
.melee__stage .fighter__effects { grid-row: 7; margin-top: 0; padding-top: var(--gap-2); justify-content: flex-start; }
.melee__stage > .melee__centre { grid-column: 3 / 5; grid-row: 1 / 5; align-self: center; padding-top: 0; }

.fighter { display: grid; justify-items: center; text-align: center; gap: var(--gap-1); min-width: 0; }
.fighter__turn {
    min-height: 1.6rem;
    font-variant: small-caps;
    letter-spacing: 0.08em;
    font-size: var(--step--1);
    color: var(--ink);
}
.fighter--to-act .fighter__turn::before, .fighter--to-act .fighter__turn::after { content: " \2014 "; color: var(--ink-faded); }
.fighter__figure { width: calc(var(--fig-h) * 0.75); height: var(--fig-h); transition: opacity 300ms, transform 300ms var(--ease-ink); }
.fighter--opponent .fighter__figure:has(.silhouette--toddler) { transform: scaleX(-1); }
.fighter--to-act .fighter__figure { transform: translateY(-3px); }
.fighter--down .fighter__figure { opacity: 0.45; transform: rotate(-8deg) translateY(6px); }
.fighter--opponent.fighter--down .fighter__figure { transform: rotate(8deg) translateY(6px); }
.fighter__name { font-size: var(--step-2); margin-top: var(--gap-1); overflow-wrap: anywhere; line-height: 1.15; }
.fighter__what { font-style: italic; color: var(--ink-faded); font-size: var(--step--1); }
.fighter__bars { display: grid; gap: var(--gap-1); width: 100%; margin-top: var(--gap-2); text-align: left; }
.fighter__bars .stat-bar { grid-template-columns: 5.6em 1fr auto; gap: var(--gap-2); align-items: center; }
.fighter__facts { display: flex; flex-wrap: wrap; justify-content: center; gap: 0 var(--gap-4); margin: var(--gap-1) 0 0; font-size: var(--step--1); }
.fighter__fact { display: flex; gap: 0.35em; align-items: baseline; }
.fighter__fact dt { font-variant: small-caps; letter-spacing: 0.04em; color: var(--ink-faded); }
.fighter__fact dd { margin: 0; }
.fighter__fact:has(.fighter__weapon) { align-items: center; }
.fighter__weapon { display: inline-flex; align-items: center; gap: 0.3em; }
.fighter__weapon-figure { width: 2.25rem; height: 2.25rem; margin-block: -0.5rem; }
.fighter__ac { font-family: var(--face-display); font-size: var(--step-1); font-variant-numeric: lining-nums; }
.fighter__aside { color: var(--ink-faded); font-size: 0.9em; }
.fighter__effects { list-style: none; margin: var(--gap-1) 0 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: var(--gap-1); }
.fighter__effect {
    padding: 0 0.5em;
    border: var(--rule-fine) solid var(--ink-faded);
    border-radius: 999px;
    font-size: var(--step--1);
    font-style: italic;
    background: var(--paper-light);
}
.fighter__effect--grim { border-color: var(--oxblood); color: var(--oxblood); }
.fighter__effect--blank { visibility: hidden; }

.silhouette { width: 100%; height: 100%; overflow: visible; }
.silhouette__shadow { fill: var(--ink); opacity: 0.16; }
.silhouette__ink { fill: var(--ink); stroke: var(--ink); stroke-linejoin: round; filter: url(#ink); }
.silhouette__limb { fill: none; stroke-width: 10; stroke-linecap: round; }
.silhouette--toddler .silhouette__limb { stroke-width: 9; }
.silhouette__foot { fill: none; stroke-width: 7; stroke-linecap: round; }
.silhouette__paper { fill: none; stroke: var(--paper-light); stroke-width: 2.6; stroke-linecap: round; }
.silhouette__eye { fill: var(--paper-light); }
.silhouette__hat { fill: var(--paper-light); stroke: var(--ink); stroke-width: 2.2; stroke-linejoin: round; filter: url(#ink); }
.silhouette__ribbon { fill: none; stroke: var(--ink); stroke-width: 2.6; stroke-linecap: round; }
.silhouette__letter { fill: var(--paper-light); font-family: var(--face-display); font-size: 22px; }

/* The centre: the upshot when it is over, and the dice tray. */
.melee__centre { display: grid; gap: var(--gap-3); align-content: start; padding-top: 1.6rem; min-width: 0; }
.melee__tray {
    display: grid;
    gap: var(--gap-2);
    padding: var(--gap-3);
    border: var(--rule-fine) solid var(--ink);
    background: rgba(238, 232, 216, 0.8);
    box-shadow: 2px 3px 0 rgba(31, 27, 22, 0.12);
    min-height: 7rem;
}
.melee__tray-empty { color: var(--ink-faded); font-style: italic; text-align: center; align-self: center; }
.melee__roll { display: grid; gap: 0.1rem; }
.melee__roll .dice { align-items: center; gap: var(--gap-2); }
.melee__roll .dice__detail { font-size: var(--step--1); line-height: 1.25; }
.melee__roller { font-variant: small-caps; letter-spacing: 0.05em; font-size: 0.8rem; color: var(--ink-faded); }
.melee__roll--opponent { justify-items: end; text-align: right; }
.melee__roll--opponent .dice { flex-direction: row-reverse; }
.melee__roll--latest .dice__face { width: 3.6rem; height: 3.6rem; }
.melee__roll--older { opacity: 0.75; }
.melee__roll--older .dice__face { width: 2.3rem; height: 2.3rem; }
.melee__roll--older + .melee__roll--older { opacity: 0.6; }
.melee__roll--latest + .melee__roll { border-top: var(--rule-fine) dashed var(--ink-faded); padding-top: var(--gap-2); }

.melee__upshot { text-align: center; padding: var(--gap-2) 0; animation: encounter-in 260ms var(--ease-ink); }
.melee__upshot-head { font-family: var(--face-display); font-size: var(--step-2); line-height: 1.15; }
.melee__upshot--lost .melee__upshot-head { color: var(--oxblood); }
.melee__upshot-line { font-family: var(--face-display); font-style: italic; margin-top: var(--gap-1); color: var(--ink-soft); }

/* What to do, in one row: Attack first and largest, Defend, the Specials and Use Item (each a list dropping below the
   row), and Flee. */
.melee__actions {
    position: relative;
    display: grid;
    gap: var(--gap-3);
    max-width: 46rem;
    width: 100%;
    margin: 0 auto;
    min-height: 3.5rem;
    padding-bottom: var(--gap-3);
    border-bottom: var(--rule-fine) solid var(--ink-faded);
}
.melee__waiting { text-align: center; font-style: italic; color: var(--ink-faded); align-self: center; }
.melee__row { display: flex; flex-wrap: wrap; justify-content: center; align-items: stretch; gap: var(--gap-2); }
.melee__row > .ink-btn { flex: 1 1 auto; padding-inline: var(--gap-3); }
.melee__attack { flex-grow: 1.4; min-height: 3.2rem; font-family: var(--face-display); font-size: var(--step-2); }
.melee__defend { flex-direction: column; justify-content: center; gap: 0; line-height: 1.15; }
.melee__defend-name { display: inline-flex; align-items: baseline; }
.melee__with { font-family: var(--face-text); font-size: var(--step--1); font-style: italic; opacity: 0.85; white-space: nowrap; }
.melee__key { margin-left: var(--gap-1); font-style: normal; font-size: 0.75rem; color: var(--ink-faded); }
.ink-btn--primary .melee__key { background: transparent; color: var(--paper-deep); border-color: var(--paper-shade); }
@media (hover: none) { .melee__key { display: none; } }
.melee__row > .melee__flee { flex: 0 0 auto; min-width: var(--target); }
.melee__caret { margin-left: 0.3em; font-size: 0.8em; }
.melee__menu-btn--open { z-index: 31; color: var(--paper-light); }
.melee__menu-btn--open::before { background: var(--slate); border-color: var(--ink); }
.melee__menu-btn--open:hover::before { background: var(--slate); }
.melee__menu-btn--open::after {   /* the list's tongue, pointing up at the button */
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    width: 0.9rem;
    height: 0.9rem;
    background: var(--paper-light);
    border-left: var(--rule-fine) solid var(--ink);
    border-top: var(--rule-fine) solid var(--ink);
    transform: translate(-50%, 0.3rem) rotate(45deg);
}
.melee__backdrop { position: fixed; inset: 0; z-index: 29; }
.melee__menu {
    position: absolute;
    z-index: 30;
    top: calc(100% - var(--gap-3) + 0.75rem);
    left: 50%;
    transform: translateX(-50%);
    width: min(30rem, 100%);
    margin: 0;
    padding: var(--gap-2) var(--gap-4);
    list-style: none;
    display: grid;
    grid-auto-flow: column;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: var(--gap-5);
    background: var(--paper-light);
    border: var(--rule-fine) solid var(--ink);
    box-shadow: 2px 4px 0 var(--paper-shade), 0 10px 24px rgba(31, 27, 22, 0.16);
    animation: encounter-in 160ms var(--ease-ink);
}
.melee__menu::before {   /* the rule between the two columns */
    content: "";
    position: absolute;
    left: 50%;
    top: var(--gap-3);
    bottom: var(--gap-3);
    border-left: var(--rule-fine) solid var(--ink-faded);
}
.melee__menu li + li { border-top: var(--rule-fine) solid rgba(31, 27, 22, 0.18); }
.melee__menu li.melee__menu-top { border-top: 0; }
.melee__option {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--gap-2);
    width: 100%;
    min-height: var(--target);
    padding: 0.3rem 0.25rem;
    border: 0;
    background: none;
    color: var(--ink);
    font-family: var(--face-display);
    font-size: var(--step-1);
    text-align: left;
    cursor: pointer;
}
.melee__option:hover:not(:disabled), .melee__option:focus-visible { background: var(--paper-deep); }
.melee__option:disabled { color: var(--ink-faded); cursor: not-allowed; }
.melee__menu--items .melee__option { justify-content: flex-start; }
.melee__option-name { min-width: 0; }
.melee__puff {
    flex: none;
    padding: 0 0.5em;
    border-radius: 999px;
    background: var(--slate);
    color: var(--paper-light);
    font-family: var(--face-text);
    font-size: 0.8rem;
    font-variant-numeric: lining-nums;
}
.melee__option:disabled .melee__puff { background: var(--slate-wash); }
/* A special's reminder of what it does: a slip of paper above it, on hover (a mouse) or keyboard focus, kept on the page:
   the left column's hangs from its left edge, the right column's from its right. */
.melee__tip {
    position: absolute;
    bottom: calc(100% + 0.35rem);
    left: 0;
    z-index: 5;
    width: max-content;
    max-width: min(16rem, 80vw);
    padding: var(--gap-1) var(--gap-2);
    background: var(--paper-light);
    border: var(--rule-fine) solid var(--ink);
    box-shadow: 2px 3px 0 var(--paper-shade);
    color: var(--ink);
    font-family: var(--face-text);
    font-size: var(--step--1);
    font-style: italic;
    line-height: 1.3;
    text-align: left;
    white-space: normal;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 120ms ease 250ms, visibility 0s linear 370ms;
}
.melee__option--right .melee__tip { left: auto; right: 0; text-align: right; }
/* The top move of each column has the Specials button and its tongue above it, drawn over the list: its slip hangs below. */
.melee__menu li:first-child .melee__tip, .melee__menu li.melee__menu-top .melee__tip { bottom: auto; top: calc(100% + 0.35rem); }
@media (hover: hover) {
    .melee__special:hover .melee__tip { opacity: 1; visibility: visible; transition-delay: 250ms, 0s; }
}
.melee__special:focus-visible .melee__tip { opacity: 1; visibility: visible; transition-delay: 0s; }
@media (prefers-reduced-motion: reduce) { .melee__tip, .melee__menu { transition: none; animation: none; } }
.melee__item-figure { width: 1.75rem; height: 1.75rem; margin-block: -0.35rem; flex: none; }
.melee-gone { max-width: 36rem; margin: 0 auto; }
.melee__carry-on { justify-self: center; min-width: 14rem; min-height: 3rem; font-family: var(--face-display); font-size: var(--step-1); }

/* Under the buttons: the fight's plain record (every move, kept), and beside it the narrator's commentary. */
.melee__account {
    max-width: 46rem;
    width: 100%;
    margin: 0 auto;
    display: grid;
    gap: var(--gap-3);
}
.melee__account--both { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.melee__record {
    display: flex;
    flex-direction: column-reverse;
    max-height: 9.5rem;
    overflow-y: auto;
    padding: var(--gap-2) var(--gap-3);
    border: var(--rule-fine) solid var(--ink-faded);
    background: var(--paper-light);
    font-family: var(--face-text);
    font-size: 1.02rem;
    line-height: 1.4;
    scrollbar-width: thin;
    scrollbar-color: var(--ink-faded) transparent;
}
.melee__fact { margin: 0 0 0.3em; color: var(--ink); }
.melee__fact--old { color: var(--ink-soft); }
.melee__fact--new { animation: line-arrives 500ms var(--ease-ink); }
.melee__commentary {
    padding: var(--gap-2) var(--gap-3);
    font-family: var(--face-display);
    font-style: italic;
    font-size: 1rem;
    line-height: 1.45;
    color: var(--ink-soft);
    border-left: var(--rule-fine) solid var(--ink-faded);
}
.melee__remark { margin: 0 0 0.5em; }

@media (max-width: 640px) {
    .game__screen:has(.melee) { padding-top: var(--gap-3); }
    .melee { gap: var(--gap-3); }
    .melee__head { display: flex; justify-content: center; align-items: baseline; gap: var(--gap-2); }
    .melee__round { font-size: var(--step-2); }
    .melee__stage { column-gap: var(--gap-2); }
    .fighter--opponent > .fighter__bars, .fighter--opponent > .fighter__facts, .fighter--opponent > .fighter__effects { padding-left: var(--gap-2); }
    .melee__stage .fighter__bars { padding-top: var(--gap-3); }
    .fighter__turn { min-height: 1.2rem; font-size: 0.8rem; }
    .melee__roll--older { display: none; }   /* room for the buttons: the latest roll only (the log has the rest) */
    .fighter__name { font-size: var(--step-1); }
    .fighter__bars .stat-bar { grid-template-columns: auto minmax(1.5rem, 1fr) auto; column-gap: var(--gap-1); }
    .fighter__bars .stat-bar__label { font-size: 0.78rem; }
    .fighter__bars .stat-bar__value { min-width: 0; font-size: 0.85rem; }
    .fighter__facts { gap: 0 var(--gap-3); }
    .fighter__fact-label--weapon { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
    .melee__tray { min-height: 0; padding: var(--gap-1) var(--gap-3); }
    .melee__roll--latest .dice__face { width: 2.8rem; height: 2.8rem; }
    /* Every action in view at 390 x 844: one row, wrapping only if it must. */
    .melee__attack { min-height: 3rem; font-size: var(--step-1); }
    .melee__row > .ink-btn { padding-inline: var(--gap-2); }
    .melee__menu { padding: var(--gap-1) var(--gap-3); column-gap: var(--gap-4); }
    .melee__option { font-size: var(--step-0, 1.05rem); }
    .melee__account--both { gap: var(--gap-2); }
    .melee__record { max-height: 6.6rem; font-size: 0.98rem; }
    .melee__commentary { padding: var(--gap-1) 0 0 var(--gap-2); font-size: 0.95rem; }
}

/* ---------- The day's end ---------- */
.dayover { display: grid; gap: var(--gap-4); }
/* Teatime itself, the pot and the clock, at the head of the day's account. */
.dayover__picture { justify-self: center; width: clamp(7rem, 30vw, 10rem); height: auto; margin-bottom: calc(var(--gap-3) * -1); filter: drop-shadow(1px 3px 0 rgba(31, 27, 22, 0.22)); }
.dayover__kicker { font-variant: small-caps; letter-spacing: 0.08em; color: var(--oxblood); margin-bottom: calc(var(--gap-3) * -1); }
.dayover__verdict { font-family: var(--face-display); font-size: var(--step-1); font-style: italic; line-height: 1.35; }
.dayover__lost { display: block; font-size: var(--step-0); }
.dayover__tally { display: flex; flex-wrap: wrap; align-items: center; gap: var(--gap-2); }
.dayover__pip {
    width: 1.1rem;
    height: 1.1rem;
    border: var(--rule) solid var(--ink);
    border-radius: 50%;
    background: var(--paper-light);
    filter: url(#ink);
}
.dayover__pip--done { background: var(--ink); }
.dayover__count { margin-left: var(--gap-1); font-variant-numeric: lining-nums; }
.dayover__badge {
    padding: 0 0.55em;
    border: var(--rule-fine) solid var(--ink);
    font-variant: small-caps;
    letter-spacing: 0.05em;
    font-size: var(--step--1);
}
.dayover__level {
    display: grid;
    justify-items: center;
    padding: var(--gap-4) var(--gap-3);
    border: var(--rule) double var(--ink);
    border-width: 4px;
    text-align: center;
    background: var(--paper);
}
.dayover__level-kicker { font-variant: small-caps; letter-spacing: 0.1em; color: var(--ink-faded); }
.dayover__level-title { font-family: var(--face-display); font-size: var(--step-3); line-height: 1.1; }
.dayover__ledger { margin: 0; display: grid; }
.dayover__row {
    display: grid;
    grid-template-columns: 8rem 1fr;
    gap: var(--gap-3);
    padding: var(--gap-2) 0;
    border-bottom: var(--rule-fine) dotted var(--ink-faded);
}
.dayover__row:first-child { border-top: var(--rule-fine) dotted var(--ink-faded); }
.dayover__row dt { font-variant: small-caps; letter-spacing: 0.05em; color: var(--ink-faded); }
.dayover__row dd { margin: 0; font-variant-numeric: lining-nums; }
.dayover__row--grim dd { color: var(--oxblood); }
.dayover__spoils { display: flex; flex-wrap: wrap; gap: var(--gap-1); margin-bottom: var(--gap-1); }
.dayover__spoil { width: 3rem; height: 3rem; }
.dayover__why { color: var(--ink-faded); font-style: italic; font-size: var(--step--1); margin-left: var(--gap-1); }
.dayover__quiet { font-style: italic; color: var(--ink-faded); }
/* The way back stays in reach however long the day's account runs. */
.modal:has(.dayover) .modal__actions {
    position: sticky;
    bottom: calc(var(--gap-5) * -1);
    margin: var(--gap-4) calc(var(--gap-5) * -1) calc(var(--gap-5) * -1);
    padding: var(--gap-3) var(--gap-5) var(--gap-5);
    background: var(--paper-light);
    border-top: var(--rule-fine) solid var(--ink);
}
@media (max-width: 640px) {
    .dayover { gap: var(--gap-3); }
    .dayover__row { grid-template-columns: 1fr; gap: 0; }
    .dayover__level { padding: var(--gap-3); }
    .dayover__back { width: 100%; }
}

/* ---------- The errand ---------- */
/* The quest's title opens the errand card: it reads as a heading, with a faint dotted rule to say it can be pressed. */
.topbar__quest-button {
    font: inherit;
    color: inherit;
    background: none;
    border: 0;
    padding: 0;
    text-align: left;
    cursor: pointer;
    text-decoration: underline dotted var(--ink-faded);
    text-decoration-thickness: 1px;
    text-underline-offset: 0.18em;
    /* A finger-sized target without making the heading any taller. */
    padding-block: 9px;
    margin-block: -9px;
}
.topbar__quest-button:hover { text-decoration-color: var(--ink); }

/* How the errand stands. Empty-handed is said in oxblood, with a rule beside it, so it is hard to walk off without noticing. */
.topbar__errand { margin: 0; font-style: italic; color: var(--ink-soft); }
.topbar__errand--empty {
    padding-left: var(--gap-3);
    border-left: 3px solid var(--oxblood);
    color: var(--oxblood);
    font-style: normal;
    font-weight: 500;
}

.quest-card { display: grid; gap: var(--gap-3); }

/* A scene card (layout B): a paper card centred over the darkened park, with a large picture standing above it, half over
   its top edge. A person is drawn in an ink ring; a thing stands free. */
.scene-scrim {
    position: fixed;
    inset: 0;
    z-index: 60;
    background: rgba(31, 27, 22, 0.45);
    animation: fade-in 180ms ease-out;
}

.scene {
    --scene-pic: clamp(132px, 34vw, 190px);
    position: fixed;
    z-index: 61;
    left: 50%;
    top: 50%;
    /* Centre the whole of it, picture and card together: the picture stands half its height above the card. */
    transform: translate(-50%, calc(-50% + var(--scene-pic) * 0.25));
    width: min(34rem, calc(100vw - 32px));
    max-height: calc(100dvh - var(--scene-pic) * 0.6 - 2 * var(--gap-4));
    overflow: visible;
    padding: calc(var(--scene-pic) * 0.5 + var(--gap-3)) var(--gap-5) var(--gap-4);
    background: var(--paper-light);
    border: var(--rule) solid var(--ink);
    box-shadow: 6px 8px 0 rgba(31, 27, 22, 0.25);
    animation: scene-rise 260ms var(--ease-ink);
    display: flex;
    flex-direction: column;
}

.scene:focus { outline: none; }

.scene__picture {
    position: absolute;
    left: 50%;
    top: calc(var(--scene-pic) * -0.5);
    transform: translateX(-50%);
    width: var(--scene-pic);
    height: var(--scene-pic);
    display: grid;
    place-items: center;
}

.scene__picture img { width: 100%; height: 100%; object-fit: cover; }

.scene__picture--portrait {
    border-radius: 50%;
    overflow: hidden;
    border: var(--rule) solid var(--ink);
    background: var(--paper-deep);
    box-shadow: 3px 4px 0 rgba(31, 27, 22, 0.2);
}

.scene__picture--figure img { object-fit: contain; filter: drop-shadow(1px 3px 0 rgba(31, 27, 22, 0.22)); }
.scene__icon { width: 62%; height: 62%; color: var(--ink); stroke: var(--ink); }

/* A piece of ground on a card, cut to a hex as it is on the map. */
.scene__picture--tile img { object-fit: cover; clip-path: polygon(50% 0, 93.3% 25%, 93.3% 75%, 50% 100%, 6.7% 75%, 6.7% 25%); }

/* The rosette pinned to an errand's own picture, at the corner, as a prize card is to a show entry. */
.scene__picture img.scene__rosette {
    position: absolute;
    right: -14%;
    bottom: -6%;
    width: 42%;
    height: auto;
    transform: rotate(12deg);
    filter: drop-shadow(2px 3px 0 rgba(31, 27, 22, 0.25));
    animation: scene-pin 420ms 240ms var(--ease-ink) both;
}
@keyframes scene-pin {
    from { opacity: 0; transform: rotate(-8deg) scale(1.5); }
    to { opacity: 1; transform: rotate(12deg) scale(1); }
}
@media (prefers-reduced-motion: reduce) { .scene__picture img.scene__rosette { animation: none; } }
.scene--still .scene__picture img.scene__rosette { animation: none; }

.scene__heading {
    margin: 0 0 var(--gap-2);
    font-family: var(--face-text);
    font-size: var(--step--1);
    font-weight: 400;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--oxblood);
    display: flex;
    justify-content: space-between;
    gap: var(--gap-3);
}

.scene--found .scene__heading, .scene--done .scene__heading { justify-content: center; }
.scene__step { color: var(--ink-faded); letter-spacing: 0.06em; }

.scene__line { margin: 0 0 var(--gap-3); font-size: var(--step-1); }
.scene--found .scene__line, .scene--done .scene__line { text-align: center; }

/* The words (and the day's errand, under Nanny's) scroll if a short screen cannot hold them; the reply stays put. */
.scene__body { flex: 1 1 auto; min-height: 0; overflow: auto; }
.scene__line, .scene__note { overflow-wrap: anywhere; }
.scene__note { margin: 0 0 var(--gap-2); }
.scene__note:first-of-type { padding-top: var(--gap-3); border-top: var(--rule-fine) solid var(--paper-shade); }

.scene__replies { display: grid; gap: var(--gap-2); margin-top: var(--gap-3); }
.scene__reply { width: 100%; }

.scene--still, .scene-scrim--still { animation: none; }

@keyframes scene-rise {
    from { opacity: 0; translate: 0 24px; }
    to { opacity: 1; translate: 0 0; }
}

@media (prefers-reduced-motion: reduce) {
    .scene, .scene-scrim { animation: none; }
}

/* ---------- The cabinet: each hero's marbles ---------- */
/* The way in: a framed slot at the foot of the right column (and in the nursery), or a tool under the map on a phone. */
.cabinet-btn {
    display: flex;
    align-items: center;
    gap: var(--gap-2);
    width: 100%;
    min-height: var(--target);
    padding: var(--gap-1) var(--gap-2);
    border: var(--rule-fine) solid var(--ink-faded);
    background: var(--paper-light);
    color: var(--ink);
    font: inherit;
    text-align: left;
    cursor: pointer;
    touch-action: manipulation;
}
.cabinet-btn:hover { border-color: var(--ink); box-shadow: 2px 2px 0 var(--paper-shade); }
.cabinet-btn__marble { flex: none; width: 38px; height: 38px; object-fit: contain; filter: drop-shadow(0 2px 2px rgba(31, 27, 22, 0.4)); }
.cabinet-btn__text { display: grid; line-height: 1.2; min-width: 0; }
.cabinet-btn__tally { font-size: var(--step-0); white-space: nowrap; }
.cabinet-btn__hint { font-size: var(--step--1); color: var(--ink-faded); font-style: italic; }
.panel--cabinet .cabinet-btn { width: auto; max-width: 16rem; }
.cabinet-dot { display: inline-block; width: 7px; height: 7px; margin-left: 4px; border-radius: 50%; background: var(--oxblood); vertical-align: middle; }
.cabinet-tool { display: none; position: relative; }
.cabinet-tool__marble { width: 22px; height: 22px; object-fit: contain; filter: drop-shadow(0 1px 1px rgba(31, 27, 22, 0.4)); }
.cabinet-tool .cabinet-dot { position: absolute; top: 6px; right: 4px; margin: 0; }
/* A marble just home: one brief ring. */
.cabinet-ring { animation: cabinet-ring 900ms var(--ease-ink) 1; }
@keyframes cabinet-ring {
    0% { box-shadow: 0 0 0 0 rgba(176, 138, 60, 0.7); }
    100% { box-shadow: 0 0 0 10px rgba(176, 138, 60, 0); }
}
@media (max-width: 640px) {
    .rail__part--cabinet { display: none; }
    .cabinet-tool { display: inline-flex; }
    /* Four tools share the phone's row under the map: equal widths, each mark above its word. */
    .park__tools { display: flex; flex: 1 1 100%; gap: var(--gap-1); margin-left: 0; }
    .park__tools .tool { flex: 1 1 0; flex-direction: column; justify-content: center; gap: 2px; padding: var(--gap-1) 2px; font-size: var(--step--1); }
}

/* Open: the chosen marble stands large (no wider than 135px, so the art stays sharp) above a paper card, half over its top
   edge, as a find card's picture does; beneath the words, a velvet-lined tray of twenty hollows, drawn inside the card. */
.cabinet-scrim {
    position: fixed;
    inset: 0;
    z-index: 60;
    background: rgba(31, 27, 22, 0.45);
    animation: fade-in 180ms ease-out;
}
.cabinet {
    --cab-pic: clamp(104px, 30vw, 135px);
    position: fixed;
    z-index: 61;
    left: 50%;
    top: 50%;
    transform: translate(-50%, calc(-50% + var(--cab-pic) * 0.25));
    width: min(25rem, calc(100vw - 32px));
    padding: calc(var(--cab-pic) * 0.5 + var(--gap-2)) var(--gap-4) var(--gap-4);
    background: var(--paper-light);
    border: var(--rule) solid var(--ink);
    box-shadow: 6px 8px 0 rgba(31, 27, 22, 0.25);
    text-align: center;
    animation: scene-rise 260ms var(--ease-ink);
}
.cabinet:focus { outline: none; }
.cabinet__picture {
    position: absolute;
    left: 50%;
    top: calc(var(--cab-pic) * -0.5);
    transform: translateX(-50%);
    width: var(--cab-pic);
    height: var(--cab-pic);
    pointer-events: none;
}
.cabinet__picture img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 8px 10px rgba(31, 27, 22, 0.55)); animation: fade-in 160ms ease-out; }
.cabinet__close {
    position: absolute;
    top: 0;
    right: 0;
    min-width: var(--target);
    min-height: var(--target);
    padding: 0 var(--gap-3);
    border: 0;
    background: none;
    color: var(--ink-faded);
    font: inherit;
    font-size: var(--step--1);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.22em;
    cursor: pointer;
    touch-action: manipulation;
}
.cabinet__close:hover { color: var(--ink); }
.cabinet__head { margin: 0; font-size: var(--step--1); font-variant: small-caps; letter-spacing: 0.08em; color: var(--ink-faded); }
.cabinet__name { margin: 0.1rem 0; font-family: var(--face-text); font-size: var(--step-1); font-style: italic; font-weight: 400; }
.cabinet__line { margin: 0 0 var(--gap-3); font-size: var(--step--1); line-height: 1.35; color: var(--ink-faded); overflow-wrap: anywhere; min-height: 2.7em; }

.cabinet__tray {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    margin: 0;
    padding: var(--gap-2);
    list-style: none;
    background: radial-gradient(ellipse at 50% 25%, var(--velvet), var(--velvet-deep) 80%);
    box-shadow: inset 0 0 0 1px var(--gilt), inset 0 6px 14px rgba(0, 0, 0, 0.55);
}
.cabinet__hollow { position: relative; aspect-ratio: 1; display: grid; place-items: center; min-width: var(--target); }
.cabinet__hollow::before {
    content: "";
    position: absolute;
    inset: 9%;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.18);
    box-shadow: inset 0 3px 6px rgba(0, 0, 0, 0.6);
}
.cabinet__hollow--empty::before { border: 1px dashed rgba(176, 138, 60, 0.55); }
.cabinet__pick {
    position: relative;
    display: grid;
    place-items: center;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: none;
    cursor: pointer;
    touch-action: manipulation;
}
.cabinet__pick img { width: 84%; height: 84%; object-fit: contain; filter: drop-shadow(0 3px 3px rgba(0, 0, 0, 0.5)); }
.cabinet__pick[aria-pressed="true"]::after { content: ""; position: absolute; inset: 2%; border-radius: 50%; border: 2px solid var(--gilt); }
.cabinet__pick:focus-visible { outline: 2px solid var(--paper-light); outline-offset: -2px; }
/* The marble just home settles into its hollow, once. */
.cabinet__pick--settle img { animation: cabinet-settle 700ms var(--ease-ink) 120ms both; }
@keyframes cabinet-settle {
    0% { transform: translateY(-60%) scale(1.25); opacity: 0; }
    60% { transform: translateY(4%) scale(0.98); opacity: 1; }
    100% { transform: none; }
}

.cabinet--still, .cabinet--still .cabinet__picture img, .cabinet--still .cabinet__pick--settle img { animation: none; }
@media (prefers-reduced-motion: reduce) {
    .cabinet, .cabinet-scrim, .cabinet__picture img, .cabinet__pick--settle img, .cabinet-ring { animation: none; }
}

/* The title's slot: a small row of the hero's marbles under the count. */
.slot__mini { display: flex; flex-wrap: wrap; gap: 2px; margin-top: 2px; }
.slot__mini img { width: 16px; height: 16px; object-fit: contain; }

.quest-card p { margin: 0; }
.quest-card__blurb { font-family: var(--face-display); font-style: italic; font-size: var(--step-1); }
.quest-card__errand { font-size: var(--step-1); }
.quest-card__clock { font-variant-numeric: lining-nums; }
.quest-card__hint { font-style: italic; color: var(--ink-faded); font-size: var(--step--1); }

/* ---------- The stage: what just happened, said over the park, then gone ---------- */
.stage {
    position: absolute;
    top: var(--gap-3);
    left: 50%;
    z-index: 3;
    width: min(34rem, calc(100% - 2 * var(--gap-3)));
    transform: translateX(-50%);
    padding: var(--gap-2) var(--gap-4);
    border: var(--rule) solid var(--ink);
    border-left: 5px solid var(--ink-faded);
    background: rgba(244, 239, 224, 0.96);
    box-shadow: 3px 4px 0 rgba(31, 27, 22, 0.16);
    pointer-events: none;   /* the park beneath can still be tapped */
    animation: stage-says 5s var(--ease-ink) forwards;
}
.stage__line {
    margin: 0;
    font-family: var(--face-display);
    font-size: clamp(1.1rem, 3.2vw, 1.4rem);
    line-height: 1.25;
}
.stage--low { top: auto; bottom: var(--gap-3); }
.stage--peril { border-left-color: var(--oxblood); }
.stage--peril .stage__line { color: var(--oxblood); }
.stage--boon { border-left-color: var(--ink); }
.stage--notice { border-left-color: var(--slate); }

/* In, held long enough to read, then away. */
@keyframes stage-says {
    0% { opacity: 0; transform: translate(-50%, -6px); }
    8% { opacity: 1; transform: translate(-50%, 0); }
    82% { opacity: 1; }
    100% { opacity: 0; visibility: hidden; }
}
@keyframes stage-says-still {
    0%, 85% { opacity: 1; }
    100% { opacity: 0; visibility: hidden; }
}

@media (prefers-reduced-motion: reduce) {
    .stage { animation-name: stage-says-still; }
}

@media (max-width: 40rem) {
    .stage { padding: var(--gap-1) var(--gap-3); }
    .stage__line { font-size: 1.05rem; }
}

/* ---- Portraits: the drawn cameos, where one exists (scripts/portraits.py) ---- */
.portrait { display: block; width: 100%; height: auto; aspect-ratio: 1; filter: drop-shadow(2px 3px 0 rgba(31, 27, 22, 0.14)); }
.cand__portrait { width: min(10rem, 60%); margin: var(--gap-2) auto var(--gap-1); }
.fighter__figure:has(.fighter__portrait) { display: grid; align-items: end; }
/* The disc stands exactly on the ground line (drawn at 94% of the figure's height), and stays there when it is his turn:
   the lift that marks the side to act suits a silhouette's feet, not a cameo, and "To act" already says so. */
.fighter__portrait { width: 100%; margin-bottom: calc(var(--fig-h) * 0.06); }
.fighter--to-act .fighter__figure:has(.fighter__portrait) { transform: none; }
.encounter__mark--portrait { width: 5.2rem; height: 5.2rem; overflow: visible; }
.encounter__portrait { width: 100%; }

/* The marble the boss carries, shown on his encounter card under the line. */
.encounter__marble { display: block; width: 3rem; height: 3rem; margin: var(--gap-3) auto 0; }

/* The five stats: a short list under each stat's heading. */
.stats-guide > p { margin: 0 0 var(--gap-2); }
.stats-guide__list { margin: 0 0 var(--gap-2); padding-left: 1.4em; display: grid; gap: 0.3rem; }

/* ---- A long game being rebuilt from its moves: a bar that fills, over everything, with a busy pointer ---- */
.loading {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: grid;
    place-items: center;
    padding: var(--gap-4);
    background: rgba(214, 205, 184, 0.72);
    cursor: progress;
}
.loading__card {
    width: min(24rem, 100%);
    display: grid;
    gap: var(--gap-2);
    padding: var(--gap-4) var(--gap-5);
    background: var(--paper-light);
    border: var(--rule-fine) solid var(--ink);
    box-shadow: 2px 4px 0 var(--paper-shade);
    text-align: center;
}
.loading__title { font-family: var(--face-display); font-size: var(--step-1); font-style: italic; }
.loading__track { height: 0.75rem; border: var(--rule-fine) solid var(--ink); background: var(--paper); }
.loading__fill {
    height: 100%;
    background: repeating-linear-gradient(-45deg, var(--slate) 0 4px, color-mix(in srgb, var(--slate) 80%, black) 4px 7px);
    transition: width 120ms linear;
}
.loading__count { font-size: var(--step--1); color: var(--ink-faded); font-variant-numeric: lining-nums; }
@media (prefers-reduced-motion: reduce) { .loading__fill { transition: none; } }

/* ---------- A puzzle box: the Fifteen ---------- */
/* A little walnut box of ivory tiles over the dimmed page, as the toy was sold in the 1880s. Each tile is placed by its
   row and column, so a slide is only a change of place and glides there. Solved, the box turns over to show its back. */
.puzzle-scrim {
    position: fixed;
    inset: 0;
    z-index: 60;
    background: rgba(31, 27, 22, 0.45);
    animation: fade-in 180ms ease-out;
}
.puzzle {
    /* The box makers' woods and ivory, for every puzzle box. */
    --walnut: #6b4428;
    --walnut-deep: #3d2615;
    --ivory: #f1e9d2;
    --ivory-shade: #cdbf9c;
    --tray: min(20rem, calc(100vw - 32px - 2 * var(--gap-4) - 28px));
    position: fixed;
    z-index: 61;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(25rem, calc(100vw - 32px));
    max-height: calc(100dvh - 2 * var(--gap-4));
    overflow: auto;
    padding: var(--gap-4);
    background: var(--paper-light);
    border: var(--rule) solid var(--ink);
    box-shadow: 6px 8px 0 rgba(31, 27, 22, 0.25);
    text-align: center;
    animation: scene-rise 260ms var(--ease-ink);
}
.puzzle:focus { outline: none; }
.puzzle__title {
    margin: 0 0 var(--gap-3);
    font-family: var(--face-text);
    font-size: var(--step--1);
    font-weight: 400;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--oxblood);
}

/* The two faces share one place; turning the box rotates each about the upright. */
.puzzle__flip { display: grid; perspective: 900px; }
.puzzle__face {
    grid-area: 1 / 1;
    display: grid;
    justify-items: center;
    align-content: start;
    gap: var(--gap-3);
    backface-visibility: hidden;
    transition: transform 700ms var(--ease-ink);
}
.puzzle__face--back { transform: rotateY(180deg); }
.puzzle--turned .puzzle__face--front { transform: rotateY(-180deg); }
/* At rest it is set flat again (no 3D transform), or the words on the back would be drawn soft. */
.puzzle--turned .puzzle__face--back { transform: none; }

/* The box: a walnut frame round a sunken tray. */
.puzzle__tray {
    position: relative;
    width: var(--tray);
    aspect-ratio: 1;
    box-sizing: content-box;
    padding: 4px;
    border: 10px solid var(--walnut);
    border-radius: 6px;
    background: var(--walnut-deep);
    box-shadow:
        inset 0 2px 6px rgba(0, 0, 0, 0.6),
        0 0 0 1px var(--ink),
        3px 5px 0 rgba(31, 27, 22, 0.25);
    background-image: linear-gradient(160deg, rgba(255, 255, 255, 0.06), transparent 60%);
}
.puzzle__tray:focus { outline: none; }
.puzzle__tray:focus-visible { box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.6), 0 0 0 1px var(--ink), 0 0 0 4px var(--gilt); }

.puzzle__tile {
    position: absolute;
    left: 4px;
    top: 4px;
    width: calc((100% - 8px) / var(--size));
    height: calc((100% - 8px) / var(--size));
    padding: 2px;
    margin: 0;
    border: 0;
    background: none;
    cursor: default;
    transform: translate(calc(var(--col) * 100%), calc(var(--row) * 100%));
    transition: transform 140ms var(--ease-ink);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
.puzzle__tile span {
    display: grid;
    place-items: center;
    width: 100%;
    height: 100%;
    border-radius: 4px;
    background: linear-gradient(145deg, #fbf6e8, var(--ivory) 45%, var(--ivory-shade));
    box-shadow: inset -1px -2px 0 rgba(61, 38, 21, 0.25), inset 1px 1px 0 rgba(255, 255, 255, 0.7), 0 1px 2px rgba(0, 0, 0, 0.45);
    font-family: var(--face-display);
    font-size: calc(var(--tray) / var(--size) * 0.42);
    line-height: 1;
    color: var(--ink);
    user-select: none;
}
/* A tapped tile hands the focus straight back to the tray, so it never wears a ring. */
.puzzle__tile:focus { outline: none; }
.puzzle__tile--free { cursor: pointer; }
.puzzle__tile--free:hover span { background: linear-gradient(145deg, #fffaf0, #f6efda 45%, var(--ivory-shade)); }
.puzzle__tile:active span { box-shadow: inset 0 1px 2px rgba(61, 38, 21, 0.35); }

.puzzle__how { margin: 0; font-size: var(--step--1); font-style: italic; color: var(--ink-faded); }

/* The back: a square of card pasted to the bare wood. */
.puzzle__card {
    width: var(--tray);
    aspect-ratio: 1;
    box-sizing: content-box;
    padding: 4px;
    border: 10px solid var(--walnut);
    border-radius: 6px;
    background: var(--walnut-deep);
    box-shadow: 0 0 0 1px var(--ink), 3px 5px 0 rgba(31, 27, 22, 0.25);
    display: grid;
}
.puzzle__card > * {
    margin: 6%;
    padding: var(--gap-4);
    display: grid;
    place-items: center;
    background: var(--paper-light);
    box-shadow: 1px 2px 3px rgba(0, 0, 0, 0.5);
}
.puzzle__blank { font-style: italic; color: var(--ink-faded); }
.puzzle__moves { margin: 0; font-size: var(--step--1); color: var(--ink-faded); }
.puzzle__away { margin-top: var(--gap-3); }

.puzzle--still, .puzzle--still .puzzle__face, .puzzle--still .puzzle__tile { animation: none; transition: none; }
@media (prefers-reduced-motion: reduce) {
    .puzzle, .puzzle-scrim { animation: none; }
    .puzzle__face, .puzzle__tile { transition: none; }
}

/* ---------- A puzzle box: the tangram ---------- */
/* A page of a Regency puzzle book: the figure printed in solid ink on a card, the seven ivory tans on the table beneath.
   The table is drawn in its own units (TangramPuzzle sets the viewBox); it is sized to fit the narrower of the screen's
   width and its height. Made, the tans go to ink and become the figure. */
.tangram {
    --table-w: min(21rem, calc(100vw - 32px - 2 * var(--gap-4)), calc((100dvh - 13rem) * 7 / var(--tangram-depth)));
    display: block;
    width: var(--table-w);
    height: auto;
    margin: 0 auto;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    overflow: visible;
}
.tangram__ground { fill: var(--paper); stroke: var(--paper-shade); stroke-width: 0.03; }
.tangram__figure { fill: var(--ink); stroke: var(--ink); stroke-width: 0.03; stroke-linejoin: round; }
.tangram__tan {
    fill: var(--ivory);
    stroke: var(--walnut-deep);
    stroke-width: 0.035;
    stroke-linejoin: round;
    cursor: grab;
    filter: drop-shadow(0 0.03px 0.04px rgba(31, 27, 22, 0.45));
    transition: fill 400ms var(--ease-ink), stroke 400ms var(--ease-ink);
    -webkit-tap-highlight-color: transparent;
}
.tangram__tan:focus { outline: none; }
.tangram__tan--focus { stroke: var(--gilt); stroke-width: 0.07; }
.tangram__tan--held { cursor: grabbing; filter: drop-shadow(0.06px 0.12px 0.08px rgba(31, 27, 22, 0.5)); }
.tangram__top { cursor: grab; }
.puzzle--made .tangram__tan { fill: var(--ink); stroke: var(--ink); cursor: default; filter: none; }

.tangram__tools { display: flex; align-items: center; justify-content: center; gap: var(--gap-3); margin-top: var(--gap-2); flex-wrap: wrap; }
.tangram__tools .puzzle__how { margin: 0; }
.tangram__flip, .tangram__copy {
    min-height: var(--target);
    padding: 0 var(--gap-3);
    font: inherit;
    font-size: var(--step--1);
    color: var(--ink);
    background: var(--paper-light);
    border: var(--rule-fine) solid var(--ink);
    cursor: pointer;
}
.tangram__flip:hover, .tangram__copy:hover { background: var(--paper); }
.tangram__copy { margin-top: var(--gap-2); }
.tangram__done { margin-top: var(--gap-3); padding: var(--gap-3); background: var(--paper); border: var(--rule-fine) solid var(--paper-shade); }
.tangram__done > * { margin: 0; }

.puzzle--still .tangram__tan { transition: none; }
@media (prefers-reduced-motion: reduce) { .tangram__tan { transition: none; } }

/* ---------- A puzzle box: the secret box ---------- */
/* A Hakone box seen one face at a time, drawn from the pieces of art/puzzles/secretbox/ (in their own pixels:
   SecretBoxDrawing's viewBox is 580 by 290). A panel slides over the dark of its groove; a part held fast gives a fraction
   and clicks back (the give classes; two, so the same give can play twice running); a knob turns, and a flap swings over on
   its hinge, into its new picture. */
.puzzle--secretbox { width: min(36rem, calc(100vw - 32px)); }
.secretbox {
    --box-w: min(32rem, calc(100vw - 32px - 2 * var(--gap-4)));
    display: block;
    width: var(--box-w);
    height: auto;
    margin: 0 auto;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}
.secretbox__turns { display: flex; align-items: center; justify-content: center; gap: var(--gap-3); margin-bottom: var(--gap-2); }
.secretbox__face-name { margin: 0; min-width: 9rem; font-style: italic; color: var(--ink-faded); }
.secretbox__turn {
    min-width: var(--target);
    min-height: var(--target);
    font: inherit;
    color: var(--ink);
    background: var(--paper-light);
    border: var(--rule-fine) solid var(--ink);
    cursor: pointer;
}
.secretbox__turn:hover:not(:disabled) { background: var(--paper); }
.secretbox__turn:disabled { opacity: 0.4; cursor: default; }

.secretbox__face { animation: fade-in 180ms ease-out; }
.secretbox__hollow { fill: #1a0f08; }
/* The shadow round a groove, where the face stands over it: a soft dark edge, kept within the groove (its stroke box). */
.secretbox__hollow-edge { fill: none; stroke: #1a0f08; stroke-width: 10; stroke-opacity: 0.6; filter: blur(3px); clip-path: inset(0) stroke-box; pointer-events: none; }
.secretbox__slip rect { fill: var(--paper-light); stroke: var(--paper-shade); stroke-width: 1.5; }
.secretbox__slip path { stroke: var(--paper-shade); stroke-width: 1.5; }

.secretbox__part { cursor: pointer; transform-box: fill-box; transform-origin: center; transition: transform 160ms var(--ease-ink); outline: none; -webkit-tap-highlight-color: transparent; }
.secretbox__part--slide, .secretbox__part--pull { cursor: grab; }
.secretbox__part--dragging { transition: none; cursor: grabbing; }
.secretbox__ring { fill: none; stroke: none; pointer-events: none; }
.secretbox__part:focus-visible .secretbox__ring { stroke: var(--gilt); stroke-width: 4; }
.puzzle--opened .secretbox__part { cursor: default; }
.secretbox__at { transition: transform 160ms var(--ease-ink); }
[data-rides] { transition: transform 160ms var(--ease-ink); }
[data-rides].secretbox__riding { transition: none; }
.secretbox__pic { transform-box: fill-box; transform-origin: center; }
/* A knob comes round the quarter it was turned; a flap swings over from its hinge (the left edge shut, the right open). */
.secretbox__swing--on { animation: box-turn-on 200ms var(--ease-ink); }
.secretbox__swing--back { animation: box-turn-back 200ms var(--ease-ink); }
.secretbox__swing--open { transform-origin: right center; animation: box-swing 260ms var(--ease-ink); }
.secretbox__swing--shut { transform-origin: left center; animation: box-swing 260ms var(--ease-ink); }
@keyframes box-turn-on { from { transform: rotate(-90deg); } }
@keyframes box-turn-back { from { transform: rotate(90deg); } }
@keyframes box-swing { from { transform: scaleX(0.05); } }

.secretbox__part--give-0 { animation: box-give-0 260ms var(--ease-ink); }
.secretbox__part--give-1 { animation: box-give-1 260ms var(--ease-ink); }
@keyframes box-give-0 {
    35% { transform: translate(var(--gx), var(--gy)) rotate(var(--gr)) scale(var(--gs)); }
    70% { transform: translate(calc(var(--gx) * -0.25), calc(var(--gy) * -0.25)) rotate(calc(var(--gr) * -0.25)); }
}
@keyframes box-give-1 {
    35% { transform: translate(var(--gx), var(--gy)) rotate(var(--gr)) scale(var(--gs)); }
    70% { transform: translate(calc(var(--gx) * -0.25), calc(var(--gy) * -0.25)) rotate(calc(var(--gr) * -0.25)); }
}

.secretbox__said { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.secretbox__tools { display: flex; align-items: center; justify-content: center; gap: var(--gap-3); margin-top: var(--gap-2); flex-wrap: wrap; }
.secretbox__tools .puzzle__how { margin: 0; }
.secretbox__again {
    min-height: var(--target);
    padding: 0 var(--gap-3);
    font: inherit;
    font-size: var(--step--1);
    color: var(--ink);
    background: var(--paper-light);
    border: var(--rule-fine) solid var(--ink);
    cursor: pointer;
}
.secretbox__again:hover { background: var(--paper); }
.secretbox__again:disabled { opacity: 0.45; cursor: default; }
.secretbox__inside { margin-top: var(--gap-3); padding: var(--gap-3); background: var(--paper); border: var(--rule-fine) solid var(--paper-shade); display: grid; gap: var(--gap-2); }
.secretbox__inside > * { margin: 0; }

/* A tilting maze (TiltMazePuzzle): a round box under glass on the table, tipped in perspective as it is held; the pad
   beneath shows the tilt. */
.puzzle--clover { width: min(30rem, calc(100vw - 32px)); }
.clover__stage {
    display: grid;
    justify-items: center;
    gap: var(--gap-3);
    outline: none;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}
.clover__stage:focus-visible:not(.clover__stage--touched) .clover__table { outline: 3px solid var(--gilt, #b8860b); outline-offset: 4px; border-radius: 50%; }
.clover__table { width: min(24rem, calc(100vw - 32px - 2 * var(--gap-4))); perspective: 900px; cursor: grab; }
.clover__stage--held .clover__table { cursor: grabbing; }
.clover { display: block; width: 100%; height: auto; transform-style: preserve-3d; filter: drop-shadow(0 6px 8px rgba(40, 24, 10, 0.35)); }
.clover__rim { fill: #7a4a26; stroke: #4b2a12; stroke-width: 1.5; }
.clover__floor { fill: #8fa86a; stroke: #4b2a12; stroke-width: 1; }
.clover__sprig { fill: #6e8a4c; opacity: 0.55; }
.clover__pen { stroke: none; }
.clover__wall { fill: none; stroke: #f1e7cc; stroke-linecap: round; filter: drop-shadow(0.6px 0.9px 0.4px rgba(40, 24, 10, 0.55)); }
.clover__sill { fill: none; stroke: #9a6b3c; stroke-width: 3; stroke-dasharray: 1.2 1; opacity: 0.85; }
.clover__pig { filter: drop-shadow(0.5px 1px 0.6px rgba(40, 24, 10, 0.5)); }
.clover__ear { fill: #d98c88; }
.clover__snout { fill: #e7a29e; stroke: #b9625f; stroke-width: 0.35; }
.clover__glass { pointer-events: none; }
.clover__pad {
    position: relative;
    width: 4.5rem;
    height: 4.5rem;
    border-radius: 50%;
    background: radial-gradient(circle at 40% 35%, var(--paper-light), var(--paper-shade));
    border: var(--rule-fine) solid var(--ink);
    cursor: grab;
}
.clover__knob {
    position: absolute;
    left: calc(50% - 0.6rem);
    top: calc(50% - 0.6rem);
    width: 1.2rem;
    height: 1.2rem;
    border-radius: 50%;
    background: var(--ink);
    pointer-events: none;
}
.clover__said { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.puzzle--still .secretbox__face, .puzzle--still .secretbox__part, .puzzle--still .secretbox__at,
.puzzle--still .secretbox__pic { animation: none; transition: none; }
@media (prefers-reduced-motion: reduce) {
    .secretbox__face, .secretbox__part, .secretbox__at, .secretbox__pic { animation: none; transition: none; }
}

/* A toddler's quirks, moves and kit, folded under a line of their own on the cards to choose from. */
.toddler__more:not(.toddler__more--folds) > .toddler__more-line { display: none; }
.toddler__more-line {
    cursor: pointer;
    min-height: var(--target);
    display: flex;
    align-items: center;
    gap: var(--gap-1);
    font-variant: small-caps;
    letter-spacing: 0.04em;
    color: var(--ink-faded);
}
.toddler__more-line:hover, .toddler__more-line:focus-visible { color: var(--ink); }
.toddler__more-line::-webkit-details-marker { display: none; }
.toddler__more-line { list-style: none; }
.toddler__more-line::before { content: "\25B8"; transition: transform 120ms ease; }
.toddler__more[open] > .toddler__more-line::before { transform: rotate(90deg); }
.cands__shuffle { display: flex; justify-content: center; margin-top: var(--gap-4); }
