/* ============================================================================
 * styles.css — "Bi Vô Địch" · cute, sáng, bo góc lớn · chạy mọi thiết bị
 * ==========================================================================*/
:root {
  --bg: #FBF7EF; --ink: #233B52; --ink-soft: #5B718A; --white: #fff;
  --primary: #4F8EF7; --pink: #FF7EA6; --purple: #9B7BF0; --green: #3FC08A; --yellow: #FFD45C;
  --focus: #FF8A3D;
  --radius: 24px; --radius-sm: 16px; --speed: 190ms;
  --shadow: 0 .5rem 1.3rem rgba(35,59,82,.13); --shadow-lg: 0 1rem 2.3rem rgba(35,59,82,.2);
  --font-scale: 1;
  color-scheme: light; /* app luôn dùng giao diện sáng, kể cả khi thiết bị đang ở chế độ tối */
}
* { box-sizing: border-box; }
/* Nút không tự kế thừa màu/phông chữ -> ép kế thừa để chữ không bị mất
   (nếu không, ở chế độ tối chữ trên nút trắng sẽ thành trắng = vô hình) */
button { color: inherit; font-family: inherit; }
html { font-size: calc(clamp(15px, 1.5vw, 22px) * var(--font-scale)); }
body { margin: 0; font-family: 'Baloo 2','Nunito',system-ui,'Segoe UI',sans-serif; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; overflow-x: hidden; }

/* ---- Khung thiết bị (tự động co giãn theo màn hình) ---- */
.device { margin: 0 auto; background: var(--bg); position: relative; width: 100%; min-height: 100vh; min-height: 100dvh; }
.app { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; background: radial-gradient(1200px 500px at 12% -8%, #FFF3DE 0, transparent 60%), radial-gradient(900px 500px at 100% 0, #E9F3FF 0, transparent 55%), var(--bg); }

/* ---- Header ---- */
.app-header { position: sticky; top: 0; z-index: 20; flex: 0 0 auto; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: .5rem; padding: .6rem max(16px, env(safe-area-inset-left, 0px)); background: rgba(251,247,239,.92); backdrop-filter: blur(6px); }
.hdr-slot { display: flex; align-items: center; gap: .5rem; min-width: 0; }
.hdr-left { justify-content: flex-start; } .hdr-title { justify-content: center; } .hdr-right { justify-content: flex-end; }
.hdr-title-text { font-weight: 800; color: var(--ink-soft); font-size: 1.05rem; }
.hdr-logo { display: inline-flex; align-items: center; gap: .4rem; font-weight: 800; color: var(--primary); font-size: 1.1rem; }
.hdr-logo .ill { width: 1.5rem; height: 1.5rem; }
.hdr-btn { font: inherit; font-weight: 700; font-size: .9rem; border: none; background: #fff; color: var(--ink); padding: .45rem .9rem; border-radius: 999px; cursor: pointer; box-shadow: var(--shadow); transition: transform var(--speed); white-space: nowrap; }
.sound-btn { font-size: 1.1rem; padding: .4rem .7rem; }

/* ---- Vùng nội dung ---- */
.app-root { flex: 1 1 auto; padding: .6rem max(16px, env(safe-area-inset-left, 0px)) 2rem; }
.screen { max-width: 1400px; margin: 0 auto; animation: fade var(--speed) ease both; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.screen-title { font-size: 1.9rem; margin: .1rem 0; font-weight: 800; }
.screen-title.small { font-size: 1.4rem; }
.screen-lead { font-size: 1.1rem; color: var(--ink-soft); margin: .2rem 0 .8rem; }
.section-label { font-size: 1.1rem; color: var(--ink-soft); margin: 1rem 0 .6rem; font-weight: 800; }

/* ---- Nút ---- */
.btn { font: inherit; font-weight: 800; border: none; cursor: pointer; border-radius: var(--radius-sm); padding: .65rem 1.2rem; font-size: 1rem; background: #fff; color: var(--ink); box-shadow: var(--shadow); transition: transform var(--speed), box-shadow var(--speed); }
.btn.primary { background: var(--primary); color: #fff; }
.btn.soft { background: #fff; }
.btn.ghost { background: rgba(255,255,255,.6); color: var(--ink-soft); box-shadow: none; }
.btn.big { padding: .85rem 1.5rem; font-size: 1.15rem; }
.btn.block { display: block; width: 100%; margin: .5rem 0; }

/* ---- Focus (D-pad) ---- */
.is-focused { outline: none; box-shadow: 0 0 0 .2rem #fff, 0 0 0 .46rem var(--focus), var(--shadow-lg) !important; transform: translateY(-3px) scale(1.04); z-index: 6; }
.hdr-btn.is-focused, .btn.is-focused, .key.is-focused, .chip.is-focused { transform: translateY(-2px) scale(1.06); }

/* ---- Hình ---- */
.ill { display: block; width: 100%; height: 100%; }
.avatar-svg { width: 100%; height: 100%; }
/* Emoji minh hoạ: canh giữa trong khung, cỡ chữ quyết định độ lớn */
.emoji-ill { display: inline-flex !important; align-items: center; justify-content: center; width: 100%; height: 100%; line-height: 1; font-size: 2.2rem; font-family: "Apple Color Emoji","Segoe UI Emoji","Noto Color Emoji","Twemoji Mozilla",sans-serif; -webkit-font-smoothing: auto; }
.card-ill .emoji-ill { font-size: 2.7rem; }
.subject-chip .emoji-ill { font-size: 2.5rem; }
.obj .emoji-ill { font-size: 3.4rem; }
.ans-ill .emoji-ill { font-size: 3.2rem; }
.stem-ill .emoji-ill { font-size: 5.2rem; }
.match-ill .emoji-ill { font-size: 2.1rem; }
.hdr-logo .emoji-ill { width: 1.5rem; height: 1.5rem; font-size: 1.4rem; }
.star-slot .emoji-ill { font-size: 1.5rem; }
.result-stars.big .star-slot .emoji-ill { font-size: 2.9rem; }
.mascot { width: 6.5rem; height: 7rem; filter: drop-shadow(0 .4rem .5rem rgba(243,183,51,.4)); }
.mascot.small { width: 3rem; height: 3.3rem; } .mascot.cheer { width: 8.5rem; height: 9.2rem; animation: bob 1.6s ease-in-out infinite; }
@keyframes bob { 0%,100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-8px) rotate(2deg); } }
.wave { display: inline-block; animation: bob 2s ease-in-out infinite; }
.star-row { display: inline-flex; gap: .2rem; } .star-slot { width: 1.6rem; height: 1.6rem; } .star-slot.off { filter: grayscale(1); opacity: .3; }
.result-stars.big .star-slot { width: 3.2rem; height: 3.2rem; } .result-stars.big .star-slot.on { animation: pop .5s ease both; }
.result-stars.big .star-slot:nth-child(2){animation-delay:.15s} .result-stars.big .star-slot:nth-child(3){animation-delay:.3s}
@keyframes pop { 0% { transform: scale(0) rotate(-40deg);} 70%{transform:scale(1.25);} 100%{transform:scale(1);} }

/* ---- Trang chủ ---- */
.home-hero { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.hero-text { flex: 1 1 auto; } .hero-mascot { flex: 0 0 auto; }
.stat-pills { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .5rem; }
.pill { background: #fff; border-radius: 999px; padding: .3rem .9rem; font-weight: 800; font-size: .95rem; box-shadow: var(--shadow); }
.feature-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin: 1rem 0; }
.feature-card { font: inherit; text-align: left; cursor: pointer; border: none; display: flex; align-items: center; gap: .9rem; padding: 1rem 1.2rem; border-radius: var(--radius); color: #fff; box-shadow: var(--shadow); transition: transform var(--speed); }
.feature-card.daily { background: linear-gradient(120deg, #FF9E57, #FF7EA6); }
.feature-card.daily.done { background: linear-gradient(120deg, #7bd0a8, #3FC08A); }
.feature-card.timed { background: linear-gradient(120deg, #4F8EF7, #9B7BF0); }
.feature-emoji { font-size: 2.4rem; }
.feature-main { display: flex; flex-direction: column; } .feature-main b { font-size: 1.2rem; } .feature-main small { opacity: .95; font-size: .88rem; }

.subject-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
.card { font: inherit; cursor: pointer; border: none; text-align: left; background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); transition: transform var(--speed); }
.subject-card { position: relative; padding: 1.1rem 1rem; display: flex; flex-direction: column; gap: .25rem; border-top: .45rem solid var(--c, var(--primary)); }
.subj-tag { position: absolute; top: .8rem; right: .8rem; background: color-mix(in srgb, var(--c,#4F8EF7) 16%, #fff); color: var(--c,#4F8EF7); font-size: .72rem; font-weight: 800; padding: .1rem .55rem; border-radius: 999px; }
.card-ill { width: 4.2rem; height: 4.2rem; border-radius: 18px; background: color-mix(in srgb, var(--c, var(--primary)) 14%, #fff); padding: .5rem; }
.card-ill.small { width: 3.6rem; height: 3.6rem; background: #F2F7FC; }
.card-title { font-weight: 800; font-size: 1.2rem; }
.card-sub { font-size: .88rem; color: var(--ink-soft); }
.subj-progress { font-size: .82rem; font-weight: 800; color: var(--c,var(--primary)); margin-top: .2rem; }
.home-foot { display: flex; gap: .8rem; flex-wrap: wrap; margin-top: 1.4rem; }

/* ---- Danh sách bài ---- */
.lessons-head { display: flex; align-items: center; gap: 1rem; margin-bottom: .8rem; }
.subject-chip { width: 4rem; height: 4rem; border-radius: 18px; padding: .5rem; box-shadow: var(--shadow); background: #fff; }
.tag-inline { font-size: .9rem; background: #fff; color: var(--c,var(--primary)); padding: .1rem .6rem; border-radius: 999px; box-shadow: var(--shadow); vertical-align: middle; }
.level-group { font-size: 1.05rem; font-weight: 800; margin: 1.1rem 0 .5rem; color: var(--ink-soft); display: flex; align-items: center; gap: .4rem; }
.level-group::after { content: ""; flex: 1; height: 2px; background: #EAEFF4; border-radius: 2px; }
.level-group-0 { color: #2E9E6B; } .level-group-1 { color: #4F8EF7; } .level-group-2 { color: #E07B45; }
.lesson-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.lesson-card { display: flex; align-items: center; gap: 1rem; padding: 1rem; border-left: .45rem solid var(--c, var(--primary)); }
.lesson-info { display: flex; flex-direction: column; gap: .2rem; min-width: 0; }
.lesson-meta { display: flex; gap: .5rem; align-items: center; margin-top: .2rem; flex-wrap: wrap; }
.level { font-size: .78rem; font-weight: 800; padding: .1rem .6rem; border-radius: 999px; background: #EFF4F9; color: var(--ink-soft); }
.badge { font-size: .76rem; font-weight: 800; padding: .1rem .6rem; border-radius: 999px; }
.badge-new { background: #E7F0FF; color: var(--primary); } .badge-done { background: #E3F7EE; color: #2E9E6B; }
.lesson-card.is-done { background: #FBFEFC; }

/* ---- Bài tập ---- */
.quiz-top { display: flex; align-items: center; gap: .8rem; margin-bottom: .6rem; }
.progress { position: relative; flex: 1; height: 1.4rem; background: #EDF1F5; border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--green), var(--primary)); transition: width var(--speed); }
.progress-label { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: .78rem; font-weight: 800; }
.pause-btn { flex: 0 0 auto; font-size: 1.1rem; }
.question-panel { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem 1.3rem; text-align: center; }
.q-prompt-row { display: flex; align-items: center; justify-content: center; gap: .5rem; flex-wrap: wrap; }
.q-prompt { font-size: 1.5rem; font-weight: 800; margin: .2rem 0 .6rem; }
.q-stage { display: flex; justify-content: center; margin: .2rem auto .7rem; }
.count-stage { background: linear-gradient(180deg,#EAF6FF,#F6FBFF); border-radius: var(--radius-sm); padding: 1rem; width: 100%; }
.object-field { display: flex; flex-wrap: wrap; gap: .5rem .9rem; justify-content: center; }
.obj { width: 4.6rem; height: 4.6rem; display: inline-flex; animation: floaty 3s ease-in-out infinite; }
@keyframes floaty { 0%,100% { transform: translateY(0);} 50% { transform: translateY(-5px);} }
.expr { font-size: 2.6rem; font-weight: 800; letter-spacing: .04em; background: #EAF2FF; color: var(--ink); padding: .6rem 1.4rem; border-radius: var(--radius-sm); }
.stem-ill { width: 6.5rem; height: 6.5rem; } .stem-swatch { width: 6.5rem; height: 6.5rem; border-radius: 20px; box-shadow: inset 0 0 0 .3rem rgba(255,255,255,.6), var(--shadow); }

.answer-grid { display: grid; gap: .9rem; margin: .3rem auto 0; max-width: 960px; }
.answer-grid.cols-2 { grid-template-columns: repeat(2, 1fr); } .answer-grid.cols-3 { grid-template-columns: repeat(3, 1fr); } .answer-grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
.answer-option { position: relative; font: inherit; cursor: pointer; border: .18rem solid #E6ECF2; background: #fff; border-radius: var(--radius-sm); padding: .9rem; min-height: 5.6rem; display: flex; align-items: center; justify-content: center; transition: transform var(--speed), border-color var(--speed), background var(--speed); }
.ans-inner { display: flex; flex-direction: column; align-items: center; gap: .35rem; }
.ans-number { font-size: 3rem; font-weight: 800; line-height: 1; }
.ans-ill { width: 4rem; height: 4rem; } .ans-swatch { width: 3rem; height: 3rem; border-radius: 12px; box-shadow: inset 0 0 0 .2rem rgba(255,255,255,.6); }
.ans-text { font-size: 1.2rem; font-weight: 800; } .ans-text.xbig { font-size: 2.6rem; }
.ans-mark { position: absolute; top: .4rem; right: .5rem; opacity: 0; transition: opacity var(--speed); }
.answer-option.is-correct { border-color: var(--green); background: #EBFBF2; } .answer-option.is-correct .ans-mark { opacity: 1; } .answer-option.is-correct .ans-mark::after { content: '✅'; font-size: 1.4rem; }
.answer-option.is-wrong { border-color: var(--pink); background: #FFF0F3; animation: nudge .35s; } .answer-option.is-wrong .ans-mark { opacity: 1; } .answer-option.is-wrong .ans-mark::after { content: '🔁'; font-size: 1.3rem; }
@keyframes nudge { 0%,100%{transform:translateX(0);} 25%{transform:translateX(-6px);} 75%{transform:translateX(6px);} }
.tf-grid .tf-emoji { font-size: 2.2rem; }

/* keypad */
.keypad-wrap { max-width: 360px; margin: 0 auto; }
.keypad-display { font-size: 2.6rem; font-weight: 800; background: #EAF2FF; border-radius: var(--radius-sm); padding: .4rem; margin-bottom: .6rem; min-height: 3.4rem; letter-spacing: .1em; }
.keypad-display.correct { background: #EBFBF2; color: #2E9E6B; } .keypad-display.shake { animation: shake .4s; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; }
.key { font: inherit; font-size: 1.8rem; font-weight: 800; border: .16rem solid #E6ECF2; background: #fff; color: var(--ink); border-radius: 14px; padding: .6rem; cursor: pointer; transition: transform var(--speed); min-height: 3.6rem; }
.key-ok { background: var(--green); color: #fff; border-color: var(--green); } .key-fn { background: #FFF2F5; }

/* match */
.match-board { display: grid; grid-template-columns: 1fr 1fr; gap: 1.4rem; max-width: 640px; margin: 0 auto; }
.match-col { display: flex; flex-direction: column; gap: .6rem; }
.match-tile { font: inherit; cursor: pointer; border: .16rem solid #E6ECF2; background: #fff; border-radius: 14px; padding: .6rem; display: flex; align-items: center; justify-content: center; gap: .5rem; min-height: 3.6rem; transition: all var(--speed); }
.match-ill { width: 2.6rem; height: 2.6rem; } .match-text { font-weight: 800; font-size: 1.15rem; }
.match-tile.sel { border-color: var(--primary); background: #EAF2FF; } .match-tile.matched { border-color: var(--green); background: #EBFBF2; opacity: .75; } .match-tile.flash { border-color: var(--pink); background: #FFF0F3; animation: nudge .4s; }

/* order */
.order-board { max-width: 640px; margin: 0 auto; }
.order-slots { display: flex; gap: .5rem; justify-content: center; min-height: 3rem; margin-bottom: .8rem; flex-wrap: wrap; }
.order-chip { background: var(--green); color: #fff; font-weight: 800; font-size: 1.4rem; padding: .3rem .9rem; border-radius: 12px; animation: pop .3s ease both; }
.order-pool { display: flex; gap: .6rem; justify-content: center; flex-wrap: wrap; }
.order-tile { font: inherit; font-size: 1.8rem; font-weight: 800; border: .16rem solid #E6ECF2; background: #fff; border-radius: 14px; padding: .5rem 1.1rem; cursor: pointer; transition: all var(--speed); }
.order-tile.placed { opacity: .25; } .order-tile.flash { border-color: var(--pink); background: #FFF0F3; animation: nudge .4s; }

.q-tools { display: flex; justify-content: center; gap: .7rem; margin-top: 1rem; flex-wrap: wrap; }
.feedback { display: none; margin-top: 1rem; align-items: center; justify-content: center; gap: .5rem; flex-wrap: wrap; font-size: 1.2rem; font-weight: 800; }
.feedback.show { display: flex; animation: fade var(--speed) both; }
.feedback .fb-emoji { font-size: 1.6rem; } .feedback.good .fb-text { color: #2E9E6B; } .feedback.bad .fb-text { color: #E06A86; } .feedback.hint .fb-text { color: #C98A1E; font-size: 1.05rem; }
.fb-explain { width: 100%; font-weight: 700; font-size: .95rem; color: var(--ink-soft); }

/* timed */
.timed-top { display: flex; align-items: center; gap: .8rem; margin-bottom: .8rem; }
.timer-wrap { position: relative; flex: 1; height: 1.6rem; background: #EDF1F5; border-radius: 999px; overflow: hidden; }
.timer-bar { height: 100%; width: 100%; background: linear-gradient(90deg, #FF7EA6, #FFA048); transition: width 1s linear; }
.timer-label { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: .82rem; }
.timed-score { font-weight: 800; font-size: 1.2rem; background: #fff; padding: .3rem .8rem; border-radius: 999px; box-shadow: var(--shadow); }

/* kết quả */
.screen-result { text-align: center; } .result-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 1.5rem; max-width: 720px; margin: .4rem auto; }
.result-title { font-size: 1.9rem; margin: .3rem 0; } .result-score, .timed-final { font-size: 1.2rem; color: var(--ink-soft); } .timed-final { font-size: 1.4rem; color: var(--ink); }
.result-actions { display: flex; justify-content: center; gap: .7rem; flex-wrap: wrap; margin-top: 1rem; }
.new-badges { margin: 1rem 0; } .new-badges p { font-weight: 800; margin: .3rem; } .nb { display: inline-block; background: #FFF6E0; border: 2px solid var(--yellow); border-radius: 999px; padding: .3rem .9rem; margin: .2rem; font-weight: 800; animation: pop .4s ease both; }

/* thành tích */
.ach-stats, .stat-row { display: flex; gap: .8rem; flex-wrap: wrap; margin-bottom: 1rem; }
.stat { flex: 1; min-width: 7rem; background: #fff; border-radius: var(--radius-sm); padding: .9rem; text-align: center; box-shadow: var(--shadow); }
.stat-num { display: block; font-size: 1.6rem; font-weight: 800; color: var(--primary); } .stat-lbl { font-size: .82rem; color: var(--ink-soft); }
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .8rem; }
.badge-chip { background: #fff; border-radius: var(--radius-sm); padding: .9rem; text-align: center; box-shadow: var(--shadow); border: 2px solid transparent; }
.badge-chip.earned { border-color: var(--yellow); background: #FFFCF2; } .badge-chip.locked { opacity: .6; filter: grayscale(.5); }
.badge-icon { font-size: 2.2rem; display: block; } .badge-name { font-weight: 800; display: block; margin-top: .2rem; } .badge-desc { font-size: .78rem; color: var(--ink-soft); display: block; }

/* phụ huynh */
.parent-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 1.2rem; }
.panel { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.3rem; }
.panel h2 { margin: 0 0 .6rem; font-size: 1.25rem; } .panel h3 { margin: 1rem 0 .4rem; font-size: 1rem; color: var(--ink-soft); }
.hist-list { list-style: none; margin: 0; padding: 0; } .hist-item { display: flex; align-items: center; gap: .6rem; justify-content: space-between; padding: .45rem 0; border-bottom: 1px dashed #E6ECF2; } .hist-name { font-weight: 700; flex: 1; } .hist-date { color: var(--ink-soft); font-size: .85rem; } .hist-empty { color: var(--ink-soft); }
.privacy-note { font-size: .82rem; color: var(--ink-soft); background: #F3F9FD; border-radius: 12px; padding: .6rem .8rem; margin-top: .8rem; }

/* cài đặt */
.settings-panel { max-width: 820px; margin: 0 auto; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .75rem 0; border-bottom: 1px dashed #E6ECF2; flex-wrap: wrap; }
.set-label { font-weight: 700; font-size: 1.05rem; } .set-group-title { font-size: 1.1rem; margin: 1.1rem 0 .2rem; color: var(--primary); border-top: 1px dashed #E6ECF2; padding-top: 1rem; }
.toggle { position: relative; font: inherit; cursor: pointer; border: none; width: 8rem; height: 2.6rem; background: #E6ECF2; color: var(--ink); border-radius: 999px; transition: background var(--speed); }
.toggle .knob { position: absolute; top: .42rem; left: .42rem; width: 1.75rem; height: 1.75rem; border-radius: 50%; background: #fff; box-shadow: var(--shadow); transition: left var(--speed); }
.toggle .toggle-text { position: absolute; top: 0; height: 100%; display: flex; align-items: center; font-weight: 800; }
.toggle.on { background: var(--green); color: #fff; } .toggle.on .knob { left: calc(100% - 2.2rem); } .toggle.on .toggle-text { left: 1rem; } .toggle.off .toggle-text { right: 1rem; }
.chip-row { display: flex; gap: .5rem; flex-wrap: wrap; }
.chip { font: inherit; cursor: pointer; border: .14rem solid #E6ECF2; background: #fff; color: var(--ink); font-weight: 800; padding: .4rem .9rem; border-radius: 999px; transition: all var(--speed); }
.chip.sel { background: var(--primary); border-color: var(--primary); color: #fff; }
.voice-note { font-size: .88rem; color: var(--ink-soft); margin-top: 1rem; background: #F3F9FD; border-radius: 12px; padding: .6rem .8rem; line-height: 1.5; }

/* hộp thoại */
.dialog-layer { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; background: rgba(35,59,82,.5); backdrop-filter: blur(3px); z-index: 60; padding: 1rem; }
.dialog-layer.show { display: flex; animation: fade var(--speed) both; }
.dialog { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 1.5rem 1.7rem; max-width: 600px; width: 100%; text-align: center; animation: pop .3s ease both; }
.dialog h2 { margin: 0 0 .5rem; font-size: 1.4rem; } .dialog p { color: var(--ink-soft); margin: .3rem 0; }
.dialog-actions { display: flex; flex-direction: column; gap: .6rem; margin-top: 1rem; } .dialog-actions .btn { width: 100%; }
.gate-sum { font-size: 2rem; font-weight: 800; margin: .5rem 0; } .gate-opts { display: flex; gap: .7rem; justify-content: center; margin: .8rem 0; }
.gate-opt { font: inherit; cursor: pointer; border: .18rem solid #E6ECF2; background: #fff; font-size: 1.8rem; font-weight: 800; width: 4.6rem; height: 4.6rem; border-radius: 18px; } .shake { animation: shake .4s; }
@keyframes shake { 0%,100%{transform:translateX(0);} 20%{transform:translateX(-10px);} 40%{transform:translateX(10px);} 60%{transform:translateX(-8px);} 80%{transform:translateX(8px);} }

/* hiệu ứng */
.pop-star { position: fixed; font-size: 1.5rem; pointer-events: none; z-index: 80; animation: popstar .9s ease-out forwards; }
@keyframes popstar { 0% { transform: translate(-50%,-50%) scale(.4); opacity: 1; } 100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.2); opacity: 0; } }
.confetti { position: fixed; top: -20px; width: 11px; height: 15px; border-radius: 3px; pointer-events: none; z-index: 70; animation: fall 2.4s linear forwards; }
@keyframes fall { 0% { transform: translateY(0) rotate(0); opacity: 1; } 100% { transform: translateY(104vh) rotate(540deg); opacity: .9; } }


body.reduce-motion *, body.reduce-motion *::before, body.reduce-motion *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
@media (prefers-reduced-motion: reduce) { * { animation-duration: .001ms !important; transition-duration: 1ms !important; } }

/* responsive */
@media (max-width: 920px) {
  .subject-grid { grid-template-columns: repeat(2, 1fr); }
  .lesson-list { grid-template-columns: 1fr; }
  .parent-grid { grid-template-columns: 1fr; }
  .feature-row { grid-template-columns: 1fr; }
  .hero-mascot { display: none; }
}
@media (max-width: 540px) {
  .subject-grid { grid-template-columns: 1fr 1fr; }
  .answer-grid.cols-3, .answer-grid.cols-4 { grid-template-columns: 1fr 1fr; }
  .match-board { gap: .8rem; }
  .result-actions .btn { flex: 1 1 100%; }
  .screen-title { font-size: 1.6rem; }
}
button:focus-visible { outline: none; }
