/* Little Learners Tablet
   Design: a toy tablet screen. Chunky "plastic key" buttons that press down,
   one bright toy colour per section, navy ink outlines, a pale sky screen.
   All sizes are in rem, and the root size follows the media prim's pixel size,
   so the layout scales from 800x500 up to 2048x1280 MoaP surfaces. */

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

:root {
  --ink: #1D2B53;
  --ink-soft: #4A5785;
  --screen: #E4F4FF;
  --panel: #FFFFFF;
  --red: #FF4D4D;     --red-d: #C42F3B;
  --ocean: #2E8BFF;   --ocean-d: #1A5FC2;
  --sun: #FFC93C;     --sun-d: #D99A12;
  --leaf: #3DCB6C;    --leaf-d: #23934A;
  --grape: #9B5DE5;   --grape-d: #6C3BB0;
  --tangerine: #FF8A3D; --tangerine-d: #C9601F;
  --teal: #1FC8C8;    --teal-d: #12908F;
  --pink: #FF6FB5;    --pink-d: #CF4A8C;
  --good: #23B35A;
  --radius-l: 1.6rem;
  --radius-m: 1.1rem;
  --radius-s: .7rem;
  --press: .32rem;
  --font: 'Fredoka', 'Trebuchet MS', 'Segoe UI', system-ui, sans-serif;
  color-scheme: light;
}

/* 16px at 1024x640; scales with the smaller of width and height. */
html { font-size: min(1.5625vw, 2.5vh); }
html, body { margin: 0; height: 100%; }
body {
  background: var(--screen);
  color: var(--ink);
  font-family: var(--font);
  font-weight: 500;
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font-family: inherit; color: inherit; }
img.emo { width: 1.2em; height: 1.2em; vertical-align: -0.2em; pointer-events: none; }
.emo-text { font-size: 1.1em; line-height: 1; }
[hidden] { display: none !important; }

.tone-red { --tone: var(--red); --tone-d: var(--red-d); }
.tone-ocean { --tone: var(--ocean); --tone-d: var(--ocean-d); }
.tone-sun { --tone: var(--sun); --tone-d: var(--sun-d); }
.tone-leaf { --tone: var(--leaf); --tone-d: var(--leaf-d); }
.tone-grape { --tone: var(--grape); --tone-d: var(--grape-d); }
.tone-tangerine { --tone: var(--tangerine); --tone-d: var(--tangerine-d); }
.tone-teal { --tone: var(--teal); --tone-d: var(--teal-d); }
.tone-pink { --tone: var(--pink); --tone-d: var(--pink-d); }

/* ---------- frame ---------- */
#tablet { position: relative; display: flex; flex-direction: column; height: 100vh; overflow: hidden;
  background-color: var(--screen);
  background-image: radial-gradient(rgba(46,139,255,.09) .12rem, transparent .13rem);
  background-size: 1.4rem 1.4rem; }

#topbar { flex: 0 0 auto; display: flex; align-items: center; gap: .6rem; padding: .55rem .8rem;
  background: var(--panel); border-bottom: .25rem solid var(--ink); z-index: 5; }
#screen-title { flex: 1 1 auto; margin: 0 .4rem; font-size: 1.45rem; font-weight: 700; letter-spacing: .01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { display: flex; align-items: center; gap: .5rem; }

.topbtn { display: inline-flex; align-items: center; gap: .35rem; height: 2.7rem; padding: 0 .95rem;
  border: .2rem solid var(--ink); border-radius: 999px; background: var(--sun); font-size: 1.05rem; font-weight: 700;
  box-shadow: 0 .22rem 0 var(--ink); cursor: pointer; transition: transform .08s, box-shadow .08s; }
.topbtn img.emo { width: 1.45rem; height: 1.45rem; }
.topbtn:active { transform: translateY(.18rem); box-shadow: 0 .04rem 0 var(--ink); }
.topbtn.icon-only { width: 2.7rem; padding: 0; justify-content: center; background: #fff; }
#btn-back { background: #fff; }
body[data-screen="home"] #btn-home { visibility: hidden; }

.chip { display: inline-flex; align-items: center; gap: .35rem; height: 2.2rem; padding: 0 .75rem; border-radius: 999px;
  font-size: .95rem; font-weight: 600; border: .16rem solid var(--ink); background: #fff; white-space: nowrap; }
.chip .dot { width: .7rem; height: .7rem; border-radius: 50%; background: #A7AFC9; }
.chip-live .dot { background: var(--good); box-shadow: 0 0 0 .2rem rgba(35,179,90,.25); }
.chip-wait .dot { background: var(--sun); }
.chip-stars { background: #FFF3C4; }
.chip-stars img.emo { width: 1.3rem; height: 1.3rem; }

#stage { position: relative; flex: 1 1 auto; overflow-x: hidden; overflow-y: auto; }
.screen { min-height: 100%; box-sizing: border-box; padding: 1rem 1.2rem 1.4rem; }
.enter { animation: screen-in .28s ease-out; }
@keyframes screen-in { from { opacity: 0; transform: translateY(.8rem) scale(.985); } to { opacity: 1; transform: none; } }

/* ---------- toy buttons ---------- */
.toybtn { --tone: #fff; --tone-d: var(--ink); display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  min-height: 3.1rem; padding: .35rem 1.2rem; border: .22rem solid var(--ink); border-radius: var(--radius-m);
  background: var(--tone); font-size: 1.2rem; font-weight: 700; cursor: pointer; color: var(--ink);
  box-shadow: 0 var(--press) 0 var(--ink); transition: transform .08s, box-shadow .08s, background .15s; }
.toybtn img.btn-ico { width: 1.6rem; height: 1.6rem; }
.toybtn:active:not(:disabled) { transform: translateY(var(--press)); box-shadow: 0 0 0 var(--ink); }
.toybtn:disabled { opacity: .45; cursor: default; }
.toybtn.primary { background: var(--sun); }
.toybtn.go { background: var(--leaf); color: #fff; }
.toybtn.danger { background: var(--red); color: #fff; }
.toybtn.quiet { background: #EEF3FF; }
.toybtn.small { min-height: 2.5rem; font-size: 1rem; padding: .2rem .85rem; }
.toybtn.on, .toybtn.selected { background: var(--ocean); color: #fff; }
button:focus-visible, .toybtn:focus-visible, .home-tile:focus-visible { outline: .25rem solid var(--ocean); outline-offset: .2rem; }

.row { display: flex; gap: .8rem; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.center { justify-content: center; }
.spacer { flex: 1; }

/* ---------- splash / loading / errors ---------- */
.splash, .loading, .error-panel { height: 100%; min-height: 20rem; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1rem; text-align: center; }
.splash-logo { display: flex; flex-direction: column; align-items: center; font-weight: 700; line-height: .95; }
.splash-logo span:first-child { font-size: 2.6rem; color: var(--ocean); }
.splash-logo span:last-child { font-size: 4rem; color: var(--red); -webkit-text-stroke: .1rem var(--ink); }
.spinner { width: 3.2rem; height: 3.2rem; border-radius: 50%; border: .45rem solid #fff; border-top-color: var(--ocean); border-right-color: var(--sun); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.error-panel h2 { margin: 0; font-size: 1.8rem; }
.error-panel p { margin: 0; font-size: 1.15rem; color: var(--ink-soft); max-width: 34rem; }
img.error-ico { width: 5rem; height: 5rem; }
.noscript { padding: 2rem; font: 1.4rem sans-serif; }

/* ---------- home ---------- */
.screen-home { display: flex; flex-direction: column; gap: 1rem; padding: 1.2rem 1.6rem 1.6rem; }
.home-head { display: flex; align-items: baseline; gap: 1rem; }
.home-hello { margin: 0; font-size: 1.25rem; color: var(--ink-soft); font-weight: 600; }
.home-q { margin: 0; font-size: 2.3rem; font-weight: 700; }
.home-grid { flex: 1; display: grid; grid-template-columns: repeat(4, 1fr); grid-auto-rows: 1fr; gap: 1.1rem 1.1rem; padding-bottom: var(--press); }
.home-tile { position: relative; display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-end; gap: .15rem;
  min-height: 9rem; padding: 1rem 1rem .9rem; border: .25rem solid var(--ink); border-radius: var(--radius-l); text-align: left;
  background: var(--tone); color: #fff; cursor: pointer; overflow: hidden;
  box-shadow: 0 .45rem 0 var(--ink); transition: transform .08s, box-shadow .08s; }
.home-tile::before { content: ''; position: absolute; right: -2.2rem; top: -2.2rem; width: 8.5rem; height: 8.5rem; border-radius: 50%; background: rgba(255,255,255,.22); }
.home-tile:active { transform: translateY(.45rem); box-shadow: 0 0 0 var(--ink); }
.tile-ico { position: absolute; top: .75rem; right: .85rem; }
.tile-ico img.emo { width: 4.2rem; height: 4.2rem; filter: drop-shadow(0 .2rem 0 rgba(29,43,83,.35)); }
.tile-title { position: relative; font-size: 1.5rem; font-weight: 700; line-height: 1.05; text-shadow: 0 .12rem 0 rgba(29,43,83,.35); }
.tile-blurb { position: relative; font-size: .98rem; font-weight: 500; opacity: .95; }
.home-tile.tone-sun, .home-tile.tone-teal { color: var(--ink); }
.home-tile.tone-sun .tile-title, .home-tile.tone-teal .tile-title { text-shadow: none; }
@media (prefers-reduced-motion: no-preference) {
  body:not(.reduced-motion) .screen-home.enter .home-tile { animation: tile-pop .4s cubic-bezier(.3,1.6,.6,1) both; animation-delay: calc(var(--i) * 35ms); }
}
@keyframes tile-pop { from { transform: scale(.7); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- shared game chrome ---------- */
.menu-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: 1rem; padding-bottom: var(--press); }
.menu-card { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .4rem; min-height: 11.5rem; padding: 1rem;
  border: .25rem solid var(--ink); border-radius: var(--radius-l); background: #fff; cursor: pointer; font-size: 1.3rem; font-weight: 700;
  box-shadow: 0 .4rem 0 var(--ink); transition: transform .08s, box-shadow .08s; text-align: center; }
.menu-card:active { transform: translateY(.4rem); box-shadow: none; }
.menu-card img.emo { width: 4.6rem; height: 4.6rem; }
.menu-card small { font-size: .95rem; font-weight: 500; color: var(--ink-soft); }
.menu-card.accent { background: var(--tone); }
.game-intro { margin: 0 0 1rem; font-size: 1.35rem; font-weight: 600; }
.prompt { margin: 0 0 .8rem; font-size: 1.7rem; font-weight: 700; text-align: center; }
.prompt .say { margin-left: .4rem; }
.hud { display: flex; align-items: center; gap: .8rem; margin-bottom: .8rem; font-size: 1.2rem; font-weight: 700; flex-wrap: wrap; }
.pill { display: inline-flex; align-items: center; gap: .35rem; padding: .3rem .85rem; border: .18rem solid var(--ink); border-radius: 999px; background: #fff; }
.level-dots { display: inline-flex; gap: .3rem; }
.level-dots i { width: .9rem; height: .9rem; border-radius: 50%; border: .15rem solid var(--ink); background: #fff; }
.level-dots i.on { background: var(--tone, var(--sun)); }
.answers { display: flex; justify-content: center; gap: 1rem; flex-wrap: wrap; padding-bottom: var(--press); }
.answer { min-width: 7rem; min-height: 7rem; font-size: 3rem; }
.answer img.btn-ico { width: 3.6rem; height: 3.6rem; }
.shake { animation: shake .45s; }
@keyframes shake { 20%, 60% { transform: translateX(-.5rem); } 40%, 80% { transform: translateX(.5rem); } }
.done-panel { display: flex; flex-direction: column; align-items: center; gap: .8rem; padding: 1.2rem; text-align: center; }
.done-panel h2 { margin: 0; font-size: 2.2rem; }
.done-panel p { margin: 0; font-size: 1.25rem; }
img.done-ico { width: 5.5rem; height: 5.5rem; }

.draggable { cursor: grab; touch-action: none; }
.draggable.dragging { cursor: grabbing; filter: drop-shadow(0 .6rem .4rem rgba(29,43,83,.3)); }
.draggable.picked { outline: .3rem dashed var(--ocean); outline-offset: .25rem; animation: pick-bob .9s ease-in-out infinite; }
@keyframes pick-bob { 50% { transform: translateY(-.3rem); } }
.has-pick [data-dropzone] { outline: .22rem dashed rgba(46,139,255,.55); outline-offset: -.1rem; }
[data-dropzone].hover { background-color: rgba(46,139,255,.15) !important; }

/* ---------- feedback ---------- */
#fx-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 40; }
.cheer { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%); display: flex; align-items: center; gap: .6rem;
  padding: .8rem 1.6rem; background: #fff; border: .3rem solid var(--ink); border-radius: 999px; font-size: 2.2rem; font-weight: 700;
  box-shadow: 0 .4rem 0 var(--ink); animation: cheer 1.4s ease-out forwards; }
img.cheer-ico { width: 3rem; height: 3rem; }
@keyframes cheer { 0% { transform: translate(-50%, -50%) scale(.4); opacity: 0; } 15% { transform: translate(-50%, -50%) scale(1.08); opacity: 1; }
  25% { transform: translate(-50%, -50%) scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -60%) scale(1); } }
body.reduced-motion .cheer { animation: fade-out 1.4s forwards; }
@keyframes fade-out { 0%, 75% { opacity: 1; } 100% { opacity: 0; } }
.confetti { position: absolute; top: -1rem; width: .7rem; height: 1.1rem; border-radius: .15rem; animation: confetti-fall 1.4s ease-in forwards; }
@keyframes confetti-fall { to { transform: translate(var(--dx), 110vh) rotate(var(--rot)); } }

.toast { position: absolute; left: 50%; bottom: 1.2rem; transform: translate(-50%, 5rem); opacity: 0; visibility: hidden; padding: .65rem 1.3rem; max-width: 80%;
  background: var(--ink); color: #fff; border-radius: 999px; font-size: 1.15rem; font-weight: 600; z-index: 45; transition: transform .25s, opacity .25s, visibility .25s; text-align: center; }
.toast.show { transform: translate(-50%, 0); opacity: 1; visibility: visible; }
.toast.soft { background: var(--grape); }

#banner-root { position: absolute; left: 0; right: 0; top: 4.2rem; display: flex; justify-content: center; z-index: 30; pointer-events: none; }
.banner { pointer-events: auto; display: flex; align-items: center; gap: .7rem; padding: .5rem .6rem .5rem 1rem; background: #fff;
  border: .22rem solid var(--ink); border-radius: var(--radius-m); box-shadow: 0 .3rem 0 var(--ink); font-size: 1.1rem; font-weight: 600; }
img.banner-ico { width: 2rem; height: 2rem; }

.modal-overlay { position: absolute; inset: 0; background: rgba(29,43,83,.45); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal { width: min(36rem, 90%); max-height: 88%; overflow: auto; background: #fff; border: .3rem solid var(--ink); border-radius: var(--radius-l); padding: 1.2rem 1.4rem 1.4rem; box-shadow: 0 .5rem 0 var(--ink); }
.modal-title { margin: 0 0 .6rem; font-size: 1.7rem; }
.modal-body { font-size: 1.15rem; }
.modal-body p { margin: .3rem 0 .8rem; }
.modal-actions { display: flex; gap: .7rem; flex-wrap: wrap; justify-content: flex-end; margin-top: 1rem; padding-bottom: var(--press); }
.gate-q { font-size: 1.4rem; font-weight: 600; }
.gate-opt { min-width: 5rem; font-size: 1.6rem; }

/* ---------- settings ---------- */
.settings { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; max-width: 62rem; margin: 0 auto; }
.set-group { background: #fff; border: .22rem solid var(--ink); border-radius: var(--radius-l); padding: .8rem 1.1rem 1rem; }
.set-group h3 { margin: 0 0 .4rem; font-size: 1.35rem; }
.set-group.about { grid-column: 1 / -1; font-size: 1rem; color: var(--ink-soft); }
.set-group.about p { margin: .25rem 0; }
.settings > .row { grid-column: 1 / -1; }
.set-row { display: flex; align-items: center; gap: 1rem; padding: .45rem 0; border-top: .12rem dashed #D5DEF5; }
.set-row:first-of-type { border-top: 0; }
.set-text { flex: 1; display: flex; flex-direction: column; }
.set-label { font-size: 1.15rem; font-weight: 600; }
.set-help { font-size: .92rem; color: var(--ink-soft); font-weight: 500; }
.set-help.warn { color: var(--red-d); }
.switch { flex: 0 0 auto; position: relative; width: 4rem; height: 2.2rem; border-radius: 999px; border: .2rem solid var(--ink); background: #D5DEF5; cursor: pointer; padding: 0; }
.switch i { position: absolute; top: .15rem; left: .2rem; width: 1.5rem; height: 1.5rem; border-radius: 50%; background: #fff; border: .16rem solid var(--ink); transition: left .15s; }
.switch.on { background: var(--leaf); }
.switch.on i { left: 1.95rem; }
.seg { display: inline-flex; border: .2rem solid var(--ink); border-radius: 999px; overflow: hidden; flex: 0 0 auto; }
.seg-btn { border: 0; background: #fff; padding: .4rem .8rem; font-size: 1rem; font-weight: 600; cursor: pointer; }
.seg-btn + .seg-btn { border-left: .16rem solid var(--ink); }
.seg-btn.on { background: var(--ocean); color: #fff; }
.slider { width: 11rem; height: 2rem; accent-color: var(--ocean); cursor: pointer; }

@media (max-aspect-ratio: 5/4) {
  .home-grid { grid-template-columns: repeat(3, 1fr); }
  .settings { grid-template-columns: 1fr; }
  .chip-stars { display: none; }
}
@media (max-width: 700px) {
  .topbtn .btn-label { display: none; }
  .topbtn { padding: 0 .6rem; }
}

/* =========================================================
   ABC & Numbers
   ========================================================= */
.menu-grid.four { grid-template-columns: repeat(4, 1fr); }
.letter-grid { display: grid; grid-template-columns: repeat(9, 1fr); gap: .6rem; padding-bottom: var(--press); }
.letter-key { aspect-ratio: 1; border: .22rem solid var(--ink); border-radius: var(--radius-m); font-size: 2.3rem; font-weight: 700; cursor: pointer;
  background: hsl(var(--hue) 90% 72%); box-shadow: 0 .25rem 0 var(--ink); transition: transform .08s, box-shadow .08s; }
.letter-key:active { transform: translateY(.25rem); box-shadow: none; }
.letter-card { display: grid; grid-template-columns: 1fr 1fr; align-items: center; gap: 1rem; background: #fff; border: .25rem solid var(--ink);
  border-radius: var(--radius-l); padding: 1rem 1.5rem; margin-bottom: 1rem; }
.big-letter { font-size: 10rem; font-weight: 700; line-height: 1; color: var(--ocean); -webkit-text-stroke: .15rem var(--ink); text-align: center; }
.big-letter .lc { color: var(--red); margin-left: .4rem; }
.letter-object { text-align: center; }
.letter-object p { margin: .3rem 0 0; font-size: 2.2rem; font-weight: 700; }
img.huge { width: 8rem; height: 8rem; }
.letter-phrase { grid-column: 1 / -1; margin: 0; text-align: center; font-size: 1.5rem; font-weight: 600; }
.letter-card .set-help { grid-column: 1 / -1; text-align: center; margin: 0; }
.trace-wrap { position: relative; height: calc(100vh - 15.5rem); min-height: 14rem; background: #fff; border: .25rem solid var(--ink); border-radius: var(--radius-l); overflow: hidden; margin-bottom: .8rem; }
.trace-canvas { display: block; touch-action: none; cursor: crosshair; }
.trace-label { font-size: 1.4rem; }
.meter { width: 10rem; height: 1rem; border: .18rem solid var(--ink); border-radius: 999px; background: #fff; overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; background: var(--leaf); transition: width .25s; }
.trace-controls { padding-bottom: var(--press); }
.quiz-card { display: flex; flex-direction: column; align-items: center; gap: .3rem; margin: 0 auto 1rem; padding: 1rem 2rem; width: fit-content; min-width: 18rem;
  background: #fff; border: .25rem solid var(--ink); border-radius: var(--radius-l); }
.quiz-card.wide { width: auto; max-width: 52rem; }
.word-blank { margin: 0; font-size: 2.8rem; font-weight: 700; letter-spacing: .04em; }
.word-blank .blank { display: inline-block; min-width: 2.6rem; text-align: center; color: var(--red); border-bottom: .3rem solid var(--ink); margin-right: .1rem; }
.letter-answer { font-size: 3.6rem; }
.toybtn.correct { background: var(--leaf) !important; color: #fff; }
.count-field { display: flex; flex-wrap: wrap; justify-content: center; gap: .9rem; max-width: 60rem; margin: 0 auto 1rem; padding: 1rem;
  background: #fff; border: .25rem solid var(--ink); border-radius: var(--radius-l); }
.count-item { position: relative; width: 6.5rem; height: 6.5rem; border: .2rem dashed #B7C4E8; border-radius: 50%; background: #F5F8FF; cursor: pointer; }
.count-item img.emo { width: 4.6rem; height: 4.6rem; }
.count-field.dense .count-item { width: 4.8rem; height: 4.8rem; }
.count-field.dense .count-item img.emo { width: 3.3rem; height: 3.3rem; }
.count-item.counted { border: .2rem solid var(--leaf); background: #E6FBEC; }
.count-num { position: absolute; top: -.6rem; right: -.6rem; min-width: 2rem; height: 2rem; border-radius: 999px; background: var(--leaf); color: #fff;
  border: .16rem solid var(--ink); font-size: 1.1rem; font-weight: 700; display: grid; place-items: center; }
.group { display: flex; flex-wrap: wrap; justify-content: center; gap: .35rem; max-width: 30rem; }
.group img.emo { width: 3rem; height: 3rem; }
.group.dense img.emo { width: 2.1rem; height: 2.1rem; }
.group-choices { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; padding-bottom: var(--press); }
.group-choice { min-width: 14rem; min-height: 9rem; max-width: 22rem; padding: .8rem; background: #fff; border: .25rem solid var(--ink); border-radius: var(--radius-l);
  box-shadow: 0 var(--press) 0 var(--ink); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.group-choice .group img.emo { width: 2.4rem; height: 2.4rem; }
.group-choice:active { transform: translateY(var(--press)); box-shadow: none; }
.group-choice.correct { background: #E6FBEC; border-color: var(--leaf-d); }
.group-choice:disabled { opacity: .45; }
.big-num { display: inline-grid; place-items: center; min-width: 4rem; height: 4rem; border-radius: var(--radius-m); background: var(--sun); border: .22rem solid var(--ink); font-size: 2.6rem; vertical-align: middle; margin-right: .3rem; }

/* =========================================================
   Colours & Shapes
   ========================================================= */
.mixer { display: flex; align-items: center; justify-content: center; gap: 3rem; margin: 1rem 0 1.5rem; }
.pots { display: flex; gap: 1.2rem; }
.pot { position: relative; width: 8rem; height: 9rem; border: 0; background: none; cursor: pointer; padding: 0; }
.pot-paint { position: absolute; left: .5rem; right: .5rem; top: 1rem; bottom: 2.3rem; background: var(--c); border: .25rem solid var(--ink); border-radius: .8rem .8rem 2.2rem 2.2rem; box-shadow: 0 .35rem 0 var(--ink); }
.pot-label { position: absolute; left: 0; right: 0; bottom: 0; font-size: 1.3rem; font-weight: 700; }
.pot.chosen .pot-paint { transform: translateY(-.6rem) rotate(-8deg); transition: transform .2s; }
.mix-bowl { --c: #fff; position: relative; width: 17rem; height: 12rem; border: .3rem solid var(--ink); border-radius: 1rem 1rem 8rem 8rem; background: #fff; overflow: hidden; display: grid; place-items: center; text-align: center; }
.mix-bowl::before { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: var(--c); transition: height .5s ease; }
.mix-bowl.half::before { height: 40%; }
.mix-bowl.full::before { height: 78%; }
.mix-text { position: relative; padding: 0 1rem; font-size: 1.35rem; font-weight: 700; background: rgba(255,255,255,.85); border-radius: .6rem; }
.swatch-row { display: flex; align-items: center; justify-content: center; gap: .8rem; }
.swatches { display: flex; gap: .5rem; flex-wrap: wrap; }
.swatch { padding: .3rem .8rem; border-radius: 999px; border: .18rem dashed #B7C4E8; color: #A7AFC9; font-weight: 600; }
.swatch.got { background: var(--c); color: #fff; border: .18rem solid var(--ink); text-shadow: 0 .1rem 0 rgba(29,43,83,.5); }
.colour-word { color: var(--c); -webkit-text-stroke: .08rem var(--ink); font-size: 2.1rem; }
.holes { display: flex; justify-content: center; gap: 1.2rem; flex-wrap: wrap; margin-bottom: 1.4rem; }
.hole { width: 9.5rem; height: 9.5rem; display: grid; place-items: center; background: #fff; border: .22rem solid var(--ink); border-radius: var(--radius-l); }
.hole svg { width: 7.5rem; height: 7.5rem; }
.hole.filled { background: #E6FBEC; }
.shape-tray, .sort-tray { display: flex; justify-content: center; gap: 1rem; flex-wrap: wrap; min-height: 8rem; padding: .8rem; background: rgba(255,255,255,.6); border: .2rem dashed #B7C4E8; border-radius: var(--radius-l); }
.shape-piece { width: 8rem; height: 8rem; display: grid; place-items: center; }
.shape-piece svg { width: 7rem; height: 7rem; }
.hole .shape-piece svg { width: 7.5rem; height: 7.5rem; }
.shape { display: inline-grid; place-items: center; line-height: 0; }
.shape-answer { min-width: 9rem; min-height: 9rem; }
.shape-answer .shape svg { width: 6.5rem; height: 6.5rem; }
.sort-item { width: 6rem; height: 6rem; display: grid; place-items: center; background: #fff; border: .2rem solid var(--ink); border-radius: var(--radius-m); }
.sort-item img.emo { width: 4.2rem; height: 4.2rem; }
.baskets { display: flex; justify-content: center; gap: 1.2rem; margin-top: 1.2rem; flex-wrap: wrap; }
.basket { min-width: 15rem; min-height: 10rem; padding: .6rem; border: .28rem solid var(--ink); border-radius: .8rem .8rem 3rem 3rem; background: var(--c); background: color-mix(in srgb, var(--c) 35%, white); }
.basket-label { display: inline-block; padding: .1rem .7rem; background: #fff; border: .16rem solid var(--ink); border-radius: 999px; font-weight: 700; font-size: 1.15rem; }
.basket-items { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .5rem; }
.basket-items .sort-item { width: 4.2rem; height: 4.2rem; }
.basket-items .sort-item img.emo { width: 3rem; height: 3rem; }

/* =========================================================
   Puzzle World
   ========================================================= */
.pz-board { display: flex; gap: 1.2rem; align-items: flex-start; }
.pz-frame-wrap { flex: 0 0 auto; padding: .5rem; background: var(--tone, var(--leaf)); border: .28rem solid var(--ink); border-radius: var(--radius-l); box-shadow: 0 .35rem 0 var(--ink); }
.pz-frame { position: relative; display: grid; grid-template-columns: repeat(var(--cols), 1fr); grid-template-rows: repeat(var(--rows), 1fr); background: #fff; border-radius: .6rem; overflow: hidden; }
.pz-ghost { position: absolute; inset: 0; background-size: 100% 100%; opacity: .16; transition: opacity .3s; pointer-events: none; }
.pz-frame.peek .pz-ghost { opacity: 1; z-index: 3; }
.pz-slot { position: relative; border: .1rem dashed rgba(29,43,83,.35); }
.pz-slot.filled { border-color: transparent; }
.pz-tray { flex: 1; display: flex; flex-wrap: wrap; align-content: center; justify-content: center; gap: 10px; min-height: 10rem; padding: .6rem; background: rgba(255,255,255,.65); border: .2rem dashed #B7C4E8; border-radius: var(--radius-l); }
.pz-piece { --s: 1; width: calc(var(--pw) * var(--s)); height: calc(var(--ph) * var(--s)); background-repeat: no-repeat;
  background-size: calc(var(--fw) * var(--s)) calc(var(--fh) * var(--s)); background-position: calc(var(--bx) * var(--s)) calc(var(--by) * var(--s)); border: .16rem solid var(--ink); border-radius: .35rem; box-sizing: border-box; background-color: #fff; }
.pz-tray .pz-piece { --s: inherit; }
.pz-slot .pz-piece { --s: 1; width: 100%; height: 100%; border-width: 0; border-radius: 0; cursor: default; }
.pz-frame.complete { animation: pz-done .7s ease; }
@keyframes pz-done { 40% { transform: scale(1.04) rotate(-1deg); } 70% { transform: scale(.99) rotate(1deg); } }
.pz-tray .done-panel { width: 100%; }

/* =========================================================
   Art Studio
   ========================================================= */
.screen-art { display: flex; flex-direction: column; padding-bottom: .8rem; }
.art-actions { margin-bottom: .6rem; padding-bottom: var(--press); }
.art-main { flex: 1; display: flex; gap: .9rem; min-height: 0; }
.art-tools { display: flex; flex-direction: column; gap: .7rem; align-items: center; padding-bottom: var(--press); }
.toybtn.tool { width: 4rem; height: 4rem; min-height: 0; padding: 0; }
.toybtn.tool img.btn-ico { width: 2.2rem; height: 2.2rem; }
.size-picks { display: flex; flex-direction: column; gap: .45rem; margin-top: .3rem; }
.size-pick { width: 3.2rem; height: 3.2rem; border-radius: 50%; border: .2rem solid var(--ink); background: #fff; display: grid; place-items: center; cursor: pointer; }
.size-pick i { display: block; border-radius: 50%; background: var(--ink); }
.size-pick.on { background: var(--sun); }
.art-center { flex: 1; display: flex; flex-direction: column; gap: .7rem; min-width: 0; }
.art-board-wrap { flex: 1; min-height: 12rem; display: flex; align-items: center; justify-content: center; }
.art-board { position: relative; border: .28rem solid var(--ink); border-radius: var(--radius-m); overflow: hidden; background: #fff; box-shadow: 0 .3rem 0 var(--ink); }
.art-layer { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
.art-layer.no-pointer { pointer-events: none; }
.art-board[data-tool="brush"] .art-layer, .art-board[data-tool="eraser"] .art-layer { cursor: crosshair; }
.art-board[data-tool="fill"] .art-layer, .art-board[data-tool="sticker"] .art-layer { cursor: pointer; }
.art-palette, .sticker-row { display: flex; justify-content: center; gap: .5rem; flex-wrap: wrap; }
.colour-pick { width: 2.9rem; height: 2.9rem; border-radius: 50%; border: .22rem solid var(--ink); background: var(--c); cursor: pointer; }
.colour-pick.on { box-shadow: 0 0 0 .25rem #fff, 0 0 0 .45rem var(--ink); }
.sticker-pick { width: 3.2rem; height: 3.2rem; border-radius: var(--radius-s); border: .2rem solid var(--ink); background: #fff; cursor: pointer; }
.sticker-pick img.emo { width: 2.2rem; height: 2.2rem; }
.sticker-pick.on { background: var(--sun); }
.page-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .7rem; }
.page-thumb { display: flex; flex-direction: column; align-items: center; gap: .2rem; padding: .4rem; border: .2rem solid var(--ink); border-radius: var(--radius-m); background: #fff; cursor: pointer; font-weight: 600; font-size: .95rem; }
.page-thumb img, .blank-page { width: 100%; aspect-ratio: 3 / 2; border-radius: .4rem; border: .1rem solid #D5DEF5; }
.blank-page { display: grid; place-items: center; color: var(--ink-soft); }
.gallery-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .7rem; }
.gallery-item { margin: 0; display: flex; flex-direction: column; gap: .3rem; align-items: center; }
.gallery-item img { width: 100%; border: .2rem solid var(--ink); border-radius: var(--radius-s); }
.gallery-item figcaption { font-size: .9rem; color: var(--ink-soft); }

/* =========================================================
   Memory Match
   ========================================================= */
.mm-grid { display: grid; grid-template-columns: repeat(var(--cols), 1fr); gap: .9rem; max-width: 52rem; margin: 0 auto; perspective: 60rem; }
.mm-hard { gap: .6rem; max-width: 48rem; }
.mm-card { position: relative; aspect-ratio: 4 / 3; border: 0; padding: 0; background: none; cursor: pointer; }
.mm-easy .mm-card { aspect-ratio: 1 / 1; }
.mm-inner { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform .35s ease; }
.mm-card.up .mm-inner { transform: rotateY(180deg); }
.mm-back, .mm-front { position: absolute; inset: 0; display: grid; place-items: center; border: .25rem solid var(--ink); border-radius: var(--radius-m); backface-visibility: hidden; -webkit-backface-visibility: hidden; box-shadow: 0 .3rem 0 var(--ink); }
.mm-back { background: var(--tangerine); background-image: radial-gradient(rgba(255,255,255,.35) .3rem, transparent .32rem); background-size: 1.4rem 1.4rem; }
.mm-back img.emo { width: 2.6rem; height: 2.6rem; opacity: .9; }
.mm-front { background: #fff; transform: rotateY(180deg); }
.mm-front img.emo { width: 60%; height: 60%; }
.mm-card.matched .mm-front { background: #E6FBEC; border-color: var(--leaf-d); }
body.reduced-motion .mm-inner { transition: none; }

/* =========================================================
   Bubble Pop
   ========================================================= */
.screen-bubbles { display: flex; flex-direction: column; }
.bp-wrap { flex: 1; min-height: 16rem; height: calc(100vh - 11.5rem); background: linear-gradient(#BFEFFF, #E8FAFF); border: .28rem solid var(--ink); border-radius: var(--radius-l); overflow: hidden; }
.bp-canvas { display: block; touch-action: none; cursor: pointer; }

/* =========================================================
   My Little Pet
   ========================================================= */
.pet-layout { display: grid; grid-template-columns: 1.1fr 1fr; gap: 1.2rem; align-items: start; border-radius: var(--radius-l); transition: background .6s; }
.pet-layout.night { background: rgba(29,43,83,.35); }
.pet-left { display: flex; flex-direction: column; align-items: center; }
.pet-stage { width: 100%; max-width: 26rem; aspect-ratio: 300 / 320; cursor: pointer; }
.pet-stage.small { max-width: 18rem; }
.pet-stage svg, .pet-thumb svg, .ward-preview svg, .mini-pet svg { width: 100%; height: 100%; display: block; }
body:not(.reduced-motion) .pet-stage[data-expr="happy"] .pet-head { animation: pet-bounce .8s ease-in-out infinite; transform-origin: 150px 200px; }
body:not(.reduced-motion) .pet-stage[data-expr="eating"] .pet-head { animation: pet-chew .3s ease-in-out infinite; transform-origin: 150px 200px; }
body:not(.reduced-motion) .pet-stage[data-expr="sleepy"] .pet-body, body:not(.reduced-motion) .pet-stage[data-expr="sleepy"] .pet-head { animation: pet-breathe 2.4s ease-in-out infinite; transform-origin: 150px 290px; }
@keyframes pet-bounce { 50% { transform: translateY(-8px) rotate(-3deg); } }
@keyframes pet-chew { 50% { transform: translateY(3px); } }
@keyframes pet-breathe { 50% { transform: scaleY(.97); } }
.pet-bubble { position: relative; padding: .5rem 1.2rem; background: #fff; border: .22rem solid var(--ink); border-radius: 1.4rem; font-size: 1.4rem; font-weight: 700; min-height: 2rem; }
.pet-bubble::after { content: ''; position: absolute; left: 50%; bottom: -.9rem; width: 1.2rem; height: 1.2rem; background: #fff; border-right: .22rem solid var(--ink); border-bottom: .22rem solid var(--ink); transform: translateX(-50%) rotate(45deg); }
.pet-right h3 { margin: .8rem 0 .4rem; font-size: 1.3rem; }
.pet-bars { display: flex; flex-direction: column; gap: .5rem; }
.pet-bar { display: grid; grid-template-columns: 2rem 5.5rem 1fr; align-items: center; gap: .4rem; font-size: 1.15rem; font-weight: 600; }
.pet-bar img.emo { width: 1.8rem; height: 1.8rem; }
.pet-bar .bar { height: 1.4rem; border: .2rem solid var(--ink); border-radius: 999px; background: #fff; overflow: hidden; }
.pet-bar .bar i { display: block; height: 100%; background: var(--tone); transition: width .5s; }
.food-tray { display: flex; gap: .6rem; flex-wrap: wrap; }
.food { width: 4.6rem; height: 4.6rem; border: .22rem solid var(--ink); border-radius: var(--radius-m); background: #fff; cursor: pointer; box-shadow: 0 .25rem 0 var(--ink); }
.food img.emo { width: 3rem; height: 3rem; }
.pet-actions { display: flex; flex-wrap: wrap; gap: .7rem; margin-top: 1rem; padding-bottom: var(--press); }
.center { text-align: center; }
.pet-thumb { width: 8rem; height: 8.5rem; }
.ball-area { position: relative; height: calc(100vh - 16rem); min-height: 14rem; background: linear-gradient(#C8F0FF 65%, #9BE07A 65%); border: .28rem solid var(--ink); border-radius: var(--radius-l); overflow: hidden; }
.ball { position: absolute; width: 5.5rem; height: 5.5rem; border: 0; background: none; cursor: pointer; transition: left .45s ease, top .45s ease; }
.ball img.emo { width: 100%; height: 100%; }
.mini-pet { position: absolute; left: 1rem; bottom: .5rem; width: 9rem; height: 9.6rem; pointer-events: none; }
.mini-pet.big { position: static; width: 12rem; height: 12.8rem; }
.ward-layout { display: grid; grid-template-columns: 18rem 1fr; gap: 1.2rem; align-items: start; }
.wardrobe { display: grid; grid-template-columns: repeat(3, 1fr); gap: .8rem; padding-bottom: var(--press); }
.ward-item { display: flex; flex-direction: column; align-items: center; gap: .1rem; padding: .5rem; border: .22rem solid var(--ink); border-radius: var(--radius-m); background: #fff; cursor: pointer; box-shadow: 0 .25rem 0 var(--ink); }
.ward-item.on { background: #FFF3C4; }
.ward-item.locked .ward-preview { filter: grayscale(1) opacity(.5); }
.ward-preview { width: 6rem; height: 6.4rem; }
.ward-name { font-weight: 700; font-size: 1.1rem; }
.ward-state { font-size: .9rem; color: var(--ink-soft); }

/* =========================================================
   Watch & Learn
   ========================================================= */
.cat-chips { display: flex; gap: .6rem; flex-wrap: wrap; margin-bottom: 1rem; }
.cat-chip { display: inline-flex; align-items: center; gap: .4rem; padding: .45rem 1rem; border: .22rem solid var(--ink); border-radius: 999px; background: #fff; font-size: 1.1rem; font-weight: 700; cursor: pointer; }
.cat-chip img.emo { width: 1.5rem; height: 1.5rem; }
.cat-chip.on { background: var(--red); color: #fff; }
.video-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
.video-card { display: flex; flex-direction: column; gap: .25rem; padding: .5rem .5rem .7rem; border: .22rem solid var(--ink); border-radius: var(--radius-m); background: #fff; cursor: pointer; text-align: left; box-shadow: 0 .3rem 0 var(--ink); }
.video-card:active { transform: translateY(.3rem); box-shadow: none; }
.thumb { position: relative; aspect-ratio: 16 / 9; border-radius: .6rem; overflow: hidden; background: #D5DEF5; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb.fallback { display: grid; place-items: center; background: linear-gradient(135deg, #FFD6D6, #D6E8FF); }
.thumb.fallback > img.emo { width: 3.5rem; height: 3.5rem; }
.play-badge { position: absolute; right: .4rem; bottom: .4rem; width: 2.4rem; height: 2.4rem; border-radius: 50%; background: #fff; display: grid; place-items: center; border: .15rem solid var(--ink); }
.play-badge img.emo { width: 1.5rem; height: 1.5rem; }
.v-title { font-size: 1.05rem; font-weight: 700; line-height: 1.15; }
.v-channel { font-size: .88rem; color: var(--ink-soft); }
.video-note { margin: 1rem 0 0; font-size: .92rem; color: var(--ink-soft); text-align: center; }
.empty { grid-column: 1 / -1; text-align: center; font-size: 1.2rem; }
.join-card { display: flex; align-items: center; gap: .7rem; padding: .5rem .6rem .5rem .9rem; margin-bottom: .9rem; background: #FFF3C4; border: .22rem solid var(--ink); border-radius: var(--radius-m); font-size: 1.15rem; font-weight: 600; }
.join-card > img.emo { width: 2rem; height: 2rem; }
.join-card span { flex: 1; }
.player-layout { display: flex; flex-direction: column; gap: .8rem; height: 100%; }
.player-shell { position: relative; width: 100%; max-width: calc((100vh - 15rem) * 16 / 9); margin: 0 auto; aspect-ratio: 16 / 9; min-height: 200px; min-width: 200px; background: #000; border: .3rem solid var(--ink); border-radius: var(--radius-m); overflow: hidden; }
.player-box, .player-box iframe, .player-box > div, .html5-video { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.player-overlay { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .7rem; padding: 1rem; text-align: center; background: rgba(29,43,83,.78); color: #fff; font-size: 1.2rem; }
.player-overlay p { margin: 0; max-width: 34rem; }
.player-overlay.error { background: #FFF3F3; color: var(--ink); }
.player-overlay .err-title { font-size: 1.6rem; font-weight: 700; }
.player-overlay.tap { background: rgba(29,43,83,.55); }
.player-controls { display: flex; flex-direction: column; gap: .6rem; max-width: 64rem; width: 100%; margin: 0 auto; padding-bottom: var(--press); }
.big-control { min-height: 3.4rem; }
.progress { flex: 1; height: 1.2rem; border: .2rem solid var(--ink); border-radius: 999px; background: #fff; overflow: hidden; cursor: pointer; }
.progress i { display: block; height: 100%; width: 0; background: var(--red); }
.time { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 6.5rem; text-align: right; }
.share-badge { display: inline-flex; align-items: center; gap: .4rem; max-width: 26rem; padding: .35rem .8rem; border-radius: var(--radius-m); background: #EEF3FF; border: .16rem solid var(--ink); font-size: .95rem; font-weight: 600; }
.share-badge.live { background: #E6FBEC; }
.share-badge.wait { background: #FFF3C4; }
.link-box, .text-in { width: 100%; box-sizing: border-box; padding: .55rem .7rem; font-size: 1.05rem; border: .18rem solid var(--ink); border-radius: var(--radius-s); -webkit-user-select: text; user-select: text; background: #fff; }
.cat-list { display: flex; flex-direction: column; gap: .3rem; max-height: 16rem; overflow: auto; margin: .5rem 0; padding-right: .3rem; }
.cat-row { display: flex; align-items: center; gap: .6rem; padding: .3rem .5rem; border-radius: var(--radius-s); background: #F5F8FF; }
.cat-row.off { opacity: .6; }
.cat-row-title { flex: 1; font-weight: 600; }
.cat-row-meta { font-size: .85rem; color: var(--ink-soft); }
.cat-add { display: grid; grid-template-columns: 1.4fr 1.2fr .9fr auto; gap: .5rem; align-items: center; padding-bottom: var(--press); }
.cat-editor h3 { margin: .8rem 0 .3rem; }
.modal:has(.cat-editor) { width: min(52rem, 94%); }

@media (max-aspect-ratio: 5/4) {
  .letter-grid { grid-template-columns: repeat(7, 1fr); }
  .video-grid { grid-template-columns: repeat(3, 1fr); }
  .pz-board { flex-direction: column; }
  .pet-layout, .ward-layout { grid-template-columns: 1fr; }
  .menu-grid.four { grid-template-columns: repeat(2, 1fr); }
  .cat-add { grid-template-columns: 1fr 1fr; }
}
