@font-face { font-family: 'Round'; src: url('fonts/Inter-Bold.otf') format('opentype'); font-weight: 400 700; font-display: swap; }
@font-face { font-family: 'Round'; src: url('fonts/Inter-Black.otf') format('opentype'); font-weight: 800 900; font-display: swap; }
:root {
  color-scheme: only light;
  --ink: #3b2d4f; --muted: #8a7ba3; --pink: #ff5c9d; --blue: #3d9bff; --yellow: #ffad14; --green: #25c288; --purple: #9b6bff;
  --card: #fff; --font: 'Round', 'Segoe UI', Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font); color: var(--ink); overscroll-behavior: none; user-select: none; -webkit-user-select: none;
  background: linear-gradient(180deg, #ffe3f0 0%, #f0e6ff 45%, #dff6ff 100%) fixed;
}
button { font: inherit; color: inherit; border: 0; cursor: pointer; }
input { font: inherit; }
#root { max-width: 560px; margin: 0 auto; min-height: 100dvh; position: relative; z-index: 1; }
.screen { display: none; min-height: 100dvh; padding: calc(12px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom)); flex-direction: column; }
.screen.active { display: flex; }

/* nốt nhạc bay nền */
.bgnotes { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
.bgnotes i { position: absolute; bottom: -60px; font-style: normal; font-size: 34px; color: rgba(155, 107, 255, .18); animation: rise 18s linear infinite; }
.bgnotes i:nth-child(1) { left: 6%; animation-delay: 0s; } .bgnotes i:nth-child(2) { left: 22%; animation-delay: -6s; font-size: 26px; color: rgba(255, 92, 157, .2); }
.bgnotes i:nth-child(3) { left: 38%; animation-delay: -11s; } .bgnotes i:nth-child(4) { left: 55%; animation-delay: -3s; color: rgba(61, 155, 255, .2); }
.bgnotes i:nth-child(5) { left: 70%; animation-delay: -14s; font-size: 40px; } .bgnotes i:nth-child(6) { left: 84%; animation-delay: -8s; color: rgba(255, 173, 20, .25); }
.bgnotes i:nth-child(7) { left: 93%; animation-delay: -16s; font-size: 24px; } .bgnotes i:nth-child(8) { left: 48%; animation-delay: -20s; color: rgba(37, 194, 136, .2); }
@keyframes rise { 0% { transform: translateY(0) rotate(0); } 100% { transform: translateY(-115vh) rotate(25deg); } }

/* ---- thẻ & nút ---- */
.card { background: var(--card); border-radius: 28px; box-shadow: 0 8px 0 rgba(124, 92, 180, .12), 0 18px 40px rgba(124, 92, 180, .12); }
.btn {
  border-radius: 999px; padding: 13px 26px; font-weight: 900; font-size: 17px; background: #fff; color: var(--ink);
  box-shadow: 0 5px 0 rgba(124, 92, 180, .22); transition: transform .1s, box-shadow .1s;
}
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 rgba(124, 92, 180, .22); }
.btn.big { font-size: 20px; padding: 16px 28px; width: 100%; }
.btn.small { font-size: 14px; padding: 9px 16px; }
.btn.pink { background: linear-gradient(180deg, #ff8fbf, #ff5c9d); color: #fff; box-shadow: 0 6px 0 #d8367a; text-shadow: 0 1px 0 rgba(160, 20, 80, .3); }
.btn.blue { background: linear-gradient(180deg, #7cc0ff, #3d9bff); color: #fff; box-shadow: 0 6px 0 #2179d8; }
.btn.yellow { background: linear-gradient(180deg, #ffd65a, #ffad14); color: #5a3a00; box-shadow: 0 5px 0 #df8d00; }
.btn.ghost { background: rgba(255, 255, 255, .7); color: var(--muted); }
.btn.danger { color: #e0395b; }
.iconbtn { width: 44px; height: 44px; border-radius: 50%; background: #fff; font-size: 20px; display: grid; place-items: center; box-shadow: 0 4px 0 rgba(124, 92, 180, .15); flex: none; }
.iconbtn.sm { width: 36px; height: 36px; font-size: 16px; }
.iconbtn:active { transform: translateY(3px); box-shadow: none; }

/* ---- linh vật ---- */
.mascot { width: 120px; height: 130px; overflow: visible; }
.mascot .m-body { transform-origin: 56px 120px; animation: bob 2.2s ease-in-out infinite; }
.mascot .m-flag { transform-origin: 78px 14px; animation: flag 1.1s ease-in-out infinite alternate; }
.mascot .m-arm-r { transform-origin: 90px 92px; animation: wave 1.4s ease-in-out infinite; }
.mascot .m-eyes { transform-origin: 56px 86px; animation: blink 4s infinite; }
.mascot.jump .m-body { animation: jump .7s cubic-bezier(.3, 1.6, .5, 1) 2; }
.mascot.sad .m-body { animation: shake .5s ease 2; }
.mascot.sad .m-mouth { d: path('M48 104 Q57 97 66 103'); }
.mascot.dance .m-body { animation: dance .8s ease-in-out infinite; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes flag { from { transform: rotate(-6deg); } to { transform: rotate(10deg); } }
@keyframes wave { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-22deg); } }
@keyframes blink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.1); } }
@keyframes jump { 0% { transform: translateY(0) scale(1, 1); } 30% { transform: translateY(-28px) scale(.95, 1.08); } 60% { transform: translateY(0) scale(1.08, .92); } 100% { transform: translateY(0); } }
@keyframes shake { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-8deg); } 75% { transform: rotate(8deg); } }
@keyframes dance { 0%, 100% { transform: rotate(-8deg) translateY(0); } 50% { transform: rotate(8deg) translateY(-12px); } }
.bubble { background: #fff; border-radius: 22px; padding: 12px 18px; font-weight: 700; font-size: 16px; line-height: 1.4; position: relative; box-shadow: 0 5px 0 rgba(124, 92, 180, .12); animation: pop .5s cubic-bezier(.3, 1.6, .5, 1) both; }
.bubble b { color: var(--pink); }

/* ---- màn chào ---- */
#s-welcome { justify-content: center; gap: 18px; }
.wl-top { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.brand { display: flex; flex-direction: column; align-items: center; }
.brand .mini { font-size: 11px; letter-spacing: .2em; color: var(--muted); font-weight: 900; }
.brand b { font-size: 38px; font-weight: 900; background: linear-gradient(90deg, #ff5c9d, #9b6bff, #3d9bff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.wl-card { padding: 20px; display: grid; gap: 14px; }
.wl-card input { width: 100%; text-align: center; font-size: 22px; font-weight: 900; padding: 14px; border-radius: 18px; border: 3px solid #f0e4f8; background: #fbf7ff; color: var(--ink); }
.wl-card input:focus { outline: none; border-color: var(--pink); background: #fff; }
.lbl { text-align: center; font-weight: 900; color: var(--muted); font-size: 14px; }
.avgrid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.avgrid button { aspect-ratio: 1; border-radius: 50%; padding: 2px; background: transparent; border: 3px solid transparent; transition: transform .15s; }
.avgrid button svg { width: 100%; height: 100%; overflow: visible; display: block; }
.avgrid button.sel { border-color: var(--pink); transform: scale(1.12); background: #fff; }
@media (max-width: 400px) { .avgrid { grid-template-columns: repeat(6, 1fr); } }

/* ---- bản đồ ---- */
.hd { display: flex; justify-content: space-between; align-items: center; }
.me { display: flex; align-items: center; gap: 10px; font-weight: 900; font-size: 19px; }
.av { display: inline-flex; width: 46px; height: 46px; } .av svg { width: 100%; height: 100%; overflow: visible; }
.hd-r { display: flex; align-items: center; gap: 10px; }
.starpill { background: linear-gradient(180deg, #ffd65a, #ffad14); color: #5a3a00; padding: 8px 14px; border-radius: 999px; font-weight: 900; box-shadow: 0 4px 0 #df8d00; }
.hero { display: flex; align-items: flex-end; gap: 8px; margin: 10px 0 6px; }
.hero .mascot { width: 104px; height: 112px; flex: none; }
.hero .bubble { margin-bottom: 30px; }
.install { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: #fff7d6; border-radius: 18px; padding: 10px 12px 10px 16px; font-weight: 700; font-size: 14px; margin-bottom: 8px; box-shadow: 0 4px 0 rgba(223, 141, 0, .2); }
.install[hidden] { display: none; }
.map { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 8px 0 12px; }
.topic {
  position: relative; border-radius: 26px; padding: 16px 12px 14px; text-align: center; background: #fff;
  box-shadow: 0 6px 0 var(--edge, rgba(124, 92, 180, .2)), 0 14px 30px rgba(124, 92, 180, .12);
  display: flex; flex-direction: column; align-items: center; gap: 6px; animation: pop .5s cubic-bezier(.3, 1.6, .5, 1) both; transition: transform .1s;
}
.topic:nth-child(even) { transform: translateY(18px); animation-name: pop2; }
.topic:active { transform: scale(.96); }
.topic:nth-child(even):active { transform: translateY(18px) scale(.96); }
.topic .ic { width: 64px; height: 64px; border-radius: 22px; display: grid; place-items: center; font-size: 34px; color: #fff; font-weight: 900; background: var(--c); box-shadow: inset 0 -5px 0 rgba(0, 0, 0, .12); }
.topic .tt { font-weight: 900; font-size: 16px; line-height: 1.2; }
.topic .ds { font-size: 12px; color: var(--muted); font-weight: 700; line-height: 1.3; min-height: 2.6em; }
.topic .st { font-size: 20px; letter-spacing: 2px; color: #e6dcf2; }
.topic .st .on { color: #ffb300; text-shadow: 0 2px 0 #df8d00; }
.topic .num { position: absolute; top: 10px; left: 12px; width: 26px; height: 26px; border-radius: 50%; background: var(--c); color: #fff; font-size: 13px; font-weight: 900; display: grid; place-items: center; }
.topic.locked { filter: grayscale(.9); opacity: .55; }
.topic.locked::after { content: '🔒'; position: absolute; top: 8px; right: 10px; font-size: 20px; }
.topic.next .ic { animation: glow 1.4s ease-in-out infinite; }
@keyframes glow { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.1); } }
@keyframes pop { 0% { transform: scale(.4); opacity: 0; } 70% { transform: scale(1.06); opacity: 1; } 100% { transform: scale(1); } }
@keyframes pop2 { 0% { transform: translateY(18px) scale(.4); opacity: 0; } 70% { transform: translateY(18px) scale(1.06); opacity: 1; } 100% { transform: translateY(18px) scale(1); } }
.foot { text-align: center; color: var(--muted); font-size: 11px; margin-top: 26px; }

/* ---- màn chơi ---- */
.qtop { display: flex; align-items: center; gap: 12px; }
.prog { flex: 1; height: 18px; border-radius: 999px; background: #fff; position: relative; box-shadow: inset 0 2px 4px rgba(0, 0, 0, .06); }
.prog .bar { height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, #ff8fbf, #ff5c9d); transition: width .5s cubic-bezier(.3, 1.4, .5, 1); }
.prog .runner { position: absolute; top: -10px; left: 0; font-size: 24px; transition: left .5s cubic-bezier(.3, 1.4, .5, 1); transform: translateX(-50%); }
.qcount { font-weight: 900; color: var(--muted); min-width: 44px; text-align: right; }
.qcard { margin-top: 18px; padding: 16px 14px 14px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.qprompt { display: flex; align-items: center; justify-content: center; gap: 10px; font-weight: 900; font-size: 21px; text-align: center; line-height: 1.3; width: 100%; }
.qprompt b { color: var(--pink); }
.qprompt small, .answers small { font-size: .7em; color: var(--muted); }
.qvisual { width: 100%; display: flex; justify-content: center; align-items: center; min-height: 40px; }
.qvisual .staff { width: 100%; max-width: 420px; height: auto; }
.qvisual .kbd { width: 100%; height: auto; }
.v-big .bignote, .v-big .symbol, .v-big .tsigbig { width: 150px; height: 160px; }
.qvisual.v-none { min-height: 0; }
.answers { margin-top: 18px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.answers.list { grid-template-columns: 1fr; }
.answers .ans {
  border-radius: 22px; padding: 16px 10px; font-weight: 900; font-size: 22px; color: #fff; min-height: 72px; line-height: 1.2;
  box-shadow: 0 6px 0 var(--edge); text-shadow: 0 2px 0 rgba(0, 0, 0, .12); animation: pop .4s cubic-bezier(.3, 1.6, .5, 1) both;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
}
.answers.list .ans { font-size: 18px; min-height: 60px; text-align: center; }
.answers .ans small { color: rgba(255, 255, 255, .85); }
.answers .ans:nth-child(1) { background: linear-gradient(180deg, #ff8db0, #ff5a8a); --edge: #e0396c; }
.answers .ans:nth-child(2) { background: linear-gradient(180deg, #7cc0ff, #3d9bff); --edge: #2179d8; animation-delay: .06s; }
.answers .ans:nth-child(3) { background: linear-gradient(180deg, #ffcf5e, #ffad14); --edge: #df8d00; animation-delay: .12s; }
.answers .ans:nth-child(4) { background: linear-gradient(180deg, #6be0b4, #25c288); --edge: #139c6a; animation-delay: .18s; }
.answers .ans:active { transform: translateY(5px); box-shadow: 0 1px 0 var(--edge); }
.answers.pics .ans { background: #fff !important; color: var(--ink); text-shadow: none; --edge: rgba(124, 92, 180, .25) !important; min-height: 130px; padding: 8px; }
.answers.pics .ans small { color: var(--muted); }
.ansnote svg { width: 64px; height: 84px; } .anssym svg { width: 90px; height: 90px; }
.answers .ans.ok { background: linear-gradient(180deg, #6be0b4, #25c288) !important; --edge: #139c6a !important; color: #fff; animation: okpop .5s ease; }
.answers .ans.bad { background: #cfc6dc !important; --edge: #a99fbb !important; animation: shake .45s ease; }
.answers .ans.dim { opacity: .45; }
.answers.pics .ans.ok svg *, .answers.pics .ans.ok small { color: #fff; }
@keyframes okpop { 0% { transform: scale(1); } 40% { transform: scale(1.1); } 100% { transform: scale(1); } }

/* hoạt hình trong câu hỏi */
.staff .tsig { font-family: Georgia, 'Times New Roman', serif; font-weight: 900; fill: var(--ink); text-anchor: middle; }
.staff .note.fly { transform-box: view-box; animation: fly .8s cubic-bezier(.3, 1.5, .5, 1) both; animation-delay: var(--d, 0s); }
@keyframes fly { 0% { transform: translateY(-90px); opacity: 0; } 60% { opacity: 1; } 100% { transform: translateY(0); } }
.staff .gap { fill: rgba(255, 92, 157, .08); stroke: var(--pink); stroke-width: 2.5; stroke-dasharray: 6 5; animation: pulse 1.2s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.staff .gaptext { font-size: 34px; font-weight: 900; fill: var(--pink); text-anchor: middle; }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }
.bignote.bounce .bn { transform-box: fill-box; transform-origin: bottom center; animation: hop .9s cubic-bezier(.3, 1.6, .5, 1) both, sway 2.4s ease-in-out .9s infinite; }
.bignote.pop .bn, .tsigbig.pop text { transform-box: fill-box; transform-origin: center; animation: pop .6s cubic-bezier(.3, 1.6, .5, 1) both; }
.symbol.wiggle .bn { transform-box: fill-box; transform-origin: center; animation: pop .6s cubic-bezier(.3, 1.6, .5, 1) both, wig 1.8s ease-in-out .6s infinite; }
@keyframes hop { 0% { transform: translateY(-80px) scale(.6); opacity: 0; } 60% { transform: translateY(0) scale(1.08, .92); opacity: 1; } 100% { transform: none; } }
@keyframes sway { 0%, 100% { transform: rotate(-4deg); } 50% { transform: rotate(4deg); } }
@keyframes wig { 0%, 100% { transform: rotate(-6deg) scale(1); } 50% { transform: rotate(6deg) scale(1.05); } }
.symbol .dyn { font-family: Georgia, 'Times New Roman', serif; font-style: italic; font-weight: 900; font-size: 76px; text-anchor: middle; }
.tsig2 { font-family: Georgia, 'Times New Roman', serif; font-weight: 900; font-size: 78px; text-anchor: middle; fill: var(--purple); }
.mathrow { display: flex; align-items: center; justify-content: center; gap: 2px; flex-wrap: nowrap; }
.mathrow .bignote { width: 64px; height: 92px; }
.mathrow .slide { animation: slidein .6s cubic-bezier(.3, 1.5, .5, 1) both; animation-delay: var(--d); }
.mathrow .op, .mathrow .qmark { font-size: 34px; font-weight: 900; color: var(--purple); animation: pop .4s both; animation-delay: var(--d); }
.mathrow .qmark { color: var(--pink); font-size: 44px; animation: pop .4s both, glow 1.2s ease-in-out infinite; animation-delay: var(--d), 1.5s; }
@keyframes slidein { 0% { transform: translateX(-60px); opacity: 0; } 100% { transform: none; opacity: 1; } }
.ear { display: flex; gap: 26px; justify-content: center; padding: 14px 0; }
.ear .bub { width: 84px; height: 84px; border-radius: 50%; display: grid; place-items: center; font-size: 34px; font-weight: 900; color: #fff; background: #d9cfe8; transition: transform .2s, background .2s; box-shadow: 0 6px 0 rgba(124, 92, 180, .2); }
.ear .bub.on { background: var(--pink); transform: scale(1.18); box-shadow: 0 0 0 12px rgba(255, 92, 157, .2); }
.ear .bub.b2.on { background: var(--blue); box-shadow: 0 0 0 12px rgba(61, 155, 255, .2); }
.eq { display: flex; gap: 8px; align-items: flex-end; height: 90px; }
.eq i { width: 16px; height: 20px; border-radius: 8px; background: linear-gradient(180deg, #ff8fbf, #9b6bff); }
.eq.on i { animation: eq .5s ease-in-out infinite alternate; }
.eq i:nth-child(2) { animation-delay: .1s; } .eq i:nth-child(3) { animation-delay: .2s; } .eq i:nth-child(4) { animation-delay: .3s; }
.eq i:nth-child(5) { animation-delay: .15s; } .eq i:nth-child(6) { animation-delay: .25s; } .eq i:nth-child(7) { animation-delay: .05s; }
@keyframes eq { from { height: 18px; } to { height: 86px; } }
.kbd .key rect { stroke: #cfc3e3; stroke-width: 1.5; transition: fill .15s; }
.kbd .white rect { fill: #fff; } .kbd .black rect { fill: #3b2d4f; stroke: #2a1f39; }
.kbd .key { cursor: pointer; }
.kbd .white.press rect { fill: #ffe0ee; } .kbd .black.press rect { fill: #7b5cff; }
.kbd .glow rect { animation: keyglow 1s ease-in-out infinite; }
.kbd .white.glow rect { fill: #ffd65a; }
@keyframes keyglow { 0%, 100% { fill: #ffd65a; } 50% { fill: #ff8fbf; } }
.kbd .klabel { font-size: 13px; font-weight: 900; fill: var(--muted); text-anchor: middle; pointer-events: none; }
.kbd .white.right rect { fill: #6be0b4; } .kbd .white.wrong rect { fill: #ffb3c7; }
.nlabel { font-size: 11px; font-weight: 900; fill: #fff; text-anchor: middle; }

/* phản hồi đúng / sai */
.feedback { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: center; padding: 0 10px calc(10px + env(safe-area-inset-bottom)); animation: up .35s cubic-bezier(.3, 1.4, .5, 1); }
.feedback[hidden] { display: none; }
.fb-inner { width: 100%; max-width: 540px; background: #fff; border-radius: 28px; padding: 14px 16px 16px; display: grid; grid-template-columns: 80px 1fr; gap: 6px 12px; align-items: center; box-shadow: 0 -6px 30px rgba(124, 92, 180, .25); border: 4px solid #ffd0e2; }
.fb-inner .mascot { width: 80px; height: 86px; }
.fb-text { display: grid; gap: 4px; } .fb-text b { font-size: 22px; color: #e0395b; } .fb-text span { font-weight: 700; font-size: 15px; line-height: 1.4; }
.fb-inner .btn { grid-column: 1 / -1; }
@keyframes up { from { transform: translateY(100%); } to { transform: none; } }

/* ---- kết quả ---- */
.res { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 10px; }
.res .mascot { width: 150px; height: 162px; }
.res h1 { margin: 0; font-size: 34px; font-weight: 900; color: var(--pink); }
.rstars { display: flex; gap: 10px; font-size: 64px; }
.rstars span { color: #e6dcf2; transform: scale(.6); transition: none; }
.rstars span.on { color: #ffb300; text-shadow: 0 4px 0 #df8d00; animation: starpop .6s cubic-bezier(.3, 1.8, .5, 1) both; }
@keyframes starpop { 0% { transform: scale(0) rotate(-90deg); } 100% { transform: scale(1) rotate(0); } }
.rscore { font-size: 18px; font-weight: 700; color: var(--muted); margin: 0 0 8px; }
.rbtns { display: grid; gap: 14px; width: 100%; max-width: 360px; }

/* ---- hộp thoại ---- */
.modal { position: fixed; inset: 0; z-index: 30; background: rgba(59, 45, 79, .35); display: flex; align-items: flex-end; justify-content: center; padding: 12px; }
.modal[hidden] { display: none; }
.sheet { width: 100%; max-width: 520px; padding: 20px; display: grid; gap: 12px; animation: up .3s ease; max-height: 90dvh; overflow: auto; }
.sheet h2 { margin: 0 0 4px; font-size: 22px; }
.row { display: flex; justify-content: space-between; align-items: center; font-weight: 700; padding: 6px 0; cursor: pointer; }
.row input { display: none; }
.sw { width: 54px; height: 32px; border-radius: 99px; background: #e6dcf2; position: relative; transition: background .2s; flex: none; }
.sw::after { content: ''; position: absolute; left: 4px; top: 4px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: left .2s; box-shadow: 0 2px 4px rgba(0, 0, 0, .15); }
.row input:checked + .sw { background: var(--green); }
.row input:checked + .sw::after { left: 26px; }
.setbtns { display: grid; gap: 10px; margin: 6px 0; }
.setbtns .btn { text-align: left; }
#installSteps ol { margin: 0; padding-left: 22px; line-height: 1.7; font-weight: 700; }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 40; overflow: hidden; }
.confetti i { position: absolute; top: -24px; animation: fall linear forwards; }
@keyframes fall { to { transform: translate(var(--dx), 110vh) rotate(var(--rot)); } }
