:root {
  --bg1: #fff6e5;
  --bg2: #e6f2ff;
  --ink: #2b2d42;
  --muted: #6b7280;
  --card: #ffffff;
  --line: #e7e3da;
  --primary: #ff7a59;
  --primary-dark: #e8603e;
  --blue: #4f8cff;
  --green: #22b07d;
  --green-soft: #dcfce7;
  --red: #ef4444;
  --red-soft: #fee2e2;
  --amber: #f59e0b;
  --amber-soft: #fef3c7;
  --kid: #ff7a59;
  --radius: 24px;
  --shadow: 0 6px 0 rgba(43, 45, 66, .08), 0 12px 28px rgba(43, 45, 66, .08);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: "Nunito", "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: linear-gradient(160deg, var(--bg1), var(--bg2)) fixed;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
input { font: inherit; }

/* ── Khung chung ── */
.center-screen { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.loading { font-size: 72px; animation: bounce 1s infinite; }
.screen { max-width: 960px; margin: 0 auto; padding: 20px 16px 48px; }
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 28px;
}
.muted { color: var(--muted); }
h1, h2, h3 { margin: 0 0 8px; line-height: 1.25; }

.btn {
  border: 0; border-radius: 18px; padding: 14px 22px; font-weight: 800; font-size: 20px;
  background: #fff; box-shadow: 0 4px 0 var(--line); transition: transform .08s, box-shadow .08s;
}
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--line); }
.btn.primary { background: var(--primary); color: #fff; box-shadow: 0 5px 0 var(--primary-dark); }
.btn.primary:active { box-shadow: 0 2px 0 var(--primary-dark); }
.btn.green { background: var(--green); color: #fff; box-shadow: 0 5px 0 #15895f; }
.btn.big { font-size: 24px; padding: 18px 28px; }
.btn.icon { padding: 10px 14px; font-size: 24px; line-height: 1; }
.btn.small { padding: 6px 10px; font-size: 18px; }
.btn.ghost { background: transparent; box-shadow: none; color: var(--muted); font-weight: 700; }

/* ── Đăng nhập ── */
.login { width: 100%; max-width: 420px; text-align: center; }
.logo { font-size: 72px; }
.login form { display: grid; gap: 14px; margin-top: 20px; text-align: left; }
.login label { display: grid; gap: 6px; font-weight: 700; }
.login input {
  border: 2px solid var(--line); border-radius: 14px; padding: 14px 16px; font-size: 18px; outline: none;
}
.login input:focus { border-color: var(--blue); }
.error { color: var(--red); font-weight: 700; min-height: 1.2em; }

/* ── Chọn bé ── */
.kids { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 18px; margin-top: 24px; }
.kid-card {
  border: 0; background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px 16px;
  display: grid; gap: 8px; justify-items: center; border-top: 10px solid var(--kid);
}
.kid-card .avatar { font-size: 72px; }
.kid-card b { font-size: 28px; }

/* ── Thanh trên cùng ── */
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; background: rgba(255, 255, 255, .85); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar .who { display: flex; align-items: center; gap: 10px; }
.topbar .who .avatar {
  font-size: 30px; width: 48px; height: 48px; display: grid; place-items: center;
  border-radius: 50%; background: color-mix(in srgb, var(--kid) 20%, white); border: 3px solid var(--kid);
}
.topbar .who span:last-child { display: grid; line-height: 1.1; }
.topbar .who small { color: var(--muted); font-weight: 700; }
.topbar .title { flex: 1; text-align: center; font-weight: 900; font-size: 20px; }
.stars-total { font-weight: 900; font-size: 20px; background: var(--amber-soft); padding: 8px 14px; border-radius: 999px; }

/* ── Trang chủ ── */
.hello { display: flex; align-items: center; gap: 16px; margin: 12px 0 24px; }
.hello .avatar { font-size: 64px; }
.hello h1 { font-size: 34px; }
.subjects { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; }
.subject {
  border: 0; text-align: left; background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 24px; display: grid; gap: 10px; border-left: 12px solid var(--c);
}
.subject .ico { font-size: 54px; }
.subject b { font-size: 28px; }
.subject .bar { height: 12px; border-radius: 99px; background: #f1efe9; overflow: hidden; }
.subject .bar i { display: block; height: 100%; background: var(--c); border-radius: 99px; }
.subject.soon { opacity: .6; }
.subject .tag { font-weight: 800; color: var(--muted); }
.notice {
  margin-top: 24px; background: var(--amber-soft); border-radius: 16px; padding: 14px 18px; font-weight: 700;
}
.footer-actions { margin-top: 32px; text-align: center; }

/* ── Danh sách bài ── */
.lessons { display: grid; gap: 14px; margin-top: 16px; }
.lesson {
  border: 0; text-align: left; background: #fff; border-radius: 20px; box-shadow: var(--shadow);
  padding: 16px 20px; display: grid; grid-template-columns: 56px 1fr auto; align-items: center; gap: 16px;
}
.lesson .num {
  width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center;
  font-size: 28px; background: var(--bg1);
}
.lesson b { font-size: 21px; display: block; }
.lesson small { color: var(--muted); font-weight: 700; }
.lesson .st { font-size: 22px; letter-spacing: 2px; white-space: nowrap; }
.lesson.locked { opacity: .55; }
.lesson.next { outline: 4px solid var(--primary); animation: pulse 1.6s infinite; }
.lesson.done .num { background: var(--green-soft); }

/* ── Trang bài học ── */
.hub-head { display: flex; gap: 18px; align-items: center; margin: 8px 0 24px; }
.hub-head .big-icon { font-size: 72px; }
.hub-head small { color: var(--muted); font-weight: 800; }
.hub-head h2 { font-size: 30px; }
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 18px; }
.step {
  border: 0; background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 26px 20px;
  display: grid; gap: 6px; justify-items: center; text-align: center;
}
.step span { font-size: 56px; }
.step b { font-size: 24px; }
.step small { color: var(--muted); font-weight: 700; font-size: 16px; }
.step.suggest { outline: 4px solid var(--primary); }

/* ── Học bài (slides) ── */
.slide-card { position: relative; text-align: center; padding: 32px 24px; }
.slide-count { position: absolute; top: 16px; left: 20px; color: var(--muted); font-weight: 800; }
.slide-card .speak { position: absolute; top: 12px; right: 12px; }
.slide-card h2 { font-size: 32px; margin-bottom: 16px; color: var(--primary-dark); }
.slide-text { font-size: 26px; line-height: 1.6; font-weight: 700; margin-top: 16px; }
.slide-text.table { columns: 2; column-gap: 40px; display: inline-block; text-align: left; font-variant-numeric: tabular-nums; }
.nav { display: flex; justify-content: space-between; gap: 12px; margin-top: 20px; }

/* ── Câu hỏi ── */
.progress { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-bottom: 16px; }
.dot { width: 22px; height: 22px; border-radius: 50%; background: #fff; border: 3px solid var(--line); }
.dot.cur { border-color: var(--primary); transform: scale(1.2); }
.dot.ok { background: var(--green); border-color: var(--green); }
.dot.ok2 { background: #a3e635; border-color: #a3e635; }
.dot.bad { background: var(--red); border-color: var(--red); }
.dot.retry { background: var(--amber); border-color: var(--amber); }
.dot.done { background: var(--blue); border-color: var(--blue); }
.qcard { position: relative; text-align: center; padding: 28px 20px; }
.qcard .speak { position: absolute; top: 12px; right: 12px; }
.prompt { font-size: 52px; font-weight: 900; padding: 8px 48px; }
.prompt.long { font-size: 28px; line-height: 1.5; font-weight: 800; }
.answer-area { margin-top: 20px; }
.choices { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.choices.n3 { grid-template-columns: repeat(3, 1fr); }
.choice {
  border: 0; background: #fff; border-radius: 20px; box-shadow: 0 6px 0 var(--line); padding: 22px 12px;
  font-size: 36px; font-weight: 900; transition: transform .08s;
}
.choice.text { font-size: 24px; }
.choice.long { font-size: 19px; text-align: left; padding: 16px 18px; line-height: 1.4; }
.listen-btn {
  margin-top: 12px; font-size: 28px; background: var(--blue); color: #fff; box-shadow: 0 5px 0 #2f6ad9;
  animation: pulse-blue 1.6s 2;
}
@keyframes pulse-blue { 50% { transform: scale(1.06); } }
.vis-emoji { font-size: 120px; line-height: 1; }
.vis-pics figure { margin: 0; display: grid; justify-items: center; gap: 4px; }
.vis-pics figure span { font-size: 56px; line-height: 1; }
.vis-pics figcaption { font-size: 24px; font-weight: 900; color: var(--blue); }
.choice:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 2px 0 var(--line); }
.choice.right { background: var(--green); color: #fff; box-shadow: 0 6px 0 #15895f; }
.choice.wrong { background: var(--red-soft); color: var(--red); box-shadow: 0 6px 0 #fca5a5; }
.choice.picked { background: var(--blue); color: #fff; }
.inputbox {
  margin: 0 auto 16px; max-width: 300px; min-height: 84px; border-radius: 20px; background: #fff;
  border: 4px solid var(--blue); font-size: 52px; font-weight: 900; display: grid; place-items: center;
}
.inputbox .placeholder { color: #cbd5e1; }
.inputbox.right { border-color: var(--green); background: var(--green-soft); }
.inputbox.wrong { border-color: var(--red); background: var(--red-soft); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 380px; margin: 0 auto; }
.key {
  border: 0; background: #fff; border-radius: 16px; box-shadow: 0 5px 0 var(--line); padding: 14px 0;
  font-size: 32px; font-weight: 900;
}
.key:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--line); }
.key.ok { background: var(--green); color: #fff; box-shadow: 0 5px 0 #15895f; }
.feedback { margin-top: 18px; display: grid; gap: 14px; justify-items: center; }
.fb { width: 100%; border-radius: 18px; padding: 16px 20px; font-size: 22px; font-weight: 700; line-height: 1.5; text-align: left; }
.fb.ok { background: var(--green-soft); color: #166534; text-align: center; font-size: 30px; font-weight: 900; }
.fb.hint { background: var(--amber-soft); }
.fb.explain { background: #e0ecff; }
.shake { animation: shake .4s; }

/* ── Hình minh họa ── */
.vis { margin: 16px auto 0; display: flex; align-items: center; justify-content: center; gap: 18px; flex-wrap: wrap; }
.obj { font-size: 40px; line-height: 1.15; display: inline-block; position: relative; }
.obj.sm { font-size: 28px; }
.obj.crossed { opacity: .35; }
.obj.crossed::after {
  content: "✕"; position: absolute; inset: 0; display: grid; place-items: center; color: var(--red);
  font-weight: 900; font-size: 34px; opacity: 1;
}
.objs { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; max-width: 280px; }
.objs.grid5 { display: grid; grid-template-columns: repeat(5, auto); }
.vis .op { font-size: 44px; font-weight: 900; color: var(--primary); }
.vis .op.sep { width: 2px; height: 60px; background: var(--line); }
.vis-rows { flex-direction: column; align-items: flex-start; gap: 10px; display: inline-flex; }
.vis-rows .row { display: flex; gap: 10px; }
.vis-groups .grp {
  display: flex; flex-wrap: wrap; gap: 2px; justify-content: center; max-width: 140px; padding: 10px;
  border: 3px dashed #cbd5e1; border-radius: 18px; background: #fffdf7;
}
.vis-groups .grp.extra { border-style: dotted; border-color: var(--red); background: var(--red-soft); }
.vis-column pre {
  margin: 0; font-family: "Consolas", "Courier New", monospace; font-size: 44px; font-weight: 700;
  line-height: 1.2; text-align: right; background: #fffdf7; border-radius: 16px; padding: 12px 24px;
  border: 2px solid var(--line);
}
.vis-tens { align-items: flex-end; gap: 8px; }
.bundle { display: grid; grid-template-rows: repeat(10, 12px); gap: 2px; padding: 4px; background: #e0ecff; border-radius: 8px; }
.bundle i, .ones i { display: block; width: 18px; height: 12px; background: var(--blue); border-radius: 3px; }
.ones { display: grid; grid-template-columns: repeat(2, 18px); gap: 4px; margin-left: 12px; }
.ones i { height: 18px; background: var(--primary); border-radius: 50%; }
.vis-caption { font-weight: 800; color: var(--muted); margin-top: 8px; font-size: 20px; }
.vis-numbers { flex-direction: column; align-items: flex-start; gap: 6px; display: inline-flex; }
.vis-numbers .row { display: flex; align-items: center; gap: 14px; }
.vis-numbers .n { font-size: 36px; font-weight: 900; width: 48px; text-align: right; color: var(--primary-dark); }
.vis-numbers .obj { font-size: 30px; }
.vis-line { gap: 6px; }
.vis-line span {
  width: 52px; height: 52px; display: grid; place-items: center; border-radius: 12px; background: #fff;
  border: 2px solid var(--line); font-size: 24px; font-weight: 900;
}
.vis-line span.mark { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ── Kết quả ── */
.result { text-align: center; }
.result .big-emoji { font-size: 96px; animation: pop .6s; }
.result h1 { font-size: 34px; }
.score { font-size: 64px; font-weight: 900; color: var(--primary-dark); margin: 8px 0; }
.star-row { font-size: 56px; letter-spacing: 8px; }
.star-row .off { filter: grayscale(1); opacity: .3; }
.star-row span { display: inline-block; animation: pop .5s backwards; }
.unlock { margin: 16px auto; background: var(--green-soft); border-radius: 16px; padding: 14px 18px; font-weight: 800; font-size: 20px; max-width: 520px; }
.review { text-align: left; margin-top: 24px; display: grid; gap: 12px; }
.review h3 { font-size: 22px; }
.review-item { background: #fff; border-radius: 16px; padding: 14px 18px; border-left: 8px solid var(--red); box-shadow: var(--shadow); }
.review-item .q { font-size: 22px; font-weight: 900; }
.review-item .a { margin: 4px 0; font-weight: 700; }
.review-item .a .bad { color: var(--red); }
.review-item .a .good { color: var(--green); }
.review-item .ex { color: var(--muted); font-weight: 600; white-space: pre-line; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin-top: 24px; }

/* ── Hiệu ứng ── */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(120px); background: var(--ink);
  color: #fff; padding: 12px 20px; border-radius: 14px; font-weight: 700; transition: transform .25s, opacity .25s;
  z-index: 50; max-width: calc(100% - 32px); opacity: 0; visibility: hidden;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; visibility: visible; }
.confetti { position: fixed; top: -60px; font-size: 32px; pointer-events: none; z-index: 40; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(540deg); } }
@keyframes pop { 0% { transform: scale(0); } 70% { transform: scale(1.2); } 100% { transform: scale(1); } }
@keyframes bounce { 50% { transform: translateY(-12px); } }
@keyframes pulse { 50% { outline-color: rgba(255, 122, 89, .35); } }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }

@media (max-width: 640px) {
  .prompt { font-size: 40px; padding: 8px 40px; }
  .prompt.long { font-size: 22px; }
  .slide-text { font-size: 21px; }
  .slide-text.table { columns: 1; }
  .topbar .title { display: none; }
  .choice { font-size: 30px; }
}
