/* Mate: shared look for the hub map and the three chapter pages (Beast-Academy-like: a lesson map, monsters, stars).
   Chapter pages: <header class="m-head"> + <main class="m-stage" id="stage"> + optional <div class="m-answers">. */
:root {
  --mat: #F4F1FB;
  --dot: #DED6F0;
  --ink: #23303F;
  --muted: #6B6585;
  --card: #FFFFFF;
  --edge: #D4CCE8;
  --good: #35A866;
  --good-dark: #23824C;
  --red: #E5483B;
  --blue: #2F6FD0;
  --yellow: #F2BC1B;
  --green: #36A85A;
  --purple: #7B4FB8;
  --orange: #F08A24;
  --pink: #EF7FA8;
  --gold: #F5B400;
  --display: "Baloo 2", "Nunito", system-ui, sans-serif;
  --body: "Nunito", system-ui, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--mat);
  background-image: radial-gradient(var(--dot) 1.4px, transparent 1.6px);
  background-size: 22px 22px;
  color: var(--ink);
  font-family: var(--body);
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; }

/* ---------- chapter page shell ---------- */
.m-app { height: 100%; display: flex; flex-direction: column; gap: 12px; padding: 10px 16px 16px; max-width: 980px; margin: 0 auto; }
.m-head { display: flex; align-items: center; gap: 10px; min-height: 60px; }
.m-head .icon-btn { all: unset; position: relative; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); cursor: pointer; flex: none; }
.m-head .icon-btn svg { width: 26px; height: 26px; }
.m-title { all: unset; cursor: pointer; flex: 1; min-width: 0; font-family: var(--display); font-weight: 800; font-size: clamp(1.15rem, 4.8vw, 1.9rem); line-height: 1.1; display: flex; align-items: center; gap: 8px; }
.m-title svg { width: 1em; height: 1em; color: var(--purple); flex: none; }
/* problem progress: one pill per problem */
.m-prog { display: flex; gap: 5px; flex: none; }
.m-prog i { width: 16px; height: 16px; border-radius: 6px; background: var(--edge); display: block; transition: background .25s, transform .25s; }
.m-prog i.ok { background: var(--good); }
.m-prog i.meh { background: var(--yellow); }
.m-prog i.now { transform: scale(1.25); box-shadow: 0 0 0 3px var(--card), 0 0 0 5px var(--purple); }
.m-stage { flex: 1; min-height: 0; position: relative; background: var(--card); border: 2px solid var(--edge); border-radius: 28px; overflow: hidden; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 16px; }
.m-answers { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; min-height: 0; }
.m-answers[data-locked] { pointer-events: none; opacity: .45; filter: grayscale(.6); }

/* big answer button: a number with its dots underneath */
.m-num { all: unset; cursor: pointer; min-width: 78px; height: 92px; padding: 0 12px; border-radius: 22px; background: var(--card); border: 3px solid var(--edge); box-shadow: 0 6px 0 var(--edge); display: grid; place-items: center; align-content: center; gap: 4px; font-family: var(--display); font-weight: 800; font-size: 2.6rem; line-height: 1; transition: transform .1s; }
.m-num:active { transform: translateY(5px); box-shadow: 0 1px 0 var(--edge); }
.m-num .dots { display: flex; flex-wrap: wrap; justify-content: center; gap: 3px; max-width: 64px; }
.m-num .dots i { width: 9px; height: 9px; border-radius: 50%; background: var(--purple); display: block; }
.m-num.right { background: #E3F6EA; border-color: var(--good); box-shadow: 0 6px 0 var(--good-dark); }
.m-num.nope, .m-shake { animation: m-shake .4s; }
@keyframes m-shake { 20% { transform: translateX(-8px); } 40% { transform: translateX(7px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(3px); } }
.m-pop { animation: m-pop .45s cubic-bezier(.3,1.6,.5,1); }
@keyframes m-pop { from { transform: scale(.6); } }
.m-hop { animation: m-hop .5s cubic-bezier(.3,1.6,.5,1); }
@keyframes m-hop { 40% { transform: translateY(-14px); } }

/* monsters (Mate.monster) */
.monster { display: block; width: var(--m, 90px); height: var(--m, 90px); flex: none; }
.monster .blink { animation: m-blink 4s infinite; transform-origin: center; transform-box: fill-box; }
@keyframes m-blink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.1); } }

/* speech bubble from the guide monster */
.m-guide { display: flex; align-items: flex-end; gap: 8px; }
.m-bubble { background: var(--card); border: 3px solid var(--edge); border-radius: 20px 20px 20px 4px; padding: 8px 14px; font-family: var(--display); font-weight: 800; font-size: 1.2rem; line-height: 1.15; }

/* lesson result card */
.m-done { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 20px; background: rgba(244,241,251,.92); }
.m-done-card { background: var(--card); border-radius: 32px; padding: 24px 22px; width: min(440px, 100%); display: grid; justify-items: center; gap: 12px; text-align: center; box-shadow: 0 0 0 3px var(--edge), 0 10px 0 var(--edge); animation: m-pop .55s cubic-bezier(.3,1.6,.5,1); }
.m-done-card h2 { margin: 0; font-family: var(--display); font-weight: 800; font-size: clamp(2.1rem, 10vw, 3rem); line-height: 1; }
.m-bigstars { display: flex; gap: 10px; }
.m-bigstars i { width: 58px; height: 58px; display: block; background: var(--edge); clip-path: polygon(50% 0, 62% 36%, 100% 38%, 69% 60%, 80% 100%, 50% 76%, 20% 100%, 31% 60%, 0 38%, 38% 36%); }
.m-bigstars i.on { background: var(--gold); animation: m-spin .8s cubic-bezier(.3,1.6,.5,1) both; }
.m-bigstars i.on:nth-child(2) { animation-delay: .25s; }
.m-bigstars i.on:nth-child(3) { animation-delay: .5s; }
@keyframes m-spin { from { transform: scale(0) rotate(-120deg); } }
.m-go { all: unset; cursor: pointer; font-family: var(--display); font-weight: 800; font-size: clamp(1.6rem, 6.5vw, 2.2rem); color: #fff; background: var(--good); border-radius: 999px; padding: 14px 42px 10px; box-shadow: 0 8px 0 var(--good-dark); }
.m-go:active { transform: translateY(5px); box-shadow: 0 3px 0 var(--good-dark); }
.m-go.alt { background: var(--card); color: var(--ink); box-shadow: 0 0 0 3px var(--edge), 0 6px 0 var(--edge); font-size: 1.2rem; padding: 10px 24px 8px; }

canvas.m-fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 70; }
@media (max-width: 520px) { .m-prog i { width: 11px; height: 11px; border-radius: 4px; } .m-prog { gap: 3px; } .m-num { min-width: 64px; height: 82px; font-size: 2.2rem; } }
@media (prefers-reduced-motion: reduce) { .m-pop, .m-hop, .m-num.nope, .m-shake, .m-done-card, .m-bigstars i.on, .monster .blink { animation: none; } }
