/* Giao diện ứng dụng học cho bé (dùng chung app.css cho phần nội dung bài)
   Phong cách: "sổ dán hình" — nền giấy kem chấm bi, thẻ bo tròn nổi khối, nút bấm dày như kẹo, linh vật hộp sữa.
   Font: Baloo 2 (tiêu đề, nút) + Nunito (chữ thường); không có mạng vẫn dùng Segoe UI/hệ thống. */

body.kid {
  --ink: #2d2a4a; --muted: #6b6785; --line: #efe2cc; --soft: #fff1d6; --bg: #fff7ea;
  --brand: #e23c66; --brand-d: #b02149; --brand2: #1683c9; --brand2-d: #0d5f97;
  --sun: #ffc23d; --sun-d: #d98f00; --mint: #1fb488; --mint-d: #128063; --grape: #7a58e0; --grape-d: #5537b8; --sky: #4cb6f2;
  --gold: #ffb703; --purple: #9b5de5; --green: #06d6a0;
  --sh: 0 2px 0 rgba(170, 120, 60, .08), 0 12px 28px -12px rgba(150, 100, 40, .30);
  --sh-sm: 0 2px 0 rgba(170, 120, 60, .10), 0 6px 14px -8px rgba(150, 100, 40, .30);
  --font-d: "Baloo 2", "Nunito", "Segoe UI", system-ui, sans-serif;
  --font-b: "Nunito", "Segoe UI", system-ui, Roboto, Arial, sans-serif;
  font-family: var(--font-b);
  color: var(--ink);
  min-height: 100vh; min-height: 100dvh;
  background-color: var(--bg);
  background-image:
    radial-gradient(rgba(214, 160, 90, .16) 1.4px, transparent 1.6px),
    radial-gradient(60vmax 40vmax at 0% 0%, #ffe9c7 0, transparent 60%),
    radial-gradient(50vmax 40vmax at 100% 100%, #e2f3ff 0, transparent 60%);
  background-size: 24px 24px, auto, auto;
  background-attachment: fixed;
  -webkit-tap-highlight-color: transparent;
}
body.kid :is(h1, h2, h3) { font-family: var(--font-d); font-weight: 800; line-height: 1.25; letter-spacing: -.005em; }
:where(body.kid) h2 { font-size: 26px; }
:where(body.kid) h3 { font-size: 21px; }
body.kid h4 { font-family: var(--font-d); font-weight: 700; font-size: 18px; }
body.kid a { color: var(--brand2); font-weight: 700; text-underline-offset: 3px; }
body.kid :focus-visible { outline: 3px solid #7cc6ff; outline-offset: 2px; }
.kwrap { max-width: 980px; margin: 0 auto; padding: 18px 16px 72px; }
.center { text-align: center; }
.small { font-size: 14px; color: var(--muted); }
.hide { display: none !important; }

/* thẻ chung trong app bé */
body.kid .card { background: #fff; border: 0; border-radius: 28px; padding: 20px 22px; margin: 16px 0; box-shadow: var(--sh); }
body.kid .card > h3:first-child { margin-top: 2px; }

/* ---------------- thanh trên ---------------- */
.kbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px; padding: 10px 18px; flex-wrap: wrap;
  background: rgba(255, 251, 244, .9); -webkit-backdrop-filter: blur(10px) saturate(1.3); backdrop-filter: blur(10px) saturate(1.3);
  color: var(--ink); box-shadow: 0 6px 18px -12px rgba(120, 80, 30, .45); }
.kbar::after { content: ''; position: absolute; left: 0; right: 0; bottom: -4px; height: 4px; pointer-events: none;
  background: linear-gradient(90deg, #ef476f 0 20%, #ffc23d 20% 40%, #1fb488 40% 60%, #4cb6f2 60% 80%, #7a58e0 80%); }
.kbar.play::after { display: none; }
.kbar .sp { flex: 1; }
.kbar button { font: inherit; color: inherit; cursor: pointer; }
.kb-back { flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; font-size: 17px; font-weight: 800;
  background: #fff; color: var(--ink); border: 2px solid var(--line); box-shadow: 0 3px 0 var(--line); transition: transform .12s, box-shadow .12s; }
.kb-back:hover { transform: translateY(-1px); }
.kb-back:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--line); }
.kb-me { display: flex; align-items: center; gap: 8px; background: transparent; border: 0; font-size: 19px; font-family: var(--font-d); padding: 0; min-width: 0; }
.kb-me b { font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 12em; }
.kb-me .av { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: #fff; box-shadow: inset 0 0 0 2px var(--line); font-size: 26px; }
.av { font-size: 28px; line-height: 1; }
.av.big { font-size: 54px; }
.pill { display: inline-flex; align-items: center; gap: 4px; background: #fff; border: 2px solid var(--line); border-radius: 999px; padding: 5px 12px; font-weight: 800; white-space: nowrap; font-size: 17px; font-variant-numeric: tabular-nums; }
.pill.streak { background: #fff1e4; border-color: #ffd2ad; color: #a8440a; }
.pill.coin { background: #fff6d3; border-color: #ffd96a; color: #865300; }
.pill.combo { background: #f2eeff; border-color: #d8ccff; color: var(--grape-d); }
.pill.combo.hot { background: var(--sun); border-color: var(--sun-d); color: #5a3300; animation: pulse 1s infinite; }
.pinfo { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.pinfo b { font-family: var(--font-d); font-size: 18px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pinfo small { color: var(--muted); font-weight: 600; }
.timer { background: var(--ink); color: #fff; border-radius: 14px; padding: 6px 12px; font-weight: 800; font-size: 20px; font-variant-numeric: tabular-nums; min-width: 92px; text-align: center; box-shadow: 0 3px 0 #17152b; }
.timer.warn { background: #e63946; box-shadow: 0 3px 0 #a3161f; animation: pulse .8s infinite; }
.tbar { height: 8px; background: #f3e4cc; }
.tbar i { display: block; height: 100%; background: linear-gradient(90deg, #1fb488, #ffc23d); border-radius: 0 99px 99px 0; transition: width .2s linear; }
.tbar.prog i { background: linear-gradient(90deg, #4cb6f2, #1683c9); }

/* ---------------- nút ---------------- */
.kbtn { font: inherit; font-family: var(--font-d); font-weight: 700; font-size: 18px; line-height: 1.2; border: 0; border-radius: 999px; padding: 11px 24px; min-height: 46px;
  background: var(--brand); color: #fff; cursor: pointer; box-shadow: 0 4px 0 var(--brand-d); display: inline-block; text-decoration: none;
  transition: transform .12s ease, box-shadow .12s ease, filter .12s; vertical-align: middle; }
.kbtn:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 6px 0 var(--brand-d); filter: brightness(1.05); }
.kbtn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--brand-d); }
.kbtn.big { font-size: 21px; padding: 14px 32px; min-height: 56px; box-shadow: 0 5px 0 var(--brand-d); }
.kbtn.small { font-size: 16px; padding: 7px 16px; min-height: 38px; box-shadow: 0 3px 0 var(--brand-d); }
.kbtn.alt { background: var(--brand2); --brand-d: var(--brand2-d); box-shadow: 0 4px 0 var(--brand2-d); }
.kbtn.big.alt { box-shadow: 0 5px 0 var(--brand2-d); }
.kbtn.small.alt { box-shadow: 0 3px 0 var(--brand2-d); }
.kbtn.ghost { background: #fff; color: var(--ink); border: 2px solid var(--line); --brand-d: var(--line); box-shadow: 0 3px 0 var(--line); }
.kbtn.gold { background: linear-gradient(180deg, #ffd65e, #ffb52e); color: #5a3300; --brand-d: var(--sun-d); box-shadow: 0 5px 0 var(--sun-d); }
.kbtn:disabled { opacity: .5; filter: grayscale(.35); cursor: default; }
a.kbtn, a.kbtn:hover { color: #fff; }
.kin { font: inherit; padding: 10px 14px; border: 2px solid var(--line); border-radius: 16px; background: #fff; color: var(--ink); transition: border-color .15s, box-shadow .15s; }
.kin:focus { outline: none; border-color: var(--brand2); box-shadow: 0 0 0 4px rgba(76, 182, 242, .25); }
.kin.small { width: 6em; padding: 6px 10px; }

/* ---------------- chào / hồ sơ ---------------- */
.hero { margin-top: 18px; display: flex; justify-content: center; }
.hero .mascot { animation: float 3s ease-in-out infinite; }
.mascot .ms-wave { transform-origin: 96px 84px; animation: wave 2.4s ease-in-out infinite; }
.ktitle { font-family: var(--font-d); color: var(--brand); font-size: 46px; line-height: 1.15; margin: 6px 0 4px; text-shadow: 0 3px 0 #ffd3dd; }
.ktitle + h3 { color: var(--muted); font-weight: 700; margin: 4px 0 14px; }
.kwrap.center > h3 { font-size: 20px; }
.plist { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; margin-bottom: 8px; }
.pcard { font: inherit; display: flex; flex-direction: column; align-items: center; gap: 4px; background: #fff; border: 3px solid transparent; border-radius: 26px; padding: 14px 26px; cursor: pointer;
  box-shadow: var(--sh); color: var(--ink); transition: transform .15s, border-color .15s; min-width: 120px; }
.pcard b { font-family: var(--font-d); font-size: 20px; }
.pcard small { color: #865300; font-weight: 700; }
.pcard:hover { transform: translateY(-3px) rotate(-1deg); border-color: var(--sky); }
.newp { max-width: 520px; margin: 10px auto; display: flex; flex-direction: column; gap: 16px; align-items: center; }
body.kid .card.newp { padding: 24px 22px; margin: 10px auto; }
.newp .kin { width: 100%; text-align: center; font-size: 22px; font-weight: 700; padding: 12px 14px; }
.avs { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; justify-items: center; width: 100%; }
.avb { font-size: 32px; line-height: 1; width: 58px; height: 58px; display: grid; place-items: center; background: #fff7ea; border: 3px solid transparent; border-radius: 50%; cursor: pointer; padding: 0;
  transition: transform .15s, background .15s, border-color .15s; }
.avb:hover { transform: scale(1.08); background: #fff0dc; }
.avb.sel { border-color: var(--brand); background: #ffe6ec; transform: scale(1.1); box-shadow: 0 4px 0 #ffc2d0; }

/* ---------------- trang chủ ---------------- */
.hello { position: relative; overflow: hidden; display: flex; align-items: center; gap: 18px; border-radius: 30px; padding: 18px 22px; box-shadow: var(--sh);
  background: linear-gradient(120deg, #fff 0%, #fff 45%, #ffeef3 100%); }
.hello::before { content: ''; position: absolute; right: -60px; top: -70px; width: 220px; height: 220px; border-radius: 50%; background: #fff5d9; z-index: 0; }
.hello > * { position: relative; z-index: 1; }
.hello .hmascot { flex: none; line-height: 0; }
.hello .htext { flex: 1; min-width: 0; }
.hello h2 { margin: 0 0 4px; font-size: 30px; }
.hello p { margin: 0 0 10px; font-weight: 600; }
.goalbar { height: 16px; background: #f3e7d4; border-radius: 99px; overflow: hidden; box-shadow: inset 0 2px 0 rgba(150, 100, 40, .10); }
.goalbar i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, #1fb488, #4cb6f2);
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .10), inset 0 4px 0 rgba(255, 255, 255, .30); }
.ring { --p: 0; width: 96px; height: 96px; border-radius: 50%; background: conic-gradient(#1fb488 calc(var(--p) * 1%), #f1e5d1 0); display: grid; place-items: center; flex: none;
  box-shadow: 0 4px 0 rgba(150, 100, 40, .10); }
.ring span { background: #fff; width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center; font-family: var(--font-d); font-weight: 800; font-size: 22px; }

.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin: 20px 0; }
.tile { position: relative; overflow: hidden; isolation: isolate; font: inherit; color: #fff; border: 0; border-radius: 28px; padding: 18px; text-align: left; cursor: pointer;
  display: flex; flex-direction: column; gap: 2px; min-height: 150px; box-shadow: 0 6px 0 var(--td, rgba(0, 0, 0, .18)); transition: transform .15s ease, box-shadow .15s ease; }
.tile::before { content: ''; position: absolute; z-index: -1; width: 170px; height: 170px; right: -50px; top: -60px; border-radius: 50%; background: rgba(255, 255, 255, .16); }
.tile::after { content: ''; position: absolute; z-index: -1; width: 90px; height: 90px; right: 30px; bottom: -50px; border-radius: 50%; background: rgba(255, 255, 255, .10); }
.tile:hover { transform: translateY(-4px) rotate(-.6deg); box-shadow: 0 10px 0 var(--td, rgba(0, 0, 0, .18)); }
.tile:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--td, rgba(0, 0, 0, .18)); }
.tile span { display: grid; place-items: center; width: 60px; height: 60px; font-size: 36px; line-height: 1; border-radius: 20px; background: rgba(255, 255, 255, .92); margin-bottom: 8px;
  box-shadow: 0 3px 0 rgba(0, 0, 0, .10); }
.tile b { font-family: var(--font-d); font-size: 21px; font-weight: 800; line-height: 1.2; }
.tile small { font-size: 14px; font-weight: 600; opacity: .95; line-height: 1.35; }
.t1, .t2 { grid-column: span 2; min-height: 170px; }
.t1 span, .t2 span { width: 70px; height: 70px; font-size: 42px; }
.t1 b, .t2 b { font-size: 25px; }
.t1 { background: linear-gradient(150deg, #2f93e6, #1565c0); --td: #0d4a8f; }
.t2 { background: linear-gradient(150deg, #f05680, #c92a5a); --td: #8f1a3d; }
.t3 { background: linear-gradient(150deg, #9168f0, #6a43d1); --td: #4a2aa0; }
.t4 { background: linear-gradient(150deg, #ffd65e, #ffb52e); --td: #d98f00; color: #4a2a00; }
.t5 { background: linear-gradient(150deg, #22b98d, #0f8a69); --td: #0a6650; }
.t6 { background: linear-gradient(150deg, #56689e, #3b4776); --td: #283258; }
.tip { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
body.kid .card.tip { display: block; line-height: 2.2; background: #fffbea; box-shadow: inset 0 0 0 2px #ffe69a; font-weight: 600; }
.kfoot { margin-top: 26px; }

/* ---------------- lộ trình ---------------- */
.tabs { display: inline-flex; gap: 6px; margin-bottom: 6px; padding: 6px; background: #fff; border-radius: 999px; box-shadow: var(--sh-sm); max-width: 100%; }
.tab { font: inherit; font-family: var(--font-d); font-weight: 700; font-size: 18px; border: 0; background: transparent; color: var(--ink); border-radius: 999px; padding: 8px 20px; cursor: pointer; transition: background .15s; white-space: nowrap; }
.tab:hover { background: #fff3e0; }
.tab.sel { background: var(--ink); color: #fff; box-shadow: 0 3px 0 #17152b; }
.chap { --c: #1fb488; --ct: #e6f8f1; background: #fff; border-radius: 28px; padding: 16px 18px 18px; margin: 18px 0; box-shadow: var(--sh); border-top: 6px solid var(--c); }
.chap.lv2 { --c: #ffb52e; --ct: #fff4d8; } .chap.lv3 { --c: #4cb6f2; --ct: #e6f5ff; } .chap.lv4 { --c: #7a58e0; --ct: #f0ebff; } .chap.lv5 { --c: #e23c66; --ct: #ffe8ee; }
.chap h3 { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; margin: 2px 0 12px; font-size: 22px; }
.chap h3 .chi { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 14px; background: var(--ct); font-size: 24px; }
.chap h3 small { margin-left: auto; color: #865300; background: #fff6d3; border-radius: 999px; padding: 2px 12px; font-size: 15px; font-family: var(--font-b); font-weight: 800; }
.chap.locked { background: #f6efe4; border-top-color: #d9cdb9; box-shadow: none; }
.chap.locked h3 .chi { background: #ece2d2; filter: grayscale(1); }
.chap.locked > p.small { margin: -4px 0 12px; font-weight: 600; }
.nodes { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.node { position: relative; font: inherit; color: var(--ink); display: flex; flex-direction: column; align-items: center; gap: 4px; background: #fff; border: 2px solid #ecdfca; border-radius: 22px; padding: 12px 8px 10px; cursor: pointer;
  box-shadow: 0 4px 0 #ecdfca; transition: transform .12s, box-shadow .12s, border-color .12s; }
.node:hover:not(:disabled) { transform: translateY(-3px); border-color: var(--c); box-shadow: 0 7px 0 #ecdfca; }
.node:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 #ecdfca; }
.node:disabled { cursor: not-allowed; filter: grayscale(1); opacity: .6; box-shadow: none; }
.node .ni { display: grid; place-items: center; width: 54px; height: 54px; border-radius: 50%; background: var(--ct); font-size: 30px; line-height: 1; }
.node .nt { font-size: 14px; text-align: center; font-weight: 700; line-height: 1.3; }
.node .ns { color: #f5b400; letter-spacing: 2px; font-size: 16px; margin-top: auto; }
.node.s1 { border-color: #ffd96a; box-shadow: 0 4px 0 #ffd96a; }
.node.s2 { border-color: #ffc23d; background: #fffaf0; box-shadow: 0 4px 0 #ffc23d; }
.node.s3 { border-color: #1fb488; background: #effcf6; box-shadow: 0 4px 0 #8ddcc0; }
.node.s3::after { content: '✓'; position: absolute; top: -8px; right: -6px; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  background: #1fb488; color: #fff; font-weight: 900; font-size: 15px; box-shadow: 0 2px 0 #128063; }

/* ---------------- cài đặt luyện tập ---------------- */
.chip { font: inherit; font-weight: 700; color: var(--ink); border: 2px solid var(--line); background: #fff; border-radius: 999px; padding: 8px 16px; min-height: 44px; margin: 4px 6px 4px 0; cursor: pointer;
  box-shadow: 0 3px 0 var(--line); transition: transform .12s, box-shadow .12s, background .12s; }
.chip:hover { transform: translateY(-1px); background: #fffaf2; }
.chip:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--line); }
.chip.sel { background: var(--brand2); border-color: var(--brand2); color: #fff; box-shadow: 0 3px 0 var(--brand2-d); }
.chips { display: flex; flex-wrap: wrap; }
.card h4 { margin: 18px 0 8px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; } .card h4:first-child { margin-top: 2px; }
.card h4 small { font-weight: 600; color: var(--muted); font-family: var(--font-b); font-size: 14px; }
.stepn { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--sun); color: #5a3300; font-style: normal; font-size: 16px; box-shadow: 0 2px 0 var(--sun-d); }

/* ---------------- câu hỏi ---------------- */
body.kid .card.qcard { padding: 22px 24px 24px; border: 0; }
.qhead { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 14px; padding-bottom: 14px; border-bottom: 2px dashed #f0e4cf; }
.qicon { flex: none; display: grid; place-items: center; width: 52px; height: 52px; border-radius: 18px; background: #fff3d6; font-size: 28px; line-height: 1; }
.qhead .prompt { flex: 1; margin: 0; align-self: center; font-family: var(--font-d); font-size: 23px; font-weight: 700; line-height: 1.35; }
.speak { flex: none; display: grid; place-items: center; font-size: 24px; width: 52px; height: 52px; cursor: pointer; border-radius: 50%;
  background: #e6f5ff; border: 2px solid #bfe3fb; box-shadow: 0 3px 0 #bfe3fb; transition: transform .12s, box-shadow .12s; }
.speak:hover { transform: translateY(-1px); }
.speak:active { transform: translateY(2px); box-shadow: 0 1px 0 #bfe3fb; }
#qbody { font-size: 19px; }
.actions { display: flex; gap: 12px; justify-content: center; margin-top: 6px; }
.actions .kbtn.big { min-width: 200px; }
body.kid .feedback { text-align: center; font-size: 20px; font-weight: 800; min-height: 34px; margin: 14px auto; width: fit-content; max-width: 100%; }
body.kid .feedback:not(:empty) { padding: 10px 22px; border-radius: 22px; background: #fff; box-shadow: var(--sh-sm); animation: pop .3s cubic-bezier(.2, 1.4, .4, 1); }
body.kid .feedback.ok:not(:empty) { background: #e2f8ee; color: #0b6e4d; box-shadow: inset 0 0 0 2px #9fe0c5; }
body.kid .feedback.bad:not(:empty) { background: #fff0f2; color: #b3183a; box-shadow: inset 0 0 0 2px #ffc4cf; }
.blank.shown { border-color: #f4a261; background: #fff4e6; }

/* ---------------- kết quả ---------------- */
body.kid .card.result { position: relative; overflow: hidden; padding-top: 26px; }
.result::before { content: ''; position: absolute; left: 50%; top: -180px; width: 520px; height: 360px; transform: translateX(-50%); border-radius: 50%;
  background: radial-gradient(closest-side, #fff2c4, rgba(255, 242, 196, 0)); pointer-events: none; }
.result > * { position: relative; }
.rhead { display: flex; align-items: center; justify-content: center; gap: 8px; }
.result .bigstars { font-size: 60px; line-height: 1.1; }
.bigstars span { display: inline-block; animation: pop .5s cubic-bezier(.2, 1.6, .4, 1) both; }
.bigstars span:nth-child(2) { animation-delay: .15s; } .bigstars span:nth-child(3) { animation-delay: .3s; }
.result h2 { font-size: 34px; margin: 4px 0 8px; color: var(--brand); }
.rgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 16px 0; }
.rgrid div { border-radius: 20px; padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; background: #eef7ff; }
.rgrid div:nth-child(2) { background: #f2eeff; } .rgrid div:nth-child(3) { background: #fff3d6; } .rgrid div:nth-child(4) { background: #e5f8ef; }
.rgrid b { font-family: var(--font-d); font-size: 28px; line-height: 1.2; }
.rgrid small { color: var(--muted); font-weight: 700; font-size: 14px; }
.unlock, .newbadge { background: #effcf6; border: 2px dashed #6fd3ae; border-radius: 18px; padding: 10px 14px; margin: 8px auto; max-width: 520px; font-size: 18px; font-weight: 600; }
.newbadge { background: #fffaea; border-color: #ffd96a; }
.newbadge span { font-size: 26px; vertical-align: middle; }

/* ---------------- kho quà ---------------- */
body.kid .card.chestcard { display: flex; gap: 22px; align-items: center; flex-wrap: wrap; background: linear-gradient(135deg, #fff6d8 0%, #ffe9ef 100%); }
.chestcard h2 { margin: 0 0 4px; }
.chestcard p { margin: 0 0 12px; font-weight: 600; }
.bigchest { font-size: 90px; line-height: 1; filter: drop-shadow(0 10px 8px rgba(170, 100, 20, .25)); animation: float 2.5s ease-in-out infinite; }
.album { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 12px; }
.stk { position: relative; background: #fff; border: 3px solid #fff; border-radius: 22px; text-align: center; padding: 10px 4px 8px; box-shadow: var(--sh-sm); transition: transform .15s; }
.stk:not(.none):hover { transform: rotate(-3deg) scale(1.05); }
.stk span { font-size: 42px; display: block; line-height: 1.2; filter: drop-shadow(0 3px 0 rgba(0, 0, 0, .08)); }
.stk small { font-size: 12px; font-weight: 700; color: var(--muted); }
.stk.r2 { box-shadow: 0 0 0 3px #a9dbff, var(--sh-sm); }
.stk.r3 { background: #fffaf0; box-shadow: 0 0 0 3px #ffc23d, 0 0 18px rgba(255, 194, 61, .45); }
.stk.none { background: #faf4ea; border: 2px dashed #e2d3bb; box-shadow: none; }
.stk.none span { filter: grayscale(1); opacity: .35; }
.stk.none.r2 { border-color: #b6dcf7; } .stk.none.r3 { border-color: #f5cf73; }
.stk i { position: absolute; top: -8px; right: -6px; font-size: 12px; font-weight: 800; font-style: normal; color: #fff; background: var(--brand); border-radius: 999px; padding: 1px 7px; }
.rlist { display: flex; flex-direction: column; gap: 10px; }
.ritem { display: flex; align-items: center; gap: 12px; background: #fff; border-radius: 20px; padding: 10px 14px; box-shadow: var(--sh-sm); }
.ritem b { flex: 1; } .ritem span { font-weight: 800; color: #865300; }
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.bdg { background: #fff; border-radius: 24px; padding: 16px 12px 14px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 2px; box-shadow: var(--sh-sm); }
.bdg span { display: grid; place-items: center; width: 76px; height: 76px; border-radius: 50%; font-size: 40px; line-height: 1; margin-bottom: 6px;
  background: radial-gradient(circle at 35% 30%, #fffbe8, #ffe08a); box-shadow: inset 0 0 0 4px #ffc23d, 0 4px 0 #d98f00; }
.bdg b { font-family: var(--font-d); font-size: 18px; } .bdg small { color: var(--muted); font-weight: 600; line-height: 1.3; } .bdg i { margin-top: 4px; font-size: 12px; color: #0b6e4d; background: #e2f8ee; border-radius: 99px; padding: 1px 8px; font-style: normal; font-weight: 700; }
.bdg.none { background: #faf4ea; box-shadow: inset 0 0 0 2px #ecdfca; }
.bdg.none span { filter: grayscale(1); opacity: .5; background: #f0e8da; box-shadow: inset 0 0 0 4px #ddd0bb; }
.bdg.none b, .bdg.none small { opacity: .7; }

/* ---------------- phụ huynh ---------------- */
.bars { position: relative; display: flex; align-items: flex-end; gap: 12px; height: 190px; padding: 22px 0 44px; }
.bcol { position: relative; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.bv { width: min(70%, 44px); background: linear-gradient(#4cb6f2, #1fb488); border-radius: 10px 10px 4px 4px; min-height: 4px; max-height: 100%; }
.bcol small { position: absolute; top: calc(100% + 4px); font-size: 12px; color: var(--muted); font-weight: 700; }
.bcol small + small { top: calc(100% + 21px); font-weight: 600; }
.goalline { position: absolute; left: 0; right: 0; border-top: 2px dashed #e23c66; pointer-events: none; bottom: calc(44px + var(--g, 1) * (100% - 66px)); }
.goalline span { position: absolute; right: 0; top: -20px; font-size: 12px; font-weight: 700; color: #c42b5a; background: #fff; padding: 0 4px; }
.ktable { width: 100%; border-collapse: collapse; font-size: 15px; }
.ktable th { font-size: 13px; color: var(--muted); text-transform: none; font-weight: 800; }
.ktable th, .ktable td { padding: 8px 8px; border-bottom: 1px solid #f1e7d6; text-align: left; }
.ktable tr:hover td { background: #fffaf2; }
.tscroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.pct { padding: 2px 10px; border-radius: 99px; font-weight: 800; }
.pct.lo { background: #ffe0e0; color: #b3121f; } .pct.mid { background: #fff3c4; color: #7a5f00; } .pct.hi { background: #dcfce7; color: #166534; }
.hrow { display: flex; gap: 12px; flex-wrap: wrap; font-size: 14px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.row { display: flex; align-items: center; gap: 8px; margin: 10px 0; flex-wrap: wrap; }
.tip .kbtn { margin-left: 6px; }
.row > .kin:not(.small) { flex: 1 1 180px; min-width: 0; max-width: 340px; }
.row:has(> input[type=checkbox]:first-child) { flex-wrap: nowrap; align-items: flex-start; }
.row input[type=checkbox] { flex: none; margin: 1px 0 0; width: 22px; height: 22px; accent-color: var(--brand2); }
.pchip { display: inline-block; background: var(--soft); border-radius: 999px; padding: 5px 14px; margin: 3px; font-weight: 600; }

/* ---------------- modal, toast, hiệu ứng ---------------- */
.modal-bg { position: fixed; inset: 0; background: rgba(45, 42, 74, .5); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: #fff; border-radius: 30px; padding: 24px 26px; max-width: 440px; width: 100%; text-align: center; animation: pop .25s cubic-bezier(.2, 1.4, .4, 1); box-shadow: 0 30px 60px -20px rgba(30, 20, 60, .5); }
.modal h2, .modal h3 { margin-top: 4px; }
.modal .kin { width: 100%; text-align: center; font-size: 24px; font-weight: 800; }
.modal .err { color: var(--bad); min-height: 20px; font-weight: 700; }
.chestbox { min-height: 250px; display: flex; flex-direction: column; align-items: center; justify-content: center; border-radius: 24px;
  background: radial-gradient(circle at 50% 38%, #fff3c4 0, rgba(255, 243, 196, 0) 60%); }
.chestbox h2 { margin: 6px 0 0; }
.chest { font-size: 110px; filter: drop-shadow(0 12px 10px rgba(170, 100, 20, .3)); }
.shake { animation: shake .25s infinite; }
.sticker { font-size: 110px; line-height: 1.1; filter: drop-shadow(0 6px 0 rgba(0, 0, 0, .08)); }
.pop { animation: pop .5s cubic-bezier(.2, 1.6, .4, 1); }
.rar { font-weight: 800; } .rar.r2 { color: #0d6fae; } .rar.r3 { color: #b07400; }
.toast { position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 22px; border-radius: 999px; z-index: 60; animation: pop .3s; font-weight: 800;
  box-shadow: 0 12px 30px -10px rgba(30, 20, 60, .6); max-width: calc(100vw - 32px); text-align: center; }
.fx-canvas { position: fixed; inset: 0; pointer-events: none; z-index: 70; }
.fx-float { position: fixed; transform: translateX(-50%); font-family: var(--font-d); font-weight: 800; font-size: 28px; color: #d98f00; text-shadow: 0 2px 0 #fff, 0 0 8px #fff; pointer-events: none; z-index: 70; animation: rise 1.3s ease-out forwards; }
@keyframes rise { from { opacity: 1; margin-top: 0; } to { opacity: 0; margin-top: -80px; } }
@keyframes pop { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes shake { 0%,100% { transform: rotate(-8deg); } 50% { transform: rotate(8deg); } }
@keyframes pulse { 50% { transform: scale(1.07); } }
@keyframes float { 50% { transform: translateY(-8px); } }
@keyframes wave { 0%, 60%, 100% { transform: rotate(0); } 70% { transform: rotate(-14deg); } 80% { transform: rotate(8deg); } 90% { transform: rotate(-8deg); } }
.toast { transform: translateX(-50%); }

/* ---------------- nhiệm vụ hằng ngày ---------------- */
body.kid .card.quests { margin-top: 16px; }
.quests h3 { margin: 0 0 10px; } .quests h3 small { font-weight: 600; color: var(--muted); font-family: var(--font-b); font-size: 15px; }
.qrow { display: grid; grid-template-columns: 1fr 140px 48px; gap: 12px; align-items: center; margin: 8px 0; padding: 8px 12px; border-radius: 16px; background: #fffaf2; font-weight: 600; }
.qrow small { font-weight: 800; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.qrow.done { background: #e9f9f1; }
.qrow.done span { color: #0b6e4d; font-weight: 800; }
.qbar { height: 12px; background: #f1e5d1; border-radius: 99px; overflow: hidden; }
.qbar i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, #ffc23d, #1fb488); }
.quests > p { margin: 10px 0 0; }

/* nội dung bài rộng hơn màn hình (tranh, hàng xếp) thì cuộn ngang trong thẻ, không tràn trang */
#qbody { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ---------------- phần nội dung bài trong app bé: nút chọn dày, ô điền rõ ---------------- */
body.kid .blank { border-radius: 12px; transition: box-shadow .15s, border-color .15s, background .15s; }
body.kid .blank:focus { outline: none; border-color: var(--brand2); background: #fff; box-shadow: 0 0 0 4px rgba(255, 194, 61, .55); }
body.kid .blank.ok { box-shadow: 0 0 0 3px rgba(31, 180, 136, .25); }
body.kid .blank.bad { box-shadow: 0 0 0 3px rgba(230, 57, 70, .2); }
body.kid .choices, body.kid .multi { gap: 12px; }
body.kid .choice, body.kid .mopt { font-weight: 700; color: var(--ink); border-radius: 18px; padding: 10px 20px; min-height: 50px; min-width: 50px; border-width: 2px;
  box-shadow: 0 4px 0 var(--line); transition: transform .12s, box-shadow .12s, border-color .12s, background .12s; }
body.kid .choice:hover:not(:disabled), body.kid .mopt:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 6px 0 var(--line); }
body.kid .choice:active:not(:disabled), body.kid .mopt:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--line); }
body.kid .choice.pick, body.kid .mopt.on { border-color: var(--brand2); background: #e6f5ff; box-shadow: 0 4px 0 #8cc9ef; }
body.kid .choice.ok, body.kid .mopt.ok { border-color: var(--mint); background: #e2f8ee; box-shadow: 0 4px 0 #8ddcc0; }
body.kid .choice.bad, body.kid .mopt.bad { border-color: #e63946; background: #ffeceb; box-shadow: 0 4px 0 #f5a9ae; }
body.kid .choice:disabled, body.kid .mopt:disabled { cursor: default; }
body.kid .mrow { border-radius: 16px; box-shadow: 0 3px 0 var(--line); transition: border-color .12s, box-shadow .12s; }
body.kid .mrow.sel { box-shadow: 0 0 0 3px #b9e6fb, 0 3px 0 #8cc9ef; }
body.kid .bond { border-color: #c9b79c; background: #fffdf7; }
body.kid .ac-box, body.kid .bond .num { border-radius: 12px; }

/* ---------------- máy tính bảng ---------------- */
@media (max-width: 860px) {
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .t1, .t2 { grid-column: span 1; }
  .rgrid { grid-template-columns: repeat(2, 1fr); }
}

/* ---------------- điện thoại ---------------- */
@media (max-width: 600px) {
  :where(body.kid) h2 { font-size: 23px; }
  .kwrap { padding: 14px 12px 64px; }
  body.kid .card { padding: 16px; border-radius: 24px; }
  .kbar { padding: 8px 10px; gap: 6px; }
  .kb-back, .kb-me .av { width: 40px; height: 40px; }
  .kb-me { font-size: 17px; }
  .kb-me b { max-width: 7em; }
  .pill { padding: 4px 9px; font-size: 15px; }
  .kbar.play { flex-wrap: nowrap; }
  .kbar.play .sp { display: none; }
  .kbar.play .pinfo { flex: 1 1 auto; }
  .kbar.play .pill { padding: 4px 8px; }
  .pinfo b { font-size: 15px; }
  .pinfo small { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .timer { font-size: 17px; min-width: 76px; padding: 5px 8px; }
  .ktitle { font-size: 38px; }
  .avs { grid-template-columns: repeat(4, 1fr); }
  .hello { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 12px; padding: 16px; text-align: left; }
  .hello .htext { display: contents; }
  .hello .hmascot { grid-row: 1; grid-column: 1; }
  .hello .hmascot svg { width: 58px; height: 68px; }
  .hello h2 { grid-row: 1; grid-column: 2; font-size: 24px; margin: 0; }
  .hello h2, .hello p, .hello .goalbar { position: relative; z-index: 1; }
  .hello::before { width: 150px; height: 150px; right: -50px; top: -60px; }
  .hello .ring { grid-row: 1; grid-column: 3; width: 72px; height: 72px; }
  .hello .ring span { width: 54px; height: 54px; font-size: 17px; }
  .hello p, .hello .goalbar { grid-column: 1 / -1; }
  .hello p { margin: 6px 0 4px; }
  .tiles { gap: 12px; }
  .tile { min-height: 132px; padding: 14px; border-radius: 24px; }
  .t1, .t2 { min-height: 140px; }
  .tile span, .t1 span, .t2 span { width: 50px; height: 50px; font-size: 30px; border-radius: 16px; }
  .tile b, .t1 b, .t2 b { font-size: 18px; }
  .tile small { font-size: 12.5px; }
  .qrow { grid-template-columns: 1fr 44px; gap: 6px 10px; font-size: 15px; }
  .qrow > span { grid-column: 1 / -1; }
  .eq, .cmp, .opq { font-size: 20px; }
  .chip { font-size: 15px; padding: 6px 12px; min-height: 40px; margin: 3px 4px 3px 0; }
  .tabs { display: flex; }
  .tab { flex: 1; padding: 8px 10px; font-size: 17px; }
  .chap { padding: 14px 12px 14px; }
  .chap h3 { font-size: 19px; }
  .nodes { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
  .node .ni { width: 46px; height: 46px; font-size: 26px; }
  .node .nt { font-size: 13px; }
  .qhead { gap: 10px; }
  .qicon { width: 44px; height: 44px; font-size: 24px; border-radius: 14px; }
  .qhead .prompt { font-size: 20px; }
  .speak { width: 44px; height: 44px; font-size: 20px; }
  .actions .kbtn.big { min-width: 0; flex: 1; max-width: 320px; }
  .result h2 { font-size: 28px; }
  .rgrid b { font-size: 24px; }
  .bigchest { font-size: 72px; }
  body.kid .card.chestcard { justify-content: center; text-align: center; }
  .album { grid-template-columns: repeat(auto-fill, minmax(60px, 1fr)); gap: 8px; }
  .stk { border-radius: 18px; padding: 8px 2px 6px; }
  .stk span { font-size: 30px; }
  .stk small { font-size: 10.5px; display: block; line-height: 1.2; }
  .badges { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .bdg span { width: 64px; height: 64px; font-size: 34px; }
  .ktable { font-size: 14px; }
  .ktable th, .ktable td { padding: 6px 5px; }
}
@media (max-width: 360px) {
  .pill.streak { display: none; }
}

/* giảm chuyển động theo cài đặt hệ thống */
@media (prefers-reduced-motion: reduce) {
  body.kid *, body.kid *::before, body.kid *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .tile:hover, .pcard:hover, .node:hover:not(:disabled) { transform: none; }
}

/* điện thoại: bớt lề để tranh vừa màn hình mà vẫn đủ to */
@media (max-width: 520px) { .kwrap { padding-left: 10px; padding-right: 10px; } .qcard { padding: 14px 12px; } }

/* "Luyện tập tổng hợp" đứng đầu, chiếm cả hàng */
.tiles .t3 { grid-column: 1 / -1; min-height: 150px; }
.tiles .t3 span { width: 70px; height: 70px; font-size: 42px; }
.tiles .t3 b { font-size: 27px; }
.tiles .t7 { grid-column: span 2; }
@media (max-width: 760px) { .tiles .t7 { grid-column: 1 / -1; } }

/* chọn dạng bài theo nhóm */
.grp-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin: 6px 0; }
.grp-subj { font-size: 22px; margin-right: 2px; }
.chip.grp small { opacity: .75; font-weight: 600; margin-left: 2px; }
.chip.grp.part { border-color: #9bd0ff; background: #eef8ff; }
.topic-more { margin-top: 8px; border-top: 2px dashed var(--line); padding-top: 6px; }
.topic-more summary { cursor: pointer; color: var(--brand2); font-weight: 700; padding: 6px 0; }
.tm-grp { margin: 8px 0; } .tm-grp > b { font-size: 15px; color: var(--muted); }
.topic-more .chip { font-size: 14px; padding: 5px 10px; }

/* ô "Tạo phiếu bài tập PDF" (là liên kết) */
a.tile { text-decoration: none; color: #fff; }
.t7 { background: linear-gradient(150deg, #2bb3a3, #0f8a7e); --td: #0b5f57; }
/* hàng nút nhỏ cuối trang chủ: Bố mẹ, Đổi bạn học */
.home-foot { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin: 4px 0 10px; }
.pbtn, .pbtn.t6 { font: inherit; font-size: 15px; font-weight: 700; color: var(--ink); background: #fff; border: 2px solid var(--line);
  border-radius: 999px; padding: 7px 16px; cursor: pointer; text-decoration: none; box-shadow: 0 2px 0 rgba(0,0,0,.06); }
.pbtn:hover { border-color: #b9c3d6; }
.tile.t7, .tile.t7 b, .tile.t7 small { color: #fff !important; }
.home-foot a.pbtn { color: var(--ink) !important; }
