/* Hộp Trí Tuệ Bé — giao diện căn hộ. Bảng màu lấy từ chính sprite của gói gốc
   (swatch_*.png, button_play_main.png, badge_panel_bg.png), không tự đặt màu mới. */
:root {
  --do: #E53935; --xanh-la: #43A047; --vang: #FDD835; --xanh-duong: #1E88E5;
  --cam: #FB8C00; --tim: #8E24AA; --tim-nut: #AB47BC;
  --troi: #81D4FA; --bang: #37474F;
  --nen: #E8F6FE; --the: #FFFFFF; --chu: #263238; --chu-mo: #607D8B;
  --vien: #B3E5FC; --bong: 0 3px 0 rgba(38,50,56,.18);
  /* vùng an toàn trình duyệt (tai thỏ, thanh điều hướng) + hai dải hub (đỉnh 46px, đáy 60px khi chạy trong khung) */
  --an-toan-tren: env(safe-area-inset-top, 0px);
  --an-toan-phai: env(safe-area-inset-right, 0px);
  --an-toan-duoi: env(safe-area-inset-bottom, 0px);
  --an-toan-trai: env(safe-area-inset-left, 0px);
  --hub-tren: var(--an-toan-tren); --hub-duoi: var(--an-toan-duoi);
  --hub-trai: var(--an-toan-trai); --hub-phai: var(--an-toan-phai);
  --r: 18px;
  --nen-anh: none;   /* skin khai anh.nen thì game đặt url() vào đây */
  /* 20-11 phiếu SKIN-THAY-HET-NUT: mọi màu từng viết cứng đều là biến — bộ khai trong atlas.json "bien" để đổi */
  --nen-tren: #BBE7FB; --nen-duoi: #D7F2DC; --chu-nut: #fff; --hop: #fff; --phu: rgba(38,50,56,.55);
  --the-toa: #FFF8E1; --the-thuong: #FFFDE7; --the-mon: #F5F9FC; --tab: #ECEFF1; --tab-on: var(--xanh-duong);
  --tat: #CFD8DC; --vang-dam: #E6A700; --sao-mo: #E0E0E0; --chuoi: var(--cam); --quang-chon: rgba(142,36,170,.22);
  /* 29-11 trạm chấm 5811031: màu chữ trên nút Chơi và nhãn màn chính theo bộ — bộ nền sáng khai chữ tối + viền sáng */
  --chu-choi: var(--chu-nut); --vien-chu-choi: transparent; --chu-nhan: var(--chu-mo); --vien-chu-nhan: transparent;
  --chu-logo: #5D2E0F; --vien-chu-logo: #fff;
  /* 01-12 trạm chấm 5811031: chữ nằm THẲNG trên nền màn chơi (tên vật, dòng hướng dẫn) — tách khỏi --chu-mo vẫn tô chữ trong hộp sáng */
  --chu-tren-nen: var(--chu-mo); --vien-chu-tren-nen: transparent;
}
body.trong-hub { --hub-tren: calc(46px + var(--an-toan-tren)); --hub-duoi: calc(60px + var(--an-toan-duoi)); }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { width: 100%; height: 100%; height: 100dvh; margin: 0; overflow: hidden; }
body {
  font-family: "Baloo 2", "Quicksand", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  background: var(--nen-anh) center / cover no-repeat, linear-gradient(var(--nen-tren), var(--nen) 42%, var(--nen-duoi));
  color: var(--chu); user-select: none; touch-action: manipulation;
}
img { -webkit-user-drag: none; user-drag: none; max-width: 100%; }

#app {
  position: fixed; inset: var(--hub-tren) var(--hub-phai) var(--hub-duoi) var(--hub-trai);
  display: flex; flex-direction: column; overflow: hidden;
}
.man { position: absolute; inset: 0; display: flex; flex-direction: column; overflow: hidden; }
.man.vao-man { animation: man-vao .24s cubic-bezier(.22,1.15,.5,1); }
@keyframes man-vao { 0% { opacity: 0; transform: translateY(8px) scale(.985) } 100% { opacity: 1; transform: translateY(0) scale(1) } }
#man-choi::after { content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 30; opacity: 0;
  box-shadow: inset 0 0 0 4px rgba(229,57,53,.55), inset 0 0 34px rgba(229,57,53,.26); }
#man-choi.phan-hoi-sai::after { animation: canh-sai .42s ease-out forwards; }
@keyframes canh-sai { 0% { opacity: 0 } 24% { opacity: 1 } 100% { opacity: 0 } }
[hidden] { display: none !important; }

/* ---------- nút chung, ô chạm >= 44x44px cho tay trẻ con ---------- */
.nut {
  border: 0; border-radius: var(--r); background: var(--tim-nut); color: var(--chu-nut);
  font: 700 17px/1.15 inherit; padding: 13px 20px; min-width: 44px; min-height: 48px; cursor: pointer;
  box-shadow: 0 4px 0 rgba(0,0,0,.18); transition: transform .1s cubic-bezier(.22,1.4,.5,1), box-shadow .1s, filter .12s;
  max-width: 100%; overflow-wrap: break-word;
}
.nut:active { transform: translateY(3px) scale(.97); box-shadow: 0 1px 0 rgba(0,0,0,.18); }
.nut.phu { background: var(--the); color: var(--chu); box-shadow: 0 3px 0 var(--vien); }
.nut.xanh { background: var(--xanh-la); } .nut.cam { background: var(--cam); }
.nut.tron { width: 60px; height: 60px; min-width: 44px; min-height: 60px; padding: 0; border-radius: 50%;
  display: grid; place-items: center; background: var(--the); box-shadow: 0 3px 0 var(--vien); }
.nut.tron img { width: 34px; height: 34px; }
.nut.tron .dau { font-size: 28px; color: var(--chu-mo); line-height: 1; }
.nut[disabled] { opacity: .45; }

/* ---------- MÀN CHÍNH ---------- */
#man-chinh {
  align-items: center; justify-content: center; justify-content: safe center;
  gap: 14px; padding: 10px 12px; text-align: center;
  overflow-y: auto; overflow-x: hidden;
}
#logo-khung { position: relative; width: min(86%, 330px); max-width: 100%; line-height: 0; flex: 0 0 auto; }
#logo { width: 100%; height: auto; }
/* tên game của bộ viết lên biển trống của logo (atlas "truyen".ten_game) — bộ không có truyện thì ẩn, giữ logo gốc */
#logo-chu { position: absolute; left: 25%; right: 25%; top: 51%; bottom: 14%; display: grid; place-items: center; text-align: center;
  font-size: clamp(9px, 3vw, 12px); font-weight: 900; line-height: 1.05; color: var(--chu-logo);
  text-shadow: 0 0 2px var(--vien-chu-logo), 0 0 2px var(--vien-chu-logo), 0 0 3px var(--vien-chu-logo); }
#truyen { width: min(100%, 380px); background: rgba(255,255,255,.82); border-radius: 14px; padding: 8px 12px;
  font-size: 12px; line-height: 1.35; color: var(--chu); text-align: left; overflow-wrap: break-word; }
#truyen p { margin: 0; }
#truyen-ten { margin: 0 0 4px; font-size: 16px; font-weight: 900; text-align: center; color: var(--chu-logo); }
#truyen-muc-tieu { margin-top: 4px !important; font-weight: 800; }
#man-chinh.co-truyen { gap: 8px; }
#man-chinh.co-truyen #cu-meo { width: 84px; height: 84px; }
#cu-meo.ngang, #man-chinh.co-truyen #cu-meo.ngang { width: min(70vw, 300px); height: auto; max-height: 120px; object-fit: contain; }
#nguoi-choi { display: flex; align-items: center; gap: 8px; background: var(--the); border: 2px solid var(--vien);
  border-radius: 999px; padding: 4px 14px 4px 4px; font-size: 14px; max-width: 100%; flex: 0 0 auto; }
#nguoi-choi img { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; flex: 0 0 auto; }
#nguoi-ten { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
#cu-meo { width: 108px; height: 108px; animation: nhun 2.4s ease-in-out infinite; flex: 0 0 auto; }
@keyframes nhun { 0%,100% { transform: translateY(0) } 50% { transform: translateY(-9px) } }
#nut-choi { font-size: clamp(18px, 5.5vw, 22px); padding: 15px 38px; border-radius: 26px; color: var(--chu-choi);
  text-shadow: 0 0 2px var(--vien-chu-choi), 0 0 2px var(--vien-chu-choi), 0 0 3px var(--vien-chu-choi); flex: 0 0 auto; }
.hang-nut { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; max-width: 100%; }
.hang-nut .o { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 72px; }
.hang-nut .o span { font-size: 11px; font-weight: 700; color: var(--chu-nhan); line-height: 1.15; max-width: 100%; overflow-wrap: break-word; }
#khau-hieu { margin: 0; font-size: 13px; color: var(--chu-nhan); font-weight: 700; max-width: 100%; overflow-wrap: break-word; }
.hang-nut .o span, #khau-hieu { text-shadow: 0 0 2px var(--vien-chu-nhan), 0 0 2px var(--vien-chu-nhan), 0 0 3px var(--vien-chu-nhan); }

/* ---------- THANH SỐ (điểm · sao · xu) — hàng riêng ngay dưới dải đỉnh ---------- */
.thanh-so { display: flex; align-items: center; gap: 8px; padding: 7px 10px; flex: 0 0 auto; max-width: 100%; }
#nut-ve { min-width: 44px; min-height: 44px; padding: 8px 12px; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; font-size: 20px; }
.nut.nut-am { width: 44px; height: 44px; min-width: 44px; min-height: 44px; padding: 0; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; color: var(--chu); }
.nut.nut-am .ic-am { width: 22px; height: 22px; display: block; pointer-events: none; }
.nut.nut-am .ic-am .loa { fill: currentColor; }
.nut.nut-am .ic-am .song { fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
.nut.nut-am .ic-am .gach { fill: none; stroke: var(--do); stroke-width: 2.4; stroke-linecap: round; display: none; }
.nut.nut-am.tat { color: var(--chu-mo); box-shadow: 0 3px 0 var(--vien), inset 0 0 0 2px rgba(229,57,53,.35); }
.nut.nut-am.tat .ic-am .song { display: none; }
.nut.nut-am.tat .ic-am .gach { display: block; }
.huy { display: flex; align-items: center; gap: 5px; background: var(--bang); color: var(--chu-nut);
  border-radius: 999px; padding: 5px 12px; font-weight: 800; font-size: 14px; min-height: 30px; white-space: nowrap; flex: 0 0 auto;
  transition: transform .16s ease, filter .16s ease; }
.huy.nhay-diem { animation: huy-nhay .38s cubic-bezier(.22,1.5,.5,1); }
@keyframes huy-nhay { 0% { transform: scale(1); filter: brightness(1) }
  45% { transform: scale(1.16); filter: brightness(1.15) drop-shadow(0 0 8px rgba(253,216,53,.65)) }
  100% { transform: scale(1); filter: brightness(1) } }
.huy img { width: 18px; height: 18px; }
.huy.xu { background: var(--cam); }
.thanh-so .lap { flex: 1 1 0; min-width: 0; }
.chip-tuoi { background: var(--the); color: var(--chu-mo); border: 2px solid var(--vien);
  border-radius: 999px; padding: 4px 10px; font-size: 11px; font-weight: 800;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 0 1 auto; }

/* ---------- LỜI NHẮC ---------- */
.loi-nhac { display: flex; align-items: center; gap: 10px; margin: 0 10px 6px;
  background: var(--the); border: 3px solid var(--vien); border-radius: var(--r); padding: 8px 10px 8px 12px;
  transition: border-color .2s, box-shadow .2s; flex: 0 0 auto; }
.loi-nhac.dang-doc { border-color: var(--xanh-duong); box-shadow: 0 0 0 4px rgba(30,136,229,.18); }
.loi-nhac b { flex: 1; min-width: 0; font-size: 16px; line-height: 1.25; overflow-wrap: break-word; }
.loi-nhac .nut { position: relative; min-width: 44px; min-height: 44px; padding: 8px 12px; font-size: 18px;
  display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; }
#nut-doc.dang-doc { animation: nut-doc-nhip .55s ease-in-out 2; }
#nut-doc.dang-doc::after { content: ''; position: absolute; inset: -4px; border-radius: inherit;
  border: 3px solid var(--xanh-duong); opacity: 0; pointer-events: none; animation: song-doc .9s ease-out infinite; }
@keyframes nut-doc-nhip { 0%,100% { transform: scale(1) } 50% { transform: scale(1.1) } }
@keyframes song-doc { 0% { transform: scale(.94); opacity: .85 } 100% { transform: scale(1.28); opacity: 0 } }

/* ---------- THANH TIẾN ĐỘ MÀN CHƠI ---------- */
#tien-do-man { display: flex; align-items: center; gap: 8px; margin: 0 12px 6px; flex: 0 0 auto; }
.thanh-tien-do { flex: 1; height: 10px; border-radius: 999px; background: rgba(255,255,255,.78);
  border: 2px solid var(--vien); overflow: hidden; box-shadow: inset 0 1px 2px rgba(0,0,0,.08); }
#tien-do-lap { display: block; height: 100%; width: 0%; border-radius: 999px;
  background: linear-gradient(90deg, var(--xanh-la), var(--vang));
  transition: width .32s cubic-bezier(.34,1.35,.64,1); }
.cham-tien-do { display: flex; align-items: center; gap: 5px; flex: 0 0 auto; }
.cham-tien-do .cham { width: 18px; height: 18px; border-radius: 50%; background: rgba(255,255,255,.85);
  border: 2px solid var(--vien); display: grid; place-items: center; font-size: 11px; font-weight: 900;
  color: #fff; transition: transform .2s, background .2s, border-color .2s; }
.cham-tien-do .cham.hien-tai { border-color: var(--tim); box-shadow: 0 0 0 3px var(--quang-chon); transform: scale(1.1); }
.cham-tien-do .cham.xong { background: var(--xanh-la); border-color: var(--xanh-la); animation: cham-no .34s cubic-bezier(.22,1.55,.5,1); }
@keyframes cham-no { 0% { transform: scale(.5) } 55% { transform: scale(1.32) } 100% { transform: scale(1) } }

/* ---------- MỐC THƯỞNG CHUỖI XUYÊN MÀN ---------- */
#moc-thuong { position: relative; display: flex; align-items: center; gap: 6px; margin: 0 12px 6px; padding: 4px 10px;
  border-radius: 999px; background: rgba(255,255,255,.84); border: 2px solid var(--vien);
  font-size: 12px; font-weight: 800; color: var(--chu); flex: 0 0 auto; max-width: calc(100% - 24px);
  overflow: hidden; pointer-events: none; transition: border-color .2s, box-shadow .2s, background-color .2s; }
#moc-thuong .moc-bieu-tuong { color: var(--cam); font-size: 14px; line-height: 1; flex: 0 0 auto; }
#moc-thuong .moc-nhan { color: var(--chu-mo); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 0 1 auto; }
#moc-thuong .moc-thanh { flex: 1 1 48px; min-width: 36px; height: 8px; border-radius: 999px;
  background: rgba(38,50,56,.1); overflow: hidden; }
#moc-lap { display: block; height: 100%; width: 0%; border-radius: 999px;
  background: linear-gradient(90deg, var(--cam), var(--vang));
  transition: width .3s cubic-bezier(.34,1.35,.64,1); }
#moc-thuong .moc-so { font-size: 12px; color: var(--chu); white-space: nowrap; flex: 0 0 auto; }
#moc-thuong .moc-qua { background: var(--cam); color: #fff; border-radius: 999px; padding: 1px 7px;
  font-size: 11px; font-weight: 900; white-space: nowrap; flex: 0 0 auto; }
#moc-thuong.sap-dat { border-color: var(--cam); box-shadow: 0 0 0 3px rgba(251,140,0,.22); }
#moc-thuong.sap-dat .moc-qua { animation: goi-y-nhip 1.1s ease-in-out infinite; }
#moc-thuong.dat-moc { border-color: var(--vang-dam); background: var(--the-thuong);
  box-shadow: 0 0 0 4px rgba(253,216,53,.45); animation: bup-nhe .42s cubic-bezier(.22,1.5,.5,1); }
#moc-thuong.dat-moc::after { content: ''; position: absolute; top: 0; bottom: 0; left: -55%; width: 48%;
  background: linear-gradient(110deg, transparent, rgba(255,255,255,.85), transparent);
  pointer-events: none; animation: loa-sang .62s ease forwards; }
#moc-thuong.mat-moc { border-color: var(--do); background: rgba(255,235,238,.94); animation: lac .36s ease; }

/* ---------- SÂN CHƠI ---------- */
#san { flex: 1; display: flex; flex-direction: column; justify-content: space-evenly; gap: 6px; padding: 0 10px 10px; min-height: 0; overflow: hidden; }
#san.rung-sai { animation: san-rung .32s ease; }
@keyframes san-rung { 0%,100% { transform: translateX(0) } 22% { transform: translateX(-4px) } 55% { transform: translateX(4px) } 80% { transform: translateX(-2px) } }
.khu { flex: 0 1 auto; display: grid; gap: 8px; align-content: center; min-height: 0; max-width: 100%; }
.khu.bon { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.khu.ba { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.khu.luoi2 { grid-template-columns: repeat(2, minmax(0, 1fr)); flex: 1 1 auto; grid-auto-rows: 1fr; max-height: 74%; }
.khu.luoi2 .the img { max-width: min(74%, 144px); max-height: 74%; width: auto; height: auto; }
.nhan-khu { margin: 0 2px -2px; font-size: 11px; font-weight: 800; color: var(--chu-tren-nen); text-transform: uppercase; letter-spacing: .4px; overflow-wrap: break-word; }

.the {
  position: relative; background: var(--the); border: 3px solid var(--vien); border-radius: var(--r);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  padding: 6px 4px; min-width: 44px; min-height: 64px; max-width: 100%; cursor: pointer; overflow: hidden;
  transition: transform .12s cubic-bezier(.22,1.35,.5,1), border-color .14s, box-shadow .14s, opacity .18s;
}
.the:active:not(.xong) { transform: scale(.95); }
.the img { width: 100%; max-width: 98px; height: auto; aspect-ratio: 1; object-fit: contain; pointer-events: none; transition: transform .16s ease; }
.nhan-khu, .the .ten { text-shadow: 0 0 2px var(--vien-chu-tren-nen), 0 0 2px var(--vien-chu-tren-nen), 0 0 3px var(--vien-chu-tren-nen); }
.the .ten { font-size: 11px; font-weight: 800; color: var(--chu-tren-nen); text-align: center; line-height: 1.1; max-width: 100%; overflow-wrap: break-word; }
.the.vao { animation: the-vao .28s cubic-bezier(.22,1.35,.55,1) both; animation-delay: var(--tre, 0ms); }
@keyframes the-vao { 0% { opacity: 0; transform: scale(.8) translateY(10px) } 100% { opacity: 1; transform: scale(1) translateY(0) } }
.the.chon { border-color: var(--tim); box-shadow: 0 0 0 4px var(--quang-chon), 0 6px 14px rgba(142,36,170,.2);
  animation: chon-nhun 1.45s ease-in-out infinite; z-index: 2; }
.the.chon-moi { animation: chon-bat .28s cubic-bezier(.22,1.5,.5,1), chon-nhun 1.45s .28s ease-in-out infinite; }
@keyframes chon-bat { 0% { transform: scale(.92) } 55% { transform: translateY(-6px) scale(1.06) } 100% { transform: translateY(-3px) scale(1.02) } }
.the.chon::before { content: '★'; position: absolute; top: 4px; right: 4px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--tim); color: #fff; font-weight: 900; font-size: 11px; line-height: 20px; text-align: center;
  box-shadow: 0 2px 5px rgba(0,0,0,.22); animation: cham-no .32s ease; }
.the.xong { opacity: .58; border-style: dashed; cursor: default; }
.the.xong::after { content: '✓'; position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--xanh-la); color: #fff; font-weight: 900; font-size: 13px; line-height: 22px; text-align: center;
  box-shadow: 0 2px 5px rgba(0,0,0,.22); }
.the.dung { animation: bup .42s cubic-bezier(.22,1.5,.5,1); border-color: var(--xanh-la);
  box-shadow: 0 0 0 5px rgba(67,160,71,.3); }
.the.sai { animation: lac .38s ease; border-color: var(--do); box-shadow: 0 0 0 5px rgba(229,57,53,.26); }
.the.nhac-lai { animation: nhac-the .42s ease; }
.the.goi-y { border-color: var(--vang); box-shadow: 0 0 0 4px rgba(253,216,53,.42), 0 0 14px rgba(251,140,0,.28);
  animation: goi-y-nhip 1.25s ease-in-out infinite; }
@keyframes goi-y-nhip { 0%,100% { transform: scale(1) } 50% { transform: scale(1.045) } }
@keyframes chon-nhun { 0%,100% { transform: translateY(-3px) scale(1.02) } 50% { transform: translateY(-7px) scale(1.04) } }
@keyframes bup { 0% { transform: scale(1) } 35% { transform: scale(1.16, .92) } 65% { transform: scale(.96, 1.08) } 100% { transform: scale(1) } }
@keyframes bup-nhe { 0% { transform: scale(1) } 45% { transform: scale(1.18) } 100% { transform: scale(1) } }
@keyframes lac { 0%,100% { transform: translateX(0) } 20% { transform: translateX(-8px) rotate(-2deg) } 55% { transform: translateX(8px) rotate(2deg) } 80% { transform: translateX(-4px) } }
@keyframes nhac-the { 0%,100% { transform: translateY(-3px) scale(1.02) } 30% { transform: translateY(-9px) scale(1.1) } 65% { transform: translateY(-5px) scale(1.05) } }

.the.gio { border-width: 4px; }
.the.toa { background: var(--the-toa); }
.the.toa .so-toa { font-size: 30px; font-weight: 900; color: var(--bang); }
.dem-vat { display: flex; flex-wrap: wrap; align-content: center; justify-content: center; gap: 4px;
  background: var(--the); border: 3px dashed var(--vien); border-radius: var(--r); padding: 10px; flex: 0 1 auto; min-height: 120px; max-width: 100%; }
.dem-vat img { width: clamp(36px, 13vw, 60px); height: auto; aspect-ratio: 1; pointer-events: none; }
.vat-dem { position: relative; display: inline-flex; align-items: center; justify-content: center;
  min-width: 44px; min-height: 44px; padding: 3px; border-radius: 14px; cursor: pointer; transition: transform .14s, background .18s; }
.vat-dem:active { transform: scale(.92); }
.vat-dem.da-dem { background: rgba(253,216,53,.3); animation: bup-nhe .32s cubic-bezier(.22,1.5,.5,1); }
.vat-dem .so-dem { position: absolute; top: -2px; right: -2px; min-width: 20px; height: 20px; padding: 0 4px;
  border-radius: 999px; background: var(--xanh-duong); color: #fff; font-weight: 900; font-size: 12px; line-height: 20px;
  text-align: center; box-shadow: 0 2px 5px rgba(0,0,0,.22); pointer-events: none; }

/* ---------- chuỗi đúng + lớp hiệu ứng canvas + vật bay / chữ nổi ---------- */
#chuoi { position: absolute; left: 50%; top: 52px; transform: translate(-50%, 6px) scale(.72);
  max-width: calc(100% - 28px); text-align: center; padding: 5px 16px; border-radius: 999px;
  background: rgba(255,255,255,.94); border: 2px solid var(--cam);
  font-size: clamp(15px, 4.6vw, 22px); font-weight: 900; color: var(--chuoi);
  box-shadow: 0 6px 18px rgba(251,140,0,.28);
  opacity: 0; pointer-events: none; z-index: 35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#chuoi.hien { animation: bung .82s cubic-bezier(.2,.9,.35,1) forwards; }
@keyframes bung { 0% { opacity: 0; transform: translate(-50%, 8px) scale(.72) }
  26% { opacity: 1; transform: translate(-50%, 0) scale(1.06) }
  72% { opacity: 1; transform: translate(-50%, -4px) scale(1) }
  100% { opacity: 0; transform: translate(-50%, -14px) scale(.94) } }
#lop-hieu-ung { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 45; display: block; }
.vat-bay { position: fixed; pointer-events: none; z-index: 46; object-fit: contain;
  filter: drop-shadow(0 6px 10px rgba(0,0,0,.24)); }
.chu-noi { position: fixed; pointer-events: none; z-index: 47; font-weight: 900; font-size: 17px;
  padding: 3px 11px; border-radius: 999px; white-space: nowrap; transform: translate(-50%, -50%);
  box-shadow: 0 3px 10px rgba(0,0,0,.2); }
.chu-noi.dung { background: var(--xanh-la); color: #fff; }
.chu-noi.xu { background: var(--cam); color: #fff; }
.chu-noi.sai { background: var(--do); color: #fff; font-size: 16px; }

/* ---------- LỚP PHỦ (thắng, bộ sưu tập, chế độ, cổng phụ huynh…) ---------- */
.lop { position: absolute; inset: 0; background: var(--phu); display: flex;
  align-items: center; justify-content: center; padding: 10px; z-index: 40; overflow-y: auto; overflow-x: hidden; }
.lop:not([hidden]) { animation: lop-vao .18s ease; }
@keyframes lop-vao { 0% { opacity: 0 } 100% { opacity: 1 } }
.hop { background: var(--hop); border-radius: 24px; padding: 16px; width: min(100%, 420px); max-width: 100%;
  max-height: 100%; overflow-y: auto; overflow-x: hidden; text-align: center; box-shadow: 0 10px 30px rgba(0,0,0,.3); }
.hop > .nut { display: block; width: 100%; }
#man-thang .hang-nut .nut { flex: 1 1 120px; }
.lop:not([hidden]) .hop { animation: hop-vao .28s cubic-bezier(.22,1.35,.55,1); }
@keyframes hop-vao { 0% { opacity: 0; transform: scale(.86) translateY(14px) } 100% { opacity: 1; transform: scale(1) translateY(0) } }
.hop h2 { margin: 2px 0 10px; font-size: 21px; overflow-wrap: break-word; }
.sao-hang { font-size: 38px; letter-spacing: 6px; color: var(--vang); text-shadow: 0 2px 0 var(--vang-dam); min-height: 48px; }
.sao-hang .mo { color: var(--sao-mo); text-shadow: none; }
.sao-hang .sao-item { display: inline-block; transform: scale(.25); opacity: 0;
  transition: transform .32s cubic-bezier(.22,1.55,.5,1), opacity .18s ease; }
.sao-hang .sao-item.hien { transform: scale(1); opacity: 1; }
.sao-hang .sao-item.sang { filter: drop-shadow(0 0 8px rgba(253,216,53,.8)); }
#thang-xu { display: inline-block; font-size: 18px; }
#thang-xu.nhay { animation: bup-nhe .32s cubic-bezier(.22,1.5,.5,1); }
.thuong-moi { position: relative; overflow: hidden; display: flex; align-items: center; gap: 12px; justify-content: center;
  background: var(--the-thuong); border: 3px solid var(--vang); border-radius: var(--r); padding: 10px; margin: 10px 0; }
.thuong-moi > div { min-width: 0; overflow-wrap: break-word; }
.thuong-moi::after { content: ''; position: absolute; top: 0; bottom: 0; left: -60%; width: 45%;
  background: linear-gradient(110deg, transparent, rgba(255,255,255,.72), transparent);
  pointer-events: none; animation: loa-sang .66s .16s ease forwards; }
@keyframes loa-sang { 0% { left: -60% } 100% { left: 130% } }
.thuong-moi img { width: 62px; height: 62px; flex: 0 0 auto; }
#bong-bay { width: 86px; height: 86px; min-width: 44px; min-height: 44px; cursor: pointer; transition: transform .15s;
  animation: bong-bay-troi 2.1s ease-in-out infinite; filter: drop-shadow(0 6px 8px rgba(0,0,0,.18)); }
#bong-bay:active { transform: scale(.88); }
#bong-bay.no { animation: bong-no .25s ease forwards; pointer-events: none; }
@keyframes bong-bay-troi { 0%,100% { transform: translateY(0) rotate(-3deg) } 50% { transform: translateY(-9px) rotate(3deg) } }
@keyframes bong-no { 0% { transform: scale(1); opacity: 1 } 55% { transform: scale(1.42); opacity: .9 } 100% { transform: scale(1.65); opacity: 0 } }

/* ---------- bộ sưu tập ---------- */
.tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.tabs .nut { flex: 1; padding: 9px 4px; font-size: 13px; min-width: 44px; min-height: 44px; background: var(--tab); color: var(--chu-mo); box-shadow: none; }
.tabs .nut.on { background: var(--tab-on); color: var(--chu-nut); }
.luoi-thuong { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.mon { background: var(--the-mon); border: 2px solid var(--vien); border-radius: 14px; padding: 7px 4px; min-width: 0; overflow: hidden; }
.mon img { width: 100%; max-width: 58px; aspect-ratio: 1; object-fit: contain; }
.mon span { display: block; font-size: 10px; font-weight: 700; line-height: 1.15; margin-top: 2px; overflow-wrap: break-word; }
.mon.khoa { filter: grayscale(1); opacity: .42; }

/* ---------- chọn chế độ ---------- */
.dong-che-do { background: var(--the); display: flex; align-items: center; gap: 10px; text-align: left;
  border: 2px solid var(--vien); border-radius: var(--r); padding: 8px 9px; margin-bottom: 8px; }
.dong-che-do img { width: 42px; height: 42px; flex: 0 0 auto; }
.dong-che-do .chu { flex: 1; min-width: 0; overflow-wrap: break-word; }
.dong-che-do b { display: block; font-size: 14px; }
.dong-che-do small { color: var(--chu-mo); font-size: 11px; }
/* vùng chạm công tắc đạt 66x44px nhờ viền trong suốt 6px, phần nhìn và ảnh skin giữ nguyên 54x32px */
.congtac { width: 66px; height: 44px; min-width: 66px; min-height: 44px; border: 6px solid transparent;
  border-radius: 999px; background-color: var(--tat); background-clip: padding-box; background-origin: padding-box;
  position: relative; flex: 0 0 auto; cursor: pointer; transition: background-color .15s; }
.congtac::after { content: ''; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px;
  border-radius: 50%; background: var(--the); transition: left .15s; }
.congtac.on { background-color: var(--xanh-la); } .congtac.on::after { left: 25px; }

/* ---------- cổng phụ huynh ---------- */
#cong-phu-huynh .hop > img { width: 54px; height: 54px; }
#cau-do { font-size: clamp(18px, 5.5vw, 22px); font-weight: 900; letter-spacing: .5px; color: var(--tim); margin: 6px 0 2px; overflow-wrap: break-word; }
#o-nhap { font-size: 30px; font-weight: 900; letter-spacing: 8px; padding-left: 8px; min-height: 42px; color: var(--bang); transition: color .15s; }
#o-nhap.sai-ma { color: var(--do); animation: lac .36s ease; }
#cong-sai.sai-ma { animation: lac .36s ease; }
.phim { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; margin-top: 8px; }
.phim .nut { background: var(--tab); color: var(--chu); font-size: 21px; min-width: 44px; min-height: 52px; padding: 10px 6px; box-shadow: 0 3px 0 var(--tat); }

/* ---------- cài đặt + hướng dẫn ---------- */
.dong-cai { display: flex; align-items: center; gap: 10px; padding: 6px 2px; border-bottom: 1px solid var(--tab); text-align: left; }
.dong-cai b { flex: 1; min-width: 0; font-size: 14px; overflow-wrap: break-word; }
.dong-cai span { flex: 0 1 auto; text-align: right; overflow-wrap: break-word; }
.danh-sach { text-align: left; font-size: 14px; line-height: 1.5; padding-left: 20px; margin: 6px 0; overflow-wrap: break-word; }
.danh-sach li { margin-bottom: 5px; }

/* ---------- tải ---------- */
#dang-tai { position: absolute; inset: 0; display: grid; place-items: center; background: var(--nen); z-index: 80; font-weight: 800; color: var(--chu-mo); }

/* màn hình hẹp (360px trở xuống): siết khoảng hở gọn gàng, không tràn ngang */
@media (max-width: 420px) {
  .thanh-so { gap: 4px; padding: 6px 8px; }
  .huy { padding: 4px 7px; font-size: 12.5px; gap: 3px; }
  .chip-tuoi { padding: 3px 6px; font-size: 10px; }
  .loi-nhac { margin: 0 8px 6px; padding: 7px 8px 7px 10px; gap: 8px; }
  .loi-nhac b { font-size: 15px; }
  #tien-do-man { margin: 0 10px 6px; gap: 6px; }
  #moc-thuong { margin: 0 10px 5px; padding: 3px 8px; gap: 5px; font-size: 11px; max-width: calc(100% - 20px); }
  #moc-thuong .moc-so { font-size: 11px; }
  #moc-thuong .moc-qua { font-size: 10.5px; padding: 1px 6px; }
  #san { padding: 0 8px 8px; }
  .khu { gap: 6px; }
  .the { padding: 5px 3px; }
  .the .ten { font-size: 10.5px; }
  .hop { padding: 14px 12px; }
  .dong-che-do { gap: 8px; padding: 7px 8px; }
  .dong-che-do img { width: 36px; height: 36px; }
}

/* màn hình dọc ngắn (ví dụ 360x640 hoặc có cốt truyện) */
@media (orientation: portrait) and (max-height: 680px) {
  #man-chinh { gap: 10px; }
  #logo-khung { width: min(78%, 270px); }
  #cu-meo { width: 88px; height: 88px; }
  #nut-choi { padding: 13px 34px; }
}

/* màn hình dọc dài (390x844, 412x915…): nới thẻ thoáng hơn, dễ bấm */
@media (orientation: portrait) and (min-height: 740px) {
  #man-chinh { gap: 16px; }
  .the { min-height: 82px; padding: 8px 5px; }
  .dem-vat { min-height: 150px; padding: 12px; gap: 6px; }
}

/* màn rộng dạng máy tính bảng: ô to hơn nhưng vẫn LẤP TRỌN bề ngang */
@media (min-width: 620px) and (min-height: 521px) {
  .the img { max-width: 110px; }
  .loi-nhac b { font-size: 19px; }
}

/* xoay ngang điện thoại (chiều cao <= 520px): bố cục gọn hai cột, không vỡ và chơi mượt */
@media (orientation: landscape) and (max-height: 520px) {
  .nut { min-height: 44px; padding: 10px 16px; font-size: 15px; }
  .nut.nut-am { width: 44px; height: 44px; min-width: 44px; min-height: 44px; padding: 0; }
  #man-chinh, #man-chinh.co-truyen {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
    grid-template-rows: auto auto auto auto;
    grid-template-areas:
      "logo nguoi"
      "logo choi"
      "cu nut"
      "phu so";
    align-items: center;
    justify-items: center;
    align-content: center;
    align-content: safe center;
    column-gap: 16px;
    row-gap: 6px;
    padding: 8px 16px;
  }
  #logo-khung { grid-area: logo; width: min(88%, 210px); }
  #cu-meo, #man-chinh.co-truyen #cu-meo { grid-area: cu; width: 68px; height: 68px; }
  #cu-meo.ngang, #man-chinh.co-truyen #cu-meo.ngang { grid-area: cu; width: min(100%, 210px); max-height: 68px; }
  #khau-hieu { grid-area: phu; font-size: 12px; }
  #truyen { grid-area: phu; width: 100%; padding: 6px 10px; font-size: 11px; }
  #truyen-ten { font-size: 13px; margin-bottom: 2px; }
  #nguoi-choi { grid-area: nguoi; font-size: 13px; padding: 3px 10px 3px 3px; }
  #nguoi-choi img { width: 26px; height: 26px; }
  #nut-choi { grid-area: choi; font-size: 19px; padding: 12px 30px; min-height: 46px; }
  #man-chinh .hang-nut { grid-area: nut; gap: 8px; }
  #man-chinh .hang-nut .o { width: 64px; gap: 2px; }
  #man-chinh .hang-nut .o span { font-size: 10.5px; }
  #man-chinh .nut.tron { width: 48px; height: 48px; min-width: 48px; min-height: 48px; }
  #man-chinh .nut.tron img, #man-chinh .nut.tron .ic img { width: 26px; height: 26px; }
  #man-chinh .nut.tron .dau { font-size: 22px; }
  #man-chinh .thanh-so { grid-area: so; padding: 2px 6px; }

  #man-choi .thanh-so { padding: 3px 10px; gap: 6px; }
  .loi-nhac { margin: 0 10px 4px; padding: 3px 8px 3px 12px; gap: 8px; }
  .loi-nhac b { font-size: 14px; line-height: 1.2; }
  #tien-do-man { margin: 0 12px 4px; }
  #moc-thuong { margin: 0 10px 3px; padding: 2px 8px; gap: 5px; font-size: 11px; max-width: calc(100% - 20px); }
  #moc-thuong .moc-thanh { height: 6px; }
  #moc-thuong .moc-so, #moc-thuong .moc-qua { font-size: 10.5px; }
  #chuoi { top: 38px; font-size: 15px; padding: 3px 12px; }
  .thanh-tien-do { height: 8px; }
  .cham-tien-do .cham { width: 16px; height: 16px; font-size: 10px; }

  #san { padding: 0 10px 6px; gap: 4px; overflow-y: auto; overflow-x: hidden; }
  .khu { gap: 6px; }
  .nhan-khu { font-size: 10.5px; margin: 0 2px; }
  .the {
    flex-direction: row; justify-content: center; gap: 6px;
    min-height: 48px; padding: 4px 8px;
  }
  .the img { width: clamp(34px, 13vh, 56px); max-width: 56px; height: auto; flex: 0 0 auto; }
  .the .ten { text-align: left; font-size: 11px; flex: 0 1 auto; min-width: 0; }
  .the.chon::before, .the.xong::after { top: 3px; right: 3px; width: 18px; height: 18px; line-height: 18px; font-size: 10px; }
  .the.toa .so-toa { font-size: 24px; }

  .khu.luoi2 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    max-height: 100%; height: 100%;
  }
  .khu.luoi2 .the { flex-direction: column; padding: 8px; }
  .khu.luoi2 .the img { width: auto; height: auto; max-width: 72%; max-height: 72%; }

  .dem-vat { min-height: 64px; padding: 6px 8px; gap: 4px; }
  .dem-vat img { width: clamp(32px, 11vh, 46px); }

  .lop { padding: 8px; }
  .hop { width: min(100%, 520px); padding: 12px 14px; border-radius: 20px; }
  .hop h2 { font-size: 18px; margin: 0 0 6px; }
  .hop p { margin: 4px 0; }
  .sao-hang { font-size: 30px; min-height: 36px; }
  .thuong-moi { padding: 6px 10px; margin: 6px 0; gap: 10px; }
  .thuong-moi img { width: 44px; height: 44px; }
  #bong-bay { width: 60px; height: 60px; }
  .luoi-thuong { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
  .mon { padding: 5px 4px; }
  .mon img { max-width: 44px; }
  #ds-che-do { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin-bottom: 8px; }
  .dong-che-do { margin-bottom: 0; padding: 6px 8px; gap: 6px; }
  .dong-che-do img { width: 34px; height: 34px; }
  .dong-che-do b { font-size: 13px; }
  #cong-phu-huynh .hop > img { width: 34px; height: 34px; }
  #cau-do { font-size: 17px; margin: 2px 0; }
  #o-nhap { font-size: 24px; min-height: 30px; }
  .phim { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; margin-top: 6px; }
  .phim .nut { min-height: 44px; font-size: 18px; padding: 6px 4px; }
}

/* ---------- ẢNH CỦA BỘ GIAO DIỆN (20-11, phiếu SKIN-THAY-HET-NUT) ----------
   Bộ có mảnh nào thì game gắn class co-<mảnh> lên <html> và đặt url vào --a-<mảnh>; không có thì giữ nguyên vẻ gốc.
   Biểu tượng chữ (★ ◉ ‹ ♪ ⚙ 🔒) nằm trong <i class="ic" data-ic="<mảnh>">, game tự thay bằng ảnh. */
.ic { font-style: normal; display: inline-grid; place-items: center; line-height: 1; }
.ic img { width: 1.25em; height: 1.25em; object-fit: contain; vertical-align: middle; }
.nut.tron .ic img { width: 34px; height: 34px; }
.sao-hang .ic img { width: 1em; height: 1em; }
html.co-nut_choi #nut-choi,
/* 01-12 trạm chấm 5811031: nut_dai là nút dài MẶC ĐỊNH — :where() hạ ưu tiên (bỏ hai #id) để nut_phim, tab, tab_bat
   của bộ luôn thắng; bộ thiếu mảnh riêng thì phím/tab vẫn lùi về nut_dai */
html.co-nut_dai .nut:where(:not(.phu):not(.tron):not(.xanh):not(#nut-choi):not(#nut-doc)),
html.co-nut_dai_xanh .nut.xanh,
html.co-nut_dai_phu .nut.phu,
html.co-nut_tron .nut.tron,
html.co-nut_doc #nut-doc,
html.co-nut_phim .phim .nut,
html.co-tab .tabs .nut:not(.on),
html.co-tab_bat .tabs .nut.on,
html.co-khung_hop .hop,
html.co-khung_the .the:not(.toa),
html.co-khung_toa .the.toa,
html.co-khung_loi_nhac .loi-nhac,
html.co-khung_dem .dem-vat,
html.co-khung_mon .mon,
html.co-khung_che_do .dong-che-do,
html.co-chip .huy,
html.co-chip .chip-tuoi,
html.co-chip #nguoi-choi,
html.co-cong_tac_tat .congtac,
html.co-cong_tac_bat .congtac.on {
  background-color: transparent; background-position: center; background-size: 100% 100%; background-repeat: no-repeat;
  border-color: transparent; box-shadow: none;
}
html.co-nut_choi #nut-choi { background-image: var(--a-nut_choi); }
html.co-nut_dai .nut:where(:not(.phu):not(.tron):not(.xanh):not(#nut-choi):not(#nut-doc)) { background-image: var(--a-nut_dai); }
html.co-nut_dai_xanh .nut.xanh { background-image: var(--a-nut_dai_xanh); }
html.co-nut_dai_phu .nut.phu { background-image: var(--a-nut_dai_phu); }
html.co-nut_tron .nut.tron { background-image: var(--a-nut_tron); }
html.co-nut_doc #nut-doc { background-image: var(--a-nut_doc); }
html.co-nut_doc #nut-doc .ic { visibility: hidden; }
html.co-nut_phim .phim .nut { background-image: var(--a-nut_phim); }
html.co-tab .tabs .nut:not(.on) { background-image: var(--a-tab); }
html.co-tab_bat .tabs .nut.on { background-image: var(--a-tab_bat); }
html.co-khung_hop .hop { background-image: var(--a-khung_hop); }
html.co-khung_the .the:not(.toa) { background-image: var(--a-khung_the); }
html.co-khung_toa .the.toa { background-image: var(--a-khung_toa); }
html.co-khung_loi_nhac .loi-nhac { background-image: var(--a-khung_loi_nhac); }
html.co-khung_dem .dem-vat { background-image: var(--a-khung_dem); }
html.co-khung_mon .mon { background-image: var(--a-khung_mon); }
html.co-khung_che_do .dong-che-do { background-image: var(--a-khung_che_do); }
html.co-chip .huy, html.co-chip .chip-tuoi, html.co-chip #nguoi-choi { background-image: var(--a-chip); }
html.co-cong_tac_tat .congtac { background-image: var(--a-cong_tac_tat); }
html.co-cong_tac_bat .congtac.on { background-image: var(--a-cong_tac_bat); }
html.co-cong_tac_tat .congtac::after, html.co-cong_tac_bat .congtac.on::after { display: none; }
/* 5811031 chấm hoat-hinh 01-12: mặt chip của bộ có thể đậm (xanh dương) — chữ '2-3 tuổi' theo --chu-chip của bộ, bộ không khai giữ --chu-mo */
html.co-chip .chip-tuoi { color: var(--chu-chip, var(--chu-mo)); text-shadow: var(--bong-chu-chip, none); }
/* giữ nguyên phản hồi chọn / đúng / sai rõ ràng ngay cả khi bộ giao diện thay khung thẻ bằng ảnh */
html.co-khung_the .the.chon { outline: 4px solid var(--tim); outline-offset: -2px; filter: drop-shadow(0 6px 10px var(--quang-chon)); }
html.co-khung_the .the.dung, html.co-khung_toa .the.dung { outline: 4px solid var(--xanh-la); outline-offset: -2px; filter: drop-shadow(0 0 10px rgba(67,160,71,.45)); }
html.co-khung_the .the.sai, html.co-khung_toa .the.sai { outline: 4px solid var(--do); outline-offset: -2px; filter: drop-shadow(0 0 10px rgba(229,57,53,.4)); }
html.co-khung_the .the.goi-y, html.co-khung_toa .the.goi-y { outline: 4px solid var(--vang); outline-offset: -2px; filter: drop-shadow(0 0 10px rgba(253,216,53,.65)); }
html.co-khung_loi_nhac .loi-nhac.dang-doc { outline: 3px solid var(--xanh-duong); outline-offset: -2px; }
html.co-nut_dai_phu .nut.nut-am.tat { filter: saturate(.5); outline: 2px solid rgba(229,57,53,.55); outline-offset: -2px; }

/* ---------- cổng phát hành: nút thưởng & tạm dừng khi chờ quảng cáo / ẩn thẻ ---------- */
#nut-thuong-qc { margin-top: 8px; width: 100%; }
body.tam-dung-qc #app { pointer-events: none; }
body.tam-dung-qc *, body.tam-dung-qc *::before, body.tam-dung-qc *::after,
body.tam-dung-an *, body.tam-dung-an *::before, body.tam-dung-an *::after { animation-play-state: paused !important; }
