/* ===== Toán Vui Tiểu Học - giao diện chính ===== */
:root {
  --bg: #fff8ec; --ink: #2d2a4a; --muted: #6f6b8f; --card: #ffffff; --line: #ece6f7;
  --primary: #7c5cff; --primary-d: #5b3fe0; --orange: #ff7a59; --yellow: #ffc93c; --green: #2bb673; --red: #ef476f; --blue: #3d8bfd; --pink: #ff5fa2;
  --g1: #ff7a59; --g2: #ffb000; --g3: #2bb673; --g4: #3d8bfd; --g5: #7c5cff;
  --radius: 22px; --shadow: 0 10px 30px rgba(76, 52, 160, .12); --font-h: 'Baloo 2', 'Nunito', system-ui, sans-serif; --font: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; font-family: var(--font); color: var(--ink); background: var(--bg); font-size: 17px; line-height: 1.6; -webkit-tap-highlight-color: transparent; overflow-x: hidden; }
body::before { content: ''; position: fixed; inset: 0; z-index: -2; background:
  radial-gradient(circle at 10% 10%, #ffe7c7 0, transparent 35%), radial-gradient(circle at 90% 20%, #e8e1ff 0, transparent 35%),
  radial-gradient(circle at 50% 100%, #d9f7ea 0, transparent 40%); }
a { color: var(--primary-d); }
img { max-width: 100%; }
h1, h2, h3, h4 { font-family: var(--font-h); line-height: 1.2; margin: 0 0 .5em; }
kbd { background: #fff; border: 1px solid #ccc; border-bottom-width: 3px; border-radius: 6px; padding: 0 6px; font-size: .85em; }
.wrap { width: min(1200px, 100% - 32px); margin-inline: auto; }
.section { padding: 28px 0; }
.muted { color: var(--muted); } .small { font-size: .85em; }
.skip { position: absolute; left: -999px; } .skip:focus { left: 10px; top: 10px; z-index: 99; background: #fff; padding: 8px; }
[hidden] { display: none !important; }

/* nền ký hiệu toán bay lơ lửng */
.bg-shapes { position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; }
.bg-shapes span { position: absolute; font-family: var(--font-h); font-weight: 800; font-size: 60px; opacity: .07; color: var(--primary); animation: float 18s ease-in-out infinite; }
.bg-shapes span:nth-child(1) { left: 5%; top: 20%; } .bg-shapes span:nth-child(2) { left: 85%; top: 30%; animation-delay: -3s; color: var(--orange); }
.bg-shapes span:nth-child(3) { left: 20%; top: 75%; animation-delay: -6s; color: var(--green); } .bg-shapes span:nth-child(4) { left: 70%; top: 80%; animation-delay: -9s; }
.bg-shapes span:nth-child(5) { left: 45%; top: 10%; animation-delay: -12s; color: var(--blue); } .bg-shapes span:nth-child(6) { left: 92%; top: 60%; animation-delay: -4s; color: var(--pink); }
.bg-shapes span:nth-child(7) { left: 3%; top: 55%; animation-delay: -7s; color: var(--yellow); } .bg-shapes span:nth-child(8) { left: 60%; top: 45%; animation-delay: -10s; }
@keyframes float { 0%, 100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-40px) rotate(20deg); } }
.bob { animation: bob 3s ease-in-out infinite; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-12px); } }

/* ===== Nút ===== */
.btn { --b: var(--primary); --bd: var(--primary-d); display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; cursor: pointer; text-decoration: none;
  font-family: var(--font-h); font-weight: 700; font-size: 18px; padding: 10px 22px; border-radius: 16px; color: #fff; background: var(--b);
  box-shadow: 0 5px 0 var(--bd); transition: transform .08s, box-shadow .08s, filter .2s; user-select: none; }
.btn:hover { filter: brightness(1.06); } .btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--bd); }
.btn-primary { --b: var(--orange); --bd: #d9573a; }
.btn-white { --b: #fff; --bd: #ddd3f5; color: var(--ink); }
.btn-ghost { --b: transparent; --bd: transparent; color: var(--primary-d); box-shadow: none; }
.btn-sm { font-size: 15px; padding: 6px 14px; border-radius: 12px; box-shadow: 0 3px 0 var(--bd); }
.btn-lg { font-size: 20px; padding: 13px 28px; } .btn-xl { font-size: 26px; padding: 16px 44px; border-radius: 22px; }
.btn-block { width: 100%; }
.icon-btn { width: 42px; height: 42px; border-radius: 50%; border: 0; background: #fff; box-shadow: 0 3px 0 #ddd3f5; font-size: 20px; cursor: pointer; }

/* ===== Header ===== */
.site-header { position: sticky; top: 0; z-index: 50; background: rgba(255, 255, 255, .88); backdrop-filter: blur(10px); border-bottom: 3px solid var(--line); }
.header-inner { display: flex; align-items: center; gap: 16px; min-height: 68px; }
.logo { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); white-space: nowrap; flex: none; }
.header-actions .btn { white-space: nowrap; }
.logo b { display: block; font-family: var(--font-h); font-size: 24px; line-height: 1; color: var(--primary); }
.logo small { display: block; font-family: var(--font-h); font-weight: 700; color: var(--orange); font-size: 15px; line-height: 1.1; }
.main-nav { display: flex; gap: 4px; margin-left: auto; }
.main-nav a { text-decoration: none; color: var(--ink); font-weight: 800; padding: 8px 12px; border-radius: 12px; font-size: 15.5px; white-space: nowrap; }
.main-nav a:hover, .main-nav a.active { background: #f1ecff; color: var(--primary-d); }
.header-actions { display: flex; align-items: center; gap: 8px; }
.nav-toggle { display: none; margin-left: auto; font-size: 26px; background: none; border: 0; cursor: pointer; }
.user-menu { position: relative; }
.user-chip { display: flex; align-items: center; gap: 8px; background: #f6f2ff; border: 0; padding: 4px 12px 4px 4px; border-radius: 99px; cursor: pointer; font: inherit; color: inherit; }
.user-chip .uc-text { display: flex; flex-direction: column; text-align: left; line-height: 1.15; }
.user-chip b { font-size: 14px; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .user-chip small { font-size: 12px; color: var(--muted); }
.avatar { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: #fff; font-size: 22px; box-shadow: 0 2px 0 #e5ddff; flex: none; }
.avatar.big { width: 64px; height: 64px; font-size: 38px; } .avatar.huge { width: 110px; height: 110px; font-size: 68px; }
.menu-pop { position: absolute; right: 0; top: calc(100% + 8px); background: #fff; border-radius: 16px; box-shadow: var(--shadow); padding: 8px; min-width: 200px; display: none; }
.user-menu.open .menu-pop { display: block; }
.menu-pop a, .menu-pop button { display: block; width: 100%; text-align: left; padding: 9px 12px; border-radius: 10px; text-decoration: none; color: var(--ink); font: inherit; font-weight: 700; background: none; border: 0; cursor: pointer; }
.menu-pop a:hover, .menu-pop button:hover { background: #f4f0ff; }
.announce { background: linear-gradient(90deg, var(--yellow), #ffdf7e); font-weight: 800; padding: 8px 0; text-align: center; font-size: 15px; }

/* ===== Hero ===== */
.hero { padding: 36px 0 10px; }
.hero-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 24px; align-items: center; }
.eyebrow { display: inline-block; background: #fff; padding: 4px 14px; border-radius: 99px; font-weight: 800; color: var(--orange); box-shadow: 0 3px 0 #ffe0d4; margin: 0 0 14px; }
.hero h1 { font-size: clamp(34px, 5vw, 58px); margin-bottom: 14px; }
.hl { background: linear-gradient(90deg, var(--primary), var(--pink)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lead { font-size: 19px; color: var(--muted); max-width: 640px; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 14px; margin: 22px 0; }
.hero-stats { display: flex; gap: 14px; list-style: none; padding: 0; margin: 0; flex-wrap: wrap; }
.hero-stats li { background: #fff; border-radius: 18px; padding: 10px 18px; box-shadow: 0 4px 0 var(--line); }
.hero-stats b { display: block; font-family: var(--font-h); font-size: 26px; color: var(--primary); line-height: 1; } .hero-stats span { font-size: 14px; color: var(--muted); font-weight: 700; }
.hero-art { position: relative; display: grid; place-items: center; min-height: 340px; }
.hero-art::before { content: ''; position: absolute; width: 320px; height: 320px; border-radius: 50%; background: radial-gradient(circle, #fff 0, #ffe9c9 60%, transparent 70%); }
.mascot-big { position: relative; width: 300px; }
.bubble { position: absolute; background: #fff; padding: 8px 16px; border-radius: 18px; font-family: var(--font-h); font-weight: 800; font-size: 22px; box-shadow: var(--shadow); animation: bob 4s ease-in-out infinite; }
.b1 { top: 8%; left: 2%; color: var(--orange); } .b2 { top: 12%; right: 4%; color: var(--green); animation-delay: -1s; }
.b3 { bottom: 14%; left: 0; color: var(--primary); animation-delay: -2s; } .b4 { bottom: 8%; right: 6%; color: var(--blue); animation-delay: -3s; }

/* ===== Tiêu đề, chip ===== */
.section-title { font-size: 28px; } .page-title { font-size: clamp(30px, 4vw, 44px); }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.link-more { font-weight: 800; text-decoration: none; }
.breadcrumb { font-size: 14px; color: var(--muted); margin-bottom: 8px; } .breadcrumb a { color: var(--muted); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0 20px; }
.chip { border: 0; cursor: pointer; text-decoration: none; background: #fff; color: var(--ink); font: inherit; font-weight: 800; padding: 7px 16px; border-radius: 99px; box-shadow: 0 3px 0 var(--line); }
.chip.on { background: var(--primary); color: #fff; box-shadow: 0 3px 0 var(--primary-d); }
.sticky-chips { position: sticky; top: 72px; z-index: 5; background: var(--bg); padding: 8px 0; }

/* ===== Lớp ===== */
.grade-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; }
.grade-grid.n4 { grid-template-columns: repeat(4, 1fr); } .grade-grid.n3 { grid-template-columns: repeat(3, 1fr); }
.grade-card { --c: var(--primary); text-decoration: none; color: #fff; background: var(--c); border-radius: var(--radius); padding: 18px; text-align: center; box-shadow: 0 7px 0 rgba(0, 0, 0, .15); transition: transform .15s; }
.grade-card:hover { transform: translateY(-5px) rotate(-1deg); }
.grade-card .gr-emoji { font-size: 44px; display: block; } .grade-card b { display: block; font-family: var(--font-h); font-size: 28px; line-height: 1.1; } .grade-card small { font-weight: 700; opacity: .9; }

/* ===== Thẻ trò chơi ===== */
.game-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 16px; }
.game-card { --c: var(--primary); position: relative; display: flex; gap: 14px; align-items: center; text-decoration: none; color: var(--ink); background: #fff; border-radius: var(--radius);
  padding: 16px; box-shadow: 0 6px 0 color-mix(in srgb, var(--c) 35%, #fff); border: 3px solid color-mix(in srgb, var(--c) 25%, #fff); transition: transform .15s; overflow: hidden; }
.game-card:hover { transform: translateY(-4px); }
.gc-icon { flex: none; display: grid; place-items: center; width: 70px; height: 70px; border-radius: 20px; font-size: 40px; background: color-mix(in srgb, var(--c) 18%, #fff); }
.gc-body { flex: 1; min-width: 0; } .gc-body strong { display: block; font-family: var(--font-h); font-size: 20px; line-height: 1.2; }
.gc-body small { display: block; color: var(--muted); font-size: 14px; line-height: 1.35; margin: 2px 0 6px; }
.gc-tags i { font-style: normal; font-size: 12px; font-weight: 800; background: color-mix(in srgb, var(--c) 15%, #fff); color: color-mix(in srgb, var(--c) 70%, #000); padding: 1px 7px; border-radius: 8px; margin-right: 4px; }
.gc-play { flex: none; width: 40px; height: 40px; border-radius: 50%; background: var(--c); color: #fff; display: grid; place-items: center; font-size: 16px; }

/* ===== Panel ===== */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.panel { background: #fff; border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.tour-row { --c: var(--orange); display: block; text-decoration: none; color: var(--ink); border-left: 6px solid var(--c); background: color-mix(in srgb, var(--c) 8%, #fff); padding: 12px 14px; border-radius: 14px; margin-bottom: 10px; }
.tour-row b { display: block; font-family: var(--font-h); font-size: 19px; } .tour-row small { display: block; color: var(--muted); }
.prize { color: #b26b00 !important; font-weight: 800; }
.tr-badge { display: inline-block; font-size: 12px; font-weight: 800; padding: 2px 10px; border-radius: 99px; background: #ddd; color: #fff; }
.tr-badge.live { background: var(--green); } .tr-badge.upcoming { background: var(--blue); } .tr-badge.ended { background: #9a96b5; }
.mini-board { list-style: none; padding: 0; margin: 0; }
.mini-board li { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 2px dashed var(--line); }
.mini-board b { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .mini-board small { color: var(--muted); } .mini-board em { font-style: normal; font-weight: 800; color: var(--primary); }
.rank { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: #efeaff; font-weight: 800; font-size: 14px; flex: none; }
.rank.r1 { background: #ffd34d; } .rank.r2 { background: #d9dde8; } .rank.r3 { background: #f2b48a; }
.feature-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.feature { --c: var(--primary); text-decoration: none; color: var(--ink); background: #fff; border-radius: var(--radius); padding: 20px; box-shadow: 0 6px 0 color-mix(in srgb, var(--c) 30%, #fff); border-top: 6px solid var(--c); }
.feature span { font-size: 40px; } .feature b { display: block; font-family: var(--font-h); font-size: 21px; } .feature p { margin: 4px 0 0; color: var(--muted); font-size: 15px; }
.seo-text { color: var(--muted); } .seo-text h2 { color: var(--ink); font-size: 24px; }
.empty { background: #fff; border-radius: var(--radius); padding: 26px; text-align: center; font-weight: 700; box-shadow: var(--shadow); margin: 12px 0; }

/* ===== Trang lớp & bài học ===== */
.grade-hero { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.lesson-list { list-style: none; padding: 0; margin: 0; }
.lesson-list a { display: block; padding: 10px 12px; border-radius: 14px; text-decoration: none; color: var(--ink); } .lesson-list a:hover { background: #f6f2ff; }
.lesson-list b { display: block; } .lesson-list small { color: var(--muted); }
.grade-label { display: inline-block; color: #fff; padding: 2px 16px; border-radius: 14px; background: var(--primary); }
.g1.grade-label, .lesson-head.g1 { background: var(--g1); } .g2.grade-label, .lesson-head.g2 { background: var(--g2); } .g3.grade-label, .lesson-head.g3 { background: var(--g3); }
.g4.grade-label, .lesson-head.g4 { background: var(--g4); } .g5.grade-label, .lesson-head.g5 { background: var(--g5); }
.lesson-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; margin-bottom: 26px; }
.lesson-card { display: block; text-decoration: none; color: var(--ink); background: #fff; padding: 18px; border-radius: var(--radius); box-shadow: var(--shadow); border-bottom: 6px solid var(--primary); transition: transform .15s; }
.lesson-card:hover { transform: translateY(-4px); }
.lesson-card.g1 { border-color: var(--g1); } .lesson-card.g2 { border-color: var(--g2); } .lesson-card.g3 { border-color: var(--g3); } .lesson-card.g4 { border-color: var(--g4); } .lesson-card.g5 { border-color: var(--g5); }
.lesson-card b { display: block; font-family: var(--font-h); font-size: 20px; line-height: 1.25; margin: 4px 0; } .lesson-card small { color: var(--muted); }
.lc-topic { display: inline-block; font-size: 13px; font-weight: 800; background: rgba(0, 0, 0, .07); padding: 2px 10px; border-radius: 99px; }
.lesson { max-width: 1000px; margin: 0 auto; }
.lesson-head { color: #fff; border-radius: 28px; padding: 28px; background: var(--primary); box-shadow: var(--shadow); }
.lesson-head h1 { font-size: clamp(28px, 4vw, 40px); margin: 8px 0; } .lesson-head p { margin: 0 0 14px; font-size: 18px; opacity: .95; }
.lesson-head .lc-topic { background: rgba(255, 255, 255, .25); }
.lesson-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.lesson-tabs { position: sticky; top: 70px; z-index: 5; display: flex; gap: 8px; overflow-x: auto; padding: 12px 0; background: var(--bg); }
.lesson-tabs a { flex: none; background: #fff; padding: 8px 16px; border-radius: 99px; text-decoration: none; font-weight: 800; color: var(--ink); box-shadow: 0 3px 0 var(--line); }
.lesson-sec { background: #fff; border-radius: var(--radius); padding: 24px; margin: 16px 0; box-shadow: var(--shadow); scroll-margin-top: 130px; }
.lesson-sec h2 { font-size: 28px; }
.remember-list { list-style: none; padding: 0; margin: 0; }
.remember-list li { position: relative; padding: 10px 14px 10px 46px; margin-bottom: 8px; background: #fffbea; border-radius: 14px; font-size: 18px; }
.remember-list li::before { content: '⭐'; position: absolute; left: 14px; top: 9px; }
.formula-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 380px), 1fr)); gap: 14px; }
.formula-card { background: linear-gradient(135deg, #f3efff, #fff); border: 3px solid #e2d9ff; border-radius: 20px; padding: 16px; }
.formula-card h4 { color: var(--primary-d); font-size: 19px; margin: 0; }
.formula-card .tex { font-size: 1.12em; overflow-x: auto; overflow-y: hidden; padding: 4px 0; }
.formula-card p { margin: 0; color: var(--muted); font-size: 15px; }
.formula-book h3 { margin-top: 18px; } .formula-book h3 a { text-decoration: none; }
.method { border: 3px dashed #ffd9cb; border-radius: 20px; padding: 18px; margin-bottom: 16px; background: #fffaf7; }
.method h4 { font-size: 21px; color: var(--orange); }
.cta-box { display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; background: linear-gradient(90deg, #fff1c9, #ffe2d6); padding: 20px 24px; border-radius: var(--radius); font-family: var(--font-h); font-size: 22px; margin: 20px 0; }
.prose h2 { margin-top: 1em; } .prose li { margin-bottom: 4px; }

/* ===== Hình động (anim.js) ===== */
.anim { position: relative; background: #fff; border-radius: 18px; padding: 16px; margin-top: 10px; border: 2px solid var(--line); min-height: 120px; overflow-x: auto; }
.anim-stage { display: flex; justify-content: center; align-items: center; min-height: 140px; }
.anim-caption { text-align: center; font-weight: 800; font-size: 18px; min-height: 30px; color: var(--primary-d); margin-top: 10px; }
.anim-ctrl { display: flex; justify-content: center; gap: 8px; margin-top: 8px; }
.anim-ctrl button { border: 0; background: #f1ecff; color: var(--primary-d); font: inherit; font-weight: 800; padding: 6px 14px; border-radius: 12px; cursor: pointer; }
.col-calc { font-family: 'Courier New', monospace; font-size: 34px; font-weight: 700; display: inline-grid; gap: 2px; }
.col-calc .row { display: flex; justify-content: flex-end; } .col-calc .cell { width: 1.1ch; text-align: center; position: relative; }
.col-calc .op { position: absolute; left: -1.6ch; } .col-calc .line { border-top: 4px solid var(--ink); margin: 2px 0; }
.col-calc .carry { font-size: 18px; color: var(--red); height: 24px; } .col-calc .hl { background: #fff1a8; border-radius: 6px; }
.col-calc .res .cell { color: var(--primary-d); } .pop-in { animation: popin .4s ease; }
@keyframes popin { 0% { transform: scale(0); } 70% { transform: scale(1.3); } 100% { transform: scale(1); } }
.dotgrid { display: inline-grid; gap: 8px; } .dot { width: 26px; height: 26px; border-radius: 50%; background: var(--orange); }
.dot.ghost { background: #eee; } .dot.on { animation: popin .3s ease; }
.groupbox { display: inline-flex; flex-wrap: wrap; gap: 6px; padding: 8px; border: 3px dashed var(--primary); border-radius: 14px; margin: 4px; min-width: 50px; min-height: 46px; vertical-align: top; }
.anim-steps { text-align: left; font-size: 19px; font-weight: 700; margin: 0; padding-left: 26px; max-width: 760px; }
.anim-steps li { margin: 6px 0; padding: 6px 10px; border-radius: 10px; background: #f8fafc; }
.unit-ladder { display: flex; align-items: flex-end; gap: 4px; flex-wrap: wrap; justify-content: center; }
.unit-ladder .step { background: var(--primary); color: #fff; font-weight: 800; padding: 8px 10px; border-radius: 10px 10px 0 0; min-width: 56px; text-align: center; transition: all .4s; }
.unit-ladder .arrow { font-size: 13px; color: var(--muted); font-weight: 800; align-self: center; }

/* ===== Sơ đồ tư duy ===== */
.mindmap { position: relative; background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); height: 460px; overflow: hidden; touch-action: none; cursor: grab; }
.mindmap-big { height: min(75vh, 720px); }
.mindmap svg { width: 100%; height: 100%; display: block; }
.mindmap .mm-node { cursor: pointer; } .mindmap .mm-node text { font-family: var(--font); font-weight: 800; pointer-events: none; }
.mm-tools { position: absolute; right: 10px; top: 10px; display: flex; gap: 6px; z-index: 2; }
.mm-tools button { width: 38px; height: 38px; border-radius: 12px; border: 0; background: #f1ecff; font-size: 18px; font-weight: 800; cursor: pointer; }

/* ===== Bảng xếp hạng ===== */
.filters { display: flex; flex-wrap: wrap; gap: 4px 20px; align-items: center; }
.game-filter select, .form select, .form input, .form textarea { font: inherit; padding: 10px 14px; border-radius: 14px; border: 3px solid var(--line); background: #fff; width: 100%; }
.game-filter select { width: auto; }
.board { width: 100%; border-collapse: separate; border-spacing: 0 6px; }
.board th { text-align: left; font-size: 14px; color: var(--muted); padding: 4px 12px; }
.board td { background: #fff; padding: 10px 12px; } .board td:first-child { border-radius: 14px 0 0 14px; } .board td:last-child { border-radius: 0 14px 14px 0; }
.board tr.me td { background: #fff3c4; }
.board.compact td { padding: 6px 10px; background: #faf8ff; }
.podium { display: flex; justify-content: center; align-items: flex-end; gap: 14px; margin: 20px 0; }
.pod { display: flex; flex-direction: column; align-items: center; text-align: center; width: 160px; }
.pod b { font-family: var(--font-h); font-size: 18px; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .pod em { font-style: normal; font-weight: 800; color: var(--primary); }
.pod-base { width: 100%; margin-top: 6px; border-radius: 16px 16px 0 0; display: grid; place-items: center; font-size: 40px; background: linear-gradient(#ffe27a, #ffc93c); }
.pod1 .pod-base { height: 130px; } .pod2 .pod-base { height: 95px; background: linear-gradient(#eef0f6, #cfd4e2); } .pod3 .pod-base { height: 70px; background: linear-gradient(#ffd8bf, #f2b48a); }
.me-rank { background: #fff3c4; padding: 12px 18px; border-radius: 16px; font-weight: 700; margin: 10px 0; }

/* ===== Giải đấu ===== */
.tour-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.tour-card { --c: var(--orange); position: relative; display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: var(--ink); background: #fff; border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); border-top: 8px solid var(--c); }
.tour-card.ended { opacity: .75; } .tour-card b { font-family: var(--font-h); font-size: 22px; } .tour-card small { color: var(--muted); }
.tc-icon { position: absolute; right: 16px; top: 14px; font-size: 40px; }
.tour-head { --c: var(--orange); display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; background: linear-gradient(135deg, var(--c), color-mix(in srgb, var(--c) 60%, #7c5cff)); color: #fff; border-radius: 28px; padding: 28px; margin-bottom: 20px; }
.tour-head h1 { font-size: clamp(28px, 4vw, 42px); margin: 8px 0; } .tour-meta { list-style: none; padding: 0; margin: 0; }
.countdown { align-self: flex-start; background: rgba(255, 255, 255, .2); border-radius: 18px; padding: 14px 20px; font-weight: 700; } .countdown b { display: block; font-family: var(--font-h); font-size: 28px; }
.attempts { font-weight: 700; }

/* ===== Tài khoản ===== */
.auth-wrap { display: grid; place-items: center; }
.auth-card { width: min(460px, 100%); background: #fff; border-radius: 28px; padding: 30px; box-shadow: var(--shadow); text-align: center; }
.auth-card.wide { width: min(680px, 100%); }
.auth-mascot { margin-top: -80px; }
.form { display: grid; gap: 14px; text-align: left; }
.form label { display: grid; gap: 4px; font-weight: 800; font-size: 15px; }
.form input:focus, .form select:focus, .form textarea:focus { outline: none; border-color: var(--primary); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pw { position: relative; display: block; } .pw-eye { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); border: 0; background: none; font-size: 18px; cursor: pointer; }
.auth-alt { margin-top: 16px; font-weight: 700; }
.alert { padding: 12px 16px; border-radius: 14px; font-weight: 700; margin: 10px 0; }
.alert-error { background: #ffe3e8; color: #b0213f; } .alert-ok { background: #ddf7ea; color: #137a4b; }
.avatar-pick { border: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.avatar-pick legend { font-weight: 800; margin-bottom: 6px; width: 100%; text-align: center; }
.avatar-pick label { cursor: pointer; } .avatar-pick input { position: absolute; opacity: 0; }
.avatar-pick span { display: grid; place-items: center; width: 52px; height: 52px; font-size: 32px; border-radius: 16px; background: #f6f2ff; border: 3px solid transparent; transition: transform .1s; }
.avatar-pick input:checked + span { border-color: var(--primary); background: #fff; transform: scale(1.12); }
.avatar-pick input:focus-visible + span { outline: 3px solid var(--orange); }
.avatar-pick.small span { width: 42px; height: 42px; font-size: 26px; }

/* ===== Hồ sơ ===== */
.profile-head { display: flex; gap: 24px; align-items: center; flex-wrap: wrap; background: #fff; border-radius: 28px; padding: 24px; box-shadow: var(--shadow); }
.ph-info { flex: 1; min-width: 240px; } .ph-info h1 { margin: 0; font-size: 34px; } .ph-info p { margin: 0 0 8px; color: var(--muted); }
.level-box b { color: var(--primary-d); } .level-box small { color: var(--muted); }
.xpbar { height: 16px; background: #efeaff; border-radius: 99px; overflow: hidden; margin: 6px 0; }
.xpbar span { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), var(--pink)); border-radius: 99px; }
.ph-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.ph-stats div { background: #f8f6ff; border-radius: 16px; padding: 10px 16px; text-align: center; } .ph-stats b { display: block; font-family: var(--font-h); font-size: 26px; } .ph-stats small { color: var(--muted); font-weight: 700; }
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.badge { background: #fff; border-radius: 18px; padding: 14px; text-align: center; box-shadow: var(--shadow); filter: grayscale(1); opacity: .5; }
.badge.got { filter: none; opacity: 1; border: 3px solid #ffd34d; }
.badge span { font-size: 38px; display: block; } .badge b { display: block; } .badge small { color: var(--muted); font-size: 13px; }
.recent { list-style: none; padding: 0; margin: 0; }
.recent li { display: grid; grid-template-columns: auto 1fr auto; grid-template-rows: auto auto; column-gap: 10px; padding: 8px 0; border-bottom: 2px dashed var(--line); }
.recent li span { grid-row: span 2; font-size: 26px; } .recent small { color: var(--muted); grid-column: 2; } .recent em { grid-row: 1 / span 2; grid-column: 3; align-self: center; font-style: normal; font-weight: 800; color: var(--primary); }

/* ===== Footer ===== */
.site-footer { margin-top: 40px; background: #2d2a4a; color: #d8d4f0; padding: 36px 0 20px; }
.site-footer a { color: #fff; text-decoration: none; } .site-footer a:hover { text-decoration: underline; }
.site-footer .logo b { color: #fff; }
.footer-grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: 20px; }
.footer-grid h3 { color: #fff; font-size: 18px; } .footer-grid ul { list-style: none; padding: 0; margin: 0; } .footer-grid li { margin-bottom: 6px; }
.footer-bottom { border-top: 1px solid #45406b; margin-top: 20px; padding-top: 14px; font-size: 14px; text-align: center; }
.error-page { text-align: center; }

/* ===== Sân chơi (game stage) ===== */
.stage { --c: var(--primary); position: relative; background: #fff; border-radius: 30px; box-shadow: 0 10px 0 color-mix(in srgb, var(--c) 30%, #fff), var(--shadow);
  border: 4px solid color-mix(in srgb, var(--c) 30%, #fff); min-height: 520px; overflow: hidden; margin: 10px 0 20px; scroll-margin-top: 90px; }
.stage:fullscreen { border-radius: 0; overflow-y: auto; display: flex; flex-direction: column; justify-content: center; }
.stage-screen { padding: 24px; }
.stage-start { text-align: center; background: radial-gradient(circle at 50% 0, color-mix(in srgb, var(--c) 18%, #fff), #fff 60%); min-height: 520px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.start-icon { font-size: 90px; line-height: 1; } .stage-start h2 { font-size: 34px; margin: 8px 0 0; } .start-desc { color: var(--muted); font-size: 18px; }
.grade-pick { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin: 8px 0 14px; }
.gp { border: 3px solid var(--line); background: #fff; font: inherit; font-weight: 800; padding: 8px 18px; border-radius: 14px; cursor: pointer; }
.gp.on { border-color: var(--c); background: var(--c); color: #fff; }
.start-rules { list-style: none; padding: 0; margin: 0 0 18px; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.start-rules li { background: #f8f6ff; padding: 6px 14px; border-radius: 12px; font-size: 15px; }
.guest-note { background: #fff6d8; padding: 8px 14px; border-radius: 12px; font-size: 15px; }
.stage-fs { position: absolute; right: 12px; bottom: 12px; border: 0; background: rgba(0, 0, 0, .06); width: 40px; height: 40px; border-radius: 12px; font-size: 20px; cursor: pointer; z-index: 5; }

.hud { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.hud-item { background: #f8f6ff; padding: 6px 14px; border-radius: 14px; font-weight: 800; font-size: 16px; white-space: nowrap; }
.hud-item b { font-family: var(--font-h); font-size: 20px; color: var(--primary-d); }
.hud .hud-quit { margin-left: auto; border: 0; background: #ffe3e8; color: #b0213f; font: inherit; font-weight: 800; padding: 6px 14px; border-radius: 14px; cursor: pointer; }
.timer { height: 14px; background: #f0ecfb; border-radius: 99px; overflow: hidden; margin-bottom: 16px; }
.timer span { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, var(--green), var(--yellow)); border-radius: 99px; transform-origin: left; }
.timer.warn span { background: linear-gradient(90deg, var(--orange), var(--red)); }
.progress-dots { display: flex; gap: 4px; flex-wrap: wrap; }
.progress-dots i { width: 12px; height: 12px; border-radius: 50%; background: #e6e1f5; } .progress-dots i.ok { background: var(--green); } .progress-dots i.no { background: var(--red); } .progress-dots i.cur { background: var(--yellow); transform: scale(1.3); }

.q-card { text-align: center; padding: 10px; }
.q-prompt { font-family: var(--font-h); font-weight: 800; font-size: clamp(26px, 4.5vw, 46px); line-height: 1.25; margin: 6px 0 16px; word-break: break-word; }
.q-prompt.long { font-size: clamp(19px, 2.6vw, 26px); font-family: var(--font); font-weight: 700; text-align: left; max-width: 820px; margin-inline: auto; }
.q-visual { display: flex; justify-content: center; margin: 4px 0 14px; }
.choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; max-width: 760px; margin: 0 auto; }
.choices.three { grid-template-columns: repeat(3, minmax(0, 1fr)); max-width: 560px; }
.choice { position: relative; border: 0; cursor: pointer; font-family: var(--font-h); font-weight: 800; font-size: clamp(22px, 3vw, 32px); padding: 16px 10px; border-radius: 20px; color: #fff;
  background: var(--cc, var(--primary)); box-shadow: 0 7px 0 rgba(0, 0, 0, .2); transition: transform .08s; min-height: 74px; }
.choice:nth-child(1) { --cc: #7c5cff; } .choice:nth-child(2) { --cc: #ff7a59; } .choice:nth-child(3) { --cc: #2bb673; } .choice:nth-child(4) { --cc: #3d8bfd; }
.choice:hover { transform: translateY(-3px); } .choice:active { transform: translateY(4px); box-shadow: 0 2px 0 rgba(0, 0, 0, .2); }
.choice .k { position: absolute; left: 10px; top: 6px; font-size: 13px; opacity: .7; font-family: var(--font); }
.choice.right { --cc: #2bb673 !important; animation: pulse .5s; } .choice.wrong { --cc: #ef476f !important; animation: shake .4s; } .choice.dim { opacity: .45; }
.choice[disabled] { cursor: default; }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }
@keyframes pulse { 50% { transform: scale(1.07); } }
.choices.sign .choice { font-size: 46px; }
.choices.tf .choice:nth-child(1) { --cc: #2bb673; } .choices.tf .choice:nth-child(2) { --cc: #ef476f; }

.input-area { max-width: 420px; margin: 0 auto; }
.answer-box { display: flex; align-items: center; justify-content: center; gap: 8px; font-family: var(--font-h); font-size: 40px; font-weight: 800; background: #f8f6ff; border: 4px solid var(--c);
  border-radius: 20px; min-height: 76px; padding: 4px 16px; margin-bottom: 12px; }
.answer-box .val { min-width: 1ch; } .answer-box .caret { width: 3px; height: 40px; background: var(--c); animation: blink 1s steps(2) infinite; } .answer-box .unit { font-size: 22px; color: var(--muted); }
@keyframes blink { 50% { opacity: 0; } }
.keypad { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.keypad button { border: 0; cursor: pointer; font-family: var(--font-h); font-weight: 800; font-size: 26px; padding: 10px; border-radius: 16px; background: #fff; box-shadow: 0 5px 0 #ddd3f5; border: 2px solid #ece6f7; }
.keypad button:active { transform: translateY(3px); box-shadow: 0 2px 0 #ddd3f5; }
.keypad .ok { grid-column: span 2; background: var(--green); color: #fff; box-shadow: 0 5px 0 #1e8d58; border-color: transparent; }
.keypad .del { background: #ffe3e8; }

.feedback { margin: 16px auto 0; max-width: 760px; border-radius: 18px; padding: 12px 18px; font-weight: 700; display: flex; gap: 12px; align-items: center; text-align: left; animation: popin .3s; }
.feedback.ok { background: #ddf7ea; color: #137a4b; } .feedback.no { background: #ffe3e8; color: #9b1c38; }
.feedback .fb-icon { font-size: 34px; } .feedback .fb-text { flex: 1; } .feedback .fb-pts { font-family: var(--font-h); font-size: 24px; }
.feedback .btn { flex: none; }
.float-score { position: absolute; font-family: var(--font-h); font-weight: 800; font-size: 34px; color: var(--green); pointer-events: none; animation: floatup 1s ease-out forwards; z-index: 20; }
@keyframes floatup { to { transform: translateY(-80px); opacity: 0; } }
.combo-badge { position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%); font-family: var(--font-h); font-weight: 800; font-size: 48px; color: var(--orange); text-shadow: 0 4px 0 #fff; animation: comboPop 1s forwards; pointer-events: none; z-index: 20; }
@keyframes comboPop { 0% { transform: translate(-50%, -50%) scale(.3); opacity: 0; } 30% { transform: translate(-50%, -50%) scale(1.2); opacity: 1; } 100% { transform: translate(-50%, -120%) scale(1); opacity: 0; } }

/* Đua xe */
.race-track { position: relative; background: repeating-linear-gradient(90deg, #6b6b80 0 40px, #75758a 40px 80px); border-radius: 18px; padding: 10px 60px 10px 10px; margin-bottom: 14px; }
.lane { position: relative; height: 64px; border-bottom: 3px dashed rgba(255, 255, 255, .6); } .lane:last-child { border-bottom: 0; }
.car { position: absolute; left: 0; top: 50%; transform: translateY(-50%) scaleX(-1); font-size: 42px; transition: left .6s cubic-bezier(.3, 1.4, .5, 1); }
.car .name { position: absolute; top: -2px; left: 50%; transform: translateX(-50%) scaleX(-1); font-size: 11px; color: #fff; font-weight: 800; white-space: nowrap; }
.finish { position: absolute; right: 10px; top: 0; bottom: 0; width: 34px; background: repeating-conic-gradient(#fff 0 25%, #222 0 50%) 0 0 / 17px 17px; border-radius: 4px; }

/* Bóng bay */
.sky { position: relative; height: 380px; border-radius: 20px; background: linear-gradient(#bfe6ff, #eaf7ff); overflow: hidden; margin-top: 10px; }
.balloon { position: absolute; bottom: -20px; width: 104px; height: 128px; border: 0; cursor: pointer; background: none; padding: 0; }
.balloon .bb { position: absolute; inset: 0 0 18px; border-radius: 50% 50% 48% 48%; background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, .6), transparent 30%), var(--bc); display: grid; place-items: center;
  font-family: var(--font-h); font-weight: 800; color: #fff; font-size: 24px; text-shadow: 0 2px 0 rgba(0, 0, 0, .2); padding: 6px; line-height: 1.05; word-break: break-word; }
.balloon::after { content: ''; position: absolute; left: 50%; bottom: 0; width: 2px; height: 22px; background: #888; }
.balloon.pop .bb { animation: popb .3s forwards; } @keyframes popb { to { transform: scale(1.6); opacity: 0; } }
.balloon.wrongb .bb { filter: grayscale(1); }
.cloud { position: absolute; font-size: 60px; opacity: .8; animation: drift 30s linear infinite; } @keyframes drift { from { left: -100px; } to { left: 110%; } }
.lives { letter-spacing: 2px; }

/* Lật thẻ */
.memory { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; max-width: 760px; margin: 0 auto; perspective: 900px; }
.mcard { position: relative; aspect-ratio: 4 / 3; border: 0; padding: 0; background: none; cursor: pointer; transform-style: preserve-3d; transition: transform .4s; }
.mcard.flip, .mcard.done { transform: rotateY(180deg); }
.mcard .f, .mcard .b { position: absolute; inset: 0; border-radius: 16px; display: grid; place-items: center; backface-visibility: hidden; font-family: var(--font-h); font-weight: 800; }
.mcard .f { background: linear-gradient(135deg, var(--primary), var(--pink)); color: #fff; font-size: 34px; box-shadow: 0 5px 0 var(--primary-d); }
.mcard .b { background: #fff; border: 3px solid var(--line); transform: rotateY(180deg); font-size: clamp(15px, 2.4vw, 24px); padding: 4px; }
.mcard.done .b { background: #ddf7ea; border-color: var(--green); } .mcard.bad .b { background: #ffe3e8; border-color: var(--red); }

/* Hình ảnh câu hỏi (visuals.js) */
.v-compare { display: flex; align-items: center; gap: 18px; font-family: var(--font-h); font-weight: 800; font-size: clamp(30px, 5vw, 52px); }
.v-compare .slot { min-width: 90px; height: 90px; border-radius: 22px; border: 4px dashed var(--c); display: grid; place-items: center; font-size: 54px; color: var(--c); }
.v-compare .side { background: #f8f6ff; border-radius: 20px; padding: 8px 20px; }
.v-count { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; max-width: 700px; }
.v-count .grp { display: flex; flex-wrap: wrap; gap: 4px; max-width: 260px; justify-content: center; font-size: 34px; line-height: 1.1; }
.v-count .grp.box { border: 3px dashed var(--c); border-radius: 16px; padding: 6px; }
.v-count .crossed { position: relative; opacity: .5; } .v-count .crossed::after { content: '✕'; position: absolute; inset: 0; color: var(--red); font-size: 34px; text-align: center; }
.frac { display: inline-flex; flex-direction: column; align-items: center; vertical-align: middle; line-height: 1; margin: 0 .12em; font-size: .82em; }
.frac > span:first-child { border-bottom: .09em solid currentColor; padding: 0 .12em .06em; } .frac > span:last-child { padding: .06em .12em 0; }
.mixed { display: inline-flex; align-items: center; }

/* Kết quả */
.result { text-align: center; }
.result .stars { font-size: 64px; letter-spacing: 6px; } .result .stars i { display: inline-block; font-style: normal; opacity: .2; filter: grayscale(1); }
.result .stars i.on { opacity: 1; filter: none; animation: popin .5s backwards; } .result .stars i.on:nth-child(2) { animation-delay: .3s; } .result .stars i.on:nth-child(3) { animation-delay: .6s; }
.result h2 { font-size: 40px; margin: 0; } .result .big-score { font-family: var(--font-h); font-weight: 800; font-size: 64px; color: var(--primary); line-height: 1; }
.result-stats { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 16px 0; }
.result-stats div { background: #f8f6ff; border-radius: 16px; padding: 10px 18px; min-width: 120px; } .result-stats b { display: block; font-family: var(--font-h); font-size: 26px; } .result-stats small { color: var(--muted); font-weight: 700; }
.result-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin: 14px 0; }
.levelup { background: linear-gradient(90deg, #fff1c9, #ffe2d6); padding: 10px; border-radius: 16px; font-weight: 800; font-size: 20px; animation: popin .5s; }
.review { text-align: left; max-width: 800px; margin: 16px auto 0; }
.review summary { cursor: pointer; font-weight: 800; font-size: 18px; text-align: center; }
.review ol { padding-left: 24px; } .review li { margin: 8px 0; padding: 8px 12px; border-radius: 12px; background: #f8f6ff; }
.review li.ok { border-left: 5px solid var(--green); } .review li.no { border-left: 5px solid var(--red); }
.review .rv-q { font-weight: 800; } .review small { display: block; color: var(--muted); }
.confetti { position: fixed; top: -20px; width: 10px; height: 16px; z-index: 100; pointer-events: none; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

/* ===== Responsive ===== */
@media (max-width: 1080px) {
  .main-nav { display: none; position: absolute; left: 0; right: 0; top: 100%; background: #fff; flex-direction: column; padding: 10px 16px 16px; box-shadow: var(--shadow); }
  .main-nav.open { display: flex; } .nav-toggle { display: block; } .header-actions { margin-left: 0; }
  .feature-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 820px) {
  body { font-size: 16px; }
  .hero-grid, .two-col, .footer-grid { grid-template-columns: 1fr; }
  .hero-art { min-height: 240px; order: -1; } .mascot-big { width: 200px; } .hero-art::before { width: 220px; height: 220px; } .bubble { font-size: 16px; }
  .grade-grid { grid-template-columns: repeat(3, 1fr); }
  .user-chip .uc-text { display: none; } .user-chip { padding: 4px; }
  .form-row { grid-template-columns: 1fr; }
  .stage-screen { padding: 14px; } .stage { min-height: 460px; border-radius: 22px; } .stage-start { min-height: 460px; }
  .memory { grid-template-columns: repeat(3, 1fr); }
  .sky { height: 340px; } .balloon { width: 84px; height: 108px; } .balloon .bb { font-size: 18px; }
  .board th:nth-child(4), .board td:nth-child(4) { display: none; }
  .pod { width: 110px; }
}
@media (max-width: 480px) {
  .grade-grid, .grade-grid.n4 { grid-template-columns: repeat(2, 1fr); } .grade-grid.n3 { grid-template-columns: 1fr; } .feature-grid { grid-template-columns: 1fr; }
  .header-actions .btn-ghost { display: none; } .logo small { display: none; }
  .header-inner { gap: 8px; } .logo b { font-size: 20px; } .logo img { width: 38px; height: 38px; }
  .header-actions .btn-sm { padding: 6px 10px; font-size: 14px; }
  .choices { gap: 10px; } .choice { min-height: 64px; padding: 12px 6px; }
  .keypad button { font-size: 22px; padding: 8px; }
  .race-track { padding-right: 44px; } .car { font-size: 34px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
@media print {
  .site-header, .site-footer, .chips, .bg-shapes, .announce { display: none !important; }
  body { background: #fff; } .formula-card { break-inside: avoid; }
}
