/* Grove UI v2 component layer (UX-005 A1). Loaded right after the token files
   (src/ui-tokens.css, src/cozy-tokens.css) and before every feature sheet, so the
   components here are the one source of truth for the parts that use them.
   Spec: docs/ux-loop/UI-V2.md §2; visual target: docs/ux-loop/mocks/ui-v2-components.html.
   Rules: tokens only, every length a multiple of 4 px or of --ui-px, pixel frames have
   no radius and no blur. Only components the app uses (or that are inert until used)
   live here; the rest of the mock moves over area by area (UI-V2 §4).

   The pixel-frame stack (one recipe for every framed part):
     inset bevel   1 UI px highlight top/left (--f-hi), 1 UI px shade bottom/right (--f-shade)
     edge          1 UI px outline on four sides, corners left open = the notch (--f-edge)
     drop          straight-down pixel shadow, 1 UI px at rest, 2 raised, 0 pressed (--f-drop-y)
   Variants only swap the --f-* colours; the geometry never changes. */

.pxf, .btn, .tip, .dock, .dock-item, .sheet-frame {
  --f-fill: var(--ui-frame-fill);
  --f-hi: var(--ui-frame-hi);
  --f-shade: var(--ui-frame-shade);
  --f-edge: var(--ui-frame-line);
  --f-drop: var(--ui-frame-drop);
  --f-drop-y: calc(var(--ui-px) * 2);
}
.pxf, .btn, .tip, .dock, .dock-item.is-active, .sheet-frame {
  background: var(--f-fill);
  border: 0;
  border-radius: 0;
  box-shadow:
    inset var(--ui-px) var(--ui-px) 0 0 var(--f-hi),
    inset calc(var(--ui-px) * -1) calc(var(--ui-px) * -1) 0 0 var(--f-shade),
    0 calc(var(--ui-px) * -1) 0 0 var(--f-edge),
    0 var(--ui-px) 0 0 var(--f-edge),
    calc(var(--ui-px) * -1) 0 0 0 var(--f-edge),
    var(--ui-px) 0 0 0 var(--f-edge),
    0 var(--f-drop-y) 0 0 var(--f-drop);
}
.pxf--raised, .dock, .tip, .sheet-frame { --f-drop-y: calc(var(--ui-px) * 3); }
.pxf--flat { --f-drop-y: var(--ui-px); }

/* ---------- focus: one ring for everything ---------- */
:is(.btn, .dock-item):focus-visible {
  outline: var(--ui-focus-ring-w) solid var(--ui-focus-ring);
  outline-offset: calc(var(--ui-px) * 2);
}

/* ---------- button: primary / secondary / ghost / icon (inert until a slice uses it) ----------
   40 px tall (44 on coarse pointers), 16 px side padding, Pixelify 16, verb labels.
   Hover 120 ms colour only; pressed sinks 1 UI px into its own drop; disabled is flat. */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--ui-s-2);
  min-height: 40px;
  padding: 0 var(--ui-s-4);
  color: var(--ui-ink);
  font-family: var(--ui-font-display);
  font-size: var(--ui-fs-16);
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color var(--ui-dur-fast) var(--ui-ease-out), transform var(--ui-dur-fast) var(--ui-ease-out);
}
.btn .ico { --ico: 14px; }
.btn:hover { --f-fill: var(--ui-secondary-hover); }
.btn:active { --f-drop-y: var(--ui-px); transform: translateY(var(--ui-press)); }
.btn--primary {
  --f-fill: var(--ui-button-primary-bg);
  --f-hi: var(--ui-primary-hover);
  --f-shade: var(--ui-line-deep);
  --f-edge: var(--ui-line-deep);
  color: var(--ui-button-primary-ink);
}
.btn--primary:hover { --f-fill: var(--ui-primary-hover); --f-hi: var(--ui-button-primary-bg); }
.btn--ghost { --f-hi: transparent; --f-shade: transparent; --f-edge: transparent; --f-drop: transparent; --f-fill: transparent; }
.btn--ghost:hover { --f-fill: var(--ui-surface-sunk); }
.btn--icon { width: 40px; padding: 0; }
.btn--icon .ico { --ico: 28px; }
.btn--sm { min-height: var(--ui-s-6); padding: 0 var(--ui-s-3); font-size: var(--ui-fs-14); }
.btn--sm.btn--icon { width: var(--ui-s-6); }
.btn--sm.btn--icon .ico { --ico: 14px; }
.btn--block { display: flex; width: 100%; min-height: var(--ui-target); }
.btn:disabled {
  --f-fill: var(--ui-disabled-bg);
  --f-hi: var(--ui-disabled-bg);
  --f-shade: var(--ui-disabled-bg);
  --f-edge: var(--ui-disabled-line);
  --f-drop-y: var(--ui-px);
  color: var(--ui-disabled-ink);
  transform: none;
  cursor: not-allowed;
}
.btn--ghost:disabled { --f-fill: transparent; --f-hi: transparent; --f-shade: transparent; --f-edge: transparent; --f-drop: transparent; }
@media (pointer: coarse), (max-width: 600px) {
  .btn { min-height: var(--ui-target); }
  .btn--icon { width: var(--ui-target); }
}

/* ---------- badge: gold pill, 20 px, Outfit 12/700 tabular (never VT323 under 20 px) ----------
   .tab-badge: the counts on sheet tabs (quests, neighbours, passport) in index.html. */
.badge, .tab-badge {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 var(--ui-s-1);
  background: var(--ui-badge-bg);
  color: var(--ui-badge-ink);
  border: var(--ui-px) solid var(--ui-line);
  border-radius: var(--ui-r-pill);
  font-family: var(--ui-font-body);
  font-size: var(--ui-fs-12);
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  box-sizing: border-box;
}
:is(.badge, .tab-badge)[hidden] { display: none; }

/* ---------- icon: 14-grid masks at whole scales only (14 / 28 / 42 px) ----------
   Takes a --px mask (the .px-* icons in shell.css until UX-007 redraws them). */
.ico {
  display: inline-block;
  flex: none;
  width: var(--ico, 14px);
  height: var(--ico, 14px);
  background: currentColor;
  -webkit-mask: var(--px) center / 100% 100% no-repeat;
  mask: var(--px) center / 100% 100% no-repeat;
}

/* ---------- key cap: 20 px, Outfit 12/700 ---------- */
kbd.key {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 var(--ui-s-1);
  background: var(--ui-surface-sunk);
  color: var(--ui-ink);
  border: var(--ui-px) solid var(--ui-line);
  border-radius: var(--ui-r-sm);
  font-family: var(--ui-font-body);
  font-size: var(--ui-fs-12);
  font-weight: 700;
  line-height: 1;
  box-sizing: border-box;
}

/* ---------- tooltip / world prompt: paper raised frame, Outfit 14, pixel tail ---------- */
.tip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--ui-s-2);
  min-height: 28px;
  padding: 0 var(--ui-s-2);
  color: var(--ui-ink);
  font-family: var(--ui-font-body);
  font-size: var(--ui-fs-14);
  font-weight: 500;
  white-space: nowrap;
}
/* The tail: a 3-step pixel triangle (6, 4, 2 UI px wide) under the centre. */
.tip::after {
  content: "";
  position: absolute;
  left: 50%;
  top: calc(100% + var(--ui-px) * 3);
  width: calc(var(--ui-px) * 6);
  height: calc(var(--ui-px) * 3);
  margin-left: calc(var(--ui-px) * -3);
  background: var(--ui-frame-drop);
  clip-path: polygon(0 0, 100% 0, 100% 33.34%, 83.34% 33.34%, 83.34% 66.67%, 66.67% 66.67%, 66.67% 100%, 33.34% 100%, 33.34% 66.67%, 16.67% 66.67%, 16.67% 33.34%, 0 33.34%);
}

/* ---------- dock (UX-005 A2): raised frame, 8 px padding, 76x56 items, ONE active item ----------
   .is-active (+ aria-current) is the only "you are here" fill: a flat peach frame on the
   open panel's item; nothing is active while no panel is open. Focus is never special-
   cased: a running session shows as a live pip + mm:ss on the Focus item, never a fill.
   Placement (fixed, bottom centre) lives with the HUD layout in shell.css (.game-tools). */
.dock {
  --f-fill: var(--ui-dock-bg);
  display: flex;
  align-items: stretch;
  gap: var(--ui-s-1);
  margin: 0;
  padding: var(--ui-s-2);
}
.dock-item {
  position: relative;
  display: grid;
  flex: 0 0 auto;
  justify-items: center;
  align-content: center;
  gap: var(--ui-s-1);
  box-sizing: border-box;
  width: 76px;
  height: 56px;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0 var(--ui-s-1);
  background: transparent;
  color: var(--ui-dock-item-ink);
  border: 0;
  border-radius: 0;
  box-shadow: none;
  font-family: var(--ui-font-display);
  font-size: var(--ui-fs-12);
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1;
  cursor: pointer;
  transition: background-color var(--ui-dur-fast) var(--ui-ease-out), transform var(--ui-dur-fast) var(--ui-ease-out);
}
.dock-item .ico { --ico: 28px; }
.dock-label { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* UX-631: only a real hover lights an item (a tap on touch left a sticky hover fill behind). */
@media (hover: hover) { .dock-item:not(.is-active):hover { background: var(--ui-dock-item-hover); } }
.dock-item:active { transform: translateY(var(--ui-press)); }
.dock-item.is-active {
  --f-fill: var(--ui-dock-item-active);
  --f-shade: var(--ui-coin-deep);
  --f-drop-y: var(--ui-px);
  color: var(--ui-dock-item-active-ink);
}
.dock-item .badge { position: absolute; top: calc(var(--ui-s-1) * -1); right: var(--ui-s-2); }
/* UX-439 slice 2 (`unlocks` flag on): a dock item that just appeared wears a "New" dot until its
   sheet opens: a 6 px coin-gold pixel square with a 1 UI px cocoa edge, top left (the count
   badge keeps the top right). Still: it never animates. */
.dock-item .dock-new {
  position: absolute;
  top: var(--ui-s-1);
  left: var(--ui-s-2);
  width: calc(var(--ui-px) * 3);
  height: calc(var(--ui-px) * 3);
  background: var(--ui-coin);
  box-shadow: 0 0 0 var(--ui-px) var(--ui-ink-strong);
  pointer-events: none;
}

/* A session on the Focus item: the time takes the label's place (the label stays for
   screen readers: "Focusing 18:42"), with a live pip; paused pips in the warning colour. */
.dock-time { font-family: var(--ui-font-body); font-size: var(--ui-fs-12); font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.dock-time[hidden] { display: none; }
.dock-item:is(.is-running, .is-paused) .dock-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.dock-item:is(.is-running, .is-paused)::after {
  content: "";
  position: absolute;
  top: var(--ui-s-1);
  right: var(--ui-s-1);
  width: var(--ui-s-2);
  height: var(--ui-s-2);
  background: var(--ui-success);
  box-shadow: 0 0 0 var(--ui-px) var(--ui-line);
}
.dock-item.is-paused::after { background: var(--ui-warning); }

/* Adventure charges: the badge with a bolt (14-grid at 1x). */
.badge.energy-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--ui-px);
  padding: 0 var(--ui-s-1) 0 var(--ui-px);
  --bolt: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14' shape-rendering='crispEdges'%3E%3Cpath d='M6 0h5v1H6zM5 1h5v1H5zM4 2h5v1H4zM3 3h5v1H3zM2 4h10v1H2zM3 5h8v1H3zM6 6h4v1H6zM5 7h4v1H5zM4 8h4v1H4zM3 9h4v1H3zM2 10h4v1H2zM1 11h3v1H1zM1 12h1v1H1z'/%3E%3C/svg%3E");
}
.badge.energy-badge[hidden] { display: none; }
.badge.energy-badge::before { content: ""; flex: none; width: 14px; height: 14px; background: currentColor; -webkit-mask: var(--bolt) center / 100% 100% no-repeat; mask: var(--bolt) center / 100% 100% no-repeat; }
/* Together: you are in a room. A small live square in the item's top-right corner, clear
   of the icon (the icon is 28 wide and centred; the corner is 4 px in from the item). */
.dock-item .badge.presence-badge {
  top: var(--ui-s-1);
  right: var(--ui-s-1);
  min-width: 0;
  width: var(--ui-s-2);
  height: var(--ui-s-2);
  padding: 0;
  background: var(--ui-success);
  border: 0;
  border-radius: 0;
  box-shadow: 0 0 0 var(--ui-px) var(--ui-line);
  font-size: 0;
}

/* Phones: 68x52 items, no gap, 4 px padding (5 x 68 + 8 = 348 fits 358); Outfit 12/600
   is narrower than the pixel face, so "Adventure" fits the 60 px label. Items shrink
   evenly below 360 px rather than overflow. */
@media (max-width: 720px) {
  .dock { gap: 0; padding: var(--ui-s-1); }
  .dock-item { flex: 0 1 68px; width: 68px; height: 52px; }
  .dock-label { font-family: var(--ui-font-body); font-weight: 600; }
  /* UX-741: with 4 px of dock padding the 4 px-offset ring landed on the dock's own dark edge
     and only thickened it. Here the ring is drawn inside the item: a cocoa ring over a peach
     halo, so it reads as a ring on the dock fill like the desktop one. */
  .dock-item:focus-visible {
    outline-offset: calc(var(--ui-focus-ring-w) * -2);
    box-shadow: inset 0 0 0 calc(var(--ui-focus-ring-w) * 2) var(--ui-focus-ring-halo);
  }
}
/* Short landscape screens: shorter items, same widths. */
@media (max-height: 560px) and (min-width: 721px) {
  .dock-item { height: var(--ui-s-7); }
}

/* ---------- status card (UX-005 A3a): you · level · coins, and the ⋯ menu ----------
   One rest frame, 44 px tall, top right (placed by .hud-right in shell.css). Inside, two
   unframed buttons sit 1 UI px in from the frame so the bevel stays whole: the main part
   (avatar 32, level, coins in VT323 24) opens the You panel; ⋯ opens the menu. Each
   button's hit area reaches the frame edge (44 px tall). The sync pip shows only when a
   save needs attention; "saved" and "saving" are read out in the title, not shown. */
.status-card {
  position: relative;
  display: inline-flex;
  align-items: stretch;
  box-sizing: border-box;
  height: var(--ui-target);
  padding: var(--ui-px);
  pointer-events: auto;
}
.status-card :is(.status-main, .status-more) {
  position: relative;
  display: inline-flex;
  align-items: center;
  box-sizing: border-box;
  height: 100%;
  min-width: 0;
  min-height: 0;
  margin: 0;
  background: transparent;
  color: var(--ui-ink);
  border: 0;
  border-radius: 0;
  box-shadow: none;
  font-family: var(--ui-font-body);
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color var(--ui-dur-fast) var(--ui-ease-out);
}
.status-card :is(.status-main, .status-more)::before { content: ""; position: absolute; inset: calc(var(--ui-px) * -1); }
.status-card :is(.status-main, .status-more):hover { background: var(--ui-secondary-hover); }
.status-card :is(.status-main, .status-more):active,
.status-card .status-more[aria-expanded="true"] { background: var(--ui-surface-sunk); }
.status-card :is(.status-main, .status-more):focus-visible {
  outline: var(--ui-focus-ring-w) solid var(--ui-focus-ring);
  outline-offset: calc(var(--ui-focus-ring-w) * -1);
}
.status-card .status-main { gap: var(--ui-s-3); padding: 0 var(--ui-s-3) 0 var(--ui-s-1); }
/* ⋯: 40 x 40, a 1 UI px shade rule between it and the main part. */
.status-card .status-more {
  justify-content: center;
  width: 40px;
  padding: 0;
  box-shadow: inset var(--ui-px) 0 0 0 var(--ui-surface-shade);
}
.status-avatar {
  position: relative;
  flex: none;
  width: var(--ui-s-6);
  height: var(--ui-s-6);
  background: var(--ui-surface-sunk);
  box-shadow: 0 0 0 var(--ui-px) var(--ui-line);
}
/* The 32 x 32 portrait canvas (drawPortrait "badge": a 2x bust, or the figure at 1x for tall looks), shown 1:1. */
.status-avatar canvas { display: block; width: 100%; height: 100%; object-fit: cover; object-position: top; image-rendering: pixelated; }
.status-avatar .sync-dot {
  position: absolute;
  right: calc(var(--ui-px) * -2);
  bottom: calc(var(--ui-px) * -2);
  width: var(--ui-s-2);
  height: var(--ui-s-2);
  background: var(--ui-warning);
  box-shadow: 0 0 0 var(--ui-px) var(--ui-line);
}
.status-avatar .sync-dot:not([data-tone="warn"]) { display: none; }
.status-level { font-size: var(--ui-fs-12); font-weight: 700; color: var(--ui-ink-muted); }
.status-level b { margin-left: var(--ui-px); font-size: var(--ui-fs-14); font-weight: 700; color: var(--ui-ink); font-variant-numeric: tabular-nums; }
.status-coins { display: inline-flex; align-items: center; gap: var(--ui-s-1); }
.status-coins .ico { color: var(--ui-coin-deep); }
.status-coin-count { font-family: var(--ui-font-num); font-size: var(--ui-fs-24); font-weight: 400; line-height: 1; font-variant-numeric: tabular-nums; }
/* Phones: tighter inside so the place card keeps its name. At 420 px and below "Lv N" and
   the coins stack in one column beside the avatar (Lv 12 over VT323 20 coins), so the card
   stays as narrow as before and nothing sits on the avatar's face (UX-005 A3d). */
@media (max-width: 720px) {
  .status-card .status-main { gap: var(--ui-s-2); padding-right: var(--ui-s-2); }
}
@media (max-width: 420px) {
  .status-card .status-main {
    display: inline-grid;
    grid-template-columns: auto auto;
    grid-template-rows: auto auto;
    align-content: center;
    justify-items: start;
    column-gap: var(--ui-s-2);
    row-gap: var(--ui-px);
  }
  .status-card .status-avatar { grid-column: 1; grid-row: 1 / 3; align-self: center; }
  .status-card .status-level { grid-column: 2; grid-row: 1; line-height: 1; }
  .status-card .status-level b { font-size: var(--ui-fs-12); }
  .status-card .status-coins { grid-column: 2; grid-row: 2; }
  .status-card .status-coin-count { font-size: var(--ui-fs-20); }
}

/* ---------- menu (⋯): raised frame, 4 px padding, 40 px items (44 on touch / phones) ----------
   Items are buttons with an icon (14), a label (Outfit 14/600) and an optional key cap.
   Hover and the open state use the sunk fill; focus is the one ring, drawn inset.
   Enter 200 ms ease-out from 8 px above + fade; exit 120 ms ease-in. Reduced motion:
   --ui-travel is 0 (src/ui-tokens.css), so it only fades. */
.menu {
  position: absolute;
  z-index: 1;
  display: grid;
  min-width: 224px;
  max-width: calc(100vw - var(--ui-s-6));
  box-sizing: border-box;
  padding: var(--ui-s-1);
  pointer-events: auto;
}
.menu[hidden] { display: none; }
.menu:not([hidden]) { animation: ui-menu-in var(--ui-dur) var(--ui-ease-out) both; }
.menu.is-closing { animation: ui-menu-out var(--ui-dur-fast) var(--ui-ease-in) both; }
@keyframes ui-menu-in { from { opacity: 0; transform: translateY(calc(var(--ui-travel) * -1)); } }
@keyframes ui-menu-out { to { opacity: 0; transform: translateY(calc(var(--ui-travel) * -1)); } }
.menu .menu-item {
  display: flex;
  align-items: center;
  gap: var(--ui-s-2);
  box-sizing: border-box;
  width: 100%;
  height: 40px;
  min-height: 0;
  margin: 0;
  padding: 0 var(--ui-s-3);
  background: transparent;
  color: var(--ui-ink);
  border: 0;
  border-radius: 0;
  box-shadow: none;
  font-family: var(--ui-font-body);
  font-size: var(--ui-fs-14);
  font-weight: 600;
  line-height: 1;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color var(--ui-dur-fast) var(--ui-ease-out);
}
.menu .menu-item .ico { color: var(--ui-ink-muted); }
.menu .menu-label { flex: 1; }
.menu .menu-item:hover { background: var(--ui-surface-sunk); }
.menu .menu-item:hover .ico { color: var(--ui-ink); }
.menu .menu-item:focus-visible {
  outline: var(--ui-focus-ring-w) solid var(--ui-focus-ring);
  outline-offset: calc(var(--ui-focus-ring-w) * -1);
}
@media (pointer: coarse), (max-width: 720px) {
  .menu .menu-item { height: var(--ui-target); }
}
/* Touch-only devices: no key caps, and no keyboard-shortcuts entry. */
@media (hover: none) and (pointer: coarse) {
  .menu kbd.key, .menu [data-touch="hide"] { display: none; }
}
/* Under the status card, right-aligned, 8 px below it; scrolls rather than leave the screen. */
.status-card .menu { top: calc(100% + var(--ui-s-2)); right: 0; max-height: calc(100dvh - var(--ui-s-7) * 2 - var(--ui-s-4)); overflow-y: auto; overscroll-behavior: contain; }
.menu .menu-item[hidden] { display: none; }
/* A titled section (the status menu's "This room" on phones): a 1 UI px shade rule above,
   then a small muted heading; its items are ordinary menu items. */
.menu .menu-group { display: grid; margin-top: var(--ui-s-1); padding-top: var(--ui-s-1); box-shadow: inset 0 var(--ui-px) 0 0 var(--ui-surface-shade); }
.menu .menu-group[hidden] { display: none; }
.menu .menu-heading { padding: var(--ui-s-2) var(--ui-s-3) var(--ui-s-1); color: var(--ui-ink-muted); font-family: var(--ui-font-body); font-size: var(--ui-fs-12); font-weight: 700; line-height: 1; }
.menu .menu-value { color: var(--ui-ink-muted); font-weight: 600; }

/* ---------- HUD card (UX-005 A3b): the top band's one look ----------
   Place card, quest strip, focus pill and the café room bar share the status card's
   frame: a rest pixel frame 44 px tall, Pixelify 16 titles, Outfit 12-14 copy, 8 px gaps.
   A card that is one button (the place card) presses like a button. A card with parts
   (quest strip, focus pill, room bar) keeps 1 UI px of padding so its unframed parts
   ("segments", 40 px tall, hit area grown to the 44 px frame) never cover the bevel. */
.hud-card {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--ui-s-2);
  box-sizing: border-box;
  min-width: 0;
  min-height: var(--ui-target);
  margin: 0;
  padding: 0 var(--ui-s-3);
  color: var(--ui-ink);
  font-family: var(--ui-font-body);
  line-height: 1;
  pointer-events: auto;
}
.hud-card[hidden] { display: none; }
button.hud-card {
  text-align: left;
  cursor: pointer;
  transition: background-color var(--ui-dur-fast) var(--ui-ease-out), transform var(--ui-dur-fast) var(--ui-ease-out);
}
button.hud-card:hover { --f-fill: var(--ui-secondary-hover); }
button.hud-card:active { --f-drop-y: var(--ui-px); transform: translateY(var(--ui-press)); }
button.hud-card:focus-visible {
  outline: var(--ui-focus-ring-w) solid var(--ui-focus-ring);
  outline-offset: calc(var(--ui-px) * 2);
}

/* Segments: the unframed buttons inside a framed card (the status card's recipe). */
:is(.next-step-dismiss, .focus-pill .pill-open, .focus-pill .pill-button, .multiplayer-hud .hud-pill, .multiplayer-hud .hud-btn, .room-menu > summary) {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  box-sizing: border-box;
  height: 40px;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
  background: transparent;
  color: var(--ui-ink);
  border: 0;
  border-radius: 0;
  box-shadow: none;
  font-family: var(--ui-font-body);
  line-height: 1;
  white-space: nowrap;
  list-style: none;
  cursor: pointer;
  transition: background-color var(--ui-dur-fast) var(--ui-ease-out);
}
:is(.next-step-dismiss, .focus-pill .pill-open, .focus-pill .pill-button, .multiplayer-hud .hud-pill, .multiplayer-hud .hud-btn, .room-menu > summary)::before {
  content: "";
  position: absolute;
  inset: calc(var(--ui-px) * -1);
}
:is(.next-step-dismiss, .focus-pill .pill-open, .focus-pill .pill-button, .multiplayer-hud .hud-pill, .multiplayer-hud .hud-btn, .room-menu > summary):hover { background: var(--ui-secondary-hover); }
:is(.next-step-dismiss, .focus-pill .pill-open, .focus-pill .pill-button, .multiplayer-hud .hud-pill, .multiplayer-hud .hud-btn, .room-menu > summary):active,
.room-menu[open] > summary { background: var(--ui-surface-sunk); }
:is(.next-step-dismiss, .focus-pill .pill-open, .focus-pill .pill-button, .multiplayer-hud .hud-pill, .multiplayer-hud .hud-btn, .room-menu > summary):focus-visible {
  outline: var(--ui-focus-ring-w) solid var(--ui-focus-ring);
  outline-offset: calc(var(--ui-focus-ring-w) * -1);
}
.room-menu > summary::-webkit-details-marker { display: none; }
/* Square segments (⋯, ×, pause, tasks, emotes): 40 x 40 with a 1 UI px shade rule on the
   left, the same ⋯ as the status card's. */
:is(.next-step-dismiss, .focus-pill .pill-button, .multiplayer-hud .hud-btn, .room-menu > summary) { width: 40px; }
/* UX-691: on touch the square segments are a full 44 wide (their 2 px ::before hit area overlaps
   the next segment's, so a 40 px segment only took about 42 of a finger). */
@media (pointer: coarse) {
  :is(.next-step-dismiss, .focus-pill .pill-button, .multiplayer-hud .hud-btn, .room-menu > summary) { width: var(--ui-target); }
}
:is(.focus-pill .pill-button, .multiplayer-hud .hud-btn, .room-menu > summary) { box-shadow: inset var(--ui-px) 0 0 0 var(--ui-surface-shade); }
.next-step-dismiss .ico { color: var(--ui-ink-muted); }
.next-step-dismiss:hover .ico { color: var(--ui-ink); }

/* Place card: where you are (opens the minimap or the map). Leaf mark 32 with a 1 UI px
   ring, 6 px in from the frame like the status card's avatar. */
.place-card { max-width: 320px; padding: 0 var(--ui-s-3) 0 calc(var(--ui-px) + var(--ui-s-1)); }
/* Wide screens: one column with the minimap under it (same width, same left edge). The
   copy takes the room between the mark and the chevron; with the minimap on, the chevron
   is the card's only sign (the minimap itself opens the map). */
@media (min-width: 721px) {
  .place-card { box-sizing: border-box; width: var(--hud-col); max-width: none; }
  .place-card .place-copy { flex: 1 1 auto; }
  .place-card.has-minimap .place-map-icon { display: none; }
}
.place-card .brand-mark {
  display: block;
  flex: none;
  width: var(--ui-s-6);
  height: var(--ui-s-6);
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: var(--ui-brand);
  border: 0;
  border-radius: 0;
  box-shadow: 0 0 0 var(--ui-px) var(--ui-line);
}
.place-card .brand-mark img { display: block; width: 100%; height: 100%; image-rendering: pixelated; }
.place-copy { display: grid; gap: var(--ui-s-1); min-width: 0; }
.place-card #scene-title { overflow: hidden; font-family: var(--ui-font-display); font-size: var(--ui-fs-16); font-weight: 600; line-height: 1; letter-spacing: 0; white-space: nowrap; text-overflow: ellipsis; }
.place-card .world-sub { overflow: hidden; color: var(--ui-ink-muted); font-family: var(--ui-font-body); font-size: var(--ui-fs-12); line-height: 1; white-space: nowrap; text-overflow: ellipsis; }
.place-card .place-map-icon { margin-left: var(--ui-s-1); color: var(--ui-ink-muted); }
.place-card:hover .place-map-icon { color: var(--ui-ink); }
/* The fold switch: a 3-step pixel chevron (6, 4, 2 UI px), turned when the minimap is open. */
.place-chevron {
  display: none;
  flex: none;
  width: calc(var(--ui-px) * 5);
  height: calc(var(--ui-px) * 3);
  margin-left: var(--ui-px);
  background: var(--ui-ink-muted);
  clip-path: polygon(0 0, 100% 0, 100% 33.34%, 80% 33.34%, 80% 66.67%, 60% 66.67%, 60% 100%, 40% 100%, 40% 66.67%, 20% 66.67%, 20% 33.34%, 0 33.34%);
  transition: transform var(--ui-dur-fast) var(--ui-ease-out);
}
.place-card.has-minimap .place-chevron { display: block; }
.place-card.is-open .place-chevron { transform: rotate(180deg); }
.place-card:hover .place-chevron { background: var(--ui-ink); }
/* Staged HUD (UX-438 G2, `unlocks` flag), map locked: the card is a plain label. It keeps
   its frame and size; no map icon, no hover fill, no press, no pointer. It is natively
   disabled (never focusable), but reads at full strength: it still says where you are. */
.place-card.is-label, .place-card.is-label:disabled { cursor: default; opacity: 1; }
.place-card.is-label:is(:hover, :active) { --f-fill: var(--ui-frame-fill); --f-drop-y: calc(var(--ui-px) * 2); transform: none; }
.place-card.is-label .place-map-icon { display: none; }

/* The door (indoors): a 44 px pixel icon button beside the place card; its words are its
   accessible name and tooltip. */
#room-toggle { width: var(--ui-target); height: var(--ui-target); min-height: 0; padding: 0; gap: 0; font-size: 0; }
#room-toggle::before { content: ""; flex: none; width: 28px; height: 28px; background: currentColor; -webkit-mask: var(--px) center / 100% 100% no-repeat; mask: var(--px) center / 100% 100% no-repeat; }
#room-toggle[hidden] { display: none; }

/* ---------- minimap (UX-005 A4, UI-V2 §3.3): the place, you and one goal; no words ----------
   One button on a rest pixel frame (pad 4) that opens the Map panel. Desktop 216 x 144,
   12 px under the place card on its left edge (top/left from src/minimap.js); phones a
   60 x 60 tile at the right of the top band's second row. Inside: the place's picture
   (covering the frame, slid to keep you in view), exits as 4 x 4 cocoa ticks, the goal
   as an 8 x 8 gold diamond and you as an 8 x 8 paper square, both ringed 1 UI px. */
.minimap {
  position: fixed;
  z-index: calc(var(--z-hud) - 1);
  top: var(--minimap-top, calc(var(--hud-band-top) + var(--ui-target) + var(--ui-s-3)));
  left: var(--minimap-left, var(--hud-band-side));
  display: block;
  box-sizing: border-box;
  width: var(--hud-col);
  height: 144px;
  margin: 0;
  padding: var(--ui-s-1);
  color: var(--ui-ink);
  cursor: pointer;
  pointer-events: auto;
  transition: background-color var(--ui-dur-fast) var(--ui-ease-out), transform var(--ui-dur-fast) var(--ui-ease-out);
}
.minimap[hidden] { display: none; }
.minimap:hover { --f-fill: var(--ui-secondary-hover); }
.minimap:active { --f-drop-y: var(--ui-px); transform: translateY(var(--ui-press)); }
.minimap:focus-visible { outline: var(--ui-focus-ring-w) solid var(--ui-focus-ring); outline-offset: calc(var(--ui-px) * 2); }
.minimap-frame { position: relative; display: block; width: 100%; height: 100%; overflow: hidden; background: var(--ui-surface-sunk); }
/* A 1 UI px shade rule round the picture, drawn over it. */
.minimap-frame::after { content: ""; position: absolute; inset: 0; z-index: 3; box-shadow: inset 0 0 0 var(--ui-px) var(--ui-frame-shade); pointer-events: none; }
.minimap-plane { position: absolute; top: 0; left: 0; display: block; }
.minimap-terrain { display: block; width: 100%; height: 100%; }
.minimap-marks { position: absolute; inset: 0; z-index: 2; }
.minimap-tick, .minimap-pin, .minimap-you { position: absolute; display: block; }
.minimap-tick { width: var(--ui-s-1); height: var(--ui-s-1); margin: calc(var(--ui-px) * -1) 0 0 calc(var(--ui-px) * -1); background: var(--ui-line-deep); }
.minimap-pin, .minimap-you {
  width: var(--ui-s-2);
  height: var(--ui-s-2);
  margin: calc(var(--ui-s-1) * -1) 0 0 calc(var(--ui-s-1) * -1);
  box-shadow: 0 0 0 var(--ui-px) var(--ui-line-deep);
}
.minimap-pin { background: var(--ui-coin); transform: rotate(45deg); }
.minimap-you { z-index: 1; background: var(--ui-surface); }
:is(.minimap-tick, .minimap-pin)[hidden] { display: none; }
@media (max-width: 720px) {
  .minimap { left: auto; right: var(--hud-band-side); width: var(--minimap-tile); height: var(--minimap-tile); }
  /* Row 2 is one row: the quest strip (or focus pill) ends 8 px short of the tile (the top
     band's column gap), starts on its top and is as tall as it, copy centred in it. */
  body.minimap-shown .hud-center { margin-right: calc(var(--minimap-tile) + var(--ui-s-2)); }
  body.minimap-shown .hud-center > :is(.next-step-bar, .focus-pill) { box-sizing: border-box; min-height: var(--minimap-tile); }
  body.minimap-shown .focus-pill :is(.pill-open, .pill-button) { align-self: stretch; height: auto; }
  /* Row 1 is tight indoors (card, door, status card): the door keeps its 44 and the card
     ends 8 after its chevron, so "Fern & Bean" is drawn whole. */
  #room-toggle { flex: none; }
  .place-card { padding-right: var(--ui-s-2); }
  .place-chevron { margin-left: 0; }
  /* Indoors the door shares row 1, so the place card shows its short name ("Cottage"); the
     full name stays in the element for screen readers, the short one is drawn, not read. */
  .place-card #scene-title[data-short] { font-size: 0; }
  .place-card #scene-title[data-short]::before { content: attr(data-short); content: attr(data-short) / ""; font-size: var(--ui-fs-16); }
  /* The same for the line under it (the café's floor or seat) and the quest strip's copy:
     a short version drawn whole instead of an ellipsis or a third line. */
  .place-card #scene-status[data-short], .next-step-bar #next-step-copy[data-short] { font-size: 0; }
  .place-card #scene-status[data-short]::before { content: attr(data-short); content: attr(data-short) / ""; font-size: var(--ui-fs-12); }
  .next-step-bar #next-step-copy[data-short]::before { content: attr(data-short); content: attr(data-short) / ""; font-size: var(--ui-fs-14); }
  /* UX-641: a quest's short form puts its reward on a line of its own (a newline in it). */
  .next-step-bar #next-step-copy[data-short]::before { white-space: pre-line; }
}
/* UX-641 (head fix 20261030-1204): on the narrowest phones (320 wide) the copy box was 43 px, so
   a short form ("Fern & Bean" / "+5 coins") was cut mid-word; while one shows, the strip's × steps
   aside (the quest is put away from the Journal) and the copy takes its room. */
@media (max-width: 340px) {
  .next-step-bar:has(#next-step-copy[data-short]) #next-step-dismiss { display: none; }
}
/* UX-306: a phone on its side and other short wide windows (under 500 px tall): the 144 px
   frame took over a third of the height (37 % at 844x390). It is 96 tall there (a quarter of
   390 is 97), still well over the 44 px target, and keeps the place card's width, so the goal
   arrow and the exit signs along the top meet it where they always did; the picture covers the
   wider frame and slides to keep you in view (src/minimap.js measures the frame). */
@media (min-width: 721px) and (max-height: 500px) {
  .minimap { height: calc(var(--ui-s-7) * 2); }
}

/* Quest strip: the next goal, one primary verb, and × to put it away. */
.next-step-bar { max-width: min(540px, 40vw, 100%); padding: var(--ui-px) var(--ui-px) var(--ui-px) var(--ui-s-3); }
.next-step-bar .next-step-icon { color: var(--ui-coin-deep); }
.next-step-bar #next-step-copy { flex: 1 1 auto; min-width: 0; overflow: hidden; font-family: var(--ui-font-body); font-size: var(--ui-fs-14); font-weight: 600; line-height: 1.15; white-space: nowrap; text-overflow: ellipsis; }
/* The reward ("+5 coins") stays on one line when the copy wraps (phones). */
.next-step-bar #next-step-copy .goal-reward { white-space: nowrap; }
.next-step-bar #next-step-action { flex: none; min-height: var(--ui-s-6); margin-left: var(--ui-s-1); }

/* Focus pill: the one countdown while a session runs (VT323 32), the task beside it,
   pause and tasks as segments, and the session's progress drawn in the bottom bevel. */
.focus-pill { gap: 0; padding: var(--ui-px); }
.focus-pill .pill-open { justify-content: flex-start; gap: var(--ui-s-2); min-width: 0; flex: 0 1 auto; padding: 0 var(--ui-s-3) 0 var(--ui-s-2); }
.focus-pill .dock-icon { --px-size: 28px; color: var(--ui-accent); }
.focus-pill .pill-copy { display: flex; align-items: baseline; gap: var(--ui-s-2); min-width: 0; text-align: left; }
.focus-pill #dock-countdown { font-family: var(--ui-font-num); font-size: var(--ui-fs-32); font-weight: 400; line-height: 1; font-variant-numeric: tabular-nums; }
.focus-pill #dock-status { display: block; max-width: 28ch; overflow: hidden; color: var(--ui-ink-muted); font-family: var(--ui-font-body); font-size: var(--ui-fs-12); font-weight: 600; white-space: nowrap; text-overflow: ellipsis; }
.focus-pill .pill-button .px { --px-size: 14px; }
.focus-pill .pill-button:disabled { color: var(--ui-disabled-ink); cursor: not-allowed; }
.focus-pill .pill-progress { position: absolute; left: 0; right: 0; bottom: 0; height: var(--ui-px); overflow: hidden; pointer-events: none; }
.focus-pill .pill-progress > span { display: block; width: calc(var(--progress, 0) * 100%); height: 100%; background: var(--ui-accent); transition: width 900ms linear; }
.focus-pill[data-status="paused"] .dock-icon { color: var(--ui-warning); }
.focus-pill[data-status="paused"] .pill-progress > span { background: var(--ui-warning); }
.focus-pill[data-status="paused"] #dock-countdown { color: var(--ui-ink-muted); }
@media (prefers-reduced-motion: reduce) { .focus-pill .pill-progress > span { transition: none; } }

/* Café room bar: the room (who is here), emotes and the room's ⋯ menu, as segments. */
.multiplayer-hud { gap: 0; max-width: min(520px, 100%); padding: var(--ui-px); }
.multiplayer-hud .hud-pill { flex: 1 1 auto; justify-content: flex-start; gap: var(--ui-s-2); padding: 0 var(--ui-s-3); }
.multiplayer-hud #hud-lobby-name { min-width: 0; overflow: hidden; font-family: var(--ui-font-display); font-size: var(--ui-fs-14); font-weight: 600; text-overflow: ellipsis; }
.multiplayer-hud .hud-count { color: var(--ui-ink-muted); font-family: var(--ui-font-body); font-size: var(--ui-fs-12); font-weight: 600; white-space: nowrap; }
.multiplayer-hud .status-dot { flex: none; width: var(--ui-s-2); height: var(--ui-s-2); background: var(--ui-warning); border: 0; border-radius: 0; box-shadow: 0 0 0 var(--ui-px) var(--ui-line); }
.multiplayer-hud .status-dot:is(.relay, .p2p) { background: var(--ui-success); }
.multiplayer-hud .hud-btn { font-size: var(--ui-fs-20); }
.room-menu { position: relative; flex: none; margin: 0; padding: 0; background: none; border: 0; }
/* The room menu: the Menu component, under the bar, right edges lined up. */
.room-menu .menu { top: calc(100% + var(--ui-px) + var(--ui-s-2)); right: calc(var(--ui-px) * -1); left: auto; min-width: 256px; }
/* GROVE-1.9: a two-way café choice is one menu item that switches on tap; its value sits on the
   right in the muted ink, like the phone's "This room" rows. */
.room-menu .cafe-choice { justify-content: space-between; gap: var(--ui-s-3); }
.room-menu .cafe-choice .menu-value { margin-left: auto; color: var(--ui-ink-muted); font-family: var(--ui-font-body); font-size: var(--ui-fs-14); font-weight: 600; }

/* Phones: segments keep 44 px hit areas (the ::before reaches the frame); copy may wrap
   to two lines in the quest strip, never more. */
@media (max-width: 720px) {
  .next-step-bar { width: 100%; max-width: none; }
  .next-step-bar #next-step-copy { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; white-space: normal; }
  .next-step-bar #next-step-action { min-height: var(--ui-s-6); }
  .focus-pill { width: 100%; }
  .focus-pill .pill-open { flex: 1 1 auto; }
  .focus-pill #dock-status { max-width: none; }
  .multiplayer-hud { max-width: 100%; }
  .multiplayer-hud .hud-lobby-place:not(:empty) { display: none; }
  /* One ⋯ in the top band: the room's actions move into the status card's ⋯ menu
     ("This room", src/ui-shell.js syncStatusRoom), so the room bar keeps the room and emotes. */
  .multiplayer-hud .room-menu { display: none; }
}
/* UX-256: on touch and phones the strip's 32 px "Show me" keeps its look, but a clear
   ::before makes its hit area 44 tall (6 px above and below, inside the strip's frame).
   It stops at its own sides, so it never reaches the × beside it. */
@media (pointer: coarse), (max-width: 720px) {
  .next-step-bar #next-step-action { position: relative; }
  .next-step-bar #next-step-action::before { content: ""; position: absolute; inset: calc((var(--ui-target) - var(--ui-s-6)) / -2) 0; }
}

/* ---------- HUD icon button (UX-005 A3c): the radio and chat corners ----------
   A 44 px HUD card with only a 28 px icon (the 14-grid at 2x): same rest frame, hover,
   press and focus as the place card. It opens a card above it (aria-expanded); while
   that card is open the button takes the sunk fill, like the status card's ⋯.
   A state worth knowing at a glance (music playing, unread chat) is an 8 px square on
   the frame's top-right corner, ringed like the dock's Together dot; it carries no text
   (the button's accessible name says it). */
.hud-card--icon { justify-content: center; width: var(--ui-target); height: var(--ui-target); padding: 0; gap: 0; }
.hud-card--icon .ico { --ico: 28px; }
/* Wide screens: the radio and chat corners also say what they are (the station's name,
   "Chat") in Pixelify 14 beside the icon; the frame grows to fit, 44 px tall. Narrower
   windows and phones keep the 44 px icon; the words stay in the accessible name. */
.hud-card-label { display: none; }
@media (min-width: 1100px) {
  .hud-card--icon:has(.hud-card-label) { width: auto; gap: var(--ui-s-2); padding: 0 var(--ui-s-3) 0 var(--ui-s-2); }
  .hud-card-label { display: block; max-width: 16ch; overflow: hidden; font-family: var(--ui-font-display); font-size: var(--ui-fs-14); font-weight: 600; line-height: 1; white-space: nowrap; text-overflow: ellipsis; }
}
.hud-card--icon[aria-expanded="true"] { --f-fill: var(--ui-surface-sunk); }
.hud-dot {
  position: absolute;
  top: calc(var(--ui-px) * -1);
  right: calc(var(--ui-px) * -1);
  width: var(--ui-s-2);
  height: var(--ui-s-2);
  overflow: hidden;
  background: var(--ui-success);
  box-shadow: 0 0 0 var(--ui-px) var(--ui-line);
  font-size: 0;
  pointer-events: none;
}
.hud-dot[hidden], .hud-dot:empty.chat-unread { display: none; }
.hud-dot.chat-unread { background: var(--ui-badge-bg); }

/* Cards that rise out of a bottom corner: 320 ms ease-out from 8 px below + fade;
   exit 200 ms ease-in. Reduced motion: --ui-travel is 0, so they only fade. */
@keyframes ui-rise-in { from { opacity: 0; transform: translateY(var(--ui-travel)); } }
@keyframes ui-rise-out { to { opacity: 0; transform: translateY(var(--ui-travel)); } }

/* ---------- radio card: what is playing, play/pause, next, volume, sound effects ----------
   A raised frame, 12 px padding: the station (Pixelify 16) over its mood (Outfit 12),
   then one row of controls. Play/pause is the card's one primary. */
.radio-card {
  display: grid;
  gap: var(--ui-s-3);
  box-sizing: border-box;
  padding: var(--ui-s-3);
  color: var(--ui-ink);
  font-family: var(--ui-font-body);
  pointer-events: auto;
}
.radio-card[hidden] { display: none; }
.radio-card:not([hidden]) { animation: ui-rise-in var(--ui-dur-slow) var(--ui-ease-out) both; }
.radio-card.is-closing { animation: ui-rise-out var(--ui-dur) var(--ui-ease-in) both; }
.radio-now { display: grid; gap: var(--ui-s-1); min-width: 0; margin: 0; padding: 0 var(--ui-s-1); }
.radio-now > * { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
#music-station { font-family: var(--ui-font-display); font-size: var(--ui-fs-16); font-weight: 600; line-height: 1.25; }
#music-mood { color: var(--ui-ink-muted); font-size: var(--ui-fs-12); line-height: 1.25; }
.radio-controls { display: flex; align-items: center; gap: var(--ui-s-2); }
.radio-controls .btn { flex: none; }
.radio-volume { display: flex; flex: 1 1 auto; align-items: center; min-width: 0; margin: 0; }
.radio-card #music-volume { width: 100%; min-width: 0; margin: 0; accent-color: var(--ui-accent); cursor: pointer; }
.radio-card #music-volume:focus-visible { outline: var(--ui-focus-ring-w) solid var(--ui-focus-ring); outline-offset: calc(var(--ui-px) * 2); }

/* ---------- chat panel: a raised frame; tabs and close in the head, one primary (Send) ----------
   Head as in the feedback sheet: 1 UI px shade rule under it, a ghost 40 px close.
   Tabs are the Tab component: 36 tall, Pixelify 16, the selected one a flat peach frame.
   Type: 16 (tabs, input), 14 (lines), 12 (note, times, status). */
.chat-panel {
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  overflow: hidden;
  color: var(--ui-ink);
  font-family: var(--ui-font-body);
}
.chat-panel[hidden] { display: none; }
.chat-panel:not([hidden]) { animation: ui-rise-in var(--ui-dur-slow) var(--ui-ease-out) both; }
.chat-head {
  display: flex;
  flex: none;
  align-items: center;
  gap: var(--ui-s-1);
  padding: var(--ui-s-2) var(--ui-s-2) var(--ui-s-2) var(--ui-s-3);
  box-shadow: inset 0 calc(var(--ui-px) * -1) 0 0 var(--ui-surface-shade);
}
.chat-panel .chat-tab {
  display: inline-flex;
  align-items: center;
  height: 36px;
  min-height: 0;
  margin: 0;
  padding: 0 var(--ui-s-3);
  background: transparent;
  color: var(--ui-tab-ink);
  border: 0;
  border-radius: 0;
  box-shadow: none;
  font-family: var(--ui-font-display);
  font-size: var(--ui-fs-16);
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  transition: background-color var(--ui-dur-fast) var(--ui-ease-out);
}
.chat-panel .chat-tab:hover:not(:disabled) { background: var(--ui-surface-sunk); color: var(--ui-ink); }
.chat-panel .chat-tab[aria-selected="true"] {
  background: var(--ui-selected);
  color: var(--ui-ink-strong);
  box-shadow:
    inset var(--ui-px) var(--ui-px) 0 0 var(--ui-surface-hi),
    inset calc(var(--ui-px) * -1) calc(var(--ui-px) * -1) 0 0 var(--ui-coin-deep),
    var(--ui-frame-edge);
}
.chat-panel .chat-tab:disabled { color: var(--ui-disabled-ink); cursor: not-allowed; }
.chat-panel .chat-tab:focus-visible { outline: var(--ui-focus-ring-w) solid var(--ui-focus-ring); outline-offset: calc(var(--ui-px) * 2); }
.chat-panel .chat-close { margin-left: auto; }
.chat-note { flex: none; margin: 0; padding: var(--ui-s-3) var(--ui-s-4) 0; color: var(--ui-ink-muted); font-size: var(--ui-fs-12); line-height: 1.5; }
.chat-messages { display: grid; flex: 1 1 auto; align-content: start; gap: var(--ui-s-2); margin: 0; padding: var(--ui-s-3) var(--ui-s-4); overflow: auto; overscroll-behavior: contain; list-style: none; }
.chat-messages li { font-size: var(--ui-fs-14); line-height: 1.45; overflow-wrap: anywhere; }
.chat-panel .chat-name {
  display: inline;
  min-height: 0;
  margin: 0 var(--ui-s-1) 0 0;
  padding: 0;
  background: none;
  color: var(--ui-ink);
  border: 0;
  border-radius: 0;
  box-shadow: none;
  font-family: var(--ui-font-display);
  font-size: var(--ui-fs-14);
  font-weight: 600;
  line-height: inherit;
  cursor: pointer;
}
.chat-panel .chat-name.mine { color: var(--ui-ink-muted); }
.chat-panel .chat-name:disabled { cursor: default; }
.chat-panel .chat-name:hover:not(:disabled) { text-decoration: underline; text-underline-offset: var(--ui-px); }
.chat-panel .chat-name:focus-visible { outline: var(--ui-focus-ring-w) solid var(--ui-focus-ring); outline-offset: var(--ui-px); }
.chat-time { margin-left: var(--ui-s-1); color: var(--ui-ink-muted); font-size: var(--ui-fs-12); font-variant-numeric: tabular-nums; }
.chat-empty { color: var(--ui-ink-muted); }
.chat-form { display: flex; flex: none; gap: var(--ui-s-2); margin: 0; padding: var(--ui-s-3); box-shadow: inset 0 var(--ui-px) 0 0 var(--ui-surface-shade); }
/* The message box: the Input component (a flat frame with the bevel inverted). */
.chat-panel #chat-input {
  flex: 1 1 auto;
  box-sizing: border-box;
  width: auto;
  min-width: 0;
  height: 40px;
  min-height: 0;
  margin: 0;
  padding: 0 var(--ui-s-3);
  color: var(--ui-input-ink);
  background: var(--ui-frame-fill);
  border: 0;
  border-radius: 0;
  box-shadow:
    inset var(--ui-px) var(--ui-px) 0 0 var(--ui-surface-shade),
    inset calc(var(--ui-px) * -1) calc(var(--ui-px) * -1) 0 0 var(--ui-surface-hi),
    var(--ui-frame-edge);
  font-family: var(--ui-font-body);
  font-size: var(--ui-fs-16);
  line-height: 1;
}
.chat-panel #chat-input::placeholder { color: var(--ui-ink-muted); opacity: 1; }
.chat-panel #chat-input:focus-visible { outline: var(--ui-focus-ring-w) solid var(--ui-focus-ring); outline-offset: calc(var(--ui-px) * 2); }
.chat-panel #chat-input:disabled { background: var(--ui-disabled-bg); color: var(--ui-disabled-ink); cursor: not-allowed; }
.chat-panel .chat-send { flex: none; }
.chat-status { flex: none; margin: 0; padding: 0 var(--ui-s-3) var(--ui-s-3); color: var(--ui-danger); font-size: var(--ui-fs-12); font-weight: 600; line-height: 1.5; }
.chat-status:empty { display: none; }
@media (pointer: coarse), (max-width: 720px) {
  .chat-panel .chat-tab { height: var(--ui-target); }
  .chat-panel #chat-input { height: var(--ui-target); }
}

/* ---------- toggle button: a button that stays pressed (aria-pressed) ----------
   Pressed is the one "chosen" fill: a flat peach frame with strong ink (as the dock's
   active item and the selected tab). Used by the café jukebox's Skip, Quiet and Boost. */
.btn--toggle[aria-pressed="true"] {
  --f-fill: var(--ui-selected);
  --f-shade: var(--ui-coin-deep);
  --f-drop-y: var(--ui-px);
  color: var(--ui-ink-strong);
}

/* ---------- café room actions (UX-005 A5): Upstairs, Staff Room, Tea, Find a free seat ----------
   One rest pixel frame above the dock holding equal unframed segments (the status card's
   recipe): two columns, 40 px rows (44 on phones), Outfit 14/600, a 1 UI px shade rule
   between neighbours. None is primary: the quest strip carries the café's next step.
   An odd last action spans both columns. Placed by the status stack (shell.css). */
.cafe-shortcuts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  box-sizing: border-box;
  width: max-content;
  max-width: 100%;
  padding: var(--ui-px);
  pointer-events: auto;
}
.cafe-shortcuts .cafe-action {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  height: 40px;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0 var(--ui-s-3);
  overflow: hidden;
  background: transparent;
  color: var(--ui-ink);
  border: 0;
  border-radius: 0;
  box-shadow: none;
  font-family: var(--ui-font-body);
  font-size: var(--ui-fs-14);
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: background-color var(--ui-dur-fast) var(--ui-ease-out);
}
.cafe-shortcuts .cafe-action:nth-child(even) { box-shadow: inset var(--ui-px) 0 0 0 var(--ui-surface-shade); }
.cafe-shortcuts .cafe-action:nth-child(n + 3) { box-shadow: inset 0 var(--ui-px) 0 0 var(--ui-surface-shade); }
.cafe-shortcuts .cafe-action:nth-child(n + 3):nth-child(even) { box-shadow: inset var(--ui-px) 0 0 0 var(--ui-surface-shade), inset 0 var(--ui-px) 0 0 var(--ui-surface-shade); }
.cafe-shortcuts .cafe-action:last-child:nth-child(odd) { grid-column: 1 / -1; }
.cafe-shortcuts .cafe-action:hover { background: var(--ui-secondary-hover); }
.cafe-shortcuts .cafe-action:active:not(:disabled) { background: var(--ui-surface-sunk); transform: none; }
.cafe-shortcuts .cafe-action:focus-visible {
  outline: var(--ui-focus-ring-w) solid var(--ui-focus-ring);
  outline-offset: calc(var(--ui-focus-ring-w) * -1);
}
.cafe-shortcuts .cafe-action:disabled { background: transparent; color: var(--ui-disabled-ink); opacity: 1; cursor: not-allowed; }
@media (pointer: coarse), (max-width: 720px) {
  .cafe-shortcuts .cafe-action { height: var(--ui-target); }
}
@media (max-width: 720px) {
  /* Full width inside the 16 px phone gutters (the status stack itself keeps 8). */
  .cafe-shortcuts { width: min(100%, calc(100vw - 2 * var(--hud-band-side))); }
}

/* ---------- sheet (UX-006 B1, UI-V2 §2.2 Sheet, §3.1, §3.2): the one side panel ----------
   src/sheet-host.js shows one panel at a time in .sheet-host > .sheet-frame: a head with the
   group's tabs and one close (.sheet-header, only when the group has tabs), an optional banner,
   then the panel (.sheet-body > dialog | aside). This is the shell every panel shares; panel
   interiors are styled by their own slices.
   Desktop: a raised pixel frame on the right, 448 wide (--sheet-w, shell.css) and 16 in from
   the edge, from 12 under the HUD band to 12 above the dock (--sheet-top / --sheet-bottom); on
   narrower windows it never grows past the place card's column, so the HUD's left column
   stays clear. The Map's full-size sheet spans the width between the same bands.
   Phones (≤ 720): a bottom sheet, full width, over a scrim (modal: the HUD and dock wait
   underneath until it closes). Its top sits 8 under the lowest card of the top band
   (--sheet-band-end, measured by src/sheet-host.js), so the quest strip and the focus pill
   are never cut in half; the full-size Map sheet covers the band whole instead.
   Head: the tabs wrap onto as many rows as they need (every tab always shows; no sideways
   scrolling, no clipped fragments) beside the close, which keeps its own column top right;
   a 1 UI px shade rule under it. Body: 16 24 24 (phones 12 16 16).
   Motion: in 320 ms ease-out from 8 px right (phones: below) + fade; reduced motion: --ui-travel
   is 0, so it only fades. It closes at once (no exit motion in this slice): Esc, focus return
   and every check see it shut immediately. */
.sheet-host {
  position: fixed;
  z-index: var(--z-sheet);
  top: var(--sheet-top);
  right: var(--hud-band-side);
  bottom: var(--sheet-bottom);
  display: flex;
  width: min(var(--sheet-w), calc(100vw - var(--hud-col) - 3 * var(--hud-band-side)));
  pointer-events: none;
}
.sheet-host[hidden] { display: none; }
.sheet-host[data-size="full"] { left: var(--hud-band-side); width: auto; }
.sheet-scrim { display: none; }
.sheet-frame {
  --f-fill: var(--ui-sheet-bg);
  --sheet-from: translateX(var(--ui-travel));
  position: relative;
  display: flex;
  flex: 1;
  flex-direction: column;
  box-sizing: border-box;
  min-width: 0;
  min-height: 0;
  /* 1 UI px in from the frame, so nothing inside ever covers its bevel. */
  padding: var(--ui-px);
  /* GROVE-1.9: clip, not hidden. A hidden-overflow box is still a scroll container, so
     focusing or scrolling a control into view scrolled the FRAME and pushed the head (title,
     tabs, close) off the top: the "tab bar clipped when scrolled" bug. Clip can't scroll. */
  overflow: hidden;
  overflow: clip;
  color: var(--ui-sheet-ink);
  font-family: var(--ui-font-body);
  pointer-events: auto;
}
.sheet-host:not([hidden]) .sheet-frame { animation: ui-sheet-in var(--ui-dur-slow) var(--ui-ease-out); }
@keyframes ui-sheet-in { from { opacity: 0; transform: var(--sheet-from); } }
@keyframes ui-fade-in { from { opacity: 0; } }

/* Head: the tabs, then the close in its own column (top right, centred on the first row of
   tabs), so no tab ever runs under it. */
.sheet-header {
  display: none;
  flex: none;
  align-items: flex-start;
  gap: var(--ui-s-1);
  padding: var(--ui-s-2) var(--ui-s-3) var(--ui-s-2) var(--ui-s-3);
  box-shadow: inset 0 calc(var(--ui-px) * -1) 0 0 var(--ui-surface-shade);
}
.sheet-host.grouped .sheet-header { display: flex; }
.sheet-header .sheet-close { flex: none; margin-top: calc(var(--ui-px) * -1); }
/* Every tab shows: a row that doesn't fit wraps onto a second (as many as it needs), with the
   same 4 px gap across and down. Nothing scrolls, so nothing is clipped or hidden. */
.sheet-tabs {
  position: relative;
  flex: 1;
  min-width: 0;
  padding: 0;
}
.sheet-tablist { display: flex; flex-wrap: wrap; gap: var(--ui-s-1); }
.sheet-tablist[hidden] { display: none; }
/* Tab: 36 tall (44 on touch and phones), Pixelify 16, muted ink; the selected one is the one
   "chosen" fill: a flat peach frame with strong ink (as the dock's open item). */
.sheet-tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--ui-s-2);
  flex: none;
  box-sizing: border-box;
  height: 36px;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0 var(--ui-s-3);
  background: transparent;
  color: var(--ui-tab-ink);
  border: 0;
  border-radius: 0;
  box-shadow: none;
  font-family: var(--ui-font-display);
  font-size: var(--ui-fs-16);
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0;
  text-decoration: none;
  text-transform: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color var(--ui-dur-fast) var(--ui-ease-out), color var(--ui-dur-fast) var(--ui-ease-out);
}
.sheet-tab[hidden] { display: none; }
.sheet-tab:hover { background: var(--ui-surface-sunk); color: var(--ui-ink); }
.sheet-tab:active:not(:disabled) { transform: none; }
.sheet-tab[aria-selected="true"] {
  background: var(--ui-selected);
  color: var(--ui-ink-strong);
  box-shadow:
    inset var(--ui-px) var(--ui-px) 0 0 var(--ui-surface-hi),
    inset calc(var(--ui-px) * -1) calc(var(--ui-px) * -1) 0 0 var(--ui-coin-deep),
    var(--ui-frame-edge);
}
.sheet-tab[data-glyph]::before { content: none; }
.sheet-tab:focus-visible {
  outline: var(--ui-focus-ring-w) solid var(--ui-focus-ring);
  outline-offset: calc(var(--ui-px) * 2);
}
/* A count on a tab (quests, neighbours, passport) is the Badge component (above). */

/* Close: the sheet head's is the ghost icon button (.btn--icon, from src/sheet-host.js). A panel
   without tabs keeps its own close in its title row (.close-dialog, written as "×" by many
   panels): drawn the same, 40 px (44 on touch and phones) with the 28 px pixel cross. */
.close-dialog {
  position: relative;
  display: inline-grid;
  place-items: center;
  flex: none;
  box-sizing: border-box;
  width: 40px;
  height: 40px;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
  background: transparent;
  color: var(--ui-ink);
  border: 0;
  border-radius: 0;
  box-shadow: none;
  font-size: 0;
  line-height: 0;
  cursor: pointer;
  transition: background-color var(--ui-dur-fast) var(--ui-ease-out), transform var(--ui-dur-fast) var(--ui-ease-out);
}
.close-dialog::before {
  content: "";
  width: 28px;
  height: 28px;
  background: currentColor;
  -webkit-mask: var(--px) center / 100% 100% no-repeat;
  mask: var(--px) center / 100% 100% no-repeat;
}
.close-dialog:hover { background: var(--ui-surface-sunk); }
.close-dialog:active:not(:disabled), dialog .close-dialog:active:not(:disabled) { box-shadow: none; transform: translateY(var(--ui-press)); }
.close-dialog:focus-visible {
  outline: var(--ui-focus-ring-w) solid var(--ui-focus-ring);
  outline-offset: calc(var(--ui-px) * 2);
}
.sheet-host.grouped .sheet-body .close-dialog { display: none; }
@media (pointer: coarse), (max-width: 720px) {
  .sheet-tab { height: var(--ui-target); }
  .close-dialog { width: var(--ui-target); height: var(--ui-target); }
  /* Tab and close are both 44: their tops line up. */
  .sheet-header .sheet-close { margin-top: 0; }
}

/* Banner (the Journal's level strip) and body. */
.sheet-banner { flex: none; padding: var(--ui-s-4) var(--ui-s-5) 0; }
.sheet-banner[hidden] { display: none; }
.sheet-body { position: relative; display: flex; flex: 1; flex-direction: column; min-height: 0; }
.sheet-body > dialog[open], .sheet-body > aside:not([hidden]) {
  position: static;
  inset: auto;
  display: block;
  flex: 1;
  box-sizing: border-box;
  width: auto;
  max-width: none;
  height: auto;
  max-height: none;
  min-height: 0;
  margin: 0;
  padding: var(--ui-s-4) var(--ui-s-5) var(--ui-s-5);
  overflow: auto;
  overscroll-behavior: contain;
  /* Things scrolled into view (keyboard focus, "show me") land clear of a sticky title row. */
  scroll-padding-top: var(--ui-s-7);
  scroll-padding-bottom: var(--ui-s-4);
  background: transparent;
  color: var(--ui-sheet-ink);
  border: 0;
  border-radius: 0;
  box-shadow: none;
  transform: none;
  scrollbar-gutter: stable;
  /* The panel takes focus only as a landing spot when it opens; its controls show the ring. */
  outline: none;
}
/* With a mouse: an 8 px square scrollbar in the paper's shade, and the banner above the panel
   keeps the panel content's right edge (24 + the 8 px bar). Touch keeps its overlay bar. */
@media (pointer: fine) {
  .sheet-body > :is(dialog, aside)::-webkit-scrollbar { width: var(--ui-s-2); }
  .sheet-body > :is(dialog, aside)::-webkit-scrollbar-track { background: transparent; }
  .sheet-body > :is(dialog, aside)::-webkit-scrollbar-thumb { background: var(--ui-surface-shade); }
  .sheet-body > :is(dialog, aside)::-webkit-scrollbar-thumb:hover { background: var(--ui-ink-muted); }
  @supports not selector(::-webkit-scrollbar) {
    .sheet-body > :is(dialog, aside) { scrollbar-width: thin; scrollbar-color: var(--ui-surface-shade) transparent; }
  }
  .sheet-banner { padding-right: calc(var(--ui-s-5) + var(--ui-s-2)); }
}

/* Title row: Pixelify 20/600, with the panel's own actions on the right. */
.sheet-body .dialog-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ui-s-3);
  margin: 0 0 var(--ui-s-4);
  padding: 0;
  background: none;
  border: 0;
}
.sheet-body .dialog-heading h2 {
  margin: 0;
  color: var(--ui-ink);
  font-family: var(--ui-font-display);
  font-size: var(--ui-fs-20);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0;
}
.sheet-body .dialog-heading .eyebrow { margin-bottom: var(--ui-s-1); }
/* A panel without tabs: its title row is the sheet's head. It stays in view while the panel
   scrolls, runs the full width of the frame and has the head's 1 UI px rule under it. */
.sheet-host:not(.grouped) .sheet-body .dialog-heading {
  position: sticky;
  top: calc(var(--ui-s-4) * -1);
  z-index: 3;
  margin: calc(var(--ui-s-4) * -1) calc(var(--ui-s-5) * -1) var(--ui-s-4);
  padding: var(--ui-s-2) var(--ui-s-3) var(--ui-s-2) var(--ui-s-5);
  background: var(--ui-sheet-bg);
  box-shadow: inset 0 calc(var(--ui-px) * -1) 0 0 var(--ui-surface-shade);
}

/* Phones: a bottom sheet across the full width over a scrim. The frame's side and bottom edges
   sit just off-screen, so its top edge, bevel and a 32 x 4 grab bar show. The top starts 8
   under the top band's lowest card (--sheet-band-end, set by src/sheet-host.js while a sheet
   is open; at least 48 from the top), so no HUD card is ever half under the sheet's edge. */
@media (max-width: 720px) {
  .sheet-host, .sheet-host[data-size="full"] { top: auto; left: 0; right: 0; bottom: 0; width: auto; height: min(88dvh, calc(100dvh - max(var(--ui-s-7), var(--sheet-band-end, 0px) + var(--ui-s-2)))); }
  .sheet-host[data-size="full"] { height: calc(100dvh - var(--ui-s-2)); }
  .sheet-scrim { position: fixed; inset: 0; display: block; background: var(--ui-sheet-scrim); pointer-events: auto; }
  .sheet-host:not([hidden]) .sheet-scrim { animation: ui-fade-in var(--ui-dur-slow) var(--ui-ease-out); }
  .sheet-frame { --sheet-from: translateY(var(--ui-travel)); }
  .sheet-frame::before {
    content: "";
    flex: none;
    width: var(--ui-s-6);
    height: var(--ui-s-1);
    /* Its 1 UI px outline sits inside the frame, above whatever comes next (a sticky title row). */
    margin: var(--ui-s-2) auto var(--ui-px);
    background: var(--ui-surface-shade);
    box-shadow: 0 0 0 var(--ui-px) var(--ui-ink-muted);
  }
  .sheet-header { padding: var(--ui-s-2) var(--ui-s-3) var(--ui-s-3) var(--ui-s-4); }
  .sheet-tab { padding: 0 var(--ui-s-2); }
  /* UX-728: a 320 phone's Focus row (Timer · Tasks · Flashcards · This week · History) needs
     every px: the tabs pad 4 a side (src/sheet-host.js balanceTabs evens out what still wraps). */
  @media (max-width: 340px) { .sheet-tab { padding: 0 var(--ui-s-1); } }
  .sheet-banner { padding: var(--ui-s-3) var(--ui-s-4) 0; }
  .sheet-body > dialog[open], .sheet-body > aside:not([hidden]) {
    padding: var(--ui-s-3) var(--ui-s-4) calc(var(--ui-s-4) + env(safe-area-inset-bottom));
    scrollbar-gutter: auto;
  }
  .sheet-body .dialog-heading { margin-bottom: var(--ui-s-3); }
  .sheet-host:not(.grouped) .sheet-body .dialog-heading {
    top: calc(var(--ui-s-3) * -1);
    margin: calc(var(--ui-s-3) * -1) calc(var(--ui-s-4) * -1) var(--ui-s-3);
    padding: var(--ui-s-1) var(--ui-s-2) var(--ui-s-2) var(--ui-s-4);
  }
}

/* ---------- Focus panel (UX-006 B2, UI-V2 §4 B2): the timer sheet's interior ----------
   One column, 16 apart: the task, the length (a segmented control), the clock and the one
   primary (Start focus); then what a minute earns, two stat cards and the extras. While a
   session runs, Start hides: Pause is secondary and Finish early is a ghost button.
   Type: 20 (title), 16 (controls, card titles), 14 (labels, meta), plus the clock: VT323 at
   --ui-fs-num-hero (64), the sheet's one big number (UI-V2 §2.2).
   Ids stay as src/app.js and the tests know them (#timer-form, #countdown, #timer-progress…). */
#study-panel .timer-card { display: grid; gap: var(--ui-s-4); max-width: none; margin: 0; padding: 0; background: none; border: 0; box-shadow: none; }
#study-panel .timer-heading { margin-bottom: 0; }
#timer-form { display: grid; gap: var(--ui-s-3); margin: 0; }
.timer-field { display: grid; gap: var(--ui-s-1); }
.timer-field[hidden] { display: none; }
#study-panel .timer-field label { margin: 0; color: var(--ui-ink); font-family: var(--ui-font-body); font-size: var(--ui-fs-14); font-weight: 600; line-height: 1.25; }
/* Task and minutes: the Input component (a flat frame with its bevel inverted). */
#study-panel :is(#task, #minutes) {
  box-sizing: border-box;
  width: 100%;
  height: 40px;
  min-height: 0;
  margin: 0;
  padding: 0 var(--ui-s-3);
  color: var(--ui-input-ink);
  background: var(--ui-frame-fill);
  border: 0;
  border-radius: 0;
  box-shadow:
    inset var(--ui-px) var(--ui-px) 0 0 var(--ui-surface-shade),
    inset calc(var(--ui-px) * -1) calc(var(--ui-px) * -1) 0 0 var(--ui-surface-hi),
    var(--ui-frame-edge);
  font-family: var(--ui-font-body);
  font-size: var(--ui-fs-16);
  line-height: 1;
}
#study-panel :is(#task, #minutes)::placeholder { color: var(--ui-ink-muted); opacity: 1; }
#study-panel :is(#task, #minutes):focus-visible { outline: var(--ui-focus-ring-w) solid var(--ui-focus-ring); outline-offset: calc(var(--ui-px) * 2); }
#study-panel :is(#task, #minutes):disabled { background: var(--ui-disabled-bg); color: var(--ui-disabled-ink); cursor: not-allowed; }

/* Length: a segmented control. A sunk track (bevel inverted) holding four segments that
   behave like tabs: muted Outfit 16/600 tabular (the chip face: Pixelify's 5 reads as S
   at this size), hover lifts to paper, the chosen one is the flat
   peach frame the sheet's selected tab wears. aria-pressed carries the choice (Custom is
   pressed while a length that isn't a preset is set); Custom also (aria-expanded) opens the
   minutes field and shows that length. */
.timer-presets {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--ui-s-1);
  padding: var(--ui-s-1);
  background: var(--ui-surface-sunk);
  box-shadow:
    inset var(--ui-px) var(--ui-px) 0 0 var(--ui-surface-shade),
    inset calc(var(--ui-px) * -1) calc(var(--ui-px) * -1) 0 0 var(--ui-surface-hi);
}
.timer-presets button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  height: 36px;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0 var(--ui-s-1);
  overflow: hidden;
  background: transparent;
  color: var(--ui-tab-ink);
  border: 0;
  border-radius: 0;
  box-shadow: none;
  font-family: var(--ui-font-body);
  font-size: var(--ui-fs-16);
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: background-color var(--ui-dur-fast) var(--ui-ease-out), color var(--ui-dur-fast) var(--ui-ease-out), transform var(--ui-dur-fast) var(--ui-ease-out);
}
.timer-presets button:hover:not(:disabled, .selected) { background: var(--ui-secondary-hover); color: var(--ui-ink); }
.timer-presets button:active:not(:disabled) { transform: translateY(var(--ui-press)); }
.timer-presets button.selected {
  background: var(--ui-selected);
  color: var(--ui-ink-strong);
  box-shadow:
    inset var(--ui-px) var(--ui-px) 0 0 var(--ui-surface-hi),
    inset calc(var(--ui-px) * -1) calc(var(--ui-px) * -1) 0 0 var(--ui-coin-deep),
    var(--ui-frame-edge);
}
.timer-presets button:focus-visible { position: relative; z-index: 1; outline: var(--ui-focus-ring-w) solid var(--ui-focus-ring); outline-offset: var(--ui-px); }
.timer-presets button:disabled { color: var(--ui-disabled-ink); cursor: not-allowed; }
.timer-presets button.selected:disabled { color: var(--ui-ink-strong); }

/* The clock: what it is doing (Outfit 14), the time (VT323 64, --ui-fs-num-hero) and the time left as a
   24-block pixel meter (12 px tall, 2 px from a 1 UI px cocoa edge; whole pixels at 1:1).
   #timer-progress keeps its dash offset from src/app.js (pathLength 502.65): the blocks
   empty from the right as the session runs; paused, they and the time turn to the warning colour. */
.timer-face { display: grid; justify-items: center; gap: var(--ui-s-2); margin: 0; padding: var(--ui-s-2) 0; }
#timer-status { color: var(--ui-ink-muted); font-family: var(--ui-font-body); font-size: var(--ui-fs-14); font-weight: 600; line-height: 1; }
#countdown { color: var(--ui-ink); font-family: var(--ui-font-num); font-size: var(--ui-fs-num-hero); font-weight: 400; line-height: 1; letter-spacing: 0; font-variant-numeric: tabular-nums; }
.timer-bar {
  display: block;
  box-sizing: content-box;
  width: var(--ui-timer-bar-w);
  max-width: calc(100% - var(--ui-s-2));
  height: 12px;
  padding: var(--ui-px);
  margin-top: var(--ui-s-1);
  background: var(--ui-sheet-bg);
  box-shadow: var(--ui-frame-edge);
  overflow: visible;
}
.timer-bar line { fill: none; stroke-width: 12; stroke-linecap: butt; }
.timer-bar .timer-track { stroke: var(--ui-surface-shade); }
.timer-bar .timer-progress { stroke: var(--ui-success); stroke-dasharray: 502.65; transition: stroke-dashoffset var(--ui-dur-slow) linear; }
.timer-bar .timer-gaps { stroke: var(--ui-sheet-bg); stroke-dasharray: 4 8; stroke-dashoffset: -8; }
#study-panel[data-status="paused"] .timer-progress { stroke: var(--ui-warning); }
#study-panel[data-status="paused"] #countdown { color: var(--ui-ink-muted); }
@media (prefers-reduced-motion: reduce) { .timer-bar .timer-progress { transition: none; } }

/* Actions. Start is the panel's one primary (.btn--primary.btn--block, 44 tall). */
.session-controls:not([hidden]) { display: grid; gap: var(--ui-s-2); }
#timer-end { justify-self: center; max-width: 100%; white-space: normal; text-align: center; line-height: 1.25; }
/* UX-727: Finish early is as tall as Pause beside it (44), so the two bottoms line up. */
#study-panel .session-controls #timer-end { min-height: var(--ui-target); }
#recovery-controls:not([hidden]) {
  display: grid;
  gap: var(--ui-s-2);
  padding: var(--ui-s-3);
  background: var(--ui-surface-sunk);
  box-shadow: inset calc(var(--ui-px) * 2) 0 0 0 var(--ui-warning);
}
#recovery-controls p { margin: 0 0 var(--ui-s-1); color: var(--ui-ink); font-family: var(--ui-font-body); font-size: var(--ui-fs-14); line-height: 1.5; }

/* What a minute earns: one quiet line under the actions. */
#study-panel .timer-reward { display: flex; align-items: center; justify-content: center; gap: var(--ui-s-2); margin: 0; color: var(--ui-ink-muted); font-family: var(--ui-font-body); font-size: var(--ui-fs-14); line-height: 1.25; }
.timer-reward .ico { color: var(--ui-coin-deep); }
.timer-reward b { color: var(--ui-ink); font-weight: 700; font-variant-numeric: tabular-nums; }

/* Stat cards (Today, your companion): flat and sunk, no frame inside the sheet's frame.
   One layout: a 48 lead (a 28 icon, or the pet at 1x), the title (Pixelify 16) over one
   meta line (Outfit 14, numbers bold and tabular), then an optional action. */
.focus-today { display: grid; gap: var(--ui-s-2); }
.stat-card {
  display: grid;
  grid-template-columns: var(--ui-s-7) minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--ui-s-3);
  min-width: 0;
}
.stat-lead { display: grid; place-items: center; width: var(--ui-s-7); height: var(--ui-s-7); overflow: hidden; }
.stat-lead .ico { --ico: 28px; color: var(--ui-accent); }
/* The 64 x 52 pet canvas at 1x, cropped to the lead's square around the pet. */
#pet-card { display: block; width: var(--ui-s-7); height: var(--ui-s-7); object-fit: none; object-position: 50% 75%; image-rendering: pixelated; }
.stat-copy { display: grid; gap: var(--ui-s-1); min-width: 0; }
#study-panel .stat-title { margin: 0; overflow: hidden; color: var(--ui-ink); font-family: var(--ui-font-display); font-size: var(--ui-fs-16); font-weight: 600; line-height: 1.25; letter-spacing: 0; white-space: nowrap; text-overflow: ellipsis; }
#study-panel .stat-meta { margin: 0; color: var(--ui-ink-muted); font-family: var(--ui-font-body); font-size: var(--ui-fs-14); line-height: 1.25; font-variant-numeric: tabular-nums; }
.stat-meta b { color: var(--ui-ink); font-weight: 700; }

/* Extras: the Chrome extension (a disclosure under a 1 UI px rule) and the 10-second preview. */
#study-panel .extension-setup { margin: 0; padding: 0; background: none; border: 0; border-radius: 0; box-shadow: inset 0 var(--ui-px) 0 0 var(--ui-surface-shade); }
#study-panel .extension-setup summary { display: flex; align-items: center; gap: var(--ui-s-2); min-height: 40px; padding-top: var(--ui-px); color: var(--ui-ink); font-family: var(--ui-font-body); font-size: var(--ui-fs-14); font-weight: 600; line-height: 1.25; cursor: pointer; transition: color var(--ui-dur-fast) var(--ui-ease-out); }
#study-panel .extension-setup summary:hover { color: var(--ui-ink-strong); }
#study-panel .extension-setup :is(summary, a):focus-visible { outline: var(--ui-focus-ring-w) solid var(--ui-focus-ring); outline-offset: var(--ui-px); }
#study-panel .extension-setup p { margin: 0 0 var(--ui-s-2); color: var(--ui-ink-muted); font-family: var(--ui-font-body); font-size: var(--ui-fs-14); line-height: 1.5; }
#study-panel .extension-setup a { display: inline-block; margin-bottom: var(--ui-s-2); color: var(--ui-ink); font-size: var(--ui-fs-14); font-weight: 600; }
#study-panel .demo-button { justify-self: center; }
#study-panel .demo-note { margin: 0; color: var(--ui-ink-muted); font-family: var(--ui-font-body); font-size: var(--ui-fs-14); line-height: 1.25; text-align: center; }

/* Touch and phones: 44 px segments and fields. */
@media (pointer: coarse), (max-width: 600px) {
  .timer-presets button { height: var(--ui-target); }
  #study-panel :is(#task, #minutes) { height: var(--ui-target); }
  #study-panel .extension-setup summary { min-height: var(--ui-target); }
}

/* UX-704: a phone held sideways (560 tall or less), or a small phone (600 tall or less, 320x568).
   Start focus shows without a scroll: before a session the clock steps aside (the chosen length
   already says it, and it is back the moment the session runs), so the task, the length and Start
   are the whole first view. Sideways on a phone 720 wide or less the Focus sheet also reaches up
   over the top band (its cards sit under the scrim anyway) instead of starting below it, which
   left it 181 px tall at 667x375. */
@media (max-height: 600px) {
  #study-panel[data-status="ready"] .timer-face { display: none; }
}
@media (max-width: 720px) and (max-height: 560px) and (orientation: landscape) {
  .sheet-host:has(#study-panel:not([hidden])) { height: calc(100dvh - var(--ui-s-2)); }
}
/* UX-709: the same short screens while a session runs (or is paused). The sheet's job is now the
   clock and Pause, so those come first and fit without a scroll: the length (locked anyway)
   steps aside, the task becomes one quiet read-only line, the clock drops to 40 (status beside
   the time on one row, the meter under it) and Pause and Finish early share one row of 44s.
   Taller screens keep the full layout. */
@media (max-height: 600px) {
  #study-panel:is([data-status="running"], [data-status="paused"]) :is(.timer-presets, #duration-field) { display: none; }
  #study-panel:is([data-status="running"], [data-status="paused"]) #timer-form { gap: var(--ui-s-2); }
  #study-panel:is([data-status="running"], [data-status="paused"]) .timer-card { gap: var(--ui-s-3); }
  #study-panel:is([data-status="running"], [data-status="paused"]) .timer-field { grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: var(--ui-s-2); }
  #study-panel:is([data-status="running"], [data-status="paused"]) .timer-field label { color: var(--ui-ink-muted); }
  #study-panel:is([data-status="running"], [data-status="paused"]) #task:disabled {
    height: auto;
    padding: 0;
    overflow: hidden;
    background: none;
    box-shadow: none;
    color: var(--ui-ink);
    font-size: var(--ui-fs-14);
    font-weight: 600;
    line-height: 1.25;
    text-overflow: ellipsis;
    cursor: default;
  }
  /* One block as wide as the meter: the status on its left, the time on its right, the meter under. */
  #study-panel:is([data-status="running"], [data-status="paused"]) .timer-face {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    justify-self: center;
    width: min(100%, calc(var(--ui-timer-bar-w) + 2 * var(--ui-px)));
    column-gap: var(--ui-s-3);
    row-gap: var(--ui-s-1);
    padding: 0;
  }
  #study-panel:is([data-status="running"], [data-status="paused"]) #timer-status { justify-self: start; }
  #study-panel:is([data-status="running"], [data-status="paused"]) #countdown { justify-self: end; font-size: var(--ui-fs-40); }
  #study-panel:is([data-status="running"], [data-status="paused"]) .timer-bar { grid-column: 1 / -1; justify-self: center; max-width: calc(100% - 2 * var(--ui-px)); margin-top: 0; }
  #study-panel .session-controls:not([hidden]) { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  /* Finish early: a quiet secondary beside the framed Pause (the sunk fill and a shade edge, no
     drop), so it reads as a button without competing. */
  #study-panel .session-controls #timer-end {
    --f-fill: var(--ui-surface-sunk);
    --f-edge: var(--ui-surface-shade);
    --f-hi: transparent;
    --f-shade: transparent;
    --f-drop: transparent;
    justify-self: stretch;
  }
  #study-panel .session-controls #timer-end:hover { --f-fill: var(--ui-secondary-hover); }
  /* UX-717 (head CHANGES UX-709): armed, the warning stays in Finish early's own cell beside Pause,
     at 14 on up to two lines inside the button's own height, so nothing moves, folds or scrolls
     between arm and disarm. */
  #study-panel .session-controls #timer-end[data-label] { padding: 0 var(--ui-s-2); font-size: var(--ui-fs-14); line-height: 1.25; text-wrap: balance; }
}
/* A 320-wide phone: the cell is ~140 wide, so app.js shows the shorter "Finish anyway? Earns
   nothing" (two lines at 14; the accessible name keeps the whole sentence). */
@media (max-height: 600px) and (max-width: 360px) {
  #study-panel .session-controls #timer-end[data-label] { padding: 0 var(--ui-s-1); }
}

/* ---------- Journal (UX-006 B3, UI-V2 §4 B3): the level strip, Journey, Quests and Backpack ----------
   One card style for the whole sheet: flat and sunk (the Focus stat cards' recipe), 12 16
   padding, 8 inside, 12 between cards. Type: 20 (the sheet title), 16 (card titles, the goal,
   the level), 14 (everything else); counts are the Badge component. One primary per tab:
   "Show me" on the next step (Journey) or "Claim" on a finished quest (Quests).
   Ids and classes stay as src/app.js, play.js and player-journal.js write them. */

/* The level strip (the sheet's banner): line 1 the level and rank beside a 20-block pixel
   meter, line 2 the XP to the next level (Outfit 14, tabular), line 3 what it unlocks. The
   meter's blocks are --level-step wide (2 of them gap), so whole blocks fill: app.js sets
   #xp-fill in steps of 5 % (one block). */
.journey-strip {
  display: grid;
  gap: var(--ui-s-1);
  margin: 0;
  padding: var(--ui-s-3) var(--ui-s-4);
  color: var(--ui-ink);
  background: var(--ui-surface-sunk);
  border: 0;
  border-radius: 0;
  box-shadow: inset 0 0 0 var(--ui-px) var(--ui-surface-shade);
}
.journey-head { display: flex; align-items: center; gap: var(--ui-s-3); min-width: 0; }
.journey-head .level-line { display: flex; flex: 1 1 auto; align-items: baseline; gap: var(--ui-s-1); min-width: 0; overflow: hidden; white-space: nowrap; }
.journey-head :is(#level-title, #level-rank) { color: var(--ui-ink); font-family: var(--ui-font-display); font-size: var(--ui-fs-16); font-weight: 600; line-height: 1.25; letter-spacing: 0; }
#level-title { flex: none; }
#level-rank { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.level-meter {
  --level-step: 8px;
  display: block;
  flex: none;
  width: calc(var(--level-step) * 20);
  height: 12px;
  margin-left: auto;
  padding: var(--ui-px) 0 var(--ui-px) var(--ui-px);
  background: var(--ui-sheet-bg);
  box-shadow: var(--ui-frame-edge);
}
.level-meter-blocks {
  display: block;
  height: 100%;
  background: var(--ui-surface-shade);
  -webkit-mask: repeating-linear-gradient(90deg, black 0 calc(var(--level-step) - var(--ui-px)), transparent calc(var(--level-step) - var(--ui-px)) var(--level-step));
  mask: repeating-linear-gradient(90deg, black 0 calc(var(--level-step) - var(--ui-px)), transparent calc(var(--level-step) - var(--ui-px)) var(--level-step));
}
#xp-fill { display: block; width: 0; height: 100%; background: var(--ui-success); border-radius: 0; transition: width var(--ui-dur-slow) var(--ui-ease-out); }
/* Line 2: the XP to go on the left, the totals on the right (under it when there is no room). */
.journey-score { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0 var(--ui-s-3); min-width: 0; }
#journey-detail { min-width: 0; color: var(--ui-ink-muted); font-family: var(--ui-font-body); font-size: var(--ui-fs-14); line-height: 1.25; font-variant-numeric: tabular-nums; white-space: nowrap; }
#xp-total { display: block; max-width: 100%; overflow: hidden; color: var(--ui-ink); font-family: var(--ui-font-body); font-size: var(--ui-fs-14); font-weight: 600; line-height: 1.25; letter-spacing: 0; font-variant-numeric: tabular-nums; white-space: nowrap; text-overflow: ellipsis; }
.journey-meta { margin: 0; color: var(--ui-ink-muted); font-family: var(--ui-font-body); font-size: var(--ui-fs-14); line-height: 1.5; font-variant-numeric: tabular-nums; }
@media (max-width: 720px) { .level-meter { --level-step: 6px; } }
@media (prefers-reduced-motion: reduce) { #xp-fill { transition: none; } }

/* The panel: a column of cards, 12 apart. Loose copy (the Study tab's lines) sits between them. */
#player-journal .journal-content { display: grid; gap: var(--ui-s-3); padding: 0; background: none; border: 0; border-radius: 0; box-shadow: none; }
#player-journal .journal-content > p { margin: 0; color: var(--ui-ink); font-family: var(--ui-font-body); font-size: var(--ui-fs-14); line-height: 1.5; }
#player-journal .journal-content > h3 { margin: var(--ui-s-2) 0 0; }
#player-journal .journal-content > .btn { justify-self: start; max-width: 100%; }
#player-journal .journal-lead { margin: 0; color: var(--ui-ink-muted); }

/* The card. */
#quest-list .quest-row {
  display: grid;
  gap: var(--ui-s-2);
  min-width: 0;
  margin: 0;
  padding: var(--ui-s-3) var(--ui-s-4);
  color: var(--ui-ink);
  background: var(--ui-surface-sunk);
  border: 0;
  border-radius: 0;
  box-shadow: inset 0 0 0 var(--ui-px) var(--ui-surface-shade);
}
#player-journal .journal-card { gap: var(--ui-s-2); }
#player-journal :is(.journal-card, .journal-content) h3, #quest-list .quest-row strong {
  margin: 0;
  color: var(--ui-ink);
  font-family: var(--ui-font-display);
  font-size: var(--ui-fs-16);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: 0;
}
#player-journal .journal-card p { margin: 0; color: var(--ui-ink); font-family: var(--ui-font-body); font-size: var(--ui-fs-14); line-height: 1.5; }
#player-journal .journal-card .journal-detail { color: var(--ui-ink-muted); }
#player-journal .journal-card .journal-goal { font-size: var(--ui-fs-16); font-weight: 600; line-height: 1.25; }
#player-journal .journal-card > .btn { justify-self: start; max-width: 100%; margin-top: var(--ui-s-1); }
#player-journal .journal-card details { font-family: var(--ui-font-body); font-size: var(--ui-fs-14); line-height: 1.5; }
#player-journal .journal-card summary { display: flex; align-items: center; min-height: var(--ui-s-6); color: var(--ui-ink); font-family: var(--ui-font-body); font-size: var(--ui-fs-14); font-weight: 600; cursor: pointer; }
#player-journal .journal-card summary:focus-visible { outline: var(--ui-focus-ring-w) solid var(--ui-focus-ring); outline-offset: var(--ui-px); }
#player-journal .journal-card details p { margin-bottom: var(--ui-s-2); color: var(--ui-ink-muted); }
#player-journal .relationship-memory { margin: 0; padding: 0 0 0 var(--ui-s-3); color: var(--ui-ink-muted); font-family: var(--ui-font-body); font-size: var(--ui-fs-14); line-height: 1.5; background: none; border: 0; border-radius: 0; box-shadow: inset calc(var(--ui-px) * 2) 0 0 0 var(--ui-surface-shade); }

/* Rows inside a card (supplies, the pond guide, finds, souvenirs): the name, a value on
   the right (tabular), an optional meta line; 1 UI px rules between them. */
#player-journal .journal-rows { display: grid; margin: 0; padding: 0; list-style: none; }
#player-journal .journal-rows li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  column-gap: var(--ui-s-3);
  row-gap: var(--ui-px);
  margin: 0;
  padding: var(--ui-s-2) 0;
  background: none;
  border: 0;
  border-radius: 0;
  box-shadow: inset 0 calc(var(--ui-px) * -1) 0 0 var(--ui-surface-shade);
  font-family: var(--ui-font-body);
  font-size: var(--ui-fs-14);
  line-height: 1.5;
}
#player-journal .journal-rows li:first-child { padding-top: 0; }
#player-journal .journal-rows li:last-child { padding-bottom: 0; box-shadow: none; }
.journal-row-name { min-width: 0; color: var(--ui-ink); font-weight: 600; }
.journal-row-value { color: var(--ui-ink); font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
.journal-rows li.is-missing .journal-row-value { color: var(--ui-ink-muted); font-weight: 400; }
.journal-rows li.is-missing .journal-row-name { font-weight: 400; }
#player-journal .journal-row-meta { grid-column: 1 / -1; color: var(--ui-ink-muted); font-size: var(--ui-fs-14); line-height: 1.5; }

/* The bag: an even grid of square slots (inverted bevel, like an input), at least 72 wide
   (44 is the floor), the decoration drawn 2x and its count as a Badge. The chosen slot wears
   the selected tab's flat peach; its name, or the hovered or focused one's, is the one line
   under the grid. */
#player-journal .bag-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: var(--ui-s-2); margin: 0; padding: 0; list-style: none; }
#player-journal .bag-grid li { display: block; min-width: 0; margin: 0; padding: 0; }
.bag-slot {
  position: relative;
  display: grid;
  place-items: center;
  box-sizing: border-box;
  width: 100%;
  min-width: var(--ui-target);
  min-height: var(--ui-target);
  aspect-ratio: 1;
  margin: 0;
  padding: 0;
  color: var(--ui-ink);
  background: var(--ui-frame-fill);
  border: 0;
  border-radius: 0;
  box-shadow:
    inset var(--ui-px) var(--ui-px) 0 0 var(--ui-surface-shade),
    inset calc(var(--ui-px) * -1) calc(var(--ui-px) * -1) 0 0 var(--ui-surface-hi),
    var(--ui-frame-edge);
  cursor: pointer;
  transition: background-color var(--ui-dur-fast) var(--ui-ease-out), transform var(--ui-dur-fast) var(--ui-ease-out);
}
.bag-slot canvas { display: block; width: 64px; height: 64px; image-rendering: pixelated; pointer-events: none; }
.bag-slot .bag-qty { position: absolute; right: var(--ui-s-1); bottom: var(--ui-s-1); pointer-events: none; }
.bag-slot:hover { background: var(--ui-secondary-hover); }
.bag-slot:active { transform: translateY(var(--ui-press)); }
.bag-slot[aria-pressed="true"] {
  background: var(--ui-selected);
  box-shadow:
    inset var(--ui-px) var(--ui-px) 0 0 var(--ui-surface-hi),
    inset calc(var(--ui-px) * -1) calc(var(--ui-px) * -1) 0 0 var(--ui-coin-deep),
    var(--ui-frame-edge);
}
.bag-slot:focus-visible { z-index: 1; outline: var(--ui-focus-ring-w) solid var(--ui-focus-ring); outline-offset: var(--ui-px); }
.bag-slot:disabled { background: var(--ui-disabled-bg); cursor: not-allowed; }
#player-journal .bag-detail { overflow: hidden; color: var(--ui-ink-muted); white-space: nowrap; text-overflow: ellipsis; }
#player-journal .bag-detail strong { color: var(--ui-ink); font-weight: 600; }

/* Quests: the same cards, the copy on the left and one action on the right. A finished
   quest's Claim is the panel's primary; Show me is secondary; a paid one says Done. */
#quest-list { display: grid; gap: var(--ui-s-3); }
#quest-list .quest-intro { margin: 0; color: var(--ui-ink-muted); font-family: var(--ui-font-body); font-size: var(--ui-fs-14); line-height: 1.5; }
#quest-list .quest-row { grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: var(--ui-s-3); }
#quest-list .quest-row > div { display: grid; gap: var(--ui-s-1); min-width: 0; }
#quest-list .quest-row strong { display: block; }
#quest-list .quest-row small { display: block; margin: 0; color: var(--ui-ink-muted); font-family: var(--ui-font-body); font-size: var(--ui-fs-14); line-height: 1.25; }
#quest-list .quest-row .quest-reward { display: inline-flex; align-items: center; gap: var(--ui-s-1); color: var(--ui-ink); font-variant-numeric: tabular-nums; }
#quest-list .quest-reward .px { --px-size: 14px; color: var(--ui-coin-deep); }
#quest-list .quest-row.ready { box-shadow: inset 0 0 0 var(--ui-px) var(--ui-surface-shade), inset calc(var(--ui-px) * 2) 0 0 0 var(--ui-success); }
#quest-list .quest-row.claimed { background: transparent; }
#quest-list .quest-row.claimed strong { color: var(--ui-ink-muted); }
#quest-list .quest-done { display: inline-flex; align-items: center; gap: var(--ui-s-1); color: var(--ui-ink); font-family: var(--ui-font-body); font-size: var(--ui-fs-14); font-weight: 600; }
#quest-list .quest-done .px { --px-size: 14px; color: var(--ui-accent); }

/* Phones: the next step's primary runs the card's width, in thumb reach. */
@media (max-width: 600px) {
  #player-journal .journal-next > .btn--primary { justify-self: stretch; }
}

/* ---------- Together (UX-006 B4, UI-V2 §4 B6): Rooms, In this room, Neighbours ----------
   The Journal's recipe: flat sunk cards (12 16 padding, 1 UI px shade line), the tab's title
   (Pixelify 20) naming the tab, card titles and names Pixelify 16, everything else Outfit 14
   or 16. One primary per view: Rooms › Join a room "Join the Fern & Bean café", Create a room
   "Create room", Servers "Connect"; In this room "Invite a friend"; Neighbours the first
   neighbour you haven't met. Room cards' Join, Leave room, Block and Report are secondary or
   ghost. Choices (the three views, the study mode) are the Focus presets' segmented row.
   Ids stay as src/multiplayer-ui.js, room-preferences.js, play.js and the tests know them. */

/* Segmented control: a sunk track holding segments that behave like tabs (aria-pressed),
   Outfit 16/600 muted; the chosen one wears the selected tab's flat peach. 36 tall (44 on
   touch and phones). Segments size to their words first, so "Create a room" keeps one line. */
.segmented {
  display: flex;
  gap: var(--ui-s-1);
  margin: 0;
  padding: var(--ui-s-1);
  background: var(--ui-surface-sunk);
  border: 0;
  border-radius: 0;
  box-shadow:
    inset var(--ui-px) var(--ui-px) 0 0 var(--ui-surface-shade),
    inset calc(var(--ui-px) * -1) calc(var(--ui-px) * -1) 0 0 var(--ui-surface-hi);
}
.segmented > button {
  display: inline-flex;
  flex: 1 1 auto;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  height: 36px;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0 var(--ui-s-2);
  background: transparent;
  color: var(--ui-tab-ink);
  border: 0;
  border-radius: 0;
  box-shadow: none;
  font-family: var(--ui-font-body);
  font-size: var(--ui-fs-16);
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color var(--ui-dur-fast) var(--ui-ease-out), color var(--ui-dur-fast) var(--ui-ease-out), transform var(--ui-dur-fast) var(--ui-ease-out);
}
.segmented > button:hover:not(:disabled, [aria-pressed="true"]) { background: var(--ui-secondary-hover); color: var(--ui-ink); }
.segmented > button:active:not(:disabled) { transform: translateY(var(--ui-press)); }
.segmented > button[aria-pressed="true"] {
  background: var(--ui-selected);
  color: var(--ui-ink-strong);
  box-shadow:
    inset var(--ui-px) var(--ui-px) 0 0 var(--ui-surface-hi),
    inset calc(var(--ui-px) * -1) calc(var(--ui-px) * -1) 0 0 var(--ui-coin-deep),
    var(--ui-frame-edge);
}
.segmented > button:focus-visible { position: relative; z-index: 1; outline: var(--ui-focus-ring-w) solid var(--ui-focus-ring); outline-offset: var(--ui-px); }
.segmented > button:disabled { color: var(--ui-disabled-ink); cursor: not-allowed; }
.segmented.mode-choice > button { flex: 1 1 0; }

/* Fields: a label (Outfit 14/600) over the Input component (the Focus task field). */
.ui-field { display: grid; gap: var(--ui-s-1); min-width: 0; }
:is(#sheet-host, #lobby-dialog, #room-presence) :is(.ui-field > label, .ui-label) {
  display: block;
  margin: 0;
  color: var(--ui-ink);
  font-family: var(--ui-font-body);
  font-size: var(--ui-fs-14);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: 0;
}
#lobby-dialog .ui-field > label.ui-label-row { display: flex; align-items: baseline; justify-content: space-between; gap: var(--ui-s-3); }
#lobby-dialog .ui-value { color: var(--ui-ink-muted); font-weight: 400; font-variant-numeric: tabular-nums; }
#lobby-dialog .ui-value b { color: var(--ui-ink); font-weight: 700; }
:is(#sheet-host, #lobby-dialog) .ui-hint { min-height: 1.5em; margin: 0; color: var(--ui-ink-muted); font-family: var(--ui-font-body); font-size: var(--ui-fs-14); line-height: 1.5; }
:is(#sheet-host, #lobby-dialog) .ui-input {
  box-sizing: border-box;
  width: 100%;
  height: 40px;
  min-height: 0;
  margin: 0;
  padding: 0 var(--ui-s-3);
  color: var(--ui-input-ink);
  background: var(--ui-frame-fill);
  border: 0;
  border-radius: 0;
  box-shadow:
    inset var(--ui-px) var(--ui-px) 0 0 var(--ui-surface-shade),
    inset calc(var(--ui-px) * -1) calc(var(--ui-px) * -1) 0 0 var(--ui-surface-hi),
    var(--ui-frame-edge);
  font-family: var(--ui-font-body);
  font-size: var(--ui-fs-16);
  line-height: 1;
}
:is(#sheet-host, #lobby-dialog) .ui-input::placeholder { color: var(--ui-ink-muted); opacity: 1; }
:is(#sheet-host, #lobby-dialog) .ui-input:focus-visible { outline: var(--ui-focus-ring-w) solid var(--ui-focus-ring); outline-offset: calc(var(--ui-px) * 2); }
:is(#sheet-host, #lobby-dialog) .ui-input:disabled { background: var(--ui-disabled-bg); color: var(--ui-disabled-ink); cursor: not-allowed; }
/* Select: the same field with a 3-step pixel chevron (the place card's) on the right. */
.ui-select { position: relative; display: block; min-width: 0; }
.ui-select::after {
  content: "";
  position: absolute;
  top: 50%;
  right: var(--ui-s-3);
  width: calc(var(--ui-px) * 5);
  height: calc(var(--ui-px) * 3);
  margin-top: calc(var(--ui-px) * -1);
  background: var(--ui-ink-muted);
  clip-path: polygon(0 0, 100% 0, 100% 33.34%, 80% 33.34%, 80% 66.67%, 60% 66.67%, 60% 100%, 40% 100%, 40% 66.67%, 20% 66.67%, 20% 33.34%, 0 33.34%);
  pointer-events: none;
}
.ui-select:hover::after { background: var(--ui-ink); }
:is(#sheet-host, #lobby-dialog) .ui-select select { -webkit-appearance: none; appearance: none; padding-right: var(--ui-s-6); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
/* Range: a sunk 8 px track that fills in the success green up to the thumb (--fill, set by
   the page), and a 16 x 24 cocoa thumb in a 1 UI px frame. */
#lobby-dialog .ui-range, #room-presence .room-preferences input[type="range"] {
  --fill: 50%;
  -webkit-appearance: none;
  appearance: none;
  display: block;
  box-sizing: border-box;
  width: 100%;
  height: var(--ui-s-6);
  min-height: 0;
  margin: 0;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  cursor: pointer;
}
#lobby-dialog .ui-range::-webkit-slider-runnable-track, #room-presence .room-preferences input[type="range"]::-webkit-slider-runnable-track {
  height: var(--ui-s-2);
  background: linear-gradient(to right, var(--ui-success) var(--fill), var(--ui-surface-shade) var(--fill));
  box-shadow: var(--ui-frame-edge);
}
#lobby-dialog .ui-range::-moz-range-track, #room-presence .room-preferences input[type="range"]::-moz-range-track {
  height: var(--ui-s-2);
  background: linear-gradient(to right, var(--ui-success) var(--fill), var(--ui-surface-shade) var(--fill));
  box-shadow: var(--ui-frame-edge);
}
#lobby-dialog .ui-range::-webkit-slider-thumb, #room-presence .room-preferences input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: var(--ui-s-4);
  height: var(--ui-s-5);
  margin-top: calc(var(--ui-s-2) * -1);
  background: var(--ui-button-primary-bg);
  border: 0;
  border-radius: 0;
  box-shadow: inset var(--ui-px) var(--ui-px) 0 0 var(--ui-primary-hover), var(--ui-frame-edge);
}
#lobby-dialog .ui-range::-moz-range-thumb, #room-presence .room-preferences input[type="range"]::-moz-range-thumb {
  width: var(--ui-s-4);
  height: var(--ui-s-5);
  background: var(--ui-button-primary-bg);
  border: 0;
  border-radius: 0;
  box-shadow: inset var(--ui-px) var(--ui-px) 0 0 var(--ui-primary-hover), var(--ui-frame-edge);
}
:is(#lobby-dialog .ui-range, #room-presence .room-preferences input[type="range"]):focus-visible { outline: var(--ui-focus-ring-w) solid var(--ui-focus-ring); outline-offset: var(--ui-px); }
:is(#lobby-dialog .ui-range, #room-presence .room-preferences input[type="range"]):disabled { cursor: not-allowed; opacity: 1; }
:is(#lobby-dialog .ui-range, #room-presence .room-preferences input[type="range"]):hover::-webkit-slider-thumb { background: var(--ui-primary-hover); }
:is(#lobby-dialog .ui-range, #room-presence .room-preferences input[type="range"]):hover::-moz-range-thumb { background: var(--ui-primary-hover); }

/* Rooms: the account line, the views' switch, then the view (a column 12 apart). */
#lobby-dialog .together-account {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--ui-s-2) var(--ui-s-3);
  min-height: var(--ui-s-7);
  box-sizing: border-box;
}
/* The connection: an 8 px square, green when connected, peach while connecting, muted otherwise. */
.together-dot { flex: none; width: var(--ui-s-2); height: var(--ui-s-2); background: var(--ui-ink-muted); box-shadow: 0 0 0 var(--ui-px) var(--ui-line); }
.together-account:is([data-status="connected"], [data-status="joined"]) .together-dot { background: var(--ui-success); }
.together-account:is([data-status="connecting"], [data-status="joining"], [data-status="reconnecting"]) .together-dot { background: var(--ui-warning); }
.together-account[data-status="error"] .together-dot { background: var(--ui-danger); }
/* Connected: the Discord sign-in has nothing left to do. */
.together-account:is([data-status="connected"], [data-status="joined"], [data-status="joining"]) #discord-auth-link { display: none; }
#lobby-dialog #google-auth-status { flex: 1 1 12em; min-width: 0; margin: 0; padding: var(--ui-s-2) 0; color: var(--ui-ink); font-family: var(--ui-font-body); font-size: var(--ui-fs-14); line-height: 1.25; }
#lobby-dialog #google-signin-button:empty { display: none; }
#lobby-dialog .together-account .btn { flex: none; }
#lobby-dialog #discord-auth-link { text-decoration: none; }
#lobby-dialog .lobby-tabs { margin: 0 0 var(--ui-s-4); }
#lobby-dialog .lobby-content:not([hidden]) { display: grid; gap: var(--ui-s-3); }
#lobby-dialog .lobby-lead { margin: 0; color: var(--ui-ink-muted); font-family: var(--ui-font-body); font-size: var(--ui-fs-14); line-height: 1.5; }
#lobby-dialog .lobby-section { margin: var(--ui-s-1) 0 0; color: var(--ui-ink); font-family: var(--ui-font-display); font-size: var(--ui-fs-16); font-weight: 600; line-height: 1.25; letter-spacing: 0; }
#lobby-dialog .lobby-note { margin: 0; color: var(--ui-ink-muted); font-family: var(--ui-font-body); font-size: var(--ui-fs-14); line-height: 1.5; overflow-wrap: anywhere; }
#lobby-dialog .lobby-note b { color: var(--ui-ink); font-weight: 600; }
#lobby-dialog :is(.create-lobby-form, .server-form) { display: grid; gap: var(--ui-s-4); margin: 0; }
#lobby-dialog .create-lobby-form > .btn--primary { margin-top: var(--ui-s-1); }

/* Room cards: the name across the card (one line), one meta line, then the mode and tags as
   chips with Join at the end of the same row. The room you are in has a 2 UI px green edge. */
#lobby-dialog .lobby-list { display: grid; gap: var(--ui-s-2); }
#lobby-dialog .lobby-card {
  display: grid;
  gap: var(--ui-s-1);
  min-width: 0;
  margin: 0;
  padding: var(--ui-s-3) var(--ui-s-3) var(--ui-s-3) var(--ui-s-4);
  color: var(--ui-ink);
  background: var(--ui-surface-sunk);
  border: 0;
  border-radius: 0;
  box-shadow: inset 0 0 0 var(--ui-px) var(--ui-surface-shade);
}
#lobby-dialog .lobby-card[aria-current="true"] { box-shadow: inset 0 0 0 var(--ui-px) var(--ui-surface-shade), inset calc(var(--ui-px) * 2) 0 0 0 var(--ui-success); }
#lobby-dialog .lobby-title {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: var(--ui-ink);
  font-family: var(--ui-font-display);
  font-size: var(--ui-fs-16);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: 0;
  white-space: nowrap;
  text-overflow: ellipsis;
}
#lobby-dialog .lobby-meta { margin: 0; color: var(--ui-ink-muted); font-family: var(--ui-font-body); font-size: var(--ui-fs-14); line-height: 1.25; font-variant-numeric: tabular-nums; }
#lobby-dialog .lobby-foot { display: flex; align-items: flex-end; gap: var(--ui-s-3); margin-top: var(--ui-s-1); }
#lobby-dialog .lobby-tags { display: flex; flex: 1 1 auto; flex-wrap: wrap; gap: var(--ui-s-1); min-width: 0; margin: 0; padding: 0; list-style: none; }
#lobby-dialog .lobby-tags li { display: inline-flex; margin: 0; }
#lobby-dialog .lobby-tag {
  align-items: center;
  gap: var(--ui-s-1);
  box-sizing: border-box;
  height: var(--ui-s-5);
  padding: 0 var(--ui-s-2);
  color: var(--ui-ink);
  background: var(--ui-surface);
  border-radius: var(--ui-r-pill);
  box-shadow: inset 0 0 0 var(--ui-px) var(--ui-surface-shade);
  font-family: var(--ui-font-body);
  font-size: var(--ui-fs-14);
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
}
#lobby-dialog .lobby-tag .ico { color: var(--ui-ink-muted); }
#lobby-dialog .lobby-tags .staff-ai-tag { align-self: center; }
#lobby-dialog .join-btn { flex: none; }

/* Empty: one line and one action, centred in a sunk card, a 28 px pixel icon on top. */
.together-empty {
  display: grid;
  justify-items: center;
  gap: var(--ui-s-2);
  padding: var(--ui-s-4);
  color: var(--ui-ink);
  background: var(--ui-surface-sunk);
  box-shadow: inset 0 0 0 var(--ui-px) var(--ui-surface-shade);
  text-align: center;
}
.together-empty .ico { --ico: 28px; color: var(--ui-ink-muted); }
.together-empty p { margin: 0; font-family: var(--ui-font-body); font-size: var(--ui-fs-14); line-height: 1.5; }

/* In this room: who is focusing (one meta line), one card of people rows, then the actions
   (Invite a friend, the view's one primary, beside Leave room) and the quiet preferences. */
#room-presence { position: static; margin: 0; padding: 0; background: none; border: 0; box-shadow: none; }
#room-presence:not([hidden]) { display: grid; gap: var(--ui-s-3); }
#room-presence .presence-summary { margin: 0; color: var(--ui-ink-muted); font-family: var(--ui-font-body); font-size: var(--ui-fs-14); line-height: 1.5; font-variant-numeric: tabular-nums; }
/* People and neighbours: one sunk card; rows 12 tall padding, a 1 UI px shade rule between. */
:is(#presence-players, #people-list) {
  display: grid;
  margin: 0;
  padding: 0 var(--ui-s-3) 0 var(--ui-s-4);
  background: var(--ui-surface-sunk);
  box-shadow: inset 0 0 0 var(--ui-px) var(--ui-surface-shade);
}
:is(#presence-players .presence-player, #people-list .person-row) {
  display: grid;
  align-items: center;
  column-gap: var(--ui-s-3);
  row-gap: var(--ui-s-1);
  min-width: 0;
  margin: 0;
  padding: var(--ui-s-3) 0;
  color: var(--ui-ink);
  background: none;
  border: 0;
  border-radius: 0;
  box-shadow: inset 0 calc(var(--ui-px) * -1) 0 0 var(--ui-surface-shade);
}
:is(#presence-players .presence-player, #people-list .person-row):last-child { box-shadow: none; }
#presence-players .presence-player { grid-template-columns: 32px minmax(0, 1fr) auto; }
#people-list .person-row { grid-template-columns: 48px minmax(0, 1fr) auto; }
/* Sprites drawn 2x (whole pixels), scaled round the figure so it fills the lead column; the
   canvas keeps its 1x box in the layout and lets clicks through. */
:is(#presence-players .presence-player, #people-list .person-row) canvas { display: block; image-rendering: pixelated; background: none; border-radius: 0; transform: scale(2); pointer-events: none; }
#presence-players .presence-player canvas { width: 32px; height: 34px; margin: var(--ui-s-3) 0; transform-origin: 50% 50%; }
#people-list .person-row canvas { width: 48px; height: 44px; margin: var(--ui-s-2) 0; transform-origin: 50% 50%; }
:is(#presence-players .presence-player, #people-list .person-row) > div { display: grid; gap: var(--ui-px); min-width: 0; }
:is(#presence-players .presence-player, #people-list .person-row) strong {
  display: block;
  overflow: hidden;
  color: var(--ui-ink);
  font-family: var(--ui-font-display);
  font-size: var(--ui-fs-16);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: 0;
  white-space: nowrap;
  text-overflow: ellipsis;
}
:is(#presence-players .presence-player, #people-list .person-row) small {
  display: block;
  margin: 0;
  overflow: hidden;
  color: var(--ui-ink-muted);
  font-family: var(--ui-font-body);
  font-size: var(--ui-fs-14);
  line-height: 1.25;
  white-space: nowrap;
  text-overflow: ellipsis;
}
/* Status: a chip with a square dot (green focused, peach paused or on a break, muted otherwise). */
#presence-players .presence-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--ui-s-2);
  box-sizing: border-box;
  height: var(--ui-s-5);
  max-width: 100%;
  padding: 0 var(--ui-s-2);
  overflow: hidden;
  color: var(--ui-ink);
  background: var(--ui-surface);
  border-radius: var(--ui-r-pill);
  box-shadow: inset 0 0 0 var(--ui-px) var(--ui-surface-shade);
  font-family: var(--ui-font-body);
  font-size: var(--ui-fs-14);
  font-weight: 500;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  text-overflow: ellipsis;
}
#presence-players .presence-badge::before { content: ""; flex: none; width: var(--ui-s-2); height: var(--ui-s-2); background: var(--ui-ink-muted); }
#presence-players .presence-player[data-status="focused"] .presence-badge::before { background: var(--ui-success); }
#presence-players .presence-player:is([data-status="paused"], [data-status="resting"], [data-status="review"]) .presence-badge::before { background: var(--ui-warning); }
#presence-players .presence-player[data-status="offline"] { opacity: .65; }
/* Block and Report (ghost) under the name, at the row's end. */
#presence-players .peer-controls { display: flex; grid-column: 2 / -1; justify-content: flex-end; align-items: center; gap: var(--ui-s-1); min-width: 0; }
#presence-players .peer-controls:empty { display: none; }
#room-presence .presence-actions { display: flex; flex-wrap: wrap; gap: var(--ui-s-2); }
#room-presence .presence-actions .btn--primary { flex: 1 1 auto; }

/* Quiet room preferences: a disclosure under a 1 UI px rule (the Focus extras' recipe). */
#room-presence .room-preferences { margin: 0; padding: 0; background: none; border: 0; border-radius: 0; box-shadow: inset 0 var(--ui-px) 0 0 var(--ui-surface-shade); color: var(--ui-ink); font-family: var(--ui-font-body); font-size: var(--ui-fs-14); line-height: 1.5; }
#room-presence .room-preferences summary { display: flex; align-items: center; gap: var(--ui-s-2); min-height: 40px; padding-top: var(--ui-px); color: var(--ui-ink); font-family: var(--ui-font-body); font-size: var(--ui-fs-14); font-weight: 600; line-height: 1.25; list-style: none; cursor: pointer; transition: color var(--ui-dur-fast) var(--ui-ease-out); }
#room-presence .room-preferences summary::-webkit-details-marker { display: none; }
/* The disclosure mark: the place card's 3-step pixel chevron, pointing right while closed. */
#room-presence .room-preferences summary::before {
  content: "";
  flex: none;
  width: calc(var(--ui-px) * 5);
  height: calc(var(--ui-px) * 3);
  background: currentColor;
  clip-path: polygon(0 0, 100% 0, 100% 33.34%, 80% 33.34%, 80% 66.67%, 60% 66.67%, 60% 100%, 40% 100%, 40% 66.67%, 20% 66.67%, 20% 33.34%, 0 33.34%);
  transform: rotate(-90deg);
  transition: transform var(--ui-dur-fast) var(--ui-ease-out);
}
#room-presence .room-preferences[open] summary::before { transform: none; }
#room-presence .room-preferences summary:hover { color: var(--ui-ink-strong); }
#room-presence .room-preferences summary:focus-visible { outline: var(--ui-focus-ring-w) solid var(--ui-focus-ring); outline-offset: var(--ui-px); }
#room-presence .room-preferences > label { display: flex; align-items: center; gap: var(--ui-s-2); min-height: 40px; margin: 0; color: var(--ui-ink); font-family: var(--ui-font-body); font-size: var(--ui-fs-14); font-weight: 400; line-height: 1.25; cursor: pointer; }
#room-presence .room-preferences > label:has(input[type="range"]) { display: grid; gap: var(--ui-s-1); padding-bottom: var(--ui-s-2); }
#room-presence .room-preferences input[type="checkbox"] { flex: none; width: 20px; height: 20px; margin: 0; accent-color: var(--ui-accent); }
#room-presence .room-preferences input[type="checkbox"]:focus-visible { outline: var(--ui-focus-ring-w) solid var(--ui-focus-ring); outline-offset: var(--ui-px); }
#room-presence .room-preferences p { margin: 0 0 var(--ui-s-2); color: var(--ui-ink-muted); font-size: var(--ui-fs-14); line-height: 1.5; }
#room-presence .room-preferences p .btn { margin-left: var(--ui-s-2); }

/* Touch and phones: 44 px segments, fields and preference rows; the presence actions run
   the width, the primary first. */
@media (pointer: coarse), (max-width: 600px) {
  .segmented > button { height: var(--ui-target); }
  :is(#sheet-host, #lobby-dialog) .ui-input { height: var(--ui-target); }
  #lobby-dialog .ui-range, #room-presence .room-preferences input[type="range"] { height: var(--ui-target); }
  #room-presence .room-preferences summary, #room-presence .room-preferences > label { min-height: var(--ui-target); }
}
@media (max-width: 600px) {
  #room-presence .presence-actions .btn { flex: 1 1 0; }
}
@media (prefers-reduced-motion: reduce) {
  #room-presence .room-preferences summary::before { transition: none; }
}

/* ---------- Adventure (UX-006 B5, UI-V2 §4 B4; UX-116): Rifts, Pet, Monsters and Games ----------
   The Journal's and Together's recipe on every tab: flat sunk cards (12 16 padding, a 1 UI px
   shade line, no frames inside the sheet's frame, no offset shadows), the tab's title naming
   the tab (Pixelify 20), section and card titles Pixelify 16, everything else Outfit 14. One
   primary per view: Rifts the first rift (or unbeaten lair) you can go to with a charge, or
   "Focus to earn charges" when there is none; Pet "Pat"; Monsters and Games none (their
   tiles and rows are the actions). Charges and the Monster Book are calm strips: "N of M"
   (Outfit 14 tabular) beside a small block meter, the hint under it in muted ink.
   Ids and classes stay as src/dungeon-ui.js, leisure-ui.js, ui-shell.js and the tests know them. */
:is(#rifts-dialog, #monsters-dialog, #play-dialog) .dialog-intro { max-width: none; margin: 0 0 var(--ui-s-4); color: var(--ui-ink-muted); font-family: var(--ui-font-body); font-size: var(--ui-fs-14); line-height: 1.5; }

/* The block meter: --blocks blocks --step wide (one UI px gap), a shade track and a fill
   that covers whole blocks (its width is a share of the track). */
.block-meter {
  --step: 8px;
  --blocks: 20;
  position: relative;
  display: block;
  flex: none;
  box-sizing: content-box;
  width: calc(var(--step) * var(--blocks) - var(--ui-px));
  height: var(--ui-s-2);
  margin: 0;
  padding: var(--ui-px);
  overflow: hidden;
  background: var(--ui-sheet-bg);
  border: 0;
  border-radius: 0;
  box-shadow: var(--ui-frame-edge);
}
.block-meter::before, .block-meter > span {
  -webkit-mask: repeating-linear-gradient(90deg, black 0 calc(var(--step) - var(--ui-px)), transparent calc(var(--step) - var(--ui-px)) var(--step));
  mask: repeating-linear-gradient(90deg, black 0 calc(var(--step) - var(--ui-px)), transparent calc(var(--step) - var(--ui-px)) var(--step));
}
.block-meter::before { content: ""; position: absolute; inset: var(--ui-px); background: var(--ui-surface-shade); }
.block-meter > span { position: relative; display: block; width: 0; height: 100%; background: var(--ui-success); border-radius: 0; transition: width var(--ui-dur-slow) var(--ui-ease-out); }

/* Strips: the charges (Rifts) and the Monster Book's progress. */
:is(#rifts-dialog .energy-card, #monsters-dialog .book-strip) {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--ui-s-1) var(--ui-s-3);
}
.energy-top { display: flex; grid-column: 1 / -1; align-items: center; gap: var(--ui-s-2); min-width: 0; }
.energy-top > .px { --px-size: 14px; color: var(--ui-coin-deep); }
#monsters-dialog .energy-top > .px { color: var(--ui-ink-muted); }
:is(.energy-count, .book-count) { flex: 1 1 auto; min-width: 0; overflow: hidden; color: var(--ui-ink); font-family: var(--ui-font-body); font-size: var(--ui-fs-14); font-weight: 700; line-height: 1.25; font-variant-numeric: tabular-nums; white-space: nowrap; text-overflow: ellipsis; }
.energy-next { margin: 0; color: var(--ui-ink-muted); font-family: var(--ui-font-body); font-size: var(--ui-fs-14); line-height: 1.5; font-variant-numeric: tabular-nums; }
#rifts-dialog .energy-card .energy-focus { grid-column: 2; grid-row: 2; }
#rifts-dialog .energy-card .energy-focus.btn--primary { grid-column: 1 / -1; grid-row: auto; justify-self: start; margin-top: var(--ui-s-2); }
#rifts-dialog .energy-card.empty .energy-top > .px { color: var(--ui-ink-muted); }
/* The charges meter: one 12 px block per charge (also on the card at a dungeon's door); a full
   one is a gold coin of a block, lit on top. */
.energy-pips { display: inline-flex; flex: none; gap: var(--ui-px); margin-left: auto; padding: var(--ui-px); background: var(--ui-sheet-bg); box-shadow: var(--ui-frame-edge); }
.energy-pip { display: block; width: var(--ui-s-3); height: var(--ui-s-3); background: var(--ui-surface-shade); border: 0; border-radius: 0; box-shadow: none; }
.energy-pip.full { background: var(--ui-coin); box-shadow: inset 0 var(--ui-px) 0 0 var(--ui-surface-hi), inset 0 calc(var(--ui-px) * -1) 0 0 var(--ui-coin-deep); }
#monsters-dialog .book-meter { --step: 8px; margin-left: auto; }

/* Section headings: Pixelify 16, 24 above, 8 below (a chip may follow the words). */
:is(#rifts-dialog .dungeon-heading, #monsters-dialog .monster-world h3, #pet-lounge-dialog .pet-group-label, #play-dialog .games-heading) {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--ui-s-2);
  margin: var(--ui-s-5) 0 var(--ui-s-2);
  color: var(--ui-ink);
  font-family: var(--ui-font-display);
  font-size: var(--ui-fs-16);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: 0;
}
#play-dialog .dialog-intro + .games-heading { margin-top: 0; }

/* Lists as one sunk card of rows: a 28 px icon or 48 px art, the copy, one action or chip on
   the right; a 1 UI px shade rule between rows. */
:is(#rifts-dialog .dungeon-list, #monsters-dialog .monster-grid, #play-dialog #badges-list) {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0 var(--ui-s-3) 0 var(--ui-s-4);
  list-style: none;
  background: var(--ui-surface-sunk);
  border: 0;
  border-radius: 0;
  box-shadow: inset 0 0 0 var(--ui-px) var(--ui-surface-shade);
}
:is(#rifts-dialog .dungeon-row, #monsters-dialog .monster-card, #play-dialog .milestone-badge) {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  column-gap: var(--ui-s-3);
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: var(--ui-s-3) 0;
  color: var(--ui-ink);
  background: none;
  border: 0;
  border-radius: 0;
  box-shadow: inset 0 calc(var(--ui-px) * -1) 0 0 var(--ui-surface-shade);
  text-align: left;
}
:is(#rifts-dialog .dungeon-row, #monsters-dialog .monster-card, #play-dialog .milestone-badge):last-child { box-shadow: none; }
#rifts-dialog .dungeon-row > .px { --px-size: 28px; color: var(--ui-ink); }
#rifts-dialog .lair-list .dungeon-row > .px { color: var(--ui-coin-deep); }
#rifts-dialog .dungeon-row.is-done > .px { color: var(--ui-accent); }
#rifts-dialog .dungeon-row.is-locked > .px { color: var(--ui-ink-muted); }
#rifts-dialog .dungeon-row.gleams { box-shadow: inset calc(var(--ui-px) * 2) 0 0 0 var(--ui-coin), inset 0 calc(var(--ui-px) * -1) 0 0 var(--ui-surface-shade); padding-left: var(--ui-s-3); margin-left: calc(var(--ui-s-3) * -1); }
#rifts-dialog .dungeon-copy { display: grid; gap: var(--ui-px); min-width: 0; }
:is(#rifts-dialog .dungeon-copy strong, #monsters-dialog .monster-copy strong) {
  display: block;
  overflow: hidden;
  color: var(--ui-ink);
  font-family: var(--ui-font-display);
  font-size: var(--ui-fs-16);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: 0;
  white-space: nowrap;
  text-overflow: ellipsis;
}
:is(#rifts-dialog .dungeon-copy small, #monsters-dialog :is(.monster-meta, .monster-lore)) { display: block; margin: 0; color: var(--ui-ink-muted); font-family: var(--ui-font-body); font-size: var(--ui-fs-14); line-height: 1.25; }
#rifts-dialog .dungeon-copy .dungeon-lock { color: var(--ui-ink); }
#rifts-dialog .dungeon-copy .dungeon-gleam { display: inline-flex; align-items: center; gap: var(--ui-s-1); color: var(--ui-ink); font-weight: 600; }
#rifts-dialog .dungeon-gleam .px { --px-size: 14px; color: var(--ui-coin-deep); }
#rifts-dialog .dungeon-row.is-done .dungeon-copy strong { color: var(--ui-ink-muted); }
#rifts-dialog .dungeon-note { margin: var(--ui-s-2) 0 0; color: var(--ui-ink-muted); font-family: var(--ui-font-body); font-size: var(--ui-fs-14); line-height: 1.5; }
#rifts-dialog .dungeon-go { flex: none; }
/* A status chip (Cleared, Locked, Met, Beaten, Not open yet): 20 tall, paper, a 14 px icon. */
.dungeon-state {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: var(--ui-s-1);
  box-sizing: border-box;
  height: var(--ui-s-5);
  padding: 0 var(--ui-s-2) 0 var(--ui-s-1);
  color: var(--ui-ink);
  background: var(--ui-surface);
  border-radius: var(--ui-r-pill);
  box-shadow: inset 0 0 0 var(--ui-px) var(--ui-surface-shade);
  font-family: var(--ui-font-body);
  font-size: var(--ui-fs-14);
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0;
  white-space: nowrap;
}
.dungeon-state .px { --px-size: 14px; color: var(--ui-ink-muted); }

/* The element: a 20 px chip with a square in the element's colour (battle boxes use it too). */
.element-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--ui-s-1);
  box-sizing: border-box;
  height: var(--ui-s-5);
  padding: 0 var(--ui-s-2);
  color: var(--ui-ink);
  background: var(--ui-surface);
  border: 0;
  border-radius: var(--ui-r-pill);
  box-shadow: inset 0 0 0 var(--ui-px) var(--ui-surface-shade);
  font-family: var(--ui-font-body);
  font-size: var(--ui-fs-12);
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}
.element-chip::before { content: ""; flex: none; width: var(--ui-s-2); height: var(--ui-s-2); background: var(--ui-ink-muted); }
.element-chip.leaf::before { background: var(--ui-success); }
.element-chip.tide::before { background: var(--ui-info); }
.element-chip.ember::before { background: var(--ui-warning); }
#monsters-dialog .element-chip { font-size: var(--ui-fs-14); }

/* The Monster Book: per world, one card of rows; the monster drawn 2x or 3x in a 48 px slot
   (the Backpack's inverted bevel), the met / beaten / gleaming chip on the right. */
#monsters-dialog .monster-world:first-child h3 { margin-top: var(--ui-s-5); }
#monsters-dialog .monster-card { grid-template-columns: 48px minmax(0, 1fr) auto; }
#monsters-dialog .monster-art { display: grid; gap: var(--ui-s-1); justify-items: center; }
#monsters-dialog .monster-art canvas {
  display: block;
  width: 48px;
  height: 48px;
  image-rendering: pixelated;
  background: var(--ui-frame-fill);
  border: 0;
  border-radius: 0;
  box-shadow:
    inset var(--ui-px) var(--ui-px) 0 0 var(--ui-surface-shade),
    inset calc(var(--ui-px) * -1) calc(var(--ui-px) * -1) 0 0 var(--ui-surface-hi),
    var(--ui-frame-edge);
}
#monsters-dialog .monster-art .monster-gleam { width: 32px; height: 32px; }
#monsters-dialog .monster-copy { display: grid; gap: var(--ui-s-1); min-width: 0; }
#monsters-dialog .monster-meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--ui-s-2); }
#monsters-dialog .monster-lore { line-height: 1.5; }
#monsters-dialog .monster-card.unseen .monster-copy strong { color: var(--ui-ink-muted); }
#monsters-dialog .monster-status { align-self: start; }
#monsters-dialog .monster-card.beaten .monster-status .px { color: var(--ui-accent); }

/* Pet: the stage (your pet drawn 2x over its name, personality and bond), what just happened,
   then Care (Pat the one primary), Follow or stay (segmented), Play together, Tricks, the
   adventure training card and the animation setting. */
#pet-lounge-dialog .pet-stage {
  display: grid;
  justify-items: center;
  gap: var(--ui-s-2);
}
#pet-lounge-dialog #lounge-pet { display: block; width: 240px; max-width: 100%; height: 120px; object-fit: cover; object-position: 50% 100%; margin: 0; image-rendering: pixelated; transform-origin: 50% 72%; background: none; border: 0; border-radius: 0; }
#pet-lounge-dialog .pet-stage-copy { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--ui-s-1) var(--ui-s-3); justify-self: stretch; min-width: 0; }
#pet-lounge-dialog .pet-stage-name { min-width: 0; overflow: hidden; color: var(--ui-ink); font-family: var(--ui-font-display); font-size: var(--ui-fs-16); font-weight: 600; line-height: 1.25; white-space: nowrap; text-overflow: ellipsis; }
#pet-lounge-dialog #lounge-pet-personality { grid-row: 2; min-width: 0; margin: 0; color: var(--ui-ink-muted); font-family: var(--ui-font-body); font-size: var(--ui-fs-14); line-height: 1.25; }
#pet-lounge-dialog .pet-bond-count { grid-column: 2; grid-row: 1; justify-self: end; color: var(--ui-ink); font-family: var(--ui-font-body); font-size: var(--ui-fs-14); font-weight: 700; line-height: 1.25; font-variant-numeric: tabular-nums; white-space: nowrap; }
#pet-lounge-dialog .pet-bond-track { --step: 6px; grid-column: 2; grid-row: 2; justify-self: end; }
#pet-lounge-dialog .pet-bond-track > span { background: var(--ui-success); }
#pet-lounge-dialog #pet-care-status { min-height: 1.5em; margin: var(--ui-s-3) 0 0; color: var(--ui-ink); font-family: var(--ui-font-body); font-size: var(--ui-fs-14); line-height: 1.5; }
#pet-lounge-dialog :is(.pet-care-actions, .pet-command-actions, .pet-tricks) { display: flex; flex-wrap: wrap; gap: var(--ui-s-2); margin: 0; padding: 0; }
#pet-lounge-dialog .pet-group-hint { margin: var(--ui-s-2) 0 0; color: var(--ui-ink-muted); font-family: var(--ui-font-body); font-size: var(--ui-fs-14); line-height: 1.5; }
#pet-lounge-dialog .pet-follow-toggle { margin: 0; }
#pet-lounge-dialog .pet-follow-toggle > button { flex: 1 1 0; }
#pet-lounge-dialog .pet-motion-setting { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--ui-s-2) var(--ui-s-3); margin: var(--ui-s-5) 0 0; color: var(--ui-ink); font-family: var(--ui-font-body); font-size: var(--ui-fs-14); font-weight: 600; line-height: 1.25; }
/* Selects in the Pet tab: the Input component with the pixel chevron (Together's). */
#pet-lounge-dialog select {
  -webkit-appearance: none;
  appearance: none;
  box-sizing: border-box;
  width: 100%;
  height: 40px;
  min-height: 0;
  margin: 0;
  padding: 0 var(--ui-s-6) 0 var(--ui-s-3);
  overflow: hidden;
  color: var(--ui-input-ink);
  background: var(--ui-frame-fill);
  border: 0;
  border-radius: 0;
  box-shadow:
    inset var(--ui-px) var(--ui-px) 0 0 var(--ui-surface-shade),
    inset calc(var(--ui-px) * -1) calc(var(--ui-px) * -1) 0 0 var(--ui-surface-hi),
    var(--ui-frame-edge);
  font-family: var(--ui-font-body);
  font-size: var(--ui-fs-16);
  font-weight: 400;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}
#pet-lounge-dialog select:focus-visible { outline: var(--ui-focus-ring-w) solid var(--ui-focus-ring); outline-offset: calc(var(--ui-px) * 2); }
#pet-lounge-dialog .pet-motion-setting .ui-choice { flex: 1 1 240px; }
/* Adventure training: the pet's level, a 20-block XP meter, four stats, the moves. */
#pet-lounge-dialog .pet-battle {
  display: grid;
  gap: var(--ui-s-2);
}
#pet-lounge-dialog .pet-battle h3 { margin: 0; color: var(--ui-ink); font-family: var(--ui-font-display); font-size: var(--ui-fs-16); font-weight: 600; line-height: 1.25; letter-spacing: 0; }
#pet-lounge-dialog .pet-battle h4 { margin: var(--ui-s-2) 0 0; color: var(--ui-ink); font-family: var(--ui-font-body); font-size: var(--ui-fs-14); font-weight: 700; line-height: 1.25; letter-spacing: 0; }
#pet-lounge-dialog :is(.pet-battle-line, .pet-battle-note) { margin: 0; color: var(--ui-ink-muted); font-family: var(--ui-font-body); font-size: var(--ui-fs-14); line-height: 1.5; }
#pet-lounge-dialog .pet-xp { --step: 8px; height: var(--ui-s-2); }
#pet-lounge-dialog .pet-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0 var(--ui-s-3); margin: var(--ui-s-1) 0 0; }
#pet-lounge-dialog .pet-stats dt { grid-row: 1; color: var(--ui-ink-muted); font-family: var(--ui-font-body); font-size: var(--ui-fs-14); line-height: 1.25; }
#pet-lounge-dialog .pet-stats dd { grid-row: 2; margin: 0; color: var(--ui-ink); font-family: var(--ui-font-body); font-size: var(--ui-fs-16); font-weight: 700; line-height: 1.5; font-variant-numeric: tabular-nums; }
#pet-lounge-dialog .move-slots { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--ui-s-2) var(--ui-s-3); }
#pet-lounge-dialog .move-slot { display: grid; gap: var(--ui-px); min-width: 0; color: var(--ui-ink-muted); font-family: var(--ui-font-body); font-size: var(--ui-fs-14); line-height: 1.25; }
#pet-lounge-dialog .move-slot strong { color: var(--ui-ink); font-size: var(--ui-fs-14); font-weight: 600; }

/* Games (UX-116): equal tiles, 3 across (the 448 sheet and a 390 phone), each the whole
   button: a 28 px icon (one per activity) over a one-line Outfit 14 label and one muted
   Outfit 12 progress line ("3 left today"), the rest frame of a secondary button. A gold
   "Ready" badge in the corner marks one that is ready today; a done one is quiet. The line
   under the grid names the tile you point at. Worlds not open yet fold into one line. */
#play-dialog .game-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--ui-s-2); margin: 0; padding: 0; list-style: none; }
#play-dialog .game-tiles > li { display: block; min-width: 0; margin: 0; padding: 0; background: none; border: 0; box-shadow: none; }
#play-dialog .game-tile {
  --f-fill: var(--ui-frame-fill);
  position: relative;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: var(--ui-s-1);
  box-sizing: border-box;
  width: 100%;
  height: 104px;
  min-width: var(--ui-target);
  min-height: var(--ui-target);
  margin: 0;
  /* 16 on top: the corner badge (it sits on the frame's edge) never touches the icon. */
  padding: var(--ui-s-4) var(--ui-s-1) var(--ui-s-3);
  color: var(--ui-ink);
  background: var(--f-fill);
  border: 0;
  border-radius: 0;
  box-shadow:
    inset var(--ui-px) var(--ui-px) 0 0 var(--ui-frame-hi),
    inset calc(var(--ui-px) * -1) calc(var(--ui-px) * -1) 0 0 var(--ui-frame-shade),
    var(--ui-frame-edge),
    0 calc(var(--ui-px) * 2) 0 0 var(--ui-frame-drop);
  font-family: var(--ui-font-body);
  font-size: var(--ui-fs-14);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: 0;
  text-align: center;
  cursor: pointer;
  transition: background-color var(--ui-dur-fast) var(--ui-ease-out), transform var(--ui-dur-fast) var(--ui-ease-out);
}
#play-dialog .game-tile .ico { --ico: 28px; margin-bottom: var(--ui-s-1); color: var(--ui-ink); }
#play-dialog :is(.game-tile-label, .game-tile-progress) { display: block; max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
#play-dialog .game-tile-progress { color: var(--ui-ink-muted); font-size: var(--ui-fs-12); font-weight: 500; line-height: 1.25; font-variant-numeric: tabular-nums; }
#play-dialog .game-tile:hover { --f-fill: var(--ui-secondary-hover); }
#play-dialog .game-tile:active {
  transform: translateY(var(--ui-press));
  box-shadow:
    inset var(--ui-px) var(--ui-px) 0 0 var(--ui-frame-hi),
    inset calc(var(--ui-px) * -1) calc(var(--ui-px) * -1) 0 0 var(--ui-frame-shade),
    var(--ui-frame-edge),
    0 var(--ui-px) 0 0 var(--ui-frame-drop);
}
#play-dialog .game-tile:focus-visible { position: relative; z-index: 1; outline: var(--ui-focus-ring-w) solid var(--ui-focus-ring); outline-offset: calc(var(--ui-px) * 2); }
#play-dialog .game-tile:disabled { --f-fill: var(--ui-disabled-bg); color: var(--ui-disabled-ink); cursor: not-allowed; }
#play-dialog .game-tile.is-done { --f-fill: var(--ui-surface-sunk); color: var(--ui-ink-muted); }
#play-dialog .game-tile.is-done .ico { color: var(--ui-ink-muted); }
/* The badge component (gold pill, Outfit 12/700, ink-strong on gold) on the frame's top
   edge, as the dock's counts sit (4 px over the edge, 4 px in from the right). */
#play-dialog .game-ready { position: absolute; top: calc(var(--ui-s-1) * -1); right: var(--ui-s-1); }
#play-dialog .games-detail { min-height: 1.5em; margin: var(--ui-s-2) 0 0; overflow: hidden; color: var(--ui-ink-muted); font-family: var(--ui-font-body); font-size: var(--ui-fs-14); line-height: 1.5; white-space: nowrap; text-overflow: ellipsis; }
#play-dialog .games-detail strong { color: var(--ui-ink); font-weight: 600; }
#play-dialog .games-more {
  display: flex;
  align-items: flex-start;
  gap: var(--ui-s-2);
}
#play-dialog .games-more[hidden] { display: none; }
#play-dialog .games-more .ico { margin-top: var(--ui-px); color: var(--ui-ink-muted); }
#play-dialog .games-more p { margin: 0; color: var(--ui-ink-muted); font-family: var(--ui-font-body); font-size: var(--ui-fs-14); line-height: 1.5; }
#play-dialog .games-more strong { color: var(--ui-ink); font-weight: 600; }
/* Little milestones: rows, a pixel check when earned, an empty box when not. */
#play-dialog .milestone-badge { grid-template-columns: 14px minmax(0, 1fr) auto; padding: var(--ui-s-2) 0; font-family: var(--ui-font-body); font-size: var(--ui-fs-14); line-height: 1.5; }
#play-dialog .milestone-badge strong { min-width: 0; color: var(--ui-ink); font-weight: 600; }
#play-dialog .milestone-badge small { color: var(--ui-ink-muted); font-size: var(--ui-fs-14); text-align: right; }
#play-dialog .milestone-badge.earned small { color: var(--ui-ink); font-weight: 700; }
#play-dialog .milestone-badge .ico { color: var(--ui-accent); }
#play-dialog .milestone-box { display: block; width: 14px; height: 14px; box-sizing: border-box; box-shadow: inset 0 0 0 var(--ui-px) var(--ui-surface-shade); }

/* Phones: rows keep one action on the right; the out-of-charges primary runs the width, in
   thumb reach; the stage's pet stays 2x. */
@media (max-width: 600px) {
  #rifts-dialog .energy-card .energy-focus.btn--primary { justify-self: stretch; }
  #pet-lounge-dialog .pet-care-actions .btn { flex: 1 1 auto; }
  #pet-lounge-dialog .move-slots { grid-template-columns: 1fr; }
  /* Two tiles across, so every label keeps one line at 390. */
  #play-dialog .game-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #play-dialog .game-tile { height: 100px; padding-bottom: var(--ui-s-2); }
}
@media (prefers-reduced-motion: reduce) {
  .block-meter > span { transition: none; }
  #play-dialog .game-tile { transition: none; }
}

/* ---------- Dungeon (UX-006 B7): the card at a rift's door, rooms, the battle, the result ----------
   Finishes the Play area on UI v2 (src/dungeon-ui.js; ids and classes as the tests know them).
   Rift-entry card: a "card" sheet (data-sheet-size="card", src/sheet-host.js): no Play tabs above
   it, its own title row is the head (Pixelify 20 + the world as a muted Outfit 14 line), the
   monster in a square pixel frame on the dark stage, the charge as the Rifts tab's calm strip,
   then Go in (the one primary) and Not now; the sheet ends under the buttons.
   Dungeon: one raised pixel frame over a deep scrim. Head (title 20, muted kind and loot 14), the
   rooms as square flat frames (here = the one --ui-selected fill), the dark stage with flat
   health cards (Pixelify 16 name, Outfit 14 level, 12 chip) and the shared block meter for health,
   the message box, then the action bar: the move that helps most is the one primary (Fight, or
   Guard / a snack when the game suggests it), the rest secondary, Run a ghost; all 48 tall.
   Phones (<= 600): full screen, and the health cards sit above and below the stage, never over
   the fighters. Reduced motion: no new motion (the dungeon already skips lunges and sparks). */

/* The card sheet: as tall as its card. */
@media (min-width: 721px) {
  .sheet-host[data-size="card"] { bottom: auto; max-height: calc(100dvh - var(--sheet-top) - var(--sheet-bottom)); }
}
@media (max-width: 720px) {
  .sheet-host[data-size="card"] { height: auto; max-height: min(88dvh, calc(100dvh - max(var(--ui-s-7), var(--sheet-band-end, 0px) + var(--ui-s-2)))); }
}
.sheet-body > #dungeon-enter[open] { display: grid; gap: var(--ui-s-4); align-content: start; }
.sheet-host:not(.grouped) .sheet-body #dungeon-enter .dialog-heading { margin-bottom: 0; }
.dungeon-enter-titles, .dungeon-titles { display: grid; gap: var(--ui-s-1); min-width: 0; }
.dungeon-enter-kind, .dungeon-kind { margin: 0; color: var(--ui-ink-muted); font-family: var(--ui-font-body); font-size: var(--ui-fs-14); font-weight: 500; line-height: 1.25; letter-spacing: 0; text-transform: none; }
#dungeon-enter .dungeon-enter-top { display: grid; grid-template-columns: calc(72px + var(--ui-px) * 2) minmax(0, 1fr); gap: var(--ui-s-4); align-items: start; }
.dungeon-enter-art { display: block; width: 72px; height: 72px; margin: var(--ui-px); image-rendering: pixelated; background: var(--ui-stage-bg); border: 0; border-radius: 0; box-shadow: var(--ui-frame-edge); }
#dungeon-enter .dungeon-enter-body { display: grid; gap: var(--ui-s-2); min-width: 0; }
#dungeon-enter .dungeon-enter-body p { margin: 0; color: var(--ui-ink); font-family: var(--ui-font-body); font-size: var(--ui-fs-16); line-height: 1.5; }
#dungeon-enter .dungeon-enter-foot { display: grid; gap: var(--ui-s-2); }
#dungeon-enter .dungeon-enter-foot:empty { display: none; }
#dungeon-enter .dungeon-cost {
  display: flex;
  align-items: center;
  gap: var(--ui-s-2);
  margin: 0;
  padding: var(--ui-s-3) var(--ui-s-4);
  color: var(--ui-ink);
  background: var(--ui-surface-sunk);
  box-shadow: inset 0 0 0 var(--ui-px) var(--ui-surface-shade);
  font-family: var(--ui-font-body);
  font-size: var(--ui-fs-14);
  font-weight: 600;
  line-height: 1.25;
}
#dungeon-enter .dungeon-cost > .px { --px-size: 14px; color: var(--ui-coin-deep); }
#dungeon-enter .dungeon-note { margin: 0; color: var(--ui-ink-muted); font-family: var(--ui-font-body); font-size: var(--ui-fs-14); line-height: 1.5; }
.dungeon-actions { display: flex; flex-wrap: wrap; gap: var(--ui-s-2); margin: 0; }

/* The dungeon: one raised frame over a deep scrim; it keeps its top edge from room to battle. */
.dungeon-layer { position: fixed; z-index: 50; inset: 0; display: grid; place-items: start center; padding: max(var(--ui-s-4), calc((100vh - 820px) / 2)) var(--ui-s-4) var(--ui-s-4); background: var(--ui-scrim-deep); }
.dungeon-layer[hidden] { display: none; }
.dungeon-frame {
  --f-fill: var(--ui-sheet-bg);
  display: grid;
  gap: var(--ui-s-4);
  box-sizing: border-box;
  width: min(760px, 100%);
  max-height: calc(100% - var(--ui-px) * 4);
  overflow: auto;
  padding: var(--ui-s-4) var(--ui-s-5) var(--ui-s-5);
  color: var(--ui-ink);
  font-family: var(--ui-font-body);
}
.dungeon-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--ui-s-1) var(--ui-s-3); }
.dungeon-head h2 { margin: 0; color: var(--ui-ink); font-family: var(--ui-font-display); font-size: var(--ui-fs-20); font-weight: 600; line-height: 1.2; letter-spacing: 0; }
.dungeon-loot { margin: 0; color: var(--ui-ink-muted); font-size: var(--ui-fs-14); line-height: 1.25; font-variant-numeric: tabular-nums; }

/* The rooms: square flat frames joined by a 4 px rule; where you are is the one chosen fill. */
.dungeon-path { display: flex; align-items: center; margin: 0; padding: var(--ui-px); list-style: none; }
.dungeon-node {
  position: relative;
  display: grid;
  place-items: center;
  flex: none;
  box-sizing: border-box;
  width: var(--ui-s-6);
  height: var(--ui-s-6);
  color: var(--ui-ink);
  background: var(--ui-surface);
  border: 0;
  border-radius: 0;
  box-shadow: var(--ui-frame-flat);
}
.dungeon-node + .dungeon-node { margin-left: var(--ui-s-5); }
.dungeon-node + .dungeon-node::before { content: ""; position: absolute; right: calc(100% + var(--ui-px)); top: 50%; width: calc(var(--ui-s-5) - var(--ui-px) * 2); height: var(--ui-s-1); margin-top: calc(var(--ui-px) * -1); background: var(--ui-line); }
.dungeon-node .px { --px-size: 14px; }
.dungeon-node.boss { width: 40px; height: 40px; }
.dungeon-node:is(.elite, .boss).ahead { color: var(--ui-danger); }
.dungeon-node.done { color: var(--ui-ink-strong); background: var(--ui-success); }
.dungeon-node.here { color: var(--ui-ink-strong); background: var(--ui-selected); }
.dungeon-node.skipped { color: var(--ui-disabled-ink); background: var(--ui-disabled-bg); }

/* Between rooms: the dark stage, your pet in a flat card (drawn 2x), the words, Onward. */
.dungeon-room { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--ui-s-3) var(--ui-s-4); align-items: center; margin: var(--ui-px); padding: var(--ui-s-4); color: var(--ui-ink-on-dark); background: var(--ui-stage-bg); border: 0; border-radius: 0; box-shadow: var(--ui-frame-edge); }
.dungeon-room[hidden] { display: none; }
.dungeon-room-petbox { display: grid; justify-items: center; gap: var(--ui-s-2); box-sizing: border-box; width: 192px; padding: var(--ui-s-2) var(--ui-s-3) var(--ui-s-3); color: var(--ui-ink); }
.dungeon-room-pet { display: block; width: 128px; height: 112px; image-rendering: pixelated; }
.dungeon-room-petbox .hp-line { flex-wrap: wrap; justify-content: space-between; width: 100%; }
.dungeon-room-petbox .hp-label { flex: 1 1 auto; min-width: 0; overflow: hidden; color: var(--ui-ink); font-family: var(--ui-font-display); font-size: var(--ui-fs-16); font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.dungeon-room-petbox .hp-bar { order: 3; }
.dungeon-room-text { margin: 0; font-family: var(--ui-font-display); font-size: var(--ui-fs-20); line-height: 1.4; }

/* Health: the shared block meter (charges, Journal XP), 20 blocks; green, gold when under half,
   red under a fifth. The words "Health" and the numbers sit beside it in Outfit. */
.hp-line { display: flex; align-items: center; gap: var(--ui-s-2); min-width: 0; color: var(--ui-ink-muted); font-family: var(--ui-font-body); font-size: var(--ui-fs-14); font-weight: 600; line-height: 1.25; }
.hp-label { font-size: var(--ui-fs-12); }
.hp-bar { --step: 8px; --blocks: 20; }
.hp-bar.low > span { background: var(--ui-coin); }
.hp-bar.danger > span { background: var(--ui-danger); }
.hp-numbers { margin-left: auto; color: var(--ui-ink); font-variant-numeric: tabular-nums; }

/* A battle: the stage (a 240x160 canvas, scaled with hard pixels) with a health card in the two
   empty corners (foe top-left, your pet bottom-right), the message box and the action bar. */
.battle { display: grid; gap: var(--ui-s-3); }
.battle[hidden] { display: none; }
.battle-stage { position: relative; margin: var(--ui-px); overflow: hidden; background: var(--ui-stage-bg); border: 0; border-radius: 0; box-shadow: var(--ui-frame-edge); }
.battle-canvas { display: block; width: 100%; aspect-ratio: 3 / 2; image-rendering: pixelated; }
.battle-box { position: absolute; display: grid; gap: var(--ui-s-2); box-sizing: border-box; width: min(46%, 296px); padding: var(--ui-s-2) var(--ui-s-3) var(--ui-s-3); color: var(--ui-ink); container-type: inline-size; }
/* A narrow card (mid widths, about 601-680 px wide) keeps "Health", all 20 blocks and "hp/max" on one
   line: the blocks step down to 6, then 5 whole px (a 121 or 101 px meter for the 8 px step's 161).
   If even that can't fit, the readout wraps under the meter, right-aligned; it never truncates. */
.battle-box .hp-line { flex-wrap: wrap; row-gap: var(--ui-s-1); }
.battle-box .hp-numbers { flex: none; white-space: nowrap; }
@container (max-width: 259px) { .battle-box .hp-bar { --step: 6px; } }
@container (max-width: 223px) { .battle-box .hp-bar { --step: 5px; } }
.battle-box.foe { top: var(--ui-s-3); left: var(--ui-s-3); }
.battle-box.pet { right: var(--ui-s-3); bottom: var(--ui-s-4); }
.battle-box.boss { --f-hi: var(--ui-coin); --f-shade: var(--ui-coin-deep); }
.battle-name { display: flex; align-items: center; gap: var(--ui-s-2); min-width: 0; margin: 0; color: var(--ui-ink); font-family: var(--ui-font-display); font-size: var(--ui-fs-16); font-weight: 600; line-height: 1.25; }
.battle-name strong { min-width: 0; overflow: hidden; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.battle-level { flex: none; margin-left: auto; color: var(--ui-ink-muted); font-family: var(--ui-font-body); font-size: var(--ui-fs-14); font-weight: 600; font-variant-numeric: tabular-nums; }
/* Square chips in the dungeon (the element, the move tags, the result). */
.dungeon-layer .element-chip { flex: none; border-radius: 0; }
.battle-bottom { display: grid; gap: var(--ui-s-3); }
.battle-message { position: relative; min-height: calc(var(--ui-fs-16) * 3 + var(--ui-s-3) * 2); margin: var(--ui-px); padding: var(--ui-s-3) var(--ui-s-6) var(--ui-s-3) var(--ui-s-4); color: var(--ui-ink); font-family: var(--ui-font-display); font-size: var(--ui-fs-16); font-weight: 500; line-height: 1.5; cursor: pointer; }
/* "More": a 2-step pixel arrow (4 and 2 UI px wide) in the corner while a line waits. */
.battle-message.waiting::after {
  content: "";
  position: absolute;
  right: var(--ui-s-3);
  bottom: var(--ui-s-3);
  width: var(--ui-s-2);
  height: var(--ui-s-1);
  background:
    linear-gradient(var(--ui-ink), var(--ui-ink)) 0 0 / 100% var(--ui-px) no-repeat,
    linear-gradient(var(--ui-ink), var(--ui-ink)) var(--ui-px) var(--ui-px) / var(--ui-s-1) var(--ui-px) no-repeat;
}
@media (prefers-reduced-motion: no-preference) { .battle-message.waiting::after { animation: blink-down .8s steps(2) infinite; } }
@keyframes blink-down { 50% { opacity: 0; } }
.battle-menu, .battle-moves { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--ui-s-2); padding: var(--ui-px); }
.battle-moves { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.battle-menu[hidden], .battle-moves[hidden] { display: none; }
.battle-action { min-height: var(--ui-s-7); }
/* A move: its name after a square in its element's colour, the details under it, tags right. */
.battle-move:not(.back) { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; justify-content: stretch; gap: var(--ui-s-1) var(--ui-s-2); min-height: 56px; padding: var(--ui-s-2) var(--ui-s-3); line-height: 1.25; text-align: left; white-space: normal; }
.battle-move strong { display: flex; align-items: center; gap: var(--ui-s-2); min-width: 0; font-size: var(--ui-fs-16); font-weight: 600; }
.battle-move strong::before { content: ""; flex: none; width: var(--ui-s-2); height: var(--ui-s-2); background: var(--ui-ink-muted); box-shadow: 0 0 0 var(--ui-px) var(--ui-line); }
.battle-move.btn--primary strong::before { box-shadow: 0 0 0 var(--ui-px) var(--ui-ink-on-dark); }
.battle-move.leaf strong::before { background: var(--ui-success); }
.battle-move.tide strong::before { background: var(--ui-info); }
.battle-move.ember strong::before { background: var(--ui-warning); }
.battle-move small { grid-column: 1; color: var(--ui-ink-muted); font-family: var(--ui-font-body); font-size: var(--ui-fs-12); font-weight: 500; }
.battle-move.btn--primary small { color: var(--ui-ink-on-dark); }
.battle-move .move-tags { display: grid; grid-column: 2; grid-row: 1 / span 2; gap: var(--ui-s-1); justify-items: end; }
.battle-move.back { grid-column: 1 / -1; }
.move-tag { display: inline-flex; align-items: center; box-sizing: border-box; height: var(--ui-s-5); padding: 0 var(--ui-s-2); color: var(--ui-ink); background: var(--ui-surface); border: 0; border-radius: 0; box-shadow: inset 0 0 0 var(--ui-px) var(--ui-surface-shade); font-family: var(--ui-font-body); font-size: var(--ui-fs-12); font-weight: 700; line-height: 1; white-space: nowrap; }
.move-tag.strong { color: var(--ui-ink-strong); background: var(--ui-success); box-shadow: none; }
.move-tag.weak { color: var(--ui-ink-muted); background: var(--ui-surface-sunk); }
.battle-move:disabled .move-tag { color: var(--ui-disabled-ink); background: var(--ui-disabled-bg); }

/* The end of a run: a flat sunk card, the title, square chips, the words, Back (the primary). */
.dungeon-result { display: grid; gap: var(--ui-s-3); margin: 0; padding: var(--ui-s-4); color: var(--ui-ink); background: var(--ui-surface-sunk); border: 0; border-radius: 0; box-shadow: inset 0 0 0 var(--ui-px) var(--ui-surface-shade); }
.dungeon-result[hidden] { display: none; }
.dungeon-result p { margin: 0; color: var(--ui-ink); font-family: var(--ui-font-body); font-size: var(--ui-fs-16); line-height: 1.5; }
.dungeon-result .session-result-head strong { font-family: var(--ui-font-display); font-size: var(--ui-fs-24); font-weight: 600; line-height: 1.2; }
:is(.dungeon-result, .session-result) .session-result-chips { display: flex; flex-wrap: wrap; gap: var(--ui-s-2); }
:is(.dungeon-result, .session-result) .session-result-chips .chip { display: inline-flex; align-items: center; box-sizing: border-box; height: var(--ui-s-5); padding: 0 var(--ui-s-2); color: var(--ui-ink); background: var(--ui-surface); border: 0; border-radius: 0; box-shadow: inset 0 0 0 var(--ui-px) var(--ui-surface-shade); font-family: var(--ui-font-body); font-size: var(--ui-fs-14); font-weight: 700; line-height: 1; }
:is(.dungeon-result, .session-result) .session-result-chips .chip.level { color: var(--ui-ink-strong); background: var(--ui-coin); box-shadow: none; }
.dungeon-result .dungeon-actions { margin-top: var(--ui-s-1); }

/* ---------- the session-complete card (UX-060; src/session-result.js) ----------
   A raised pixel frame in the status stack, above the dock: the title (Pixelify 20) and a
   ghost close icon (32 px on desktop, a 44 px target on touch and phones), the same square
   chips as the end of a run (Outfit 14/700; the coins chip leads with the pixel coin), one
   muted line (Outfit 14), then one primary (Another session) and one secondary (Spend
   coins). Three type sizes: 20 · 16 (buttons) · 14. Enter 320 ms ease-out, 8 px up + fade;
   reduced motion: --ui-travel is 0, so it only fades. */
.session-result-head { display: flex; align-items: center; justify-content: space-between; gap: var(--ui-s-2); }
.session-result {
  display: grid;
  gap: var(--ui-s-3);
  box-sizing: border-box;
  width: min(400px, 100%);
  /* (Its bottom padding as a property: the pinned actions row below reads it, UX-576.) */
  --session-result-pb: var(--ui-s-4);
  padding: var(--ui-s-2) var(--ui-s-4) var(--session-result-pb);
  color: var(--ui-ink);
  /* Head CHANGES 0841 (3): its own width decides where the Next line goes (see below). */
  container: session-result / inline-size;
  text-align: left;
  /* Head CHANGES UX-572 (3): the short-screen backstops (below, shell.css) measure the window
     with the dynamic viewport (a phone's bars shown), vh where dvh is unknown. */
  --session-vh: 100vh;
}
@supports (height: 100dvh) { .session-result { --session-vh: 100dvh; } }
.session-result[hidden] { display: none; }
.session-result:not([hidden]) { animation: session-result-in var(--ui-dur-slow) var(--ui-ease-out) both; }
@keyframes session-result-in { from { opacity: 0; transform: translateY(var(--ui-travel)); } }
/* The in-app reduced-motion setting too (session-result.js sets data-motion from motionReduced). */
.session-result[data-motion="reduced"]:not([hidden]) { animation-name: session-result-fade; }
@keyframes session-result-fade { from { opacity: 0; } }
/* The close icon sits in the corner, its 32 px box 8 px in from the frame's top and right
   (a 44 px box 4 px in on touch and phones). */
.session-result .session-result-head { margin-right: calc(var(--ui-s-2) * -1); }
.session-result .session-result-head strong { font-family: var(--ui-font-display); font-size: var(--ui-fs-20); font-weight: 600; line-height: 1.2; }
.session-result .session-result-close { color: var(--ui-ink-muted); }
.session-result .session-result-close:hover { color: var(--ui-ink); }
.session-result .session-result-chips .chip { background: var(--ui-surface-sunk); }
.session-result :is(.chip--coins, .chip--quest) { gap: var(--ui-s-1); }
.session-result :is(.chip--coins, .chip--quest) .ico { --ico: 14px; color: var(--ui-coin-deep); }
/* UX-713: quests paid as the card comes up (the first session's "First focus") are a chip on it,
   not a toast over it: the pixel tick in meadow ink, then "Quest done · First focus · +10 coins".
   It rises in 8 px over 200 ms once the card has come in (320 ms); reduced motion only fades. */
.session-result .chip--quest { animation: session-result-next-in var(--ui-dur) var(--ui-ease-out) var(--ui-dur-slow) both; }
.session-result .chip--quest .ico { color: var(--ui-success-ink); }
.session-result[data-motion="reduced"] .chip--quest { animation-name: session-result-fade; }
/* On a card fitted to a short screen (data-fit stack/scroll: its chips row scrolls out of view
   under the pinned actions, UX-733) the quest chip sits in the title row, between the title and
   the ×, as the same square chip: "✓ First focus · +10" ("Quest done · " and " coins" are for
   screen readers there; the whole line is its tooltip). A long quest name ellipsizes. */
.session-result-head:has(.chip--quest) strong { flex: none; }
.session-result-head .chip--quest { display: inline-flex; align-items: center; gap: var(--ui-s-1); box-sizing: border-box; min-width: 0; height: var(--ui-s-5); margin-left: auto; padding: 0 var(--ui-s-2); color: var(--ui-ink); background: var(--ui-surface-sunk); box-shadow: inset 0 0 0 var(--ui-px) var(--ui-surface-shade); font-family: var(--ui-font-body); font-size: var(--ui-fs-14); font-weight: 700; line-height: 1; }
.session-result .chip-quest-text { min-width: 0; overflow: hidden; line-height: 1.3; text-overflow: ellipsis; white-space: nowrap; }
/* Fix round: on a phone the chips row wraps as before and the quest chip, after the coins chip,
   takes the short form too ("✓ First focus · +10"), so XP, coins and the quest all show. */
.session-result-head :is(.chip-quest-lead, .chip-quest-unit) { position: absolute; width: var(--ui-px); height: var(--ui-px); overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (max-width: 600px) {
  /* Head CHANGES UX-713/699 fix round: a quest chip's card lets its line go only where it would
     come within 8 px of you (measured: session-result.js tightLine, data-tight; hud-ui: 8 px
     clear of the player). First "N focus minutes." (the chips say it): the rest (a level's
     unlocks, the rift pointer) stays, on one line, whole on hover; then the whole line; then the
     quest chip goes up beside the title ("head", session-result.js seatQuest). */
  .session-result[data-tight="minutes"] > p { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .session-result[data-tight="minutes"] > p .session-result-minutes { display: none; }
  .session-result:is([data-tight="line"], [data-tight="head"]) > p { display: none; }
  .session-result-chips :is(.chip-quest-lead, .chip-quest-unit) { position: absolute; width: var(--ui-px); height: var(--ui-px); overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}
.session-result p { margin: 0; color: var(--ui-ink-muted); font-family: var(--ui-font-body); font-size: var(--ui-fs-14); line-height: 1.5; }
.session-result-actions { display: flex; flex-wrap: wrap; gap: var(--ui-s-2); }
/* UX-060 slice 2b: one quiet "what next" line in the actions row: a short break, or the quest
   strip's next step when the strip is hidden or dismissed (never a repeat of it). Muted, not a
   button (the card keeps its one primary): "Next" in Pixelify 14, the step in Outfit 14.
   Desktop: beside the buttons, after a 1 UI px rule in the chips' shade, wrapping to at most two
   lines, so the card does not grow up over the world (the card is 480 px wide to make room).
   Phones and touch: its own line under the buttons, one line, under the same rule. It waits for
   the beat (--session-result-settle, set from World.CELEBRATE_MS), then rises 8 px and fades in
   over 200 ms; reduced motion (OS: --ui-travel is 0; in-app: data-motion) only fades. */
.session-result p.session-result-next {
  display: flex;
  flex: 1 1 0;
  align-items: baseline;
  column-gap: var(--ui-s-2);
  min-width: 0;
  align-self: center;
  padding-left: var(--ui-s-3);
  border-left: var(--ui-px) solid var(--ui-surface-shade);
  color: var(--ui-ink-muted);
  line-height: 1.25;
  animation: session-result-next-in var(--ui-dur) var(--ui-ease-out) var(--session-result-settle, 0ms) both;
}
.session-result-next-label { flex: none; font-family: var(--ui-font-display); font-size: var(--ui-fs-14); font-weight: 600; }
/* Head CHANGES 0841 (3): the step is never cut off (no clamp, no ellipsis): it wraps beside the
   buttons on the 480 px desktop card, and goes under them on a narrower card (see below). */
.session-result-next-text { min-width: 0; overflow-wrap: break-word; }
/* A hyphenated word ("5-minute", session-result.js keepWhole) never breaks at its hyphen. */
.session-result-keep { white-space: nowrap; }
@keyframes session-result-next-in { from { opacity: 0; transform: translateY(var(--ui-travel)); } }
.session-result[data-motion="reduced"] p.session-result-next { animation-name: session-result-fade; }
/* UX-517 (G3 slice 1, `unlocks` flag on): an intro beat's "New" block between the line and the
   actions: a sunk pixel well (1 UI px shade inset, square like the chips) with a gold "New" tag
   (Pixelify 14, as the Level chip) and its line in Outfit 14 ink. Its Open Home button stands
   in for Spend coins (secondary; Another session stays the one primary). It waits for the beat
   (--session-result-settle) and rises 8 px over 200 ms; reduced motion only fades. */
.session-result-intro {
  display: grid;
  justify-items: start;
  gap: var(--ui-s-1);
  padding: var(--ui-s-2) var(--ui-s-3) var(--ui-s-3);
  background: var(--ui-surface-sunk);
  box-shadow: inset 0 0 0 var(--ui-px) var(--ui-surface-shade);
  animation: session-result-next-in var(--ui-dur) var(--ui-ease-out) var(--session-result-settle, 0ms) both;
}
.session-result-intro-label { padding: 0 var(--ui-s-1); color: var(--ui-ink-strong); background: var(--ui-coin); font-family: var(--ui-font-display); font-size: var(--ui-fs-14); font-weight: 600; line-height: 1.5; }
/* UX-547 fix round: the block's `justify-items: start` (for its grid form) also shrank the line to
   fit-content in the block form beside the floated tag (block-level justify-self), so it broke
   early with room left: the line stretches across the well, its lines balanced. */
.session-result p.session-result-intro-line { justify-self: stretch; color: var(--ui-ink); text-wrap: balance; }
.session-result[data-motion="reduced"] .session-result-intro { animation-name: session-result-fade; }
/* Short or narrow screens (phones either way up): the card stays its old height so it covers
   neither you, your pet nor the HUD: the minutes line steps aside (the chips say it) and the
   tag leads its line, and the card's rhythm tightens to 8 px. UX-573 fix round: tag and line are
   two columns (baselines aligned), so a wrapped line lines up under its first line, not the tag. */
@media (max-height: 480px), (max-width: 600px) {
  .session-result:has(.session-result-intro) { gap: var(--ui-s-2); }
  .session-result:has(.session-result-intro) > p { display: none; }
  .session-result-intro { grid-template-columns: auto minmax(0, 1fr); align-items: baseline; column-gap: var(--ui-s-2); padding: var(--ui-s-2); }
}
/* Head CHANGES UX-573 (2): on a narrow phone the text column beside the tag is too narrow (a
   390 px card: 280 px), so a beat's line balanced to three short lines and the card grew 20 px
   over you and your pet. There the tag leads the line and the line wraps on under it, using the
   well's full width: two lines, the card its old height. Wider cards keep the two columns. */
@media (max-width: 600px) {
  .session-result-intro { display: block; }
  .session-result-intro-label { float: left; margin-right: var(--ui-s-2); }
}
/* UX-552: a short landscape screen (a phone held sideways): a level-up card's chips take a row
   more, so its minutes line steps aside (the chips say it), and a card still too tall scrolls
   inside, its top never off the window (the cottage's card beside you: shell.css UX-572).
   UX-576/577: its height is measured (session-result.js fit(): --session-fit-h, from 8 px under
   the top band to the card's foot), so it never climbs over the place card, the status card or
   the timer. And it is the one panel: the status cards under it (the café's shortcuts, Upgrade
   your cottage, a hint) step aside until it closes, as in the cottage (UX-546). A fishing,
   breathing or route card closes it instead (session-result.js), so those stay. */
@media (max-height: 480px) {
  .status-stack > .session-result { max-height: var(--session-fit-h, calc(var(--session-vh) - var(--sheet-bottom) - var(--hud-edge))); overflow-y: auto; overscroll-behavior: contain; }
  body:has(#session-result:not([hidden])) .status-stack > :not(#session-result, #fishing-hud, #breathing-hud, #route-hud) { display: none; }
  .session-result:has(.chip.level) > p { display: none; }
  /* Still too tall for its room (fit() sets data-fit): the minutes line steps aside too. */
  .session-result[data-fit]:has(.session-result-chips .chip) > p { display: none; }
}
/* UX-576 fix round: a fitted card that still scrolls (data-fit="scroll", session-result.js fit())
   keeps its actions row (the buttons, the Next line) whole: pinned to the card's foot over the
   scrolling chips and beat, on the card's own paper, under a 1 UI px rule and a short paper fade
   that says there is more above. The row reaches down through the card's bottom padding (less
   the frame's 1 px inner shade) and 8 px of paper over the rule above the buttons; its margins
   and paddings cancel, so the layout does not move. */
.session-result[data-fit="scroll"] .session-result-actions {
  --session-result-pin: calc(var(--session-result-pb) - var(--ui-px));
  position: sticky;
  bottom: calc(var(--session-result-pin) * -1);
  z-index: 1;
  margin: calc(var(--ui-s-2) * -1) 0 calc(var(--session-result-pin) * -1);
  padding: var(--ui-s-2) 0 var(--session-result-pin);
  background: var(--f-fill);
}
/* Fix round: the rule and fade only when more than the fade's 12 px scrolls under the row
   (data-more, session-result.js fit()); otherwise the chips above it stay crisp. */
.session-result[data-fit="scroll"][data-more] .session-result-actions { box-shadow: 0 calc(var(--ui-px) * -1) 0 0 var(--ui-surface-shade); }
/* Bug hunter fix round (568x320): scrolled to its end, the last of the content (the chip strip,
   and its focus ring) sat under the rule and fade. 16 px of paper runway (--ui-s-4: the 12 px
   fade, the rule and a focus ring) lets it scroll clear of both; session-result.js scrolls a
   focused control there. */
.session-result[data-fit="scroll"][data-more] .session-result-actions { margin-top: calc(var(--ui-s-4) - var(--ui-s-2)); }
.session-result[data-fit="scroll"][data-more] .session-result-actions::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + var(--ui-px));
  height: var(--ui-s-3);
  background: linear-gradient(to top, var(--f-fill), transparent);
  pointer-events: none;
}
/* UX-576 fix round 2: so the pinned row never hides a beat's one-time New line (667x375,
   700x390, staged): the New block moves up under the title, and the chips keep to one row that
   scrolls sideways (no bar; they are a summary, the beat's line is the news). Title, ×, New line
   and actions then all show at once; anything left over scrolls under the pinned row.
   Fix round: the same order in "stack" (a card too short for a pinned row, e.g. 568x320: it
   scrolls whole, × at its top); both keep an 8 px rhythm and a 12 px foot. */
.session-result:is([data-fit="stack"], [data-fit="scroll"]) { gap: var(--ui-s-2); --session-result-pb: var(--ui-s-3); }
.session-result:is([data-fit="stack"], [data-fit="scroll"]) > .session-result-head { order: -2; margin-bottom: calc(var(--ui-s-2) * -1); }
.session-result:is([data-fit="stack"], [data-fit="scroll"]) > .session-result-intro { order: -1; }
.session-result:is([data-fit="stack"], [data-fit="scroll"]) .session-result-chips {
  flex-wrap: nowrap;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  /* A chip cut at the edge fades out (there is more to swipe), it is not sliced; the row's end
     padding (the fade's width) lets the last chip scroll fully clear of it. */
  padding-inline-end: var(--ui-s-5);
  mask-image: linear-gradient(to left, transparent, var(--ui-ink) var(--ui-s-5));
}
.session-result:is([data-fit="stack"], [data-fit="scroll"]) .session-result-chips::-webkit-scrollbar { display: none; }
.session-result:is([data-fit="stack"], [data-fit="scroll"]) .session-result-chips .chip { flex: none; white-space: nowrap; }
/* UX-739/755 fix round: out of the cottage the view makes room for you, so a "stack" card's
   chips wrap where it still fits whole (data-strip "wrap", session-result.js fit()): every
   reward reads, on the desktop card's width (two rows of seven chips, not three). */
.session-result[data-fit="stack"][data-strip="wrap"] { width: min(480px, 100%); }
.session-result[data-fit="stack"][data-strip="wrap"] .session-result-chips { flex-wrap: wrap; overflow-x: visible; padding-inline-end: 0; mask-image: none; }
/* UX-752/740 fix round: the smallest phones, the card over you (data-actions "pair",
   session-result.js tightLine): its two actions side by side, equal width, 44 px tall, a row
   less, so the view can show you above it. (A beat's actions keep their own stack, UX-547.) */
.session-result[data-actions="pair"] .session-result-actions:not(:has(> [data-intro])) > .btn { flex: 1 1 0; min-width: 0; padding-inline: var(--ui-s-2); white-space: normal; }
/* Head CHANGES UX-573 (2): a narrow phone's beat card keeps its chips to that one row too: a
   second session's level-up chip wrapped them to two rows and the card grew 32 px over you at
   the cottage door (Fernwood's beat, flag on). The Level chip leads; the rest scroll sideways.
   UX-734: the first session's quest chip makes four (XP, coins, the quest and "Mochi grew a
   little": the last was cut to "Mo…" under the fade). Where the taller card still keeps 8 px
   clear of you (seated at the desk, say), the row wraps, so every reward reads
   (data-chips="wrap", session-result.js wrapChips); in at the door it would cover you, so there
   the row stays one row, as before. The pet keeps out from under the card on its own (setAvoid). */
@media (max-width: 600px) {
  .session-result:has(.session-result-intro):not([data-chips]) .session-result-chips { flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; padding-inline-end: var(--ui-s-5); mask-image: linear-gradient(to left, transparent, var(--ui-ink) var(--ui-s-5)); }
  .session-result:has(.session-result-intro):not([data-chips]) .session-result-chips::-webkit-scrollbar { display: none; }
  .session-result:has(.session-result-intro):not([data-chips]) .session-result-chips .chip { flex: none; white-space: nowrap; }
  /* Fix round (320x568, seated): wrapped, the card would rise over the top bar. Packed, the coins
     and the quest lead (two rows, not three); still too tall, it is capped 8 px under the top
     band (--session-wrap-h, session-result.js wrapChips) and scrolls inside, every chip whole. */
  .session-result[data-chips="pack"] .session-result-chips .chip--coins { order: -2; }
  .session-result[data-chips="pack"] .session-result-chips .chip--quest { order: -1; }
  /* Head CHANGES 20261102-0541 (3): capped, it scrolls inside as said (taller than 480 px the
     short-screen overflow rule did not reach it, so "Open Home" spilled out of the card's foot
     over the café's grid at 320x568). */
  /* UX-773: a card without a beat, capped under the top band the same way (data-cap, clearBand). */
  .status-stack > .session-result:is([data-chips="pack"], [data-cap]) { max-height: min(var(--session-wrap-h, 100vh), var(--session-fit-h, calc(var(--session-vh) - var(--sheet-bottom) - var(--hud-edge)))); overflow-y: auto; overscroll-behavior: contain; }
}
/* Head CHANGES UX-576/577 polish: such a row is a keyboard stop (session-result.js fit()); its
   focus ring is the buttons' (drawn inside, so the card's scroll box does not clip it), whole:
   the edge fade steps aside while it is focused. */
.session-result .session-result-chips:focus-visible { outline: var(--ui-focus-ring-w) solid var(--ui-focus-ring); outline-offset: calc(var(--ui-focus-ring-w) * -1); mask-image: none; }
@media (pointer: fine) and (min-width: 601px) {
  /* (An intro beat's card too, UX-439: its chips stay on one row and its line on two.) */
  .session-result:is(:has(.session-result-next), :has(.session-result-intro)) { width: min(480px, 100%); }
  /* As on phones, the beat's card keeps the plain card's height so it clears you and your pet:
     the minutes line steps aside (the chips say it) and the tag leads its line. */
  .session-result:has(.session-result-intro) > p { display: none; }
  .session-result-intro { grid-template-columns: auto minmax(0, 1fr); align-items: baseline; column-gap: var(--ui-s-2); }
  .session-result .session-result-actions { flex-wrap: nowrap; }
  .session-result .session-result-actions .btn { flex: none; }
}
@media (pointer: coarse), (max-width: 600px) {
  .session-result p.session-result-next { flex: 1 0 100%; padding: var(--ui-s-2) 0 0; border-left: 0; border-top: var(--ui-px) solid var(--ui-surface-shade); }
}
/* Head CHANGES 0841 (3): a card narrower than the 480 px desktop card (its content box is 448 px;
   a short laptop's cottage column, a small tablet) puts the step on its own line under the
   buttons, as phones do. */
@container session-result (max-width: 439px) {
  .session-result .session-result-actions { flex-wrap: wrap; }
  .session-result p.session-result-next { flex: 1 0 100%; padding: var(--ui-s-2) 0 0; border-left: 0; border-top: var(--ui-px) solid var(--ui-surface-shade); }
}
/* UX-547 fix round: phones under about 360 px (a card content box under 300 px, e.g. 320x568):
   a beat's two actions stack at full, equal width, the beat's own first, 8 px apart (the row's gap). */
@container session-result (max-width: 299px) {
  .session-result .session-result-actions:has(> [data-intro]) { flex-direction: column; align-items: stretch; }
  .session-result .session-result-actions:has(> [data-intro]) > .btn { width: 100%; }
}
@media (pointer: coarse), (max-width: 600px) {
  .session-result .session-result-close { width: var(--ui-target); min-width: var(--ui-target); min-height: var(--ui-target); }
  .session-result { padding-top: var(--ui-s-1); }
  .session-result .session-result-head { margin-right: calc(var(--ui-s-3) * -1); }
}

/* The beat's coins (src/session-beat.js): pixel coins in an overlay above the HUD that takes
   no input; each is placed at the chip's coin and flown by the Web Animations API (leaving at
   2x, 28 px, landing at 1x on the counter's coin), then removed. Gold with a 1 UI px cocoa
   outline, so they read over grass, trees and paper. The counter pops 1 UI px up as the last
   one lands. Never under reduced motion. */
.coin-fly-layer { position: fixed; inset: 0; z-index: var(--z-toast); overflow: hidden; pointer-events: none; }
.coin-fly {
  --ico: 28px;
  position: absolute;
  display: block;
  width: var(--ico);
  height: var(--ico);
  margin: calc(var(--ico) / -2) 0 0 calc(var(--ico) / -2);
  color: var(--ui-coin);
  /* On the box, not the masked coin: a mask would clip the outline away. */
  filter:
    drop-shadow(var(--ui-px) 0 0 var(--ui-line-deep))
    drop-shadow(calc(var(--ui-px) * -1) 0 0 var(--ui-line-deep))
    drop-shadow(0 var(--ui-px) 0 var(--ui-line-deep))
    drop-shadow(0 calc(var(--ui-px) * -1) 0 var(--ui-line-deep));
  will-change: transform;
}
.coin-fly .ico { display: block; }
.status-coin-count.is-landed { animation: coin-count-pop var(--ui-dur-fast) var(--ui-ease-out); }
@keyframes coin-count-pop { 50% { transform: translateY(calc(var(--ui-px) * -1)); } }
@media (prefers-reduced-motion: reduce) { .status-coin-count.is-landed { animation: none; } }

/* Phones: full screen (the frame's edges off-screen); health cards above and below the stage. */
@media (max-width: 600px) {
  .dungeon-layer { padding: 0; place-items: stretch; }
  .dungeon-frame { width: 100%; height: 100%; max-height: none; gap: var(--ui-s-3); padding: var(--ui-s-3) var(--ui-s-4) calc(var(--ui-s-4) + env(safe-area-inset-bottom)); align-content: start; box-shadow: none; }
  .dungeon-room { grid-template-columns: minmax(0, 1fr); justify-items: center; text-align: center; }
  .dungeon-room .dungeon-actions { justify-content: center; }
  .battle-stage { display: grid; gap: var(--ui-s-2); margin: 0; overflow: visible; background: none; box-shadow: none; }
  .battle-canvas { width: calc(100% - var(--ui-px) * 2); margin: var(--ui-px); background: var(--ui-stage-bg); box-shadow: var(--ui-frame-edge); }
  .battle-box { position: static; width: auto; margin: var(--ui-px) var(--ui-px) calc(var(--ui-px) * 3); }
  .battle-box.foe { order: -1; }
  .battle-menu { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .battle-moves { grid-template-columns: minmax(0, 1fr); }
  /* The Rifts tab's small Focus is the standard secondary on phones. */
  #rifts-dialog .energy-focus.btn--sm { padding: 0 var(--ui-s-4); font-size: var(--ui-fs-16); }
}

/* ---------- Map (UX-006 B6, UI-V2 §4 B5): the full-size sheet's interior ----------
   The title row names the panel ("Map", Pixelify 20) over one muted line (where you are, and
   the World guide as a ghost button). Left: the painted map (its ground and trails stay in
   shell.css) in a 1 UI px frame edge, each place a rest-frame card (art, Pixelify 16 name,
   Outfit 14 muted meta); the chosen place is the one v2 selected look (a flat frame in
   --ui-selected with strong ink, as the selected tab), and "You" is a small paper tag.
   Right: the place (Pixelify 20 name, Outfit 14 muted kind and blurb), 20 px status chips,
   ONE primary (Travel now / Go there / Join), every other action secondary, then its places as
   one sunk card of rows, or "Around you" as a grid of secondary buttons (Outfit 14/600, no
   arrow glyphs; disabled ones stay readable: muted ink on the disabled fill, 6.0:1).
   Sizes: 20 · 16 · 14 only. The details column fades at the bottom while it scrolls.
   Ids and classes stay as src/world-map.js and the tests know them. */
.sheet-body > #map-dialog[open] { display: flex; flex-direction: column; padding-bottom: var(--ui-s-4); }
#map-dialog { --map-row-h: calc(var(--ui-s-6) + var(--ui-s-2)); } /* 40: a secondary button's height */
#map-dialog .dialog-heading { flex: none; align-items: flex-start; }
#map-dialog .map-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 0 var(--ui-s-2); margin: var(--ui-s-1) 0 0; color: var(--ui-ink-muted); font-family: var(--ui-font-body); font-size: var(--ui-fs-14); line-height: 1.5; }
#map-dialog .map-current { color: var(--ui-ink-muted); }
#map-dialog .map-explorer { margin-left: calc(var(--ui-s-3) * -1 + var(--ui-s-2)); }
#map-dialog .map-layout { display: grid; flex: 1; grid-template-columns: minmax(0, 1fr) minmax(300px, 360px); gap: var(--ui-s-5); min-height: 0; }

/* The painted map: a 1 UI px frame edge (corners notched), no radius. It is its own stacking
   layer (UX-334), so a card's raise (selected, focused, "You") orders it among the cards only
   and the sticky title row above stays on top while the sheet scrolls. */
#map-dialog .map-world { isolation: isolate; margin: var(--ui-px); border: 0; border-radius: 0; box-shadow: var(--ui-frame-edge); }

/* Place cards: a secondary button's rest frame (paper, edge, 1 UI px drop). */
#map-dialog .map-place {
  /* UX-394: a card's centre is held far enough in from the map's edges that the whole card and
     its focus ring (4 offset + 2 ring, the 8 here) stay inside the frame's overflow: hidden
     (Your cottage lost 9 px at 1024x600, Study hall 4 px at the bottom at 1280x720). The height
     is the picture (5:3 of the card's inner width) plus the name and kind rows. */
  --map-card-w: clamp(calc(var(--ui-s-7) * 2.5), 13.5vw, 172px);
  --map-card-h: calc(var(--map-card-w) * .6 + 56px);
  position: absolute;
  left: clamp(calc(var(--map-card-w) / 2 + var(--ui-s-2)), var(--x), calc(100% - var(--map-card-w) / 2 - var(--ui-s-2)));
  top: clamp(calc(var(--map-card-h) / 2 + var(--ui-s-2)), var(--y), calc(100% - var(--map-card-h) / 2 - var(--ui-s-2)));
  z-index: 2;
  display: grid;
  gap: var(--ui-s-1);
  box-sizing: border-box;
  width: var(--map-card-w);
  min-height: 0;
  margin: 0;
  padding: var(--ui-s-1) var(--ui-s-1) var(--ui-s-2);
  color: var(--ui-ink);
  background: var(--ui-frame-fill);
  border: 0;
  border-radius: 0;
  box-shadow:
    inset var(--ui-px) var(--ui-px) 0 0 var(--ui-frame-hi),
    inset calc(var(--ui-px) * -1) calc(var(--ui-px) * -1) 0 0 var(--ui-frame-shade),
    var(--ui-frame-edge),
    0 calc(var(--ui-px) * 2) 0 0 var(--ui-frame-drop);
  font-family: var(--ui-font-body);
  letter-spacing: 0;
  text-align: left;
  text-transform: none;
  cursor: pointer;
  transform: translate(-50%, -50%);
  transition: background-color var(--ui-dur-fast) var(--ui-ease-out);
}
#map-dialog .map-place.map-cafe { --map-card-w: clamp(104px, 10.5vw, 136px); }
#map-dialog .map-place:hover { background: var(--ui-secondary-hover); }
#map-dialog .map-place:active {
  transform: translate(-50%, calc(-50% + var(--ui-press)));
  box-shadow:
    inset var(--ui-px) var(--ui-px) 0 0 var(--ui-frame-hi),
    inset calc(var(--ui-px) * -1) calc(var(--ui-px) * -1) 0 0 var(--ui-frame-shade),
    var(--ui-frame-edge),
    0 var(--ui-px) 0 0 var(--ui-frame-drop);
}
#map-dialog .map-place:focus-visible { z-index: 3; outline: var(--ui-focus-ring-w) solid var(--ui-focus-ring); outline-offset: calc(var(--ui-px) * 2); }
/* The one "chosen" look (UI-V2 §2.2): the selected tab's flat frame in --ui-selected. */
#map-dialog .map-place.is-selected {
  z-index: 3;
  color: var(--ui-ink-strong);
  background: var(--ui-selected);
  box-shadow:
    inset var(--ui-px) var(--ui-px) 0 0 var(--ui-surface-hi),
    inset calc(var(--ui-px) * -1) calc(var(--ui-px) * -1) 0 0 var(--ui-coin-deep),
    var(--ui-frame-edge),
    0 var(--ui-px) 0 0 var(--ui-frame-drop);
}
#map-dialog .map-place-art { position: relative; display: block; overflow: hidden; border: 0; border-radius: 0; }
#map-dialog .map-place-art img { display: block; width: 100%; height: auto; aspect-ratio: 5 / 3; object-fit: cover; image-rendering: pixelated; }
/* A 1 UI px shade rule round the picture, drawn over it (the minimap's recipe). */
#map-dialog .map-place-art::after { content: ""; position: absolute; inset: 0; box-shadow: inset 0 0 0 var(--ui-px) var(--ui-frame-shade); pointer-events: none; }
#map-dialog .map-place.is-selected .map-place-art::after { box-shadow: inset 0 0 0 var(--ui-px) var(--ui-coin-deep); }
#map-dialog .map-place.unexplored .map-place-art img { filter: saturate(.25) brightness(1.08) contrast(.85); }
#map-dialog .map-place.unexplored .map-place-art::after {
  content: "?";
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--ui-surface) 40%, transparent);
  color: var(--ui-ink);
  font-family: var(--ui-font-display);
  font-size: var(--ui-fs-20);
}
#map-dialog .map-place-name { padding: 0 var(--ui-s-1); font-family: var(--ui-font-display); font-size: var(--ui-fs-16); font-weight: 600; line-height: 1.25; }
#map-dialog .map-place-meta { min-height: 1.25em; padding: 0 var(--ui-s-1); color: var(--ui-ink-muted); font-size: var(--ui-fs-14); line-height: 1.25; }
#map-dialog .map-place.is-selected .map-place-meta { color: var(--ui-ink-strong); }
/* "You": a paper tag in a frame edge over the card you are in, your sprite at 1x. */
#map-dialog .map-you {
  position: absolute;
  top: calc(var(--ui-s-5) * -1);
  left: 50%;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: var(--ui-px);
  height: var(--ui-s-5);
  padding: 0 var(--ui-s-2) 0 0;
  transform: translateX(-50%);
  color: var(--ui-ink);
  background: var(--ui-frame-fill);
  border: 0;
  border-radius: 0;
  box-shadow: var(--ui-frame-edge);
  font-family: var(--ui-font-body);
  font-size: var(--ui-fs-14);
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}
#map-dialog .map-you[hidden] { display: none; }
#map-dialog .map-you canvas { width: 32px; height: 34px; margin: calc(var(--ui-s-3) * -1) 0 0; image-rendering: pixelated; }
@media (prefers-reduced-motion: no-preference) {
  #map-dialog .map-you { animation: map-you 1.6s ease-in-out infinite; }
  @keyframes map-you { 50% { transform: translate(-50%, calc(var(--ui-px) * -2)); } }
}

/* The details column. */
#map-dialog .map-detail { display: grid; align-content: start; gap: var(--ui-s-3); min-height: 0; overflow: auto; padding: var(--ui-px) var(--ui-px) var(--ui-s-4); }
#map-dialog .map-detail.more-below {
  -webkit-mask-image: linear-gradient(to bottom, black calc(100% - var(--ui-s-7)), transparent);
  mask-image: linear-gradient(to bottom, black calc(100% - var(--ui-s-7)), transparent);
}
#map-dialog .map-detail-art img { display: block; width: 100%; aspect-ratio: 2 / 1; object-fit: cover; image-rendering: pixelated; border: 0; border-radius: 0; box-shadow: var(--ui-frame-edge); }
#map-dialog .map-detail-head { display: grid; gap: var(--ui-s-1); }
#map-dialog .map-detail-kind { margin: 0; color: var(--ui-ink-muted); font-family: var(--ui-font-body); font-size: var(--ui-fs-14); font-weight: 500; line-height: 1.25; letter-spacing: 0; text-transform: none; }
#map-dialog .map-detail-head h3 { margin: 0; color: var(--ui-ink); font-family: var(--ui-font-display); font-size: var(--ui-fs-20); font-weight: 600; line-height: 1.2; letter-spacing: 0; }
#map-dialog :is(.map-detail-blurb, .map-route, .map-empty) { margin: 0; color: var(--ui-ink-muted); font-family: var(--ui-font-body); font-size: var(--ui-fs-14); line-height: 1.5; }
#map-dialog .map-locked { color: var(--ui-ink); font-weight: 600; }
/* Status chips: 20 tall, paper, a shade line; an 8 px square says here / portal / locked. */
#map-dialog .map-chips { display: flex; flex-wrap: wrap; gap: var(--ui-s-2); }
#map-dialog .map-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--ui-s-1);
  box-sizing: border-box;
  height: var(--ui-s-5);
  padding: 0 var(--ui-s-2);
  color: var(--ui-ink);
  background: var(--ui-surface);
  border: 0;
  border-radius: var(--ui-r-pill);
  box-shadow: inset 0 0 0 var(--ui-px) var(--ui-surface-shade);
  font-family: var(--ui-font-body);
  font-size: var(--ui-fs-14);
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
}
#map-dialog .map-chip:is(.here, .portal, .locked)::before { content: ""; flex: none; width: var(--ui-s-2); height: var(--ui-s-2); background: var(--ui-ink-muted); }
#map-dialog .map-chip.here::before { background: var(--ui-success); }
#map-dialog .map-chip.portal::before { background: var(--ui-coin); }
/* Actions: one primary, the rest secondary; the route under them in muted words. */
#map-dialog .map-actions { display: grid; gap: var(--ui-s-2); }
#map-dialog .map-actions:empty { display: none; }
#map-dialog .map-note { margin: 0; padding: var(--ui-s-3) var(--ui-s-4); color: var(--ui-ink); background: var(--ui-surface-sunk); border: 0; border-radius: 0; box-shadow: inset 0 0 0 var(--ui-px) var(--ui-surface-shade); font-family: var(--ui-font-body); font-size: var(--ui-fs-14); line-height: 1.5; }
/* Places here / Around you: a section heading (Pixelify 16), then the list. */
#map-dialog .map-places { display: grid; gap: var(--ui-s-2); }
#map-dialog .map-places h4 { margin: var(--ui-s-3) 0 0; color: var(--ui-ink); font-family: var(--ui-font-display); font-size: var(--ui-fs-16); font-weight: 600; line-height: 1.25; letter-spacing: 0; }
/* Places in another world: one sunk card of rows, the name and a muted line, Go on the right. */
#map-dialog .map-place-list {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0 var(--ui-s-3) 0 var(--ui-s-4);
  list-style: none;
  background: var(--ui-surface-sunk);
  border: 0;
  border-radius: 0;
  box-shadow: inset 0 0 0 var(--ui-px) var(--ui-surface-shade);
}
#map-dialog .map-place-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ui-s-3);
  margin: 0;
  padding: var(--ui-s-2) 0;
  background: none;
  border: 0;
  border-radius: 0;
  box-shadow: inset 0 calc(var(--ui-px) * -1) 0 0 var(--ui-surface-shade);
}
#map-dialog .map-place-list li:last-child { box-shadow: none; }
#map-dialog .map-place-copy { display: grid; gap: var(--ui-px); min-width: 0; }
#map-dialog .map-place-copy strong { overflow: hidden; color: var(--ui-ink); font-family: var(--ui-font-display); font-size: var(--ui-fs-16); font-weight: 600; line-height: 1.25; white-space: nowrap; text-overflow: ellipsis; }
#map-dialog .map-place-copy small { color: var(--ui-ink-muted); font-family: var(--ui-font-body); font-size: var(--ui-fs-14); line-height: 1.25; }
#map-dialog .map-go { flex: none; }
#map-dialog .map-passport { justify-self: start; }
/* Around you: every place a secondary button in an even grid (two across in the column). */
#map-dialog .map-here { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: var(--ui-s-2); }
#map-dialog .map-here[hidden] { display: none; }
#map-dialog .map-here > h3 { display: none; }
#map-dialog .map-here .location-actions { display: contents; }
#map-dialog .map-here .location-actions[hidden] { display: none; }
#map-dialog .map-here .location-actions button {
  display: block;
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  height: auto;
  min-height: var(--map-row-h);
  margin: 0;
  padding: 0 var(--ui-s-3);
  overflow: hidden;
  color: var(--ui-ink);
  background: var(--ui-frame-fill);
  border: 0;
  border-radius: 0;
  box-shadow:
    inset var(--ui-px) var(--ui-px) 0 0 var(--ui-frame-hi),
    inset calc(var(--ui-px) * -1) calc(var(--ui-px) * -1) 0 0 var(--ui-frame-shade),
    var(--ui-frame-edge),
    0 calc(var(--ui-px) * 2) 0 0 var(--ui-frame-drop);
  font-family: var(--ui-font-body);
  font-size: var(--ui-fs-14);
  font-weight: 600;
  line-height: var(--map-row-h);
  letter-spacing: 0;
  text-align: left;
  text-transform: none;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color var(--ui-dur-fast) var(--ui-ease-out), transform var(--ui-dur-fast) var(--ui-ease-out);
}
#map-dialog .map-here .location-actions button::before,
#map-dialog .map-here .location-actions button::after { content: none; }
#map-dialog .map-here .location-actions button:hover:not(:disabled) { background: var(--ui-secondary-hover); }
#map-dialog .map-here .location-actions button:active:not(:disabled) {
  transform: translateY(var(--ui-press));
  box-shadow:
    inset var(--ui-px) var(--ui-px) 0 0 var(--ui-frame-hi),
    inset calc(var(--ui-px) * -1) calc(var(--ui-px) * -1) 0 0 var(--ui-frame-shade),
    var(--ui-frame-edge),
    0 var(--ui-px) 0 0 var(--ui-frame-drop);
}
#map-dialog .map-here .location-actions button:focus-visible { position: relative; z-index: 1; outline: var(--ui-focus-ring-w) solid var(--ui-focus-ring); outline-offset: calc(var(--ui-px) * 2); }
/* Waiting (the garden's watering timer says why in its own words): flat, muted, still readable. */
#map-dialog .map-here .location-actions button:disabled {
  color: var(--ui-ink-muted);
  background: var(--ui-disabled-bg);
  box-shadow: var(--ui-frame-edge);
  opacity: 1;
  cursor: not-allowed;
}

/* Narrower windows: a 300 px details column, then one column (the sheet scrolls, no fade). */
@media (max-width: 980px) {
  #map-dialog .map-layout { grid-template-columns: minmax(0, 1fr) 300px; }
}
@media (max-width: 860px) {
  #map-dialog .map-layout { flex: none; grid-template-columns: 1fr; }
  #map-dialog .map-world { min-height: 360px; }
  #map-dialog .map-detail { overflow: visible; }
  #map-dialog .map-detail.more-below { -webkit-mask-image: none; mask-image: none; }
}
@media (max-height: 560px) and (min-width: 721px) {
  #map-dialog .map-world { min-height: 300px; }
}
/* Phones: the map keeps its shape (cards at their phone spots, names only), 44 px targets. */
@media (max-width: 720px) {
  #map-dialog .map-world { min-height: 0; aspect-ratio: 4 / 3.4; }
  #map-dialog .map-place { left: var(--mx); top: var(--my); width: 30%; gap: var(--ui-px); padding: var(--ui-px) var(--ui-px) var(--ui-s-1); }
  #map-dialog .map-place.map-cafe { width: 24%; }
  #map-dialog .map-place-meta { display: none; }
  #map-dialog .map-place-name { padding: 0 var(--ui-px); font-size: var(--ui-fs-12); line-height: 1.2; }
  /* The cards sit close together: "You" moves inside the card, over its picture's corner. */
  #map-dialog .map-you { top: var(--ui-s-1); left: var(--ui-s-1); z-index: 3; padding: 0 var(--ui-s-2); transform: none; animation: none; }
  #map-dialog .map-you canvas { display: none; }
  #map-dialog .map-here .location-actions button { min-height: var(--ui-target); line-height: var(--ui-target); }
}
@media (pointer: coarse) {
  #map-dialog .map-here .location-actions button { min-height: var(--ui-target); line-height: var(--ui-target); }
}
@media (prefers-reduced-motion: reduce) {
  #map-dialog :is(.map-place, .map-here .location-actions button) { transition: none; }
}
/* UX-496 slice 2 (flag on): a world not introduced yet has no card. ONE overgrown tile stands
   for all of them: the slice-1 arch's vines (meadow on a faded paper fill) in a dashed moss
   edge, and one calm line. Scenery, not a button: not a .map-place, no hover, no press, no count. */
#map-dialog :is(.map-place, .map-uncleared)[hidden] { display: none; }
#map-dialog .map-uncleared {
  position: absolute;
  left: var(--x);
  top: var(--y);
  z-index: 1;
  display: grid;
  gap: var(--ui-s-1);
  box-sizing: border-box;
  width: clamp(calc(var(--ui-s-7) * 2.5), 13.5vw, 172px);
  padding: var(--ui-s-1) var(--ui-s-1) var(--ui-s-2);
  color: var(--ui-ink-muted);
  font-family: var(--ui-font-body);
  background: color-mix(in srgb, var(--ui-frame-fill) 88%, transparent);
  box-shadow: none;
  outline: var(--ui-px) dashed var(--p-meadow-600);
  outline-offset: calc(var(--ui-px) * -1);
  cursor: default;
  transform: translate(-50%, -50%);
}
#map-dialog .map-uncleared-art {
  aspect-ratio: 5 / 3;
  background:
    radial-gradient(closest-side, var(--p-meadow-400) 0 70%, transparent 72%) var(--ui-s-1) var(--ui-s-2) / var(--ui-s-4) var(--ui-s-3),
    radial-gradient(closest-side, var(--p-meadow-600) 0 70%, transparent 72%) var(--ui-s-3) var(--ui-s-1) / var(--ui-s-4) var(--ui-s-4),
    repeating-linear-gradient(90deg, transparent 0 calc(var(--ui-s-4) - var(--ui-px)), var(--p-meadow-600) 0 var(--ui-s-4)),
    color-mix(in srgb, var(--p-meadow-200) 45%, var(--ui-frame-fill));
  -webkit-mask-image: linear-gradient(to bottom, var(--ui-ink) 45%, transparent);
  mask-image: linear-gradient(to bottom, var(--ui-ink) 45%, transparent);
}
#map-dialog .map-uncleared-art::after { content: none; }
#map-dialog .map-uncleared-line { min-height: 0; text-align: center; text-wrap: balance; }
#map-dialog .map-trail.uncleared { stroke-dasharray: .5 13; opacity: .6; }
@media (max-width: 720px) {
  #map-dialog .map-uncleared { left: var(--mx); top: var(--my); width: 30%; gap: var(--ui-px); padding: var(--ui-px) var(--ui-px) var(--ui-s-1); }
  #map-dialog .map-uncleared-line { display: block; padding: 0 var(--ui-px); font-size: var(--ui-fs-12); line-height: 1.2; }
}

/* ---------- Settings (UX-006 B8a, UI-V2 §4 B7): the You sheet's Settings tab ----------
   The Journal's recipe: a column of flat sunk cards 12 apart (12 16 padding, 1 UI px shade
   line), each titled Pixelify 16 in sentence case. A setting is one row: its label (Outfit 16)
   with an optional muted hint (Outfit 14) on its own line under it, the control on the right;
   1 UI px shade rules between rows. On/off settings are the Switch; the backup source is the
   Select (the Input component); Help and the backup actions are secondary buttons. No primary:
   every setting applies at once. Sizes in the panel: 20 (title), 16, 14.
   Ids stay as app.js, play.js, ui-shell.js, native.js and the tests know them. */
#settings-dialog .dialog-intro {
  max-width: none;
  margin: 0 0 var(--ui-s-3);
  color: var(--ui-ink-muted);
  font-family: var(--ui-font-body);
  font-size: var(--ui-fs-14);
  line-height: 1.5;
}
/* Groups, headings, rows, labels and hints are the shared .ui-section / .ui-row layout
   (Menu controls, below). Only the parts Settings alone has stay here. */
/* A row is the whole label, so it is one 44+ px target for its switch (the .ui-row recipe). */
#settings-dialog div.settings-row { cursor: default; }

/* Switch: a real checkbox (role="switch") over a square pixel track. The input is the hit
   area (36 tall, 44 on touch and phones) and stays transparent; the track draws it: off, a
   sunk paper track (bevel inverted) with the thumb on the left; on, the accent green with the
   thumb on the right. Thumb: a 16 px paper square in a 1 UI px frame. 120 ms slide; reduced
   motion: no slide. Focus: the ring round the track. */
.ui-switch {
  position: relative;
  display: inline-grid;
  place-items: center;
  flex: none;
  width: var(--ui-s-7);
  height: 36px;
}
.ui-switch > input[type="checkbox"] {
  -webkit-appearance: none;
  appearance: none;
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  opacity: 0;
  cursor: pointer;
}
.ui-switch-track {
  position: relative;
  display: block;
  box-sizing: border-box;
  width: var(--ui-s-7);
  height: var(--ui-s-5);
  background: var(--ui-surface-shade);
  box-shadow:
    inset var(--ui-px) var(--ui-px) 0 0 var(--ui-frame-shade),
    inset calc(var(--ui-px) * -1) calc(var(--ui-px) * -1) 0 0 var(--ui-surface-hi),
    var(--ui-frame-edge);
  pointer-events: none;
  transition: background-color var(--ui-dur-fast) var(--ui-ease-out);
}
.ui-switch-track::after {
  content: "";
  position: absolute;
  top: var(--ui-s-1);
  left: var(--ui-s-1);
  width: var(--ui-s-4);
  height: var(--ui-s-4);
  background: var(--ui-frame-fill);
  box-shadow:
    inset var(--ui-px) var(--ui-px) 0 0 var(--ui-surface-hi),
    inset calc(var(--ui-px) * -1) calc(var(--ui-px) * -1) 0 0 var(--ui-frame-shade),
    var(--ui-frame-edge);
  transition: transform var(--ui-dur-fast) var(--ui-ease-out), background-color var(--ui-dur-fast) var(--ui-ease-out);
}
.ui-switch > input:checked + .ui-switch-track { background: var(--ui-accent); }
.ui-switch > input:checked + .ui-switch-track::after { transform: translateX(var(--ui-s-5)); }
:is(.ui-switch:hover, .settings-row:hover) .ui-switch-track::after { background: var(--ui-secondary-hover); }
.ui-switch > input:active + .ui-switch-track::after {
  box-shadow:
    inset var(--ui-px) var(--ui-px) 0 0 var(--ui-frame-shade),
    inset calc(var(--ui-px) * -1) calc(var(--ui-px) * -1) 0 0 var(--ui-surface-hi),
    var(--ui-frame-edge);
}
.ui-switch > input:focus-visible { outline: none; }
.ui-switch > input:focus-visible + .ui-switch-track { outline: var(--ui-focus-ring-w) solid var(--ui-focus-ring); outline-offset: calc(var(--ui-px) * 2); }
.ui-switch > input:disabled { cursor: not-allowed; }
.ui-switch > input:disabled + .ui-switch-track { background: var(--ui-disabled-bg); box-shadow: 0 0 0 var(--ui-px) var(--ui-disabled-line); }
.ui-switch > input:disabled + .ui-switch-track::after { background: var(--ui-disabled-bg); box-shadow: 0 0 0 var(--ui-px) var(--ui-disabled-line); }

/* Touch-only devices have no keyboard: no shortcuts button. */
@media (hover: none) and (pointer: coarse) { #settings-dialog .settings-keyboard { display: none; } }

/* Your data: the backup source (Select), then Export / Import side by side. */
#settings-dialog #install-app { margin-bottom: 0; }
#settings-dialog #install-app[hidden] { display: none; }
/* The phone app's alerts row: the status, then its one action under it (the copy is long). */
#settings-dialog .app-alerts { grid-template-columns: minmax(0, 1fr); row-gap: var(--ui-s-2); justify-items: start; }
#settings-dialog .app-alerts .btn[hidden] { display: none; }

@media (pointer: coarse), (max-width: 720px) {
  .ui-switch { height: var(--ui-target); }
  #settings-dialog .settings-row { min-height: var(--ui-target); }
}
@media (prefers-reduced-motion: reduce) {
  .ui-switch-track, .ui-switch-track::after { transition: none; }
}

/* ---------- You: Account and Character (UX-006 B8b, UI-V2 §4 B7) ----------
   The Settings recipe on both tabs: the tab's title (Pixelify 20) names the tab; a column of
   flat sunk cards 12 apart (12 16 padding, a 1 UI px shade line), each titled Pixelify 16 in
   sentence case; copy is an Outfit 16 label over a muted Outfit 14 hint; fields are the
   Input / Select components (Together's). One primary per view: signed out, Log in (Create
   account & sync); signed in, none (the cloud save runs on its own) unless a save conflict
   shows its Apply choice; Character, Save look. Sign out, Sync now and Open study rooms are
   secondary; Reset to saved look is ghost. Portraits are drawn by drawPortrait / drawPet and
   shown at 2x (whole pixels). Ids stay as app.js, creator.js, boutique-ui.js and the tests know them. */
/* Cards, headings, rows and hints are the shared .ui-section / .ui-row layout (Menu controls). */
/* (.account-hint / .creator-hint: .ui-row-hint / .ui-section-hint.) */

/* Signed out: the form's fields 12 apart, the error in danger ink, Log in across the card. */
#account-dialog .auth-form { display: grid; gap: var(--ui-s-3); margin: 0; }
#account-dialog .auth-form .ui-field[hidden] { display: none; }
#account-dialog .auth-status { margin: 0; color: var(--ui-ink-muted); font-family: var(--ui-font-body); font-size: var(--ui-fs-14); font-weight: 600; line-height: 1.5; }
#account-dialog .auth-status[data-tone="error"] { color: var(--ui-danger); }
#account-dialog .auth-status:empty { display: none; }
#account-dialog .account-providers { display: grid; gap: var(--ui-s-2); }
#account-dialog .account-providers[hidden] { display: none; }
#account-dialog #account-discord-rooms { text-decoration: none; }
#account-dialog .account-or { margin: 0; color: var(--ui-ink-muted); font-family: var(--ui-font-body); font-size: var(--ui-fs-14); text-align: center; }
/* A save conflict: the summary, the choice and Apply choice, under a 1 UI px rule. */
#account-dialog .account-recovery { display: grid; gap: var(--ui-s-3); padding-top: var(--ui-s-3); box-shadow: inset 0 var(--ui-px) 0 0 var(--ui-surface-shade); }
#account-dialog .account-recovery[hidden] { display: none; }

/* Character: the preview (the 120 x 60 canvas at 2x) over its pose, the sections switch,
   the cards, and the footer with Save look. */
#customize-dialog form { display: block; margin: 0; }
#customize-dialog .creator-preview { justify-items: center; }
#customize-dialog .creator-preview canvas { display: block; width: 240px; height: 120px; max-width: 100%; image-rendering: pixelated; }
#customize-dialog .creator-pose { justify-self: stretch; }
#customize-dialog .creator-tabs { margin: 0 0 var(--ui-s-3); }
#customize-dialog .creator-tabs > button[aria-selected="true"] {
  background: var(--ui-selected);
  color: var(--ui-ink-strong);
  box-shadow:
    inset var(--ui-px) var(--ui-px) 0 0 var(--ui-surface-hi),
    inset calc(var(--ui-px) * -1) calc(var(--ui-px) * -1) 0 0 var(--ui-coin-deep),
    var(--ui-frame-edge);
}
#customize-dialog .creator-columns { display: grid; gap: 0; min-width: 0; }
#customize-dialog .creator-section { min-width: 0; margin: 0; padding: 0; border: 0; }
#customize-dialog .creator-section[hidden] { display: none; }
/* GROVE-1.9: one column; each choice is a full-width segmented row under its name. */
#customize-dialog .creator-detail-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--ui-s-3); }

/* Style and kind tiles: an even grid of sunk slots (an input's inverted bevel); the portrait
   (drawPortrait "chip", 32 x 34) and the pet (40 x 40) drawn 2x; the name Outfit 14 under it.
   Chosen: the selected peach and strong ink, like a selected segment. */
#customize-dialog .sprite-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: var(--ui-s-2); margin: 0; }
/* The four styles on one row at every size (a tile is 74+ px: the 64 px portrait and its padding). */
#customize-dialog #avatar-presets { grid-template-columns: repeat(4, minmax(0, 1fr)); }
#customize-dialog .pet-gallery { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
#customize-dialog .sprite-choice {
  display: grid;
  justify-items: center;
  align-content: start;
  gap: var(--ui-s-1);
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: var(--ui-s-2) var(--ui-s-1);
  color: var(--ui-ink);
  background: var(--ui-frame-fill);
  border: 0;
  border-radius: 0;
  box-shadow:
    inset var(--ui-px) var(--ui-px) 0 0 var(--ui-surface-shade),
    inset calc(var(--ui-px) * -1) calc(var(--ui-px) * -1) 0 0 var(--ui-surface-hi),
    var(--ui-frame-edge);
  font-family: var(--ui-font-body);
  font-size: var(--ui-fs-14);
  font-weight: 600;
  line-height: 1.25;
  text-transform: capitalize;
  cursor: pointer;
  transition: background-color var(--ui-dur-fast) var(--ui-ease-out), transform var(--ui-dur-fast) var(--ui-ease-out);
}
#customize-dialog .sprite-choice span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#customize-dialog .sprite-choice canvas { display: block; width: 64px; height: 68px; image-rendering: pixelated; }
#customize-dialog .pet-gallery .sprite-choice canvas { width: 80px; height: 80px; }
#customize-dialog .sprite-choice:hover:not([aria-pressed="true"]) { background: var(--ui-secondary-hover); }
#customize-dialog .sprite-choice:active { transform: translateY(var(--ui-press)); }
#customize-dialog .sprite-choice[aria-pressed="true"] {
  color: var(--ui-ink-strong);
  background: var(--ui-selected);
  box-shadow:
    inset var(--ui-px) var(--ui-px) 0 0 var(--ui-surface-hi),
    inset calc(var(--ui-px) * -1) calc(var(--ui-px) * -1) 0 0 var(--ui-coin-deep),
    var(--ui-frame-edge);
}
#customize-dialog .sprite-choice:focus-visible { position: relative; z-index: 1; outline: var(--ui-focus-ring-w) solid var(--ui-focus-ring); outline-offset: calc(var(--ui-px) * 2); }

/* Colour swatches: 32 px squares (44 on touch and phones) in a 1 UI px cocoa edge; the chosen
   one gets a 1 UI px paper gap and a 2 UI px strong-ink ring, so it reads without colour. */
#customize-dialog .swatches { display: flex; flex-wrap: wrap; gap: var(--ui-s-2); margin: 0; }
#customize-dialog .swatch {
  flex: none;
  width: var(--ui-s-6);
  height: var(--ui-s-6);
  min-height: 0;
  margin: var(--ui-px);
  padding: 0;
  color: var(--ui-ink);
  border: 0;
  border-radius: 0;
  box-shadow: var(--ui-frame-edge);
  font-family: var(--ui-font-body);
  font-size: var(--ui-fs-16);
  line-height: 1;
  cursor: pointer;
}
#customize-dialog .swatch[aria-pressed="true"] {
  box-shadow:
    0 0 0 var(--ui-px) var(--ui-frame-fill),
    0 0 0 calc(var(--ui-px) * 3) var(--ui-ink-strong);
}
#customize-dialog .swatch:focus-visible { outline: var(--ui-focus-ring-w) solid var(--ui-focus-ring); outline-offset: calc(var(--ui-px) * 4); }

/* Custom art: the 16 x 16 grid (256 px, 16 px a cell), the paint colours, then the actions. */
#customize-dialog .pixel-workspace { display: grid; justify-items: start; gap: var(--ui-s-3); min-width: 0; }
#customize-dialog #pixel-editor { display: block; width: 256px; max-width: 100%; height: auto; image-rendering: pixelated; touch-action: none; cursor: crosshair; box-shadow: var(--ui-frame-edge); }
#customize-dialog #pixel-editor:focus-visible { outline: var(--ui-focus-ring-w) solid var(--ui-focus-ring); outline-offset: calc(var(--ui-px) * 2); }
#customize-dialog .pixel-actions { display: flex; flex-wrap: wrap; gap: var(--ui-s-2); }
#customize-dialog .pixel-actions .btn { flex: 1 1 0; }

/* The footer: Reset (ghost) and Save look (the primary), in the shared pinned .sheet-footer. */
#customize-dialog .creator-save { justify-content: flex-end; gap: var(--ui-s-2); }

@media (pointer: coarse), (max-width: 600px) {
  #customize-dialog .swatch { width: var(--ui-target); height: var(--ui-target); }
}
@media (max-width: 720px) {
  #customize-dialog .creator-save .btn { flex: 1 1 0; }
}
@media (prefers-reduced-motion: reduce) {
  #customize-dialog .sprite-choice { transition: none; }
  #customize-dialog .sprite-choice:active { transform: none; }
}

/* ---------- You: Wardrobe (UX-006 B8c, UI-V2 §4 B7) ----------
   The Account / Character recipe: the tab's title names it; a sunk wallet card (the pixel coin
   at 2x, the balance VT323 32 tabular, how many looks you have, one muted line); the looks as
   square pixel-frame tiles three across (the drawPortrait "tile" portrait, 40 x 42 at 2x, the
   name Outfit 14/600 on one line, then the price with the coin or an Owned / Wearing tag in
   Outfit 12); the signature gear as rows in a sunk card behind a disclosure; and a pinned footer
   for the selected offer with its ONE action (Buy · price, Wear, or a disabled Wearing; short of
   coins, a ghost How to earn). Selecting never spends: the tile is a toggle (aria-pressed) in the
   selected peach. Unaffordable prices are muted, the tile stays a normal, selectable tile. */
/* Things scrolled into view (keyboard focus, the last row) land fully above the pinned footer,
   8 clear of its rule, in all three shops: --shop-footer-h is the footer's measured height
   (purchase-moment.js trackShopFooters; it grows with a two- or three-line note). Before the
   first measure, the old fixed clearance. The clearance is each item's scroll margin, not the
   sheet's scroll padding: the footer is inside the sheet's scrollport, so a padding that tall
   made focusing the footer's own action (Tab, or focus staying on Buy as it turns into Wear
   now / Place now) scroll the grid by a screen to bring it "above the footer", pushing the
   tile just bought out of view (head CHANGES 20261022-0741). The footer keeps the sheet's
   16 px, so focusing it never scrolls. A tile already on screen but partly under the footer
   is brought clear by trackShopFooters when it takes keyboard focus, and by keepInView right
   after a buy (purchase-moment.js). */
:is(#boutique-dialog, #room-workshop-dialog, #shop-dialog) > :not(.boutique-detail, .room-detail, .shop-detail),
:is(#boutique-dialog, #room-workshop-dialog, #shop-dialog) > :not(.boutique-detail, .room-detail, .shop-detail) * {
  scroll-margin-bottom: calc(var(--shop-footer-h, calc(var(--ui-s-7) * 2)) + var(--ui-s-2) - var(--ui-s-4));
}
/* The wallet card is as tight as the Coins tab's (same recipe, same height): 8 above and below
   the coin row, which is the 2x coin's 28 (the VT323 balance sits in it on line-height .875). */
#boutique-dialog .boutique-wallet-card,
#shop-dialog .shop-wallet-card {
  display: grid;
  gap: var(--ui-s-1);
  margin: 0 0 var(--ui-s-3);
  padding: var(--ui-s-2) var(--ui-s-4);
  color: var(--ui-ink);
  background: var(--ui-surface-sunk);
  box-shadow: inset 0 0 0 var(--ui-px) var(--ui-surface-shade);
}
#boutique-dialog .boutique-wallet-line,
#shop-dialog .shop-wallet-line { display: flex; align-items: center; gap: var(--ui-s-2); margin: 0; font-family: var(--ui-font-body); font-size: var(--ui-fs-16); font-weight: 600; line-height: 1.25; font-variant-numeric: tabular-nums; }
#boutique-dialog .boutique-wallet-line .ico,
#shop-dialog .shop-wallet-line .ico { --ico: 28px; color: var(--ui-coin-deep); }
/* The balance is the card's one big number, as on the Coins tab: VT323 32, tabular, with the
   pixel coin at 2x; the "coins" word stays Outfit 16 so the number carries the weight. */
#boutique-dialog #boutique-wallet,
#shop-dialog #shop-wallet { font-family: var(--ui-font-num); font-size: var(--ui-fs-32); font-weight: 400; line-height: .875; font-variant-numeric: tabular-nums; }
#boutique-dialog .boutique-collected { margin-left: auto; color: var(--ui-ink-muted); font-size: var(--ui-fs-14); font-weight: 400; white-space: nowrap; }
#boutique-dialog .boutique-note,
#shop-dialog .shop-note { margin: 0; color: var(--ui-ink-muted); font-family: var(--ui-font-body); font-size: var(--ui-fs-14); line-height: 1.5; }
#boutique-dialog .boutique-heading,
#shop-dialog .shop-heading { margin: 0 0 var(--ui-s-2); color: var(--ui-ink); font-family: var(--ui-font-display); font-size: var(--ui-fs-16); font-weight: 600; line-height: 1.25; letter-spacing: 0; }

/* The looks: equal tiles, 3 across (124 px wide on the 448 sheet, 112 at 390). */
#boutique-dialog .boutique-characters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-rows: 1fr; gap: var(--ui-s-2); margin: 0 0 var(--ui-s-4); }
#boutique-dialog .look-tile,
#room-workshop-dialog .room-tile,
#shop-dialog .shop-tile {
  position: relative;
  display: grid;
  grid-template-rows: auto auto auto;
  justify-items: center;
  align-content: center;
  /* Sized by its content (art, a name of one or two lines, the tag) with 8 px above and below:
     about square with one-line names; the grids' rows are 1fr, so when one name takes two lines
     every tile in that grid grows with it and they all stay the same height. */
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: var(--ui-s-2) var(--ui-s-1);
  overflow: hidden;
  color: var(--ui-ink);
  background: var(--ui-frame-fill);
  border: 0;
  border-radius: 0;
  box-shadow:
    inset var(--ui-px) var(--ui-px) 0 0 var(--ui-surface-shade),
    inset calc(var(--ui-px) * -1) calc(var(--ui-px) * -1) 0 0 var(--ui-surface-hi),
    var(--ui-frame-edge);
  font-family: var(--ui-font-body);
  text-align: center;
  cursor: pointer;
  transition: background-color var(--ui-dur-fast) var(--ui-ease-out), transform var(--ui-dur-fast) var(--ui-ease-out);
}
/* The tile portrait has 1 art px clear above the tallest look and 4 under the feet (8 at 2x). */
/* The portrait already carries its own air above the head: no block padding, so the look tiles
   stay about square (names still wrap to two lines, never cut). */
#boutique-dialog .look-tile { padding-block: 0; }
/* The tile clips that one clear art px above the tallest look (the row is empty in every look);
   the name sits over the lowest 2 of the 4 under the feet; the tag is one 12 line (its own size,
   no extra leading). Each tile is 4 shorter (108), so on a 390 x 844 phone the third row's names
   and tags end above the pinned footer, never cut by it. */
#boutique-dialog .look-tile canvas { display: block; width: 80px; height: 84px; margin: calc(var(--ui-px) * -1) 0 calc(var(--ui-px) * -2); image-rendering: pixelated; }
#boutique-dialog .look-tile .offer-tag { line-height: var(--ui-s-3); }
#boutique-dialog .look-name { max-width: 100%; overflow: hidden; color: inherit; font-size: var(--ui-fs-14); font-weight: 600; line-height: var(--ui-s-4); }
/* Tile names are never cut: up to two balanced lines (every current name fits two at 390). */
#boutique-dialog .look-name,
#room-workshop-dialog .room-tile-name,
#shop-dialog .shop-tile-name { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow-wrap: anywhere; text-wrap: balance; white-space: normal; }
#boutique-dialog .look-tile:hover:not([aria-pressed="true"]),
#room-workshop-dialog .room-tile:hover:not([aria-pressed="true"]),
#shop-dialog .shop-tile:hover:not([aria-pressed="true"]) { background: var(--ui-secondary-hover); }
#boutique-dialog .look-tile:active,
#room-workshop-dialog .room-tile:active,
#shop-dialog .shop-tile:active { transform: translateY(var(--ui-press)); }
#boutique-dialog :is(.look-tile, .gear-row)[aria-pressed="true"],
#room-workshop-dialog .room-tile[aria-pressed="true"],
#shop-dialog .shop-tile[aria-pressed="true"] {
  color: var(--ui-ink-strong);
  background: var(--ui-selected);
  box-shadow:
    inset var(--ui-px) var(--ui-px) 0 0 var(--ui-surface-hi),
    inset calc(var(--ui-px) * -1) calc(var(--ui-px) * -1) 0 0 var(--ui-coin-deep),
    var(--ui-frame-edge);
}
#boutique-dialog :is(.look-tile, .gear-row):focus-visible,
#room-workshop-dialog .room-tile:focus-visible,
#shop-dialog .shop-tile:focus-visible { position: relative; z-index: 1; outline: var(--ui-focus-ring-w) solid var(--ui-focus-ring); outline-offset: calc(var(--ui-px) * 2); }

/* The tag: the price (coin + number, tabular) or Owned / Wearing (a square dot, green when worn). */
:is(#boutique-dialog, #room-workshop-dialog, #shop-dialog) .offer-tag { display: inline-flex; align-items: center; gap: var(--ui-s-1); color: var(--ui-ink); font-family: var(--ui-font-body); font-size: var(--ui-fs-12); font-weight: 700; line-height: var(--ui-s-4); font-variant-numeric: tabular-nums; white-space: nowrap; }
:is(#boutique-dialog, #room-workshop-dialog, #shop-dialog) .offer-tag .ico { color: var(--ui-coin-deep); }
:is(#boutique-dialog, #room-workshop-dialog, #shop-dialog) .offer-tag.is-short { color: var(--ui-ink-muted); font-weight: 600; }
:is(#boutique-dialog, #room-workshop-dialog, #shop-dialog) .offer-tag.is-short .ico { color: var(--ui-ink-muted); }
:is(#boutique-dialog, #room-workshop-dialog, #shop-dialog) .offer-tag:is(.is-owned, .is-wearing)::before { content: ""; flex: none; width: var(--ui-s-2); height: var(--ui-s-2); background: var(--ui-ink-muted); }
:is(#boutique-dialog, #room-workshop-dialog, #shop-dialog) .offer-tag.is-wearing::before { background: var(--ui-success); }
:is(#boutique-dialog, #room-workshop-dialog, #shop-dialog) [aria-pressed="true"] .offer-tag { color: var(--ui-ink-strong); }
:is(#boutique-dialog, #room-workshop-dialog, #shop-dialog) [aria-pressed="true"] .offer-tag .ico { color: var(--ui-ink-strong); }
:is(#boutique-dialog, #room-workshop-dialog, #shop-dialog) [aria-pressed="true"] .offer-tag.is-owned::before { background: var(--ui-ink-strong); }

/* Signature gear: a sunk card with the disclosure (the room preferences' chevron), rows inside. */
/* Signature gear: a .ui-section.ui-more--card disclosure (Menu controls). */
#boutique-dialog .boutique-gear-hint { color: var(--ui-ink-muted); font-family: var(--ui-font-body); font-size: var(--ui-fs-14); font-weight: 400; }
#boutique-dialog .boutique-items { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--ui-s-2); padding: 0 0 var(--ui-s-4); }
#boutique-dialog .gear-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ui-s-2);
  min-width: 0;
  min-height: var(--ui-target);
  margin: 0;
  padding: 0 var(--ui-s-3);
  color: var(--ui-ink);
  background: var(--ui-frame-fill);
  border: 0;
  border-radius: 0;
  box-shadow:
    inset var(--ui-px) var(--ui-px) 0 0 var(--ui-surface-shade),
    inset calc(var(--ui-px) * -1) calc(var(--ui-px) * -1) 0 0 var(--ui-surface-hi),
    var(--ui-frame-edge);
  font-family: var(--ui-font-body);
  font-size: var(--ui-fs-14);
  font-weight: 600;
  line-height: 1.25;
  text-align: left;
  cursor: pointer;
  transition: background-color var(--ui-dur-fast) var(--ui-ease-out);
}
#boutique-dialog .gear-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#boutique-dialog .gear-row:hover:not([aria-pressed="true"]) { background: var(--ui-secondary-hover); }
#boutique-dialog #boutique-fancy-sheet { grid-column: 1 / -1; }

/* The footer: the selected offer (Pixelify 16 name, Outfit 14 line and note) and its one
   action, in the shared pinned .sheet-footer. */
#boutique-dialog .boutique-detail-copy { display: grid; flex: 1 1 auto; min-width: 0; font-family: var(--ui-font-body); font-size: var(--ui-fs-14); line-height: 1.4; color: var(--ui-ink-muted); }
#boutique-dialog #boutique-detail-name { color: var(--ui-ink); font-family: var(--ui-font-display); font-size: var(--ui-fs-16); font-weight: 600; line-height: 1.25; }
#boutique-dialog #boutique-detail-line { text-wrap: pretty; }
#boutique-dialog #boutique-detail-note { color: var(--ui-ink); font-weight: 600; font-variant-numeric: tabular-nums; }
#boutique-dialog #boutique-detail-note.is-short { color: var(--ui-danger); }
#boutique-dialog .boutique-detail .btn { flex: none; }
#boutique-dialog .boutique-detail .btn[hidden] { display: none; }
#boutique-dialog #boutique-buy .ico { color: currentColor; }

@media (max-width: 380px) {
  #boutique-dialog .boutique-items { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  #boutique-dialog :is(.look-tile, .gear-row) { transition: none; }
  #boutique-dialog .look-tile:active { transform: none; }
}

/* ---------- You: Coins (UX-006 B8c slice 2, UI-V2 §4 B7) ----------
   The Wardrobe recipe: the tab's title names it; the sunk wallet card first (the pixel coin at
   2x, the balance VT323 32 tabular as the tab's focal number, one muted line); How coins work as one sunk card (a muted
   hint, then name-value price rows over 1 UI px shade lines); History as one sunk card grouped
   by day (an Outfit 14/600 muted day title, then rows: the reason Outfit 16 over a muted 14
   time, the amount 16/700 tabular on the right, + in the success ink, − in plain ink: the sign
   carries the meaning, the colour only helps). Empty: one muted line and a secondary Start a
   focus session. No primary: nothing here spends. Sizes: 16, 14 and the closing 12 note. */
#coin-dialog .coin-wallet-line { display: flex; align-items: center; gap: var(--ui-s-2); margin: 0; font-family: var(--ui-font-body); font-size: var(--ui-fs-16); font-weight: 600; line-height: 1.25; font-variant-numeric: tabular-nums; }
#coin-dialog .coin-wallet-line .ico { --ico: 28px; color: var(--ui-coin-deep); }
/* The tab's focal number: VT323 32 (the big-number family), tabular, the pixel coin at 2x
   beside it; "coins" stays Outfit 16 so the number carries the weight. Same as the Wardrobe. */
#coin-dialog #coin-journal-balance { font-family: var(--ui-font-num); font-size: var(--ui-fs-32); font-weight: 400; line-height: .875; font-variant-numeric: tabular-nums; }
#coin-dialog :is(.coin-note, .coin-hint, .coin-empty) { margin: 0; color: var(--ui-ink-muted); font-family: var(--ui-font-body); font-size: var(--ui-fs-14); font-weight: 400; line-height: 1.5; }

/* Wallet, How coins work and History are .ui-section cards (Menu controls). */

/* Prices: one row each, the name on the left, the coin and range on the right. */
#coin-dialog .coin-prices { display: grid; margin: 0; padding: 0; }
#coin-dialog .coin-price { display: flex; align-items: center; justify-content: space-between; gap: var(--ui-s-3); margin: 0; padding: var(--ui-s-2) 0; box-shadow: inset 0 var(--ui-px) 0 0 var(--ui-surface-shade); font-family: var(--ui-font-body); font-size: var(--ui-fs-16); line-height: 1.25; }
#coin-dialog .coin-price dt { margin: 0; color: var(--ui-ink); font-weight: 400; }
#coin-dialog .coin-price dd { display: inline-flex; align-items: center; gap: var(--ui-s-1); margin: 0; color: var(--ui-ink); font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
#coin-dialog .coin-price dd .ico { color: var(--ui-coin-deep); }

/* History: day groups 12 apart; rows over 1 UI px shade lines. */
#coin-dialog #coin-transactions { display: grid; gap: var(--ui-s-3); min-width: 0; }
#coin-dialog .coin-start { justify-self: start; max-width: 100%; }
#coin-dialog .coin-day { display: grid; min-width: 0; margin: 0; }
#coin-dialog .coin-day-title { margin: 0 0 var(--ui-s-1); color: var(--ui-ink-muted); font-family: var(--ui-font-body); font-size: var(--ui-fs-14); font-weight: 600; line-height: 1.5; }
#coin-dialog .coin-day-list { display: grid; margin: 0; padding: 0; list-style: none; }
#coin-dialog .coin-transaction {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ui-s-3);
  min-width: 0;
  margin: 0;
  padding: var(--ui-s-2) 0;
  box-shadow: inset 0 var(--ui-px) 0 0 var(--ui-surface-shade);
}
#coin-dialog .coin-row-copy { display: grid; min-width: 0; }
#coin-dialog .coin-reason { color: var(--ui-ink); font-family: var(--ui-font-body); font-size: var(--ui-fs-16); font-weight: 400; line-height: 1.25; overflow-wrap: anywhere; }
#coin-dialog .coin-time { color: var(--ui-ink-muted); font-family: var(--ui-font-body); font-size: var(--ui-fs-14); line-height: 1.5; font-variant-numeric: tabular-nums; }
#coin-dialog .coin-amount { flex: none; color: var(--ui-ink); font-family: var(--ui-font-body); font-size: var(--ui-fs-16); font-weight: 700; line-height: 1.25; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
#coin-dialog .coin-transaction.earned .coin-amount { color: var(--ui-success-ink); }

#coin-dialog .coin-history-note { margin: 0; color: var(--ui-ink-muted); font-family: var(--ui-font-body); font-size: var(--ui-fs-12); line-height: 1.5; }

/* ---------- You: Home (UX-006 B8c slice 3, UI-V2 §4 B7) ----------
   The Wardrobe recipe for the room workshop: the tab's title names it; the room drawn 1:1
   (whole pixels) in a sunk stage cropped to its walls; the furniture kinds as the segmented
   control; the pieces as the Wardrobe's square pixel-frame tiles, three across (each piece
   shown 2x where it sits in the room, the name Outfit 14/600 on one line, then the price or
   an Owned / In your room tag in Outfit 12); one muted status line (danger ink on an error);
   palette, light and weather as Select rows in a sunk card; and the Wardrobe's pinned footer
   for the selected piece with its ONE action (Buy · price, Place in room, a disabled In your
   room; short of coins, a ghost How to earn). Tiles, tags and footer share the Wardrobe rules. */
#room-workshop-dialog .room-stage {
  position: relative;
  height: 200px;
  margin: 0 0 var(--ui-s-3);
  overflow: hidden;
  background: var(--ui-surface-sunk);
}
#room-workshop-dialog .room-stage::after { content: ""; position: absolute; inset: 0; box-shadow: inset 0 0 0 var(--ui-px) var(--ui-line-deep); pointer-events: none; }
#room-workshop-dialog #room-preview { display: block; width: 400px; height: 240px; max-width: none; margin: calc(var(--ui-s-5) * -1) 0 0 calc(50% - 200px); image-rendering: pixelated; }

#room-workshop-dialog .room-slots { margin: 0 0 var(--ui-s-3); }
#room-workshop-dialog .room-slots > button { flex: 1 1 0; }

/* The pieces: equal tiles, 3 across; the 48 x 36 art px window at 2x over the name and tag. */
#room-workshop-dialog .room-style-items { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-rows: 1fr; gap: var(--ui-s-2); margin: 0 0 var(--ui-s-2); }
#room-workshop-dialog .room-tile { gap: var(--ui-s-1); }
#room-workshop-dialog .room-tile canvas { display: block; width: 96px; max-width: 100%; height: auto; aspect-ratio: 4 / 3; image-rendering: pixelated; box-shadow: 0 0 0 var(--ui-px) var(--ui-surface-shade); }
#room-workshop-dialog .room-tile-name { max-width: 100%; overflow: hidden; color: inherit; font-size: var(--ui-fs-14); font-weight: 600; line-height: var(--ui-s-4); }

#room-workshop-dialog #room-workshop-status { margin: 0 0 var(--ui-s-4); color: var(--ui-ink-muted); font-family: var(--ui-font-body); font-size: var(--ui-fs-14); font-weight: 400; line-height: 1.5; font-variant-numeric: tabular-nums; }
#room-workshop-dialog #room-workshop-status[data-tone="error"] { color: var(--ui-danger); font-weight: 600; }

/* Room look: a .ui-section.ui-more--card disclosure (Menu controls). */
#room-workshop-dialog .room-field { grid-template-columns: minmax(0, 1fr); gap: var(--ui-s-2); }

/* The footer (the Wardrobe's): the piece's name, one note, and its one action. */
#room-workshop-dialog .room-detail-copy { display: grid; flex: 1 1 auto; min-width: 0; color: var(--ui-ink-muted); font-family: var(--ui-font-body); font-size: var(--ui-fs-14); line-height: 1.4; }
#room-workshop-dialog #room-detail-name { color: var(--ui-ink); font-family: var(--ui-font-display); font-size: var(--ui-fs-16); font-weight: 600; line-height: 1.25; text-wrap: balance; }
#room-workshop-dialog #room-detail-note { color: var(--ui-ink); font-weight: 600; font-variant-numeric: tabular-nums; }
#room-workshop-dialog #room-detail-note.is-short { color: var(--ui-danger); }
#room-workshop-dialog .room-detail .btn { flex: none; }
#room-workshop-dialog .room-detail .btn[hidden] { display: none; }
#room-workshop-dialog #room-place .ico { color: currentColor; }

@media (prefers-reduced-motion: reduce) {
  #room-workshop-dialog .room-tile { transition: none; }
  #room-workshop-dialog .room-tile:active { transform: none; }
}

/* ---------- You: Decorate (UX-006 B8c slice 4, UI-V2 §4 B7) ----------
   The Wardrobe / Home recipe for the decorations shop: the tab's title names it; the Wardrobe's
   sunk wallet card (pixel coin, the balance VT323 32 as the focal number, one muted line); the
   decorations as the shared square pixel-frame tiles, three across (each drawn 2x on a 32 x 34
   art px canvas, the name Outfit 14/600 on one line, then the price or an N in bag / Placed /
   Level N tag in Outfit 12); your bag as rows in a sunk card (name over a muted count, then
   secondary Place, or Move and Pick up); and the shared pinned footer for the selected
   decoration with its ONE primary (Buy · price, or Place in grove while one waits in the bag,
   beside a ghost Buy another; a disabled Unlocks at level N; short of coins, a ghost How to
   earn). Wallet, tiles, tags and footer share the Wardrobe / Home rules above. */
#shop-dialog .shop-items { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-rows: 1fr; gap: var(--ui-s-2); margin: 0 0 var(--ui-s-4); }
/* UX-613: Hazel's stall with nothing within your coins hides the tiles, their heading and the
   footer; her line in the wallet card is the whole sheet. */
#shop-dialog :is(.shop-items, .shop-heading, .shop-detail)[hidden] { display: none; }
#shop-dialog .shop-tile { gap: var(--ui-s-1); }
#shop-dialog .shop-tile canvas { display: block; width: 64px; height: 68px; image-rendering: pixelated; }
#shop-dialog .shop-tile-name { max-width: 100%; overflow: hidden; color: inherit; font-size: var(--ui-fs-14); font-weight: 600; line-height: var(--ui-s-4); }

/* Your bag: a sunk card of rows over 1 UI px shade lines (the Coins tab's rows). */
#shop-dialog .shop-bag { margin: 0 0 var(--ui-s-4); }
#shop-dialog #bag-count { color: var(--ui-ink-muted); font-family: var(--ui-font-body); font-size: var(--ui-fs-14); font-weight: 400; font-variant-numeric: tabular-nums; }
#shop-dialog .bag-items {
  display: grid;
  min-width: 0;
  padding: var(--ui-s-1) var(--ui-s-4);
  color: var(--ui-ink);
  background: var(--ui-surface-sunk);
  box-shadow: inset 0 0 0 var(--ui-px) var(--ui-surface-shade);
}
#shop-dialog .bag-row { display: flex; align-items: center; gap: var(--ui-s-2); min-width: 0; padding: var(--ui-s-2) 0; }
#shop-dialog .bag-row + .bag-row { box-shadow: inset 0 var(--ui-px) 0 0 var(--ui-surface-shade); }
#shop-dialog .bag-row-copy { display: grid; flex: 1 1 auto; min-width: 0; font-family: var(--ui-font-body); line-height: 1.25; }
#shop-dialog .bag-row-name { overflow: hidden; color: var(--ui-ink); font-size: var(--ui-fs-16); text-overflow: ellipsis; white-space: nowrap; }
#shop-dialog .bag-row-meta { color: var(--ui-ink-muted); font-size: var(--ui-fs-14); line-height: 1.5; font-variant-numeric: tabular-nums; }
#shop-dialog .bag-row .btn { flex: none; }
#shop-dialog .bag-empty { margin: 0; padding: var(--ui-s-2) 0; color: var(--ui-ink-muted); font-family: var(--ui-font-body); font-size: var(--ui-fs-14); line-height: 1.5; }

/* The footer (the Wardrobe's): the decoration's name, one note, and its one primary. */
#shop-dialog .shop-detail-copy { display: grid; flex: 1 1 auto; min-width: 0; color: var(--ui-ink-muted); font-family: var(--ui-font-body); font-size: var(--ui-fs-14); line-height: 1.4; }
#shop-dialog #shop-detail-name { color: var(--ui-ink); font-family: var(--ui-font-display); font-size: var(--ui-fs-16); font-weight: 600; line-height: 1.25; text-wrap: balance; }
/* The note wraps (up to two lines, like the name) rather than lose its end: a locked
   decoration's line is its description (polish run 20261021-2303). */
#shop-dialog #shop-detail-note { color: var(--ui-ink); font-weight: 600; font-variant-numeric: tabular-nums; text-wrap: pretty; }
#shop-dialog #shop-detail-note.is-short { color: var(--ui-danger); }
#shop-dialog .shop-detail .btn { flex: none; }
#shop-dialog .shop-detail .btn[hidden] { display: none; }
#shop-dialog .shop-detail .btn .ico { color: currentColor; }
/* One in the bag: the secondary +1 · price (a framed pixel button, 40 tall, 44 on a phone)
   sits beside the primary Place on the same row (UX-156: one row at 390 too), with 12 px
   sides so the short label keeps the row. */
#shop-dialog .shop-detail { flex-wrap: nowrap; }
#shop-dialog #shop-buy-more { gap: var(--ui-s-1); padding: 0 var(--ui-s-3); font-variant-numeric: tabular-nums; }
/* On a phone the primary reads "Place" (the words "in grove" go; its aria-label keeps them), so
   the decoration's name keeps the first row beside +1 · price and never breaks mid-name. */
@media (max-width: 480px) {
  #shop-dialog #shop-place .shop-place-where { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  #shop-dialog .shop-tile { transition: none; }
  #shop-dialog .shop-tile:active { transform: none; }
}

/* ---------- The purchase moment (UX-156), all three shops ----------
   Right after a buy the footer's status line reads "Yours now · N coins left" in muted ink
   (Outfit 14, tabular) over the one use-it-now primary (Wear now / Place now); the bought tile's
   tag pops once to Owned: scale 1 → 1.06 → 1 in 200 ms, ease-out, transform only (no layout
   shift, no glow). Reduced motion (the OS or the in-app setting): no pop. The wallet tick is JS
   (purchase-moment.js), instant under reduced motion. */
:is(#boutique-dialog, #room-workshop-dialog, #shop-dialog) :is(#boutique-detail-note, #room-detail-note, #shop-detail-note).is-yours { color: var(--ui-ink-muted); font-weight: 400; font-variant-numeric: tabular-nums; }
/* "Yours now · N coins left" on one line while it fits; in a narrow footer the two parts stack
   and the separator goes, so no line ever starts (or ends) with a dot. The copy column is the
   container, so the rule follows the space it really has (the buttons beside it vary). */
:is(.boutique-detail-copy, .room-detail-copy, .shop-detail-copy) { container: detail-copy / inline-size; }
:is(#boutique-dialog, #room-workshop-dialog, #shop-dialog) :is(.yours-now, .yours-count) { white-space: nowrap; }
/* 12em of the copy's Outfit 14 (168 px): the desktop column (~175) keeps one line, a phone's
   (~140) stacks; "Yours now · 9999 coins left" is under 168 px, so one line never wraps. */
@container detail-copy (max-width: 12em) {
  :is(#boutique-dialog, #room-workshop-dialog, #shop-dialog) :is(.yours-now, .yours-count) { display: block; }
  :is(#boutique-dialog, #room-workshop-dialog, #shop-dialog) .yours-sep { display: none; }
}
:is(#boutique-dialog, #room-workshop-dialog, #shop-dialog) .offer-tag.is-popped { animation: offer-pop var(--ui-dur) var(--ui-ease-out); }
@keyframes offer-pop {
  0% { transform: scale(1); }
  45% { transform: scale(1.06); }
  100% { transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  :is(#boutique-dialog, #room-workshop-dialog, #shop-dialog) .offer-tag.is-popped { animation: none; }
}
.presentation-reduced :is(#boutique-dialog, #room-workshop-dialog, #shop-dialog) .offer-tag.is-popped { animation: none; }

/* Level-locked tiles, the same in every shop: the art dimmed (--ui-dim), the pixel lock (1x) in
   the top-right corner in muted ink, the tag "Level N" in muted ink. Still selectable; the
   name and tag stay full strength (text is never dimmed). Unaffordable but unlocked tiles keep
   full art; only the price is muted (.offer-tag.is-short above). */
:is(#boutique-dialog, #room-workshop-dialog, #shop-dialog) .tile-lock { display: none; }
:is(#boutique-dialog, #room-workshop-dialog, #shop-dialog) .is-locked .tile-lock { position: absolute; top: var(--ui-s-2); right: var(--ui-s-2); display: block; color: var(--ui-ink-muted); }
:is(#boutique-dialog, #room-workshop-dialog, #shop-dialog) .is-locked[aria-pressed="true"] .tile-lock { color: var(--ui-ink-strong); }
:is(#boutique-dialog, #room-workshop-dialog, #shop-dialog) .is-locked canvas { opacity: var(--ui-dim); }

/* ---------- emote panel (UX-229) ----------
   #emote-wheel (src/multiplayer-ui.js): a raised pixel-frame panel anchored above the dock,
   bottom centre, so it never covers the player in the middle of the view. "Emote" title
   (Pixelify 16) + ghost x, then the eight emotes: one row of 72 px items on wide screens,
   4 x 2 inside the 16 px gutters on phones. Items are dock-like (no frame of their own):
   a 2x pixel icon, the label (Outfit 12) and a muted key hint 1-8 in the corner.
   Two type sizes. Enter 200 ms ease-out rising 8 px + fade; exit 120 ms ease-in; reduced
   motion (OS: --ui-travel 0; in-app: .presentation-reduced) fades only. */
.emote-wheel {
  --emote-travel: var(--ui-travel);
  position: fixed;
  z-index: var(--z-modal);
  left: 0;
  right: 0;
  /* 16 above the dock's box: its 3 UI px drop + the dock's edge leave 8 px of world between. */
  bottom: calc(var(--sheet-bottom) + var(--ui-s-1));
  display: grid;
  gap: var(--ui-s-1);
  box-sizing: border-box;
  width: max-content;
  max-width: calc(100vw - var(--ui-s-4) * 2);
  margin: 0 auto;
  padding: var(--ui-s-2);
  color: var(--ui-ink);
}
.presentation-reduced .emote-wheel { --emote-travel: 0px; }
.emote-wheel[hidden] { display: none; }
.emote-wheel:not([hidden]) { animation: emote-panel-in var(--ui-dur) var(--ui-ease-out) both; }
.emote-wheel.is-closing { animation: emote-panel-out var(--ui-dur-fast) var(--ui-ease-in) both; pointer-events: none; }
@keyframes emote-panel-in { from { opacity: 0; transform: translateY(var(--emote-travel)); } }
@keyframes emote-panel-out { to { opacity: 0; transform: translateY(var(--emote-travel)); } }
.emote-wheel-head { display: flex; align-items: center; justify-content: space-between; gap: var(--ui-s-2); padding-left: var(--ui-s-2); }
.emote-wheel-title { margin: 0; color: var(--ui-ink); font-family: var(--ui-font-display); font-size: var(--ui-fs-16); font-weight: 600; line-height: 1; letter-spacing: 0; }
.emote-wheel-close .ico { --ico: 14px; }
.emote-wheel-items { display: grid; grid-template-columns: repeat(8, 72px); gap: var(--ui-s-1); }
.emote-btn {
  position: relative;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: var(--ui-s-2);
  box-sizing: border-box;
  min-width: var(--ui-target);
  min-height: 64px;
  margin: 0;
  padding: var(--ui-s-2) var(--ui-s-1);
  background: transparent;
  color: var(--ui-ink);
  border: 0;
  border-radius: 0;
  box-shadow: none;
  font: inherit;
  cursor: pointer;
  transition: background-color var(--ui-dur-fast) var(--ui-ease-out), transform var(--ui-dur-fast) var(--ui-ease-out);
}
.emote-btn .ico { --ico: 28px; }
.emote-label { font-family: var(--ui-font-body); font-size: var(--ui-fs-12); font-weight: 600; line-height: 1; white-space: nowrap; }
.emote-key {
  position: absolute;
  top: var(--ui-s-1);
  right: var(--ui-s-1);
  display: grid;
  place-items: center;
  min-width: var(--ui-s-4);
  height: var(--ui-s-4);
  padding: 0;
  background: var(--ui-surface-sunk);
  color: var(--ui-ink-muted);
  border: 0;
  border-radius: var(--ui-r-sm);
  font-family: var(--ui-font-body);
  font-size: var(--ui-fs-12);
  font-weight: 600;
  line-height: 1;
}
@media (hover: hover) {
  .emote-btn:hover { background: var(--ui-dock-item-hover); }
  .emote-btn:hover .emote-key { background: var(--ui-surface); }
}
.emote-btn:active { background: var(--ui-surface-sunk); transform: translateY(var(--ui-press)); }
.emote-btn:focus-visible { outline: var(--ui-focus-ring-w) solid var(--ui-focus-ring); outline-offset: calc(var(--ui-focus-ring-w) * -1); }
/* Phones: 4 x 2 on the dock's own left and right edges (the dock's box, measured when the
   panel opens: --emote-dock-left/-width from src/multiplayer-ui.js), else in the 16 px gutters. */
@media (max-width: 720px) {
  .emote-wheel {
    left: var(--emote-dock-left, var(--ui-s-4));
    right: auto;
    width: var(--emote-dock-width, calc(100vw - var(--ui-s-4) * 2));
    max-width: none;
    margin: 0;
  }
  .emote-wheel-items { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
/* Touch screens have no number keys to hint at: the 1-8 caps go (the labels still name them). */
@media (hover: none) {
  .emote-key { display: none; }
}

/* GROVE-1.4 (NAV-07/08): on a short landscape screen (a phone on its side) a tabbed sheet's
   title row only repeats the selected tab, and its 50 px is a seventh of the screen: the
   title stays for screen readers, the row goes. Title rows with their own actions stay. */
@media (max-height: 560px) and (min-width: 640px) {
  .sheet-host.grouped .sheet-body .dialog-heading:has(> h2:only-child),
  .sheet-host.grouped .sheet-body .dialog-heading:has(> h2 + .close-dialog:last-child) {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: 0;
    overflow: hidden;
    clip-path: inset(50%);
  }
}

/* GROVE-1.4 (NAV-07): on a short landscape screen an open sheet would cut the quest strip mid
   word ("Step inside your co…"); it steps aside while the sheet is open and comes back after. */
@media (max-height: 560px) and (min-width: 640px) {
  body.sheet-open .next-step-bar { visibility: hidden; opacity: 0; pointer-events: none; }
}

/* UX-511: the pixel display font turns "fi" and "fl" into ligature glyphs that read as an "A";
   ligatures are off everywhere (nothing in the UI relies on them). */
html { font-variant-ligatures: no-common-ligatures; }

/* GROVE-1.4 (NAV-12): touch targets at least 44 px on touch screens (Download draft, the rift
   list's Go buttons). */
@media (pointer: coarse) {
  .notebook-draft-action, .dungeon-go { min-height: var(--ui-target); min-width: var(--ui-target); }
}

/* UX-479 (GROVE-1.4 NAV-09): the session card's folded rewards and the chip that opens them. */
.session-result-chips .chip[hidden] { display: none; }
.session-result-chips .chip--more {
  border: 0;
  background: transparent;
  color: var(--ui-ink-muted);
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.session-result-chips .chip--more:hover { color: var(--ui-ink); }
.session-result-chips .chip--more:focus-visible { outline: var(--ui-focus-ring-w) solid var(--ui-focus-ring); outline-offset: 2px; }

/* ---------- GROVE-1.7: the deferred Low rows (tour card, session card, toasts) ---------- */
/* UX-541: on a short landscape screen the place's title card arrives under the top band, not
   over the quest strip (top 30% is 117 px at 844x390, inside the band). */
@media (max-height: 560px) and (min-width: 640px) {
  .place-title { top: calc(var(--sheet-top) + var(--ui-s-2)); transform: translate(-50%, 0); }
}
/* UX-747: on touch screens (no hover tooltip) the tight session card's line keeps two lines. */
@media (pointer: coarse) {
  .session-result[data-tight="minutes"] > p {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    white-space: normal;
  }
}
/* UX-768: a packed or stacked card that scrolls keeps its title and × in view. */
.session-result:is([data-fit="stack"], [data-fit="scroll"], [data-fit="tight"]) .session-result-head {
  position: sticky;
  top: calc(var(--ui-s-3) * -1);
  z-index: 1;
  background: var(--ui-surface);
}
/* UX-759: where the compact card's line steps aside, what the level unlocks rides on its chip. */
.session-result:is([data-fit], [data-tight]) .chip.level[data-unlock]::after { content: " · " attr(data-unlock); font-weight: 400; }

/* ---------- villager talk (GROVE-1.6) ----------
   UX-670: a card sheet (data-sheet-size="card" in index.html): as tall as the talk, so a phone
   keeps the town in view above it instead of an empty half sheet.
   UX-615: on a short landscape phone (667x375) the line scrolls and the actions stay pinned to
   the sheet's foot, so "Show my next chapter goal" and "See you around" are always in view.
   UX-616: the talk's buttons are 44 tall on touch (the legacy .button is 42). */
.sheet-body > #villager-dialog[open] { display: flex; flex-direction: column; }
.sheet-body > #villager-dialog[open] > .villager-intro { flex: 0 1 auto; min-height: 0; }
#villager-dialog #villager-actions {
  position: sticky;
  bottom: calc(var(--ui-s-5) * -1);
  z-index: 1;
  margin: var(--ui-s-3) calc(var(--ui-s-5) * -1) calc(var(--ui-s-5) * -1);
  padding: var(--ui-s-3) var(--ui-s-5) var(--ui-s-5);
  background: var(--ui-sheet-bg);
}
@media (max-height: 480px) {
  #villager-dialog #villager-line { margin: var(--ui-s-2) 0; font-size: var(--ui-fs-16); }
  #villager-dialog .villager-intro { margin-top: var(--ui-s-2); }
  #villager-dialog #villager-preview { width: 48px; height: 44px; }
}
@media (pointer: coarse) {
  .sheet-body :is(.button, label.button) { min-height: var(--ui-target); }
}

/* UX-669: a nearby place whose feature is not introduced yet (src/world-map.js markIntroduced). */
#map-here .location-actions button[data-unintroduced] { display: none; }

/* ---------- Menu controls (GROVE-1.9, docs/MENUS-REVAMP.md) ----------
   One small set every menu shares, built by src/ui-controls.js: a choice group (segmented, chips,
   swatches, option cards) that stands in for a <select>, a stepper, the setting row, the section
   card and the "More options" disclosure. Tokens only. The <select> a choice group replaces stays
   in the DOM as its source of truth, hidden here. */
.ui-native-select {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  clip-path: inset(50%);
}
.ui-native-select select, select.ui-native-select { visibility: hidden; min-width: 0 !important; min-height: 0 !important; padding: 0 !important; border: 0 !important; }
.ui-native-select::after { content: none !important; }

.ui-choice { display: flex; gap: var(--ui-s-1); min-width: 0; margin: 0; }
.ui-choice-item {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--ui-s-2);
  box-sizing: border-box;
  min-width: 0;
  min-height: 36px;
  margin: 0;
  padding: 0 var(--ui-s-3);
  color: var(--ui-ink-muted);
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  font-family: var(--ui-font-body);
  font-size: var(--ui-fs-16);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0;
  text-align: center;
  cursor: pointer;
  transition: background-color var(--ui-dur-fast) var(--ui-ease-out), color var(--ui-dur-fast) var(--ui-ease-out), transform var(--ui-dur-fast) var(--ui-ease-out), box-shadow var(--ui-dur-fast) var(--ui-ease-out);
}
.ui-choice-item:hover:not(:disabled, [aria-checked="true"]) { background: var(--ui-secondary-hover); color: var(--ui-ink); }
.ui-choice-item:active:not(:disabled) { transform: translateY(var(--ui-press)); }
.ui-choice-item:focus-visible { z-index: 1; outline: var(--ui-focus-ring-w) solid var(--ui-focus-ring); outline-offset: var(--ui-px); }
.ui-choice-item:disabled { color: var(--ui-disabled-ink); cursor: not-allowed; opacity: .7; }
.ui-choice-item[aria-checked="true"] {
  color: var(--ui-ink-strong);
  background: var(--ui-selected);
  box-shadow:
    inset var(--ui-px) var(--ui-px) 0 0 var(--ui-surface-hi),
    inset calc(var(--ui-px) * -1) calc(var(--ui-px) * -1) 0 0 var(--ui-coin-deep),
    var(--ui-frame-edge);
}
.ui-choice-label { min-width: 0; overflow-wrap: anywhere; }

/* Segmented: the Focus presets' sunk track; every segment the same width, one row. */
.ui-choice--segmented {
  padding: var(--ui-s-1);
  background: var(--ui-surface-sunk);
  box-shadow:
    inset var(--ui-px) var(--ui-px) 0 0 var(--ui-surface-shade),
    inset calc(var(--ui-px) * -1) calc(var(--ui-px) * -1) 0 0 var(--ui-surface-hi);
}
.ui-choice--segmented > .ui-choice-item { flex: 1 1 0; padding: 0 var(--ui-s-2); }

/* Chips: framed pills that wrap; the chosen one peach. */
.ui-choice--chips { flex-wrap: wrap; gap: var(--ui-s-2); }
.ui-choice--chips > .ui-choice-item {
  min-height: 36px;
  padding: 0 var(--ui-s-3);
  color: var(--ui-ink);
  background: var(--ui-surface);
  box-shadow: var(--ui-frame-flat);
  font-size: var(--ui-fs-14);
}

/* Swatches: a square of the colour in a pixel frame and its name under it; chosen = peach plate. */
.ui-choice--swatches { flex-wrap: wrap; gap: var(--ui-s-2); }
.ui-choice--swatches > .ui-choice-item {
  flex-direction: column;
  gap: var(--ui-s-1);
  min-width: 64px;
  padding: var(--ui-s-2);
  color: var(--ui-ink);
  font-size: var(--ui-fs-14);
}
.ui-choice-swatch {
  display: block;
  width: var(--ui-s-6);
  height: var(--ui-s-6);
  background: var(--swatch, var(--ui-surface-sunk));
  box-shadow: inset 0 0 0 var(--ui-px) var(--ui-line), inset var(--ui-px) var(--ui-px) 0 calc(var(--ui-px) * 2) var(--ui-surface-hi);
}

/* Option cards: one per row, a radio dot, the name and a muted second line. */
.ui-choice--cards { flex-direction: column; gap: var(--ui-s-2); }
.ui-choice--cards > .ui-choice-item {
  display: grid;
  grid-template-columns: var(--ui-s-4) minmax(0, 1fr);
  column-gap: var(--ui-s-3);
  row-gap: calc(var(--ui-px));
  align-items: center;
  justify-content: stretch;
  min-height: var(--ui-target);
  padding: var(--ui-s-2) var(--ui-s-3);
  color: var(--ui-ink);
  background: var(--ui-surface);
  box-shadow: var(--ui-frame-flat);
  text-align: left;
}
.ui-choice--cards > .ui-choice-item::before {
  content: "";
  grid-row: 1 / span 2;
  width: var(--ui-s-4);
  height: var(--ui-s-4);
  background: var(--ui-surface);
  box-shadow: inset 0 0 0 var(--ui-px) var(--ui-line);
}
.ui-choice--cards > .ui-choice-item[aria-checked="true"]::before {
  background: var(--ui-ink);
  box-shadow: inset 0 0 0 var(--ui-px) var(--ui-line), inset 0 0 0 calc(var(--ui-px) * 2) var(--ui-surface);
}
.ui-choice--cards > .ui-choice-item:not(:has(.ui-choice-hint))::before { grid-row: 1; }
.ui-choice--cards .ui-choice-label { grid-column: 2; }
.ui-choice-hint {
  grid-column: 2;
  color: var(--ui-ink-muted);
  font-size: var(--ui-fs-14);
  font-weight: 400;
  line-height: 1.35;
}
.ui-choice--cards > .ui-choice-item[aria-checked="true"] .ui-choice-hint { color: var(--ui-ink-strong); }

/* Stepper: − [ number ] +, one 40 px row (44 on touch). */
.ui-stepper { display: inline-grid; grid-template-columns: 40px minmax(56px, 88px) 40px; align-items: stretch; height: 40px; }
.ui-stepper > input {
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  min-height: 0;
  margin: 0;
  padding: 0 var(--ui-s-1);
  color: var(--ui-input-ink);
  background: var(--ui-frame-fill);
  border: 0;
  border-radius: 0;
  box-shadow: inset var(--ui-px) var(--ui-px) 0 0 var(--ui-surface-shade), var(--ui-frame-edge);
  font-family: var(--ui-font-body);
  font-size: var(--ui-fs-16);
  font-variant-numeric: tabular-nums;
  text-align: center;
  -moz-appearance: textfield;
}
.ui-stepper > input::-webkit-inner-spin-button, .ui-stepper > input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.ui-stepper > input:focus-visible { position: relative; z-index: 1; outline: var(--ui-focus-ring-w) solid var(--ui-focus-ring); outline-offset: var(--ui-px); }
.ui-stepper-btn {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
  color: var(--ui-ink);
  background: var(--ui-surface-sunk);
  border: 0;
  border-radius: 0;
  box-shadow: var(--ui-frame-flat);
  font-family: var(--ui-font-body);
  font-size: var(--ui-fs-20);
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}
.ui-stepper-btn:hover:not(:disabled) { background: var(--ui-secondary-hover); }
.ui-stepper-btn:active:not(:disabled) { transform: translateY(var(--ui-press)); }
.ui-stepper-btn:focus-visible { position: relative; z-index: 1; outline: var(--ui-focus-ring-w) solid var(--ui-focus-ring); outline-offset: var(--ui-px); }
.ui-stepper-btn:disabled { color: var(--ui-disabled-ink); background: var(--ui-disabled-bg); cursor: not-allowed; }

/* Section and row: THE layout every sheet uses (GROVE-1.9 second pass; it replaces the
   per-dialog copies .settings-group, .account-group, .creator-group, .coin-group, .room-group
   and their headings and rows). Type scale, from the tokens in src/ui-tokens.css:
     sheet title   --ui-type-sheet-title    Pixelify 20/600  (the sheet head)
     section title --ui-type-section-title  Pixelify 16/600
     row label     --ui-type-row-label      Outfit 16/500    (a setting's name)
     field label   --ui-type-field-label    Outfit 14/600    (over an input or a choice)
     hint          --ui-type-hint           Outfit 14/400, muted
   A section is a flat sunk card: 12 16 16 padding, 12 between its parts, 12 between cards.
   Inside it a row puts the name (and hint) on the left and its control on the right, 16 apart;
   rows are 12 tall-padded and ruled by a 1 UI px shade line, so every switch, value and button
   in every sheet starts on the same right edge. A .ui-row--stack puts a wide control (a choice
   group) under its name. */
.ui-section {
  display: grid;
  gap: var(--ui-s-3);
  min-width: 0;
  margin: 0 0 var(--ui-s-3);
  padding: var(--ui-s-3) var(--ui-s-4) var(--ui-s-4);
  color: var(--ui-ink);
  background: var(--ui-surface-sunk);
  border: 0;
  border-radius: 0;
  box-shadow: inset 0 0 0 var(--ui-px) var(--ui-surface-shade);
}
.ui-section:last-child { margin-bottom: 0; }
/* Compact: a status strip or a stat card (an icon, a line, an action). */
.ui-section--compact { padding: var(--ui-s-2) var(--ui-s-3); }
.ui-section[hidden] { display: none; }
/* (Also under .sheet-body: the legacy ".sheet-body h3 { font-size: 17px }" must not win.) */
.ui-section-title, .sheet-body .ui-section-title {
  margin: 0;
  color: var(--ui-ink);
  font: var(--ui-type-section-title);
  letter-spacing: 0;
}
/* A group of rows: no gap between them, the rules do the separating. */
.ui-rows { display: grid; gap: 0; min-width: 0; }
.ui-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  column-gap: var(--ui-s-4);
  row-gap: var(--ui-s-2);
  min-width: 0;
  margin: 0;
  padding: var(--ui-s-3) 0;
  color: var(--ui-ink);
  background: none;
  border: 0;
  border-radius: 0;
  box-shadow: inset 0 calc(var(--ui-px) * -1) 0 0 var(--ui-surface-shade);
  font: var(--ui-type-row-label);
}
.ui-section > .ui-row:first-of-type, .ui-rows > .ui-row:first-child { padding-top: 0; }
.ui-row:last-child, .ui-row:has(+ :is(.ui-row-hint, .ui-hint, [hidden]:last-child)) { box-shadow: none; padding-bottom: 0; }
.ui-row[hidden] { display: none; }
label.ui-row { cursor: pointer; }
.ui-row--stack { grid-template-columns: minmax(0, 1fr); }
/* Consecutive rows: the section's gap gives way to the rows' own padding and rule. */
.ui-section > .ui-row + .ui-row, .ui-section > .ui-row + .ui-row[hidden] + .ui-row { margin-top: calc(var(--ui-s-3) * -1); }
.ui-row-copy { display: grid; gap: var(--ui-s-1); min-width: 0; }
.ui-row-label, .sheet-body .ui-row-label { margin: 0; color: var(--ui-ink); font: var(--ui-type-row-label); overflow-wrap: anywhere; }
label.ui-row:hover .ui-row-label { color: var(--ui-ink-strong); }
.ui-row-hint, .ui-section-hint { display: block; margin: 0; color: var(--ui-ink-muted); font: var(--ui-type-hint); overflow-wrap: anywhere; }
/* A section's actions: buttons side by side, each as wide as its words, wrapping when needed. */
.ui-actions { display: flex; flex-wrap: wrap; gap: var(--ui-s-2); margin: 0; }
.ui-actions > .btn { flex: 1 1 auto; margin: 0; }
.ui-actions > .btn[hidden] { display: none; }

/* More options: rarely used settings fold under one quiet disclosure. */
/* (style.css gives every details a top rule and 17 px padding; a disclosure has neither.) */
.ui-more { min-width: 0; margin: 0; padding-top: 0; border-top: 0; }
.ui-more > summary {
  display: inline-flex;
  align-items: center;
  gap: var(--ui-s-2);
  min-height: var(--ui-target);
  color: var(--ui-ink-muted);
  font-family: var(--ui-font-body);
  font-size: var(--ui-fs-14);
  font-weight: 600;
  list-style: none;
  cursor: pointer;
}
.ui-more > summary::-webkit-details-marker { display: none; }
.ui-more > summary::before {
  content: "";
  width: calc(var(--ui-px) * 3);
  height: calc(var(--ui-px) * 5);
  background: currentColor;
  clip-path: polygon(0 0, 33.34% 0, 33.34% 20%, 66.67% 20%, 66.67% 40%, 100% 40%, 100% 60%, 66.67% 60%, 66.67% 80%, 33.34% 80%, 33.34% 100%, 0 100%);
  transition: transform var(--ui-dur-fast) var(--ui-ease-out);
}
.ui-more[open] > summary::before { transform: rotate(90deg); }
.ui-more > summary:hover { color: var(--ui-ink); }
.ui-more > summary:focus-visible { outline: var(--ui-focus-ring-w) solid var(--ui-focus-ring); outline-offset: var(--ui-px); }
.ui-more-body { display: grid; gap: var(--ui-s-3); padding-top: var(--ui-s-1); }
/* A section that folds (Room look, Signature gear): the card's title row is the summary, a
   full-width 44 px target in the section-title type; open, its body follows inside the card. */
.ui-section.ui-more--card { gap: 0; padding-top: 0; padding-bottom: 0; }
.ui-section.ui-more--card[open] { padding-bottom: var(--ui-s-4); }
.ui-more--card > summary { width: 100%; color: var(--ui-ink); font: var(--ui-type-section-title); }
.ui-more--card > summary:hover { color: var(--ui-ink-strong); }

/* Touch and phones: 44 px targets. */
@media (pointer: coarse), (max-width: 560px) {
  .ui-choice-item, .ui-choice--chips > .ui-choice-item { min-height: var(--ui-target); }
  .ui-stepper { grid-template-columns: var(--ui-target) minmax(56px, 1fr) var(--ui-target); height: var(--ui-target); }
}
@media (prefers-reduced-motion: reduce) {
  .ui-choice-item, .ui-stepper-btn, .ui-more > summary::before { transition: none; }
}

/* Settings → Help (GROVE-1.9): a list of rows, each the full width with its words on the left
   and a chevron on the right, instead of a grid of framed buttons that wrapped unevenly
   ("Keyboard / shortcuts" on two lines beside one-line neighbours). */
#settings-dialog .settings-help { display: grid; gap: 0; }
/* display sits at the lowest specificity so the rules that hide a row (Send feedback for
   non-testers, Keyboard shortcuts on touch, the app's own hides) still win. */
:where(#settings-dialog .settings-help) .btn { display: flex; }
#settings-dialog .settings-help .btn {
  justify-content: space-between;
  align-items: center;
  flex: none;
  width: 100%;
  min-height: var(--ui-target);
  padding: 0 var(--ui-s-1);
  color: var(--ui-ink);
  background: transparent;
  box-shadow: inset 0 calc(var(--ui-px) * -1) 0 0 var(--ui-surface-shade);
  font-family: var(--ui-font-body);
  font-size: var(--ui-fs-16);
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
}
#settings-dialog .settings-help .btn:last-child { box-shadow: none; }
#settings-dialog .settings-help .btn::after {
  content: "";
  flex: none;
  width: calc(var(--ui-px) * 3);
  height: calc(var(--ui-px) * 5);
  background: var(--ui-ink-muted);
  clip-path: polygon(0 0, 33.34% 0, 33.34% 20%, 66.67% 20%, 66.67% 40%, 100% 40%, 100% 60%, 66.67% 60%, 66.67% 80%, 33.34% 80%, 33.34% 100%, 0 100%);
}
#settings-dialog .settings-help .btn:hover { background: var(--ui-secondary-hover); }
#settings-dialog .settings-help .btn:active { transform: none; }
#settings-dialog #backup-more { margin-top: var(--ui-s-2); }

/* Focus → Custom: the minutes field inside the stepper keeps the stepper's shape (GROVE-1.9). */
#study-panel .ui-stepper > #minutes { width: 100%; height: 100%; padding: 0 var(--ui-s-1); text-align: center; }
#study-panel .timer-field .ui-stepper { justify-self: start; }

/* ---------- Sheet frame v2 (GROVE-1.9, docs/MENUS-REVAMP.md "Second pass") ----------
   Head: the group's places on ONE row that never wraps (sections merge related tabs, so a
   row holds at most four; if a translation ever overflows it scrolls sideways, never wraps),
   the close beside it, and for a merged section a quiet switch under the row. The head never
   scrolls; under it a 1 UI px rule turns into a 2 px pixel shadow once the panel is scrolled
   (src/sheet-host.js sets .is-scrolled), so content visibly slides under it instead of
   looking cut. The panel's own title row only repeated the chosen tab: it is visually hidden
   in grouped sheets at every size (kept for screen readers; GROVE-1.4 did this on short
   landscape screens). The panel's one primary sits in a pinned footer (.sheet-footer). */
.sheet-host.grouped .sheet-header {
  display: grid;
  gap: var(--ui-s-2);
  padding: var(--ui-s-2) var(--ui-s-3) var(--ui-s-3) var(--ui-s-4);
  transition: box-shadow var(--ui-dur) var(--ui-ease-out);
}
.sheet-head-row { display: flex; align-items: center; justify-content: space-between; gap: var(--ui-s-3); min-width: 0; }
/* The sheet's name: the type scale's sheet title (Pixelify 20/600). */
.sheet-title { margin: 0; min-width: 0; color: var(--ui-ink); font-family: var(--ui-font-display); font-size: var(--ui-fs-20); font-weight: 600; line-height: 1.2; letter-spacing: 0; }
.sheet-host.grouped .sheet-header .sheet-close { margin: 0; }
.sheet-host.grouped.is-scrolled .sheet-header,
.sheet-host.is-scrolled .sheet-body .dialog-heading {
  box-shadow: inset 0 calc(var(--ui-px) * -1) 0 0 var(--ui-surface-shade), 0 var(--ui-px) 0 0 var(--ui-surface-shade);
}
.sheet-host.grouped .sheet-header > .sheet-tabs { display: grid; gap: var(--ui-s-2); }
/* The row's track is GROVE-1.4's tab tray (NAV-05, moved here): one sunk bar the tabs share. */
.sheet-host.grouped .sheet-tablist:not([hidden]) {
  padding: var(--ui-s-1);
  background: var(--ui-surface-sunk);
  box-shadow: inset 0 0 0 var(--ui-px) var(--ui-surface-shade);
  flex-wrap: nowrap;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
}
.sheet-host.grouped .sheet-tablist::-webkit-scrollbar { display: none; }
.sheet-host.grouped .sheet-tablist .sheet-tab { flex: 1 0 auto; justify-content: center; padding: 0 var(--ui-s-3); }
@media (max-width: 720px) { .sheet-host.grouped .sheet-tablist .sheet-tab { padding: 0 var(--ui-s-2); } }
.sheet-host.grouped .sheet-tablist .sheet-tab .tab-badge,
.sheet-host.grouped .sheet-tablist .sheet-tab .badge { margin-left: 0; }

/* The section switch: text tabs in Outfit 14/600; the chosen one strong ink over a 2 UI px
   cocoa bar (the row's one peach stays on the top-level tab, so the two levels never look
   alike). 32 tall, 44 on touch. */
.sheet-subnav { display: flex; gap: var(--ui-s-1); margin: 0; padding: 0 var(--ui-s-1); overflow-x: auto; scrollbar-width: none; }
.sheet-subnav[hidden] { display: none; }
.sheet-subnav::-webkit-scrollbar { display: none; }
.sheet-subtab {
  position: relative;
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: var(--ui-s-2);
  box-sizing: border-box;
  height: 32px;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0 var(--ui-s-2);
  color: var(--ui-ink-muted);
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  font-family: var(--ui-font-body);
  font-size: var(--ui-fs-14);
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: color var(--ui-dur-fast) var(--ui-ease-out), background-color var(--ui-dur-fast) var(--ui-ease-out);
}
.sheet-subtab[hidden] { display: none; }
.sheet-subtab::after {
  content: "";
  position: absolute;
  left: var(--ui-s-2);
  right: var(--ui-s-2);
  bottom: 0;
  height: calc(var(--ui-px) * 2);
  background: transparent;
  transition: background-color var(--ui-dur-fast) var(--ui-ease-out);
}
.sheet-subtab:hover { color: var(--ui-ink); background: var(--ui-surface-sunk); }
.sheet-subtab:active:not(:disabled) { transform: none; }
.sheet-subtab[aria-pressed="true"] { color: var(--ui-ink-strong); }
.sheet-subtab[aria-pressed="true"]::after { background: var(--ui-ink); }
.sheet-subtab:focus-visible { outline: var(--ui-focus-ring-w) solid var(--ui-focus-ring); outline-offset: calc(var(--ui-px) * -1); }
.sheet-subtab .tab-badge, .sheet-subtab .badge { position: static; }
@media (pointer: coarse), (max-width: 720px) {
  .sheet-subtab { height: var(--ui-target); }
}

/* The title row that only repeats the chosen tab: hidden, kept for screen readers. Title rows
   with their own actions (a count, a button) stay. */
.sheet-host.grouped .sheet-body .dialog-heading:has(> h2:only-child),
.sheet-host.grouped .sheet-body .dialog-heading:has(> h2 + .close-dialog:last-child) {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
}

/* Switching tabs: the new panel fades in (calm; reduced motion keeps the fade, no travel). */
.sheet-host.grouped .sheet-body > :is(dialog[open], aside:not([hidden])) { animation: ui-fade-in var(--ui-dur) var(--ui-ease-out); }

/* The pinned footer: the panel's one primary (and its quiet partner) held at the bottom over a
   1 UI px rule, inside the panel's padding, clear of a phone's home bar. Used by Character
   (Save look), Wardrobe, Home and Decorate (the selected piece's Buy / Place / Wear) and
   Create a room. */
.sheet-footer {
  position: sticky;
  bottom: calc(var(--ui-s-5) * -1);
  z-index: 2;
  display: flex;
  align-items: center;
  gap: var(--ui-s-3);
  width: auto;
  max-width: none;
  margin: var(--ui-s-4) calc(var(--ui-s-5) * -1) calc(var(--ui-s-5) * -1);
  padding: var(--ui-s-3) var(--ui-s-5) var(--ui-s-5);
  background: var(--ui-sheet-bg);
  border: 0;
  border-top: 0;
  box-shadow: inset 0 var(--ui-px) 0 0 var(--ui-surface-shade);
}
@media (max-width: 720px) {
  .sheet-footer {
    bottom: calc((var(--ui-s-4) + env(safe-area-inset-bottom)) * -1);
    margin: var(--ui-s-3) calc(var(--ui-s-4) * -1) calc((var(--ui-s-4) + env(safe-area-inset-bottom)) * -1);
    padding: var(--ui-s-3) var(--ui-s-4) calc(var(--ui-s-4) + env(safe-area-inset-bottom));
  }
}

/* Short landscape screens (a phone on its side): height is the scarce thing, so the sheet's
   name steps aside and the close sits at the end of the places row. */
@media (max-height: 560px) and (min-width: 640px) {
  .sheet-host.grouped .sheet-header { grid-template-columns: minmax(0, 1fr) auto; align-items: start; column-gap: var(--ui-s-2); padding-top: var(--ui-s-2); }
  .sheet-host.grouped .sheet-head-row { display: contents; }
  .sheet-host.grouped .sheet-title { display: none; }
  .sheet-host.grouped .sheet-header > .sheet-tabs { grid-column: 1; grid-row: 1; }
  .sheet-host.grouped .sheet-header .sheet-close { grid-column: 2; grid-row: 1; }
}

/* Touch: every button in a sheet is a 44 px target (the Focus sheet's Add deck, Save notes and
   "Make a moment to focus" were 32-42). */
@media (pointer: coarse) {
  #sheet-host :is(.btn, .button) { min-height: var(--ui-target); }
}
/* The Monster Book's panel is a tab stop (it scrolls): show where focus is when tabbed to. */
.sheet-body > #monsters-dialog:focus-visible { outline: var(--ui-focus-ring-w) solid var(--ui-focus-ring); outline-offset: calc(var(--ui-px) * -2); }
.sheet-body { overflow: clip; }
