/* KidGo · giao diện dùng chung. Viết cho điện thoại trước; nút chính tối thiểu 48px (03). */
:root {
  --bg: #fff8ec;
  --card: #ffffff;
  --ink: #2b2b2b;
  --muted: #6b6b6b;
  --accent: #e4572e;
  --accent-ink: #ffffff;
  --ok: #2e9e5b;
  --warn: #d98c00;
  --line: #eadfcd;
  --radius: 18px;
}
* { box-sizing: border-box; }
/* Các lớp như .overlay đặt display riêng; thuộc tính hidden phải luôn thắng để JS ẩn được. */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif; font-size: 17px; line-height: 1.5;
}
a { color: var(--accent); }
.wrap { max-width: 720px; margin: 0 auto; padding: 16px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; }
.brand { font-weight: 800; color: var(--accent); text-decoration: none; font-size: 20px; }
h1 { font-size: 26px; margin: 8px 0 12px; }
h2 { font-size: 20px; margin: 20px 0 8px; }
p.muted, .muted { color: var(--muted); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 12px 0; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 10px 20px;
  border-radius: 999px; border: 2px solid var(--accent); background: var(--accent); color: var(--accent-ink);
  font-size: 18px; font-weight: 700; text-decoration: none; cursor: pointer;
}
.btn.secondary { background: transparent; color: var(--accent); }
.btn.small { min-height: 40px; font-size: 15px; padding: 6px 14px; }
.btn.big { min-height: 72px; font-size: 26px; padding: 14px 36px; }
.btn:focus-visible, button:focus-visible, a:focus-visible, input:focus-visible { outline: 3px solid #1d6fd6; outline-offset: 3px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
form.stack label { display: block; font-weight: 600; margin: 14px 0 6px; }
form.stack input, form.stack select {
  width: 100%; min-height: 48px; padding: 10px 14px; font-size: 18px; border: 2px solid var(--line); border-radius: 12px; background: #fff;
}
form.stack .hint { font-size: 14px; color: var(--muted); margin-top: 4px; }
.error { color: #b3261e; font-size: 15px; margin-top: 4px; }
.flash { background: #e8f6ee; border: 1px solid #b6e3c8; border-radius: 12px; padding: 10px 14px; margin: 10px 0; }
.flash.warn { background: #fff4dc; border-color: #f2d48b; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.grid-avatars { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; margin: 16px 0; }
.avatar-btn {
  width: 100%; min-height: 160px; border: 3px solid var(--line); border-radius: 24px; background: #fff; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; font-size: 20px; font-weight: 700; color: var(--ink);
}
.avatar-btn .emoji { font-size: 72px; line-height: 1; }
.avatar-pick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.avatar-pick label { margin: 0 !important; }
.avatar-pick input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.avatar-pick span { display: flex; justify-content: center; align-items: center; font-size: 40px; min-height: 64px; border: 3px solid var(--line); border-radius: 16px; background: #fff; cursor: pointer; }
.avatar-pick input:checked + span { border-color: var(--accent); background: #ffe9e1; }
.adult-corner { position: fixed; top: 10px; right: 10px; z-index: 5; }
table.simple { width: 100%; border-collapse: collapse; font-size: 16px; }
table.simple th, table.simple td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.phrase { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.phrase .en { font-weight: 700; }
.icon-btn { min-width: 48px; min-height: 48px; border-radius: 50%; border: 2px solid var(--accent); background: #fff; font-size: 22px; cursor: pointer; }

/* ── Trình phát bài của bé ──
   Bố cục: thanh trên (thoát, tiến độ tới ngôi sao) → lời hướng dẫn trong khung thoại → nội dung và nút Tiếp đi liền
   nhau, cả khối căn giữa phần còn lại của màn hình. Nội dung dài thì nút Tiếp dính đáy. Nút to, nổi khối như kẹo
   để bé 3–10 tuổi nhận ra chỗ chạm; chạm vào thì lún xuống. */
.player { max-width: 720px; margin: 0 auto; padding: 10px 16px 12px; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
#player { flex: 1; display: flex; flex-direction: column; }
.player-top { display: flex; align-items: center; gap: 12px; }
.player-top .btn.small { flex: none; width: 44px; height: 44px; min-height: 44px; padding: 0; border-radius: 50%; background: #fff; box-shadow: 0 3px 0 var(--line); }
.dots { display: flex; flex: 1; align-items: center; gap: 5px; }
.dots i { flex: 1; height: 12px; border-radius: 6px; background: #efe3cf; display: block; }
.dots i.done { background: var(--ok); }
.dots i.now { background: var(--accent); box-shadow: 0 0 0 3px #ffd9cb; }
.dots::after { content: '⭐'; font-size: 24px; line-height: 1; margin-left: 2px; }
.instruction { display: flex; align-items: center; gap: 10px; margin: 12px 0 0; padding: 8px 14px 8px 8px; background: #fff; border-radius: 22px; box-shadow: 0 3px 0 var(--line); font-size: 18px; font-weight: 600; line-height: 1.35; }
.instruction .icon-btn { flex: none; background: var(--accent); border-color: var(--accent); color: #fff; }
.stage { display: flex; flex-direction: column; align-items: center; gap: 14px; margin-top: auto; padding-top: 14px; }
.stage img.main { width: auto; max-width: min(100%, 520px); max-height: 42vh; object-fit: contain; border-radius: 24px; border: 4px solid #fff; background: #fff; box-shadow: 0 6px 18px rgba(120, 80, 30, .15); }
/* Clip của bé (D21): khung vuông như tranh; điểm nhấn vẽ chồng lên theo tỉ lệ khung. */
.vis { position: relative; display: block; overflow: hidden; }
.vis video { display: block; width: 100%; height: auto; aspect-ratio: 1 / 1; object-fit: cover; background: #fff; }
.stage .vis.main { width: min(100%, 520px, 42vh); border-radius: 24px; border: 4px solid #fff; background: #fff; box-shadow: 0 6px 18px rgba(120, 80, 30, .15); }
.cards button .vis, .cards button .vis video { border-radius: 14px; }
.choices button .vis, .choices button .vis video { border-radius: 18px; }
.cue { position: absolute; pointer-events: none; transform: translate(-50%, -50%); }
.cue.ring { width: 22%; aspect-ratio: 1 / 1; border: 5px solid #ffcf3f; border-radius: 50%; box-shadow: 0 0 0 4px rgba(255, 255, 255, .7), 0 0 18px rgba(255, 190, 0, .8); animation: cue-pulse .7s ease-in-out infinite alternate; }
.cue.arrow { font-size: clamp(28px, 9vw, 56px); line-height: 1; color: #ff8a00; text-shadow: 0 0 6px #fff, 0 0 2px #fff; animation: cue-nudge .5s ease-in-out infinite alternate; }
@keyframes cue-pulse { from { transform: translate(-50%, -50%) scale(.9); } to { transform: translate(-50%, -50%) scale(1.08); } }
@keyframes cue-nudge { from { margin-top: -4px; } to { margin-top: 4px; } }
.lines { width: min(100%, 520px); }
.lines p { margin: 6px 0; font-size: 22px; }
.lines p b { color: var(--accent); }
.lines p.on { background: #fff1c2; border-radius: 10px; }
.chant-lines p { font-size: 26px; font-weight: 700; text-align: center; margin: 4px 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; width: 100%; }
.cards button { background: #fff; border: 3px solid var(--line); border-radius: 20px; padding: 8px; cursor: pointer; font-size: 22px; font-weight: 800; color: var(--ink); box-shadow: 0 5px 0 var(--line); }
.cards button img { width: 100%; border-radius: 14px; display: block; }
.cards button.seen { border-color: var(--ok); }
.cards button.playing { border-color: var(--accent); transform: scale(1.03); }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; width: 100%; max-width: 760px; }
.choices button { background: #fff; border: 4px solid var(--line); border-radius: 24px; padding: 6px; cursor: pointer; box-shadow: 0 5px 0 var(--line); }
.choices button img { width: 100%; border-radius: 18px; display: block; }
.choices button.correct { border-color: var(--ok); box-shadow: 0 0 0 6px #c9efd8; }
.choices button.wrong { border-color: #c0392b; animation: shake .35s; }
.choices button.hint { border-color: var(--warn); box-shadow: 0 0 0 6px #ffe7b0; }
.choices.locked button { opacity: .5; }
.speaker { width: 84px; height: 84px; border-radius: 50%; border: 4px solid var(--accent); background: #fff; font-size: 40px; cursor: pointer; box-shadow: 0 5px 0 #f0b9a5; }
.player .btn.secondary.tool { background: #fff; box-shadow: 0 4px 0 #f0b9a5; }
.player .btn.secondary.tool.primary { background: var(--accent); box-shadow: 0 4px 0 #b8401f; }
.speaker:active, .player .tool:active, .cards button:active, .choices button:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--line); }
.feedback { font-size: 26px; font-weight: 800; min-height: 40px; text-align: center; }
.feedback.ok { color: var(--ok); }
.feedback.try { color: var(--warn); }
/* M2.1 · lượt nói, nghe và làm theo, trò nghe chọn nhanh, nhiệm vụ ở nhà */
.scene-note { width: min(100%, 520px); margin: 0; font-size: 19px; color: var(--muted); text-align: center; }
.bubble { width: min(100%, 520px); background: #fff; border: 3px solid var(--line); border-radius: 22px; padding: 10px 16px; font-size: 24px; font-weight: 700; }
.bubble small { display: block; font-size: 15px; font-weight: 600; color: var(--muted); }
.bubble.partner { border-color: var(--accent); }
.bubble.model { border-style: dashed; border-color: var(--warn); }
.bubble.turn { border-color: var(--ok); text-align: center; }
.talk-tools { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; width: min(100%, 520px); }
.talk-tools .btn { min-height: 56px; font-size: 20px; }
.talk-tools .btn.said { background: var(--ok); border-color: var(--ok); color: #fff; }
.mic-note { font-size: 16px; color: var(--muted); text-align: center; min-height: 20px; margin: 0; }
.commands { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; width: min(100%, 560px); }
.commands span { background: #fff; border: 3px solid var(--line); border-radius: 18px; padding: 10px 16px; font-size: 24px; font-weight: 800; }
.commands span.on { border-color: var(--accent); background: #fff1c2; transform: scale(1.08); }
.commands span.done { border-color: var(--ok); }
.do-figure { font-size: 88px; line-height: 1; }
.rounds { display: flex; gap: 8px; font-size: 30px; }
.rounds i { font-style: normal; opacity: .25; filter: grayscale(1); }
.rounds i.done { opacity: 1; filter: none; }
.rounds i.now { opacity: .6; filter: grayscale(1); transform: scale(1.25); animation: pop .4s ease-out; }
.mission { width: min(100%, 560px); background: #fff; border: 3px solid var(--ok); border-radius: 22px; padding: 14px 18px; }
.mission p { font-size: 22px; font-weight: 700; margin: 0 0 8px; }
.mission .muted { font-size: 16px; font-weight: 600; }
.mission .phrase-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 0; border-top: 1px solid var(--line); font-size: 22px; font-weight: 700; }
.mission .phrase-row button { width: 56px; height: 56px; border-radius: 50%; border: 3px solid var(--accent); background: #fff; font-size: 26px; cursor: pointer; }
/* Nút thao tác dùng chung (biểu tượng + nhãn). Giao diện cũ: một hàng chữ; loa tròn lớn chỉ hiện biểu tượng. */
.speaker .lbl { display: none; }
.btn.secondary.primary { background: var(--accent); color: var(--accent-ink); }
.tappable { cursor: pointer; }
.rail { display: none; }

/* ── Giao diện video ngắn (đang thử với L002): màn hình dọc, cột nút bên phải, vuốt lên để đi tiếp ── */
body:has(.player.shorts) { background: #15110e; }
.player.shorts { position: relative; max-width: 560px; height: 100vh; height: 100dvh; padding: 0; overflow: hidden; background: #15110e; color: #fff; }
.shorts .player-top { position: absolute; top: 0; left: 0; right: 0; z-index: 4; padding: 10px 12px 18px; background: linear-gradient(rgba(0, 0, 0, .55), transparent); }
.shorts .player-top .btn { color: #fff; border-color: rgba(255, 255, 255, .7); }
.shorts .player-top .btn.small { background: rgba(0, 0, 0, .3); box-shadow: none; }
.shorts .dots { gap: 4px; }
.shorts .dots i { flex: 1; width: auto; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, .3); transform: none; }
.shorts .dots i.done { background: #fff; }
.shorts .dots i.now { background: var(--accent); transform: none; }
/* Căn giữa bằng margin auto thay vì justify-content: nội dung cao hơn màn hình vẫn cuộn được, không bị cắt phía trên. */
.shorts .stage { position: absolute; inset: 0; margin: 0; padding: 64px 84px 160px 12px; overflow-y: auto; justify-content: flex-start; gap: 12px; }
/* Cột nút phải trống (thẻ từ, nhiệm vụ ở nhà): nội dung căn giữa, dùng hết bề ngang. */
.shorts #player.no-rail .stage { padding-right: 12px; }
.shorts #player.no-rail .stage > img.main, .shorts #player.no-rail .stage > .vis.main { width: 100%; align-self: center; }
.shorts #player.no-rail .instruction { padding-right: 12px; }
.shorts .dots::after { content: none; }
.shorts .stage > :first-child { margin-top: auto; }
.shorts .stage > :last-child { margin-bottom: auto; }
.shorts .stage.enter { animation: slide-up .35s ease-out; }
.shorts .stage > img.main, .shorts .stage > .vis.main { width: calc(100% + 72px); max-width: none; max-height: none; aspect-ratio: 1 / 1; object-fit: cover; align-self: flex-start; border: 0; border-radius: 16px; }
.shorts .choices { grid-template-columns: 1fr; width: min(100%, calc((100dvh - 330px) / 2)); }
.shorts .cards { grid-template-columns: 1fr 1fr; gap: 14px; width: min(100%, 440px, calc(100dvh - 300px)); }
.shorts .cards button { font-size: 24px; padding: 8px 8px 6px; }
.shorts .lines p, .shorts .chant-lines p { color: #fff; }
.shorts .lines p b { color: #ffb38f; }
.shorts .lines p.on { background: rgba(255, 207, 63, .28); }
.shorts .scene-note, .shorts .mic-note { color: #e6ddd2; }
.shorts .feedback.ok { color: #5fd68f; }
.shorts .feedback.try { color: #ffc04d; }
.shorts .bubble, .shorts .mission, .shorts .commands span { color: var(--ink); }
.shorts .instruction { position: absolute; left: 0; right: 0; bottom: 84px; z-index: 3; margin: 0; padding: 28px 84px 10px 12px; border-radius: 0; box-shadow: none; background: linear-gradient(transparent, rgba(0, 0, 0, .75)); color: #fff; font-size: 16px; font-weight: 600; text-shadow: 0 1px 2px #000; }
.shorts .instruction .icon-btn { background: rgba(255, 255, 255, .15); color: #fff; border-color: rgba(255, 255, 255, .6); }
.shorts .rail { position: absolute; right: 6px; bottom: 160px; z-index: 5; display: flex; flex-direction: column; align-items: center; gap: 14px; width: 72px; }
.shorts .rail .talk-tools { flex-direction: column; flex-wrap: nowrap; align-items: center; gap: 14px; width: auto; }
.shorts .rail .btn.secondary.tool { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 72px; height: auto; min-height: 0; padding: 0; border: 0; border-radius: 0; background: none; color: #fff; font-size: 12px; font-weight: 700; text-shadow: 0 1px 2px #000; box-shadow: none; }
.shorts .rail .tool .ico { display: flex; align-items: center; justify-content: center; width: 56px; height: 56px; border-radius: 50%; background: rgba(255, 255, 255, .2); font-size: 28px; text-shadow: none; }
.shorts .rail .tool .lbl { display: block; line-height: 1.2; text-align: center; }
.shorts .rail .btn.secondary.tool.primary { background: none; box-shadow: none; }
.shorts .rail .tool.primary .ico { background: var(--accent); }
.shorts .rail .tool:active { transform: none; box-shadow: none; }
.shorts .rail .tool:active .ico { transform: scale(.92); }
.shorts .rail .tool.said .ico { background: var(--ok); }
.shorts .player-bottom { position: absolute; left: 0; right: 0; bottom: 0; margin: 0; background: transparent; border: 0; padding: 10px 16px 18px; z-index: 6; }
.shorts .player-bottom .btn.big { min-height: 60px; font-size: 22px; padding: 10px 30px; box-shadow: 0 6px 0 #9c3517, 0 8px 18px rgba(0, 0, 0, .35); }
.shorts .player-bottom .btn.big:not([disabled]) { animation: nudge-up 1.1s ease-in-out infinite; }
.shorts .player-bottom .btn.big[disabled] { background: rgba(255, 255, 255, .14); border-color: rgba(255, 255, 255, .25); color: #e6ddd2; box-shadow: none; font-size: 18px; }
.shorts .overlay { background: #15110e; color: #fff; }
@keyframes slide-up { from { transform: translateY(60px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes nudge-up { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
/* Nút Tiếp đi liền dưới nội dung (cùng khối căn giữa); nội dung dài thì dính đáy, nền mờ dần để không che chữ. */
.player-bottom { position: sticky; bottom: 0; z-index: 4; margin-bottom: auto; display: flex; justify-content: center; gap: 12px; padding: 18px 0 8px; background: linear-gradient(rgba(255, 248, 236, 0), var(--bg) 40%); }
.player-bottom .btn.big { min-width: 220px; border-color: var(--accent); box-shadow: 0 6px 0 #b8401f; transition: transform .08s, box-shadow .08s; }
.player-bottom .btn.big:active:not([disabled]) { transform: translateY(4px); box-shadow: 0 2px 0 #b8401f; }
.player-bottom .btn.big:not([disabled]) { animation: ready 2.4s ease-in-out infinite; }
/* Còn khóa: nút màu cát, ghi lý do (Con nghe hết đã, Con chọn tranh nhé…) thay cho chữ Tiếp. */
.player-bottom .btn.big[disabled] { opacity: 1; background: #ece0cd; border-color: #ece0cd; color: #7d6c57; box-shadow: 0 6px 0 #d8c7ae; font-size: 20px; }
.next .wait { display: none; }
.next[disabled] .go { display: none; }
.next[disabled] .wait { display: inline; }
@keyframes ready { 0%, 80%, 100% { transform: scale(1); } 88% { transform: scale(1.06); } }
.overlay { position: fixed; inset: 0; background: var(--bg); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; z-index: 10; padding: 24px; text-align: center; }
.overlay .emoji { font-size: 96px; }
.net { position: fixed; left: 50%; transform: translateX(-50%); bottom: 90px; background: #fff4dc; border: 1px solid #f2d48b; border-radius: 12px; padding: 8px 14px; z-index: 6; }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.overlay .emoji, .feedback.ok { animation: pop .4s ease-out; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
@media (max-width: 420px) { h1 { font-size: 22px; } .btn.big { font-size: 22px; } .lines p { font-size: 19px; } }
/* Màn hình thấp (điện thoại nhỏ, cửa sổ xem trước): thu tranh và nút để nội dung cùng nút Tiếp vừa một màn hình. */
@media (max-height: 700px) {
  .stage img.main { max-height: 34vh; }
  .stage .vis.main { width: min(100%, 520px, 34vh); }
  .speaker { width: 68px; height: 68px; font-size: 32px; }
  .instruction { font-size: 16px; }
  .player-bottom .btn.big { min-height: 60px; font-size: 22px; }
  .chant-lines p { font-size: 22px; }
}

/* Vùng quản trị (/admin) */
.wrap.wide { max-width: 1100px; }
.admin-bar { flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.stat-grid .stat { margin: 0; }
.stat-grid .stat b { font-size: 28px; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th, .table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
