/* =========================================================
   Bé Vui Học Toán — giao diện chung
   Phong cách: Claymorphism (khối mềm, bo tròn, bóng đổ dày)
   Font: Baloo 2 (hỗ trợ tiếng Việt)
   ========================================================= */

:root {
  color-scheme: light;

  /* Màu chính (design-system/toan-tu-duy/MASTER.md) */
  --primary: #2563EB;
  --primary-strong: #1E40AF;
  --on-primary: #FFFFFF;
  --secondary: #F59E0B;
  --secondary-strong: #B45309;
  --on-secondary: #0F172A;
  --accent: #DB2777;
  --accent-strong: #9D174D;
  --on-accent: #FFFFFF;
  --violet: #7C3AED;
  --violet-strong: #5B21B6;

  --success: #15803D;
  --success-soft: #DCFCE7;
  --success-line: #86EFAC;
  --warn: #B45309;
  --warn-soft: #FEF3C7;
  --warn-line: #FCD34D;
  --danger: #DC2626;
  --danger-soft: #FEE2E2;
  --danger-line: #FCA5A5;

  --bg: #EFF6FF;
  --fg: #0F172A;
  --card: #FFFFFF;
  --muted: #F1F5FD;
  --muted-fg: #475569;
  --border: #DBE6FB;
  --border-strong: #BFD3F7;
  --ring: #2563EB;

  --radius-xl: 32px;
  --radius-lg: 24px;
  --radius: 18px;
  --radius-sm: 12px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;

  --font: 'Baloo 2', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
}

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 18px;
  line-height: 1.5;
  color: var(--fg);
  background-color: var(--bg);
  background-image:
    radial-gradient(circle at 8% 12%, rgba(245, 158, 11, .16) 0 90px, transparent 91px),
    radial-gradient(circle at 92% 18%, rgba(219, 39, 119, .12) 0 70px, transparent 71px),
    radial-gradient(circle at 85% 88%, rgba(37, 99, 235, .12) 0 120px, transparent 121px),
    radial-gradient(circle at 10% 92%, rgba(124, 58, 237, .10) 0 80px, transparent 81px);
  background-attachment: fixed;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3 { line-height: 1.15; margin: 0; font-weight: 800; }
p { margin: 0; }
a { color: var(--primary); }
[hidden] { display: none !important; }

:focus-visible {
  outline: 4px solid var(--ring);
  outline-offset: 3px;
  border-radius: 12px;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.icon { display: inline-block; width: 1em; height: 1em; flex: none; vertical-align: -0.125em; }
[data-icon] { display: inline-flex; }

/* ---------- Bố cục ---------- */
.app {
  max-width: 980px;
  margin: 0 auto;
  padding: var(--space-4) var(--space-4) var(--space-7);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.screen { display: flex; flex-direction: column; gap: var(--space-5); flex: 1; }

/* ---------- Thẻ đất sét ---------- */
.card {
  background: var(--card);
  border: 3px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: 0 8px 0 var(--border-strong), 0 18px 36px rgba(37, 99, 235, .10);
  padding: var(--space-5);
}

/* ---------- Thanh trên cùng ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.topbar-title {
  flex: 1;
  font-size: clamp(1.4rem, 4.5vw, 2rem);
  color: var(--primary-strong);
}

.icon-btn {
  width: 60px; height: 60px;
  display: inline-grid; place-items: center;
  font-size: 28px;
  color: var(--primary-strong);
  background: var(--card);
  border: 3px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 5px 0 var(--border-strong);
  cursor: pointer;
  text-decoration: none;
  transition: transform 150ms var(--ease-out), box-shadow 150ms var(--ease-out), background-color 150ms;
  flex: none;
}
.icon-btn:hover { background: var(--muted); }
.icon-btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--border-strong); }
.icon-btn[aria-pressed="false"] { color: var(--muted-fg); }

/* ---------- Nút bấm ---------- */
.btn {
  --btn-bg: var(--card);
  --btn-fg: var(--fg);
  --btn-shadow: var(--border-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 60px;
  padding: 10px 28px;
  font: 800 1.3rem/1.1 var(--font);
  color: var(--btn-fg);
  background: var(--btn-bg);
  border: 3px solid rgba(15, 23, 42, .06);
  border-radius: 22px;
  box-shadow: 0 6px 0 var(--btn-shadow), inset 0 -4px 0 rgba(0, 0, 0, .08);
  cursor: pointer;
  text-decoration: none;
  user-select: none;
  transition: transform 150ms var(--ease-out), box-shadow 150ms var(--ease-out), filter 150ms;
}
.btn:hover { filter: brightness(1.05); }
.btn:active { transform: translateY(5px); box-shadow: 0 1px 0 var(--btn-shadow), inset 0 -2px 0 rgba(0, 0, 0, .08); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn .icon { font-size: 1.3em; }

.btn-primary { --btn-bg: var(--primary); --btn-fg: var(--on-primary); --btn-shadow: var(--primary-strong); }
.btn-yellow  { --btn-bg: var(--secondary); --btn-fg: var(--on-secondary); --btn-shadow: var(--secondary-strong); }
.btn-pink    { --btn-bg: var(--accent); --btn-fg: var(--on-accent); --btn-shadow: var(--accent-strong); }
.btn-green   { --btn-bg: #16A34A; --btn-fg: #fff; --btn-shadow: #166534; }
.btn-white   { --btn-bg: var(--card); --btn-fg: var(--primary-strong); --btn-shadow: var(--border-strong); border-color: var(--border); }
.btn-danger  { --btn-bg: var(--card); --btn-fg: var(--danger); --btn-shadow: var(--danger-line); border-color: var(--danger-soft); }
.btn-xl { min-height: 76px; font-size: 1.7rem; padding: 12px 40px; border-radius: 26px; }
.btn-sm { min-height: 48px; font-size: 1.05rem; padding: 6px 18px; border-radius: 16px; }

.btn-row { display: flex; flex-wrap: wrap; gap: var(--space-4); justify-content: center; }

/* ---------- Viên thông tin ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 52px;
  padding: 6px 18px;
  font-weight: 700; font-size: 1.2rem;
  background: var(--card);
  border: 3px solid var(--border);
  border-radius: 999px;
  box-shadow: 0 4px 0 var(--border-strong);
  font-variant-numeric: tabular-nums;
}
.pill .icon { color: var(--primary); font-size: 1.3em; }

/* ---------- Thanh tiến độ ---------- */
.progress {
  height: 16px;
  background: var(--muted);
  border: 3px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.progress > span {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--secondary), var(--accent));
  border-radius: 999px;
  transition: width 300ms var(--ease-out);
}
.progress.green > span { background: linear-gradient(90deg, #4ADE80, #16A34A); }

/* =========================================================
   TRANG CHỦ
   ========================================================= */
.hero {
  text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: var(--space-2);
  padding-top: var(--space-5);
}
.mascot { width: 132px; height: 132px; }
.mascot svg { width: 100%; height: 100%; overflow: visible; }
.mascot .eye-lid { transform-origin: center; transform-box: fill-box; animation: blink 5s infinite; }
.mascot { animation: bob 3.2s ease-in-out infinite; }
@keyframes blink { 0%, 94%, 100% { transform: scaleY(0); } 96% { transform: scaleY(1); } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

.hero h1 {
  font-size: clamp(2.2rem, 8vw, 3.6rem);
  color: var(--primary-strong);
  letter-spacing: -.5px;
}
.hero h1 .hl { color: var(--accent); }
.greet { font-size: clamp(1.15rem, 3.6vw, 1.45rem); color: var(--muted-fg); font-weight: 600; }

.menu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-5);
  margin-top: var(--space-4);
}

.menu-card {
  --c: var(--primary);
  --c-strong: var(--primary-strong);
  --c-soft: #DBEAFE;
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: var(--space-3);
  padding: var(--space-6) var(--space-5) var(--space-5);
  text-align: center;
  text-decoration: none;
  color: var(--fg);
  background: var(--card);
  border: 4px solid var(--c-soft);
  border-radius: var(--radius-xl);
  box-shadow: 0 10px 0 var(--c-strong), 0 22px 40px rgba(15, 23, 42, .10);
  cursor: pointer;
  transition: transform 200ms var(--ease-out), box-shadow 200ms var(--ease-out);
}
.menu-card:hover { transform: translateY(-4px); box-shadow: 0 14px 0 var(--c-strong), 0 26px 44px rgba(15, 23, 42, .14); }
.menu-card:active { transform: translateY(8px); box-shadow: 0 2px 0 var(--c-strong), 0 8px 16px rgba(15, 23, 42, .10); }
.menu-card.is-pink { --c: var(--accent); --c-strong: var(--accent-strong); --c-soft: #FCE7F3; }
.menu-card.is-violet { --c: var(--violet); --c-strong: var(--violet-strong); --c-soft: #EDE9FE; }

.menu-art {
  width: 100%;
  max-width: 260px;
  height: 130px;
  display: grid; place-items: center;
  background: var(--c-soft);
  border-radius: var(--radius-lg);
}
.menu-art svg { width: 88%; height: 88%; }
.menu-title { font-size: 2rem; font-weight: 800; color: var(--c-strong); line-height: 1.1; }
.menu-sub { font-size: 1.1rem; color: var(--muted-fg); font-weight: 600; }
.menu-go {
  margin-top: var(--space-2);
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 26px;
  font-size: 1.3rem; font-weight: 800;
  color: #fff;
  background: var(--c);
  border-radius: 999px;
}

.home-footer {
  margin-top: auto;
  padding-top: var(--space-6);
  display: flex; justify-content: center; gap: var(--space-4); flex-wrap: wrap;
}

/* =========================================================
   TÍNH NHANH
   ========================================================= */
.start-card { display: flex; flex-direction: column; align-items: center; gap: var(--space-5); text-align: center; }
.start-card h2 { font-size: clamp(1.8rem, 6vw, 2.6rem); color: var(--primary-strong); }
.lead { font-size: 1.25rem; color: var(--muted-fg); font-weight: 600; }

.mastery-mini { width: 100%; max-width: 460px; display: flex; flex-direction: column; gap: var(--space-2); font-weight: 700; font-size: 1.15rem; }
.mastery-mini b { color: var(--success); font-size: 1.4rem; }

.choice-group { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; align-items: center; gap: var(--space-3); }
.choice-group legend { font-weight: 800; font-size: 1.2rem; margin-bottom: var(--space-3); padding: 0; }
.seg { display: flex; gap: var(--space-3); flex-wrap: wrap; justify-content: center; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label {
  min-width: 96px; min-height: 64px;
  display: inline-grid; place-items: center;
  padding: 6px 18px;
  font-size: 1.6rem; font-weight: 800;
  color: var(--primary-strong);
  background: var(--card);
  border: 3px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 5px 0 var(--border-strong);
  cursor: pointer;
  transition: transform 150ms var(--ease-out), box-shadow 150ms, background-color 150ms, color 150ms;
}
.field-label { font-weight: 700; margin-bottom: 6px; }
.seg label small { display: block; font-size: .85rem; font-weight: 600; color: inherit; opacity: .8; line-height: 1; }
.seg input:checked + label { background: var(--primary); color: #fff; border-color: var(--primary); box-shadow: 0 5px 0 var(--primary-strong); }
.seg input:focus-visible + label { outline: 4px solid var(--ring); outline-offset: 3px; }
.seg label:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--border-strong); }

.play-status { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.play-status .spacer { flex: 1; }

.question-card {
  display: grid; place-items: center;
  padding: var(--space-5) var(--space-4);
  min-height: 190px;
  transition: background-color 200ms, border-color 200ms;
}
.question {
  display: flex; align-items: center; justify-content: center; gap: .25em;
  font-size: clamp(3.6rem, 15vw, 7rem);
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--fg);
}
.question .op { color: var(--accent); }
.question .eq { color: var(--muted-fg); }
.ans-slot {
  min-width: 1.4em;
  padding: 0 .12em;
  text-align: center;
  color: var(--primary);
  background: var(--muted);
  border: 4px dashed var(--border-strong);
  border-radius: 22px;
}
.question-card.is-correct { background: var(--success-soft); border-color: var(--success-line); }
.question-card.is-correct .ans-slot { color: var(--success); border-style: solid; border-color: var(--success-line); background: #fff; }
.question-card.is-wrong { background: var(--warn-soft); border-color: var(--warn-line); }
.question-card.is-wrong .ans-slot { color: var(--success); border-style: solid; border-color: var(--success-line); background: #fff; }
.question-card.pop .question { animation: pop 260ms var(--ease-spring); }
.question-card.is-wrong .question { animation: shake 420ms ease-in-out; }

@keyframes pop { from { transform: scale(.85); opacity: .3; } to { transform: scale(1); opacity: 1; } }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-10px); } 40% { transform: translateX(10px); }
  60% { transform: translateX(-6px); } 80% { transform: translateX(6px); }
}

.keypad {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-3);
}
@media (min-width: 640px) { .keypad { grid-template-columns: repeat(6, 1fr); gap: var(--space-4); } }

.key {
  --k: var(--primary);
  min-height: 78px;
  display: grid; place-items: center;
  font: 800 clamp(2.2rem, 8vw, 3rem)/1 var(--font);
  color: var(--k);
  background: var(--card);
  border: 3px solid var(--border);
  border-radius: 22px;
  box-shadow: 0 6px 0 var(--k), 0 10px 18px rgba(15, 23, 42, .08);
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
  transition: transform 120ms var(--ease-out), box-shadow 120ms var(--ease-out), background-color 150ms;
}
.key:hover { background: var(--muted); }
.key:active { transform: translateY(5px); box-shadow: 0 1px 0 var(--k); }
.key:disabled { cursor: default; }
.key.key-correct { background: var(--success-soft); border-color: var(--success-line); color: var(--success); }
.key.key-wrong { background: var(--danger-soft); border-color: var(--danger-line); color: var(--danger); }
.key.key-hint { background: var(--success-soft); border-color: #16A34A; color: var(--success); animation: pulse 700ms ease-in-out 2; }
@keyframes pulse { 50% { transform: scale(1.08); } }

/* Lớp phủ tạm dừng */
.overlay {
  position: fixed; inset: 0;
  z-index: 50;
  display: grid; place-items: center;
  padding: var(--space-4);
  background: rgba(15, 23, 42, .45);
  backdrop-filter: blur(4px);
}
.overlay .card { width: min(440px, 100%); text-align: center; display: flex; flex-direction: column; gap: var(--space-4); align-items: stretch; }
.overlay h2 { font-size: 2rem; color: var(--primary-strong); }

/* Kết quả */
.result-hero { text-align: center; display: flex; flex-direction: column; align-items: center; gap: var(--space-3); }
.result-hero h2 { font-size: clamp(2.4rem, 9vw, 3.6rem); color: var(--accent); }
.result-hero .big { font-size: clamp(1.3rem, 4.5vw, 1.6rem); font-weight: 700; }
.result-hero .compare { font-size: clamp(1.2rem, 4vw, 1.45rem); color: var(--success); font-weight: 800; }
.stars { display: flex; gap: 8px; font-size: 80px; }
.stars .icon { width: clamp(60px, 18vw, 84px); height: clamp(60px, 18vw, 84px); }

/* Ba ô số to: đúng / nhanh / sai */
.score-tiles {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: clamp(8px, 2.5vw, 16px);
  width: 100%; max-width: 560px;
}
.score-tile {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: clamp(10px, 3vw, 18px) 6px;
  border-radius: var(--radius-lg);
  border: 3px solid var(--border);
  background: var(--muted);
}
.score-tile b {
  font-size: clamp(2.6rem, 12vw, 4.2rem); font-weight: 800; line-height: 1;
  font-variant-numeric: tabular-nums;
}
.score-tile .st-label { font-size: clamp(1rem, 3.6vw, 1.25rem); font-weight: 700; }
.score-tile .st-ico .icon { width: clamp(26px, 7vw, 34px); height: clamp(26px, 7vw, 34px); stroke-width: 3; }
.score-tile.is-ok { background: var(--success-soft); border-color: var(--success-line); color: var(--success); }
.score-tile.is-fast { background: var(--warn-soft); border-color: var(--warn-line); color: var(--secondary-strong); }
.score-tile.is-wrong { background: var(--danger-soft); border-color: var(--danger-line); color: var(--danger); }
.stars .on { color: var(--secondary); filter: drop-shadow(0 4px 0 var(--secondary-strong)); }
.stars .off { color: var(--border-strong); }
.stars .on:nth-child(1) { animation: starIn 400ms var(--ease-spring) 100ms both; }
.stars .on:nth-child(2) { animation: starIn 400ms var(--ease-spring) 300ms both; }
.stars .on:nth-child(3) { animation: starIn 400ms var(--ease-spring) 500ms both; }
@keyframes starIn { from { transform: scale(0) rotate(-40deg); } to { transform: scale(1) rotate(0); } }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--space-4);
}
.stat {
  background: var(--card);
  border: 3px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 5px 0 var(--border-strong);
  padding: var(--space-4);
  text-align: center;
}
.stat .label { font-size: 1.1rem; color: var(--muted-fg); font-weight: 700; }
.stat .value { font-size: clamp(2rem, 7vw, 2.6rem); font-weight: 800; color: var(--primary-strong); font-variant-numeric: tabular-nums; line-height: 1.2; }

.panel-title { font-size: 1.4rem; color: var(--primary-strong); display: flex; align-items: center; gap: 10px; }
.hint { color: var(--muted-fg); font-size: 1rem; }

.group { margin-top: var(--space-5); }
.group h4 { margin: 0 0 var(--space-3); font-size: 1.15rem; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 34px; height: 30px; padding: 0 10px;
  border-radius: 999px; font-size: 1rem; font-weight: 800;
}
.lv-fast .badge, .badge.lv-fast { background: var(--success-soft); color: var(--success); }
.lv-ok .badge, .badge.lv-ok { background: var(--warn-soft); color: var(--warn); }
.lv-weak .badge, .badge.lv-weak { background: var(--danger-soft); color: var(--danger); }

.chips { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.chip {
  display: inline-flex; flex-direction: column;
  padding: 6px 14px;
  border-radius: 14px;
  border: 2px solid var(--border);
  background: var(--muted);
  line-height: 1.2;
}
.chip b { font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.chip small { font-size: .9rem; color: var(--muted-fg); font-weight: 600; }
.chip.lv-fast { background: var(--success-soft); border-color: var(--success-line); }
.chip.lv-ok { background: var(--warn-soft); border-color: var(--warn-line); }
.chip.lv-weak { background: var(--danger-soft); border-color: var(--danger-line); }
.chip .wrong { color: var(--danger); }
.empty-note { color: var(--muted-fg); font-style: italic; }

/* Thông báo nhỏ */
.toast {
  position: fixed;
  left: 50%; top: 18px;
  z-index: 60;
  transform: translate(-50%, -140%);
  padding: 12px 26px;
  font-size: 1.3rem; font-weight: 800;
  color: #fff;
  background: var(--violet);
  border-radius: 999px;
  box-shadow: 0 6px 0 var(--violet-strong), 0 12px 30px rgba(15, 23, 42, .2);
  transition: transform 300ms var(--ease-spring);
  pointer-events: none;
  white-space: nowrap;
  max-width: calc(100vw - 32px);
  overflow: hidden; text-overflow: ellipsis;
}
.toast.show { transform: translate(-50%, 0); }

.confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 70; }

/* =========================================================
   TOÁN TƯ DUY
   ========================================================= */
.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-5);
}
.game-card {
  --c: var(--primary); --c-strong: var(--primary-strong); --c-soft: #DBEAFE;
  display: flex; flex-direction: column; align-items: center; gap: var(--space-2);
  padding: var(--space-5) var(--space-4) var(--space-4);
  font-family: var(--font);
  color: var(--fg);
  text-align: center;
  background: var(--card);
  border: 4px solid var(--c-soft);
  border-radius: var(--radius-xl);
  box-shadow: 0 8px 0 var(--c-strong);
  cursor: pointer;
  transition: transform 180ms var(--ease-out), box-shadow 180ms var(--ease-out);
}
.game-card:hover { transform: translateY(-3px); box-shadow: 0 11px 0 var(--c-strong); }
.game-card:active { transform: translateY(6px); box-shadow: 0 2px 0 var(--c-strong); }
.game-card .preview {
  width: 100%; min-height: 84px;
  display: grid; place-items: center;
  padding: 8px;
  font-size: 2rem; letter-spacing: 2px; line-height: 1.2;
  background: var(--c-soft);
  border-radius: var(--radius);
}
.game-card .g-title { font-size: 1.5rem; font-weight: 800; color: var(--c-strong); line-height: 1.1; }
.game-card .g-desc { font-size: 1rem; color: var(--muted-fg); font-weight: 600; }
.game-card .g-stars { display: flex; gap: 2px; font-size: 22px; }
.game-card .g-stars .on { color: var(--secondary); }
.game-card .g-stars .off { color: var(--border-strong); }

.c-blue   { --c: #2563EB; --c-strong: #1E40AF; --c-soft: #DBEAFE; }
.c-pink   { --c: #DB2777; --c-strong: #9D174D; --c-soft: #FCE7F3; }
.c-yellow { --c: #D97706; --c-strong: #92400E; --c-soft: #FEF3C7; }
.c-green  { --c: #16A34A; --c-strong: #166534; --c-soft: #DCFCE7; }
.c-violet { --c: #7C3AED; --c-strong: #5B21B6; --c-soft: #EDE9FE; }
.c-teal   { --c: #0D9488; --c-strong: #115E59; --c-soft: #CCFBF1; }
.c-orange { --c: #EA580C; --c-strong: #9A3412; --c-soft: #FFEDD5; }

/* Nhân vật (SVG mặc định hoặc ảnh bố mẹ tải lên) — cỡ theo font-size như emoji */
.ch { display: inline-block; width: 1em; height: 1em; vertical-align: middle; line-height: 0; flex: none; }
.ch svg { width: 100%; height: 100%; display: block; overflow: visible; }
img.ch { object-fit: contain; }
.char-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: var(--space-4); }
.char-item {
  display: grid; grid-template-columns: 72px 1fr; gap: 10px 14px; align-items: center;
  padding: var(--space-3); border: 2px solid var(--border); border-radius: var(--radius);
}
.char-pic { width: 72px; height: 72px; display: grid; place-items: center; font-size: 60px; background: var(--muted); border-radius: 16px; }
.char-item .field { margin: 0; }
.char-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; }
.preview-chars { display: inline-flex; align-items: flex-end; gap: 2px; font-size: 2.2rem; }

/* ---------- Cân thăng bằng ---------- */
.scales { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); width: 100%; }
.scales.one { grid-template-columns: minmax(0, 340px); justify-content: center; }
.scale { --tilt: 0deg; position: relative; height: clamp(190px, 44vw, 260px); }
.scale-base {
  position: absolute; left: 50%; bottom: 0; width: 46%; height: 14px;
  transform: translateX(-50%);
  background: #64748B; border-radius: 10px 10px 6px 6px;
}
.scale-post {
  position: absolute; left: 50%; bottom: 10px; top: 58%;
  width: 10px; margin-left: -5px;
  background: #94A3B8; border-radius: 5px;
}
.scale-beam {
  position: absolute; left: 2%; right: 2%; top: 58%; height: 10px; margin-top: -5px;
  background: #475569; border-radius: 5px;
  transform: rotate(var(--tilt));
  transition: transform 900ms cubic-bezier(.34, 1.4, .64, 1);
}
.scale-pivot {
  position: absolute; left: 50%; top: 50%; width: 22px; height: 22px; margin: -11px 0 0 -11px;
  background: #F59E0B; border: 3px solid #B45309; border-radius: 50%;
}
.pan {
  position: absolute; bottom: 5px; width: 44%;
  display: flex; flex-direction: column; align-items: center;
  transform: rotate(calc(var(--tilt) * -1)); transform-origin: 50% 100%;
  transition: transform 900ms cubic-bezier(.34, 1.4, .64, 1);
}
.pan::after { content: ''; width: 8px; height: 12px; background: #B45309; border-radius: 0 0 3px 3px; } /* chân đĩa nối xuống đòn cân */
.pan-l { left: 0; }
.pan-r { right: 0; }
.pan-items {
  display: flex; flex-wrap: wrap-reverse; justify-content: center; align-content: flex-start;
  gap: 1px; min-height: 1.1em; max-width: 100%;
  font-size: clamp(1.7rem, 6.4vw, 3rem); line-height: 1;
}
.pan-plate { display: block; width: 100%; height: 12px; background: #FBBF24; border: 3px solid #B45309; border-top-width: 2px; border-radius: 0 0 40px 40px; }
.pan-ask { padding-bottom: 2px; }
.pan-q {
  display: grid; place-items: center;
  width: 1.5em; height: 1.5em;
  font-size: clamp(1.4rem, 5vw, 2rem); font-weight: 800; color: var(--accent);
  background: #FCE7F3; border: 3px dashed var(--accent); border-radius: 14px;
}
.pan-ask.filled { animation: pop 380ms var(--ease-out); }
.choices.panels3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-3); width: 100%; }
.choices.panels3 .choice.panel { min-width: 0; min-height: 112px; padding: 10px 6px; }
.choices.panels3 .pan-items, .t-panels3 .pan-items { font-size: clamp(1.7rem, 7vw, 2.8rem); gap: 2px; }
.t-panels3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-3); width: min(520px, 100%); }
.t-panels3 .choice.panel { min-width: 0; min-height: 96px; padding: 8px 6px; }

.dots { display: flex; gap: 8px; flex-wrap: wrap; }
.dots span {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--card); border: 3px solid var(--border-strong);
}
.dots span.done { background: var(--success-line); border-color: #16A34A; }
.dots span.miss { background: var(--warn-line); border-color: var(--secondary-strong); }
.dots span.now { background: var(--secondary); border-color: var(--secondary-strong); transform: scale(1.2); }

.prompt {
  display: flex; align-items: center; justify-content: center; gap: var(--space-3);
  text-align: center;
  font-size: clamp(1.6rem, 5.5vw, 2.4rem);
  font-weight: 800;
  color: var(--primary-strong);
}
.prompt em { font-style: normal; color: var(--accent); text-decoration: underline; text-decoration-thickness: 4px; text-underline-offset: 6px; }

.stage {
  min-height: 170px;
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-4);
}
.stage-emoji { font-size: clamp(2.4rem, 9vw, 3.6rem); line-height: 1; }
.slot-q {
  width: clamp(64px, 16vw, 92px); height: clamp(64px, 16vw, 92px);
  display: grid; place-items: center;
  font-size: clamp(2.2rem, 8vw, 3.2rem); font-weight: 800;
  color: var(--accent);
  background: #FCE7F3;
  border: 4px dashed var(--accent);
  border-radius: 22px;
}
.slot-q.filled { border-style: solid; background: var(--success-soft); border-color: #16A34A; color: inherit; }

.num-bubble {
  width: clamp(60px, 15vw, 88px); height: clamp(60px, 15vw, 88px);
  display: grid; place-items: center;
  font-size: clamp(2rem, 7vw, 3rem); font-weight: 800;
  color: var(--primary-strong);
  background: #DBEAFE;
  border: 3px solid var(--border-strong);
  border-radius: 50%;
}

.choices {
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: var(--space-4);
}
.choice {
  min-width: 110px; min-height: 104px;
  display: grid; place-items: center;
  padding: 10px 18px;
  font: 800 clamp(2.4rem, 9vw, 3.4rem)/1 var(--font);
  color: var(--primary-strong);
  background: var(--card);
  border: 3px solid var(--border);
  border-radius: 26px;
  box-shadow: 0 7px 0 var(--border-strong), 0 12px 20px rgba(15, 23, 42, .08);
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 140ms var(--ease-out), box-shadow 140ms var(--ease-out), background-color 150ms, opacity 200ms;
}
.choice:hover { background: var(--muted); }
.choice:active { transform: translateY(6px); box-shadow: 0 1px 0 var(--border-strong); }
.choice.is-right { background: var(--success-soft); border-color: #16A34A; box-shadow: 0 7px 0 #16A34A; }
.choice.is-wrong { background: var(--danger-soft); border-color: var(--danger-line); opacity: .55; animation: shake 420ms ease-in-out; }
.choice:disabled { cursor: default; }

.choices.panels { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
.choice.panel {
  min-height: 200px;
  padding: var(--space-4);
  align-content: center;
}
.panel-items { display: flex; flex-wrap: wrap; justify-content: center; align-content: center; gap: 4px; max-width: 100%; }
.panel-items span { line-height: 1.1; }

/* Khung 10 ô (ten-frame) & xúc xắc */
.tenframe {
  display: grid; grid-template-columns: repeat(5, 1fr);
  gap: 6px; padding: 8px;
  background: #1E40AF;
  border-radius: 16px;
  width: min(380px, 100%);
}
.tenframe span { aspect-ratio: 1; background: #fff; border-radius: 10px; display: grid; place-items: center; }
.tenframe span i, .dice span i {
  width: 72%; height: 72%; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #FDA4AF, #DB2777 70%);
}
.dice {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  width: min(220px, 70vw); aspect-ratio: 1; padding: 16px;
  background: #fff;
  border: 4px solid var(--border-strong);
  border-radius: 28px;
  box-shadow: 0 6px 0 var(--border-strong);
}
.dice span { display: grid; place-items: center; }
.cover {
  width: min(380px, 100%); min-height: 150px;
  display: grid; place-items: center;
  font-size: 4rem; font-weight: 800; color: #fff;
  background: repeating-linear-gradient(45deg, var(--violet), var(--violet) 18px, #8B5CF6 18px, #8B5CF6 36px);
  border-radius: 24px;
}

/* Ngôi nhà số */
.house { display: flex; flex-direction: column; align-items: center; width: min(320px, 90%); }
.house .roof {
  width: 100%; height: 120px;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  line-height: 1;
  padding-bottom: 10px;
  font-size: 3.2rem; font-weight: 800; color: #fff;
  background: var(--accent);
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}
.house .rooms {
  width: 86%;
  display: grid; grid-template-columns: 1fr 1fr;
  border: 4px solid var(--accent-strong);
  border-top: 0;
  background: #fff;
  border-radius: 0 0 18px 18px;
  overflow: hidden;
}
.house .room {
  min-height: 110px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  font-size: 3rem; font-weight: 800;
  color: var(--primary-strong);
  padding: 8px;
}
.house .room + .room { border-left: 4px solid var(--accent-strong); }
.house .room .mini { font-size: 1rem; letter-spacing: 1px; line-height: 1; color: var(--accent); }
.house .room .slot-q { width: 76px; height: 76px; }
.house .roof-mini { color: #FDE68A; font-size: .95rem; letter-spacing: 1px; margin-top: 4px; }
/* Phép tính hiện ra sau khi bé trả lời đúng */
.bond-eq { width: 100%; text-align: center; font-size: clamp(2rem, 8vw, 2.8rem); font-weight: 800; color: var(--success); line-height: 1.1; }

/* ---------- Hướng dẫn dạng video ---------- */
.tutor-video {
  position: relative;
  padding: 0; overflow: hidden;
  background: linear-gradient(180deg, #F0FDFA 0%, #FFFFFF 70%);
  border: 4px solid #5EEAD4;
  box-shadow: 0 8px 0 #0D9488, 0 14px 28px rgba(15, 23, 42, .1);
}
.tutor-badge {
  position: absolute; top: 12px; left: 12px; z-index: 1;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px;
  border-radius: 999px;
  background: #0D9488; color: #fff;
  font-size: .95rem; font-weight: 700;
}
.tutor-badge .icon { width: 18px; height: 18px; }
.tutor-frame {
  position: relative;
  min-height: clamp(380px, 52vh, 480px);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px;
  padding: 52px 12px 20px;
}
.tutor-overlay {
  position: absolute; inset: 0; z-index: 3;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  border: 0; cursor: pointer;
  background: rgba(15, 23, 42, .38);
  font: 800 1.5rem/1.2 var(--font); color: #fff;
}
.tutor-overlay .bigplay {
  width: 112px; height: 112px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent); color: #fff;
  box-shadow: 0 8px 0 var(--accent-strong);
  transition: transform 160ms var(--ease-out);
}
.tutor-overlay:hover .bigplay { transform: scale(1.06); }
.tutor-overlay .bigplay .icon { width: 54px; height: 54px; margin-left: 6px; }
.tutor-caption {
  min-height: 2.8em; margin: 0;
  text-align: center;
  font-size: clamp(1.25rem, 4.6vw, 1.6rem); font-weight: 800; line-height: 1.35;
  color: var(--primary-strong);
}
.tutor-controls { display: flex; align-items: center; gap: var(--space-3); }
.tutor-controls .progress { flex: 1; }
.tutor-controls .progress span { transition: width 500ms var(--ease-out); }

/* Ngôi nhà trong hướng dẫn */
.t-house { width: min(300px, 88%); }
.t-house .roof { height: 150px; gap: 8px; padding-bottom: 12px; font-size: 2.8rem; }
.t-house .room { min-height: 128px; justify-content: flex-start; padding-top: 12px; }
.t-pool { display: flex; gap: 6px; min-height: 24px; justify-content: center; }
.t-dot {
  display: inline-block; width: 24px; height: 24px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #FEF3C7, #F59E0B 70%);
  border: 2px solid #fff;
  box-shadow: 0 2px 0 rgba(146, 64, 14, .35);
}
.t-num { min-height: 3rem; display: grid; place-items: center; font-size: 2.8rem; line-height: 1; }
.t-num .slot-q { width: 64px; height: 64px; font-size: 2.4rem; }
.t-room-dots { display: flex; flex-wrap: wrap; gap: 5px; justify-content: center; min-height: 24px; max-width: 110px; }
.t-room-dots.t-shine .t-dot { box-shadow: 0 0 0 5px #FDE68A; }
.t-eq { min-height: 1.2em; font-size: clamp(2rem, 8vw, 2.8rem); font-weight: 800; line-height: 1.1; color: var(--success); }
.t-choices { display: flex; gap: 14px; justify-content: center; }
.t-choices .choice { min-width: 76px; min-height: 72px; font-size: 2.2rem; cursor: default; pointer-events: none; }
.t-hand {
  position: absolute; left: 0; top: 0; z-index: 2;
  font-size: 3rem; line-height: 1;
  opacity: 0;
  transform: translate(75vw, 520px);
  transition: transform 850ms cubic-bezier(.2,.8,.2,1), opacity 300ms;
  pointer-events: none;
  filter: drop-shadow(0 3px 2px rgba(0, 0, 0, .25));
}
.t-hand.tap { animation: tTap 380ms ease-in-out 2; }
@keyframes tTap { 50% { scale: .78; } }
/* Các trò khác trong hướng dẫn */
.t-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: var(--space-3); }
.t-row .stage-emoji, .t-row .num-bubble, .t-row .slot-q { flex: none; }
.t-ask {
  min-height: 1.3em;
  text-align: center;
  font-size: clamp(1.5rem, 5.5vw, 2rem); font-weight: 800;
  color: var(--primary-strong);
}
.t-ask em { font-style: normal; color: var(--accent); text-decoration: underline; text-decoration-thickness: 4px; text-underline-offset: 6px; }
.t-panels { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); width: min(520px, 100%); }
.t-panels .choice.panel { min-height: 170px; cursor: default; pointer-events: none; }
/* Khung chứa hình của trò Nhìn nhanh: cần bề rộng cố định, nếu không khung 10 ô
   (rộng theo % của khung chứa) sẽ bị co lại thành một vệt nhỏ */
.stage > [data-pic] { width: min(380px, 100%); display: grid; place-items: center; gap: var(--space-3); }
/* Thanh đếm ngược của mỗi câu (ngắn dần, chuyển đỏ lúc sắp hết); thời gian theo cài đặt của bé, biến --qlimit */
.q-timer {
  width: 100%; height: 16px;
  border-radius: 999px; overflow: hidden;
  background: var(--card); border: 3px solid var(--border);
}
.q-timer span {
  display: block; height: 100%;
  background: var(--violet);
  border-radius: 999px;
  transform-origin: left center;
}
@keyframes qTimer {
  0% { transform: scaleX(1); background: var(--violet); }
  70% { background: var(--violet); }
  100% { transform: scaleX(0); background: var(--danger); }
}
/* Hết giờ: chỉ cho bé thấy đáp án đúng */
.choice.is-answer { background: var(--success-soft); border: 3px dashed #16A34A; box-shadow: 0 7px 0 var(--success-line); animation: pop 400ms var(--ease-spring) both; }
.t-flash { width: min(380px, 100%); display: grid; place-items: center; }
.t-flash > [data-pic] { width: 100%; display: grid; place-items: center; }
.t-flash .cover { width: 100%; }
.tenframe span.t-hl5 { background: #FEF3C7; }
.tenframe span.t-hl { background: #DCFCE7; box-shadow: inset 0 0 0 3px #16A34A; }
.t-pop { animation: pop 420ms var(--ease-spring) both; }
.t-glow { animation: tGlow 650ms ease-in-out 2; }
@keyframes tGlow { 50% { transform: scale(1.07); filter: brightness(1.15); } }
.btn.pulse { animation: tPulse 1.1s ease-in-out infinite; }
@keyframes tPulse { 50% { transform: scale(1.06); } }

.round-result { text-align: center; display: flex; flex-direction: column; align-items: center; gap: var(--space-4); }
.round-result h2 { font-size: clamp(2rem, 7vw, 3rem); color: var(--accent); }
.form-report { width: 100%; text-align: left; border-top: 2px dashed var(--border); padding-top: var(--space-4); }
.form-report .group { margin-top: var(--space-3); }
.form-report .chip b { font-size: 1.15rem; }

/* =========================================================
   GÓC BỐ MẸ
   ========================================================= */
.gate { max-width: 460px; margin: var(--space-6) auto 0; text-align: center; display: flex; flex-direction: column; gap: var(--space-4); }
.gate h2 { font-size: 1.8rem; color: var(--primary-strong); }
.gate .q { font-size: 2.2rem; font-weight: 800; }

.field { display: flex; flex-direction: column; gap: 6px; text-align: left; }
.field label { font-weight: 700; }
.field .help { font-size: .95rem; color: var(--muted-fg); }
.input {
  min-height: 56px;
  padding: 8px 16px;
  font: 700 1.3rem var(--font);
  color: var(--fg);
  background: #fff;
  border: 3px solid var(--border-strong);
  border-radius: 16px;
  width: 100%;
}
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px rgba(37, 99, 235, .25); }
.field-error { color: var(--danger); font-weight: 700; min-height: 1.5em; }

.check { display: flex; align-items: center; gap: 12px; min-height: 48px; font-weight: 700; cursor: pointer; }
.check input { width: 28px; height: 28px; accent-color: var(--primary); cursor: pointer; }

.section-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; margin-bottom: var(--space-4); }
.section-head h2 { font-size: 1.6rem; color: var(--primary-strong); display: flex; align-items: center; gap: 10px; }

.legend { display: flex; flex-wrap: wrap; gap: var(--space-3); font-size: 1rem; font-weight: 600; margin-bottom: var(--space-4); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 26px; height: 26px; border-radius: 8px; display: inline-grid; place-items: center; font-style: normal; font-size: .9rem; font-weight: 800; border: 2px solid; }

.grids { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: var(--space-5); }
.grid-wrap h3 { font-size: 1.25rem; margin-bottom: var(--space-2); }
.grid-wrap .axis { font-size: .9rem; color: var(--muted-fg); margin-bottom: var(--space-2); }
.fact-table { border-collapse: separate; border-spacing: 3px; width: 100%; table-layout: fixed; }
.fact-table th { font-size: .9rem; font-weight: 800; color: var(--muted-fg); padding: 2px 0; }
.fact-table th.corner { color: var(--accent); font-size: 1.1rem; }
.fact-table td { padding: 0; }
.cell {
  width: 100%; aspect-ratio: 1;
  min-height: 26px;
  display: grid; place-items: center;
  padding: 0;
  font: 800 .85rem var(--font);
  border: 2px solid;
  border-radius: 7px;
  cursor: pointer;
}
.cell.lv-none { background: #F8FAFC; border-color: #E2E8F0; color: #94A3B8; }
.cell.lv-fast, .legend i.lv-fast { background: #BBF7D0; border-color: #16A34A; color: #14532D; }
.cell.lv-ok,   .legend i.lv-ok   { background: #FDE68A; border-color: #D97706; color: #78350F; }
.cell.lv-weak, .legend i.lv-weak { background: #FECACA; border-color: #DC2626; color: #7F1D1D; }
.legend i.lv-none { background: #F8FAFC; border-color: #CBD5E1; color: #94A3B8; }
.cell.sel { outline: 3px solid var(--primary); outline-offset: 1px; }

.fact-detail { margin-top: var(--space-4); padding: var(--space-3) var(--space-4); background: var(--muted); border-radius: var(--radius); min-height: 56px; font-weight: 600; }

.table-scroll { overflow-x: auto; }
.hist { width: 100%; border-collapse: collapse; font-size: 1rem; }
.hist th, .hist td { padding: 10px 8px; text-align: left; border-bottom: 2px solid var(--border); white-space: nowrap; }
.hist th { color: var(--muted-fg); font-size: .9rem; }
.hist td.num { font-variant-numeric: tabular-nums; }
.bar { display: inline-block; height: 12px; border-radius: 6px; background: var(--primary); vertical-align: middle; margin-left: 8px; min-width: 4px; }

.logic-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--space-3); }
.logic-item { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 14px; background: var(--muted); border-radius: var(--radius); font-weight: 700; }
.logic-item .g-stars .on { color: var(--secondary); }
.logic-item .g-stars .off { color: var(--border-strong); }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--space-4); }

.tips details {
  border: 3px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-4);
  background: #fff;
}
.tips details + details { margin-top: var(--space-3); }
.tips summary { font-weight: 800; font-size: 1.15rem; cursor: pointer; color: var(--primary-strong); min-height: 36px; display: flex; align-items: center; }
.tips ul { margin: var(--space-2) 0 0; padding-left: 1.3em; }
.tips li + li { margin-top: 6px; }

/* =========================================================
   HỒ SƠ TỪNG BÉ
   ========================================================= */
/* màu lấy từ lớp .c-blue / .c-pink ... gắn kèm */
.avatar {
  width: 96px; height: 96px;
  display: inline-grid; place-items: center;
  flex: none;
  font-size: 56px; line-height: 1;
  background: var(--c-soft);
  border: 4px solid var(--c-strong);
  border-radius: 50%;
}
.avatar-sm { width: 40px; height: 40px; font-size: 24px; border-width: 3px; }
.avatar-md { width: 64px; height: 64px; font-size: 38px; }
.avatar-lg { width: 128px; height: 128px; font-size: 76px; border-width: 5px; }

.who-chip {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 60px;
  padding: 6px 16px 6px 8px;
  font: 800 1.15rem var(--font);
  color: var(--fg);
  background: var(--card);
  border: 3px solid var(--border);
  border-radius: 999px;
  box-shadow: 0 5px 0 var(--border-strong);
  cursor: pointer;
  text-decoration: none;
  max-width: 46vw;
  transition: transform 150ms var(--ease-out), box-shadow 150ms var(--ease-out);
}
.who-chip:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--border-strong); }
.who-text { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; text-align: left; }
.who-text small { font-size: .85rem; font-weight: 700; color: var(--muted-fg); }
.who-chip.who-big {
  margin-top: var(--space-3);
  min-height: 84px;
  padding: 8px 10px 8px 10px;
  gap: 12px;
  font-size: 1.5rem;
  max-width: calc(100vw - 32px);
  border-color: var(--border-strong);
  box-shadow: 0 6px 0 var(--border-strong), 0 14px 26px rgba(37, 99, 235, .12);
}
.who-switch {
  display: inline-flex; align-items: center;
  min-height: 48px;
  padding: 4px 18px;
  font-size: 1.1rem; font-weight: 800;
  color: #fff;
  background: var(--primary);
  border-radius: 999px;
  white-space: nowrap;
}

.profile-card.add-card {
  color: var(--primary-strong);
  border: 4px dashed var(--border-strong);
  box-shadow: none;
  background: transparent;
  text-decoration: none;
  justify-content: center;
}
.profile-card.add-card .plus {
  width: 128px; height: 128px;
  display: grid; place-items: center;
  font-size: 72px; font-weight: 800; line-height: 1;
  border-radius: 50%;
  background: var(--muted);
}
.profile-card.add-card:hover, .profile-card.add-card:active { box-shadow: none; }
@media (max-width: 480px) { .profile-card.add-card .plus { width: 96px; height: 96px; font-size: 56px; } }
.who-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Màn hình "Ai đang học?" */
.picker {
  position: fixed; inset: 0;
  z-index: 40;
  overflow-y: auto;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--space-6);
  padding: var(--space-6) var(--space-4);
  background: var(--bg);
}
.picker h1 { font-size: clamp(2rem, 7vw, 3.2rem); color: var(--primary-strong); text-align: center; }
.picker-grid {
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: var(--space-5);
  max-width: 900px;
}
.profile-card {
  width: 200px;
  display: flex; flex-direction: column; align-items: center; gap: var(--space-3);
  padding: var(--space-5) var(--space-4);
  font: 800 1.6rem/1.1 var(--font);
  color: var(--c-strong);
  background: var(--card);
  border: 4px solid var(--c-soft);
  border-radius: var(--radius-xl);
  box-shadow: 0 9px 0 var(--c-strong);
  cursor: pointer;
  transition: transform 180ms var(--ease-out), box-shadow 180ms var(--ease-out);
}
.profile-card:hover { transform: translateY(-3px); box-shadow: 0 12px 0 var(--c-strong); }
.profile-card:active { transform: translateY(7px); box-shadow: 0 2px 0 var(--c-strong); }
.profile-card .p-name { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 480px) {
  .profile-card { width: 150px; font-size: 1.3rem; }
  .profile-card .avatar-lg { width: 96px; height: 96px; font-size: 56px; }
}

/* Chọn bé trong Góc bố mẹ */
.kid-tabs { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; }
.kid-tabs .label { font-weight: 800; margin-right: 4px; }
.kid-tab {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 56px;
  padding: 6px 18px 6px 8px;
  font: 800 1.1rem var(--font);
  color: var(--fg);
  background: var(--card);
  border: 3px solid var(--border);
  border-radius: 999px;
  box-shadow: 0 4px 0 var(--border-strong);
  cursor: pointer;
}
.kid-tab[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 4px 0 var(--primary-strong); }

.compare-table td .avatar-sm { vertical-align: middle; margin-right: 6px; }
.trend-up { color: var(--success); font-weight: 800; }
.trend-down { color: var(--danger); font-weight: 800; }
.trend-flat { color: var(--muted-fg); font-weight: 700; }

.profile-list { display: flex; flex-direction: column; gap: var(--space-4); }
.profile-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-4);
  padding: var(--space-4);
  background: var(--muted);
  border-radius: var(--radius-lg);
  align-items: start;
}
.profile-row .fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--space-3); }
.profile-row .actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: var(--space-3); }
.pick-row { display: flex; flex-wrap: wrap; gap: 6px; }
.pick-row button {
  width: 48px; height: 48px;
  display: grid; place-items: center;
  font-size: 28px;
  background: #fff;
  border: 3px solid var(--border);
  border-radius: 14px;
  cursor: pointer;
  padding: 0;
}
.pick-row button[aria-pressed="true"] { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .3); }
.pick-row .swatch { width: 30px; height: 30px; border-radius: 50%; background: var(--c); }
@media (max-width: 480px) {
  .profile-row { grid-template-columns: 1fr; }
  .topbar .who-chip { padding: 6px; min-height: 54px; }
  .topbar .who-name { display: none; }
}

/* =========================================================
   SAO THƯỞNG & KHO QUÀ
   ========================================================= */
.star-ico { color: var(--secondary); filter: drop-shadow(0 2px 0 var(--secondary-strong)); }

/* Thưởng sao ở màn hình kết quả */
.star-award {
  display: flex; flex-direction: column; align-items: center; gap: var(--space-2);
  width: 100%; max-width: 520px;
  margin-top: var(--space-2);
  padding: var(--space-4) clamp(10px, 3vw, var(--space-5));
  background: var(--warn-soft);
  border: 3px solid var(--warn-line);
  border-radius: var(--radius-lg);
}
.star-award .plus {
  display: inline-flex; align-items: center; gap: 10px;
  font-size: clamp(2.8rem, 12vw, 4rem); font-weight: 800; line-height: 1;
  color: var(--secondary-strong);
  animation: pop 500ms var(--ease-spring) 600ms both;
}
.star-award .plus .icon { width: 1em; height: 1em; }
.star-award .total { font-weight: 700; font-size: clamp(1.2rem, 4vw, 1.4rem); }
/* Bảng chia sao: câu nhanh × 2, câu đúng × 1 */
.award-rows { width: 100%; display: flex; flex-direction: column; gap: 8px; }
.award-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px clamp(10px, 3vw, 14px);
  background: var(--card);
  border: 2px solid var(--warn-line);
  border-radius: 16px;
  font-size: clamp(1.05rem, 4.2vw, 1.4rem); font-weight: 700;
  text-align: left;
}
.award-row .ar-ico { display: inline-flex; flex: none; }
.award-row .ar-ico .icon { width: 28px; height: 28px; stroke-width: 3; }
.award-row.is-fast .ar-ico { color: var(--secondary-strong); }
.award-row.is-ok .ar-ico { color: var(--success); }
.award-row .ar-txt { flex: 1; white-space: nowrap; }
.award-row .ar-txt b { font-size: 1.2em; font-variant-numeric: tabular-nums; }
.award-row .ar-val { display: inline-flex; align-items: center; gap: 4px; font-weight: 800; color: var(--secondary-strong); white-space: nowrap; font-variant-numeric: tabular-nums; }
.award-row .ar-val .icon { width: 1em; height: 1em; }
.star-award .goal { width: 100%; display: flex; flex-direction: column; gap: 6px; font-weight: 600; color: var(--muted-fg); text-align: center; }
.star-award.no-award { background: var(--muted); border-color: var(--border); }

/* Số sao lớn ở Kho quà */
.wallet {
  display: flex; flex-direction: column; align-items: center; gap: var(--space-2);
  text-align: center;
}
.wallet .amount {
  display: inline-flex; align-items: center; gap: 12px;
  font-size: clamp(3rem, 12vw, 4.6rem); font-weight: 800; line-height: 1;
  color: var(--secondary-strong);
  font-variant-numeric: tabular-nums;
}
.wallet .amount .icon { width: .9em; height: .9em; }
.wallet .sub { color: var(--muted-fg); font-weight: 600; font-size: 1.1rem; }

.reward-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: var(--space-5);
}
.reward-card {
  display: flex; flex-direction: column; align-items: center; gap: var(--space-3);
  padding: var(--space-5) var(--space-4);
  text-align: center;
  background: var(--card);
  border: 4px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: 0 8px 0 var(--border-strong);
}
.reward-card.ready { border-color: var(--warn-line); box-shadow: 0 8px 0 var(--secondary-strong); }
.reward-card .r-icon {
  width: 110px; height: 110px;
  display: grid; place-items: center;
  font-size: 64px; line-height: 1;
  background: var(--muted);
  border-radius: 50%;
}
.reward-card.ready .r-icon { background: var(--warn-soft); animation: wiggle 2.4s ease-in-out infinite; }
@keyframes wiggle { 0%, 80%, 100% { transform: rotate(0); } 85% { transform: rotate(-8deg); } 90% { transform: rotate(8deg); } 95% { transform: rotate(-4deg); } }
.reward-card .r-name { font-size: 1.5rem; font-weight: 800; color: var(--primary-strong); line-height: 1.15; }
.reward-card .r-cost { display: inline-flex; align-items: center; gap: 6px; font-size: 1.3rem; font-weight: 800; color: var(--secondary-strong); }
.reward-card .progress { width: 100%; }
.reward-card .r-left { font-weight: 600; color: var(--muted-fg); }

.redeem-list { display: flex; flex-direction: column; gap: var(--space-3); }
.redeem-item {
  display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap;
  padding: 10px 14px;
  background: var(--muted);
  border-radius: var(--radius);
  font-weight: 700;
}
.redeem-item .ri-icon { font-size: 2rem; line-height: 1; }
.redeem-item .ri-main { flex: 1; min-width: 160px; }
.redeem-item .ri-main small { display: block; font-weight: 600; color: var(--muted-fg); }
.status {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 34px; padding: 2px 14px;
  border-radius: 999px;
  font-size: .95rem; font-weight: 800;
}
.status.wait { background: var(--warn-soft); color: var(--warn); }
.status.done { background: var(--success-soft); color: var(--success); }

/* Hộp xác nhận của bố mẹ */
.gate-modal { width: min(440px, 100%); display: flex; flex-direction: column; gap: var(--space-3); text-align: center; }
.gate-modal h2 { font-size: 1.7rem; color: var(--primary-strong); }
.gate-modal .gate-q { font-size: 2.2rem; font-weight: 800; }
.gate-art { font-size: 64px; line-height: 1; }

/* Thẻ Kho quà ở trang chủ */
.menu-card.is-gold { --c: #D97706; --c-strong: #92400E; --c-soft: #FEF3C7; }
/* Toán tư duy: luật sao ở danh sách trò + "+2 ★" bay lên khi bấm đúng */
.logic-star-hint {
  display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 4px 16px;
  margin: 0 auto var(--space-4); padding: 10px 18px; max-width: 640px;
  text-align: center; font-weight: 700; font-size: 1.1rem;
  background: var(--warn-soft); border: 2px solid var(--warn-line); border-radius: 22px;
}
.logic-star-hint .lsh-rule { display: inline; color: var(--secondary-strong); }
.logic-star-hint .lsh-rule .icon { width: 1.3em; height: 1.3em; vertical-align: -0.3em; margin-right: 4px; }
.logic-star-hint .lsh-left { color: var(--muted-fg); }
.round-result .star-award { margin: var(--space-3) auto 0; }
.choice { position: relative; }
.star-pop {
  position: absolute; left: 50%; top: 0;
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 1.6rem; font-weight: 800; color: var(--secondary-strong); white-space: nowrap;
  pointer-events: none;
  animation: starPop 900ms var(--ease-out) forwards;
}
.star-pop .icon { width: 1.1em; height: 1.1em; }
@keyframes starPop {
  0% { transform: translate(-50%, 0) scale(.6); opacity: 0; }
  25% { transform: translate(-50%, -70%) scale(1.15); opacity: 1; }
  100% { transform: translate(-50%, -150%) scale(1); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) { .star-pop { animation: none; transform: translate(-50%, -80%); } }
.menu-stars { display: inline-flex; align-items: center; gap: 6px; font-size: 1.25rem; font-weight: 800; color: var(--secondary-strong); }

/* Góc bố mẹ: quản lý quà */
.reward-edit { display: flex; flex-direction: column; gap: var(--space-3); }
.reward-row {
  display: grid;
  grid-template-columns: auto 1fr 140px auto;
  gap: var(--space-3);
  align-items: end;
  padding: var(--space-3);
  background: var(--muted);
  border-radius: var(--radius);
}
.reward-row .r-icon-btn {
  width: 56px; height: 56px;
  display: grid; place-items: center;
  font-size: 32px;
  background: #fff;
  border: 3px solid var(--border-strong);
  border-radius: 16px;
  cursor: pointer;
}
.reward-row .pick-row { grid-column: 1 / -1; }
@media (max-width: 560px) {
  .reward-row { grid-template-columns: auto 1fr; }
  .reward-row .cost-field, .reward-row .row-actions { grid-column: span 1; }
}
.inline-form { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: end; }
.inline-form .field { flex: 1; min-width: 160px; }
.star-log { font-size: .98rem; }
.star-log .plus { color: var(--success); font-weight: 800; }
.star-log .minus { color: var(--danger); font-weight: 800; }

/* ---------- Màn hình nhỏ ---------- */
@media (max-width: 480px) {
  body { font-size: 17px; }
  .app { padding: var(--space-3) var(--space-3) var(--space-6); }
  .card { padding: var(--space-4); border-radius: 26px; }
  .icon-btn { width: 54px; height: 54px; font-size: 24px; }
  .key { min-height: 70px; }
  .choice { min-width: 92px; min-height: 92px; }
  .choice.panel { min-height: 170px; }
  .question-card { min-height: 160px; }
}

/* Màn hình thấp (điện thoại xoay ngang) */
@media (max-height: 520px) and (orientation: landscape) {
  .question-card { min-height: 110px; padding: var(--space-3); }
  .question { font-size: 3.2rem; }
  .key { min-height: 56px; font-size: 2rem; }
  .keypad { grid-template-columns: repeat(6, 1fr); }
}

/* =========================================================
   TOÁN TƯ DUY: CẤP ĐỘ, BẠN CỔ VŨ, COMBO
   ========================================================= */
.game-card { position: relative; }
.g-tag {
  position: absolute; top: 10px; right: 10px;
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 10px; font-size: .85rem; font-weight: 800;
  color: var(--c-strong); background: var(--card); border: 2px solid var(--c-soft); border-radius: 999px;
}
.g-tag .icon { width: 14px; height: 14px; }
.g-tag.is-new { color: #fff; background: var(--accent); border-color: var(--accent); }
/* Thưởng chăm chỉ mỗi ngày (sao tăng dần theo số ngày liên tiếp) */
.daily-hint {
  display: block; width: fit-content; max-width: 100%; margin: 10px auto 0;
  padding: 8px 16px; border-radius: 18px;
  font-weight: 700; line-height: 1.4; text-align: center; color: #9A3412;
  background: #FFF7ED; border: 2px dashed #FDBA74;
}
.daily-hint[hidden] { display: none; }
.daily-hint b { color: #C2410C; }
.daily-hint .icon { width: 1.05em; height: 1.05em; vertical-align: -2px; color: #F59E0B; }
.daily-card { max-width: 440px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.daily-day { font-size: 1.15rem; font-weight: 700; }
.daily-day b { font-size: 1.4em; color: var(--accent); }
.daily-plus { display: flex; justify-content: center; align-items: center; gap: 6px; width: 100%; font-size: 2.6rem; font-weight: 800; line-height: 1.1; color: #B45309; }
.daily-plus .icon { width: .9em; height: .9em; color: #F59E0B; }
.daily-ladder { display: flex; justify-content: center; gap: 6px; list-style: none; margin: 4px 0; padding: 0; flex-wrap: wrap; }
.daily-ladder li {
  display: flex; flex-direction: column; align-items: center; min-width: 58px; padding: 6px 4px;
  border-radius: 14px; border: 2px solid var(--border); background: var(--card); line-height: 1.15;
}
.daily-ladder li small { font-size: .78rem; font-weight: 700; color: var(--muted-fg); }
.daily-ladder li b { font-size: 1.15rem; }
.daily-ladder li.is-past { opacity: .55; }
.daily-ladder li.is-now { background: #FEF3C7; border-color: #F59E0B; transform: scale(1.08); }
.daily-ladder li.is-next b { color: var(--success); }

/* Góc bố mẹ: giới hạn sao mỗi ngày của từng trò */
.cap-all { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 12px; }
.cap-all .field-label { margin: 0; }
.cap-all .seg { gap: 8px; justify-content: flex-start; }
.cap-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 10px; margin-bottom: 8px; }
.cap-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 10px 8px 14px; border: 2px solid var(--border); border-radius: 16px; background: var(--card);
}
.cap-row label { display: flex; flex-direction: column; font-weight: 800; line-height: 1.25; }
.cap-row label small { font-weight: 600; font-size: .85rem; color: var(--muted-fg); }
.cap-row select.input { width: auto; min-width: 116px; min-height: 44px; padding: 6px 10px; flex: none; }
.cap-row.is-off { background: #F8FAFC; }
.cap-row.is-off label { color: #64748B; }

/* Sao hôm nay của trò: đã nhận / được phép */
.g-today {
  position: absolute; top: 10px; left: 10px;
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 10px; font-size: .95rem; font-weight: 800; font-variant-numeric: tabular-nums;
  color: #92400E; background: #FEF3C7; border: 2px solid #FCD34D; border-radius: 999px;
}
.g-today .icon { width: 14px; height: 14px; color: #F59E0B; }
.g-today.is-full { color: #166534; background: #DCFCE7; border-color: #86EFAC; }
.g-today.is-full .icon { color: #16A34A; }
.lv-pill { min-height: 44px; padding: 4px 14px; font-weight: 800; color: var(--secondary-strong); background: var(--warn-soft); border-color: var(--warn-line); }
.lv-pill .icon { width: 18px; height: 18px; }
.lv-pill.lv-up { animation: lvUp 700ms var(--ease-spring); }
.lv-pill.lv-down { animation: shake 420ms ease-in-out; }
@keyframes lvUp { 40% { transform: scale(1.3); background: #FDE68A; } }
#screenGame > .dots { justify-content: center; }
#btnGuide.pulse { animation: pulse 700ms ease-in-out 3; }

.buddy { position: relative; width: 52px; height: 52px; flex: none; }
.buddy-face { display: block; font-size: 52px; line-height: 0; transform-origin: 50% 100%; }
.buddy.is-happy.go .buddy-face { animation: buddyHop 500ms var(--ease-out); }
.buddy.is-dance.go .buddy-face { animation: buddyDance 900ms ease-in-out 2; }
.buddy.is-sad.go .buddy-face { animation: buddySad 900ms ease-in-out; }
@keyframes buddyHop { 40% { transform: translateY(-14px) scale(1.08); } }
@keyframes buddyDance {
  20% { transform: rotate(-14deg) translateY(-8px); } 40% { transform: rotate(14deg) translateY(-14px); }
  60% { transform: rotate(-10deg) translateY(-6px); } 80% { transform: rotate(8deg) scale(1.1); }
}
@keyframes buddySad { 30%, 70% { transform: rotate(-8deg) translateY(3px) scale(.95); } }
.buddy-bubble {
  position: absolute; left: 58px; top: 50%; z-index: 5;
  transform: translateY(-50%);
  width: max-content; max-width: min(240px, 60vw);
  padding: 6px 12px; font-size: 1rem; font-weight: 700; line-height: 1.3; color: var(--fg);
  background: var(--card); border: 2px solid var(--border-strong); border-radius: 14px;
  box-shadow: 0 4px 10px rgba(15, 23, 42, .1);
  animation: pop 260ms var(--ease-out);
}
.combo-banner {
  position: fixed; left: 50%; top: 22%; z-index: 40;
  transform: translateX(-50%);
  padding: 12px 26px; white-space: nowrap;
  font-size: clamp(1.4rem, 5vw, 2rem); font-weight: 800; color: #fff;
  background: linear-gradient(135deg, #F59E0B, #DB2777); border-radius: 999px;
  box-shadow: 0 8px 0 #9D174D, 0 14px 30px rgba(219, 39, 119, .35);
  pointer-events: none;
}
.combo-banner b { font-size: 1.3em; }
.combo-banner.go { animation: comboIn 1400ms var(--ease-out) both; }
@keyframes comboIn {
  0% { transform: translate(-50%, 20px) scale(.6); opacity: 0; }
  20% { transform: translate(-50%, 0) scale(1.08); opacity: 1; }
  80% { opacity: 1; }
  100% { transform: translate(-50%, -20px) scale(1); opacity: 0; }
}
.d-level { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 4px 0; }
.combo-pill { min-height: 44px; padding: 4px 14px; font-weight: 800; color: var(--accent); }
.choices.list { display: grid; grid-template-columns: minmax(0, 440px); justify-content: center; gap: var(--space-3); width: 100%; }
.choices.list .choice.panel, .t-list .choice.panel { min-height: 72px; padding: 8px 14px; }
.t-list { display: grid; grid-template-columns: minmax(0, 380px); gap: 10px; width: 100%; justify-content: center; }
.stage-like { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: var(--space-3); width: 100%; }

/* ---------- Chia đều ---------- */
.share { display: flex; flex-direction: column; align-items: center; gap: var(--space-4); width: 100%; }
.share-pile { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; min-height: 2.6rem; max-width: 340px; font-size: clamp(1.8rem, 7vw, 2.4rem); line-height: 1; }
.share-kids { display: flex; justify-content: center; gap: clamp(10px, 4vw, 28px); }
.share-kid { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.share-face { font-size: clamp(2.8rem, 11vw, 3.6rem); line-height: 0; }
.share-plate {
  display: flex; flex-wrap: wrap; justify-content: center; align-content: center; gap: 1px;
  width: clamp(84px, 24vw, 112px); min-height: 52px; padding: 6px;
  font-size: 1.35rem; line-height: 1;
  background: #F1F5F9; border: 3px solid #CBD5E1; border-radius: 50%;
}

/* ---------- Đường đi ---------- */
.a-grid { display: grid; grid-template-columns: repeat(var(--n), 1fr); gap: 6px; width: min(calc(var(--n) * 76px), 82vw); }
.a-cell {
  aspect-ratio: 1; display: grid; place-items: center;
  font-size: clamp(1.8rem, 8vw, 2.6rem); line-height: 0;
  background: #F8FAFC; border: 3px solid #E2E8F0; border-radius: 14px;
  transition: background-color 200ms;
}
.a-cell.a-trail { background: #FEF3C7; border-color: #FCD34D; }
.a-walker { display: inline-block; line-height: 0; }
.arrow-seq { display: inline-flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.arrow-seq i {
  display: grid; place-items: center; width: 2.6rem; height: 2.6rem;
  font-style: normal; font-size: 1.7rem; font-weight: 800; line-height: 1; color: #fff;
  background: var(--primary); border-radius: 12px; box-shadow: 0 3px 0 var(--primary-strong);
}

/* ---------- Sudoku bạn nhỏ ---------- */
.sdk { display: grid; grid-template-columns: repeat(var(--n), 1fr); gap: 4px; padding: 6px; background: #7C3AED; border-radius: 18px; width: min(calc(var(--n) * 72px + 20px), 82vw); }
.sdk-cell { aspect-ratio: 1; display: grid; place-items: center; font-size: clamp(2rem, 9vw, 2.8rem); line-height: 0; background: #fff; border-radius: 12px; }
.sdk-cell.empty { background: #EDE9FE; }
.sdk .slot-q { width: 100%; height: 100%; font-size: inherit; border-radius: 12px; border-width: 3px; }

/* ---------- Xoay hình ---------- */
.shape-stage { display: flex; align-items: center; justify-content: center; gap: clamp(10px, 4vw, 24px); font-size: clamp(2.6rem, 10vw, 3.4rem); }
.shape-target { display: inline-grid; place-items: center; padding: 10px; background: #F5F3FF; border-radius: 18px; transition: transform 1200ms var(--ease-out); }
.shape-target.t-spin { transform: rotate(90deg); }
.shape-rot { font-size: .8em; font-weight: 800; color: var(--muted-fg); }
.shape-svg { display: block; overflow: visible; }
.slot-q .shape-svg { font-size: .8em; }
.preview-shapes { display: inline-flex; align-items: center; gap: 8px; font-size: 2.6rem; }

/* ---------- Ai ở nhà nào ---------- */
.houses { display: flex; flex-direction: column; align-items: center; gap: var(--space-3); }
.houses-row { display: flex; gap: clamp(10px, 4vw, 24px); font-size: clamp(2.6rem, 10vw, 3.4rem); }
.house-svg { display: inline-block; width: 1.3em; height: 1.2em; vertical-align: middle; }
.clues { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.clue {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 14px; font-size: clamp(1.9rem, 7vw, 2.4rem); line-height: 1;
  background: #F8FAFC; border: 2px solid #E2E8F0; border-radius: 999px;
}
.clue-mark { display: grid; place-items: center; width: 1.2em; height: 1.2em; font-size: .75em; font-weight: 900; color: #fff; border-radius: 50%; }
.clue-mark.no { background: #DC2626; }
.clue-mark.yes { background: #16A34A; }
.clue-mark.ask { background: transparent; color: var(--muted-fg); font-size: .8em; }
.clue-ask { background: #FFF7ED; border-color: #FED7AA; }
.clue-ask .slot-q { width: 1.7em; height: 1.7em; font-size: inherit; border-width: 3px; border-radius: 14px; }
.preview-chars .house-svg { width: 1.1em; height: 1em; }

/* ---------- Đo bằng khối ---------- */
.measure { display: flex; flex-direction: column; gap: 6px; width: min(460px, 100%); }
.m-row { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; } /* dài nhất 8 khối */
.m-bar {
  position: relative; display: flex; align-items: center; height: clamp(30px, 8vw, 40px); padding-left: 4px;
  background: var(--bc); border-radius: 999px; box-shadow: inset 0 -5px 0 rgba(0, 0, 0, .15);
}
.m-ico { font-size: clamp(1.3rem, 5vw, 1.7rem); line-height: 1; }
.m-len { position: absolute; right: -2px; top: 50%; transform: translate(100%, -50%); padding-left: 6px; font-size: 1.5rem; font-weight: 800; color: var(--fg); }
.m-block {
  display: grid; place-items: center; aspect-ratio: 1;
  font-size: 1rem; font-weight: 800; color: #1E3A8A;
  background: #BFDBFE; border: 2px solid #3B82F6; border-radius: 6px;
}
.m-row + .m-row[data-mrow] { margin-top: 12px; }
.m-ask { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 10px; font-size: clamp(2rem, 8vw, 2.6rem); font-weight: 800; }

/* ---------- Bé làm cô giáo ---------- */
.teach { display: flex; flex-direction: column; align-items: center; gap: var(--space-3); width: 100%; }
.teach-q { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: var(--space-3); width: 100%; }
.teach-who { display: inline-flex; align-items: center; gap: 10px; font-size: 2.4rem; line-height: 0; }
.teach-says { padding: 8px 14px; font-size: 1.05rem; font-weight: 700; line-height: 1.3; background: #FFF7ED; border: 2px solid #FDBA74; border-radius: 14px; }
.slot-q.teach-pick { border-style: solid; border-color: #F59E0B; background: #FEF3C7; color: var(--fg); }
.pan-ask.teach-pick { outline: 3px solid #F59E0B; outline-offset: 2px; border-radius: 10px; background: #FEF3C7; }
.verdict { display: grid; place-items: center; width: 1.4em; height: 1.4em; font-size: 1em; font-weight: 900; color: #fff; border-radius: 50%; }
.verdict.yes { background: #16A34A; }
.verdict.no { background: #DC2626; }

/* =========================================================
   PHIÊU LƯU MỖI NGÀY
   ========================================================= */
.adv-card {
  display: flex; align-items: center; gap: var(--space-4); width: 100%;
  margin-bottom: var(--space-4); padding: var(--space-4) var(--space-5);
  font-family: var(--font); color: #fff; text-align: left;
  background: linear-gradient(135deg, #F97316, #DB2777);
  border: 0; border-radius: var(--radius-xl); box-shadow: 0 8px 0 #9D174D;
  cursor: pointer; transition: transform 160ms var(--ease-out), box-shadow 160ms var(--ease-out);
}
.adv-card:hover { transform: translateY(-2px); box-shadow: 0 10px 0 #9D174D; }
.adv-card:active { transform: translateY(6px); box-shadow: 0 2px 0 #9D174D; }
.adv-card.is-done { background: linear-gradient(135deg, #16A34A, #0D9488); box-shadow: 0 8px 0 #115E59; }
.adv-card-ico { font-size: 3rem; line-height: 1; }
.adv-card-main { flex: 1; display: flex; flex-direction: column; }
.adv-card-main b { font-size: clamp(1.4rem, 5vw, 1.8rem); line-height: 1.15; }
.adv-card-main small { font-size: 1.05rem; font-weight: 600; opacity: .95; }
.adv-flame { display: inline-flex; align-items: center; gap: 4px; padding: 4px 14px; font-size: 1.4rem; font-weight: 800; color: #9A3412; background: #FFEDD5; border-radius: 999px; white-space: nowrap; }
.adv-flame.big { font-size: 2rem; padding: 6px 18px; }
.adv-head { display: flex; flex-direction: column; gap: var(--space-4); }
.adv-streak { display: flex; align-items: center; gap: var(--space-4); }
.adv-streak-txt { display: flex; flex-direction: column; }
.adv-streak-txt b { font-size: 1.4rem; }
.adv-streak-txt small { font-size: 1rem; color: var(--muted-fg); font-weight: 600; }
.adv-badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 8px; }
.badge-item {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px;
  text-align: center; background: var(--muted); border-radius: 14px; opacity: .45; filter: grayscale(1);
}
.badge-item.on { opacity: 1; filter: none; background: var(--warn-soft); border: 2px solid var(--warn-line); }
.bi-ico { font-size: 2rem; line-height: 1; }
.badge-item small { font-size: .8rem; font-weight: 700; line-height: 1.2; }
.adv-story { display: flex; align-items: center; gap: var(--space-4); background: #FFF7ED; border: 3px solid #FDBA74; animation: pop 320ms var(--ease-out); }
.adv-story-who { display: inline-flex; font-size: 3rem; line-height: 0; flex: none; }
.adv-story p { margin: 0; font-size: clamp(1.15rem, 4vw, 1.35rem); font-weight: 700; line-height: 1.45; }
.adv-today { display: flex; flex-direction: column; gap: var(--space-3); }
.adv-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.adv-step { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border: 2px solid var(--border); border-radius: 16px; }
.adv-step .as-n { display: grid; place-items: center; width: 40px; height: 40px; flex: none; font-weight: 800; font-size: 1.2rem; color: var(--muted-fg); background: var(--muted); border-radius: 50%; }
.adv-step .as-n .icon { width: 22px; height: 22px; stroke-width: 3; }
.adv-step .as-main { display: flex; flex-direction: column; }
.adv-step .as-main small { color: var(--muted-fg); font-weight: 600; }
.adv-step.now { border-color: #F59E0B; background: var(--warn-soft); }
.adv-step.now .as-n { color: #fff; background: #F59E0B; }
.adv-step.done .as-n { color: #fff; background: #16A34A; }
.adv-map-card { padding: 8px; overflow: hidden; }
.adv-map { position: relative; width: 100%; max-width: 460px; margin: 0 auto; }
.adv-svg { display: block; width: 100%; height: auto; border-radius: 18px; }
.adv-svg .adv-now { animation: advPulse 1.4s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes advPulse { 50% { transform: scale(1.15); } }
.adv-walker { position: absolute; transform: translate(-50%, -50%); font-size: clamp(2.2rem, 9vw, 2.8rem); line-height: 0; filter: drop-shadow(0 4px 2px rgba(0, 0, 0, .2)); animation: buddyHop 1.2s ease-in-out infinite; }
.adv-lap { position: absolute; right: 10px; top: 10px; padding: 2px 12px; font-weight: 800; color: #fff; background: #7C3AED; border-radius: 999px; }
.adv-cele { max-width: 440px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.ac-big { font-size: 4rem; line-height: 1; animation: pop 500ms var(--ease-spring); }
.ac-badges { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.ac-badges .badge-item { min-width: 100px; }

/* =========================================================
   IN PHIẾU BÀI TẬP
   ========================================================= */
.print-controls { display: flex; flex-direction: column; gap: var(--space-3); }
.print-games { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 6px 12px; }
.print-sheet { background: #fff; color: #0F172A; border-radius: var(--radius-lg); padding: 18px; box-shadow: 0 4px 16px rgba(15, 23, 42, .08); }
.ps-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 8px; padding-bottom: 10px; margin-bottom: 14px; border-bottom: 2px solid #CBD5E1; }
.ps-head h2 { margin: 0; font-size: 1.6rem; }
.ps-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.pq { display: flex; flex-direction: column; gap: 8px; padding: 10px; border: 2px solid #CBD5E1; border-radius: 14px; break-inside: avoid; page-break-inside: avoid; }
.pq-head { display: flex; align-items: center; gap: 8px; }
.pq-n { display: grid; place-items: center; width: 30px; height: 30px; flex: none; font-weight: 800; color: #fff; background: #334155; border-radius: 50%; }
.pq-t { font-weight: 700; font-size: 1.05rem; }
.pq-stage { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px; font-size: 13px; }
.pq-stage .stage-emoji { font-size: 2.2rem; }
.pq-stage .num-bubble, .pq-stage .slot-q { width: 46px; height: 46px; font-size: 1.6rem; border-width: 2px; }
.pq-stage .scale { height: 150px; }
.pq-stage .pan-items { font-size: 1.5rem; }
.pq-stage .tenframe, .pq-stage .dice { width: 170px; }
.pq-stage .house { transform: scale(.75); transform-origin: top center; margin-bottom: -50px; }
.pq-stage .sdk { width: 190px; }
.pq-stage .sdk-cell { font-size: 1.9rem; }
.pq-stage .a-grid { width: 180px; }
.pq-stage .a-cell { font-size: 1.6rem; }
.pq-stage .shape-stage { font-size: 2rem; }
.pq-stage .houses-row, .pq-stage .clue { font-size: 1.7rem; }
.pq-choices { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.pq-choice { display: grid; place-items: center; min-width: 54px; min-height: 48px; padding: 4px 10px; font-size: 1.6rem; font-weight: 800; border: 2px solid #94A3B8; border-radius: 12px; }
.pq-choice .panel-items, .pq-choice .pan-items { font-size: 1.1rem !important; max-width: 120px; }
.pq-choice .arrow-seq i { width: 1.8rem; height: 1.8rem; font-size: 1.1rem; }
.ps-keys { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin-top: 16px; padding-top: 10px; border-top: 2px dashed #CBD5E1; font-size: .95rem; }
.ps-key { display: inline-flex; align-items: center; gap: 4px; font-size: 1.1rem; }
.ps-key .pan-items, .ps-key .panel-items { font-size: .9rem !important; }
.ps-key .arrow-seq i { width: 1.3rem; height: 1.3rem; font-size: .85rem; box-shadow: none; }

/* ---------- Xem đồng hồ ---------- */
.clk-wrap { display: flex; flex-direction: column; align-items: center; gap: var(--space-3); }
.clock { display: block; width: clamp(180px, 54vw, 250px); height: auto; flex: none; }
.clk-rim { fill: #BE123C; }
.clk-face { fill: #FFFFFF; }
.clk-tk { stroke: #94A3B8; stroke-width: 1.5; }
.clk-tk.big { stroke: #334155; stroke-width: 3.5; stroke-linecap: round; }
.clk-num circle { fill: transparent; transition: fill 300ms; }
.clk-num text { font: 800 22px var(--font); fill: #1E293B; text-anchor: middle; dominant-baseline: central; }
.clk-num.on circle { fill: #BFDBFE; }
.clk-num.on text { fill: #1D4ED8; }
.clk-num.on-m circle { fill: #FECDD3; }
.clk-num.on-m text { fill: #BE123C; }
.clk-h, .clk-m { transform-origin: 100px 100px; }
.clk-h line { stroke: #2563EB; stroke-width: 10; stroke-linecap: round; }
.clk-m line { stroke: #E11D48; stroke-width: 6; stroke-linecap: round; }
.clk-pin { fill: #1E293B; }
.clk-pulse line { animation: clkPulse 650ms ease-in-out 3; }
@keyframes clkPulse { 50% { stroke: #FACC15; } }
.clk-ask { display: flex; align-items: center; gap: 10px; font-size: clamp(1.3rem, 5vw, 1.8rem); font-weight: 800; color: var(--primary-strong); }
.clk-ask .slot-q.clk-slot { width: auto; min-width: clamp(120px, 34vw, 170px); padding: 0 16px; font-size: clamp(1.5rem, 6vw, 2.1rem); white-space: nowrap; }
.clk-plus { padding: 6px 14px; border-radius: 999px; background: #DBEAFE; color: #1D4ED8; white-space: nowrap; }
.clk-time { display: flex; flex-direction: column; align-items: center; line-height: 1.05; }
.clk-time b { font-size: clamp(2.2rem, 9vw, 3rem); }
.clk-time small { font-size: clamp(1rem, 3.8vw, 1.25rem); font-weight: 800; white-space: nowrap; }
.choices.panels3 .clock, .t-panels3 .clock { width: clamp(88px, 26vw, 150px); max-width: 100%; }
.clk-mini .clk-tk:not(.big) { display: none; } /* đồng hồ nhỏ: bỏ vạch phút cho dễ nhìn */
.clk-target { display: flex; align-items: baseline; flex-wrap: wrap; justify-content: center; gap: 8px; padding: 12px 20px; font-size: clamp(1.3rem, 5vw, 1.8rem); font-weight: 800; text-align: center; color: var(--primary-strong); background: #DBEAFE; border-radius: 22px; }
.clk-target b { font-size: 1.7em; line-height: 1; color: #1D4ED8; }
.preview-chars .clock { display: inline-block; width: 1.25em; margin: 0 2px; vertical-align: middle; }
.pq-stage .clock { width: 150px; }
.pq-stage .clk-ask { font-size: 1.1rem; }
.pq-stage .clk-ask .slot-q.clk-slot { min-width: 110px; height: 46px; font-size: 1.1rem; }
.pq-stage:has(.clk-target) { display: none; } /* trên phiếu, tiêu đề câu đã ghi giờ cần tìm */
.pq-choice .clock { width: 72px; }
.pq-choice:has(.clock) { padding: 3px; }
.pq-choice .clk-time b { font-size: 1.5rem; }
.pq-choice .clk-time small { font-size: .8rem; }
.ps-key .clock { width: 36px; }
.ps-key .clk-time { flex-direction: row; gap: 3px; align-items: baseline; }
.ps-key .clk-time b { font-size: 1.1rem; }
.ps-key .clk-time small { font-size: .85rem; }
@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff !important; }
  .topbar, .no-print, #screenMenu, #screenMap, #screenTutor, #screenGame, #screenDone, .toast, .overlay { display: none !important; }
  .app { padding: 0 !important; max-width: none !important; }
  .print-sheet { box-shadow: none; padding: 0; }
  .ps-grid { grid-template-columns: 1fr 1fr; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- Giảm chuyển động ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
  .mascot, .mascot .eye-lid { animation: none !important; }
  .q-timer span { animation-duration: var(--qlimit, 10000ms) !important; } /* thanh thời gian là thông tin, giữ nguyên */
}
