/* Rainbow Riders. Big targets, strong focus rings, no color-only signals.
   Colors, sizes and fonts are tokens on :root; components use only tokens. */
@font-face {
  font-family: "Nunito";
  src: url("assets/fonts/nunito-latin.woff2") format("woff2");
  font-weight: 200 1000;
  font-display: swap;
}

[data-palette-sample="default"],
:root {
  --sticker-rarity-gem: 16px;
  --book-cover-art: 4rem;
  --book-empty-art: 4rem;
  --book-page-count-w: calc(var(--text-md) * 8);
  --card-dialog-h-max: 22dvh;   /* the tallest the card grows in its dialog (the card book's one card) */
  --book-card-h-max: 11.5rem;   /* the tallest a card in the card book's grid grows (about 150x180 at 1280x800); the paper's height shrinks it */
  --book-card-art-height: 0.58;
  --book-card-art-width: 0.72;
  --book-card-art-short: 0.28;
  --book-card-count-reserve: 2rem;
  --sticker-book-star-slot: 1rem;
  --scrapbook-pile-art: 1.125rem;
  --place-book-pager-w: calc(var(--target-lg) * 2 + var(--gap-targets));
  --z-drag-preview: 10;
  --book-paper-opacity: 0.4;
  --book-page-pad: var(--space-2);   /* the card book's binder page: room round its pockets */
  --book-ring-room: 2rem;            /* ...the room at its left edge for the rings */
  --book-ring-d: 1.25rem;            /* ...a ring */
  --book-slot-pad: var(--space-1);   /* ...the room between a pocket's edge and its card */
  --art-milestone: 16rem;
  --art-milestone-height: 9rem;
  --art-bond: 1rem;
  --scrapbook-dialog-w: 960px;
  --scrapbook-box-w: clamp(16rem, 32%, 18rem);   /* keep the box readable while the paper takes more of the room */
  --scrapbook-paper-shape: 4 / 3; /* a scrapbook page: one shape everywhere, so stickers stay where they were put */
  --scrapbook-icon: 2rem;
  --sideways-pic: 7rem;   /* the turning phone on the "turn your phone sideways" view */
  --finder-memory-lines: 2;   /* the memories under a board page: this many lines, clamped */
  --finder-memory-h: calc(var(--text-xs) * var(--leading-tight) * var(--finder-memory-lines));
  --finder-page-shape: 1.3333;   /* the Sticker Finder's page, 4:3 (ui/sticker-book.js), the hero of its pane */
  --finder-side-min-w: calc(var(--target) * 2 + var(--space-2));   /* the little stickers' column beside the page: two squares across at least */
  --finder-arrow-room: calc(var(--target) + var(--space-2));   /* a phone's page arrows float at the pane's edges: the page keeps clear of them */
  --finder-sticker-max: 76px;   /* a sticker on the Finder's page: its usual size, smaller when the page is short */
  --finder-sticker-min: 36px;
  --finder-sticker-share: 14cqh;   /* ...at most this share of the page's height (room under it for its hint)... */
  --finder-sticker-share-bare: 22cqh;   /* ...or this when the page is too small to draw hints (books.css) */
  --finder-sheet-cols: 9;   /* the pages sheet's chips across (32 pages: 4 rows) */
  --sticker-tab-icon: 1.6rem;   /* a page's picture on its tab in the sticker book */         /* the little pictures by the page's name, the tools and the box */
  --scrapbook-tile-art-wide: 1.75rem;
  --scrapbook-tile-name-h: calc(var(--text-xs) * var(--leading-tight) * 2);
  --scrapbook-tile-h: calc(var(--scrapbook-tile-art-wide) + var(--scrapbook-tile-name-h) + var(--sticker-rarity-gem) + var(--space-1) * 2 + var(--space-0) * 2 + var(--border-1) * 2);
  --packet-reveal-art: 5rem;
  --packet-emerge-scale: 0.6;
  --scrapbook-tool-w: 4.5rem;     /* a tool in a tablet's column: icon over word */
  --scrapbook-compact-cols: 2;    /* a phone's tool strip: 2 columns of squares (the box's columns are CONFIG.ui.stickerBook.boxColumns) */
  --scrapbook-pop-w: 17rem;       /* the box's filters, opened beside the strip */
  --scrapbook-tile-art: 2rem;   /* a sticker in a phone's box tile, clear of its corner badge */
  --scrapbook-paper-min: 9rem;    /* the least a page shrinks to before the dialog scrolls instead */
  --sticker-picked-scale: 1.08;
  --scrapbook-drag-scale: 1.12;
  --scrapbook-bound-max: 45%;
  --scrapbook-bound-scale: 0.75;
  /* The scrapbook's papers (content/scrapbook.js names one per paper): pale enough for stickers to
     stand out, and each looks like its name in every palette (no palette overrides them) */
  --paper-cream: #fff3d6;
  --paper-cloud: #d6ebff;
  --paper-mint: #d2f4e4;
  --paper-lavender: #e6dcff;
  --ink: #2b2340;
  --ink-soft: #5a4f73;
  --paper: #ffffff;
  --panel: #fffdf8;
  --line: #7f72a6;          /* borders that must be visible: 3:1+ on panel and glass */
  --line-soft: #d9d0ea;     /* decorative dividers only */
  --sky-1: #cfe8ff;
  --sky-2: #f6e3ff;
  --accent: #6b3fd4;
  --accent-ink: #ffffff;
  --accent-soft: #f1eaff;
  --good: #2f8f46;
  --good-soft: #eaf7ee;
  --bad: #c0392b;
  --bad-soft: #fdeceb;
  --calm: #4b58c8;
  --calm-soft: #f1f3ff;
  --shield: #3a78c9;
  --shield-soft: #e2efff;
  --focus: #1b6ef3;
  --gold: #f2c14e;
  --gold-deep: #b07a10;
  --gold-soft: #fffbea;
  --warn: #a87e00;
  --warn-soft: #fff3cd;
  --hp-1: #e84545;
  --hp-2: #ff8a8a;
  --hp-stripe: rgb(255 255 255 / 0.4);   /* the HP bar's diagonal stripes */
  --track: #eee6f5;
  --rainbow-1: #e63946;
  --rainbow-2: #f3722c;
  --rainbow-3: #f9c74f;
  --rainbow-4: #43aa8b;
  --rainbow-5: #4d96ff;
  --rainbow-6: #9b5de5;
  --glass: rgb(255 255 255 / 0.9);
  --shade: rgb(0 0 0 / 0.25);
  --backdrop: rgb(43 35 64 / 0.55);   /* behind a dialog */
  --dialog-w: 520px;
  --dialog-w-lg: 720px;     /* the card book and the sticker book */
  --foil-shine: rgb(255 255 255 / 0.45);   /* the light that sweeps across a shiny card */
  --bad-glow: rgb(192 57 43 / 0.35);
  --power-plain: #c8c2d6;   /* cards that belong to no power */
  --stage-sky-top: #9fd4ff; /* battle backdrop when an island has no scene */
  --stage-sky-bottom: #e8f6ff;
  --stage-ground: #7cc27a;
  /* Maps (ui/map-view.js): the sea, roads and fog. Island colors come from each island's scene. */
  --sea-light: #9edcf5;
  --sea-deep: #4f9fd6;
  --town-grass: #a6e08c;    /* the town's meadow (its ground picture's base): under the town, so nothing blue shows while it's drawn */
  --sea-wave: rgb(255 255 255 / 0.6);
  --sea-wake: rgb(255 255 255 / 0.3);
  --shore: #7ccdf0;
  --shore-foam: rgb(255 255 255 / 0.7);
  --road: #fff1cf;
  --road-edge: rgb(43 35 64 / 0.3);
  --road-dot: #b07a10;
  --fog: rgb(255 255 255 / 0.8);
  --fog-road: rgb(255 255 255 / 0.35);
  --ground-spot: rgb(255 255 255 / 0.1);
  --dock: #b9824a;
  --boat: #e07a5f;
  /* Verbs: one color per kind of action (VERBS in src/content/text.js, .claude/reference/design-ui.md "Verbs").
     They point at the palette colors, so every palette recolors them. Use them through the
     .verb-<id> classes (which set --verb and --verb-soft), on cards, floaters, pop-ups, the
     combat log, and buttons that do one of these things. */
  --verb-damage: var(--bad);
  --verb-damage-soft: var(--bad-soft);
  --verb-shield: var(--shield);
  --verb-shield-soft: var(--shield-soft);
  --verb-heal: var(--good);
  --verb-heal-soft: var(--good-soft);
  --verb-good: var(--good);
  --verb-good-soft: var(--good-soft);
  --verb-bad: var(--bad);
  --verb-bad-soft: var(--bad-soft);
  --verb-draw: var(--calm);
  --verb-draw-soft: var(--calm-soft);
  --verb-sparks: var(--gold-deep);
  --verb-sparks-soft: var(--gold-soft);
  --verb-rainbow: var(--rainbow-6);   /* the rainbow sequence, never --accent (that is "go") */
  --verb-rainbow-soft: #f4ecff;

  /* ---------- Design system (.claude/reference/design-ui.md "Design system") ----------
     Rules below the token blocks use these through var() only: a test fails
     on any raw px or rem size in a rule. */

  /* Spacing: an 8-point scale with 4-point half steps (Material 3, Apple HIG) */
  --space-0: 2px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-8: 64px;

  /* Type: a 1.2 (minor third) scale from the 20px body size (grade-school sizing, spin 4) */
  --root-size: 20px;
  --root-size-big: 24px;        /* Bigger text setting: everything in rem grows */
  --text-xs-ratio: 0.72;
  --text-xs: calc(var(--text-xs-ratio) * 1rem);   /* 14px: captions under icon buttons, badges; nothing smaller */
  --text-floor: 0.62rem;        /* 12px, 15px with Bigger text: the least any word on a tile or chip may shrink to */
  --tile-name-leading: 1.4;    /* an arrow tile's name, where it shows two lines in a roomy tile (the gift): the lines' room, so the clamp cuts nothing */
  --tile-text-floor: 12px;      /* an arrow tile's words: tile-sized, never under this (the tile itself grows with Bigger text where it has room) */
  --card-text-floor: 12px;      /* ...and on a card, which grows with its own width, not with Bigger text */
  --text-sm: 0.85rem;           /* 17px: hints, card text, chips */
  --text-md: 1rem;              /* 20px: body, buttons */
  --text-lg: 1.2rem;            /* 24px: large buttons, choices, story, labels that lead */
  --text-xl: 1.44rem;           /* 29px: h2, panel titles; h1 on phones */
  --text-2xl: 1.73rem;          /* 35px: h1 on tablets, battle heading, floating numbers */
  --text-3xl: 2.07rem;          /* 41px: h1 on desktop */
  --h1: var(--text-3xl);        /* h1: 3xl on desktop, 2xl on tablets, xl on phones (the @media blocks) */
  --weight-body: 400;
  --weight-semi: 600;
  --weight-bold: 700;
  --weight-heavy: 800;
  --weight-ultra: 900;
  --leading-tight: 1.15;
  --leading-note: 1.1;          /* a note under a celebrating title: two lines still fit beside your picture */
  --leading: 1.4;

  /* Shape: radius and border scales */
  --radius-xs: 6px;             /* key badges */
  --radius-sm: 12px;            /* inputs, arrow tiles, small boxes */
  --radius-md: 16px;            /* cards, tiles, icon buttons, callouts */
  --radius-lg: 24px;            /* panels, HUD, stage, dialogs */
  --radius-pill: 999px;         /* buttons, chips, stats */
  --radius-round: 50%;
  --hairline: 1px;
  --border-1: 2px;              /* controls, chips, panels */
  --border-2: 3px;              /* cards, tiles, stage, emphasis */
  --border-3: 4px;              /* dialogs, the sparks orb */

  /* Elevation: flat storybook offsets (no blur) for things you press, one soft
     shadow for the dialog. High contrast turns --elev-color to solid ink. */
  --elev-color: rgb(43 35 64 / 0.18);
  --elev-0: none;
  --elev-1: 0 3px 0 var(--elev-color);         /* buttons, panels, tiles */
  --elev-2: 0 5px 0 var(--elev-color);         /* hovered buttons */
  --elev-3: 0 12px 32px var(--elev-color);     /* dialog */
  --press: 2px;                                /* a pressed button moves down this much */
  --lift: 1px;                                 /* a hovered button moves up this much */
  --card-lift: 6px;                            /* a hovered card */
  --card-raise: 22px;                          /* a focused card in the hand */
  --fan: 4deg;                                 /* each card in the hand leans this much more than the last... */
  --fan-spread: 20deg;                         /* ...shared out in a big hand, so it never leans off the page */
  --fan-lean: 0.17;                            /* how far the end cards of a fanned hand lean past their room, per card height */
  --fan-show: 0.8;                            /* the share of each card a fanned hand shows past the next (its name stays readable) */
  --fan-card-min: 0.75;                        /* the smallest a fanned hand's cards get to keep that, as a share of --card-w */

  /* Sizes */
  --target: 56px;               /* smallest tap target: kids' fingers (WCAG 2.5.8, HIG 44pt, M3 48dp, plus room) */
  --scroll-bar: 1.5rem;         /* the few scroll bars left (.claude/reference/design-ui.md "Scroll areas"): wide enough to grab; the thumb is at least --target long */
  --scroll-bar-edge: var(--border-2);   /* the track's color around the thumb, so it reads as a pill */
  --target-lg: 64px;            /* main actions: menus, Go, Set out, big moments */
  --target-xl: 88px;            /* minimum height of choice tiles and conversation answers */
  --gap-targets: var(--space-3);  /* the least room between two targets in a row */
  --gap-choices: var(--space-4);  /* the room between choice tiles */
  /* Same-size controls (.claude/reference/design-ui.md "Same-size rule"): every control of one class is one size
     whatever it says or holds, so kids learn where to tap */
  --slot-cols: 3;               /* the title's adventure cards: three in one row where they fit */
  /* (each card is at least 12rem wide, else one column: the @container rule below, which can't read a variable) */
  --slot-card-min-h: var(--target-xl);   /* ...and never shorter; a row is as tall as its tallest card */
  --save-notice-line: 14rem;    /* the save notice's words: the least width before its button wraps under */
  --tile-answer-h: 5rem;        /* a talk answer: two lines of words and its picture, every answer */
  --tile-answer-pic: 2.2rem;    /* ...the picture on it, for kids who can't read yet */
  --talk-answer-cols: 2;        /* ...in a fixed grid: a lone answer takes one tile, not the row */
  --talk-answers-gap: var(--gap-targets);   /* ...between them; the grid keeps rows for the talk's most answers (--talk-answers-most, from ui/talk.js) */
  --talk-answers-w: 14rem;      /* a phone's and a short tablet's talk: the column of answers beside the scene */
  --talk-said-min-w: 3rem;      /* what you said, beside Back one line: never narrower (it wraps before it is cut)... */
  --talk-bubble-h: 7.2em;       /* the friend's speech bubble: four lines beside Hear it, whatever they say */
  --tile-house-h: 6.5rem;       /* an action tile in a house: its picture over two lines of words */
  --house-cols: 3;              /* ...three to a row */
  --room-h: clamp(10rem, 34vh, 14rem);   /* a house's room (ui/house.js): the same height in every house */
  --house-place-room-h: clamp(10rem, 29vh, 12rem); /* room beside house-story details in the shared place frame */
  --room-figure: 8rem;          /* ...a horse standing in it (its rider at the riding scale) */
  --room-thing: 2.4rem;         /* ...a thing on the shelf */
  --check: 36px;                /* checkbox box */
  --new-bg: var(--gold);        /* the New! mark (components.js newMark): one gold pill for everything waiting for you */
  --new-ink: var(--ink);
  --new-mark-out: calc(var(--space-2) * -1);   /* ...poking out of its host's top right corner */
  --icon-sm: 0.85em;            /* icons follow the text they sit in */
  --icon-md: 1.2em;
  --tries-spent-stroke: 16px;   /* a spent star of tries is drawn hollow: its outline, in the icon's 256-unit box */
  --icon-lg: 1.5em;
  --icon-xl: 2em;
  --icon-btn: 1.75rem;          /* the icon in an icon button (HUD and tools) */
  --icon-gap: 0.3em;            /* icon to words, in running text */
  --focus-width: 4px;
  --focus-offset: 3px;
  --focus-offset-tight: calc(var(--focus-width) * -1);   /* a ring drawn inside its control: in a region whose padding is too thin for one outside (a region clips at its padding) */
  --new-mark-out-tight: calc(var(--space-1) * -1);       /* ...and a New! mark poking out only as far as that padding */
  /* The screen frame (ui/frame.js, .claude/reference/design-ui.md "Screen frame"): the top bar (HUD or slim
     bar), the main pane and the footer share one width (#app), radius, border and elevation. */
  --frame-gap: var(--space-3);          /* between the bar, the notes, the pane and the footer */
  --frame-radius: var(--radius-lg);
  --frame-border: var(--border-1);
  --frame-line: var(--line);
  --frame-elev: var(--elev-1);
  --bar-bg: var(--glass);               /* the top bar and the footer */
  --bar-pad: var(--space-2) var(--space-3);
  --pane-bg: var(--panel);              /* the main pane's card */
  --pane-pad: var(--space-5);
  --pane-gap: var(--space-4);           /* between the page title and what follows it */
  /* Regions (.claude/reference/design-ui.md "Screen layout"): each screen names its regions' heights from these
     (frame.regions); the pane takes the room they leave, never under its paneMin (--pane-min-h unless
     it says). Each is what its
     region holds at its fullest, so nothing in play changes it. */
  --bar-chrome: calc(var(--space-2) * 2 + var(--frame-border) * 2);   /* a bar's padding and border, top and bottom */
  --hud-chrome: calc(var(--space-1) * 2 + var(--frame-border) * 2);   /* the HUD's slimmer padding and border (a narrow window's and a phone's HUD rows add it) */
  /* A row of big buttons, and of small ones: never under their tap targets, and in rem, so it grows
     with Bigger text as the words in it do (at the usual size, --target-lg and --target) */
  --row-lg: max(var(--target-lg), 3.2rem);
  --row-md: max(var(--target), 2.8rem);
  --rail-w: var(--row-md);              /* the rail (.frame-rail, the shortest window held sideways): one target's width per HUD button across it */
  --top-bar-h: calc(var(--row-lg) + var(--bar-chrome));              /* a slim bar: Back, a title, the tools */
  --battle-bar-h: var(--top-bar-h);     /* the battle's slim bar (slimmer in a short battle) */
  --top-hud-h: calc(max(var(--art-hud), var(--row-lg)) + var(--bar-chrome));   /* the HUD: you on your horse, the numbers, the buttons, one row */
  --top-steps-h: var(--top-bar-h);      /* the create steps' bar: Back, the pips, Hear it */
  --foot-h: calc(var(--row-lg) + var(--bar-chrome));                 /* one row of big buttons */
  /* the head (a map's): where you are, beside the notice slot (frame.js noticeSlot), whose words
     show at most --notice-lines lines (all of them are said as you arrive) */
  --notice-lines: 2;
  --notice-h: max(var(--row-md), calc(var(--text-sm) * var(--leading) * var(--notice-lines) + var(--space-1) * 2 + var(--frame-border) * 2));
  --head-title: var(--text-xl);         /* the place's name in the head */
  --head-pic: 2.4rem;                   /* ...and its picture */
  --head-title-max: 45%;                /* the most of the head's width the name takes: the notice gets the rest */
  --head-h: calc(var(--notice-h) + var(--bar-chrome));
  --map-pane-pad: var(--space-2);       /* a map's pane: a thin edge around its window, so the map gets the room */
  --travel-btn-h: calc(var(--travel-pic) + var(--space-1) * 2 + var(--border-1) * 2);   /* a travel button */
  --foot-travel-h: calc(var(--travel-btn-h) + var(--bar-chrome));    /* a travel button and a row of buttons beside it */
  --foot-map-h: calc(var(--map-sign-h) + var(--bar-chrome));         /* a map's sign (an island, the sea) */
  --foot-town-h: calc(var(--map-sign-h-town) + var(--bar-chrome));   /* the town's sign */
  --foot-barn-h: calc(max(var(--travel-btn-h), var(--barn-sign-h)) + var(--bar-chrome));       /* the barn's sign beside the way back (as the memory match's) */
  --foot-tack-h: calc(var(--tack-sign-h) + var(--bar-chrome));       /* the tack room's sign */
  --foot-show-h: calc(max(var(--travel-btn-h), var(--show-sign-h)) + var(--bar-chrome));       /* the Horse Show's sign */
  --foot-memory-h: calc(max(var(--travel-btn-h), var(--memory-sign-h)) + var(--bar-chrome));   /* the memory match's sign beside the way back */
  --hand-h: calc(var(--card-h) + var(--space-2) + var(--space-1));   /* the battle's hand: a card, lifted a little */
  --tray-h: calc(var(--hand-h) + var(--space-2) + var(--tile-tray) + var(--bar-chrome));   /* the tray: the hand, then the arrows, the ledger and End turn */
  --keys-h: calc(var(--text-sm) * var(--leading));                   /* one line of key help */
  --pane-min-h: var(--map-room-min);    /* the pane is never shorter: past that (Bigger text, a tiny window) the page scrolls */
  --dialog-pad: var(--space-5);         /* inside a dialog; its last row of buttons is its footer */
  --dialog-foot-h: calc(var(--frame-border) + var(--space-3) + var(--target-lg) + var(--dialog-pad));   /* that sticky footer's height: a scrolling dialog keeps a focused button above it */
  --title-pic: 1.6em;                   /* a page title's picture, beside its words */
  --icon-xl-root: 2rem;                 /* the "saved" horse's picture (--icon-xl at the page's text size)... */
  --saved-cue-w: calc(var(--icon-xl-root) + var(--space-2) * 2 + var(--border-1) * 2);   /* ...in its round window (ui/saved-cue.js) */
  --saved-cue-over: calc(var(--saved-cue-w) - var(--space-3));   /* how far it reaches into a top bar from the bar's start: a phone's battle bar keeps that room for its picture, so the horse never lies over the level's name */
  --travel: var(--shield);              /* travel buttons: the sea's blue */
  --travel-soft: var(--shield-soft);
  --travel-pic: 3rem;                   /* the destination's picture on a travel button */
  --pip-size: 2.4rem;                   /* a create step's progress pip (the current one is --target) */
  --pip-now: var(--target);             /* the gift's step pip you are on */
  --pip-phone: 1.8rem;                  /* the gift's step pips on a phone (over its picture, not in the rail)... */
  --pip-phone-now: 2.4rem;              /* ...and the one you are on */
  --page-max: 1100px;           /* the screen frame's width: the top bar, the pane and the footer */
  --measure: 720px;             /* story text */
  --story-line-scale: 7cqb;     /* the create story's lines scale with the room's height, between --text-sm and the most the class allows */
  --story-line-scale-phone: 5cqb;   /* ...on a phone, whose lines are narrower */
  --story-ride-arrow: 1.1rem;   /* the arrow on Ride's island picture, on a phone */
  --menu-w: 460px;              /* title menu */
  --brand-emblem-w: min(5rem, 12vh);
  --brand-wordmark-w: min(16rem, 30vh);
  --brand-subtitle-w: 100%;                /* "Magic Meadow" under the wordmark: as wide as the wordmark's own box */
  --brand-edge-w: min(34rem, 90vw);        /* the meadow's grass and daisies: one picture, cut in half, a half in each bottom corner */
  --brand-butterfly-w: 3rem;
  --butterfly-dx: var(--space-4);          /* how far a title butterfly drifts across and up */
  --butterfly-dy: calc(var(--space-3) * -1);
  --doc-subtitle-w: min(13rem, 55vw);      /* the subtitle under the logo on a grown-up page */
  --brand-flourish-w: 12rem;
  --brand-flourish-h: 0.6rem;
  --title-top: min(var(--space-8), 3vh);   /* the sky over the logo: less on a short window... */
  --title-gap: min(var(--space-6), 2.5vh); /* ...and between the logo, the cards and the menu */
  --panel-narrow: 640px;        /* the new-power panel */
  --panel-wide: min(1000px, 92vw);   /* the Power Tree drawer on a laptop or tablet: two columns */
  --name-w: 20ch;
  --pick-w: 11rem;              /* rider tiles: room for an --art-pick picture */
  --pick-w-horse: 176px;        /* horse tiles: five fit in one row on a tablet */
  --power-edge: 8px;            /* a power's colored edge */
  --verb-badge: 1.6em;          /* the verb picture in front of a card line or pop-up row */
  --stat-pad: var(--space-2);   /* a stat pill's room each side of its icon and number */
  --chip-h: max(var(--target), 2.5rem);   /* status chips are buttons, and HUD / pile stat pills: never under a tap target */
  --chip-icon: 1.6em;           /* the status picture in a chip */
  --intent-pic: 1.4em;          /* pictures in a foe's intent */
  --info-pic: 6rem;             /* the big picture in a status or intent pop-up */
  --pop-pic-w: 40%;             /* a phone's battle pop-up: the hero's column, full height, beside the lines */
  --pile-h: var(--target);      /* the draw and used piles in battle: big enough to read at a glance */
  --token: 64px;                /* power tokens in the powers drawer */
  /* Arrow tiles, everywhere: 6rem, but never so big that the battle tray's four tiles run into the
     sparks, rainbow and End turn beside them (--tray-sides), even with Bigger text */
  --tile: 6rem;
  /* In the battle tray the four tiles share their row with the ledger and End turn (--tray-sides:
     End turn's words and the ledger's narrowest, in rem, plus the gaps), and stay short enough
     that the whole battle fits the window */
  --tray-sides: 28rem;
  --tile-tray: clamp(var(--target), calc((min(100vw, var(--page-max)) - var(--space-4) * 4 - var(--tray-sides)) / 4), 4.4rem);
  /* Cards: one size per kind: the hand and the reward picks; small ones (the card book, horse
     tiles); the big one in the card book's card dialog. The height is fixed, so every card of a
     size is the same size (tests/e2e/battle.spec.js checks every card fits). Inside, all em. */
  --card-w: 8.4rem;             /* 168 by 200 */
  --card-h: 10rem;
  --card-aspect: calc(10 / 8.4);   /* a card's height for its width (every size about the same) */
  --card-w-sm: 6.8rem;
  --card-h-sm: 8.1rem;
  --card-w-lg: 10.8rem;
  --card-h-lg: 12.9rem;
  --card-tall: 1.19;            /* a card's height for its width (168 by 200) */
  --card-tall-pick-short: 1.45; /* ...and on a short phone, where the pick has less room under the title */
  --card-tall-pick: 1.65;       /* ...a card you pick from three across a phone: taller, so its words keep 12px's room */
  --card-scale: 0.119;          /* a card's words grow with its width (20px on a 168px card), so every size looks the same */
  --card-pad: 0.35em;           /* inside a card */
  --card-gap: 0.2em;            /* between its rows */
  --card-head: 2.1em;           /* the cost, picture and key row */
  --card-art: 2em;
  --card-name: max(0.95em, var(--card-text-floor));
  --card-rules: max(0.8em, var(--card-text-floor));
  --card-cost: 1.8em;           /* the round cost badge */
  --card-cost-pad: 0.25em;
  --card-badge: 1.5em;          /* the verb picture in front of a rules line */
  --card-foot: max(0.7em, var(--card-text-floor));
  --sticker: 76px;              /* a sticker in the sticker book and on the reward screen */
  --star-slot: 36px;            /* one star on the star card (after a win, and in the Sticker Book) */
  --star-rise: 120%;            /* how far below its slot a star starts as it floats onto the card */
  --star-slot-sm: 30px;         /* ...smaller, on the Sticker Book's packet stack */
  --star-row: 5;                /* star slots in a row on the star card */
  --sticker-sm: 48px;           /* a sticker in a list (the Journey page) */
  --sticker-s: 0.8;             /* a sticker's size on its page (content/stickers.js `size`), times --sticker */
  --sticker-m: 1;
  --sticker-l: 1.3;
  --sticker-cut: 3px;           /* a die-cut sticker's white edge: four of these, one each way */
  --sticker-edge-svg: 12;       /* a shaped sticker's white edge, in its 100-unit box (half of it shows) */
  --sticker-outline-svg: 2;     /* an empty spot's dashed outline, in the same box */
  --holo-travel: 30px;          /* how far a holographic sheen slides, pointer from one side to the other (box units) */
  --glitter-dot: 1px;           /* a die-cut sticker's glitter specks, and how far apart they are */
  --glitter-gap: 7px;
  --sticker-hint-w: 7.5em;      /* an empty spot's hint wraps at this width */
  --sticker-slot-w: 5.5em;      /* a slot in the little stickers' row under a page (its name wraps there) */
  --orb: 100px;                 /* the sparks orb */
  --pip-w: 14px;                /* rainbow meter pips */
  --pip-h: 22px;
  --bar-h: 14px;                /* HP bars */
  --stripe: 4px;                /* HP bar stripes */
  --plate-w: 280px;             /* name plates on the stage */
  /* Every cue in battle has its spot (.claude/reference/design-ui.md "Every cue has its spot"): what comes and goes
     fills a slot that is always there, so nothing grows, shrinks or moves */
  --intent-h: var(--target);    /* a foe's intent: one row completely above its model */
  /* how tall a foe's picture may be: its room (.foe-room, a size container) less the complete intent height and gap
     (resolved where it's used, on the picture) */
  --foe-pic-h: max(0px, calc(100cqh - var(--intent-h) - var(--space-2)));
  --shield-w: calc(var(--icon-md) + 2ch + 3 * var(--space-1) + 2 * var(--border-1));   /* the Shield's slot beside the hearts: its icon and two digits, their gap, its padding and border, no more */
  --shield-h: 1.6em;            /* ...and its height, so a Shield coming never makes the row taller */
  --hp-pic: calc(var(--icon-md) + var(--space-1));   /* the heart in front of the hearts' number */
  --status-row-h: var(--chip-h);   /* the statuses' row on a plate: one row of chips */
  --stage-min: clamp(260px, 42vh, 440px);
  /* The battle fits the window (kids can't scroll easily): the stage takes the room the tray leaves
     it, never less than --stage-fit-min, and each fighter's picture takes the room its plate and
     intent leave (a size container), up to its --art-* size. */
  --stage-fit-min: 240px;
  --hero-aspect: 0.8;           /* you on your horse: width for each unit of height */
  --foe-aspect: 1.1;            /* a foe's picture, about */
  --stage-top: var(--space-4);  /* room above the fighters */
  --ledger-h: var(--tile-tray); /* the ledger under the hand: as tall as the arrow tiles beside it */
  --ledger-row-h: 1.6rem;       /* a ledger row (at least; a long one takes more lines, up to --ledger-lines) */
  --ledger-lines: 2;            /* the most lines a ledger row's words take (all of it was said aloud) */
  --term-line: 2px;             /* the dotted line under a game word you can open (components.js termText) */
  --term-line-gap: 3px;         /* ...this far under the letters */
  --term-tip-w: 20rem;          /* its bubble: at most this wide... */
  --term-tip-gap: 8px;          /* ...this far from the word and from the window's edges */
  --ledger-h-phone: calc(var(--ledger-row-h) * 2 + var(--space-1) * 3 + var(--border-1) * 2);   /* phones: two rows */
  --ledger-pic-new: 1.5rem;     /* the picture in front of the newest ledger row */
  --ledger-pic: 1.3rem;         /* ...and in front of the others */
  --shake: 8px;
  --float-rise: 48px;
  --float-at: 12%;              /* floating numbers start low over the fighter's body, clear of faces */
  --float-x: 60%;               /* ...a little toward the middle of the stage */
  --pick-ring-out: -10%;        /* the "tap a foe" ring reaches this far around the foe */
  --pick-glow: rgb(255 255 255 / 0.25);

  /* Art sizes (widths; heights follow each picture's viewBox) */
  --art-hero: clamp(8.5rem, 24vw, 15rem);     /* you on your horse, in battle */
  
  --art-foe: clamp(4.8rem, 12vw, 8.5rem);
  --art-foe-big: clamp(8.5rem, 26vw, 16rem);
  --peek-room: clamp(1.75rem, 4vw, 3rem);      /* the strip at the stage's right edge the foes still to come peek in from */
  --art-peek: clamp(3.5rem, 8vw, 5.5rem);      /* a foe peeking in (most of it is past the edge) */
  --peek-step: 1.5rem;                         /* each foe behind the next one peeks a little higher */
  --peek-soft: 0.8;                            /* ...softly: see-through this much */
  --peek-sway: -12%;                           /* a peeking foe leans in this far, now and then (not in calm mode) */
  --arrive-step: 115%;                         /* a foe stepping in hops from the edge: this far (of its picture) for each place */
  --name-letters: 10;                           /* a name idea's longest length (CONFIG.rider.maxName): a phone's name tile keeps room for this many letters */
  --name-tile-min-w: calc(var(--name-letters) * 0.62em + var(--space-4));   /* em is the tile's own text size, so Bigger text widens it too */
  --name-caption-w: 9rem;                       /* reserve the horse-name caption independently of the picked name */
  --art-pick: 9rem;                            /* rider and horse picker tiles */
  --art-preview: clamp(9rem, 30vw, 14rem);     /* your rider or horse on the create steps */
  --art-pair: 10rem;                           /* you on your horse, at home */
  --art-joins: clamp(6rem, 16vh, 8rem);        /* a friend's horse on New island found */
  --art-adventure: clamp(6rem, 15vh, 10rem);   /* ...on an adventure card on the title: smaller on a short window, so Settings is in view */
  --surprise-pic: clamp(3.5rem, 11vw, 6rem);   /* what popped out of the Surprise arrow's gift box */
  --surprise-box: clamp(2rem, 6vw, 3rem);      /* ...and the little gift box it came out of */
  --barn-min-h: 200px;                         /* the barn (screens/barn.js) gets the room the screen leaves it, never less (it doesn't grow with Bigger text) */
  --tile-barn-h: 96px;                         /* a thing in the barn you press: its picture over its word (it doesn't grow with Bigger text) */
  --barn-tool-w: 7rem;                         /* ...never wider than this */
  --barn-tool-pic: 48px;                       /* ...its picture */
  --barn-tool-gap: var(--gap-targets);         /* ...the room between two of them */
  --barn-tool-spacer: calc(var(--space-3) - var(--barn-tool-gap) * 2);   /* a phone's row: the track between the care things and the trick and the pat (with the gaps either side, --space-3) */
  --barn-horse-share: 0.68;                    /* how much of the stall's height your horse is */
  --bin-pad: var(--space-2);                   /* the crate of treats is a tray: this much room round the treat buttons, on every side */
  --barn-card-scale: 0.45;                     /* your horse's card pinned on the wall: the small card, this much smaller */
  --barn-card-h: calc(var(--card-h-sm) * var(--barn-card-scale));
  --barn-sign-h: var(--row-lg);                /* the sign under the barn: one row, the meters and the bonus line, then the trick and the pat */
  --barn-plank: 2.2rem;                        /* one plank of the barn's walls */
  --barn-wander: 0.9rem;                       /* how far your horse wanders either way in its stall */
  --horse-pupil-back: -2px;                    /* a horse's pupil looking back (the rig's own units) */
  --barn-meter-h: auto;                        /* the brushing meter's row under the barn: as tall as its pips */
  --barn-status-lines: 3;                      /* the line about the bonus under the barn: never more (a phone's has short words) */
  --barn-stall-rise: 26%;                      /* how high the stall's boards stand (a share of the barn) */
  --barn-strip-gap: var(--space-2);            /* a phone: the room between the strip of meters and the barn's left edge */
  --care-mood: 3rem;                           /* your horse's face bubble */
  --care-brush: 4.5rem;                        /* the brush that follows your finger or the mouse */
  --care-bite: 2.6rem;                         /* a treat being munched */
  --bond-shoe: 1.5em;                          /* a horseshoe of your horse's bond meter, under the barn */
  --barn-opener: var(--target);                /* a thing in the barn that opens something (the tack chest): never a smaller target */
  --tack-min-h: 300px;                         /* the tack room (screens/tack-room.js) gets the room the screen leaves it, never less */
  --tack-mirror-w: min(36%, 22rem);            /* the mirror with your horse in it, beside the shelf */
  /* the circus's memory match (screens/memory.js): the board gets the room the screen leaves it, cut
     into the round's grid (--cols by --rows, set from the game's data); never so small a card is under --target */
  --memory-gap: var(--space-2);                /* between cards */
  --memory-card-ratio: 0.75;                   /* a card's width for its height (like a playing card) */
  --memory-min-h: calc(var(--rows, 1) * var(--target) + (var(--rows, 1) - 1) * var(--memory-gap));
  --memory-result-w: min(90%, 26rem);          /* the prize, over the board */
  --circus-tent-w: 9rem;                       /* the tent in the circus's dialog */
  --circus-game-pic: min(5rem, 12vh);   /* a game's picture in the circus's dialog (tablet and desktop; a phone's fills the room its tile leaves) */
  --circus-game-tile-h: min(8.5rem, 25vh);                 /* a game's tile there: the picture over its name and short line */
  --circus-played-dim: 0.4;                    /* a played game's picture, dimmed under its check */
  --circus-done-size: 2.5rem;                  /* the check over a played game's picture */
  --tack-mirror-h: 8rem;                       /* ...and above it on a phone */
  --tab-min-w: 4.6rem;                         /* a tab (tabList) is at least this wide: its longest word fits */
  --tab-min-w-wide: 6.5rem;                    /* ...the Grown-ups area's tabs ("Accessibility") */
  --tab-min-w-wide-phone: 6rem;                /* ...on a phone: two to a row */
  --grown-ups-panel-h: min(28rem, 55vh);
  --gate-lead-h: 3.6em;                        /* the question's lead and "Not quite" share this slot: two lines, kept */
  --text-doc-logo: clamp(1.8rem, 7vw, 2.6rem);  /* the logo at the top of a grown-up page (tools/pages.js) */       /* the Grown-ups area's page: one height, whichever tab */
  --tack-tile: 7.5rem;                         /* a piece of tack on the shelf: one size, whatever it says */
  --icon-md-ratio: 1.2;                        /* --icon-md as a plain number (icons are 1.2em), for sums of heights */
  --tack-badge-h: calc(var(--text-xs) * var(--icon-md-ratio) + var(--space-1) + var(--border-1) * 2);   /* a tile's badge (price, lock, check): one line */
  --tack-tile-h: calc(var(--tack-tile-pic) + var(--text-sm) * var(--leading-tight) * 2 + var(--space-2) * 2 + var(--space-1) * 2 + var(--border-2) * 2);   /* a tile: its picture, its name (two lines at most), the room round them */
  --tack-tile-pic: 5.5rem;                     /* ...its picture: your horse wearing it */
  --tack-mirror-w-phone: 40%;                  /* a phone: the mirror column is this share of the pane */
  --tack-tile-pic-phone: 2.6rem;               /* a phone's tile: its picture */
  --tack-tile-phone-h: calc(var(--tack-tile-pic-phone) + var(--tack-badge-h) + var(--space-1) * 3 + var(--border-2) * 2);   /* a phone's tile: its picture and its badge (the name is said aloud, not drawn) */
  --tack-sign-h: 6.4rem;                       /* the sign under the tack room: what you are trying on and its one button */
  --drawer-tile: min(var(--tile), 4.6rem);     /* an arrow in the Power Tree drawer: a laptop's size, so the list keeps room (smaller on a phone) */
  --drawer-side-w: min(24rem, 45%);            /* the drawer's left column on a laptop or tablet: the arrows over the sign */
  --drawer-sign-lines: 3;                      /* the Power Tree sign: the most lines of a power's words (all of it is in Hear it and the token's name) */
  --drawer-hint-lines: 4;                      /* ...of the hint, which has no name over it */
  --drawer-sign-pic: 2.6rem;                   /* ...the power's picture on it */
  --drawer-sign-row: var(--target-lg);         /* ...the row of its picture and buttons (Hear it, Take it off) */
  /* ...one height, whatever it shows: a name and its words, over the picture and the buttons */
  --drawer-sign-h: calc(var(--text-md) * var(--leading-tight) + var(--text-sm) * var(--leading-tight) * var(--drawer-sign-lines) + var(--space-1) * 3 + var(--drawer-sign-row));
  --show-min-h: 300px;                         /* the Horse Show's ring (screens/horse-show.js) gets the room the screen leaves it, never less */
  --show-tile-h: var(--row-lg);               /* a trick's tile under the ring: one size, whatever it says */
  --show-pip: 1.8rem;                          /* a pip of the show (one per trick of the whole show) */
  --show-sign-h: var(--row-lg);                      /* the sign under the ring: what is happening and its one button */
  --memory-strip-h: var(--icon-md);            /* the phone's strip over the board: the pair slots and the stars */
  --memory-sign-h: var(--target);              /* the memory match's sign: the pairs, the turns and the Shine in one row */
  --art-friend: 5.5rem;                        /* a friend on their horse, at home */
  --art-hud: 4rem;                             /* you on your horse, in the HUD: big enough to read the face */
  --art-cheer: 5.5rem;                         /* you cheering (an adventure card on a phone) */
  --art-celebrate: clamp(3.4rem, 9vh, 5.5rem); /* you cheering beside a celebration's heading: smaller on a short window */
  --scroll-cue: 2rem;                          /* the fade at the bottom of a part that scrolls inside its box, where there is more */
  --reward-news-min: 4rem;                     /* the least room what you won keeps over the card pick */
  --confetti-bit: 1.6rem;                      /* a bit of party confetti */
  --golden-glow: var(--space-3);               /* a golden foe's glow around its picture */
  --letter-drawing: 7rem;                      /* the drawing in a friend's letter */
  --moment-bubble-max: 10rem;                  /* your horse's moment bubble is never wider than this */
  --rider-stand-w: 0.5;                        /* a standing rider's width, × horse width (the same scale as riding) */
  --rider-stand-x: 0.3;                        /* how far a standing rider stands in front of the horse, × horse width */
  --swatch: var(--paper);                      /* a color swatch's own color, set per swatch from content */
  --swatch-size: 72px;                         /* skin, hair and eye swatches: big for small fingers */
  --swatch-badge: 1.5rem;                      /* the check on the picked swatch */
  /* optionPicker's tiles (components.js): one size per picker, whatever they say (the same-size rule);
     a screen sets its own (the looks step's tiles have your rider's picture) */
  --settings-nav-w: 11rem;                     /* Settings' tab column (a phone's is the rail) */
  --settings-dialog-w: 52rem;                  /* ...and the dialog's width */
  --settings-dialog-h: 34rem;                  /* ...and the dialog's height: every page is the same */
  --settings-tile-h: var(--target);            /* ...a colors tile */
  --palette-dot: 1rem;                         /* a palette tile's dots */
  --option-tile-w: 10rem;                      /* a tile is at least this wide; the row shares what is left */
  --option-tile-h: var(--target-xl);           /* ...and this tall */
  --option-pic-w: 0;                           /* ...its picture's box (none on a words-only tile) */
  --option-pic-h: 0;
  /* the looks step (create/looks.js): your rider beside the tabs and one tab's choices, all in one
     screen. The preview never scrolls away; past its room (Bigger text) only the choices scroll */
  --looks-preview-w: clamp(7rem, 20vw, 12rem); /* your rider, beside the tabs and the choices */
  --look-tile-w: 5rem;                         /* a look's picture tile: your rider wearing it, and its words */
  --look-tile-h: calc(var(--space-2) * 2 + var(--look-pic-h) + var(--space-1) + var(--text-sm) * var(--leading-tight) * 2 + var(--border-1) + var(--border-3) * 2);   /* its padding, picture, gap, two lines of words and borders, whole */
  --look-clothes-w: 6rem;                      /* whole-body clothes choices have room for their labels */
  --look-pic-w: 4.2rem;                        /* ...its picture's box: your head (or the whole of you) */
  --look-pic-h: 2.8rem;
  --small-tablet-h: 640px;                     /* THE small tablet's limit: #app's content height under it (1024x600 less padding) is a small tablet. A container query cannot read var(), so every `@container app (max-height: 640px)` repeats this one number; change them together (grep --small-tablet-h) */
  --steps-pips-h: var(--target);               /* room for the phone’s clickable progress controls */
  --steps-pips-top: var(--space-0);
  --steps-back-w: 9rem;                        /* ...and the Back button's room, so a long question wraps rather than meets it */
  --steps-title-clear: 7rem;                    /* a small tablet: the question ends this far left of the bar's middle, clear of the pips */
  --steps-pip: 1rem;
  --steps-pip-now: 1.3rem;
  --looks-min-h: 16rem;                        /* the least room the tabs and choices get (Bigger text on a short window) */
  --horse-choice-h: 18rem;                     /* natural desktop/tablet horse card, capped by its pane */
  --story-content-h: 24rem;                    /* story scene stays proportionate in a tall window */
  --horse-min-h: 12rem;                        /* the least room the five horse tiles get (Bigger text on a short window) */
  --face-pop: 1.12;                            /* how much the head pops when the face changes */
  --art-heading: 1.8em;                        /* next to a heading's words */
  --art-inline: 1.7em;                         /* foes on a level button */
  --art-sign: 1.3em;                           /* ...and in a map's sign on a phone, where it is one short line */
  /* Where the rider sits on any horse (the art contract, see .claude/reference/design-sound-art.md "Art"):
     rider width, its left edge, and its bottom edge, as shares of the horse picture */
  --rider-w: 50%;
  --seat-x: 22.5%;
  --seat-y: 45%;
  --rider-headroom: 0.17;                      /* rider's head above the horse, × horse width */
  --art-halo: drop-shadow(0 0 1.5px var(--paper)) drop-shadow(0 3px 2px rgb(43 35 64 / 0.25));
  --bob: -4px;                                 /* gentle idle bob (off in calm mode) */
  --bob-time: 3.2s;

  /* Map sizes, as shares of the map's width (cqw), so a map looks the same at
     every size. Nodes are real buttons, so never below --target. */
  --map-min-w: 440px;       /* the whole map fits its window, shrinking down to this (past that, Bigger text in a short window, it pans) */
  --map-phone-min-w: 620px; /* ...and on a phone never narrower than this (its spots stay tap targets): it pans in its window */
  /* A map's window gets the room the screen leaves it (.claude/reference/design-ui.md "Screen frame"): the window's
     height less everything else on the page (--map-chrome, measured by ui/map-room.js when the page
     changes size, never per frame), so every spot is on screen above the footer without scrolling
     the page. Never shorter than --map-room-min: past that (Bigger text on a small phone) the page
     scrolls and the footer sticks. */
  --map-chrome: 0px;        /* set on <html>, where --map-room is worked out */
  --map-room-min: 180px;    /* room for a spot, the rider over it and its label (maps don't grow with Bigger text) */
  --screen-h: 100vh;        /* the window's height: 100svh where it's known (below), so a phone's toolbar never covers the footer */
  --map-room: max(var(--map-room-min), var(--screen-h) - var(--map-chrome));
  --map-fill: var(--pane-bg);   /* past a map's sides in its pane (the world map fills it with its sea) */
  /* A map's sign keeps one height (.claude/reference/design-ui.md "Screen frame"): what shows in it changes as you
     ride (a place's button pops up, a note, why you can't go there), so its room is kept and the
     footer, and with it the map's window, never changes size. */
  --map-sign-h: 4rem;          /* an island or the sea: where you are, and one line (foes, prize) */
  --map-sign-h-town: 4.4rem;   /* town: where you are, and a line or two (a friend's help, a wish's gift) */
  --rail-go-h: var(--target-lg);   /* the town's floating go button on a phone: a square, icon only */
  --map-float-inset: var(--space-2);   /* a floating part's distance from the pane's edge */
  --map-go-h: var(--target-lg);   /* a phone's map footer: the row with the travel and go buttons */
  --map-sign-lines: 2;         /* the most lines a line of words in the town's sign shows (the rest is in the spot's name, read aloud) */
  --map-button-lines: 2;       /* ...and a button's words in a phone's map footer (all of them are its name) */
  --map-node: max(var(--target), 6.8cqw);         /* a level */
  --map-lair: max(var(--target), 9.5cqw);     /* the guardian's lair */
  --map-isle: 17cqw;                              /* an island on the world map */
  --map-home-isle: 22cqw;                         /* Magic Meadow Island */
  --map-rider: 9cqw;                              /* you on your horse */
  --map-friend: 4.6cqw;                           /* friends and horses at home */
  --map-badge: max(1.4rem, 3.2cqw);               /* star / lock on a node */
  --map-critter: max(1.6rem, 3.4cqw);             /* the critter hiding on an island: small on purpose */
  --map-critter-cover: max(1.8rem, 3.8cqw);       /* what it hides behind */
  --map-critter-hit: max(var(--target), 6cqw);    /* ...but its button is never under a tap target */
  /* little surprises on the maps (ui/finds.js): small pictures on hit areas never under a tap target */
  --map-find: max(1.6rem, 3.6cqw);                /* a visitor, a secret's picture, a piece of treasure */
  --map-visitor: max(1.8rem, 4.6cqw);             /* a visitor: a little bigger, to spot and catch as it drifts */
  --map-find-pop: max(1.4rem, 3cqw);              /* what pops out of a secret (an apple, a wink) */
  --map-find-hit: max(var(--target), 6cqw);
  --map-find-chip: max(1.3rem, 2.4cqw);           /* the treasure count's picture */
  --map-badge-out: -0.55rem;                      /* how far a badge pokes out of its node */
  --map-ring-gap: -9px;                           /* the open ring around a node */
  --map-label-text: clamp(0.7rem, 1.7cqw, 0.85rem);
  --map-token-sink: 0.4rem;                       /* hooves sink this far into the spot */
  --map-road-shadow: 3px;
  --map-road-w: 30;         /* road widths in map units (the map scales) */
  --map-dot-w: 12;
  --map-dot-gap: 26;
  --mask-shown: #000;                             /* the part of a mask that shows (any solid color) */
  --map-edge-fade: 1.5rem;                        /* a scrolling map fades this far in from a side that has more */
  --ride-pulse: 1.8s;
  /* riding freely in town (ui/roam-view.js) */
  --roam-min-w: var(--map-min-w);   /* the town is never narrower than this: past that the window follows you */
  --trot-bob: -3px;         /* the horse's little bob as it trots (off in calm mode and reduced motion) */
  --trot-time: 0.34s;

  /* How long things move. Every animation and transition takes one of these (a test checks),
     and calm mode and reduced motion switch them all off at the end of this file. */
  --dur-press: 0.1s;        /* a button or tile going down under a press */
  --dur-lift: 0.15s;        /* a card lifting under the pointer */
  --dur-slide: 0.2s;        /* a caption or the drawer sliding in */
  --dur-line: 0.3s;         /* a friend's next line popping in */
  --dur-face: 0.35s;        /* a face that just changed */
  --dur-shake: 0.4s;        /* a hit's shake, a picked tile's pop */
  --dur-grow: 0.5s;         /* a hearts bar changing, a note or a stripe appearing */
  --dur-pop: 0.6s;          /* a new spot, or the sword, popping up */
  --dur-star: 0.5s;         /* a star floating onto the star card (none in calm mode) */
  --dur-burst: 0.8s;        /* a puff of sparkles */
  --dur-pulse: 1.2s;        /* one soft pulse; a path fading in; the gift's magic flying */
  --dur-drift: 9s;          /* a title butterfly drifting there and back (none in calm mode and reduced motion) */
  --dur-sway: 5s;           /* the title's grass swaying a little (none in calm mode and reduced motion) */
  --dur-twinkle: 1.6s;      /* a sparkle twinkling */
  --dur-turn: 1.8s;         /* the phone on the "turn it sideways" view turning (none in calm mode) */
  --dur-shimmer: 2.8s;      /* the foil shimmer across a shiny card (none in calm mode) */
  --dur-surprise: 2.6s;     /* the Surprise arrow's gift box: pop open, show what came out, fade */
  --dur-walk: 1.4s;         /* your horse walking across its stall in the barn */
  --dur-turn: 0.4s;         /* ...and turning around */
  --dur-swish: 3.2s;        /* one swish of a horse's tail, with a rest (the horse rig) */
  --dur-blink: 4.6s;        /* a horse blinks once in this long */
  --dur-flick: 5.8s;        /* ...flicks an ear once in this long */
  --dur-dragon-swish: 3.8s; /* one swish of a rig dragon's tail, with a rest (the dragon rig) */
  --dur-dragon-flap: 2.6s;  /* ...one slow flap of its wings */
  --dur-dragon-blink: 5.2s; /* ...it blinks once in this long */
  --dur-look: 9s;           /* ...and looks up at you once in this long */
  --dur-wander: 13s;        /* one gentle wander about its stall (it starts over) */
  --dur-ripple: 1.1s;       /* the stall trough's water rippling as your horse drinks (none in calm mode and reduced motion) */
  --ripple: 2px;            /* how far it ripples */
  --critter-rustle: 4.5s;   /* a hidden critter's bush (or rock, or shell) rustles once in this long */
  --find-flap: 0.5s;        /* a visitor's wings flap (it bobs up and down) once in this long */
  --find-glint: 6s;         /* a secret over the scenery glints once in this long */
  --dur-sparkle-fade: 2.4s; /* a missed sparkle in town fading away */
  --delay-pop: 0.6s;        /* a new spot waits for its path to start fading in */
  --delay-splash: 0.7s;     /* the fountain's sparkles wait for the wish's shell to land */
  --delay-gift-sword: 0.9s; /* the sword appears as the magic lands... */
  --delay-gift-stripes: 1.3s; /* ...and then its stripes */
  --dur-rumble: 1.4s;       /* the ground rumbling in the gift's story (a few small shakes) */
  --dur-ride-in: 0.9s;      /* your friends riding up in the gift's story */
  /* little joys (ui/joys.js): none of them move in calm mode or with reduced motion */
  --dur-moment-wait: 3s;    /* stand still this long and your horse does its little moment... */
  --dur-moment-cycle: 12s;  /* ...and again now and then: the moment plays in the first part of this */
  --dur-win-nuzzle: 2.7s;   /* the brief reward nuzzle fades out while the rider and horse celebrate */
  --dur-dance: 0.9s;        /* one turn of your perfect-win dance (it dances --times-dance) */
  --times-dance: 3;         /* turns of a dance: your party dance, your buddy's, your horse's nuzzle */
  --times-invite: 2;        /* hops of a soft "tap me": the cards to pick, the mailbox, the surprise box */
  --times-ready: 3;         /* pulses of an arrow power's key when it is ready */
  --dur-confetti: 3.2s;     /* a bit of confetti falling down the screen */
  --delay-confetti: 0.08s;  /* each bit of confetti starts this much after the one before */

  /* Cursors, one token per role (the "cursor map" section says which elements have which role).
     These are the system cursors. With the Big friendly pointer setting and a mouse,
     ui/cursors.js sets each role to its picture from src/content/cursors.js (CURSOR_FOR).
     CSS can't size a cursor picture, so each SVG is drawn at --cursor-size. */
  --cursor-size: 44px;
  --cursor-default: default;     /* everything else */
  --cursor-press: pointer;       /* buttons, map spots, cards, tiles, swatches */
  --cursor-aim: crosshair;       /* picking a foe */
  --cursor-grab: grab;           /* something you can pick up and drag (powers in the drawer) */
  --cursor-grabbing: grabbing;   /* while you drag it */
  --cursor-locked: not-allowed;  /* locked, not ready, can't be used */
  --cursor-type: text;           /* name boxes: a friendly I-beam with the pointer setting */

  --font: "Nunito", ui-rounded, "Trebuchet MS", system-ui, sans-serif;
  --emoji: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
  color-scheme: light;
}
@supports (height: 100svh) {
  :root { --screen-h: 100svh; }
}

/* Palettes (Settings > Colors). Each one only overrides tokens above; ids match
   PALETTES in src/content/text.js. Good and bad never rely on color alone:
   chips carry ▲/▼, the HP bar is striped with an ink edge, and threatening
   intents have a solid border while the rest are dashed. tests/palettes.test.js
   checks the contrast of every token pair the UI draws together. */

/* Red-green safe (deuteranopia, protanopia): Okabe-Ito blue for good,
   vermillion/orange for bad and HP, reddish purple for shields. */
[data-palette-sample="red-green"],
html[data-palette="red-green"] {
  --good: #0072b2;
  --good-soft: #e3f0fa;
  --bad: #c75300;
  --bad-soft: #fdeee3;
  --bad-glow: rgb(199 83 0 / 0.35);
  --shield: #8a3f8f;
  --shield-soft: #f6e8f6;
  --warn: #a86f00;
  --hp-1: #c75300;
  --hp-2: #e69f00;
  --rainbow-1: #d55e00;
  --rainbow-2: #e69f00;
  --rainbow-3: #f0e442;
  --rainbow-4: #009e73;
  --rainbow-5: #56b4e9;
  --rainbow-6: #0072b2;
  --stage-ground: #c9b458;
}

/* Blue-yellow safe (tritanopia): red against teal, and shields in slate
   grey so they don't meet good in the blue-green that looks alike. */
[data-palette-sample="blue-yellow"],
html[data-palette="blue-yellow"] {
  --good: #007a5e;
  --good-soft: #e2f4ef;
  --bad: #c8102e;
  --bad-soft: #fde7ea;
  --bad-glow: rgb(200 16 46 / 0.35);
  --shield: #565a6e;
  --shield-soft: #eceef3;
  --calm: #565a6e;
  --calm-soft: #eceef3;
  --hp-1: #d7263d;
  --hp-2: #ff8fa0;
  --rainbow-1: #c8102e;
  --rainbow-2: #f28482;
  --rainbow-3: #f6bd60;
  --rainbow-4: #1b998b;
  --rainbow-5: #3d5a80;
  --rainbow-6: #7d4e9f;
}

/* High contrast: black ink on flat white, dark strong colors, opaque glass. */
[data-palette-sample="high-contrast"],
html[data-palette="high-contrast"] {
  --ink: #000000;
  --ink-soft: #333333;
  --paper: #ffffff;
  --panel: #ffffff;
  --line: #000000;
  --line-soft: #595959;
  --sky-1: #ffffff;
  --sky-2: #ffffff;
  --accent: #3a0ca3;
  --accent-soft: #ece6ff;
  --good: #006b21;
  --good-soft: #e6f5ea;
  --bad: #b00020;
  --bad-soft: #fde8ea;
  --bad-glow: rgb(176 0 32 / 0.5);
  --calm: #2c2c9e;
  --calm-soft: #eef0ff;
  --shield: #004c99;
  --shield-soft: #e3efff;
  --focus: #0000cc;
  --verb-rainbow: #5b2a9e;
  --verb-rainbow-soft: #f4ecff;
  --gold: #ffd23f;
  --gold-deep: #6b4a00;
  --gold-soft: #fffbea;
  --warn: #6b4a00;
  --warn-soft: #fff3cd;
  --hp-1: #b00020;
  --hp-2: #d8203f;
  --track: #ffffff;
  --glass: #ffffff;
  --elev-color: #000000;
}

/* Riding freely in town (ui/roam-view.js): where the rider and each friend stand (percent of the
   town's width) and the camera. Set every frame while you ride, so they don't inherit: a change
   restyles only the one node that has it. */
@property --rx { syntax: "<number>"; inherits: false; initial-value: 0; }
@property --ry { syntax: "<number>"; inherits: false; initial-value: 0; }
@property --cam-x { syntax: "<length>"; inherits: false; initial-value: 0px; }
@property --cam-y { syntax: "<length>"; inherits: false; initial-value: 0px; }

/* A palette tile's 3 dots (settings.js paletteDots): each sample is listed beside its palette's own block, so its
   dots read the palette's own --good, --bad and --shield */
.palette-dots { display: inline-flex; gap: var(--space-0); flex: none; }
.palette-dot { width: var(--palette-dot); height: var(--palette-dot); border-radius: var(--radius-round); border: var(--border-2) solid var(--ink); background: var(--good); }
.palette-dot:nth-child(2) { background: var(--bad); }
.palette-dot:nth-child(3) { background: var(--shield); }

* { box-sizing: border-box; }

/* ---------- scroll bars (.claude/reference/design-ui.md "Scroll areas") ----------
   Almost nothing scrolls: a screen fits by its regions, smaller tiles, paging or wrapping. The few
   areas that must scroll are the kept list below (each holds its own scroll), and every bar is
   wide (--scroll-bar), its thumb a tap target long, in the palette's colors. A row you swipe or a
   map's camera hides its bar instead (scrollbar-width: none). tests/design-tokens.test.js fails
   on an overflow: auto or scroll that is in neither. The wide bar is for a pointer that grabs it
   (a mouse, a trackpad): a touch-only screen swipes, and keeps its own thin bar that floats over
   the content, so a phone's width stays its tap targets'. */
:is(.region-fill, .dialog, .dialog.powers-drawer, .looks-panel, .tack-shelf, .ledger-scroll, .reward-news, .grown-ups-panel, .settings-panel, .drawer-powers, .dialog.talk .talk-scene, .dialog.info-pop .info-lines, .gift-body > .gift-words, .gift-body > .gift-power, .cleared .story-lines, .finale .story-lines, .create-story .story-lines, .book-controls.scroll-inside, .town-place-screen .sticker-book-panel.is-finder.scroll-inside, .town-place-screen .scrapbook-pile.scroll-inside, .town-place-screen .scrapbook-workspace.scroll-inside, :root[data-layout=phone] .town-place-screen .scrapbook-workspace.scroll-inside) { overscroll-behavior: contain; }
.town-place-screen .sticker-book-panel.is-finder.scroll-inside,
.town-place-screen .scrapbook-pile.scroll-inside,
.town-place-screen .scrapbook-workspace.scroll-inside { overscroll-behavior: contain; }
@media (any-pointer: fine) {
  ::-webkit-scrollbar { width: var(--scroll-bar); height: var(--scroll-bar); }
  ::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: var(--track); border-radius: var(--radius-pill); }
  ::-webkit-scrollbar-thumb { min-width: var(--target); min-height: var(--target); background: var(--line); border: var(--scroll-bar-edge) solid var(--track); border-radius: var(--radius-pill); }
  ::-webkit-scrollbar-thumb:is(:hover, :active) { background: var(--accent); }
}
@supports not selector(::-webkit-scrollbar) {
  * { scrollbar-color: var(--line) var(--track); }   /* Firefox: its bars can't be wider, but they take the palette's colors */
}

/* ---------- base ---------- */
html {
  min-height: 100%;
  font-size: var(--root-size);
  touch-action: manipulation; overscroll-behavior: none;   /* see Touch below */
  /* on html, not body with `fixed`: it covers the whole page, iOS Safari included */
  background: var(--sky-1) linear-gradient(160deg, var(--sky-1), var(--sky-2));
}
html.big-text { font-size: var(--root-size-big); }

/* Touch: a double tap never zooms and a pull never reloads, but a pinch still zooms (the viewport
   never sets user-scalable=no or maximum-scale, WCAG 1.4.4). touch-action combines down the tree,
   so the drag surfaces that say none or pan-y keep theirs. */
/* A long press on a card, tile or picture opens no copy or save menu and selects no text; a text
   field (the rider's name) stays selectable and editable. */
:where(button, summary, .card, .foe, .choice-tile, .arrow-tile, .scrapbook-box-sticker, .sticker, img, svg) {
  -webkit-touch-callout: none; user-select: none; -webkit-user-select: none;
}
:where(img) { -webkit-user-drag: none; }

body {
  margin: 0;
  /* the page's width, for the few rules that follow the window's (styles/screens.css: the tray stacks at
     900px). issue 474 task 18 adds #app's own container (app / size) for the 2 rules keyed on the height */
  container: page / inline-size;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font);
  color: var(--ink);
  line-height: var(--leading);
  overscroll-behavior: none;
}

.visually-hidden {
  position: absolute !important;
  width: var(--hairline); height: var(--hairline); margin: calc(var(--hairline) * -1); padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

:focus-visible { outline: var(--focus-width) solid var(--focus); outline-offset: var(--focus-offset); }
h1:focus, h2:focus { outline: none; }

#app {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: var(--space-4) max(var(--space-4), env(safe-area-inset-right)) max(var(--space-4), env(safe-area-inset-bottom)) max(var(--space-4), env(safe-area-inset-left));
}

/* what a search engine or a visitor without scripts sees; the app replaces it when it starts (index.html) */
.intro { min-height: var(--screen-h); display: flex; flex-direction: column; justify-content: center; text-align: center; }

/* ---------- type ---------- */
h1 { font-size: var(--h1); line-height: var(--leading-tight); margin: var(--space-1) 0 var(--space-3); }
h2 { font-size: var(--text-xl); line-height: var(--leading-tight); margin: 0 0 var(--space-3); }
h3 { font-size: var(--text-lg); line-height: var(--leading-tight); margin: var(--space-1) 0; }
p { margin: var(--space-2) 0; }
.with-pic { display: flex; align-items: center; gap: var(--space-2); }
.lede { color: var(--ink-soft); margin-top: 0; }
.hint { color: var(--ink-soft); font-size: var(--text-sm); }
kbd {
  font: inherit; font-size: var(--text-xs); font-weight: var(--weight-heavy);
  border: var(--border-1) solid currentColor; border-radius: var(--radius-xs); padding: 0 var(--space-1);
}

/* ---------- icons (ui/icons.js) ---------- */
.icon {
  display: inline-block; flex: none;
  width: var(--icon-md); height: var(--icon-md);
  margin-inline-end: var(--icon-gap);
  vertical-align: -0.25em;
}
.icon-sm { width: var(--icon-sm); height: var(--icon-sm); }
.icon-lg { width: var(--icon-lg); height: var(--icon-lg); }
.icon-xl { width: var(--icon-xl); height: var(--icon-xl); }
svg.icon-ui { fill: currentColor; }
img.icon-pic { object-fit: contain; }
.icon-text {
  width: auto; height: auto;
  font-family: var(--emoji); font-size: var(--icon-md); font-weight: var(--weight-body); line-height: 1;
  vertical-align: baseline;
}
.icon-text.icon-sm { font-size: var(--icon-sm); }
.icon-text.icon-lg { font-size: var(--icon-lg); }
.icon-text.icon-xl { font-size: var(--icon-xl); }
/* In flex rows the gap spaces the icon, not a margin */
:where(.btn, .btn-label, .stat, .field-row, .with-pic, .intent-bit, .hp-text, .shield, .chip, .card-cost,
  .arrow-tile, .arrow-tile-cost, .rainbow-label, .float, .sound-caption, .dialog-title) > .icon { margin: 0; }

/* ---------- controls ---------- */
button, select, input { font: inherit; color: inherit; }
button, select, summary, .card, .foe {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
button, .card, .arrow-tile { user-select: none; -webkit-user-select: none; }

select, input[type="text"] {
  min-height: var(--target);
  padding: var(--space-1) var(--space-3);
  border: var(--border-1) solid var(--ink);
  border-radius: var(--radius-sm);
  background: var(--paper);
}
input[type="text"] { font-size: var(--text-lg); width: 100%; max-width: var(--name-w); }

/* Buttons (components.js btn / iconButton). Roles: go, secondary, quiet, remove,
   danger (and back, a secondary with the arrow); sizes: md, lg; icon buttons carry
   a caption. States: hover (mouse only), focus-visible, pressed (:active), toggled
   (aria-pressed), disabled. */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: var(--target); min-width: var(--target);
  padding: var(--space-1) var(--space-5);
  border: var(--border-1) solid var(--ink);
  border-radius: var(--radius-pill);
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--elev-1);
  font-size: var(--text-md); font-weight: var(--weight-bold); line-height: var(--leading-tight);
  text-align: center;
  transition: transform var(--dur-press), box-shadow var(--dur-press);
}
.btn-label { min-width: 0; }
.btn-go { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-quiet { background: transparent; border-color: var(--line); box-shadow: var(--elev-0); }
/* remove is undoable in one tap: the secondary look with its minus icon, never red */
.btn-remove { border-color: var(--ink); }
/* danger only appears inside confirm(): soft red with a red border, ink words, and the trash icon */
.btn-danger { background: var(--bad-soft); border-color: var(--bad); color: var(--ink); }
.btn-danger > .icon { color: var(--bad); }
/* A button that does a game verb at once (btn({ verb })): the verb's picture sits on a
   chip in the verb's soft color; the role keeps the button's own shape and fill */
.btn-verb > .icon:first-child { box-sizing: content-box; padding: var(--space-1); border-radius: var(--radius-round); background: var(--verb-soft); }
.btn-lg { min-height: var(--target-lg); padding-inline: var(--space-6); font-size: var(--text-lg); }
.btn-block { width: 100%; }
.btn:active:not(:disabled):not([aria-disabled="true"]) { transform: translateY(var(--press)); box-shadow: var(--elev-0); }
.btn[aria-pressed="false"] { background: var(--track); border-style: dashed; }
.btn:disabled, .btn[aria-disabled="true"] {
  background: var(--track); border-color: var(--ink-soft); border-style: dashed; color: var(--ink-soft);
  box-shadow: var(--elev-0);
}
.btn-icon {
  flex-direction: column; gap: 0;
  min-width: var(--target-lg);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-md);
  font-size: var(--text-xs); font-weight: var(--weight-heavy);
}
.btn-icon > .icon { width: var(--icon-btn); height: var(--icon-btn); }
/* Words give way to icons on a phone (design-ui.md "The rail"): a button with an icon (btn-pic, an icon button's
   caption) shows only its icon, a target square at least; its words stay in the DOM, clipped, and its name is
   its aria-label. A btn-words button (End turn, a talk's answers, Start over) keeps its words. */
:root[data-layout=phone] .btn.btn-pic:not(.btn-words) { min-width: var(--target); padding-inline: var(--space-2); }
:root[data-layout=phone] .btn.btn-pic:not(.btn-words) > .icon { display: inline-block; margin: 0; }   /* its icon always shows (a row that gives words its room hides the icons of the others) */
:root[data-layout=phone] .btn.btn-pic:not(.btn-words) > .btn-label, :root[data-layout=phone] .btn-icon > .btn-caption, :root[data-layout=phone] .arrow-tile .arrow-tile-name { position: absolute; width: var(--hairline); height: var(--hairline); overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
/* ...and an arrow tile (the arrowTile contract) is its picture, its arrow and its cost: its name is
   clipped (its aria-label and title keep it), so no name breaks inside a small tile; an empty one is
   its dashed outline and its arrow */
:root[data-layout=phone] .arrow-tile { grid-template-rows: minmax(0, 1fr) var(--tile-text); }
:root[data-layout=phone] .arrow-tile .arrow-tile-icon .icon { width: calc(var(--tile) * 0.4); height: calc(var(--tile) * 0.4); }

/* A row of buttons: secondary first, primary last (right; on top when stacked) */
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--gap-targets); margin-top: var(--space-5); }
.actions-split { justify-content: space-between; }
.actions-center { justify-content: center; }
.actions-stack { flex-direction: column; align-items: stretch; margin-top: 0; }
.dialog .actions, .panel .actions { margin-top: var(--space-2); }

/* "New!" (components.js newMark): one mark wherever something waits for you, on its host's top
   right corner. Its sparkle and word carry it, never the gold alone; it twinkles gently (still in
   calm mode and with reduced motion) and never takes a tap from its host. */
:where(.has-new) { position: relative; }   /* a host that has its own position keeps it */
.new-mark {
  position: absolute; top: var(--new-mark-out); right: var(--new-mark-out); z-index: 2;
  display: inline-flex; align-items: center; gap: var(--space-0);
  padding: var(--space-0) var(--space-2);
  border: var(--border-1) solid var(--ink); border-radius: var(--radius-pill);
  background: var(--new-bg); color: var(--new-ink); box-shadow: var(--elev-1);
  font-size: var(--text-xs); font-weight: var(--weight-heavy); line-height: var(--leading-tight); white-space: nowrap;
  pointer-events: none;
  animation: bob var(--dur-twinkle) ease-in-out infinite;
}
.new-mark > .icon { width: var(--icon-md); height: var(--icon-md); margin: 0; }

/* Checkbox rows and form rows (settings, the helper choice) */
.field-group { display: flex; flex-direction: column; gap: var(--space-1); }
.field-row {
  display: flex; align-items: center; gap: var(--space-3);
  min-height: var(--target);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  font-weight: var(--weight-semi);
}
.setting-elsewhere { margin: 0; color: var(--ink-soft); }   /* an adventure's setting, on the title: where it is */
.field-row.is-disabled { color: var(--ink-soft); }
.about-setting .hint { padding-inline: var(--space-2); }   /* in line with the switch's row above it */
.field-text { flex: 1 1 auto; min-width: 0; }
.check { flex: none; width: var(--check); height: var(--check); margin: 0; accent-color: var(--accent); cursor: inherit; }
/* a setting picked from a short list (settings.js choiceRow): its tiles under its icon and name */
.setting-choice { padding: var(--space-1) var(--space-2); }
.setting-choice legend { display: flex; align-items: center; gap: var(--space-3); font-size: var(--text-md); font-weight: var(--weight-semi); }

/* Stat pills: an icon, a number and a word (HUD, piles, the You panel) */
.stat {
  display: inline-flex; align-items: center; gap: var(--space-1);
  min-height: var(--chip-h);
  padding: 0 var(--stat-pad);   /* the same each side: the icon and number sit centred in the pill */
  border: var(--border-1) solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--paper);
  font-weight: var(--weight-heavy);
  white-space: nowrap;
}
.stat-word { font-size: var(--text-sm); font-weight: var(--weight-semi); color: var(--ink-soft); }

/* Callouts: a tinted box with a border that says what kind it is */
.callout { border: var(--border-1) solid; border-radius: var(--radius-md); padding: var(--space-2) var(--space-4); }
.callout-warn { background: var(--warn-soft); border-color: var(--warn); }
.field-row.callout { width: fit-content; max-width: 100%; margin: 0 0 var(--space-4); font-weight: var(--weight-bold); }

.panel {
  background: var(--panel);
  border: var(--border-1) solid var(--line-soft);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  box-shadow: var(--elev-1);
}
.row { display: flex; gap: var(--space-3); flex-wrap: wrap; align-items: center; }
/* ---------- the screen frame (ui/frame.js) ----------
   The top bar, the main pane and the footer: one width (#app), radius, border and elevation. */
/* Regions (.claude/reference/design-ui.md "Screen layout"): the page is the window's height, and each region is the
   height its screen says (a token: --region-h, set by frame.js), never its content's; the pane takes
   the room left (.region-fill) and scrolls inside itself if it must. Nothing in play moves an edge.
   With Bigger text on a small window the regions keep their sizes and the page may scroll. */
#app:has(> .frame) { display: flex; flex-direction: column; height: var(--screen-h); container: app / size; }   /* the one shell container (layout-system.md section 1): size, so only where the height is explicit (above); the title and the intro have auto height */
#app > .frame { flex: 1 1 0; min-height: 0; }
.region { flex: none; height: var(--region-h); min-height: 0; }
.region:not(.region-fill) { overflow: clip; }   /* sized to hold its content; nothing ever spills over a neighbour. It clips at its padding's edge in every engine (no overflow-clip-margin: Safari has none), so its padding holds a focus ring and a New! mark */
.frame-foot:has(> .tray) {
  overflow: visible; position: relative; z-index: 3;
  clip-path: inset(calc(var(--screen-h) * -1) 0);
}   /* the hand's footer clips only sideways: a lifted, focused or picked card (and the why note) stands over its top edge, in every engine. Its rows are fixed, so nothing else ever reaches past it */
.region-fill { flex: 1 1 0; min-height: var(--pane-min); overflow-y: auto; }   /* --pane-min: the screen's paneMin, set by frame.js */
.frame { display: flex; flex-direction: column; gap: var(--frame-gap); }
.frame-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-4);
  padding: var(--bar-pad);
  background: var(--bar-bg);
  border: var(--frame-border) solid var(--frame-line);
  border-radius: var(--frame-radius);
  box-shadow: var(--frame-elev);
}
.frame-top { margin-bottom: var(--frame-gap); }
/* the head: where you are, then the notice slot (its room kept whether or not a notice shows) */
.frame-head { flex-wrap: nowrap; }
.frame-head > .page-title { flex: 0 1 auto; flex-wrap: nowrap; min-width: 0; max-width: var(--head-title-max); --h1: var(--head-title); --title-pic: var(--head-pic); }
.frame-head .page-title-words { flex: 0 1 auto; }
.frame-head .page-title-text { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
.frame-notice { flex: 1 1 0; min-width: 0; height: var(--notice-h); display: flex; align-items: center; gap: var(--space-2); }
.frame-notice-empty { visibility: hidden; }
.frame-notice > .notice { flex: 1 1 auto; width: auto; height: 100%; padding: var(--space-1) var(--space-3); font-size: var(--text-sm); line-height: var(--leading); }
.frame-notice > .notice > span { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: var(--notice-lines); line-clamp: var(--notice-lines); overflow: hidden; }
.frame-notice > .notice-next { flex: none; height: var(--notice-h); }
.pane-card:has(> .map-area) { --pane-pad: var(--map-pane-pad); }
.frame-pane { display: flex; flex-direction: column; gap: var(--pane-gap); min-width: 0; }
.pane-card {
  padding: var(--pane-pad);
  background: var(--pane-bg);
  border: var(--frame-border) solid var(--frame-line);
  border-radius: var(--frame-radius);
  box-shadow: var(--frame-elev);
}
.pane-stage { position: relative; gap: 0; overflow: hidden; }   /* the stage is the pane: what pokes out of it is clipped, never scrolled; the over bar floats in it */
.pane-plain { text-align: center; }
/* the footer: the travel button's slot first, then the sign, the tray or a row of actions */
.frame-foot { justify-content: space-between; }
.frame-foot-empty { visibility: hidden; }   /* its room is kept, with nothing in it */
.frame-travel { flex: none; }
.frame-foot > .actions { flex: 1 1 auto; margin: 0; }
/* the go button is always at the right of its row, alone too (Done in every dialog, a footer's go) */
.actions-split > .btn-go:last-child { margin-inline-start: auto; }
.screen-nav { flex: none; }

/* pageTitle(): the picture and the words in one heading style on every screen */
.page-title { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-4); }
.page-title-words { flex: 1 1 14em; min-width: 0; }
.page-title h1 { margin: 0; }
.page-title .lede { margin: var(--space-1) 0 0; }
.page-title-pic { display: inline-grid; place-items: center; flex: none; width: var(--title-pic); height: var(--title-pic); }
.page-title-pic > * { width: 100%; height: 100%; margin: 0; object-fit: contain; }
.page-title .hear-it, .page-title-aside { flex: none; margin-left: auto; }
.frame-top > .page-title { flex: 1 1 14em; }   /* a title in the slim bar (battle), its tools at the end */

/* statusNote(): news about where you are, styled once; the tone backs up its icon and words */
.status-note {
  display: flex; align-items: center; gap: var(--space-2);
  width: fit-content; max-width: 100%; margin: 0;
  padding: var(--space-2) var(--space-4);
  border: var(--frame-border) solid var(--note-line);
  border-radius: var(--radius-md);
  background: var(--note-bg);
  font-weight: var(--weight-bold);
}
.status-good { --note-line: var(--good); --note-bg: var(--good-soft); }
.status-rest { --note-line: var(--calm); --note-bg: var(--calm-soft); }
.status-party { --note-line: var(--gold-deep); --note-bg: var(--gold-soft); }
.status-story { --note-line: var(--line-soft); --note-bg: var(--paper); font-weight: var(--weight-semi); }

/* Travel buttons (travelButton): where you're going, as a picture in a round window, the way
   you go (small, with its arrow) and the place's name (big), on the sea's blue */
.btn-travel {
  justify-content: flex-start; gap: var(--space-3);
  padding: var(--space-1) var(--space-5) var(--space-1) var(--space-1);
  background: var(--travel-soft); border-color: var(--travel);
  text-align: left;
}
.travel-pic {
  display: grid; place-items: center; flex: none;
  width: var(--travel-pic); height: var(--travel-pic);
  border: var(--frame-border) solid var(--travel); border-radius: var(--radius-round);
  background: var(--paper);
  overflow: hidden;
}
.travel-art { width: 80%; height: auto; }
.travel-words { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; }
.travel-way { display: inline-flex; align-items: center; gap: var(--space-1); font-size: var(--text-sm); font-weight: var(--weight-semi); color: var(--ink-soft); }
.travel-way > .icon { margin: 0; }
.travel-name { font-size: var(--text-lg); font-weight: var(--weight-heavy); }

/* Why something can't happen yet: shown next to it, not only said */
.why-note { display: flex; align-items: center; gap: var(--space-2); width: fit-content; max-width: 100%; margin: var(--space-2) auto; font-weight: var(--weight-bold); }

/* Choice tiles (choiceTile): big picture radios. Picked is a thick accent border,
   a check badge and a lift, never the tint alone */
.choice-tile {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: var(--target-xl, var(--target-lg));
  padding: var(--space-3);
  background: var(--panel);
  border: var(--border-2) solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--elev-1);
  text-align: center; font-weight: var(--weight-bold);
}
.choice-tile.picked { border: var(--border-3) solid var(--accent); box-shadow: var(--elev-2); transform: translateY(calc(var(--lift) * -2)); }
.create-step .choice-tile { border-width: var(--border-3); }
.create-step .choice-tile.picked { transform: none; }
.choice-tile:focus-within { outline: var(--focus-width) solid var(--focus); outline-offset: var(--focus-offset); }
.choice-radio { position: absolute; opacity: 0; pointer-events: none; }
.choice-badge { position: absolute; top: var(--space-1); left: var(--space-1); z-index: 1; }
/* Tabs (tabList): a row of them that wraps, each at least --tab-min-w (in rem, so it grows with
   Bigger text) and --target tall; the picture over the whole word, which wraps, never cut off */
.tab-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(var(--tab-min-w), 1fr)); grid-auto-rows: minmax(var(--target), auto); gap: var(--space-1); }
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; min-width: 0; padding: var(--space-1);
  border: var(--border-2) solid var(--line); border-radius: var(--radius-md); background: var(--paper); color: var(--ink);
  font: inherit; font-size: var(--text-xs); font-weight: var(--weight-bold); line-height: var(--leading-tight); text-align: center;
}
.tab > .icon { margin: 0; flex: none; }
.tab-word { display: block; max-width: 100%; }
.tab.is-on { border: var(--border-3) solid var(--accent); background: var(--accent-soft); box-shadow: var(--elev-1); }
.choice-check {
  position: absolute; top: calc(var(--space-2) * -1); right: calc(var(--space-2) * -1);
  display: grid; place-items: center;
  width: var(--icon-xl); height: var(--icon-xl);
  border-radius: var(--radius-round); background: var(--accent); color: var(--accent-ink);
}
.choice-check > .icon { margin: 0; }

/* Rainbow sequences: the logo letters and the rainbow meter share one color run */
.rainbow-seq > :nth-child(6n+1) { --seq: var(--rainbow-1); }
.rainbow-seq > :nth-child(6n+2) { --seq: var(--rainbow-2); }
.rainbow-seq > :nth-child(6n+3) { --seq: var(--rainbow-3); }
.rainbow-seq > :nth-child(6n+4) { --seq: var(--rainbow-4); }
.rainbow-seq > :nth-child(6n+5) { --seq: var(--rainbow-5); }
.rainbow-seq > :nth-child(6n+6) { --seq: var(--rainbow-6); }

/* Verbs (.claude/reference/design-ui.md "Verbs"): each verb's tone class gives its color (--verb, --verb-soft)
   and its feel class the way its floating number moves (see "motion"). VERBS in
   src/content/text.js names both for every verb; parts.js verbClass() applies them. */
.verb-damage { --verb: var(--verb-damage); --verb-soft: var(--verb-damage-soft); }
.verb-shield { --verb: var(--verb-shield); --verb-soft: var(--verb-shield-soft); }
.verb-heal { --verb: var(--verb-heal); --verb-soft: var(--verb-heal-soft); }
.verb-good { --verb: var(--verb-good); --verb-soft: var(--verb-good-soft); }
.verb-bad { --verb: var(--verb-bad); --verb-soft: var(--verb-bad-soft); }
.verb-draw { --verb: var(--verb-draw); --verb-soft: var(--verb-draw-soft); }
.verb-sparks { --verb: var(--verb-sparks); --verb-soft: var(--verb-sparks-soft); }
.verb-rainbow { --verb: var(--verb-rainbow); --verb-soft: var(--verb-rainbow-soft); }
.feel-bonk { --verb-feel: float-bonk; }
.feel-clink { --verb-feel: float-clink; }
.feel-rise { --verb-feel: float-rise; }

/* ---------- turn your phone sideways (ui/sideways.js) ---------- */
.sideways {
  width: min(var(--dialog-w), calc(100% - var(--space-6)));
  padding: var(--dialog-pad);
  color: var(--ink);
  background: var(--panel);
  border: var(--border-3) solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--elev-3);
  font-family: var(--font);
}
.sideways::backdrop { background: var(--backdrop); }
.sideways-card { display: flex; flex-direction: column; align-items: center; gap: var(--space-4); text-align: center; }
.sideways-title { margin: 0; }
.sideways-hint { margin: 0; font-size: var(--text-md); }
.sideways-pic { width: var(--sideways-pic); height: var(--sideways-pic); color: var(--accent); transform-origin: center; animation: sideways-turn var(--dur-turn) ease-in-out infinite alternate; }
@keyframes sideways-turn { from { rotate: 0deg; } 40% { rotate: 0deg; } to { rotate: -90deg; } }
html.calm .sideways-pic { animation: none; rotate: -90deg; }
@media (prefers-reduced-motion: reduce) { .sideways-pic { animation: none; rotate: -90deg; } }

/* ---------- terms: game words you can open (components.js termText) ---------- */
/* In the words, nothing changes size: a dotted line under the word, and a tap target of --target
   from its first letter that takes no room. The term is not its own containing block, so a row
   that clips its words to two lines (the ledger) doesn't clip the target; it lies over the rows
   beside it. A ledger row's own tap opens all its words too (termRow). */
.term {
  display: inline; margin: 0; padding: 0; border: 0; background: none;
  font: inherit; color: inherit; letter-spacing: inherit; text-align: inherit;
  text-decoration: underline dotted; text-decoration-thickness: var(--term-line); text-underline-offset: var(--term-line-gap);
}
/* what holds the target: the ledger's scroller (it clips it; a row and its words' line clamp don't,
   and the row stays its own height), a pop-up row, the reward's power line */
:where(.ledger-scroll, .verb-line, .new-power .special) { position: relative; }
button.term::before { content: ''; position: absolute; width: var(--target); height: var(--target); translate: 0 calc((var(--target) - 1lh) / -2); }
button.term[aria-expanded="true"] { background: var(--verb-soft, var(--accent-soft)); border-radius: var(--radius-xs); }
/* The bubble: over everything (the top layer), never taking a tap, so play goes on under it */
.term-tip {
  position: fixed; inset: auto; left: var(--tip-x, 0); top: var(--tip-y, 0); z-index: 40; margin: 0;
  display: none; flex-direction: column; gap: var(--space-2);
  width: max-content; max-width: min(var(--term-tip-w), calc(100vw - var(--term-tip-gap) * 2));
  padding: var(--space-2) var(--space-3);
  border: var(--border-2) solid var(--line); border-radius: var(--radius-md);
  background: var(--paper); color: var(--ink); box-shadow: var(--elev-2);
  font-family: var(--font); font-size: var(--text-sm); font-weight: var(--weight-semi); line-height: var(--leading-tight);
  pointer-events: none;
}
.term-tip:popover-open, .term-tip.is-open { display: flex; }   /* .is-open: a browser without popovers */
.term-tip-row { margin: 0; }
.term-tip-row .term-tip-pic { vertical-align: middle; margin-inline-end: var(--space-1); }
.term-tip-title { font-weight: var(--weight-heavy); }

/* ---------- dialog (ui/dialog.js) ---------- */
.dialog {
  width: min(var(--dialog-w), calc(100% - var(--space-6)));
  max-height: calc(100% - var(--space-6));
  overflow: auto;
  padding: var(--dialog-pad);
  color: var(--ink);
  background: var(--panel);
  border: var(--border-3) solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--elev-3);
  font-family: var(--font);
}
.dialog::backdrop { background: var(--backdrop); }
.dialog-title { display: flex; align-items: center; gap: var(--space-2); }
/* The header: the title, and the Close X at the top right of every dialog */
.dialog-header { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-3); }
.dialog-header .dialog-title { margin: 0; align-self: center; }
.dialog-close { flex: none; }
.confirm-text { font-size: var(--text-lg); margin: 0; }
/* A confirm's two answers sit side by side at every size: the danger answer at the start, Keep (go) at the end;
   their words wrap inside the button, never cut */
.confirm .actions-split { flex-wrap: nowrap; align-items: stretch; }
.confirm .actions-split > .btn { flex: 1 1 0; min-width: 0; }
.dialog-body { display: flex; flex-direction: column; gap: var(--space-3); align-items: stretch; }
/* A dialog's last row of buttons is its footer (settings, the places, the books): it stays in reach
   while the body scrolls, under the frame's line, like a screen's footer (caring for your horse too) */
:where(.place-dialog .dialog-body) > .actions:last-child {
  position: sticky; bottom: calc(var(--dialog-pad) * -1); z-index: 1;
  margin: 0 calc(var(--dialog-pad) * -1) calc(var(--dialog-pad) * -1);
  padding: var(--space-3) var(--dialog-pad) var(--dialog-pad);
  border-top: var(--frame-border) solid var(--line-soft);
  background: var(--pane-bg);
}

/* a phone's dialog scrolls: its title and Close stay in view while the body scrolls under them */
:root[data-layout=phone] .dialog-header {
  position: sticky; top: calc(var(--dialog-pad) * -1); z-index: 2;
  margin: calc(var(--dialog-pad) * -1) calc(var(--dialog-pad) * -1) var(--space-1);
  padding: var(--dialog-pad) var(--dialog-pad) var(--space-1);
  background: inherit;
}
:root[data-layout=phone] .dialog { width: 100%; max-width: none; height: 100%; max-height: 100%; border-radius: 0; margin: 0; }
/* a small dialog (the confirm, the notice) is a card over the dimmed screen on a phone: as tall as its content */
:root[data-layout=phone] .dialog.dialog-small { width: min(var(--dialog-w-lg), calc(100% - var(--space-6))); height: auto; max-height: calc(100% - var(--space-6)); border-radius: var(--radius-lg); margin: auto; }
/* A phone held sideways (a window under 421px tall): a dialog's chrome gives way so its
   body has room: less padding, a footer of --target buttons, no gap above it, a smaller house room */
:root[data-layout=phone] .house-dialog { --room-h: 4.5rem; --room-figure: 4rem; --room-thing: 1.5rem; --tile-house-h: var(--target-lg); }
:root[data-layout=phone] .town-place-screen .house-place-view { --room-h: 4.5rem; --room-figure: 4rem; --room-thing: 1.5rem; --tile-house-h: var(--target-lg); }
:root[data-layout=phone] .house-dialog .room-arrive { left: var(--space-3); translate: none; max-width: 42%; font-size: var(--text-sm); }   /* beside who is home, not over them */
:root[data-layout=phone] .town-place-screen .room-arrive { left: var(--space-3); translate: none; max-width: 42%; font-size: var(--text-sm); }
:root[data-layout=phone] .btn.house-tile.house-tile { flex-direction: row; justify-content: flex-start; gap: var(--space-3); padding-inline: var(--space-4); }   /* the picture beside its words, as on a phone held upright */
:root[data-layout=phone] .house-tile.house-tile > .icon { width: var(--icon-lg); height: var(--icon-lg); }
:root[data-layout=phone] .frame-foot > .actions > .btn-lg { font-size: var(--text-md); padding-block: 0; }   /* a footer's big button keeps two lines inside its row ("Ride to Magic Meadow Island!") */
:root[data-layout=phone] .sticker-tabs, :root[data-layout=phone] .book-tabs, :root[data-layout=phone] .book-chips { margin-bottom: var(--space-2); }
:root[data-layout=phone] .book-tab, :root[data-layout=phone] .book-chip { padding-inline: var(--space-3); }
:root[data-layout=phone] :where(.place-dialog .dialog-body) > .actions:last-child { margin-top: 0; padding-top: var(--space-2); bottom: 0; margin-bottom: 0; padding-block: 0; }
:root[data-layout=phone] :where(.place-dialog .dialog-body) > .actions:last-child .btn-lg { min-height: var(--target); }
/* a talk on a phone: styles/talk.css (its one phone block) */
/* a battle pop-up: the dialog never scrolls; the picture keeps its size and the lines take the rest and scroll */
.dialog.info-pop[open] { display: flex; flex-direction: column; overflow: hidden; }
.dialog.info-pop > .dialog-body { flex: 1 1 auto; min-height: 0; }
.dialog.info-pop .info-hero { flex: none; }
.dialog.info-pop .info-lines { flex: 1 1 auto; min-height: 0; overflow: auto; }
/* a battle pop-up (a status, a foe's move, a card): the picture in a column the window's height, beside the title
   and Close, the lines (they scroll in their own cell) and the buttons pinned under them */
:root[data-layout=phone] .dialog.info-pop.info-pop[open] { display: grid; grid-template-columns: var(--pop-pic-w) minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto; grid-template-areas: "hero head" "hero lines" "hero foot"; column-gap: var(--space-3); overflow: hidden; }
:root[data-layout=phone] .dialog.info-pop.info-pop > .dialog-body { display: contents; }
:root[data-layout=phone] .dialog.info-pop.info-pop > .dialog-header { grid-area: head; position: static; margin: 0; padding: 0; background: none; }
:root[data-layout=phone] .dialog.info-pop.info-pop .info-hero { grid-area: hero; }
:root[data-layout=phone] .dialog.info-pop.info-pop .info-lines { grid-area: lines; }
:root[data-layout=phone] .dialog.info-pop.info-pop .dialog-body > .actions:last-child { grid-area: foot; margin: 0; }
/* Grown-ups: the sheet is a grid; the 7 tabs are one row of icons with Close, and the page under them is the one scroller */
:root[data-layout=phone] .dialog.grown-ups[open] { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto minmax(0, 1fr); grid-template-areas: "tabs close" "panel panel"; column-gap: var(--space-2); row-gap: var(--space-2); overflow: hidden; align-content: stretch; }
:root[data-layout=phone] .dialog.grown-ups > :where(.dialog-header, .dialog-body) { display: contents; }
:root[data-layout=phone] .dialog.grown-ups .dialog-title { position: absolute; width: var(--hairline); height: var(--hairline); overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:root[data-layout=phone] .dialog.grown-ups .dialog-close { grid-area: close; min-width: var(--target); min-height: var(--target); }
:root[data-layout=phone] .dialog.grown-ups .dialog-body > div:has(> .grown-ups-tabs) { grid-area: tabs; min-width: 0; }
:root[data-layout=phone] .dialog.grown-ups .grown-ups-tabs { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: minmax(var(--target), 1fr); }
:root[data-layout=phone] .dialog.grown-ups .tab { padding-inline: 0; }
:root[data-layout=phone] .dialog.grown-ups .tab-word { position: absolute; width: var(--hairline); height: var(--hairline); overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:root[data-layout=phone] .dialog.grown-ups .grown-ups-panel { grid-area: panel; height: auto; min-height: 0; }
:root[data-layout=phone] .dialog.grown-ups .grown-ups-page-title { display: block; margin-top: 0; }
:root[data-layout=phone] .dialog.grown-ups .gate { gap: var(--space-1); }
:root[data-layout=phone] .dialog.grown-ups .gate-question { font-size: var(--text-xl); }
:root[data-layout=phone] .dialog.grown-ups .gate-answer { min-height: var(--target); font-size: var(--text-lg); }
:root[data-layout=phone] .dialog.grown-ups .grown-ups-slot { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: var(--space-2); padding-block: var(--space-1); }
:root[data-layout=phone] .dialog.grown-ups .grown-ups-slot > h3 { grid-column: 1; grid-row: 1; font-size: var(--text-sm); }
:root[data-layout=phone] .dialog.grown-ups .grown-ups-slot > .grown-ups-who { grid-column: 1; grid-row: 2; margin: 0; font-size: var(--text-sm); }
:root[data-layout=phone] .dialog.grown-ups .grown-ups-slot > .grown-ups-actions { grid-column: 2; grid-row: 1 / span 2; flex-wrap: nowrap; margin: 0; }
:root[data-layout=phone] .dialog.grown-ups .grown-ups-slot > :nth-child(n+4) { grid-column: 1 / -1; grid-row: auto; }

/* The phone class: a dialog with a pinned footer (Settings,
   a card, a place) draws its chrome thin so its body is at least 60% of it (issue 469, dialog-fit.spec.js): the
   header (title and the --target Close X) and the footer (Done, a --target button) keep their full targets and
   stay pinned, with no padding above or below them. It applies at every phone height. */
:root[data-layout=phone] .dialog:has(.dialog-body > .actions:last-child) { padding-block: 0; }
:root[data-layout=phone] .dialog:has(.dialog-body > .actions:last-child) > .dialog-header { top: 0; margin: 0 calc(var(--dialog-pad) * -1); padding: 0 var(--dialog-pad); }
:root[data-layout=phone] .dialog:has(.dialog-body > .actions:last-child) > .dialog-header > .dialog-close { width: var(--target); height: var(--target); min-width: 0; min-height: 0; }
:root[data-layout=phone] .dialog.settings-dialog { padding-block: 0; }
:root[data-layout=phone] .dialog.settings-dialog > .dialog-header { top: 0; margin: 0 calc(var(--dialog-pad) * -1); padding: 0 var(--dialog-pad); }
:root[data-layout=phone] .dialog.settings-dialog > .dialog-header > :is(.dialog-close, .grown-ups-button) { min-width: var(--target); min-height: var(--target); }
:root[data-layout=phone] .dialog.settings-dialog > .dialog-header > .dialog-close { width: var(--target); height: var(--target); }


/* The letter (ui/mail.js): the paper (3fr) beside what came with it (2fr), at every size class. The header and the
   buttons stay in view; the paper and the news scroll in their own cells, so focusing Put it away never scrolls the paper. */
.letter-dialog { width: min(var(--panel-wide), calc(100% - var(--space-6))); --letter-drawing: calc(var(--target-lg) * 2); }
:root[data-layout=phone] .letter-dialog { --letter-drawing: calc(var(--target-lg) * 1.5); }
.letter-dialog[open] { display: flex; flex-direction: column; overflow: hidden; }
.letter-dialog > .dialog-body {
  flex: 1 1 auto; min-height: 0; display: grid; column-gap: var(--space-4); row-gap: var(--space-2);
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); grid-template-rows: minmax(0, 1fr) auto; grid-template-areas: "paper came" "paper foot";
}
.letter-dialog > .dialog-body:not(:has(.letter-came)) { grid-template-columns: minmax(0, 1fr); grid-template-areas: "paper" "foot"; }
.letter-dialog .letter { grid-area: paper; overflow: auto; scrollbar-width: none; min-height: 0; align-content: start; }
.letter-dialog .letter-came { grid-area: came; overflow: auto; scrollbar-width: none; min-height: 0; display: grid; gap: var(--space-2); align-content: start; justify-items: center; }
.letter-dialog > .dialog-body > .actions { grid-area: foot; margin: 0; justify-content: flex-end; }


/* Settings (ui/settings.js): three pages behind tabs. One tree; the grid places it: the tabs at the top of the
   left column, Done pinned at its foot, the page beside them. Every page is one height, so nothing moves on a tab. */
.dialog.settings-dialog { width: min(var(--settings-dialog-w), calc(100% - var(--space-6))); }
.dialog.settings-dialog[open] { display: flex; flex-direction: column; overflow: hidden; height: min(var(--settings-dialog-h), calc(100% - var(--space-6))); }
:root[data-layout=phone] .dialog.settings-dialog[open] { height: 100%; }
.settings-dialog .dialog-header { justify-content: flex-end; align-items: center; flex: none; }
.settings-dialog .dialog-header .dialog-title { margin-inline-end: auto; }
.settings-dialog > .dialog-body { flex: 1 1 auto; min-height: 0; display: grid; grid-template-rows: minmax(0, 1fr); }
.settings-body {
  display: grid; min-height: 0; align-content: stretch; column-gap: var(--space-3); row-gap: var(--space-3);
  grid-template-columns: var(--settings-nav-w) minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: "tabs panel" "done panel";
}
.settings-tabs { grid-area: tabs; grid-template-columns: minmax(0, 1fr); align-content: start; }
.settings-tabs .tab { flex-direction: row; justify-content: flex-start; gap: var(--space-2); min-height: var(--target); padding-inline: var(--space-3); text-align: start; }
.settings-body > .actions { grid-area: done; align-self: end; margin: 0; }
.settings-body > .actions > .btn { flex: 1 1 auto; }
.settings-panel { grid-area: panel; min-height: 0; overflow: auto; padding: var(--space-1); }
.settings-panel:focus-visible { outline: var(--focus-width) solid var(--focus); outline-offset: var(--focus-offset); }
.settings-panel .sound-settings { border: 0; padding: 0; }
.settings-panel .option-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: var(--settings-tile-h); gap: var(--space-2); }
.settings-panel .setting-choice { padding: 0; }
.settings-panel .setting-choice + .setting-choice { margin-top: var(--space-1); }
.settings-panel .setting-choice legend { font-size: var(--text-sm); margin: 0 0 var(--space-1); }
.settings-panel .option-tile { flex-direction: row; justify-content: flex-start; gap: var(--space-2); padding: var(--space-1) var(--space-2); text-align: start; }
.settings-panel .option-tile .choice-art { width: auto; height: auto; }
.settings-panel .option-tile .choice-word { flex: 1 1 0; min-width: 0; line-height: 1.3; padding-block: var(--space-0); }
:root[data-layout=phone] .settings-body { grid-template-columns: var(--rail-1-w) minmax(0, 1fr); column-gap: var(--space-2); row-gap: var(--space-2); }
:root[data-layout=phone] .settings-tabs .tab { justify-content: center; padding-inline: 0; }
:root[data-layout=phone] .settings-tabs .tab-word { position: absolute; width: var(--hairline); height: var(--hairline); overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:root[data-layout=phone] .settings-body > .actions { justify-content: center; }
:root[data-layout=phone] .settings-body > .actions > .btn { flex: none; }
/* ---------- HUD (ui/hud.js) ---------- */
/* the HUD is the frame's top bar (.frame-bar); these are its own parts */
.hud-who { display: flex; align-items: center; gap: var(--space-2); min-width: 0; }
.hud-names { margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-stats { display: flex; flex-wrap: wrap; gap: var(--space-2); margin: 0; padding: 0; list-style: none; }
.hud-buttons { display: flex; gap: var(--gap-targets); margin-left: auto; }
.hud-place { display: none; }   /* where you are: shown only in the rail (a short window held sideways, below), where the head is not drawn */
.hud-notice { display: none; }   /* the head's notices behind a tap (ui/hud.js noticeButton): shown only in the rail (screens.css), where the head is not drawn */
/* The HUD is one row whatever the window or the text size, and it lays out by its OWN box: it is the
   container "hud", so only its parts answer (a container cannot style itself). Sizes are in rem, so
   Bigger text moves them. */
.hud { flex-wrap: nowrap; container: hud / inline-size; }
/* a box with room: your names give way ("Skye & Sun...") before anything wraps */
@container hud (min-width: 30rem) {
  .hud-who { flex: 0 1 auto; }
  .hud-stats { flex-wrap: nowrap; }
}
/* a tight box: Shine and Stickers leave */
@container hud (max-width: 26rem) {
  .hud-extra { display: none; }
}

/* Hover lifts only where there is a real mouse (they stick on touch screens). */
@media (hover: hover) {
  .btn:hover:not(:disabled):not([aria-disabled="true"]) { transform: translateY(calc(var(--lift) * -1)); box-shadow: var(--elev-2); }
  .btn-quiet:hover:not(:disabled) { background: var(--paper); }
  .field-row:not(.is-disabled):not(.callout):hover { background: var(--accent-soft); }
  .card:hover:not(.cannot):not(.still) { transform: translateY(calc(var(--card-lift) * -1)); }
}
/* Keyboard hints only where there is probably a keyboard. */
@media (pointer: coarse) {
  kbd, .keys-help, .card-key { display: none; }
}

/* ---------- title ---------- */
.title-screen { padding-top: var(--title-top); }
.title-screen > .frame-pane { --pane-gap: var(--title-gap); }
.logo { display: flex; align-items: center; justify-content: center; gap: var(--space-2); margin: 0; width: 100%; }
.tagline { position: relative; margin: 0; font-size: var(--text-lg); text-wrap: balance; }
.menu { max-width: var(--menu-w); margin: 0 auto; }
/* the main build's badge: words, small, centered under the menu */
.main-build-badge { margin: var(--space-2) auto 0; width: max-content; max-width: 100%; padding: var(--space-1) var(--space-3); border: var(--border-1) solid var(--line); border-radius: var(--radius-pill); font-size: var(--text-sm); font-weight: 700; }
/* Settings and For grown-ups: one row, centered, even a little wider than the menu (Bigger text); a phone stacks them */
.menu .actions-center { margin-top: 0; align-self: flex-start; width: max-content; flex-wrap: nowrap; position: relative; left: 50%; translate: -50%; }
.menu .actions-center > .btn { width: auto; white-space: nowrap; }

/* ---------- saves (ui/saved-cue.js, the title's adventure cards, ui/grown-ups.js) ---------- */
/* The "saved" horse: over the top bar's start corner (its picture), never over a footer's words or
   buttons (the ledger, a sign) and never in the way of a tap; still in calm mode */
.saved-cue {
  position: fixed; z-index: 30;
  left: max(var(--space-2), env(safe-area-inset-left)); top: max(var(--space-2), env(safe-area-inset-top));
  display: grid; place-items: center; box-sizing: border-box; width: var(--saved-cue-w); height: var(--saved-cue-w); padding: var(--space-2);
  background: var(--glass); border: var(--border-1) solid var(--line-soft); border-radius: var(--radius-round); box-shadow: var(--elev-1);
  opacity: 0; pointer-events: none;
}
/* on a phone every screen has a rail at the left (--rail-1-w, the battle's too): the horse lies just clear of it, over the pane's corner */
:root[data-layout=phone] .saved-cue { left: calc(var(--rail-1-w) + var(--space-2) + max(var(--space-0), env(safe-area-inset-left))); }
.saved-cue > .icon { width: var(--icon-xl-root); height: var(--icon-xl-root); margin: 0; }
.saved-cue.show { opacity: 1; animation: saved-cue var(--saved-cue-time) ease-in-out both; }
@keyframes saved-cue {
  0% { opacity: 0; transform: translateY(calc(var(--space-2) * -1)); }
  20%, 75% { opacity: 1; transform: none; }
  100% { opacity: 0; }
}

/* The save notice (ui/save-notice.js): a calm note for a grown-up over the page's bottom edge; no
   timer, and only the note itself takes taps, so play is never blocked */
.save-notice {
  position: fixed; z-index: 30; display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap;
  left: max(var(--space-4), env(safe-area-inset-left)); right: max(var(--space-4), env(safe-area-inset-right));
  bottom: max(var(--space-4), env(safe-area-inset-bottom)); max-width: var(--page-max); margin-inline: auto;
  box-shadow: var(--elev-1);
}
.save-notice > p { margin: 0; flex: 1 1 var(--save-notice-line); }

/* The title's adventure cards: the whole card is one big button (Keep playing, or a
   new adventure in an empty slot).
   The three slots are one grid: three equal columns where they fit, else one column, and every row
   as tall as the tallest card (grid-auto-rows: 1fr), so a card is the same size full, empty or
   just deleted, and a new "Oops!" under them never moves them. Where three fit is the slots'
   own width (a container query, so Bigger text counts): three cards (12rem each) and two gaps. */
.adventures { container-type: inline-size; width: 100%; margin: 0 auto; }
.adventure-cards {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(var(--slot-cols), minmax(0, 1fr)); grid-auto-rows: 1fr;
  gap: var(--gap-choices);
}
.adventure-cards > li { display: flex; min-width: 0; }
.adventure-card {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; align-items: center; gap: var(--space-2);
  min-height: var(--slot-card-min-h);
  padding: var(--space-4);
  background: var(--panel); color: var(--ink);
  border: var(--border-2) solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--elev-1);
  font-size: var(--text-md); line-height: var(--leading-tight); text-align: center;
  transition: transform var(--dur-press), box-shadow var(--dur-press);
}
.adventure-card:active { transform: translateY(var(--press)); box-shadow: var(--elev-0); }
.adventure-card .mount { --art-mount: var(--art-adventure); filter: var(--art-halo); }
.adventure-names { display: flex; flex-direction: column; align-items: center; gap: var(--space-1); }
.adventure-rider { font-size: var(--text-xl); }
.adventure-horse { display: inline-flex; align-items: center; gap: var(--space-1); font-weight: var(--weight-bold); color: var(--ink-soft); }
.adventure-stars { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: var(--space-1); }
/* one row of stars, one per island: each is --icon-lg at most and shrinks so the row never wraps
   (a second row would push Settings off the title with Bigger text, however many islands there are) */
.adventure-star-row { display: flex; flex-wrap: nowrap; justify-content: center; gap: var(--space-1); width: 100%; min-width: 0; }
.adventure-star-row .icon { flex: 0 1 var(--icon-lg); min-width: 0; width: auto; height: auto; aspect-ratio: 1; margin: 0; }
.adventure-stars-count { display: none; }
.star-waiting { filter: grayscale(1); opacity: 0.35; }
.adventure-stars-text { flex-basis: 100%; font-size: var(--text-sm); color: var(--ink-soft); text-align: center; }
.adventure-battle { display: inline-flex; align-items: center; gap: var(--space-1); font-weight: var(--weight-bold); }
.adventure-go {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  width: 100%; min-height: var(--target-lg); margin-top: auto; padding: 0 var(--space-5);
  background: var(--accent); color: var(--accent-ink); border: var(--border-1) solid var(--accent); border-radius: var(--radius-pill);
  font-size: var(--text-lg); font-weight: var(--weight-heavy);
}
.adventure-go > .icon { margin: 0; }
.adventure-new { justify-content: center; border-style: dashed; background: var(--glass); }
.adventure-new .adventure-go { background: var(--paper); color: var(--ink); border-color: var(--ink); }
.adventure-new-pic { color: var(--accent); }
.adventure-note { background: var(--warn-soft); border-color: var(--warn); font-weight: var(--weight-bold); }
@media (hover: hover) {
  .adventure-card:hover { transform: translateY(calc(var(--lift) * -1)); box-shadow: var(--elev-2); }
}
/* a save from a newer copy of the game: its note only, nothing to tap, so it never lifts */
.adventure-newer { justify-content: center; border-style: dashed; background: var(--glass); }
.adventure-newer:is(:hover, :active) { transform: none; box-shadow: var(--elev-1); }
/* On a phone, adventure cards become compact tiles. The title screen places the row; these rules
   own how each card and its parts fit inside it. */
:where(:root[data-layout=phone]) .adventure-card {
  display: flex; flex-direction: column; align-items: center; justify-content: space-between; position: relative;
  text-align: center; padding: var(--space-1) var(--space-2); gap: var(--space-1);
}
:where(:root[data-layout=phone]) .adventure-battle {
  position: absolute; top: var(--space-1); right: var(--space-1); justify-content: center;
}
:where(:root[data-layout=phone]) .adventure-card .mount { --art-mount: var(--art-cheer); grid-row: auto; }
:where(:root[data-layout=phone]) .adventure-names { align-items: center; min-width: 0; max-width: 100%; }
:where(:root[data-layout=phone]) .adventure-rider,
:where(:root[data-layout=phone]) .adventure-horse { max-width: 100%; overflow-wrap: anywhere; }
:where(:root[data-layout=phone]) .adventure-stars { justify-content: center; }
:where(:root[data-layout=phone]) .adventure-star-row,
:where(:root[data-layout=phone]) .adventure-stars-text,
:where(:root[data-layout=phone]) .adventure-go > .adventure-words,
:where(:root[data-layout=phone]) .adventure-battle > .adventure-words {
  position: absolute; width: var(--hairline); height: var(--hairline); overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
:where(:root[data-layout=phone]) .adventure-star-row { justify-content: flex-start; }
:where(:root[data-layout=phone]) .adventure-stars-text { font-size: var(--text-xs); text-align: left; }
:where(:root[data-layout=phone]) .adventure-stars-count {
  display: inline-flex; align-items: center; gap: var(--space-1); font-size: var(--text-sm); font-weight: var(--weight-bold); color: var(--ink-soft);
}
:where(:root[data-layout=phone]) .adventure-stars-count .icon { width: var(--text-md); height: var(--text-md); }
:where(:root[data-layout=phone]) .adventure-go {
  width: auto; min-width: calc(var(--target) * 0.75); min-height: calc(var(--target) * 0.75);
  margin-top: 0; padding: 0 var(--space-3); font-size: var(--text-md); white-space: nowrap;
}
:where(:root[data-layout=phone]) .adventure-new .adventure-go { width: 100%; }
:where(:root[data-layout=phone]) .adventure-note { justify-content: center; }
:where(:root[data-layout=phone]) .adventure-new-pic { display: block; }
/* 3 cards x 12rem + 2 x --gap-choices: CSS can't read a variable here */
@container (max-width: 38rem) {
  .adventure-cards { --slot-cols: 1; }
}

/* The Grown-ups area: the question, then one panel per slot */
.gate { display: flex; flex-direction: column; gap: var(--space-3); }
.gate-lead { height: var(--gate-lead-h); display: flex; align-items: center; }
.grown-ups-panel .gate-lead > p, .gate-lead > .why-note { margin: 0; }
.gate-question { margin: 0; font-size: var(--text-2xl); font-weight: var(--weight-heavy); text-align: center; }
.gate-answers { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: var(--gap-targets, var(--space-3)); }
.gate-answer { font-size: var(--text-xl); }
.grown-ups-slots { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-3); }
.grown-ups-slot h3, .grown-ups-backup h3 { margin: 0; }
.grown-ups-backup { margin-top: var(--space-3); }
.grown-ups-who { margin: var(--space-1) 0 var(--space-2); font-weight: var(--weight-semi); }
.grown-ups-actions { gap: var(--gap-targets, var(--space-3)); }
.about-update { align-items: center; gap: var(--space-3); }
.grown-ups-button { align-self: flex-start; }
.dialog.grown-ups { width: min(var(--dialog-w-lg), calc(100% - var(--space-6))); }
.grown-ups-tabs { --tab-min-w: var(--tab-min-w-wide); }
/* Every tab's page is one height and scrolls inside, so switching tabs never moves the dialog */
.grown-ups-panel { height: var(--grown-ups-panel-h); overflow: auto; overscroll-behavior: contain; padding: var(--space-1); }
.grown-ups-panel:focus-visible { outline: var(--focus-width) solid var(--focus); outline-offset: var(--focus-offset); }
.grown-ups-panel > :first-child { margin-top: 0; }
.grown-ups-panel h3 { margin: var(--space-4) 0 var(--space-1); }
.grown-ups-panel p { margin: var(--space-2) 0; }
.about-list { margin: var(--space-2) 0; padding-left: var(--space-5); display: flex; flex-direction: column; gap: var(--space-1); }
.about-links { flex-wrap: wrap; gap: var(--gap-targets, var(--space-3)); margin: var(--space-3) 0; }
.about-contact { margin-top: var(--space-6); padding-top: var(--space-4); border-top: var(--border-1) solid var(--line-soft); }
.about-touch { margin-top: var(--space-6); padding-top: var(--space-4); border-top: var(--border-1) solid var(--line-soft); }
.about-touch h2, .about-touch h3 { margin-top: 0; }
.about-touch-list { list-style: none; margin: var(--space-2) 0 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-3); }
.about-touch-list li { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-4); }
.about-touch-words { min-width: 7em; font-weight: 700; }
a.about-inline, .btn.about-inline { all: unset; display: inline; color: inherit; font: inherit; text-decoration: underline; padding-block: calc((var(--target) - 1lh) / 2 + var(--border-1)); cursor: var(--cursor-press); border-radius: var(--radius-sm); }
a.about-inline:focus-visible, .btn.about-inline:focus-visible { outline: var(--focus-width) solid var(--focus); outline-offset: var(--focus-offset); }
.link-button { text-decoration: none; max-width: 100%; }
.link-button .btn-label { overflow-wrap: anywhere; }

/* ---------- the grown-up pages on their own (tools/pages.js): about/, privacy/, terms/... ----------
   No script: the game's tokens, font, logo and buttons, one readable column. */
.doc-page { max-width: var(--measure); margin: 0 auto; padding: var(--space-5) var(--space-4) var(--space-6); }
.doc-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); }
.doc-logo { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; min-height: var(--target); text-decoration: none; border-radius: var(--radius-md); }
.doc-logo .logo { font-size: var(--text-doc-logo); }
.doc-subtitle { width: var(--doc-subtitle-w); height: auto; }
.doc-nav ul { list-style: none; margin: var(--space-4) 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--space-2); }
.doc-nav-link {
  display: inline-flex; align-items: center; gap: var(--space-1); min-height: var(--target); padding: 0 var(--space-3);
  border: var(--border-2) solid var(--line); border-radius: var(--radius-md); background: var(--paper);
  color: var(--ink); font-weight: var(--weight-bold); text-decoration: none;
}
.doc-nav-link[aria-current="page"] { border: var(--border-3) solid var(--accent); background: var(--accent-soft); box-shadow: var(--elev-1); }
.doc-main h1 { margin: 0 0 var(--space-2); font-size: var(--text-xl); }
.doc-main h2 { margin: var(--space-5) 0 var(--space-1); font-size: var(--text-lg); }
.doc-main p { margin: var(--space-2) 0; }
.doc-foot { margin-top: var(--space-4); font-size: var(--text-sm); text-align: center; }
/* The file input stays a real control (keyboard, screen readers); its label is the button you see */
.file-button { position: relative; min-height: var(--target); }
.grown-ups-page-title { display: none; }   /* a phone shows it (dialogs.css): its tabs are icons */
.file-button:focus-within { outline: var(--focus-width) solid var(--focus); outline-offset: var(--focus-offset); }
.file-input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; }

/* ---------- sound (ui/sound-controls.js) ---------- */
.sound-settings { border: var(--border-1) solid var(--line-soft); border-radius: var(--radius-md); padding: var(--space-1) var(--space-2) var(--space-2); margin: 0; }
.sound-settings legend { font-weight: var(--weight-bold); padding: 0 var(--space-2); }
.volume { display: grid; grid-template-columns: auto minmax(6em, auto) minmax(0, 1fr) 3.2em; }
.volume input[type="range"] { width: 100%; min-height: var(--target); margin: 0; accent-color: var(--accent); }
.volume-readout { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-soft); }
.sound-captions {
  /* just under the HUD buttons, top right */
  position: fixed; z-index: 20; top: calc(env(safe-area-inset-top) + var(--target-lg) + var(--space-5)); right: max(var(--space-4), env(safe-area-inset-right));
  list-style: none; margin: 0; padding: 0; display: flex; justify-content: flex-end; gap: var(--space-2);
  max-width: 70vw; pointer-events: none;
}
.sound-caption {
  display: inline-flex; align-items: center; gap: var(--space-1);
  background: var(--ink); color: var(--paper); border-radius: var(--radius-pill); padding: var(--space-0) var(--space-3);
  font-size: var(--text-sm); font-weight: var(--weight-bold); white-space: nowrap; animation: caption-in var(--dur-slide) ease-out;
}
@keyframes caption-in { from { opacity: 0; transform: translateY(calc(var(--space-2) * -1)); } }

/* ---------- create ---------- */
/* Color swatches (swatchPicker): round radio buttons; the picked one has a ring and a check */
.swatch-picker { border: 0; padding: 0; margin: 0 0 var(--space-5); text-align: center; }
.swatch-picker legend { font-weight: var(--weight-bold); font-size: var(--text-lg); margin: 0 auto var(--space-3); }
.swatch-picked { font-weight: var(--weight-body); }
.swatches { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--gap-targets); }
.swatch { position: relative; display: grid; place-items: center; width: var(--swatch-size); height: var(--swatch-size); }
.swatch-radio { position: absolute; opacity: 0; pointer-events: none; }
.swatch-dot {
  width: 100%; height: 100%;
  border-radius: var(--radius-round);
  background: var(--swatch);
  border: var(--border-1) solid var(--line);
  box-shadow: var(--elev-1);
}
.swatch.picked .swatch-dot { border: var(--border-3) solid var(--ink); box-shadow: 0 0 0 var(--border-2) var(--paper), 0 0 0 var(--border-3) var(--accent); }
.swatch-check {
  position: absolute; right: calc(var(--space-1) * -1); bottom: calc(var(--space-1) * -1);
  width: var(--swatch-badge); height: var(--swatch-badge); padding: var(--space-0);
  border-radius: var(--radius-round); background: var(--paper); color: var(--accent); border: var(--border-1) solid var(--accent);
}
.swatch:focus-within { outline: var(--focus-width) solid var(--focus); outline-offset: var(--focus-offset); border-radius: var(--radius-round); }
/* Option tiles (optionPicker): a radio group of big tiles under its legend, in place of a drop-down.
   Every tile of a picker is one size (--option-tile-w by --option-tile-h); words wrap to two lines */
.option-picker { border: 0; padding: 0; margin: 0; min-width: 0; }
.option-picker legend { font-weight: var(--weight-bold); font-size: var(--text-lg); margin: 0 0 var(--space-2); padding: 0; }
.option-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--option-tile-w)), 1fr)); grid-auto-rows: var(--option-tile-h); gap: var(--gap-targets); }
.choice-tile.option-tile { min-width: 0; min-height: var(--target); gap: var(--space-1); padding: var(--space-2) var(--space-1); font-size: var(--text-sm); line-height: var(--leading-tight); }
.option-tile .choice-art { flex: none; display: flex; justify-content: center; width: var(--option-pic-w); height: var(--option-pic-h); overflow: hidden; }
.option-tile .choice-word { flex: none; height: calc(1em * var(--leading-tight) * 2 + var(--border-1)); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; }

/* ---------- create steps (ui/screens/create/) ----------
   One decision per step, centered: [Back] the pips [Hear it], the question, the
   choice, and the go button at the bottom right (full width on phones). */
.create-nav { flex: 1 1 100%; display: grid; grid-template-columns: 1fr auto 1fr; grid-template-areas: "back pips hear"; align-items: center; gap: var(--space-3); }
.create-nav > .screen-nav { grid-area: back; justify-self: start; }
.create-hear { grid-area: hear; justify-self: end; }
.create-body { width: 100%; max-width: var(--measure); margin: 0 auto; }
.create-horse .create-body, .create-looks .create-body { max-width: none; }

/* Progress pips: each is a named 56px control; done ones are filled, this one has a ring,
   and steps not reached yet stay dashed and disabled. */
.step-pips { grid-area: pips; list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: var(--space-2); }
.step-pip {
  display: grid; place-items: center; flex: none;
  width: var(--target); min-width: var(--target); height: var(--target); min-height: var(--target); padding: 0;
  border: var(--border-1) dashed var(--line); border-radius: var(--radius-round);
  background: var(--panel); color: var(--ink-soft);
}
.step-pip > .icon { margin: 0; }
.step-pip > .btn-label { position: absolute; width: var(--hairline); height: var(--hairline); overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.step-pip-done { border-style: solid; border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.step-pip-now {
  width: var(--target); height: var(--target);
  border: var(--border-3) solid var(--accent); background: var(--paper); color: var(--ink);
  box-shadow: 0 0 0 var(--border-1) var(--paper), 0 0 0 var(--border-3) var(--accent-soft);
  font-size: var(--text-lg);
}

/* The choice grid: big tiles, centered rows */
.choice-grid { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--gap-choices, var(--space-4)); }
.choice-grid > .choice-tile { flex: 0 1 var(--pick-w); font-size: var(--text-lg); }
/* Horse choices stay in one row at a natural bounded height: picture, coat, card name and effect. */
.create-horse .create-body { flex: 1 1 0; min-height: var(--horse-min-h); display: flex; flex-direction: column; }
.create-horse .choice-grid { flex: 1 1 0; min-height: 0; flex-wrap: nowrap; justify-content: center; align-items: center; padding-inline: var(--space-1); }   /* the inline room is the pop's */
.create-horse .choice-grid > .choice-tile { flex: 1 1 0; min-width: 0; max-width: calc(var(--art-hero) + var(--space-3) * 2 + var(--border-3) * 2); container-type: inline-size; justify-content: center; height: min(100%, var(--horse-choice-h)); gap: var(--space-3); }
.create-horse .choice-art { display: flex; justify-content: center; width: 100%; min-height: 0; }
.create-horse .choice-pic { width: min(100cqi, var(--art-hero)); height: auto; }
.horse-card-rules { display: block; font-size: var(--text-sm); line-height: var(--leading-tight); }
.create-horse .choice-word { display: grid; width: 100%; gap: var(--space-1); justify-items: center; }
.create-horse .choice-name { width: 100%; padding-bottom: 0.15em; min-height: calc(var(--text-lg) * var(--leading-tight) * 2); overflow-wrap: normal; hyphens: manual; }
.create-horse .card-chip { box-sizing: border-box; flex-wrap: nowrap; justify-content: flex-start; width: 100%; height: calc(var(--icon-md) + var(--space-1) * 2 + var(--border-1) * 2); min-height: 0; margin: 0; }
.create-horse .card-chip > .icon { width: var(--icon-md); height: var(--icon-md); font-size: var(--icon-md); }
.create-horse .card-chip > span:not(.icon) { flex: 1 1 auto; min-width: 0; text-align: left; white-space: nowrap; }
/* want an easier ride?: the two tiles share the pane (side by side, the pane's whole room under the lede); the picture fills the tile's art box,
   which takes the room the word leaves, so it scales with the tile */
.create-easier .create-body { flex: 1 1 auto; min-height: 0; max-width: none; display: flex; flex-direction: column; }
.create-easier .choice-grid { flex: 1 1 auto; min-height: 0; flex-wrap: nowrap; align-items: stretch; }
.create-easier .choice-grid > .choice-tile { flex: 1 1 0; min-width: 0; min-height: var(--target); padding-block: var(--space-3); }
.create-easier .choice-art { position: relative; flex: 1 1 0; min-height: 0; width: 100%; }
.create-easier .easier-picture { position: absolute; inset: 0; display: grid; place-items: center; }
.create-easier .easier-picture .mount { --art-mount: min(var(--art-hero), 90cqi); }
.create-easier .choice-tile { container-type: inline-size; }
.easier-cue { position: absolute; right: var(--space-3); top: var(--space-3); display: flex; gap: var(--space-1); padding: var(--space-2); border-radius: var(--radius-pill); background: var(--paper); border: var(--border-2) solid var(--line); }
.choice-advance { font: inherit; font-weight: var(--weight-bold); color: var(--ink); }
.choice-advance:focus-visible { outline: var(--focus-width) solid var(--focus); outline-offset: var(--focus-offset); }
.choice-pic { width: var(--art-pick); }
.choice-name { display: block; line-height: var(--leading-tight); }
.choice-tile.just-picked { animation: pick-pop var(--dur-shake) ease-out; }
@keyframes pick-pop { 40% { transform: scale(1.08); } }
.card-chip {
  display: inline-flex; align-items: center; gap: var(--space-1);
  margin-top: var(--space-2); padding: var(--space-1) var(--space-2);
  border: var(--border-1) solid var(--line); border-radius: var(--radius-pill);
  background: var(--gold-soft); font-size: var(--text-sm);
}

/* Your look: your rider on the left (beside the tabs on a phone), never scrolled away; the tabs,
   then one tab's choices, which scroll inside their own room only past it (Bigger text) */
.create-preview { width: var(--art-preview, calc(var(--art-pick) * 1.6)); }
.create-looks .create-body { flex: 1 1 0; min-height: var(--looks-min-h); }
.create-looks { --swatch-size: var(--target); --option-tile-w: var(--look-tile-w); --option-tile-h: var(--look-tile-h); --option-pic-w: var(--look-pic-w); --option-pic-h: var(--look-pic-h); }
.looks {
  height: 100%; min-height: 0; display: grid; gap: var(--space-2) var(--space-5);
  grid-template-columns: var(--looks-preview-w) minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: "preview tabs" "preview panel";
}
.looks-preview { grid-area: preview; display: grid; place-items: center; min-height: 0; }
.looks-preview > .create-preview { width: var(--looks-preview-w); max-height: 100%; }
.looks-tabs { grid-area: tabs; grid-template-columns: repeat(var(--looks-tab-columns), minmax(0, 1fr)); }
.create-looks .looks-tabs .tab { border-width: var(--border-3); }
.looks-panel {
  grid-area: panel; display: flex; flex-wrap: wrap; align-content: flex-start; gap: var(--space-3) var(--space-5);
  min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 0 var(--space-2); justify-content: flex-start;
}
/* a color's swatches have the whole row; a part's tiles sit beside another's when both fit (--options: its tile count) */
.looks-panel > .swatch-picker { flex: 1 1 100%; min-inline-size: 0; margin: 0; }
.looks-panel > .look-view-whole { --option-tile-w: var(--look-clothes-w); }
.looks-panel > .option-picker { flex: 1 1 calc(var(--options, 1) * var(--option-tile-w) + (var(--options, 1) - 1) * var(--gap-targets)); }

.looks-panel legend { font-size: var(--text-md); margin: 0 var(--space-1) var(--space-1) 0; text-align: left; }
.looks-panel > .swatch-picker legend {
  display: block; width: 100%; min-width: 0;
}
.looks-panel .picker-name { display: block; width: 100%; min-width: 0; height: calc(var(--text-md) * var(--leading-tight)); text-align: left; white-space: nowrap; }
.looks-panel .swatch-picked { margin-top: var(--space-1); display: block; width: 100%; min-width: 0; height: calc(var(--text-md) * var(--leading-tight)); text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.looks-panel .picker-title { display: block; width: 100%; height: 100%; white-space: nowrap; }
.looks-panel .swatches { justify-content: flex-start; }
.looks-panel .swatch { flex: none; }
.create-looks .choice-tile.option-tile { box-sizing: border-box; }
.create-looks .looks-panel .swatches { margin-inline: 0; }
.looks-panel.more-down::after {
  content: ""; position: sticky; bottom: 0; z-index: 1; display: block; flex: none; grid-column: 1 / -1;
  width: 100%; height: var(--scroll-cue); margin-top: calc(var(--scroll-cue) * -1);
  background: linear-gradient(transparent, var(--pane-bg)); pointer-events: none;
}
.looks-panel:has(> .swatch-picker ~ .swatch-picker) { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--space-1) var(--space-3); }
.looks-panel:has(> .swatch-picker ~ .swatch-picker) > .swatch-picker { grid-column: 1; }
.looks-panel:has(> .swatch-picker ~ .swatch-picker) > .option-picker { grid-column: 2; grid-row: 1 / span 2; min-width: calc(var(--option-tile-w) * var(--options) + var(--gap-targets)); }
/* Every color palette uses the same swatch spacing. */
.looks-panel > .look-part-bodyStyle legend { margin-bottom: 0; }

.swatch-picker legend > .icon { margin-right: var(--space-1); }
/* a look's tile shows your head (look-view-head) or the whole of you (look-view-whole), from its part's `view` */
.look-view-head .choice-art { align-items: start; }
.look-view-head .look-tile-pic { width: 100%; }
.look-view-whole .look-tile-pic { height: 100%; width: auto; }

/* Names: the ideas, New ideas, and your own box, all centered. Naming your horse, your horse and its
   card stand in a column on the left, beside the rest, so the step fits the screen unscrolled */
.create-name .create-body:has(> .name-aside) {
  max-width: none; display: grid; gap: var(--space-3) var(--space-5); align-content: start;
  grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "aside ideas" "aside dice" "aside own";
}
.create-name .create-body > .name-aside { grid-area: aside; flex-direction: column; margin: 0; }
.name-aside .create-preview { width: var(--art-pick); }
.create-name .create-body:has(> .name-aside) > .name-ideas { grid-area: ideas; align-self: end; }
.create-name .create-body:has(> .name-aside) > .name-dice { grid-area: dice; margin: 0; }
.create-name .create-body:has(> .name-aside) > .name-own { grid-area: own; margin-top: 0; }
.name-aside { display: flex; align-items: center; justify-content: center; gap: var(--space-4); margin-bottom: var(--space-4); }
.name-aside-card { width: max(var(--art-pick), var(--card-w-sm), var(--name-caption-w)); max-width: 100%; display: flex; flex-direction: column; align-items: center; gap: var(--space-2); }
.name-brings { display: grid; margin: 0; font-size: var(--text-sm); line-height: var(--leading-tight); font-weight: var(--weight-bold); text-align: center; overflow-wrap: anywhere; }
.name-brings > span { grid-area: 1 / 1; align-self: center; }
.name-brings-room { visibility: hidden; }
.name-aside-chip { display: none; }
/* "a name first" floats over the foot of the pane (a tablet or desktop), in no room of its own */
:root:not([data-layout=phone]) .create-name > .frame-pane { position: relative; }
:root:not([data-layout=phone]) .create-name .create-why { position: absolute; left: 50%; translate: -50% 0; bottom: var(--space-1); z-index: 2; margin: 0; width: max-content; max-width: 100%; }
.name-ideas { display: flex; flex-wrap: wrap; justify-content: flex-start; gap: var(--gap-choices, var(--space-4)); padding: var(--space-2); border-radius: var(--radius-lg); }
.name-ideas > .choice-tile { border-width: var(--border-3); transform: none; flex: 1 1 0; min-width: var(--pick-w); font-size: var(--text-xl); }
.name-ideas .choice-word { max-width: 100%; overflow-wrap: anywhere; }
/* "Tap a name, or type your own": a gentle dashed ring around the ideas */
.name-ideas.needs-pick { outline: var(--border-2) dashed var(--warn); background: var(--warn-soft); }
.name-dice { display: flex; justify-content: center; margin-top: var(--space-3); }
.name-own { display: flex; flex-direction: column; align-items: center; gap: var(--space-2); max-width: var(--menu-w); margin: var(--space-4) auto 0; }
.name-own label { font-weight: var(--weight-bold); font-size: var(--text-lg); }
.name-box { display: flex; align-items: center; gap: var(--space-2); width: 100%; }
.name-box > .icon { margin: 0; }
.name-box input[type="text"] { flex: 1 1 auto; max-width: none; min-height: var(--target-lg); font-size: var(--text-xl); text-align: center; }

/* ---------- art: pictures from artFor() (.claude/reference/design-sound-art.md "Art") ---------- */
img.art { display: block; height: auto; max-width: 100%; user-select: none; -webkit-user-select: none; }
svg.rider-art { display: block; height: auto; max-width: 100%; overflow: visible; }
svg.horse-art { display: block; height: auto; max-width: 100%; overflow: visible; user-select: none; -webkit-user-select: none; }
svg.horse-art.horse-view { overflow: hidden; }   /* a part of the picture only (the rig's views) */
/* The horse rig (src/content/horse-art.js, ui/art.js): each part is a group that turns about its
   own pivot (--ox, --oy, set on it in the picture's units). An `alive` horse blinks, flicks an ear,
   swishes its tail and looks up now and then, each on its own clock; none of it moves in calm
   mode or with reduced motion (the end of this file). A screen turns the head (.looks-brush in
   the barn) and nods it (Web Animations, src/ui/screens/barn.js). */
.horse-art .horse-part { transform-box: view-box; transform-origin: var(--ox, 50%) var(--oy, 50%); }
.horse-art .horse-eye { transform-box: fill-box; transform-origin: center; }
.horse-art .horse-head, .horse-art .horse-pupil { transition: rotate var(--dur-turn) ease-in-out, translate var(--dur-turn) ease-in-out; }
.horse-alive .horse-tail { animation: horse-swish var(--dur-swish) ease-in-out infinite; }
.horse-alive .horse-ear { animation: horse-flick var(--dur-flick) ease-in-out infinite; }
.horse-alive .horse-eye { animation: horse-blink var(--dur-blink) linear infinite; }
.horse-alive .horse-head { animation: horse-look var(--dur-look) ease-in-out infinite; }
.looks-brush .horse-alive .horse-head { animation: none; rotate: var(--look-turn, 0deg); }
.horse-alive .tack-twinkle { transform-box: fill-box; transform-origin: center; animation: tack-twinkle var(--dur-twinkle) ease-in-out infinite alternate; }
@keyframes tack-twinkle {
  from { opacity: 0.55; scale: 0.7; }
  to { opacity: 1; scale: 1.1; }
}
.looks-brush .horse-art .horse-pupil { translate: var(--horse-pupil-back) 0; }
@keyframes horse-swish {
  0%, 40%, 100% { rotate: 0deg; }
  55% { rotate: 9deg; }
  70% { rotate: -5deg; }
  85% { rotate: 3deg; }
}
@keyframes horse-flick {
  0%, 88%, 100% { rotate: 0deg; }
  92% { rotate: -16deg; }
  96% { rotate: 4deg; }
}
@keyframes horse-blink {
  0%, 93%, 100% { scale: 1 1; }
  96% { scale: 1 0.1; }
}
@keyframes horse-look {
  0%, 35%, 75%, 100% { rotate: 0deg; }
  45%, 65% { rotate: -6deg; }
}
/* The dragon rig (src/content/dragon-art.js, src/dragon.js, ui/art.js): a foe drawn from parts on
   one skeleton. Each part turns about its own pivot (--ox, --oy); an `alive` dragon (in battle)
   swishes its tail, flaps its wings slowly and blinks, each on its own clock; none of it moves in
   calm mode or with reduced motion (the end of this file). */
svg.dragon-art { display: block; height: auto; max-width: 100%; overflow: visible; user-select: none; -webkit-user-select: none; }
.dragon-art .dragon-part { transform-box: view-box; transform-origin: var(--ox, 50%) var(--oy, 50%); }
.dragon-art .dragon-eye { transform-box: fill-box; transform-origin: center; }
.dragon-alive .dragon-tail { animation: dragon-swish var(--dur-dragon-swish) ease-in-out infinite; }
.dragon-alive :is(.dragon-wing, .dragon-wingFar) { animation: dragon-flap var(--dur-dragon-flap) ease-in-out infinite; }
.dragon-alive .dragon-wingFar { animation-delay: calc(var(--dur-dragon-flap) / -8); }
.dragon-alive .dragon-eye { animation: horse-blink var(--dur-dragon-blink) linear infinite; }
@keyframes dragon-swish {
  0%, 30%, 100% { rotate: 0deg; }
  50% { rotate: -7deg; }
  70% { rotate: 4deg; }
  85% { rotate: -2deg; }
}
@keyframes dragon-flap {
  0%, 100% { rotate: 0deg; }
  50% { rotate: -8deg; }
}

/* Re-skinned foes (src/foe-look.js, content/foe-tints.js): the picture a foe borrows, recolored by
   its tint (an SVG filter on the page, --look-tint), with its accent drawn over it at its place
   (--look-x, --look-y: its center; --look-size: its width). The box takes the picture's place. */
.art-look { position: relative; display: block; aspect-ratio: 1; max-width: 100%; user-select: none; -webkit-user-select: none; }
.art-look > .look-base { display: block; width: 100%; height: 100%; object-fit: contain; object-position: 50% 100%; filter: var(--look-tint, none); }
.art-look > .look-accent { position: absolute; left: var(--look-x); top: var(--look-y); width: var(--look-size); height: auto; translate: -50% -50%; overflow: visible; pointer-events: none; }
/* A new chapter's moment ("New islands appear!", screens/world-map.js): its picture, then its story */
.chapter-reveal-pic { display: flex; justify-content: center; }
.chapter-reveal-line { text-align: center; }
.look-tints { position: absolute; width: 0; height: 0; overflow: hidden; pointer-events: none; }

/* The colors you pick for your rider (src/content/rider-art.js SLOT), set on each picture */
.rider-art .rider-skin { fill: var(--skin); }
.rider-art .rider-hair { fill: var(--hair); }
.rider-art .rider-eyes { fill: var(--eyes); }
.rider-art .rider-top { fill: var(--top); }
.rider-art .rider-top-line { stroke: var(--top); }
.rider-art .rider-headwear { fill: var(--headwear, var(--top)); }
.rider-art .rider-headwear-line { stroke: var(--headwear, var(--top)); }
.rider-art .rider-pants { fill: var(--pants); }
.rider-art .rider-pants-line { stroke: var(--pants); }
/* Never wider than its column; the % in margin-top is the column width too, so the headroom matches */
.mount {
  --art-mount: var(--art-pair);
  --mount-w: min(var(--art-mount), 100%);
  position: relative; flex: none;
  width: var(--mount-w);
  margin-top: calc(var(--mount-w) * var(--rider-headroom));
}
.mount.hero-mount { --art-mount: var(--art-hero); }
.hud .mount { --art-mount: var(--art-hud); --mount-w: var(--art-mount); }   /* a fixed width: a % here made the bar wrap */
.mount-horse { width: 100%; }
.mount-rider { position: absolute; left: var(--seat-x); bottom: var(--seat-y); width: var(--rider-w); }
:is(img, svg).header-token { width: var(--art-heading); height: auto; flex: none; }
:is(img, svg, .art-look).level-foe { width: var(--art-inline); }


/* ---------- the create steps' rail: a steps screen on a phone ----------
   On a phone (html[data-layout=phone]) the steps' top bar and footer stand as one slim column at the left
   (--rail-1-w), as the framed screens' rail does (styles/screens.css): Back, Hear it, the step pips in a
   column, then Surprise me over Go, each a target square; the pane takes the page's height at the right.
   Keyed on the class, no size @media. */
/* the tokens, the grid and the seam are the framed rail's (styles/screens.css); the steps add what is in the bar */
:root[data-layout=phone] #app:has(> .frame[data-kind=steps]) {
  --pip-size: var(--steps-pip);   /* the pips, one small row over the pane's top */
}
:root[data-layout=phone] #app:has(> .frame[data-kind=steps]) > .frame-top { padding: var(--rail-pad); }
:root[data-layout=phone] .frame[data-kind=steps] > .region-foot { padding: var(--rail-pad); align-self: end; }
:root[data-layout=phone] .frame[data-kind=steps] > .region-foot.frame-foot-empty { display: none; }
:root[data-layout=phone] #app:has(> .frame[data-kind=steps]) > .frame-top .create-nav { display: flex; flex-direction: column; flex-wrap: nowrap; align-items: center; gap: var(--rail-gap); }
:root[data-layout=phone] #app:has(> .frame[data-kind=steps]) > .frame-top .create-nav > .screen-nav { order: 0; flex: none; }
:root[data-layout=phone] #app:has(> .frame[data-kind=steps]) > .frame-top .create-hear { order: 1; flex: none; }
:root[data-layout=phone] #app:has(> .frame[data-kind=steps]) > .frame-top .create-nav > .step-pips {
  order: 2; flex: none; position: absolute; top: var(--steps-pips-top); left: calc(var(--rail-1-w) + var(--space-0) + max(var(--space-0), env(safe-area-inset-left))); right: max(var(--space-0), env(safe-area-inset-right));
  height: auto; min-height: var(--target); flex-direction: row; justify-content: center; gap: var(--space-2); padding: 0; pointer-events: none; z-index: 1;
}
:root[data-layout=phone] #app:has(> .frame[data-kind=steps]) > .frame-top .step-pip-now { border-width: var(--border-2); box-shadow: none; }
:root[data-layout=phone] #app:has(> .frame[data-kind=steps]) > .frame-top .create-nav .btn { width: var(--rail-w); height: var(--rail-w); min-height: var(--rail-w); min-width: var(--rail-w); padding: 0; }
:root[data-layout=phone] .frame[data-kind=steps] > .region-foot .actions { flex-direction: column; align-items: stretch; flex-wrap: nowrap; gap: var(--rail-gap); margin: 0; width: 100%; max-width: none; }   /* Surprise me over Go */
:root[data-layout=phone] .frame[data-kind=steps] > .region-foot .actions .btn { flex: none; width: 100%; max-width: none; height: var(--rail-w); min-height: var(--rail-w); padding: 0; }
:root[data-layout=phone] #app:has(> .frame[data-kind=steps]) > .frame-top .create-nav > .step-pips > .step-pip {
  width: var(--target); min-width: var(--target); height: var(--target); min-height: var(--target); padding: 0;
  box-sizing: border-box; overflow: hidden; pointer-events: auto;
}

/* ---------- the create story: the picture beside the five lines ----------
   One tree. The pane is a size container; the hero (the island, you on your horse, the shooting star) is
   at the left and the lines at the right. The lines scale first (--story-line-scale, between --text-sm and the
   class's largest), then scroll inside their room (focusable, SCROLLS_INSIDE) as the last step. On a phone the
   rail shows Ride as the island's picture with its arrow; elsewhere Ride shows its words. */
.create-story .story-body { flex: 0 1 var(--story-content-h); width: 100%; margin-block: auto; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); column-gap: var(--space-4); align-items: stretch; container: story / size; }
.create-story .story-hero { position: relative; min-height: 0; min-width: 0; }
.create-story .story-island { position: absolute; inset: 0 0 auto 0; width: 100%; height: 70%; object-fit: contain; }
.create-story .story-mount { position: absolute; bottom: 0; left: 50%; translate: -50% 0; --art-mount: min(var(--art-hero), 100cqw, calc(100cqh * var(--hero-aspect))); }
.create-story .story-lines { min-height: 0; max-width: var(--measure); margin-inline: 0; display: flex; flex-direction: column; justify-content: safe center; overflow-y: auto; }
.create-story .story-line { flex: none; font-size: clamp(var(--text-sm), var(--story-line-scale), var(--text-lg)); margin: var(--space-1) 0; }
.create-story .ride-pic { display: none; }
:where(:root[data-layout=phone]) .create-story .story-body { grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); column-gap: var(--space-3); }
:where(:root[data-layout=phone]) .create-story .story-line { font-size: clamp(var(--text-sm), var(--story-line-scale-phone), var(--text-md)); margin: var(--space-0) 0; }
:where(:root[data-layout=phone]) .create-story > .frame-pane > .page-title { position: absolute; width: var(--hairline); height: var(--hairline); overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }   /* not drawn, still the heading */
:root[data-layout=phone] #app:has(> .frame.create-story) .region-foot .btn[data-focus=ride] { position: relative; overflow: hidden; }
:root[data-layout=phone] #app:has(> .frame.create-story) .region-foot .btn[data-focus=ride] > .ride-pic { display: grid; place-items: center; position: absolute; inset: 0; }
:root[data-layout=phone] #app:has(> .frame.create-story) .region-foot .btn[data-focus=ride] > .ride-pic > .travel-art { width: 80%; height: 80%; object-fit: contain; }
:root[data-layout=phone] #app:has(> .frame.create-story) .region-foot .btn[data-focus=ride] > .icon { position: absolute; right: var(--space-0); bottom: var(--space-0); width: var(--story-ride-arrow); height: var(--story-ride-arrow); }

/* The steps' pips on a phone sit as one small row over the pane's top on every step, at one size (the rail's row where they stood is empty);
   every step's pane keeps their room as its top padding (one rule; no step reserves it its own way). */
:root[data-layout=phone] .frame.create-step > .frame-pane { padding-top: calc(var(--steps-pips-top) + var(--steps-pips-h) + var(--space-0)); }

/* The question on tablet and desktop, short of height (a small tablet, 1024x600: #app's content under 640px; or Bigger text): it moves up
   into the slim bar beside the pips, one rule for every create step (a frame of the steps kind has the pips; the story has none and is not touched). Only the h1 moves (the pane's own title stays its box, so the lede stays in the
   pane and screen readers keep the heading). Fixed: #app (a size container) is its box, as the bar is, so the pane does not hold or clip it. */
@container app (max-height: 640px) {   /* --small-tablet-h */
  :root:not([data-layout=phone]) .frame.create-step[data-kind=steps] > .frame-pane > .page-title h1 {
    position: fixed; z-index: 4; top: calc(var(--space-1) + var(--frame-border) + var(--space-2)); height: var(--target); right: calc(50% + var(--steps-title-clear)); margin: 0;
    display: flex; align-items: center; justify-content: flex-end; text-align: right; --h1: var(--text-lg); max-width: calc(50% - var(--steps-title-clear) - var(--steps-back-w));
  }
  :root:not([data-layout=phone]) .frame.create-step[data-kind=steps] > .frame-pane > .page-title .page-title-pic { display: none; }
  :root:not([data-layout=phone]) .frame.create-step[data-kind=steps] > .frame-pane > .page-title:not(:has(.lede)) { margin-bottom: calc(var(--pane-gap) * -1); }   /* nothing left in the pane: no gap for it */
}
html.big-text:not([data-layout=phone]) .frame.create-step[data-kind=steps] > .frame-pane > .page-title h1 {
  position: fixed; z-index: 4; top: calc(var(--space-1) + var(--frame-border) + var(--space-2)); height: var(--target); right: calc(50% + var(--steps-title-clear)); margin: 0;
  display: flex; align-items: center; justify-content: flex-end; text-align: right; --h1: var(--text-lg); max-width: calc(50% - var(--steps-title-clear) - var(--steps-back-w));
}
html.big-text:not([data-layout=phone]) .frame.create-step[data-kind=steps] > .frame-pane > .page-title .page-title-pic { display: none; }
html.big-text:not([data-layout=phone]) .frame.create-step[data-kind=steps] > .frame-pane > .page-title:not(:has(.lede)) { margin-bottom: calc(var(--pane-gap) * -1); }
/* ---------- maps (ui/map-view.js, screens/world-map.js, screens/island.js) ---------- */
.map-area {
  position: relative; margin: 0;   /* relative: what floats over the map's window (ui/finds.js) */
  /* the map's width: as big as fits its window (the pane's width, the room's height), never under
     --map-min-w (worked out here, where the map's shape, --map-w and --map-h, is set) */
  --map-fit-w: max(var(--map-min-w), min(100%, calc(var(--map-room) * var(--map-w) / var(--map-h))));
}
.map-scroll {
  width: 100%;
  height: var(--map-room);   /* the window fills the pane: as tall as the room the screen leaves it */
  display: grid;   /* the map sits in its middle (margin: auto), on its own ground or sea (--map-fill) */
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;   /* a camera, not a page: it pans to your spot and to what has focus, and its edges fade where the map goes on (.claude/reference/design-ui.md "Scroll areas") */
  border-radius: var(--radius-md);   /* a window inside the pane's card */
  background: var(--map-fill);   /* the map's own ground or sea, past its sides where it is narrower than the pane */
  /* a side where the map goes on past its window fades out (ui/map-view.js markEdges) */
  --fade-left: 0%; --fade-right: 0%; --fade-top: 0%; --fade-bottom: 0%;
  mask-image:
    linear-gradient(to right, transparent, var(--mask-shown) var(--fade-left), var(--mask-shown) calc(100% - var(--fade-right)), transparent),
    linear-gradient(to bottom, transparent, var(--mask-shown) var(--fade-top), var(--mask-shown) calc(100% - var(--fade-bottom)), transparent);
  mask-composite: intersect;
}
.map-scroll.more-left { --fade-left: var(--map-edge-fade); }
.map-scroll.more-right { --fade-right: var(--map-edge-fade); }
.map-scroll.more-up { --fade-top: var(--map-edge-fade); }
.map-scroll.more-down { --fade-bottom: var(--map-edge-fade); }
/* the whole map fits its window, as big as it can (--map-fit-w), in its middle; a phone's pans */
.map { position: relative; width: var(--map-fit-w); margin: auto; aspect-ratio: var(--map-w) / var(--map-h); container-type: inline-size; }
.world-map { --map-fill: var(--sea-deep); }
.map-art { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.map-nodes { list-style: none; margin: 0; padding: 0; }

/* the picture: sea, shore, ground, roads (SVG widths are map units, so they scale with the map) */
.map-sea-light { stop-color: var(--sea-light); }
.map-sea-deep { stop-color: var(--sea-deep); }
.map-wave { fill: none; stroke: var(--sea-wave); stroke-width: 5; stroke-linecap: round; }
.map-compass circle { fill: none; stroke: var(--sea-wave); stroke-width: 4; }
.map-compass path { fill: var(--paper); stroke: var(--ink); stroke-width: 3; stroke-linejoin: round; }
.map-compass .map-compass-north { fill: var(--rainbow-1); }
.map-sky { fill: var(--stage-sky-top); }
.map-ground { fill: var(--stage-ground); }
.map-ground-spot { fill: var(--ground-spot); }
.map-shore { fill: var(--shore); stroke: var(--shore-foam); stroke-width: 6; }
.map-dock { fill: var(--dock); stroke: var(--ink); stroke-width: 4; stroke-linejoin: round; }
.map-dock-line { stroke: var(--ink); stroke-width: 2; opacity: 0.5; }
.map-boat-hull { fill: var(--boat); stroke: var(--ink); stroke-width: 4; stroke-linejoin: round; }
.map-boat-sail { fill: var(--paper); stroke: var(--ink); stroke-width: 3.5; stroke-linejoin: round; }
.map-boat-mast { stroke: var(--ink); stroke-width: 4; stroke-linecap: round; }
.map-path path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.map-path-edge { stroke: var(--road); stroke-width: var(--map-road-w); filter: drop-shadow(0 var(--map-road-shadow) 0 var(--road-edge)); }
.map-path-line { stroke: var(--road-dot); stroke-width: var(--map-dot-w); stroke-dasharray: 0 var(--map-dot-gap); }
.map-path.fog .map-path-edge { stroke: var(--fog-road); filter: none; }
.map-path.fog .map-path-line { stroke: var(--fog); stroke-dasharray: 4 var(--map-dot-gap); stroke-width: 6; }
.sea-route .map-path-edge { stroke: var(--sea-wake); filter: none; }
.sea-route .map-path-line { stroke: var(--paper); }
.map-path.reveal { animation: map-reveal var(--dur-pulse) ease-out both; }

/* spots: every one is a real button, placed by --x / --y (percent of the map) */
.map-node {
  position: absolute; left: var(--x); top: var(--y); translate: -50% -50%;
  z-index: 2;
  width: var(--map-node); height: var(--map-node); min-width: var(--target); min-height: var(--target);
  padding: 0;
  display: grid; place-items: center;
  border: var(--border-3) solid var(--ink); border-radius: var(--radius-round);
  background: var(--paper);
  box-shadow: var(--elev-1);
}
.map-node-face { width: 100%; height: 100%; border-radius: inherit; overflow: hidden; display: grid; place-items: center; }
:is(img, svg, .art-look).map-node-art { width: 80%; }
.map-badge, .map-prize {
  position: absolute; top: var(--map-badge-out);
  width: var(--map-badge); height: var(--map-badge);
  display: grid; place-items: center;
  background: var(--paper); border: var(--border-1) solid var(--ink); border-radius: var(--radius-round);
}
.map-badge { right: var(--map-badge-out); }
.map-badge.done { border-color: var(--gold-deep); }
.map-prize { left: var(--map-badge-out); border: var(--border-2) solid var(--power); }
.map-badge .icon, .map-prize .icon { width: 66%; height: 66%; margin: 0; }
/* a level won before (the replay ramp): its star badge grows a count, out over the edge (never the layout) */
.map-badge.tougher { width: auto; min-width: var(--map-badge); padding-inline: var(--space-1); grid-auto-flow: column; gap: var(--space-1); border-radius: var(--radius-pill); }
.map-badge.tougher .icon { width: calc(var(--map-badge) * 0.66); height: calc(var(--map-badge) * 0.66); }
.map-badge-count { font-size: var(--map-label-text); font-weight: var(--weight-heavy); line-height: 1; }
.map-label {
  position: absolute; top: calc(100% + var(--space-1)); left: 50%; translate: var(--label-anchor, -50%) 0;
  padding: 0 var(--space-2);
  white-space: nowrap; font-size: var(--map-label-text); font-weight: var(--weight-heavy); line-height: 1.5;
  background: var(--glass); border: var(--border-1) solid var(--line); border-radius: var(--radius-pill);
}
.map-label-note { display: block; font-weight: var(--weight-bold); font-size: max(0.85em, var(--text-floor)); text-align: center; }
/* states: never color alone. Done has a star, locked is dashed with a lock (and fog on
   the world map), open (not done yet) has a ring around it that gently pulses. */
.map-node.locked:not(.isle) { border-style: dashed; border-color: var(--line); background: var(--track); box-shadow: var(--elev-0); }
.map-node.locked .map-node-face, .map-node.locked .map-isle-face { filter: grayscale(0.7) opacity(0.55); }
.map-node.open:not(.isle)::after {
  content: ""; position: absolute; inset: var(--map-ring-gap);
  border: var(--border-2) solid var(--accent); border-radius: inherit;
  animation: map-pulse var(--ride-pulse) ease-in-out infinite;
}
.map-node.lair {
  width: var(--map-lair); height: calc(var(--map-lair) * 1.1);
  border-radius: 50% 50% var(--radius-sm) var(--radius-sm) / 45% 45% var(--radius-sm) var(--radius-sm);
  background: var(--gold-soft);
}
.map-node.lair :is(img, svg, .art-look).map-node-art { width: 92%; margin-top: 10%; }
.map-node.pop { animation: map-pop var(--dur-pop) var(--delay-pop) ease-out both; }
/* the critter hiding on an island (ui/critter.js): a small picture peeking over its cover (a bush,
   a rock, a shell), on a round hit area never under --target. The cover rustles now and then;
   hover or focus coaxes the critter up a little; found, it sits up beside its cover. */
.map-critter {
  position: absolute; translate: -50% -50%;
  left: clamp(calc(var(--map-critter-hit) / 2), var(--x), calc(100% - var(--map-critter-hit) / 2));   /* its hit area stays inside the map, so a focused one is always all in the window */
  top: clamp(calc(var(--map-critter-hit) / 2), var(--y), calc(100% - var(--map-critter-hit) / 2));
  z-index: 2;   /* over a spot's label, so a tap on the critter is never taken by a label beside it */
  width: var(--map-critter-hit); height: var(--map-critter-hit);
  padding: 0; border: 0; border-radius: var(--radius-round); background: none;
}
.map-critter-pic, .map-critter-cover { position: absolute; left: 50%; translate: -50% 0; display: grid; place-items: center; }
.map-critter-pic { width: var(--map-critter); bottom: 30%; translate: -50% 45%; transition: translate var(--dur-lift) ease-out; }
.map-critter-pic > img, .map-critter-pic > .icon { width: 100%; height: auto; margin: 0; filter: var(--art-halo); }
.map-critter-cover { width: var(--map-critter-cover); bottom: 8%; transform-origin: 50% 100%; animation: critter-rustle var(--critter-rustle) ease-in-out infinite; }
.map-critter-cover .icon { width: 100%; height: auto; margin: 0; filter: var(--art-halo); }
.map-critter:hover .map-critter-pic, .map-critter:focus-visible .map-critter-pic { translate: -50% 15%; }
.map-critter.found .map-critter-pic { translate: -20% -10%; scale: 1.3; }
.map-critter.found .map-critter-cover { translate: -85% 0; animation: none; }
.map-critter.peek .map-critter-pic { animation: critter-peek var(--dur-pop) ease-out both; }
@keyframes critter-rustle { 0%, 80%, 100% { rotate: 0deg; } 85% { rotate: -6deg; } 90% { rotate: 5deg; } 95% { rotate: -3deg; } }
@keyframes critter-peek { 0% { transform: translateY(40%) scale(0.6); } 55% { transform: translateY(-35%) scale(1.25); } 100% { transform: none; } }
/* little surprises on a map (ui/finds.js): a visitor drifting across, scenery to tap, treasure.
   Each is a round hit area (never under --target) around a small picture, placed by --x / --y
   like the spots; they float over the map and take no room. */
.map-find {
  position: absolute; left: var(--x); top: var(--y); translate: -50% -50%;
  z-index: 1;   /* under the spots (2): a visitor drifting by never blocks riding */
  width: var(--map-find-hit); height: var(--map-find-hit);
  display: grid; place-items: center;
  padding: 0; border: 0; border-radius: var(--radius-round); background: none;
}
.map-find.telling { z-index: 6; }   /* above place labels (up to 5) while its pickup bubble is showing */
.map-find .art, .map-find .icon { width: 100%; height: auto; margin: 0; filter: var(--art-halo); }
.map-visitor-pic, .map-secret-pic, .map-treasure-pic { width: var(--map-find); display: grid; place-items: center; }
.map-visitor-pic { width: var(--map-visitor); animation: find-flap var(--find-flap) ease-in-out infinite alternate; }
.map-visitor-pic.flip > * { transform: scaleX(-1); }
.map-visitor.caught .map-visitor-pic { animation: map-pop var(--dur-pop) ease-out both; }
@keyframes find-flap { from { translate: 0 calc(var(--map-find) * -0.12); } to { translate: 0 calc(var(--map-find) * 0.12); } }
/* a secret with its own picture moves as you tap it; one over the backdrop's picture glints now and then */
.map-secret-glint { width: var(--map-find-pop); opacity: 0; animation: find-glint var(--find-glint) ease-in-out infinite; }
.map-secret:hover .map-secret-glint, .map-secret:focus-visible .map-secret-glint { opacity: 1; animation: none; }
@keyframes find-glint { 0%, 88%, 100% { opacity: 0; scale: 0.4; } 94% { opacity: 1; scale: 1; } }
.map-secret.find-move-wiggle .map-secret-pic.tapped { animation: find-wiggle var(--dur-shake) ease-in-out both; }
.map-secret.find-move-boing .map-secret-pic.tapped { transform-origin: 50% 100%; animation: find-boing var(--dur-pop) ease-out both; }
@keyframes find-wiggle { 25% { rotate: -12deg; } 50% { rotate: 10deg; } 75% { rotate: -6deg; } }
@keyframes find-boing { 30% { scale: 1.2 0.7; } 60% { scale: 0.9 1.25; translate: 0 -30%; } 100% { scale: 1; translate: 0; } }
/* what pops out: it rests where it ends (calm mode keeps it there, still) */
.map-secret-pop { position: absolute; left: 50%; width: var(--map-find-pop); translate: -50% 0; pointer-events: none; }
.map-secret-pop.pop-up { bottom: 70%; animation: find-pop-up var(--dur-pulse) ease-out both; }
.map-secret-pop.pop-fall { top: 85%; animation: find-pop-fall var(--dur-grow) ease-in both; }
@keyframes find-pop-up { 0% { opacity: 0; transform: translateY(60%) scale(0.4); } 25% { opacity: 1; transform: none; } 75% { opacity: 1; } 100% { opacity: 0; transform: translateY(-40%); } }
@keyframes find-pop-fall { 0% { transform: translateY(-160%); } 70% { transform: translateY(8%); } 85% { transform: translateY(-12%); } 100% { transform: none; } }
.map-treasure-pic { animation: find-shine var(--ride-pulse) ease-in-out infinite alternate; }
@keyframes find-shine { to { scale: 1.12; } }
/* sparkles in town now and then (ui/sparkles.js): a little picture that twinkles where it fell;
   a missed one fades away softly (calm mode and reduced motion: it is just gone) */
.map-sparkle-pic { width: var(--map-find); display: grid; place-items: center; animation: find-twinkle var(--dur-twinkle) ease-in-out infinite alternate; }
@keyframes find-twinkle { from { scale: 0.92; rotate: -6deg; } to { scale: 1.1; rotate: 6deg; } }
.map-sparkle.fading { animation: find-fade var(--dur-sparkle-fade) ease-in both; }
@keyframes find-fade { to { opacity: 0; scale: 0.6; } }
.map-sparkle-told { pointer-events: none; }
/* the bubble beside what you found: a sticker, or a gift (below a visitor, which flies near the top) */
.find-bubble {
  position: absolute; left: 50%; bottom: 100%; translate: var(--label-anchor, -50%) 0; z-index: 3; pointer-events: none;
  display: flex; align-items: center; gap: var(--space-1);
  width: max-content; padding: var(--space-1) var(--space-2);
  border: var(--border-2) solid var(--ink); border-radius: var(--radius-pill);
  background: var(--paper); box-shadow: var(--elev-1);
  font-size: var(--text-sm); font-weight: var(--weight-heavy); color: var(--ink);
  animation: map-pop var(--dur-grow) ease-out both;
}
.find-bubble.side-left, .find-bubble.side-right { bottom: auto; top: 50%; }
.find-bubble.side-left { left: auto; right: 100%; translate: 0 -50%; }
.find-bubble.side-right { left: 100%; translate: 0 -50%; }
.find-bubble .icon { width: var(--map-find-chip); }
.find-bubble .sticker-art[data-size] { --sticker: var(--sticker-sm); --sticker-cut: var(--border-1); --size: var(--sticker-m); }
/* how many pieces of treasure toward the next set, over the top left of the map's window */
.map-treasure-count {
  position: absolute; z-index: 4; top: var(--space-2); pointer-events: none;
  left: calc((100% - min(100%, var(--map-fit-w))) / 2 + var(--space-2));   /* the map's left edge */
  display: flex; align-items: center; gap: var(--space-1); margin: 0;
  padding: var(--space-0) var(--space-2);
  border: var(--border-1) solid var(--line); border-radius: var(--radius-pill);
  background: var(--glass);
  font-size: var(--map-label-text); font-weight: var(--weight-heavy);
  animation: map-pop var(--dur-grow) ease-out both;
}
.map-treasure-count .art, .map-treasure-count .icon { width: var(--map-find-chip); height: auto; margin: 0; }
.map-treasure-count .sticker-art[data-size] { --sticker: var(--sticker-sm); --sticker-cut: var(--border-1); --size: var(--sticker-s); }

/* islands on the world map: the island's own picture is the button */
.map-node.isle {
  width: var(--map-isle); height: auto; aspect-ratio: 5 / 4;
  border: 0; border-radius: var(--radius-md); background: none; box-shadow: none;
}
.map-node.home-isle { width: var(--map-home-isle); }
/* an island with levels still to play glows (its label also shows how many are done) */
.map-node.isle.open:not(.done):not(.home-isle):not(.has-new)::after {   /* an unexplored island has the New! mark instead */
  content: ""; position: absolute; inset: 8% 0 4%;
  border: var(--border-2) dashed var(--paper); border-radius: 50%;
  animation: map-pulse var(--ride-pulse) ease-in-out infinite;
}
.map-isle-face { width: 100%; }
img.map-isle-art { width: 100%; }
.map-node.isle .map-badge { top: 0; right: 0; }
.map-node.isle .map-label { top: 92%; }

/* you on your horse, standing on your spot (the picture only; the button says "you are here") */
.map-token {
  --stand: calc(var(--map-node) / -2 + var(--map-token-sink));
  position: absolute; left: var(--x); top: var(--y); translate: -50% calc(-100% + var(--stand));
  z-index: 3;
  width: var(--map-rider);
  pointer-events: none;
  filter: var(--art-halo);
}
.map-token.on-lair { --stand: calc(var(--map-lair) * -0.55 + var(--map-token-sink)); }
.map-token.on-isle { --stand: calc(var(--map-isle) * 0.12); translate: calc(-50% + var(--map-isle) * 0.3) calc(-100% + var(--stand)); }
.map-token.on-home-isle { --stand: calc(var(--map-home-isle) * 0.1); translate: calc(-50% + var(--map-home-isle) * 0.05) calc(-100% + var(--stand)); }
.map-token-face.left { transform: scaleX(-1); }
.map-token .mount, .map-friends .mount { --art-mount: 100%; }
.map-token-boat { position: absolute; left: -12%; bottom: -14%; width: 124%; z-index: -1; opacity: 0; }

/* friends and horses at home */
.map-friends { position: absolute; left: var(--x); top: var(--y); width: 0; height: 0; z-index: 1; pointer-events: none; }
.map-friends-left, .map-friends-right { position: absolute; top: calc(var(--map-home-isle) * 0.05); display: flex; align-items: flex-end; gap: var(--space-0); }
.map-friends-left { right: calc(var(--map-home-isle) * 0.42); }
.map-friends-right { left: calc(var(--map-home-isle) * 0.42); }
.map-friends .mount, .map-friend-horse { width: var(--map-friend); max-width: none; filter: var(--art-halo); }
.map-friends-right > * { transform: scaleX(-1); }

/* the sign under the map: always --map-sign-h tall (the room is kept, so nothing that pops up in
   it moves the map), its words beside its go button. Why you can't go somewhere covers the words
   while it shows; words past the room are cut (they are in the spot's name too, read aloud),
   never pushing a button away. */
.map-sign { flex: 1 1 20em; display: flex; align-items: center; gap: var(--space-3); height: var(--map-sign-h); min-width: 0; }
.town-screen { --map-sign-h: var(--map-sign-h-town); }
.map-sign-text { position: relative; flex: 1 1 40%; align-self: stretch; display: flex; flex-direction: column; justify-content: safe center; min-width: 0; overflow: hidden; }
.map-sign-text > .why-note { position: absolute; inset: 0; width: auto; margin: 0; }
.map-sign-go { flex: 0 1 auto; min-width: 0; max-width: 50%; }
.map-sign-go .btn { max-width: 100%; font-size: var(--text-md); }   /* one size in every sign, so a long one (the resting fountain) still fits the kept room */
/* the town's sign: under the name, one line of room. A place's own line (the fountain's gift or
   its calm, a friend's "Come with me!", who is coming along) takes the place of its description;
   the town's news is above the map, never in the sign. Every line of words shows at most
   --map-sign-lines lines (all of it is in the spot's name, read aloud), so nothing is ever cut. */
.town-sign .map-sign-text { gap: var(--space-1); }
.town-sign .map-sign-text > * { margin: 0; }
.town-sign .map-sign-name { font-size: var(--text-lg); flex-wrap: nowrap; }   /* one line beside the go buttons, Bigger text too */
.town-sign .map-sign-text:has(> :not(.map-sign-name, .map-sign-about, .why-note)) > .map-sign-about { display: none; }
.town-sign .map-sign-text > p:not(.status-note), .town-sign .map-sign-text > .status-note > span {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: var(--map-sign-lines); line-clamp: var(--map-sign-lines); overflow: hidden;
}
/* a friend's house: "Come with me!" with how they help beside it, under the name */
.town-sign .map-sign-text > .buddy-note { padding-block: 0; font-size: var(--text-sm); }
/* the fountain's gift, right after a wish: it has the whole sign (you know where you are) */
.map-sign-text:has(> .wish-note) > .map-sign-name { display: none; }
.map-sign-text > .wish-note:has(+ .wish-note) { display: none; }   /* the splash is said aloud; the sign shows the gift */
.map-sign-text > .wish-note { margin: 0; padding-block: 0; font-size: var(--text-sm); }
.map-sign-name { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-2); margin: 0; }   /* one row where it fits: else its chips go under its words (a chip too long for a row ends in "...") */
.map-sign-state {
  display: block; flex: 0 1 auto; min-width: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;   /* a chip too long for its row ends in "..." (all of it is in the live region), never cut mid-word */
  padding: 0 var(--space-3);
  font-size: var(--text-sm); font-weight: var(--weight-bold);
  border: var(--border-1) solid var(--good); border-radius: var(--radius-pill); background: var(--good-soft);
}
.map-sign-state > .icon { display: inline-block; vertical-align: middle; margin-inline-end: var(--icon-gap); }
.map-sign-state.tougher { border-color: var(--gold-deep); background: var(--paper); }
.map-sign-foes { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-2); margin: var(--space-1) 0 0; }

@keyframes map-pulse { 50% { scale: 1.12; opacity: 0.4; } }
@keyframes map-pop { from { scale: 0.3; opacity: 0; } }
@keyframes map-reveal { from { opacity: 0; } }

/* ---------- story ---------- */
.story-lines { max-width: var(--measure); margin-inline: auto; }
.story-line { font-size: var(--text-lg); margin: var(--space-4) 0; }

/* ---------- shared bits the old home screen had (banners, notes, you by your horse, the deck) ---------- */
.level-prize { font-size: var(--text-sm); font-weight: var(--weight-semi); }
/* You standing in front of your horse, at the same scale as riding */
.beside { --beside-w: var(--art-pair); position: relative; flex: none; width: var(--beside-w); padding-left: calc(var(--beside-w) * var(--rider-stand-x)); box-sizing: content-box; filter: var(--art-halo); }
.beside-horse { width: 100%; }
.beside-rider { position: absolute; left: 0; bottom: 0; width: calc(var(--beside-w) * var(--rider-stand-w)); }
.special { font-weight: var(--weight-semi); }
details summary { display: flex; align-items: center; gap: var(--space-2); min-height: var(--target); font-weight: var(--weight-bold); font-size: var(--text-lg); }
.deck { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-top: var(--space-3); }

/* ---------- the town: Magic Meadow (screens/home.js, ui/places.js) ----------
   Sizes are shares of the map box (cqw), so the town scales as one picture. */
.town-map {
  --map-fill: var(--town-grass);   /* what shows under and past the town is its own meadow */
  --map-place: 15cqw;            /* a place's picture (200x160 art) */
  --map-house: max(var(--target) * 1.25, 12cqw);   /* a friend's house: a little smaller, so a lane of them fits (never shorter than a tap target) */
  --town-fruit: 2.4cqw;          /* a glowing fruit on the Power Tree */
  --town-bud: 1.5cqw;            /* a fruit still to find: a little bud */
  --town-friend: 5cqw;           /* a friend on their horse, hanging out */
  --town-horse: 4.4cqw;          /* a horse grazing in the paddock */
  --roam-friend: 7.5cqw;         /* riding freely: a friend ambling about on their horse */
}
/* a place: its picture is the button, like an island on the world map */
.map-node.place { width: var(--map-place); height: auto; aspect-ratio: 5 / 4; border: 0; border-radius: var(--radius-md); background: none; box-shadow: none; }
.map-node.place.friend-house { width: var(--map-house); }
.map-node.place.place-round { width: var(--map-node); height: var(--map-node); aspect-ratio: 1; border: var(--border-3) solid var(--ink); border-radius: var(--radius-round); background: var(--paper); box-shadow: var(--elev-1); }
.map-place-face { position: relative; width: 100%; height: 100%; display: grid; place-items: center; }
.map-place-art { width: 100%; height: auto; filter: var(--art-halo); }
/* The Magic Meadow pictures (town places, the ground, scenery: data-art-kit, tools/icons.js) name
   palette roles, and --accent is also the page's own color: on them it is unset, so a picture keeps
   its own accent wherever it is drawn, unless its palette (or a door's color, inline) sets it */
[data-art-kit] { --accent: initial; }
.map-node.place:not(.place-round) .map-label { top: 92%; }
/* something is waiting there (a letter, a friend to meet, a new island): the New! mark on its corner */
.map-node .new-mark { top: 0; right: 0; }
.map-token.on-place { --stand: calc(var(--map-place) * 0.3); translate: calc(-50% + var(--map-place) * 0.4) calc(-100% + var(--stand)); }
/* the Power Tree's fruit: lit ones are big, in the power's color, with a light ring; buds are small and pale */
.place-fruits { position: absolute; inset: 0; pointer-events: none; }
.place-fruit {
  position: absolute; left: var(--fx); top: var(--fy); translate: -50% -50%;
  width: var(--town-bud); aspect-ratio: 1;
  border: var(--hairline) solid var(--ink); border-radius: var(--radius-round);
  background: var(--paper);
}
.place-fruit.lit { width: var(--town-fruit); border-width: var(--border-1); background: var(--power); box-shadow: 0 0 0 var(--border-2) var(--gold-soft); }
/* the paddock by the stable, and friends hanging out (pictures only; the words are on the places) */
.town-paddock, .town-friends { position: absolute; left: var(--x); top: var(--y); translate: -50% -50%; z-index: 1; pointer-events: none; }
.town-paddock { width: var(--map-place); }
.town-paddock-art { width: 100%; height: auto; display: block; }
.town-paddock-art + .town-paddock-art { position: absolute; inset: 0; }
.town-grazing { position: absolute; inset: 22% 8% 18%; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; }
.town-horse { width: var(--town-horse); filter: var(--art-halo); }
.town-grazing > :nth-child(even) { transform: scaleX(-1); }
.town-friends { display: flex; align-items: flex-end; gap: var(--space-0); }
.town-friends .mount { --art-mount: 100%; width: var(--town-friend); filter: var(--art-halo); }
.town-friends > :nth-child(even) { transform: scaleX(-1); }
/* riding freely (ui/roam-view.js): a window onto the town (all of it on a big screen, following
   you on a phone), the rider and friends placed by --rx/--ry (in cqw of the town, so nothing is
   measured to draw them), and the camera by --cam-x/--cam-y. Press anywhere to ride there. */
.roam-area { container-type: inline-size; }   /* the town's window is sized from its width (100cqw) */
.roam-view {
  --view-h: var(--map-room);   /* the window fills the pane: the pane's width, and the room the screen leaves it */
  position: relative;
  width: 100cqw;
  height: var(--view-h);
  display: grid;   /* the town sits in its middle (margin: auto); one bigger than it (a phone) starts at its corner and the camera follows you */
  overflow: hidden;
  border-radius: var(--radius-md);   /* a window inside the pane's card, like the maps */
  background: var(--map-fill);   /* the town's own meadow: if the window is ever a frame ahead of the camera, grass shows, not a blue flash */
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.roam-world { width: max(var(--roam-min-w), min(100%, calc(var(--view-h) * var(--map-w) / var(--map-h)))); margin: auto; translate: var(--cam-x) var(--cam-y); will-change: translate; }
/* A place's label is never hidden by you or a friend riding past or standing at it: the place is
   centred on its spot by its list item (a 0x0 box: no translate on the button, which would make it
   a layer of its own), so its picture sits under the riders (2) and its label over them (4). */
.roam-spot { position: absolute; left: var(--x); top: var(--y); width: 0; height: 0; display: flex; align-items: center; justify-content: center; }
.roam-spot > .map-node { position: relative; left: auto; top: auto; translate: none; flex: none; z-index: auto; }
.roam-spot .map-place-face { z-index: 2; }
.roam-spot .map-label { z-index: 4; pointer-events: none; }   /* (a tap on it rides there, like any tap on the town: it never takes a tap meant for a place beside it) */
.roam-spot .map-node.here .map-label { z-index: 5; }   /* the place you stand at keeps its label on top of a neighbour's, where two houses' labels overlap on a small map */
.roam-rider, .roam-friend { left: 0; top: 0; will-change: translate; }
.roam-rider { translate: calc(var(--rx) * 1cqw - 50%) calc(var(--ry) * 1cqw - 100% + var(--map-token-sink)); }
.roam-friend {
  position: absolute; z-index: 2; width: var(--roam-friend);
  translate: calc(var(--rx) * 1cqw - 50%) calc(var(--ry) * 1cqw - 100%);
  pointer-events: none; filter: var(--art-halo);
}
.roam-friend .mount { --art-mount: 100%; }
.roam-rider.moving .map-token-face > .mount { animation: trot var(--trot-time) ease-in-out infinite; }
@keyframes trot { 50% { translate: 0 var(--trot-bob); } }
/* the big buttons for where you are: go in, or talk to the friend you rode up to. They pop up
   at the end of the sign in the footer, where every map's go button is, so they never cover the
   town; they share one row inside the sign's kept room (the pop is a scale: it takes no room) */
.roam-pop {
  display: flex; flex-wrap: nowrap; justify-content: flex-end; gap: var(--space-2);
  animation: map-pop var(--dur-grow) ease-out both;
}
.roam-pop > .btn { flex: 0 1 auto; min-width: 0; }
.roam-touch-help { display: none; text-align: center; margin: 0 0 var(--space-3); }
@media (pointer: coarse) {
  .roam-touch-help { display: block; }
}
/* the sign: the place's own button, and the shortcut (Set out!) beside it */
.wish-note { animation: map-pop var(--dur-grow) ease-out both; }
/* a wish on the fountain's spot: a shell arcs in, then sparkles splash up from the water. It ends
   hidden, so with calm mode (no animation) nothing shows and the sign's words carry it. */
.wish-toss { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.wish-shell, .wish-sparkle { position: absolute; left: 50%; top: 45%; translate: -50% -50%; opacity: 0; }
.wish-shell .icon, .wish-sparkle .icon { width: var(--icon-xl); height: var(--icon-xl); margin: 0; }
.wish-shell { animation: wish-shell var(--dur-pulse) ease-in both; }
.wish-sparkle {
  --turn: calc(var(--i) / var(--of) * 1turn - 0.25turn);
  animation: wish-sparkle var(--dur-burst) var(--delay-splash) ease-out both;
}
@keyframes wish-shell {
  0% { opacity: 1; transform: translate(-160%, -220%) rotate(-120deg) scale(1.2); }
  60% { opacity: 1; transform: translate(0, -40%) rotate(160deg) scale(0.9); }
  100% { opacity: 0; transform: translate(0, 10%) rotate(200deg) scale(0.3); }
}
@keyframes wish-sparkle {
  0% { opacity: 0; transform: rotate(var(--turn)) translateX(0) scale(0.4); }
  30% { opacity: 1; }
  100% { opacity: 0; transform: rotate(var(--turn)) translateX(160%) scale(1.1); }
}
/* a place's dialog */
.place-names { text-align: center; font-size: var(--text-lg); margin: var(--space-2) 0; }
.place-names .coat { color: var(--ink-soft); }
.place-count { display: flex; align-items: center; gap: var(--space-2); margin: 0; font-weight: var(--weight-bold); }

/* ---------- houses (ui/house.js; .claude/reference/design-world.md "Houses") ----------
   Your house and a friend's are one layout: a room (--room-h, the same in every house) drawn
   from its data (--wall, --floor, --door, --sky-top, --sky-bottom), who lives there standing on
   its floor, what they say as you come in over the wall, then the same-size tiles. A talk at a
   friend's house (.talk-scene.house-room) happens in the same room. */
.dialog.house-dialog, .dialog.talk { width: min(var(--dialog-w-lg), calc(100% - var(--space-6))); margin-top: var(--space-6); }
.house-room {
  position: relative; isolation: isolate; overflow: hidden;
  border: var(--border-2) solid var(--ink); border-radius: var(--radius-lg);
  background: linear-gradient(to bottom, var(--wall, var(--paper)) 0 68%, var(--floor, var(--track)) 68%);
}
.house-dialog .house-room { height: var(--room-h); flex: none; }
.room-backdrop { position: absolute; inset: 0; z-index: -1; pointer-events: none; }
/* the window: the owner's sky, with a cross of window bars */
.room-window {
  position: absolute; left: 5%; top: 10%; width: 17%; aspect-ratio: 1;
  border: var(--border-3) solid var(--paper); border-radius: var(--radius-sm); box-shadow: 0 0 0 var(--border-1) var(--ink);
  background:
    linear-gradient(var(--paper), var(--paper)) center / var(--border-2) 100% no-repeat,
    linear-gradient(var(--paper), var(--paper)) center / 100% var(--border-2) no-repeat,
    linear-gradient(var(--sky-top, var(--travel-soft)), var(--sky-bottom, var(--paper)));
}
/* a picture in a frame on the wall */
.room-picture {
  position: absolute; left: 27%; top: 30%; width: 13%; aspect-ratio: 5 / 4; overflow: hidden;
  display: grid; place-items: center;
  border: var(--border-3) solid var(--gold); border-radius: var(--radius-xs); background: var(--paper);
}
.room-picture-art { width: 100%; }
.room-picture-art > .icon { width: 70%; height: auto; }
/* the shelf with the owner's things on it */
.room-shelf {
  position: absolute; right: 20%; top: 30%;
  display: flex; align-items: flex-end; gap: var(--space-2); padding: 0 var(--space-2);
  border-bottom: var(--border-3) solid var(--ink-soft);
}
.room-thing { width: var(--room-thing); height: var(--room-thing); margin: 0; }
/* the door, in the owner's color, with its knob */
.room-door {
  position: absolute; right: 5%; bottom: 32%; width: 12%; height: 50%;
  border: var(--border-2) solid var(--ink); border-bottom: 0; border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  background: radial-gradient(circle at 20% 55%, var(--gold) 0 7%, transparent 8%), var(--door, var(--accent));
}
.room-rug {
  position: absolute; left: 20%; right: 20%; bottom: 5%; height: 20%;
  border-radius: var(--radius-round); background: color-mix(in srgb, var(--door, var(--accent)) 35%, var(--paper));
}
/* who lives there, standing on the floor */
.room-people {
  position: absolute; inset: auto 0 8% 0;
  display: flex; align-items: flex-end; justify-content: center; gap: var(--space-5);
}
.room-people .beside { --beside-w: var(--room-figure); }
.room-guest { width: calc(var(--room-figure) * var(--rider-stand-w)); filter: var(--art-halo); transform: scaleX(-1); }   /* you face your friend */
/* what they say as you come in: a bubble over the wall */
.room-arrive {
  position: absolute; left: 50%; top: var(--space-3); translate: -50% 0; z-index: 1;
  max-width: 60%; margin: 0; padding: var(--space-1) var(--space-3);
  border: var(--border-2) solid var(--ink); border-radius: var(--radius-lg); background: var(--paper); box-shadow: var(--elev-1);
  font-weight: var(--weight-bold); text-align: center; line-height: var(--leading-tight);
}
.house-about { display: grid; align-content: center; min-height: var(--target-lg); text-align: center; }
.house-about > * { margin: 0; }
.house-about .buddy-note { justify-content: center; }
/* the actions: same-size tiles in a fixed grid, their picture over their words */
.house-tiles { display: grid; grid-template-columns: repeat(var(--house-cols), minmax(0, 1fr)); grid-auto-rows: var(--tile-house-h); gap: var(--gap-targets); }
.btn.house-tile {
  height: var(--tile-house-h); min-width: 0; flex-direction: column; justify-content: center; gap: var(--space-1);
  padding: var(--space-2); border-radius: var(--radius-md); white-space: normal; text-align: center; line-height: var(--leading-tight);
}
.house-tile > .icon { width: var(--icon-xl); height: var(--icon-xl); margin: 0; flex: none; }
.house-tile > .btn-label { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }

/* ---------- the barn: caring for your horse (ui/barn.js; .claude/reference/design-features.md "Horse care") ----------
   A screen of its own: the barn gets the room the screen leaves it (--map-room, like a map's
   window; never under --barn-min-h): wooden walls, a window letting the sun in, your horse's card
   pinned on the wall, the stall with your horse in it, and its things along the front
   (--barn-front), each a button; under it a sign of one height (--barn-sign-h). The
   colors come from the Stable's data (--barn-*, --sky-*). Your horse walks across its stall
   (--hx, a share of the way; --face, 1 or -1 to turn) only above the front row, so it never
   covers a button; it wanders and swishes its tail with CSS, nods from script. Calm mode and
   reduced motion stop all of it (the end of this file): it stands, and only its face changes.
   The horse is where you brush (touch-action: none, so a finger brushes instead of scrolling). */
.barn-screen .frame-pane { display: flex; flex-direction: column; }
.barn {
  --barn-h: max(var(--barn-min-h), var(--map-room));
  --barn-front: calc(var(--tile-barn-h) + var(--space-3) * 2);   /* the front of the barn, where its things stand */
  --barn-floor-at: calc(100% - var(--barn-front) - var(--space-5));   /* where the wall meets the straw */
  --barn-stall-h: calc(var(--barn-h) - var(--barn-front));
  --barn-stall-room: calc(var(--barn-stall-h) - var(--border-2) * 2);   /* what is inside the barn's border: the room the bubble has above the things along the front */
  --barn-horse-h: calc(var(--barn-stall-h) * var(--barn-horse-share));   /* its card on the wall stays over it (z-index), so a tap on the card is always the card */
  --barn-horse-w: min(42%, calc(var(--barn-horse-h) * 1.2));         /* every horse picture is 240 by 200 */
  position: relative; isolation: isolate; overflow: hidden; flex: none;
  height: var(--barn-h);
  border: var(--border-2) solid var(--ink); border-radius: var(--radius-lg);
  background:
    linear-gradient(to bottom, transparent var(--barn-floor-at), var(--barn-floor, var(--gold-soft)) var(--barn-floor-at)),
    repeating-linear-gradient(to right, var(--barn-wall, var(--gold-soft)) 0 calc(var(--barn-plank) - var(--border-1)), var(--barn-seam, var(--line)) 0 var(--barn-plank));
}
.barn-backdrop { position: absolute; inset: 0; z-index: -1; pointer-events: none; }
.barn-backdrop > * { position: absolute; }
/* straw on the floor */
.barn-backdrop::after {
  content: ''; position: absolute; inset: var(--barn-floor-at) 0 0 0;
  background: repeating-linear-gradient(100deg, transparent 0 var(--space-3), var(--barn-straw, var(--gold)) 0 calc(var(--space-3) + var(--border-1)));
  opacity: 0.6;
}
/* a beam across the top */
.barn-rafter { left: 0; right: 0; top: 0; height: var(--space-4); background: var(--barn-rafter, var(--ink-soft)); border-bottom: var(--border-2) solid var(--ink); }
/* the window, with the sky through it, and the sunlight falling from it across the barn */
.barn-window {
  left: 6%; top: 14%; width: 14%; aspect-ratio: 1;
  border: var(--border-3) solid var(--barn-rafter, var(--paper)); border-radius: var(--radius-sm); box-shadow: 0 0 0 var(--border-1) var(--ink);
  background:
    linear-gradient(var(--barn-rafter, var(--paper)), var(--barn-rafter, var(--paper))) center / var(--border-2) 100% no-repeat,
    linear-gradient(var(--barn-rafter, var(--paper)), var(--barn-rafter, var(--paper))) center / 100% var(--border-2) no-repeat,
    linear-gradient(var(--sky-top, var(--travel-soft)), var(--sky-bottom, var(--paper)));
}
.barn-light {
  left: 6%; top: 14%; width: 60%; bottom: 0;
  clip-path: polygon(0 0, 23% 0, 100% 100%, 40% 100%);
  background: linear-gradient(to bottom right, var(--barn-light, var(--paper)), transparent);
  opacity: 0.7;
}
/* the stall: low boards with a rail, behind your horse */
.barn-stall {
  left: 22%; right: 2%; bottom: calc(100% - var(--barn-floor-at)); height: var(--barn-stall-rise);
  border: var(--border-2) solid var(--ink); border-bottom: 0; border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  background:
    linear-gradient(var(--barn-rafter, var(--ink-soft)), var(--barn-rafter, var(--ink-soft))) top / 100% var(--space-2) no-repeat,
    repeating-linear-gradient(to bottom, var(--barn-stall, var(--gold)) 0 calc(var(--space-4) - var(--border-1)), var(--barn-seam, var(--line)) 0 var(--space-4));
}
/* the barn's things (content/town.js `things`), each on its layer: on the wall behind your horse, or in front of it */
.barn-thing { position: absolute; left: var(--tx); top: var(--ty); width: var(--tw); pointer-events: none; }
.barn-thing[data-layer="back"] { z-index: 0; }
.barn-thing[data-layer="front"] { z-index: 2; }
.barn-thing-art { display: block; width: 100%; height: auto; }
/* your horse's card, pinned on the wall by the window: a button that shows it big */
.btn.barn-card {
  position: absolute; left: var(--cx); top: var(--space-4); z-index: 2;
  width: calc(var(--card-w-sm) * var(--barn-card-scale)); height: var(--barn-card-h); min-width: 0; min-height: 0; padding: 0;
  border: 0; border-radius: var(--radius-sm); background: none; box-shadow: var(--elev-1); rotate: -4deg;
}
.btn.barn-card > .btn-label { display: block; width: 100%; height: 100%; }
.barn-card .card { scale: var(--barn-card-scale); transform-origin: top left; pointer-events: none; }
/* what is happening, in a bubble at the top beside the card (the same as a house's): it never pushes
   anything, it is on top of everything in the barn (the tack chest too), and it stays in the stall,
   above the things along the front */
.room-arrive.barn-bubble {
  left: calc(var(--cx, 0%) + var(--card-w-sm) * var(--barn-card-scale) + var(--space-3)); right: var(--space-3); top: var(--space-4);
  translate: none; width: fit-content; max-width: none; max-height: calc(var(--barn-stall-room) - var(--space-4) - var(--space-2)); overflow: hidden;
  margin-inline: auto; pointer-events: none; z-index: 4;
}
/* your horse in its stall */
.barn-stall-floor { position: absolute; left: 0; right: 0; top: 0; bottom: var(--barn-front); pointer-events: none; }
.barn-horse {
  position: absolute; bottom: 0; left: calc((100% - var(--barn-horse-w)) * var(--hx, 0.5)); width: var(--barn-horse-w);
  scale: var(--face, 1) 1; z-index: 1;
  transition: left var(--dur-walk) ease-in-out, scale var(--dur-turn) ease-in-out;
}
/* a prop in the stall (content/town.js a tool's `stall`): it stands on the floor where your horse is at its tool, set off and sized from your horse */
.barn-prop { position: absolute; bottom: 0; left: calc((100% - var(--barn-horse-w)) * var(--px) + var(--barn-horse-w) * var(--pdx)); width: calc(var(--barn-horse-w) * var(--pw)); pointer-events: none; }
.barn-prop[data-layer="back"] { z-index: 0; }
.barn-prop[data-layer="front"] { z-index: 2; }
.barn-prop-art { display: block; width: 100%; height: auto; }
.barn-prop.is-used [data-art-layer="water"] { animation: barn-ripple var(--dur-ripple) ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes barn-ripple {
  0%, 100% { translate: 0 0; scale: 1 1; }
  50% { translate: 0 var(--ripple); scale: 1.02 0.96; }
}
.barn-wander { animation: barn-wander var(--dur-wander) ease-in-out infinite; transform-origin: 30% 100%; }
.barn-horse.is-busy .barn-wander, .barn-wander:has(.is-brushing) { animation-play-state: paused; }
@keyframes barn-wander {
  0%, 100% { translate: 0 0; rotate: 0deg; }
  20% { translate: var(--barn-wander) 0; rotate: 0deg; }
  32% { translate: var(--barn-wander) 0; rotate: -2deg; }
  44% { translate: var(--barn-wander) 0; rotate: 0deg; }
  70% { translate: calc(var(--barn-wander) * -1) 0; rotate: 1deg; }
  82% { translate: calc(var(--barn-wander) * -1) 0; rotate: 0deg; }
}
.care-stage {
  position: relative; display: block; pointer-events: auto;
  touch-action: none; user-select: none; -webkit-user-select: none;
  cursor: var(--cursor-grab);
}
.care-stage.is-brushing { cursor: var(--cursor-grabbing); }
.barn-body { position: relative; }
.care-horse { display: block; width: 100%; height: auto; filter: var(--art-halo); pointer-events: none; }
.care-mood {
  position: absolute; left: var(--mx); top: var(--my);
  display: grid; place-items: center;
  width: var(--care-mood); height: var(--care-mood);
  translate: -50% 0;
  border: var(--border-2) solid var(--ink); border-radius: var(--radius-round);
  background: var(--paper); box-shadow: var(--elev-1);
  pointer-events: none;
}
.care-mood > .icon { width: 80%; height: 80%; margin: 0; }
.care-bite {
  position: absolute; left: var(--tx); top: var(--ty);
  width: var(--care-bite); height: var(--care-bite);
  translate: -50% -50%; transform-origin: center;
  pointer-events: none;
}
.care-bite-pic { width: 100%; height: 100%; object-fit: contain; }
.care-sparkles { position: absolute; inset: 0; overflow: hidden; border-radius: var(--radius-lg); pointer-events: none; }
.care-sparkle { position: absolute; left: var(--sx); top: var(--sy); display: flex; font-size: var(--text-xl); translate: -50% -50%; }
.care-sparkle .icon { margin: 0; }
.care-brush-pic {
  position: absolute; left: var(--bx); top: var(--by);
  width: var(--care-brush); height: var(--care-brush);
  translate: -30% -70%;
  opacity: 0; pointer-events: none;
}
.care-stage.is-brushing .care-brush-pic { opacity: 1; }
.care-brush-pic > .art { width: 100%; height: 100%; }
/* the things along the front of the barn: one size, in one row, whatever they say */
.barn-tools {
  position: absolute; left: 0; right: 0; bottom: 0; height: var(--barn-front); z-index: 2;
  display: grid; grid-template-columns: repeat(var(--barn-cols), minmax(0, var(--barn-tool-w))); grid-auto-rows: var(--tile-barn-h);
  justify-content: space-evenly; align-content: center; gap: var(--barn-tool-gap); padding: 0 var(--space-3);
}
/* the treats sit in their bin: one column each, on a wooden crate */
.barn-bin {
  position: relative; grid-column: span var(--span); display: grid; grid-template-columns: subgrid; grid-auto-rows: var(--tile-barn-h);
  /* the padding is the tray's rim round its treat buttons; the equal negative margin keeps the buttons the size of the others in the row */
  padding: var(--bin-pad); margin: calc(var(--bin-pad) * -1);
  border-radius: var(--radius-md);
  background: linear-gradient(to top, var(--barn-stall, var(--gold)) 0 40%, transparent 40%);
  box-shadow: 0 0 0 var(--border-2) var(--barn-rafter, var(--ink-soft));
}
.btn.barn-tool {
  position: relative; height: var(--tile-barn-h); min-width: 0; flex-direction: column; justify-content: center; gap: var(--space-1);
  padding: var(--space-1) var(--space-2); border-radius: var(--radius-md); white-space: nowrap; line-height: var(--leading-tight);
}
.btn.barn-tool > .btn-label { display: flex; flex-direction: column; align-items: center; gap: var(--space-1); min-width: 0; max-width: 100%; }
.barn-tool-pic { display: block; width: var(--barn-tool-pic); height: var(--barn-tool-pic); margin: 0; object-fit: contain; }
.barn-tool-word { overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.barn-tool-done { position: absolute; top: var(--space-1); right: var(--space-1); display: inline-flex; color: var(--good); }
.barn-bin > .barn-tool-done { top: calc(var(--space-2) * -1); right: calc(var(--space-2) * -1); z-index: 1; border-radius: var(--radius-round); background: var(--paper); }
.barn-tool-done > .icon { margin: 0; }
/* the sign under the barn, one height: the brushing meter and the line about the bonus, then the pat */
.barn-sign { display: flex; align-items: center; gap: var(--space-3); height: var(--barn-sign-h); min-width: 0; max-width: 100%; flex: 1 1 auto; }
.barn-pat { flex: none; }
.barn-sign-text { display: flex; flex-direction: row; flex-wrap: nowrap; align-items: center; justify-content: safe center; gap: var(--space-4); min-width: 0; flex: 1 1 auto; overflow: hidden; }
/* the meters share the one line (their pips shrink); the bonus line has no room beside them: it is said aloud, not drawn */
.barn-sign-text > :is(.care-meter-row, .bond-row) { flex: 0 1 auto; }
.barn-sign-text > .care-status { position: absolute; width: var(--hairline); height: var(--hairline); margin: 0; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
/* a phone's meters, trick and pat (over the stall and along the front), drawn instead of the sign's, which is the other classes' */
.barn-tool-extras { display: contents; }
.barn-strip {
  display: flex; position: absolute; z-index: 3; pointer-events: none;
  left: var(--barn-strip-gap); top: calc(var(--barn-floor-at) - var(--barn-stall-rise)); translate: 0 -50%;   /* over the stall's top edge */
  flex-direction: row; align-items: center; gap: var(--space-2); padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-pill); background: var(--paper); box-shadow: var(--elev-1);
}
.care-meter-row { display: flex; align-items: center; gap: var(--space-2); justify-content: center; height: var(--barn-meter-h); flex: none; min-width: 0; max-width: 100%; font-weight: var(--weight-bold); white-space: nowrap; }
.care-meter { display: flex; gap: var(--space-1); min-width: 0; }
/* the pips and horseshoes shrink to share a narrow sign (a phone's, with Bigger text), never spilling out */
.care-pip { display: grid; place-items: center; width: var(--icon-lg); flex: 0 1 auto; min-width: 0; aspect-ratio: 1; border: var(--border-2) dashed var(--line); border-radius: var(--radius-round); }
.care-pip > .icon { width: 70%; height: 70%; margin: 0; opacity: 0.25; filter: grayscale(1); }
.care-pip.is-on { border-style: solid; border-color: var(--ink); background: var(--gold-soft); }
.care-pip.is-on > .icon { opacity: 1; filter: none; }
.barn-sign .care-status { margin: 0; text-align: center; line-height: var(--leading-tight); }
.barn-sign-buttons { display: flex; gap: var(--space-2); flex: none; }
/* your horse's bond: a horseshoe for each level, lit (solid, gold) once reached, a pale dashed one still to come */
.bond-row { display: flex; align-items: center; gap: var(--space-2); justify-content: center; flex: none; min-width: 0; max-width: 100%; font-weight: var(--weight-bold); white-space: nowrap; }
.bond-meter { display: flex; gap: var(--space-1); min-width: 0; }
.bond-shoe { display: grid; grid-template: minmax(0, 1fr) / minmax(0, 1fr); place-items: center; width: var(--bond-shoe); flex: 0 1 auto; min-width: 0; aspect-ratio: 1; border: var(--border-2) dashed var(--line); border-radius: var(--radius-sm); }
.bond-shoe .bond-shoe-pic, .bond-shoe .bond-shoe-pic > svg { display: block; width: 100%; height: 100%; min-width: 0; min-height: 0; margin: 0; }
.bond-shoe .bond-shoe-pic { opacity: 0.25; filter: grayscale(1); }
.bond-shoe.is-on { border-style: solid; border-color: var(--ink); background: var(--gold-soft); }
.bond-shoe.is-on .bond-shoe-pic { opacity: 1; filter: none; }
/* your horse's card, big, in a window that is short (a small tablet): it takes the room the dialog leaves it, so the dialog
   never scrolls and its title and Close stay whole (a phone's is a sheet: books.css) */
:where(:root:not([data-layout=phone])) .barn-card-dialog[open] { display: flex; flex-direction: column; }
:where(:root:not([data-layout=phone])) .barn-card-dialog > :is(.dialog-header) { flex: none; }
:where(:root:not([data-layout=phone])) .barn-card-dialog > .dialog-body { flex: 1 1 auto; min-height: 0; }
:where(:root:not([data-layout=phone])) .barn-card-dialog .card-big { flex: 1 1 var(--card-h-lg); min-height: 0; container-type: size; align-items: center; }
:where(:root:not([data-layout=phone])) .barn-card-dialog .card-big .card { --card-h: min(var(--card-h-lg), 100cqh); --card-w: calc(var(--card-h) * var(--card-w-lg) / var(--card-h-lg)); }
/* the treat your horse loves most wears a star */
.barn-favorite { position: absolute; top: var(--space-1); left: var(--space-1); display: inline-flex; }
.barn-favorite > .icon { margin: 0; }
/* a thing in the barn that opens something (the tack chest): its picture is the button, with its word under it */
.btn.barn-opener {
  position: absolute; left: var(--tx); top: var(--ty); z-index: 3;
  width: max(var(--tw), var(--barn-opener)); min-width: 0; min-height: var(--barn-opener); height: auto; padding: 0;
  border: 0; border-radius: var(--radius-md); background: none; box-shadow: none; color: var(--ink);
}
.btn.barn-opener > .btn-label { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; width: 100%; }
.barn-opener .barn-thing-art { width: 100%; height: auto; }
.barn-opener .barn-opener-room { visibility: hidden; }   /* the button is see-through: its picture is drawn on its layer, so your horse shows through */
.barn-opener-word {
  padding: 0 var(--space-2); border: var(--border-2) solid var(--ink); border-radius: var(--radius-pill);
  background: var(--paper); font-size: var(--text-sm); font-weight: var(--weight-bold); white-space: nowrap; box-shadow: var(--elev-1);
}
/* ---------- the tack room: dressing up your horse (ui/screens/tack-room.js; .claude/reference/design-features.md "The tack room") ----------
   A screen of its own like the barn: the room gets the room the screen leaves it (--map-room; never
   under --tack-min-h), so nothing in it grows or pushes the footer away. The mirror on the left (on
   top on a phone), the slots' tabs and the shelf beside it; the shelf scrolls inside its own room.
   Every tile is one size (--tack-tile, --tack-tile-h), whatever it says. */
.tack-screen .frame-pane { display: flex; flex-direction: column; }
.tack-room {
  height: max(var(--tack-min-h), var(--map-room));
  display: grid; gap: var(--space-3);
  grid-template-columns: var(--tack-mirror-w) minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: "tabs tabs" "mirror shelf";
}
.tack-room > .tack-tabs { grid-area: tabs; }
/* the tabs are always ONE row: a tab scales, then shows its icon only (the width below), and the row swipes sideways if it must */
.tack-tabs { container: tack-tabs / inline-size; grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: minmax(var(--target), 1fr); overflow-x: auto; scrollbar-width: none; }   /* a row you swipe: no bar */
.tack-tabs > .tab { position: relative; min-width: 0; }
/* narrower than 46rem (ten tabs of --tab-min-w, in rem so Bigger text follows): the words are not drawn (aria-label and read-aloud keep them);
   a phone's tabs are always icons only */
@container tack-tabs (max-width: 46rem) {
  .tack-tabs .tab-word { position: absolute; width: var(--hairline); height: var(--hairline); margin: 0; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}
:where(:root[data-layout=phone]) .tack-tabs .tab-word, :where(:root[data-layout=phone]) .tack-tile .choice-word { position: absolute; width: var(--hairline); height: var(--hairline); margin: 0; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.tack-room > .tack-mirror { grid-area: mirror; }
.tack-room > .tack-shelf { grid-area: shelf; }
.tack-mirror { position: relative; display: flex; flex-direction: column; gap: var(--space-2); min-height: 0; }
/* a mirror: a gold frame, a pale glass with a soft shine, your horse in it, mirrored */
.tack-mirror-frame {
  position: relative; display: grid; place-items: center; width: 100%; min-height: 0; flex: 1 1 auto; padding: var(--space-2);
  border: var(--border-3) solid var(--gold); border-radius: var(--radius-lg) var(--radius-lg) var(--radius-md) var(--radius-md);
  background: linear-gradient(135deg, var(--sky-1), var(--paper) 45%, var(--sky-2)); box-shadow: 0 0 0 var(--border-1) var(--ink), var(--elev-1);
  overflow: hidden;
}
.tack-mirror-frame > .tack-mirror-horse {
  position: absolute; left: var(--space-2); top: var(--space-2);
  width: calc(100% - var(--space-2) * 2); height: calc(100% - var(--space-2) * 2); max-width: none; scale: -1 1; filter: var(--art-halo);
}
.tack-mirror-big { height: var(--art-preview); }
/* a phone's sign, under the horse: the picked piece's name on one line, then its one button (drawn instead of the footer's sign, which is the other classes') */
.tack-pane-sign { display: flex; flex-direction: column; gap: var(--space-1); flex: none; min-width: 0; }
.tack-pane-name { margin: 0; font-size: var(--text-md); line-height: var(--leading-tight); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center; }
.tack-pane-sign > .actions { margin: 0; width: 100%; }
.tack-pane-sign .btn { width: 100%; height: var(--target); min-height: var(--target); padding-block: 0; }
.tack-mirror-words { margin: 0; text-align: center; }
.tack-mirror-frame > .tack-mirror-button { position: absolute; right: var(--space-1); bottom: var(--space-1); }
/* the mirror sheet on a phone: the horse in one column, the words and the buttons in the other, so nothing scrolls */
:where(:root[data-layout=phone]) .tack-mirror-dialog .dialog-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; align-items: center; column-gap: var(--space-3); row-gap: var(--space-2); }
:where(:root[data-layout=phone]) .tack-mirror-dialog .tack-mirror-frame { grid-area: 1 / 1 / 3 / 2; height: 100%; min-height: 0; }
:where(:root[data-layout=phone]) .tack-mirror-dialog .tack-mirror-words { grid-area: 1 / 2; align-self: center; }
:where(:root[data-layout=phone]) .tack-mirror-dialog .dialog-body > .actions:last-child { grid-area: 2 / 2; position: static; margin: 0; padding: 0; border-top: 0; background: none; }
/* a tablet's or laptop's: the horse shrinks to the room a short window leaves, so the words and Done stay in view (as the barn's card) */
:where(:root:not([data-layout=phone])) .tack-mirror-dialog[open] { display: flex; flex-direction: column; }
:where(:root:not([data-layout=phone])) .tack-mirror-dialog > .dialog-header { flex: none; }
:where(:root:not([data-layout=phone])) .tack-mirror-dialog > .dialog-body { flex: 1 1 auto; min-height: 0; }
:where(:root:not([data-layout=phone])) .tack-mirror-dialog .tack-mirror-big { flex: 0 1 var(--art-preview); height: auto; min-height: 0; }
.tack-shelf { min-height: 0; overflow-y: auto; padding: var(--space-1); }
.tack-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--tack-tile), 1fr)); grid-auto-rows: var(--tack-tile-h); gap: var(--space-2); }
.choice-tile.tack-tile {
  justify-content: flex-start; gap: var(--space-1); height: var(--tack-tile-h); min-width: 0; min-height: 0; padding: var(--space-2) var(--space-1);
  background: var(--paper); font-size: var(--text-sm); line-height: var(--leading-tight);
}
.tack-tile .choice-art { display: grid; place-items: center; width: var(--tack-tile-pic); height: var(--tack-tile-pic); flex: none; }
.tack-tile .choice-art > svg { width: 100%; height: 100%; }
.tack-tile .choice-word { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; text-overflow: ellipsis; }   /* two lines at most, then an ellipsis */
.tack-tile.is-later .choice-art { opacity: 0.55; filter: grayscale(0.6); }
.tack-tile.is-worn { border-color: var(--good); }
.tack-tile.is-trying { background: var(--accent-soft); }
.tack-badge {
  display: inline-flex; align-items: center; gap: var(--space-1);
  padding: 0 var(--space-1); border: var(--border-1) solid var(--ink); border-radius: var(--radius-pill); background: var(--paper);
  font-size: var(--text-xs); font-weight: var(--weight-bold); line-height: var(--leading-tight);
}
.tack-badge > .icon { margin: 0; }
/* a phone's tile: its picture, then its badge under it (an icon, or a price's number); the badge's words are the full words said aloud */
:where(:root[data-layout=phone]) .tack-tile .choice-badge { position: static; align-self: center; }
:where(:root[data-layout=phone]) .tack-badge-word { position: absolute; width: var(--hairline); height: var(--hairline); margin: 0; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.tack-badge.badge-worn > .icon { color: var(--good); }
.tack-badge.badge-shop { background: var(--gold-soft); }
/* the sign under the room: what you are trying on, and its one button (always there, one height,
   its room beside the way back: .claude/reference/design-ui.md "Screen layout") */
.frame-foot > .tack-sign { flex-basis: 0; }
.tack-sign { display: flex; align-items: center; gap: var(--space-3); height: var(--tack-sign-h); min-width: 0; max-width: 100%; flex: 1 1 auto; }
.tack-sign-text { flex: 1 1 auto; min-width: 0; overflow: hidden; }
.tack-sign-name { margin: 0; font-size: var(--text-lg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tack-sign-line { margin: 0; line-height: var(--leading-tight); }
.tack-sign > .actions { flex: none; margin: 0; }
/* new tack, as news (the reward screen, a letter): your horse wearing it, and its words */
.tack-news { display: grid; gap: var(--space-2); justify-items: center; }
.tack-news-item { display: flex; align-items: center; gap: var(--space-3); margin: 0; font-weight: var(--weight-bold); }
.tack-news-pic { display: grid; place-items: center; width: var(--tack-tile-pic); height: var(--tack-tile-pic); flex: none; border: var(--border-2) solid var(--gold); border-radius: var(--radius-md); background: var(--paper); }
.tack-news-pic > svg { width: 100%; height: 100%; }
.find-tack-pic { width: var(--icon-xl, 2em); height: var(--icon-xl, 2em); }
/* ---------- the Horse Show: copy the show horse's tricks (ui/screens/horse-show.js; .claude/reference/design-features.md "Horse Show") ----------
   The ring gets the room the screen leaves it (--map-room; never under --show-min-h): the two horses on
   the stage take what the pips and the tricks leave. Every pip's room is kept, lit or not, and every
   trick's tile is one size (--show-tile-h), so nothing moves as the show goes on. */
.show-screen .frame-pane { display: flex; flex-direction: column; }
.show-ring {
  height: max(var(--show-min-h), var(--map-room));
  display: grid; gap: var(--space-2); grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "stars pips" "stage stage" "tricks tricks"; grid-template-rows: auto minmax(0, 1fr) var(--show-tile-h);
  padding: var(--space-2); border: var(--border-3) solid var(--gold); border-radius: var(--radius-lg);
  background: linear-gradient(var(--sky-1), var(--paper) 60%, var(--gold-soft));
}
.show-stage { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); min-height: 0; }
.show-act { display: flex; flex-direction: column; align-items: center; gap: var(--space-1); min-height: 0; margin: 0; }
.show-act > .show-horse { flex: 1 1 auto; min-height: 0; width: 100%; filter: var(--art-halo); }
.show-ring > .show-ring-stars { grid-area: stars; align-self: center; }   /* the stars of mistakes: one copy, in the ring's top-left corner on every class */
.show-ring > .show-pips { grid-area: pips; justify-content: flex-end; }
.show-ring > .show-stage { grid-area: stage; }
.show-ring > .show-tricks { grid-area: tricks; }
.show-name { font-weight: var(--weight-bold); text-align: center; line-height: var(--leading-tight); }
.show-pips { display: flex; justify-content: center; gap: var(--space-1); margin: 0; padding: 0; list-style: none; }
.show-pip {
  display: grid; place-items: center; width: var(--show-pip); height: var(--show-pip);
  border: var(--border-2) solid var(--ink); border-radius: var(--radius-pill); background: var(--paper); visibility: hidden;
}
.show-pip.is-on { visibility: visible; }
.show-pip.is-now { border-color: var(--gold); background: var(--gold-soft); box-shadow: 0 0 0 var(--border-2) var(--gold); }
.show-pip.is-copied { background: var(--accent-soft); }
.show-pip > .icon { width: 80%; height: 80%; margin: 0; }
.show-tricks { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(var(--target), 1fr); gap: var(--space-2); min-width: 0; }
.btn-icon.show-trick { flex-direction: row; gap: var(--space-2); height: var(--show-tile-h); min-width: 0; padding: var(--space-1); background: var(--paper); }   /* the picture beside its word */
.btn-icon.show-trick.is-showing { border-color: var(--gold); background: var(--gold-soft); box-shadow: 0 0 0 var(--border-3) var(--gold); }
.frame-foot > .show-sign { flex-basis: 0; }
.show-sign { display: flex; align-items: center; gap: var(--space-3); height: var(--show-sign-h); min-width: 0; max-width: 100%; flex: 1 1 auto; }
.show-sign-text { display: flex; align-items: center; gap: var(--space-3); flex: 1 1 auto; min-width: 0; }   /* the line and the stars of mistakes */
.show-sign-line { flex: 1 1 auto; min-width: 0; margin: 0; font-weight: var(--weight-bold); line-height: var(--leading-tight); overflow: hidden; }
.show-sign > .actions { flex: none; margin: 0; }
.show-done-words, .show-done-gifts { margin: 0; text-align: center; }
/* a phone: what you earned beside the words, the footer row (Read to me, Play again, Done) under both */
:where(:root[data-layout=phone]) .show-done-dialog .dialog-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: center; column-gap: var(--space-3); row-gap: var(--space-1); }
:where(:root[data-layout=phone]) .show-done-dialog .show-done-words { grid-column: 1; grid-row: 1 / span 3; }
:where(:root[data-layout=phone]) .show-done-dialog :is(.show-done-gifts, .tack-news) { grid-column: 2; }
:where(:root[data-layout=phone]) .show-done-dialog .dialog-body > .actions:last-child { grid-column: 1 / -1; }
/* the sign keeps its room beside the way back (.claude/reference/design-ui.md "Screen layout"): it never wraps under
   it, and the bonus line shows at most `--barn-status-lines` lines (all of it is read to screen readers) */
.frame-foot > .barn-sign { flex-basis: 0; }
.barn-sign :is(.care-status:not(.status-note), .care-status > span) { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: var(--barn-status-lines); line-clamp: var(--barn-status-lines); overflow: hidden; }
/* your horse's help in the battle log: its head, zoomed in on the picture (it faces right) */
.log-pic > .horse-face { width: 100%; height: 100%; display: block; overflow: hidden; }
.horse-face-art { width: 100%; height: 100%; }
/* a static picture (a horse's `art`) has no face view: zoom in on its head instead */
img.horse-face-art { object-fit: cover; object-position: 100% 0; scale: 2.3; transform-origin: 92% 20%; }

/* ---------- the circus (ui/places.js, screens/memory.js; .claude/reference/design-features.md "The circus") ----------
   The circus's dialog: its tent, the welcome, and a same-size tile per game. The memory match: a
   screen of its own like the tack room (its board is a map window: --map-room, never under
   --memory-min-h), cut into the round's grid; each card turns over in its own cell (a flip, none
   in calm mode or with reduced motion: then it just shows), and the prize floats over the board. */
.circus-tent { display: flex; align-items: center; gap: var(--space-3); }
.circus-tent-art { width: var(--circus-tent-w); flex: none; }
.circus-arrive { margin: 0; font-weight: var(--weight-bold); }
.dialog.circus-dialog { width: min(var(--dialog-w-lg), calc(100% - var(--space-6))); }   /* wide enough for a game's short line to be one line */
.circus-dialog .house-tiles { --house-cols: 2; grid-auto-rows: var(--circus-game-tile-h); }
.circus-dialog .btn.circus-game { position: relative; height: var(--circus-game-tile-h); gap: var(--space-1); }
.circus-dialog .circus-game > .btn-label { flex: none; }
.circus-dialog .circus-game > .icon { width: var(--circus-game-pic); height: var(--circus-game-pic); object-fit: contain; }
.circus-game-text { font-size: var(--text-sm); font-weight: var(--weight-body); line-height: var(--leading-tight); }
.circus-game.is-played > .icon-pic { opacity: var(--circus-played-dim); }
.circus-done { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.circus-done > .icon { width: var(--circus-done-size); height: var(--circus-done-size); }
/* a phone: two big tiles side by side, each a picture over its name; the tent, the welcome and the short line are only said */
:root[data-layout=phone] .circus-dialog .circus-tent, :root[data-layout=phone] .circus-dialog .circus-game-text { display: none; }
:root[data-layout=phone] .circus-dialog[open] { display: flex; flex-direction: column; overflow: hidden; }
:root[data-layout=phone] .circus-dialog .dialog-body { flex: 1 1 0; min-height: 0; }
:root[data-layout=phone] .circus-dialog .dialog-body > .house-tiles { flex: 1 1 0; min-height: 0; grid-auto-rows: minmax(0, 1fr); }
:root[data-layout=phone] .circus-dialog .btn.house-tile.house-tile { flex-direction: column; justify-content: center; gap: var(--space-1); padding: var(--space-2); height: auto; min-height: 0; }
:root[data-layout=phone] .circus-dialog .house-tile.house-tile > .icon { flex: 1 1 0; min-height: 0; width: 100%; height: auto; }
.memory-screen .frame-pane { display: flex; flex-direction: column; }
.memory-stage {
  position: relative; height: max(var(--memory-min-h), var(--map-room));
}
.memory-board {
  display: grid; height: 100%; gap: var(--memory-gap);
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); grid-template-rows: repeat(var(--rows), minmax(0, 1fr));
}
.memory-cell { container-type: size; display: grid; place-items: center; min-width: 0; min-height: 0; }
.memory-card {
  position: relative; display: block; padding: 0; border: 0; background: none;
  width: min(100cqw, 100cqh * var(--memory-card-ratio)); height: min(100cqh, 100cqw / var(--memory-card-ratio));
  min-width: var(--target); min-height: var(--target); border-radius: var(--radius-md); perspective: 60em;
}
.memory-card-inner {
  position: absolute; inset: 0; display: block; transform-style: preserve-3d;
  transition: transform var(--dur-grow) ease-in-out;
}
.memory-card.is-up .memory-card-inner { transform: rotateY(180deg); }
.memory-card-back, .memory-card-face {
  position: absolute; inset: 0; display: grid; place-items: center; backface-visibility: hidden;
  border: var(--border-2) solid var(--ink); border-radius: var(--radius-md); box-shadow: var(--elev-1);
}
.memory-card-back {
  background: repeating-linear-gradient(45deg, var(--accent-soft) 0 12%, var(--paper) 12% 24%);
  font-size: min(40cqw, 30cqh);
}
.memory-card-face { transform: rotateY(180deg); background: var(--paper); padding: 8%; }
.memory-card-face > .art { width: 100%; height: 100%; object-fit: contain; display: grid; place-items: center; font-size: min(45cqw, 34cqh); }
.memory-card-face > svg { width: 100%; height: 100%; }
.memory-card.is-found .memory-card-face { border-color: var(--gold); background: var(--gold-soft); }
.memory-card.is-found .memory-card-face::after { content: ""; position: absolute; inset: 0; border-radius: inherit; box-shadow: inset 0 0 0 var(--border-2) var(--gold); }
.memory-result {
  position: absolute; inset-inline: 0; top: 50%; translate: 0 -50%; margin-inline: auto; width: var(--memory-result-w);
  display: grid; gap: var(--space-2); padding: var(--space-4);
  border: var(--border-2) solid var(--gold); border-radius: var(--radius-md); background: var(--paper); box-shadow: var(--elev-2);
}
.memory-result > * { margin: 0; }
.memory-tidy { font-weight: var(--weight-bold); text-align: center; }
/* the sign keeps to the footer's room beside the way back (--memory-sign-h): the pairs, the stars of tries and
   the Shine in one row (a phone's: the pairs and the stars over the Shine). A spent star is a hollow one */
.frame-foot > .memory-sign {
  flex: 1 1 0; min-width: 0; height: var(--memory-sign-h); display: grid; grid-template-columns: repeat(3, max-content); justify-content: end; align-content: center; align-items: center;
  column-gap: var(--space-3); font-size: var(--text-sm); line-height: var(--leading-tight);
}
/* the phone's strip over the board (drawn instead of the sign, which is a tablet's and a desktop's): a slot per pair, then the stars of tries */
.memory-strip { display: flex; flex: none; align-items: center; justify-content: space-between; gap: var(--space-3); height: var(--memory-strip-h); margin: 0 0 var(--space-1); }
.memory-pairs { display: flex; align-items: center; gap: var(--space-1); margin: 0; }
.memory-pair { width: var(--icon-md); height: var(--icon-md); margin: 0; }
.memory-pair.is-open { box-sizing: border-box; border: var(--border-2) dashed currentColor; border-radius: var(--radius-pill); }   /* a pair not found yet: an empty ring (a shape, not a color) */
.memory-count { margin: 0; font-weight: var(--weight-bold); white-space: nowrap; }
.tries-stars { display: flex; align-items: center; gap: var(--space-1); margin: 0; }   /* the stars of tries (components.js starsLeft) */
.tries-star { width: var(--icon-md); height: var(--icon-md); margin: 0; }
.tries-star.is-spent { fill: none; stroke: currentColor; stroke-width: var(--tries-spent-stroke); stroke-linejoin: round; }   /* hollow, so spent reads by shape, not only color */

/* ---------- arrow tiles: one contract everywhere ----------
   Always --tile square. The arrow badge sits in the top left corner (the ready or state
   badge in the top right), over three fixed rows: icon, name (max two lines, clipped), cost.
   Long names never change the size, and the words stay big enough to read on a phone. */
.arrow-pad {
  display: grid;
  gap: var(--space-2);
  grid-template-areas: ". up ." "left . right" ". down .";
  grid-template-columns: repeat(3, var(--tile));
  grid-template-rows: repeat(3, var(--tile));
  justify-content: center;
}
.arrow-tile {
  grid-area: var(--area);
  position: relative;
  display: grid;
  /* every row and font is a share of --tile, so the tile scales as one piece */
  --tile-text: max(var(--tile-text-floor), calc(var(--tile) * 0.15));   /* the words: a share of the tile, never under the floor */
  grid-template-rows: calc(var(--tile) * 0.28) minmax(0, 1fr) var(--tile-text);
  justify-items: center;
  align-items: center;
  width: var(--tile);
  height: var(--tile);
  min-height: 0;
  padding: calc(var(--tile) * 0.03);
  overflow: hidden;
  border: var(--border-1) solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper);
  box-shadow: var(--elev-1);
  font: var(--weight-bold) var(--tile-text)/1.15 var(--font);
  text-align: center;
  color: var(--ink);
}
.arrow-tile.slot-up { --area: up; }
.arrow-tile.slot-down { --area: down; }
.arrow-tile.slot-left { --area: left; }
.arrow-tile.slot-right { --area: right; }
.arrow-tile-key { position: absolute; top: calc(var(--tile) * 0.04); left: calc(var(--tile) * 0.05); display: flex; line-height: 1; }
.arrow-tile-key .icon { width: calc(var(--tile) * 0.15); height: calc(var(--tile) * 0.15); }
.arrow-tile-icon { display: flex; line-height: 1; }
.arrow-tile-icon .icon { width: calc(var(--tile) * 0.28); height: calc(var(--tile) * 0.28); margin: 0; }
.arrow-tile-icon .icon-text { font-size: calc(var(--tile) * 0.27); }
.arrow-tile-name {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  max-width: 100%;
  overflow-wrap: anywhere;
}
.arrow-tile-cost { display: inline-flex; align-items: center; gap: var(--space-0); font-size: var(--tile-text); font-weight: var(--weight-heavy); line-height: 1; white-space: nowrap; }
.arrow-tile-cost .icon { width: calc(var(--tile) * 0.16); height: calc(var(--tile) * 0.16); }
.arrow-tile.empty { color: var(--ink-soft); border-style: dashed; box-shadow: var(--elev-0); }
button.arrow-tile:active:not([aria-disabled="true"]) { transform: translateY(var(--press)); }
/* Not ready yet: the words stay full strength so kids can still read them */
button.arrow-tile[aria-disabled="true"] .arrow-tile-icon { filter: grayscale(0.6); }
.arrow-tile.ready { border-width: var(--border-2); border-color: var(--power, var(--accent)); background: var(--accent-soft); }
@supports (background: color-mix(in srgb, red, blue)) {
  .arrow-tile.ready { background: color-mix(in srgb, var(--power, var(--accent)) 25%, var(--paper)); }
}
.arrow-tile.ready .arrow-tile-key { animation: pulse var(--dur-pulse) ease-in-out var(--times-ready); }
.arrow-tile-ready { position: absolute; top: calc(var(--tile) * 0.03); right: calc(var(--tile) * 0.05); display: flex; }
.arrow-tile-ready .icon { width: calc(var(--tile) * 0.15); height: calc(var(--tile) * 0.15); margin: 0; }
/* States while you set up your powers (ARROW_STATE in ui/parts.js). Each one is a shape,
   not only a color: a ring, a dashed edge, a lock or a check badge. */
.arrow-tile[data-drag] { touch-action: none; }
.arrow-tile.is-target { border: var(--border-3) solid var(--accent); animation: tile-target var(--target-pulse, var(--dur-pulse)) ease-in-out infinite; }
.arrow-tile.is-hover { scale: 1.08; border: var(--border-3) solid var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 var(--focus-offset) var(--accent-soft), var(--elev-3); z-index: 1; }
.arrow-tile.is-picked { border: var(--border-3) dashed var(--ink); background: var(--accent-soft); }
.arrow-tile.is-dragging { border: var(--border-2) dashed var(--ink); box-shadow: var(--elev-0); }
.arrow-tile.is-dragging > :not(.arrow-tile-key) { opacity: 0.25; }
.arrow-tile.is-pinned { border-width: var(--border-2); background: var(--panel); }
.arrow-tile.is-pinned[aria-disabled="true"] .arrow-tile-icon { filter: none; }
.arrow-tile.is-placed { border: var(--border-3) solid var(--good); }
@keyframes tile-target { 50% { box-shadow: 0 0 0 var(--focus-offset) var(--accent-soft); } }

/* ---------- cards ----------
   Every card of a size is that size, whatever it says (--card-w by --card-h, per breakpoint):
   the head row (cost, picture, key), the name (at most two lines), the rules (the shorter words
   when there are several, describe.js SHORT), then the power. Everything inside is in em, so
   .card-sm and the card book's big card scale the whole card as one piece. */
.card {
  --power: var(--power-plain);
  position: relative;
  display: flex; flex-direction: column; align-items: stretch; gap: var(--card-gap);
  flex: none; width: var(--card-w); height: var(--card-h);   /* never squeezed by a row */
  padding: var(--card-pad);
  border: var(--border-2) solid var(--ink);
  border-radius: var(--radius-md);
  background: var(--paper);
  box-shadow: 0 var(--space-1) 0 var(--ink);
  color: var(--ink);
  font-size: calc(var(--card-w) * var(--card-scale));
  line-height: var(--leading-tight);
  text-align: center;
  overflow: hidden;
}
.card-sm { --card-w: var(--card-w-sm); --card-h: var(--card-h-sm); }
@supports (background: color-mix(in srgb, red, blue)) {
  .card {
    background: linear-gradient(180deg, color-mix(in srgb, var(--power) 35%, var(--paper)), var(--paper) 55%);
    box-shadow: 0 var(--space-1) 0 color-mix(in srgb, var(--power) 70%, var(--ink));
  }
}
/* A shiny card: a foil border (a gold ring outside the gold edge) and a light that sweeps across
   it now and then (none in calm mode or reduced motion). The name says "Shiny" with the sparkle
   picture too, so it never relies on color alone. */
.card.shiny { border-color: var(--gold-deep); box-shadow: 0 0 0 var(--border-1) var(--gold), 0 var(--space-1) 0 var(--gold-deep); }
.card.shiny::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(115deg, transparent 35%, var(--foil-shine) 50%, transparent 65%) no-repeat;
  background-size: 300% 100%; background-position: 100% 0;
  animation: foil-shimmer var(--dur-shimmer) ease-in-out infinite;
}
@keyframes foil-shimmer { 60%, 100% { background-position: 0 0; } }
.card.cannot { filter: grayscale(0.8); border-style: dashed; }
/* The head row: the cost on the left, the picture in the middle, the key on the right */
.card-head {
  flex: none;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: start;
  height: var(--card-head);
}
.card-cost {
  justify-self: start;
  font-size: max(1em, var(--card-text-floor));
  display: inline-flex; align-items: center; justify-content: center; gap: 0;
  min-width: var(--card-cost); height: var(--card-cost); padding: 0 var(--card-cost-pad);
  border-radius: var(--radius-pill);
  border: var(--border-1) solid var(--ink);
  background: var(--gold);
  font-weight: var(--weight-heavy);
}
.card-key {
  grid-column: 3; justify-self: end;
  font-size: var(--text-xs); font-weight: var(--weight-heavy);
  border: var(--border-1) solid var(--ink); border-radius: var(--radius-xs); padding: 0 var(--space-1); background: var(--paper);
}
.card-art { grid-column: 2; grid-row: 1; display: flex; font-size: var(--card-art); line-height: 1; }
.card-art > .art { width: 1em; height: 1em; object-fit: contain; }
.card-art > .art > .icon { font-size: inherit; width: 1em; height: 1em; margin: 0; }
.card-art > .icon { width: 1em; height: 1em; margin: 0; }
.card-art > .icon-text { font-size: 1em; }
.card-shiny { display: inline-flex; align-items: center; gap: var(--space-0); margin-inline-end: var(--space-1); color: var(--ink); font-weight: var(--weight-heavy); }
/* The name: at most two lines (the whole name is in the card's read-aloud) */
.card-name {
  flex: none;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden;
  font-weight: var(--weight-heavy); font-size: var(--card-name);
}
/* The rules fill the room between the name and the power, in the middle of it */
.card-text {
  flex: 1 1 auto; min-height: 0; overflow: hidden;
  display: flex; flex-direction: column; justify-content: safe center; gap: var(--card-gap);
  font-size: var(--card-rules); line-height: var(--leading-tight); text-align: left;
}
.card-text .verb-words { min-width: 0; }
.card-text .verb-badge { width: var(--card-badge); height: var(--card-badge); }

/* A sentence with its verb's picture in a small ring of the verb's color (cards, pop-ups) */
.verb-line { display: flex; align-items: center; gap: var(--space-1); }
.verb-badge {
  flex: none; display: grid; place-items: center;
  width: var(--verb-badge); height: var(--verb-badge);
  border-radius: var(--radius-round);
  border: var(--border-1) solid var(--verb, var(--line));
  background: var(--verb-soft, var(--paper));
}
.verb-badge > .icon { width: 70%; height: 70%; margin: 0; font-size: 0.9em; }
.verb-bad .verb-badge { border-style: dashed; }   /* tricky statuses are never color alone */
.card-power { flex: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: var(--card-foot); color: var(--ink-soft); }
/* the rules as pictures and numbers (a phone's hand shows these instead of the words: styles/screens.css) */
.card-amounts { display: none; }

/* ---------- battle ---------- */
.battle-title h1 { font-size: var(--text-2xl); }   /* the title in the battle's slim bar */
.battle-tools { display: flex; align-items: center; gap: var(--space-2); flex: none; }
.round { font-weight: var(--weight-bold); color: var(--ink-soft); margin-right: var(--space-2); }

/* The stage: you on the left, foes on the right, like a side-view RPG */
.stage {
  --sky-top: var(--stage-sky-top);
  --sky-bottom: var(--stage-sky-bottom);
  --ground: var(--stage-ground);
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.7fr);
  align-items: end;
  gap: var(--space-3);
  min-height: var(--stage-min);
  padding: var(--stage-top) var(--space-5) var(--space-3);
  border-radius: var(--frame-radius);
  border: var(--frame-border) solid var(--frame-line);   /* the stage is the battle's pane */
  box-shadow: var(--frame-elev);
  background: linear-gradient(180deg, var(--sky-top), var(--sky-bottom));
  overflow: hidden;
}
.stage::after {
  content: "";
  position: absolute;
  inset: auto -10% 0 -10%;
  height: 30%;
  background: var(--ground);
  border-radius: 50% 50% 0 0 / 40% 40% 0 0;
  z-index: 0;
}
.stage > * { position: relative; z-index: 1; }
/* The battle fits the window: the page is the window's height, the tray keeps its size, and the
   stage takes the rest. You and each foe fill the stage's height: the plate and the intent take what
   they need (two-line names, statuses, "Bonk Night Bat!" while you pick), and the picture's room
   (.hero-art, .foe-room: size containers) takes the rest, the picture as big as fits it (100cqh) */
.screen.battle .stage { flex: 1 1 0; min-height: 0; grid-template-rows: minmax(0, 1fr); align-items: stretch; container: stage / size; }   /* its size comes from the page, not its content: its plates and marks query it (@container stage) */
.screen.battle .hero, .screen.battle .foes, .screen.battle .foe { min-height: 0; }
.screen.battle .hero { justify-content: flex-end; }
.screen.battle .hero-art { flex: 1 1 0; min-height: 0; container-type: size; align-items: flex-end; }
.screen.battle .mount.hero-mount { --art-mount: min(var(--art-hero), calc(100cqh * var(--hero-aspect))); }
/* The room reserves the complete intent height and gap above the model (--foe-pic-h). Taps go through the room to the foe's name
   button, which lies over the whole foe; only the intent takes them. */
.foe-room { display: flex; justify-content: center; align-items: flex-end; pointer-events: none; }
.screen.battle .foes { align-items: stretch; }
/* a size container is a stacking context of its own: it lies over the name button (z-index 1) so
   the intent in it can be tapped, and lets every other tap through (pointer-events above) */
.screen.battle .foe-room { flex: 1 1 0; min-height: 0; width: 100%; container-type: size; position: relative; z-index: 2; }
.screen.battle :is(img, svg, .art-look).foe-pic { width: min(var(--art-foe), calc(var(--foe-pic-h) * var(--foe-aspect)), 100cqw); max-height: var(--foe-pic-h); object-fit: contain; object-position: 50% 100%; }   /* a picture taller than --foe-aspect still stays in its room */
.screen.battle .foe.size-big :is(img, svg, .art-look).foe-pic { width: min(var(--art-foe-big), calc(var(--foe-pic-h) * var(--foe-aspect)), 100cqw); }
/* a bar in one row with the hearts' number and the Shield (a big guardian's plate, a phone's
   crowded row) is never thinner than this */
.screen.battle .plate .bar { min-width: var(--space-6); }
/* The island's backdrop picture replaces the plain sky and ground */
.stage.has-scene::after { content: none; }
.stage > .stage-backdrop {
  position: absolute; inset: 0; z-index: 0;
  width: 100%; height: 100%; max-width: none;
  object-fit: cover; object-position: var(--scene-position, 50% 100%);
}

/* The ledger under the hand (.claude/reference/design-ui.md "Battle screen"): one row per thing that happened,
   newest at the bottom. A fixed height (--ledger-h) that scrolls inside itself: the scroller runs
   bottom up (column-reverse), so it starts at the newest row and new rows land in the same place. */
.battle-log { grid-area: log; min-width: 0; align-self: stretch; }
.ledger-scroll {
  display: flex; flex-direction: column-reverse;
  height: var(--ledger-h);
  overflow-y: auto;
  padding: var(--space-1);
  border-radius: var(--radius-lg);
  border: var(--border-1) solid var(--line-soft);
  background: var(--glass);
}
.log-lines {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: var(--space-1);
}
.log-line {
  --ledger-pic-now: var(--ledger-pic);
  flex: none; display: flex; align-items: center; gap: var(--space-2);
  min-height: var(--ledger-row-h);
  padding: var(--space-0) var(--space-3) var(--space-0) var(--space-0);
  border-radius: var(--radius-lg);
  border: var(--border-1) solid var(--verb, var(--line));
  background: var(--panel);
  color: var(--ink-soft); font-size: var(--text-sm); font-weight: var(--weight-semi); line-height: var(--leading-tight);
}
/* the rows of the last step: brighter; the newest one says New */
.log-line.fresh { background: var(--paper); color: var(--ink); font-weight: var(--weight-heavy); }
.log-line.newest { --ledger-pic-now: var(--ledger-pic-new); border-width: var(--border-2); box-shadow: var(--elev-1); }
/* a new turn and End turn: a band across the ledger with the turn's number */
.log-line.row-turn { border-style: dashed; background: var(--accent-soft); color: var(--ink); }
.log-turn {
  flex: none;
  padding: 0 var(--space-2);
  border-radius: var(--radius-pill); border: var(--border-1) solid var(--ink);
  background: var(--paper); color: var(--ink);
  font-size: var(--text-xs); font-weight: var(--weight-heavy);
}
.log-pic {
  flex: none; display: grid; place-items: center;
  width: var(--ledger-pic-now); height: var(--ledger-pic-now);
  border-radius: var(--radius-round);
  background: var(--verb-soft, var(--accent-soft));
  overflow: hidden;
}
.log-pic > .icon { width: 70%; height: 70%; margin: 0; font-size: 1.1em; }
.log-pic > .log-art { width: 90%; height: auto; }
.log-words {
  min-width: 0; flex: 1 1 auto;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: var(--ledger-lines); line-clamp: var(--ledger-lines); overflow: hidden;
}
.log-new {
  flex: none; margin-inline-start: auto;
  display: inline-flex; align-items: center; gap: var(--space-1);
  padding: 0 var(--space-2);
  border-radius: var(--radius-pill); border: var(--border-1) solid var(--gold-deep);
  background: var(--gold-soft); color: var(--ink);
  font-size: var(--text-xs); font-weight: var(--weight-heavy);
}

.plate {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 0 var(--space-1);
  width: min(100%, var(--plate-w));
  padding: var(--space-1) var(--space-2) var(--space-2);
  border-radius: var(--radius-md);
  border: var(--border-1) solid var(--ink);
  background: var(--glass);
  color: var(--ink);
}
.plate-name { font-size: var(--text-sm); text-align: center; width: 100%; overflow-wrap: anywhere; grid-column: 1 / -1; }
.screen.battle .plate { flex: none; width: min(100%, var(--plate-w)); container: combat-plate / inline-size; position: relative; z-index: 3; pointer-events: none; padding: var(--space-1); gap: 0; }
.screen.battle .plate .hp { grid-template-columns: auto auto; column-gap: var(--space-1); }
.screen.battle .plate .hp > .bar { grid-column: 1 / -1; min-width: 0; }
.screen.battle .plate .hp-text { font-size: var(--text-sm); }
@container combat-plate (min-width: 220px) {
  .statuses { width: calc(var(--chip-h) * 2 + var(--space-1)); }
}
@container combat-plate (max-width: 10rem) {
  .hp-text { --hp-pic: 0px; font-size: var(--text-xs); }
  .hp-text > .icon { display: none; }
}
@container combat-plate (max-width: 8rem) {
  .hp { grid-template-columns: minmax(0, 1fr) auto; }
  .hp > .bar { grid-column: 1 / -1; grid-row: 1; }
  .hp > .shield { grid-column: 2; grid-row: 2; }
  .hp > .hp-text { grid-column: 1; grid-row: 2; justify-self: center; }
}

.plate-sub { font-weight: var(--weight-semi); color: var(--ink-soft); }

.hero { justify-self: stretch; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: var(--space-2); }
.hero-art { position: relative; width: 100%; display: flex; justify-content: center; }
.hero-art .mount, .foe-art .foe-pic { filter: var(--art-halo); animation: bob var(--bob-time) ease-in-out infinite; }
.foe:nth-child(even) .foe-art .foe-pic { animation-delay: calc(var(--bob-time) / -2); }
:is(img, svg, .art-look).foe-pic { width: var(--art-foe); }
.foe.size-big :is(img, svg, .art-look).foe-pic { width: var(--art-foe-big); }

.ground-shadow {
  position: absolute; left: 15%; right: 15%; bottom: calc(var(--space-1) * -1); height: var(--space-3);
  border-radius: var(--radius-round);
  background: var(--shade);
  z-index: -1;
}

.foes { display: flex; justify-content: flex-end; align-items: flex-end; gap: var(--space-3); }
.foe {
  display: flex; flex-direction: column; align-items: center; gap: var(--space-2);
  flex: 0 1 var(--plate-w);
  min-width: 0;
  padding: var(--space-1);
  border-radius: var(--radius-md);
  color: var(--ink);
}
.foe-art { position: relative; }
.foe.size-big { flex-basis: calc(var(--plate-w) * 1.5); }
.foe.aimed .plate { border-color: var(--bad); box-shadow: 0 0 0 var(--border-3) var(--bad-glow); }
/* ...and its picture wears the pointing hand on its top right corner, taking no room */
.aim-mark {
  position: absolute; top: 0; right: 0; translate: 30% -30%; z-index: 3; pointer-events: none;
  display: grid; place-items: center;
  border-radius: var(--radius-round); border: var(--border-2) solid var(--bad); background: var(--paper);
  padding: var(--space-0);
}
.aim-mark > .icon { margin: 0; }
.foe.aimed .foe-art { filter: drop-shadow(0 0 var(--space-2) var(--paper)); }
.foe.down { opacity: 0.5; filter: grayscale(1); }
/* Asking which foe: every foe that can be picked pulses with a dashed ring (a still ring in
   calm mode), the one picked out by the keys has a solid ring, and a banner says Tap a foe! */
.pick-ring {
  position: absolute; inset: var(--pick-ring-out);
  border-radius: var(--radius-round);
  border: var(--border-3) dashed var(--accent);
  background: var(--pick-glow);
  pointer-events: none;
  animation: pick-pulse var(--dur-pulse) ease-in-out infinite;
}
.foe.pickable.aimed .pick-ring { border-style: solid; border-color: var(--bad); }
.foe.pickable .plate { border-color: var(--accent); border-width: var(--border-2); }
.foe.pickable.aimed .plate { border-color: var(--bad); }
.stage > .pick-banner {
  position: absolute; top: var(--space-2); left: 50%; transform: translateX(-50%); z-index: 3;
  display: inline-flex; align-items: center; gap: var(--space-2);
  margin: 0; padding: var(--space-1) var(--space-4);
  border-radius: var(--radius-pill); border: var(--border-2) solid var(--accent);
  background: var(--paper); box-shadow: var(--elev-1);
  font-size: var(--text-xl); font-weight: var(--weight-ultra); white-space: nowrap;
  pointer-events: none;
}
.log-line.log-prompt { border-color: var(--accent); }
.pick-cancel { margin-inline-start: auto; flex: none; }
.hand .card.picked { transform: translateY(calc(var(--card-raise) * -1)); box-shadow: 0 0 0 var(--border-3) var(--accent); z-index: 5; }
@keyframes pick-pulse { 50% { transform: scale(1.08); opacity: 0.7; } }
/* The foe's name is the real button: a full-height target without a button's frame */
.aim-button {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-1);
  min-height: var(--target);
  padding: 0 var(--space-2);
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  font-size: var(--text-md); font-weight: var(--weight-heavy); line-height: var(--leading-tight);
}
.aim-button > .icon { margin: 0; }
.foe.aimed .aim-button { background: var(--bad-soft); }
/* While asking which foe, the name is a go button with the verb's picture ("Bonk Night Bat!"),
   kept small enough for the plate */
.aim-go { padding-inline: var(--space-3); gap: var(--space-1); }

/* The complete intent badge sits above the model with a gap, inside the room reserved for it.
   One placement rule applies to every foe, regardless of model size or screen class. */
.intent {
  position: absolute; bottom: calc(100% + var(--space-2)); left: 50%; translate: -50% 0; z-index: 2;
  pointer-events: auto;
  display: flex; flex-wrap: nowrap; justify-content: center; align-items: center; gap: 0 var(--space-2);
  width: max-content; max-width: 100cqw; height: var(--intent-h); min-width: var(--target);
  white-space: nowrap; box-shadow: var(--elev-1);
  background: var(--paper);
  border: var(--border-1) dashed var(--line);   /* guarding, healing, powering up */
  border-radius: var(--radius-md);
  padding: var(--space-0) var(--space-3);
  color: var(--ink);
  font-size: var(--text-md);
  font-weight: var(--weight-heavy);
  line-height: var(--leading-tight);
}
.intent-bit > .icon { width: var(--intent-pic); height: var(--intent-pic); }
.intent-icons { display: inline-flex; flex: none; align-items: center; gap: var(--space-2); }
.intent-bit { display: inline-flex; align-items: center; gap: var(--space-0); }
.intent.threat { border: var(--border-2) solid var(--bad); }   /* hitting you or making you weaker */
.intent.beaten { border: var(--border-1) solid var(--ink-soft); }
.intent-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; font-weight: var(--weight-semi); color: var(--ink-soft); }

/* A fighter's hearts: three slots, the bar, the number and the Shield (hpBar). The number's slot is
   as wide as the most hearts written out (--hp-digits) and the Shield's is always there, empty
   while there is none, so the bar is one width all battle long */
.hp {
  display: grid; grid-template-columns: auto auto; align-items: center; justify-content: safe center;   /* never cut at its start: the number's first digit always shows */
  gap: var(--space-0) var(--space-2); width: 100%;
}
.hp > .bar { grid-column: 1 / -1; }   /* the bar on a row of its own, the number and the Shield's spot under it */
.bar { min-width: 0; height: var(--bar-h); border-radius: var(--radius-pill); background: var(--track); border: var(--border-1) solid var(--ink); overflow: hidden; }
.bar-fill {
  display: block; height: 100%; width: var(--fill);
  /* striped, with an ink edge where HP ends, so the fill never depends on color */
  background: repeating-linear-gradient(135deg, var(--hp-stripe) 0 var(--stripe), transparent var(--stripe) calc(var(--stripe) * 2)), linear-gradient(90deg, var(--hp-1), var(--hp-2));
  border-right: var(--border-1) solid var(--ink);
  transition: width var(--dur-grow) ease-out;
}
.hp-text {
  display: inline-flex; align-items: center; justify-content: flex-end; gap: var(--space-1);
  min-width: calc(var(--hp-pic) + (var(--hp-digits) * 2 + 1.5) * 1ch);   /* "185/185" and a heart: the digits, the slash and a little room */
  font-weight: var(--weight-heavy); font-size: var(--text-md); font-variant-numeric: tabular-nums;
}
.shield {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-1);
  width: var(--shield-w); height: var(--shield-h);
  font-weight: var(--weight-heavy); font-size: var(--text-sm); font-variant-numeric: tabular-nums;
  background: var(--shield-soft); border: var(--border-1) solid var(--shield); border-radius: var(--radius-pill); padding: 0 var(--space-1);
}
.shield.is-empty { visibility: hidden; }

/* Status chips: big enough to tap (--chip-h), each a button that opens what it does. On a plate
   they are one row of their own (--status-row-h), always there: more than fit scroll sideways */
.statuses { list-style: none; padding: 0; margin: 0; display: flex; gap: var(--space-1); flex-wrap: wrap; justify-content: center; }
.plate .statuses {
  flex-wrap: nowrap; justify-content: flex-start; max-width: 100%; width: var(--chip-h);
  height: var(--status-row-h); flex: none;
  overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; scrollbar-width: none;
}
.plate .statuses > li { flex: none; }
.chip {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-0);
  min-height: var(--chip-h); min-width: var(--chip-h);
  padding: 0 var(--space-2) 0 var(--space-1);
  border-radius: var(--radius-pill);
  border: var(--border-2) solid var(--verb);
  background: var(--verb-soft);
  color: var(--ink);
  font-size: var(--text-md); font-weight: var(--weight-heavy); line-height: 1;
}
.chip.verb-bad { border-style: dashed; }
.chip-pic { width: var(--chip-icon); height: var(--chip-icon); }
.chip-mark { width: var(--icon-sm); height: var(--icon-sm); color: var(--verb); }
@media (hover: hover) {
  button.chip:hover, button.intent:hover { box-shadow: var(--elev-2); transform: translateY(calc(var(--lift) * -1)); }
}

/* Pop-ups that explain a status or a foe's next move (the shared dialog) */
.info-hero { display: flex; justify-content: center; align-items: center; gap: var(--space-4); margin-bottom: var(--space-3); }
.info-pic {
  display: grid; place-items: center;
  width: var(--info-pic); height: var(--info-pic);
  border-radius: var(--radius-round);
  border: var(--border-2) solid var(--verb, var(--line));
  background: var(--verb-soft, var(--accent-soft));
}
.info-pic > .icon { width: 70%; height: 70%; margin: 0; font-size: var(--text-3xl); }
.info-pop.verb-bad .info-pic { border-style: dashed; }
.info-count { display: inline-flex; align-items: center; gap: var(--space-1); font-size: var(--text-3xl); font-weight: var(--weight-ultra); }
.info-count > .icon, .info-kind > .icon { color: var(--verb); margin: 0; }
.info-foe { width: var(--info-pic); filter: var(--art-halo); }
.info-lines { display: flex; flex-direction: column; gap: var(--space-2); }
:where(:root[data-layout=phone]) .info-pop .info-hero { height: 100%; margin: 0; flex-direction: column; min-height: 0; }
:where(:root[data-layout=phone]) .info-pop .info-foe { max-height: 100%; width: auto; max-width: 100%; }
.info-pop .info-hero .card { --card-w: var(--card-w-lg); --card-h: var(--card-h-lg); }
:where(:root[data-layout=phone]) .info-pop .info-hero .card { --card-w: var(--card-w-sm); --card-h: var(--card-h-sm); }
.info-lead { font-size: var(--text-lg); font-weight: var(--weight-heavy); margin: 0 0 var(--space-2); }
.info-kind { display: flex; align-items: center; gap: var(--space-2); font-weight: var(--weight-bold); }
.info-rows { list-style: none; padding: 0; margin: 0 0 var(--space-4); display: flex; flex-direction: column; gap: var(--space-2); }
.info-row { font-size: var(--text-lg); font-weight: var(--weight-semi); }

/* Floating numbers over whoever just got hit, shielded, healed or a status: stickers in
   their verb's color that pop in, stay for --float-time (CONFIG.ui.floatMs), then drift off.
   Newest at the bottom; older ones are pushed up, so they start low (--float-at) and faces
   (the rider's reactions) stay in view; in a room too short for them all they stand side by side.
   Never in the way of a tap. */
.floaters {
  position: absolute; left: var(--float-x); bottom: var(--float-at); transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: var(--space-1);
  max-height: calc(100% - var(--float-at)); flex-wrap: wrap-reverse; align-content: center;   /* in a short room (Bigger text) more floats stand side by side, never above the stage */
  pointer-events: none; z-index: 4;
}
.float {
  display: inline-flex; align-items: center; gap: var(--space-1);
  padding: 0 var(--space-3);
  border-radius: var(--radius-pill);
  border: var(--border-2) solid var(--verb, var(--ink));
  background: var(--paper);
  box-shadow: var(--elev-1);
  color: var(--verb, var(--ink));
  font-family: var(--font); font-size: var(--text-xl); font-weight: var(--weight-ultra);
  line-height: var(--leading-tight);
  white-space: nowrap;
  opacity: 0;   /* until its feel starts; gone again when it ends */
  animation: var(--verb-feel, float-rise) var(--float-time) ease-out forwards;
}
.float > .icon { width: 1.1em; height: 1.1em; }
/* floaters with a place of their own (EVENT_LOOKS `floatAt`): 'corner' sits by the picture's top
   left corner (a foe stepping in's sparkle), clear of its face, and only fades, never rising over it */
.floaters-corner { left: 0; top: 0; bottom: auto; transform: translate(-25%, -25%); }
.floaters-corner > .float { animation-name: float-fade; }
.float.verb-damage { font-size: var(--text-3xl); }
.float.verb-bad { border-style: dashed; }

/* The tray: your hand on top (sparks, rainbow and the piles at its left), and under it the arrow
   powers, the ledger of what happened and End turn. Nothing in it changes size as you play: the
   why note floats over the hand, and the ledger is a fixed height that scrolls inside itself. */
.tray {
  display: grid;
  grid-template-columns: auto auto auto minmax(0, 1fr) auto;
  grid-template-rows: minmax(0, 1fr) minmax(0, 1fr) auto var(--tile-tray);   /* the hand's rows share --hand-h: the footer is --tray-h, whatever the hand holds */
  grid-template-areas:
    "orb  draw hand hand hand"
    "orb  used hand hand hand"
    "rain rain hand hand hand"
    "pad  pad  pad  log  right";
  align-items: center;
  gap: var(--space-2) var(--space-3);
  flex: 1 1 100%; align-self: stretch; height: 100%;   /* the whole footer bar */
  --tile: var(--tile-tray);
  /* (a big hand's leaning edge cards never scroll the page: the footer clips sideways, its padding their room) */
  container: tray / inline-size;
  position: relative;
  z-index: 3;
}
.tray-meters, .tray-left { display: contents; }   /* on wide screens their parts have places of their own in the tray */
.tray .sparks-orb { grid-area: orb; justify-self: center; }
.tray .rainbow { grid-area: rain; }
/* In battle the same tiles sit in one row, like the keyboard's arrow keys: left, up, down, right */
.tray .arrow-pad {
  grid-area: pad;
  grid-template-areas: "left up down right";
  grid-template-columns: repeat(4, var(--tile));
  grid-template-rows: var(--tile);
  justify-content: start;
}
.tray-right { grid-area: right; display: flex; flex-direction: column; align-items: stretch; gap: var(--space-2); }
/* with a swap left, Swap a card stands beside End turn, each its picture over its words, so the row keeps its height */
.tray-right:has(> .swap-card) { flex-direction: row; }
.tray-right:has(> .swap-card) > .btn { flex-direction: column; gap: 0; height: 100%; min-width: 0; padding-inline: var(--space-2); white-space: normal; }
.pile { justify-self: stretch; justify-content: center; min-height: var(--pile-h); font-size: var(--text-lg); }
.pile > .icon { width: var(--icon-lg); height: var(--icon-lg); }
/* a tray narrow for its words (Bigger text in a small window): the piles are their pictures and
   counts (their names are still read out), so the hand keeps the room its cards' names need */
@container tray (max-width: 42rem) { .pile .stat-word { display: none; } }
.pile-draw { grid-area: draw; }
.pile-used { grid-area: used; }
/* The hand, with the why note floating over its top edge */
/* The hand takes the width it is given (a container), and its cards overlap more when there are many */
.hand-area {
  grid-area: hand; position: relative; min-width: 0; align-self: stretch; display: flex; flex-direction: column; justify-content: flex-end; container-type: inline-size;
  --fan-room: calc(100cqw - (var(--card-h) * var(--fan-lean) - var(--space-3)) * 2 - var(--space-2) * 2);   /* the fan's room (see .hand below) */
}
/* Why the card or arrow just tapped can't be used yet (whyNote), or what to do while swapping:
   over the top of the hand, so nothing moves when it shows */
.tray-why {
  position: absolute; top: 0; left: 50%; transform: translate(-50%, -70%); z-index: 6;
  width: max-content; max-width: 100%; margin: 0;
  box-shadow: var(--elev-2);
  pointer-events: none;
}
/* How many cards, and "swipe": only on phones, where the hand is one row you swipe */
.hand-hint { display: none; }

.sparks-orb {
  display: grid; place-items: center; align-content: center;
  flex: none;
  width: var(--orb); height: var(--orb);
  border-radius: var(--radius-round);
  border: var(--border-3) solid var(--ink);
  background: var(--gold);
  background: radial-gradient(circle at 35% 30%, var(--gold-soft), var(--gold) 55%, var(--gold-deep));
  font-weight: var(--weight-ultra); font-size: var(--text-xl);
  line-height: 1;
  box-shadow: var(--elev-1);
}
.orb-icon { margin: 0; }
.rainbow { display: flex; flex-direction: column; align-items: center; gap: var(--space-1); background: var(--glass); border-radius: var(--radius-sm); padding: var(--space-1) var(--space-2); }
.rainbow-label { display: inline-flex; align-items: center; gap: var(--space-1); font-weight: var(--weight-heavy); font-size: var(--text-md); }
.meter, .pips { display: flex; gap: var(--space-0); }
.pip { width: var(--pip-w); height: var(--pip-h); border-radius: calc(var(--radius-xs) / 2); border: var(--border-1) solid var(--ink-soft); background: var(--paper); }
.pip.on { border-color: var(--ink); background: var(--seq); }

.hand {
  display: flex; justify-content: center; align-items: flex-end;
  padding: var(--space-2) var(--space-2) var(--space-1);
}
/* The fan's room: the hand's width less the end cards' lean (--fan-lean) past the gap beside it, so
   no card leans over the piles or past the tray. Cards overlap to fit it, and in the hand you're
   dealt (--dealt, CONFIG.turn.handSize) each shows at least --fan-show of itself past the next, so
   its name is never covered: where they can't, every card in the hand is drawn a little smaller
   (down to --fan-card-min; Bigger text in a narrow window), one size however many you hold (a
   bigger hand overlaps more). The hand fans when its tray is 841px wide or more (the tray of a 901px
   window), the one edge for both sides; a narrower tray holds one row you swipe, whatever the window is. */
@container tray (min-width: 841px) {
  .hand { --hand-card-w: clamp(calc(var(--card-w) * var(--fan-card-min)), calc(var(--fan-room) / (1 + (var(--dealt) - 1) * var(--fan-show))), var(--card-w)); }
  .hand > :is(.card, .card-ghost) { --card-w: var(--hand-card-w); --card-h: calc(var(--hand-card-w) * var(--card-aspect)); }
  .hand > :is(.card, .card-ghost):first-child { margin-inline-start: 0; }   /* the cards overlap each other, never the hand's edges */
  .hand > :is(.card, .card-ghost):last-child { margin-inline-end: 0; }
  .hand :is(.card, .card-ghost) {
    margin: 0 min(calc(var(--space-3) * -1), calc((var(--fan-room) - var(--cards) * var(--card-w)) / max(var(--cards) - 1, 1) / 2));
    transform-origin: 50% 120%;
    transform: rotate(calc((var(--i) - (var(--cards) - 1) / 2) * min(var(--fan), var(--fan-spread) / var(--cards))));
  }
}
.hand :is(.card, .card-ghost) { transition: transform var(--dur-lift); }
.hand .card:focus-visible { transform: translateY(calc(var(--card-raise) * -1)) scale(1.06); z-index: 5; }
@media (hover: hover) {
  .hand .card:hover:not(.cannot) { transform: translateY(calc(var(--card-raise) * -1)) scale(1.06); z-index: 5; }
}
/* An empty hand keeps its room: faint dashed outlines of the cards you're dealt (CONFIG.turn.handSize) */
.card-ghost {
  flex: none; width: var(--card-w); height: var(--card-h);
  border: var(--border-2) dashed var(--line-soft); border-radius: var(--radius-md);
  background: var(--glass);
}
/* A tray narrower than the fan's edge (841px, above): one row you swipe, so End turn stays on screen,
   cards unfanned (the fan's rules apply only from 841px), no bar (design-ui.md "Scroll areas"). The row
   scrolls, so it clips: a card never lifts out of it (picked, focused or under the mouse), and its
   focus ring is drawn inside it. After the lift rules, so these win */
@container tray (width < 841px) {
  .hand { justify-content: flex-start; gap: var(--space-2); overflow-x: auto; scrollbar-width: none; padding: var(--space-1); scroll-snap-type: x mandatory; --focus-offset: var(--focus-offset-tight); }
  .hand :is(.card, .card-ghost) { flex: 0 0 auto; scroll-snap-align: start; }
  .hand .card:is(.picked, :focus-visible, :hover:not(.cannot)) { transform: none; }
}
.end-turn { white-space: nowrap; }
.btn-label > kbd { margin-inline-start: var(--space-2); }

.keys-help { font-size: var(--text-sm); color: var(--ink-soft); text-align: center; }

/* "Yay! What next?" once the result is closed: over the bottom of the stage, so the stage keeps its size */
.over-bar { position: absolute; inset: auto 0 var(--space-3); z-index: 4; display: flex; justify-content: center; margin: 0; pointer-events: none; }
.over-bar > * { pointer-events: auto; }
.dialog.result { text-align: center; border-color: var(--gold-deep); background: var(--gold-soft); }
.dialog.result.lost { border-color: var(--calm); background: var(--calm-soft); }
.dialog.result .dialog-title { justify-content: center; }
.battle.over .tray { opacity: 0.5; }

/* ---------- a crowded stage ----------
   With CONFIG.ui.compactFoesFrom foes (two) or more the foes share their side of the stage, each one
   a share of it. A phone's stage is short and wide, so it keeps you beside them (styles/screens.css). */
:where(:root[data-layout=phone]) .stage.compact-foes .foe { flex: 1 1 0; }
/* A foe's picture and plate open its details until a targeted card is selected. Its intent and
   status buttons are above that large surface and open their own explanations. */
.screen.battle .foe { position: relative; gap: var(--space-1); padding: 0; }
.screen.battle .plate .chip {
  pointer-events: auto; position: relative; padding: 0; font-size: var(--text-xs);
  border: 0; background: transparent;
}
.screen.battle .plate .chip::before {
  content: ''; position: absolute; z-index: 0; top: 50%; left: 50%; translate: -50% -50%;
  width: calc(100% - var(--space-2)); height: calc(100% - var(--space-3));
  border: var(--border-2) solid var(--verb); border-radius: var(--radius-pill);
  background: var(--verb-soft);
}
.screen.battle .plate .chip.verb-bad::before { border-style: dashed; }
.screen.battle .plate .chip > * { position: relative; z-index: 1; }
.screen.battle .plate .chip-pic { width: var(--icon-sm); height: var(--icon-sm); }
.screen.battle .foe :is(.aim-button, .aim-go) {
  position: absolute; inset: 0; z-index: 1; min-height: 0; padding: 0;
  border: 0; border-radius: var(--radius-md); background: transparent; box-shadow: none; color: transparent;
}
.screen.battle .foe :is(.aim-button, .aim-go) > * { opacity: 0; }
/* ---------- reward ---------- */
/* What you won scrolls inside its room; the card pick keeps its room beside it (under it on a
   phone), so the cards are always in full view (.claude/reference/design-ui.md "Screen layout") */
.reward-body { flex: 1 1 0; min-height: 0; display: flex; gap: var(--pane-gap); }
.reward-news { flex: 1 1 0; min-width: 0; min-height: var(--reward-news-min); overflow-y: auto; overflow-anchor: none; display: flex; flex-direction: column; align-items: stretch; gap: var(--pane-gap); }
.reward-news:empty { display: none; }
.reward-news.more-down::after {   /* news that scrolls in its box says so: it fades out at the bottom while there is more */
  content: ""; position: sticky; bottom: 0; flex: none; height: var(--scroll-cue); margin-top: calc((var(--scroll-cue) + var(--pane-gap)) * -1);
  background: linear-gradient(transparent, var(--pane-bg)); pointer-events: none;
}
.reward-news > * { flex: none; margin-block: 0; }
.reward-news .tack-news { justify-items: stretch; }
.reward-news .tack-news-item { display: grid; grid-template-columns: var(--tack-tile-pic) minmax(0, 1fr); }
.reward-pick { flex: none; position: relative; display: flex; flex-direction: column; justify-content: center; align-items: center; }
.reward-pick > h2 { margin: 0; text-align: center; }
.reward-pick > .why-note { position: absolute; top: 0; left: 50%; translate: -50% 0; z-index: 2; margin: 0; width: max-content; max-width: 100%; }   /* over the heading, in no room of its own */
.reward-pick > .choices { flex-wrap: nowrap; }
/* until one is picked, the cards hop a little as you arrive: these are what to tap (Take waits for a pick) */
.reward-pick > .choices:not(:has(.picked)) > .card { animation: choice-invite var(--dur-pulse) ease-in-out var(--times-invite); }
@keyframes choice-invite { 50% { translate: 0 calc(var(--card-lift) * -1); } }
.cheer-figure { flex: none; width: var(--art-celebrate); filter: var(--art-halo); }
.new-power { border-left: var(--power-edge) solid var(--power); text-align: left; max-width: var(--panel-narrow); margin: 0 auto var(--space-5); }
.choices { display: flex; gap: var(--gap-choices); justify-content: center; flex-wrap: wrap; padding: var(--space-4) 0; }
/* The picked reward card: lifted, a thick accent border and a check (take it with Take, or a second tap) */
.choices .card.picked { border: var(--border-3) solid var(--accent); transform: translateY(calc(var(--card-lift) * -1)); box-shadow: var(--elev-2); }
.card-picked {
  position: absolute; top: calc(var(--space-3) * -1); right: calc(var(--space-3) * -1);
  display: grid; place-items: center;
  width: var(--icon-xl); height: var(--icon-xl); font-size: var(--text-lg);
  border-radius: var(--radius-round); background: var(--accent); color: var(--accent-ink);
}
.card-picked > .icon { margin: 0; }

/* ---------- cursor map (.claude/reference/design-ui.md "Cursors") ----------
   Which role each element has; the role's token says what it looks like. One rule
   per role, all at zero specificity, so a later role wins: a disabled button is
   locked, not press. A cursor is only ever an extra hint: focus rings stay as they are. */
:where(html) { cursor: var(--cursor-default); }
:where(button, summary, .field-row, .choice-tile, .swatch, .card, .foe, input[type="range"], .file-button, .file-input, .roam-view, .log-line:has(button.term)) { cursor: var(--cursor-press); }
:where(.picking .foe.pickable, .picking .aim-button, .aim-go) { cursor: var(--cursor-aim); }   /* targeting a foe for a selected card */
:where(.power-token, .arrow-tile[data-drag], button.sticker) { cursor: var(--cursor-grab); }
:where(.volume, .card.still, .foe.down, .aim-button:disabled) { cursor: var(--cursor-default); }
:where(:disabled, [aria-disabled="true"], .field-row.is-disabled, .card.cannot, .map-node.locked, .arrow-tile.is-pinned, .power-token.is-pinned, .power-token.is-still) { cursor: var(--cursor-locked); }
:where(input[type="text"], textarea) { cursor: var(--cursor-type); }
:where(.powers-drawer.drawer-dragging, .powers-drawer.drawer-dragging *, .sticker.is-dragging, .sticker.is-dragging *) { cursor: var(--cursor-grabbing); }

/* ---------- motion ---------- */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(calc(var(--shake) * -1)); }
  40% { transform: translateX(var(--shake)); }
  60% { transform: translateX(calc(var(--shake) * -0.6)); }
  80% { transform: translateX(calc(var(--shake) * 0.6)); }
}
@keyframes pulse { 50% { transform: scale(1.25); } }
@keyframes bob { 50% { transform: translateY(var(--bob)); } }
/* The rider's face just changed: the head pops a little (calm mode and reduced motion keep the face, not the pop) */
@keyframes face-pop { 40% { transform: scale(var(--face-pop)); } }
.face-pop .rider-head { transform-box: fill-box; transform-origin: 50% 90%; animation: face-pop var(--dur-face) ease-out; }
/* Verb feels (the .verb-* classes pick one): a bonk wobbles in big, a clink pops in and
   tilts, a rise floats up softly. All hold still and readable for most of --float-time. */
@keyframes float-bonk {
  0% { opacity: 0; transform: scale(0.4); }
  8% { opacity: 1; transform: scale(1.3) rotate(-6deg); }
  16% { transform: scale(1) rotate(3deg); }
  22%, 80% { opacity: 1; transform: none; }
  100% { opacity: 0; transform: translateY(calc(var(--float-rise) * -1)); }
}
@keyframes float-clink {
  0% { opacity: 0; transform: scale(0.6); }
  10% { opacity: 1; transform: scale(1.15) rotate(8deg); }
  20%, 80% { opacity: 1; transform: none; }
  100% { opacity: 0; transform: translateY(calc(var(--float-rise) * -1)); }
}
@keyframes float-rise {
  0% { opacity: 0; transform: translateY(var(--float-rise)) scale(0.8); }
  15%, 80% { opacity: 1; transform: none; }
  100% { opacity: 0; transform: translateY(calc(var(--float-rise) * -1)); }
}
/* Calm mode and reduced motion: the same stickers, just appearing and fading, no movement */
@keyframes float-fade {
  0% { opacity: 0; }
  8%, 85% { opacity: 1; }
  100% { opacity: 0; }
}
.hit { animation: shake var(--dur-shake); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .horse-art .horse-part { rotate: none !important; translate: none !important; }   /* a horse's head holds still too */
  .dragon-art .dragon-part { rotate: none !important; translate: none !important; }
  .floaters .float { animation: float-fade var(--float-time) linear forwards !important; }
  .surprise-card { animation: float-fade var(--dur-surprise) linear forwards !important; }
}
html.calm *, html.calm *::before, html.calm *::after { animation: none !important; transition: none !important; }
html.calm .horse-art .horse-part { rotate: none !important; translate: none !important; }
html.calm .dragon-art .dragon-part { rotate: none !important; translate: none !important; }
html.calm .floaters .float { animation: float-fade var(--float-time) linear forwards !important; }
html.calm .surprise-card { animation: float-fade var(--dur-surprise) linear forwards !important; }

/* ---------- stickers (ui/sticker-book.js, the reward screen) ----------
   Each sticker says its shape, size and finish (content/stickers.js). A shaped one is an SVG
   backing (a paper edge, its face color, its finish's layers clipped to the shape) with its
   picture on top; a die-cut one is its picture with a paper edge that follows its outline, the
   finish's layers masked to the picture. Both cast one soft shadow. An empty spot is the same
   shape, dashed (a die-cut one: the picture's pale silhouette with a thin outline). */
.sticker-art {
  --size: var(--sticker-m);
  --hx: calc((var(--px, 0.5) - var(--sxn, 0.5)) * 2);   /* the holo sheen: -1 to 1, the pointer's side of the sticker */
  display: grid; place-items: center; flex: none; position: relative; isolation: isolate;
  width: calc(var(--sticker) * var(--size)); height: calc(var(--sticker) * var(--size));
  filter: drop-shadow(0 var(--space-1) var(--space-1) var(--shade));
}
.sticker-art[data-size="s"] { --size: var(--sticker-s); }
.sticker-art[data-size="l"] { --size: var(--sticker-l); }
.sticker-art > * { grid-area: 1 / 1; }
.sticker-art .sticker-back { width: 100%; height: 100%; overflow: visible; }
.sticker-art .sticker-pic, .sticker-cut-finish {
  width: var(--pic-size); height: var(--pic-size);
  translate: 0 var(--pic-shift, 0);   /* the picture's middle where its shape wants it (a heart's is high) */
  font-size: var(--text-lg); object-fit: contain;
}
.sticker-art .sticker-pic > .icon { width: 100%; height: 100%; margin: 0; }
.sticker-edge { fill: var(--paper); stroke: var(--paper); stroke-width: var(--sticker-edge-svg); stroke-linejoin: round; }
.sticker-face { fill: var(--face); }
/* the finishes' layers on a shaped sticker (SVG) */
.sticker-back .stop-shine { stop-color: var(--foil-shine); }
.sticker-back .stop-clear { stop-color: var(--foil-shine); stop-opacity: 0; }
.sticker-back .stop-shade { stop-color: var(--shade); }
.sticker-back .stop-holo-1 { stop-color: var(--rainbow-1); }
.sticker-back .stop-holo-2 { stop-color: var(--rainbow-2); }
.sticker-back .stop-holo-3 { stop-color: var(--rainbow-3); }
.sticker-back .stop-holo-4 { stop-color: var(--rainbow-4); }
.sticker-back .stop-holo-5 { stop-color: var(--rainbow-5); }
.sticker-back .stop-holo-6 { stop-color: var(--rainbow-6); }
.sticker-back .speck-1 { fill: var(--gold); }
.sticker-back .speck-2 { fill: var(--paper); }
.sticker-back .speck-3 { fill: var(--rainbow-6); }
.sticker-grain { opacity: 0.22; }
.sticker-holo { opacity: 0.4; transform: translateX(calc(var(--hx) * var(--holo-travel))); transition: transform var(--dur-slide) ease-out; }
.sticker-holo-band { opacity: 0.9; transform: translateX(calc(var(--hx) * var(--holo-travel) * 2)); }
.sticker-glitter { opacity: 0.85; }
.sticker-twinkle { animation: sticker-twinkle var(--dur-twinkle) ease-in-out infinite alternate; }
@keyframes sticker-twinkle { from { opacity: 0.1; } to { opacity: 0.9; } }
.sticker-art.has-puff { filter: drop-shadow(0 var(--space-1) 0 var(--shade)) drop-shadow(0 var(--space-2) var(--space-2) var(--shade)); }
/* a die-cut sticker: a paper edge all the way round its picture (four sharp shadows, one each way) */
.sticker-art.is-cutout .sticker-pic {
  filter: drop-shadow(var(--sticker-cut) 0 0 var(--paper)) drop-shadow(calc(var(--sticker-cut) * -1) 0 0 var(--paper))
    drop-shadow(0 var(--sticker-cut) 0 var(--paper)) drop-shadow(0 calc(var(--sticker-cut) * -1) 0 var(--paper));
}
.sticker-cut-finish {
  display: grid; pointer-events: none;
  mask: var(--pic-mask) center / contain no-repeat; -webkit-mask: var(--pic-mask) center / contain no-repeat;
}
.sticker-cut-finish > * { grid-area: 1 / 1; }
.cut-grain { background: repeating-linear-gradient(67deg, var(--shade) 0 var(--glitter-dot), transparent var(--glitter-dot) var(--glitter-gap)); opacity: 0.12; }
.cut-gloss { background: linear-gradient(160deg, var(--foil-shine), transparent 45%); }
.cut-holo {
  background: linear-gradient(115deg, var(--rainbow-1), var(--rainbow-2), var(--rainbow-3), var(--rainbow-4), var(--rainbow-5), var(--rainbow-6), var(--rainbow-1));
  background-size: 300% 300%; background-position: calc(50% + var(--hx) * 50%) 50%;
  mix-blend-mode: overlay; opacity: 0.35; transition: background-position var(--dur-slide) ease-out;
}
.cut-glitter {
  background:
    radial-gradient(circle, var(--paper) 0 var(--glitter-dot), transparent calc(var(--glitter-dot) * 1.5)) 0 0 / var(--glitter-gap) var(--glitter-gap),
    radial-gradient(circle, var(--gold) 0 var(--glitter-dot), transparent calc(var(--glitter-dot) * 1.5)) calc(var(--glitter-gap) / 2) calc(var(--glitter-gap) / 3) / var(--glitter-gap) var(--glitter-gap);
  opacity: 0.7; animation: sticker-twinkle var(--dur-twinkle) ease-in-out infinite alternate;
}
.cut-puff { background: radial-gradient(circle at 36% 30%, var(--foil-shine), transparent 55%), radial-gradient(circle at 45% 40%, transparent 60%, var(--shade)); }
/* still in calm mode and with reduced motion: the sheen stays put (the animations stop at the end of this file) */
html.calm .sticker-art { --hx: 0; }
@media (prefers-reduced-motion: reduce) { .sticker-art { --hx: 0; } }
/* empty spots: the shape, dashed, with a soft silhouette of the picture */
.sticker-art.is-empty { filter: none; }
.sticker-art.is-empty .sticker-edge { fill: none; stroke: var(--line); stroke-width: var(--sticker-outline-svg); stroke-dasharray: 5 4; }
.sticker-art.is-shaped.is-empty .sticker-pic { filter: brightness(0); opacity: 0.18; }
.sticker-art.is-cutout.is-empty .sticker-pic {
  filter: brightness(0) invert(1) drop-shadow(var(--border-1) 0 0 var(--line)) drop-shadow(calc(var(--border-1) * -1) 0 0 var(--line))
    drop-shadow(0 var(--border-1) 0 var(--line)) drop-shadow(0 calc(var(--border-1) * -1) 0 var(--line));
}
/* a secret sticker's empty spot: a big soft "?" (its `emptyMark`) instead of a silhouette, in a dashed ring on a die-cut one */
.sticker-art .sticker-mark { font-size: var(--text-2xl); font-weight: var(--weight-heavy); line-height: 1; color: var(--ink-soft); }
.sticker-art.is-cutout .sticker-mark { display: grid; place-items: center; width: 80%; height: 80%; border: var(--border-1) dashed var(--line); border-radius: var(--radius-round); }
.sticker-name { font-weight: var(--weight-heavy); font-size: var(--text-sm); line-height: var(--leading-tight); text-align: center; }
.new-stickers { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-4); margin: var(--space-3) 0; }
.new-sticker { display: flex; flex-direction: column; align-items: center; gap: var(--space-1); max-width: calc(var(--sticker) * 1.9); text-align: center; }
/* "Peel and stick": it flies in turned and small, and presses flat */
.new-sticker.peel .sticker-art { animation: sticker-peel var(--dur-pop) ease-out both; }
/* ...and as it lands, a holographic one's sheen sweeps across it once (none in calm mode) */
.new-sticker.peel .sticker-holo { animation: sticker-holo-sweep var(--dur-shimmer) var(--dur-pop) ease-in-out both; }
.new-sticker.peel .cut-holo { animation: cut-holo-sweep var(--dur-shimmer) var(--dur-pop) ease-in-out both; }
@keyframes sticker-holo-sweep { from { transform: translateX(calc(var(--holo-travel) * -2)); } }
@keyframes cut-holo-sweep { from { background-position: 0 50%; } }
/* the reward shows every new sticker at one size, so the screen never grows */
.new-sticker .sticker-art[data-size] { --size: var(--sticker-m); }
@keyframes sticker-peel {
  from { opacity: 0; transform: translateY(-40%) rotate(-24deg) scale(0.5); }
  70% { opacity: 1; transform: rotate(4deg) scale(var(--scrapbook-drag-scale)); }
}
.sticker-news h2 { display: flex; align-items: center; justify-content: center; gap: var(--space-2); margin: 0; }
.new-stickers > :is(.win-art, .sticker-news-art), .win-pictures > .win-art { flex: none; width: var(--sticker); height: var(--sticker); max-width: 100%; margin: 0; }   /* a milestone picture (your first ride, your first sticker) leads the row, a sticker's size: its room is kept */
.new-stickers > .win-art, .win-pictures > .win-art { width: auto; }   /* a wide picture keeps its shape at a sticker's height */
.win-pictures { display: flex; justify-content: center; gap: var(--space-4); }
/* award stickers after a win (a guardian's, a milestone's): a ribbon in their own row, apart from the stars */
.sticker-news.award-ribbon { border-top: var(--border-2) solid var(--gold); background: var(--gold-soft); }

/* The star card (ui/stars.js): two rows of star slots, filled (a star) or waiting (an outline), and its count.
   After a win each star floats up into its slot; the card keeps one size, so nothing moves as it fills. */
.star-card { display: flex; flex-direction: column; align-items: center; gap: var(--space-1); margin-inline: auto; }
.star-card-name { flex: none; font-weight: var(--weight-heavy); }
/* ui/stars.js sets --star-cols from perCard: ten stars are always two rows of five. */
.star-slots { --slot: var(--star-slot); display: grid; grid-template-columns: repeat(var(--star-cols), var(--slot)); justify-content: center; gap: var(--space-2); }
.star-slot { display: grid; place-items: center; width: var(--slot); height: var(--slot); border-radius: var(--radius-round); background: var(--paper); border: var(--border-2) dashed var(--line); }
.star-slot.is-filled { border-style: solid; border-color: var(--gold-deep); background: var(--gold-soft); }
/* no margin, so the star sits at the slot's middle (an icon's own end margin, .icon, would push it aside) */
.star-slot svg, .star-slot img { width: 70%; height: 70%; margin: 0; }
/* the star drawn with an ink edge, so a filled slot reads on its pale gold (3:1 or more, never color alone) */
.star-slot.is-filled svg, .star-slot.is-filled img { filter: drop-shadow(0 0 var(--border-1) var(--ink)) drop-shadow(0 0 var(--border-1) var(--ink)); }
.star-slot.is-new svg, .star-slot.is-new img { animation: star-float var(--dur-star) ease-out both; }
@keyframes star-float { from { opacity: 0; transform: translateY(var(--star-rise)) scale(0.6); } }
.star-card-count { font-size: var(--text-sm); }
.star-moment { display: flex; flex-direction: column; align-items: center; gap: var(--space-1); text-align: center; }
.star-card-button { flex-direction: column; min-height: var(--target); max-width: 100%; border-radius: var(--radius-sm); background: var(--paper); padding: var(--space-2) var(--space-3); }
.star-card-button > .btn-label { display: flex; flex-direction: column; align-items: center; gap: var(--space-1); }
.star-card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-1); width: 100%; min-height: var(--star-slot); }
.star-packet-stamp { display: inline-flex; align-items: center; gap: var(--space-1); padding: var(--space-1); border: var(--border-2) solid var(--gold-deep); border-radius: var(--radius-sm); background: var(--gold-soft); font-size: var(--text-xs); font-weight: var(--weight-heavy); white-space: nowrap; }
.star-packet-stamp svg, .star-packet-stamp img { width: var(--icon-sm); height: var(--icon-sm); flex: none; }
.star-packet-stamp.is-waiting { visibility: hidden; }
.star-from { margin: 0; min-height: calc(var(--text-md) * var(--leading-tight) * 2); }
.shine-news { display: flex; flex-direction: column; gap: var(--space-2); margin: var(--space-3) 0; }

/* The sticker book: page tabs, then the page, a scrapbook sheet stickers sit anywhere on */
.dialog.sticker-book-dialog, .dialog.card-book-dialog { width: min(var(--dialog-w-lg), calc(100% - var(--space-6))); }
.sticker-tabs, .book-tabs, .book-chips { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-bottom: var(--space-3); }
/* the Finder's page chips are picture squares, one target each, in the pages sheet (.finder-pages-sheet below) */
.btn.sticker-tab { width: var(--target); padding: 0; justify-content: center; }
.btn.sticker-tab > .icon { width: var(--sticker-tab-icon); height: var(--sticker-tab-icon); margin: 0; }
/* the open tab or chip: a thick accent border, a soft fill and heavier words (aria-current says it too) */
.sticker-tab.is-on, .book-tab.is-on, .book-chip.is-on { border: var(--border-2) solid var(--accent); background: var(--accent-soft); font-weight: var(--weight-heavy); }
/* a chip's New! (and the Pages button's) is a dot at its corner, not words over its picture */
.finder-pages-tool .new-mark, .sticker-tab .new-mark { top: 0; right: 0; padding: 0; width: var(--space-3); height: var(--space-3); justify-content: center; }
.finder-pages-tool .new-mark > .icon, .sticker-tab .new-mark > .icon { width: var(--space-2); height: var(--space-2); }
.finder-pages-tool .new-mark-word, .sticker-tab .new-mark-word { position: absolute; width: var(--hairline); height: var(--hairline); overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.sticker-page-name { margin: 0; }
.sticker-page {
  position: relative; width: 100%; aspect-ratio: 4 / 3;
  border: var(--border-1) solid var(--line-soft); border-radius: var(--radius-md);
  background: repeating-linear-gradient(0deg, var(--panel) 0 calc(var(--space-6) - var(--border-1)), var(--line-soft) calc(var(--space-6) - var(--border-1)) var(--space-6));
  touch-action: pan-y;
}
.sticker {
  position: absolute; left: var(--sx); top: var(--sy);
  display: flex; flex-direction: column; align-items: center; gap: var(--space-1);
  min-width: var(--target); min-height: var(--target); padding: var(--space-1);
  border: var(--border-1) solid transparent; border-radius: var(--radius-md);
  background: none; color: var(--ink); font: inherit;
  transform: translate(-50%, -50%) rotate(var(--tilt));
  touch-action: none; user-select: none;
}
.sticker.is-picked { border: var(--border-2) dashed var(--accent); background: var(--accent-soft); transform: translate(-50%, -50%) scale(1.08); z-index: 2; }
.sticker.is-dragging { z-index: 3; transform: translate(-50%, -50%) scale(var(--scrapbook-drag-scale)); }
.sticker.is-dragging .sticker-art { filter: drop-shadow(0 var(--space-2) var(--space-3) var(--shade)); }
.sticker .sticker-name { max-width: 100%; padding: 0 var(--space-1); border-radius: var(--radius-xs); background: var(--glass); overflow-wrap: anywhere; }   /* a long name wraps inside its sticker, never past the page's edge */
.sticker-hint { max-width: var(--sticker-hint-w); color: var(--ink-soft); font-size: var(--text-xs); line-height: var(--leading-tight); text-align: center; }
.sticker-count { display: flex; align-items: center; gap: var(--space-2); font-weight: var(--weight-bold); }
.sticker-memories {
  margin: 0; min-height: var(--finder-memory-h); max-height: var(--finder-memory-h); color: var(--ink-soft); font-size: var(--text-xs); line-height: var(--leading-tight); text-align: center;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: var(--finder-memory-lines); line-clamp: var(--finder-memory-lines); overflow: hidden;
}   /* under a board page: its stickers' memories, clamped to a few lines, the room always kept */
/* the little stickers' row under an island's page: fixed slots, so nothing moves as they are found */
.sticker-strip { margin-top: var(--space-2); padding: var(--space-2) var(--space-3); border: var(--border-1) dashed var(--line-soft); border-radius: var(--radius-md); }
.sticker-strip-title { margin: 0 0 var(--space-1); font-weight: var(--weight-bold); }
.sticker-strip-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--sticker-slot-w), 1fr)); gap: var(--space-2); margin: 0; padding: 0; list-style: none; }
.sticker-strip-slot { display: flex; flex-direction: column; align-items: center; gap: var(--space-1); text-align: center; }
.sticker-strip-slot .sticker-art[data-size] { --sticker: var(--sticker-sm); --sticker-cut: var(--border-1); --size: var(--sticker-m); }
.sticker-strip .sticker-hint { max-width: none; margin: var(--space-1) 0 0; text-align: start; }
.sticker-cover { display: flex; flex-direction: column; align-items: center; gap: var(--space-2); padding: var(--space-5); border-radius: var(--radius-lg); background: var(--gold-soft); text-align: center; }
/* in the Finder the cover is one row, its picture beside its words, so it and Hear it fit the pane */
.is-finder .sticker-cover { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; justify-items: start; column-gap: var(--space-4); padding: var(--space-3); text-align: start; }
.is-finder .sticker-cover > .scrapbook-cover-art { grid-row: 1 / span 3; }
.is-finder .sticker-cover > * { margin: 0; }
.sticker-book-panel.is-finder:has(> .sticker-cover) { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--space-3); }   /* Hear it beside the cover, not under it */
:root[data-layout=phone] .is-finder .sticker-cover { padding: var(--space-2) var(--space-3); }
:root[data-layout=phone] .is-finder .sticker-cover h3 { font-size: var(--text-lg); line-height: var(--leading-tight); }
:root[data-layout=phone] .is-finder .sticker-cover p { font-size: var(--text-sm); line-height: var(--leading-tight); }
:root[data-layout=phone] .is-finder .sticker-cover > .scrapbook-cover-art { width: var(--sticker-sm); height: var(--sticker-sm); }
.sticker-cover h3 { margin: 0; font-size: var(--text-xl); }
.journey { display: flex; flex-direction: column; gap: var(--space-2); margin: var(--space-2) 0; padding: 0; list-style: none; }
.journey-entry { display: flex; align-items: center; gap: var(--space-3); }
/* in a list every sticker is one size, whatever its size on a page */
.journey-entry .sticker-art[data-size] { --sticker: var(--sticker-sm); --sticker-cut: var(--border-1); --size: var(--sticker-m); }
.journey-entry.is-empty { color: var(--ink-soft); }

/* ---------- the card book (ui/card-book.js) ---------- */
.book-summary p { margin: var(--space-1) 0; }
.book-shine { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1); }
.book-grid { display: flex; flex-wrap: wrap; align-items: flex-start; gap: var(--space-4); margin: var(--space-3) 0; }
.book-entry { position: relative; }
.book-entry .count {
  position: absolute; right: var(--space-1); top: var(--space-1); z-index: 1;   /* top right, inside the pocket */
  padding: 0 var(--space-2); border: var(--border-1) solid var(--ink); border-radius: var(--radius-pill); pointer-events: none;   /* a tap on the count opens the card under it */
  background: var(--paper); font-weight: var(--weight-heavy);
}
.card-big { position: relative; display: flex; justify-content: center; margin-bottom: var(--space-3); }
/* what comes and goes in the card's dialog (news, new stickers, why not) floats over the card's foot,
   in no room of its own, so the card, where it is and the buttons never move (Make it shiny stays) */
.card-news {
  position: absolute; inset-inline: 0; bottom: 0; z-index: 1;   /* under a scrolling dialog's sticky header and footer */
  display: flex; flex-direction: column-reverse; align-items: center; gap: var(--space-2);   /* the news nearest the buttons, new stickers over it */
  pointer-events: none;
}
.card-news > * { margin: 0; box-shadow: var(--elev-2); }
.card-news .sticker-news { padding: var(--space-2) var(--space-4); }
.card-news .sticker-news h2 { font-size: var(--text-md); }
.card-news .new-stickers { margin: var(--space-1) 0 0; }
.card-news .new-sticker { flex-direction: row; max-width: none; }
.card-news .new-sticker .sticker-art[data-size] { --sticker: var(--sticker-sm); }
.card-news .new-sticker .hint { display: none; }
.dialog.card-dialog { scroll-padding-bottom: var(--dialog-foot-h); }   /* a short window: Make it shiny, focused, stays clear of Done's row */
.card-big .card { --card-h: min(var(--card-h-lg), var(--card-dialog-h-max)); --card-w: calc(var(--card-h) / var(--card-aspect)); }   /* the big card gives way to the window's height so the dialog's buttons stay in view (Bigger text) */
.card-where { display: flex; align-items: center; justify-content: center; gap: var(--space-2); text-align: center; }
/* a phone held sideways, or a short tablet (data-short): the card, a small one, beside where it is and its buttons; Done's row under both */
:root:is([data-layout=phone], [data-short=tablet]) .card-dialog .dialog-body { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto 1fr; align-items: start; gap: var(--space-2) var(--space-3); }
:root:is([data-layout=phone], [data-short=tablet]) .card-dialog .dialog-body > .card-big { grid-row: 1 / 3; margin-bottom: 0; }
:root:is([data-layout=phone], [data-short=tablet]) .card-dialog .dialog-body > .actions:last-child { grid-column: 1 / -1; }
:root:is([data-layout=phone], [data-short=tablet]) .card-dialog .card-big .card { --card-w: var(--card-w-sm); --card-h: var(--card-h-sm); }
:root[data-layout=phone] .card-dialog .dialog-body > .actions:not(:last-child) { flex-direction: row; flex-wrap: nowrap; }   /* icon squares side by side: all 3 stay in the short window */
:root[data-layout=phone] .card-dialog .dialog-body > .actions:not(:last-child) > .btn { flex: 1 1 0; min-width: 0; }

/* Town places reuse the screen frame. Their pane and footer keep one size while the place content
   scrolls inside the pane when Bigger text or a small window needs more room. */
.town-place-screen { --pane-gap: var(--space-2); container: book / size; }   /* the book's container (screens.css, the scrapbook's @container rules) */
.town-place-screen .house-place-view { --room-h: var(--house-place-room-h); }
.house-place-view { display: flex; flex-direction: column; gap: var(--space-3); min-height: 0; }
.house-place-view .house-room { height: var(--room-h); flex: none; }
.place-card-book { display: flex; flex-direction: column; min-height: 0; flex: 1 1 auto; gap: var(--space-3); }
.place-card-book .book-controls { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "tabs shine" "chips chips"; align-items: center; gap: var(--space-1) var(--space-3); flex: none; min-height: 0; }
.place-card-book .book-tabs { grid-area: tabs; display: flex; flex-wrap: nowrap; gap: var(--space-1); margin: 0; }
.place-card-book .book-tabs .tab { display: inline-flex; align-items: center; gap: var(--space-1); }
.place-card-book .tab-count { padding-inline: var(--space-1); border-radius: var(--radius-round); background: var(--accent-soft); font-weight: var(--weight-bold); }
.place-card-book .book-over { position: absolute; top: var(--space-1); left: 50%; translate: -50% 0; z-index: 2; margin: 0; width: max-content; max-width: calc(100% - var(--space-2)); padding: var(--space-1) var(--space-2); border-radius: var(--radius-md); background: var(--paper); }   /* floats over the page's top: no room of its own */
.place-card-book .book-shine { grid-area: shine; justify-self: end; margin: 0; }
.place-card-book .book-chips { grid-area: chips; display: flex; flex-wrap: nowrap; gap: var(--space-1); margin: 0; }
.place-card-book .book-chips .book-chip { flex: 1 1 0; min-width: 0; min-height: var(--target); padding-block: 0; padding-inline: var(--space-1); font-size: var(--text-sm); line-height: var(--leading-tight); }
.place-card-book .book-paper > .book-paper-art { height: 100%; border-radius: var(--radius-md); }   /* img.art's auto height would let the page's picture grow past its paper */
.place-card-book .book-filter { display: none; }
.card-filter .book-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-2); margin: 0; }
.book-page-count .page-short { display: none; }
:root[data-layout=phone] .place-card-book .book-tabs .tab-paren { display: none; }   /* a badge on a phone's tab is the count alone, whole */
.place-card-book .book-paper { position: relative; display: flex; flex: 1 1 auto; min-height: 0; container-type: size; box-sizing: border-box;
  padding: var(--book-page-pad); padding-inline-start: var(--book-ring-room); border: var(--border-2) solid var(--line); border-radius: var(--radius-md); background: var(--paper-cream); }
.place-card-book .book-grid {
  --book-slot-gap: var(--space-2);
  --book-slot-inset: calc(var(--book-slot-pad) + var(--border-2));   /* a pocket's edge and the room inside it: a card never touches it */
  --book-slot-h: calc((100cqh - var(--book-slot-gap) * (var(--book-rows) - 1)) / var(--book-rows));
  --book-slot-w: calc((100cqw - var(--book-slot-gap) * (var(--book-cols) - 1)) / var(--book-cols));
  display: grid; grid-template-columns: repeat(var(--book-cols), minmax(0, 1fr)); grid-template-rows: repeat(var(--book-rows), minmax(0, 1fr));
  justify-items: stretch; align-items: stretch; align-content: stretch; gap: var(--book-slot-gap); width: 100%; height: 100%; margin: 0;
}
/* a binder page: its rings at the left edge, a clear pocket for every position */
.place-card-book .book-paper::before {
  content: ""; position: absolute; inset-block: var(--book-page-pad); inset-inline-start: calc((var(--book-ring-room) - var(--book-ring-d)) / 2); width: var(--book-ring-d); pointer-events: none;
  background: radial-gradient(circle closest-side, var(--panel) 0 50%, var(--ink-soft) 56% 88%, transparent 92%) 0 0 / 100% calc(100% / var(--book-rows)) repeat-y;
}
.book-slot {
  position: relative; display: grid; place-items: center; min-width: 0; min-height: 0; overflow: hidden;
  border: var(--border-2) solid var(--line); border-radius: var(--radius-md); background: var(--glass);
}
.book-slot::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(135deg, var(--foil-shine), transparent 38%); }   /* the clear pocket's sheen */
.book-slot.is-empty { border-style: dashed; border-color: var(--line-soft); background: var(--panel); }
.book-slot.is-empty::after { display: none; }
.book-slot .book-entry { display: grid; place-items: center; }
.place-card-book .book-grid .card-compact {
  --card-h: max(var(--target), min(var(--book-card-h-max), calc(var(--book-slot-h) - var(--book-slot-inset) * 2), calc((var(--book-slot-w) - var(--book-slot-inset) * 2) * var(--card-aspect))));
  --card-w: max(var(--target), calc(var(--card-h) / var(--card-aspect)));
  --card-gap: 0;
  padding: var(--space-1);
  display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; align-items: stretch; justify-items: stretch;
  font-size: max(var(--text-floor), calc(var(--card-w) * var(--card-scale)));
}
.place-card-book .book-grid .card-compact .card-head { display: grid; place-items: center; width: 100%; height: auto; min-height: 0; }
.place-card-book .book-grid .card-compact .card-art { font-size: min(calc(var(--card-h) * var(--book-card-art-height)), calc(var(--card-w) * var(--book-card-art-width))); }
.place-card-book .book-grid .card-compact .card-name { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; max-width: 100%; overflow: hidden; overflow-wrap: anywhere; }
.place-card-book .book-empty { display: grid; place-content: center; justify-items: center; width: 100%; text-align: center; }
.book-page-count { min-width: var(--book-page-count-w); text-align: center; font-weight: var(--weight-bold); }
.book-tabs .tab { min-width: var(--target-lg); min-height: var(--target); }
.book-tabs .tab.is-on { border: var(--border-2) solid var(--accent); background: var(--accent-soft); font-weight: var(--weight-heavy); }
.scrapbook-drag-preview {
  position: fixed; left: var(--drag-pointer-x); top: var(--drag-pointer-y); z-index: var(--z-drag-preview);
  display: grid; place-items: center; width: calc(var(--sticker) * var(--sticker-l)); height: calc(var(--sticker) * var(--sticker-l));
  translate: -50% -50%; pointer-events: none; filter: drop-shadow(0 var(--space-2) var(--space-3) var(--shade));
}
.scrapbook-drag-preview .sticker-art { width: 100%; height: 100%; }
.town-place-screen .sticker-book { display: flex; flex-direction: column; min-height: 0; flex: 1 1 auto; }
.town-place-screen .sticker-book > .tab-list { flex: none; margin-top: 0; }
.town-place-screen .sticker-book > [role="tabpanel"] { display: flex; flex: 1 1 auto; flex-direction: column; min-height: 0; }
.town-place-screen .scrapbook-workspace { flex: 1 1 auto; min-height: 0; }
.place-book-pager-slot { display: flex; flex: 0 0 var(--place-book-pager-w); justify-content: flex-end; }
.place-book-pager { display: flex; width: 100%; justify-content: space-between; gap: var(--gap-targets); }
.place-book-pager:empty { min-height: var(--target-lg); }


/* The Sticker Finder (ui/sticker-book.js, design-ui.md "Layout per screen"): one grid. Its head row holds the 2 book tabs, the
   Pages button, the open page's name and its count; under it the page, 4:3 and as tall as the pane lets it be, with the little
   stickers beside it. The 32 page chips are in a sheet over the book. Nothing on a board page scrolls; a list page does, inside. */
.town-place-screen .sticker-book.is-finder { position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); align-items: center; gap: var(--space-2); }
.is-finder > .tab-list { grid-template-columns: repeat(2, auto); }
.is-finder > .tab-list .tab { flex-direction: row; gap: var(--space-1); padding-inline: var(--space-3); font-size: var(--text-sm); }
.finder-head > .btn { flex: none; }
.finder-head { display: flex; align-items: center; gap: var(--space-2); min-width: 0; }
.finder-head .sticker-page-name { display: flex; flex: 1 1 auto; align-items: center; gap: var(--space-2); min-width: min-content; font-size: var(--text-md); line-height: var(--leading-tight); }
.finder-head .sticker-page-name > .icon { flex: none; margin: 0; }
.finder-head .sticker-count { flex: none; gap: var(--space-3); margin: 0; }
.finder-count, .finder-shiny { display: inline-flex; align-items: center; gap: var(--space-1); white-space: nowrap; }
.finder-count > .icon, .finder-shiny > .icon { margin: 0; }
.sticker-book-panel.is-finder { grid-column: 1 / -1; align-self: stretch; position: relative; display: flex; flex-direction: column; gap: var(--space-2); min-height: 0; }   /* position: nothing in it (a hidden label) escapes the scroller and scrolls the page */
.sticker-book-panel.is-finder > * { flex: none; }
.sticker-book-panel.is-finder > .finder-board { flex: 1 1 0; min-height: 0; }
.finder-board { container-type: size; display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: var(--space-3); }
.finder-board .sticker-page {
  container-type: size; height: auto; aspect-ratio: var(--finder-page-shape);
  width: min(calc((100cqh - var(--finder-memory-h) - var(--space-1)) * var(--finder-page-shape)), calc(100cqw - var(--finder-side-min-w) - var(--space-3)));
}
.finder-page-col { display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; }
.finder-page-col > .sticker-memories { width: 0; min-width: 100%; }   /* the page sets the column's width, not the words */
.finder-board .sticker { --sticker: max(var(--finder-sticker-min), min(var(--finder-sticker-max), var(--finder-sticker-share))); }
.finder-side { display: flex; flex-direction: column; justify-content: center; gap: var(--space-2); min-width: 0; min-height: 0; }
.finder-side .sticker-strip { margin: 0; }
.finder-side .sticker-move-hint { margin: 0; }
/* The packet ceremony uses the same dialog at every size. The opened packet and its stickers have
   separate rooms; the action stays below them, including in the shortest phone window. */
.dialog.packet-dialog .dialog-body { padding: var(--space-1); }
.dialog.packet-dialog .packet-reveal { display: grid; grid-template-columns: var(--packet-reveal-art) minmax(0, 1fr); grid-template-areas: "packet stickers" "action action"; align-items: center; gap: var(--space-2); }
.dialog.packet-dialog .packet-reveal-art { grid-area: packet; width: var(--packet-reveal-art); height: var(--packet-reveal-art); object-fit: contain; }
.dialog.packet-dialog .packet-reveal-words { grid-area: stickers; margin: 0; text-align: center; }
.dialog.packet-dialog .packet-reveal > .btn { grid-area: action; justify-self: center; }
.dialog.packet-dialog .sticker-news { grid-area: stickers; min-width: 0; padding: var(--space-1); border: 0; box-shadow: none; background: none; }
.dialog.packet-dialog .sticker-news > h2 { position: absolute; width: var(--hairline); height: var(--hairline); overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }   /* the dialog's title says it */
.dialog.packet-dialog .new-stickers { margin: 0; justify-content: center; gap: var(--space-2); }
.dialog.packet-dialog .new-stickers > .sticker-news-art { display: none; }   /* milestone pictures have their own reward; this reveal shows only the packet's stickers */
.dialog.packet-dialog .new-sticker { flex: 1 1 0; min-width: 0; max-width: calc(var(--sticker) * 1.9); }
.dialog.packet-dialog .new-sticker .sticker-name { line-height: var(--leading); }
.dialog.packet-dialog .new-sticker .hint { display: none; }
.dialog.packet-dialog .new-sticker .sticker-art { width: min(calc(var(--sticker) * var(--size)), 24vh); height: min(calc(var(--sticker) * var(--size)), 24vh); }
.dialog.packet-dialog .new-sticker.peel .sticker-art { animation: packet-emerge var(--dur-pop) calc(var(--reveal-index) * var(--dur-pop)) ease-out both; }
@keyframes packet-emerge { from { opacity: 0; transform: translateX(calc(var(--packet-reveal-art) * -1)) scale(var(--packet-emerge-scale)); } }
/* the pages sheet: the chips in rows, over the whole book, with a way to close it */
.finder-pages-sheet {
  position: absolute; inset: 0; z-index: 3; display: grid; grid-template-columns: repeat(var(--finder-sheet-cols), var(--target)); grid-auto-rows: var(--target);
  align-content: start; justify-content: center; gap: var(--space-1); padding: var(--space-2);
  border: var(--border-1) solid var(--line); border-radius: var(--radius-md); background: var(--paper); box-shadow: var(--elev-2);
}
.finder-pages-sheet > .sticker-tabs { display: contents; }
.finder-pages-sheet .sticker-tab { margin: 0; }
.finder-pages-close { width: var(--target); padding: 0; justify-content: center; order: -1; }
/* a page too small for words keeps its pictures: each spot's hint and each sticker's name are said (their labels), not drawn;
   the finder's page is the container (@container reads its own box, never the window's) */
@container (height < 480px) { .finder-side .sticker-move-hint { display: none; } }   /* the board's own height: a short one has no room for the how-to line */
@container (height < 460px) { .finder-board .sticker-page .sticker-hint { position: absolute; width: var(--hairline); height: var(--hairline); overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; } }   /* a spot's hint needs a tall page */
@container (height < 330px) {
  .finder-board .sticker { --finder-sticker-share: var(--finder-sticker-share-bare); }
  .finder-board .sticker-page :is(.sticker-caption, .sticker-hint) { position: absolute; width: var(--hairline); height: var(--hairline); overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}
/* a phone: the 2 book tabs are icon squares, the page is the hero, the little stickers are squares beside it (their words are their names) */
:root[data-layout=phone] .is-finder > .tab-list .tab { min-width: var(--target); padding: 0; }
:root[data-layout=phone] .is-finder > .tab-list .tab-word, :root[data-layout=phone] .finder-shiny-word, :root[data-layout=phone] .finder-board :is(.sticker-caption, .sticker-hint, .sticker-strip-title, .sticker-move-hint),
:root[data-layout=phone] .finder-board .sticker-strip-slot .sticker-caption { position: absolute; width: var(--hairline); height: var(--hairline); overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:root[data-layout=phone] .sticker-book-panel.is-finder { padding-inline: var(--finder-arrow-room); }
:root[data-layout=phone] .finder-board .sticker-strip { padding: var(--space-1); border: 0; }
:root[data-layout=phone] .finder-board .sticker-strip-row { grid-template-columns: repeat(auto-fill, minmax(var(--target), 1fr)); }
/* the page arrows float at the pane's edges, centered (the footer's pager is placed over the page, not in the rail) */
:root[data-layout=phone] #app:has(> .frame[data-kind=framed]) .frame-foot .place-book-pager-slot > .btn { position: absolute; top: 50%; translate: 0 -50%; order: 0; z-index: 1; width: var(--target); min-width: var(--target); height: var(--target); min-height: var(--target); }
:root[data-layout=phone] #app:has(> .frame[data-kind=framed]) .frame-foot .place-book-pager-slot > .btn:first-child { left: calc(var(--rail-1-w) + var(--space-2)); }
:root[data-layout=phone] #app:has(> .frame[data-kind=framed]) .frame-foot .place-book-pager-slot > .btn:last-child { right: var(--space-2); }
/* ---------- powers drawer (ui/powers-drawer.js) ----------
   A side sheet from the right (a bottom sheet on phones). The header, the arrows, the power
   sign and Done stay put while only the list of powers scrolls. On a laptop or tablet (wider
   than 900px) and a phone held sideways it is two columns: the arrows and the sign on the
   left, the list at full height over Done on the right; narrower, they stack. The sign keeps
   one height (--drawer-sign-h) whatever it shows: a power's words are clamped, Take it off is
   always there, and a why note floats over the words. The tiles' states are in the arrow
   tile section. */
.dialog.powers-drawer {
  width: min(var(--panel-narrow), 100%);
  max-width: 100%;
  height: 100%;
  max-height: 100%;
  margin: 0 0 0 auto;
  overflow: hidden;
  border-width: 0 0 0 var(--border-3);
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
  animation: drawer-in var(--drawer-in, var(--dur-slide)) ease-out;
}
.dialog.powers-drawer[open] { display: flex; flex-direction: column; }
.powers-drawer .dialog-body { flex: 1 1 auto; min-height: 0; }
.drawer { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: var(--space-3); }
.drawer-top {
  flex: none; display: flex; flex-direction: column; gap: var(--space-3);
  padding-bottom: var(--space-3);
  border-bottom: var(--border-1) solid var(--line-soft);
}
.drawer-powers { flex: 1 1 auto; min-height: var(--target-lg); overflow-y: auto; }
.drawer > .actions, .drawer-alone { flex: none; }
.drawer > .actions { justify-content: flex-end; margin-top: 0; }
.drawer .arrow-pad { --tile: var(--drawer-tile); }
:root:not([data-layout=phone]) .drawer .arrow-pad { --tile: min(var(--drawer-tile), var(--drawer-tile-vh, 100vh)); }   /* a short window (a small tablet with Bigger text) shrinks the arrows so Take it off stays in view */
.drawer-sign {
  display: grid; grid-template-columns: var(--drawer-sign-pic) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) var(--drawer-sign-row);
  grid-template-areas: "pic words" "buttons buttons";   /* the picture beside the name and words, the buttons under them */
  align-items: center; gap: var(--space-1) var(--space-3);
  height: var(--drawer-sign-h); min-width: 0;
  padding: var(--space-1) var(--space-3);
  background: var(--accent-soft); border-radius: var(--radius-sm);
}
.drawer-sign-show { display: contents; }
.drawer-sign-pic {
  grid-area: pic; align-self: start; display: grid; place-items: center;
  width: var(--drawer-sign-pic); height: var(--drawer-sign-pic);
  border: var(--border-2) solid var(--ink); border-radius: var(--radius-pill);
  background: var(--power, var(--paper));
}
.drawer-sign-pic.is-empty { border-style: dashed; border-color: var(--line); background: var(--paper); }   /* a power goes here */
.drawer-sign-words { grid-area: words; position: relative; align-self: stretch; display: flex; flex-direction: column; justify-content: center; min-width: 0; overflow: hidden; }
.drawer-sign-name { font-size: var(--text-md); line-height: var(--leading-tight); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer-sign-about {
  margin: 0; font-size: var(--text-sm); line-height: var(--leading-tight); overflow-wrap: anywhere;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: var(--drawer-sign-lines); line-clamp: var(--drawer-sign-lines); overflow: hidden;
}
.drawer-sign-words.is-hint .drawer-sign-about { -webkit-line-clamp: var(--drawer-hint-lines); line-clamp: var(--drawer-hint-lines); color: var(--ink); }
.drawer-sign-special { font-weight: var(--weight-bold); }
.drawer-sign-special .icon { vertical-align: text-bottom; }
.drawer-sign-buttons { grid-area: buttons; display: flex; align-items: center; justify-content: flex-end; gap: var(--space-2); }
.drawer-take-off { flex: none; padding-inline: var(--space-3); white-space: nowrap; }
:root:not([data-layout=phone]) .drawer-take-off > .btn-label { min-width: max-content; }   /* one line, beside Hear it on the smallest phone */
.drawer-why { position: absolute; inset: 0; z-index: 1; width: auto; margin: 0; }   /* over the words, in no room of its own */
.drawer-alone { margin: 0; }
.drawer-powers h3 { margin: 0 0 var(--space-2); font-size: var(--text-lg); }
.drawer-power-list { list-style: none; padding: 0; margin: 0 0 var(--space-2); display: flex; flex-direction: column; gap: var(--space-2); }
.drawer-power {
  display: flex; align-items: center; gap: var(--space-3);
  min-height: var(--target-xl, var(--target-lg));
  padding: var(--space-2) var(--space-3);
  background: var(--paper);
  border: var(--border-1) solid var(--line);
  border-left: var(--power-edge) solid var(--power);
  border-radius: var(--radius-sm);
}
.drawer-power.is-holding { background: var(--accent-soft); }
.drawer-power > .new-mark { left: var(--new-mark-out); right: auto; }   /* over the token, clear of Hear it */
.drawer-power-words { display: flex; flex-direction: column; gap: var(--space-0); flex: 1 1 auto; min-width: 0; }
.drawer-power-special, .drawer-power-where { display: flex; align-items: center; gap: var(--icon-gap); font-size: var(--text-sm); }
.drawer-power-where { color: var(--ink-soft); }
.drawer-power-where.is-marked { color: var(--ink); font-weight: var(--weight-bold); }
.drawer-hear { flex: none; }
/* A power's token: a round coin in its color with its picture, the drag handle. Picked up
   it lifts with a dashed ring; while its power is dragged away it leaves a dashed hole. */
.power-token {
  position: relative; flex: none; display: grid; place-items: center;
  width: var(--token, var(--target-lg)); height: var(--token, var(--target-lg));
  min-width: var(--target); min-height: var(--target);
  padding: 0;
  border: var(--border-2) solid var(--ink);
  border-radius: var(--radius-pill);
  background: var(--power, var(--accent-soft));
  box-shadow: var(--elev-1);
  touch-action: none;
}
.power-token-pic { width: 62%; height: 62%; margin: 0; pointer-events: none; }
.power-token.is-picked { scale: 1.1; box-shadow: var(--elev-2); }
.power-token.is-picked::after {
  content: ""; position: absolute; inset: calc(var(--space-1) * -1);
  border: var(--border-2) dashed var(--ink); border-radius: var(--radius-pill);
}
.power-token.is-dragging { background: var(--paper); border-style: dashed; box-shadow: var(--elev-0); }
.power-token.is-dragging .power-token-pic { opacity: 0.25; }
.power-token.is-pinned, .power-token.is-still { touch-action: auto; }
.power-token-badge {
  position: absolute; right: calc(var(--space-1) * -1); bottom: calc(var(--space-1) * -1);
  display: flex; padding: var(--space-0);
  background: var(--paper); border: var(--border-1) solid var(--ink); border-radius: var(--radius-pill);
}
.power-token-badge .icon { margin: 0; }
:root:not([data-layout=phone]) .power-token-badge.is-where { display: none; }   /* a phone's token shows where it is; the row's words say it elsewhere */
/* The token that follows your finger or mouse, and the sparkles when a power lands.
   --drag-x and --drag-y are set from script; the flight itself animates `translate`. */
.drawer-ghost, .drawer-sparkle {
  position: fixed; left: var(--drag-x); top: var(--drag-y); z-index: 3;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.drawer-ghost { margin: 0; scale: 1.1; box-shadow: var(--elev-3); }
.drawer-sparkle { display: flex; font-size: var(--text-xl); }
.drawer-sparkle .icon { margin: 0; }
@keyframes drawer-in { from { translate: 100% 0; } }
/* two columns: tablet, desktop and a phone held sideways (the phone's own block is below) */
:root[data-layout] .drawer {
  display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas: "top alone" "top list" "top done"; gap: var(--space-2) var(--space-4);
}
:root[data-layout] .drawer-top { grid-area: top; padding: 0 var(--space-4) 0 0; border-bottom: 0; border-right: var(--border-1) solid var(--line-soft); }
:root[data-layout] .drawer-alone { grid-area: alone; }
:root[data-layout] .drawer-powers { grid-area: list; }
:root[data-layout] .drawer > .actions { grid-area: done; }
:root[data-layout=tablet], :root[data-layout=desktop] {
  --drawer-sign-lines: 5; --drawer-hint-lines: 6; --drawer-tile-vh: 12vh;   /* the left column has the room: all of a power's words */
}
:root[data-layout=tablet] .dialog.powers-drawer, :root[data-layout=desktop] .dialog.powers-drawer { width: min(var(--panel-wide), 100%); }
:root[data-layout=tablet] .drawer, :root[data-layout=desktop] .drawer { grid-template-columns: var(--drawer-side-w) minmax(0, 1fr); gap: var(--space-3) var(--space-5); }
:root[data-layout=tablet] .drawer-top, :root[data-layout=desktop] .drawer-top { padding-right: var(--space-5); }
/* a phone: three columns at the window's full height. The arrows on the left, the powers as a grid of
   tokens in the middle (a token shows its picture; its name, what it does and where it is are its
   label and the sign's words), the sign over Done on the right. The sign is one grid row, so it
   keeps one height; its buttons are icons only. A why note floats over the sign's words. */
:root[data-layout=phone] .dialog.powers-drawer { width: 100%; }
:root[data-layout=phone] .drawer {
  --token: var(--target-lg); --drawer-tile: var(--target); --drawer-sign-lines: 3; --drawer-hint-lines: 3; --drawer-sign-row: var(--target);
  grid-template-columns: auto minmax(0, 1fr) var(--drawer-sign-w); grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas: "alone alone alone" "pad list sign" "pad list done"; gap: var(--space-2) var(--space-3);
}
:root[data-layout=phone] .drawer-top { display: contents; }
:root[data-layout=phone] .drawer .arrow-pad { grid-area: pad; align-self: center; }
:root[data-layout=phone] .drawer .arrow-tile-name { display: none; }   /* the tile's aria-label keeps the words */
:root[data-layout=phone] .drawer .arrow-tile-cost { grid-row: 3; }
:root[data-layout=phone] .drawer-sign {
  grid-area: sign; height: auto; align-self: stretch; padding: var(--space-1) var(--space-2); gap: var(--space-1) var(--space-2);
}
:root[data-layout=phone] .drawer > .actions { justify-self: end; }
:root[data-layout=phone] .drawer-power-list {
  display: grid; grid-template-columns: repeat(auto-fill, var(--token)); justify-content: center; gap: var(--space-2);
}
:root[data-layout=phone] .drawer-power {
  position: relative; justify-content: center; min-height: 0; padding: 0; background: none; border: 0; border-radius: 0;
}
:root[data-layout=phone] .drawer-power-words, :root[data-layout=phone] .drawer-power > .drawer-hear { display: none; }   /* the sign has the one Hear it */
/* ---------- friends (ui/talk.js, the quest buddy in battle, "wants to come home", ui/places.js) ----------
   A friend's own color arrives as --door (their house's door, content/friends.js). Pictures
   are the rider model at the same scale as riding (--rider-stand-w), like you by your horse. */
.talk, .friend-joins, .stage, .town-map, .world-map, .battle-log {
  --friend-face: 2.6rem;         /* a friend's face in a round frame (their help in battle) */
  --friend-face-zoom: 171%;      /* the rider picture inside the frame: zoomed in on the head... */
  --friend-face-x: -38%;         /* ...and moved so the face sits in the middle */
  --friend-face-y: -10%;
  --art-buddy: clamp(2.2rem, 6vw, 3.8rem);   /* your quest buddy on the battle stage */
}
/* A talk is one height, whatever is said (.claude/reference/design-ui.md "Screen layout"): what you said
   on top, the answers at the bottom with room for the most any line shows, and the scene between
   takes the rest, so a long line grows the bubble into it and never moves the answers. Past its room
   (a long line on a small phone) the scene scrolls inside itself. What you said is a small bubble by you in the
   scene (it has no row of its own). */
.dialog.talk[open] { display: flex; flex-direction: column; height: min(var(--talk-h), calc(100% - var(--talk-margin) * 2)); }
.dialog.talk > .dialog-body { flex: 1 1 0; min-height: 0; container: talk / inline-size; }
.dialog.talk .talk-answers { flex: none; grid-area: answers; }
.dialog.talk .talk-scene { flex: 1 1 0; min-height: 0; overflow-y: auto; grid-area: scene; }
.talk {
  --talk-h: 36rem;               /* the whole dialog, never more than the window has... */
  --talk-margin: var(--space-6); /* ...less this above and below */
  --talk-horse: 11rem;           /* the friend's horse; the friend stands in front of it */
  --talk-you: 3.6rem;            /* you, small, listening */
  --talk-tail: 0.9rem;           /* the speech bubble's tail */
}
.talk-scene { position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "friend bubble you"; align-items: end; gap: var(--space-4); }
.talk-scene > .talk-friend { grid-area: friend; }
.talk-scene > .talk-bubble { grid-area: bubble; }
.talk-scene > .talk-you { grid-area: you; }
.talk-scene.house-room { min-height: var(--room-h); padding: var(--space-3) var(--space-4) var(--space-4); }
.talk-scene.house-room, .room-owner { --talk-horse: var(--room-figure); }
.talk-friend, .friend-joins-art, .room-owner {
  --beside-w: var(--talk-horse);
  position: relative; flex: none; box-sizing: content-box;
  width: var(--beside-w); padding-right: calc(var(--beside-w) * var(--rider-stand-x));
  filter: var(--art-halo);
}
/* their horse peeks in from behind (turned the other way), so the friend stands next to
   their speech bubble and faces you */
.talk-horse, .friend-joins-horse, .room-horse { width: 100%; display: block; transform: scaleX(-1); }
.talk-portrait, .friend-joins-figure, .room-friend { position: absolute; right: 0; bottom: 0; width: calc(var(--beside-w) * var(--rider-stand-w)); }
/* the friend's bubble keeps one size (--talk-bubble-h), and Hear it is always its top corner:
   the words flow around the room kept for it (.talk-hear-room) */
.talk-bubble { position: relative; align-self: center; min-width: 0; }
.talk-bubble > .talk-line { min-height: var(--talk-bubble-h); font-size: var(--text-md); }
.talk-hear-room { float: right; width: calc(var(--target) + var(--space-4)); height: calc(var(--target) + var(--space-2));   /* the button with its caption, and a gap */
  margin: calc(var(--space-2) * -1) calc(var(--space-3) * -1) 0 var(--space-2); }
.talk-bubble > .hear-it { position: absolute; top: var(--space-1); right: var(--space-1); z-index: 1; }
.talk-bubble.pop { animation: map-pop var(--dur-line) ease-out both; }
/* what the friend says: a speech bubble whose tail points at them */
.talk-line {
  position: relative; margin: 0;
  padding: var(--space-3) var(--space-4);
  border: var(--border-2) solid var(--ink); border-radius: var(--radius-lg);
  background: var(--paper); box-shadow: var(--elev-1);
  font-size: var(--text-lg); font-weight: var(--weight-semi); line-height: var(--leading);
}
.talk-line::before {
  content: ""; position: absolute; left: calc(var(--talk-tail) / -2 - var(--border-2)); bottom: var(--space-4);
  width: var(--talk-tail); height: var(--talk-tail);
  background: inherit; border: solid var(--ink); border-width: 0 0 var(--border-2) var(--border-2);
  transform: rotate(45deg);
}
/* what you just answered: your own small bubble by you at the foot of the scene (at most two lines) */
.talk-said {
  position: absolute; right: calc(var(--talk-you) + var(--space-5)); bottom: var(--space-3); z-index: 1;
  margin: 0; min-width: var(--talk-said-min-w); max-width: 40%;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; overflow-wrap: anywhere;
  font-size: var(--text-sm); line-height: var(--leading-tight);
  padding: var(--space-1) var(--space-2);
  border: var(--border-1) solid var(--line); border-radius: var(--radius-lg);
  background: var(--accent-soft); font-weight: var(--weight-bold);
}
.talk-you { width: var(--talk-you); }
.talk-you-art { display: block; width: 100%; filter: var(--art-halo); transform: scaleX(-1); }   /* you face your friend */
/* the answers: same-size tiles (--tile-answer-h) in a fixed grid; a lone answer is one tile too */
.talk-answers {
  --talk-answer-rows: round(up, var(--talk-answers-most, 1) / var(--talk-answer-cols), 1);
  display: grid; grid-template-columns: repeat(var(--talk-answer-cols), minmax(0, 1fr)); grid-auto-rows: var(--tile-answer-h); align-content: start; gap: var(--talk-answers-gap);
  height: calc(var(--talk-answer-rows) * (var(--tile-answer-h) + var(--talk-answers-gap)) - var(--talk-answers-gap));
}
.btn.talk-answer {
  height: var(--tile-answer-h); min-width: 0; justify-content: flex-start; padding-inline: var(--space-4);
  border-radius: var(--radius-lg); font-size: var(--text-lg); text-align: left; white-space: normal; line-height: var(--leading-tight);
}
.talk-answer > .icon { flex: none; width: var(--tile-answer-pic); height: var(--tile-answer-pic); }
.talk-answer > .btn-label { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }

/* a friend's face, round: the rider picture zoomed in on the head */
.buddy-face {
  flex: none; display: block; overflow: hidden;
  width: var(--friend-face); height: var(--friend-face);
  border: var(--border-1) solid var(--ink); border-radius: var(--radius-round);
  background: var(--paper);
}
.buddy-face > .art { display: block; width: var(--friend-face-zoom); max-width: none; margin: var(--friend-face-y) 0 0 var(--friend-face-x); }

/* "Nova wants to come home with you!" on New island found */
.friend-joins {
  --talk-horse: var(--art-pair);
  --talk-tail: 0.9rem;
  display: flex; align-items: center; gap: var(--space-5);
  margin: var(--space-4) 0; text-align: left;
  border-left: var(--power-edge) solid var(--door);
}
.friend-joins-words { min-width: 0; }
.friend-joins h2 { display: flex; align-items: center; gap: var(--space-2); margin: 0 0 var(--space-3); }
/* New island found fits its pane unscrolled: its lines sit closer and the friend a little smaller.
   The words (and the friend who joins) show in full, or on a short upright phone scroll inside their room
   (SCROLLS_INSIDE); the pictures over them
   (.cleared-art, side by side) take the room the words leave, and give way to nothing if need be */
.cleared .story-lines { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; justify-content: safe center; overflow-y: auto; }
.cleared .story-line { flex: none; margin: var(--space-2) 0; }
.cleared-art { flex: 0 1 var(--art-milestone-height); min-height: 0; display: flex; justify-content: center; gap: var(--space-3); overflow: hidden; }
.cleared-art > .milestone-art { width: auto; height: 100%; max-width: 50%; margin: 0; }
.cleared .friend-joins { --talk-horse: var(--art-joins); flex: none; margin: var(--space-2) 0; }

/* the town: friends stand on the lawn (at the scale of a rider on a horse), and a friend's
   house shows who is coming along */
.town-friends .friend-standing { width: calc(var(--town-friend) * var(--rider-stand-w) * 1.6); filter: var(--art-halo); }
.map-friends .friend-standing { width: calc(var(--map-friend) * var(--rider-stand-w) * 1.6); max-width: none; filter: var(--art-halo); }
/* you stand beside a friend's house (it is smaller than a place), not on its door */
.map-token.on-friend-house { --stand: calc(var(--map-house) * 0.3); translate: calc(-50% + var(--map-house) * 0.62) calc(-100% + var(--stand)); }
.buddy-note { margin: var(--space-2) 0; }
.buddy-along { display: flex; align-items: center; gap: var(--space-2); margin: var(--space-1) 0 0; font-weight: var(--weight-bold); }
/* on a phone the sign keeps only its buttons; who is coming along still shows */
.map-sign .map-sign-text > p.buddy-along { display: flex; }

/* your quest buddy in battle: small, beside your horse, looking around (they don't fight) */
.hero-art > .buddy-figure { position: absolute; left: 0; bottom: 0; z-index: 1; width: var(--art-buddy); filter: var(--art-halo); }
/* what their help did is a log line with their face where an event's picture would be */
.log-pic > .buddy-face { width: 100%; height: 100%; border: 0; }
/* Swap a card (a buddy's bonus): the button above End turn, and the cards you can swap */
.swap-card { white-space: nowrap; }
.swap-note { display: flex; align-items: center; gap: var(--space-2); font-weight: var(--weight-bold); }
.hand .card.swappable { box-shadow: 0 0 0 var(--border-2) var(--good); }

@container talk (max-width: 40rem) {
  .talk-scene { --talk-horse: 8rem; }
}
/* a battle rule, not a talk's: Swap a card keeps a full target on a phone */
:root[data-layout=phone] .swap-card { min-height: var(--target); padding-inline: var(--space-3); }
/* What a small phone needs, upright or held sideways (a window under 500px tall has the room of one): a footer's row of buttons, the barn, and a friend who joins. */
/* ...but a footer's row stays one row (the footer is one height, --foot-h): its buttons share it and their words wrap */
:where(:root[data-layout=phone]) .frame-foot > .actions { flex-direction: row; flex-wrap: nowrap; align-items: stretch; }
:where(:root[data-layout=phone]) .frame-foot > .actions > .btn { flex: 1 1 0; min-width: 0; padding-inline: var(--space-2); white-space: normal; }
:where(:root[data-layout=phone]) .frame-foot > .actions:has(> .btn:nth-child(3)) > .btn { font-size: var(--text-sm); padding-inline: var(--space-1); }   /* three share the row: room for a word like "thanks," */
:where(:root[data-layout=phone]) .frame-foot > .actions:has(> .btn:nth-child(3)) > .btn > .icon { display: none; }   /* three share the row: their words get the room */
html.big-text:where([data-layout=phone]) .frame-foot > .actions > .btn > .icon { display: none; }   /* with Bigger text, two do too ("Take the sword!") */
:where(:root[data-layout=phone]) .frame-foot > .actions > .btn > .btn-label { line-height: var(--leading-tight); display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }   /* two lines at most, so a button keeps the row's height (its name is all of it) */
:where(:root[data-layout=phone]) .friend-joins { --talk-horse: var(--art-friend); flex-direction: column; align-items: flex-start; gap: var(--space-3); }
/* here the friend is above their words, so the tail points up */
:where(:root[data-layout=phone]) .friend-joins .talk-line::before { top: calc(var(--talk-tail) / -2 - var(--border-2)); bottom: auto; border-width: var(--border-2) 0 0 var(--border-2); }
/* on a phone the friend stands beside "Nova wants to come home with you!", their words under both */
:where(:root[data-layout=phone]) .cleared .friend-joins { --talk-horse: var(--art-friend); display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; column-gap: var(--space-3); margin: var(--space-1) 0; padding: var(--space-2) var(--space-3); }
:where(:root[data-layout=phone]) .cleared .friend-joins-words { display: contents; }
:where(:root[data-layout=phone]) .cleared .friend-joins h2 { margin: 0; font-size: var(--text-md); grid-column: 2; align-self: end; }
:where(:root[data-layout=phone]) .cleared > .frame-pane { --pane-gap: var(--space-2); }
:where(:root[data-layout=phone]) .cleared .friend-joins .talk-line { grid-column: 2; margin-top: 0; padding: var(--space-1) var(--space-3); font-size: var(--text-sm); }
:where(:root[data-layout=phone]) .cleared .story-line { margin: var(--space-1) 0; font-size: var(--text-md); }
/* a horse's card chip: a smaller picture, and the card's name never breaks (with Bigger text the
picture goes over it) */
:where(:root[data-layout=phone]) .create-horse .card-chip { margin: 0; }
:where(:root[data-layout=phone]) .card-chip { flex-wrap: wrap; justify-content: center; max-width: 100%; padding-inline: var(--space-1); }
:where(:root[data-layout=phone]) .card-chip > span:not(.icon) { white-space: nowrap; }
:where(:root[data-layout=phone]) .card-chip > .icon { width: var(--icon-md); height: var(--icon-md); }
/* the barn on a phone (or held sideways): your horse big in its stall, its things and then the trick and the pat in one row
along the front, and the meters as a strip of icons over the stall; the rail has only the way back (the sign's words are
kept for screen readers) */
:where(:root[data-layout=phone]) .barn-screen { --tile-barn-h: var(--target); --barn-tool-w: 4.5rem; --barn-horse-share: 0.86; --barn-tool-pic: 2rem; --barn-tool-gap: var(--space-1); --bin-pad: var(--space-1); --barn-status-lines: 2; --bond-shoe: calc(var(--icon-md) * 0.7); }
:where(:root[data-layout=phone]) .barn { --barn-horse-w: min(52%, calc(var(--barn-horse-h) * 1.2)); --care-mood: 2.4rem; }
:where(:root[data-layout=phone]) .barn-screen .barn { --barn-front: calc(var(--tile-barn-h) + var(--space-2)); }   /* the things stand on the floor, close to the front */
:where(:root[data-layout=phone]) .barn-tools { padding-inline: var(--space-1); }
/* the care things, then a gap, then the trick and the pat: one row of tiles (the sign's copies are not drawn: the rail has only the way back) */
:root[data-layout=phone] .barn-tools { grid-template-columns: repeat(var(--barn-cols), minmax(0, var(--barn-tool-w))) var(--barn-tool-spacer) repeat(2, minmax(0, var(--barn-tool-w))); }
:root[data-layout=phone] .barn-tool-spacer { display: block; }
:root[data-layout=phone] .barn-tool-extras > .btn { height: var(--tile-barn-h); min-width: 0; padding-inline: var(--space-1); }
/* the meters float over the stall as one strip of icons, their counts said by the meters, not drawn */
/* one row of five on a phone: pictures only (each still says its name to screen readers) */
:where(:root[data-layout=phone]) .barn-tool-word { display: none; }
/* the meters on a phone are just their pips (each is a progress bar that says its count) */
:where(:root[data-layout=phone]) .care-meter-count, :where(:root[data-layout=phone]) .bond-count { display: none; }
:where(:root[data-layout=phone]) .barn-opener-word { font-size: var(--text-xs); padding: 0 var(--space-1); }

/* ---------- the Friendship Sword (screens/gift.js, the team in battle, the ending) ----------
   A gift's story moment, the whole team cheering at the side of a battle, the sparkly hit and
   your friends at the ending. A friend's own color arrives as --door, the gift's as --power. */
.gift, .finale, .stage {
  --gift-figure: clamp(2.6rem, 9vw, 4rem);     /* a friend cheering, on the gift screen and the ending */
  --gift-sword: clamp(3rem, 10vw, 4rem);       /* the sword over your hands... */
  --gift-sword-fit: 34cqh;                     /* ...never taller than the picture holds, with you under it */
  --gift-figure-fit: 35cqh;                    /* ...and every figure in it */
  --gift-hold: 0.4;                            /* ...its hilt in your raised hands (this much of its width overlaps you) */
  --gift-magic: 1rem;                          /* a friend's sparkle of magic... */
  --gift-fly: clamp(2.5rem, 12vw, 7rem);       /* ...and how far it flies toward the sword */
  --team-face: 2.6rem;                         /* a cheering friend's portrait on the battle stage */
  --gift-scene-h: clamp(9rem, 29vh, 16rem);    /* the gift's picture: the same height on every step, and what's in it fits... */
  --gift-scene-h-phone: 7rem;                  /* ...on a phone, shorter, so the last step's words fit under it */
  --gift-mount: clamp(3.4rem, 11vw, 6rem);     /* you, or a friend, riding a horse */
  --gift-far: clamp(2.4rem, 8vw, 4rem);        /* the volcano far off, or magic in the air */
  --gift-wrap: clamp(2.6rem, 8vw, 4rem);       /* the wrapped gift */
  --gift-ride: clamp(3rem, 14vw, 8rem);        /* how far your friends ride in from */
  --chat-max: 17rem;                           /* a friend's speech bubble in battle: its widest... */
  --chat-face: 1.8rem;                         /* ...the speaker's face inside it... */
  --hero-col: 37%;                             /* where the stage's second column starts: a buddy's bubble stands in the sky there, beside you */
  --chat-tail: 0.55rem;                        /* ...and its little point toward them */
}
/* the picture beside the words, and what the gift does (its arrow tile and words) across under both,
   so the last step fits the pane with the go button in its place */
/* It fills the pane; if the words don't fit (Bigger text), they scroll inside their room (SCROLLS_INSIDE). */
.gift-body {
  flex: 1 1 0; min-height: 0; text-align: center;
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: minmax(0, 1fr) auto; grid-template-areas: "scene words" "power power"; align-items: center; column-gap: var(--space-5);
}
.gift-body > .gift-scene { grid-area: scene; }
.gift-body > .gift-words { grid-area: words; max-height: 100%; overflow-y: auto; }
.gift-body > .gift-power { grid-area: power; margin: 0; max-width: none; text-align: left; }
.gift-words > .story-line { margin: var(--space-1) 0; line-height: var(--leading-tight); }
.gift-from { display: flex; align-items: center; justify-content: center; gap: var(--space-2); margin: var(--space-2) 0; font-weight: var(--weight-bold); }
.gift-scene {
  display: flex; align-items: flex-end; justify-content: center; gap: var(--space-3);
  margin: var(--space-3) 0; padding: var(--space-5) var(--space-2) var(--space-4);
  border: var(--border-2) solid var(--gold-deep); border-radius: var(--radius-lg);
  background: var(--gold-soft);
  height: var(--gift-scene-h); box-sizing: border-box;   /* one height on every step of the story */
  container-type: size;   /* what's in it is sized to fit it (cqh) */
}
.gift-side, .finale-party { display: flex; align-items: flex-end; justify-content: center; gap: var(--space-2); }
.finale-party { flex-wrap: wrap; margin: var(--space-3) 0; }
.gift-friend, .finale-friend { position: relative; display: flex; flex-direction: column; align-items: center; gap: var(--space-1); }
.gift-figure, .finale-figure { width: var(--gift-figure); filter: var(--art-halo); }
.gift-figure { width: min(var(--gift-figure), var(--gift-figure-fit)); }
/* a friend's name, ringed in their color (the name says who, not the color) */
.gift-name {
  padding: 0 var(--space-2);
  border: var(--border-2) solid var(--door); border-radius: var(--radius-pill);
  background: var(--paper); color: var(--ink);
  font-size: var(--text-sm); font-weight: var(--weight-bold);
}
.gift-middle { display: flex; flex-direction: column; align-items: center; }
.gift-sword { width: min(var(--gift-sword), var(--gift-sword-fit)); filter: var(--art-halo); }
.gift-you { width: calc(min(var(--gift-figure), var(--gift-figure-fit)) * 1.15); filter: var(--art-halo); }   /* you, a little bigger than your friends */
.gift-sword + .gift-you { margin-top: calc(min(var(--gift-sword), var(--gift-sword-fit)) * var(--gift-hold) * -1); }   /* you hold the sword up: its hilt in your hands */
/* each friend's magic: a dot in their color that flies to the sword, once. Calm mode and
   reduced motion show the finished picture: the sword with its stripes. */
.gift-magic {
  position: absolute; top: 0; left: 50%;
  width: var(--gift-magic); height: var(--gift-magic); margin-left: calc(var(--gift-magic) / -2);
  border: var(--border-1) solid var(--ink); border-radius: var(--radius-round);
  background: var(--door);
  opacity: 0;
}
.gift-right .gift-magic { --gift-dir: -1; }
.gift-scene.fresh .gift-magic { animation: gift-fly var(--dur-pulse) ease-in both; }
.gift-scene.fresh .gift-sword { animation: map-pop var(--dur-pop) var(--delay-gift-sword) ease-out both; }
.gift-scene.fresh .sword-stripe { animation: gift-stripe var(--dur-grow) var(--delay-gift-stripes) ease-out both; }
.sword-sparkle { transform-box: fill-box; transform-origin: center; animation: twinkle var(--dur-twinkle) ease-in-out infinite; }
.sword-sparkle:nth-child(even) { animation-delay: calc(var(--dur-twinkle) / -2); }
@keyframes gift-fly {
  0% { opacity: 0; transform: none; }
  20% { opacity: 1; }
  100% { opacity: 0; transform: translate(calc(var(--gift-fly) * var(--gift-dir, 1)), calc(var(--gift-figure) * -0.5)) scale(0.5); }
}
@keyframes gift-stripe { from { opacity: 0; } }
@keyframes twinkle { 50% { transform: scale(0.6); opacity: 0.6; } }
/* what the gift does: its arrow tile (the shared one, untouched) beside the words */
.gift-power { display: flex; align-items: center; gap: var(--space-4); padding: var(--space-2) var(--space-4); }
.gift-power > .arrow-tile { flex: none; }
.gift-power-words { flex: 1 1 0; min-width: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-flow: column; grid-template-rows: auto auto; column-gap: var(--space-4); align-items: center; }
.gift-power-words > p { margin: var(--space-1) 0; font-size: var(--text-sm); line-height: var(--leading-tight); }
.gift-power-words > .special { grid-row: span 2; }   /* what it does, beside where it went and your hearts */
/* the gift's story, one step at a time (world.js `gift.steps`): the screen fills the window and the
   scene keeps one height from step to step, so the go button stays in one place; each step's parts
   come in once */
.gift-side-wrap { display: flex; align-items: flex-end; min-width: 0; }
.gift-step { margin: 0; color: var(--ink-soft); font-size: var(--text-sm); font-weight: var(--weight-bold); }
.gift-mount.mount { --art-mount: var(--gift-mount); filter: var(--art-halo); }
.gift-rider .gift-mount.mount { --art-mount: calc(var(--gift-mount) * 0.85); }
.gift-rider.gift-right .gift-mount { scale: -1 1; }   /* friends on the right face you too */
.gift-far { width: var(--gift-far); height: var(--gift-far); }
.gift-twinkle { animation: twinkle var(--dur-twinkle) ease-in-out infinite; }
/* the gift in their colors: a band each, under a bow */
.gift-wrapped { position: relative; display: grid; place-items: center; width: var(--gift-wrap); height: var(--gift-wrap); }
.gift-wrap-bands {
  position: absolute; inset: 15% 10% 5%; display: flex; overflow: hidden;
  border: var(--border-2) solid var(--ink); border-radius: var(--radius-sm);
}
.gift-wrap-band { flex: 1; background: var(--door); }
.gift-wrap-pic { position: relative; width: 70%; height: 70%; }
.gift-scene.fresh.shows-rumble { animation: shake var(--dur-rumble) ease-in-out both; }
.gift-scene.fresh .gift-rider.gift-left { animation: gift-ride-in var(--dur-ride-in) ease-out both; }
.gift-scene.fresh .gift-rider.gift-right { --gift-dir: -1; animation: gift-ride-in var(--dur-ride-in) ease-out both; }
.gift-scene.fresh .gift-wrapped { animation: map-pop var(--dur-pop) var(--dur-ride-in) ease-out both; }
@keyframes gift-ride-in { from { opacity: 0; transform: translateX(calc(var(--gift-ride) * -1 * var(--gift-dir, 1))); } }

/* the whole team at the side of the battle: round portraits, each ringed in their own color,
   in a column down the stage's left edge (a row across its top corner on a phone) */
.stage > .team-cheer {
  position: absolute; top: var(--space-2); left: var(--space-2); z-index: 2;
  display: flex; flex-direction: column; gap: var(--space-1);
}
.team-face { width: var(--team-face); height: var(--team-face); border: var(--border-2) solid var(--door); box-shadow: 0 0 0 var(--border-1) var(--ink); }

/* The Surprise arrow's gift box (battle.js surpriseView): over the middle of the stage, a card
   with the little box, what came out (big) and its name. It pops in, stays a moment and fades,
   never moving anything and never in the way of a tap. Calm mode and reduced motion: it only
   fades in and out (float-fade, above). */
.stage > .surprise-pop {
  position: absolute; inset: 0; z-index: 4;
  display: grid; place-items: center;
  pointer-events: none;
}
.surprise-card {
  display: grid; grid-template-columns: auto auto; grid-template-rows: auto auto; align-items: center; justify-items: center;
  column-gap: var(--space-2);
  max-width: 90%;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-lg); border: var(--border-3) solid var(--gold);
  background: var(--paper); box-shadow: var(--elev-3);
  opacity: 0;
  animation: surprise-pop var(--dur-surprise) ease-out forwards;
}
.surprise-box { grid-row: 1 / 3; display: grid; }
.surprise-box .icon { width: var(--surprise-box); height: var(--surprise-box); animation: surprise-wiggle var(--dur-shake) ease-in-out var(--times-invite); }
.surprise-out { display: grid; place-items: center; width: var(--surprise-pic); height: var(--surprise-pic); }
.surprise-out .surprise-pic { width: 100%; height: 100%; object-fit: contain; animation: surprise-out var(--dur-pop) var(--dur-shake) ease-out both; }
.surprise-out .surprise-pic > .icon { width: 100%; height: 100%; }   /* a sticker without art: its icon, as big */
.surprise-words { display: grid; justify-items: center; text-align: center; font-size: var(--text-lg); font-weight: var(--weight-bold); line-height: 1.1; }
.surprise-words strong { font-size: var(--text-xl); font-weight: var(--weight-ultra); }
@keyframes surprise-pop {
  0% { opacity: 0; transform: scale(0.4); }
  12% { opacity: 1; transform: scale(1.08); }
  20%, 80% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1); }
}
/* a lost battle keeps its Surprise stickers: a line in the rest dialog with the sticker's picture */
.kept-sticker { display: flex; align-items: center; gap: var(--space-2); }
@keyframes surprise-wiggle { 25% { transform: rotate(-12deg); } 75% { transform: rotate(12deg); } }
@keyframes surprise-out { 0% { transform: translateY(40%) scale(0.2); opacity: 0; } 70% { transform: translateY(-8%) scale(1.1); opacity: 1; } 100% { transform: none; opacity: 1; } }

/* The foes still to come (engine/queue.js; battle.js waitingPeek) peek in from the stage's right
   edge: the stage keeps a strip for them (.has-waiting), so they grow nothing and cover no foe on
   stage. Each is mostly past the edge (the stage clips it), soft, and now and then leans in a
   little (not in calm mode or reduced motion); the next one is in front, the others behind it,
   a little higher. The strip is a note you can focus: it says how many are coming, and who. */
.stage.has-waiting { padding-right: var(--peek-room); }
.stage > .waiting-peek {
  position: absolute; top: 0; bottom: 0; right: 0; width: var(--peek-room); z-index: 1;
  border-radius: var(--radius-md);
}
.waiting-peek .peek {
  position: absolute; top: 50%; left: 0; width: var(--art-peek); z-index: calc(3 - var(--peek-i));
  transform: translateY(calc(var(--peek-i) * var(--peek-step) * -1));
  opacity: var(--peek-soft);
}
.waiting-peek .peek-pic {
  display: block; width: 100%; max-width: none; height: auto;
  animation: peek-sway var(--dur-shimmer) ease-in-out infinite alternate;
}
@keyframes peek-sway { to { transform: translateX(var(--peek-sway)); } }
/* a foe stepping in (EVENT_LOOKS `burst: 'arrive'`): it hops in once, from the edge where it was
   peeking (--to-edge places away). Nothing in calm mode or reduced motion; the sparkle floater and
   the ledger's row still come. */
.burst-arrive .foe-art { animation: foe-arrive var(--dur-pop) ease-out both; }
@keyframes foe-arrive {
  0% { opacity: var(--peek-soft); transform: translateX(calc(var(--to-edge, 1) * var(--arrive-step))); }
  60% { opacity: 1; transform: translateX(0) translateY(-10%) scale(1.05); }
  100% { opacity: 1; transform: none; }
}
/* a friend's speech bubble (content/friends.js BATTLE_CHATTER): it floats over the stage beside
   the one speaking, so nothing moves; taps go through it. Their face says who (with their name in
   the ledger), not the color. Beside the team's column, or by your buddy at the bottom left. */
.stage > .chat-bubble {
  position: absolute; z-index: 4; pointer-events: none;
  display: flex; align-items: center; gap: var(--space-2);
  max-width: min(62%, var(--chat-max)); margin: 0;
  padding: var(--space-2) var(--space-3);
  border: var(--border-2) solid var(--door); border-radius: var(--radius-lg);
  background: var(--paper); color: var(--ink); box-shadow: var(--elev-1);
  font-size: var(--text-md); font-weight: var(--weight-bold); line-height: var(--leading-tight); text-align: left;
  animation: map-pop var(--dur-pop) ease-out both;
}
.chat-bubble > .buddy-face { width: var(--chat-face); height: var(--chat-face); }
.chat-words { min-width: 0; }
.chat-bubble::before {
  content: ""; position: absolute;
  width: var(--chat-tail); height: var(--chat-tail);
  background: var(--paper); border: solid var(--door); border-width: 0 0 var(--border-2) var(--border-2);
}
.stage > .chat-bubble.from-team {
  top: calc(var(--space-2) + var(--speaker) * (var(--team-face) + var(--space-1)));
  left: calc(var(--space-2) * 2 + var(--team-face));
}
.chat-bubble.from-team::before { left: calc(var(--chat-tail) / -2 - var(--border-1)); top: calc(var(--team-face) / 2 - var(--chat-tail)); rotate: 45deg; }
.stage > .chat-bubble.from-buddy { top: var(--space-5); left: var(--hero-col); max-width: min(calc(100% - var(--hero-col) - var(--plate-w) * 2 - var(--space-8)), var(--chat-max)); }   /* clear of the foes' move badges (room for two foes) */   /* in the sky beside you and your buddy, never over your plate's name */
.chat-bubble.from-buddy::before { left: calc(var(--chat-tail) / -2 - var(--border-1)); top: var(--space-3); rotate: 45deg; }

/* a sparkly hit (EVENT_LOOKS `burst: 'sparkle'`): a ring of sparkles puffs out over the foe,
   once. Nothing in calm mode or reduced motion; the sparkle floater and the words still come. */
.burst-sparkle .foe-art::before {
  content: ""; position: absolute; inset: 0; z-index: 3;
  border: var(--border-3) dotted var(--gold); border-radius: var(--radius-round);
  box-shadow: 0 0 var(--space-4) var(--gold), inset 0 0 var(--space-4) var(--gold);
  opacity: 0; pointer-events: none;
  animation: burst-sparkle var(--dur-burst) ease-out both;
}
@keyframes burst-sparkle {
  0% { opacity: 0; transform: scale(0.4); }
  25% { opacity: 1; }
  100% { opacity: 0; transform: scale(1.5) rotate(60deg); }
}

/* the scene beside its words whenever the pane has room; stacked only in a narrow pane (a safety: no supported window is that narrow) */
.gift > .frame-pane { container-type: inline-size; }
@container (max-width: 28rem) {
  .gift-body { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto; grid-template-areas: "scene" "words" "power"; gap: 0; }
}


/* A talk on a phone and a short tablet: the scene on the left, the answers stacked in one column on the
   right (Bye, the Close X, over them); the bubble runs across the scene's width over the figures, which scale
   down before the line scrolls; a phone's chrome is thin, so 4 answers of --target fit under the title. */
:root[data-layout=phone] .dialog.talk[open] { --dialog-pad: var(--space-2); --talk-answers-gap: var(--space-1); }
:root[data-layout=phone] .dialog.talk.talk { --talk-margin: var(--space-1); --room-figure: 5.6rem; }
:root[data-layout=phone] .dialog.talk .btn.talk-answer { min-height: 0; font-size: var(--text-sm); padding-inline: var(--space-2); gap: var(--space-2); }
:root[data-layout=phone] .dialog.talk .talk-scene.house-room { min-height: 0; padding: var(--space-2); }
:root:is([data-layout=phone], [data-short=tablet]) .dialog.talk.talk { --talk-answer-cols: 1; --tile-answer-h: var(--target); --tile-answer-pic: 1.4rem; --talk-bubble-h: 3.6em; }
:root[data-short=tablet] .dialog.talk.talk { --talk-answers-gap: var(--space-2); --tile-answer-h: var(--target-lg); }
:root:is([data-layout=phone], [data-short=tablet]) .dialog.talk > .dialog-body {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, var(--talk-answers-w)); grid-template-rows: minmax(0, 1fr); grid-template-areas: "scene answers"; column-gap: var(--space-3);
}
:root:is([data-layout=phone], [data-short=tablet]) .dialog.talk .talk-scene.talk-scene {
  container-type: size; --talk-horse: min(11rem, 40cqh); --talk-you: calc(var(--talk-horse) * 0.45);
  grid-template-columns: auto minmax(0, 1fr) auto; grid-template-rows: auto minmax(0, 1fr); grid-template-areas: "bubble bubble bubble" "friend said you"; row-gap: var(--space-2); column-gap: var(--space-2);
}
:root:is([data-layout=phone], [data-short=tablet]) .dialog.talk .talk-you { display: block; }
:root:is([data-layout=phone], [data-short=tablet]) .dialog.talk .talk-said { position: static; grid-area: said; justify-self: end; max-width: 100%; margin-bottom: var(--space-1); }
:root:is([data-layout=phone], [data-short=tablet]) .dialog.talk .talk-bubble { align-self: start; }
:root:is([data-layout=phone], [data-short=tablet]) .dialog.talk .talk-line::before { left: var(--space-5); bottom: calc(var(--talk-tail) / -2 - var(--border-2)); border-width: 0 var(--border-2) var(--border-2) 0; }
/* ---------- short screens ----------
   A window under 900px tall (laptops, tablets on their side, phones): a map screen's page title
   and sign are short, so the map gets the room (--map-room). The sign keeps where you are, its
   state, foes and prize; the place's story is still in its spot's name (read aloud and to
   screen readers) and, for an island, on its own screen. */
@container app (max-height: 868px) {   /* #app's content box: the window's 900px less its 16px padding above and below (a query cannot read var(); a window within 32px of 900 may differ by that) */
  .frame-pane:has(> .map-area) { --pane-gap: var(--space-2); }
  .frame-foot .map-sign-text > p:not(.map-sign-foes):not(.why-note):not(.buddy-along):not(.wish-note) { display: none; }
}
/* A short window (a laptop): the battle leaves out its key help line (each key is also on its
   card, arrow tile and End turn) and the room above the fighters, so the fighters stay big */
/* The small tablet, 1024x600 (a content height under --small-tablet-h, 640px, as every small-tablet rule's query): the barn's title is only for screen readers, its tool row is
   one --row-lg tall so the stall keeps its room. */
@container app (max-height: 640px) {   /* --small-tablet-h */
  :where(:root:not([data-layout=phone])) .barn-screen { --tile-barn-h: var(--row-lg); --barn-tool-pic: 1.8rem; }
  :where(:root:not([data-layout=phone])) .tack-screen { --tack-sign-h: var(--row-lg); }
  :where(:root:not([data-layout=phone])) .tack-screen > .region-foot { --foot-tack-h: calc(max(var(--travel-btn-h), var(--row-lg)) + var(--bar-chrome)); }   /* the way back and the one-line sign: one row (--foot-h, or the way back at Bigger text) */
  :where(:root:not([data-layout=phone])) .tack-screen .tack-sign-line { position: absolute; width: var(--hairline); height: var(--hairline); margin: 0; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  :where(:root:not([data-layout=phone])) .tack-screen .frame-pane > .page-title,
  :where(:root:not([data-layout=phone])) .memory-screen .frame-pane > .page-title,
  :where(:root:not([data-layout=phone])) .show-screen .frame-pane > .page-title,
  :where(:root:not([data-layout=phone])) .barn-screen .frame-pane > .page-title { position: absolute; width: var(--hairline); height: var(--hairline); margin: 0; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}
@container app (max-height: 868px) {   /* the same 868px: the window's 900px less #app's padding */
  .screen.battle .keys-help { display: none; }
  .screen.battle .stage { --stage-top: var(--space-1); }
}

/* ---------- small screens ----------
   The old 900px block, split (issue 474 task 3). Its phone tokens are in the :root[data-layout=phone]
   block (with the 500px block's, below), and its stage, plate and foe rules follow the phone class
   here (:where() keeps each rule's weight). The rest still follows the window's width, 900px or
   less: a container query on the page (body is the container, base.css), so its width is the
   window's. There the battle's tray stacks (the arrow tiles stay big enough to read), and the page's
   edges and the HUD's two rows stay, so a desktop window 568 to 900 wide (tablet class) keeps a HUD
   that fits (task 13 moves the HUD to a container query of its own). */
:where(:root[data-layout=phone]) .stage { padding: var(--stage-top) var(--space-1) var(--space-3); gap: var(--space-2); }   /* 4 at its sides (layout-system.md "Battle plates"): your plate keeps the width */
:where(:root[data-layout=phone]) .plate { padding: var(--space-1); }
:where(:root[data-layout=phone]) .plate-name, :where(:root[data-layout=phone]) .aim-button, :where(:root[data-layout=phone]) .aim-go { font-size: var(--text-sm); }
/* The verb's picture sits above the words, so "Bonk Shadow Fox!" fits its plate after the size-up */
:where(:root[data-layout=phone]) .aim-go { flex-direction: column; padding-inline: var(--space-1); }
:where(:root[data-layout=phone]) .plate-sub { display: none; }
:where(:root[data-layout=phone]) .intent { font-size: var(--text-sm); padding: 0 var(--space-2); }
:where(:root[data-layout=phone]) .intent-name { display: none; }
:where(:root[data-layout=phone]) .foes { gap: var(--space-1); }
@container page (max-width: 900px) {
  /* Four arrow tiles in a row always fit the page (the arrowTile contract), even with Bigger text;
     the tokens are on body's children (a container query can't style body or :root), :where() so
     they weigh no more than :root's did. A token :root builds from them is built again here. */
  :where(body > *) {
    --tile: min(4.6rem, calc((100vw - var(--space-3) * 2 - var(--space-2) * 3) / 4));
    /* ...and in the battle's tray, inside the page's and the footer bar's padding and border */
    --tile-tray: min(4.6rem, calc((100vw - var(--space-3) * 4 - var(--frame-border) * 2 - var(--space-2) * 3) / 4));
    --card-w-sm: 6.4rem; --card-h-sm: 7.6rem;
    --hand-h: calc(var(--card-h) + var(--space-1) * 2);
    --tray-h: calc(var(--tile-tray) + var(--tray-meter-h) + var(--hand-h) + var(--ledger-h) + var(--tray-gap) * 3 + var(--bar-chrome));
    --barn-card-h: calc(var(--card-h-sm) * var(--barn-card-scale));   /* base.css's, built from this --card-h-sm */
  }
  #app { padding-top: var(--space-3); padding-left: max(var(--space-3), env(safe-area-inset-left)); padding-right: max(var(--space-3), env(safe-area-inset-right)); }
  .hud { padding: var(--space-1) var(--space-2); gap: var(--space-2); }
  .hud, .frame-foot:has(.map-sign) { --focus-offset: var(--focus-offset-tight); --new-mark-out: var(--new-mark-out-tight); }   /* their padding is --space-1: rings and marks stay inside it */
  .hud-horse { display: none; }
  .hud-who { flex: 1 1 0; }
  .hud-buttons { order: 2; }
  .hud-stats { order: 3; width: 100%; gap: var(--space-1); }
  /* The words stay on phones, so Shine and Stickers never rest on look-alike pictures */
  .hud .stat { --stat-pad: var(--space-1); }
  .hud .stat-word { font-size: var(--text-xs); }
  /* The tray stacks: the arrow powers; sparks and rainbow, the hand's count and the piles; the
     hand (one row you swipe); then the ledger with End turn beside it, under your thumb */
  .tray {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: var(--tile-tray) var(--tray-meter-h) var(--hand-h) var(--ledger-h);
    grid-template-areas: "pad pad" "meters meters" "hand hand" "log right";
    gap: var(--tray-gap) var(--space-2);
  }
  /* the meters' row: sparks and rainbow, the hand's count, then the piles at the end */
  .tray-meters { grid-area: meters; display: flex; align-items: center; gap: var(--space-2); min-width: 0; }
  .tray-left { display: flex; flex: 0 1 auto; align-items: center; }
  .tray .sparks-orb, .tray .rainbow { grid-area: auto; }
  .tray-meters > .pile { flex: none; }
  .tray .arrow-pad { justify-content: center; }
  .pile { min-height: var(--pile-h); font-size: var(--text-md); }
  .pile > .icon { width: var(--icon-md); height: var(--icon-md); }
  .hand-hint {
    flex: 1 1 auto; display: flex; align-items: center; justify-content: center; gap: var(--space-1);
    margin: 0; font-size: var(--text-sm); font-weight: var(--weight-bold); color: var(--ink-soft);
  }
  /* The last card fades out at the edge while more are off screen; the end padding lets the
     last card scroll clear of the fade */
  .tray:has(.hand-hint.swipes) .hand {
    padding-inline-end: var(--space-6);
    mask-image: linear-gradient(to right, var(--ink) calc(100% - var(--space-6)), transparent);
  }
  .tray-left { gap: var(--space-2); }
  .tray-right { align-self: stretch; justify-content: center; }
  .end-turn { min-height: var(--target); padding-inline: var(--space-3); font-size: var(--text-md); }
  .tray-left, .rainbow { min-width: 0; }
  .sparks-orb { font-size: var(--text-lg); }
  .rainbow { padding: var(--space-1); }
}
/* ...and the tray tokens that the phone's battle and the 560px blocks set on :root again: here only
   where those don't, so theirs still win */
@container page (560px < width <= 900px) {
  /* the card sizes in every class (a card in a dialog, the card book or the drawer on a phone held
     sideways too): the phone's battle sets its own on #app and the reward on .reward, so theirs win */
  :where(body > *) { --card-w: 7.2rem; --card-h: 8.6rem; }
  :where(:root:not([data-layout=phone]) body > *) {
    --orb: 68px;
    --tray-meter-h: max(var(--orb), 3rem);   /* the sparks, the rainbow and the piles */
    --tray-gap: var(--space-2);              /* between the tray's rows */
    --ledger-h: var(--tile-tray);                 /* base.css's, built from this --tile-tray */
    --drawer-tile: min(var(--tile), 4.6rem);      /* base.css's, built from this --tile */
  }
}
/* ---------- a phone's battle ----------
   A phone upright (560px and under) and any short window held sideways (500px tall and under: a
   phone on its side, .claude/reference/design-ui.md "Battle screen") share the phone's battle: the slim bar,
   the crowded stage, the short plates and the ledger's newest row. */
/* The battle's bar is the rail's tools (the ledger shows the turn); the level's name is said, not drawn */
:root[data-layout=phone] .battle-tools .round { display: none; }
html.big-text[data-layout=phone] #app:has(> .frame[data-kind=stage]) > .frame-top .btn-icon { font-size: var(--battle-tool-caption); }   /* the tools' captions kept with Bigger text, so they fit their target */
:root[data-layout=phone] .log-new { display: none; }     /* the newest row is the one at the bottom, and it is marked fresh */
:root[data-layout=phone] .log-turn { display: none; }    /* a turn's band is its dashed look; the room goes to its words */
:root[data-layout=phone] .log-line { font-size: var(--text-xs); }
/* while you pick a foe the stage says "Tap a foe!", so the ledger's question is just Cancel */
:root[data-layout=phone] .log-prompt .log-words { position: absolute; width: var(--hairline); height: var(--hairline); overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
:root[data-layout=phone] .log-prompt .pick-cancel { flex: 1 1 auto; }
/* a foe plate's hearts number is smaller, without its heart (the bar is the hearts), so the number and
   the Shield's spot fit under the bar on the narrowest plate */
:root[data-layout=phone] .hp-text { font-size: var(--text-sm); }
:root[data-layout=phone] .plate .hp-text { --hp-pic: 0px; }
:root[data-layout=phone] .plate .hp-text > .icon { display: none; }
:root[data-layout=phone] .screen.battle .plate-name { font-size: var(--text-xs); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* a phone's stage is short and wide: you on the left and the foes on the right, each plate under its
   picture (layout-system.md "Battle plates"), a crowded stage too. Your plate is one row, your hearts
   and your statuses, as tall as the tap-sized chip, and a foe's as tall, so the pictures keep the
   stage's height */
:root[data-layout=phone] .screen.battle .stage { --stage-top: var(--space-1); padding-bottom: var(--space-1); }
:root[data-layout=phone] .screen.battle .stage:not(.compact-foes) { grid-template-columns: repeat(2, minmax(0, 1fr)); }   /* a lone foe and you share it evenly */

:root[data-layout=phone] .stage {
  --team-face: 2rem;
  --chat-phone-face: 1.4rem;
}
:root[data-layout=phone] .stage > .team-cheer { flex-direction: row; flex-wrap: wrap; max-width: 40%; }
/* the stage is short: your floats hang from your picture's top edge and fade where they are (no
   rise), from its start edge, newer ones under them, so every one stays inside it */
:root[data-layout=phone] .stage > .hero .floaters { top: 0; bottom: auto; left: 0; transform: none; align-items: flex-start; max-height: none; flex-wrap: nowrap; --float-rise: 0px; }
/* a phone's stage has no room beside anyone: the bubble is a strip across the top of the stage,
   over your row, as wide as the stage, so every word of it shows (two lines; three with Bigger
   text) until your next move. It stays inside the stage, so it never covers the top bar's
   buttons; the ledger keeps the words after it goes. */
:root[data-layout=phone] .stage > .chat-bubble.from-team, :root[data-layout=phone] .stage > .chat-bubble.from-buddy {
  top: var(--space-1); bottom: auto; left: var(--space-2); right: var(--space-2); max-width: none;
  padding: var(--space-1) var(--space-2); gap: var(--space-2); font-size: var(--text-xs);
}
:root[data-layout=phone] .chat-bubble > .buddy-face { width: var(--chat-phone-face); height: var(--chat-phone-face); }
:root[data-layout=phone] .chat-bubble.from-team::before, :root[data-layout=phone] .chat-bubble.from-buddy::before { left: var(--space-4); top: auto; bottom: calc(var(--chat-tail) / -2 - var(--border-1)); rotate: -45deg; }
/* ---------- a phone's battle held sideways ----------
   The phone class (html[data-layout=phone]: 500px tall and under) has no room for a bar over the stage
   and a tray under it (.claude/reference/design-ui.md "Battle screen"). One tree, the page's grid places
   it: the rail at the left (Sound, Settings, Swap a card, the piles), the stage over the hand, the side
   column at the right (the rainbow's count, the arrows two by two, the newest row of the ledger) over
   End turn. The hand's row runs under the stage and the side column, across the window: the orb, the
   cards (five fit, one size however many you hold), End turn with its words. Each part is sized by the
   window, never by what is in it, so nothing moves as you play. The cards and arrow tiles keep one
   size with Bigger text (in px: the window has no more room for them; their words are read aloud and
   the card book shows them big), while the words around them grow. */
/* the battle's own tokens (on #app, so cards and tiles elsewhere keep theirs: the reward, the card
   book); the sizes built from them are declared again here, where these resolve */
:root[data-layout=phone] #app:has(> .frame[data-kind=stage]) {
  --frame-gap: var(--space-1); padding-block: var(--space-1);   /* the battle is the fullest screen on a phone: the page's edges and the gaps are slim */
  padding-inline: max(var(--space-1), env(safe-area-inset-left)) max(var(--space-1), env(safe-area-inset-right));
  --bar-chrome-slim: calc(var(--space-1) * 2 + var(--frame-border) * 2);   /* the rail's padding and border */
  --battle-bar-h: calc(var(--row-md) + var(--bar-chrome-slim));   /* the top region's token (frame.js regions.top): a phone draws the rail instead */
  --icon-btn-slim: 1.3rem;               /* the tools' icons in the rail, so they are --target squares */
  --orb: var(--target);
  --pip-h: var(--text-sm);
  --ledger-lines: 2;                      /* the newest row's words: two lines at most (all of it was said aloud; a tap opens the rest) */
  --stage-fit-min: 180px;                 /* the cards keep their size down to this stage */
  --art-foe: clamp(80px, 26vh, 8.5rem);   /* a foe's picture: by the window's height (it is short, and wide) */
  /* the side column: the rainbow's count, the arrows two by two, the newest row of the ledger. Its
     tiles are by the window's height, never under a target; the column is two tiles wide */
  --battle-tile: clamp(var(--target), calc(var(--screen-h) * 0.17), 78px);
  --battle-side-w: clamp(136px, calc(var(--battle-tile) * 2 + var(--space-0)), 164px);
  --battle-meter-h: calc(var(--text-xs) * 1.3);
  --battle-pad-h: calc(var(--battle-tile) * 2 + var(--space-0));
  --battle-end-w: 68px;                   /* End turn at the hand's right: its picture over its two words */
  --rail-step: calc(var(--target) + var(--space-1));                 /* one row of the rail */
  --rail-top: calc(var(--frame-border) + var(--space-1));            /* the rail's first row, inside its edge */
  /* the hand: five cards across what the rail, the orb and End turn leave (.hand shares it by
     --dealt), never taller than the window leaves over the stage's least room; Bigger text grows
     the words around them, never the cards */
  --card-h: calc(var(--screen-h) - var(--space-1) * 3 - var(--hand-pad-h) - var(--stage-fit-min));
  --card-w: calc(var(--card-h) / var(--card-aspect));
  --hand-pad-h: calc(var(--space-0) + var(--space-1));               /* above the cards, and their shadow under them */
  --hand-h: calc(var(--card-h) + var(--hand-pad-h));
  --tray-h: var(--hand-h);               /* the footer's token (frame.js regions.foot): on a phone the tray is the hand's row */
  /* the rail, the stage over the hand, and the side column over End turn */
  display: grid; gap: var(--space-1);
  grid-template-columns: var(--rail-1-w) var(--orb) minmax(0, 1fr) calc(var(--battle-side-w) - var(--battle-end-w) - var(--space-1)) var(--battle-end-w);
  grid-template-rows: var(--battle-meter-h) var(--battle-pad-h) minmax(0, 1fr) auto;
  grid-template-areas:
    "rail stage stage rain rain"
    "rail stage stage pad  pad"
    "rail stage stage log  log"
    "rail orb   hand  hand end";
}
/* the rail: Sound, Settings, Swap a card (its row kept while no swap is left), then the piles, each
   a --target square at its row (--rail-step), so nothing moves when one comes or goes. The level's
   name is said, not drawn (it names the stage) */
:root[data-layout=phone] #app:has(> .frame[data-kind=stage]) > .frame-top { display: contents; --icon-btn: var(--icon-btn-slim); }
:root[data-layout=phone] #app:has(> .frame[data-kind=stage]) > .frame-top > .battle-tools {
  grid-area: rail; flex-direction: column; align-items: center; gap: var(--space-1); min-height: 0; padding: var(--space-1);
  background: var(--bar-bg); border: var(--frame-border) solid var(--frame-line); border-radius: var(--frame-radius); box-shadow: var(--frame-elev);
}
:root[data-layout=phone] #app:has(> .frame[data-kind=stage]) > .frame-top .btn-icon { width: var(--target); height: var(--target); min-width: 0; min-height: 0; padding: 0; }
:root[data-layout=phone] #app:has(> .frame[data-kind=stage]) > .frame-top > .battle-title { position: absolute; width: var(--hairline); height: var(--hairline); overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:root[data-layout=phone] .frame[data-kind=stage] .tray :is(.swap-card, .pile) {
  grid-area: rail; align-self: start; justify-self: center; z-index: 1;
  width: var(--target); height: var(--target); min-width: 0; min-height: 0; margin: 0; padding: 0;
}
:root[data-layout=phone] .frame[data-kind=stage] .tray .swap-card { margin-block-start: calc(var(--rail-top) + var(--rail-step) * 2); }
:root[data-layout=phone] .frame[data-kind=stage] .tray .pile-draw { margin-block-start: calc(var(--rail-top) + var(--rail-step) * 3); }
:root[data-layout=phone] .frame[data-kind=stage] .tray .pile-used { margin-block-start: calc(var(--rail-top) + var(--rail-step) * 4); }
:root[data-layout=phone] .frame[data-kind=stage] .tray .pile { justify-content: center; gap: var(--space-0); font-size: var(--text-sm); line-height: 1; }
:root[data-layout=phone] .frame[data-kind=stage] .tray .pile > .icon { width: var(--icon-md); height: var(--icon-md); margin: 0; }
:root[data-layout=phone] .frame[data-kind=stage] .tray .pile .stat-word { position: absolute; width: var(--hairline); height: var(--hairline); overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
/* the footer and the tray's groups give their parts to the page's grid */
:root[data-layout=phone] #app > .frame[data-kind=stage] { display: contents; }
:root[data-layout=phone] .frame[data-kind=stage] > .region-foot, :root[data-layout=phone] .frame[data-kind=stage] > .region-foot > .tray, :root[data-layout=phone] .frame[data-kind=stage] .tray :is(.tray-meters, .tray-left, .tray-right) { display: contents; }
:root[data-layout=phone] .frame[data-kind=stage] > .region-keys { display: none; }
/* the side column: the rainbow's count (its pips are said, not drawn), the arrows two by two, the newest row */
:root[data-layout=phone] .frame[data-kind=stage] .tray .rainbow { grid-area: rain; flex-direction: row; justify-content: center; min-width: 0; padding: 0; background: none; }
:root[data-layout=phone] .frame[data-kind=stage] .tray .rainbow-label { font-size: var(--text-xs); line-height: 1; }
:root[data-layout=phone] .frame[data-kind=stage] .tray .meter { position: absolute; width: var(--hairline); height: var(--hairline); overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:root[data-layout=phone] .frame[data-kind=stage] .tray .arrow-pad {
  grid-area: pad; --tile: var(--battle-tile); gap: var(--space-0);
  grid-template-areas: "left up" "down right"; grid-template-columns: repeat(2, var(--tile)); grid-template-rows: repeat(2, var(--tile));
  justify-content: center; align-content: center;
}
:root[data-layout=phone] .frame[data-kind=stage] .tray .battle-log { grid-area: log; min-height: 0; }
/* the hand's row: the sparks orb, the hand you swipe, End turn */
:root[data-layout=phone] .frame[data-kind=stage] .tray .sparks-orb { grid-area: orb; align-self: center; font-size: var(--text-sm); border-width: var(--border-2); }   /* its number fits inside it */
:root[data-layout=phone] .frame[data-kind=stage] .tray .hand-hint { display: none; }   /* the hand's label says how many; a sixth card peeks past the edge */
:root[data-layout=phone] .frame[data-kind=stage] .tray .hand-area { grid-area: hand; justify-content: flex-start; }
:root[data-layout=phone] .frame[data-kind=stage] .tray .end-turn {
  grid-area: end; align-self: stretch; flex-direction: column; gap: 0; width: var(--battle-end-w); min-width: 0; height: auto;
  padding: var(--space-1); font-size: var(--text-sm); white-space: normal; text-align: center;
}
/* the hand you are dealt shares the row: each card one share (--dealt), never past --card-w, and one
   size however many you hold: a sixth card peeks in at the end (--hand-peek) and the row swipes */
:root[data-layout=phone] #app:has(> .frame[data-kind=stage]) .hand {
  gap: var(--space-0); padding: var(--space-0) var(--space-0) var(--space-1); mask-image: none;
  justify-content: flex-start; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; scroll-snap-type: x mandatory; --focus-offset: var(--focus-offset-tight);
  --hand-card-w: min(var(--card-w), calc((100cqw - var(--space-0) * 2 - var(--space-0) * (var(--dealt) - 1) - var(--hand-peek)) / var(--dealt)));
  --hand-peek: var(--space-2);   /* the room past the dealt hand where a sixth card peeks in */
}
:root[data-layout=phone] #app:has(> .frame[data-kind=stage]) .hand > :is(.card, .card-ghost) { flex: 0 0 auto; scroll-snap-align: start; --card-w: var(--hand-card-w); --card-h: calc(var(--hand-card-w) * var(--card-aspect)); }
:root[data-layout=phone] #app:has(> .frame[data-kind=stage]) .hand .card:is(.picked, :focus-visible, :hover:not(.cannot)) { transform: none; }
/* a card's face in the hand: its cost, its picture about half its height, then a picture and a number
   per rule (the intent's look); no name, no sentence (the card's name and read-aloud keep them), and
   its power's color is its edge. The reward's and the card book's cards keep their words */
:root[data-layout=phone] #app:has(> .frame[data-kind=stage]) .hand .card:not(.shiny) { border-color: var(--power); }
:root[data-layout=phone] #app:has(> .frame[data-kind=stage]) .hand .card :is(.card-name, .card-text, .card-power) { display: none; }
:root[data-layout=phone] #app:has(> .frame[data-kind=stage]) .hand .card-head { height: 50%; align-items: center; }
:root[data-layout=phone] #app:has(> .frame[data-kind=stage]) .hand .card-head > :is(.card-cost, .card-key) { align-self: start; }
:root[data-layout=phone] #app:has(> .frame[data-kind=stage]) .hand .card-art { font-size: calc(var(--card-h) * 0.4); }
:root[data-layout=phone] #app:has(> .frame[data-kind=stage]) .hand .card-amounts {
  flex: 1 1 auto; min-height: 0; display: flex; flex-wrap: wrap; align-content: center; justify-content: center; gap: 0 var(--card-pad);
  font-size: max(1.15em, var(--card-text-floor)); font-weight: var(--weight-heavy); line-height: 1;
}
/* the ledger is its newest row, two lines at most, and a tap opens all of it ("What happened") */
:root[data-layout=phone] .frame[data-kind=stage] .ledger-scroll { height: 100%; overflow: hidden; padding: var(--space-0); cursor: var(--cursor-press); }
:root[data-layout=phone] .frame[data-kind=stage] .ledger-scroll .log-lines { height: 100%; }
:root[data-layout=phone] .frame[data-kind=stage] .ledger-scroll .log-line { flex: 1 1 auto; min-height: 0; padding-inline-end: var(--space-1); gap: var(--space-1); }
:root[data-layout=phone] .frame[data-kind=stage] .ledger-scroll .log-line:not(:last-child) { display: none; }
:root[data-layout=phone] .frame[data-kind=stage] .ledger-scroll .log-line:not(.log-prompt) { pointer-events: none; }   /* the tap is the ledger's: it opens the sheet */
/* why, or what to do while swapping: floating over the top of the hand, never over the side column */
:root[data-layout=phone] .frame[data-kind=stage] .tray .tray-why { top: var(--space-1); transform: translateX(-50%); font-size: var(--text-sm); }

/* ---------- a small tablet's battle (1024x600, layout-system.md decision 7) ----------
   A tablet or desktop page under 640px of content height (#app's container, never the window's
   size) keeps the battle's layout, slimmer: the slim bar one small row (--row-md, its tools' icons
   smaller), the bars' padding and the gaps between the regions --space-2 or less, the hand's cards the
   small card (--card-w-sm), and the stage's least room 200px, so the page fits without scrolling,
   Bigger text too. The fighters keep their sizes. */
@container app (max-height: 640px) {   /* --small-tablet-h */
  :root:not([data-layout=phone]) #app > :is(.frame-top:has(+ .frame[data-kind=stage]), .frame[data-kind=stage]) {
    --frame-gap: var(--space-2);
    --bar-pad: var(--space-1) var(--space-3);
    --bar-chrome: calc(var(--space-1) * 2 + var(--frame-border) * 2);
  }
  :root:not([data-layout=phone]) #app > .frame-top:has(+ .frame[data-kind=stage]) { --battle-bar-h: calc(var(--row-md) + var(--bar-chrome)); --icon-btn: 1.3rem; }
  :root:not([data-layout=phone]) #app > .frame-top:has(+ .frame[data-kind=stage]) .btn-icon { min-height: 0; height: var(--row-md); padding-block: var(--space-1); }
  :root:not([data-layout=phone]) .frame[data-kind=stage] {
    --card-w: min(var(--card-w-sm), 136px); --card-h: calc(var(--card-w) * var(--card-aspect));   /* the small card at the usual text size: Bigger text grows the words, not the cards */
    --hand-h: calc(var(--card-h) + var(--space-2) + var(--space-1));
    --tray-h: calc(var(--hand-h) + var(--space-2) + var(--tile-tray) + var(--bar-chrome));
    --stage-fit-min: 200px;
    /* the plates one name and one row of hearts, so the foes keep their pictures (96px) */
  }
  :root:not([data-layout=phone]) .frame[data-kind=stage] .stage { padding-bottom: var(--space-1); }
}
/* A short desktop window with Bigger text (1280x720): the words grow with the text, so the cards take the small size
   the small tablet's battle takes, and the arrow powers stay in the window */
@container app (max-height: 720px) {
  :root.big-text:not([data-layout=phone]) .frame[data-kind=stage] {
    --card-w: min(var(--card-w-sm), 136px); --card-h: calc(var(--card-w) * var(--card-aspect));
    --hand-h: calc(var(--card-h) + var(--space-2) + var(--space-1));
    --tray-h: calc(var(--hand-h) + var(--space-2) + var(--tile-tray) + var(--bar-chrome));
  }
}
/* ---------- little joys (ui/joys.js, ui/mail.js; content/joys.js, content/mail.js) ----------
   A golden foe, your horse's moments, the perfect-win party and friends' letters. Pictures only
   (aria-hidden) over things that keep their room: nothing here takes space or a tap from what is
   under it. Calm mode and reduced motion stop every animation (above), and the moving ones aren't
   drawn then at all. */

/* A golden foe: its picture glows gold and sparkles twinkle round it, with a crown over its head
   (the crown and its name say "golden", not the color alone) */
.foe.golden .foe-art .foe-pic { filter: var(--art-halo) sepia(0.55) saturate(1.9) brightness(1.08) drop-shadow(0 0 var(--golden-glow) var(--gold)); }
.foe.golden .plate { border-color: var(--gold-deep); background: linear-gradient(var(--gold-soft), var(--glass)); }
.golden-shine { position: absolute; inset: 0; pointer-events: none; }
.golden-mark { position: absolute; left: 50%; top: 0; translate: -50% 0; font-size: var(--text-xl); }
.golden-mark > .icon { width: var(--icon-xl); height: var(--icon-xl); margin: 0; }
.golden-sparkle {
  position: absolute; left: calc(var(--i) / var(--of) * 90%); top: calc(20% + var(--i) * 20%);
  font-size: var(--text-lg);
  animation: twinkle var(--dur-twinkle) ease-in-out calc(var(--i) * var(--dur-twinkle) / -3) infinite;
}

/* Your horse's moment while you stand still in town: after --dur-moment-wait the horse does its
   little thing (sneeze, bow, stamp, yawn) and a bubble pops up over it, then now and then again */
.horse-moment {
  position: absolute; left: 50%; bottom: 100%; translate: -50% 0;
  display: flex; align-items: center; gap: var(--space-1); max-width: var(--moment-bubble-max);
  padding: var(--space-1) var(--space-2);
  border: var(--border-1) solid var(--ink); border-radius: var(--radius-pill); background: var(--paper); box-shadow: var(--elev-1);
  font-size: var(--text-sm); font-weight: var(--weight-bold); line-height: var(--leading-tight); white-space: nowrap;
  opacity: 0; pointer-events: none;
}
.moment-pics { display: inline-flex; }
.moment-pics > .icon { margin: 0; }
.roam-rider .horse-moment { animation: moment-bubble var(--dur-moment-cycle) ease-in-out var(--dur-moment-wait) infinite both; }
.roam-rider.moving .horse-moment { display: none; }
.roam-rider:not(.moving) .map-token-face > .mount { transform-origin: 50% 100%; animation: var(--moment-anim, none) var(--dur-moment-cycle) ease-in-out var(--dur-moment-wait) infinite; }
.roam-rider.moment-sneeze { --moment-anim: moment-sneeze; }
.roam-rider.moment-bow { --moment-anim: moment-bow; }
.roam-rider.moment-stamp { --moment-anim: moment-stamp; }
.roam-rider.moment-yawn { --moment-anim: moment-yawn; }
@keyframes moment-bubble { 0% { opacity: 0; scale: 0.6; } 4%, 22% { opacity: 1; scale: 1; } 28%, 100% { opacity: 0; scale: 0.8; } }
@keyframes moment-sneeze { 0%, 4% { rotate: 0deg; } 7% { rotate: -5deg; } 10% { rotate: 7deg; translate: 0 -4%; } 13%, 100% { rotate: 0deg; translate: 0 0; } }
@keyframes moment-bow { 0%, 4% { rotate: 0deg; } 9%, 15% { rotate: 9deg; } 20%, 100% { rotate: 0deg; } }
@keyframes moment-stamp { 0%, 4%, 7%, 10%, 13%, 100% { translate: 0 0; } 5.5%, 8.5%, 11.5% { translate: 0 -6%; } }
@keyframes moment-yawn { 0%, 4% { scale: 1; } 10%, 16% { scale: 1.05 0.96; } 22%, 100% { scale: 1; } }

/* After a win your horse nuzzles you: a bubble with its face and a heart pops up by your picture */
.cheer-with { position: relative; display: inline-flex; align-items: center; gap: var(--space-1); }
.horse-moment.win-moment { position: relative; flex: none; left: auto; right: auto; bottom: auto; translate: none; opacity: 0; animation: win-nuzzle var(--dur-win-nuzzle) ease-in-out both; }
.reward .reward-horse[class*=dance-] { animation-direction: reverse; }
.reward .cheer-figure { transform-origin: 50% 100%; }
.reward .dance-nuzzle { animation: reward-nuzzle var(--dur-dance) ease-in-out var(--times-dance); }
.reward .dance-five { animation: reward-five var(--dur-dance) ease-in-out var(--times-dance); }
.reward .dance-hop { animation: reward-hop var(--dur-dance) ease-in-out var(--times-dance); }
.reward .dance-bow { animation: reward-bow var(--dur-dance) ease-in-out var(--times-dance); }
.reward .dance-sway { animation: reward-sway var(--dur-dance) ease-in-out var(--times-dance); }
@keyframes reward-nuzzle { 50% { rotate: 5deg; } }
@keyframes reward-five { 50% { rotate: -6deg; translate: 0 -6%; } }
@keyframes reward-hop { 50% { translate: 0 -10%; } }
@keyframes reward-bow { 50% { rotate: 9deg; } }
@keyframes reward-sway { 25% { rotate: -4deg; } 75% { rotate: 4deg; } }
.moment-nuzzle .moment-pics > :first-child { animation: nuzzle var(--dur-dance) ease-in-out var(--times-dance); }
@keyframes win-nuzzle { 0%, 100% { opacity: 0; scale: 0.8; } 15%, 60% { opacity: 1; scale: 1; } }
@keyframes nuzzle { 50% { rotate: -14deg; translate: 15% 0; } }

/* The perfect-win party: you dance, confetti falls over the screen, and a friend (or your horse)
   dances beside you; the cheer's words are the note under the title, said, and in Read to me */
.cheer-figure.dance-twirl { transform-origin: 50% 100%; animation: dance-twirl var(--dur-dance) ease-in-out var(--times-dance); }
@keyframes dance-twirl { 25% { rotate: -10deg; translate: 0 -8%; } 50% { rotate: 0deg; translate: 0 0; } 75% { rotate: 10deg; translate: 0 -8%; } }
.party-layer { position: fixed; inset: 0 calc((100% - 100vw) / 2);   /* #app is a container (a fixed box is laid out against it): the sides reach out to the window's */
   z-index: 10; overflow: hidden; pointer-events: none; }
.confetti-bit {
  position: absolute; left: calc(var(--x) * 96%); top: 0; font-size: var(--confetti-bit);
  opacity: 0;
  animation: confetti-fall var(--dur-confetti) linear calc(var(--i) * var(--delay-confetti)) both;
}
.confetti-bit > .icon { width: var(--confetti-bit); height: var(--confetti-bit); margin: 0; }
@keyframes confetti-fall {
  0% { opacity: 0; translate: 0 -10vh; rotate: 0deg; }
  8% { opacity: 1; }
  85% { opacity: 1; }
  100% { opacity: 0; translate: 0 105vh; rotate: 540deg; }
}
/* ...and its words stay under the title, beside your cheering picture (in the room it already takes) */
.celebrate .lede:has(.party-note) { margin-top: 0; font-size: var(--text-sm); font-weight: var(--weight-bold); line-height: var(--leading-note); color: var(--ink); }

/* Friends' mail: the mailbox stands in your house's room while a letter waits, its flag up */
.btn.room-mailbox {
  position: absolute; left: var(--mx); top: var(--my); translate: -50% -50%; z-index: 1;
  border: var(--border-2) solid var(--ink); background: var(--paper); box-shadow: var(--elev-2);
  animation: pulse var(--dur-pulse) ease-in-out var(--times-invite);
}
.letter {
  display: grid; gap: var(--space-2); margin: 0; padding: var(--space-4);
  border: var(--border-2) solid var(--door, var(--accent)); border-radius: var(--radius-md); background: var(--gold-soft); box-shadow: var(--elev-1);
}
.letter > p { margin: 0; }
.letter-greeting, .letter-sign { font-weight: var(--weight-bold); }
.letter-sign { justify-self: end; }
.letter-joke strong { display: block; }
.letter-drawing {
  justify-self: center; display: grid; place-items: center; width: var(--letter-drawing); aspect-ratio: 1; margin: 0; overflow: hidden;
  border: var(--border-3) dashed var(--door, var(--accent)); border-radius: var(--radius-md); background: var(--paper);
}
.letter-drawing > * { max-width: 90%; max-height: 90%; }
.letter-drawing .beside { --beside-w: calc(var(--letter-drawing) * 0.8); }
.letter-gift { justify-content: center; }
/* a phone's stage is narrow: the golden mark is smaller (the stage is its container, .screen.battle .stage) */
@container stage (max-width: 30rem) { .golden-mark { font-size: var(--text-lg); } }
/* On a phone the brief win bubble shows pictures in its own slot beside the pair. */
:where(:root[data-layout=phone]) .horse-moment.win-moment { padding: var(--space-1); }
:where(:root[data-layout=phone]) .win-moment .moment-pop { display: none; }

/* Decorative celebration vectors share one bounded size, leaving room for actions. */
.milestone-art { display: block; width: min(100%, var(--art-milestone)); height: auto; max-height: var(--art-milestone-height); margin-inline: auto; }
.barn-bond-art { width: var(--art-bond); max-height: var(--art-bond); display: inline-block; vertical-align: middle; margin-inline-end: var(--space-1); }

/* The scrapbook (ui/scrapbook.js): the paper and controls on the left, one page of box tiles on the right.
   Only the whole workspace may scroll at a size where its frame has too little room. */
/* The scrapbook (ui/scrapbook.js, .claude/reference/design-ui.md "Layout per screen"): one grid, the paper its hero. A tablet and
   a desktop (the book's frame taller than 560px): the 2 book tabs across the top, over a column of tools
   (icon over word), the paper with its page controls below it, and the box. A phone, and a small tablet
   (@container book (height <= 560px), where the frame is the pane): the tool strip is 2 columns of squares, the 2 book
   tabs first and then the tools, left of the paper, which takes the rest, with the box in a column at its right;
   the page controls sit below the paper, and the paper's swatches and the box's filters open
   beside the strip. The paper keeps one shape everywhere, so stickers stay put. Nothing scrolls on a phone
   (the workspace's scroll is the last resort). */
.scrapbook-workspace {
  display: grid; gap: var(--space-2); align-items: stretch; padding: var(--space-1) var(--space-1) 0;   /* the side inline padding holds the New! mark that pokes past the packet button */
  grid-template-columns: auto minmax(0, 1fr) var(--scrapbook-box-w); grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: "tabs tabs tabs" "tools stage side";
}
.scrapbook-strip { display: contents; }
.scrapbook-strip > .tab-list { grid-area: tabs; }
.scrapbook-tool-grid { grid-area: tools; display: flex; flex-direction: column; gap: var(--space-2); }
.scrapbook-tool-grid > .btn { position: relative; width: var(--scrapbook-tool-w); flex-direction: column; gap: var(--space-0); padding-inline: var(--space-0); font-size: var(--text-xs); line-height: var(--leading-tight); }
.scrapbook-badge { display: none; }
.scrapbook-stage { grid-area: stage; position: relative; container: scrap-stage / size; display: flex; justify-content: center; align-items: flex-start; min-height: 0; }
.scrapbook-spread { width: min(100cqw, calc((100cqh - var(--target) - var(--space-1)) * 4 / 3)); min-width: 0; }
.scrapbook-spread > .scrapbook-paper { width: 100%; height: auto; aspect-ratio: var(--scrapbook-paper-shape); }
.scrapbook-page-bar { display: flex; align-items: center; justify-content: center; gap: var(--space-3); min-height: var(--target); margin-top: var(--space-1); }
.scrapbook-side { grid-area: side; position: relative; display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; min-height: 0; }
.scrapbook-side-head { display: flex; flex-direction: column; gap: var(--space-1); }
.scrapbook-filter-tool { display: none; }
.scrapbook-filter-pop { display: flex; flex-direction: column; gap: var(--space-1); }
.scrapbook-paper-pop { position: absolute; left: 0; bottom: 0; z-index: 2; padding: var(--space-2); border: var(--border-1) solid var(--line); border-radius: var(--radius-md); background: var(--paper); box-shadow: var(--elev-2); }
.scrapbook-page-title { display: flex; align-items: center; gap: var(--space-1); }
.scrapbook-album, .scrapbook-tool-art, .scrapbook-box-art { flex: none; width: var(--scrapbook-icon); height: var(--scrapbook-icon); pointer-events: none; }
.sticker-page.scrapbook-paper { position: relative; aspect-ratio: var(--scrapbook-paper-shape); border: var(--border-1) solid var(--line); background: var(--page-paper, var(--paper-cream)); }   /* --page-paper: the page's paper's own color (ui/scrapbook.js) */
.scrapbook-tab-art { position: absolute; right: 0; bottom: 0; width: var(--scrapbook-icon); pointer-events: none; }
.scrapbook-cover-art { width: var(--sticker); height: var(--sticker); object-fit: contain; }
.swatch-picker.scrapbook-papers { --swatch-size: var(--target); display: flex; flex-direction: column; align-items: center; gap: var(--space-1); margin: 0; padding: 0; border: 0; }
.scrapbook-papers legend { margin: 0; padding: 0; font-size: var(--text-md); text-align: center; }
.scrapbook-papers .swatches { gap: var(--space-2); }
.scrapbook-box { display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; }
.scrapbook-box-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
.scrapbook-box-title { display: flex; align-items: center; gap: var(--space-1); margin: 0; font-size: var(--text-md); }
.scrapbook-filters { --tab-min-w: 0; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); }
.scrapbook-set-step { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: var(--space-2); }
.scrapbook-set-step.is-reserved { display: none; }   /* a set's arrows take a row only while Sets is showing; the pile gives it the room */
.btn.scrapbook-arrow { flex: none; width: var(--target); padding-inline: 0; justify-content: center; }   /* an arrow alone: its words are for screen readers */
.scrapbook-set-name { text-align: center; font-size: var(--text-sm); overflow-wrap: anywhere; }
.scrapbook-set-name.is-off { color: var(--ink-soft); font-weight: var(--weight-body); }
.scrapbook-box-pages { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
.scrapbook-box-at { font-size: var(--text-sm); text-align: center; }
/* The box's stickers: --box-cols-wide across (ui/scrapbook.js; a phone has its own columns), each tile one size
   (--scrapbook-tile-h: the sticker, then its name in two lines at most); the pile takes the box's height
   and the pager under it never moves */
.scrapbook-pile { display: grid; grid-template-columns: repeat(var(--box-cols-wide), minmax(0, 1fr)); grid-auto-rows: var(--scrapbook-tile-h); gap: var(--space-2); align-content: start; min-height: 0; overflow: hidden; }
.scrapbook-box-sticker {
  position: relative; display: grid; grid-template-rows: var(--scrapbook-tile-art-wide) var(--scrapbook-tile-name-h) var(--sticker-rarity-gem); justify-items: center; align-content: center; gap: var(--space-1);
  width: 100%; height: var(--scrapbook-tile-h); min-width: 0; min-height: 0; padding: var(--space-0) var(--space-1);
  background: transparent; border: var(--border-1) solid transparent; border-radius: var(--radius-md); touch-action: none; overflow: hidden;
}
.scrapbook-box-sticker > .btn-label { display: contents; }
.scrapbook-box-sticker .sticker-caption { display: contents; }
.scrapbook-box-sticker .sticker-name {
  grid-row: 2; align-self: center; max-width: 100%; max-height: var(--scrapbook-tile-name-h); font-size: var(--text-xs); line-height: var(--leading-tight); overflow-wrap: anywhere; text-align: center;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden;
}
.scrapbook-box-sticker .sticker-rarity { grid-row: 3; align-self: center; }
.scrapbook-box-sticker .new-mark { top: 0; right: 0; z-index: 4; width: var(--space-3); height: var(--space-3); padding: 0; justify-content: center; }
.scrapbook-box-sticker .new-mark > .icon { width: var(--space-2); height: var(--space-2); }
.scrapbook-box-sticker .new-mark-word { position: absolute; width: var(--hairline); height: var(--hairline); overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.scrapbook-box-sticker.btn:is(:hover, :active):not(:disabled):not([aria-disabled="true"]) { transform: none; box-shadow: none; }
.scrapbook-box-sticker .sticker-art[data-size] { grid-row: 1; --sticker: var(--scrapbook-tile-art-wide); --size: 1; }   /* one size in the box, whatever its size on a page */
.scrapbook-box-sticker.is-picked { border-color: var(--accent); background: var(--accent-soft); }

.scrapbook-sticker.is-picked { z-index: 2; }
.scrapbook-workspace select { min-height: var(--target); font: inherit; border-radius: var(--radius-md); padding: var(--space-2); }
.packet-picture { width: var(--sticker); height: var(--sticker); object-fit: contain; }
/* The packets waiting in the Sticker Book (ui/scrapbook.js): a stack beside the sticker box, the way to
   open one, and your star card. A packet's stickers drop into the box one at a time (all at once in calm mode). */
.packet-stack { display: flex; flex-direction: column; gap: var(--space-1); padding: var(--space-1) var(--space-2); border: var(--border-1) solid var(--line); border-radius: var(--radius-md); background: var(--paper); }
.packet-stack-row { display: flex; align-items: center; gap: var(--space-2); }
.packet-stack-count { flex: 1; min-width: 0; margin: 0; font-size: var(--text-sm); font-weight: var(--weight-heavy); min-height: calc(var(--text-sm) * var(--leading) * 2); display: flex; align-items: center; }
.packet-pile { position: relative; flex: none; display: grid; isolation: isolate; }
.packet-pile .packet-picture { width: var(--star-slot); height: var(--star-slot); }
.packet-pile.is-stack::before { content: ''; position: absolute; inset: 0; translate: var(--space-1) var(--space-1); border-radius: var(--radius-md); background: var(--accent-soft); z-index: -1; }
.packet-pile.is-empty { filter: grayscale(1); opacity: 0.35; }
.packet-stack .star-card { flex-direction: row; flex-wrap: wrap; justify-content: center; column-gap: var(--space-2); }
.packet-stack .star-slots { --slot: var(--star-slot-sm); }
.scrapbook-box-sticker.is-out .sticker-art { animation: scrapbook-box-drop var(--dur-pop) calc(var(--out) * var(--dur-pop)) ease-out both; }
@keyframes scrapbook-box-drop { from { opacity: 0; translate: 0 calc(var(--space-2) * -1); } }

.scrapbook-sticker .sticker-name { display: none; }
.scrapbook-box-sticker.is-dragging { z-index: var(--z-drag-preview); }
.sticker-rarity { display: flex; flex-wrap: wrap; justify-content: center; max-width: 100%; color: var(--ink); background: var(--paper); border-radius: var(--radius-pill); z-index: 3; }
.sticker-rarity > .icon { flex: none; width: var(--sticker-rarity-gem); height: var(--sticker-rarity-gem); margin: 0; }

.scrapbook-sticker { z-index: 1; --scrap-bound: min(var(--scrapbook-bound-max), calc(var(--sticker) * var(--sticker-l) * var(--scrapbook-bound-scale) + var(--space-2))); left: clamp(var(--scrap-bound), var(--sx), calc(100% - var(--scrap-bound))); top: clamp(var(--scrap-bound), var(--sy), calc(100% - var(--scrap-bound))); }

.dialog.sticker-book-dialog { width: min(var(--scrapbook-dialog-w), calc(100% - var(--space-6))); }
/* A sticker's placement owns its geometry, including during a button press. */
.scrapbook-sticker.btn,
.scrapbook-sticker.btn:is(:hover, :active):not(:disabled):not([aria-disabled="true"]) {
  transform: none; translate: -50% -50%; rotate: var(--tilt); scale: var(--scrap-scale, 1); background: none; box-shadow: none;
}
.scrapbook-sticker.btn.is-picked { --scrap-scale: var(--sticker-picked-scale); background: var(--accent-soft); }
.scrapbook-sticker.btn.is-dragging { --scrap-scale: var(--scrapbook-drag-scale); }
/* The book's container: on a tablet or desktop the place's frame, which is the window less #app's
   edges and the top bar (24px across, so 536px is the old 560px window and 736px the old 760px one, and
   1068px is the frame at --page-max); on a phone the place's pane (its frame is no box beside the rail).
   Neither takes its size from the book. Wide puts the page beside the tools and the box, as the old
   561px landscape window did: a frame 537px across and 6/5 or wider (about where the window turns
   portrait: 800x700 gives 776x504, 1280x720 1068x576), a frame at its widest (1920x1080 or taller), or
   a phone's short pane 420px across (667x320 gives 439x284; no tablet frame is 360px tall or less
   under 537px across). A tall window keeps one column (520x820 gives 496x700). The frame's container is set
   with its other rules (books.css .town-place-screen). */
:root[data-layout=phone] .town-place-screen > .frame-pane { container: book / size; }
/* the packets, the box and the pile on a tablet: the stack is one row over the box, the box takes the column's height */
.scrapbook-side .packet-stack { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); grid-template-rows: minmax(0, 1fr); align-items: center; gap: var(--space-1); padding: var(--space-0); min-height: var(--target); }
.scrapbook-side .packet-stack > .btn { grid-column: 2; grid-row: 1; min-height: var(--target); padding-block: var(--space-0); }
.scrapbook-side .packet-stack > .star-card { grid-column: 1; grid-row: 1; }
.scrapbook-side .packet-stack > .packet-pile { display: none; }
.scrapbook-side .packet-stack-open > .btn-label { display: flex; flex-direction: column; align-items: center; gap: 0; line-height: var(--leading-tight); }
.scrapbook-side .packet-stack-open.btn:is(:hover, :active) { transform: none; }   /* the open button sits flush with the workspace's top edge */
.scrapbook-side .packet-stack .star-card { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-0); margin: 0; }
.scrapbook-side .packet-stack .star-card-name { position: absolute; width: var(--hairline); height: var(--hairline); overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.scrapbook-side .packet-stack .star-slots { --slot: var(--sticker-book-star-slot); display: grid; grid-template-columns: repeat(var(--star-row), minmax(0, var(--slot))); gap: var(--space-1); max-width: calc(var(--slot) * var(--star-row) + var(--space-1) * (var(--star-row) - 1)); }
.scrapbook-side .packet-stack .star-slot { box-sizing: border-box; flex: 0 0 var(--slot); }
.scrapbook-side .packet-stack-count, .scrapbook-side .packet-stack .star-card-count { min-height: 0; font-size: var(--text-xs); line-height: var(--leading-tight); white-space: nowrap; }
.scrapbook-side .packet-stack-badge { display: none; }
.scrapbook-side .scrapbook-box { flex: 1 1 0; min-height: 0; gap: var(--space-0); }
.town-place-screen .scrapbook-pile { flex: 1 1 0; min-height: 0; overflow: hidden; }
.scrapbook-side .scrapbook-box-pages { flex: none; }

/* a phone and a small tablet: the strip, the paper, the box column */
@container book (height <= 560px) {
  .scrapbook-workspace { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-rows: minmax(0, 1fr); grid-template-areas: "tools stage side"; padding: 0; }
  .scrapbook-strip { grid-area: tools; display: grid; grid-template-columns: repeat(var(--scrapbook-compact-cols), minmax(var(--target), max-content)); grid-auto-rows: var(--target); gap: var(--space-1); align-content: start; }
  .scrapbook-strip > .tab-list, .scrapbook-tool-grid { display: contents; }
  .scrapbook-strip .tab { min-width: var(--target); padding: 0; }
  .scrapbook-strip .tab-word, .scrapbook-filter-tool > .btn-label, .scrapbook-workspace .scrapbook-box-pages .btn-label, .scrapbook-workspace .scrapbook-box-at, .scrapbook-page-title, .scrapbook-side .packet-stack .star-card, .scrapbook-side .packet-stack-open-word, .scrapbook-side .packet-stack-count { position: absolute; width: var(--hairline); height: var(--hairline); overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .scrapbook-tool-grid > .btn { width: auto; }
  .scrapbook-page-bar { justify-content: space-between; }
  .scrapbook-side { width: calc(var(--target) * var(--box-cols-wide) + var(--space-1) * (var(--box-cols-wide) - 1)); }
  .scrapbook-side-head { display: grid; grid-template-columns: repeat(var(--box-cols-wide), var(--target)); gap: var(--space-1); }
  .scrapbook-side .packet-stack { display: contents; }
  .scrapbook-side .packet-stack > .btn { grid-column: auto; position: relative; width: var(--target); padding: 0; }
  .scrapbook-side .packet-stack-open > .btn-label { display: contents; }
  .scrapbook-side .packet-stack-badge { display: block; position: absolute; top: 0; right: 0; min-width: var(--space-4); padding-inline: var(--space-0); border-radius: var(--radius-round); background: var(--accent); color: var(--paper-cream); font-size: var(--text-xs); line-height: var(--leading-tight); text-align: center; }
  .scrapbook-side .scrapbook-filter-tool.btn-pic { display: inline-flex; width: var(--target); padding-inline: 0; }
  .scrapbook-filter-pop { display: none; }
  .scrapbook-filter-pop.is-open { display: flex; position: absolute; top: 0; right: 0; z-index: 2; width: var(--scrapbook-pop-w); padding: var(--space-2); border: var(--border-1) solid var(--line); border-radius: var(--radius-md); background: var(--paper); box-shadow: var(--elev-2); }
  .scrapbook-workspace .scrapbook-pile { grid-template-columns: repeat(var(--box-cols-wide), var(--target)); grid-auto-rows: var(--target); gap: var(--space-1); }
  .scrapbook-workspace .scrapbook-box-sticker { display: flex; height: var(--target); padding: 0; justify-content: center; }
  .scrapbook-workspace .scrapbook-box-sticker .sticker-caption { display: flex; position: absolute; width: var(--hairline); height: var(--hairline); overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }   /* the name and the gems are in the tile's label */
  .scrapbook-workspace .scrapbook-box-sticker .sticker-art[data-size] { --sticker: min(var(--scrapbook-tile-art), calc(var(--target) - var(--space-3) * 2 - var(--space-1) - var(--space-0))); --size: 1; }
  .scrapbook-workspace .scrapbook-box-pages { justify-content: space-between; gap: var(--space-1); }
  .scrapbook-workspace .scrapbook-box-pages > .btn.btn-pic { width: var(--target); min-width: var(--target); padding-inline: 0; }
}
/* a phone's tools show their icon, and Turn's degrees and Size's letter on it */
:root[data-layout=phone] .scrapbook-badge { display: block; position: absolute; right: 0; bottom: 0; padding-inline: var(--space-0); border-radius: var(--radius-round); background: var(--accent-soft); font-size: var(--text-xs); line-height: var(--leading-tight); font-weight: var(--weight-bold); }

/* a narrow tall window: the footer holds the way back over the pager (it sets the
   footer's height, which the frame holds), and the book flows down the pane, which scrolls. The shell
   container's query (#app's edges are 24px across, so 736px is the old 760px window), set on the frame
   that reads it */
@container app (width <= 736px) and (aspect-ratio < 1) {
  .town-place-screen { --foot-travel-h: calc(var(--travel-btn-h) + var(--space-1) + var(--row-md) + var(--bar-chrome)); }
  .place-book-pager-slot { flex-basis: auto; min-width: 0; flex: 1 1 0; }
  .place-book-pager { justify-content: flex-end; gap: var(--space-1); }
  .book-page-count { min-width: 0; font-size: var(--text-sm); }
}

/* a phone: the card book and the scrapbook keep to the short window */
/* a phone: the controls are a slim column of icon squares (the tabs with their counts, the filter) left of the cards; the pager is in the rail with the way back */
:root[data-layout=phone] .place-card-book { display: grid; grid-template-columns: auto minmax(0, 1fr) var(--target); grid-template-rows: minmax(0, 1fr); gap: var(--space-2); }
:root[data-layout=phone] .place-card-book .book-controls { display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: var(--space-1); }
:root[data-layout=phone] .place-card-book .book-tabs { flex-direction: column; }
:root[data-layout=phone] .place-card-book .book-tabs .tab { position: relative; justify-content: center; width: var(--target); min-width: var(--target); padding: 0; }
:root[data-layout=phone] .place-card-book .book-tabs .tab-name, :root[data-layout=phone] .book-page-count .page-long { position: absolute; width: var(--hairline); height: var(--hairline); overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:root[data-layout=phone] .place-card-book .book-tabs .tab-count { position: absolute; top: 0; right: 0; width: max-content; min-width: var(--space-4); padding-inline: var(--space-0); border-radius: var(--radius-round); background: var(--accent); color: var(--paper-cream); font-size: var(--text-xs); line-height: var(--leading-tight); text-align: center; }
:root[data-layout=phone] .place-card-book .book-chips, :root[data-layout=phone] .place-card-book .book-shine { display: none; }
:root[data-layout=phone] .place-card-book .book-filter { display: inline-flex; width: var(--target); min-width: var(--target); padding: 0; justify-content: center; }
:root[data-layout=phone] .book-page-count { min-width: 0; }
:root[data-layout=phone] .book-page-count .page-short { display: block; font-size: var(--text-sm); }
:root[data-layout=phone] .place-card-book .book-entry .count { top: var(--space-0); right: auto; left: var(--space-0); padding-inline: var(--space-1); font-size: var(--text-xs); pointer-events: none; }   /* a tap on the count opens the card under it */
:root[data-layout=phone] .town-place-screen > .frame-pane > .page-title { position: absolute; width: var(--hairline); height: var(--hairline); overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:root[data-short=tablet] .town-place-screen > .frame-pane:has(:is(.place-card-book, .scrapbook-workspace)) > .page-title { position: absolute; width: var(--hairline); height: var(--hairline); overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }   /* a short tablet's card book: its title gives way */
/* a short desktop window with Bigger text (1280x720): the scrapbook's title gives way too, so the paper stays the hero */
@container app (max-height: 720px) {
  :root.big-text:not([data-layout=phone]) .town-place-screen > .frame-pane:has(.scrapbook-workspace) > .page-title { position: absolute; width: var(--hairline); height: var(--hairline); overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}

/* A quiet vector lockup, with independently recolorable letters and horse layers. */
.brand-emblem { width: min(22%, var(--brand-emblem-w)); height: auto; flex-shrink: 0; }
.brand-words { display: flex; flex-direction: column; align-items: center; width: min(72%, var(--brand-wordmark-w)); }
.brand-wordmark { width: 100%; height: auto; }
.brand-subtitle { width: var(--brand-subtitle-w); height: auto; margin-top: calc(var(--space-1) * -1); }

/* the title's meadow: behind the title, outside its layout, never taking a tap */
.title-meadow { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.meadow-edge { position: absolute; bottom: 0; width: calc(var(--brand-edge-w) / 2); overflow: hidden; transform-origin: bottom center; animation: meadow-sway var(--dur-sway) ease-in-out infinite alternate; }
.meadow-edge-left { left: 0; }
.meadow-edge-right { right: 0; animation-delay: calc(var(--dur-sway) * -0.5); }
.brand-meadow-edge { display: block; width: var(--brand-edge-w); max-width: none; height: auto; }
.meadow-edge-right .brand-meadow-edge { margin-left: calc(var(--brand-edge-w) / -2); }
.brand-butterfly { position: absolute; width: var(--brand-butterfly-w); height: auto; animation: butterfly-drift var(--dur-drift) ease-in-out infinite alternate; }
.brand-butterfly-one { left: 6%; bottom: 22%; }
.brand-butterfly-two { right: 8%; bottom: 30%; animation-delay: calc(var(--dur-drift) * -0.4); }
html.big-text .title-screen { --brand-wordmark-w: min(16rem, 26vh); }   /* Bigger text needs the room for its cards: a smaller logo, subtitle with it */
@keyframes meadow-sway { from { rotate: -0.6deg; } to { rotate: 0.6deg; } }
@keyframes butterfly-drift { from { translate: 0 0; rotate: -6deg; } to { translate: var(--butterfly-dx) var(--butterfly-dy); rotate: 6deg; } }
.brand-flourish { position: absolute; top: 100%; left: 50%; translate: -50% 0; width: var(--brand-flourish-w); max-width: 50%; height: var(--brand-flourish-h); pointer-events: none; }

/* ---------- a phone held sideways (812x375, and any short wide window) ----------
   Under 500px tall the page has no room for two rows of HUD, a 80px head and a 100px footer around
   a pane (a map got its 180px minimum and the page scrolled 230px). Every framed screen but the
   battle (its own block, in the battle's section) slims its bars: the HUD is one row (stat words
   give way, as on a phone), a bar is one tap target of height, the gaps are --space-1, and the pane
   takes the rest. Every height is a token, worked out here where the rules read them (a token that
   uses another is resolved where it is defined). The screens' own signs and rooms then follow
   (their sections below). */
/* The phone class's sizes (layout-system.md "Tokens for each class"): one block, keyed on the class
   src/ui/size-class.js sets. From the 900px block: the pips, the stage, the h1 and the HUD's two rows
   (--orb is not here: the phone battle's block sets it for every phone). From the 500px block: the
   map, barn, tack and show rooms and the celebrations' pictures. */
:root[data-layout=phone] {
  --rail-1-w: 68px;   /* the phone battle's rail: one --target, 2x4 padding and its border (layout-system.md "The phone battle") */
  --battle-tool-caption: calc(var(--text-xs-ratio) * var(--root-size));   /* the slim bar's tools' captions (--text-xs at the usual size) kept with Bigger text */
  /* the phone battle's piles and ledger */
  --pile-h: 0px; --ledger-h: var(--ledger-h-phone); --orb: max(56px, 2.8rem); --tray-gap: var(--space-1); --ledger-lines: 3; --stage-fit-min: 220px; 
  --pip-w: 8px; --pip-h: 20px; --stage-min: clamp(220px, 30vh, 320px); --h1: var(--text-2xl); --dialog-pad: var(--space-3); --gate-lead-h: 1.6em;
  --top-hud-h: calc(max(var(--art-hud), var(--row-lg)) + var(--space-2) + var(--chip-h) + var(--hud-chrome));   /* you and the buttons, then the numbers' row */
  --map-label-text: clamp(0.62rem, 1.7cqw, 0.85rem); --card-w-pick: 136px; --art-celebrate: 2.6rem; --art-friend: 3rem; --map-room-min: 96px; --barn-min-h: var(--map-room-min); --tack-min-h: var(--map-room-min); --show-min-h: var(--map-room-min);   /* room for a spot, the rider over it and its label; a barn, a tack room and a ring take what the bars leave */
  /* the drawer (task 15): the sign, the arrows and the list tokens */
  --drawer-sign-w: min(12rem, 30vw); --drawer-tile: min(3.4rem, 68px); --drawer-sign-lines: 5; --drawer-hint-lines: 6; --token: var(--target);   /* the sign: its picture and Hear it, a name and five lines, then Take it off; the list's tokens a tap target */
  /* ...one height, whatever it shows (a power or the hint): its two rows of buttons, a name and five lines between them */
  --drawer-sign-h: calc(var(--drawer-sign-row) * 2 + var(--text-md) * var(--leading-tight) + var(--text-sm) * var(--leading-tight) * var(--drawer-sign-lines) + var(--space-1) * 2 + var(--space-2) * 2);
}
/* The shell's slim bars on a phone (html[data-layout=phone]): every screen but the stage (the battle). As specific as the
   rail's rules below, so the rail wins on a framed screen. */
:root[data-layout=phone] #app:has(> .frame:not([data-kind=stage])) {
  --frame-gap: var(--space-1);
  --bar-pad: var(--space-1) var(--space-3);
  --bar-chrome: calc(var(--space-1) * 2 + var(--frame-border) * 2);
  --hud-chrome: var(--bar-chrome);
  --art-hud: var(--row-md);
  --row-lg: var(--row-md);
  --pane-pad: var(--space-2);
  --pane-gap: var(--space-1);
  --h1: var(--text-lg);
  --travel-pic: 2rem;
  --travel-btn-h: calc(var(--travel-pic) + var(--space-1) * 2 + var(--border-1) * 2);
  --top-bar-h: calc(var(--row-lg) + var(--bar-chrome));
  --top-steps-h: var(--top-bar-h);
  --top-hud-h: calc(max(var(--art-hud), var(--row-md)) + var(--hud-chrome));   /* one row: you, the numbers, the buttons */
  --foot-h: calc(var(--row-lg) + var(--bar-chrome));
  --foot-travel-h: calc(var(--row-lg) + var(--bar-chrome));   /* the way back and a row of buttons beside it */
  --foot-barn-h: calc(var(--row-lg) + var(--bar-chrome));
  --foot-tack-h: calc(max(var(--tack-sign-h), var(--row-lg)) + var(--bar-chrome));
  --foot-show-h: calc(var(--row-lg) + var(--bar-chrome));
  --foot-memory-h: calc(var(--row-lg) + var(--bar-chrome));
  --barn-sign-h: var(--row-lg);
  --tack-sign-h: calc(var(--text-md) * var(--leading-tight) + var(--text-sm) * var(--leading-tight) * 2 + var(--space-1));   /* its name, then its words (two lines at most) */
  --show-sign-h: var(--row-lg);
  --memory-sign-h: var(--row-lg);
  padding-top: var(--space-1); padding-bottom: var(--space-1);
}
:root[data-layout=phone] #app:has(> .frame:not([data-kind=stage])) .hud { flex-wrap: nowrap; --focus-offset: var(--focus-offset-tight); --new-mark-out: var(--new-mark-out-tight); }
:root[data-layout=phone] #app:has(> .frame:not([data-kind=stage])) .hud-stats { order: 0; width: auto; flex-wrap: nowrap; }
:root[data-layout=phone] #app:has(> .frame:not([data-kind=stage])) .hud-buttons { order: 0; }
:root[data-layout=phone] #app:has(> .frame:not([data-kind=stage])) .hud-who { flex: 0 1 auto; }
:root[data-layout=phone] #app:has(> .frame:not([data-kind=stage])) .hud .stat-word { display: none; }
:root[data-layout=phone] #app:has(> .frame:not([data-kind=stage])) .frame-top .btn { height: var(--row-md); min-height: 0; padding-block: var(--space-1); }
:root[data-layout=phone] #app:has(> .frame:not([data-kind=stage])) .frame-foot { --focus-offset: var(--focus-offset-tight); --new-mark-out: var(--new-mark-out-tight); }
:root[data-layout=phone] #app:has(> .frame:not([data-kind=stage])) .frame-foot :is(.btn-travel, .actions .btn, .map-sign-go .btn) { min-height: var(--row-md); }   /* one row tall, so the footer's row is its sign's */

/* The tablet's and desktop's shell: the same regions as the phone's, with less around the pane, so the pane
   keeps its designed share of the height (layout-system.md section 1). Tokens only; the stage (the battle) keeps its own. */
:root:not([data-layout=phone]) #app:has(> .frame:not([data-kind=stage])) {
  --frame-gap: var(--space-1);
  --bar-pad: var(--space-1) var(--space-3);
  --bar-chrome: calc(var(--space-1) * 2 + var(--frame-border) * 2);
  --art-hud: var(--row-md);
  --top-bar-h: calc(var(--row-lg) + var(--bar-chrome));
  --top-steps-h: var(--top-bar-h);
  --top-hud-h: calc(max(var(--art-hud), var(--row-md)) + var(--bar-chrome));
  --head-h: calc(var(--notice-h) + var(--bar-chrome));
  --foot-h: calc(var(--row-lg) + var(--bar-chrome));
  --foot-travel-h: calc(var(--travel-btn-h) + var(--bar-chrome));
  --foot-map-h: calc(var(--map-sign-h) + var(--bar-chrome));
  --foot-town-h: calc(var(--map-sign-h-town) + var(--bar-chrome));
  --foot-barn-h: calc(max(var(--travel-btn-h), var(--barn-sign-h)) + var(--bar-chrome));
  --foot-tack-h: calc(var(--tack-sign-h) + var(--bar-chrome));
  --foot-show-h: calc(max(var(--travel-btn-h), var(--show-sign-h)) + var(--bar-chrome));
  --foot-memory-h: calc(max(var(--travel-btn-h), var(--memory-sign-h)) + var(--bar-chrome));
  padding-top: var(--space-1); padding-bottom: var(--space-1);
}
:root:not([data-layout=phone]) #app:has(> .frame:not([data-kind=stage])) .frame-top .btn { height: var(--row-md); min-height: 0; padding-block: var(--space-1); }   /* the HUD's row is one tap target tall */

/* The rest of the phone's rules (the screens' own: the barn, the tack room, the show, the reward,
   the gift, the title, the create steps), keyed on the class. :where keeps each rule's specificity as it was in the 500px query. */
/* the barn: its things are one tap target tall; the strip's pips are smaller (the meters float over the stall) */
:where(:root[data-layout=phone]) .barn-strip :is(.care-meter, .bond-meter) { align-items: center; }
:where(:root[data-layout=phone]) .barn-strip :is(.care-meter-row, .bond-row, .bond-shoe, .care-pip) { min-height: 0; }
:where(:root[data-layout=phone]) .barn-strip .care-pip { width: calc(var(--icon-md) * 0.7); }
:where(:root[data-layout=phone]) .room-arrive.barn-bubble { top: var(--space-0); font-size: var(--text-sm); line-height: var(--leading-tight); padding-block: var(--space-0); border-width: var(--border-1); max-height: calc(var(--barn-stall-room) - var(--space-0)); }   /* the stall is short: two lines of Bigger text fit with a thin edge and a little padding */
/* the tack room on a phone: its title is only for screen readers; the tabs are one row of icons (they swipe if they do not fit), the
   mirror column is 40% of the pane (the horse, the picked piece's name and its one button) and the shelf's tiles are a picture and a badge */
:where(:root[data-layout=phone]) .tack-screen { --tab-min-w: var(--target); --tack-mirror-w: var(--tack-mirror-w-phone); --tack-tile: var(--target); --tack-tile-pic: var(--tack-tile-pic-phone); --tack-tile-h: var(--tack-tile-phone-h); }
:where(:root[data-layout=phone]) .tack-screen .frame-pane > .page-title { position: absolute; width: var(--hairline); height: var(--hairline); overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:where(:root[data-layout=phone]) .tack-room { gap: var(--space-1) var(--space-2); }
:where(:root[data-layout=phone]) .tack-screen .tab { padding-inline: var(--space-0); }
/* the Horse Show: the ring is the room (its title is only for screen readers); the stars of mistakes in its top-left corner, the round's pips
   top-right, the horses between (their names are said aloud, not drawn), and a trick's tile is a target square, its picture only */
:where(:root[data-layout=phone]) .show-screen { --show-tile-h: var(--row-md); --show-pip: 1.4rem; }
:where(:root[data-layout=phone]) .show-screen .frame-pane > .page-title { position: absolute; width: var(--hairline); height: var(--hairline); overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:where(:root[data-layout=phone]) .show-ring { gap: var(--space-1); padding: var(--space-1) var(--space-2); }
:where(:root[data-layout=phone]) .show-name { position: absolute; width: var(--hairline); height: var(--hairline); margin: 0; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
/* the memory match: its board takes the room the title would (the title is in the HUD's frame) */
:where(:root[data-layout=phone]) .memory-screen .frame-pane > .page-title { position: absolute; width: var(--hairline); height: var(--hairline); overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
/* the reward: its title and what you won in the left column, the card pick in a column of its own at full height (the cards share their room with nothing) */
:where(:root[data-layout=phone]) .reward { --card-w: var(--card-w-pick); --card-h: calc(var(--card-w) * var(--card-tall)); }
:where(:root[data-layout=phone]) .reward > .frame-pane { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto minmax(0, 1fr); column-gap: var(--space-3); }
:where(:root[data-layout=phone]) .reward > .frame-pane > .celebrate { grid-area: 1 / 1 / 2 / 3; }
:where(:root[data-layout=phone]) .page-title-words { flex-basis: 0; }   /* a celebration's cheering picture stays beside its title */
:where(:root[data-layout=phone]) .celebrate .lede:has(.party-note) { margin-top: 0; }
:where(:root[data-layout=phone]) .reward-body { display: contents; }
:where(:root[data-layout=phone]) .reward-news { grid-area: 2 / 1; }
:where(:root[data-layout=phone]) .reward-pick { grid-area: 2 / 2; }
:where(:root[data-layout=phone]) .reward-news .star-card-button .star-slots { display: none; }   /* what you won on a phone: the star card is its count chip (its words are the button's label and the read-aloud) */
:where(:root[data-layout=phone]) .reward-news .star-card-name { display: none; }   /* the count names the chip; its packet stamp still appears in the kept header room */
:where(:root[data-layout=phone]) .reward-news .star-card-button { min-height: var(--sticker); justify-content: center; }
:where(:root[data-layout=phone]) .reward-news .new-power { margin: 0; padding: var(--space-1) var(--space-2); }   /* a guardian's power: one line (the rest is in read-aloud) */
:where(:root[data-layout=phone]) .reward-news .new-power > p:not(.special) { display: none; }
:where(:root[data-layout=phone]) .reward-news .new-power > .special { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 1; line-clamp: 1; overflow: hidden; margin: 0; }
:where(:root[data-layout=phone]) .celebrate .party-note { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 1; line-clamp: 1; overflow: hidden; }   /* one line; read-aloud has all of it */
:root[data-layout=phone] #app:has(> .frame:is(.reward, .cleared)) > .hud .hud-stats { display: none; }   /* a celebration drops Hearts from the rail, as the battle's rail does */
:where(:root[data-layout=phone]) .reward-pick > h2 { font-size: var(--text-md); }
:where(:root[data-layout=phone]) .reward-pick > .choices { padding: var(--space-2) 0 var(--space-1); gap: var(--space-2); }
/* tablet and desktop: one top-to-bottom ledger beside the card pick; its entries never change columns or scroll origin. */
:root:not([data-layout=phone]) .reward-news > * { margin-block: 0; }
:root:not([data-layout=phone]) .reward-news .new-stickers { gap: var(--space-2); margin-block: var(--space-1); }
:root:not([data-layout=phone]) .reward-news .win-pictures { flex-wrap: wrap; gap: var(--space-2); }
:root:not([data-layout=phone]) .celebrate .page-title-aside { margin-left: 0; }
:root:not([data-layout=phone]) .celebrate .page-title-words { flex: 0 1 auto; }
/* a pane too short for the title over the cards (the small tablet, 1024x600): the title, the party note and the figure share one row.
   The pane is a named size container, so this is the pane's height, not a window-size rule. */
.reward > .frame-pane { container: reward / size; }
@container reward (max-height: 27rem) {
  :root:not([data-layout=phone]) .celebrate { flex-wrap: nowrap; }
  :root:not([data-layout=phone]) .celebrate .page-title-words { display: flex; align-items: center; flex-wrap: nowrap; column-gap: var(--space-3); }
  :root:not([data-layout=phone]) .celebrate .lede:has(.party-note) { min-width: 0; }
  :root:not([data-layout=phone]) .reward-pick > .choices { padding-block: var(--space-1); }
  :root:not([data-layout=phone]) .reward-pick > h2 { font-size: var(--text-lg); }
  :root:not([data-layout=phone]) .celebrate .party-note { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
}
/* new island found: the same two columns on every class. What happened (and the two milestone pictures, a sticker's height) on the left, the friend who joins on the right.
   The pane is a named size container: a pane too short for the pictures drops them (a phone, the small tablet), so this is the pane's height, not a window-size rule. */
.cleared > .frame-pane { container: cleared / size; }
.cleared > .frame-pane .story-lines { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); align-content: center; align-items: center; column-gap: var(--space-4); max-width: none; }
.cleared .cleared-text { display: flex; flex-direction: column; min-width: 0; }
.cleared .cleared-text > .cleared-art { flex: none; height: var(--sticker); overflow: visible; margin-bottom: var(--space-2); }
.cleared .cleared-art > .milestone-art { width: auto; height: 100%; max-width: 50%; }
.cleared .cleared-text > .story-line { margin: var(--space-1) 0; }
.cleared .cleared-friends { display: flex; flex-direction: column; gap: var(--space-2); min-width: 0; }
.cleared .cleared-friends > .friend-joins { margin: 0; }
@container cleared (max-height: 440px) {   /* the pane's content height: the small tablet's is about 390px, a desktop 720px high with Bigger text about 480px (a query cannot read var() or scale with the root size) */
  .cleared .cleared-text > .cleared-art { display: none; } }
:where(:root[data-layout=phone]) .cleared .cleared-text > .cleared-art { display: none; }
:where(:root[data-layout=phone]) .cleared .cleared-text > .story-line { font-size: var(--text-sm); }
:where(:root[data-layout=phone]) .cleared .cleared-friends > .friend-joins { padding: var(--space-2) var(--space-3); }
:where(:root[data-layout=phone]) .cleared .friend-joins .friend-joins-art { grid-row: auto; align-self: center; }
:where(:root[data-layout=phone]) .cleared .cleared-friends .friend-joins h2 { position: absolute; width: var(--hairline); height: var(--hairline); overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }   /* heard, not drawn: the words and the picture say it */
:where(:root[data-layout=phone]) .cleared .cleared-friends .friend-joins .talk-line { align-self: center; }
:where(:root[data-layout=phone]) .cleared .friend-joins .talk-line::before { top: auto; bottom: auto; left: calc(var(--talk-tail) * -1); top: 50%; border-width: 0 0 var(--border-2) var(--border-2); rotate: 45deg; translate: 0 -50%; }   /* the friend is beside their words: the tail points left */
/* the gift: one tree, placed per class. The step (words and pips) sits over the picture, the words beside it, and what the gift does
   (its arrow tile and words) across the bottom on a tablet or desktop, under the words on a phone. The rows are fixed, so the picture
   never rides up over the title. */
:where(.gift) .gift-body { grid-template-rows: auto minmax(0, 1fr) auto; grid-template-areas: "progress progress" "scene words" "power power"; row-gap: var(--space-2); }
.gift-body > .gift-progress { grid-area: progress; display: flex; align-items: center; justify-content: center; gap: var(--space-3); }
.gift-progress > .gift-step { margin: 0; font-weight: var(--weight-bold); }
.gift-progress .step-pips { gap: var(--space-2); }
.gift-power .arrow-tile-name { line-height: var(--tile-name-leading); }
.gift-pips .step-pip-now { width: var(--pip-now); height: var(--pip-now); }
:where(:root[data-layout=phone]) .gift > .frame-pane { --pane-pad: var(--space-1); }
:where(:root[data-layout=phone]) .gift > .frame-pane > .page-title { position: absolute; width: var(--hairline); height: var(--hairline); overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:where(:root[data-layout=phone]) .gift-body { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); grid-template-rows: auto minmax(0, 1fr) auto; grid-template-areas: "progress words" "scene words" "scene power"; column-gap: var(--space-3); row-gap: var(--space-1); }
:where(:root[data-layout=phone]) .gift-progress > .gift-step { position: absolute; width: var(--hairline); height: var(--hairline); overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }   /* said, not drawn: the pips show the step */
:where(:root[data-layout=phone]) .gift-progress { --pip-size: var(--pip-phone); --pip-now: var(--pip-phone-now); }
:where(:root[data-layout=phone]) .gift-words > .gift-from { position: absolute; width: var(--hairline); height: var(--hairline); overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }   /* said, not drawn: their names are under their pictures */
.gift > .frame-pane.pane-card { container: gift / size; }
/* a short pane (a phone, or a small tablet at 1024x600), whatever the window: the picture fills its column, the figures scale to its smaller side and
   what the gift does joins the words column (a tablet puts the step over the words; a phone puts it over the picture, above) */
@container gift (max-height: 27rem) {
  .gift-body { --gift-figure: 2.2rem; --tile: 4.2rem; }
  :where(:root:not([data-layout=phone])) .gift-body { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-areas: "scene progress" "scene words" "scene power"; }
  .gift-body > .gift-scene { --gift-figure-fit: min(26cqh, 18cqw); --gift-sword-fit: min(28cqh, 20cqw); height: auto; min-height: 0; margin: 0; padding: var(--space-2) var(--space-1) var(--space-1); gap: var(--space-1); align-self: stretch; }
  .gift-scene :is(.gift-side, .gift-side-wrap) { gap: var(--space-1); }
  .gift-scene .gift-name { font-size: var(--text-xs); padding: 0 var(--space-1); }
  .gift-scene > * { --gift-mount: min(clamp(3.4rem, 11vw, 6rem), 17cqw); }   /* riders are a share of the picture's width, so five fit across */
  .gift-body > .gift-words { align-self: start; text-align: start; }
  .gift-body > .gift-words > .story-line, .gift-body > .gift-words > .gift-from { font-size: var(--text-sm); margin: 0 0 var(--space-1); }
  .gift-body > .gift-power { padding: var(--space-1) var(--space-2); gap: var(--space-2); max-height: 55cqh; overflow-y: auto; }
  .gift-power-words { grid-template-columns: minmax(0, 1fr); grid-auto-flow: row; grid-template-rows: auto; }
  .gift-power-words > .special { grid-row: auto; grid-column: 1 / -1; }
  .gift-power-words > p { margin: 0; font-size: var(--text-xs); }
}
/* the title: the three adventures in a row, short, and Settings and For grown-ups under them */
:where(:root[data-layout=phone]) .title-screen .tagline { font-size: var(--text-md); }
:where(:root[data-layout=phone]) .title-screen .adventure-rider { font-size: var(--text-lg); }
/* the title's own rail (the title is a plain pane, so the framed rail does not reach it): one grid on the pane, the rail's column
   at the left (the emblem over the icon squares), the wordmark and the three cards in the other. The pane's children are
   siblings, so CSS places them: .logo, .menu and the stack give up their boxes (display: contents). Same tokens as the framed rail. */
:root[data-layout=phone] .title-screen { --art-cheer: min(3.4rem, 15vh); --pane-gap: var(--space-1); --slot-card-min-h: var(--target); --brand-emblem-w: var(--rail-w); --brand-wordmark-w: min(16rem, 50vh); --rail-w: var(--target); --rail-gap: var(--space-0); }
:root[data-layout=phone] .title-screen > .frame-pane { display: grid; grid-template-columns: var(--rail-1-w) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) minmax(0, 3fr); column-gap: 0; row-gap: var(--pane-gap); align-items: stretch; text-align: center; }
:root[data-layout=phone] .title-screen .logo { display: contents; }
:root[data-layout=phone] .title-screen .brand-emblem { grid-area: 1 / 1; place-self: center; width: var(--rail-w); }
:root[data-layout=phone] .title-screen .brand-words { grid-area: 1 / 2; place-self: center; min-height: 0; max-height: 100%; width: min(100%, var(--brand-wordmark-w)); }
:root[data-layout=phone] .title-screen .brand-words > .icon, :root[data-layout=phone] .title-screen .brand-words > svg, :root[data-layout=phone] .title-screen .brand-words > img { max-height: 100%; }
:root[data-layout=phone] .title-screen .tagline { position: absolute; width: var(--hairline); height: var(--hairline); overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }   /* said, not shown */
:root[data-layout=phone] .title-screen .main-build-badge { grid-area: 1 / 2; place-self: start end; margin: 0; }
:root[data-layout=phone] .title-screen .adventures { grid-area: 2 / 2; min-height: 0; height: 100%; }
:root[data-layout=phone] .title-screen .adventure-cards { --slot-cols: 3; gap: var(--space-2); height: 100%; }   /* three in a row, whatever the pane's width (hud.css's container rule makes one column under 38rem) */
:root[data-layout=phone] .title-screen .menu, :root[data-layout=phone] .title-screen .menu > .actions-stack { display: contents; }
:root[data-layout=phone] .title-screen .menu .actions-center {
  grid-area: 2 / 1; display: flex; flex-direction: column; flex-wrap: nowrap; align-items: center; justify-content: flex-end; gap: var(--rail-gap);
  align-self: stretch; margin: 0; width: auto; position: static; left: auto; translate: none;
}
:root[data-layout=phone] .title-screen .menu .actions-center > .btn { flex: none; width: var(--rail-w); min-width: var(--rail-w); height: var(--rail-w); min-height: var(--rail-w); padding: 0; justify-content: center; }
:root[data-layout=phone] .title-screen .title-start { grid-area: 2 / 2; place-self: center; width: auto; }
/* tablet and desktop: the star row sizes to its card (each star at most the card's width over the islands, less the gaps; the
   count is --islands, set on the card by title.js), and a pane too short for tall cards (the small tablet, 1024x600) puts a card's
   picture beside its names. The pane is a named size container, so this is the pane's height, not a window-size rule. */
.title-screen > .frame-pane.pane-plain { container: title / size; }
.adventures .adventure-card { container-type: inline-size; --star-room: 100cqi; }
.adventure-card .adventure-star-row .icon { flex: 0 1 min(var(--icon-lg), calc((var(--star-room) - var(--space-1) * (var(--islands) - 1)) / var(--islands))); }
@container title (max-height: 32rem) {
  :root:not([data-layout=phone]) .title-screen .brand-emblem { --brand-emblem-w: 3.5rem; }
  :root:not([data-layout=phone]) .title-screen .brand-words { --brand-wordmark-w: 11rem; }
  :root:not([data-layout=phone]) .title-screen .adventure-card:not(:is(.adventure-new, .adventure-newer)) {
    display: grid; grid-template-columns: var(--art-cheer) minmax(0, 1fr); align-items: center; column-gap: var(--space-3); padding: var(--space-3); text-align: left;
    --star-room: calc(100cqi - var(--art-cheer) - var(--space-3));
  }
  :root:not([data-layout=phone]) .title-screen .adventure-card .mount { --art-mount: var(--art-cheer); grid-row: span 2; }
  :root:not([data-layout=phone]) .title-screen .adventure-card > :is(.adventure-battle, .adventure-note, .adventure-go) { grid-column: 1 / -1; }
  :root:not([data-layout=phone]) .title-screen .adventure-card:not(:is(.adventure-new, .adventure-newer)) .adventure-names { align-items: flex-start; }
  :root:not([data-layout=phone]) .title-screen .adventure-card:not(:is(.adventure-new, .adventure-newer)) :is(.adventure-stars, .adventure-star-row) { justify-content: flex-start; }
  :root:not([data-layout=phone]) .title-screen .adventure-card:not(:is(.adventure-new, .adventure-newer)) .adventure-stars-text { text-align: left; }
  :root:not([data-layout=phone]) .title-screen .adventure-card:not(:is(.adventure-new, .adventure-newer)) .adventure-go { margin-top: 0; }
}
/* naming (the phone): row 1 your horse's picture over its card chip, then the ideas side by side, each name whole on one line (the
   picture scales first, never the names); row 2 New ideas (the dice) beside your own box, whose pencil shows. No label drawn: the
   box rises under the ideas, so it stays above an on-screen keyboard. The rider step has no picture: its first column is empty. */
:where(:root[data-layout=phone]) .create-name .create-body, :where(:root[data-layout=phone]) .create-name .create-body:has(> .name-aside) { max-width: none; display: grid; grid-template-columns: auto auto minmax(0, 1fr); grid-template-areas: "aside ideas ideas" "aside dice own"; gap: var(--space-2) var(--space-3); align-content: center; align-items: center; }
:where(:root[data-layout=phone]) .create-name .create-body > .name-ideas, :where(:root[data-layout=phone]) .create-name .create-body:has(> .name-aside) > .name-ideas { grid-area: ideas; flex-direction: row; flex-wrap: nowrap; align-self: center; padding-block: var(--space-1); padding-inline: 0; gap: var(--space-2); min-width: 0; }
:where(:root[data-layout=phone]) .create-name .create-body > .name-ideas > .choice-tile { flex: 1 1 auto; min-width: var(--name-tile-min-w); min-height: var(--target); font-size: var(--text-md); padding-block: 0; padding-inline: var(--space-1); }
:where(:root[data-layout=phone]) .create-name .name-ideas .choice-word { max-width: none; overflow-wrap: normal; word-break: normal; white-space: nowrap; }   /* a name is never broken */
:where(:root[data-layout=phone]) .create-name .name-box > input { min-height: var(--target); height: var(--target); min-width: 0; }
:where(:root[data-layout=phone]) .create-name .create-body > .name-dice, :where(:root[data-layout=phone]) .create-name .create-body:has(> .name-aside) > .name-dice { grid-area: dice; margin: 0; }
:where(:root[data-layout=phone]) .create-name .create-body > .name-own, :where(:root[data-layout=phone]) .create-name .create-body:has(> .name-aside) > .name-own { grid-area: own; margin: 0; max-width: none; align-items: stretch; gap: 0; }
:where(:root[data-layout=phone]) .create-name .name-own label { position: absolute; width: var(--hairline); height: var(--hairline); overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }   /* said, not drawn: the pencil and the box say it */
:where(:root[data-layout=phone]) .create-name .create-body > .name-aside { margin: 0; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-1); }
:where(:root[data-layout=phone]) .create-name { --art-pick: 5rem; }
/* the horse step: the card is its chip, which carries "Sunny brings Gallop!" in its label; the card and the caption are not drawn */
:where(:root[data-layout=phone]) .create-name .name-aside-card { width: auto; }
:where(:root[data-layout=phone]) .create-name .name-aside-card > :not(.name-brings) { display: none; }
:where(:root[data-layout=phone]) .create-name .name-brings { position: absolute; width: var(--hairline); height: var(--hairline); overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:where(:root[data-layout=phone]) .create-name .name-aside-chip { display: inline-flex; margin: 0; }
/* naming (tablet and desktop, a small tablet: 1024x600): your horse's card stands beside the ideas, not under them (the question moves up
   into the bar with the other steps: styles/create.css) */
@container app (max-height: 640px) {   /* --small-tablet-h */
  :root:not([data-layout=phone]) .create-name .create-body > .name-aside { flex-direction: row; gap: var(--space-2); }
  :root:not([data-layout=phone]) .create-name .create-body > .name-ideas > .choice-tile { min-width: var(--name-tile-min-w); font-size: var(--text-lg); }
  :root:not([data-layout=phone]) .create-name > .frame-pane { padding-block: var(--space-1); }
}
/* making your rider: the horses fit the pane, your rider stands beside the looks' tabs, and the story is shorter lines */
:where(:root[data-layout=phone]) .create-who { --art-pick: 3.2rem; }
/* pick your horse (the phone): the pips are one small row over the pane's top (styles/create.css: every step), the question is not drawn (still the
   heading; Hear it says it), and the five tiles stand in one row at the pane's whole height, each horse scaling to its tile; the chip is
   its icon, and the coat's words are whole (smaller words first, never broken inside a word) */
:where(:root[data-layout=phone]) .create-horse > .frame-pane { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
:where(:root[data-layout=phone]) .create-horse > .frame-pane > .create-body { grid-area: 1 / 1; min-height: 0; }
:where(:root[data-layout=phone]) .create-horse > .frame-pane > .page-title { position: absolute; width: var(--hairline); height: var(--hairline); overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }   /* not drawn, still a heading */
:where(:root[data-layout=phone]) .create-horse .choice-grid { gap: var(--space-1); align-items: stretch; }
:where(:root[data-layout=phone]) .create-horse .horse-card-rules { display: none; }
:where(:root[data-layout=phone]) .create-horse .choice-grid > .choice-tile { font-size: var(--text-sm); padding: var(--space-1); gap: var(--space-1); max-width: none; height: auto; }
:where(:root[data-layout=phone]) .create-horse .choice-name { min-height: calc(var(--text-sm) * var(--leading-tight) * 2); font-size: var(--text-sm); }
:where(:root[data-layout=phone]) .create-horse .choice-word .card-chip { width: auto; justify-content: center; padding-inline: var(--space-1); }
:where(:root[data-layout=phone]) .create-horse .card-chip-name { position: absolute; width: var(--hairline); height: var(--hairline); overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }   /* its words name the tile for screen readers */
:where(:root[data-layout=phone]) .create-easier .page-title .lede { font-size: var(--text-sm); line-height: var(--leading-tight); }
:where(:root[data-layout=phone]) .create-easier .easier-later { position: absolute; width: var(--hairline); height: var(--hairline); overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }   /* said, not drawn: Hear it says it */
:where(:root[data-layout=phone]) .create-easier > .frame-pane > .page-title h1 { position: absolute; width: var(--hairline); height: var(--hairline); overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }   /* the question is not drawn, still the heading */
:where(:root[data-layout=phone]) .create-easier .page-title-pic { display: none; }
:where(:root[data-layout=phone]) .create-easier .create-body { justify-content: center; }
:where(:root[data-layout=phone]) .create-easier .choice-grid { flex: 0 1 60%; }   /* the tiles are about 60% of the pane's height */
:where(:root[data-layout=phone]) .create-easier .choice-grid > .choice-tile { padding-block: var(--space-2); }
/* your look (phone): your rider the pane's whole height at the left, the tabs a 2x4 grid of icons beside it, the choices in the rest.
   (The steps' pips over the pane are styles/create.css.) The question is not drawn (it stays for screen readers, and Hear it says it);
   Surprise me stands over Undo over Looks great! */
:root[data-layout=phone] .create-looks > .region-foot .actions > :first-child { order: 1; }   /* Undo under Surprise me */
:root[data-layout=phone] .create-looks > .region-foot .actions > :last-child { order: 2; }
:where(:root[data-layout=phone]) .create-looks {
  --looks-preview-w: 7.2rem; --looks-min-h: 0px; --swatch-size: var(--target); --h1: var(--text-md);
  --look-tile-w: 3.4rem; --look-pic-w: 2.2rem; --look-pic-h: 1.4rem;
  --look-tile-h: calc(var(--space-1) * 2 + var(--look-pic-h) + var(--space-1) + var(--text-xs) * var(--leading-tight) * 2 + var(--border-1) + var(--border-2) * 2);
}
:where(:root[data-layout=phone]) .create-looks .choice-tile.option-tile { padding: var(--space-1) var(--space-0); border-width: var(--border-2); font-size: var(--text-xs); }
:where(:root[data-layout=phone]) .create-looks > .frame-pane { display: grid; grid-template-columns: var(--looks-preview-w) auto minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); column-gap: var(--space-2); row-gap: 0; }
:where(:root[data-layout=phone]) .create-looks > .frame-pane > .page-title { position: absolute; width: var(--hairline); height: var(--hairline); overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }   /* not drawn, still a heading */
:where(:root[data-layout=phone]) .create-looks .create-body, :where(:root[data-layout=phone]) .create-looks .looks { display: contents; }
:where(:root[data-layout=phone]) .create-looks .looks-preview { grid-area: 1 / 1; grid-template-rows: minmax(0, 1fr); }
:where(:root[data-layout=phone]) .create-looks .looks-preview > .create-preview { width: auto; height: 100%; max-width: 100%; }
:where(:root[data-layout=phone]) .create-looks .looks-tabs { grid-area: 1 / 2; --tab-min-w: var(--target); grid-template-columns: repeat(2, var(--target)); grid-template-rows: repeat(4, var(--target)); grid-auto-rows: var(--target); align-content: start; }
:where(:root[data-layout=phone]) .create-looks .looks-tabs .tab { min-width: var(--target); min-height: var(--target); padding: 0; justify-content: center; }
:where(:root[data-layout=phone]) .create-looks .looks-tabs .tab-word { position: absolute; width: var(--hairline); height: var(--hairline); overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }   /* its words name the tab for screen readers */
/* One stable grid gives each picker its space, independent of its current color name. */
:where(:root[data-layout=phone]) .create-looks .looks-panel { grid-area: 1 / 3; display: grid; grid-template-columns: minmax(0, 1fr); align-items: start; align-content: start; justify-content: stretch; gap: var(--space-1); --gap-targets: var(--space-1); padding: 0; }
:where(:root[data-layout=phone]) .create-looks .looks-panel:has(> .swatch-picker):has(> .option-picker) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
:where(:root[data-layout=phone]) .create-looks .looks-panel > .swatch-picker, :where(:root[data-layout=phone]) .create-looks .looks-panel > .option-picker { min-width: 0; }
:where(:root[data-layout=phone]) .create-looks .looks-panel:has(> .swatch-picker) > .option-picker { --option-tile-w: var(--target); }
/* The open tab names its tiles; their legend stays available to screen readers. */
:where(:root[data-layout=phone]) .create-looks .looks-panel:has(> .swatch-picker) > .option-picker > legend { position: absolute; width: var(--hairline); height: var(--hairline); overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:where(:root[data-layout=phone]) .create-looks .looks-panel legend { font-size: var(--text-xs); margin-bottom: 0; }
:where(:root[data-layout=phone]) .create-looks .looks-panel > .swatch-picker legend { margin: 0; }
:where(:root[data-layout=phone]) .create-looks .looks-panel .swatches { max-width: none; margin-inline: 0; }
:where(:root[data-layout=phone]) .create-looks .looks-panel .picker-name, :where(:root[data-layout=phone]) .create-looks .looks-panel .swatch-picked { font-size: var(--text-floor); line-height: 1; height: var(--text-floor); }
:where(:root[data-layout=phone]) .create-looks .looks-panel .swatch-picked { margin-top: 0; }
:where(:root[data-layout=phone]) .create-looks .looks-panel .picker-title .icon { display: none; }

/* your look (tablet and desktop, short of height): the question moves up into the slim top bar beside the pips (the pane's own title is that
   heading, so screen readers keep it), which gives the pane its height back, and your rider scales to it. Short is a small tablet (1024x600:
   #app's height under 640px of content) or Bigger text, which makes the choices taller. */
@container app (max-height: 640px) {   /* #app's content box: the window's 600px to 640px less its padding */
  :root:not([data-layout=phone]) .create-looks { --look-pic-h: 2.2rem; }   /* a shorter picture in each tile */
  :root:not([data-layout=phone]) .create-horse > .frame-pane,
  :root:not([data-layout=phone]) .create-looks > .frame-pane { padding-block: var(--space-1); }
  :root:not([data-layout=phone]) .create-looks .looks { row-gap: var(--space-1); }
  :root:not([data-layout=phone]) .create-looks .looks-preview > .create-preview { width: auto; height: 100%; max-width: 100%; }
  :root:not([data-layout=phone]) .create-looks .looks-tabs { --tab-min-w: 0; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); }   /* every tab in one row */
  :root:not([data-layout=phone]) .create-looks .looks-tabs .tab { padding-inline: var(--space-0); font-size: var(--text-xs); }
  :root:not([data-layout=phone]) .create-looks .looks-panel legend { margin-bottom: 0; }
}
html.big-text:not([data-layout=phone]) .create-looks { --look-pic-h: 2.2rem; }
html.big-text:not([data-layout=phone]) .create-horse > .frame-pane,
html.big-text:not([data-layout=phone]) .create-looks > .frame-pane { padding-block: var(--space-1); }
html.big-text:not([data-layout=phone]) .create-looks .looks { row-gap: var(--space-1); }
html.big-text:not([data-layout=phone]) .create-looks .looks-panel legend { margin-bottom: 0; }
html.big-text:not([data-layout=phone]) .create-looks .looks-preview > .create-preview { width: auto; height: 100%; max-width: 100%; }

:where(:root[data-layout=phone]) #app:has(.frame-head) {
  --map-sign-lines: 1;
  --map-sign-h: var(--row-md);
  --map-sign-h-town: var(--row-md);
  --notice-lines: 2;
  --notice-h: max(var(--row-md), calc(var(--text-sm) * var(--leading) * var(--notice-lines) + var(--space-1) * 2 + var(--frame-border) * 2));
  --head-h: calc(var(--notice-h) + var(--bar-chrome));
  --foot-map-h: calc(var(--map-sign-h) + var(--bar-chrome));
  --foot-town-h: calc(var(--map-sign-h-town) + var(--bar-chrome));
}
:where(:root[data-layout=phone]) #app:has(.frame-head) .frame-foot:has(.map-sign) { flex-wrap: nowrap; align-items: center; }   /* the travel button, the sign and the go button share the one row */
:where(:root[data-layout=phone]) #app:has(.frame-head) .frame-foot > .map-sign { flex: 1 1 0; }
:where(:root[data-layout=phone]) #app:has(.frame-head) .frame-foot .map-sign-text { flex-direction: row; flex-wrap: wrap; justify-content: flex-start; align-items: center; align-content: safe center; gap: 0 var(--space-3); }   /* where you stand, then its state, foes and prize, in the sign's one row of room */
:where(:root[data-layout=phone]) #app:has(.frame-head) .frame-foot .map-sign-text > * { margin: 0; }
:where(:root[data-layout=phone]) #app:has(.frame-head) .frame-foot .map-sign-text > p { font-size: var(--text-sm); }
:where(:root[data-layout=phone]) #app:has(.frame-head) .frame-foot .map-sign-text > :is(.why-note, .buddy-along) { flex-basis: 100%; }
:where(:root[data-layout=phone]) #app:has(.frame-head) .frame-foot .map-sign-name, :where(:root[data-layout=phone]) #app:has(.frame-head) .town-sign .map-sign-name { font-size: var(--text-md); }
:where(:root[data-layout=phone]) #app:has(.frame-head) .frame-foot .map-sign-go .btn { padding-inline: var(--space-3); font-size: var(--text-sm); max-height: 100%; }   /* one size, and its words (all of them are its name) stay in the row */
:where(:root[data-layout=phone]) #app:has(.frame-head) .frame-foot .map-sign-go .btn-label { line-height: var(--leading-tight); display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: var(--map-button-lines); line-clamp: var(--map-button-lines); overflow: hidden; }
/* the town's touch line floats over the map's top edge, over the sky (never a place's label): its room can't be kept in a pane this short */
:where(:root[data-layout=phone]) #app:has(.frame-head) .frame-pane { position: relative; }
:where(:root[data-layout=phone]) #app:has(.frame-head) .roam-touch-help { position: absolute; left: 50%; top: calc(var(--map-pane-pad) + var(--space-1)); bottom: auto; translate: -50% 0; z-index: 2; margin: 0; padding: 0 var(--space-3); border-radius: var(--radius-round); background: var(--pane-bg); pointer-events: none; }

/* the stage pane is the battle's grid area */
:root[data-layout=phone] .frame[data-kind=stage] > .region-pane { grid-area: stage; }

/* ---------- the rail: a framed screen on a phone ----------
   On a phone (html[data-layout=phone], 500px tall or less) a framed screen (data-kind=framed: one
   with a top bar) draws no head, and its top bar and footer join into one slim column at the left
   (the rail, --rail-1-w: one target wide, like the battle's): the pane takes the page's height at the
   right. The rail is one column of icon squares, top to bottom: your hearts, the notice button, Home,
   Sound and Settings, an empty row that takes what is left, then the travel button and Go (or the
   place's main action). Where the column is taller than the page, the top bar scrolls in itself and
   the footer stays whole (design-ui.md "The rail"). Keyed on the class, not the window: no size @media. */
/* the tokens, the grid and the seam, shared by a framed screen and the create steps (one rail) */
:root[data-layout=phone] #app:has(> .frame:is([data-kind=framed],[data-kind=steps])) {
  --rail-w: var(--target);   /* one target: the rail's squares, with Bigger text too (--rail-1-w holds it) */
  --rail-pad: calc(var(--space-1) / 2);   /* the rail's inner edge */
  --rail-gap: var(--space-0);   /* between the rail's squares: as tight as a column of targets allows */
  --rail-across: var(--space-0);   /* between the rail's squares where a row holds two */
  display: grid; grid-template-columns: var(--rail-1-w) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto;
  column-gap: var(--space-0); row-gap: 0;
  padding-left: max(var(--space-0), env(safe-area-inset-left)); padding-right: max(var(--space-0), env(safe-area-inset-right));
}
:root[data-layout=phone] #app > .frame:is([data-kind=framed],[data-kind=steps]) { display: contents; }
:root[data-layout=phone] .frame:is([data-kind=framed],[data-kind=steps]) > .region-pane { grid-area: 1 / 2 / 3 / 3; }
:root[data-layout=phone] .frame:is([data-kind=framed],[data-kind=steps]) > .region-foot { grid-area: 2 / 1; height: auto; min-height: min-content; border-top: 0; border-top-left-radius: 0; border-top-right-radius: 0; }   /* the footer is as wide as the top bar (--rail-1-w), and meets it (below) */
:root[data-layout=phone] #app:has(> .frame:is([data-kind=framed],[data-kind=steps]) > .region-foot) > .frame-top { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
/* the top bar scrolls in itself where the column is taller than the page (a 320px phone): the footer's travel and Go stay
   whole. A swiped column: its bar is hidden, and a button that takes focus scrolls itself into view */
:root[data-layout=phone] #app:has(> .frame:is([data-kind=framed],[data-kind=steps])) > .frame-top { grid-area: 1 / 1; margin: 0; height: auto; min-height: 0; overflow-x: clip; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: none; }
:root[data-layout=phone] #app:has(> .frame[data-kind=framed]) {
  --map-pane-pad: calc(var(--space-1) / 2);   /* a thinner edge round the map: at 667px wide the map keeps its least width (--map-min-w) */
  --art-hud: var(--rail-w);
}
:root[data-layout=phone] .frame[data-kind=framed] > .region-keys { display: none; }
/* the head is not seen: its title (where you are) stays for screen readers and takes focus as you arrive; its notices are said as you arrive */
:root[data-layout=phone] .frame[data-kind=framed] > .region-head { position: absolute; width: var(--hairline); height: var(--hairline); padding: 0; border: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:root[data-layout=phone] .frame[data-kind=framed] > .region-head > .frame-notice { display: none; }
/* one rail: the top bar's bottom meets the footer's top (no top edge, above), with one line between them */
:root[data-layout=phone] #app:has(> .frame[data-kind=framed] > .region-foot) > .frame-top { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
/* the top bar: one column of squares: your hearts, the notice button, Home, Sound and Settings */
:root[data-layout=phone] #app:has(> .frame[data-kind=framed]) > .hud {
  display: flex; flex-direction: column; flex-wrap: nowrap; align-items: center; gap: var(--rail-gap);
  padding: var(--space-1) var(--rail-pad); width: var(--rail-1-w);
}
/* the place's name, you and your names: kept for screen readers, not drawn (a 68px column has no room for words or a second picture) */
:root[data-layout=phone] #app:has(> .frame[data-kind=framed]) :is(.hud-place, .hud-who, .hud-names) { display: block; position: absolute; width: var(--hairline); height: var(--hairline); margin: 0; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:root[data-layout=phone] #app:has(> .frame[data-kind=framed]) .hud-stats { flex: none; flex-wrap: nowrap; margin: 0; }
:root[data-layout=phone] #app:has(> .frame[data-kind=framed]) .hud-extra { display: none; }   /* Hearts only, as on a phone upright */
:root[data-layout=phone] #app:has(> .frame[data-kind=framed]) .hud .stat-word { display: none; }
:root[data-layout=phone] #app:has(> .frame[data-kind=framed]) .hud .stat { gap: var(--space-0); padding-inline: var(--space-0); font-size: var(--text-sm); }   /* the heart and its number, a size smaller: in the column's width, Bigger text too */
:root[data-layout=phone] #app:has(> .frame[data-kind=framed]) .hud-buttons { flex: none; flex-direction: column; flex-wrap: nowrap; align-items: center; margin: 0; gap: var(--rail-gap); }
:root[data-layout=phone] #app:has(> .frame[data-kind=framed]) :is(.hud-buttons .btn, .hud-notice) { flex: none; width: var(--rail-w); min-width: var(--rail-w); height: var(--rail-w); min-height: var(--rail-w); padding: 0; }
/* the notice button: under your hearts (a screen with a head: its notices; layout-system.md decision 1), a target square;
   a dot on its top right corner when there is news (its name says so too) */
:root[data-layout=phone] #app:has(> .frame[data-kind=framed]) .hud-notice { display: inline-flex; position: relative; }
:root[data-layout=phone] #app:has(> .frame[data-kind=framed]) .hud-notice > .notice-dot {
  position: absolute; top: var(--space-1); right: var(--space-1); width: var(--space-3); height: var(--space-3);
  border: var(--border-1) solid var(--new-ink); border-radius: var(--radius-round); background: var(--new-bg); pointer-events: none;
}
/* a narrow pane (667px wide): a map that fills its window's width keeps half a target of room at each side, so a spot or a find at its edge stays in the window */
:root[data-layout=phone] #app:has(> .frame[data-kind=framed]) .map-area { --map-fit-w: max(var(--map-min-w), min(calc(100% - var(--target)), calc(var(--map-room) * var(--map-w) / var(--map-h)))); }
/* the footer: the rest of the column (layout-system.md section 3): an empty room that takes what is left, then the travel button,
   then Go or the place's main action (a full-screen place's buttons stack, a place book's pager too), each a target square.
   The sign's words (where you stand) are its Go button's name and are said aloud: not drawn. The sign and its buttons take
   part in the footer's column themselves (display: contents): no node moves. */
:root[data-layout=phone] #app:has(> .frame[data-kind=framed]) .frame-foot, :root[data-layout=phone] #app:has(> .frame[data-kind=framed]) .frame-foot:has(.map-sign) {
  display: flex; flex-direction: column; flex-wrap: nowrap; align-items: center; justify-content: flex-end; gap: var(--rail-gap);
  width: var(--rail-1-w); padding: var(--space-1) var(--rail-pad);
}
:root[data-layout=phone] #app:has(> .frame[data-kind=framed]) .frame-foot :is(.map-sign, .map-sign-go, .actions, .place-book-pager-slot) { display: contents; }
:root[data-layout=phone] #app:has(> .frame[data-kind=framed]) .frame-foot > .frame-travel { flex: none; margin: 0; display: flex; }
:root[data-layout=phone] #app:has(> .frame[data-kind=framed]) .frame-foot .map-sign-text { display: block; position: absolute; width: var(--hairline); height: var(--hairline); margin: 0; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:root[data-layout=phone] #app:has(> .frame[data-kind=framed]) .frame-foot :is(.map-sign-go, .actions, .place-book-pager-slot) .btn { flex: none; order: 1; width: var(--rail-w); min-width: var(--rail-w); max-width: none; height: var(--rail-w); min-height: var(--rail-w); margin: 0; padding: 0; }
/* a full-screen place's sign (the tack room, the show, the memory match): its words are not drawn (said aloud and kept for screen
   readers, as the map's sign), its stars and its shine (icons and a number) stack in the column over its button */
:root[data-layout=phone] #app:has(> .frame[data-kind=framed]) .frame-foot :is(.show-sign, .show-sign-text) { display: contents; }
:root[data-layout=phone] #app:has(> .frame[data-kind=framed]) .frame-foot .show-sign-line { display: block; position: absolute; width: var(--hairline); height: var(--hairline); margin: 0; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:root[data-layout=phone] #app:has(> .frame[data-kind=framed]) .frame-foot .tries-stars { flex: none; flex-wrap: wrap; justify-content: center; gap: 0; max-width: var(--rail-w); margin: 0; }
:root[data-layout=phone] #app:has(> .frame[data-kind=framed]) .frame-foot .stat { flex: none; max-width: var(--rail-w); padding-inline: var(--space-1); }
:root[data-layout=phone] #app:has(> .frame[data-kind=framed]) .frame-foot .stat-word { display: none; }
/* a button with no icon keeps its words: smaller, in its square (a place's own main action; layout-system.md decision 5) */
:root[data-layout=phone] #app:has(> .frame[data-kind=framed]) .frame-foot .actions .btn:not(.btn-pic) { font-size: var(--text-xs); white-space: normal; overflow-wrap: anywhere; }
:root[data-layout=phone] #app:has(> .frame[data-kind=framed]) .frame-foot > .actions.book-pager {
  display: flex; flex-direction: column; align-items: center; gap: var(--space-1); position: absolute; top: 50%; right: var(--space-1); translate: 0 -50%; width: var(--target); z-index: 1;
}   /* the card book's pager stands at the cards' right edge (the frame is its containing block), not in the rail: the rail has no room for it */
/* a place's book (the house's sticker book): its pager stacks over the way back to the house (the footer's go button) */
:root[data-layout=phone] #app:has(> .frame[data-kind=framed]) .frame-foot .place-book-pager-slot .btn { order: 0; }
/* an icon square always shows its icon in the rail's footer (talk.css's rows that give their words the room hide icons) */
:root[data-layout=phone] .frame:is([data-kind=framed],[data-kind=steps]) > .region-foot .btn.btn-pic:not(.btn-words) > .icon { display: inline-block; margin: 0; }
/* the travel button: a target square (its picture; its words are still its name, said aloud) */
:root[data-layout=phone] #app:has(> .frame[data-kind=framed]) .btn-travel { width: var(--rail-w); min-width: var(--rail-w); height: var(--rail-w); min-height: var(--rail-w); padding: 0; justify-content: center; }
:root[data-layout=phone] #app:has(> .frame[data-kind=framed]) .btn-travel .travel-words { position: absolute; width: var(--hairline); height: var(--hairline); overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- the town on a phone and a small tablet (issue 525) ----------
   One tree; the class places it. On a phone the rail keeps the hearts, the notice button, Sound, Settings and the travel button;
   the town's sign is one chip floating at the pane's bottom left (the place's picture and name), its go button (or the roam
   pop's two) floats at the bottom right, the touch line is at the top (above), and the saved cue is at the pane's top right.
   The parts are the footer's children, so they float by the window (fixed) and stay inside the pane's rect. */
:root[data-layout=phone] #app:has(> .frame[data-kind=framed]) :is(.town-screen, .world-screen, .island-screen) {
  --town-edge-l: calc(var(--rail-1-w) + max(var(--space-0), env(safe-area-inset-left)) + var(--map-float-inset));   /* the pane's left edge, and the inset */
  --town-edge-r: calc(max(var(--space-0), env(safe-area-inset-right)) + var(--map-float-inset));
  --town-edge-b: calc(var(--space-1) + var(--map-float-inset));
}
:root[data-layout=phone] #app:has(> .frame[data-kind=framed]) :is(.town-screen, .world-screen, .island-screen) .frame-foot :is(.map-sign-go, :is(.town-sign, .world-sign, .island-sign) .map-sign-text) { position: fixed; bottom: var(--town-edge-b); z-index: 2; }
:root[data-layout=phone] #app:has(> .frame[data-kind=framed]) :is(.town-screen, .world-screen, .island-screen) .frame-foot .map-sign-go {
  display: flex; flex-direction: column-reverse; gap: var(--map-float-inset); right: var(--town-edge-r);
}
:root[data-layout=phone] #app:has(> .frame[data-kind=framed]) :is(.town-screen, .world-screen, .island-screen) .frame-foot .map-sign-go .btn {
  order: 0; width: var(--rail-go-h); min-width: var(--rail-go-h); height: var(--rail-go-h); min-height: var(--rail-go-h); margin: 0; padding: 0;
}
:root[data-layout=phone] #app:has(> .frame[data-kind=framed]) :is(.town-screen, .world-screen, .island-screen) .frame-foot :is(.town-sign, .world-sign, .island-sign) .map-sign-text {
  display: flex; align-items: center; left: var(--town-edge-l); width: auto; height: auto; margin: 0; padding: var(--space-1) var(--space-3); overflow: hidden; clip: auto; white-space: nowrap;
  box-sizing: border-box; min-height: var(--target); max-width: calc(100vw - var(--town-edge-l) - var(--town-edge-r) - var(--rail-go-h) - var(--map-float-inset));
  background: var(--pane-bg); border: var(--border-1) solid var(--line-soft); border-radius: var(--radius-round); box-shadow: var(--elev-1);
}
:root[data-layout=phone] #app:has(> .frame[data-kind=framed]) :is(.town-screen, .world-screen, .island-screen) .frame-foot :is(.town-sign, .world-sign, .island-sign) .map-sign-name {
  display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--text-md);
}
:root[data-layout=phone] #app:has(> .frame[data-kind=framed]) :is(.town-screen, .world-screen, .island-screen) .frame-foot :is(.town-sign, .world-sign, .island-sign) .map-sign-name .header-token { vertical-align: middle; margin-inline-end: var(--space-2); }
:root[data-layout=phone] #app:has(> .frame[data-kind=framed]) .town-screen .roam-touch-help { width: max-content; max-width: 70%; }   /* one line where it fits, over the sky, clear of the saved cue at the right */
/* the sign's other lines are kept for screen readers, not drawn */
:root[data-layout=phone] #app:has(> .frame[data-kind=framed]) :is(.town-screen, .world-screen, .island-screen) .frame-foot :is(.town-sign, .world-sign, .island-sign) .map-sign-text > :not(.map-sign-name, .map-sign-stars, .map-sign-chips) {
  position: absolute; display: block; width: var(--hairline); height: var(--hairline); margin: 0; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
/* the spots map keeps its window clear of the floating parts (map-view.js reads these) */
:root[data-layout=phone] :is(.town-screen, .world-screen, .island-screen) .map-scroll { scroll-padding-bottom: calc(var(--rail-go-h) + var(--map-float-inset)); scroll-padding-right: calc(var(--rail-go-h) + var(--map-float-inset)); }
/* the saved cue: at the pane's top right on the town, not over the rail */
:root[data-layout=phone]:has(.town-screen) .saved-cue {
  left: auto; right: calc(max(var(--space-0), env(safe-area-inset-right)) + var(--map-float-inset));
  top: calc(var(--space-1) + var(--map-float-inset));
}
/* ---------- the sea map on a phone (issue 526) ----------
   The rail keeps Sound, Settings, Home, the notice button and the travel button (its hearts leave it); the sign is a chip at the
   pane's bottom left (the island's picture, its name and its stars done), the go button floats at the bottom right (above), and
   the hearts are a chip at the pane's top left. One tree: the parts float by the window (fixed), inside the pane's rect. */
/* the star count is drawn on a phone only (screen readers have the sign's words) */
.world-sign .map-sign-stars { display: none; }
:root[data-layout=phone] #app:has(> .frame[data-kind=framed]) .world-screen .frame-foot .world-sign .map-sign-name { display: flex; align-items: center; }   /* the island's picture (a block) and its name on one line */
:root[data-layout=phone] #app:has(> .frame[data-kind=framed]) .world-screen .frame-foot .world-sign .map-sign-text { pointer-events: none; }   /* the chip is words only: a tap goes through to the map under it */
:root[data-layout=phone] #app:has(> .frame[data-kind=framed]) .world-screen .frame-foot .world-sign .map-sign-stars { display: inline-flex; flex: none; align-items: center; gap: var(--space-1); margin: 0 0 0 var(--space-3); font-size: var(--text-md); font-weight: var(--weight-heavy); }
:root[data-layout=phone] #app:has(> .frame[data-kind=framed]):has(:is(.world-screen, .island-screen)) > .hud { overflow: visible; }
:root[data-layout=phone] #app:has(> .frame[data-kind=framed]):has(:is(.world-screen, .island-screen)) > .hud .hud-buttons { display: contents; }
:root[data-layout=phone] #app:has(> .frame[data-kind=framed]):has(:is(.world-screen, .island-screen)) > .hud .hud-buttons > .sound-toggle { order: 1; }
:root[data-layout=phone] #app:has(> .frame[data-kind=framed]):has(:is(.world-screen, .island-screen)) > .hud .hud-buttons > :last-child { order: 2; }
:root[data-layout=phone] #app:has(> .frame[data-kind=framed]):has(:is(.world-screen, .island-screen)) > .hud .hud-buttons > :first-child { order: 3; }
:root[data-layout=phone] #app:has(> .frame[data-kind=framed]):has(:is(.world-screen, .island-screen)) > .hud > .hud-notice { order: 4; }
:root[data-layout=phone] #app:has(> .frame[data-kind=framed]):has(:is(.world-screen, .island-screen)) > .hud > .hud-stats {
  position: fixed; top: calc(var(--space-1) + var(--map-float-inset)); left: calc(var(--rail-1-w) + max(var(--space-0), env(safe-area-inset-left)) + var(--map-float-inset)); z-index: 2;
  display: flex; align-items: center; min-height: var(--target); box-sizing: border-box; padding: 0 var(--space-3);
  background: var(--pane-bg); border: var(--border-1) solid var(--line-soft); border-radius: var(--radius-round); box-shadow: var(--elev-1);
}
:root[data-layout=phone] #app:has(> .frame[data-kind=framed]):has(:is(.world-screen, .island-screen)) > .hud .hud-stats .stat { font-size: var(--text-md); }

/* the island's sign on a phone: its state is icon chips after the name (the words are kept for screen readers, not drawn) */
.island-sign .map-sign-chips { display: none; }
/* the treasure count (today's stars) sits beside the hearts chip at the pane's top left, not under it */
:root[data-layout=phone] #app:has(> .frame[data-kind=framed]) .island-screen .map-treasure-count {
  left: calc(var(--map-float-inset) * 2 + var(--target-lg) + var(--target) / 2); top: calc(var(--space-1) + var(--map-float-inset) + var(--space-2));
}
:root[data-layout=phone] #app:has(> .frame[data-kind=framed]) .island-screen .frame-foot .island-sign .map-sign-text { pointer-events: none; }
:root[data-layout=phone] #app:has(> .frame[data-kind=framed]) .island-screen .frame-foot .island-sign .map-sign-name { display: flex; align-items: center; flex: 0 1 auto; }
:root[data-layout=phone] #app:has(> .frame[data-kind=framed]) .island-screen .frame-foot .island-sign .map-sign-state {
  position: absolute; width: var(--hairline); height: var(--hairline); margin: 0; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
:root[data-layout=phone] #app:has(> .frame[data-kind=framed]) .island-screen .frame-foot .island-sign .map-sign-chips { display: inline-flex; flex: none; align-items: center; gap: var(--space-2); margin: 0 0 0 var(--space-3); font-size: var(--text-md); font-weight: var(--weight-heavy); }
:root[data-layout=phone] #app:has(> .frame[data-kind=framed]) .island-screen .frame-foot .island-sign .map-sign-chip { display: inline-flex; align-items: center; gap: var(--space-1); }

/* the New! mark on an island draws over the rider: its island is not a stacking context, and the mark is above the rider's 3 (a map label is 3 to 5) */
.world-map .map-node.isle.has-new { z-index: auto; translate: none; margin: calc(var(--map-isle) / -2.5) 0 0 calc(var(--map-isle) / -2); }   /* a translate makes a stacking context too: the island (5 wide to 4 high) is centred by its margin instead */
.world-map .map-node.isle.has-new.pop { animation-fill-mode: backwards; }   /* and so does a held pop-in (opacity, scale): once it has played the island is as it is */
.world-map .map-node.isle .new-mark { z-index: 6; }

/* a small tablet (the tablet class, a window about 600px tall): the head row is not drawn; the place's name and the notice button
   join the top bar. Keyed by the shell container's height (#app's content box: the window less 32px), not the window */
@container app (max-height: 640px) {   /* --small-tablet-h */
  :where(:root:not([data-layout=phone])) .frame-head { position: absolute; width: var(--hairline); height: 0; padding: 0; border: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }   /* not drawn, and out of the flow (its room goes to the map), but its title still takes focus as you arrive */
  :where(:root:not([data-layout=phone])) .frame-head > .frame-notice { display: none; }
  :where(:root:not([data-layout=phone])) #app:has(.frame-head) .hud .hud-place { display: block; flex: 0 100 auto; min-width: 0; margin: 0; height: var(--target); line-height: var(--target); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  :where(:root:not([data-layout=phone])) #app:has(.frame-head) .hud .hud-extra { display: list-item; }   /* Shine and Stickers stay (issue 525): it is the rider's name that gives way, to one line with an ellipsis (the full name is the bar's accessible name) */
  :where(:root:not([data-layout=phone])) #app:has(.frame-head) .hud .hud-who { flex: 0 1 auto; min-width: 0; }
  :where(:root:not([data-layout=phone])) #app:has(.frame-head) .hud .hud-stats { flex-wrap: nowrap; flex: none; }
  :where(:root:not([data-layout=phone])) #app:has(.frame-head) .hud .hud-names { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  :where(:root:not([data-layout=phone])) #app:has(.frame-head) .hud .hud-notice { display: inline-flex; flex: none; min-width: var(--target); min-height: var(--target); }
}

/* Approved book art decorates the current deck-management dialog. */
.book-summary { display: flow-root; }
.book-cover-art { float: inline-start; margin-inline-end: var(--space-2); width: var(--book-cover-art); height: var(--book-cover-art); object-fit: contain; }
.book-paper { position: relative; isolation: isolate; }
.book-paper-art { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; opacity: var(--book-paper-opacity); pointer-events: none; z-index: -1; }
.book-empty { display: flex; align-items: center; gap: var(--space-2); }
.book-empty-art { width: var(--book-empty-art); height: var(--book-empty-art); object-fit: contain; }
/* Small box pictures have wider named tiles: keep the gem row inside that tile,
   beside the picture's edges, instead of stacking it across the picture. */
.scrapbook-box .sticker-rarity { flex-wrap: nowrap; max-width: none; }

/* Names and rarity stay outside sticker artwork. Tool selection keeps its room. */
.sticker-caption { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: var(--space-1); min-width: 0; }
.scrapbook-sticker .sticker-caption { display: none; }
.scrapbook-tools { display: flex; flex-direction: column; gap: var(--space-2); }
.scrapbook-tools-name > .sticker-art { --sticker: var(--scrapbook-icon); --size: var(--sticker-m); flex: none; }
.scrapbook-tools-name .sticker-caption { justify-content: flex-start; }

.town-place-screen:has(.sticker-book) > .frame-pane > .page-title { --title-pic: var(--target); --h1: var(--text-lg); }

.town-place-screen:has(.sticker-book) > .frame-pane { --pane-pad: var(--space-3); }

/* ---------- the one-time full-screen note (ui/full-screen.js) ---------- */
.full-screen-note .full-screen-say { margin: 0; font-size: var(--text-md); }
.full-screen-note .full-screen-steps { margin: 0; padding-inline-start: var(--space-5); display: flex; flex-direction: column; gap: var(--space-1); font-size: var(--text-md); }
.full-screen-note .actions { margin-top: 0; }
/* the delete confirm (opened from the title): on a phone its two answers sit side by side, the danger answer first and Keep (go) at the end,
   with a tighter header and gap, so "Yes, start over" is above the fold at 667x320 (dialogs.css puts them in one row at every size) */
:root[data-layout=phone] dialog.confirm .actions-split { gap: var(--space-2); }
:root[data-layout=phone] dialog.confirm .dialog-header { margin-bottom: var(--space-1); }
:root[data-layout=phone] dialog.confirm .dialog-body { gap: var(--space-2); }
:root[data-layout=phone] dialog.confirm .confirm-text { font-size: var(--text-md); }
:root[data-layout=phone] .full-screen-note .dialog-header { margin-bottom: var(--space-2); }
:root[data-layout=phone] .full-screen-note .dialog-body { gap: var(--space-2); }
:root[data-layout=phone] .full-screen-note .full-screen-steps { gap: 0; }
/* the finale: one scene and the story, two columns on every class. You ride your horse in the middle of the scene; your
   friends cheer above and below you with their names; the story is the other column (it scrolls inside, and takes focus, only if it must). */
.finale > .frame-pane { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: auto minmax(0, 1fr); column-gap: var(--space-4); }
.finale > .frame-pane > .page-title { grid-column: 1 / -1; }
.finale .finale-scene { grid-area: 2 / 1; height: auto; min-height: 0; margin: 0; --gift-figure-fit: 16cqh; flex-direction: column; align-items: center; justify-content: space-evenly; gap: var(--space-1); }   /* party / you / party, top to bottom */
.finale .finale-party { margin: 0; flex-wrap: wrap; }
.finale .finale-party .finale-figure { width: min(var(--gift-figure), var(--gift-figure-fit)); }
.finale .gift-you-riding { width: min(var(--gift-mount), 30cqh); }
.finale .story-lines { grid-area: 2 / 2; align-self: center; max-height: 100%; overflow-y: auto; max-width: none; margin: 0; text-align: start; }
:where(:root[data-layout=phone]) .finale .finale-scene { --gift-figure: 2.2rem; padding: var(--space-2) var(--space-1) var(--space-1); gap: var(--space-1); }
:where(:root[data-layout=phone]) .finale .gift-name { font-size: var(--text-xs); padding: 0 var(--space-1); }
:where(:root[data-layout=phone]) .finale .story-line { font-size: var(--text-sm); margin: 0 0 var(--space-1); }

/* ---------- a friend's house (ui/places.js friendHouseView) ----------
   The room, then one row: Talk and Come with me! as two tiles (a --row-lg row), and the help they give. On a
   phone and a short tablet (data-short) the room takes the pane's height less that row, and the row is
   the tiles beside the help; a phone shows the help as the buddy's icon and a number (the words are
   read aloud), a tablet its words. A taller tablet and a desktop keep the room's usual height, the row
   under it, the help under that. */
.friend-house-view .house-tiles { --house-cols: 2; grid-auto-rows: var(--row-lg); }
.friend-house-view .btn.house-tile.house-tile { height: var(--row-lg); flex-direction: row; justify-content: center; gap: var(--space-2); padding-inline: var(--space-3); }   /* its picture beside its words, in one row */
.friend-house-view .house-tile > .icon { width: var(--icon-lg); height: var(--icon-lg); }
.friend-house-view .house-tile > .btn-label { -webkit-line-clamp: 1; line-clamp: 1; }
.friend-house-view .house-about { min-height: 0; }
.buddy-help { margin: 0; font-size: var(--text-md); line-height: var(--leading-tight); }
.buddy-help-chip { display: none; }
:root:is([data-layout=phone], [data-short=tablet]) .friend-house-view {
  flex: 1 1 0; min-height: 0; display: grid; gap: var(--space-2) var(--space-3);
  grid-template-columns: auto minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; align-items: center;
}
:root:is([data-layout=phone], [data-short=tablet]) .friend-house-view > .house-room { grid-column: 1 / -1; height: auto; min-height: 0; align-self: stretch; --room-figure: 6rem; }
:root:is([data-layout=phone], [data-short=tablet]) .friend-house-view .house-tiles { grid-template-columns: repeat(2, auto); gap: var(--space-2); }
:root[data-layout=phone] .friend-house-view .house-tiles { grid-template-columns: repeat(2, var(--row-lg)); }
:root[data-layout=phone] .friend-house-view .btn.house-tile.house-tile { justify-content: center; padding-inline: 0; min-width: 0; }
:root[data-layout=phone] .friend-house-view .house-tile.house-tile > .icon { width: var(--icon-lg); height: var(--icon-lg); }
:root[data-layout=phone] .friend-house-view .buddy-help-words {
  position: absolute; width: var(--hairline); height: var(--hairline); overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
:root[data-layout=phone] .friend-house-view .buddy-help { display: flex; align-items: center; justify-content: center; }
:root[data-layout=phone] .friend-house-view .buddy-help-chip { display: inline-flex; align-items: center; gap: var(--space-2); font-size: var(--text-lg); font-weight: var(--weight-bold); }
:root[data-layout=phone] .friend-house-view .buddy-help-chip > .icon { width: var(--icon-lg); height: var(--icon-lg); margin: 0; }
