/* Math Detectives — styles (tablet-first) */
:root {
  --ink: #1f1640;
  --ink-soft: #5b5277;
  --paper: #fffaf0;
  --card: #ffffff;
  --yellow: #ffd23f;
  --pink: #ff5d8f;
  --teal: #2ec4b6;
  --purple: #7b5cff;
  --blue: #3a86ff;
  --orange: #ff9f1c;
  --green: #22b35e;
  --red: #ef4444;
  --accent: var(--yellow);
  --accent-2: var(--pink);
  --bg1: #3b1f8f;
  --bg2: #0f4c81;
  --radius: 22px;
  --shadow: 0 10px 0 rgba(0, 0, 0, 0.18), 0 18px 40px rgba(0, 0, 0, 0.18);
  --item: 2rem;
  --title: 'Luckiest Guy', 'Fredoka', system-ui, sans-serif;
}
.theme-home { --bg1: #3b1f8f; --bg2: #0f4c81; }
.theme-g3 { --bg1: #2b1d5c; --bg2: #6a2c91; --accent: #ffd23f; --accent-2: #2ec4b6; }
.theme-g1 { --bg1: #0ea5a0; --bg2: #3a6dff; --accent: #ffd23f; --accent-2: #ff5d8f; }
.theme-gk { --bg1: #ff7eb3; --bg2: #ffb347; --accent: #ffd23f; --accent-2: #7b5cff; }
.theme-g2 { --bg1: #12a150; --bg2: #0e7490; --accent: #ffd23f; --accent-2: #ff5d8f; }
.theme-g4 { --bg1: #0b1f4d; --bg2: #1e40af; --accent: #ffb703; --accent-2: #2ec4b6; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: 'Fredoka', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--ink);
  background: var(--bg1);
  overflow-x: hidden;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}
input { -webkit-user-select: text; user-select: text; }
button { font-family: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }

/* ---------- Background ---------- */
.bg { position: fixed; inset: 0; width: 100%; height: 100%; z-index: -1; }
.bg-s1 { stop-color: var(--bg1); transition: stop-color 0.6s; }
.bg-s2 { stop-color: var(--bg2); transition: stop-color 0.6s; }
.blob { fill: rgba(255, 255, 255, 0.06); }
.qmark { font: 140px var(--title); fill: rgba(255, 255, 255, 0.12); }
.qmark.small { font-size: 90px; }
.bgstar { fill: rgba(255, 230, 120, 0.55); }
.float { animation: floaty 7s ease-in-out infinite; transform-box: fill-box; }
.f2 { animation-duration: 9s; animation-delay: -2s; }
.f3 { animation-duration: 6s; animation-delay: -4s; }
.f4 { animation-duration: 8s; animation-delay: -1s; }
@keyframes floaty { 50% { transform: translateY(-22px) rotate(4deg); } }
.twinkle { animation: twinkle 3s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.t2 { animation-delay: -1s; } .t3 { animation-delay: -2s; }
@keyframes twinkle { 50% { opacity: 0.3; transform: scale(0.7); } }
.trail use { animation: step 6s infinite; opacity: 0; }
.trail use:nth-child(2) { animation-delay: 0.5s; } .trail use:nth-child(3) { animation-delay: 1s; }
.trail use:nth-child(4) { animation-delay: 1.5s; } .trail use:nth-child(5) { animation-delay: 2s; }
.trail use:nth-child(6) { animation-delay: 2.5s; }
@keyframes step { 0% { opacity: 0; } 10%, 60% { opacity: 1; } 80%, 100% { opacity: 0; } }

/* ---------- Layout ---------- */
#app { max-width: 1180px; margin: 0 auto; padding: max(12px, env(safe-area-inset-top)) 16px 40px; }
.screen { animation: fadeIn 0.35s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; min-height: 56px; }
.tb-right { display: flex; gap: 8px; }
.team-title { font: 1.5rem var(--title); color: #fff; letter-spacing: 1px; text-shadow: 0 3px 0 rgba(0, 0, 0, 0.25); text-align: center; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.section-title { font: 1.6rem var(--title); color: #fff; letter-spacing: 1px; margin: 26px 4px 12px; text-shadow: 0 3px 0 rgba(0, 0, 0, 0.25); }
.muted { color: var(--ink-soft); font-size: 0.95rem; }
.hidden { display: none !important; }

/* ---------- Buttons ---------- */
.btn {
  font: 600 1.2rem 'Fredoka', sans-serif;
  padding: 0.75em 1.4em;
  border-radius: 18px;
  border: 0;
  background: var(--accent);
  color: var(--ink);
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.28);
  transition: transform 0.08s, box-shadow 0.08s;
  min-height: 56px;
}
.btn:active { transform: translateY(5px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.28); }
.btn.big { font-size: 1.45rem; padding: 0.8em 1.8em; }
.btn.small { font-size: 1rem; min-height: 46px; padding: 0.5em 1em; }
.btn.alt { background: #efeaff; }
.btn.off { background: #e5e7eb; }
.btn.danger { background: #fecaca; }
.icon-btn {
  width: 56px; height: 56px; border-radius: 18px; border: 0; font-size: 1.7rem;
  background: rgba(255, 255, 255, 0.92); box-shadow: 0 5px 0 rgba(0, 0, 0, 0.22); flex: none;
}
.icon-btn:active { transform: translateY(4px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.22); }
.row-btns { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin-top: 18px; }

/* ---------- Home ---------- */
.hero { text-align: center; color: #fff; margin: 0 0 26px; }
.hero-mascot { width: 170px; margin: 0 auto -10px; }
.logo { margin: 0; font-family: var(--title); font-weight: 400; line-height: 0.9; letter-spacing: 2px; }
.logo span { display: block; text-shadow: 0 6px 0 rgba(0, 0, 0, 0.3); }
.logo .l1 { font-size: clamp(2.6rem, 7vw, 4.2rem); color: #fff; }
.logo .l2 { font-size: clamp(3.2rem, 10vw, 6rem); color: var(--yellow); transform: rotate(-3deg); }
.tagline { font-size: 1.35rem; font-weight: 500; opacity: 0.95; margin: 14px 0 0; }
.grade-cards { display: flex; flex-wrap: wrap; justify-content: center; gap: 16px; max-width: 1140px; margin: 0 auto; }
.grade-cards .grade-card { flex: 1 1 165px; max-width: 214px; padding: 34px 12px 18px; }
.grade-card {
  position: relative; border: 0; border-radius: 30px; padding: 28px 20px 24px; text-align: center;
  box-shadow: 0 12px 0 rgba(0, 0, 0, 0.25); transition: transform 0.15s; overflow: hidden;
}
.grade-card:hover { transform: translateY(-4px) rotate(-1deg); }
.grade-card:active { transform: translateY(6px); box-shadow: 0 4px 0 rgba(0, 0, 0, 0.25); }
.gc-g1 { background: linear-gradient(160deg, #fff2a8, #ffc3d6); }
.gc-g3 { background: linear-gradient(160deg, #c9f7f1, #d6c8ff); }
.gc-gk { background: linear-gradient(160deg, #ffe0ef, #ffe8c2); }
.gc-g2 { background: linear-gradient(160deg, #d3f8df, #c7f0fa); }
.gc-g4 { background: linear-gradient(160deg, #d6e4ff, #ffe8b8); }
.gc-badge { position: absolute; top: 14px; left: 14px; background: var(--ink); color: #fff; font-weight: 700; border-radius: 99px; padding: 4px 14px; }
.gc-icon { font-size: 4rem; animation: bob 3s ease-in-out infinite; }
.gc-team { font: 1.7rem var(--title); letter-spacing: 1px; margin-top: 4px; }
.gc-sub { font-size: 1.1rem; color: var(--ink-soft); font-weight: 500; }
.gc-who { margin-top: 14px; background: #fff; border-radius: 99px; display: inline-block; padding: 6px 16px; font-weight: 600; }
.gc-who.new { background: var(--ink); color: #fff; }
@keyframes bob { 50% { transform: translateY(-8px); } }

/* ---------- Mascot ---------- */
.hoot { width: 100%; height: auto; overflow: visible; }
.hoot .lids { animation: blink 5s infinite; }
@keyframes blink { 0%, 94%, 100% { height: 0; } 96% { height: 36px; } }
.hoot.bob, .mascot.happy .hoot { animation: bob 1.6s ease-in-out infinite; }
.mascot.think .hoot { animation: tilt 1.2s ease-in-out infinite; }
.mascot.think .pupils { transform: translate(-3px, -3px); }
.mascot.happy .glass { animation: wave 0.6s ease-in-out 3; transform-origin: 104px 112px; }
@keyframes tilt { 50% { transform: rotate(-6deg); } }
@keyframes wave { 50% { transform: rotate(-18deg); } }

/* ---------- Setup ---------- */
.setup-card { max-width: 640px; margin: 10px auto; text-align: center; }
.id-card { background: linear-gradient(135deg, #fff7d1, #ffe08a); border: 4px solid var(--ink); border-radius: 20px; overflow: hidden; text-align: left; }
.id-head { background: var(--ink); color: var(--yellow); font-weight: 700; letter-spacing: 2px; padding: 8px 16px; font-size: 0.9rem; }
.id-body { display: flex; gap: 16px; align-items: center; padding: 16px; }
.id-avatar { font-size: 4.2rem; background: #fff; border-radius: 18px; width: 100px; height: 100px; display: grid; place-items: center; border: 3px dashed var(--ink); flex: none; }
.id-label { font-weight: 600; color: var(--ink-soft); margin-bottom: 4px; }
.name-input { font: 600 1.6rem 'Fredoka', sans-serif; padding: 10px 14px; border-radius: 14px; border: 3px solid var(--ink); width: 100%; max-width: 320px; color: var(--ink); background: #fff; }
.avatars { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-bottom: 20px; }
.avatar { font-size: 2.3rem; width: 66px; height: 66px; border-radius: 18px; border: 3px solid transparent; background: #f3efff; }
.avatar.on { border-color: var(--purple); background: #fff4c2; transform: scale(1.1); }

/* ---------- Board ---------- */
.agent-bar { display: flex; align-items: center; gap: 16px; }
.agent-avatar { font-size: 3.2rem; width: 76px; height: 76px; display: grid; place-items: center; background: #fff4c2; border-radius: 20px; flex: none; }
.agent-info { flex: 1; min-width: 0; }
.agent-name { font: 1.6rem var(--title); letter-spacing: 1px; }
.rank-name { font-weight: 600; }
.rank-next { font-size: 0.9rem; color: var(--ink-soft); }
.meter { height: 14px; background: #ece8f7; border-radius: 99px; overflow: hidden; margin: 4px 0; display: inline-block; width: 100%; max-width: 360px; vertical-align: middle; }
.meter i { display: block; height: 100%; background: linear-gradient(90deg, var(--teal), var(--purple)); border-radius: 99px; transition: width 0.6s; }
.meter.good i { background: var(--green); } .meter.ok i { background: var(--orange); } .meter.low i { background: var(--red); }
.coins { font-size: 1.5rem; font-weight: 700; background: #fff4c2; border-radius: 99px; padding: 6px 16px; white-space: nowrap; }
.coins.bump { animation: bump 0.4s; }
@keyframes bump { 50% { transform: scale(1.25); } }
.mission { display: flex; align-items: center; gap: 14px; margin-top: 16px; background: linear-gradient(135deg, #fff, #fff6d6); font-size: 1.25rem; font-weight: 500; }
.mission-mascot { width: 76px; flex: none; }
.mission-text { flex: 1; }
.mission-label { font-weight: 700; color: var(--purple); font-size: 0.95rem; letter-spacing: 1px; }
.case-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 20px; }
.case-file {
  position: relative; border: 0; text-align: left; padding: 30px 14px 14px; border-radius: 6px 16px 16px 16px;
  background: #f6d98f; box-shadow: 0 8px 0 #c9a45a, 0 14px 24px rgba(0, 0, 0, 0.2);
  transform: rotate(var(--tilt)); transition: transform 0.15s; min-height: 190px; display: flex; flex-direction: column;
}
.case-file::before { content: ''; position: absolute; top: -10px; left: 50%; width: 70px; height: 22px; margin-left: -35px; background: rgba(255, 255, 255, 0.55); transform: rotate(-4deg); }
.case-file:hover { transform: rotate(0) translateY(-4px); }
.case-file:active { transform: translateY(4px); }
.case-file.locked { filter: grayscale(0.8) brightness(0.85); }
.case-file.rec { outline: 5px solid var(--accent); outline-offset: 3px; animation: glow 1.6s ease-in-out infinite; }
@keyframes glow { 50% { outline-color: #fff; } }
.cf-tab { position: absolute; top: 0; left: 0; background: var(--ink); color: #fff; font-size: 0.75rem; font-weight: 700; letter-spacing: 1px; padding: 4px 10px; border-radius: 6px 0 10px 0; }
.cf-icon { font-size: 2.8rem; }
.cf-title { font: 1.3rem var(--title); letter-spacing: 0.5px; line-height: 1.1; margin-top: 4px; }
.cf-topic { font-size: 0.95rem; color: #6b5420; flex: 1; }
.cf-stars { font-size: 1.5rem; color: rgba(0, 0, 0, 0.18); letter-spacing: 2px; }
.cf-stars .on { color: #ff9f1c; text-shadow: 0 2px 0 #b45309; }
.rec-flag { position: absolute; right: 10px; top: 4px; font-weight: 700; font-size: 0.85rem; background: var(--accent); padding: 2px 8px; border-radius: 99px; }
.stamp {
  font: 1.4rem var(--title); color: #e11d48; border: 4px solid #e11d48; border-radius: 10px; padding: 2px 10px;
  transform: rotate(-12deg); letter-spacing: 2px; opacity: 0.85; display: inline-block;
}
.stamp.small { position: absolute; right: 8px; bottom: 34px; font-size: 1rem; padding: 0 6px; border-width: 3px; }
.badges { display: flex; flex-wrap: wrap; gap: 12px; }
.badge { font-size: 2.2rem; width: 70px; height: 70px; border-radius: 50%; display: grid; place-items: center; background: #eee; filter: grayscale(1); opacity: 0.35; }
.badge.got { background: radial-gradient(circle, #fff6c2, #ffd23f); filter: none; opacity: 1; box-shadow: 0 4px 0 #c9a227; }

/* ---------- Briefing ---------- */
.folder { max-width: 900px; margin: 0 auto; }
.folder-tab { display: inline-block; background: #f6d98f; padding: 8px 22px; border-radius: 16px 16px 0 0; font-weight: 700; letter-spacing: 2px; }
.folder-body { background: #fdf1cf; border-radius: 0 22px 22px 22px; padding: 22px; box-shadow: var(--shadow); text-align: center; }
.brief-head { display: flex; align-items: center; gap: 16px; text-align: left; }
.brief-head h1 { font: 2.2rem var(--title); letter-spacing: 1px; margin: 0; line-height: 1; }
.brief-icon { font-size: 3.6rem; }
.brief-topic { color: #6b5420; font-weight: 500; }
.brief-story { display: flex; align-items: center; gap: 12px; margin: 18px 0; text-align: left; }
.mini-mascot { width: 90px; flex: none; }
.lesson { display: grid; grid-template-columns: 1.2fr 1fr; gap: 18px; align-items: center; background: #fff; border-radius: 18px; padding: 16px; margin-bottom: 22px; border: 3px dashed #e6c879; }
.lesson-lines { text-align: left; font-size: 1.3rem; margin: 0; padding-left: 1.4em; }
.lesson-lines li { margin: 8px 0; }
.lesson-vis { display: flex; justify-content: center; }

/* ---------- Speech bubble ---------- */
.bubble { position: relative; flex: 1; background: #fff; border: 3px solid var(--ink); border-radius: 20px; padding: 12px 56px 12px 16px; font-size: 1.3rem; line-height: 1.35; min-height: 64px; display: flex; align-items: center; }
.bubble::before { content: ''; position: absolute; left: -14px; top: 50%; margin-top: -10px; border: 10px solid transparent; border-right: 14px solid var(--ink); border-left: 0; }
.bubble .speak { position: absolute; right: 6px; top: 50%; margin-top: -24px; width: 48px; height: 48px; font-size: 1.4rem; box-shadow: 0 3px 0 rgba(0, 0, 0, 0.18); background: #f3efff; }

/* ---------- Play ---------- */
.play-top { align-items: center; }
.play-title { flex: 1; color: #fff; font: 1.3rem var(--title); letter-spacing: 1px; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.3); text-align: center; }
.track { position: relative; height: 14px; background: rgba(255, 255, 255, 0.3); border-radius: 99px; margin: 8px auto 0; max-width: 460px; }
.track > i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 99px; transition: width 0.6s; }
.track-mag { position: absolute; top: -14px; left: 0; transform: translateX(-50%); font-size: 1.6rem; transition: left 0.6s; text-shadow: none; }
.play-grid { display: grid; grid-template-columns: 1.35fr 1fr; gap: 18px; align-items: start; }
.pane { min-height: 200px; }
.story-row { display: flex; align-items: center; gap: 18px; }
.mascot { width: 92px; flex: none; }
.visual { margin-top: 16px; display: flex; justify-content: center; align-items: center; min-height: 120px; }
.ask { font-size: 1.6rem; font-weight: 600; text-align: center; margin-bottom: 14px; min-height: 2em; }
.input { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.feedback { margin-top: 12px; text-align: center; }
.praise { font-size: 1.5rem; font-weight: 700; color: var(--green); }
.clue { background: #fff6d6; border: 3px solid var(--orange); border-radius: 16px; padding: 12px 14px; font-size: 1.15rem; text-align: left; }
.solution { background: #e9f7ff; border: 3px solid var(--blue); border-radius: 16px; padding: 12px 14px; font-size: 1.2rem; margin-bottom: 12px; }
.reveal { width: 100%; }
.chain { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 1.35rem; font-weight: 600; }
.chain > div:not(.arrow) { background: #f3efff; border-radius: 14px; padding: 6px 14px; }
.chain .big { font-size: 2rem; background: var(--accent) !important; box-shadow: 0 4px 0 rgba(0, 0, 0, 0.2); }
.chain .arrow { color: var(--purple); }

/* Numpad */
.numpad-wrap { width: 100%; max-width: 330px; }
.answer-box { font: 700 2.6rem 'Fredoka', sans-serif; text-align: center; background: #f7f5ff; border: 4px solid var(--ink); border-radius: 18px; padding: 4px; margin-bottom: 12px; min-height: 72px; }
.answer-box.empty { color: #c4bcdc; }
.answer-box.right { background: #d1fae5; border-color: var(--green); }
.answer-box.wrong { background: #ffe4e6; border-color: var(--red); }
.numpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.key { font: 700 1.9rem 'Fredoka', sans-serif; height: 66px; border: 0; border-radius: 16px; background: #efeaff; box-shadow: 0 5px 0 #c9bff0; }
.key:active { transform: translateY(4px); box-shadow: 0 1px 0 #c9bff0; }
.key.go { background: var(--green); color: #fff; box-shadow: 0 5px 0 #15803d; }
.key.del { background: #ffe4e6; box-shadow: 0 5px 0 #fca5a5; }

/* Choices */
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: 100%; }
.choices.wide { grid-template-columns: 1fr; }
.choice { font: 600 1.5rem 'Fredoka', sans-serif; padding: 14px; border: 0; border-radius: 16px; background: #efeaff; box-shadow: 0 5px 0 #c9bff0; min-height: 64px; }
.choice:active { transform: translateY(4px); box-shadow: 0 1px 0 #c9bff0; }
.choice.right { background: #bbf7d0; box-shadow: 0 5px 0 var(--green); }
.choice.wrong { background: #fecdd3; box-shadow: 0 5px 0 var(--red); opacity: 0.6; text-decoration: line-through; }

/* ---------- Visual models ---------- */
.item { font-size: var(--item); line-height: 1; display: inline-flex; position: relative; }
.num-badge {
  position: absolute; top: -8px; right: -10px; background: var(--purple); color: #fff; font: 700 0.85rem 'Fredoka', sans-serif;
  min-width: 22px; height: 22px; padding: 0 4px; border-radius: 99px; display: grid; place-items: center; animation: popIn 0.3s; z-index: 2;
}
.num-badge.big { background: var(--pink); font-size: 1.1rem; min-width: 30px; height: 30px; }
.groups { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; }
.group {
  position: relative; min-width: 104px; min-height: 104px; padding: 12px 10px; border-radius: 50%; background: #fff7e0;
  border: 4px dashed #e2b65c; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
}
.group-items { display: grid; justify-content: center; justify-items: center; gap: 2px; }
.group.tappable { cursor: pointer; box-shadow: 0 5px 0 #e2b65c; }
.group.tappable:active { transform: translateY(3px); }
.group.full { border-style: solid; border-color: var(--green); background: #e7fbe9; box-shadow: none; }
.group.lit { border-color: var(--purple); border-style: solid; }
.group .counter { font-weight: 700; color: var(--ink-soft); }
.tag { position: absolute; top: -14px; right: -8px; background: var(--purple); color: #fff; font-weight: 700; font-size: 1.1rem; border-radius: 99px; padding: 2px 10px; box-shadow: 0 3px 0 rgba(0, 0, 0, 0.2); }
.array-wrap { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.array { display: grid; gap: 6px; align-items: center; justify-items: center; transition: transform 0.45s, opacity 0.45s; }
.array .item.lit { animation: popIn 0.3s; filter: drop-shadow(0 0 6px var(--accent)); }
.array .rt { font-weight: 700; color: var(--purple); font-size: 1.3rem; min-width: 2.4em; text-align: left; }
.array.dots { gap: 4px; }
.array.dots .rt { font-size: 1.05rem; }
.dot { width: var(--dot, 20px); height: var(--dot, 20px); border-radius: 50%; background: var(--purple); display: inline-block; }
.dot.alt { background: var(--teal); }
.dot.lit { box-shadow: 0 0 0 3px var(--accent); }
.split-line { height: 0; border-top: 3px dashed var(--pink); width: 100%; margin: 2px 0; }
.array.spin { transform: rotate(90deg) scale(0.8); opacity: 0; }
.array.unspin { animation: unspin 0.45s; }
@keyframes unspin { from { transform: rotate(-90deg) scale(0.8); opacity: 0; } }
.numline-wrap { width: 100%; overflow-x: auto; }
.numline { width: 100%; min-width: 320px; height: auto; max-height: 190px; }
.numline.unitline { min-width: 560px; }
.nl-axis { stroke: var(--ink); stroke-width: 4; stroke-linecap: round; }
.nl-tick { stroke: var(--ink); stroke-width: 3; }
.nl-label { font: 700 24px 'Fredoka', sans-serif; text-anchor: middle; fill: var(--ink); }
.nl-label.sm { font-size: 17px; }
.nl-label.q { fill: var(--pink); }
.nl-label.lit { fill: var(--purple); }
.nl-arc { fill: none; stroke: var(--pink); stroke-width: 4; stroke-dasharray: 200; stroke-dashoffset: 200; animation: draw 0.6s forwards; }
.nl-arc.back { stroke: var(--blue); }
@keyframes draw { to { stroke-dashoffset: 0; } }
.nl-jump { font: 700 18px 'Fredoka', sans-serif; text-anchor: middle; fill: var(--pink); }
.nl-hopnum { font: 700 14px 'Fredoka', sans-serif; text-anchor: middle; fill: var(--blue); }
.nl-start { fill: var(--orange); stroke: var(--ink); stroke-width: 3; }
.nl-end { fill: var(--green); stroke: var(--ink); stroke-width: 3; }
.barmodel { width: 100%; max-width: 560px; padding-top: 4px; }
.brace { position: relative; height: 40px; border: 4px solid var(--ink); border-bottom: 0; border-radius: 16px 16px 0 0; margin: 0 6px 8px; }
.brace span { position: absolute; left: 50%; top: -24px; transform: translateX(-50%); background: #fff; padding: 0 10px; font-size: 1.7rem; font-weight: 700; }
.brace span.q, .unit.q { color: var(--pink); }
.bar { display: flex; height: 64px; border: 4px solid var(--ink); border-radius: 8px; overflow: hidden; }
.unit { flex: 1; display: grid; place-items: center; font-size: 1.6rem; font-weight: 700; background: #c9f2ec; border-right: 4px solid var(--ink); transition: background 0.3s; }
.unit:last-child { border-right: 0; }
.unit:nth-child(even) { background: #d9d0ff; }
.unit.rest { background: repeating-linear-gradient(45deg, #fff, #fff 10px, #f1f1f6 10px, #f1f1f6 20px); font-size: 1.1rem; color: var(--ink-soft); }
.unit.lit { background: #fff1a8 !important; }
.bar-under { display: flex; margin-top: 4px; }
.under-cell { flex: 1; text-align: center; font-size: 1.4rem; font-weight: 600; color: var(--purple); min-height: 1.5em; }
.deal, .makegroups { display: flex; flex-direction: column; align-items: center; gap: 14px; width: 100%; }
.pile-wrap { text-align: center; }
.pile { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; max-width: 420px; padding: 10px; background: #f5f2ff; border-radius: 18px; min-height: 60px; }
.pile-count { font-weight: 700; color: var(--ink-soft); margin-top: 6px; font-size: 1.1rem; }
.plates { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.plate { border: 0; background: #fff; border-radius: 22px; padding: 8px 10px 10px; min-width: 104px; box-shadow: 0 5px 0 #d6d0ea, 0 0 0 4px #ece8f7 inset; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.plate:active { transform: translateY(3px); }
.plate.full { box-shadow: 0 0 0 4px var(--green) inset; }
.plate .who { font-size: 2.2rem; }
.plate-items { display: flex; flex-wrap: wrap; justify-content: center; max-width: 100px; min-height: 30px; --item: 1.5rem; }
.plate .counter { font-weight: 700; font-size: 1.2rem; }
.gone-up { animation: goneUp 0.4s forwards; }
@keyframes goneUp { to { transform: translateY(-30px) scale(0.3); opacity: 0; } }
.tappable-item { border: 0; background: transparent; padding: 4px; border-radius: 12px; font-size: var(--item); line-height: 1; position: relative; }
.tappable-item.sel { background: #ffe58a; box-shadow: 0 0 0 3px var(--orange); transform: scale(1.1); }
.tappable-item.used { visibility: hidden; }
.tappable-item.counted { background: #e7fbe9; }
.scatter { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; max-width: 520px; --item: 2.4rem; }
.item.gone, .tappable-item.gone { opacity: 0.55; }
.item.gone::after, .tappable-item.gone::after { content: '✖'; position: absolute; inset: 0; display: grid; place-items: center; color: var(--red); font-size: 2.2rem; font-weight: 700; }
.frames { display: flex; flex-wrap: wrap; gap: 16px; justify-content: center; }
.frame { display: grid; grid-template-columns: repeat(5, 46px); grid-template-rows: repeat(2, 46px); border: 4px solid var(--ink); border-radius: 8px; background: var(--ink); gap: 3px; }
.frame .cell { background: #fff; display: grid; place-items: center; position: relative; }
.counter-dot { width: 34px; height: 34px; border-radius: 50%; display: inline-block; animation: popIn 0.3s; }
.c-a { background: radial-gradient(circle at 35% 35%, #ff8fb1, #e11d64); }
.c-b { background: radial-gradient(circle at 35% 35%, #7fd6ff, #2563eb); }
.c-empty { background: transparent; border: 3px dashed #b6a8e8; }
.bond-wrap { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.bond { width: 300px; max-width: 100%; }
.bond-line { stroke: var(--ink); stroke-width: 5; }
.bond-c { stroke: var(--ink); stroke-width: 5; }
.bond-c.whole { fill: #fff1a8; } .bond-c.pa { fill: #ffd0df; } .bond-c.pb { fill: #cfe8ff; }
.bond-c.q { fill: #fff; stroke-dasharray: 8 6; stroke: var(--pink); }
.bond-t { font: 700 34px 'Fredoka', sans-serif; text-anchor: middle; fill: var(--ink); }
.bond-t.q { fill: var(--pink); }
.dot-strip { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.dot-strip .counter-dot { width: 28px; height: 28px; position: relative; }
.twosets { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: center; }
.twosets .set { display: flex; flex-wrap: wrap; gap: 6px; max-width: 190px; justify-content: center; background: #fff7e0; border-radius: 18px; padding: 10px; border: 3px dashed #e2b65c; }
.twosets .op { font: 3rem var(--title); color: var(--purple); }
.tri-wrap { display: flex; justify-content: center; }
.tri { width: 260px; max-width: 100%; }
.tri-shape { fill: #f3efff; stroke: var(--purple); stroke-width: 6; stroke-linejoin: round; }
.tri-op { font: 700 30px 'Fredoka', sans-serif; text-anchor: middle; fill: var(--purple); }
.tri-c { fill: #fff; stroke: var(--ink); stroke-width: 4; }
.tri-c.top { fill: #fff1a8; }
.tri-c.q { stroke: var(--pink); stroke-dasharray: 7 5; }
.tri-t { font: 700 28px 'Fredoka', sans-serif; text-anchor: middle; fill: var(--ink); }
.equation { font: 700 clamp(2.4rem, 6vw, 3.6rem) 'Fredoka', sans-serif; text-align: center; letter-spacing: 2px; }
.qbox { display: inline-block; min-width: 1.3em; border: 4px dashed var(--pink); color: var(--pink); border-radius: 12px; padding: 0 6px; animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { transform: scale(1.08); } }
.stack { display: flex; flex-direction: column; align-items: center; gap: 18px; width: 100%; }
.evidence { background: #fdf1cf; border: 3px dashed #c9a45a; border-radius: 18px; padding: 16px 24px; text-align: center; transform: rotate(-2deg); }
.evidence-icons { --item: 3rem; display: flex; gap: 10px; justify-content: center; }
.evidence-label { font-weight: 700; letter-spacing: 2px; color: #8a6a1f; margin-top: 6px; }

/* ---------- Results ---------- */
.results-card { max-width: 720px; margin: 20px auto; text-align: center; position: relative; overflow: hidden; }
.results-card h1 { font: 2.3rem var(--title); letter-spacing: 1px; margin: 8px 0; }
.big-stamp { font-size: 2.4rem; animation: stampIn 0.6s cubic-bezier(.2, 1.6, .4, 1) both; margin: 10px 0; }
@keyframes stampIn { from { transform: scale(3) rotate(-12deg); opacity: 0; } to { transform: scale(1) rotate(-12deg); opacity: 0.9; } }
.res-icon { font-size: 4rem; }
.res-stars { font-size: 3.6rem; color: #ddd; letter-spacing: 6px; }
.res-stars .on { color: #ff9f1c; display: inline-block; animation: popIn 0.5s both; text-shadow: 0 4px 0 #b45309; }
.res-coins { font-size: 1.35rem; font-weight: 600; }
.new-badge, .promo { display: inline-block; background: #fff4c2; border-radius: 99px; padding: 8px 18px; font-weight: 700; font-size: 1.2rem; margin: 6px; }
.promo { background: #e0d7ff; }
.res-mascot { width: 120px; margin: 10px auto 0; }
.clue-lists { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; text-align: left; margin: 14px 0; }
.clue-list { border-radius: 16px; padding: 10px 16px; font-size: 1.15rem; }
.clue-list.good { background: #e7fbe9; } .clue-list.todo { background: #fff6d6; }
.clue-list h3 { margin: 4px 0; }

/* ---------- Parent ---------- */
.gate, .panel { max-width: 720px; margin: 10px auto; text-align: center; font-size: 1.2rem; }
.gate .name-input { margin: 8px; }
.skills { width: 100%; border-collapse: collapse; text-align: left; font-size: 1.05rem; margin-top: 10px; }
.skills th, .skills td { padding: 8px 6px; border-bottom: 1px solid #eee; }
.skills .meter { width: 60%; }

/* ---------- Effects ---------- */
.pop { animation: popIn 0.35s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes popIn { from { transform: scale(0.3); opacity: 0; } }
.shake { animation: shake 0.45s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); background: var(--ink); color: #fff; font-weight: 600; font-size: 1.2rem;
  padding: 12px 22px; border-radius: 99px; z-index: 50; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3); animation: popIn 0.3s; max-width: 92vw; text-align: center;
}
.toast.out { opacity: 0; transition: opacity 0.4s; }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
.confetti i { position: absolute; top: -20px; width: 12px; height: 16px; animation: fall linear forwards; }
@keyframes fall { to { top: 110%; transform: translateX(60px) rotate(720deg); } }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .play-grid { grid-template-columns: 1fr; }
  .pane-r { display: flex; flex-direction: column; }
  .pane-r .ask { order: 1; }
  .pane-r .feedback { order: 2; margin: 0 0 10px; }
  .pane-r .feedback:empty { display: none; }
  .pane-r .input { order: 3; }
  .lesson { grid-template-columns: 1fr; }
  :root { --item: 1.75rem; }
}
@media (max-width: 560px) {
  #app { padding-left: 12px; padding-right: 12px; }
  .mascot { width: 64px; }
  .bubble { font-size: 1.1rem; }
  .ask { font-size: 1.35rem; }
  .agent-bar { flex-wrap: wrap; }
  .clue-lists { grid-template-columns: 1fr; }
  .frame { grid-template-columns: repeat(5, 36px); grid-template-rows: repeat(2, 36px); }
  .counter-dot { width: 26px; height: 26px; }
  .case-grid { grid-template-columns: 1fr 1fr; gap: 14px; }
  .brief-head h1 { font-size: 1.7rem; }
  .group { min-width: 86px; min-height: 86px; }
}

/* ---------- v2: language, streak, missions, gym, welcome ---------- */
.lang-btn { font: 700 1.05rem 'Fredoka', sans-serif; height: 56px; padding: 0 16px; border-radius: 18px; border: 0; background: rgba(255, 255, 255, 0.92); box-shadow: 0 5px 0 rgba(0, 0, 0, 0.22); }
.lang-btn:active { transform: translateY(4px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.22); }
.center { text-align: center; }
.agent-stats { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.streak { font-size: 1.25rem; font-weight: 700; background: #ffe1cc; border-radius: 99px; padding: 4px 14px; }
.side-missions { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; margin-top: 12px; }
.side-mission { display: flex; align-items: center; gap: 10px; text-align: left; border: 0; border-radius: 18px; padding: 12px 16px; font: 500 1.1rem 'Fredoka', sans-serif; background: rgba(255, 255, 255, 0.9); box-shadow: 0 5px 0 rgba(0, 0, 0, 0.18); }
.side-mission:active { transform: translateY(4px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.18); }
.sm-icon { font-size: 1.8rem; }
.gym-banner { display: flex; align-items: center; gap: 14px; width: 100%; margin-top: 16px; border: 0; border-radius: var(--radius); padding: 14px 18px; text-align: left;
  background: linear-gradient(135deg, #ff9f1c, #ff5d8f); color: #fff; box-shadow: 0 8px 0 rgba(0, 0, 0, 0.22); }
.gym-banner:active { transform: translateY(5px); box-shadow: 0 3px 0 rgba(0, 0, 0, 0.22); }
.gb-icon { font-size: 2.6rem; }
.gb-text { flex: 1; display: flex; flex-direction: column; font-size: 1.05rem; }
.gb-text b { font: 1.6rem var(--title); letter-spacing: 1px; }
.gb-go { font-size: 1.8rem; }
.board-hint { color: #fff; opacity: 0.9; margin: -6px 4px 14px; font-size: 1.05rem; }
.table-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 14px; }
.table-card { position: relative; border: 0; border-radius: 20px; padding: 14px 10px 10px; background: #fff; box-shadow: 0 6px 0 #d6d0ea; text-align: center; }
.table-card:active { transform: translateY(4px); box-shadow: 0 2px 0 #d6d0ea; }
.table-card.weak { background: #fff1e6; box-shadow: 0 6px 0 #ffb27a, 0 0 0 3px #ff9f1c inset; }
.table-card.done { background: #e7fbe9; box-shadow: 0 6px 0 #86d9a3; }
.tc-n { font: 2.4rem var(--title); color: var(--purple); letter-spacing: 1px; }
.table-card .meter { max-width: 100%; }
.tc-flag { position: absolute; top: -10px; right: -6px; background: #ff9f1c; color: #fff; font-weight: 700; font-size: 0.85rem; border-radius: 99px; padding: 2px 10px; transform: rotate(6deg); }
.factmap-wrap { overflow-x: auto; }
.factmap { display: grid; grid-template-columns: repeat(13, minmax(22px, 1fr)); gap: 3px; max-width: 560px; margin: 0 auto; }
.fm-h { font-weight: 700; color: var(--purple); text-align: center; font-size: 0.85rem; align-self: center; }
.fm-c { aspect-ratio: 1; border-radius: 6px; display: grid; place-items: center; font-size: 0.62rem; font-weight: 700; color: #14532d; }
.fm-new, .fm-legend .fm-new { background: #ece8f7; }
.fm-trouble { background: #fca5a5; }
.fm-learning { background: #fde68a; }
.fm-mastered { background: #86efac; }
.fm-legend { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; margin-top: 10px; font-size: 0.95rem; }
.fm-legend i { display: inline-block; width: 16px; height: 16px; border-radius: 4px; vertical-align: -3px; margin-right: 4px; }
.welcome-card { max-width: 720px; margin: 10px auto; text-align: center; }
.welcome-mascot { width: 150px; margin: 0 auto; }
.id-avatar.big { margin: -40px auto 10px; position: relative; left: 60px; width: 76px; height: 76px; font-size: 2.8rem; }
.welcome-lines { text-align: left; font-size: 1.3rem; line-height: 1.4; list-style: none; padding: 0; margin: 0 0 10px; }
.welcome-lines li { background: #f6f3ff; border-radius: 16px; padding: 10px 14px; margin: 8px 0; animation: popIn 0.4s both; }
.clue.alert { background: #ffe8ec; border-color: var(--pink); }
.clue-extra { margin-top: 6px; font-size: 1.05rem; color: var(--ink-soft); }
.res-cheer { font-size: 1.3rem; font-weight: 600; margin: 0; }
.mistakes { text-align: left; background: #fff6d6; border-radius: 16px; padding: 6px 16px; margin: 10px 0; }
.id-fields { flex: 1; min-width: 0; }


/* ---------- New grade visuals ---------- */
.shape-svg { width: 220px; max-width: 100%; }
.twosets.compare .op.vs { font-size: 1.6rem; }
.item.paired { filter: drop-shadow(0 0 6px var(--green)); }
.item.extra { animation: pulse 1s infinite; filter: drop-shadow(0 0 8px var(--orange)); }
.pattern { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: center; --item: 2.6rem; }
.pattern-q { font-size: 2rem; font-weight: 700; }
.unit-mark { background: #fff1a8; border-radius: 12px; }
.blocks { display: flex; flex-wrap: wrap; gap: 18px; align-items: flex-end; justify-content: center; }
.b-group { display: flex; flex-wrap: wrap; gap: 6px; align-items: flex-end; max-width: 100%; }
.b-group.ones { max-width: 90px; }
.b-flat { position: relative; display: grid; grid-template-columns: repeat(10, 7px); gap: 1px; padding: 2px; background: #1e7a4f; border-radius: 3px; }
.b-flat i { width: 7px; height: 7px; background: #4ade80; }
.b-rod { position: relative; display: grid; grid-template-rows: repeat(10, 9px); gap: 1px; padding: 2px; background: #1d4ed8; border-radius: 3px; }
.b-rod i { width: 12px; height: 9px; background: #60a5fa; }
.b-one { position: relative; width: 16px; height: 16px; background: #f59e0b; border: 2px solid #b45309; border-radius: 3px; }
.clock-wrap { display: flex; justify-content: center; }
.clock { width: 220px; max-width: 100%; }
.clock-face { fill: #fff; stroke: var(--ink); stroke-width: 6; }
.clock-num { font: 700 20px 'Fredoka', sans-serif; text-anchor: middle; fill: var(--ink); }
.clock-tick { stroke: #9a93b5; stroke-width: 2; }
.clock-hour { stroke: var(--pink); stroke-width: 9; stroke-linecap: round; }
.clock-min { stroke: var(--purple); stroke-width: 6; stroke-linecap: round; }
.clock-pin { fill: var(--ink); }
.clock-five { font: 700 13px 'Fredoka', sans-serif; text-anchor: middle; fill: var(--teal); }
.unit.part-b { background: #ffd0df !important; }
.area { width: 100%; max-width: 520px; font-weight: 700; }
.area-top, .area-row { display: flex; gap: 4px; }
.area-corner, .area-side { flex: 0 0 52px; display: grid; place-items: center; color: var(--purple); font-size: 1.4rem; }
.area-head { text-align: center; color: var(--purple); font-size: 1.4rem; padding-bottom: 4px; }
.area-cell { min-height: 110px; display: grid; place-items: center; background: #c9f2ec; border: 4px solid var(--ink); border-radius: 8px; font-size: 1.5rem; }
.area-cell:nth-child(odd) { background: #d9d0ff; }
.area-cell.lit { background: #fff1a8 !important; }
.frac-stack { display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 520px; }
.frac-row { display: flex; align-items: center; gap: 10px; }
.frac-label { flex: 0 0 64px; font-size: 1.5rem; font-weight: 700; text-align: right; }
.frac-bar { display: flex; flex: 1; height: 54px; border: 4px solid var(--ink); border-radius: 8px; overflow: hidden; width: 100%; max-width: 520px; }
.frac-part { flex: 1; border-right: 3px solid var(--ink); background: #fff; position: relative; }
.frac-part:last-child { border-right: 0; }
.frac-part.on { background: var(--pink); }
.frac-part .num-badge { top: 2px; right: 2px; }
.nl-tick.mid { stroke: var(--pink); stroke-dasharray: 4 3; }
.leftover { display: flex; align-items: center; gap: 6px; background: #ffe8ec; border: 3px dashed var(--pink); border-radius: 16px; padding: 8px 12px; }
.leftover-label { font-weight: 700; color: var(--pink); margin-left: 6px; }
.choice.emoji { font-size: 1.9rem; letter-spacing: 2px; }


/* ---------- Long division ---------- */
.longdiv { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.ld-cycle { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.ld-step { background: #f1eefb; color: var(--ink-soft); border-radius: 99px; padding: 4px 10px; font-weight: 600; font-size: 0.95rem; }
.ld-step.on { background: var(--accent); color: var(--ink); box-shadow: 0 3px 0 rgba(0, 0, 0, 0.15); }
.ld-grid { font: 700 2rem 'Fredoka', sans-serif; font-variant-numeric: tabular-nums; }
.ld-row { display: flex; }
.ld-cell { width: 1.25em; height: 1.35em; display: grid; place-items: center; position: relative; }
.ld-q { color: var(--purple); }
.ld-q.lit { color: var(--purple); }
.ld-divisor { color: var(--pink); }
.ld-dig { border-top: 4px solid var(--ink); }
.ld-dig.first { border-left: 4px solid var(--ink); border-top-left-radius: 14px; }
.ld-dig.lit { background: #fff1a8; }
.ld-dig.down::after { content: '⬇'; position: absolute; bottom: -0.55em; font-size: 0.45em; color: var(--teal); }
.ld-sign { color: var(--pink); }
.ld-under { border-bottom: 3px solid var(--ink); }
.ld-plain .ld-cell, .ld-final .ld-cell { color: var(--teal); }
.ld-final .ld-cell { color: var(--green); }


/* ---------- Academy & lessons ---------- */
.academy-banner { background: linear-gradient(135deg, #7b5cff, #2ec4b6); }
.lesson-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.lesson-card-btn { display: flex; align-items: center; gap: 12px; border: 0; border-radius: 20px; padding: 16px; text-align: left; background: #fff; font: 600 1.15rem 'Fredoka', sans-serif; box-shadow: 0 6px 0 #d6d0ea; }
.lesson-card-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #d6d0ea; }
.lc-icon { font-size: 2.2rem; }
.lesson-overlay { position: fixed; inset: 0; z-index: 80; background: rgba(20, 12, 50, 0.72); display: flex; align-items: flex-start; justify-content: center; padding: max(12px, env(safe-area-inset-top)) 12px 12px; overflow-y: auto; animation: fadeIn 0.25s; }
.lesson-card { width: 100%; max-width: 820px; }
.lesson-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.lesson-title { font: 1.4rem var(--title); letter-spacing: 1px; }
.lesson-dots { display: flex; gap: 6px; justify-content: center; margin: 8px 0 12px; }
.lesson-dots i { width: 10px; height: 10px; border-radius: 50%; background: #e3def3; }
.lesson-dots i.on { background: var(--purple); }
.lesson-visual { min-height: 170px; }
.lesson-nav { margin-top: 14px; }
.table-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px 18px; font-size: 1.25rem; }
.tl-row { padding: 2px 8px; border-radius: 8px; }
.tl-row.tricky { background: #fff1a8; font-weight: 700; }
.learn-btn { display: inline-block; margin-top: 8px; border: 0; background: #ece7ff; color: #4c2fd6; font: 700 1.05rem 'Fredoka', sans-serif; border-radius: 99px; padding: 8px 16px; box-shadow: 0 3px 0 #c9bff0; }
.learn-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #c9bff0; }
.hint-btn:disabled { opacity: 0.6; box-shadow: none; }
.solo { font-weight: 700; color: #c2410c; font-size: 1.15rem; margin-top: 4px; }
.clue.swap { background: #eef6ff; border-color: var(--blue); }
.lesson-more { text-align: center; margin-top: 8px; }
.brief-more { margin: -6px 0 16px; }
.reread-btn { width: 48px; height: 48px; font-size: 1.4rem; }
.hint-btn.pulse { animation: pulse 1s infinite; background: var(--accent); }
.clue.nudge { background: #f2efff; border-color: var(--purple); }
.voice-select { font: 500 1rem 'Fredoka', sans-serif; padding: 10px; border-radius: 12px; border: 2px solid #d6d0ea; max-width: 100%; }
@media (max-width: 560px) { .table-list { grid-template-columns: repeat(2, 1fr); font-size: 1.1rem; } .lesson-title { font-size: 1.1rem; } }

/* ---------- Hints ---------- */
.hint-btn { border: 0; background: #fff6d6; color: #8a5a00; font: 600 1.05rem 'Fredoka', sans-serif; border-radius: 99px; padding: 8px 18px; box-shadow: 0 3px 0 #f0d58a; margin-top: 4px; }
.hint-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #f0d58a; }
.clue-2 { margin-top: 8px; padding-top: 8px; border-top: 2px dashed #f3c27a; }
.choice.eliminated { opacity: 0.35; text-decoration: line-through; background: #eee; box-shadow: none; }

/* ---------- Updates ---------- */
.version-label { text-align: center; color: rgba(255, 255, 255, 0.55); font-size: 0.85rem; margin-top: 22px; }
.update-box { background: #eef6ff; border-radius: 16px; padding: 6px 16px 12px; margin: 14px 0; }
.update-banner {
  position: fixed; left: 16px; right: 16px; margin: 0 auto; width: fit-content; bottom: 18px; z-index: 70; border: 0; border-radius: 99px;
  padding: 14px 24px; font: 700 1.15rem 'Fredoka', sans-serif; background: var(--yellow); color: var(--ink);
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.25), 0 12px 30px rgba(0, 0, 0, 0.3); animation: popIn 0.4s, pulse 1.6s 0.4s infinite; max-width: 92vw;
}

/* ---------- Phones ---------- */
@media (max-width: 560px) {
  .topbar { min-height: 48px; margin-bottom: 10px; }
  .icon-btn, .lang-btn { height: 48px; }
  .icon-btn { width: 48px; font-size: 1.45rem; border-radius: 14px; }
  .team-title { font-size: 1.15rem; }
  .card { padding: 14px; border-radius: 18px; }
  .agent-avatar { width: 58px; height: 58px; font-size: 2.4rem; }
  .agent-name { font-size: 1.25rem; }
  .agent-stats { flex-direction: row; width: 100%; justify-content: flex-start; }
  .mission { flex-wrap: wrap; font-size: 1.1rem; }
  .mission-mascot { width: 56px; }
  .mission .btn { width: 100%; }
  .section-title { font-size: 1.3rem; margin-top: 20px; }
  .case-file { min-height: 160px; padding: 28px 10px 10px; }
  .cf-title { font-size: 1.05rem; }
  .cf-topic { font-size: 0.85rem; }
  .cf-icon { font-size: 2.2rem; }
  .play-title { font-size: 1rem; }
  .play-grid { gap: 12px; }
  .pane { min-height: 0; }
  .visual { margin-top: 10px; min-height: 80px; }
  .ask { font-size: 1.3rem; margin-bottom: 10px; }
  .answer-box { font-size: 2.1rem; min-height: 58px; margin-bottom: 8px; }
  .key { height: 54px; font-size: 1.6rem; }
  .numpad { gap: 8px; }
  .choice { font-size: 1.25rem; min-height: 54px; padding: 10px; }
  .btn.big { font-size: 1.2rem; padding: 0.75em 1.2em; }
  .bubble { padding: 10px 50px 10px 12px; }
  .bubble .speak { width: 40px; height: 40px; margin-top: -20px; font-size: 1.1rem; }
  .lesson-lines { font-size: 1.1rem; }
  .folder-body { padding: 14px; }
  .brief-icon { font-size: 2.6rem; }
  .group { min-width: 76px; min-height: 76px; padding: 8px; }
  .plate { min-width: 84px; }
  .chain { font-size: 1.1rem; }
  .chain .big { font-size: 1.5rem; }
  .results-card h1 { font-size: 1.6rem; }
  .big-stamp { font-size: 1.7rem; }
  .welcome-lines { font-size: 1.1rem; }
  .table-grid { grid-template-columns: repeat(3, 1fr); gap: 10px; }
  .tc-n { font-size: 1.8rem; }
  .gb-text b { font-size: 1.25rem; }
  .barmodel .unit { font-size: 1.3rem; }
  .bar { height: 54px; }
  .equation { font-size: 2.3rem; }
  .numline.unitline { min-width: 480px; }
  .fm-c { font-size: 0.5rem; }
}


/* ---------- Parent dashboard ---------- */
.dashboard { text-align: left; max-width: 900px; }
.dash-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.dash-head h2 { margin: 0; }
.dash-head > div:nth-child(2) { flex: 1; min-width: 180px; }
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 16px 0 4px; }
.stat-tile { background: #f6f3ff; border-radius: 16px; padding: 12px 14px; }
.st-value { font-size: 1.9rem; font-weight: 700; color: var(--ink); line-height: 1.1; }
.st-label { font-size: 0.95rem; color: var(--ink-soft); }
.dash-section { border-top: 2px solid #f0edf8; margin-top: 18px; padding-top: 6px; }
.dash-section h3 { margin: 8px 0 10px; }
.week-chart { max-width: 520px; }
.wk-bars { display: flex; gap: 2px; align-items: flex-end; height: 150px; border-bottom: 1px solid #d9d4ea; }
.wk-col { flex: 1; height: 100%; display: flex; flex-direction: column; align-items: center; border: 0; background: none; padding: 0 4px; position: relative; }
.wk-track { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; }
.wk-bar { display: block; width: 60%; max-width: 34px; background: var(--purple); border-radius: 4px 4px 0 0; transition: height 0.5s; }
.wk-col:hover .wk-bar, .wk-col:focus .wk-bar { background: #5b3fe0; }
.wk-day { position: absolute; bottom: -24px; font-size: 0.85rem; color: var(--ink-soft); }
.wk-col.today .wk-day { color: var(--ink); font-weight: 700; }
.chart-caption { margin-top: 30px; font-weight: 600; color: var(--ink); }
.insight { background: #fff8e6; border-radius: 16px; padding: 10px 14px; margin: 10px 0; }
.insight p { margin: 6px 0; }
.in-head { display: flex; align-items: center; gap: 8px; font-size: 1.15rem; }
.in-icon { font-size: 1.4rem; }
.in-tip { background: #fff; border-radius: 12px; padding: 8px 10px; }
.skills .given { color: var(--red); font-weight: 700; }
.tag-note { font-size: 0.8rem; color: var(--ink-soft); }
.mini-stars { color: #ff9f1c; }
.fluency td:last-child { white-space: nowrap; }
.dashboard .skills { font-size: 0.98rem; }
.dashboard .factmap-wrap { margin-top: 10px; }

/* ---------- Small / short screens (small tablets in landscape) ---------- */
@media (orientation: landscape) and (max-height: 680px) and (min-width: 600px) {
  :root { --item: 1.55rem; }
  #app { padding-top: 8px; padding-bottom: 16px; }
  .topbar { min-height: 44px; margin-bottom: 8px; }
  .icon-btn, .lang-btn { height: 44px; }
  .icon-btn { width: 44px; font-size: 1.3rem; border-radius: 14px; }
  .play-grid { grid-template-columns: 1.25fr 1fr; gap: 12px; }
  .pane-r { display: block; }
  .pane-r .feedback { margin-top: 8px; }
  .card { padding: 12px; }
  .mascot { width: 58px; }
  .bubble { font-size: 1.05rem; padding: 8px 48px 8px 12px; min-height: 48px; }
  .bubble .speak { width: 38px; height: 38px; margin-top: -19px; font-size: 1rem; }
  .visual { margin-top: 8px; min-height: 80px; }
  .ask { font-size: 1.25rem; margin-bottom: 8px; min-height: 0; }
  .answer-box { font-size: 1.9rem; min-height: 50px; margin-bottom: 8px; padding: 0; }
  .key { height: 46px; font-size: 1.45rem; }
  .numpad { gap: 7px; }
  .choice { font-size: 1.2rem; min-height: 50px; padding: 8px; }
  .clue, .solution { font-size: 1rem; padding: 8px 10px; }
  .praise { font-size: 1.2rem; }
  .btn { min-height: 48px; font-size: 1.05rem; }
  .btn.big { font-size: 1.15rem; padding: 0.6em 1.2em; }
  .group { min-width: 74px; min-height: 74px; padding: 6px; }
  .frame { grid-template-columns: repeat(5, 38px); grid-template-rows: repeat(2, 38px); }
  .counter-dot { width: 28px; height: 28px; }
  .bar { height: 50px; }
  .unit { font-size: 1.3rem; }
  .equation { font-size: 2.2rem; }
  .chain { font-size: 1.05rem; }
  .chain .big { font-size: 1.5rem; }
  .hero-mascot { width: 110px; }
  .logo .l2 { font-size: 3.4rem; }
  .grade-card { padding: 18px 16px; }
  .gc-icon { font-size: 3.4rem; }
  .lesson { padding: 10px; margin-bottom: 12px; }
  .brief-story { margin: 10px 0; }
  .lesson-lines { font-size: 1.1rem; }
  .welcome-lines { font-size: 1.1rem; }
  .results-card .res-mascot { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
