/* style.css — one classroom, drawn with boxes and border-radius.
   Stacking is deliberate and spelled out, because "something invisible is
   covering the buttons" is the bug that keeps coming back:
     room and pupils .... 1
     bubbles ............ 20
     hud / noise ........ 50
     floating points .... 100
     end-of-round card .. 300                                              */

:root {
  --wall: #f5ead6;
  --wall2: #eadcc0;
  --chalk: #2f6b52;
  --wood: #b0763f;
  --wood2: #97622f;
  --ink: #2a2a33;
  --good: #34a05a;
  --bad: #d8453f;
  --gold: #f0b429;
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; height: 100%; overflow: hidden;
  font-family: "Baloo 2", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--wall);
  background-image:
    radial-gradient(1200px 700px at 50% -20%, #fffaf0, transparent 70%),
    repeating-linear-gradient(90deg, transparent 0 78px, rgba(0,0,0,.028) 78px 80px);
  user-select: none;
}
body { display: flex; flex-direction: column; }

button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }

/* ------------------------------------------------------------- the menu -- */
#menu {
  position: fixed; inset: 0; z-index: 400;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background: linear-gradient(160deg, #2f6b52, #1e4736 60%, #16332a);
}
#menu[hidden] { display: none; }
.menu-box {
  width: min(560px, 100%); text-align: center; color: #f3f7f2;
  background: rgba(0,0,0,.22); border: 3px solid rgba(255,255,255,.16);
  border-radius: 26px; padding: clamp(22px, 5vw, 42px);
  box-shadow: 0 24px 60px rgba(0,0,0,.35);
}
.chalk {
  font-size: clamp(44px, 13vw, 84px); font-weight: 800; letter-spacing: -1px; line-height: 1;
  color: #fff; text-shadow: 0 3px 0 rgba(0,0,0,.25);
}
.tagline { font-size: clamp(15px, 3.6vw, 18px); line-height: 1.6; opacity: .92; margin: 16px 0 8px; }
.note { font-size: 15px; opacity: .8; margin-bottom: 10px; }
.best { margin-top: 14px; font-size: 15px; opacity: .85; }
.linky { margin-top: 12px; font-size: 14px; opacity: .7; text-decoration: underline; }
.menu-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 4px 16px; }
.teacher-card {
  margin: 12px auto 2px; display: flex; align-items: center; justify-content: center; gap: 12px;
  color: #fff; background: rgba(255,255,255,.1); border: 2px solid rgba(255,255,255,.18);
  border-radius: 16px; padding: 8px 16px; min-width: min(280px, 100%);
}
.teacher-card > span:last-child { display: flex; flex-direction: column; text-align: left; }
.teacher-card small { opacity: .7; font-size: 11px; }
.tp-avatar { position: relative; display: inline-flex; flex-direction: column; align-items: center; width: 42px; height: 54px; }
.tp-head { position: relative; z-index: 2; width: 34px; height: 36px; border-radius: 45%; background: var(--skin); }
.tp-hair { position: absolute; left: -4%; right: -4%; top: -7%; height: 38%; border-radius: 50% 50% 18% 18%; background: var(--hair); }
.tp-head[data-hair="long"] .tp-hair { height: 68%; left: -10%; right: -10%; }
.tp-head[data-hair="bald"] .tp-hair { display: none; }
.tp-head[data-hair="mohawk"] .tp-hair { left: 34%; right: 34%; top: -22%; height: 34%; border-radius: 70% 70% 10% 10%; }
.tp-head[data-hair="curls"] .tp-hair,
.tp-head[data-hair="coils"] .tp-hair { height: 45%; background: radial-gradient(circle at 20% 60%, var(--hair) 0 28%, transparent 30%), radial-gradient(circle at 50% 35%, var(--hair) 0 34%, transparent 36%), radial-gradient(circle at 80% 60%, var(--hair) 0 28%, transparent 30%); }
.tp-eye { position: absolute; top: 48%; width: 4px; height: 5px; border-radius: 50%; background: var(--eye); }
.tp-eye.left { left: 8px; } .tp-eye.right { right: 8px; }
.tp-body { width: 40px; height: 22px; margin-top: -4px; border-radius: 45% 45% 8px 8px; background: var(--top); }
.tp-body[data-top="striped"], .hud-teacher-body[data-top="striped"] { background: repeating-linear-gradient(0deg,var(--top) 0 5px,#fff9 5px 7px); }
.tp-body[data-top="jacket"], .hud-teacher-body[data-top="jacket"] { background: linear-gradient(90deg,var(--top) 0 46%,#fff9 46% 54%,var(--top) 54%); }
.tp-body[data-top="hoodie"], .hud-teacher-body[data-top="hoodie"] { box-shadow: inset 0 5px rgba(0,0,0,.13); }
.tp-body[data-top="dress"] { width: 46px; clip-path: polygon(18% 0,82% 0,100% 100%,0 100%); }
.tp-accessory { position: absolute; left: 50%; top: -15px; transform: translateX(-50%); font-size: 15px; }
.passport-modal { position: fixed; inset: 0; z-index: 1000; overflow: auto; padding: 16px; background: rgba(13,28,22,.88); }
.passport-modal[hidden] { display: none; }
.passport-editor { width: min(680px, 100%); margin: auto; }

.big {
  display: inline-block; margin-top: 12px;
  background: var(--gold); color: #3a2a00; font-weight: 800;
  font-size: clamp(19px, 4.6vw, 24px); padding: 16px 34px; border-radius: 999px;
  box-shadow: 0 6px 0 #c8920f; transition: transform .08s, box-shadow .08s;
}
.big:active { transform: translateY(4px); box-shadow: 0 2px 0 #c8920f; }

/* ------------------------------------------------------------ the scene -- */
.scene {
  position: relative; flex: 1; min-height: 0;
  display: flex; flex-direction: column;
  padding: max(8px, env(safe-area-inset-top)) 10px calc(8px + env(safe-area-inset-bottom));
  gap: 8px;
}
.scene[hidden] { display: none; }

/* ------------------------------------------------------------- the hud --- */
.hud {
  position: relative; z-index: 50; flex: none;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: #fff; border: 2px solid #e3d7bd; border-radius: 16px;
  padding: 8px 12px; box-shadow: 0 3px 0 rgba(0,0,0,.06);
}
.hud-title { font-weight: 800; font-size: clamp(15px, 3.4vw, 19px); }
.hud-teacher { position: relative; width: 29px; height: 34px; flex: none; display: flex; flex-direction: column; align-items: center; }
.hud-teacher-head { position: relative; z-index: 2; width: 22px; height: 23px; border-radius: 45%; background: var(--skin); box-shadow: inset 0 -2px rgba(0,0,0,.08); }
.hud-teacher-head::before { content: ''; position: absolute; left: -4%; right: -4%; top: -7%; height: 38%; border-radius: 50% 50% 18% 18%; background: var(--hair); }
.hud-teacher-head[data-hair="long"]::before { height: 68%; left: -10%; right: -10%; }
.hud-teacher-head[data-hair="bald"]::before { display: none; }
.hud-teacher-head[data-hair="mohawk"]::before { left: 34%; right: 34%; top: -22%; height: 34%; }
.hud-teacher-head i { position: absolute; top: 48%; width: 3px; height: 3px; border-radius: 50%; background: var(--eye); }
.hud-teacher-head i:first-child { left: 5px; } .hud-teacher-head i:last-child { right: 5px; }
.hud-teacher-body { width: 27px; height: 14px; margin-top: -2px; border-radius: 45% 45% 5px 5px; background: var(--top); }
.hud-teacher-body[data-top="dress"] { width: 31px; clip-path: polygon(18% 0,82% 0,100% 100%,0 100%); }
.hud-stats { display: flex; gap: 8px; margin-left: auto; flex-wrap: wrap; }
.stat {
  display: flex; align-items: center; gap: 5px;
  background: #f6f1e4; border-radius: 10px; padding: 4px 9px; font-size: 14px;
}
.stat b { font-size: 17px; }
.stat .lbl { opacity: .6; font-size: 12px; }
.stat.pop { animation: pop .35s ease; }
@keyframes pop { 0%{transform:scale(1)} 45%{transform:scale(1.22)} 100%{transform:scale(1)} }

.clock { position: relative; width: 100%; height: 12px; background: #ece3cf; border-radius: 999px; overflow: hidden; }
.clock-fill { height: 100%; width: 100%; background: linear-gradient(90deg, #57b979, #8fd35f); transition: width .1s linear; }
.clock.low .clock-fill { background: linear-gradient(90deg, #e8664f, #f0a03c); }
.clock-num {
  position: absolute; right: 8px; top: -20px; font-size: 13px; font-weight: 800; opacity: .65;
}

/* ---------------------------------------------------------- chalkboard --- */
.board {
  flex: none; text-align: center;
  background: var(--chalk); color: #eaf6ee;
  border: 6px solid var(--wood2); border-radius: 10px;
  padding: 8px 14px; font-size: clamp(14px, 3.2vw, 18px);
  box-shadow: inset 0 0 34px rgba(0,0,0,.22);
}

/* ------------------------------------------------------------ the class -- */
.room {
  position: relative; z-index: 1; flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: repeat(var(--cols, 4), 1fr);
  align-content: center; justify-items: center;
  gap: clamp(4px, 1.4vw, 14px);
  padding: 4px;
}

.pupil {
  position: relative; display: flex; flex-direction: column; align-items: center;
  width: 100%; max-width: 130px; padding: 2px 0 0;
  transition: transform .12s;
}
.pupil:active { transform: scale(.95); }

.kid { position: relative; display: flex; flex-direction: column; align-items: center; transition: transform .22s ease; }
.pupil.lean-left .kid { transform: translateX(-26%) rotate(-16deg); }
.pupil.lean-right .kid { transform: translateX(26%) rotate(16deg); }

.head {
  position: relative;
  width: clamp(30px, 7.2vw, 50px); aspect-ratio: 1 / 1.06;
  border-radius: 42% 42% 46% 46% / 40% 40% 52% 52%;
  box-shadow: inset 0 -3px 0 rgba(0,0,0,.08);
}
.hair { position: absolute; left: -6%; right: -6%; top: -12%; height: 46%; border-radius: 50% 50% 20% 20%; }
.hair.h1 { height: 34%; border-radius: 50% 50% 6% 6%; }
.hair.h2 { height: 54%; left: -12%; right: -12%; border-radius: 50% 50% 38% 38%; }

.eye {
  position: absolute; top: 46%; width: 22%; aspect-ratio: 1;
  background: #fff; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.12);
}
.eye.left { left: 18%; } .eye.right { right: 18%; }
.eye i { width: 52%; height: 52%; background: #22222c; border-radius: 50%; transition: transform .16s ease; }
.pupil[data-look="left"]  .eye i { transform: translateX(-42%); }
.pupil[data-look="right"] .eye i { transform: translateX(42%); }
.pupil[data-look="up"]    .eye i { transform: translateY(-38%); }
.pupil[data-look="down"]  .eye i { transform: translateY(34%); }

.mouth {
  position: absolute; left: 50%; top: 72%; transform: translateX(-50%);
  width: 30%; height: 9%; background: #7d4436; border-radius: 0 0 999px 999px;
}
.pupil[data-mood="happy"] .mouth { height: 16%; background: #7d2f2f; }
.pupil[data-mood="sad"] .mouth,
.pupil[data-mood="cross"] .mouth { border-radius: 999px 999px 0 0; }
.pupil[data-mood="caught"] .head { box-shadow: inset 0 -3px 0 rgba(0,0,0,.08), 0 0 0 3px #f3a; }
.pupil[data-mood="cross"] .head { filter: saturate(1.3); }

.body {
  width: clamp(34px, 8vw, 58px); height: clamp(20px, 4.6vw, 34px);
  margin-top: -4px; border-radius: 40% 40% 14% 14%;
}

.bubble {
  position: absolute; z-index: 20; left: 50%; top: -34%;
  transform: translate(-50%, 6px) scale(.5); opacity: 0;
  font-size: clamp(17px, 4.2vw, 26px); line-height: 1;
  background: #fff; border: 2px solid #e2d6bc; border-radius: 999px;
  padding: 3px 7px; box-shadow: 0 3px 8px rgba(0,0,0,.14);
  transition: transform .16s ease, opacity .16s ease; pointer-events: none;
}
.bubble.on { opacity: 1; transform: translate(-50%, 0) scale(1); }

.desk {
  position: relative; width: 96%; max-width: 118px;
  height: clamp(14px, 3.4vw, 24px); margin-top: -2px;
  background: linear-gradient(180deg, var(--wood), var(--wood2));
  border-radius: 5px; box-shadow: 0 3px 0 rgba(0,0,0,.16);
}
.paper {
  position: absolute; left: 50%; top: -5px; transform: translateX(-50%);
  width: 58%; height: 62%; background: #fdfbf3; border-radius: 2px;
  box-shadow: 0 1px 2px rgba(0,0,0,.16);
}
.tag { font-size: clamp(10px, 2.4vw, 13px); font-weight: 700; opacity: .72; margin-top: 3px; }

.pupil.busted { animation: shake .4s; }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-6px)} 75%{transform:translateX(6px)} }
.pupil.noisy .desk { box-shadow: 0 3px 0 rgba(0,0,0,.16), 0 0 0 3px rgba(216,69,63,.35); }
.pupil.hand .kid { animation: wave 1s ease-in-out infinite; }
@keyframes wave { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-6px)} }

.pupil.empty { opacity: .55; }
.pupil.empty .kid.gone {
  width: clamp(30px, 7.2vw, 50px); height: clamp(54px, 12vw, 84px);
  border: 3px dashed #c7b795; border-radius: 12px;
}

/* ------------------------------------------------------- register list --- */
.namelist {
  flex: none; background: #fff; border: 2px solid #e3d7bd; border-radius: 16px; padding: 8px 10px;
}
.namelist h3 { margin: 0 0 7px; font-size: 14px; opacity: .7; font-weight: 700; }
.names { display: flex; flex-wrap: wrap; gap: 6px; }
.name {
  background: #f6f1e4; border: 2px solid #e3d7bd; border-radius: 999px;
  padding: 7px 13px; font-size: clamp(13px, 3vw, 15px); font-weight: 700;
}
.name.right { background: #dff3e4; border-color: var(--good); }
.name.wrong { background: #fbe0de; border-color: var(--bad); opacity: .8; }

/* ------------------------------------------------------------- noise ----- */
.noise {
  position: relative; z-index: 50; flex: none;
  display: flex; align-items: center; gap: 9px;
  background: #fff; border: 2px solid #e3d7bd; border-radius: 14px; padding: 6px 12px;
}
.noise-label { font-size: 13px; font-weight: 700; opacity: .7; white-space: nowrap; }
.noise-bar { flex: 1; height: 13px; background: #ece3cf; border-radius: 999px; overflow: hidden; }
.noise-fill { height: 100%; width: 0; background: linear-gradient(90deg, #6fc98a, #e8c34f); transition: width .12s linear; }
.noise.loud .noise-fill { background: linear-gradient(90deg, #f08a3c, #e0453f); }
.noise.loud { animation: buzz .35s ease-in-out infinite; }
@keyframes buzz { 0%,100%{transform:translateX(0)} 50%{transform:translateX(2px)} }

/* ----------------------------------------------------------- marking ----- */
.marking { align-items: center; justify-content: center; }
.markdesk { display: flex; flex-direction: column; align-items: center; gap: clamp(14px, 4vw, 30px); width: 100%; }
.book {
  width: min(460px, 92%); background: #fffdf6;
  border: 3px solid #e3d7bd; border-left: 12px solid var(--wood);
  border-radius: 10px; padding: clamp(18px, 5vw, 34px); text-align: center;
  box-shadow: 0 8px 0 rgba(0,0,0,.07);
}
.book.in { animation: dealt .22s ease; }
@keyframes dealt { from { transform: translateY(14px) rotate(-1.5deg); opacity: 0 } to { transform: none; opacity: 1 } }
.book.ok { border-color: var(--good); background: #f2fbf4; }
.book.no { border-color: var(--bad); background: #fdf1f0; }
.who { font-size: 14px; opacity: .6; margin-bottom: 10px; font-weight: 700; }
.sum { font-size: clamp(30px, 9vw, 54px); font-weight: 800; letter-spacing: 1px; }
.markbtns { display: flex; gap: clamp(12px, 4vw, 26px); }
.mark {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: clamp(30px, 8vw, 44px);
  background: #fff; border: 3px solid #e3d7bd; border-radius: 20px;
  padding: 12px clamp(18px, 6vw, 40px); box-shadow: 0 5px 0 rgba(0,0,0,.1);
}
.mark span { font-size: 13px; font-weight: 700; opacity: .6; }
.mark:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0,0,0,.1); }
.mark.tick { border-color: #bfe6cb; } .mark.cross { border-color: #f0c9c6; }

/* ------------------------------------------------------ floaty bits ------ */
.say {
  position: absolute; z-index: 100; left: 50%; top: 64px; transform: translateX(-50%);
  background: rgba(28,28,34,.9); color: #fff; font-weight: 700;
  font-size: clamp(14px, 3.4vw, 17px); padding: 9px 18px; border-radius: 999px;
  animation: sayin .28s ease; pointer-events: none; max-width: 92%; text-align: center;
}
.say.good { background: rgba(36,132,74,.94); }
.say.bad { background: rgba(190,53,47,.94); }
.say.out { opacity: 0; transform: translate(-50%, -10px); transition: .3s; }
@keyframes sayin { from { opacity: 0; transform: translate(-50%, 10px) } }

.float {
  position: absolute; z-index: 100; transform: translate(-50%, -50%);
  font-weight: 800; font-size: clamp(16px, 4vw, 22px); pointer-events: none;
  animation: floaty .9s ease-out forwards; text-shadow: 0 2px 0 rgba(255,255,255,.7);
}
.float.good { color: #1c8a4a; } .float.bad { color: #c8342e; }
@keyframes floaty { to { transform: translate(-50%, -220%); opacity: 0 } }

/* --------------------------------------------------------- round card ---- */
.card-screen {
  position: absolute; inset: 0; z-index: 300;
  display: flex; align-items: center; justify-content: center; padding: 18px;
  background: rgba(22,30,26,.72); backdrop-filter: blur(3px);
  animation: sayin .22s ease;
}
.card-box {
  width: min(480px, 100%); text-align: center; color: #23231f;
  background: #fffdf6; border: 4px solid #e3d7bd; border-radius: 24px;
  padding: clamp(22px, 5vw, 36px); box-shadow: 0 20px 50px rgba(0,0,0,.3);
}
.card-screen.bad .card-box { border-color: #eec0bc; }
.card-box h2 { margin: 0 0 12px; font-size: clamp(23px, 6vw, 32px); }
.card-box p { margin: 7px 0; font-size: clamp(14px, 3.6vw, 17px); line-height: 1.55; }
.stars { font-size: clamp(22px, 6vw, 30px); letter-spacing: 3px; }

/* on anything wide the carpet sits them six across instead of four */
@media (min-width: 680px) { .carpetarea { grid-template-columns: repeat(6, 1fr); } }

/* Landscape on a tablet: the class gets the room, the lists stay small. */
@media (orientation: landscape) and (max-height: 560px) {
  .board { padding: 5px 12px; font-size: 14px; }
  .tag { display: none; }
}

/* ------------------------------------------------- breaking the rules ----
   Everything a pupil can be doing wrong in the inspection round.

   These are drawn as the very same emoji shown in the rules strip along the
   top. The first version drew a cap out of CSS boxes, and on a pupil with
   auburn hair it just looked like more hair — which is not a fair thing to
   ask anyone to spot. Matching the icon exactly means she can always check
   what she is looking at against the rule.                                */
.hat, .phones, .phone, .sweet { display: none; }

.brk-hat .hat, .brk-phones .phones {
  display: block; position: absolute; left: 50%; transform: translateX(-50%);
  font-size: clamp(19px, 4.6vw, 30px); line-height: 1;
  filter: drop-shadow(0 2px 2px rgba(0,0,0,.3));
}
.brk-hat .hat { top: -52%; }
.brk-hat .hat::before { content: '🧢'; }
.brk-phones .phones { top: -30%; }
.brk-phones .phones::before { content: '🎧'; }

.brk-phone .phone, .brk-sweet .sweet {
  display: block; position: absolute; top: -80%;
  font-size: clamp(15px, 3.6vw, 23px); line-height: 1;
  filter: drop-shadow(0 2px 2px rgba(0,0,0,.25));
}
.brk-phone .phone { right: 6%; }
.brk-phone .phone::before { content: '📱'; }
.brk-sweet .sweet { left: 6%; }
.brk-sweet .sweet::before { content: '🍭'; }

/* fast asleep instead of working */
.brk-asleep .eye { transform: scaleY(.16); }
.brk-asleep .kid { transform: rotate(-10deg); }

/* no work out at all — everyone else has a sheet of paper */
.brk-nowork .paper { display: none; }

/* the rule card down the side, so she can always check what counts */
.rules {
  flex: none; display: flex; flex-wrap: wrap; gap: 6px; justify-content: center;
  background: #fff; border: 2px solid #e3d7bd; border-radius: 14px; padding: 7px 10px;
}
.rule {
  display: flex; align-items: center; gap: 5px;
  background: #f6f1e4; border-radius: 999px; padding: 4px 10px;
  font-size: clamp(11px, 2.6vw, 13.5px); font-weight: 700;
}
.rule .ic { font-size: 15px; }
.wave {
  position: absolute; z-index: 100; left: 50%; top: 46%; transform: translate(-50%,-50%);
  font-size: clamp(26px, 8vw, 44px); font-weight: 800; color: #2f6b52;
  text-shadow: 0 3px 0 rgba(255,255,255,.8); pointer-events: none;
  animation: waveflash .9s ease forwards;
}
@keyframes waveflash { 0%{opacity:0;transform:translate(-50%,-50%) scale(.6)} 30%{opacity:1;transform:translate(-50%,-50%) scale(1)} 100%{opacity:0;transform:translate(-50%,-90%) scale(1)} }
.pupil.found .desk { box-shadow: 0 3px 0 rgba(0,0,0,.16), 0 0 0 3px var(--good); }

/* --------------------------------------------------------- home time -----
   No timer here, so nothing needs to be quick to read. Big, warm, and
   everything you can touch looks touchable.                               */
.outside { justify-content: flex-end; padding: 0; }
.outside .sky {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, #f9b45e 0%, #f08a5d 38%, #c96b6b 62%, #6b4b7a 100%);
}
.outside .sun { position: absolute; right: 12%; top: 14%; font-size: clamp(40px, 11vw, 78px); }
.street { position: relative; z-index: 2; display: flex; flex-direction: column; align-items: center; padding-bottom: 4vh; }
.house { position: relative; width: min(340px, 76vw); }
.roof {
  width: 0; height: 0; margin: 0 auto;
  border-left: min(180px, 40vw) solid transparent;
  border-right: min(180px, 40vw) solid transparent;
  border-bottom: clamp(60px, 15vw, 96px) solid #8d4038;
  filter: drop-shadow(0 -3px 0 rgba(0,0,0,.12));
}
.frontwall {
  position: relative; background: #e8d6b4; border: 4px solid #c3ab84; border-top: 0;
  border-radius: 0 0 10px 10px; height: clamp(130px, 30vw, 190px);
  display: flex; align-items: flex-start; justify-content: space-around; padding: 14px 12px 0;
  box-shadow: inset 0 -30px 40px rgba(0,0,0,.06);
}
.frontwall .window {
  width: 24%; height: 34%; background: #ffe9a8; border: 4px solid #a9855a; border-radius: 4px;
  box-shadow: 0 0 22px rgba(255, 220, 130, .7);
}
.frontdoor {
  position: absolute; left: 50%; bottom: 0; transform: translateX(-50%);
  width: 30%; height: 52%; background: linear-gradient(180deg, #a4622f, #8a4f26);
  border: 4px solid #6f3d1c; border-bottom: 0; border-radius: 7px 7px 0 0;
  display: flex; align-items: center; justify-content: center;
  animation: doorglow 1.6s ease-in-out infinite;
}
@keyframes doorglow { 0%,100%{box-shadow:0 0 0 0 rgba(255,225,150,.0)} 50%{box-shadow:0 0 0 7px rgba(255,225,150,.35)} }
.frontdoor .knob { position: absolute; right: 12%; top: 50%; width: 9px; height: 9px; background: #f0c14b; border-radius: 50%; }
.doorhint {
  position: absolute; bottom: 108%; left: 50%; transform: translateX(-50%);
  background: #fffdf6; color: #3a2a18; font-weight: 800; font-size: 13px;
  padding: 5px 12px; border-radius: 999px; white-space: nowrap; border: 2px solid #d8c39a;
}
.path {
  width: 22%; height: clamp(26px, 7vw, 50px); border-radius: 0 0 6px 6px;
  background: repeating-linear-gradient(180deg, #c9b391 0 10px, #bda684 10px 20px);
}

.indoors { justify-content: center; }
.room {
  position: relative; flex: 1; min-height: 0; border-radius: 16px; overflow: hidden;
  border: 4px solid #d8c39a;
}
.roomwall { position: absolute; inset: 0 0 26% 0; background: linear-gradient(180deg, #f6e6c9, #efdab6); }
.roomfloor { position: absolute; inset: 74% 0 0 0; background: repeating-linear-gradient(90deg, #b98d5c 0 26px, #ac8153 26px 52px); }
.things { position: absolute; inset: 0; }
.thing {
  position: absolute; transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: rgba(255,253,246,.94); border: 3px solid #d8c39a; border-radius: 16px;
  padding: 8px 12px; box-shadow: 0 4px 0 rgba(0,0,0,.12);
  max-width: min(30vw, 150px);
  transition: transform .12s, opacity .2s;
}
.thing:active { transform: translate(-50%, -46%) scale(.95); }
.thing-ic { font-size: clamp(24px, 6.5vw, 40px); line-height: 1; }
.thing-lbl { font-size: clamp(10px, 2.5vw, 13px); font-weight: 700; opacity: .75; text-align: center; line-height: 1.25; }
.thing.done { opacity: .42; border-style: dashed; box-shadow: none; }
.thing.done .thing-ic { filter: grayscale(.7); }

.bed {
  position: absolute; right: 3%; bottom: 3%;
  display: flex; flex-direction: column; align-items: center;
  font-size: clamp(28px, 7vw, 44px);
  background: #6b4b7a; color: #fff; border-radius: 18px; padding: 10px 20px;
  box-shadow: 0 5px 0 #4d3559;
}
.bed span { font-size: clamp(12px, 2.8vw, 15px); font-weight: 800; }
.bed:active { transform: translateY(3px); box-shadow: 0 2px 0 #4d3559; }

.restbar { flex: none; display: flex; align-items: center; gap: 9px; background: #fff;
  border: 2px solid #e3d7bd; border-radius: 14px; padding: 7px 12px; }
.restlabel { font-size: 13px; font-weight: 700; opacity: .7; white-space: nowrap; }
.restouter { flex: 1; height: 13px; background: #ece3cf; border-radius: 999px; overflow: hidden; }
.restfill { height: 100%; width: 0; background: linear-gradient(90deg, #7fc9a0, #5aa9d6); transition: width .25s ease; }

/* the front room itself — none of this is tappable, it is just somewhere to be */
.decor { position: absolute; inset: 0; pointer-events: none; }
.decor .win {
  position: absolute; left: 6%; top: 8%; width: 22%; height: 30%;
  background: linear-gradient(180deg, #f7b26a, #d8737a 70%, #6b4b7a);
  border: 6px solid #c9ab7e; border-radius: 6px;
  box-shadow: 0 0 30px rgba(255,190,120,.55);
}
.decor .win span {
  position: absolute; inset: 0; border-left: 4px solid #c9ab7e; border-top: 4px solid #c9ab7e;
  left: 50%; top: 50%;
}
.decor .pic { position: absolute; right: 26%; top: 9%; font-size: clamp(26px, 6vw, 44px); opacity: .9; }
.decor .shelf {
  position: absolute; left: 36%; top: 14%; display: flex; gap: 8px; align-items: flex-end;
  padding-bottom: 5px; border-bottom: 7px solid #b98d5c; border-radius: 2px;
  font-size: clamp(16px, 4vw, 26px);
}
.decor .rug {
  position: absolute; left: 50%; bottom: 4%; transform: translateX(-50%);
  width: 52%; height: 16%; border-radius: 50%;
  background: repeating-radial-gradient(circle, #c2607a 0 10px, #a94f66 10px 20px);
  opacity: .85;
}
.decor .skirting { position: absolute; left: 0; right: 0; top: 74%; height: 3.5%; background: #e6d3ae; border-top: 3px solid #cbb287; }

/* --------------------------------------------------------------- juice --- */
.bit {
  position: absolute; z-index: 110; width: 9px; height: 9px; border-radius: 2px;
  transform: translate(-50%, -50%); pointer-events: none;
  animation: bitfly .68s cubic-bezier(.2,.7,.3,1) forwards;
}
@keyframes bitfly {
  to { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) rotate(220deg); opacity: 0; }
}
@keyframes shakesm { 0%,100%{transform:translate(0,0)} 25%{transform:translate(-5px,2px)} 75%{transform:translate(5px,-2px)} }
@keyframes shakelg { 0%,100%{transform:translate(0,0)} 20%{transform:translate(-11px,4px)} 60%{transform:translate(11px,-4px)} 85%{transform:translate(-5px,2px)} }
.shake-sm { animation: shakesm .28s ease; }
.shake-lg { animation: shakelg .42s ease; }

.combo {
  position: absolute; z-index: 105; left: 50%; top: 96px; transform: translateX(-50%);
  font-weight: 800; font-size: clamp(15px, 3.8vw, 21px); color: #b4700c;
  background: #fff6dd; border: 3px solid #f0b429; border-radius: 999px;
  padding: 5px 16px; pointer-events: none; white-space: nowrap;
  box-shadow: 0 4px 0 rgba(0,0,0,.1);
}
.combo[hidden] { display: none; }
.combo.hot { color: #fff; background: linear-gradient(90deg, #f0803e, #e8534a); border-color: #c33a34; }
.combo.bump { animation: bump .3s ease; }
@keyframes bump { 0%{transform:translateX(-50%) scale(1)} 45%{transform:translateX(-50%) scale(1.2)} 100%{transform:translateX(-50%) scale(1)} }

/* --------------------------------------------------------- playground --- */
.yard { }
.yardarea {
  position: relative; flex: 1; min-height: 0; border-radius: 16px; overflow: hidden;
  background: linear-gradient(180deg, #9dc9e8 0 26%, #8fbf6a 26% 34%, #b9b2a6 34%);
  border: 4px solid #cbb287;
}
.yardarea .markings {
  position: absolute; left: 50%; top: 58%; transform: translate(-50%,-50%);
  width: min(230px, 46%); aspect-ratio: 1; border: 5px solid rgba(255,255,255,.5); border-radius: 50%;
}
.yardarea .fence {
  position: absolute; left: 0; right: 0; top: 26%; height: 8%;
  background: repeating-linear-gradient(90deg, #7b8a99 0 4px, transparent 4px 16px);
}
.pupil.roam {
  position: absolute; width: auto; max-width: none; transform: translate(-50%,-50%);
  transition: left 1.3s ease-in-out, top 1.3s ease-in-out;
  padding: 10px 14px;              /* a bigger target than the child is drawn */
}
/* Once they are in trouble they stop dead. Chasing a child who is still
   sliding across the playground is not a fair thing to ask of a thumb. */
.pupil.roam.trouble {
  transition: none; animation: jiggle .35s ease-in-out infinite; z-index: 10;
}
@keyframes jiggle { 0%,100%{transform:translate(-50%,-50%) rotate(-6deg)} 50%{transform:translate(-50%,-50%) rotate(6deg)} }

/* -------------------------------------------------------- dinner hall --- */
.hallarea {
  position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column;
  justify-content: space-between; gap: 10px;
  background: linear-gradient(180deg, #f4e7cd, #e6d2ab);
  border: 4px solid #cbb287; border-radius: 16px; padding: 12px 10px;
}
.tables {
  position: absolute; left: 0; right: 0; top: 8%;
  display: flex; justify-content: space-around; font-size: clamp(18px, 4.5vw, 30px); opacity: .28;
}
.tables::before, .tables::after {
  content: ''; position: absolute; left: 4%; right: 4%; height: 10px;
  background: #c49a63; border-radius: 4px; opacity: .5;
}
.tables::before { top: -14px; } .tables::after { top: 46px; }
.queue {
  display: flex; align-items: center; justify-content: center;
  gap: clamp(4px, 1.6vw, 16px); flex: 1; min-height: 0; padding-bottom: 4px;
}
.pupil.queuer {
  /* the padding is the point: it makes the drop target far bigger than the
     child is drawn, which on a phone is the difference between 29px and 50px
     of something to aim a finger at */
  position: relative; width: auto; max-width: none; flex: none;
  padding: 6px 12px; min-width: 58px;
  opacity: .8; transform: scale(.85); transform-origin: bottom center;
  transition: transform .22s ease, opacity .22s ease;
  animation: joinq .28s ease;
}
/* The one you are actually serving: full size, full colour, and lit up. */
.pupil.queuer.front {
  opacity: 1; transform: scale(1.12);
  filter: drop-shadow(0 0 0 rgba(0,0,0,0));
}
.pupil.queuer.front::before {
  content: ''; position: absolute; left: 50%; bottom: -10px; transform: translateX(-50%);
  width: 108%; height: 16px; border-radius: 50%;
  background: radial-gradient(ellipse, rgba(240,180,41,.75), transparent 70%);
}
.pupil.queuer .bubble { top: -46%; font-size: clamp(15px, 3.6vw, 22px); }
.pupil.queuer.front .bubble {
  top: -86%; font-size: clamp(24px, 6.5vw, 40px); padding: 5px 12px;
  border-color: #f0b429; border-width: 3px;
}
.pupil.queuer.front .tag::after { content: ''; }
/* while you are carrying something, everyone who could take it lights up */
.queue.taking .pupil.queuer { outline: 4px dashed rgba(240,180,41,.85); outline-offset: 3px; border-radius: 14px; }
@keyframes joinq { from { opacity: 0; transform: translateX(40px) scale(.6) } }
.pupil.queuer.going { opacity: 0; transform: translateY(-16px) scale(.7); transition: .26s; }
.pupil.queuer.impatient .kid { animation: jiggle .3s ease-in-out infinite; }
.patience {
  display: block; width: 80%; height: 8px; margin: 6px auto 0;
  background: #d9c8a5; border-radius: 999px; overflow: hidden;
}
.pupil.queuer.front .patience { height: 11px; box-shadow: 0 0 0 2px rgba(240,180,41,.4); }
.patience i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg,#57b979,#e8c34f); }
.pupil.queuer.impatient .patience i { background: linear-gradient(90deg,#f0803e,#e0453f); }

.hatch { flex: none; background: #fffdf6; border: 3px solid #d8c39a; border-radius: 14px; padding: 8px; }
.hatchtop { text-align: center; font-size: 13px; font-weight: 800; opacity: .6; margin-bottom: 6px; }
.trays { display: flex; flex-wrap: wrap; justify-content: center; gap: clamp(6px, 2vw, 14px); }
.tray {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  background: #f6f1e4; border: 3px solid #d8c39a; border-radius: 14px;
  padding: 7px clamp(9px, 3vw, 20px); box-shadow: 0 4px 0 rgba(0,0,0,.1);
}
.tray-ic { font-size: clamp(23px, 6vw, 36px); line-height: 1; }
.tray-lbl { font-size: clamp(10px, 2.4vw, 12.5px); font-weight: 700; opacity: .65; }
.tray:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,.1); }

/* ---------------------------------------------- dragging and holding ----- */
.ghost {
  position: fixed; z-index: 500; transform: translate(-50%,-50%);
  font-size: clamp(30px, 8vw, 50px); pointer-events: none;
  filter: drop-shadow(0 6px 8px rgba(0,0,0,.35)); animation: lift .14s ease;
}
@keyframes lift { from { transform: translate(-50%,-50%) scale(.7) } }
.lifted { opacity: .45; }
.droptarget { outline: 4px dashed #f0b429; outline-offset: 4px; border-radius: 14px; }

.holdring {
  position: absolute; left: 50%; top: 40%; transform: translate(-50%,-50%);
  width: clamp(46px, 12vw, 74px); aspect-ratio: 1; border-radius: 50%;
  background: conic-gradient(#f0b429 calc(var(--k) * 360deg), rgba(255,255,255,.35) 0);
  pointer-events: none; opacity: 0; transition: opacity .12s;
  -webkit-mask: radial-gradient(circle, transparent 56%, #000 58%);
  mask: radial-gradient(circle, transparent 56%, #000 58%);
}
.holding .holdring, .pupil[data-k]:not([data-k="0"]) .holdring { opacity: 1; }

.trail {
  position: absolute; z-index: 108; height: 7px; border-radius: 999px;
  transform-origin: left center; pointer-events: none;
  background: linear-gradient(90deg, rgba(255,255,255,0), #fff);
  animation: fadetrail .3s ease forwards;
}
@keyframes fadetrail { to { opacity: 0 } }

/* --------------------------------------------------------- story time --- */
.carpetarea {
  position: relative; flex: 1; min-height: 0; border-radius: 16px;
  border: 4px solid #cbb287; padding: 10px;
  display: grid; grid-template-columns: repeat(4, 1fr);
  align-content: center; justify-items: center; gap: clamp(4px, 1.4vw, 12px);
  background:
    radial-gradient(ellipse at 50% 60%, #d98fa6 0 32%, #c2607a 32% 56%, #a94f66 56%),
    #f4e7cd;
}
.pupil.sitter { max-width: 110px; touch-action: none; }
.pupil.sitter.fidgeting .kid { animation: jiggle .3s ease-in-out infinite; }
.pupil.sitter.holding .kid { animation: none; }
.pupil.sitter .holdring { z-index: 22; }

/* ---------------------------------------------------------------- PE ---- */
.court {
  position: relative; flex: 1; min-height: 0; overflow: hidden;
  border: 4px solid #cbb287; border-radius: 16px; touch-action: none;
  background: linear-gradient(180deg, #f0e2c4, #dcc79f);
}
.court .net {
  position: absolute; left: 0; right: 0; top: 62%; height: 10%;
  background: repeating-linear-gradient(90deg, rgba(255,255,255,.75) 0 3px, transparent 3px 12px);
  border-top: 4px solid rgba(255,255,255,.85);
}
.court .line {
  position: absolute; left: 8%; right: 8%; bottom: 12%; height: 5px;
  background: rgba(255,255,255,.7); border-radius: 3px;
}
.flier {
  position: absolute; transform: translate(-50%,-50%);
  font-size: clamp(30px, 8vw, 50px); line-height: 1; pointer-events: none;
  filter: drop-shadow(0 3px 4px rgba(0,0,0,.28));
}
.flier.notball { filter: drop-shadow(0 3px 4px rgba(0,0,0,.28)) saturate(1.3); }
.flier.whacked { animation: whacked .3s ease forwards; }
@keyframes whacked { to { transform: translate(-50%,-50%) scale(1.9) rotate(90deg); opacity: 0 } }
.flier.fouled { animation: fouled .3s ease forwards; }
@keyframes fouled { to { transform: translate(-50%,-50%) scale(.4); opacity: 0 } }

/* ----------------------------------------------------- number bubbles --- */
.sumboard { font-weight: 800; }
.sumtext { font-size: clamp(24px, 7vw, 40px); letter-spacing: 1px; }
.sumboard.pulse { animation: sumpulse .34s ease; }
@keyframes sumpulse { 0%{transform:scale(1)} 40%{transform:scale(1.05)} 100%{transform:scale(1)} }
.tank {
  position: relative; flex: 1; min-height: 0; overflow: hidden;
  border: 4px solid #cbb287; border-radius: 16px;
  background: linear-gradient(180deg, #cfe9f7, #eaf6fb 60%, #f6efdc);
}
.bub {
  position: absolute; transform: translateX(-50%);
  min-width: clamp(52px, 13vw, 78px); aspect-ratio: 1; border-radius: 50%;
  font-size: clamp(20px, 5.5vw, 30px); font-weight: 800; color: #17506e;
  background: radial-gradient(circle at 34% 30%, rgba(255,255,255,.95), rgba(160,215,240,.85) 62%, rgba(110,185,225,.9));
  border: 3px solid rgba(255,255,255,.85);
  box-shadow: 0 4px 12px rgba(40,110,150,.25), inset 0 -6px 12px rgba(60,140,180,.25);
}
.bub::after {
  content: ''; position: absolute; left: 22%; top: 16%; width: 22%; height: 16%;
  background: rgba(255,255,255,.9); border-radius: 50%; transform: rotate(-20deg);
}
.bub:active { transform: translateX(-50%) scale(.92); }
.bub.popped { animation: popbub .2s ease forwards; }
@keyframes popbub { to { transform: translateX(-50%) scale(1.7); opacity: 0 } }

/* ---- the living classroom ---- */
.pupil.needs .bubble{opacity:var(--wait,1); transform:translateY(-4px) scale(1.06)}
.pupil.needs{animation:cl-nudge 1.1s ease-in-out infinite}
@keyframes cl-nudge{50%{transform:translateY(-3px)}}
.pupil.sorted{animation:cl-sorted .7s ease}
@keyframes cl-sorted{0%{transform:scale(1)} 45%{transform:scale(1.14)} 100%{transform:scale(1)}}
.busy-tag{position:fixed; left:50%; bottom:18px; transform:translateX(-50%) translateY(20px);
  background:#20304a; color:#fff; padding:10px 18px; border-radius:99px; font-size:15px;
  opacity:0; transition:opacity .18s, transform .18s; pointer-events:none; z-index:30}
.busy-tag.on{opacity:1; transform:translateX(-50%) translateY(0)}
.noise-fill.hot{background:linear-gradient(90deg,#ffb347,#ff5b5b)}
.head-in{position:fixed; inset:0; display:flex; flex-direction:column; align-items:center;
  justify-content:center; gap:10px; background:rgba(10,16,30,.72); color:#fff; z-index:40;
  animation:cl-head .35s ease; text-align:center; padding:20px}
.head-in span{font-size:74px}
.head-in b{font-size:clamp(18px,5vw,24px)}
@keyframes cl-head{from{opacity:0} to{opacity:1}}
