/* ============================================================
   Word Workshop — chrome, palettes and game styles for the
   four Toolshed word games (Word Match, Story Time, Sentence
   Sense, Word Builder). Shares the 11 palettes with the Work
   Cycle Timer and the Toolshed site: keep the html[data-theme]
   blocks in sync with site.css (SwankyMcGee.github.io) and
   styles.css (work-cycle-timer). --accent2 is the palette's
   second accent (THEMES chips[4]) and marks "the other group"
   in two-group visuals.
   ============================================================ */

/* ---------- Bundled display font ----------
   Fredoka (variable 300–700, SIL Open Font License) — a friendly
   rounded face for headings, the big words and choice buttons.
   The woff2 lives in fonts/ so every page stays fully offline.
   Body copy keeps the system stack for legibility. */
@font-face {
  font-family: 'Fredoka';
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url('fonts/fredoka-latin.woff2') format('woff2');
}

:root {
  --font-display: 'Fredoka', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --bg: #f2f6f8;
  --surface: #ffffff;
  --surface-2: #e9eff3;
  --text: #33414d;
  --dim: #6b7c8a;
  --border: #d5dfe6;
  --accent: #4d84a6;
  --accent2: #628f5d;
  --hold-bg: #fdf3dd;
  --hold-text: #7a5c1e;
  --hold-border: #eeddb3;
}

* { box-sizing: border-box; }

/* Author display beats the UA's [hidden] — the lesson from the site:
   any element we give display:flex needs this guard. */
[hidden] { display: none !important; }

html { font-size: 16px; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  transition: background-color .35s ease, color .35s ease;   /* gentle palette switch */
}

a { color: var(--accent); }

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Header / nav ---------- */

.site-head {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: .7rem 1.2rem;
  display: flex;
  flex-wrap: wrap;
  gap: .4rem 1rem;
  align-items: center;
  transition: box-shadow .2s ease;
}

/* Lifted off the page once content scrolls beneath it. */
.site-head.scrolled { box-shadow: 0 2px 14px rgba(0, 0, 0, .09); }

.brand {
  font-weight: 700;
  text-decoration: none;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  font-family: var(--font-display);
  font-size: 1.06rem;
  letter-spacing: -.01em;
}

.brand .brand-sub { font-weight: 500; color: var(--dim); font-size: .88rem; letter-spacing: 0; }

.brand-mark { display: inline-flex; }
.brand-mark svg { display: block; width: 26px; height: 26px; }

.site-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .25rem .35rem;
  font-size: .92rem;
}

.site-nav a { text-decoration: none; color: var(--dim); border-radius: 999px; padding: .22rem .7rem; }
.site-nav a:hover { color: var(--accent); background: var(--surface-2); }
.site-nav a[aria-current="page"] { color: var(--text); font-weight: 700; background: var(--surface-2); }
.site-nav a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.head-tools {
  margin-left: auto;
  display: flex;
  gap: .5rem;
  align-items: center;
}

/* The standard Toolshed control cluster (Chime · Fullscreen ·
   Settings · Home) — right-aligned, wraps before anything collides. */
.header-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: .5rem;
}

main {
  max-width: 60rem;
  margin: 0 auto;
  padding: 1.2rem 1.2rem 2.5rem;
}

h1, h2, h3 { font-family: var(--font-display); font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: clamp(1.9rem, 4vw, 2.3rem); font-weight: 700; margin: .6rem 0 .4rem; }
h2 { font-size: 1.3rem; margin: 1.4rem 0 .5rem; }
p { margin: .45rem 0; }

/* Section headings ("Pick a game") get a hairline rule that runs
   to the edge of the column. */
.section-h { display: flex; align-items: center; gap: .8rem; }
.section-h::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ---------- Footer (shared Toolshed scene + rotating wisdom) ---------- */

.site-foot {
  max-width: 62rem;
  margin: 0 auto;
  padding: 0 1.2rem 1.4rem;
  color: var(--dim);
  font-size: .85rem;
  border-top: 1px solid var(--border);
  text-align: center;
}

.foot-scene {
  position: relative;
  display: block;
  width: min(100%, 1080px);
  aspect-ratio: 1100 / 160;
  margin: 0 auto;
  padding-top: .4rem;
  /* One generated panorama per palette, painted from --foot-img so it
     tracks the theme switch. The twinkles stay inline SVG on top. */
  background: var(--foot-img) center / cover no-repeat;
}
.foot-scene svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.foot-phrase { margin: .3rem 0 0; font-size: .95rem; font-weight: 700; color: var(--text); }
.foot-phrase a { color: var(--accent); }
.foot-wisdom {
  margin: .35rem 0 0;
  min-height: 1.4em;
  font-style: italic;
  color: var(--dim);
  transition: opacity .6s ease;
}
.foot-wisdom.fading { opacity: 0; }
.foot-meta { margin: .55rem 0 0; font-size: .8rem; }

/* Scene life — slow sways, switched off under reduced motion. */
.foot-scene .sway { transform-box: fill-box; transform-origin: 50% 0%; }
.foot-scene .nod { transform-box: fill-box; transform-origin: 50% 100%; }
@media (prefers-reduced-motion: no-preference) {
  .foot-scene .sway { animation: toolSway 6s ease-in-out infinite alternate; }
  .foot-scene .nod { animation: sproutNod 7s ease-in-out infinite alternate; }
  .foot-scene .glow { animation: twinkle 4.5s ease-in-out infinite alternate; }
}
@keyframes toolSway { from { transform: rotate(-1.6deg); } to { transform: rotate(1.6deg); } }
@keyframes sproutNod { from { transform: rotate(-2deg); } to { transform: rotate(2deg); } }
@keyframes twinkle { from { opacity: .3; } to { opacity: .85; } }
@media (prefers-reduced-motion: reduce) {
  .foot-wisdom { transition: none; }
}

/* ---------- Hold-to-activate (kid-safe buttons) ----------
   Each holdable button sets --hold-dur (1s home/skip, 3s gear);
   the .holding class runs the fill for that long. */

.hold-btn {
  --hold-dur: 1s;
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font: inherit;
  font-size: .92rem;
  font-weight: 600;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: .34rem .8rem;
  min-height: 40px;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  overflow: hidden;
}

.hold-btn:hover { border-color: var(--accent); }
.hold-btn.holding { border-color: var(--accent); color: var(--accent); }
.hold-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.hold-btn .hold-emoji { font-size: 1.05rem; }
.hold-icon { display: inline-flex; align-items: center; }
.hold-icon svg { display: block; }

.hold-track {
  position: absolute;
  left: 7px;
  right: 7px;
  bottom: 4px;
  height: 4px;
  border-radius: 2px;
  background: var(--surface);
  overflow: hidden;
}

.hold-fill {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
}

.holding .hold-fill {
  animation: holdFill var(--hold-dur, 1s) linear forwards;
}

@keyframes holdFill {
  from { width: 0; }
  to   { width: 100%; }
}

/* ---------- Header palette picker (word.js injects this) ---------- */

.theme-wrap {
  position: relative;
}

.theme-btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font: inherit;
  font-size: .92rem;
  font-weight: 600;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: .34rem .8rem;
  min-height: 40px;
  cursor: pointer;
}

.theme-btn:hover { border-color: var(--accent); }

.theme-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.theme-panel {
  position: absolute;
  right: 0;
  top: calc(100% + .45rem);
  z-index: 30;
  width: min(21.5rem, calc(100vw - 2rem));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .15);
  padding: .5rem;
}

.theme-opt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .7rem;
  width: 100%;
  font: inherit;
  font-size: .95rem;
  text-align: left;
  color: var(--text);
  background: none;
  border: 1px solid transparent;
  border-radius: 9px;
  padding: .45rem .6rem;
  cursor: pointer;
}

.theme-opt:hover { background: var(--surface-2); }

.theme-opt.active {
  border-color: var(--accent);
  background: var(--surface-2);
}

.theme-opt:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.theme-name { flex: 1; }

.theme-chips {
  display: inline-flex;
  gap: 3px;
  flex: none;
}

.theme-chip {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid var(--border);
}

/* ---------- Cards ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem 1.1rem;
}

.card h3 { margin: 0 0 .3rem; font-size: 1.05rem; }
.card p { color: var(--dim); font-size: .93rem; }

/* ---------- Home: hero + game chooser ---------- */

.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 1.1rem 0 .5rem;
}

.hero-art {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: min(330px, 74vw);
  aspect-ratio: 1;
  z-index: 1;
}

/* Soft tinted disc behind the shed so the art reads as a badge. */
.hero-art::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
}

/* The shed itself is a generated WebP per palette (--hero-img, set in
   the theme blocks below); the tinted disc behind stays pure CSS so
   the art still reads as a badge. */
.hero-art::after {
  content: '';
  position: absolute;
  inset: 4%;
  background: var(--hero-img) center / contain no-repeat;
}

.hero-kicker {
  display: inline-block;
  font-size: .76rem;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border));
  border-radius: 999px;
  padding: .22rem .85rem;
  margin: 0 0 .55rem;
}

.hero h1 { margin: .1rem 0 .35rem; }

.hero-tagline {
  color: var(--dim);
  font-size: 1.03rem;
  margin: .3rem auto 0;
  max-width: 42em;
}

@media (min-width: 880px) {
  .hero {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas: 'art copy';
    align-items: center;
    gap: 2.2rem;
    text-align: left;
    padding: 1.4rem 0 .8rem;
  }
  .hero-art { grid-area: art; width: min(330px, 24vw); }
  .hero-copy { grid-area: copy; }
  .hero-tagline { margin-left: 0; }
}

.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: .9rem;
  margin-top: .9rem;
}

.game-card {
  display: flex;
  flex-direction: column;
  gap: .55rem;
  text-decoration: none;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.1rem 1.15rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 5px 16px rgba(0, 0, 0, .05);
  transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease;
}

.game-card:hover {
  border-color: var(--accent);
  transform: translateY(-3px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, .05), 0 12px 26px rgba(0, 0, 0, .09);
}
.game-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Icon sits in a tinted rounded tile. */
.game-card .gc-icon {
  width: 56px;
  height: 56px;
  padding: 10px;
  box-sizing: border-box;
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--border));
  border-radius: 14px;
}

.game-card h3 { margin: 0; font-size: 1.12rem; }
.game-card p { margin: 0; color: var(--dim); font-size: .92rem; flex: 1; }

.game-card .gc-go {
  align-self: flex-start;
  color: var(--accent);
  background: var(--surface-2);
  border-radius: 999px;
  padding: .26rem .9rem;
  font-weight: 700;
  font-size: .88rem;
}
.game-card:hover .gc-go { background: color-mix(in srgb, var(--accent) 12%, var(--surface-2)); }

/* ---------- Home: continue strip (last game played) ---------- */

.continue-strip {
  display: flex;
  align-items: center;
  gap: .7rem;
  margin-top: 1rem;
  padding: .85rem 1.1rem;
  text-decoration: none;
  color: var(--text);
  background: var(--surface);
  border: 1.5px solid var(--accent);
  border-radius: 16px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 5px 16px rgba(0, 0, 0, .05);
  transition: background-color .15s ease, box-shadow .15s ease;
}

.continue-strip:hover { background: var(--surface-2); box-shadow: 0 2px 4px rgba(0, 0, 0, .05), 0 10px 22px rgba(0, 0, 0, .08); }
.continue-strip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.continue-strip .cs-emoji { color: var(--accent); font-size: 1.1rem; }
.continue-strip .cs-text { flex: 1; font-size: .97rem; }

/* ---------- Setup bar (grade + operations) ---------- */

.setup {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: .9rem 1.1rem;
  margin-top: 1rem;
}

.setup-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.02rem;
  margin: 0 0 .5rem;
}

.setup-row {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
  align-items: center;
  margin-bottom: .55rem;
}

.setup-label {
  font-size: .85rem;
  font-weight: 700;
  color: var(--dim);
  width: 100%;
  margin-bottom: .1rem;
}

.chip {
  font: inherit;
  font-family: var(--font-display);
  font-size: .95rem;
  font-weight: 600;
  color: var(--text);
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: 999px;
  padding: .38rem .9rem;
  min-height: 42px;
  cursor: pointer;
  transition: border-color .15s ease, background-color .15s ease;
}

.chip:hover { border-color: var(--accent); }
.chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.chip[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

/* On the four dark palettes the accent is light — white text on it
   would fail, so pressed chips switch to a dark label there. */
html[data-theme="high"] .chip[aria-pressed="true"],
html[data-theme="dark"] .chip[aria-pressed="true"],
html[data-theme="midnight"] .chip[aria-pressed="true"],
html[data-theme="warm"] .chip[aria-pressed="true"] {
  color: #0b0d10;
}

.chip[disabled] {
  opacity: .45;
  cursor: not-allowed;
}

.setup-note {
  font-size: .87rem;
  color: var(--dim);
  margin: .3rem 0 0;
}

/* ---------- Game page layout ---------- */

.game-stage {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: clamp(1rem, 3vw, 1.8rem);
  margin-top: 1rem;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .04), 0 8px 26px rgba(0, 0, 0, .05);
}

/* The stage's headline (a word or sentence, set by the page). */
.problem {
  font-family: var(--font-display);
  font-size: clamp(2.1rem, 7vw, 3.4rem);
  font-weight: 600;
  letter-spacing: .01em;
  margin: .2rem 0 .6rem;
  line-height: 1.2;
  word-break: break-word;
}

.prompt-line {
  color: var(--dim);
  font-size: .97rem;
  margin: 0 0 .8rem;
  min-height: 1.5em;
}

/* Big answer choices — one row of up to 4, wrapping. */
.choices {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .7rem;
  margin: .8rem 0 .4rem;
}

.choice {
  font: inherit;
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 4vw, 1.9rem);
  font-weight: 600;
  color: var(--text);
  background: var(--surface-2);
  border: 2px solid var(--border);
  border-radius: 16px;
  padding: .55rem 1.3rem;
  min-width: 5.4rem;
  min-height: 62px;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
  transition: border-color .15s ease, transform .12s ease, box-shadow .15s ease;
}

.choice:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, .08);
}
.choice:active { transform: translateY(0); }
.choice:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.choice.correct {
  border-color: var(--accent2);
  background: var(--surface-2);
  color: var(--accent2);
  animation: choicePop .3s ease;
}

@keyframes choicePop {
  50% { transform: scale(1.06); }
}

.choice.soft { opacity: .5; }        /* not the answer — stays visible, no red */

.choice.tried { opacity: .45; }      /* already tried — still readable, no red */

/* ---------- Symbol-card choices (Word Match) ----------
   The button itself carries the card; the inner .sym-card drops
   its own border so there is only one frame. */
.choice.sym-choice {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: .35rem;
  padding: .7rem .8rem .55rem;
  min-width: clamp(120px, 28vw, 176px);
}

.choice.sym-choice .sym-card {
  border: none;
  box-shadow: none;
  padding: 0;
  background: none;
  gap: .35rem;
}

.choice.sym-choice .sym-card .sym-svg { width: clamp(84px, 20vw, 128px); }

.choice.sym-choice .sym-label {
  font-size: clamp(1.2rem, 3.6vw, 1.6rem);
  color: inherit;
}

/* ---------- Sentence chips (Sentence Sense) ----------
   The runner wraps each chip in a .choice button; the button
   takes the chip's look and the inner span stays plain text. */
.choices.sentence-choices { gap: .5rem .45rem; }

.choices.sentence-choices .choice {
  font-size: clamp(1.25rem, 3.6vw, 1.7rem);
  font-weight: 600;
  min-height: 52px;
  padding: .35rem .7rem;
  background: var(--surface-2);
  border: 2px solid var(--border);
  border-radius: 12px;
}

.choices.sentence-choices .choice:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.choices.sentence-choices .choice.pending {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, var(--surface-2));
}

.choices.sentence-choices .choice.correct {
  border-color: var(--accent2);
  background: var(--surface-2);
  color: var(--accent2);
  animation: choicePop .3s ease;
}

.choices.sentence-choices .choice.punct {
  font-size: .95em;
  min-width: 52px;
}

/* ---------- Big tappable reading lines ---------- */

.def-read,
.passage-read {
  display: flex;
  width: 100%;
  max-width: 34em;
  margin: 0 auto;
  font-size: clamp(1.15rem, 3vw, 1.45rem);
  font-weight: 600;
  line-height: 1.6;
  text-align: left;
}

.def-read .tr-text,
.passage-read .tr-text { flex: 1; }

/* ---------- Letter tiles (Word Builder) ---------- */

.tile.selected {
  outline: 3px solid var(--accent2);
  outline-offset: 2px;
  transform: translateY(-3px);
}

.ghost-tile {
  display: grid;
  place-items: center;
  opacity: .9;
  box-shadow: 0 8px 22px rgba(0, 0, 0, .25);
}

/* Feedback line: gentle, never a buzzer. Success gets a check. */
.feedback {
  min-height: 1.6em;
  font-size: 1.02rem;
  font-weight: 600;
  color: var(--accent2);
  margin: .3rem 0 0;
}

.feedback:not(.neutral):not(:empty)::before { content: '\2713\00a0'; }

.feedback.neutral { color: var(--dim); font-weight: 500; }

.stage-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .7rem;
  margin-top: 1rem;
}

/* Plain tap buttons (not hold) for in-game flow. */
.btn {
  font: inherit;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: 999px;
  padding: .55rem 1.3rem;
  min-height: 46px;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
  transition: border-color .15s ease, background-color .15s ease;
}

.btn:hover { border-color: var(--accent); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

html[data-theme="high"] .btn.primary,
html[data-theme="dark"] .btn.primary,
html[data-theme="midnight"] .btn.primary,
html[data-theme="warm"] .btn.primary {
  color: #0b0d10;
}

.btn[disabled] { opacity: .5; cursor: default; }

/* ---------- Read-aloud: tap-to-read buttons + karaoke words ----------
   Every readable line is a .tap-read button; while speech runs,
   its word spans light up one by one (.kw-now), then settle
   (.kw-done). Reduced motion keeps the colors, drops the tween. */

.tap-read {
  font: inherit;
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  text-align: left;
  background: var(--surface-2);
  border: 1.5px dashed var(--border);
  border-radius: 12px;
  padding: .4rem .8rem;
  color: inherit;
  cursor: pointer;
  transition: border-color .15s ease, background-color .15s ease;
}

.tap-read:hover { border-color: var(--accent); border-style: solid; }
.tap-read:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.tr-ico { font-size: .9em; opacity: .75; flex: none; }

.kw { border-radius: 4px; transition: background-color .12s ease, color .12s ease; }
.kw-now {
  background: color-mix(in srgb, var(--accent) 30%, transparent);
  color: var(--text);
  font-weight: 700;
}
.kw-done { color: var(--dim); }

/* The stage's big text: a tappable word/passage, not an equation. */
.big-word {
  font-family: var(--font-display);
  font-size: clamp(2.3rem, 8vw, 3.6rem);
  font-weight: 600;
  letter-spacing: .01em;
  margin: .2rem 0 .6rem;
  line-height: 1.15;
  word-break: break-word;
}

/* ---------- PECS-style symbol card ----------
   Original flat line art on a white card with a colored border —
   the Boardmaker look, drawn from scratch (PCS is copyrighted). */
.sym-card {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: .3rem;
  background: var(--surface);
  border: 3px solid var(--accent);
  border-radius: 14px;
  padding: .55rem .7rem .4rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .06);
}

/* .sym-svg matches both the inline SVG fallback and the
   generated PNG (<img class="sym-svg">) — same box either way. */
.sym-card .sym-svg { width: clamp(90px, 22vw, 140px); height: auto; display: block; }
.sym-card img.sym-svg { object-fit: contain; }

.sym-label {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
}

.sym-card.tappable { cursor: pointer; transition: transform .12s ease, border-color .15s ease; }
.sym-card.tappable:hover { transform: translateY(-2px); border-color: var(--accent2); }
.sym-card.tappable:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.sym-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-start;
  gap: .8rem;
  margin: .3rem 0 .7rem;
}

/* ---------- Passage (Story Time) ---------- */

.passage {
  max-width: 34em;
  margin: 0 auto .8rem;
  font-size: clamp(1.1rem, 2.6vw, 1.3rem);
  line-height: 1.75;
  text-align: left;
}

.passage .tap-read { display: inline; border-radius: 8px; }

/* ---------- Sentence chips (Sentence Sense) ----------
   Styled via .choices.sentence-choices .choice (see above) —
   the runner wraps every chip in a .choice button. */

/* ---------- Letter tiles + slots (Word Builder) ---------- */

.slots {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .5rem;
  margin: .5rem auto .8rem;
}

.slot {
  width: clamp(46px, 11vw, 64px);
  height: clamp(56px, 13vw, 74px);
  background: var(--surface);
  border: 2.5px dashed var(--dim);
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 5vw, 2.1rem);
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: border-color .15s ease, background-color .15s ease;
}

.slot.filled { border-style: solid; border-color: var(--accent); background: var(--surface-2); }
.slot.drop-ok { border-color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }
.slot:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.slot .kw-now { background: color-mix(in srgb, var(--accent) 30%, transparent); }

.tile-rack {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .5rem;
  margin: .3rem auto .4rem;
  min-height: 60px;
}

.tile {
  font: inherit;
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 5vw, 2.1rem);
  font-weight: 600;
  color: var(--text);
  background: var(--accent);
  border: 2px solid rgba(0, 0, 0, .15);
  border-radius: 12px;
  width: clamp(46px, 11vw, 64px);
  height: clamp(56px, 13vw, 74px);
  cursor: grab;
  box-shadow: 0 2px 4px rgba(0, 0, 0, .12);
  transition: transform .12s ease, opacity .12s ease;
  touch-action: none;
}

html[data-theme="high"] .tile,
html[data-theme="dark"] .tile,
html[data-theme="midnight"] .tile,
html[data-theme="warm"] .tile { color: #0b0d10; }

.tile:hover { transform: translateY(-2px); }
.tile:focus-visible { outline: 3px solid var(--accent2); outline-offset: 2px; }
.tile.used { opacity: .25; pointer-events: none; }
.tile.drag-src { opacity: .3; }

/* ---------- Choice pending: the tap registered, the voice speaks ---------- */

.choice.pending {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, var(--surface-2));
}

/* ---------- Round progress dots ---------- */

.progress {
  display: flex;
  justify-content: center;
  gap: .45rem;
  margin-top: .9rem;
}

.pdot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
}

.pdot.done { background: var(--accent2); border-color: var(--accent2); }
.pdot.now {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}

.progress-label {
  font-size: .83rem;
  color: var(--dim);
  margin-top: .35rem;
  text-align: center;
}

/* ---------- Game visual area, hint, extra controls ---------- */

.visual { margin: .2rem 0 .5rem; }

.hint-line {
  max-width: 34em;
  margin: .6rem auto 0;
  font-size: .97rem;
  color: var(--dim);
  background: var(--surface-2);
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: .55rem .9rem;
  text-align: left;
}

.choice.tried { opacity: .4; }   /* "not that one" — no red, no buzzer */

.check-row {
  display: flex;
  justify-content: center;
  gap: .7rem;
  margin-top: .8rem;
}

.count-line {
  font-size: .97rem;
  font-weight: 700;
  color: var(--text);
  margin: .6rem 0 0;
  font-variant-numeric: tabular-nums;
}

.model-caption {
  font-size: .8rem;
  font-weight: 700;
  color: var(--dim);
  margin: 0 0 .3rem;
  text-align: center;
}

/* ---------- Settings row (grade/focus on every game page) ---------- */

.playing-as {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  align-items: center;
  justify-content: center;
  font-size: .9rem;
  color: var(--dim);
  margin-top: .7rem;
}

.playing-as strong { color: var(--text); }

/* ---------- Home background patterns (toggleable) ----------
   Whisper-quiet word motif, home page only. Toggle lives in the
   palette panel ("Background patterns") and shares the site's
   homeMotifs setting. Low/high contrast get no pattern. */

body.home::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-repeat: repeat;
  background-size: 220px 220px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><g fill='none' stroke='%23808080' stroke-opacity='0.13' stroke-width='2' stroke-linecap='round'><path d='M30 30 h16 M38 22 v16'/><path d='M150 40 h14'/><circle cx='170' cy='150' r='7'/><path d='M45 140 h16 M45 154 h16 M48 143 l10 8 M58 143 l-10 8'/><path d='M110 95 h14 M117 88 v14'/><path d='M95 185 h14'/></g></svg>");
}

html.motifs-off body.home::before { display: none; }
html[data-theme="low"] body.home::before,
html[data-theme="high"] body.home::before { display: none; }

/* ---------- Score + round-complete screen ---------- */

.score-pill {
  margin: 0 0 .3rem;
  text-align: right;
  font-size: .92rem;
  font-weight: 700;
  color: var(--dim);
}

.round-done { padding: .4rem 0 .2rem; }
.rd-emoji { font-size: 2.6rem; line-height: 1.1; }
.rd-title { font-size: 1.7rem; margin: .35rem 0 .3rem; font-weight: 700; }
.rd-line { font-size: 1.05rem; margin: .15rem 0; }
.rd-line strong { color: var(--accent2); }
.rd-total { color: var(--dim); font-size: .95rem; margin: .15rem 0 .45rem; }
.rd-ask { font-weight: 700; margin: .2rem 0 .1rem; }

/* ---------- Locked choices (kept for gated flows) ---------- */

.choice.is-locked { opacity: .45; cursor: not-allowed; }

/* ---------- Drag and drop (Word Builder tiles) ---------- */

.tile { touch-action: none; }

.drag-ghost {
  position: fixed;
  z-index: 100;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

body.dragging-active,
body.dragging-active * { cursor: grabbing !important; user-select: none; }

/* ---------- Shared color palettes (all 11) ----------
   word.js sets html[data-theme] before first paint. These blocks
   mirror site.css (SwankyMcGee.github.io) exactly, plus --accent2
   = the palette's second accent (THEMES chips[4]) used for the
   "other group" in two-group visuals. */

html[data-theme="calm"] {
  --bg: #f2f6f8;
  --surface: #ffffff;
  --surface-2: #e9eff3;
  --text: #33414d;
  --dim: #6b7c8a;
  --border: #d5dfe6;
  --accent: #4d84a6;
  --accent2: #628f5d;
  --hold-bg: #fdf3dd;
  --hold-text: #7a5c1e;
  --hold-border: #eeddb3;

  --hero-img: url("img/heroes/calm.webp");
  --foot-img: url("img/footers/calm.jpg");
}

html[data-theme="lavender"] {
  --bg: #f5f3fb;
  --surface: #ffffff;
  --surface-2: #ece8f7;
  --text: #3d3a52;
  --dim: #75708f;
  --border: #ddd7ef;
  --accent: #7a6fc0;
  --accent2: #6a9a76;
  --hold-bg: #fdf3dd;
  --hold-text: #7a5c1e;
  --hold-border: #eeddb3;

  --hero-img: url("img/heroes/lavender.webp");
  --foot-img: url("img/footers/lavender.jpg");
}

html[data-theme="mint"] {
  --bg: #eef8f3;
  --surface: #ffffff;
  --surface-2: #e0f0e8;
  --text: #2f4640;
  --dim: #648076;
  --border: #cfe6dc;
  --accent: #35837e;
  --accent2: #6f9a58;
  --hold-bg: #fdf3dd;
  --hold-text: #7a5c1e;
  --hold-border: #eeddb3;

  --hero-img: url("img/heroes/mint.webp");
  --foot-img: url("img/footers/mint.jpg");
}

html[data-theme="peach"] {
  --bg: #fdf6ef;
  --surface: #fffdfb;
  --surface-2: #f9ece0;
  --text: #4d3f34;
  --dim: #8a7566;
  --border: #f0e0d0;
  --accent: #c26a3c;
  --accent2: #7a9a5a;
  --hold-bg: #fdf3dd;
  --hold-text: #7a5c1e;
  --hold-border: #eeddb3;

  --hero-img: url("img/heroes/peach.webp");
  --foot-img: url("img/footers/peach.jpg");
}

html[data-theme="rose"] {
  --bg: #fdf4f6;
  --surface: #ffffff;
  --surface-2: #f9e7ec;
  --text: #4f3540;
  --dim: #8c6b78;
  --border: #f2dae1;
  --accent: #c25f7e;
  --accent2: #6f9466;
  --hold-bg: #fdf3dd;
  --hold-text: #7a5c1e;
  --hold-border: #eeddb3;

  --hero-img: url("img/heroes/rose.webp");
  --foot-img: url("img/footers/rose.jpg");
}

html[data-theme="ocean"] {
  --bg: #eef8fa;
  --surface: #ffffff;
  --surface-2: #dff0f4;
  --text: #2c4750;
  --dim: #5f7f89;
  --border: #cfe6eb;
  --accent: #2f87a3;
  --accent2: #5f9a6a;
  --hold-bg: #fdf3dd;
  --hold-text: #7a5c1e;
  --hold-border: #eeddb3;

  --hero-img: url("img/heroes/ocean.webp");
  --foot-img: url("img/footers/ocean.jpg");
}

html[data-theme="low"] {
  --bg: #eef1f3;
  --surface: #f6f8f9;
  --surface-2: #eaedef;
  --text: #5b6570;
  --dim: #838d97;
  --border: #e2e6e9;
  --accent: #94b4c3;
  --accent2: #a9c5a5;
  --hold-bg: #f4efe3;
  --hold-text: #8a8172;
  --hold-border: #e8e0cf;

  --hero-img: url("img/heroes/low.webp");
  --foot-img: url("img/footers/low.jpg");
}

html[data-theme="high"] {
  --bg: #000000;
  --surface: #0b0d10;
  --surface-2: #16191e;
  --text: #ffffff;
  --dim: #d0d6dc;
  --border: #ffffff;
  --accent: #56e0ff;
  --accent2: #b7ff5e;
  --hold-bg: #2a2105;
  --hold-text: #ffe066;
  --hold-border: #ffe066;

  --hero-img: url("img/heroes/high.webp");
  --foot-img: url("img/footers/high.jpg");
}

html[data-theme="dark"] {
  --bg: #151a20;
  --surface: #1e242b;
  --surface-2: #252c34;
  --text: #e7edf2;
  --dim: #9aa7b3;
  --border: #323b45;
  --accent: #6fa9c7;
  --accent2: #8fbf88;
  --hold-bg: #3a3320;
  --hold-text: #f0dca6;
  --hold-border: #5c5030;

  --hero-img: url("img/heroes/dark.webp");
  --foot-img: url("img/footers/dark.jpg");
}

html[data-theme="midnight"] {
  --bg: #0a0f1e;
  --surface: #121a30;
  --surface-2: #1a2440;
  --text: #e3e9f7;
  --dim: #9aa6c4;
  --border: #2c3a5e;
  --accent: #6fa8ff;
  --accent2: #67d6a5;
  --hold-bg: #1c2745;
  --hold-text: #a9c6f5;
  --hold-border: #3d5585;

  --hero-img: url("img/heroes/midnight.webp");
  --foot-img: url("img/footers/midnight.jpg");
}

html[data-theme="warm"] {
  --bg: #211a14;
  --surface: #2b221a;
  --surface-2: #352a20;
  --text: #f0e6da;
  --dim: #b3a291;
  --border: #4a3c2e;
  --accent: #d9a05f;
  --accent2: #93b877;
  --hold-bg: #3a3020;
  --hold-text: #f0dca6;
  --hold-border: #5c4c2e;

  --hero-img: url("img/heroes/warm.webp");
  --foot-img: url("img/footers/warm.jpg");
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  * {
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
  }
  .game-card:hover { transform: none; }
}
