:root {
  --bg-top: #fffdf5;
  --bg-mid: #e8f6ec;
  --bg-bot: #cfe9d8;
  --ink: #2d2a26;
  --btn-a: #ff6b6b;
  --btn-b: #ff9f43;
  --bubble: #fffef9;
  --shadow: rgba(40, 60, 40, 0.18);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
}

html {
  min-height: 100%;
  background: var(--bg-bot); /* solid fallback in the gradient's end colour, so no seam can show through */
}

body {
  min-height: 100vh;
  min-height: 100dvh; /* fill the visible screen on mobile (accounts for the dynamic toolbar) */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  font-family: "Trebuchet MS", "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  /* One continuous wash — cream at the top fading to mint — whose end stop sits at
     115% (below the bottom edge), so it keeps transitioning all the way down with no
     flat band / hard cut-off line on screen. */
  background: radial-gradient(150% 115% at 50% 0%, var(--bg-top), var(--bg-mid) 50%, var(--bg-bot) 100%) no-repeat;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-font-smoothing: antialiased;
}

/* ---------- accessibility ---------- */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------- footer ---------- */
.site-foot {
  padding: 12px 16px 18px;
  font-size: 13px;
  color: #566459;
  text-align: center;
}

/* ---------- stage ---------- */
.stage {
  position: relative;
  flex: 1;
  width: 100%;
  max-width: 760px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 8px 16px;
}

.bug-wrap {
  height: min(62vmin, 400px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.bug {
  filter: drop-shadow(0 12px 14px var(--shadow));
  animation: floaty 3.6s ease-in-out infinite;
  transform-origin: center;
}

.bug svg {
  width: min(60vmin, 380px);
  height: auto;
  display: block;
  overflow: visible;
}

/* Placeholder shown while a lazily-loaded character module is fetched. */
.bug-skeleton {
  width: min(60vmin, 380px);
  aspect-ratio: 1 / 1;
  border-radius: 26px;
  background:
    linear-gradient(110deg, rgba(255, 255, 255, 0.15) 28%,
      rgba(255, 255, 255, 0.55) 50%, rgba(255, 255, 255, 0.15) 72%),
    rgba(255, 255, 255, 0.18);
  background-size: 220% 100%, 100% 100%;
  animation: skeleton-shimmer 1.2s ease-in-out infinite;
}

@keyframes skeleton-shimmer {
  0%   { background-position: 120% 0, 0 0; }
  100% { background-position: -120% 0, 0 0; }
}

@keyframes floaty {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-9px); }
}

.bug-name {
  margin: 0;
  min-height: 1.4em;
  font-size: clamp(18px, 3.4vw, 24px);
  font-weight: 700;
  color: #2f6d3a;
  letter-spacing: 0.3px;
}

/* ---------- button ---------- */
.do-btn {
  appearance: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-weight: 800;
  font-size: clamp(18px, 3.6vw, 26px);
  color: #3a1500;
  padding: 16px 34px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--btn-a), var(--btn-b));
  box-shadow: 0 8px 0 #d35400, 0 12px 22px rgba(211, 84, 0, 0.35);
  transform: translateY(0);
  transition: transform 0.08s ease, box-shadow 0.08s ease, filter 0.15s ease;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.3);
}

.do-btn:hover { filter: brightness(1.05); }

.do-btn:active {
  transform: translateY(6px);
  box-shadow: 0 2px 0 #d35400, 0 4px 10px rgba(211, 84, 0, 0.35);
}

.do-btn:disabled {
  cursor: default;
  filter: grayscale(0.35) brightness(0.95);
  opacity: 0.8;
  transform: translateY(2px);
  box-shadow: 0 6px 0 #b0b0b0, 0 8px 16px rgba(0, 0, 0, 0.18);
}

.do-btn:focus-visible {
  outline: 3px solid #2f6d3a;
  outline-offset: 3px;
}

/* Idle "tap me" hint — after a few idle seconds the button presses itself in a
   loop (mimicking a tap) so kids/first-timers know to tap it. Cleared on tap. */
@keyframes do-hint-press {
  0%, 62%, 100% { transform: translateY(0); box-shadow: 0 8px 0 #d35400, 0 12px 22px rgba(211, 84, 0, 0.35); }
  10%, 24%      { transform: translateY(6px); box-shadow: 0 2px 0 #d35400, 0 4px 10px rgba(211, 84, 0, 0.35); }
}
.do-btn.hint { animation: do-hint-press 1.6s ease-in-out infinite; }

/* ---------- speech bubble fact ---------- */
.fact {
  margin: 0;
  max-width: 520px;
  min-height: 1.2em;
  text-align: center;
  font-size: clamp(15px, 2.6vw, 18px);
  font-weight: 600;
  line-height: 1.35;
  color: var(--ink);
  background: var(--bubble);
  border-radius: 16px;
  padding: 0 14px;
  opacity: 0;
  transform: translateY(8px) scale(0.96);
  transition: opacity 0.25s ease, transform 0.25s ease, padding 0.25s ease;
  box-shadow: 0 6px 16px var(--shadow);
  pointer-events: none;
}

.fact.show {
  opacity: 1;
  transform: translateY(0) scale(1);
  padding: 12px 18px;
}

/* ---------- poof particles ---------- */
.poof-particle {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  will-change: transform, opacity;
  z-index: 5;
}

/* ---------- shared transform-origin helpers for animated SVG parts ----------
   Per-part origins now live INLINE in each module's SVG (co-located with the art,
   via `style="transform-box:…;transform-origin:…"`). What remains here are the
   genuinely SHARED helpers reused across many characters — keep new reusable
   helpers here, but put a one-off part's origin inline in its own module. */

/* Rotate / scale around the part's OWN center (wheels, props, pulses, bills). */
.bug svg .spin,
.bug svg .sea-pulse,
.bug svg .duck-bill,
.bug svg .llama-spit,
.bug svg .mt-wheel,
.bug svg .daddy-bicep,
.bug svg .icon-wrench,
.bug svg .icon-toy { transform-box: fill-box; transform-origin: center; }

/* Pivot at the TOP of the part's own box (limbs/flames swinging from a hinge). */
.bug svg .leg-pivot,
.bug svg .jp-flame,
.bug svg .tr-arm,
.bug svg .tf-arm-l, .bug svg .tf-arm-r,
.bug svg .tf-leg-l, .bug svg .tf-leg-r { transform-box: fill-box; transform-origin: center top; }

/* Shared view-box origins (same pivot reused by more than one module). */
.bug svg .farm-head  { transform-box: view-box; transform-origin: 120px 135px; } /* 12 farm animals */
.bug svg .dr-all     { transform-box: view-box; transform-origin: 120px 122px; } /* dragonfly + drone */

/* ---------- top-right action stack (share, safety, coffee) ---------- */
.top-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  padding-top: 12px;
}
.top-row { display: flex; gap: 10px; justify-content: center; }
.safety-btn {
  display: inline-block;
  font-family: inherit;
  font-weight: 700;
  font-size: 14px;
  color: #2f6d3a;
  text-decoration: none;
  background: rgba(255, 255, 255, 0.85);
  border-radius: 999px;
  padding: 8px 15px;
  box-shadow: 0 3px 10px var(--shadow);
  transition: transform 0.08s ease, background 0.15s ease;
}
.safety-btn:hover { background: #ffffff; }
.safety-btn:active { transform: translateY(1px); }
.safety-btn:focus-visible { outline: 3px solid #2f6d3a; outline-offset: 2px; }

/* ---------- share button ---------- */
.share-btn {
  appearance: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-weight: 700;
  font-size: 14px;
  color: #2f6d3a;
  background: rgba(255, 255, 255, 0.85);
  border-radius: 999px;
  padding: 8px 15px;
  box-shadow: 0 3px 10px var(--shadow);
  transition: transform 0.08s ease, background 0.15s ease;
}
.share-btn:hover { background: #ffffff; }
.share-btn:active { transform: translateY(1px); }
.share-btn:focus-visible { outline: 3px solid #2f6d3a; outline-offset: 2px; }

/* ---------- buy-a-coffee support ---------- */
.site-foot .foot-line { display: block; }
/* Website-only "get the app" badges (data-web-only; stripped in the app build). */
.app-cta { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; margin-top: 12px; }
.app-cta-label { font-weight: 700; font-size: .88rem; color: #6a5a52; }
.app-badge { display: inline-block; }
.app-badge > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; background: #2a2a2e; color: #fff; font-weight: 700; font-size: .88rem; padding: 8px 16px; border-radius: 10px; transition: background .15s; }
.app-badge > summary::-webkit-details-marker { display: none; }
.app-badge > summary::marker { content: ""; }
.app-badge > summary:hover, .app-badge[open] > summary { background: #3a3a40; }
.app-soon { display: inline-block; margin: 6px 0 0; font-weight: 700; font-size: .85rem; color: #b4480e; }
.coffee-wrap { position: relative; }
.coffee {
  display: inline-block;
  cursor: pointer;
  list-style: none;
  user-select: none;
  font-size: 14px;
  font-weight: 800;
  color: #6b4423;
  background: #f4e3c8;
  padding: 8px 18px;
  border-radius: 999px;
  box-shadow: 0 3px 8px var(--shadow);
  transition: background 0.15s ease, transform 0.08s ease;
}
.coffee::-webkit-details-marker { display: none; }
.coffee::marker { content: ""; }
.coffee:hover,
.coffee-wrap[open] .coffee { background: #ead2a8; }
.coffee:active { transform: translateY(1px); }
.coffee:focus-visible { outline: 3px solid #6b4423; outline-offset: 2px; }

.coffee-choices { position: absolute; left: 50%; transform: translateX(-50%); top: calc(100% + 11px); display: flex; gap: 12px; justify-content: center; z-index: 21; }
.coffee-wrap:not([open]) .coffee-choices { display: none; } /* absolutely positioned so opening doesn't reflow/clip the page; also re-hidden here because an author display on a <details> child overrides its native hide in Chromium */
.pay {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 112px;
  font-size: 15.5px;
  font-weight: 800;
  letter-spacing: 0.2px;
  color: #fff;
  text-decoration: none;
  padding: 12px 26px;
  border-radius: 999px;
  box-shadow: 0 4px 11px rgba(40, 60, 40, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  transition: transform 0.1s ease, box-shadow 0.15s ease, filter 0.15s ease;
}
.pay:hover { transform: translateY(-1.5px); filter: brightness(1.05); box-shadow: 0 8px 17px rgba(40, 60, 40, 0.26), inset 0 1px 0 rgba(255, 255, 255, 0.35); }
.pay:active { transform: translateY(1px); box-shadow: 0 2px 6px rgba(40, 60, 40, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.25); }
.pay:focus-visible { outline: 3px solid #2f6d3a; outline-offset: 3px; }
.pay-venmo { background: linear-gradient(180deg, #1f74cf, #0a4f96); }
.pay-paypal { background: linear-gradient(180deg, #0b6fae, #0a2a6e); }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  top: 33%;
  transform: translateX(-50%) translateY(-10px);
  background: #2d2a26;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 30;
  max-width: 80vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- legal / privacy page ---------- */
body.legal-page { overflow: auto; display: block; height: auto; background: #f4f8f1; }
.legal {
  max-width: 680px;
  margin: 0 auto;
  padding: 40px 22px 64px;
  text-align: left;
  line-height: 1.55;
  font-size: 16px;
}
.legal h1 { color: #2f6d3a; margin: 8px 0 2px; font-size: 28px; }
.legal h2 { color: #b4480e; font-size: 19px; margin: 26px 0 6px; }
.legal a { color: #b4480e; }
.legal-updated { color: #6b7a6e; font-size: 14px; margin: 0 0 18px; }
.legal-back { display: inline-block; font-weight: 700; text-decoration: none; margin-bottom: 8px; }

/* App-only: hide web monetization, reveal the store entry. */
body.app-mode .coffee-wrap { display: none !important; }

.more-btn {
  appearance: none; border: none; cursor: pointer; font-family: inherit;
  font-weight: 800; font-size: 14px; color: #6b4423; background: #f4e3c8;
  padding: 8px 18px; border-radius: 999px; box-shadow: 0 3px 8px var(--shadow);
}
.more-btn:active { transform: translateY(1px); }
body.app-mode .more-btn[hidden] { display: inline-block; } /* shown in app mode */

.gate-overlay, .store-overlay {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: center;
  justify-content: center; background: rgba(20, 30, 20, 0.5); padding: 20px;
}
.gate-card, .store-card {
  background: var(--bubble); border-radius: 18px; padding: 22px; max-width: 340px;
  width: 100%; text-align: center; box-shadow: 0 12px 40px var(--shadow);
}
.gate-input { font-size: 20px; padding: 8px 12px; width: 96px; text-align: center; border: 2px solid #cbb68e; border-radius: 10px; margin: 8px 0; }
.gate-row, .store-card { display: flex; flex-direction: column; gap: 10px; }
.gate-row { flex-direction: row; justify-content: center; }
.store-buy { display: flex; flex-direction: column; gap: 2px; text-align: center; font-weight: 800; color: #fff; background: linear-gradient(135deg, var(--btn-a), var(--btn-b)); border: none; border-radius: 18px; padding: 12px 18px; font-size: 16px; cursor: pointer; }
.store-buy-title { font-size: 16px; }
.store-buy-blurb { font-size: 12px; font-weight: 600; opacity: .92; }
.store-restore, .store-close, .gate-cancel, .gate-ok { border: none; background: #efe6d4; border-radius: 999px; padding: 10px 16px; font-weight: 700; cursor: pointer; }
.store-msg { min-height: 1.2em; font-size: 13px; color: #4d5a4e; }
.shake { animation: shake 0.3s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
@media (prefers-reduced-motion: reduce) { .shake { animation: none; } }

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .bug { animation: none; }
  .bug-skeleton { animation: none; }
  .do-btn { transition: none; }
  .do-btn.hint { animation: none; }
}

/* ---------- mode picker (mode-build) ---------- */
.mode-picker { display: flex; flex-direction: column; align-items: center; gap: 6px; margin: 4px 0 2px; }
.mode-seg { display: inline-flex; flex-wrap: wrap; justify-content: center; background: #fff; border-radius: 999px; padding: 3px; box-shadow: 0 2px 8px rgba(0, 0, 0, .08); }
.mode-seg-btn { border: 0; background: transparent; padding: 7px 15px; border-radius: 999px; font: inherit; font-weight: 700; color: #6a5a52; cursor: pointer; }
.mode-seg-btn.is-active { background: linear-gradient(135deg, #ffb24d, #ff7a59); color: #3a1500; }
.mode-seg-btn.is-coming-soon { opacity: .5; cursor: default; }
.mode-badge { font-size: .6rem; font-weight: 800; text-transform: uppercase; letter-spacing: .03em; background: #d9cfc0; color: #5a4a3a; border-radius: 999px; padding: 1px 6px; margin-left: 3px; vertical-align: middle; }
.mode-toggles { display: inline-flex; flex-wrap: wrap; justify-content: center; gap: 6px 16px; }
.mode-guided, .mode-flashcard { font-size: .85rem; color: #6a5a52; display: inline-flex; align-items: center; gap: 5px; }
.mode-guided[hidden], .mode-flashcard[hidden] { display: none; }

/* Calm / Low-Stim chrome: muted palette + no sparkle. Toggled on <body> by main.js. */
body.low-stim {
  --bg-top: #f3f4f2; --bg-mid: #e7ebe8; --bg-bot: #dde2de;
  --btn-a: #9bb3a4; --btn-b: #b6cabd; --bubble: #f5f6f4;
}
body.low-stim .bug { filter: saturate(0.7); }
body.low-stim .poof-particle { display: none; } /* backstop; poof() already skips them */
body.low-stim .do-btn.hint { animation: none; }
body.low-stim .mode-seg-btn.is-active { background: linear-gradient(135deg, #9bb3a4, #b6cabd); color: #243029; }

/* App compliance backstop: web-only payment/funnel chrome must never show in the
   app (main.js also removes [data-web-only] from the DOM when isApp). */
body.app-mode [data-web-only] { display: none !important; }

/* ---------- Speech target-word picker (mode-build) ---------- */
.target-btn { border: 0; border-radius: 999px; padding: 8px 16px; font: inherit; font-weight: 700; color: #3a2a26; background: rgba(255, 255, 255, 0.85); box-shadow: 0 2px 8px rgba(0, 0, 0, .08); cursor: pointer; }
.target-btn[hidden] { display: none; }
.target-overlay { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; background: rgba(20, 30, 20, 0.5); padding: 18px; }
.target-card { background: var(--bubble); border-radius: 18px; width: 100%; max-width: 460px; max-height: 86vh; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 12px 40px rgba(0, 0, 0, .3); }
.target-head { padding: 16px 18px 8px; }
.target-head h2 { margin: 0; font-size: 1.15rem; }
.target-count { margin: 4px 0 0; font-size: .85rem; color: #6a5a52; }
.target-list { overflow-y: auto; padding: 4px 10px; flex: 1; }
.target-cat { border-bottom: 1px solid rgba(0, 0, 0, .07); }
.target-cat summary { display: flex; justify-content: space-between; align-items: center; padding: 10px 8px; font-weight: 700; cursor: pointer; list-style: none; }
.target-cat summary::-webkit-details-marker { display: none; }
.target-cat-meta { font-size: .8rem; font-weight: 700; color: #b4480e; }
.target-cat-words { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 8px 12px; }
.target-all { border: 0; background: #efe7da; border-radius: 999px; padding: 6px 12px; font: inherit; font-size: .8rem; font-weight: 700; color: #6a4423; cursor: pointer; }
.target-chip { border: 1.5px solid #e2d6c4; background: #fff; border-radius: 999px; padding: 6px 12px; font: inherit; font-size: .85rem; font-weight: 600; color: #6a5a52; cursor: pointer; }
.target-chip.on { background: linear-gradient(135deg, #ffb24d, #ff7a59); border-color: transparent; color: #3a1500; }
.target-foot { display: flex; justify-content: space-between; gap: 10px; padding: 12px 16px; border-top: 1px solid rgba(0, 0, 0, .08); }
.target-clear { border: 0; background: transparent; font: inherit; font-weight: 700; color: #6a5a52; cursor: pointer; }
.target-done { border: 0; border-radius: 999px; padding: 10px 24px; font: inherit; font-weight: 800; color: #3a1500; background: linear-gradient(135deg, #ffb24d, #ff7a59); cursor: pointer; }

/* ---------- Card layout / Flashcard View (mode-build) ---------- */
.card-stage { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 16px; }
.card-stage[hidden] { display: none; }
.flashcard { background: #fff; border-radius: 22px; box-shadow: 0 10px 30px rgba(0, 0, 0, .12); padding: 18px 18px 10px; display: flex; flex-direction: column; align-items: center; gap: 6px; max-width: 320px; width: 86vw; }
.flashcard-art { width: 240px; height: 240px; max-width: 70vw; max-height: 70vw; }
.flashcard-art svg { width: 100%; height: 100%; }
.flashcard-word { margin: 4px 0 8px; font-size: clamp(1.6rem, 7vw, 2.4rem); font-weight: 800; color: #3a2a26; text-align: center; line-height: 1.1; }
.card-next { border: 0; border-radius: 999px; padding: 14px 34px; font: inherit; font-size: 1.1rem; font-weight: 800; color: #3a1500; background: linear-gradient(135deg, #ffb24d, #ff7a59); box-shadow: 0 6px 18px rgba(255, 122, 89, .35); cursor: pointer; }

/* ---------- Paged layout / Story (mode-build) ---------- */
.paged-stage { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 16px; }
.paged-stage[hidden] { display: none; }
.storybook { background: #fffdf6; border-radius: 20px; box-shadow: 0 10px 30px rgba(0, 0, 0, .12); border: 1px solid #f0e6d2; padding: 18px; display: flex; flex-direction: column; align-items: center; gap: 10px; max-width: 360px; width: 88vw; }
.story-art { width: 200px; height: 200px; max-width: 60vw; max-height: 60vw; }
.story-art svg { width: 100%; height: 100%; }
.story-text { margin: 4px 8px 8px; font-size: clamp(1.2rem, 5vw, 1.6rem); font-weight: 700; color: #3a2a26; text-align: center; line-height: 1.3; min-height: 2.6em; }
.story-turn { border: 0; border-radius: 999px; padding: 13px 30px; font: inherit; font-size: 1.05rem; font-weight: 800; color: #3a1500; background: linear-gradient(135deg, #ffb24d, #ff7a59); box-shadow: 0 6px 18px rgba(255, 122, 89, .35); cursor: pointer; }
.story-turn:disabled { opacity: .5; cursor: default; }

/* ---------- Grouped layout / Teacher circle-time (mode-build) — big & projectable ---------- */
.grouped-stage { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; padding: 16px; }
.grouped-stage[hidden] { display: none; }
.circle { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.circle-art { width: 340px; height: 340px; max-width: 82vw; max-height: 82vw; }
.circle-art svg { width: 100%; height: 100%; }
.circle-text { margin: 0; font-size: clamp(1.8rem, 8vw, 3rem); font-weight: 800; color: #3a2a26; text-align: center; line-height: 1.15; min-height: 1.3em; }
.circle-next { border: 0; border-radius: 999px; padding: 18px 50px; font: inherit; font-size: 1.3rem; font-weight: 800; color: #3a1500; background: linear-gradient(135deg, #ffb24d, #ff7a59); box-shadow: 0 6px 18px rgba(255, 122, 89, .35); cursor: pointer; }
.circle-next:disabled { opacity: .5; cursor: default; }

/* ---------- Category picker (Teacher theme) (mode-build) ---------- */
.cat-overlay { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; background: rgba(20, 30, 20, 0.5); padding: 18px; }
.cat-card { background: var(--bubble); border-radius: 18px; width: 100%; max-width: 420px; max-height: 86vh; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 12px 40px rgba(0, 0, 0, .3); }
.cat-card h2 { margin: 0; padding: 16px 18px 8px; font-size: 1.15rem; }
.cat-list { overflow-y: auto; padding: 4px 10px; flex: 1; display: flex; flex-direction: column; gap: 4px; }
.cat-item { text-align: left; border: 1.5px solid #e2d6c4; background: #fff; border-radius: 12px; padding: 10px 12px; font: inherit; font-weight: 700; color: #6a5a52; cursor: pointer; }
.cat-item.on { background: linear-gradient(135deg, #ffb24d, #ff7a59); border-color: transparent; color: #3a1500; }
.cat-close { margin: 10px 16px; align-self: flex-end; border: 0; border-radius: 999px; padding: 10px 24px; font: inherit; font-weight: 800; color: #3a1500; background: linear-gradient(135deg, #ffb24d, #ff7a59); cursor: pointer; }

/* ---------- Clinic layout / Therapist (mode-build) ---------- */
.clinic-stage { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 12px; overflow-y: auto; }
.clinic-stage[hidden] { display: none; }
.clinic { width: 100%; max-width: 420px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.clinic-top { width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.clinic-targets, .clinic-homework { border: 0; background: rgba(255, 255, 255, .85); border-radius: 999px; padding: 7px 12px; font: inherit; font-weight: 700; font-size: .85rem; color: #3a2a26; box-shadow: 0 2px 8px rgba(0, 0, 0, .08); cursor: pointer; }
.clinic-trial { font-size: .8rem; font-weight: 700; color: #6a5a52; }
.clinic-art { width: 180px; height: 180px; }
.clinic-art svg { width: 100%; height: 100%; }
.clinic-word { margin: 0; font-size: clamp(1.6rem, 7vw, 2.2rem); font-weight: 800; color: #3a2a26; text-align: center; }
.clinic-model { border: 0; border-radius: 999px; padding: 10px 22px; font: inherit; font-weight: 800; color: #3a1500; background: linear-gradient(135deg, #ffb24d, #ff7a59); cursor: pointer; }
.clinic-score { display: flex; gap: 8px; }
.score-btn { border: 0; border-radius: 12px; padding: 12px 14px; font: inherit; font-weight: 800; cursor: pointer; }
.score-correct { background: #cdeccd; color: #14600f; }
.score-approx { background: #fdebc4; color: #7a5400; }
.score-incorrect { background: #f6cccc; color: #7a1414; }
.clinic-tally { font-size: .95rem; font-weight: 700; color: #3a2a26; min-height: 1.2em; }
.clinic-next { border: 0; border-radius: 999px; padding: 10px 24px; font: inherit; font-weight: 800; color: #6a5a52; background: rgba(255, 255, 255, .85); box-shadow: 0 2px 8px rgba(0, 0, 0, .08); cursor: pointer; }
.clinic-guard { font-size: .72rem; color: #8a7a72; text-align: center; max-width: 38ch; margin: 4px 0; }

/* ---------- Therapist password gate (mode-build) ---------- */
.pw-overlay { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; background: rgba(20, 30, 20, .5); padding: 20px; }
.pw-card { background: var(--bubble); border-radius: 18px; padding: 22px; max-width: 320px; width: 100%; box-shadow: 0 12px 40px rgba(0, 0, 0, .3); }
.pw-q { margin: 0 0 12px; font-weight: 700; }
.pw-input { width: 100%; box-sizing: border-box; padding: 10px; border: 1.5px solid #e2d6c4; border-radius: 10px; font: inherit; }
.pw-row { display: flex; justify-content: flex-end; gap: 10px; margin-top: 12px; }
.pw-cancel { border: 0; background: transparent; font: inherit; font-weight: 700; color: #6a5a52; cursor: pointer; }
.pw-ok { border: 0; border-radius: 999px; padding: 10px 22px; font: inherit; font-weight: 800; color: #3a1500; background: linear-gradient(135deg, #ffb24d, #ff7a59); cursor: pointer; }
.pw-msg { color: #b4480e; font-size: .85rem; margin: 8px 0 0; min-height: 1em; }

/* ---------- Therapist homework sheet (mode-build) ---------- */
.hw-overlay { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; background: rgba(20, 30, 20, .5); padding: 18px; }
.hw-card { background: #fff; border-radius: 16px; max-width: 460px; width: 100%; max-height: 86vh; overflow-y: auto; box-shadow: 0 12px 40px rgba(0, 0, 0, .3); }
.hw-sheet { padding: 20px; }
.hw-sheet h2 { margin: 0 0 6px; }
.hw-sub { color: #6a5a52; font-size: .9rem; margin: 0 0 12px; }
.hw-table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.hw-table th, .hw-table td { border-bottom: 1px solid #eee; padding: 6px 8px; text-align: center; }
.hw-table th:first-child, .hw-table td:first-child { text-align: left; }
.hw-note { font-size: .72rem; color: #8a7a72; margin: 14px 0 0; }
.hw-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 12px 18px; border-top: 1px solid #eee; }
.hw-clear { border: 0; background: transparent; font: inherit; font-weight: 700; color: #b4480e; cursor: pointer; }
.hw-print, .hw-close { border: 0; border-radius: 999px; padding: 10px 20px; font: inherit; font-weight: 800; cursor: pointer; }
.hw-print { color: #3a1500; background: linear-gradient(135deg, #ffb24d, #ff7a59); }
.hw-close { color: #6a5a52; background: #efe7da; }
@media print { body > *:not(.hw-overlay) { display: none !important; } .hw-overlay { position: static; background: none; padding: 0; } .hw-card { box-shadow: none; max-height: none; } .hw-actions { display: none; } }

/* === Options lock (APP-ONLY): the gear + the grown-up sheet ================= */
/* The gear sits in the top-right corner of the kid screen — reachable by a parent,
   easy for a kid to ignore. Safe-area insets keep it clear of a phone notch. */
.options-gear {
  position: fixed;
  top: max(8px, env(safe-area-inset-top));
  right: max(10px, env(safe-area-inset-right));
  z-index: 6;
  width: 42px; height: 42px;
  border: 0; border-radius: 999px;
  background: rgba(255, 255, 255, .45);
  font-size: 20px; line-height: 1;
  cursor: pointer; opacity: .6;
}
.options-gear:active { transform: translateY(1px); }
.options-gear:focus-visible { outline: 3px solid #2f6d3a; outline-offset: 2px; }

/* Sheet overlay + card mirror .pw-overlay / .store-overlay. */
.options-overlay {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  background: rgba(20, 30, 20, .5); padding: 20px;
}
.options-overlay[hidden] { display: none; } /* author display:flex overrides the [hidden] attr in Chromium, so re-hide explicitly */
.options-card {
  background: var(--bubble);
  border-radius: 18px; padding: 18px;
  max-width: 360px; width: 100%; max-height: 86vh; overflow: auto;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .3);
  display: flex; flex-direction: column; gap: 14px;
}
.options-head { display: flex; align-items: center; justify-content: space-between; }
.options-title { font-weight: 800; color: #3a1500; }
.options-close { border: 0; background: transparent; font-size: 18px; cursor: pointer; padding: 4px 8px; color: #3a1500; }
.options-body { display: flex; flex-direction: column; align-items: center; gap: 12px; }
