/* ---------- 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) ---------- */
/* The header is a band of leaves; the brand and buttons sit inside it on a branch. */
.site-header { position: relative; z-index: 5; background: transparent; }
.header-canopy { position: absolute; left: 0; right: 0; top: 0; height: calc(100% + 54px); pointer-events: none; overflow: hidden; filter: drop-shadow(0 6px 6px rgba(15, 80, 40, .25)); }
.header-canopy-svg { width: 100%; height: 100%; }
.header-inner { position: relative; max-width: 1320px; margin: 0 auto; padding: .6rem clamp(1rem, 3vw, 2rem) .55rem; 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 #0b5a31; transition: transform .2s; }
.brand:hover .brand-icon { transform: rotate(-8deg) scale(1.06); }
.brand-text { display: flex; flex-direction: column; text-shadow: 0 2px 0 #0b5a31, 0 0 8px rgba(5, 60, 30, .5); }
.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 { position: relative; display: inline-flex; align-items: center; min-height: 48px; padding: .35em 1em; border-radius: 999px; background: #fffdf2; color: var(--navy); text-decoration: none; font-family: var(--font-display); font-weight: 700; font-size: 1.12rem; box-shadow: 0 4px 0 #0b5a31, 0 6px 10px rgba(5, 50, 25, .3); transition: transform .15s ease, background-color .15s; }
/* A small leaf tucked on each button */
.nav-link::after { content: ''; position: absolute; top: -6px; right: 10px; width: 14px; height: 9px; background: var(--lime); border-radius: 0 100% 0 100%; transform: rotate(-20deg); box-shadow: inset -2px -1px 0 rgba(0,0,0,.12); transition: transform .25s; }
.nav-link:hover { background: #fff; transform: translateY(-2px); }
.nav-link:hover::after { transform: rotate(-50deg) translateY(-2px); }
.nav-link[aria-current] { background: var(--sun); box-shadow: 0 4px 0 #b57f00, 0 6px 10px rgba(5, 50, 25, .3); }
.nav-link[aria-current]::after { background: #ff8a3c; }
.signout-form { margin: 0; }
.signout-btn { background: rgba(5, 60, 30, .35); color: #fff; border: 2px solid rgba(255,255,255,.85); border-radius: 999px; padding: .35em .9em; min-height: 44px; font: 700 .95rem var(--font-body); cursor: pointer; }
.signout-btn:hover { background: rgba(5, 60, 30, .55); }
/* Pages start a little lower so the hanging leaves don't cover their first line */
.page-subject main, .page-activities main, .page-family main, .page-meet main, .page-activity main { padding-top: .6rem; }

/* ---------- 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, .intro-portrait .teacher-photo { display: block; 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; }
/* Wide screens: the header floats over the top of the treehouse so the leaves blend into the scene */
@media (min-width: 821px) {
  .page-treehouse .site-header { position: absolute; top: 0; left: 0; right: 0; }
  .page-treehouse .header-canopy { filter: drop-shadow(0 4px 4px rgba(15, 80, 40, .2)); }
  .page-treehouse .canopy-scene { margin-top: 0; }
}

.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 (deck) pages: a slim banner, then every game as a tile */
.subject { padding-top: .9rem; }
.deck-banner { position: relative; display: grid; grid-template-columns: auto 1fr auto; gap: 1.2rem; align-items: center; border-radius: 26px; padding: .3rem 1.2rem .55rem .6rem; background: linear-gradient(180deg, #7dccff 0, #bfe9ff 74%, #8fdc6f 74%); box-shadow: var(--shadow); overflow: hidden; }
.theme-reading .deck-banner { background: linear-gradient(100deg, #a98cff 0, #d9ccff 55%, #efe8ff 100%); }
.theme-math .deck-banner { background: linear-gradient(100deg, #ffb26b 0, #ffe0a8 55%, #fff1d9 100%); }
.theme-discovery .deck-banner { background: linear-gradient(100deg, #47d6d0 0, #b6f2ee 55%, #e3fbf9 100%); }
.deck-banner::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 12px; background: repeating-linear-gradient(90deg, var(--leaf) 0 22px, var(--lime) 22px 44px); opacity: .9; }
.deck-art { width: clamp(120px, 12vw, 160px); }
.deck-art .room-svg { width: 100%; height: auto; filter: drop-shadow(0 6px 0 rgba(27,42,74,.15)); }
.deck-text h1 { font-size: clamp(1.8rem, 3vw, 2.3rem); margin: 0; }
.deck-intro { margin: 0; font-size: 1.05rem; line-height: 1.4; max-width: 60ch; }
.deck-banner .back-link { margin: 0; }
.deck-pick { display: flex; align-items: baseline; gap: .7rem; flex-wrap: wrap; margin: .9rem 0 .7rem; font-size: clamp(1.4rem, 2.4vw, 1.75rem); }
.deck-count { font-family: var(--font-body); font-size: 1rem; font-weight: 800; color: #fff; background: var(--subject-dark, var(--purple-dark)); border-radius: 999px; padding: .05em .8em; }
.subject-reading .deck-count { background: var(--reading-dark); }
.subject-math .deck-count { background: var(--math-dark); }
.subject-discovery .deck-count { background: var(--discovery-dark); }

.tiles { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 330px)); justify-content: start; gap: 1.2rem; }
.tile-link { display: flex; flex-direction: column; height: 100%; background: var(--paper); border-radius: var(--radius); overflow: hidden; text-decoration: none; color: var(--navy); font-weight: 400; box-shadow: 0 6px 0 var(--subject-dark), 0 14px 26px rgba(27,42,74,.14); border: 4px solid var(--subject); transition: transform .18s ease, box-shadow .18s ease; }
.tile-link:hover { transform: translateY(-5px) rotate(-.4deg); box-shadow: 0 10px 0 var(--subject-dark), 0 20px 32px rgba(27,42,74,.18); }
.tile-link:active { transform: translateY(2px); box-shadow: 0 3px 0 var(--subject-dark); }
.tile-link:focus-visible { outline: 5px solid var(--focus); outline-offset: 4px; border-radius: var(--radius); }
.tile-art { position: relative; display: block; aspect-ratio: 2 / 1; overflow: hidden; background: var(--subject-tint); }
.tile-art > svg { width: 100%; height: 100%; transition: transform .35s ease; }
.tile-link:hover .tile-art > svg, .tile-link:hover .tile-icon { transform: scale(1.06); }
.tile-badge { position: absolute; top: 10px; left: 10px; background: var(--coral-dark); color: #fff; border-radius: 999px; padding: .05em .75em; font-weight: 800; font-size: .9rem; box-shadow: 0 3px 0 rgba(0,0,0,.2); }
.tile-icon-art { position: absolute; inset: 0; display: grid; place-items: center; background: radial-gradient(circle at 50% 120%, #fff 0, transparent 60%), var(--subject-tint); }
.tile-icon { width: 34%; aspect-ratio: 1; padding: 6%; border-radius: 28px; background: #fff; box-shadow: 0 6px 0 rgba(27,42,74,.12); transition: transform .35s ease; }
.tile-icon svg { width: 100%; height: 100%; }
.tile-bubble { position: absolute; border-radius: 50%; background: var(--subject); opacity: .22; }
.tile-bubble-a { width: 22%; aspect-ratio: 1; left: 8%; top: 14%; }
.tile-bubble-b { width: 12%; aspect-ratio: 1; right: 12%; top: 10%; }
.tile-bubble-c { width: 16%; aspect-ratio: 1; right: 18%; bottom: 8%; }
.tile-body { flex: 1; display: flex; flex-direction: column; gap: .15rem; padding: .7rem 1rem 1rem; }
.tile-kind { font-weight: 800; font-size: .9rem; color: var(--subject-dark); }
.tile-title { font-family: var(--font-display); font-weight: 800; font-size: 1.4rem; line-height: 1.15; }
.tile-summary { font-size: 1rem; line-height: 1.4; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-bottom: .6rem; }
.tile-go { margin-top: auto; align-self: flex-start; display: inline-flex; align-items: center; gap: .45em; min-height: 46px; padding: .3em 1.2em; border-radius: 999px; background: var(--subject-dark); color: #fff; font-family: var(--font-display); font-weight: 800; font-size: 1.15rem; box-shadow: 0 4px 0 rgba(0,0,0,.25); }
.tile-game .tile-go { background: #e8452f; box-shadow: 0 4px 0 #a8301f; }
.tile-go-arrow { font-size: .8em; transition: transform .2s; }
.tile-link:hover .tile-go-arrow { transform: translateX(4px); }

/* 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 { display: block; width: 100%; height: auto; }
.meet-portrait .teacher-photo { filter: drop-shadow(0 8px 0 rgba(27,42,74,.12)); }
.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; }
  .hc-sway-a { animation: leafSway 6s ease-in-out infinite alternate; }
  .hc-sway-b { animation: leafSway 8s ease-in-out infinite alternate-reverse; }
  .hc-vine-a { animation: vineSwing 4.5s ease-in-out infinite alternate; }
  .hc-vine-b { animation: vineSwing 5.5s ease-in-out infinite alternate-reverse; }
  .falling-leaf { animation: leafFall 16s linear infinite; }
  .falling-leaf-2 { animation-duration: 21s; animation-delay: -7s; }
  .falling-leaf-3 { animation-duration: 25s; animation-delay: -15s; }
  .tile { animation: tileIn .5s cubic-bezier(.3, 1.4, .6, 1) both; animation-delay: calc(var(--i, 0) * 90ms + 80ms); }
  .tile-badge { animation: badgeWiggle 3.2s ease-in-out infinite; transform-origin: 20% 50%; }
  .deck-art { animation: bob 4s ease-in-out infinite alternate; }
  .tile-link:hover .tile-icon { animation: jiggle .7s ease-in-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 leafSway { from { translate: -4px 0; } to { translate: 4px 1px; } }
@keyframes vineSwing { from { rotate: -4deg; } to { rotate: 4deg; } }
@keyframes leafFall { 0% { translate: 0 -60px; rotate: 0deg; opacity: 0; } 6% { opacity: 1; } 50% { translate: 60px 420px; rotate: 200deg; } 90% { opacity: 1; } 100% { translate: -20px 900px; rotate: 380deg; opacity: 0; } }
@keyframes tileIn { from { opacity: 0; transform: translateY(18px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes badgeWiggle { 0%, 80%, 100% { rotate: 0deg; } 85% { rotate: -6deg; } 90% { rotate: 5deg; } 95% { rotate: -3deg; } }
@keyframes bob { from { translate: 0 0; } to { translate: 0 -5px; } }
@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; }
  .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; }
}


/* Short laptop windows: tighter tiles so the whole row of choices fits on the first screen */
@media (min-width: 821px) and (max-height: 760px) {
  .tile-summary { display: none; }
  .tile-body { display: grid; grid-template-columns: 1fr auto; align-items: center; column-gap: .8rem; padding: .55rem .9rem .75rem; }
  .tile-kind { grid-column: 1; }
  .tile-title { grid-column: 1; font-size: 1.3rem; }
  .tile-go { grid-column: 2; grid-row: 1 / span 2; margin: 0; align-self: center; }
}

/* ---------- Deck pages on phones: compact rows so every choice fits near the top ---------- */
@media (max-width: 820px) {
  .header-canopy { height: calc(100% + 18px); }
  .hc-vine { display: none; }
  .subject { padding-top: 1rem; }
  .deck-banner { grid-template-columns: 96px 1fr; gap: .7rem; padding: .4rem .8rem .7rem .4rem; }
  .deck-art { width: 96px; }
  .deck-text h1 { font-size: 1.6rem; }
  .deck-intro { font-size: .98rem; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .deck-banner .back-link { grid-column: 1 / -1; grid-row: 1; justify-self: start; margin-top: .2rem; min-height: 40px; font-size: 1rem; }
  .deck-pick { margin: .9rem 0 .6rem; }
  .tiles { grid-template-columns: 1fr; gap: .8rem; }
  .tile-link { flex-direction: row; align-items: stretch; border-width: 3px; }
  .tile-art { flex: 0 0 40%; aspect-ratio: auto; min-height: 112px; }
  .tile-art > svg { position: absolute; inset: 0; height: 100%; object-fit: cover; }
  .tile-badge { top: 6px; left: 6px; font-size: .78rem; }
  .tile-icon { width: 46%; }
  .tile-body { padding: .55rem .8rem .7rem; }
  .tile-title { font-size: 1.2rem; }
  .tile-summary { display: none; }
  .tile-go { min-height: 44px; font-size: 1.05rem; padding: .2em 1em; margin-top: .4rem; }
}
