/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 1.125rem;
  line-height: 1.6;
  color: var(--navy);
  background: linear-gradient(180deg, #bfe8ff 0, var(--sky-pale) 360px, #f2fbff 100%);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}
main { flex: 1; outline: none; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.15; margin: 0 0 .4em; letter-spacing: .005em; }
h1 { font-size: clamp(2rem, 4.5vw, 3.1rem); font-weight: 800; }
h2 { font-size: clamp(1.4rem, 2.6vw, 1.85rem); font-weight: 800; }
h3 { font-size: 1.3rem; font-weight: 700; }
p { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }
a { color: var(--purple-dark); font-weight: 700; text-underline-offset: .18em; }
svg { display: block; }
img { max-width: 100%; height: auto; }
.lead { font-size: 1.25rem; }
.muted { color: var(--muted); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

:focus-visible { outline: 4px solid var(--focus); outline-offset: 3px; border-radius: 10px; }
.skip-link { position: absolute; left: 12px; top: -80px; z-index: 100; background: var(--navy); color: #fff; padding: 12px 18px; border-radius: 12px; }
.skip-link:focus { top: 12px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4em;
  min-height: 52px; padding: .55em 1.4em;
  font-family: var(--font-display); font-weight: 800; font-size: 1.25rem; line-height: 1.1;
  text-decoration: none; border: 0; border-radius: 999px; cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, background-color .15s ease;
}
.btn-primary { background: #e8452f; color: #fff; box-shadow: 0 6px 0 #a8301f; text-shadow: 0 1px 0 rgba(0,0,0,.15); }
.btn-primary:hover { background: #f05a44; transform: translateY(-2px); box-shadow: 0 8px 0 #a8301f; }
.btn-primary:active { transform: translateY(3px); box-shadow: 0 3px 0 #a8301f; }
.btn-xl { font-size: clamp(1.35rem, 2.4vw, 1.7rem); min-height: 66px; padding: .6em 1.6em; }
.btn-block { width: 100%; }
.btn-small { min-height: 46px; font-size: 1.1rem; padding: .45em 1.15em; }
.btn-ghost { background: #fff; color: var(--navy); box-shadow: inset 0 0 0 3px var(--navy), 0 4px 0 rgba(27,42,74,.25); }
.btn-ghost:hover { background: var(--sky-pale); }
.btn-small:not(.btn-ghost) { background: var(--purple-dark); color: #fff; box-shadow: 0 5px 0 #3d1a99; }
.btn-small:not(.btn-ghost):hover { transform: translateY(-2px); }
.btn-card { align-self: start; background: var(--subject-dark, var(--purple-dark)); color: #fff; box-shadow: 0 5px 0 rgba(0,0,0,.25); font-size: 1.15rem; min-height: 50px; }
.btn-card:hover { transform: translateY(-2px); }

.back-link { display: inline-flex; align-items: center; gap: .35em; margin-bottom: .8rem; text-decoration: none; color: var(--navy); background: #fff; border-radius: 999px; padding: .35em .9em; box-shadow: var(--shadow-sm); min-height: 44px; }
.back-link:hover { background: var(--sky-pale); }

/* ---------- Panels ---------- */
.panel { background: var(--paper); border-radius: var(--radius); padding: clamp(1.1rem, 2.5vw, 1.8rem); box-shadow: var(--shadow); }
.panel-sun { background: #fff4cc; }

/* ---------- Header (signed in) ---------- */
.site-header { background: var(--sky); position: relative; z-index: 5; }
.header-inner { max-width: 1320px; margin: 0 auto; padding: .7rem clamp(1rem, 3vw, 2rem) .2rem; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: .55rem; text-decoration: none; color: #fff; font-family: var(--font-display); font-weight: 800; font-size: 1.3rem; line-height: 1; margin-right: auto; }
.brand-icon { width: 46px; height: 46px; background: #fff; border-radius: 50%; padding: 5px; box-shadow: 0 3px 0 var(--sky-deep); }
.brand-text { display: flex; flex-direction: column; text-shadow: 0 2px 0 var(--sky-deep); }
.brand-small { font-size: .85rem; font-weight: 700; opacity: .95; }
.main-nav ul { list-style: none; margin: 0; padding: 0; display: flex; gap: .45rem; flex-wrap: wrap; }
.nav-link { display: inline-flex; align-items: center; min-height: 48px; padding: .35em 1em; border-radius: 999px; background: rgba(255,255,255,.92); color: var(--navy); text-decoration: none; font-family: var(--font-display); font-weight: 700; font-size: 1.12rem; box-shadow: 0 4px 0 var(--sky-deep); }
.nav-link:hover { background: #fff; transform: translateY(-1px); }
.nav-link[aria-current] { background: var(--sun); box-shadow: 0 4px 0 #d89a00; }
.signout-form { margin: 0; }
.signout-btn { background: transparent; color: #fff; border: 2px solid rgba(255,255,255,.8); border-radius: 999px; padding: .35em .9em; min-height: 44px; font: 700 .95rem var(--font-body); cursor: pointer; }
.signout-btn:hover { background: rgba(255,255,255,.18); }
.garland { height: 34px; margin-bottom: -26px; position: relative; overflow: hidden; }
.garland-svg { width: 100%; height: 70px; }

/* ---------- Footer ---------- */
.site-footer { background: #145c36; color: #fff; text-align: center; padding: 1.2rem 1rem 1.4rem; font-size: .95rem; margin-top: 3rem; }
.site-footer p { max-width: 760px; margin: 0 auto; }
.page-landing .site-footer { margin-top: 0; }

/* ---------- Landing ---------- */
.hero { position: relative; min-height: min(100vh, 980px); min-height: min(100svh, 980px); overflow: hidden; background: var(--sky); }
.hero-art { position: absolute; inset: 0; }
.hero-art .scene-svg { width: 100%; height: 100%; }
.hero-card {
  position: absolute; left: clamp(1rem, 5vw, 5rem); top: 42%; transform: translateY(-50%);
  width: min(500px, 40vw); background: rgba(255, 253, 247, .96); border-radius: 30px;
  padding: clamp(1.4rem, 2.6vw, 2.3rem); box-shadow: 0 10px 0 rgba(27,42,74,.12), 0 24px 50px rgba(15, 60, 110, .25);
  border: 5px solid #fff;
}
.hero-kicker { display: inline-block; background: var(--turquoise); color: var(--navy); font-weight: 800; border-radius: 999px; padding: .15em .9em; margin-bottom: .7rem; font-size: 1rem; }
.hero-title { font-size: clamp(2.2rem, 4.4vw, 3.6rem); color: var(--navy); margin-bottom: .25em; }
.hero-tagline { font-size: clamp(1.15rem, 1.7vw, 1.35rem); margin-bottom: 1.3rem; }
.hero-note { margin-top: 1rem; font-weight: 700; color: var(--leaf-dark); }
.intro { background: linear-gradient(180deg, #34b04a 0, #2aa046 40px, #e9f9e4 40px); padding: 0 1rem 3rem; }
.intro-inner { max-width: 980px; margin: 0 auto; display: grid; grid-template-columns: 240px 1fr; gap: 2rem; align-items: center; padding-top: 1rem; }
.intro-portrait .portrait-svg { width: 100%; height: auto; filter: drop-shadow(0 8px 0 rgba(27,42,74,.12)); }

/* ---------- Sign in ---------- */
.signin { max-width: 1060px; margin: 0 auto; padding: clamp(1.5rem, 5vw, 4rem) 1rem; display: grid; grid-template-columns: 1fr 1.05fr; gap: clamp(1.5rem, 4vw, 3rem); align-items: center; }
.page-signin main { background: radial-gradient(ellipse at 20% 30%, #c9f0ff 0, transparent 60%), linear-gradient(180deg, #8fd6ff 0, #c8ecff 60%, #9fe08a 60%, #7bd06a 100%); }
.door-svg { width: 100%; max-width: 420px; margin: 0 auto; height: auto; filter: drop-shadow(0 12px 0 rgba(27,42,74,.12)); }
.signin-panel h1 { margin-top: .2rem; }
.field { margin-bottom: 1.1rem; }
.field label { display: block; font-weight: 800; margin-bottom: .3rem; }
.field input { width: 100%; min-height: 56px; font: inherit; font-size: 1.2rem; padding: .5em .8em; border: 3px solid #9fb0cc; border-radius: 14px; background: #fff; color: var(--navy); }
.field input:focus { border-color: var(--purple-dark); outline: 3px solid #c8b4ff; outline-offset: 1px; }
.password-wrap { position: relative; }
.password-wrap input { padding-right: 5.2rem; }
.show-password { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); min-height: 40px; padding: 0 .8em; border-radius: 10px; border: 0; background: var(--sky-pale); color: var(--navy); font: 800 .95rem var(--font-body); cursor: pointer; }
.form-message { padding: .8rem 1rem; border-radius: 14px; margin-bottom: 1rem; font-weight: 700; border-left: 8px solid; }
.form-error { background: #ffe9e5; border-color: var(--coral-dark); color: #7a1b0e; }
.form-info { background: #e3f5ff; border-color: var(--sky-deep); }
.form-help { margin-top: 1rem; color: var(--muted); }
button[disabled] { opacity: .75; cursor: progress; }

/* ---------- Treehouse home ---------- */
.canopy { max-width: 1600px; margin: 0 auto; padding: 0; }
/* Welcome heading stays in the page for screen readers; the scene sits right under the garland */
.canopy-heading { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.scene { position: relative; }
.canopy-scene { aspect-ratio: 16 / 9; margin: 0 auto; max-width: 1600px; border-radius: 0; overflow: hidden; }
.canopy-scene .scene-svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.branches { list-style: none; margin: 0; padding: 0; }
.branch { position: absolute; display: block; border-radius: 28px; text-decoration: none; color: var(--navy); }
.branch-item { display: contents; }
.branch-reading { left: 5.6%; top: 36.7%; width: 26.3%; height: 37.8%; }
.branch-math { left: 37.5%; top: 24.4%; width: 25%; height: 37.8%; }
.branch-discovery { left: 69.4%; top: 33.3%; width: 25.6%; height: 37.8%; }
.branch-art { display: none; }
.branch::before { content: ''; position: absolute; inset: -2%; border-radius: 28px; border: 5px dashed transparent; transition: border-color .15s, background-color .15s; }
@media (hover: hover) { .branch:hover::before { border-color: rgba(255,255,255,.95); background: rgba(255,255,255,.14); } }
.branch:focus-visible { outline: none; }
.branch:focus-visible::before { border: 6px solid var(--focus); background: rgba(255,255,255,.18); box-shadow: 0 0 0 4px #fff; }
.branch-sign {
  position: absolute; left: 50%; bottom: -9%; transform: translateX(-50%);
  white-space: nowrap; background: var(--wood-light); border: 4px solid var(--wood-dark);
  border-radius: 16px; padding: .2em .9em; box-shadow: 0 5px 0 var(--wood-dark);
  font-family: var(--font-display); font-weight: 800; font-size: clamp(1rem, 1.9vw, 1.7rem); color: var(--navy);
  transition: transform .15s;
}
.branch-sign::before, .branch-sign::after { content: ''; position: absolute; top: 50%; width: 9px; height: 9px; margin-top: -4px; border-radius: 50%; background: var(--wood-dark); }
.branch-sign::before { left: 7px; } .branch-sign::after { right: 7px; }
.branch:hover .branch-sign, .branch:focus-visible .branch-sign { transform: translateX(-50%) translateY(-4px) scale(1.05); background: var(--sun); }
.scene-room { transition: transform .2s ease; transform-box: fill-box; }
.canopy-scene:has(.branch-reading:is(:hover, :focus-visible)) #scene-reading,
.canopy-scene:has(.branch-math:is(:hover, :focus-visible)) #scene-math,
.canopy-scene:has(.branch-discovery:is(:hover, :focus-visible)) #scene-discovery { filter: brightness(1.08) drop-shadow(0 0 14px rgba(255,255,255,.9)); }

.friends { position: absolute; inset: 0; pointer-events: none; }
.friends > * { pointer-events: auto; }
.friend-squirrel { position: absolute; left: 61.5%; top: 64.5%; width: 6.5%; }
.squirrel-btn, .acorn-btn, .chime-btn { background: none; border: 0; padding: 0; cursor: pointer; border-radius: 16px; }
.squirrel-btn { width: 100%; display: block; }
.squirrel-btn svg { width: 100%; height: auto; transition: transform .2s; }
.squirrel-btn:hover svg { transform: rotate(-4deg) scale(1.06); }
.bubble {
  position: absolute; bottom: 100%; right: 30%; margin-bottom: 8px; width: max-content; max-width: min(300px, 70vw);
  background: #fff; color: var(--navy); border: 4px solid var(--navy); border-radius: 18px; padding: .55em .9em;
  font-weight: 800; font-size: 1.05rem; line-height: 1.35; box-shadow: var(--shadow-sm); z-index: 3;
}
.bubble::after { content: ''; position: absolute; right: 16px; bottom: -14px; border: 10px solid transparent; border-top-color: var(--navy); border-bottom: 0; }
.acorn-btn { position: absolute; left: 68%; top: 68.5%; width: 3.2%; min-width: 44px; }
.acorn-btn svg { width: 100%; height: auto; }
.acorn-btn:hover svg { transform: rotate(10deg); }
.chime-btn { position: absolute; left: 16.2%; top: 8.5%; width: 5.4%; height: 12%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; }
.chime-btn .chime-icon { display: none; }
.chime-label { background: #fff; color: var(--navy); border-radius: 999px; padding: .1em .6em; font-weight: 800; font-size: .85rem; white-space: nowrap; transform: translateY(70%); box-shadow: var(--shadow-sm); }

.board {
  max-width: 1200px; margin: -2.5rem auto 0; position: relative; z-index: 2; padding: 1.4rem;
  background: var(--wood); border: 8px solid var(--wood-dark); border-radius: 26px; box-shadow: var(--shadow);
  display: grid; grid-template-columns: 1.2fr 1.2fr .9fr; gap: 1.2rem;
  background-image: repeating-linear-gradient(90deg, rgba(255,255,255,.06) 0 40px, rgba(0,0,0,.04) 40px 80px);
}
.note { background: var(--paper); border-radius: 14px; padding: 1.1rem 1.2rem 1.2rem; position: relative; box-shadow: 0 5px 0 rgba(0,0,0,.18); }
.note::before { content: ''; position: absolute; top: -10px; left: 50%; margin-left: -18px; width: 36px; height: 18px; border-radius: 6px; background: var(--turquoise); box-shadow: 0 3px 0 #13908b; }
.note-try { background: #fff4cc; }
.note-try::before { background: var(--coral); box-shadow: 0 3px 0 var(--coral-dark); }
.note-sound::before { background: var(--purple); box-shadow: 0 3px 0 var(--purple-dark); }
.note-title { font-size: 1.35rem; }
.note-sign { font-family: var(--font-display); font-weight: 700; font-size: 1.2rem; color: var(--purple-dark); }
.try-badge { display: inline-block; background: var(--coral-dark); color: #fff; border-radius: 999px; padding: 0 .55em; font-size: .9rem; vertical-align: .2em; }

/* ---------- Page sections ---------- */
.page-section, .subject, .activity { max-width: 1120px; margin: 0 auto; padding: 2.4rem clamp(1rem, 3vw, 2rem) 0; }
.page-head { margin-bottom: 1.4rem; }
.section-title { margin-top: 2rem; }

.filters ul { list-style: none; padding: 0; margin: 0 0 1.5rem; display: flex; gap: .6rem; flex-wrap: wrap; }
.filter { display: inline-flex; align-items: center; min-height: 50px; padding: .35em 1.2em; border-radius: 999px; background: #fff; color: var(--navy); text-decoration: none; font-family: var(--font-display); font-weight: 800; font-size: 1.15rem; box-shadow: inset 0 0 0 3px #c9d4e6, var(--shadow-sm); }
.filter:hover { box-shadow: inset 0 0 0 3px var(--navy), var(--shadow-sm); }
.filter[aria-current] { background: var(--navy); color: #fff; box-shadow: var(--shadow-sm); }
.filter[aria-current]::before { content: '\2713'; margin-right: .4em; }

.activity-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 1.4rem; }
.activity-card { --subject: var(--purple); --subject-dark: var(--purple-dark); --subject-tint: #efe8ff; display: flex; flex-direction: column; gap: 1rem; background: var(--paper); border-radius: var(--radius); padding: 1.3rem; box-shadow: var(--shadow); border-top: 12px solid var(--subject); }
.subject-reading { --subject: var(--reading); --subject-dark: var(--reading-dark); --subject-tint: var(--reading-tint); }
.subject-math { --subject: var(--math); --subject-dark: var(--math-dark); --subject-tint: var(--math-tint); }
.subject-discovery { --subject: var(--discovery); --subject-dark: var(--discovery-dark); --subject-tint: var(--discovery-tint); }
.card-icon { width: 84px; height: 84px; padding: 10px; border-radius: 22px; background: var(--subject-tint, #efe8ff); }
.card-body { flex: 1; }
.card-subject { font-weight: 800; color: var(--subject-dark, var(--purple-dark)); text-transform: none; margin-bottom: .2rem; font-size: 1rem; }
.card-title { font-size: 1.6rem; margin-bottom: .3rem; }
.card-tag { display: inline-block; background: #fff4cc; border: 2px solid #e8b400; border-radius: 999px; padding: .05em .7em; font-weight: 800; font-size: .95rem; }
.empty-state { display: flex; gap: 1rem; align-items: center; }
.empty-icon { width: 64px; flex: none; }

/* Subject pages */
.subject-hero { display: grid; grid-template-columns: 1fr 1.1fr; gap: 2rem; align-items: center; border-radius: 30px; padding: 1.5rem; background: linear-gradient(180deg, #7dccff 0, #bfe9ff 70%, #8fdc6f 70%); box-shadow: var(--shadow); }
.theme-reading .subject-hero { background: linear-gradient(180deg, #a98cff 0, #d9ccff 72%, #8fdc6f 72%); }
.theme-math .subject-hero { background: linear-gradient(180deg, #ffb26b 0, #ffe0a8 72%, #8fdc6f 72%); }
.theme-discovery .subject-hero { background: linear-gradient(180deg, #47d6d0 0, #b6f2ee 72%, #8fdc6f 72%); }
.subject-art .room-svg { width: 100%; height: auto; filter: drop-shadow(0 10px 0 rgba(27,42,74,.15)); }

/* Activity pages */
.activity-title-row { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.activity-icon { width: 92px; height: 92px; flex: none; padding: 12px; border-radius: 24px; background: var(--subject-tint); box-shadow: var(--shadow-sm); }
.activity-intro { margin-bottom: 1rem; }
.print-action { margin: 1rem 0 0; }
.steps { list-style: none; margin: 1.6rem 0 0; padding: 0; display: grid; gap: 1rem; counter-reset: s; }
.step { display: flex; gap: 1rem; align-items: flex-start; background: var(--paper); border-radius: var(--radius); padding: 1.2rem 1.4rem; box-shadow: var(--shadow); border-left: 10px solid var(--subject); flex-wrap: wrap; }
.step > div { flex: 1; min-width: 200px; }
.step-num { flex: none; width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; background: var(--subject-dark); color: #fff; font-family: var(--font-display); font-weight: 800; font-size: 1.6rem; }
.step-title { font-size: 1.45rem; margin: .45rem 0 .2rem; font-family: var(--font-display); font-weight: 800; }
.steps-reveal .step { display: block; padding: 0; }
.reveal summary { list-style: none; display: flex; align-items: center; gap: 1rem; padding: 1rem 1.3rem; cursor: pointer; min-height: 76px; border-radius: var(--radius); }
.reveal summary::-webkit-details-marker { display: none; }
.reveal summary .step-title { margin: 0; flex: 1; }
.reveal-hint { flex: none; background: var(--subject-tint); color: var(--subject-dark); border-radius: 999px; padding: .2em .9em; font-weight: 800; }
.reveal[open] .reveal-hint::after { content: 'ed'; }
.reveal summary:hover { background: var(--subject-tint); }
.reveal p { padding: 0 1.4rem 1.3rem calc(1.3rem + 52px + 1rem); font-size: 1.2rem; }
.closing { margin-top: 1.4rem; font-family: var(--font-display); font-size: 1.4rem; font-weight: 700; text-align: center; background: #fff4cc; }
.print-lines, .print-footer { display: none; }

/* Ten-frame */
.tenframe-panel { margin-top: 1.6rem; text-align: center; }
.tenframe { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0; max-width: 640px; margin: 0 auto 1.2rem; border: 6px solid var(--navy); border-radius: 18px; overflow: hidden; background: var(--navy); gap: 6px; }
.tf-cell { aspect-ratio: 1; background: #fff; border: 0; cursor: pointer; display: grid; place-items: center; padding: 0; min-height: 56px; transition: background-color .12s; }
.tf-cell:hover { background: var(--math-tint); }
.tf-cell:focus-visible { outline: 5px solid var(--focus); outline-offset: -8px; border-radius: 0; }
.tf-counter { width: 68%; height: 68%; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #ff9a8a 0, var(--coral) 45%, var(--coral-dark) 100%); transform: scale(0); transition: transform .18s cubic-bezier(.3, 1.6, .6, 1); }
.tf-cell[aria-pressed="true"] .tf-counter { transform: scale(1); }
.tf-status { display: flex; justify-content: center; gap: 1rem 2.5rem; flex-wrap: wrap; font-family: var(--font-display); font-weight: 800; font-size: 1.6rem; }
.tf-num { display: inline-block; min-width: 1.6em; background: var(--navy); color: #fff; border-radius: 12px; padding: 0 .3em; }
.tf-count, .tf-need { margin: 0; }
.tf-message { font-size: 1.3rem; font-weight: 800; color: var(--leaf-dark); min-height: 1.6em; margin: .8rem 0 1rem; }
.tf-help { color: var(--muted); font-size: 1rem; margin-top: 1rem; }

/* Family + Meet */
.family-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.4rem; }
.tick-list, .idea-list, .link-list { padding-left: 1.2rem; margin: 0 0 .6rem; }
.tick-list li, .idea-list li, .link-list li { margin-bottom: .55rem; }
.meet-hero { display: grid; grid-template-columns: 260px 1fr; gap: 2rem; align-items: center; margin-bottom: 1.6rem; }
.meet-portrait .portrait-svg, .teacher-photo { width: 100%; height: auto; border-radius: 50%; }
.highlights { list-style: none; padding: 0; margin: 0 0 1.6rem; display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.4rem; }
.highlight-icon { display: block; width: 76px; height: 76px; padding: 10px; border-radius: 22px; background: var(--sky-pale); margin-bottom: .6rem; }
.highlight:nth-child(1) .highlight-icon { background: var(--reading-tint); }
.highlight:nth-child(2) .highlight-icon { background: var(--discovery-tint); }
.highlight:nth-child(3) .highlight-icon { background: #e6f9d8; }
.meet .closing, .family .closing { margin-top: 1.4rem; }
.meet > .panel + .panel { margin-top: 0; }

/* Error */
.error-panel { text-align: center; max-width: 640px; margin: 1rem auto; }
.error-art { display: block; width: 130px; margin: 0 auto .5rem; }

/* ---------- Motion (only when the visitor allows it) ---------- */
@media (prefers-reduced-motion: no-preference) {
  .canopy-sway { transform-box: fill-box; transform-origin: 50% 100%; animation: sway 7s ease-in-out infinite alternate; }
  .cloud-a { animation: drift 60s linear infinite alternate; }
  .cloud-b { animation: drift 75s linear infinite alternate-reverse; }
  .cloud-c { animation: drift 90s linear infinite alternate; }
  .bird-fly { animation: fly 26s linear infinite; }
  .bird-wing { transform-box: fill-box; transform-origin: 80% 100%; animation: flap .35s ease-in-out infinite alternate; }
  .squirrel-peek { animation: peek 14s ease-in-out infinite; }
  .teacher-wave { animation: wave 4.5s ease-in-out infinite; }
  .gear-a { animation: spin 14s linear infinite; }
  .gear-b { animation: spin 9s linear infinite reverse; }
  .page-treehouse .canopy-scene { animation: rise .55s ease-out both; }
  .squirrel-btn.hop svg { animation: hop .7s ease-out; }
  .squirrel-btn.flip svg { animation: flip .9s ease-in-out; }
  .acorn-btn.toss svg { animation: toss .7s ease-out; }
  .chime-art.ringing .chime-tube { animation: ring .9s ease-in-out; }
  .chime-art.ringing .chime-tube:nth-child(odd) { animation-delay: .08s; }
  .chime-btn.ringing .chime-icon svg { animation: jiggle .9s ease-in-out; }
  .reveal[open] p { animation: fadeUp .25s ease-out; }
}
@keyframes sway { from { transform: rotate(-0.6deg); } to { transform: rotate(0.6deg); } }
@keyframes drift { from { translate: -40px 0; } to { translate: 60px 0; } }
@keyframes fly { 0% { translate: 0 0; } 40% { translate: 1900px -60px; } 100% { translate: 1900px -60px; } }
@keyframes flap { from { transform: scaleY(1); } to { transform: scaleY(-.6); } }
@keyframes peek { 0%, 60%, 100% { translate: -80px 0; } 68%, 88% { translate: 0 0; } }
@keyframes wave { 0%, 55%, 100% { rotate: 0deg; } 62% { rotate: -14deg; } 70% { rotate: 8deg; } 78% { rotate: -12deg; } 86% { rotate: 4deg; } }
@keyframes spin { to { rotate: 360deg; } }
@keyframes rise { from { opacity: 0; transform: translateY(40px); } to { opacity: 1; transform: none; } }
@keyframes hop { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-22%); } 70% { transform: translateY(0) scaleY(.92); } }
@keyframes flip { 0% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-35%) rotate(-180deg); } 100% { transform: translateY(0) rotate(-360deg); } }
@keyframes toss { 0% { transform: none; } 50% { transform: translate(-60%, -90%) rotate(-200deg); } 100% { transform: none; } }
@keyframes ring { 0%, 100% { rotate: 0deg; } 25% { rotate: 9deg; } 50% { rotate: -8deg; } 75% { rotate: 5deg; } }
@keyframes jiggle { 0%, 100% { transform: none; } 30% { transform: rotate(8deg); } 60% { transform: rotate(-6deg); } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Tablet ---------- */
@media (max-width: 1080px) {
  .board { grid-template-columns: 1fr 1fr; margin: 1.4rem 1rem 0; }
  .note-sound { grid-column: 1 / -1; }
  .highlights { grid-template-columns: 1fr; }
  .highlight { display: grid; grid-template-columns: 76px 1fr; column-gap: 1rem; }
  .highlight-icon { grid-row: span 2; }
  .header-inner { justify-content: center; }
  .brand { margin-right: 0; flex-basis: 100%; justify-content: center; }
}

/* ---------- Phone / small tablet: treehouse becomes a stack of big branch cards ---------- */
@media (max-width: 820px) {
  body { font-size: 1.1rem; }
  .hero { min-height: 0; display: flex; flex-direction: column; background: linear-gradient(180deg, #2fa8f0, #9fe0ff); }
  .hero-card { position: relative; left: auto; top: auto; transform: none; width: auto; margin: 1rem 1rem 0; text-align: center; z-index: 2; order: -1; padding: 1.2rem 1.1rem 1.4rem; }
  .hero-title { font-size: clamp(2rem, 9vw, 2.6rem); }
  .hero-art { position: relative; inset: auto; aspect-ratio: 5 / 4; margin-top: -1.5rem; overflow: hidden; }
  .hero-art .scene-svg { width: 125%; transform: translateX(-20%); }
  .intro-inner { grid-template-columns: 1fr; text-align: center; }
  .intro-portrait { max-width: 200px; margin: 0 auto; }

  .signin { grid-template-columns: 1fr; }
  .signin-art { max-width: 260px; margin: 0 auto; order: -1; }

  .canopy-scene { aspect-ratio: auto; background: linear-gradient(180deg, #2fa8f0 0, #9fe0ff 100%); padding: 2.4rem .8rem 1.4rem; border-radius: 0; }
  .canopy-scene .scene-svg { display: none; }
  /* Compact room selector: picture left, wooden sign right, so all three rooms fit near the top */
  .branches { display: grid; gap: .8rem; padding-top: 0; }
  .branch-item { display: block; }
  .branch { position: relative; left: auto; top: auto; width: auto; height: auto; display: grid; grid-template-columns: clamp(120px, 38vw, 220px) 1fr; align-items: center; gap: .6rem; background: rgba(255,255,255,.35); border-radius: 22px; padding: .45rem .8rem .45rem .45rem; min-height: 112px; box-shadow: 0 5px 0 rgba(15,60,110,.2); }
  .branch-art { display: block; }
  .branch-art .room-svg { width: 100%; height: auto; }
  .branch-sign { position: relative; left: auto; bottom: auto; transform: none; justify-self: center; font-size: clamp(1.15rem, 5vw, 1.6rem); line-height: 1.1; white-space: normal; text-align: center; padding: .3em 1.15em; }
  .branch:hover .branch-sign, .branch:focus-visible .branch-sign { transform: translateY(-3px); }
  .branch::before { inset: 0; }

  .friends { position: relative; inset: auto; display: flex; align-items: flex-end; justify-content: center; gap: 1rem; margin-top: 1.4rem; flex-wrap: wrap; }
  .friend-squirrel, .acorn-btn, .chime-btn { position: relative; left: auto; top: auto; }
  .friend-squirrel { width: 110px; }
  .bubble { right: auto; left: 0; bottom: 100%; max-width: min(280px, 80vw); }
  .bubble::after { right: auto; left: 40px; }
  .acorn-btn { width: 58px; }
  .chime-btn { width: auto; height: auto; flex-direction: row; gap: .4rem; background: #fff; border-radius: 999px; padding: .3rem .9rem .3rem .4rem; box-shadow: var(--shadow-sm); min-height: 56px; }
  .chime-btn .chime-icon { display: block; width: 44px; }
  .chime-label { transform: none; box-shadow: none; padding: 0; font-size: 1.05rem; }

  .board { grid-template-columns: 1fr; margin: 1.4rem 1rem 0; border-width: 6px; padding: 1.2rem 1rem; }
  .subject-hero, .meet-hero, .family-grid { grid-template-columns: 1fr; }
  .subject-art { max-width: 380px; margin: 0 auto; }
  .meet-portrait { max-width: 220px; margin: 0 auto; }
  .reveal p { padding-left: 1.3rem; }
  /* Compact header: brand + Sign out share a row, nav is a labeled 2x2 grid of 44px pills */
  .header-inner { justify-content: space-between; gap: .5rem; padding: .5rem .75rem .3rem; }
  .brand { flex-basis: auto; margin-right: 0; justify-content: flex-start; font-size: 1.1rem; gap: .45rem; }
  .brand-icon { width: 38px; height: 38px; padding: 4px; }
  .brand-small { font-size: .75rem; }
  .signout-form { order: 1; }
  .signout-btn { min-height: 44px; padding: .25em .9em; font-size: .9rem; }
  .main-nav { order: 2; width: 100%; }
  .main-nav ul { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; width: 100%; }
  .nav-link { justify-content: center; width: 100%; min-height: 44px; padding: .2em .6em; font-size: 1rem; line-height: 1.1; text-align: center; box-shadow: 0 3px 0 var(--sky-deep); }
  .nav-link[aria-current] { box-shadow: 0 3px 0 #d89a00; }
}
@media (max-width: 380px) {
  .tf-status { font-size: 1.3rem; }
  .activity-grid { grid-template-columns: 1fr; }
}

/* ---------- Game spotlight card (subject pages) ---------- */
.spotlight { display: grid; grid-template-columns: 1.15fr 1fr; gap: 1.5rem; align-items: center; margin-top: 2rem; padding: 1.2rem; border-radius: 30px; background: #fff4cc; border: 6px solid var(--wood); box-shadow: var(--shadow); }
.spotlight-art { border-radius: 22px; overflow: hidden; box-shadow: var(--shadow-sm); }
.spotlight-art svg { width: 100%; height: auto; }
.spotlight-kicker { display: inline-block; background: var(--coral-dark); color: #fff; border-radius: 999px; padding: .05em .8em; font-weight: 800; margin-bottom: .5rem; }
.spotlight h2 { font-size: clamp(1.8rem, 3.4vw, 2.5rem); }
@media (max-width: 820px) { .spotlight { grid-template-columns: 1fr; text-align: center; } }
