:root {
  --nen: #fff4e0;
  --giay: #ffffff;
  --chu: #3a2e2a;
  --mo: #8a7a70;
  --chu-mau: #ff6b4a;   /* Học chữ */
  --toan-mau: #3a86ff;  /* Toán */
  --anh-mau: #22a96b;   /* Tiếng Anh */
  --vang: #ffbe0b;
  --dung: #2bb673;
  --sai: #ef476f;
  --bong: 0 4px 0 rgba(58, 46, 42, .12), 0 8px 20px rgba(58, 46, 42, .08);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh;
  background: var(--nen);
  color: var(--chu);
  font-family: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-weight: 800;
  -webkit-tap-highlight-color: transparent;
  user-select: none; -webkit-user-select: none;
}
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; touch-action: manipulation; }

/* Thanh đầu */
.dau {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: rgba(255, 244, 224, .94); backdrop-filter: blur(6px);
  border-bottom: 2px solid rgba(58, 46, 42, .06);
}
.dau h1 { flex: 1; margin: 0; font-size: clamp(20px, 5vw, 28px); font-weight: 900; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nut-lui {
  width: 52px; height: 52px; border-radius: 16px; flex: none;
  background: var(--giay); box-shadow: var(--bong); font-size: 28px; font-weight: 900;
}
.sao {
  display: flex; align-items: center; gap: 6px; flex: none;
  background: var(--giay); padding: 8px 14px; border-radius: 999px; box-shadow: var(--bong);
  font-size: 22px;
}
.sao.nay { animation: nay .5s; }

main { max-width: 960px; margin: 0 auto; padding: 16px 16px 48px; }

/* Trang chủ */
.chao { display: flex; align-items: center; gap: 14px; margin: 8px 0 20px; }
.chao h2 { margin: 0; font-size: clamp(26px, 7vw, 40px); font-weight: 900; }
.chao p { margin: 4px 0 0; color: var(--mo); font-size: 18px; }
.nut-loa {
  width: 64px; height: 64px; border-radius: 50%; flex: none;
  background: var(--vang); box-shadow: var(--bong); font-size: 30px;
}
.nut-loa:active { transform: translateY(3px); box-shadow: none; }

.luoi-mon { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; }
.the-mon {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
  min-height: 170px; padding: 20px; border-radius: 28px; color: #fff; text-align: left;
  box-shadow: 0 6px 0 rgba(0, 0, 0, .15);
  transition: transform .12s;
}
.the-mon:active { transform: translateY(4px); box-shadow: 0 2px 0 rgba(0, 0, 0, .15); }
.the-mon .bt { font-size: 56px; line-height: 1; }
.the-mon b { font-size: 30px; font-weight: 900; }
.the-mon small { font-size: 17px; opacity: .92; font-weight: 700; }
.mau-chu { background: var(--chu-mau); }
.mau-toan { background: var(--toan-mau); }
.mau-anh { background: var(--anh-mau); }

/* Danh mục trò trong một môn */
.ds-tro { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.the-tro {
  display: flex; align-items: center; gap: 14px; padding: 18px; min-height: 96px;
  background: var(--giay); border-radius: 24px; box-shadow: var(--bong); text-align: left;
}
.the-tro:active { transform: translateY(3px); }
.the-tro .bt { font-size: 44px; width: 64px; height: 64px; display: grid; place-items: center; border-radius: 18px; flex: none; }
.the-tro b { font-size: 22px; display: block; }
.the-tro small { color: var(--mo); font-size: 15px; font-weight: 700; }

/* Bảng chữ cái */
.luoi-chu { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 10px; }
.o-chu {
  position: relative; aspect-ratio: 1; border-radius: 20px; background: var(--giay); box-shadow: var(--bong);
  font-size: 46px; font-weight: 900; color: var(--chu-mau);
}
.o-chu small { position: absolute; top: 6px; right: 10px; font-size: 16px; color: var(--mo); }
.o-chu:active { transform: scale(.94); }

/* Lớp phủ xem một chữ / phần thưởng */
.lop-phu {
  position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px;
  background: rgba(58, 46, 42, .45);
}
.lop-phu[hidden] { display: none; }
.the-to {
  width: min(420px, 100%); padding: 24px; border-radius: 32px; background: var(--giay); text-align: center;
  animation: bung .25s ease-out;
}
.the-to .chu-to { font-size: clamp(110px, 32vw, 170px); line-height: 1; font-weight: 900; color: var(--chu-mau); }
.the-to .hinh-to { font-size: 90px; line-height: 1.1; }
.the-to .tu { font-size: 34px; margin: 6px 0 16px; }
.hang-nut { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }
.nut {
  min-height: 56px; padding: 0 22px; border-radius: 18px; font-size: 20px; font-weight: 900;
  background: var(--vang); box-shadow: 0 4px 0 rgba(0, 0, 0, .15);
}
.nut.phu { background: #efe6da; }
.nut:active { transform: translateY(3px); box-shadow: none; }

/* Trò chơi hỏi đáp */
.cau-hoi {
  background: var(--giay); border-radius: 28px; box-shadow: var(--bong);
  padding: 20px 16px; margin-bottom: 18px; text-align: center;
}
.cau-hoi .loi-dan { color: var(--mo); font-size: 18px; margin: 0 0 12px; }
.loa-to {
  width: 110px; height: 110px; border-radius: 50%; font-size: 54px;
  background: var(--vang); box-shadow: 0 6px 0 rgba(0, 0, 0, .15);
}
.loa-to:active { transform: translateY(4px); box-shadow: none; }
.loa-to.dang { animation: tho 1s infinite; }
.lua-chon { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.lua-chon.hai { grid-template-columns: repeat(2, 1fr); }
.o-chon {
  min-height: 110px; border-radius: 24px; background: var(--giay); box-shadow: var(--bong);
  font-size: clamp(44px, 12vw, 64px); font-weight: 900; padding: 8px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
}
.o-chon small { font-size: 16px; color: var(--mo); font-weight: 800; }
.o-chon:active { transform: scale(.96); }
.o-chon.dung { background: var(--dung); color: #fff; animation: nay .45s; }
.o-chon.dung small { color: #fff; }
.o-chon.sai { background: #f3e6e9; color: #c9a3ad; animation: lac .4s; }
.o-chon:disabled { cursor: default; }

/* Toán */
.dem { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; font-size: clamp(38px, 10vw, 56px); line-height: 1.15; max-width: 520px; margin: 0 auto; }
.phep { display: flex; align-items: flex-end; justify-content: center; gap: clamp(6px, 2vw, 14px); }
.nhom { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.nhom .dv { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px; font-size: clamp(22px, 6.4vw, 36px); max-width: min(200px, 30vw); min-height: 40px; }
.nhom .so-nho { line-height: 1.2; font-size: 40px; font-weight: 900; color: var(--toan-mau); }
.dau-phep { line-height: 1.2; font-size: clamp(34px, 9vw, 48px); font-weight: 900; color: var(--toan-mau); }
.hoi { line-height: 1.2; font-size: clamp(34px, 9vw, 48px); font-weight: 900; color: var(--sai); }
.o-chon.dau-ss { font-size: clamp(54px, 14vw, 74px); }

/* Ghép tiếng */
.ghep-kq { font-size: clamp(90px, 26vw, 140px); line-height: 1; font-weight: 900; color: var(--chu-mau); margin: 4px 0; }
.danh-van { font-size: clamp(18px, 4.6vw, 24px); color: var(--mo); margin-bottom: 12px; }
.ghep-hang { margin: 14px 0; }
.ghep-hang h3 { margin: 0 0 8px; font-size: 18px; color: var(--mo); }
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  min-width: 64px; height: 64px; padding: 0 14px; border-radius: 18px; background: var(--giay); box-shadow: var(--bong);
  font-size: 30px; font-weight: 900;
}
.chip small { display: block; font-size: 12px; margin-top: 2px; color: var(--mo); line-height: 1; }
.chip.chon { background: var(--chu-mau); color: #fff; }
.chip.chon small { color: #fff; }

/* Tiếng Anh */
.luoi-the { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; margin-bottom: 18px; }
.the-tu {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 14px 8px;
  border-radius: 24px; background: var(--giay); box-shadow: var(--bong);
}
.the-tu:active { transform: scale(.95); }
.the-tu .hinh { font-size: 60px; line-height: 1.1; min-height: 66px; display: grid; place-items: center; }
.the-tu b { font-size: 24px; color: var(--anh-mau); }
.the-tu small { font-size: 15px; color: var(--mo); }
.cham-mau { width: 60px; height: 60px; border-radius: 50%; border: 3px solid rgba(0, 0, 0, .12); display: inline-block; }
.o-chon .cham-mau { width: 70px; height: 70px; }
.so-anh { font-size: 54px; font-weight: 900; color: var(--anh-mau); }
.the-tu.dang { outline: 4px solid var(--vang); }

/* Pháo hoa ngôi sao */
.phao { position: fixed; top: -60px; z-index: 30; font-size: 36px; pointer-events: none; animation: roi 2.4s linear forwards; }

@keyframes nay { 0% { transform: scale(1); } 40% { transform: scale(1.12); } 100% { transform: scale(1); } }
@keyframes lac { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }
@keyframes bung { from { transform: scale(.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes tho { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.07); } }
@keyframes roi { to { transform: translateY(110vh) rotate(540deg); } }

@media (max-width: 420px) {
  .o-chon { min-height: 92px; }
  .luoi-chu { grid-template-columns: repeat(4, 1fr); }
  .the-mon { min-height: 140px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ===== Bản 3 tab (18/10/2026) ===== */
main { padding-bottom: 120px; }
.thanh-tab {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: var(--giay); box-shadow: 0 -4px 16px rgba(58, 46, 42, .1);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px 10px; font-size: 15px; font-weight: 900; color: var(--mo); }
.tab span { font-size: 26px; line-height: 1.1; }
.tab.chon { color: var(--chu); }
.tab[data-tab="doc"].chon { box-shadow: inset 0 4px 0 var(--chu-mau); }
.tab[data-tab="toan"].chon { box-shadow: inset 0 4px 0 var(--toan-mau); }
.tab[data-tab="anh"].chon { box-shadow: inset 0 4px 0 var(--anh-mau); }
.the-mon em { font-style: normal; font-size: 15px; background: rgba(255, 255, 255, .25); padding: 3px 10px; border-radius: 999px; margin-top: 4px; }

.nhom-tieu-de { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-size: 21px; margin: 22px 0 10px; }
.nhom-tieu-de small { font-size: 15px; color: var(--mo); font-weight: 700; }
.luoi-bai { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.the-bai {
  position: relative; display: flex; align-items: center; gap: 12px; padding: 12px 14px; min-height: 72px;
  background: var(--giay); border-radius: 20px; box-shadow: var(--bong); text-align: left;
}
.the-bai:active { transform: translateY(3px); }
.so-bai {
  flex: none; min-width: 48px; height: 48px; padding: 0 6px; border-radius: 14px; display: grid; place-items: center;
  background: var(--m, var(--chu-mau)); color: #fff; font-size: 24px; font-weight: 900;
}
.so-bai.to { min-width: 64px; height: 64px; font-size: 32px; background: var(--chu-mau); }
.ten-bai b { display: block; font-size: 18px; line-height: 1.25; }
.ten-bai small { color: var(--mo); font-size: 14px; font-weight: 700; }
.the-bai.xong { background: #eaf8f0; }
.dau-xong { position: absolute; top: 6px; right: 10px; color: var(--dung); font-size: 22px; }

/* Bài đánh vần */
.dau-bai { display: flex; align-items: center; gap: 14px; }
.dau-bai h2 { margin: 0; font-size: clamp(22px, 6vw, 30px); }
.chu-y { margin: 4px 0 0; color: #a0522d; font-size: 16px; }
.luoi-moi, .luoi-tieng, .luoi-tu { display: flex; flex-wrap: wrap; gap: 10px; }
.o-moi, .o-tieng, .o-tu {
  background: var(--giay); box-shadow: var(--bong); border-radius: 18px; font-weight: 900; color: var(--chu);
}
.o-moi { min-width: 74px; height: 74px; padding: 0 14px; font-size: 38px; color: var(--chu-mau); }
.o-moi small { display: block; font-size: 13px; color: var(--mo); }
.o-tieng { min-width: 70px; height: 62px; padding: 0 12px; font-size: 30px; }
.o-tu { height: 56px; padding: 0 18px; font-size: 24px; }
.o-moi:active, .o-tieng:active, .o-tu:active { transform: scale(.95); }
.dang-doc { outline: 4px solid var(--vang) !important; background: #fff8de !important; }
.khung-cau { background: var(--giay); border-radius: 22px; box-shadow: var(--bong); padding: 10px; }
.dong-cau { display: block; width: 100%; text-align: left; padding: 10px 12px; border-radius: 14px; font-size: clamp(20px, 5.2vw, 26px); line-height: 1.4; font-weight: 800; }
.dong-cau + .dong-cau { margin-top: 2px; }
.ten-tho { margin: 12px 12px 4px; font-size: 22px; color: var(--chu-mau); }
.nut.nho { min-height: 40px; padding: 0 14px; font-size: 16px; }
.cuoi-bai { margin-top: 20px; }
.dieu-huong { margin-top: 14px; justify-content: space-between; }
.phu-de {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 7;
  max-width: calc(100% - 32px); padding: 10px 20px; border-radius: 18px; text-align: center;
  background: #3a2e2a; color: #fff; font-size: clamp(22px, 6vw, 32px); font-weight: 900; box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
}
.phu-de small { display: block; font-size: 14px; font-weight: 700; opacity: .8; }
.am-doc { color: var(--mo); font-size: 20px; margin: 4px 0; }
.am-doc b { color: var(--chu-mau); }
.chua-am { color: var(--mo); font-size: 16px; margin: 0; }

/* Trò chơi */
.tien-do { display: flex; gap: 6px; justify-content: center; margin-bottom: 12px; }
.tien-do i { width: 22px; height: 8px; border-radius: 99px; background: #e8dccb; }
.tien-do i.qua { background: var(--dung); }
.tien-do i.nay { background: var(--vang); }
.ket-qua { text-align: center; background: var(--giay); border-radius: 28px; box-shadow: var(--bong); padding: 28px 16px; }
.ba-sao { font-size: 64px; letter-spacing: 6px; }
.ba-sao span { opacity: .2; }
.ket-qua h2 { font-size: 28px; margin: 8px 0; }
.ket-qua p { color: var(--mo); font-size: 18px; }
.chu-tu { font-size: clamp(24px, 6.5vw, 34px); }
.chu-tu.en { color: var(--anh-mau); }
.hinh-chon { font-size: clamp(54px, 15vw, 76px); line-height: 1.1; }
.hinh-hoi { font-size: 110px; line-height: 1.1; }
.hinh-hoi .cham-mau { width: 120px; height: 120px; }
.hinh-hoi .so-anh { font-size: 110px; }
.phep.chu-so { align-items: center; font-size: clamp(46px, 13vw, 72px); font-weight: 900; gap: 10px; }
.cau-chu { font-size: clamp(20px, 5.4vw, 26px); line-height: 1.45; margin: 8px 0 0; }
.hinh-bai { font-size: 34px; letter-spacing: 2px; }
.goi-y { color: var(--mo); font-size: 20px; margin: 10px 0 0; }
.tach { display: inline-flex; flex-direction: column; align-items: center; gap: 10px; }
.tach-tren { font-size: 52px; font-weight: 900; color: var(--toan-mau); border: 4px solid var(--toan-mau); border-radius: 18px; padding: 0 22px; }
.tach-duoi { display: flex; gap: 12px; }
.o-tach { min-width: 110px; padding: 8px; border: 3px dashed #c9b9a6; border-radius: 16px; font-size: 22px; }
.o-tach b { display: block; font-size: 40px; }
.hinh-hoc { width: 84px; height: 84px; }
.dong-ho { width: min(220px, 60vw); height: auto; }
.o-chon.chon-gio { font-size: clamp(26px, 7vw, 36px); }
.khung-que { display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-end; gap: 16px; }
.bo-que, .que-le { display: flex; gap: 3px; align-items: flex-end; position: relative; }
.bo-que i, .que-le i { display: block; width: 7px; height: 70px; border-radius: 4px; background: #e9a23b; }
.bo-que { padding: 0 4px 22px; }
.bo-que::after { content: ''; position: absolute; left: 0; right: 0; top: 30px; height: 8px; background: var(--sai); border-radius: 4px; }
.bo-que span { position: absolute; bottom: 0; left: 0; right: 0; text-align: center; font-size: 14px; color: var(--mo); }

/* Tiếng Anh: câu */
.ds-cau-anh { display: grid; gap: 10px; margin-bottom: 18px; }
.the-cau { display: flex; align-items: center; gap: 14px; padding: 12px 16px; border-radius: 22px; background: var(--giay); box-shadow: var(--bong); text-align: left; }
.the-cau .hinh { font-size: 46px; flex: none; }
.the-cau b { display: block; font-size: clamp(20px, 5.4vw, 26px); color: var(--anh-mau); }
.the-cau small { font-size: 16px; color: var(--mo); }
.the-tu .hinh-chon { font-size: 60px; }
@media (max-width: 420px) {
  .luoi-bai { grid-template-columns: 1fr; }
  .o-tieng { min-width: 62px; height: 56px; font-size: 26px; }
}
.tach { display: flex; max-width: 100%; }
.tach-duoi { flex-wrap: wrap; justify-content: center; max-width: 100%; }
.o-tach { min-width: 0; width: min(150px, 40vw); font-size: 17px; line-height: 1.3; word-break: break-all; }
.hinh-hoi .hinh-chon { font-size: clamp(90px, 28vw, 130px); }
.chu-tu.en { font-size: clamp(18px, 5vw, 30px); word-break: break-word; }

.dong-en { margin: 12px 0 0; font-size: clamp(18px, 4.8vw, 24px); color: var(--anh-mau); font-weight: 800; }

.sao.trang { background: #eef1fb; }
.sao.trang.nay { animation: lac .4s; }
.dem-sao { font-size: 22px !important; color: var(--chu) !important; font-weight: 900; }
@media (max-width: 420px) { .sao { padding: 6px 10px; font-size: 18px; gap: 4px; } .dau { gap: 8px; } }

/* Trò chơi: mê cung */
:root { --tim: #8e24aa; }
.thanh-tab { grid-template-columns: repeat(4, 1fr); }
.tab { font-size: 13px; }
.tab[data-tab="choi"].chon { box-shadow: inset 0 4px 0 var(--tim); }
.mau-choi { background: var(--tim); }
.me-cung { width: min(100%, 520px); height: auto; touch-action: none; border-radius: 12px; background: #fff; display: block; margin: 0 auto; }
.phim-mc { display: grid; grid-template-columns: repeat(3, 72px); gap: 8px; justify-content: center; margin-top: 14px; }
.phim-mc .nut { min-height: 64px; padding: 0; font-size: 30px; }

.dem-sao-mc { margin: -4px 0 8px; font-size: 18px; font-weight: 900; color: #a0522d; }
