:root {
  color-scheme: light;
  --paper: #f8f4eb;
  --card: #fffdf8;
  --ink: #22253c;
  --muted: #504e64;
  --line: #d8d1c3;
  --violet: #403072;
  --lavender: #eee8fb;
  --teal: #23675c;
  --mint: #e9f4ec;
  --orange: #9e451e;
  --peach: #f9e5d5;
  font-family: system-ui, sans-serif;
  line-height: 1.55;
  color: var(--ink);
  background: var(--paper);
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-inline-size: 0; }
[hidden] { display: none !important; }
.shell { width: min(100% - 2rem, 65rem); margin-inline: auto; }
.masthead { background: var(--card); border-bottom: 1px solid var(--line); }
.masthead-inner, #session { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; }
.masthead-inner { justify-content: space-between; min-height: 4.25rem; padding-block: .45rem; }
.brand { display: flex; align-items: center; gap: .55rem; font-size: 1.2rem; font-weight: 800; }
.brand-mark { background: var(--violet); color: white; border-radius: 35%; padding-inline: .5rem; }
.footer { padding-block: 1.5rem; color: var(--muted); font-size: .875rem; }
main { padding-top: clamp(1rem, 3vw, 2.5rem); }
.panel { min-width: 0; border: 1px solid var(--line); background: var(--card); border-radius: 1.5rem; padding: clamp(1rem, 4vw, 2.25rem); box-shadow: 0 5px 0 #e9e2d5; }
.narrow { max-width: 39rem; margin-inline: auto; }
h1, h2, h3 { line-height: 1.2; margin: 0; overflow-wrap: anywhere; }
h1 { font-family: ui-serif, Georgia, serif; letter-spacing: -.025em; font-size: clamp(2rem, 5vw, 3.4rem); }
h2 { font-size: 1.25rem; }
h3 { font-size: 1rem; }
p { margin: 0; overflow-wrap: anywhere; }
.stack { display: grid; gap: 1rem; }
.stack-small { display: grid; gap: .5rem; }
.eyebrow { font-size: .8rem; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; color: var(--violet); }
.intro { display: grid; gap: .45rem; }
.intro > p:not(.eyebrow) { color: var(--muted); max-width: 60ch; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: .65rem; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; min-height: 2.75rem; padding: .5rem 1rem; border: 1px solid var(--violet); border-radius: .7rem; background: var(--lavender); color: var(--violet); font-weight: 750; }
button:hover:not(:disabled) { background: #e0d5f6; }
button.primary { background: var(--violet); color: #fff; }
button.primary:hover:not(:disabled) { background: #30215b; }
button.quiet { background: transparent; border-color: transparent; text-decoration: underline; text-underline-offset: .2em; }
button:disabled { cursor: not-allowed; opacity: .65; }
:focus-visible { outline: 3px solid #225aab; outline-offset: 3px; }
.field { display: grid; gap: .25rem; }
.field label, legend { font-weight: 700; }
.field small { color: var(--muted); }
input, select, textarea { width: 100%; min-height: 2.75rem; padding: .55rem .7rem; background: #fff; color: var(--ink); border-radius: .55rem; border: 1px solid #817988; }
textarea { min-height: 6rem; resize: vertical; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend { padding: 0 0 .45rem; }
.choice-grid { display: grid; gap: .65rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 10rem), 1fr)); }
.choice { position: relative; display: grid; align-content: start; gap: .35rem; border: 1px solid #817988; border-radius: .75rem; background: #fff; cursor: pointer; padding: .7rem 2.4rem .7rem .85rem; min-height: 3.3rem; overflow-wrap: anywhere; }
.choice:hover, .choice:has(:checked) { background: var(--lavender); border-color: var(--violet); }
.choice:has(:focus-visible) { outline: 3px solid #225aab; outline-offset: 3px; }
.choice input { accent-color: var(--violet); position: absolute; inset: .9rem .8rem auto auto; margin: 0; min-height: 0; width: 1.15rem; height: 1.15rem; }
.choice-icon { font-size: 1.35rem; color: var(--violet); }
.choice-name { font-weight: 750; }
.message, .feedback { padding: .85rem 1rem; border-radius: .75rem; border: 1px solid; }
.message { color: #751f17; background: #fff0e8; margin-bottom: 1rem; }
.feedback { color: var(--violet); background: var(--lavender); border-color: #bcb1d4; }
.feedback.success { color: #174b40; background: var(--mint); border-color: #8cb5a5; }
.demo-action { margin-top: .65rem; }

.quest-grid { display: grid; align-items: start; gap: clamp(1.15rem, 3vw, 2rem); }
.workspace { display: grid; gap: 1.1rem; min-width: 0; }
.board { background: var(--mint); border: 1px solid #aacabd; border-radius: 1rem; padding: clamp(.5rem, 2.5vw, 1rem); }
.board.source { background: var(--peach); border-color: #d9ac90; }
.board h2 { font-size: 1.05rem; }
.summary { color: var(--muted); font-size: .9rem; }
.cells { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: clamp(.18rem, 1vw, .55rem); width: min(100%, 24rem); }
.cell { display: grid; place-items: center; min-width: 0; min-height: 2.75rem; aspect-ratio: 1.1; border-radius: .5rem; background: #fffdf8; border: 1px solid #91afa1; }
.cell.empty { border-style: dashed; }
.source .cell { border-color: #c4957d; }
.source .cell.empty { background: #fff6ee; }
.piece { display: block; border-radius: 50%; width: 70%; max-width: 2.25rem; aspect-ratio: 1; background: var(--teal); border: 2px solid #16453e; box-shadow: inset 0 0 0 3px #ffffff35; }
button.cell { padding: 0; }
button.cell .piece, .piece.moved { background: var(--orange); border-color: #703016; }
button.cell:hover:not(:disabled) { background: #ffe3c9; border-color: #703016; }
button[aria-disabled="true"] { cursor: wait; }
.numbers { grid-template-columns: repeat(4, minmax(0, 1fr)); max-width: 22rem; }
.numbers button { padding-inline: .3rem; }
.numbers button[aria-pressed="true"] { background: var(--violet); color: #fff; }
[data-theme="cat-cafe"] .board:not(.source) { background: #f8edf3; }
[data-theme="block-builders"] .piece { border-radius: .35rem; }
[data-theme="underground-adventure"] .board:not(.source) { background: #ece8fa; }
[data-theme="underground-adventure"] .piece { border-radius: .25rem .8rem; }
[data-theme="arcade-hangout"] .board:not(.source) { background: #e7effa; }

.parent-grid { display: grid; gap: 1.5rem; align-items: start; }
.log { margin: 0; padding-left: 1.25rem; }
.log > li + li { margin-top: .75rem; padding-top: .75rem; border-top: 1px solid var(--line); }
.details { display: grid; gap: .2rem; margin: .35rem 0 0; }
.details > div { display: flex; gap: .35rem; flex-wrap: wrap; }
.details dt { font-weight: 700; }
.details dd { margin: 0; overflow-wrap: anywhere; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

.trail-list, .tap-list { display: flex; flex-wrap: wrap; gap: .55rem; margin: 0; padding: 0; list-style: none; }
.trail-list { display: grid; }
.trail-list button { display: grid; gap: .25rem; width: 100%; text-align: left; padding: .7rem .9rem; overflow-wrap: anywhere; }
.trail-list button > span { font-weight: 500; }
.current-trail { font-size: .9rem; }
.practice .board { max-width: 42rem; }
.tap-choice { min-width: 2.75rem; }
.tap-choice[aria-pressed="true"] { background: var(--violet); color: white; box-shadow: inset 0 0 0 2px white; }
.practice button[aria-disabled="true"] { cursor: default; }
.practice button[aria-disabled="true"]:not([aria-pressed="true"]) { opacity: .7; }
.number-line { display: flex; overflow-x: auto; font-variant-numeric: tabular-nums; }
.line-tick { flex: 1 0 1.4em; min-inline-size: 0; text-align: center; font-size: clamp(.85rem, 2.5vw, 1rem); }
.line-tick > span { display: block; }
.tick-icon { border-bottom: 2px solid currentColor; }
.line-tick[data-spot] { font-weight: 800; color: var(--violet); }
.line-tick[data-spot] .tick-icon { background: var(--lavender); }
.word-sequence, .pattern-row { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem; min-height: 3rem; padding: .45rem; background: var(--card); border: 1px dashed #817988; border-radius: .55rem; }
.word-sequence > span, .tile { padding: .25rem .55rem; }
.word-sequence > span { border: 1px solid var(--line); border-radius: .45rem; background: white; overflow-wrap: anywhere; }
.pictogram-word { font-size: clamp(1.65rem, 5vw, 2.4rem); font-weight: 750; }
.pictograms button { min-width: 4.25rem; min-height: 4.25rem; padding: .35rem .65rem; font-size: 2.45rem; line-height: 1.1; }
.tile { display: grid; place-items: center; min-width: 2.5rem; min-height: 2.5rem; color: var(--ink); background: var(--card); border: 1px solid currentColor; border-radius: .4rem; font-size: 1.5rem; line-height: 1; }
.word-sequence > span, .tap-choice { overflow-wrap: anywhere; max-inline-size: 100%; }
.pattern-row { justify-content: flex-start; list-style: none; }
.pattern-row .tile:last-child { border-style: dashed; }

@media (prefers-reduced-motion: reduce) {
  .practice *, .trail-list * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

@media (min-width: 53rem) {
  .quest-grid { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); }
  .parent-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 23rem) {
  .shell { width: calc(100% - 1rem); }
  .panel { padding-inline: .65rem; }
  .board { padding-inline: .35rem; }
}
