/* Toybox shared layer: styles for common/toybox.js.
   Include it BEFORE the app's own <style>, so the app can override anything:
     <link rel="stylesheet" href="../common/toybox.css">
   Provides: the design tokens (plans/redesign.md 1.10, 1.13, 1.14), .btn, the grown-up sheet,
   hold-to-confirm buttons, the warning toast, the ending banner, the timer badge, the rest screen, the app shell
   (header, stage, panel) and the shared components (Go, step row, job bar, tiles, bottom bar, coach, ghost hand,
   name tags, gate, map places). Demo of everything: tools/shell-demo.html. */

/* ---------- Tokens (apps may redefine any of these in their own :root) ---------- */
:root {
  /* Older names, still used by every page (keep them). */
  --bg: #CDE9FF;
  --panel: #FFFFFF;
  --ink: #1D2340;
  --muted: #4A5578;
  --edge: #1D2340;
  --accent: #FFC93C;
  --plate: #F4FAFF;
  --focus: #2D5BD7;
  --font: "Baloo 2", "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  color-scheme: light;

  /* Color: one meaning per color (redesign 1.10). Chrome uses only these; the play scene owns every other color. */
  --tb-ink: #1D2340;      /* outlines, text, icons */
  --tb-ink-2: #4A5578;    /* secondary words: coming steps, job tabs */
  --tb-bg: #CDE9FF;       /* page */
  --tb-surface: #FFFFFF;  /* panel, tiles, header buttons, pills */
  --tb-tile-bg: #F6F9FF;  /* tile face */
  --tb-lip: #B9C6DE;      /* the bottom lip under white buttons and tiles */
  --tb-go: #1E8C4E;       /* Go (main action) and done ticks only */
  --tb-go-lip: #146638;
  --tb-pick: #FFC93C;     /* picked tile, picked job tab underline, the coach's step dot: never color alone */
  --tb-pick-lip: #D9A21A;
  --tb-glow: rgba(255, 201, 60, 0.35);
  --tb-new: #FF9A4D;      /* New (start over) only */
  --tb-new-lip: #D9702A;
  --tb-shelf: #3DB4FF;    /* Shelf (his collection) only */
  --tb-shelf-lip: #1E8FD6;
  --tb-job: #E3F1FF;      /* job tabs not picked */
  --tb-off: #E3E8F2;      /* coming steps, lines */
  --tb-line: var(--edge); /* 2 px chrome outlines */
  --tb-focus: #2D5BD7;
  --tb-card: 0 6px 18px rgba(29, 35, 64, 0.14);

  /* Shape and depth (1.14) */
  --tb-outline: 2px; --tb-frame: 3px; --tb-lip-h: 4px; --tb-lip-h-sm: 3px;
  --tb-r-stage: 24px; --tb-r-panel: 24px; --tb-r-btn: 16px; --tb-r-tile: 18px; --tb-r-pill: 999px;
  /* Spacing scale */
  --tb-s1: 4px; --tb-s2: 8px; --tb-s3: 12px; --tb-s4: 16px; --tb-s5: 24px; --tb-s6: 32px;
  /* Type scale (Baloo 2) */
  --tb-fs-title: 24px; --tb-fs-go: 26px; --tb-fs-btn: 18px; --tb-fs-tile: 16px; --tb-fs-coach: 22px;
  --tb-fs-count: 18px; --tb-fs-small: 14px;
  /* Targets for a 3-year-old's finger (1.8). Phone first. */
  --tb-key: 120px;        /* 2 cm: main targets, invisible hit areas of drawn parts */
  --tb-go-h: 72px; --tb-tile: 84px; --tb-tab-h: 64px; --tb-bar-h: 60px; --tb-head-icon: 52px;
  --tb-gap: 12px; --tb-gap-new: 24px; --tb-edge: 16px;
  --tb-chip: 56px;        /* step chip */
  /* Timing */
  --tb-t-press: 80ms; --tb-t-pick: 160ms; --tb-t-move: 900ms; --tb-t-cheer: 1800ms;
}
@media (min-width: 700px) and (min-height: 700px) {   /* iPad either way */
  :root {
    --tb-key: 104px; --tb-go-h: 84px; --tb-tile: 112px; --tb-tab-h: 72px; --tb-bar-h: 68px; --tb-head-icon: 60px;
    --tb-gap: 16px; --tb-chip: 68px;
    --tb-r-stage: 28px; --tb-r-panel: 28px;
    --tb-fs-title: 30px; --tb-fs-go: 30px; --tb-fs-btn: 20px; --tb-fs-tile: 18px; --tb-fs-coach: 28px;
    --tb-fs-count: 20px; --tb-fs-small: 16px;
  }
}
@media (max-height: 500px) {                          /* phone held sideways: the panel is a 220-260 px column */
  :root { --tb-go-h: 60px; --tb-bar-h: 56px; --tb-chip: 48px; --tb-head-icon: 48px; --tb-fs-go: 24px; }
}
/* Nothing sets data-theme; the :not() only raises the specificity, so these dark values beat a page's own light
   :root tokens whatever order the page's styles come in. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #13233F;
    --panel: #1C3157;
    --ink: #EEF3FF;
    --muted: #B4C1DE;
    --edge: #9FB8E8;
    --plate: #E6F2FF;
    --focus: #FFC93C;
    --tb-ink: #EEF3FF; --tb-ink-2: #B4C1DE; --tb-bg: #13233F; --tb-surface: #1C3157; --tb-tile-bg: #22395F;
    --tb-lip: #0B1528; --tb-job: #2A4470; --tb-off: #2B3B5C; --tb-focus: #FFC93C;
    --tb-card: 0 6px 18px rgba(0, 0, 0, 0.35);
    color-scheme: dark;
  }
}

/* ---------- Buttons ----------
   The cleaner chrome (redesign 1.14): a 2 px outline and a short bottom lip, like a real push button. Pressed, it
   moves down by the lip. Sizes stay as they were for the pages not yet moved to the new components, so their
   panels keep their layout; the components below use the token sizes. */
.btn {
  font: inherit;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--ink);
  background: var(--panel);
  border: var(--tb-outline) solid var(--edge);
  border-radius: var(--tb-r-btn);
  padding: 0.45rem 0.8rem;
  min-height: 52px;
  cursor: pointer;
  box-shadow: 0 var(--tb-lip-h-sm) 0 var(--tb-lip);
  transition: transform var(--tb-t-press) ease, box-shadow var(--tb-t-press) ease, filter var(--tb-t-press) ease;
}
.btn:active { transform: translateY(var(--tb-lip-h-sm)); box-shadow: 0 0 0 var(--tb-lip); filter: brightness(0.94); }
/* Picked: the pick yellow, a 3 px outline (drawn inside, so nothing moves) and its own lip. */
.btn[aria-pressed="true"] { background: var(--tb-pick); color: #1D2340;
  box-shadow: inset 0 0 0 1px var(--edge), 0 var(--tb-lip-h-sm) 0 var(--tb-pick-lip); }
.btn[aria-pressed="true"]:active { box-shadow: inset 0 0 0 1px var(--edge); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
/* Grown-up sheet only (yellow means "picked" for children's controls). */
.btn.primary { background: var(--accent); color: #1D2340; box-shadow: 0 var(--tb-lip-h-sm) 0 var(--tb-pick-lip); }
.btn[hidden] { display: none; }
button {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

/* While the timer winds down, the way out is closed. */
body.ending .homebtn { pointer-events: none; opacity: 0.4; }

/* ---------- Timer badge (optional; the app places the <svg class="tbadge">) ---------- */
.tbadge { width: 46px; height: 46px; display: block; }
.tbadge[hidden] { display: none; }
@media (min-width: 744px) and (min-height: 640px) {
  .tbadge { width: 56px; height: 56px; }
}

/* ---------- Warning toast and ending banner ---------- */
.toast {
  position: fixed;
  top: calc(max(10px, env(safe-area-inset-top, 0px)) + 120px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 9;
  background: var(--accent);
  color: #1D2340;
  border: 3px solid #1D2340;
  border-radius: 24px;
  padding: 0.3rem 1rem;
  font-size: 1.4rem;
  font-weight: 800;
  /* One line when it fits; wraps instead of running off a phone screen. */
  width: max-content;
  max-width: calc(100vw - 32px);
  text-align: center;
  line-height: 1.2;
  box-shadow: 3px 3px 0 #1D2340;
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
}
.toast.show { opacity: 1; }
.toast[hidden] { display: none; }
.farewell {
  position: fixed;
  left: 50%;
  bottom: max(18px, calc(env(safe-area-inset-bottom, 0px) + 8px));
  transform: translateX(-50%);
  z-index: 9;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: #FFFFFF;
  color: #1D2340;
  border: 3px solid #1D2340;
  border-radius: 22px;
  padding: 10px 16px 12px;
  box-shadow: 4px 4px 0 #1D2340;
  text-align: center;
}
.farewell[hidden] { display: none; }
.farewell p { margin: 0; font-size: 1.35rem; font-weight: 800; white-space: nowrap; }
.goodbye {
  background: var(--accent);
  color: #1D2340;
  border-color: #1D2340;
  box-shadow: 3px 3px 0 #1D2340;
  font-size: 1.35rem;
  min-height: 58px;
  padding: 0.4rem 1.2rem;
}
.goodbye[hidden] { display: none; }

/* ---------- Grown-up sheet ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(12px, env(safe-area-inset-top, 0px)) 12px max(12px, env(safe-area-inset-bottom, 0px));
  background: rgba(13, 20, 38, 0.55);
}
.modal[hidden] { display: none; }
.sheet {
  width: 100%;
  max-width: 480px;
  max-height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  background: var(--panel);
  color: var(--ink);
  font-family: var(--font);
  border: 4px solid var(--edge);
  border-radius: 24px;
  box-shadow: 6px 6px 0 var(--edge);
  padding: 18px 18px 20px;
  -webkit-user-select: text;
  user-select: text;
}
.sheet h2 { margin: 0 0 4px; font-size: 1.6rem; font-weight: 800; text-align: center; }
.sheet h3 { margin: 16px 0 8px; font-size: 1.15rem; font-weight: 800; text-align: center; }
.sheet section + section { margin-top: 8px; padding-top: 6px; border-top: 3px dashed rgba(127, 140, 170, 0.45); }
.sheet .opt { color: var(--muted); font-weight: 500; }
.sheet .sub { margin: 0; color: var(--muted); text-align: center; font-size: 1rem; }
.sheet .row { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.sheet .row .btn { min-width: 74px; }
.sheet .textin {
  display: block;
  width: 100%;
  font: inherit;
  font-size: 1.1rem;
  color: var(--ink);
  background: var(--bg);
  border: 3px solid var(--edge);
  border-radius: 14px;
  padding: 0.45rem 0.8rem;
}
.sheet .textin:focus-visible { outline: 4px solid var(--focus); outline-offset: 2px; }
.sheet .check { display: flex; align-items: center; gap: 10px; margin-top: 12px; font-size: 1.05rem; cursor: pointer; }
.sheet .check input { width: 24px; height: 24px; accent-color: #2D5BD7; flex: none; }
.sheet .sheet-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.sheet .time-left { margin: 6px 0 8px; text-align: center; font-size: 1.6rem; font-weight: 800; }
.sheet .status { margin: 0 0 8px; text-align: center; font-weight: 700; }
.sheet [hidden] { display: none; }

/* Kind words controls in the home screen's Grown-ups sheet (common/toybox.js, kindBuildSettings). */
.sheet .tb-kd-h { margin: 14px 0 6px; text-align: center; font-weight: 800; }
.sheet .tb-kd .check { margin-top: 8px; }
.tb-kd-pic { display: inline-block; flex: none; width: 1.5em; height: 1.4em; vertical-align: middle; }
.tb-kd-pic svg { display: block; width: 100%; height: 100%; }
.sheet .tb-kd-kindbtn { display: inline-flex; align-items: center; gap: 4px; min-width: 0; }
.tb-kd-mine { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.tb-kd-line { display: flex; align-items: center; gap: 6px; }
.tb-kd-line .textin { flex: 1 1 auto; min-width: 0; font-size: 1rem; }
.sheet .tb-kd-line .btn { flex: none; min-width: 46px; min-height: 46px; padding: 0 6px; }
.tb-kd-add { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.tb-kd-usual { margin-top: 12px; border: 3px solid var(--edge); border-radius: 14px; padding: 8px 12px; }
.tb-kd-usual summary { cursor: pointer; font-weight: 800; min-height: 32px; line-height: 32px; }
.tb-kd-group { margin-top: 8px; }
.sheet .tb-kd-gh { display: flex; align-items: center; gap: 8px; margin: 10px 0 2px; font-weight: 800; }
.sheet .tb-kd-gh .btn { min-width: 0; min-height: 36px; padding: 0 12px; font-size: 0.95rem; }
.sheet .tb-kd-gh .btn:first-of-type { margin-left: auto; }


.hold { position: relative; overflow: hidden; -webkit-touch-callout: none; }
.hold .fill { position: absolute; inset: 0 auto 0 0; width: 0; background: rgba(255, 201, 60, 0.75); }
.hold .label { position: relative; }

/* ---------- Rest screen ---------- */
.rest {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top, 0px)) 16px max(16px, env(safe-area-inset-bottom, 0px));
  background: var(--bg);
  font-family: var(--font);
}
.rest[hidden] { display: none; }
.rest-card {
  width: 100%;
  max-width: 440px;
  max-height: 100%;
  overflow: hidden;
  background: var(--plate);
  color: #1D2340;
  border: 4px solid var(--edge);
  border-radius: 28px;
  box-shadow: 6px 6px 0 var(--edge);
  padding: 20px 20px 24px;
  text-align: center;
}
.rest-art { display: block; width: min(60vw, 250px, 34vh); height: auto; margin: 0 auto 6px; }
.rest-card h2 { margin: 4px 0 6px; font-size: 2.2rem; font-weight: 800; line-height: 1.1; }
.rest-line { margin: 2px 0; font-size: 1.25rem; font-weight: 700; }
.rest-next {
  margin: 16px auto 0;
  display: inline-block;
  background: var(--accent);
  border: 3px solid #1D2340;
  border-radius: 16px;
  padding: 0.4rem 1.1rem;
  font-size: 1.5rem;
  font-weight: 700;
}
.rest-next[hidden] { display: none; }
.lock {
  position: fixed;
  right: max(14px, env(safe-area-inset-right, 0px));
  bottom: max(14px, env(safe-area-inset-bottom, 0px));
  width: 64px;
  height: 48px;
  border: 3px solid var(--edge);
  border-radius: 14px;
  background: var(--panel);
  font-size: 1.3rem;
  cursor: pointer;
  opacity: 0.7;
  touch-action: none;
}
.lock:focus-visible { outline: 4px solid var(--focus); outline-offset: 2px; }
@media (orientation: landscape) and (max-height: 520px) {
  .rest-card { padding: 10px 16px 14px; }
  .rest-art { width: min(30vh, 150px); margin-bottom: 0; }
  .rest-card h2 { font-size: 1.7rem; margin: 0 0 2px; }
  .rest-next { margin-top: 8px; font-size: 1.2rem; }
}

@media (prefers-reduced-motion: reduce) {
  .btn { transition: none; }
  .toast { transition: none; }
}

/* ---------- "Turn it sideways!": an app that prefers one orientation (Toybox.init({ orientation })) ---------- */
.tb-turn {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top, 0px)) 16px max(16px, env(safe-area-inset-bottom, 0px));
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
.tb-turn[hidden] { display: none; }
.tb-turn-card { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.tb-turn-text { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.tb-turn-art { width: min(56vw, 42vh, 320px); height: min(56vw, 42vh, 320px); }
.tb-turn-art svg { display: block; width: 100%; height: 100%; overflow: visible; }
/* The tablet turns a quarter turn, holds, fades out and comes back upright: slow, like the rest of the Toybox. */
.tb-tablet { transform-origin: 80px 80px; animation: tb-turn-land 4.2s ease-in-out infinite; }
.tb-turn.to-port .tb-tablet { animation-name: tb-turn-port; }
@keyframes tb-turn-land {
  0%, 22% { transform: rotate(0deg); opacity: 1; }
  52%, 84% { transform: rotate(-90deg); opacity: 1; }
  92% { transform: rotate(-90deg); opacity: 0; }
  93% { transform: rotate(0deg); opacity: 0; }
  100% { transform: rotate(0deg); opacity: 1; }
}
@keyframes tb-turn-port {
  0%, 22% { transform: rotate(-90deg); opacity: 1; }
  52%, 84% { transform: rotate(0deg); opacity: 1; }
  92% { transform: rotate(0deg); opacity: 0; }
  93% { transform: rotate(-90deg); opacity: 0; }
  100% { transform: rotate(-90deg); opacity: 1; }
}
.tb-turn h2 { margin: 0; font-size: 2.4rem; font-weight: 800; line-height: 1.1; }
.tb-turn .btn { margin-top: 10px; font-size: 1rem; min-height: 46px; padding: 0.3rem 1rem; opacity: 0.8; }
@media (orientation: landscape) and (max-height: 520px) {
  .tb-turn-card { flex-direction: row; gap: 24px; }
  .tb-turn-art { width: min(40vh, 200px); height: min(40vh, 200px); }
  .tb-turn h2 { font-size: 1.9rem; }
}
@media (prefers-reduced-motion: reduce) {
  .tb-tablet { animation: none; transform: rotate(-90deg); }
  .tb-turn.to-port .tb-tablet { transform: none; }
}

/* ======================================================================
   App shell: the same layout and the same pieces in every app.
   See AGENTS.md "Standard layout" and plans/redesign.md 1.2. Demo: tools/shell-demo.html
   Pages moved to the new system add "tb-v2" to the shell (<div class="tb-app-shell tb-v2">): that turns on the
   token sizes (header icons, title, coach, counter, panel spacing). Pages without it keep their old sizes and get
   only the cleaner look, so their panels keep their layout.
   ====================================================================== */
.tb-app-shell { position: fixed; inset: 0; display: flex; flex-direction: column; gap: 8px;
  padding: max(8px, env(safe-area-inset-top, 0px)) max(10px, env(safe-area-inset-right, 0px))
           max(8px, env(safe-area-inset-bottom, 0px)) max(10px, env(safe-area-inset-left, 0px)); }
/* Header: Back (stations only), Home, title, then Big on the right. All white with ink line icons. */
.tb-head { flex: none; display: flex; align-items: center; gap: 8px; min-height: 48px; }
.tb-head .tb-title { margin: 0; font-size: 1.6rem; font-weight: 800; line-height: 1; letter-spacing: 0.2px; white-space: nowrap; overflow: hidden; min-width: 0; flex: 1 1 auto; }
/* A station's title starts with its app's name, quieter than the station's own name ("Workshop · Drill Press"). */
.tb-head .tb-title .tb-app { color: var(--tb-ink-2, #4A5578); font-weight: 700; }
/* An upright phone has room only for the station's name (the dad, 2026-11-14). */
@media (max-width: 600px) { .tb-head .tb-title .tb-app { display: none; } }
.tb-head .tb-spacer { flex: 1 1 auto; }
.tb-iconbtn { min-width: 48px; min-height: 48px; padding: 0 10px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.tb-iconbtn svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
/* Back is white like Home and Big (yellow means picked). */
.tb-back { background: var(--panel); color: var(--ink); font-weight: 800; }
/* Stage: the play area, the star of the screen. A 3 px frame where it meets the drawn scene, no shadow.
   Counter top-left, coach line top-center (bottom-center on phones); nothing else floats in it. */
.tb-stage { position: relative; flex: 1 1 auto; min-height: 0; border: var(--tb-frame) solid var(--edge); border-radius: var(--tb-r-stage);
  box-shadow: none; overflow: hidden; background: var(--plate); }
.tb-counter { position: absolute; left: 10px; top: 10px; z-index: 3; background: #FFFFFF; color: #1D2340;
  border: var(--tb-outline) solid #1D2340; border-radius: 999px; padding: 0.15rem 0.8rem; font-weight: 800; font-size: 1.2rem;
  box-shadow: none; pointer-events: none; }
/* Panel: under the stage in portrait, a column on the right in landscape. A soft white card (no outline).
   Order inside (redesign 1.2): job bar (hangs from the stage, see .tb-jobs), then EITHER the step row (Go is the
   current step) OR Go + choice tiles, then the bottom bar (Shelf, New, Surprise). */
.tb-panel { flex: none; display: flex; flex-direction: column; gap: 8px; background: var(--panel);
  border: 0; border-radius: var(--tb-r-panel); box-shadow: var(--tb-card); padding: var(--tb-s3); }
.tb-choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.tb-tile { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 72px; padding: 4px; font-size: 0.95rem; line-height: 1.05; background: var(--tb-tile-bg); border-radius: var(--tb-r-tile); }
.tb-tile svg, .tb-tile canvas, .tb-tile img { width: 44px; height: 44px; flex: none; }
/* Picked tile: a round ink tick badge in the corner (never color alone). */
.tb-tile[aria-pressed="true"]::after {
  content: ""; position: absolute; right: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%; pointer-events: none;
  background: #1D2340 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M5.5 10.5l3 3 6-6.5' fill='none' stroke='white' stroke-width='2.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/100% no-repeat;
}
/* Old text tab bar (retired in favor of .tb-bottombar and .tb-jobs; kept working for pages not yet moved). */
.tb-tabs { display: flex; gap: 6px; }
.tb-tabs .btn { flex: 1 1 0; min-height: 46px; min-width: 0; padding: 0.2rem 0.4rem; font-size: 1rem; white-space: nowrap; }
/* The one big main action ("Launch!", "Drive!", "Print!", "Pour!"): always green, white bold words, a deep lip. */
.btn.tb-go { background: var(--tb-go); color: #FFFFFF; font-size: 1.6rem; font-weight: 800; min-height: 60px;
  text-shadow: none; box-shadow: 0 var(--tb-lip-h) 0 var(--tb-go-lip); }
.btn.tb-go:active { transform: translateY(var(--tb-lip-h)); box-shadow: 0 0 0 var(--tb-go-lip); }
/* Start over ("New"): always orange, with the circular arrow. */
.btn.tb-new { background: var(--tb-new); color: #1D2340; box-shadow: 0 var(--tb-lip-h) 0 var(--tb-new-lip); }
.btn.tb-new:active { transform: translateY(var(--tb-lip-h)); box-shadow: 0 0 0 var(--tb-new-lip); }
/* Surprise: a sparkly rainbow outline with two twinkling stars (the "magic" cue). */
@property --tb-spin { syntax: "<angle>"; inherits: false; initial-value: 0deg; }
.btn.tb-surprise {
  position: relative; border: 3px solid transparent; font-weight: 800;
  background:
    linear-gradient(var(--panel), var(--panel)) padding-box,
    conic-gradient(from var(--tb-spin), #FF4D6D, #FFB627, #FFE14D, #4CD964, #3DB4FF, #8E6CFF, #FF6FD8, #FF4D6D) border-box;
  box-shadow: 0 var(--tb-lip-h-sm) 0 var(--tb-lip), 0 0 8px rgba(255, 201, 60, 0.45);
  animation: tb-spin 3s linear infinite;
}
.btn.tb-surprise:active { box-shadow: 0 0 8px rgba(255, 201, 60, 0.45); }
.btn.tb-surprise[aria-pressed="true"] {
  background:
    linear-gradient(var(--accent), var(--accent)) padding-box,
    conic-gradient(from var(--tb-spin), #FF4D6D, #FFB627, #FFE14D, #4CD964, #3DB4FF, #8E6CFF, #FF6FD8, #FF4D6D) border-box;
}
.btn.tb-surprise::before, .btn.tb-surprise::after {
  content: "\2726"; position: absolute; font-size: 0.8rem; line-height: 1; color: #FFC93C;
  text-shadow: 0 0 5px #FFFFFF, 0 0 2px #1D2340; pointer-events: none; animation: tb-twinkle 1.6s ease-in-out infinite;
}
.btn.tb-surprise::before { left: -6px; top: -8px; }
.btn.tb-surprise::after { right: -5px; bottom: -8px; color: #FF6FD8; animation-delay: 0.8s; }
@keyframes tb-spin { to { --tb-spin: 360deg; } }
@keyframes tb-twinkle { 0%, 100% { transform: scale(0.6) rotate(0deg); opacity: 0.5; } 50% { transform: scale(1.2) rotate(45deg); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .btn.tb-surprise, .btn.tb-surprise::before, .btn.tb-surprise::after { animation: none; } }
/* Landscape: stage on the left, panel as a column on the right. */
@media (orientation: landscape) {
  .tb-body { flex: 1 1 auto; min-height: 0; display: flex; gap: 10px; }
  .tb-body .tb-panel { width: min(38%, 400px); overflow: hidden; }
  .tb-body .tb-panel .tb-choices { flex: 1 1 auto; align-content: start; overflow-y: auto; }
}
@media (orientation: portrait) {
  .tb-body { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 8px; }
}
@media (max-width: 600px), (orientation: landscape) and (max-height: 520px) {
  .tb-head { min-height: 44px; }
  .tb-head .tb-title { font-size: 1.3rem; }
  .tb-iconbtn { min-width: 44px; min-height: 44px; }
  .tb-iconbtn span { display: none; }
  .tb-stage, .tb-panel { border-radius: 20px; }
  .btn.tb-go { font-size: 1.35rem; min-height: 52px; }
  .tb-counter { font-size: 1rem; }
}
/* Coach line: one short line in a big pill at the bottom-center of the stage on every size, near his hands, where he
   looks (the dad, 2026-10-10: small at the top, he missed it). Taps pass through it. */
.tb-coach { position: absolute; left: 50%; top: auto; bottom: 14px; z-index: 3; transform: translateX(-50%); width: max-content;
  max-width: calc(100% - 24px); background: #FFFFFF; color: #1D2340; border: var(--tb-outline) solid #1D2340; border-radius: 26px;
  box-shadow: var(--tb-card); padding: 0.3rem 1.2rem; font-size: 1.6rem; font-weight: 800; line-height: 1.15;
  white-space: normal; overflow-wrap: break-word; text-wrap: balance;
  text-align: center; pointer-events: none; transition: opacity 0.6s ease; }
.tb-coach.off { opacity: 0; }
body.ending .tb-coach { visibility: hidden; }
/* Tablets: bigger tiles and tabs. */
@media (min-width: 700px) and (min-height: 700px) {
  .tb-choices { grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
  .tb-tile { min-height: 100px; font-size: 1.1rem; }
  .tb-tile svg, .tb-tile canvas, .tb-tile img { width: 62px; height: 62px; }
  .tb-tabs .btn { min-height: 54px; font-size: 1.15rem; }
}
@media (max-width: 600px), (orientation: landscape) and (max-height: 520px) {
  .tb-coach { top: auto; bottom: 10px; font-size: 1.25rem; padding: 0.2rem 0.9rem; }
  .tb-tabs { gap: 5px; }
  .tb-tabs .btn { font-size: 0.92rem; padding: 0.15rem 0.25rem; }
}
/* The last header item (Big) always sits at the right edge, even when the title is dropped. */
.tb-head > :last-child { margin-left: auto; }

/* ---------- tb-v2: the token sizes for pages moved to the new system ---------- */
.tb-v2.tb-app-shell { gap: 10px;
  padding: max(8px, env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-right, 0px))
           max(8px, calc(env(safe-area-inset-bottom, 0px) + 4px)) max(12px, env(safe-area-inset-left, 0px)); }
.tb-v2 .tb-head { min-height: var(--tb-head-icon); gap: var(--tb-s2); }
.tb-v2 .tb-head .tb-title { font-size: var(--tb-fs-title); }
.tb-v2 .tb-iconbtn { min-width: var(--tb-head-icon); min-height: var(--tb-head-icon); padding: 0 12px; font-size: var(--tb-fs-btn); }
.tb-v2 .tb-iconbtn svg { width: 26px; height: 26px; }
.tb-v2 .tb-iconbtn .tb-mapic { width: 30px; height: 30px; stroke: none; }
.tb-v2 .tb-body { gap: 10px; }
.tb-v2 .tb-panel { gap: var(--tb-s3); padding: var(--tb-s3); }
.tb-v2 .tb-counter { font-size: var(--tb-fs-count); padding: 0.1rem 0.75rem; }
.tb-v2 .tb-coach { font-size: var(--tb-fs-coach); font-weight: 700; padding: 4px 16px; border-radius: var(--tb-r-pill); }
/* The coach names the current step: a small pick-colored dot at its start. */
.tb-coach .tb-coach-dot { display: none; width: 0.55em; height: 0.55em; border-radius: 50%; background: var(--tb-pick);
  box-shadow: 0 0 0 3px var(--tb-glow); margin-right: 0.45em; vertical-align: 0.08em; }
.tb-coach.is-step .tb-coach-dot { display: inline-block; }
/* The step dot belongs to the redesign; older pages that run their lines through Toybox.coach never had it. */
.tb-app-shell:not(.tb-v2) .tb-coach .tb-coach-dot { display: none; }
/* Always centered and fully inside the stage: it wraps (up to two lines) rather than running off an edge. */
.tb-v2 .tb-coach { max-width: calc(100% - 32px); white-space: normal; overflow-wrap: break-word; text-wrap: balance; }
/* A new line pops in (the pill stays centered). */
.tb-coach.is-new { animation: tb-coach-pop 0.35s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes tb-coach-pop { from { transform: translateX(-50%) scale(0.85); } to { transform: translateX(-50%) scale(1); } }
@media (prefers-reduced-motion: reduce) { .tb-coach.is-new { animation: none; } }
@media (min-width: 700px) and (min-height: 700px) {
  .tb-v2.tb-app-shell { gap: 16px;
    padding: max(10px, env(safe-area-inset-top, 0px)) max(20px, env(safe-area-inset-right, 0px))
             max(10px, calc(env(safe-area-inset-bottom, 0px) + 4px)) max(20px, env(safe-area-inset-left, 0px)); }
  .tb-v2 .tb-body { gap: 16px; }
  .tb-v2 .tb-panel { padding: var(--tb-s4); gap: var(--tb-s4); }
}
@media (max-width: 600px), (orientation: landscape) and (max-height: 520px) {
  .tb-v2 .tb-iconbtn { padding: 0 10px; }
  .tb-v2 .tb-counter { font-size: var(--tb-fs-count); }
  .tb-v2 .tb-coach { font-size: var(--tb-fs-coach); padding: 3px 14px; bottom: 12px; }
  .tb-v2 .tb-stage, .tb-v2 .tb-panel { border-radius: var(--tb-r-stage); }
}
@media (orientation: landscape) {
  .tb-v2 .tb-body .tb-panel { width: min(34%, 380px); overflow: visible; }
}
@media (orientation: landscape) and (max-height: 520px) {
  .tb-v2 .tb-body .tb-panel { width: 252px; padding: 10px; gap: 10px; }
}
/* A panel that holds only the bottom bar (the hands-on Farm stations: no step row, no Go, no tiles): in landscape it
   is a slim column with New and Surprise stacked at the bottom, so the stage gets the room instead of an empty
   white card (the builders of the Farm stations, 2026-10-16). */
@media (orientation: landscape) {
  .tb-v2 .tb-body .tb-panel.tb-panel-bar { width: 132px; padding: 10px; background: transparent; box-shadow: none; }
  .tb-v2 .tb-panel.tb-panel-bar > .tb-bottombar { flex-direction: column; align-items: stretch; gap: 12px; }
  .tb-v2 .tb-panel.tb-panel-bar > .tb-bottombar .btn { flex: 0 0 auto; margin-left: 0; flex-direction: column; gap: 2px; padding: 6px 4px; }
}
@media (orientation: landscape) and (max-height: 520px) {
  .tb-v2 .tb-body .tb-panel.tb-panel-bar { width: 96px; padding: 6px; }
  .tb-v2 .tb-panel.tb-panel-bar > .tb-bottombar .btn { min-height: 64px; font-size: 14px; }
}

/* ---------- Done card (common/toybox.js Toybox.done): the end of a station's job, low on the stage ---------- */
.tb-done { position: absolute; left: 50%; bottom: 12px; z-index: 6; width: max-content; max-width: calc(100% - 24px);
  display: none; flex-direction: column; align-items: center; gap: var(--tb-sp-2, 8px); padding: 10px 14px 14px;
  background: #FFFFFF; color: #1D2340; border: var(--tb-outline, 2px) solid #1D2340; border-radius: 22px;
  box-shadow: 0 6px 18px rgba(29, 35, 64, 0.22); font-family: var(--font, "Baloo 2", sans-serif);
  transform: translateX(-50%); touch-action: manipulation; }
.tb-done.show { display: flex; animation: tb-done-in 0.6s cubic-bezier(.3, 1.4, .5, 1); }
.tb-done-line { display: flex; align-items: center; gap: 10px; margin: 0; font-size: clamp(1.2rem, 4.6vw, 1.6rem);
  font-weight: 800; line-height: 1.15; text-align: center; }
.tb-done-art { display: block; flex: none; width: 1.6em; height: 1.5em; }
.tb-done-art svg { display: block; width: 100%; height: 100%; }
.tb-done-btns { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px 24px; }
.tb-done-btns .btn { display: inline-flex; align-items: center; justify-content: center; min-height: 60px; padding: 0 18px;
  gap: 6px; font-size: 1.15rem; font-weight: 800; line-height: 1; white-space: nowrap; }
.tb-done-btns .btn svg { flex: none; }
.tb-done-btns .tb-ui-ic { width: 26px; height: 26px; }
.tb-done-btns .tb-mapic { width: 30px; height: 30px; }
.tb-done-back { background: #FFFFFF; color: #1D2340; }
body.ending .tb-done, body.resting .tb-done { display: none; }
/* Phones: one compact card that keeps most of the finished scene in view. */
@media (max-width: 480px), (max-height: 500px) {
  .tb-done { bottom: 8px; padding: 8px 10px 10px; gap: 6px; border-radius: 18px; }
  .tb-done-line { font-size: 1.1rem; gap: 8px; }
  .tb-done-btns .btn { min-height: 52px; padding: 0 12px; font-size: 1.05rem; }
  .tb-done-btns .tb-ui-ic { width: 22px; height: 22px; }
  .tb-done-btns .tb-mapic { width: 26px; height: 26px; }
}
@media (max-height: 500px) {
  .tb-done.show { flex-direction: row; gap: 14px; }
}
@keyframes tb-done-in { from { opacity: 0; transform: translate(-50%, 40px); } to { opacity: 1; transform: translate(-50%, 0); } }
@media (prefers-reduced-motion: reduce) { .tb-done.show { animation: none; } }

/* ---------- Kind words (common/toybox.js): a card with a sun, star or heart that floats in at the top ---------- */
.tb-kind {
  position: fixed;
  top: calc(max(8px, env(safe-area-inset-top, 0px)) + 4px);
  left: 50%;
  z-index: 38;
  display: flex;
  align-items: center;
  gap: 10px;
  width: max-content;
  max-width: calc(100vw - 32px);
  padding: 0.35rem 1.1rem 0.35rem 0.7rem;
  background: #FFFFFF;
  color: #1D2340;
  border: 4px solid #1D2340;
  border-radius: 999px;
  box-shadow: 4px 4px 0 #1D2340;
  font-family: var(--font, "Baloo 2", sans-serif);
  font-size: clamp(1.3rem, 5vw, 1.9rem);
  font-weight: 800;
  line-height: 1.15;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, -140%);
}
.tb-kind-art { display: block; flex: none; width: 1.6em; height: 1.5em; }
.tb-kind-art svg { display: block; width: 100%; height: 100%; }
.tb-kind.show { visibility: visible; animation: tb-kind-in 0.7s cubic-bezier(.3, 1.5, .5, 1) forwards; }
.tb-kind.show .tb-kind-art { animation: tb-kind-beat 0.9s ease-in-out 0.6s 4; }
.tb-kind.show.hide { animation: tb-kind-out 0.6s ease-in forwards; }
.tb-kind.preview { z-index: 70; }  /* "Show one now" in the Grown-ups sheet shows above the sheet */
@keyframes tb-kind-in { from { opacity: 0; transform: translate(-50%, -140%) scale(0.7); } to { opacity: 1; transform: translate(-50%, 0) scale(1); } }
@keyframes tb-kind-out { from { opacity: 1; transform: translate(-50%, 0); } to { opacity: 0; transform: translate(-50%, -60%); } }
@keyframes tb-kind-beat { 0%, 100% { transform: scale(1); } 30% { transform: scale(1.25); } 60% { transform: scale(0.95); } }
@media (prefers-reduced-motion: reduce) {
  .tb-kind.show { animation: tb-kind-fade 0.3s linear forwards; transform: translate(-50%, 0); }
  .tb-kind.show .tb-kind-art { animation: none; }
  .tb-kind.show.hide { animation: tb-kind-fade 0.3s linear reverse forwards; }
  @keyframes tb-kind-fade { from { opacity: 0; } to { opacity: 1; } }
}

/* Re-tapping the tile or tab already picked: a small wiggle (common/toybox.js) so the tap never looks dead. */
@keyframes tb-again { 0%, 100% { transform: none; } 30% { transform: rotate(-4deg) scale(1.06); } 70% { transform: rotate(4deg) scale(1.06); } }
.tb-again { animation: tb-again 0.42s ease; }
@media (prefers-reduced-motion: reduce) { .tb-again { animation: none; } }

/* ---------- No page bounce on iOS ----------
   In the home-screen app, iOS lets the whole page rubber-band when a drag starts outside a touch-action:none
   surface, even though nothing overflows (the dad: "the whole page moves" in Bubbles). Pin the page: it never
   scrolls anyway (AGENTS.md), and inner scroll areas (the Grown-ups sheet, the Tool Wall) keep scrolling. */
html, body { position: fixed; inset: 0; width: 100%; height: 100%; overflow: hidden; overscroll-behavior: none; }
/* iOS can enlarge text when the phone turns sideways, which would grow panels past the screen. */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

/* Grown-ups sheet: "Which apps use ..." lists under a setting (common/toybox.js SETTINGS list). */
.sheet .tb-uses { margin: 8px 0 4px; border: 3px solid var(--edge); border-radius: 14px; padding: 6px 12px; }
.sheet .tb-uses summary { cursor: pointer; font-weight: 800; min-height: 32px; line-height: 32px; }
.sheet .tb-uses ul { margin: 6px 0 4px; padding-left: 1.2em; }
.sheet .tb-uses li { margin: 4px 0; font-size: 0.98rem; }


/* ======================================================================
   Shared components (common/toybox.js: Toybox.go, steps, jobs, tiles, bar, coach, ghost, nametag, gate, map).
   plans/redesign.md section 2. Each renders into a container the page provides.
   ====================================================================== */
/* Picture inside a component: a content drawing (2 px ink outline, flat colors) given by the page as SVG. */
.tb-pic { display: inline-flex; align-items: center; justify-content: center; flex: none; }
.tb-pic > svg, .tb-pic > canvas, .tb-pic > img { display: block; width: 100%; height: 100%; }
.tb-panel[hidden], .tb-steps[hidden], .tb-tilerow[hidden], .tb-bottombar[hidden], .tb-jobs[hidden], .tb-place[hidden] { display: none; }
/* UI action icons: one family, 24 px grid, 2.5 px rounded stroke, no fill. */
.tb-ui-ic { width: 24px; height: 24px; flex: none; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Go (Toybox.go): the green pill; also the current step inside the step row ---------- */
.btn.tb-go.tb-gopill { position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center;
  gap: 10px; width: 100%; min-width: 0; min-height: var(--tb-go-h); padding: 0 14px; border-radius: var(--tb-r-btn);
  font-size: var(--tb-fs-go); font-weight: 800; line-height: 1.05; white-space: nowrap; touch-action: manipulation; }
.tb-gopill .tb-pic { width: 1.35em; height: 1.35em; position: relative; }
.tb-gopill .tb-go-word { position: relative; min-width: 0; }
/* A motion is running: a lighter fill grows across the pill (go.busy(fraction)). */
.tb-gopill .tb-go-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: rgba(255, 255, 255, 0.22);
  pointer-events: none; transition: width 0.25s linear; }
.tb-gopill.is-busy .tb-go-fill { width: var(--tb-go-p, 100%); }
.tb-gopill.is-pulse { animation: tb-go-pulse 1.1s ease-in-out infinite; }
@keyframes tb-go-pulse { 0%, 100% { filter: none; } 50% { filter: brightness(1.18); transform: scale(1.03); } }
.tb-wiggle { animation: tb-wiggle 0.5s ease; }
@keyframes tb-wiggle { 0%, 100% { transform: none; } 25% { transform: rotate(-3deg) scale(1.04); } 60% { transform: rotate(3deg) scale(1.04); } }
.tb-pop { animation: tb-pop 0.45s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes tb-pop { 0% { transform: scale(0.7); } 100% { transform: scale(1); } }

/* ---------- Step row (Toybox.steps): done ticks | Go (the current step) | coming steps ---------- */
.tb-steps { list-style: none; margin: 0; padding: 0; display: flex; align-items: center; gap: 6px; min-width: 0;
  background: linear-gradient(var(--tb-off), var(--tb-off)) 0 calc(var(--tb-chip) / 2 - 2px) / 100% 4px no-repeat; }
.tb-steps > .tb-st-go { flex: 1 1 auto; min-width: 0; display: flex; }
.tb-chip { flex: none; position: relative; min-width: var(--tb-chip); /* grows to fit its word so words never run together */ display: flex; flex-direction: column; align-items: center; gap: 2px;
  cursor: pointer; -webkit-tap-highlight-color: transparent; align-self: flex-start; }
.tb-chip-dot { position: relative; width: var(--tb-chip); height: var(--tb-chip); border-radius: 50%; display: flex; align-items: center;
  justify-content: center; background: #FFFFFF; border: var(--tb-outline) solid #9AA6C2; }
.tb-chip-dot .tb-pic { width: 60%; height: 60%; opacity: 0.55; }
.tb-chip-word { font-size: var(--tb-fs-small); font-weight: 700; line-height: 1.1; color: var(--tb-ink-2); white-space: nowrap; }
.tb-chip.is-done .tb-chip-dot { background: var(--tb-go); border-color: var(--tb-line); }
.tb-chip.is-done .tb-chip-dot .tb-pic { display: none; }
.tb-chip .tb-tick { display: none; width: 58%; height: 58%; }
.tb-chip.is-done .tb-tick { display: block; }
.tb-chip.is-done .tb-chip-word { color: var(--tb-ink); }
/* Several steps done on a narrow row: one chip for all of them. */
.tb-chip.is-many .tb-chip-dot { box-shadow: 4px 0 0 -1px var(--tb-go), 4px 0 0 1px var(--tb-line); }
.tb-chip.is-wiggle .tb-chip-dot { animation: tb-wiggle 0.5s ease; }
.tb-steps.is-pulse .tb-st-go .tb-gopill { animation: tb-go-pulse 1.1s ease-in-out infinite; }
/* A finished job: every step ticked, Go says "Again!". */
.tb-steps.is-finished .tb-st-go .tb-gopill { animation: tb-pop 0.5s cubic-bezier(.3, 1.6, .5, 1); }
@media (max-width: 520px) {
  .tb-steps.is-crowded { --tb-chip: 48px; gap: 5px; }
}
/* In a side column (landscape) the row wraps: done ticks above Go, coming steps below it. */
@media (orientation: landscape) {
  .tb-v2 .tb-steps, .tb-steps.is-column { flex-wrap: wrap; justify-content: center; row-gap: 6px; background: none; }
  .tb-v2 .tb-steps > .tb-st-go, .tb-steps.is-column > .tb-st-go { flex: 1 1 100%; }
  .tb-v2 .tb-steps .tb-chip, .tb-steps.is-column .tb-chip { align-self: auto; }
}

/* ---------- Job bar (Toybox.jobs): folder tabs hanging from the stage's bottom edge ----------
   Put the stage and the bar in a column: <div class="tb-stagecol"><main class="tb-stage">..</main><div id="jobs"></div></div> */
.tb-stagecol { flex: 1 1 auto; min-height: 0; min-width: 0; display: flex; flex-direction: column; }
.tb-stagecol > .tb-stage { flex: 1 1 auto; }
.tb-jobs { flex: none; display: flex; gap: var(--tb-s2); padding: 0 var(--tb-s3); margin-top: calc(-1 * var(--tb-frame)); position: relative; z-index: 1; }
.tb-job { flex: 1 1 0; min-width: 0; min-height: var(--tb-tab-h); display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 0 8px; font: inherit; font-size: var(--tb-fs-btn); font-weight: 700; line-height: 1.05; color: var(--tb-ink-2);
  background: var(--tb-job); border: var(--tb-outline) solid var(--tb-line); border-top: 0; border-radius: 0 0 16px 16px; cursor: pointer;
  white-space: nowrap; transition: transform var(--tb-t-press) ease; }
.tb-job .tb-pic { width: 30px; height: 30px; }
.tb-job:active { transform: translateY(2px); }
.tb-job[aria-selected="true"] { background: var(--tb-surface); color: var(--tb-ink); box-shadow: inset 0 -5px 0 var(--tb-pick);
  border-color: var(--tb-line); margin-top: 0; }
.tb-job:focus-visible { outline: 3px solid var(--tb-focus); outline-offset: 2px; }
@media (max-width: 520px) {
  .tb-jobs { gap: 6px; padding: 0 8px; }
  .tb-job { gap: 4px; padding: 0 4px; }
  .tb-job .tb-pic { width: 26px; height: 26px; }
}

/* ---------- Choice tiles (Toybox.tiles) ---------- */
.tb-tilerow { display: grid; grid-template-columns: repeat(var(--tb-cols, 4), minmax(0, 1fr)); gap: var(--tb-s2); }
.tb-tilerow .btn.tb-tile { min-height: var(--tb-tile); min-width: 0; padding: 6px 4px 4px; font-size: var(--tb-fs-tile); font-weight: 700;
  gap: 2px; border-radius: var(--tb-r-tile); }
.tb-tilerow .tb-tile .tb-pic { width: calc(var(--tb-tile) * 0.52); height: calc(var(--tb-tile) * 0.52); }
.tb-tilerow .tb-tile-word { display: block; max-width: 100%; white-space: nowrap; }
.tb-tilerow .btn.tb-tile[aria-pressed="true"] { box-shadow: inset 0 0 0 1px var(--tb-line), 0 var(--tb-lip-h-sm) 0 var(--tb-pick-lip); }
/* Action tiles (drop a fruit in): no picked state, a small "+" badge. */
.tb-tile.is-action::after { content: "+"; position: absolute; right: 4px; top: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--tb-go); color: #FFFFFF; font-size: 17px; line-height: 19px; font-weight: 800; text-align: center; pointer-events: none; }
.tb-tile.is-flash { animation: tb-pop 0.45s cubic-bezier(.3, 1.6, .5, 1); }
/* Color swatches: the fill is the color; picked = a thick ring + the tick. */
.tb-tilerow .btn.tb-tile.is-swatch { background: var(--tb-sw); }
.tb-tilerow .btn.tb-tile.is-swatch[aria-pressed="true"] { background: var(--tb-sw); box-shadow: inset 0 0 0 4px #FFFFFF, inset 0 0 0 6px var(--tb-line), 0 var(--tb-lip-h-sm) 0 var(--tb-lip); }
@media (min-width: 700px) and (min-height: 700px) { .tb-tilerow { gap: var(--tb-s3); } }

/* ---------- Bottom bar (Toybox.bar): Shelf (left) ... New, Surprise (right) ---------- */
.tb-bottombar { display: flex; align-items: center; gap: var(--tb-s3); width: 100%; max-width: 560px; margin: 0 auto; }
.tb-bottombar .btn { min-height: var(--tb-bar-h); min-width: 0; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 0 14px; font-size: var(--tb-fs-btn); font-weight: 700; white-space: nowrap; }
.tb-bottombar .tb-bb-new { flex: 1 1 0; }
.tb-bottombar .tb-bb-surprise { flex: 1.2 1 0; margin-left: calc(var(--tb-gap-new) - var(--tb-s3)); }
.tb-bottombar .btn.tb-bb-shelf { flex: 1 1 0; background: var(--tb-shelf); color: #1D2340; box-shadow: 0 var(--tb-lip-h) 0 var(--tb-shelf-lip); }
.tb-bottombar .btn.tb-bb-shelf:active { transform: translateY(var(--tb-lip-h)); box-shadow: none; }
.tb-bottombar .btn.tb-bb-shelf[aria-pressed="true"] { background: #FFFFFF; box-shadow: inset 0 0 0 1px var(--tb-line), 0 var(--tb-lip-h) 0 var(--tb-shelf-lip); }
@media (orientation: landscape) {
  /* Side column: Go at the top, the bottom bar at the bottom; the hanging job bar stays clear of the edge. */
  .tb-v2 .tb-panel > .tb-bottombar { margin-top: auto; }
  .tb-v2 .tb-stagecol { padding-bottom: 8px; }
}
@media (orientation: landscape) and (max-height: 520px) {
  .tb-bottombar { gap: 8px; }
  .tb-bottombar .btn { padding: 0 8px; gap: 6px; font-size: 16px; }
  .tb-bottombar .tb-bb-surprise { margin-left: calc(var(--tb-gap-new) - 8px); }
}

/* ---------- Ghost hand (Toybox.ghost) ---------- */
.ghosthand { position: fixed; left: 0; top: 0; z-index: 45; display: none; pointer-events: none; opacity: 0; will-change: transform, opacity; }
.ghosthand svg { display: block; width: 100%; height: 100%; overflow: visible; }
.ghosthand > svg { position: relative; }
.ghosthand .gh-carry svg { width: 100%; height: 100%; transform: rotate(14deg); }
.ghosthand .gh-carry img { display: block; width: 100%; height: 100%; transform: rotate(14deg); }
.ghosthand .gh-press { opacity: 0; transition: opacity 0.12s ease; }

/* ---------- Name tags (Toybox.nametag): a real part's name for a moment ----------
   Info, not an instruction, so it looks nothing like the coach line (the dad, 2026-10-10: the same oval bubble and
   font for both was confusing): small plain text on a small square-cornered label, regular weight, a thin outline,
   and a little pointer down to the part. (x, y) is the pointer's tip; --tb-tag-dx moves the pointer along the label
   when the label is nudged in from the screen edge. */
.tb-nametag { position: fixed; z-index: 35; left: 0; top: 0; transform: translate(-50%, calc(-100% - 7px)); padding: 1px 7px 2px;
  background: #FFFFFF; color: #1D2340; border: 1px solid rgba(29, 35, 64, 0.6); border-radius: 4px;
  box-shadow: 0 1px 3px rgba(29, 35, 64, 0.18);
  font-family: var(--font, "Baloo 2", system-ui, sans-serif); font-size: 14px; font-weight: 500; line-height: 1.25; white-space: nowrap;
  pointer-events: none; animation: tb-tag-in 0.25s ease-out; transition: opacity 0.3s ease; }
.tb-nametag::after { content: ""; position: absolute; left: calc(50% + var(--tb-tag-dx, 0px)); top: 100%; width: 8px; height: 8px;
  background: #FFFFFF; border-right: 1px solid rgba(29, 35, 64, 0.6); border-bottom: 1px solid rgba(29, 35, 64, 0.6);
  transform: translate(-50%, -4px) rotate(45deg); }
.tb-nametag.out { opacity: 0; }
@keyframes tb-tag-in { from { transform: translate(-50%, calc(-100% - 2px)); opacity: 0; } to { transform: translate(-50%, calc(-100% - 7px)); opacity: 1; } }
body.ending .tb-nametag { display: none; }

/* ---------- Station map places (Toybox.map): the whole place is the hit area, a picture + word label ---------- */
.tb-place { position: absolute; z-index: 2; display: block; border-radius: 18px; text-decoration: none; color: #1D2340;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.tb-place:focus-visible { outline: 3px solid var(--tb-focus); outline-offset: 2px; }
.tb-place-label { position: absolute; left: 50%; bottom: 6px; transform: translateX(-50%); display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 12px 3px 6px; background: #FFFFFF; border: var(--tb-outline) solid #1D2340; border-radius: var(--tb-r-pill);
  box-shadow: var(--tb-card); font-size: var(--tb-fs-btn); font-weight: 800; line-height: 1.15; white-space: nowrap; }
.tb-place-label .tb-pic { width: 30px; height: 30px; }
.tb-place.is-press .tb-place-label { transform: translateX(-50%) translateY(2px) scale(0.96); }
.tb-place.is-press { background: rgba(255, 201, 60, 0.18); }

/* ---------- Gear-up / getting-ready gate (Toybox.gate) ---------- */
.tb-gate { position: fixed; inset: 0; z-index: 30; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--tb-s3); padding: max(16px, env(safe-area-inset-top, 0px)) 16px max(20px, calc(env(safe-area-inset-bottom, 0px) + 16px));
  background: var(--bg); color: var(--ink); font-family: var(--font); touch-action: none; -webkit-user-select: none; user-select: none; }
.tb-gate[hidden] { display: none; }
.tb-gate-title { margin: 0; font-size: calc(var(--tb-fs-title) * 1.25); font-weight: 800; line-height: 1.1; text-align: center; }
.tb-gate-row { display: flex; align-items: center; justify-content: center; gap: var(--tb-s5); min-height: 0; flex: 0 1 auto; width: 100%; }
.tb-gate-worker { position: relative; width: min(62vw, 46vh, 360px); aspect-ratio: 3 / 4; cursor: pointer; border-radius: 24px;
  background: var(--tb-surface); border: var(--tb-frame) solid var(--tb-line); box-shadow: var(--tb-card); flex: none; }
.tb-gate-worker > svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.tb-gate-worker .tb-gate-on { opacity: 0; transform: translateY(-14%) scale(1.1); transition: opacity 0.35s ease, transform 0.45s cubic-bezier(.3, 1.6, .5, 1); }
.tb-gate-worker .tb-gate-on.is-on { opacity: 1; transform: none; }
.tb-gate-items { display: grid; grid-template-columns: repeat(var(--tb-cols, 2), minmax(0, 1fr)); gap: var(--tb-gap); width: min(100%, 520px); }
.tb-gate-items .btn.tb-tile { min-height: calc(var(--tb-tile) * 1.15); font-size: var(--tb-fs-tile); touch-action: none; }
.tb-gate-items .tb-tile .tb-pic { width: calc(var(--tb-tile) * 0.62); height: calc(var(--tb-tile) * 0.62); }
.tb-gate-items .btn.tb-tile.is-on { opacity: 0.45; }
.tb-gate-hint { margin: 0; font-size: var(--tb-fs-coach); font-weight: 700; text-align: center; }
@media (orientation: landscape) {
  .tb-gate-worker { width: min(34vw, 58vh, 360px); }
  .tb-gate-items { width: min(44vw, 460px); }
}
@media (orientation: landscape) and (max-height: 520px) {
  .tb-gate { gap: 6px; padding-top: 8px; padding-bottom: 8px; }
  .tb-gate-title { font-size: 26px; }
  .tb-gate-worker { width: min(30vw, 62vh); }
}
@media (prefers-reduced-motion: reduce) {
  .tb-wiggle, .tb-pop, .tb-gopill.is-pulse, .tb-steps.is-pulse .tb-st-go .tb-gopill, .tb-chip.is-wiggle .tb-chip-dot,
  .tb-tile.is-flash, .tb-nametag { animation: none; }
  .tb-gate-worker .tb-gate-on { transition: opacity 0.2s linear; transform: none; }
}
/* The Big button is gone (the dad, 2026-10-10); the module hides it too. */
.bigtoggle { display: none !important; }
/* No page zoom (the dad, 2026-10-10): double-tap zoom is off everywhere; inner scroll areas still pan. */
html { touch-action: pan-x pan-y; }
/* Instruction or information (the dad, 2026-10-11: they looked the same and were easy to overlook; nothing showed
   when he had to do something). common/toybox.js sorts every coach line into is-do or is-info.
   Instruction: dark pill, white bold text, a yellow tapping finger, a gentle pulse while it waits for him.
   Information: small, plain, quiet. */
.tb-coach.is-do { background: #1D2340; color: #FFFFFF; border-color: #1D2340; font-weight: 800;
  padding-left: 2.4em; box-shadow: 0 0 0 4px rgba(255, 210, 63, 0.55), var(--tb-card);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9 11V5.5a1.5 1.5 0 0 1 3 0V10m0-1.5a1.5 1.5 0 0 1 3 0V11m0-1a1.5 1.5 0 0 1 3 0v4.5c0 3.3-2.2 6.5-5.8 6.5h-.7c-2 0-3.4-.8-4.6-2.4L4.6 14.8a1.6 1.6 0 0 1 2.4-2l2 2' fill='%23FFD23F' stroke='%23FFD23F' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-size: 1.35em 1.35em; background-position: 0.65em 50%;
  animation: tb-do-pulse 2.6s ease-in-out infinite; }
.tb-coach.is-do.is-new { animation: tb-coach-pop 0.35s cubic-bezier(.3, 1.6, .5, 1), tb-do-pulse 2.6s ease-in-out 0.35s infinite; }
.tb-coach.is-do .tb-coach-dot { display: none; }
@keyframes tb-do-pulse {
  0%, 70%, 100% { box-shadow: 0 0 0 4px rgba(255, 210, 63, 0.55), var(--tb-card); }
  85% { box-shadow: 0 0 0 10px rgba(255, 210, 63, 0.25), var(--tb-card); }
}
.tb-coach.is-info { background: rgba(255, 255, 255, 0.92); color: #3A4060; border-width: 1.5px; border-color: rgba(29, 35, 64, 0.35);
  font-weight: 700; font-size: 1.25rem; padding: 0.15rem 0.85rem; box-shadow: none; }
@media (max-width: 600px), (orientation: landscape) and (max-height: 520px) { .tb-coach.is-info { font-size: 1.05rem; } }
.tb-v2 .tb-coach.is-info { font-size: calc(var(--tb-fs-coach) * 0.8); }
/* A new instruction pops up in the middle of the stage (the dad, 2026-10-15: at the bottom, and at the top before
   that, he didn't see them; "just put it in the middle"). It is not persistent (the dad, 2026-11-15: they "never
   ever leave and take up a ton of space"): after his first touch (at least 2 s after it appeared) or 8 s, it fades
   away where it is (is-seen), and comes back with the idle ghost hand; the next new instruction pops up again
   (common/toybox.js). Information lines stay quiet at the bottom. Taps pass through. */
/* --tb-coach-top is set by coach.avoid() when the middle would cover the part the instruction names. */
.tb-coach.is-do:not(.is-seen) { top: var(--tb-coach-top, 50%); bottom: auto; transform: translate(-50%, -50%); }
.tb-coach.is-do.is-new:not(.is-seen) { animation: tb-coach-pop-mid 0.35s cubic-bezier(.3, 1.6, .5, 1), tb-do-pulse 2.6s ease-in-out 0.35s infinite; }
@keyframes tb-coach-pop-mid { from { transform: translate(-50%, -50%) scale(0.85); } to { transform: translate(-50%, -50%) scale(1); } }
.tb-coach.is-do.is-seen { top: var(--tb-coach-top, 50%); bottom: auto; transform: translate(-50%, -50%); animation: none;
  opacity: 0; visibility: hidden; transition: opacity 0.4s ease, visibility 0s linear 0.4s; }
/* After the rules above, so it outranks the pop and the pulse of a new instruction. */
@media (prefers-reduced-motion: reduce) { .tb-coach.is-do, .tb-coach.is-do.is-new:not(.is-seen) { animation: none; } }
