@font-face {
  font-family: 'Fredoka';
  src: url('../fonts/fredoka-latin.woff2') format('woff2');
  font-weight: 300 700;
  font-display: swap;
}

:root {
  --ink: #3b2a5a;
  --ink-soft: #6c5a8e;
  --card: #ffffff;
  --lilac: #f3ecff;
  --lilac-2: #e2d5ff;
  --pink: #ff6fae;
  --violet: #8f6bff;
  --mint: #3fc6a0;
  --gold: #ffc93c;
  --shadow: 0 10px 30px rgba(91, 58, 140, 0.14);
  --shadow-sm: 0 4px 14px rgba(91, 58, 140, 0.12);
  --radius: 26px;
  --font: 'Fredoka', 'Nunito', 'Segoe UI Rounded', 'Segoe UI', system-ui, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background: linear-gradient(160deg, #fff0fb 0%, #f1ebff 45%, #e3f2ff 100%) fixed;
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
  overscroll-behavior: none;
}

button, input { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; }
:focus-visible { outline: 4px solid #b9a2ff; outline-offset: 3px; }

#app { min-height: 100vh; min-height: 100dvh; }

.splash { min-height: 100dvh; display: grid; place-content: center; text-align: center; font-size: 1.4rem; color: var(--ink-soft); }
.splash-star { font-size: 3rem; color: var(--gold); animation: bob 1.6s ease-in-out infinite; }

/* Screens and top bar */
.screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  animation: screen-in 0.28s ease-out;
}
@keyframes screen-in { from { opacity: 0; transform: translateY(8px); } }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 18px 6px;
}
.top-right { display: flex; align-items: center; gap: 10px; }
.game-title {
  margin: 0;
  font-size: clamp(1.6rem, 4.2vmin, 2.4rem);
  font-weight: 700;
  background: linear-gradient(90deg, #ff6fae, #b07bff 55%, #4fb6ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-align: center;
}
.screen-title { margin: 0; font-size: clamp(1.4rem, 3.6vmin, 2rem); font-weight: 700; text-align: center; flex: 1; }

.icon { display: inline-grid; place-items: center; }
.icon svg { width: 1.3em; height: 1.3em; display: block; }
.icon.tiny svg { width: 0.95em; height: 0.95em; }
.dust-icon { color: var(--gold); filter: drop-shadow(0 1px 0 #d99a00); }

.icon-btn {
  width: 52px;
  height: 52px;
  flex: none;
  border: 0;
  border-radius: 50%;
  background: #fff;
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  display: grid;
  place-items: center;
  cursor: pointer;
  font-size: 1.15rem;
}
.icon-btn:active { transform: scale(0.94); }

.dust-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px 8px 12px;
  border-radius: 999px;
  background: #fff;
  box-shadow: var(--shadow-sm);
  font-weight: 700;
  font-size: 1.25rem;
  min-width: 86px;
  justify-content: center;
}
.dust-pill.bump { animation: bump 0.35s ease; }
@keyframes bump { 50% { transform: scale(1.18); } }

/* Buttons */
.btn {
  border: 0;
  border-radius: 999px;
  padding: 0.65em 1.4em;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 4px 0 #dccdfb;
  transition: transform 0.08s ease;
}
.btn:active { transform: translateY(2px); box-shadow: 0 2px 0 #dccdfb; }
.btn.primary { background: linear-gradient(180deg, #ff8cc1, #ff5fa2); color: #fff; box-shadow: 0 5px 0 #d84b8b; }
.btn.primary:active { box-shadow: 0 2px 0 #d84b8b; }
.btn.soft { background: var(--lilac); box-shadow: 0 4px 0 var(--lilac-2); }
.btn.danger { background: #ffe3e1; color: #a3271f; box-shadow: 0 4px 0 #f2b8b3; }
.btn.big { font-size: 1.3rem; padding: 0.7em 1.6em; }
.btn.huge { font-size: clamp(1.4rem, 3.6vmin, 1.9rem); padding: 0.75em 1.7em; }
.btn .icon svg { width: 1.1em; height: 1.1em; }

.chip { display: inline-block; padding: 8px 14px; border-radius: 999px; background: var(--lilac); font-weight: 600; font-size: 1.05rem; border: 0; }
.chip.gold { background: #fff3c4; box-shadow: inset 0 0 0 2px #ffd65c; }
.chip.pick { cursor: pointer; box-shadow: 0 3px 0 var(--lilac-2); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }

.big-line { font-size: clamp(1.2rem, 3vmin, 1.55rem); font-weight: 600; margin: 0.4em 0; }
.line { font-size: 1.1rem; color: var(--ink-soft); margin: 0.4em 0; }

/* Unicorn animations */
.hero-pet svg, .pet svg { width: 100%; height: auto; display: block; }
svg.unicorn { overflow: visible; }
.idle svg { animation: bob 3.2s ease-in-out infinite; }
.u-tail { animation: sway 2.8s ease-in-out infinite; }
.u-eye { animation: blink 5.5s infinite; }
.hop svg { animation: hop 0.6s ease; }
.hop-loop svg { animation: hop 1.1s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-3%); } }
@keyframes sway { 50% { transform: rotate(7deg); } }
@keyframes blink { 0%, 93%, 100% { transform: scaleY(1); } 96% { transform: scaleY(0.12); } }
@keyframes hop { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-10%) rotate(-3deg); } 70% { transform: translateY(0) scaleY(0.96); } }

/* Home */
.home-main {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: center;
  gap: 24px;
  padding: 8px 28px 64px;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}
.hero { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.hero-pet { width: min(100%, 420px, 58vh); }
.hero-pet.small { width: min(60vw, 240px); }
.name-tag { background: #fff; padding: 8px 22px; border-radius: 999px; font-weight: 700; font-size: 1.4rem; box-shadow: var(--shadow-sm); margin-top: -6px; }
.home-actions { display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; }
.greeting { font-size: clamp(1.3rem, 3.4vmin, 1.8rem); font-weight: 600; margin: 0; }
.where { margin: 0; color: var(--ink-soft); font-size: 1.1rem; }
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; width: min(100%, 460px); margin-top: 6px; }
.tile {
  border: 0;
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 5px 0 #e3d7fd;
  padding: 14px 6px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 1.05rem;
  cursor: pointer;
}
.tile:active { transform: translateY(2px); box-shadow: 0 3px 0 #e3d7fd; }
.tile-icon { color: var(--violet); }
.tile-icon svg { width: 2.1em; height: 2.1em; }
.grownups-link {
  position: fixed;
  right: 14px;
  bottom: 12px;
  border: 0;
  background: rgba(255, 255, 255, 0.7);
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 0.95rem;
  cursor: pointer;
}

/* Quest */
.session { height: 100vh; height: 100dvh; overflow: hidden; }
.progress { flex: 1; height: 18px; border-radius: 999px; background: #fff; box-shadow: inset 0 2px 4px rgba(91, 58, 140, 0.12); overflow: hidden; max-width: 640px; }
.progress-fill { height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, #ff8cc1, #b07bff, #5cc0ff); transition: width 0.4s ease; }
.session-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(120px, 0.75fr) minmax(0, 1.7fr) minmax(240px, 1fr);
  gap: 18px;
  align-items: center;
  padding: 6px 22px 20px;
}
.session.no-pad .session-body { grid-template-columns: minmax(120px, 0.6fr) minmax(0, 2.8fr); }
.session.no-pad .pad-wrap { display: none; }
.pet { align-self: end; max-width: 300px; justify-self: center; width: 100%; }
.stage { display: flex; justify-content: center; align-items: center; min-width: 0; min-height: 0; max-height: 100%; }
.pad-wrap { display: flex; justify-content: center; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 26px;
  width: 100%;
  max-width: 720px;
  text-align: center;
  position: relative;
  max-height: calc(100dvh - 120px);
  overflow: auto;
}
.pop-in { animation: pop-in 0.3s cubic-bezier(0.2, 1.4, 0.4, 1); }
@keyframes pop-in { from { transform: scale(0.92); opacity: 0; } }
.card.right { box-shadow: 0 0 0 5px #9ff0cf, var(--shadow); }
.card h2 { margin: 0.2em 0 0.3em; font-size: clamp(1.5rem, 3.8vmin, 2.1rem); }
.card h3 { margin: 0.2em 0; font-size: 1.3rem; color: var(--violet); }
.tag { display: inline-block; padding: 5px 14px; border-radius: 999px; background: #fff0f8; color: #d23c7c; font-weight: 700; font-size: 0.95rem; letter-spacing: 0.04em; text-transform: uppercase; }
.q-note { font-size: 1.25rem; font-weight: 600; color: var(--violet); margin-bottom: 4px; }
.problem {
  font-size: clamp(3rem, 10vmin, 6.2rem);
  font-weight: 600;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.28em;
  line-height: 1.2;
  margin: 6px 0;
}
.problem .op, .problem .eq { color: #b07bff; }
.problem.small { font-size: clamp(2rem, 6vmin, 3.2rem); }
.answer {
  min-width: 1.7em;
  padding: 0 0.18em;
  border-radius: 20px;
  background: var(--lilac);
  color: #b9a8dc;
  text-align: center;
}
.answer.typed { color: var(--ink); background: #fff3fa; box-shadow: inset 0 0 0 4px #ffc2df; }
.answer.shake { animation: shake 0.4s; }
@keyframes shake { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }
.praise {
  position: absolute;
  left: 50%;
  top: 8px;
  transform: translateX(-50%);
  font-size: 1.6rem;
  font-weight: 700;
  color: #2a9d7d;
  animation: rise 0.85s ease-out forwards;
  pointer-events: none;
  white-space: nowrap;
}
@keyframes rise { from { opacity: 0; transform: translate(-50%, 10px); } 20% { opacity: 1; } to { opacity: 0; transform: translate(-50%, -26px); } }

.lesson-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 18px; align-items: center; text-align: left; margin: 8px 0 14px; }
.picture-wrap { display: flex; justify-content: center; }
.picture-wrap svg { width: 100%; max-height: 42vh; height: auto; }
.picture-wrap.tri svg { max-width: 240px; }
.picture text { font-family: var(--font); }
.steps p { font-size: 1.25rem; margin: 0.35em 0; }
.steps .big-line { font-size: 1.45rem; }
.fact-title { font-size: clamp(2.2rem, 6vmin, 3.2rem) !important; }
.rhyme { background: #fff7d6; border-radius: 16px; padding: 10px 14px; font-style: italic; }

.keypad { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; width: 100%; max-width: 330px; }
.key {
  aspect-ratio: 1.12;
  border: 0;
  border-radius: 22px;
  background: #fff;
  font-size: clamp(1.7rem, 4.6vmin, 2.5rem);
  font-weight: 600;
  box-shadow: 0 5px 0 #dccdfb;
  cursor: pointer;
  display: grid;
  place-items: center;
  touch-action: manipulation;
}
.key.pressed { animation: press 0.15s; }
@keyframes press { 50% { transform: translateY(3px) scale(0.96); box-shadow: 0 2px 0 #dccdfb; } }
.key-back { background: var(--lilac); }
.key-ok { background: linear-gradient(180deg, #84e6c1, #3fc6a0); color: #fff; box-shadow: 0 5px 0 #2a9d7d; }
.keypad.disabled { opacity: 0.5; pointer-events: none; }

.island-card .friend-art, .island-info .friend-art { width: 150px; margin: 0 auto; }
.friend-art svg { width: 100%; height: auto; display: block; }
.friend-art.shadowed svg { filter: brightness(0) opacity(0.25); }

/* Results */
.results-main { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 18px 20px 40px; text-align: center; max-width: 900px; margin: 0 auto; width: 100%; }
.results .hero-pet { width: min(60vw, 260px, 34vh); }
.stat-row { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.stat { background: #fff; border-radius: 22px; box-shadow: var(--shadow-sm); padding: 12px 20px; display: flex; flex-direction: column; align-items: center; min-width: 130px; }
.stat b { font-size: 2rem; }
.stat span { color: var(--ink-soft); }
.news { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; width: 100%; max-width: 620px; }
.news li { background: #fff7d6; border-radius: 18px; padding: 12px 16px; font-size: 1.2rem; font-weight: 600; display: flex; align-items: center; gap: 12px; justify-content: center; }
.news .big-news { background: linear-gradient(90deg, #ffe3f1, #e9e0ff); font-size: 1.35rem; }
.mini-friend { width: 56px; flex: none; }
.spell-list h3 { margin: 6px 0; color: var(--violet); }
.row-actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; margin-top: 8px; }

/* Hatching and designing */
.hatch-main { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 20px; text-align: center; }
.egg { width: min(48vw, 250px, 40vh); cursor: pointer; }
.egg svg { width: 100%; display: block; }
.egg.wobble svg { animation: wobble 2.2s ease-in-out infinite; transform-origin: 50% 90%; }
.egg.shake svg { animation: egg-shake 0.35s; transform-origin: 50% 90%; }
@keyframes wobble { 0%, 70%, 100% { transform: rotate(0); } 78% { transform: rotate(-6deg); } 86% { transform: rotate(5deg); } 93% { transform: rotate(-3deg); } }
@keyframes egg-shake { 25% { transform: rotate(-10deg); } 75% { transform: rotate(9deg); } }
.name-input {
  font-size: 1.8rem;
  text-align: center;
  border-radius: 22px;
  border: 3px solid var(--lilac-2);
  padding: 10px 18px;
  width: min(90vw, 420px);
  background: #fff;
}

.boutique-main { flex: 1; min-height: 0; padding: 4px 18px 18px; }
.designer { display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.3fr); gap: 18px; height: 100%; max-width: 1200px; margin: 0 auto; }
.designer-left { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; }
.designer-preview { width: min(100%, 400px, 56vh); }
.designer-preview svg { width: 100%; display: block; }
.designer-right { display: flex; flex-direction: column; gap: 12px; min-height: 0; background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; }
.designer-right > .btn { align-self: center; }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.tab { border: 0; border-radius: 999px; padding: 8px 14px; background: var(--lilac); font-weight: 600; font-size: 1.05rem; cursor: pointer; }
.tab.on { background: linear-gradient(180deg, #b9a2ff, #8f6bff); color: #fff; }
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; overflow: auto; min-height: 0; flex: 1; padding: 4px; align-content: start; }
.swatch {
  border: 0;
  border-radius: 18px;
  background: #faf7ff;
  padding: 8px 6px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  box-shadow: inset 0 0 0 2px #eee6ff;
  position: relative;
}
.swatch.on { box-shadow: inset 0 0 0 4px #ff8cc1; background: #fff2f9; }
.swatch.locked .swatch-art { opacity: 0.55; }
.swatch-art { width: 58px; height: 58px; display: grid; place-items: center; }
.swatch-art svg { width: 100%; height: 100%; }
.swatch-name { font-size: 0.9rem; font-weight: 600; }
.price { display: inline-flex; align-items: center; gap: 3px; font-size: 0.85rem; font-weight: 700; background: #fff; border-radius: 999px; padding: 2px 8px; box-shadow: var(--shadow-sm); }

/* Map */
.screen.map { height: 100vh; height: 100dvh; overflow: hidden; }
.map-main { flex: 1; min-height: 0; padding: 0 12px 12px; display: flex; }
.map-wrap { flex: 1; min-height: 0; display: flex; }
.map-svg { width: 100%; height: 100%; border-radius: var(--radius); box-shadow: var(--shadow); }
.trail { fill: none; stroke: #ffffff; stroke-width: 7; stroke-dasharray: 2 16; stroke-linecap: round; opacity: 0.9; }
.wave { fill: none; stroke: #ffffff; stroke-width: 3; stroke-linecap: round; opacity: 0.55; }
.isle { cursor: pointer; }
.isle-shadow { fill: #6aa9d8; opacity: 0.35; }
.isle-label rect { fill: #ffffff; opacity: 0.92; }
.isle-label text { font-family: var(--font); font-size: 19px; font-weight: 600; fill: var(--ink); }
.isle-chip rect { fill: #8f6bff; }
.isle-chip text { font-family: var(--font); font-size: 17px; font-weight: 700; fill: #fff; }
.isle.locked > path:not(.isle-shadow) { filter: saturate(0.25) brightness(1.05); }
.cloud path { fill: #ffffff; stroke: #c9d6ee; stroke-width: 3; opacity: 0.95; }
.isle-star { fill: #ffd34d; stroke: #d99a00; stroke-width: 2; }
.pulse { fill: none; stroke: #ff8cc1; stroke-width: 6; opacity: 0.8; animation: pulse 1.8s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes pulse { 50% { transform: scale(1.08); opacity: 0.3; } }
.island-modal .meter { position: relative; height: 30px; border-radius: 999px; background: var(--lilac); overflow: hidden; margin-top: 10px; }
.meter-fill { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, #ffc2df, #b9a2ff); }
.meter span { position: relative; line-height: 30px; font-weight: 600; }
.island-info { text-align: center; }

/* Magic Window */
.window-main { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 18px; align-items: center; padding: 4px 22px 22px; max-width: 1200px; margin: 0 auto; width: 100%; }
.window-wrap { display: flex; justify-content: center; min-height: 0; }
.window-svg { width: 100%; max-height: calc(100dvh - 110px); }
.frame { fill: #8a6bc9; }
.arch-glass { fill: #fde9ff; }
.window-title { font-family: var(--font); font-size: 30px; font-weight: 700; fill: #8a4fb8; text-anchor: middle; }
.head-dot { fill: #ffffff; }
.head-num { font-family: var(--font); font-size: 19px; font-weight: 700; fill: var(--ink); text-anchor: middle; }
.head-num.times { fill: #ffffff; font-size: 26px; }
.pane { cursor: pointer; }
.pane rect { stroke: #5b3f96; stroke-width: 3; }
.pane.square rect { stroke: #ffc93c; stroke-width: 4; }
.pane.picked rect { stroke: #ff3f97; stroke-width: 5; }
.shine { fill: none; stroke: #ffffff; stroke-width: 4; stroke-linecap: round; opacity: 0.75; }
.window-side { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 22px; }
.pane-info { font-size: 1.25rem; font-weight: 600; color: var(--violet); min-height: 3em; }

/* Grown-ups */
.grownups { background: #f7f4fc; }
.gate { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 20px; }
.btn.hold { position: relative; overflow: hidden; font-size: 1.2rem; padding: 0.9em 1.8em; }
.hold-fill { position: absolute; inset: 0; width: 0; background: #e2d5ff; }
.hold-fill.go { width: 100%; transition: width 1.5s linear; }
.btn.hold span { position: relative; }
.dash { display: grid; gap: 16px; padding: 6px 18px 40px; max-width: 980px; margin: 0 auto; width: 100%; }
.panel { background: #fff; border-radius: 20px; box-shadow: var(--shadow-sm); padding: 16px 20px; font-size: 1.05rem; }
.panel h2 { margin: 0.2em 0 0.5em; font-size: 1.35rem; }
.panel h3 { margin: 1em 0 0.3em; font-size: 1.15rem; }
.note { color: var(--ink-soft); font-size: 0.95rem; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.kpi { background: #faf7ff; border-radius: 16px; padding: 12px 14px; }
.kpi b { display: block; font-size: 1.6rem; }
.kpi span { color: var(--ink-soft); font-size: 0.95rem; }
.strip { display: flex; gap: 6px; flex-wrap: wrap; }
.day { width: 26px; height: 26px; border-radius: 8px; background: #eee8f7; }
.day.on { background: #7fdca0; }
.heat { display: grid; gap: 3px; max-width: 620px; }
.heat .hd { font-size: 0.8rem; font-weight: 700; color: var(--ink-soft); display: grid; place-items: center; }
.cell { border: 0; border-radius: 6px; aspect-ratio: 1; font-size: 0.75rem; font-weight: 600; color: #3b2a5a; cursor: pointer; padding: 0; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 10px; font-size: 0.95rem; }
.legend i { display: inline-block; width: 16px; height: 16px; border-radius: 5px; vertical-align: -3px; margin-right: 6px; }
.cell-detail { min-height: 2.6em; font-weight: 600; color: var(--violet); }
.tricky { margin: 0; padding-left: 1.2em; display: grid; gap: 6px; }
.field { display: grid; gap: 6px; margin: 12px 0; }
.field > span { font-weight: 700; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.text-input { flex: 1; min-width: 0; border: 2px solid var(--lilac-2); border-radius: 14px; padding: 10px 12px; font-size: 1.05rem; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg-btn { border: 0; border-radius: 999px; padding: 8px 14px; background: var(--lilac); cursor: pointer; font-weight: 600; }
.seg-btn.on { background: #8f6bff; color: #fff; }
.hidden-file { display: none; }

/* Modals and toasts */
.modal-wrap { position: fixed; inset: 0; background: rgba(59, 42, 90, 0.35); display: grid; place-items: center; padding: 16px; z-index: 40; animation: fade 0.2s; }
@keyframes fade { from { opacity: 0; } }
.modal { background: #fff; border-radius: var(--radius); padding: 22px 24px; width: min(100%, 460px); box-shadow: var(--shadow); text-align: center; animation: pop-in 0.25s ease-out; max-height: 90dvh; overflow: auto; }
.modal h2 { margin: 0 0 8px; }
.modal p { font-size: 1.15rem; }
.modal-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 999px; font-weight: 600; z-index: 60; max-width: 90vw; text-align: center; animation: pop-in 0.25s; transition: opacity 0.4s; }
.toast.out { opacity: 0; }

/* Effects */
.fx-layer { position: fixed; inset: 0; pointer-events: none; z-index: 50; overflow: hidden; }
.fx-spark {
  position: absolute;
  width: 16px;
  height: 16px;
  margin: -8px;
  background: var(--c);
  clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
  animation: spark 0.85s ease-out forwards;
}
@keyframes spark { from { transform: translate(0, 0) scale(var(--s)); opacity: 1; } to { transform: translate(var(--dx), var(--dy)) scale(0) rotate(160deg); opacity: 0; } }
.fx-dust {
  position: absolute;
  width: 26px;
  height: 26px;
  background: var(--gold);
  clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
}
.fx-confetti { position: absolute; top: -20px; width: 10px; height: 15px; border-radius: 3px; background: var(--c); animation-name: fall; animation-timing-function: linear; animation-fill-mode: forwards; }
@keyframes fall { to { transform: translate(var(--x), 110vh) rotate(var(--r)); } }

/* Calm motion */
.calm .idle svg, .calm .u-tail, .calm .u-eye, .calm .hop-loop svg, .calm .pulse, .calm .egg.wobble svg, .calm .splash-star { animation: none !important; }

/* Tall screens (tablet held upright, narrow windows) */
@media (max-aspect-ratio: 4/5), (max-width: 760px) {
  .home-main { grid-template-columns: 1fr; align-content: center; padding: 4px 18px 70px; gap: 18px; }
  .hero-pet { width: min(80vw, 360px, 38vh); }
  .session-body { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr) auto; padding: 4px 16px 18px; gap: 10px; }
  .session.no-pad .session-body { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  .pet { width: 120px; align-self: center; }
  .session .stage { align-self: stretch; align-items: flex-start; overflow-y: auto; }
  .picture-wrap svg { max-height: 24vh; }
  .steps p { font-size: 1.1rem; }
  .keypad { max-width: 420px; }
  .key { aspect-ratio: 1.5; }
  .lesson-grid { grid-template-columns: 1fr; text-align: center; }
  .card { max-height: none; }
  .designer { grid-template-columns: 1fr; height: auto; }
  .designer-preview { width: min(70vw, 300px); }
  .swatches { max-height: 46vh; }
  .window-main { grid-template-columns: 1fr; }
  .window-svg { max-height: none; }
}

/* Short screens (small Chromebooks) */
@media (max-height: 640px) and (min-aspect-ratio: 4/5) {
  .topbar { padding-top: 8px; }
  .problem { font-size: clamp(2.6rem, 9vmin, 4.4rem); }
  .picture-wrap svg { max-height: 36vh; }
}

@media print {
  body { background: #fff; }
  body * { visibility: hidden; }
  .window-wrap, .window-wrap * { visibility: visible; }
  .window-wrap { position: absolute; inset: 0; }
  .window-svg { max-height: none; }
}
