:root {
  --cream: #fffaf1;
  --ink: #222347;
  --plum: #553381;
  --lavender: #ece4fa;
  --yellow: #ffdb73;
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--cream); font: 1rem/1.6 system-ui, sans-serif; }
a { color: inherit; text-underline-offset: .24em; }
a:hover { color: var(--plum); }
:focus-visible { outline: 3px solid #9c4516; outline-offset: 4px; }
.container { width: min(100% - 2.5rem, 1150px); margin-inline: auto; padding-inline: 0; }
.skip { position: absolute; z-index: 3; padding: .5rem 1rem; background: white; transform: translateY(-150%); }
.skip:focus { transform: translateY(0); }
.site-header { border-bottom: 1px solid #ded5eb; }
.topbar, .nav-links { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .65rem 1.6rem; }
.topbar { min-height: 76px; padding-block: .75rem; }
.nav-links a { font-weight: 650; text-decoration: none; }
.nav-links a:hover { text-decoration: underline; }
.brand { font-size: 1.7rem; font-weight: 900; letter-spacing: -.06em; text-decoration: none; }
.brand-portrait { width: 62px; height: auto; vertical-align: middle; margin-right: .18em; }
.hero { background: var(--lavender); }
.hero-grid { display: grid; grid-template-columns: 1.05fr 1fr; align-items: center; gap: clamp(1.5rem, 6vw, 6rem); padding-block: clamp(2.75rem, 7vw, 5.8rem); }
.eyebrow { font-size: .78rem; font-weight: 850; letter-spacing: .14em; text-transform: uppercase; color: var(--plum); margin: 0 0 .75rem; }
h1, h2, h3 { font-family: Georgia, serif; font-weight: 700; line-height: 1.08; margin: 0 0 .7rem; }
h1 { font-size: clamp(3.3rem, 7.6vw, 6.7rem); letter-spacing: -.075em; }
h1 em { color: var(--plum); }
h2 { font-size: clamp(2.5rem, 5.5vw, 4.25rem); letter-spacing: -.05em; }
h3 { font-size: 1.55rem; }
.hero-intro { font-size: clamp(1.06rem, 2vw, 1.26rem); max-width: 34ch; margin: 1.2rem 0 1.65rem; }
.action { display: inline-flex; align-items: center; gap: 1rem; background: var(--ink); color: white; border: 2px solid var(--ink); border-radius: 99px; padding: .72rem 1.18rem; font-weight: 750; text-decoration: none; }
.action:hover { background: var(--plum); color: white; }
.hero-art { position: relative; isolation: isolate; margin: 0 .6rem .8rem 0; }
.hero-art img { display: block; width: 100%; aspect-ratio: 1.18; object-fit: cover; object-position: center 84%; border-radius: 34% 34% 1.5rem 1.5rem; border: 6px solid var(--cream); box-shadow: 9px 10px 0 #bba7df; }
.sparkle { position: absolute; top: 0; right: 4%; color: var(--plum); font-size: 3.8rem; line-height: 1; }
.caption { position: absolute; inset: auto 5% -.8rem auto; background: var(--yellow); border-radius: .6rem; padding: .4rem .8rem; font-weight: 800; font-size: .83rem; transform: rotate(-4deg); }
.section { padding-block: clamp(3rem, 7vw, 6rem); }
.section-intro { margin: 0 0 1.8rem; }
.books { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.15rem; }
.book { display: flex; flex-direction: column; border: 1px solid #ded5eb; overflow: hidden; background: white; border-radius: 1.3rem; }
.cover { display: grid; place-items: center; padding: 1.3rem; }
.cover-es { background: #f8e0a5; }
.cover-ca { background: #d9ebdf; }
.cover-en { background: #e6ddf9; }
.cover img { width: 100%; height: 225px; object-fit: contain; }
.book-body { padding: 1.15rem; display: flex; flex-direction: column; flex: 1; }
.book-body > p:not(.language) { margin: 0 0 1rem; }
.book-body a { margin-top: auto; color: var(--plum); font-weight: 800; }
.language { color: var(--plum); font-size: .75rem; font-weight: 800; text-transform: uppercase; letter-spacing: .1em; margin: 0 0 .5rem; }
.collection { background: var(--ink); color: var(--cream); }
.collection-inner { display: flex; align-items: center; gap: clamp(1rem, 6vw, 5rem); padding-block: 3.5rem; }
.collection-inner p { max-width: 65ch; }
.collection .eyebrow, .collection a, .moon { color: var(--yellow); }
.collection a { font-weight: 750; }
.moon { font: 700 clamp(5rem, 17vw, 11rem)/1 Georgia, serif; }
.reading-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.reading-grid article { padding: clamp(1.2rem, 3vw, 2rem); border-radius: 1.2rem; background: #f8e0a5; }
.reading-grid article + article { background: #d9ebdf; }
.reading-grid p { margin: 0; }
footer { background: var(--lavender); }
@media (max-width: 950px) { .books { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 680px) {
  .hero-grid, .reading-grid { grid-template-columns: 1fr; }
  .hero-art { max-width: 460px; }
  .collection-inner { align-items: flex-start; gap: 1rem; }
}
@media (max-width: 450px) {
  .books { grid-template-columns: 1fr; }
  .moon { display: none; }
  .nav-links { gap: .4rem 1rem; font-size: .9rem; }
}

.games { background: #f1eafa; }
.games-layout { display: grid; grid-template-columns: minmax(0, .75fr) minmax(0, 1.25fr); gap: 1.25rem; align-items: start; }
.games-story, .games-board { border-radius: 1.3rem; overflow: hidden; margin: 0; background: white; border: 1px solid #ded5eb; }
.games-story img { display: block; width: 100%; height: auto; }
.games-story figcaption { padding: 1rem 1.25rem; background: #ffebad; }
.games-story figcaption p { margin: .2rem 0 0; }
.games-board { padding: clamp(1rem, 3vw, 1.6rem); }
.games-board [hidden] { display: none; }
.game-modes, .game-controls, .game-answers { display: flex; flex-wrap: wrap; gap: .65rem; }
.game-modes button, .game-answers button, .game-hint {
  min-height: 44px; border: 1px solid #c5afd8; border-radius: .75rem; padding: .45rem .7rem;
  background: #f7f0ff; color: var(--ink); font: inherit; font-weight: 750;
}
.game-modes button[aria-pressed="true"] { background: var(--plum); color: white; }
.game-modes button span { font-size: 1.2em; margin-right: .2em; }
.game-progress { margin: 1.35rem 0 .45rem; color: var(--plum); font-weight: 750; }
.game-objects { display: flex; align-items: stretch; flex-wrap: wrap; gap: .65rem; margin-block: 1rem; }
.block-group { min-width: 4rem; flex: 1 1 7rem; display: grid; align-content: end; gap: .45rem; padding: .75rem; text-align: center; border-radius: .8rem; background: #f1e5ff; }
.block-group:nth-child(even) { background: #e5f3e6; }
.block-group.stored { border: 2px dashed #70522e; background: #fae7c8; }
.block-group.tower { flex-basis: 4rem; }
.blocks { display: flex; justify-content: center; flex-wrap: wrap; gap: .28rem; }
.tower .blocks { flex-direction: column; align-items: center; }
.toy-block {
  display: block; width: 1.45rem; height: 1.45rem; border-radius: .28rem;
  background: #8b54bb; box-shadow: inset 0 3px #ffffff50, inset -3px -4px #0003;
}
.block-group:nth-child(even) .toy-block { background: #368558; }
.block-group.stored .toy-block { background: #a96628; }
.game-equation { font-size: 1.5rem; font-weight: 850; margin: .6rem 0; }
.game-answers button { min-width: 3.4rem; font-size: 1.15rem; }
.game-answers .answer-correct { color: white; background: #286945; border-color: #286945; }
.game-controls { margin-top: .8rem; }
.game-feedback { margin: .8rem 0 0; font-weight: 650; color: var(--plum); }
.game-feedback:empty { margin: 0; }
@media (max-width: 760px) { .games-layout { grid-template-columns: 1fr; } }

.detail-title { font-size: clamp(2.65rem, 6vw, 4.75rem); }
.detail-notes { margin-top: 2rem; }
.detail-notes h2 { font-size: clamp(1.8rem, 4vw, 2.5rem); }
.worksheet { max-width: 820px; }
.worksheet-intro, .worksheet-links { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.worksheet-intro img { width: 110px; height: auto; border-radius: .75rem; }
.worksheet-intro p { flex: 1 1 210px; }
.worksheet-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; padding-left: 1.5rem; }
.worksheet-grid li { padding: .6rem; border: 1px solid #c5afd8; border-radius: .5rem; break-inside: avoid; }
.worksheet-stars { color: var(--plum); font-size: 1.35em; }
@media (max-width: 460px) { .worksheet-grid { grid-template-columns: 1fr; } }
@media print {
  body:has(.worksheet) { background: white; }
  body:has(.worksheet) :is(header, footer, .skip, .worksheet-links) { display: none; }
  .worksheet { width: 100%; padding: 0; }
  .worksheet-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.towers-board { max-width: 580px; }
.towers-score { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem; margin-bottom: .65rem; }
#tower-canvas { display: block; width: min(100%, 288px); height: auto; margin: 0 auto .8rem; border-radius: .65rem; border: 1px solid #c5afd8; }
.tower-controls { display: flex; flex-wrap: wrap; gap: .5rem; }
.tower-controls button:not(.action) { min-height: 44px; min-width: 44px; border: 1px solid #c5afd8; border-radius: .75rem; background: #f7f0ff; color: var(--ink); font-weight: 750; padding: .4rem .65rem; }
.tower-controls button:disabled { opacity: .55; }

.english-settings { display: flex; flex-wrap: wrap; gap: .75rem; margin-bottom: .8rem; }
.english-settings label { flex: 1 1 12rem; font-weight: 750; }
.english-settings select { display: block; width: 100%; min-height: 44px; margin-top: .25rem; padding: .45rem; }
#english-question { font-size: clamp(1.5rem, 4vw, 2rem); letter-spacing: normal; }
.english-pattern { font-size: clamp(1.6rem, 5vw, 2.5rem); font-weight: 800; color: var(--plum); }

.family-article { max-width: 780px; }
.family-photo { display: block; width: 100%; max-height: 340px; object-fit: cover; object-position: center 40%; border-radius: 1rem; margin: 1.25rem 0; }
.family-article h2, .family-guides h2 { font-size: clamp(1.65rem, 3.5vw, 2.3rem); letter-spacing: -.025em; }
.family-article h2 { margin-top: 1.6rem; }
.family-guides { margin-bottom: 1rem; }

.language-options { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .4rem; }
.language-options a { padding: .25rem .55rem; border-radius: .55rem; font-size: .88rem; font-weight: 700; }
.language-options a[aria-current="page"] { background: var(--lavender); text-decoration: none; }
.language-suggestion { display: flex; align-items: center; justify-content: space-between; gap: .6rem; margin-bottom: .75rem; padding: .5rem .75rem; background: #ffebad; border-radius: .65rem; }
.language-suggestion[hidden] { display: none; }
.language-suggestion button { background: transparent; color: inherit; border: 0; font-size: 1.4rem; min-width: 44px; min-height: 44px; }

.memory-panel { max-width: 820px; margin-inline: auto; }
.memory-panel [hidden] { display: none; }
.memory-settings, .memory-score { display: flex; flex-wrap: wrap; align-items: center; gap: .7rem 1.2rem; }
.memory-settings label { font-weight: 750; }
.memory-settings select { border: 1px solid #c5afd8; border-radius: .5rem; background: white; color: var(--ink); padding: .55rem; }
.memory-score { margin-top: 1rem; font-weight: 750; }
.memory-grid { display: grid; grid-template-columns: repeat(var(--memory-size, 4), minmax(0, 1fr)); gap: clamp(3px, 1vw, 9px); margin-top: .65rem; }
.memory-grid[data-size="4"] { max-width: 520px; margin-inline: auto; }
.memory-card { aspect-ratio: 1; padding: 0; min-width: 0; overflow: hidden; border: 2px solid transparent; border-radius: clamp(4px, 1.1vw, 12px); background: #5c3b88; color: var(--ink); cursor: pointer; }
.memory-card[data-face="matched"] { background: #276448; border-color: #276448; cursor: default; }
.memory-back, .memory-front { width: 100%; height: 100%; }
.memory-back { display: flex; align-items: center; justify-content: center; gap: 1%; padding: 3%; }
.memory-back img { width: 48%; height: auto; border: 1px solid #fff5d7; border-radius: 50%; }
.memory-front { position: relative; display: block; background: #fff7e5; }
.memory-front img { width: 100%; height: 100%; object-fit: cover; display: block; }
.memory-name { position: absolute; inset: auto 0 0; padding: .08em; background: #fff7e5ed; font-size: clamp(.52rem, 1.35vw, .83rem); line-height: 1.15; font-weight: 750; }
.memory-card[data-face="back"] .memory-front, .memory-card:not([data-face="back"]) .memory-back { display: none; }
@media (max-width: 580px) { .memory-grid[data-size="8"] .memory-name, .memory-grid[data-size="6"] .memory-name { display: none; } }

.flight-panel { max-width: 820px; margin-inline: auto; }
.flight-panel [hidden] { display: none; }
.flight-art { display: block; width: min(100%, 620px); height: auto; border-radius: .8rem; margin: 0 auto .85rem; }
.flight-choices { display: flex; flex-wrap: wrap; gap: .5rem; margin: .25rem 0 .9rem; }
.flight-choices label { display: inline-flex; align-items: center; gap: .4rem; padding: .35rem .55rem; background: #f4ebff; border: 1px solid #c5afd8; border-radius: .65rem; cursor: pointer; font-weight: 750; }
.flight-choices label:has(input:checked) { outline: 2px solid var(--plum); }
.flight-choices img { border-radius: .35rem; }
#flight-sky { display: block; width: 100%; height: auto; border-radius: .65rem; touch-action: none; }
#flight-keys { margin: .6rem 0 0; }
.flight-result h2 { font-size: clamp(1.65rem, 4vw, 2.65rem); }
.flight-result img { display: block; width: min(100%, 652px); height: auto; margin: 0 0 1rem; border-radius: .75rem; }

.color-panel { max-width: 820px; margin-inline: auto; }
.color-panel [hidden] { display: none; }
.color-palette { display: flex; flex-wrap: wrap; gap: .5rem; }
.color-palette button { display: inline-flex; align-items: center; gap: .35rem; min-height: 44px; padding: .35rem .6rem; border: 1px solid #c5afd8; border-radius: 99px; background: #fff; color: var(--ink); font-weight: 750; }
.color-palette button[aria-pressed="true"] { background: var(--lavender); outline: 2px solid var(--plum); }
.color-palette button:disabled { opacity: .62; }
.color-palette button:disabled::after { content: '✓'; }
.color-dot { display: inline-block; width: 1.1rem; height: 1.1rem; border: 1px solid #222347; border-radius: 50%; }
#color-picture { display: block; width: min(100%, 660px); height: auto; margin: .65rem auto; border-radius: .65rem; cursor: crosshair; }
#color-keys { margin: .65rem 0 0; }
#color-picture[hidden] { display: none; }

.flag-panel { max-width: 690px; margin-inline: auto; text-align: center; }
.flag-panel [hidden] { display: none; }
.flag-panel h2 { font-size: clamp(1.65rem, 4vw, 2.6rem); letter-spacing: -.025em; }
.flag-frame { display: grid; place-items: center; width: min(100%, 320px); aspect-ratio: 4/3; margin: 1rem auto; background: #f6effb; border: 1px solid #d7cae6; border-radius: .7rem; overflow: hidden; }
.flag-frame img { display: block; width: 100%; height: auto; }
.flag-frame img[hidden] { display: none; }
.flag-options, .flag-controls { justify-content: center; }

#game-difficulty { margin-top: 1rem; }
#game-difficulty legend { font-size: 1rem; font-weight: 750; }
.game-stars { display: flex; flex-wrap: wrap; gap: .35rem; }
.game-stars label { position: relative; cursor: pointer; }
.game-stars input { position: absolute; width: 100%; height: 100%; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.game-stars span { display: grid; width: 44px; min-height: 44px; place-items: center; border: 1px solid #c5afd8; border-radius: .65rem; color: var(--plum); background: white; font-size: 1.35rem; }
.game-stars label:has(input:checked) span, .game-stars label:has(~ label input:checked) span { background: #ffdb73; color: #47276b; }
.game-stars input:focus-visible + span { outline: 3px solid #9c4516; outline-offset: 3px; }
.game-objects:empty { display: none; }

.analytics-banner { position: fixed; z-index: 5; inset: auto 1rem 1rem auto; width: min(430px, calc(100% - 2rem)); padding: 1rem; background: var(--cream); color: var(--ink); border: 1px solid #c5afd8; border-radius: 1rem; box-shadow: 0 4px 24px #22234730; }
.analytics-banner[hidden] { display: none; }
.analytics-banner h2 { font-size: 1.35rem; letter-spacing: 0; }
.analytics-banner p { margin-bottom: .65rem; }
.analytics-controls { display: flex; flex-wrap: wrap; gap: .5rem; }
.analytics-controls button { flex: 1 1 9rem; min-height: 44px; padding: .35rem .6rem; font-weight: 750; color: var(--ink); background: #f0e7fc; border: 1px solid #c5afd8; border-radius: .6rem; }
.analytics-settings { display: block; margin: 0 auto; padding: .45rem; border: 0; background: transparent; color: var(--ink); text-decoration: underline; }
@media print { .analytics-banner { display: none; } }

.puzzle-panel { max-width: 1050px; margin-inline: auto; }
.puzzle-settings { display: flex; align-items: end; gap: .75rem 1.25rem; flex-wrap: wrap; }
.puzzle-settings legend { font-size: 1rem; font-weight: 750; margin-bottom: .35rem; }
.puzzle-layout { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 1rem; align-items: start; margin-top: .9rem; }
.puzzle-board { display: grid; grid-template-columns: repeat(var(--puzzle-size, 2), minmax(0, 1fr)); grid-template-rows: repeat(var(--puzzle-size, 2), minmax(0, 1fr)); background: white; outline: 2px solid #bda9d1; border-radius: .35rem; isolation: isolate; }
.puzzle-slot { position: relative; display: grid; place-items: center; min-width: 0; min-height: 0; padding: 0; border: 0; outline: 1px dashed #d9d0e3; background: transparent; cursor: pointer; }
.puzzle-slot:focus-visible { outline: 3px solid #9c4516; z-index: 2; }
.puzzle-slot:disabled { outline: none; cursor: default; }
.puzzle-hover:not(:disabled) { background: #eee1fb; }
.puzzle-placed { position: absolute; max-width: none; pointer-events: none; z-index: 1; }
.puzzle-tray { display: grid; grid-template-columns: repeat(var(--puzzle-size, 2), minmax(0, 1fr)); gap: .3rem; padding: .5rem; background: #f1eafa; border-radius: .65rem; }
.puzzle-piece { display: grid; place-items: center; min-width: 0; min-height: 44px; padding: .15rem; border: 2px solid transparent; border-radius: .45rem; background: transparent; cursor: grab; touch-action: none; }
.puzzle-piece canvas { display: block; width: min(100%, 132px); height: auto; pointer-events: none; }
.puzzle-piece[aria-pressed="true"] { border-color: var(--plum); background: white; }
.puzzle-ghost { position: fixed; z-index: 20; transform: translate(-50%, -50%); height: auto; pointer-events: none; filter: drop-shadow(0 4px 6px #22234760); }
.puzzle-complete { outline-color: #286945; }
.puzzle-help { margin: .85rem 0 0; }
@media (max-width: 680px) {
  .puzzle-layout { grid-template-columns: minmax(0, 1fr); }
  .puzzle-board { width: min(100%, 420px); margin-inline: auto; }
}

.chess-panel { max-width: 820px; margin-inline: auto; }
.chess-panel [hidden] { display: none; }
.chess-settings-group { margin: 0 0 .85rem; }
.chess-settings-group legend { font-size: 1rem; font-weight: 750; margin-bottom: .35rem; }
.chess-settings-group > label { display: inline-flex; min-height: 44px; align-items: center; gap: .4rem; padding: .3rem .65rem; border: 1px solid #c5afd8; border-radius: .65rem; margin: 0 .3rem .35rem 0; background: #f7f0ff; cursor: pointer; font-weight: 650; }
.chess-settings-group > label:has(input:checked) { border-color: var(--plum); background: #ece0fc; }
.chess-settings-group input[type="radio"] { accent-color: var(--plum); }
.chess-settings-group img { border-radius: 50%; }
.chess-board { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); width: min(100%, 560px); margin: .65rem auto; border: 3px solid #52375c; border-radius: .35rem; }
.chess-square { position: relative; display: grid; aspect-ratio: 1; place-items: center; min-width: 0; min-height: 0; padding: 0; border: 0; cursor: pointer; }
.chess-light { background: #f7e4c2; color: #4b2d53; }
.chess-dark { background: #9574ae; color: #170e24; }
.chess-square.chess-last { box-shadow: inset 0 0 0 3px #f4bb51; }
.chess-square[aria-pressed="true"] { box-shadow: inset 0 0 0 3px #382166; }
.chess-square.chess-check { background: #d98b91; }
.chess-square:focus-visible { outline: 3px solid #552b03; outline-offset: -4px; z-index: 1; }
.chess-square.chess-destination::after { content: ''; position: absolute; width: 24%; aspect-ratio: 1; border-radius: 50%; background: #302143a0; pointer-events: none; }
.chess-square.chess-destination:has(.chess-piece)::after { width: 85%; background: transparent; border: 3px solid #3c295c; }
.chess-occupant, .chess-piece { display: grid; width: 100%; height: 100%; place-items: center; }
.chess-piece { position: relative; font: 1em/1 'DejaVu Sans','Segoe UI Symbol','Apple Symbols',serif; font-size: clamp(1.45rem, 6.5vw, 3.45rem); }
.chess-piece-w { color: #fff9e9; text-shadow: 1px 0 #4b3559, -1px 0 #4b3559, 0 -1px #4b3559, 0 1px #4b3559; }
.chess-piece-b { color: #271936; text-shadow: 1px 1px #f5d7f4; }
.chess-king img { position: absolute; top: 24%; left: 50%; transform: translateX(-50%); width: 54%; aspect-ratio: 1; border: 2px solid currentColor; border-radius: 50%; object-fit: cover; }
.chess-coordinate { position: absolute; font-size: clamp(.54rem, 1.4vw, .72rem); font-weight: 850; pointer-events: none; }
.chess-rank { left: 2px; top: 0; }
.chess-file { right: 2px; bottom: 0; }
#chess-keys { margin: 0; text-align: center; }
