/* Biệt đội nhí: màu chủ đạo vàng nghệ #D09312 và xanh #0078C1, chữ Roboto. Chữ to, nút to cho trẻ lớp 1.
   Xanh lá chỉ dùng cho "đúng". */
:root {
  --c-vang: #d09312; --c-vang-dam: #93680d; --c-xanh: #0078c1; --c-xanh-dam: #00578c; --c-xanh-nhat: #3393cd;
  --kem: #fffaf0; --kem-2: #f7ead0; --vang: #f2c14e; --vang-2: var(--c-vang); --ngoi: var(--c-xanh); --la: #3f8f57; --la-2: #52a56a;
  --troi: #8cc8ec; --tim: var(--c-xanh-nhat); --tim-2: var(--c-xanh-dam); --muc: #22313f; --muc-2: #55606b; --hong: #f08ab0;
  --f-tieu: "Roboto", system-ui, sans-serif; --f-chu: "Roboto", system-ui, sans-serif;
  --bo: 18px; --bong: 0 6px 0 rgba(34, 49, 63, .18);
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; overflow: hidden; background: var(--kem); color: var(--muc); font-family: var(--f-chu); -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none; }
button { font: inherit; color: inherit; cursor: pointer; }
#game { position: fixed; inset: 0; }
#canh { position: absolute; inset: 0; }
#canh canvas { display: block; width: 100%; height: 100%; touch-action: none; }

/* ---------- nút chung ---------- */
.btn { min-height: 52px; padding: 10px 22px; border-radius: 999px; border: 3px solid var(--muc); background: #fff; font-weight: 700; font-size: 1.05rem; box-shadow: 0 4px 0 var(--muc); transition: transform .08s; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--muc); }
.btn.chinh { background: var(--vang); }
.btn.to { min-height: 64px; padding: 12px 34px; font-size: 1.3rem; }
.btn:disabled { opacity: .45; cursor: default; }
.hang { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 18px; }
.hang.cot { flex-direction: column; align-items: stretch; }

/* ---------- màn phủ ---------- */
.phu { position: absolute; inset: 0; display: grid; place-items: center; padding: 16px; z-index: 30; background: rgba(34, 49, 63, .35); overflow-y: auto; }
#mChao, #mBan, #mKhu { background: linear-gradient(180deg, rgba(124, 196, 232, .55), rgba(255, 247, 230, .2) 60%), transparent; }
.giay { width: min(560px, 100%); background: var(--kem); border: 3px solid var(--muc); border-radius: 28px; padding: 26px 24px 22px; box-shadow: 0 10px 0 rgba(34, 49, 63, .25); text-align: center; margin: auto; }
.nho-giay { width: min(400px, 100%); }
.kicker { margin: 0 0 6px; font-size: .82rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ngoi); }
h1 { font-family: var(--f-tieu); font-weight: 900; font-size: clamp(2.6rem, 9vw, 3.6rem); line-height: .95; margin: 4px 0 12px; color: var(--c-xanh-dam); }
h1 span { display: block; font-family: var(--f-chu); font-weight: 800; font-size: clamp(1.05rem, 4vw, 1.35rem); color: var(--c-vang-dam); margin-top: 8px; }
h2 { font-family: var(--f-tieu); font-weight: 900; color: var(--c-xanh-dam); font-size: clamp(1.6rem, 6vw, 2.1rem); margin: 4px 0 12px; line-height: 1.1; }
.lead { font-size: 1.08rem; line-height: 1.5; margin: 0 auto; max-width: 30em; }
.nho { font-size: .82rem; color: var(--muc-2); margin: 16px 0 0; line-height: 1.45; }
.caidat { display: flex; flex-wrap: wrap; gap: 8px 14px; justify-content: center; margin-top: 18px; font-size: .95rem; }
.caidat label { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; cursor: pointer; }
.caidat input { width: 22px; height: 22px; accent-color: var(--la); }
.lop-o { margin-top: 14px; font-size: .95rem; }
.lop-o p { margin: 6px 0; }
.lien { background: none; border: 0; color: var(--ngoi); text-decoration: underline; font-weight: 700; padding: 4px; }
.lop-form { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.lop-form input { min-height: 46px; border: 2px solid var(--muc); border-radius: 12px; padding: 6px 12px; font: inherit; width: 9em; }
.lop-tb.loi { color: var(--ngoi); }

/* chọn nhân vật */
.ban-chon { display: flex; gap: 14px; justify-content: center; margin: 8px 0 14px; }
.ban { flex: 1; max-width: 190px; border: 3px solid var(--muc); border-radius: 22px; background: #fff; padding: 12px 10px 10px; box-shadow: var(--bong); }
.ban .anh { display: block; width: 100%; aspect-ratio: 1; }
.ban .anh svg, .ban .anh img { width: 100%; height: 100%; object-fit: contain; }
.ban b { display: block; font-size: 1.1rem; margin-top: 4px; }
.ban.chon { background: var(--vang); outline: 4px solid var(--la); outline-offset: 2px; }
.ten-o { display: grid; gap: 6px; font-weight: 700; max-width: 320px; margin: 0 auto; }
.ten-o input { min-height: 52px; border: 3px solid var(--muc); border-radius: 14px; font: inherit; font-size: 1.15rem; padding: 6px 14px; text-align: center; -webkit-user-select: text; user-select: text; }

/* chọn khu */
.ds-khu { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 10px; text-align: left; }
.ds-khu button { width: 100%; display: grid; grid-template-columns: 54px 1fr 56px auto; align-items: center; gap: 12px; border: 3px solid var(--muc); border-radius: 18px; background: #fff; padding: 10px 14px; box-shadow: var(--bong); text-align: left; }
.ds-khu button:disabled { background: #e9edf0; box-shadow: none; opacity: .75; cursor: default; }
.ds-khu .so { width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; background: var(--vang); font: 800 1.5rem var(--f-tieu); border: 3px solid var(--muc); }
.ds-khu button:disabled .so { background: #d3d9de; }
.ds-khu .trum { width: 56px; height: 56px; object-fit: contain; }
.ds-khu button:disabled .trum { filter: grayscale(.6); opacity: .8; }
.ds-khu b { display: block; font-size: 1.1rem; }
.ds-khu small { color: var(--muc-2); font-size: .88rem; }
.ds-khu .nhan { font-size: .85rem; font-weight: 700; color: var(--la); white-space: nowrap; }

/* ---------- HUD ---------- */
#hud { position: absolute; top: max(10px, env(safe-area-inset-top)); left: 10px; right: 10px; display: flex; gap: 8px; align-items: center; z-index: 10; pointer-events: none; flex-wrap: wrap; }
.chip { pointer-events: auto; display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 6px 14px; border-radius: 999px; background: rgba(255, 247, 230, .94); border: 2.5px solid var(--muc); font-weight: 700; font-size: .95rem; box-shadow: 0 3px 0 rgba(34, 49, 63, .25); }
.ten-khu { background: var(--vang); }
.tien { gap: 4px; }
.tien i { width: 24px; height: 24px; border-radius: 50%; background: #d3d9de; border: 2px solid var(--muc); display: inline-grid; place-items: center; font-style: normal; font-size: .7rem; }
.tien i.quy { background: var(--tim); }
.tien i.xong { background: var(--la-2); }
.tien i.xong::after { content: "✓"; color: #fff; font-weight: 800; }
.tien i.trum { width: 30px; height: 30px; }
.chuoi { display: inline-flex; gap: 3px; }
.chuoi i { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--muc); background: #fff; }
.chuoi i.on { background: var(--vang); }
.den { margin-left: 4px; }
.nut { margin-left: auto; width: 48px; height: 48px; justify-content: center; padding: 0; }
.pz { width: 14px; height: 16px; border-left: 5px solid var(--muc); border-right: 5px solid var(--muc); }
@media (max-width: 520px) { #hChuoi { order: 5; } .ten-khu { font-size: .85rem; padding: 6px 10px; } .tien i { width: 20px; height: 20px; } .tien i.trum { width: 24px; height: 24px; } }

/* ---------- thoại ---------- */
#thoai { position: absolute; left: 50%; bottom: max(14px, env(safe-area-inset-bottom)); translate: -50% 0; width: min(720px, calc(100% - 20px)); display: grid; grid-template-columns: 64px 1fr 48px; gap: 12px; align-items: center; background: var(--kem); border: 3px solid var(--muc); border-radius: 22px; padding: 12px 14px 22px; box-shadow: 0 6px 0 rgba(34, 49, 63, .25); z-index: 20; cursor: pointer; animation: len .25s ease-out; }
@keyframes len { from { translate: -50% 20px; opacity: 0; } }
.mat { width: 64px; height: 64px; border-radius: 50%; border: 3px solid var(--muc); overflow: hidden; background: #fff; display: block; }
.mat svg, .mat img { width: 100%; height: 100%; display: block; object-fit: cover; }
.mat { background: #fde7c4; }
.noi b { display: block; color: var(--ngoi); font-size: .95rem; }
.noi p { margin: 2px 0 0; font-size: clamp(1.08rem, 3.6vw, 1.3rem); line-height: 1.4; font-weight: 600; }
.nghe { width: 48px; height: 48px; border-radius: 50%; border: 2.5px solid var(--muc); background: #fff; font-size: 1.3rem; display: grid; place-items: center; padding: 0; }
#thoai .tiep { position: absolute; right: 16px; bottom: 4px; font-size: .78rem; color: var(--muc-2); font-weight: 700; }
#goiY { position: absolute; top: 70px; left: 50%; translate: -50% 0; width: min(560px, calc(100% - 20px)); display: grid; grid-template-columns: 48px 1fr; gap: 10px; align-items: center; background: #fff; border: 3px solid var(--muc); border-radius: 18px; padding: 8px 12px; z-index: 26; box-shadow: var(--bong); }
#goiY .mat { width: 48px; height: 48px; }
#goiY p { margin: 0; font-weight: 600; font-size: 1.02rem; line-height: 1.35; }

/* ---------- khung câu hỏi ---------- */
#hoi { position: absolute; inset: 0; z-index: 25; display: flex; align-items: flex-end; justify-content: center; padding: 10px; background: rgba(34, 49, 63, .22); }
#hoi .the { width: min(760px, 100%); max-height: calc(100% - 64px); overflow-y: auto; background: var(--kem); border: 3px solid var(--muc); border-radius: 28px; padding: 14px 16px 12px; box-shadow: 0 8px 0 rgba(34, 49, 63, .3); animation: len2 .3s ease-out; }
@keyframes len2 { from { transform: translateY(40px); opacity: 0; } }
.hoi-dau { display: grid; grid-template-columns: 48px 1fr auto; gap: 10px; align-items: center; }
.hoi-dau h2 { margin: 0; font-family: var(--f-chu); font-weight: 800; font-size: clamp(1.25rem, 4.6vw, 1.7rem); line-height: 1.25; text-align: left; }
.den-soi { min-height: 44px; border-radius: 999px; border: 2.5px solid var(--muc); background: var(--vang); font-weight: 700; padding: 4px 12px; }
.hinh { margin: 10px 0 4px; display: grid; place-items: center; }
.nhom { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.nhom.lon { max-width: 420px; }
.o { position: relative; display: inline-block; }
.nhom.lon .ic { width: clamp(44px, 12vw, 64px); height: clamp(44px, 12vw, 64px); }
.o .dem { position: absolute; top: -6px; right: -6px; min-width: 26px; height: 26px; border-radius: 13px; background: var(--ngoi); color: #fff; font-weight: 800; font-size: .9rem; display: grid; place-items: center; border: 2px solid #fff; animation: bat .25s ease-out; }
@keyframes bat { from { transform: scale(0); } }
.hai-hang { position: relative; display: grid; gap: 22px; }
.hang-do { display: flex; gap: 8px; }
.hang-do .ic { width: clamp(38px, 9vw, 54px); height: clamp(38px, 9vw, 54px); }
.noi-day { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.so-sanh { display: flex; align-items: center; gap: clamp(12px, 4vw, 28px); }
.ss-so { display: grid; justify-items: center; gap: 6px; }
.ss-so b { font: 800 clamp(3rem, 14vw, 4.4rem)/1 var(--f-chu); }
.cham { display: grid; grid-template-columns: repeat(5, 12px); gap: 4px; min-height: 12px; }
.cham i { width: 12px; height: 12px; border-radius: 50%; background: var(--troi); border: 1.5px solid var(--muc); }
.o-dau { width: clamp(64px, 18vw, 84px); height: clamp(64px, 18vw, 84px); border: 3px dashed var(--muc); border-radius: 18px; display: grid; place-items: center; font: 800 clamp(2.4rem, 10vw, 3.2rem)/1 var(--f-chu); color: var(--tim); background: #fff; }
.o-dau.dien { border-style: solid; color: var(--la); }
.tia-so { display: flex; gap: 2px; margin-top: 12px; opacity: .55; transition: opacity .3s, transform .3s; }
.tia-so span { width: clamp(22px, 6.5vw, 34px); text-align: center; border-top: 3px solid var(--muc); padding-top: 4px; font-weight: 700; font-size: .95rem; position: relative; }
.tia-so span::before { content: ""; position: absolute; top: -8px; left: 50%; width: 3px; height: 10px; background: var(--muc); translate: -50% 0; }
.tia-so span.hl { color: var(--ngoi); font-size: 1.15rem; }
.tia-so.sang { opacity: 1; transform: scale(1.04); }
.gom { display: flex; gap: 14px; align-items: center; justify-content: center; flex-wrap: wrap; }
.gom > div { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px; border: 3px solid var(--muc); border-radius: 16px; min-height: 64px; min-width: 64px; justify-content: center; max-width: 280px; background: #fff; }
.gom .ic { width: clamp(36px, 9vw, 48px); height: clamp(36px, 9vw, 48px); }
.gom-b { border-style: dashed !important; }
.gom-b .o.an .ic { opacity: .12; }
.gom-b .o.hien .ic { opacity: 1; transition: opacity .3s; }
.gom-cau { font-size: clamp(1.6rem, 6vw, 2rem); font-weight: 800; margin: 10px 0 0; }
.gom-cau .hoi { color: var(--tim); }
.day-so { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.day-so b { width: clamp(52px, 15vw, 72px); height: clamp(52px, 15vw, 72px); display: grid; place-items: center; border: 3px solid var(--muc); border-radius: 16px; background: #fff; font-size: clamp(1.8rem, 7vw, 2.4rem); }
.day-so b.trong { border-style: dashed; color: var(--tim); }
.day-so b.sang, .the-so.sang { background: var(--vang); }
.the-goi { margin: 0; font-weight: 800; color: var(--muc-2); }
.day-chon { display: flex; gap: 8px; min-height: 60px; justify-content: center; flex-wrap: wrap; }
.day-chon b { width: 52px; height: 52px; display: grid; place-items: center; border: 3px solid var(--la); border-radius: 14px; background: #e6f4e9; font-size: 1.6rem; animation: bat .2s; }

.chon { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin: 14px 0 6px; }
.chon button { min-width: clamp(76px, 20vw, 108px); min-height: clamp(76px, 20vw, 96px); border: 3px solid var(--muc); border-radius: 22px; background: #fff; box-shadow: 0 5px 0 var(--muc); display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 12px; font-weight: 800; transition: transform .08s; }
.chon button:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--muc); }
.chon .so { font-size: clamp(2rem, 8vw, 2.6rem); line-height: 1; }
.chon .ic.nho { width: 34px; height: 34px; }
.chon .chu { font-size: clamp(1.05rem, 4vw, 1.3rem); }
.chon button.nhom-nut { flex: 1 1 180px; max-width: 230px; padding: 10px; }
.chon .nhom.nho .ic { width: 30px; height: 30px; }
.chon .nhom.nho { gap: 3px; }
.chon button.sai { animation: lac .4s; background: #e9edf0; opacity: .55; }
.chon button.dung { background: #c9ecd2; border-color: var(--la); box-shadow: 0 5px 0 var(--la); }
.chon button.goi { outline: 5px solid var(--vang); outline-offset: 3px; animation: nay .7s ease-in-out infinite alternate; }
.chon button.da { background: #e6f4e9; border-color: var(--la); opacity: .6; }
.chon button.bo { visibility: hidden; }
@keyframes lac { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }
@keyframes nay { to { transform: translateY(-4px) scale(1.03); } }
.loi-giai { background: #fff; border: 3px solid var(--vang-2); border-radius: 18px; padding: 10px 14px; margin: 8px 0; text-align: left; }
.loi-giai ol { margin: 6px 0 10px; padding-left: 1.4em; font-size: 1.1rem; font-weight: 600; line-height: 1.5; }
.loi-giai .btn { width: 100%; }
.nguon { margin: 6px 0 0; font-size: .75rem; color: var(--muc-2); text-align: right; }
.trum-thanh { display: grid; grid-template-columns: 52px 1fr; gap: 10px; align-items: center; margin-bottom: 10px; padding-bottom: 10px; border-bottom: 2px dashed rgba(34, 49, 63, .25); }
.trum-thanh .mat { width: 52px; height: 52px; }
.trum-thanh b { font-size: 1rem; }
.trum-thanh span#trumPha { margin-left: 8px; font-size: .85rem; color: var(--muc-2); font-weight: 700; }
.hp { height: 14px; border: 2.5px solid var(--muc); border-radius: 8px; background: #fff; overflow: hidden; margin-top: 4px; }
.hp i { display: block; height: 100%; background: var(--tim); width: 100%; transition: width .5s; }

/* đạo đức */
.dd-chon { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.dd-chon button { border: 3px solid var(--muc); border-radius: 18px; background: #fff; padding: 8px; box-shadow: var(--bong); font-weight: 700; font-size: 1rem; line-height: 1.3; }
.dd-chon svg { width: 100%; height: auto; display: block; margin-bottom: 6px; border-radius: 10px; }
.dd-chon button.dung { background: #c9ecd2; border-color: var(--la); }
.dd-chon button.sai { opacity: .6; }
.dd-loi { min-height: 2.8em; font-weight: 600; font-size: 1.05rem; line-height: 1.45; }
@media (max-width: 380px) { .dd-chon { grid-template-columns: 1fr; } }

/* kết quả */
.sao-to { font-size: 3rem; letter-spacing: 6px; color: #d3d9de; }
.sao-to .on { color: var(--vang); text-shadow: 0 3px 0 var(--vang-2); }
.manh { display: flex; gap: 12px; align-items: center; justify-content: center; background: #fff; border: 3px solid var(--muc); border-radius: 18px; padding: 8px 14px; margin: 8px 0; text-align: left; }
.manh p { margin: 0; font-size: 1.02rem; line-height: 1.4; }
.choi { width: 54px; height: 54px; flex: none; background: linear-gradient(135deg, transparent 44%, #a8743f 44%, #a8743f 56%, transparent 56%); border-radius: 12px; border: 2px dashed var(--vang-2); }
.so-lieu { display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; max-width: 300px; margin: 10px auto; text-align: left; }
.so-lieu dt { color: var(--muc-2); }
.so-lieu dd { margin: 0; font-weight: 800; }

.loi-js { position: absolute; inset: auto 16px 16px; z-index: 60; background: #fff; border: 3px solid var(--ngoi); border-radius: 16px; padding: 12px; font-weight: 700; text-align: center; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- màu chủ đạo ---------- */
.giay { border-top: 8px solid var(--c-vang); }
.btn.chinh { background: var(--c-vang); color: #fff; border-color: var(--c-vang-dam); box-shadow: 0 4px 0 var(--c-vang-dam); }
.btn.chinh:active { box-shadow: 0 1px 0 var(--c-vang-dam); }
.ten-khu { background: var(--c-xanh); color: #fff; }
.ds-khu .so { background: var(--c-vang); color: #fff; }

/* ---------- chuyển cảnh mượt ---------- */
@keyframes bd-mo { from { opacity: 0; } to { opacity: 1; } }
@keyframes bd-noi { from { opacity: 0; transform: translateY(18px) scale(.96); } to { opacity: 1; transform: none; } }
.phu:not([hidden]) { animation: bd-mo .3s ease-out; }
.phu:not([hidden]) > .giay { animation: bd-noi .38s cubic-bezier(.2, .8, .3, 1.2); }
#canh canvas { animation: bd-mo .7s ease-out; }
@media (prefers-reduced-motion: reduce) {
  .phu:not([hidden]), .phu:not([hidden]) > .giay, #canh canvas { animation: none; }
}
@media (max-width: 420px) { .ds-khu button { grid-template-columns: 44px 1fr 40px auto; gap: 8px; padding: 10px; } .ds-khu .so { width: 44px; height: 44px; } .ds-khu .trum { width: 40px; height: 40px; } }
