:root {
  --bg: #eef7ff;
  --card: #ffffff;
  --ink: #1f2a44;
  --muted: #62708c;
  --line: #e3e9f4;
  --primary: #4f7cff;
  --primary-dark: #3557d6;
  --sun: #ffb020;
  --good: #22c55e;
  --good-bg: #dcfce7;
  --bad: #ef4444;
  --bad-bg: #fee2e2;
  --radius: 20px;
  --shadow: 0 6px 0 rgba(31, 42, 68, .06), 0 10px 30px rgba(31, 42, 68, .08);
  font-size: 17px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: 'Baloo 2', 'Segoe UI', system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--bg);
  background-image: radial-gradient(#d6e8ff 1.5px, transparent 1.5px);
  background-size: 26px 26px;
  line-height: 1.5;
  min-height: 100vh;
}
a { color: var(--primary-dark); text-decoration: none; }
h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h4 { font-size: 1.1rem; margin-top: 1.1em; color: var(--primary-dark); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.center { text-align: center; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ---------- Thanh trên ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 24px; background: #fff; border-bottom: 3px solid var(--line);
}
.logo { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.35rem; color: var(--ink); }
.logo b { color: var(--sun); font-size: 1.6rem; }
.logo-icon { font-size: 1.7rem; }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a {
  padding: 6px 12px; border-radius: 999px; font-weight: 600; color: var(--muted); white-space: nowrap;
}
.nav a:hover { background: var(--bg); color: var(--ink); }
.nav a.active { background: var(--primary); color: #fff; }
.me { display: flex; align-items: center; gap: 10px; }
.pill {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 12px; border-radius: 999px;
  font-weight: 700; background: #fff5db; color: #a16207; border: 2px solid #ffe2a1; white-space: nowrap;
}
.pill.fire { background: #ffe8e0; color: #c2410c; border-color: #ffcbb8; }
.me-btn { background: none; border: 0; cursor: pointer; padding: 0; }

/* ---------- Thanh dưới (điện thoại) ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; display: none;
  background: #fff; border-top: 3px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.tabbar a { flex: 1; text-align: center; font-size: .72rem; font-weight: 600; color: var(--muted); padding: 2px; border-radius: 12px; }
.tabbar a span { display: block; font-size: 1.45rem; line-height: 1.2; }
.tabbar a.active { color: var(--primary-dark); background: #eaf0ff; }

@media (max-width: 900px) {
  .nav { display: none; }
  .tabbar:not(.hidden) { display: flex; }
  .topbar { padding: 8px 16px; }
  .app { padding-bottom: 96px !important; }
  .logo span:last-child { display: none; }
  :root { font-size: 16px; }
}
@media (max-width: 520px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .grid-4 .card { padding: 14px 10px; }
  .hello .stats { margin-left: 0; }
  .podium .p { width: 96px; }
}

/* ---------- Bố cục ---------- */
.app { max-width: 1080px; margin: 0 auto; padding: 24px 16px 48px; }
.loading { text-align: center; padding: 80px 0; color: var(--muted); font-size: 1.2rem; }
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 22px; border: 2px solid var(--line);
}
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.section { margin-top: 28px; }
.section-title { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.section-title h2 { margin: 0; }
.breadcrumb { color: var(--muted); font-weight: 600; margin-bottom: 10px; }
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--primary-dark); }

/* ---------- Nút ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 700; font-size: 1rem; cursor: pointer;
  padding: 10px 22px; border-radius: 16px; border: 0;
  background: var(--primary); color: #fff; box-shadow: 0 4px 0 var(--primary-dark);
  transition: transform .08s, box-shadow .08s, filter .15s;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--primary-dark); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn.big { font-size: 1.15rem; padding: 14px 28px; border-radius: 18px; }
.btn.sun { background: var(--sun); box-shadow: 0 4px 0 #d48806; color: #3b2600; }
.btn.good { background: var(--good); box-shadow: 0 4px 0 #15803d; }
.btn.bad { background: var(--bad); box-shadow: 0 4px 0 #b91c1c; }
.btn.ghost { background: #fff; color: var(--ink); border: 2px solid var(--line); box-shadow: 0 4px 0 var(--line); }
.btn.small { padding: 6px 14px; font-size: .9rem; border-radius: 12px; }

/* ---------- Biểu mẫu ---------- */
label { display: block; font-weight: 700; margin: 12px 0 4px; }
input, select {
  width: 100%; font: inherit; font-size: 1.05rem; padding: 10px 14px; border-radius: 14px;
  border: 2px solid var(--line); background: #fbfdff; color: var(--ink);
}
input:focus, select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px #dbe6ff; }
.form-error { color: var(--bad); font-weight: 600; min-height: 1.5em; margin-top: 8px; }

/* ---------- Đăng nhập ---------- */
.auth-wrap { min-height: calc(100vh - 80px); display: grid; place-items: center; }
.auth { width: 100%; max-width: 440px; }
.auth-hero { text-align: center; margin-bottom: 14px; }
.auth-hero .mascot { font-size: 4.5rem; display: inline-block; animation: bob 2.4s ease-in-out infinite; }
.auth-hero h1 { margin: 4px 0 0; }
.auth-hero h1 b { color: var(--sun); }
.auth .switch { text-align: center; margin-top: 14px; }
@keyframes bob { 50% { transform: translateY(-8px) rotate(-4deg); } }

/* ---------- Trang chủ ---------- */
.hello {
  display: flex; gap: 20px; align-items: center; flex-wrap: wrap;
  background: linear-gradient(120deg, #4f7cff, #7c5cff); color: #fff; border: 0;
}
.hello h1 { margin: 0; }
.hello p { margin: 4px 0 0; opacity: .92; }
.hello .stats { display: flex; gap: 12px; flex-wrap: wrap; margin-left: auto; }
.stat { background: rgba(255, 255, 255, .18); border-radius: 16px; padding: 8px 16px; text-align: center; min-width: 96px; }
.stat b { display: block; font-size: 1.6rem; line-height: 1.1; }
.stat small { opacity: .9; font-weight: 600; }
.bubble {
  position: relative; background: #fff; border: 2px solid var(--line); border-radius: 18px; padding: 12px 16px;
  font-weight: 600; box-shadow: var(--shadow);
}

/* ---------- Ảnh đại diện ---------- */
.avatar {
  display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  background: #fff5db; font-size: 1.6rem; border: 3px solid #fff; box-shadow: 0 0 0 2px var(--line); flex: none;
}
.avatar.lg { width: 88px; height: 88px; font-size: 3.2rem; }
.avatar.fr_sky { box-shadow: 0 0 0 4px #38bdf8; }
.avatar.fr_rainbow { box-shadow: 0 0 0 4px transparent; background-clip: padding-box; position: relative; }
.avatar.fr_rainbow::before {
  content: ''; position: absolute; inset: -7px; border-radius: 50%; z-index: -1;
  background: conic-gradient(#f87171, #fbbf24, #34d399, #60a5fa, #a78bfa, #f87171);
}
.avatar.fr_gold { box-shadow: 0 0 0 4px #f59e0b, 0 0 14px 3px #fcd34d; }

/* ---------- Khóa học ---------- */
.course-card { position: relative; overflow: hidden; display: flex; flex-direction: column; gap: 10px; transition: transform .15s; }
.course-card:hover { transform: translateY(-3px); }
.course-card .band { position: absolute; inset: 0 0 auto 0; height: 8px; background: var(--c); }
.course-head { display: flex; gap: 12px; align-items: center; }
.course-icon {
  width: 58px; height: 58px; border-radius: 18px; display: grid; place-items: center; font-size: 2rem; flex: none;
  background: color-mix(in srgb, var(--c) 18%, white);
}
.course-card h3 { margin: 0; font-size: 1.2rem; }
.course-card p { margin: 0; color: var(--muted); flex: 1; }
.tag { display: inline-block; font-size: .8rem; font-weight: 700; padding: 1px 10px; border-radius: 999px; background: var(--bg); color: var(--muted); }
.tag.ok { background: var(--good-bg); color: #15803d; }
.progress { height: 12px; border-radius: 999px; background: #edf1f8; overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: 999px; background: var(--c, var(--good)); transition: width .4s; }

.course-hero { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; border-top: 8px solid var(--c); }
.course-hero .course-icon { width: 80px; height: 80px; font-size: 2.8rem; }
.lesson-list { display: grid; gap: 12px; margin-top: 18px; }
.lesson-item {
  display: flex; align-items: center; gap: 14px; padding: 14px 18px; color: var(--ink);
  background: #fff; border: 2px solid var(--line); border-radius: 18px; box-shadow: 0 4px 0 var(--line);
}
.lesson-item:hover { border-color: var(--c); }
.lesson-num {
  width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; font-weight: 800; font-size: 1.2rem; flex: none;
  background: color-mix(in srgb, var(--c) 18%, white); color: color-mix(in srgb, var(--c) 70%, black);
}
.lesson-item.done .lesson-num { background: var(--good); color: #fff; }
.lesson-item .info { flex: 1; min-width: 0; }
.lesson-item .info b { display: block; }
.lesson-item .info small { color: var(--muted); }
.stars { font-size: 1.2rem; letter-spacing: 2px; white-space: nowrap; }
.stars .off { filter: grayscale(1); opacity: .3; }

/* ---------- Bài học ---------- */
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin: 16px 0; }
.tab {
  font: inherit; font-weight: 700; cursor: pointer; padding: 8px 18px; border-radius: 999px;
  border: 2px solid var(--line); background: #fff; color: var(--muted);
}
.tab.active { background: var(--c, var(--primary)); border-color: var(--c, var(--primary)); color: #fff; }
.content { font-size: 1.08rem; }
.content p { margin: .5em 0; }
.content ul, .content ol { padding-left: 1.3em; }
.content li { margin: 4px 0; }
.rule {
  background: #fff8e6; border: 2px dashed #f5b942; border-radius: 16px; padding: 12px 16px; margin: 12px 0; font-weight: 500;
}
.formula { text-align: center; font-size: 1.2rem; font-weight: 700; color: var(--primary-dark); background: #f1f5ff; border-radius: 14px; padding: 8px; }
.tbl { border-collapse: collapse; margin: 12px 0; width: 100%; font-size: .95rem; display: block; overflow-x: auto; }
.tbl th, .tbl td { border: 2px solid var(--line); padding: 6px 10px; text-align: center; }
.tbl th { background: #f1f5ff; }
pre.calc { font-family: ui-monospace, Menlo, monospace; font-size: 1.15rem; background: #f8fafc; border-radius: 12px; padding: 10px 16px; display: inline-block; }
svg.shape { display: block; max-width: 320px; margin: 12px auto; }
.pie-wrap { display: flex; gap: 24px; align-items: center; justify-content: center; flex-wrap: wrap; margin: 12px 0; }
.pie { width: 170px; height: 170px; border-radius: 50%; border: 4px solid #fff; box-shadow: var(--shadow); }
.legend { list-style: none; padding: 0; margin: 0; font-weight: 600; }
.legend i { display: inline-block; width: 16px; height: 16px; border-radius: 4px; margin-right: 8px; vertical-align: -2px; }
.caption { text-align: center; color: var(--muted); font-style: italic; }

.frac { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; line-height: 1.05; margin: 0 2px; font-size: .92em; }
.frac > span:first-child { border-bottom: 2px solid currentColor; padding: 0 3px; }
.frac > span:last-child { padding: 0 3px; }

.notes { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.notes li { display: flex; gap: 12px; align-items: flex-start; background: #fff4f0; border: 2px solid #ffd9cc; border-radius: 16px; padding: 12px 16px; }
.notes li::before { content: '⚠️'; font-size: 1.3rem; }
.example { border: 2px solid var(--line); border-radius: 18px; padding: 16px; margin-bottom: 14px; background: #fbfdff; }
.example .label { font-weight: 800; color: var(--primary-dark); }
.solution { margin-top: 10px; background: var(--good-bg); border-radius: 14px; padding: 12px 16px; }

/* ---------- Trắc nghiệm ---------- */
.quiz-top { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.quiz-top .progress { flex: 1; height: 16px; }
.q-text { font-size: 1.3rem; font-weight: 700; margin: 6px 0 18px; }
.options { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.option {
  font: inherit; font-size: 1.15rem; font-weight: 600; text-align: left; cursor: pointer;
  display: flex; gap: 12px; align-items: center; padding: 12px 16px; border-radius: 16px;
  border: 3px solid var(--line); background: #fff; color: var(--ink); box-shadow: 0 4px 0 var(--line);
  transition: transform .08s;
}
.option:hover { border-color: #b7c7ef; }
.option:active { transform: translateY(2px); }
.option .key {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none;
  background: var(--bg); font-weight: 800; color: var(--muted);
}
.option.chosen { border-color: var(--primary); background: #eef3ff; box-shadow: 0 4px 0 #b7c7ef; }
.option.chosen .key { background: var(--primary); color: #fff; }
.option.right { border-color: var(--good); background: var(--good-bg); box-shadow: 0 4px 0 #86efac; }
.option.right .key { background: var(--good); color: #fff; }
.option.wrong { border-color: var(--bad); background: var(--bad-bg); box-shadow: 0 4px 0 #fca5a5; }
.option.wrong .key { background: var(--bad); color: #fff; }
.dots { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin-top: 18px; }
.dot { width: 34px; height: 34px; border-radius: 10px; border: 2px solid var(--line); background: #fff; font: inherit; font-weight: 700; cursor: pointer; color: var(--muted); }
.dot.answered { background: #eef3ff; border-color: #b7c7ef; color: var(--primary-dark); }
.dot.current { border-color: var(--primary); box-shadow: 0 0 0 3px #dbe6ff; }

.result-hero { text-align: center; }
.result-hero .big-emoji { font-size: 5rem; line-height: 1; animation: pop .5s ease-out; }
.result-hero .score { font-size: 3rem; font-weight: 800; color: var(--primary-dark); line-height: 1.1; }
.result-hero .earn { display: inline-block; margin-top: 8px; font-size: 1.3rem; }
@keyframes pop { 0% { transform: scale(.3); } 70% { transform: scale(1.15); } 100% { transform: scale(1); } }
.review { display: grid; gap: 14px; margin-top: 20px; }
.review-item { border-left: 6px solid var(--line); }
.review-item.ok { border-left-color: var(--good); }
.review-item.no { border-left-color: var(--bad); }
.explain { margin-top: 10px; background: #f1f5ff; border-radius: 12px; padding: 10px 14px; }

/* ---------- Huy hiệu & quà ---------- */
.badge-card { text-align: center; }
.badge-card .ic { font-size: 3rem; line-height: 1.2; }
.badge-card.locked .ic { filter: grayscale(1); opacity: .35; }
.badge-card.locked { background: #f7f9fc; }
.badge-card b { display: block; }
.badge-card small { color: var(--muted); display: block; }
.shop-item { text-align: center; display: flex; flex-direction: column; gap: 6px; align-items: center; }
.shop-item .ic { font-size: 3rem; line-height: 1.2; }
.shop-item .cost { font-weight: 800; color: #a16207; }
.status { font-weight: 700; padding: 1px 10px; border-radius: 999px; font-size: .85rem; }
.status.pending { background: #fff5db; color: #a16207; }
.status.delivered { background: var(--good-bg); color: #15803d; }
.status.rejected { background: var(--bad-bg); color: #b91c1c; }
.status.done { background: #eef3ff; color: var(--primary-dark); }

/* ---------- Bảng xếp hạng ---------- */
.rank-list { display: grid; gap: 10px; }
.rank-row { display: flex; align-items: center; gap: 14px; padding: 10px 16px; }
.rank-row.me { border-color: var(--primary); background: #f3f6ff; }
.rank-no { width: 40px; text-align: center; font-weight: 800; font-size: 1.3rem; color: var(--muted); }
.podium { display: flex; justify-content: center; align-items: flex-end; gap: 14px; margin: 10px 0 24px; }
.podium .p { text-align: center; width: 120px; }
.podium .block { border-radius: 16px 16px 0 0; color: #fff; font-weight: 800; font-size: 1.6rem; padding-top: 8px; }
.podium .p1 .block { height: 120px; background: #f59e0b; }
.podium .p2 .block { height: 90px; background: #94a3b8; }
.podium .p3 .block { height: 66px; background: #c2814b; }

/* ---------- Bảng quản trị ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px; border-bottom: 2px solid var(--line); text-align: left; vertical-align: middle; }
.table th { color: var(--muted); font-size: .9rem; }
.table-wrap { overflow-x: auto; }

/* ---------- Thông báo, hộp thoại, pháo giấy ---------- */
.toasts { position: fixed; top: 76px; right: 16px; z-index: 60; display: grid; gap: 10px; }
.toast {
  background: #fff; border-radius: 16px; padding: 12px 18px; font-weight: 600; box-shadow: var(--shadow);
  border-left: 6px solid var(--primary); animation: slide .3s ease-out; max-width: 340px;
}
.toast.good { border-left-color: var(--good); }
.toast.bad { border-left-color: var(--bad); }
@keyframes slide { from { transform: translateX(120%); } }
.modal { position: fixed; inset: 0; z-index: 70; background: rgba(20, 30, 60, .45); display: grid; place-items: center; padding: 16px; }
.modal .card { max-width: 440px; width: 100%; text-align: center; animation: pop .35s ease-out; }
.modal .ic { font-size: 5rem; line-height: 1.1; }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 80; }
.empty { text-align: center; padding: 30px; color: var(--muted); }
.empty .ic { font-size: 3.5rem; }

/* =====================================================================
   Phiên bản 2: nhiệm vụ, trình làm bài mới, luyện tập, lớp học
   ===================================================================== */
.sound-btn { background: none; border: 0; font-size: 1.3rem; cursor: pointer; padding: 2px 4px; }
.big-ic { font-size: 3.4rem; line-height: 1.1; }
.big-ic.sm { font-size: 2.2rem; }
.tag.warn { background: #ffedd5; color: #c2410c; }
.notice { background: #fff8e6; border: 2px dashed #f5b942; border-radius: 14px; padding: 10px 14px; margin-top: 12px; font-weight: 600; }
.champ-banner { margin-top: 18px; background: linear-gradient(90deg, #fff7d6, #fff); border-color: #fde68a; font-weight: 600; }
.mini-stat { background: var(--bg); border-radius: 14px; padding: 10px; text-align: center; }
.mini-stat b { display: block; font-size: 1.4rem; color: var(--primary-dark); }
.mini-stat small { color: var(--muted); font-weight: 600; }

/* Nhiệm vụ & rương */
.quests .quest { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 14px; border: 2px solid var(--line); margin-bottom: 10px; color: var(--ink); }
.quests a.quest[href]:hover { border-color: var(--primary); }
.quest.done { background: var(--good-bg); border-color: #86efac; }
.q-ic { font-size: 1.6rem; }
.q-body { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.q-body .progress { height: 9px; }
.q-num { font-weight: 800; color: var(--muted); }
.chest-row { display: flex; align-items: center; gap: 12px; margin-top: 6px; padding: 10px; border-radius: 16px; background: #fffaf0; }
.chest { font-size: 2.6rem; }
.chest.locked { filter: grayscale(.8); opacity: .6; }
.chest.shake { animation: shake 1s ease-in-out infinite; }
@keyframes shake { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(-12deg); } 40% { transform: rotate(10deg); } 60% { transform: rotate(-6deg); } 80% { transform: rotate(4deg); } }

/* Luyện tập nhanh & gợi ý */
.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.quick-btn { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 6px; border-radius: 16px; border: 2px solid var(--line); background: #fbfdff; font-weight: 700; color: var(--ink); text-align: center; box-shadow: 0 4px 0 var(--line); }
.quick-btn span { font-size: 2rem; }
.quick-btn em { position: absolute; top: 6px; right: 8px; background: var(--bad); color: #fff; font-style: normal; border-radius: 999px; padding: 0 8px; font-size: .8rem; }
.quick-btn:hover { border-color: var(--primary); }
.suggest { display: flex; gap: 8px; align-items: center; padding: 8px 12px; border-radius: 12px; background: #fff4f0; margin-top: 8px; color: var(--ink); }
.suggest .tag { margin-left: auto; }

/* Thẻ luyện tập / kiểm tra */
.practice-pick .pick { font: inherit; cursor: pointer; text-align: center; color: var(--ink); transition: transform .15s; }
.practice-pick .pick:hover { transform: translateY(-3px); border-color: var(--c, var(--primary)); }
.speed-card { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; color: var(--ink); border-top: 6px solid var(--c); }
.speed-card:hover, .exam-card:hover, .class-card:hover { transform: translateY(-3px); }
.exam-card { color: var(--ink); border-left: 8px solid var(--c); transition: transform .15s; }
.exam-card.passed { background: #f3fff6; }
.exam-item .lesson-num { background: #fff5db; }
.class-card { color: var(--ink); display: grid; gap: 6px; transition: transform .15s; }
.code { font-family: ui-monospace, Menlo, monospace; letter-spacing: 2px; background: #f1f5ff; padding: 1px 8px; border-radius: 8px; color: var(--primary-dark); }
.code.big { font-size: 1.4rem; }
pre.report { white-space: pre-wrap; font-family: inherit; background: #f8fafc; border-radius: 14px; padding: 14px; line-height: 1.7; margin: 0; }

/* Sổ tay */
.mistake.due { border-color: #fdba74; }
.m-q { font-size: 1.1rem; font-weight: 600; margin: 8px 0; }

/* Trình làm bài */
.player-intro { text-align: center; padding: 16px 0; }
.player-intro .big-ic { font-size: 4rem; }
.q-meta { color: var(--muted); font-weight: 600; font-size: .9rem; }
.good-pill { background: var(--good-bg); color: #15803d; border-color: #86efac; }
.clock { font-weight: 800; font-size: 1.25rem; font-variant-numeric: tabular-nums; padding: 2px 12px; border-radius: 12px; background: #eef3ff; color: var(--primary-dark); }
.clock.hurry { background: var(--bad-bg); color: var(--bad); animation: pulse .6s ease-in-out infinite alternate; }
@keyframes pulse { to { transform: scale(1.08); } }
.options.tf { grid-template-columns: 1fr 1fr; }
.options.tf .option { justify-content: center; font-size: 1.3rem; padding: 18px; }
.option:disabled { cursor: default; }
.input-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.answer-input { max-width: 260px; font-size: 1.5rem; font-weight: 700; text-align: center; padding: 12px; border-width: 3px; }
.answer-input.right { border-color: var(--good); background: var(--good-bg); }
.answer-input.wrong { border-color: var(--bad); background: var(--bad-bg); }
.unit { font-size: 1.3rem; font-weight: 700; color: var(--muted); }
.order-slots { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.order-slots .lt { color: var(--muted); font-weight: 800; }
.slot { min-width: 84px; min-height: 48px; border-radius: 14px; border: 3px dashed #c7d2e8; background: #fbfdff; font: inherit; font-weight: 700; font-size: 1.1rem; color: var(--muted); cursor: default; }
.slot.filled { border-style: solid; border-color: var(--primary); background: #eef3ff; color: var(--ink); cursor: pointer; }
.chips { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0; min-height: 50px; }
.chip { font: inherit; font-weight: 700; font-size: 1.15rem; padding: 10px 18px; border-radius: 14px; border: 3px solid var(--line); background: #fff; box-shadow: 0 4px 0 var(--line); cursor: pointer; color: var(--ink); }
.chip:hover { border-color: var(--primary); }
.match { display: grid; gap: 10px; margin-bottom: 14px; }
.match-row { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; }
.m-left { font-weight: 700; font-size: 1.15rem; background: #f1f5ff; border-radius: 12px; padding: 10px 14px; text-align: center; }
.m-eq { font-weight: 800; color: var(--muted); }
.feedback { margin-top: 16px; padding: 14px; border-radius: 18px; border: 3px solid var(--line); animation: pop .3s ease-out; }
.feedback.ok { border-color: #86efac; background: #f3fff6; }
.feedback.no { border-color: #fca5a5; background: #fff6f6; }
.right-answer { font-size: 1.1rem; margin: 8px 0; }
.mascot-say { display: flex; align-items: center; gap: 10px; }
.mascot-say .owl { font-size: 2.6rem; }
.mascot-say.happy .owl { animation: bob 1.2s ease-in-out infinite; }
.mascot-say.sad .owl { filter: saturate(.7); }
.mascot-say .bubble { padding: 8px 14px; font-size: 1.05rem; }
.flash { margin-left: 10px; font-size: 1.6rem; animation: pop .3s ease-out; }
.flash.ok { color: var(--good); }
.flash.no { color: var(--bad); }
.breakdown { display: inline-grid; gap: 2px; margin-top: 8px; color: var(--muted); font-weight: 600; text-align: left; }
.quest-mini { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 16px; }
.quest-mini span { background: var(--bg); border-radius: 999px; padding: 3px 12px; font-weight: 600; font-size: .9rem; }
.quest-mini span.done { background: var(--good-bg); color: #15803d; }
.ans-line { margin-top: 6px; }
.ans-line.right { color: #15803d; }

@media (max-width: 520px) {
  .quick { grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
  .quick-btn { font-size: .8rem; }
  .match-row { grid-template-columns: 1fr; }
  .m-eq { display: none; }
  .answer-input { max-width: 100%; flex: 1; }
}

/* =====================================================================
   Phiên bản 3: soạn câu hỏi, bài tập bổ sung, phân quyền
   ===================================================================== */
textarea {
  width: 100%; font: inherit; font-size: 1rem; padding: 10px 14px; border-radius: 14px;
  border: 2px solid var(--line); background: #fbfdff; color: var(--ink); resize: vertical;
}
textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px #dbe6ff; }
.tag.bad { background: var(--bad-bg); color: #b91c1c; }
.author-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 14px; border: 2px solid var(--line); margin-top: 8px; color: var(--ink); flex-wrap: wrap; }
.author-row:hover { border-color: var(--primary); background: #f8faff; }
.lesson-num.sm { width: 34px; height: 34px; font-size: 1rem; border-radius: 10px; background: var(--bg); color: var(--muted); }
.editor { margin-top: 16px; border: 3px dashed #b7c7ef; background: #fbfcff; }
.editor h3 { margin-bottom: 4px; }
.type-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.type-pick .tab { padding: 6px 14px; }
.opt-row { margin-top: 6px; flex-wrap: nowrap; }
.opt-row input:not([type=radio]) { flex: 1; }
.preview { margin-top: 12px; border-radius: 16px; background: #fff; border: 2px solid var(--line); padding: 12px 16px; }
.preview .label { font-weight: 800; color: var(--primary-dark); margin-bottom: 4px; }
.preview .q-text { font-size: 1.15rem; margin: 4px 0 10px; }
.options.compact { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; margin-top: 8px; }
.options.compact .option { font-size: 1rem; padding: 8px 12px; cursor: default; }
.q-card .m-q { margin-top: 10px; }
details.card summary { cursor: pointer; }
.base-q { padding: 10px 0; border-bottom: 2px solid var(--line); }
.perm-help { background: var(--bg); border-radius: 14px; padding: 10px 14px; }

/* =====================================================================
   Phiên bản 4: nhiều khối lớp
   ===================================================================== */
.grade-chip:not(:empty) { margin-left: 6px; font-size: .85rem; padding: 2px 10px; border-radius: 999px; background: var(--sun); color: #3b2600; align-self: center; }
.logo .grade-chip { display: inline-block; }
@media (max-width: 900px) { .logo span:nth-child(2) { display: none; } }
.grade-line { margin: 0; font-weight: 700; color: var(--primary-dark); }
.grade-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0 14px; }
.grade-tab {
  display: flex; flex-direction: column; align-items: center; min-width: 74px; padding: 6px 14px; border-radius: 16px;
  border: 3px solid var(--line); background: #fff; color: var(--ink); font-weight: 800; box-shadow: 0 3px 0 var(--line);
}
.grade-tab small { font-weight: 600; color: var(--muted); font-size: .7rem; }
.grade-tab.active { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 3px 0 var(--primary-dark); }
.grade-tab.active small { color: #dbe6ff; }
.grade-pick, .pick-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0; }
.grade-opt input, .icon-opt input, .color-opt input { position: absolute; opacity: 0; pointer-events: none; }
.grade-opt span { display: inline-block; padding: 6px 14px; border-radius: 12px; border: 2px solid var(--line); font-weight: 700; cursor: pointer; background: #fff; }
.grade-opt input:checked + span { background: var(--primary); border-color: var(--primary); color: #fff; }
.icon-opt span { display: grid; place-items: center; width: 44px; height: 44px; font-size: 1.5rem; border-radius: 12px; border: 2px solid var(--line); cursor: pointer; background: #fff; }
.icon-opt input:checked + span { border-color: var(--primary); box-shadow: 0 0 0 3px #dbe6ff; }
.color-opt span { display: block; width: 36px; height: 36px; border-radius: 50%; cursor: pointer; border: 3px solid #fff; box-shadow: 0 0 0 2px var(--line); }
.color-opt input:checked + span { box-shadow: 0 0 0 3px var(--ink); }
.grade-opt, .icon-opt, .color-opt { position: relative; margin: 0; }

/* Câu hỏi tư duy / nâng cao */
.adv-tag { display: inline-block; margin: 6px 0 2px; padding: 4px 14px; border-radius: 999px; font-weight: 700; font-size: .95rem;
  background: linear-gradient(90deg, #ede9fe, #fae8ff); color: #6d28d9; border: 2px solid #ddd6fe; }
.tag.adv { background: #ede9fe; color: #6d28d9; }
.adv-sum { font-weight: 600; color: #6d28d9; margin: 4px 0; }
