:root {
  --bg: #fff8f1; --card: #ffffff; --ink: #2b2118; --muted: #7a6a5c; --line: #f0e2d4;
  --brand: #f26b3a; --brand-ink: #ffffff; --soft: #ffe9dc; --ok: #1f8a4c; --no: #c0392b; --gold: #f5b301;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #1d1712; --card: #2a221b; --ink: #f6ece2; --muted: #b9a797; --line: #3d3228; --soft: #3d2a1f; --ok: #4cc283; --no: #ff7a6b; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 17px/1.5 Nunito, system-ui, sans-serif; }
main { max-width: 860px; margin: 0 auto; padding: 16px 16px 48px; }
h1 { font-size: 1.6rem; line-height: 1.25; margin: .4em 0; }
h2 { font-size: 1.2rem; margin: 1.4em 0 .6em; }
a { color: var(--brand); }
.muted { color: var(--muted); } .small { font-size: .85rem; } .center { text-align: center; }
.error { color: var(--no); min-height: 1em; margin: 0; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 16px; }
label { display: flex; flex-direction: column; gap: 4px; font-weight: 700; }
input, select, textarea { font: inherit; padding: 10px 12px; border: 2px solid var(--line); border-radius: 12px; background: var(--card); color: var(--ink); width: 100%; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.btn { display: inline-block; text-align: center; text-decoration: none; cursor: pointer; border: 0; border-radius: 14px; padding: 10px 18px; font: inherit; font-weight: 800; background: var(--brand); color: var(--brand-ink); }
.btn.big { font-size: 1.15rem; padding: 14px 22px; width: 100%; margin-top: 12px; }
.btn.ghost { background: var(--soft); color: var(--ink); }
.btn:disabled { opacity: .6; cursor: wait; }

.login { max-width: 400px; margin: 6vh auto 0; text-align: center; }
.login form { text-align: left; margin-top: 20px; }
.kid input { font-size: 1.3rem; letter-spacing: .1em; }

.top { display: flex; justify-content: space-between; align-items: center; }
.stars { background: var(--soft); border-radius: 999px; padding: 6px 16px; font-size: 1.3rem; }
.tabs { display: flex; gap: 8px; margin: 14px 0 4px; flex-wrap: wrap; }
.tabs a, .tabs button { padding: 8px 16px; border-radius: 999px; text-decoration: none; color: var(--ink); background: var(--card); border: 1px solid var(--line); font: inherit; font-weight: 700; cursor: pointer; }
.tabs [aria-current], .tabs [aria-selected="true"] { background: var(--ink); color: var(--bg); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.item { display: flex; gap: 12px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 10px; text-decoration: none; color: inherit; }
.item:hover { border-color: var(--brand); }
.thumb { width: 84px; height: 84px; flex: none; border-radius: 12px; background: var(--soft); display: grid; place-items: center; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.emoji { font-size: 2.4rem; }
.title { font-weight: 800; line-height: 1.25; margin: 2px 0 4px; }
.done { color: var(--ok); font-weight: 800; font-size: .9rem; }
.todo { color: var(--brand); font-weight: 800; font-size: .9rem; }
.empty { text-align: center; padding: 48px 0; color: var(--muted); font-size: 1.1rem; }

.back { display: inline-block; margin-bottom: 8px; text-decoration: none; font-weight: 700; }
.media video, .media iframe, .media .page { width: 100%; border-radius: 14px; border: 0; background: #000; }
.media iframe { height: 75vh; background: #fff; }
.media audio { width: 100%; }
.reading { background: var(--card); border-radius: 14px; padding: 8px 20px; font-size: 1.15rem; line-height: 1.7; }

.progress { display: flex; gap: 6px; margin: 8px 0 16px; }
.progress span { flex: 1; height: 8px; border-radius: 4px; background: var(--line); }
.progress .on { background: var(--ok); } .progress .now { background: var(--brand); }
.q { font-size: 1.5rem; }
.opt { font: inherit; font-size: 1.2rem; font-weight: 700; text-align: left; padding: 16px 18px; border-radius: 16px; border: 2px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; min-height: 56px; }
.opt:hover { border-color: var(--brand); }

.result { padding: 16px 0; }
.burst { font-size: 5rem; animation: pop .6s ease-out; }
@keyframes pop { from { transform: scale(.2) rotate(-30deg); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .burst { animation: none; } }
.review { padding-left: 20px; } .review li { margin-bottom: 12px; }
.review .ok b { color: var(--ok); } .review .no b { color: var(--no); }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 16px; }
.stats .card { text-align: center; padding: 12px 6px; } .stats b { display: block; font-size: 1.8rem; } .stats span { font-size: .85rem; color: var(--muted); }
table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: 14px; overflow: hidden; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.bar { display: inline-block; width: 60px; height: 8px; background: var(--line); border-radius: 4px; margin-right: 8px; overflow: hidden; vertical-align: middle; }
.bar i { display: block; height: 100%; background: var(--ok); }
.plain { list-style: none; padding: 0; } .plain li { padding: 6px 0; border-bottom: 1px solid var(--line); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; } .row > * { flex: 1 1 160px; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 14px; font-weight: 400; }
.checks label { flex-direction: row; align-items: center; font-weight: 400; gap: 6px; }
.checks input, .opts-edit input[type=radio] { width: auto; }
.qedit { border-left: 4px solid var(--brand); }
.opts-edit { display: grid; grid-template-columns: auto 1fr; gap: 6px 8px; align-items: center; }
.table-wrap { overflow-x: auto; }
@media (max-width: 520px) { body { font-size: 16px; } .stats b { font-size: 1.4rem; } }
.frame { position: relative; width: 100%; aspect-ratio: 16 / 9; border-radius: 14px; overflow: hidden; background: #000; }
.frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.stop { padding: 32px 16px; }
.tv { text-align: center; padding-top: 4vh; }
.tv .qr { background: #fff; display: inline-block; padding: 16px; border-radius: 18px; }
.tv .qr svg { width: min(44vh, 70vw); height: auto; display: block; }
.tv .code { font-size: 3rem; letter-spacing: .3em; font-weight: 900; margin: 12px 0; }
/* tivi điều khiển bằng remote: ô đang chọn phải thật rõ */
@media (min-width: 1200px) and (hover: none) { a:focus, button:focus { outline: 5px solid var(--gold); outline-offset: 4px; } }
[hidden] { display: none !important; }
