/* 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: #1b1a24;
  --wall2: #24222f;
  --chalk: #2b2838;
  --wood: #6b5b46;
  --wood2: #524636;
  --ink: #ece9f2;
  --good: #34a05a;
  --bad: #d8453f;
  --gold: #f0b429;
  color-scheme: dark;
}

* { 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: #ece9f2;
  background: var(--wall);
  background-image:
    radial-gradient(1100px 620px at 50% -15%, rgba(120,110,160,.20), transparent 70%),
    repeating-linear-gradient(90deg, transparent 0 78px, rgba(255,255,255,.02) 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, #3a3252, #1f1c2c 60%, #14121c);
}
#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);
}
.logo {
  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; }

.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 #3c3850; 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); color: #ece9f2; }
.hud-stats { display: flex; gap: 8px; margin-left: auto; flex-wrap: wrap; }
.stat {
  display: flex; align-items: center; gap: 5px;
  background: #332f44; 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: #3c3850; 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;
}

/* ------------------------------------------------------ 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(520px, 100%); text-align: center; color: #ece9f2;
  background: #2b2838; border: 4px solid #3c3850; 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); } }

/* --------------------------------------------------------------- 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: #ffffff; 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: #332f44; 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 } }



/* ------------------------------------------------------- the case board -- */
.brief {
  flex: none; background: #2b2838; border: 2px solid #3c3850; border-radius: 12px;
  padding: 8px 12px; font-size: clamp(12px, 3vw, 15px); line-height: 1.45; text-align: center;
}
.brief b { color: #f0c869; }

.boardwrap { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 8px; }
@media (min-width: 820px) { .boardwrap { flex-direction: row; } }

.lineup {
  flex: 1; min-height: 0; display: grid; gap: clamp(4px, 1.4vw, 10px);
  grid-template-columns: repeat(auto-fit, minmax(84px, 1fr));
  align-content: center; justify-items: center;
  background:
    repeating-linear-gradient(45deg, rgba(255,255,255,.015) 0 8px, transparent 8px 16px),
    #241f2e;
  border: 4px solid #3c3850; border-radius: 14px; padding: 8px; overflow: auto;
}
.sus {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: #322d42; border: 3px solid #453f5c; border-radius: 12px;
  padding: 7px 5px 5px; width: 100%; max-width: 128px;
  transition: transform .1s, opacity .18s, border-color .18s;
}
.sus:active { transform: scale(.96); }
.figure { position: relative; display: flex; flex-direction: column; align-items: center; }
.figure.short { transform: scale(.84); transform-origin: bottom center; }

.s-head {
  position: relative; width: clamp(30px, 8vw, 44px); aspect-ratio: 1/1.06;
  border-radius: 42% 42% 46% 46% / 40% 40% 52% 52%;
}
.s-hair { position: absolute; left: -7%; right: -7%; top: -14%; height: 44%; border-radius: 50% 50% 22% 22%; }
.s-hat {
  position: absolute; left: -6%; right: -6%; top: -40%; height: 40%;
  background: #d8a13c; border-radius: 46% 46% 6% 6%;
  box-shadow: inset 0 -4px 0 rgba(0,0,0,.22);
}
.s-hat::after {                      /* the brim, sticking out either side */
  content: ''; position: absolute; left: -26%; right: -26%; bottom: -5px;
  height: 7px; background: #b07d24; border-radius: 999px;
}
.s-eye { position: absolute; top: 48%; width: 15%; aspect-ratio: 1; background: #22222c; border-radius: 50%; }
.s-eye.l { left: 24%; } .s-eye.r { right: 24%; }
.s-specs { position: absolute; top: 42%; left: 8%; right: 8%; display: flex; justify-content: space-between; align-items: center; }
.s-specs::before {
  content: ''; position: absolute; left: 32%; right: 32%; top: 46%; height: 2px; background: #10101a;
}
.s-specs i {
  width: 34%; aspect-ratio: 1; border: 2.5px solid #10101a; border-radius: 50%;
  background: rgba(190,220,255,.25);
}
.s-mouth { position: absolute; left: 50%; top: 74%; transform: translateX(-50%); width: 26%; height: 8%; background: #7d4436; border-radius: 0 0 999px 999px; }
.s-body { width: clamp(34px, 9vw, 50px); height: clamp(22px, 5.5vw, 34px); margin-top: -3px; border-radius: 38% 38% 14% 14%; }
.s-bag { position: absolute; right: -22%; bottom: 2px; font-size: clamp(15px, 4vw, 22px); }
.s-name { font-size: clamp(10px, 2.5vw, 13px); font-weight: 800; opacity: .85; }

.s-cross {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: clamp(40px, 11vw, 62px); color: #e0453f; opacity: 0; pointer-events: none;
  text-shadow: 0 2px 6px rgba(0,0,0,.6); transition: opacity .14s;
}
.sus.out { opacity: .38; border-color: #5a2c2c; }
.sus.out .s-cross { opacity: 1; }
.sus.guilty { border-color: #f0c869; box-shadow: 0 0 0 4px rgba(240,200,105,.35); opacity: 1; }
.sus.guilty::after {
  content: 'GUILTY'; position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%) rotate(-12deg);
  font-weight: 800; font-size: clamp(11px, 3vw, 15px); letter-spacing: 2px;
  color: #f0c869; border: 3px solid #f0c869; border-radius: 6px; padding: 2px 8px;
  background: rgba(30,26,40,.85);
}

/* ------------------------------------------------------------ notebook --- */
.notebook {
  flex: none; display: flex; flex-direction: column; gap: 7px;
  background: #2b2838; border: 4px solid #3c3850; border-radius: 14px; padding: 9px;
}
@media (min-width: 820px) { .notebook { width: 330px; flex: none; } }
.nbtop { font-size: 12px; font-weight: 800; letter-spacing: 1px; opacity: .65; }
.clues {
  margin: 0; padding: 0 0 0 22px; list-style: decimal; max-height: 30vh; overflow: auto;
  display: flex; flex-direction: column; gap: 5px;
}
@media (min-width: 820px) { .clues { max-height: none; flex: 1; } }
.clue {
  font-size: clamp(12.5px, 3.1vw, 15px); line-height: 1.4;
  background: #343048; border-radius: 7px; padding: 6px 9px; border-left: 3px solid #f0c869;
}
.clue.new { animation: clueIn .3s ease; }
@keyframes clueIn { from { opacity: 0; transform: translateX(-10px) } }

.ask, .arrest {
  border-radius: 999px; font-weight: 800; padding: 11px 14px;
  font-size: clamp(13px, 3.3vw, 16px);
}
.ask { background: #4a4266; color: #ece9f2; box-shadow: 0 4px 0 #332d47; }
.ask:disabled { opacity: .4; }
.arrest { background: #c8392f; color: #fff; box-shadow: 0 4px 0 #8f2721; }
.arrest:disabled { opacity: .35; }
.ask:active, .arrest:active { transform: translateY(3px); box-shadow: none; }

.whylist { text-align: left; margin: 8px 0; padding-left: 20px; font-size: clamp(12px, 3vw, 14.5px); line-height: 1.6; }
