/* Bé Tập Nói — giao diện */
:root {
  --ink: #3B2A20;
  --ink-soft: #6B5A4E;
  --paper: #FFF8EC;
  --bg: #FFF8EC;
  --c: #FFB547;
  --font: 'Baloo 2', 'Nunito', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --shadow: 0 6px 0 rgba(59, 42, 32, .18);
  --radius: 28px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--paper); color: var(--ink); font-family: var(--font); overscroll-behavior: none; }
body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: manipulation; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; touch-action: manipulation; }
button:disabled { opacity: .35; cursor: default; }
[hidden] { display: none !important; }

.screen {
  min-height: 100vh; min-height: 100dvh; height: 100vh; height: -webkit-fill-available; height: 100dvh; overflow: hidden;
  display: flex; flex-direction: column;
  background: var(--bg);
  padding: max(10px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  animation: screen-in .28s ease-out;
}
@keyframes screen-in { from { opacity: 0; transform: scale(.985); } }

/* ---------- Nút ---------- */
.btn { background: #fff; border-radius: 999px; box-shadow: var(--shadow); font-weight: 800; transition: transform .08s; }
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 rgba(59, 42, 32, .18); }
.btn.round { width: 60px; height: 60px; font-size: 28px; display: grid; place-items: center; flex: none; }
.btn.pill { padding: 10px 20px; font-size: 20px; background: var(--c, #fff); }
.btn.big { padding: 14px 28px; font-size: clamp(22px, 5vw, 30px); background: var(--c, #FFD54F); }
.btn.mini { width: 46px; height: 46px; font-size: 20px; display: grid; place-items: center; box-shadow: 0 3px 0 rgba(59,42,32,.15); }
.btn.danger { background: #FFE1DD; color: #B3261E; font-size: 17px; }
.chip { background: #fff; border-radius: 999px; padding: 6px 16px; font-size: 22px; font-weight: 800; box-shadow: var(--shadow); }

/* Nút nhấn giữ */
.hold { position: relative; overflow: hidden; }
.hold::before { content: ''; position: absolute; top: 0; left: 0; right: 0; bottom: 0; border-radius: inherit; background: rgba(93, 187, 99, .45); transform: scaleX(0); transform-origin: left; }
.hold.holding::before { animation: hold-fill var(--hold, 3s) linear forwards; }
@keyframes hold-fill { to { transform: scaleX(1); } }

.bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 64px; flex: none; }
.bar .title { margin: 0; font-size: clamp(20px, 4.6vw, 30px); line-height: 1.1; text-align: center; flex: 1; }
.bar > span { width: 60px; }
.logo { margin: 0; font-size: clamp(40px, 11vw, 72px); font-weight: 800; letter-spacing: .5px; color: #FF7A45; text-shadow: 3px 3px 0 #FFD54F, 6px 6px 0 rgba(59,42,32,.15); }
.logo.small { font-size: clamp(30px, 7vw, 44px); }
.word { font-size: clamp(34px, 9vw, 64px); font-weight: 800; line-height: 1.05; text-align: center; }

/* ---------- Hình & hoạt hình ---------- */
.art { position: relative; width: 100%; flex: none; }
.art::before { content: ''; display: block; padding-top: 100%; }
.art > svg { position: absolute; top: 0; left: 0; right: 0; bottom: 0; width: 100%; height: 100%; display: block; overflow: hidden; }
.art .blink { transform-box: fill-box; transform-origin: center; animation: blink 5s infinite; animation-delay: var(--d); }
.art .wag { transform-box: view-box; animation: wag 2.6s ease-in-out infinite; animation-delay: var(--d); }
.art.talk .wag { animation-duration: .55s; }
.art.sleep .blink { animation: none; transform: scaleY(.12); }
.art.sleep .wag { animation-duration: 5s; }
@keyframes blink { 0%, 93%, 100% { transform: scaleY(1); } 96% { transform: scaleY(.1); } }
@keyframes wag { 0%, 100% { transform: rotate(-10deg); } 50% { transform: rotate(10deg); } }
.boing { animation: boing .6s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes boing { 0% { transform: scale(1); } 25% { transform: scale(1.12, .88); } 50% { transform: scale(.92, 1.1) translateY(-6%); } 75% { transform: scale(1.04, .97); } 100% { transform: scale(1); } }
.wiggle { animation: wiggle .5s ease-in-out; }
@keyframes wiggle { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(-7deg); } 40% { transform: rotate(6deg); } 60% { transform: rotate(-4deg); } 80% { transform: rotate(2deg); } }

/* ---------- Màn chào ---------- */
.splash { background: radial-gradient(circle at 50% 35%, #FFF3C4, #FFD9A8 70%); cursor: pointer; }
.splash-inner { margin: auto; display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.splash-art { width: min(62vw, 42vh, 340px); animation: float 2.4s ease-in-out infinite; }
.splash .start { animation: pulse 1.4s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-14px); } }
@keyframes pulse { 50% { transform: scale(1.07); } }

/* ---------- Trang chủ ---------- */
.home { background: linear-gradient(#FFF6DF, #FFEBD0); }
.tiles { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: clamp(10px, 2.5vw, 20px); padding: 8px 0; align-content: center; overflow-y: auto; }
.tile { position: relative; background: var(--tb); border: 5px solid var(--c); border-radius: var(--radius); box-shadow: 0 7px 0 var(--c); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 8px 6px 6px; min-height: 0; }
.tile:active { transform: translateY(5px); box-shadow: 0 2px 0 var(--c); }
.tile .art { width: min(30vw, 15vh, 170px); }
.tile span { font-size: clamp(20px, 4.8vw, 30px); font-weight: 800; line-height: 1.1; }
.tile .badge { position: absolute; top: 6px; right: 10px; font-style: normal; font-size: 26px; }
.foot { display: flex; justify-content: center; flex: none; padding-top: 6px; }
.gear { opacity: .7; width: 52px; height: 52px; font-size: 24px; }
@media (min-aspect-ratio: 4/3) {
  .tiles { grid-template-columns: repeat(3, 1fr); }
  .tile .art { width: min(18vw, 22vh, 190px); }
}

/* ---------- Xem thẻ ---------- */
.stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 6px 0; }
/* Thẻ thu nhỏ còn 80% so với trước (rộng, cao, hình và chữ). */
.card-wrap { width: min(80%, 496px); height: 80%; display: flex; }
.card { flex: 1; background: var(--cb); border-radius: 36px; border: 6px solid #fff; box-shadow: 0 10px 0 rgba(59,42,32,.12), 0 18px 40px rgba(59,42,32,.12); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 16px; position: relative; touch-action: pan-y; }
.card { overflow: hidden; }
.card > *:not(.scene) { position: relative; z-index: 1; }
/* Ảnh tự lấy phần chỗ còn lại trong thẻ: thêm câu (bấm "Nói câu") thì ảnh tự nhỏ lại, không bao giờ bị cắt. */
.card .hero { flex: 1 1 0; min-height: 90px; max-height: min(336px, 57.6vw); width: 100%; display: flex; justify-content: center; align-items: center; container-type: size; }
/* Ô vuông = cạnh ngắn của phần chỗ còn lại (đơn vị cq). Không dùng aspect-ratio + height:100% vì Safari iPad tính sai. */
.card .hero-box { position: relative; width: min(100cqw, 100cqh); height: min(100cqw, 100cqh); }
.card .art { width: 100%; cursor: pointer; }
.card .chips span { font-size: clamp(16px, 4vw, 24px); }
/* Đến lượt bé nói: chữ đang có trên thẻ nhún nhẹ, kèm 🗣️ — không thêm bóng chữ lặp lại. */
.card .turn { animation: turn-pop 1.2s ease-in-out infinite; }
.card .word.turn::before, .card .sentence.turn .chips::before { content: '🗣️'; font-size: .7em; margin-right: .25em; }
.card .sentence.turn .chips::before { font-size: clamp(18px, 4.4vw, 26px); align-self: center; }
@keyframes turn-pop { 50% { transform: scale(1.07); } }
.card .word { font-size: clamp(27px, 7.2vw, 51px); }
.card .art svg { animation: breathe 3.4s ease-in-out infinite; transform-origin: 50% 92%; }
@keyframes breathe { 50% { transform: scale(1.025, .975); } }
.hero { position: relative; }
.scene { position: absolute; top: 0; left: 0; right: 0; bottom: 0; z-index: 0; pointer-events: none; }
.scene svg { width: 100%; height: 100%; display: block; }
.scene .cloud { animation: drift var(--cd, 40s) linear infinite; animation-delay: calc(var(--cd, 40s) * -.4); }
@keyframes drift { from { transform: translateX(-220px); } to { transform: translateX(440px); } }
.scene .sun { transform-box: view-box; animation: spin 30s linear infinite; }
.scene .sway { transform-box: view-box; animation: sway var(--sd, 4s) ease-in-out infinite; }
@keyframes sway { 0%, 100% { transform: rotate(-4deg); } 50% { transform: rotate(4deg); } }
.scene .bubble { animation: rise var(--bd, 6s) linear infinite; animation-delay: var(--bdl, 0s); opacity: .8; }
@keyframes rise { 0% { transform: translateY(0); opacity: 0; } 10% { opacity: .8; } 90% { opacity: .6; } 100% { transform: translateY(-460px); opacity: 0; } }
.scene .wave { animation: wave 5s ease-in-out infinite; }
@keyframes wave { 50% { transform: translateX(-30px); } }
.scene .dot { animation: floaty var(--dd, 5s) ease-in-out infinite; animation-delay: var(--ddl, 0s); }
@keyframes floaty { 50% { transform: translateY(-14px); } }
.pop { position: absolute; top: 2%; right: -6%; background: #fff; border: 4px solid var(--ink); border-radius: 22px; padding: 2px 14px; font-size: clamp(16px, 4vw, 26px); font-weight: 800; white-space: nowrap; pointer-events: none; transform-origin: 0 100%; }
.pop::after { content: ''; position: absolute; left: 14px; bottom: -14px; border: 8px solid transparent; border-top: 10px solid var(--ink); border-left-width: 4px; }
.pop.show { animation: pop-in 2.4s ease-out forwards; }
@keyframes pop-in { 0% { transform: scale(0) rotate(-10deg); opacity: 0; } 12% { transform: scale(1.15) rotate(3deg); opacity: 1; } 20% { transform: scale(1) rotate(0); } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(-14px); } }
.burst { position: fixed; width: 0; height: 0; pointer-events: none; z-index: 45; }
.burst i { position: absolute; left: -14px; top: -14px; font-style: normal; font-size: 28px; animation: burst 1.4s ease-out forwards; }
@keyframes burst { 0% { transform: translate(0, 0) scale(.3); opacity: 1; } 70% { opacity: 1; } 100% { transform: translate(var(--x), var(--y)) scale(var(--s)); opacity: 0; } }
.card .sub { display: flex; align-items: center; gap: 10px; font-size: clamp(16px, 4vw, 24px); font-weight: 700; color: var(--ink-soft); }
.swatch { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--ink); display: inline-block; }
.card .word { cursor: pointer; }
.in-right { animation: in-right .35s ease-out; }
.in-left { animation: in-left .35s ease-out; }
@keyframes in-right { from { transform: translateX(40%) rotate(4deg); opacity: 0; } }
@keyframes in-left { from { transform: translateX(-40%) rotate(-4deg); opacity: 0; } }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex: none; padding: 6px 4px; }
.pager .btn.round { width: 72px; height: 72px; font-size: 30px; background: #fff; }
.dots { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; align-items: center; }
.dots i { width: 10px; height: 10px; border-radius: 50%; background: rgba(59,42,32,.2); font-style: normal; }
.dots i.on { background: var(--ink); transform: scale(1.3); }
.dots i.end { width: auto; height: auto; background: none; font-size: 16px; color: rgba(59,42,32,.3); }
.dots i.end.on { color: #FFB400; transform: scale(1.5); background: none; }
.tips { flex: none; background: rgba(255,255,255,.75); border-radius: 18px; padding: 8px 14px; font-size: 15px; line-height: 1.35; color: var(--ink-soft); -webkit-user-select: text; user-select: text; }
.tips ul { margin: 4px 0 0; padding-left: 20px; }
.end-card .big-emoji { font-size: clamp(80px, 20vw, 140px); animation: float 2s ease-in-out infinite; }
.end-actions { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; margin-top: 14px; }
@media (orientation: landscape) and (max-height: 620px) {
  /* Điện thoại xoay ngang (màn thấp): ảnh bên trái, tên + câu + nút xếp dọc bên phải. Thẻ rộng hơn vì màn thấp. */
  .card-wrap { width: min(92%, 760px); height: 92%; container-type: size; }
  .card:not(.end-card) { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: 1fr auto auto auto auto 1fr;
    column-gap: 20px; row-gap: 4px; justify-items: center; align-items: center; padding: 12px 16px; }
  /* Ảnh vuông cao bằng thẻ (trừ viền + lề), tối đa 42% bề ngang thẻ — không phụ thuộc cột chữ bên phải. */
  .card .hero { grid-column: 1; grid-row: 1 / -1; max-height: none; min-height: 0;
    width: min(calc(100cqh - 36px), 42cqw); height: min(calc(100cqh - 36px), 42cqw); }
  .card .word { grid-column: 2; grid-row: 2; font-size: clamp(22px, 8vh, 44px); }
  .card .sub { grid-column: 2; grid-row: 3; }
  .card .sentence { grid-column: 2; grid-row: 4; margin-top: 0; padding: 2px 8px; border-radius: 14px; }
  .card .sentence .lv i { width: 7px; height: 7px; }
  .card .talkbtn { grid-column: 2; grid-row: 5; margin-top: 0; font-size: clamp(14px, 4.4vh, 22px); padding: 4px 14px; }
  .card .chips { gap: 4px; }
  .card .chips span { font-size: clamp(13px, 4.4vh, 22px); padding: 0 6px; border-radius: 9px; }
  .tips { display: none; }
}

/* ---------- Trò chơi ---------- */
.progress { display: flex; gap: 6px; }
.progress i { width: clamp(26px, 7vw, 40px); aspect-ratio: 1; background: rgba(59,42,32,.15); clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%); transition: background .3s; }
.progress i.on { background: #FFB400; animation: boing .6s; }
.ask { flex: none; display: flex; justify-content: center; padding: 2px 0 6px; }
.question { background: #fff; border-radius: 999px; padding: 6px 24px; font-size: clamp(24px, min(6.5vw, 5vh), 44px); font-weight: 800; box-shadow: var(--shadow); text-align: center; }
.question span { color: #FF7A45; }
/* Thẻ lựa chọn tự phóng to cho vừa hết khoảng trống còn lại (container query), tối đa 560px */
.choices { flex: 1; min-height: 0; display: flex; flex-wrap: wrap; align-content: center; justify-content: center; gap: 16px; container-type: size; }
.choice { --s: min(70vw, 31vh, 320px); width: var(--s); height: var(--s); background: var(--cb); border: 6px solid #fff; border-radius: 36px; box-shadow: 0 8px 0 rgba(59,42,32,.14); padding: 3%; transition: opacity .3s, transform .3s; }
.choices.n3 .choice { --s: min(45vw, 29vh, 280px); }
@supports (width: 1cqw) {
  .choices.n2 .choice { --s: min(560px, max(min(96cqw, 50cqh - 12px), min(50cqw - 12px, 96cqh))); }
  .choices.n3 .choice { --s: min(520px, max(min(96cqw, 33.3cqh - 14px), min(50cqw - 12px, 50cqh - 12px), min(33.3cqw - 14px, 96cqh))); }
}
.choice .art { animation: bob 3s ease-in-out infinite; animation-delay: var(--d); }
@keyframes bob { 50% { transform: translateY(-3%); } }
.choice:active { transform: scale(.96); }
.choice.yay { border-color: #FFD54F; animation: yay .8s ease-out; z-index: 2; transform: scale(1.08); }
.choice.fade { opacity: .25; transform: scale(.9); }
.choice.hint { animation: glow 1s ease-in-out infinite; }
@keyframes yay { 0% { transform: scale(1); } 40% { transform: scale(1.22) rotate(-4deg); } 70% { transform: scale(1.04) rotate(3deg); } 100% { transform: scale(1.08); } }
@keyframes glow { 50% { box-shadow: 0 0 0 10px rgba(255, 213, 79, .8), 0 8px 0 rgba(59,42,32,.14); } }

/* ---------- Phần thưởng ---------- */
.reward { background: radial-gradient(circle, #FFF6C7, #FFD59A); overflow: hidden; position: relative; }
.rays { position: absolute; inset: -50%; background: repeating-conic-gradient(rgba(255,255,255,.45) 0 10deg, transparent 10deg 20deg); animation: spin 18s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.reward-inner { position: relative; margin: auto; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.reward-title { font-size: clamp(30px, 8vw, 52px); font-weight: 800; color: #FF7A45; text-shadow: 2px 2px 0 #fff; }
.sticker-big { width: min(64vw, 40vh, 360px); background: #fff; border-radius: 50%; padding: 7%; box-shadow: 0 0 0 10px #FFD54F, 0 14px 30px rgba(0,0,0,.15); animation: sticker-in .9s cubic-bezier(.3, 1.5, .5, 1); cursor: pointer; }
@keyframes sticker-in { from { transform: scale(0) rotate(-200deg); } }

/* ---------- Sticker ---------- */
.book-body { flex: 1; overflow-y: auto; padding-bottom: 20px; }
.book-sec h3 { margin: 14px 4px 8px; font-size: 24px; color: var(--ink); border-left: 8px solid var(--c); padding-left: 10px; }
.book-sec h3 small { color: var(--ink-soft); font-size: 18px; }
.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(28vw, 130px), 1fr)); gap: 10px; }
.stk { position: relative; aspect-ratio: 1; overflow: hidden; background: var(--cb); border-radius: 50%; border: 5px solid #fff; box-shadow: 0 5px 0 rgba(59,42,32,.12); padding: 10%; }
.stk.locked { background: rgba(59,42,32,.06); box-shadow: none; border-style: dashed; border-color: rgba(59,42,32,.2); }
.stk.locked .art { filter: brightness(0); opacity: .12; }
.stk em { position: absolute; right: -2px; bottom: -2px; background: #FFB400; color: #fff; font-style: normal; font-weight: 800; border-radius: 999px; padding: 0 8px; font-size: 16px; }
.book-hint { text-align: center; color: var(--ink-soft); font-size: 18px; }

/* ---------- Nghỉ ngơi ---------- */
.rest-inner { margin: auto; text-align: center; display: flex; flex-direction: column; align-items: center; }
.sleepy { width: min(60vw, 40vh, 320px); }
.rest-inner p { font-size: 20px; color: var(--ink-soft); max-width: 420px; }
.zzz { font-size: 40px; font-weight: 800; color: #7C83FD; height: 60px; }
.zzz span { display: inline-block; animation: zz 2.4s ease-in-out infinite; }
.zzz span:nth-child(2) { animation-delay: .4s; font-size: 50px; }
.zzz span:nth-child(3) { animation-delay: .8s; font-size: 62px; }
@keyframes zz { 0%, 100% { opacity: 0; transform: translateY(10px); } 50% { opacity: 1; transform: translateY(-10px); } }
.unlock { background: #fff; font-size: 18px; }

/* ---------- Bố mẹ ---------- */
.parent { -webkit-user-select: text; user-select: text; }
.parent-body, .rec-list { flex: 1; overflow-y: auto; padding-bottom: 24px; }
.panel { background: #fff; border-radius: 20px; padding: 14px 16px; margin: 10px 0; box-shadow: 0 3px 0 rgba(59,42,32,.08); font-size: 17px; line-height: 1.45; }
.panel h3 { margin: 0 0 6px; font-size: 21px; }
.panel p { margin: 6px 0; }
.panel .btn.pill { margin-top: 6px; background: #FFD54F; font-size: 18px; }
.muted { color: var(--ink-soft); font-size: 15px; }
.pad { padding: 0 6px; }
.ok { color: #2E7D32; }
.warn { color: #9A4B00; background: #FFF3E0; border-radius: 12px; padding: 8px 12px; font-size: 15px; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.seg button { padding: 8px 14px; border-radius: 999px; background: #F1EBE0; font-weight: 700; font-size: 16px; }
.seg button.on { background: var(--ink); color: #fff; }
.tabs { flex: none; }
.sw { display: flex; align-items: center; gap: 10px; margin: 10px 0; cursor: pointer; }
.sw input { display: none; }
.sw span { width: 52px; height: 30px; border-radius: 999px; background: #D9D1C4; position: relative; flex: none; transition: background .2s; }
.sw span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .2s; }
.sw input:checked + span { background: #5DBB63; }
.sw input:checked + span::after { transform: translateX(22px); }
.tipsbox ul { margin: 4px 0; padding-left: 20px; }
.tipsbox li { margin: 4px 0; }
.rec-row { display: flex; gap: 12px; align-items: center; background: #fff; border-radius: 20px; padding: 10px; margin: 8px 0; }
.rec-art { width: 76px; flex: none; background: var(--cb); border-radius: 18px; padding: 6px; }
.rec-main { flex: 1; min-width: 0; }
.rec-main > b { font-size: 21px; }
.slot { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.slot-label { flex: 1; min-width: 0; font-weight: 700; font-size: 16px; }
.slot-label small { display: block; font-weight: 500; color: var(--ink-soft); font-size: 13px; }
.slot.has .slot-label::after { content: ' ✓'; color: #2E7D32; }
.btn.rec.recording { background: #E53935; color: #fff; width: auto; padding: 0 12px; animation: pulse 1s infinite; }

/* ---------- Toast & pháo giấy ---------- */
.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 20px; border-radius: 999px; font-size: 17px; font-weight: 700; z-index: 50; animation: screen-in .2s; max-width: 90vw; text-align: center; }
.confetti { position: fixed; left: 50%; top: 45%; width: 0; height: 0; pointer-events: none; z-index: 40; }
.confetti i { position: absolute; width: 12px; height: 16px; border-radius: 3px; animation: conf 1.5s cubic-bezier(.15, .6, .4, 1) forwards; }
@keyframes conf {
  0% { transform: translate(0, 0) rotate(0); opacity: 1; }
  70% { opacity: 1; }
  100% { transform: translate(var(--x), calc(var(--y) + 260px)) rotate(var(--r)); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .art .blink, .art .wag, .rays, .splash-art, .splash .start, .scene *, .card .art svg, .choice .art, .card .turn { animation: none !important; }
}

/* ---------- Trang chủ nhiều chủ đề ---------- */
.home-body { flex: 1; min-height: 0; overflow-y: auto; padding-bottom: 12px; -webkit-overflow-scrolling: touch; }
.home .tiles { flex: none; overflow: visible; padding: 4px 0; grid-template-columns: repeat(auto-fill, minmax(min(27vw, 150px), 1fr)); align-content: start; gap: 8px; }
.home .tile .art { width: min(20vw, 104px); }
.home .tile span { font-size: clamp(16px, 4vw, 22px); }
.home .tiles.modes { grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 4px; }
.home .tiles.modes .tile { border-width: 4px; padding: 4px 2px; }
.home .tiles.modes .art { width: min(16vw, 90px); }
.home .tiles.modes span { font-size: clamp(13px, 3.4vw, 19px); }
.group h2 { margin: 14px 4px 6px; font-size: clamp(20px, 5vw, 28px); }
@media (min-aspect-ratio: 4/3) { .home .tiles { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); } }
.loading .loader { margin: auto; text-align: center; font-size: 22px; font-weight: 700; color: var(--ink-soft); }
.loading .loader .art { width: 160px; margin: 0 auto; animation: float 1.6s ease-in-out infinite; }
.dots b { font-size: 18px; color: var(--ink-soft); }

/* ---------- Nói câu ---------- */
.talkbtn { margin-top: 6px; background: #fff; font-size: clamp(17px, 4.2vw, 22px); }
.sentence { background: rgba(255,255,255,.85); border-radius: 20px; padding: 6px 12px; margin-top: 6px; text-align: center; max-width: 100%; }
.sentence .lv { display: flex; gap: 6px; justify-content: center; margin-bottom: 2px; }
.sentence .lv i { width: 10px; height: 10px; border-radius: 50%; background: rgba(59,42,32,.2); }
.sentence .lv i.on { background: #FFB400; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.chips span { font-size: clamp(20px, 5vw, 30px); font-weight: 800; padding: 2px 10px; border-radius: 12px; background: #F1EBE0; color: #9B8B7E; transition: background .2s, color .2s, transform .2s; }
.chips span.on { background: #FFD54F; color: var(--ink); transform: translateY(-3px); }

/* ---------- Ghép câu ---------- */
.strip { display: flex; align-items: center; justify-content: center; gap: 10px; flex: none; padding: 4px 0 8px; }
.strip .slot { display: flex; flex-direction: column; align-items: center; line-height: 1.1; width: min(38vw, 160px); background: #fff; border: 4px dashed rgba(59,42,32,.25); border-radius: 24px; padding: 6px; text-align: center; transition: border-color .2s, transform .2s; }
.strip .slot.active { border-color: #FF8A65; transform: scale(1.04); }
.strip .slot.filled { border-style: solid; border-color: #FFD54F; }
.strip .slot-art { height: min(22vw, 90px); display: flex; justify-content: center; }
.strip .slot-art .art { width: min(22vw, 90px); }
.strip .slot b { font-size: clamp(16px, 4vw, 22px); }
.strip .plus { font-size: 34px; font-weight: 800; color: #FF8A65; }
.choices.n4 .choice { --s: min(44vw, 30vh, 240px); position: relative; }
@supports (width: 1cqw) { .choices.n4 .choice { --s: min(300px, max(min(48cqw - 12px, 48cqh - 12px), min(24cqw - 14px, 94cqh))); } }
.choice .cap { position: absolute; left: 0; right: 0; bottom: 4px; font-size: clamp(14px, 3.6vw, 20px); font-weight: 800; text-shadow: 0 2px 0 #fff; }
.choices.result { align-content: center; }
.result-card { background: #fff; border-radius: 32px; padding: 12px 16px; box-shadow: 0 8px 0 rgba(59,42,32,.12); text-align: center; animation: sticker-in .7s cubic-bezier(.3, 1.5, .5, 1); max-width: 96%; }
.result-card .pair { display: flex; gap: 8px; justify-content: center; }
.result-card .pair .art { width: min(38vw, 30vh, 220px); }
.build-foot { display: flex; justify-content: center; flex: none; padding: 8px 0; }

/* ---------- Bảng Con muốn… ---------- */
.talk-say { flex: none; text-align: center; background: #fff; border-radius: 999px; padding: 8px 18px; margin: 0 auto 8px; font-size: clamp(20px, 5vw, 32px); font-weight: 800; box-shadow: var(--shadow); }
.talk-say.pulse { animation: pop-small .5s ease-out; }
@keyframes pop-small { 0% { transform: scale(.7); } 60% { transform: scale(1.06); } 100% { transform: scale(1); } }
.talk-grid { flex: 1; min-height: 0; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(42vw, 170px), 1fr)); gap: 10px; padding-bottom: 12px; }
.talk-tile { background: var(--cb); border: 4px solid #fff; border-radius: 24px; box-shadow: 0 5px 0 rgba(59,42,32,.12); padding: 6px; display: flex; flex-direction: column; align-items: center; }
.talk-tile .art { width: min(30vw, 130px); }
.talk-tile span { font-size: clamp(15px, 3.8vw, 20px); font-weight: 800; line-height: 1.15; text-align: center; }

/* ---------- Sticker khoá & chọn chủ đề thu âm ---------- */
.stk.locked { display: grid; place-items: center; font-size: 30px; font-weight: 800; color: rgba(59,42,32,.25); }
.topic-select { flex: none; font: inherit; font-size: 18px; font-weight: 700; padding: 10px 14px; border-radius: 14px; border: 2px solid #E5DCCD; background: #fff; margin: 4px 0; }

/* ---------- Safari / iPad: giữ hình nằm gọn trong thẻ ---------- */
.choice, .tile, .talk-tile, .stk, .rec-art, .strip .slot, .sticker-big { overflow: hidden; }
.choice { display: flex; flex-direction: column; align-items: center; justify-content: center; }
.choice > .art { width: 100%; max-width: 100%; }
.choices.n4 .choice > .art, .build .choice > .art { width: 82%; }
.tile > .art, .talk-tile > .art { max-width: 100%; }
@supports not (aspect-ratio: 1) {
  .stk { height: min(28vw, 130px); }
  .progress i { height: clamp(26px, 7vw, 40px); }
}
/* 4 hình: màn ngang xếp 1 hàng, màn dọc xếp 2×2 (theo khung còn trống) */
@container (min-aspect-ratio: 3/2) { .choices.n4 .choice { --s: min(300px, 24cqw - 14px, 94cqh); } }
@container (max-aspect-ratio: 3/2) { .choices.n4 .choice { --s: min(300px, 48cqw - 12px, 48cqh - 12px); } }

/* ---------- Ảnh chụp thật ---------- */
.art.photo > img { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover; display: block;
  border-radius: 18%; border: 4px solid #fff; box-shadow: 0 6px 14px rgba(59,42,32,.18); box-sizing: border-box; background: #fff;
  -webkit-user-drag: none; user-select: none; pointer-events: none; }
.card .art.photo { animation: photo-float 4.5s ease-in-out infinite; animation-delay: var(--d); }
.card .art.photo.boing { animation: boing .6s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes photo-float { 50% { transform: translateY(-2.5%) rotate(-1deg); } }
.choice .art.photo > img, .talk-tile .art.photo > img, .tile .art.photo > img { border-width: 3px; border-radius: 16%; }
.stk .art.photo > img, .sticker-big .art.photo > img { border-radius: 50%; border: 0; box-shadow: none; }
.strip .art.photo > img, .rec-art .art.photo > img { border-width: 2px; }
/* Trang nguồn ảnh */
.credit-list { list-style: none; padding: 0; margin: 0; }
.credit-list li { display: flex; gap: 10px; align-items: center; background: #fff; border-radius: 14px; padding: 8px; margin: 6px 0; }
.credit-list img { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; flex: none; }
.credit-list small { display: block; color: var(--ink-soft); font-size: 13px; line-height: 1.35; word-break: break-word; }
.credit-list a { color: #1E88E5; }
@media (prefers-reduced-motion: reduce) { .card .art.photo { animation: none; } }

/* ---------- Phần bị khoá (trang chủ) ---------- */
.group .group-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 16px 4px 6px; }
.group .group-head h2 { margin: 0; }
.group.locked .group-head h2 { color: var(--ink-soft); }
.group-head .unlock { flex: none; font-size: clamp(15px, 3.6vw, 19px); padding: 7px 16px; background: #fff; border: 3px solid #FFD54F; box-shadow: 0 4px 0 rgba(59,42,32,.14); }
/* Ô khoá vẫn giữ hình dáng ô thường, chỉ dịu màu đi và có ổ khoá ở góc. */
.tile.locked { --c: #E4D8C8 !important; --tb: #FBF7F0 !important; }
.tile.locked .art { filter: grayscale(.45); opacity: .72; }
.tile.locked span { color: #9C8B7E; }
.tile .lock { position: absolute; top: 6px; right: 6px; width: 30px; height: 30px; display: grid; place-items: center; font-style: normal; font-size: 16px;
  background: #fff; border-radius: 50%; box-shadow: 0 2px 6px rgba(59,42,32,.16); }
.home .tiles.modes .tile .lock { width: 26px; height: 26px; font-size: 14px; top: 4px; right: 4px; }

/* ---------- Hộp nhập mã ---------- */
.unlock-ov { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px;
  background: rgba(59,42,32,.42); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); animation: fade-in .18s ease-out; }
.unlock-ov.out { opacity: 0; transition: opacity .18s; }
@keyframes fade-in { from { opacity: 0; } }
.unlock-box { width: min(100%, 460px); max-height: 100%; overflow-y: auto; text-align: center; background: #FFFDF8; border-radius: 30px;
  padding: 22px 22px 18px; box-shadow: 0 10px 0 rgba(59,42,32,.14), 0 24px 60px rgba(59,42,32,.28); animation: screen-in .22s ease-out; }
.unlock-icon { position: relative; width: 80px; height: 80px; margin: 0 auto 8px; display: grid; place-items: center; font-size: 46px; line-height: 1;
  background: #FFF1D6; border-radius: 50%; }
.unlock-icon i { position: absolute; right: -2px; bottom: -2px; width: 34px; height: 34px; display: grid; place-items: center; font-style: normal; font-size: 18px;
  background: #fff; border-radius: 50%; box-shadow: 0 2px 6px rgba(59,42,32,.18); }
.unlock-icon.yay { background: #FFF6C7; animation: float 2s ease-in-out infinite; }
.unlock-box h3 { margin: 0 0 12px; font-size: clamp(20px, 5vw, 26px); line-height: 1.2; }
.unlock-peek { display: grid; grid-template-columns: repeat(var(--n, 6), minmax(0, 1fr)); gap: 8px; margin: 0 0 12px; }
.peek { display: flex; flex-direction: column; align-items: center; background: var(--tb); border: 3px solid var(--c); border-radius: 16px; padding: 5px 2px 4px; }
.peek .art { width: min(52px, 100%); }
.peek span { margin-top: 3px; font-size: 12px; font-weight: 800; line-height: 1.1; }
.unlock-hint { margin: 0 0 12px; color: var(--ink-soft); font-size: 16px; }
.unlock-code { width: 100%; padding: 10px 14px; font: inherit; font-size: 26px; font-weight: 800; letter-spacing: .2em; text-align: center; text-transform: uppercase;
  color: var(--ink); background: #fff; border: 3px solid #F1E2C8; border-radius: 18px; outline: none; transition: border-color .15s; }
.unlock-code::placeholder { font-size: 18px; font-weight: 600; letter-spacing: normal; text-transform: none; color: #B9A999; }
.unlock-code:focus { border-color: #FFB547; }
.unlock-code.bad { border-color: #E57373; }
.unlock-err { min-height: 1.35em; margin: 6px 0 8px; color: #B3261E; font-size: 15px; font-weight: 700; }
.unlock-actions { display: flex; gap: 10px; }
.unlock-actions .btn { flex: 1; padding: 11px 14px; font-size: 19px; }
.unlock-actions .later { background: #F3ECE2; }
.unlock-actions .go { background: #FFB547; }
.unlock-actions .go:disabled { opacity: .6; }
@media (prefers-reduced-motion: reduce) { .unlock-icon.yay, .unlock-ov, .unlock-box { animation: none; } }

/* ---------- Mua mã bằng chuyển khoản ---------- */
.unlock-or { display: flex; align-items: center; gap: 10px; margin: 16px 0 10px; color: #A8988A; font-size: 14px; font-weight: 700; }
.unlock-or::before, .unlock-or::after { content: ''; flex: 1; height: 2px; background: #F1E6D6; border-radius: 2px; }
.unlock-box .buy { width: 100%; padding: 11px 14px; font-size: 18px; background: #E8F5E9; color: #2E6B34; box-shadow: 0 4px 0 rgba(46,107,52,.18); }
.unlock-box .buy.wait, .group-head .unlock.wait { background: #FFF6C7; color: #7A5A00; border-color: #FFE082; }
.pay-back { display: block; margin: -6px 0 2px -6px; padding: 6px 8px; background: none; border: 0; font: inherit; font-size: 15px; font-weight: 700; color: var(--ink-soft); cursor: pointer; }
.pay-note { margin: -4px 0 10px; padding: 8px 12px; border-radius: 14px; background: #FFE9E6; color: #A1332B; font-size: 14px; font-weight: 600; }
.pay-card { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 14px; align-items: center; text-align: left; background: #fff; border: 3px solid #F1E2C8; border-radius: 22px; padding: 12px; }
.pay-qr { width: 150px; aspect-ratio: 1; display: grid; place-items: center; background: #fff; border-radius: 12px; }
.pay-qr svg { width: 100%; height: 100%; display: block; }
.pay-qr-wait { font-size: 13px; color: #A8988A; text-align: center; padding: 8px; }
.pay-info { margin: 0; display: grid; gap: 6px; }
.pay-info div { display: grid; gap: 1px; }
.pay-info dt { font-size: 12px; font-weight: 700; color: #A8988A; text-transform: uppercase; letter-spacing: .03em; }
.pay-info dd { margin: 0; display: flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 800; word-break: break-word; }
.pay-amount { font-size: 22px; color: #E8590C; }
.pay-ref { font-family: ui-monospace, Menlo, Consolas, monospace; background: #FFF1D6; padding: 1px 7px; border-radius: 8px; white-space: nowrap; }
.pay-info dd > span { white-space: nowrap; }
.copy { flex: none; padding: 3px 10px; border: 0; border-radius: 999px; background: #F3ECE2; font: inherit; font-size: 13px; font-weight: 800; color: var(--ink-soft); cursor: pointer; }
.copy:active { transform: translateY(1px); }
.pay-steps { margin: 12px 0 10px; padding-left: 22px; text-align: left; font-size: 15px; line-height: 1.45; color: var(--ink-soft); }
.pay-steps li + li { margin-top: 4px; }
.pay-pick { display: flex; flex-direction: row; justify-content: center; align-items: center; gap: 12px; padding: 10px 12px; min-height: 56px; border: 3px dashed #E4D3BC; border-radius: 18px; background: #FFFBF3; cursor: pointer; font-weight: 800; color: #8A6A3F; }
.pay-pick:active { background: #FFF4E2; }
.pay-preview { flex: none; width: auto; max-width: 72px; height: 72px; object-fit: cover; object-position: top; border-radius: 10px; box-shadow: 0 2px 8px rgba(59,42,32,.15); }
/* Chọn các phần muốn mua (mua nhiều phần một lần) */
.pay-pick-hint { margin: 0 0 6px; font-size: 14px; font-weight: 700; color: var(--ink-soft); text-align: left; }
.pay-parts { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 6px; margin: 0 0 10px; }
.unlock-box.wide { width: min(100%, 640px); }
.unlock-box.wide .pay-card { grid-template-columns: 170px minmax(0, 1fr); }
.unlock-box.wide .pay-qr { width: 170px; }
.unlock-box.wide .pay-info { gap: 3px; }
.pay-steps .pay-amount { font-size: inherit; }
.pp { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border: 3px solid #F1E2C8; border-radius: 16px; background: #fff; cursor: pointer; text-align: left; transition: border-color .15s, background .15s; }
.pp input { width: 20px; height: 20px; margin: 0; flex: none; accent-color: #43A047; }
.pp span { flex: 1; min-width: 0; font-weight: 800; font-size: 15px; line-height: 1.15; }
.pp small { display: block; font-weight: 600; font-size: 12px; color: #A8988A; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pp b { flex: none; font-size: 14px; color: #E8590C; }
.pp .ic { font-style: normal; }
.pp.on { border-color: #81C784; background: #F1F8F1; }
/* Màn hẹp (điện thoại): QR nhỏ cạnh số tiền + ngân hàng; số tài khoản, chủ tài khoản, nội dung trải hết bề ngang. */
@media (max-width: 440px) {
  .unlock-box { padding: 18px 16px 14px; }
  .pay-card, .unlock-box.wide .pay-card { grid-template-columns: 112px minmax(0, 1fr); gap: 8px 12px; padding: 10px; }
  .pay-qr, .unlock-box.wide .pay-qr { width: 112px; grid-row: 1 / span 3; grid-column: 1; }
  .pay-parts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pp { padding: 7px 8px; gap: 6px; }
  .pp .ic, .pp small { display: none; }
  .pp span { white-space: nowrap; }
  .pay-info { display: contents; }
  /* Cạnh QR: số tiền, ngân hàng, chủ TK. Số tài khoản và nội dung mỗi thứ một hàng (không ngắt dòng). */
  .pay-info div:nth-child(1) { grid-column: 2; grid-row: 1; }
  .pay-info div:nth-child(2) { grid-column: 2; grid-row: 2; }
  .pay-info div:nth-child(4) { grid-column: 2; grid-row: 3; }
  .pay-info div:nth-child(3) { grid-column: 1 / -1; grid-row: 4; }
  .pay-info div:nth-child(5) { grid-column: 1 / -1; grid-row: 5; }
  .pay-info dd { font-size: 15px; }
  .pay-steps { margin: 10px 0 8px; font-size: 14px; }
  .unlock-actions .btn { padding: 10px 8px; font-size: 17px; white-space: nowrap; }
}
