/* =====================================================================
   Học & Chơi - theme.css  ·  phong cách "Đảo Chữ": đồ chơi arcade / sticker
   - viền mực đậm (--c-ink) + bóng cứng lệch xuống, khối bo tròn, gradient bóng bẩy, nền trời-biển.
   - TOÀN BỘ token nằm ở :root (sáng) và [data-theme="dark"] (tối). JS không chứa màu cứng cho DOM;
     canvas lấy màu qua HC.theme (js/core/theme.js).
   - Chủ đề: HC.theme đặt data-theme="light|dark" trên <html> theo cài đặt (auto = theo hệ điều hành).
   - Game mới: chỉ dùng các biến + component ở đây (.btn .card .chip .progress .hud .screen ...).
   ===================================================================== */
:root {
  color-scheme: light;
  /* mực + bề mặt */
  --c-ink: #1b2559;
  --c-bg: #9fdcff;
  --c-bg-2: #e3f6ff;
  --c-surface: #fffdf6;
  --c-surface-2: #eef4ff;
  --c-surface-3: #dce7fb;
  --c-border: #1b2559;
  --c-line: #cfdaf2;
  --c-text: #1b2559;
  --c-muted: #56628e;
  /* màu chức năng: *-fill = nền khối, màu trơn = chữ trên bề mặt (đạt AA) */
  --c-primary: #2f66f3;
  --c-primary-hi: #5f8dff;
  --c-primary-deep: #1b3fae;
  --c-primary-ink: #ffffff;
  --c-primary-soft: #dfe8ff;
  --c-link: #1f4fd6;
  --c-accent: #ffc928;
  --c-accent-hi: #ffe680;
  --c-accent-deep: #c47a00;
  --c-accent-ink: #3a2500;
  --c-accent-soft: #fff3c4;
  --c-good: #0b7d4a;
  --c-good-fill: #35d184;
  --c-good-deep: #0b6e42;
  --c-good-soft: #d5f8e3;
  --c-bad: #c22436;
  --c-bad-fill: #ff5d6c;
  --c-bad-deep: #a81d2d;
  --c-bad-soft: #ffe0e3;
  --c-hot: #d62f45;          /* nền đỏ cho chữ trắng (đạt AA) */
  --c-warn: #8a4b00;
  --c-warn-fill: #ffab1f;
  --c-warn-soft: #ffefc2;
  --c-focus: #b5179e;
  --c-overlay: rgba(16, 24, 64, .62);
  /* biểu tượng */
  --c-heart: #ff4d6d;
  --c-heart-off: #c9d3ea;
  --c-flame: #ff7a1a;
  --c-flame-hi: #ffd23f;
  --c-star: #ffc928;
  --c-star-off: #d5dcec;
  --c-xp: #8b5cf6;
  /* màu nhận diện từng game (tranh bìa, viền thẻ) */
  --c-g-fish: #23a6f0;
  --c-g-cards: #9a6bff;
  --c-g-rain: #14b8a6;
  --c-g-sent: #ff8a3d;
  /* cảnh nền (trời, mây, đồi, sóng) */
  --c-sky-1: #7fd0ff;
  --c-sky-2: #dff6ff;
  --c-cloud: #ffffff;
  --c-sun: #ffd84d;
  --c-sun-glow: rgba(255, 233, 130, .55);
  --c-hill-1: #8fe0a0;
  --c-hill-2: #56c878;
  --c-wave-1: #62cdfa;
  --c-wave-2: #2fa4ea;
  --scene-stars: 0;
  /* canvas Mưa chữ (HC.theme đọc các biến này) */
  --c-canvas-bg: #86cfff;
  --c-canvas-bg-2: #e6f7ff;
  --c-canvas-ground: #56c878;
  --c-word-bg: #fffdf6;
  --c-word-ink: #1b2559;
  --c-word-done: #0b7d4a;
  --c-word-wrong: #c22436;
  --c-word-hint: #56628e;
  --c-card-band: #fff0b8;
  --c-card-line: #e3d7a6;
  /* hình khối */
  --radius-s: 10px;
  --radius-m: 16px;
  --radius-l: 24px;
  --radius-pill: 999px;
  --bw: 3px;
  --border-w: 3px;
  --shadow-1: 0 4px 0 var(--c-ink);
  --shadow-2: 0 6px 0 var(--c-ink);
  --shadow-soft: 0 14px 30px rgba(27, 37, 89, .22);
  /* chữ: chỉ dùng font hệ thống */
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  --font-emoji: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
  --fs-xs: .78rem;
  --fs-s: .9rem;
  --fs-m: 1rem;
  --fs-l: 1.25rem;
  --fs-xl: 1.75rem;
  --fs-xxl: 2.5rem;
  /* khoảng cách */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --page-max: 1080px;
  --tap: 48px;
  --dur: .18s;
}

/* ---------- Chủ đề tối: biển đêm ---------- */
:root[data-theme="dark"] {
  color-scheme: dark;
  --c-ink: #050a22;
  --c-bg: #0f1a47;
  --c-bg-2: #1a2a6b;
  --c-surface: #232f6e;
  --c-surface-2: #2c3a82;
  --c-surface-3: #394998;
  --c-border: #050a22;
  --c-line: #3d4c9a;
  --c-text: #f4f6ff;
  --c-muted: #bcc6f0;
  --c-primary: #3565ec;
  --c-primary-hi: #5f8dff;
  --c-primary-deep: #1d3da8;
  --c-primary-soft: #2b3f96;
  --c-link: #a9c1ff;
  --c-accent-soft: #4b3f17;
  --c-good: #6fe8ad;
  --c-good-soft: #17493f;
  --c-bad: #ff9aa3;
  --c-bad-soft: #57213a;
  --c-warn: #ffd27a;
  --c-warn-soft: #4a3a16;
  --c-focus: #ffe14d;
  --c-overlay: rgba(3, 6, 24, .7);
  --c-heart-off: #46549c;
  --c-star-off: #46549c;
  --c-sky-1: #0b1238;
  --c-sky-2: #1c2f7a;
  --c-cloud: #33438f;
  --c-sun: #f4f1d0;
  --c-sun-glow: rgba(214, 226, 255, .28);
  --c-hill-1: #1d4f6b;
  --c-hill-2: #163d5c;
  --c-wave-1: #1f4fa3;
  --c-wave-2: #173b85;
  --scene-stars: 1;
  --c-canvas-bg: #0d1640;
  --c-canvas-bg-2: #24388a;
  --c-canvas-ground: #1f6b55;
  --c-word-bg: #fffdf6;
  --c-word-ink: #1b2559;
  --c-word-done: #0b7d4a;
  --c-word-wrong: #c22436;
  --shadow-soft: 0 14px 30px rgba(0, 0, 0, .45);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh;
  background: linear-gradient(var(--c-sky-1), var(--c-sky-2) 70%) fixed var(--c-bg); color: var(--c-text);
  font-family: var(--font); font-size: var(--fs-m); line-height: 1.5; overflow-x: hidden;
}
h1, h2, h3, p { margin: 0; }
a { color: var(--c-link); }
img, canvas, svg { max-width: 100%; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); border: 0; white-space: nowrap; }
:focus-visible { outline: 3px solid var(--c-focus); outline-offset: 3px; }
button, input, select, textarea { font: inherit; color: inherit; }
.emoji { font-family: var(--font-emoji); }

/* ---------- Cảnh nền minh họa (HC.ui chèn .scene vào đầu <body>) ---------- */
.scene { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; background: linear-gradient(var(--c-sky-1), var(--c-sky-2) 72%); }
.scene__stars { position: absolute; inset: 0 0 35% 0; opacity: var(--scene-stars);
  background-image: radial-gradient(circle, #fff 1px, transparent 1.6px), radial-gradient(circle, #cfe0ff 1.2px, transparent 2px), radial-gradient(circle, #fff 1px, transparent 1.5px);
  background-size: 140px 120px, 220px 180px, 90px 160px; background-position: 20px 30px, 80px 90px, 50px 10px; }
.scene__sun { position: absolute; top: 5vh; right: 7vw; width: clamp(64px, 11vw, 120px); aspect-ratio: 1; border-radius: 50%; background: var(--c-sun); box-shadow: 0 0 0 14px var(--c-sun-glow), 0 0 0 34px var(--c-sun-glow); }
.scene__cloud { position: absolute; fill: var(--c-cloud); opacity: .92; width: clamp(110px, 18vw, 220px); animation: hc-drift 60s linear infinite alternate; }
.scene__cloud--1 { top: 9vh; left: 4vw; }
.scene__cloud--2 { top: 26vh; right: 16vw; width: clamp(80px, 12vw, 150px); opacity: .75; animation-duration: 85s; animation-direction: alternate-reverse; }
.scene__cloud--3 { top: 46vh; left: 22vw; width: clamp(70px, 10vw, 130px); opacity: .6; animation-duration: 110s; }
.scene__land { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: clamp(90px, 20vh, 190px); display: block; }
.scene__land .l1 { fill: var(--c-hill-1); }
.scene__land .l2 { fill: var(--c-hill-2); }
.scene__land .w1 { fill: var(--c-wave-1); }
.scene__land .w2 { fill: var(--c-wave-2); }

/* ---------- Bố cục ---------- */
.page { max-width: var(--page-max); margin: 0 auto; padding: var(--sp-4); }
.stack > * + * { margin-top: var(--sp-4); }
.row { display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: center; }
.row--between { justify-content: space-between; }
.grow { flex: 1 1 auto; }
.muted { color: var(--c-muted); }

/* tiêu đề kiểu game: chữ đậm có viền mực + bóng cứng */
.title-3d {
  font-weight: 900; letter-spacing: .01em; line-height: 1.1; color: var(--c-accent);
  text-shadow: -2px -2px 0 var(--c-ink), 2px -2px 0 var(--c-ink), -2px 2px 0 var(--c-ink), 2px 2px 0 var(--c-ink), 0 -2px 0 var(--c-ink), 0 2px 0 var(--c-ink), -2px 0 0 var(--c-ink), 2px 0 0 var(--c-ink), 0 6px 0 var(--c-ink);
}
.title-3d--white { color: #ffffff; }

/* thanh trên cùng của trang game */
.topbar { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); max-width: var(--page-max); margin: 0 auto; }
.topbar__title { display: inline-flex; align-items: center; gap: var(--sp-2); font-weight: 900; font-size: var(--fs-l); min-width: 0; padding: 4px 16px 4px 6px; background: var(--c-surface); border: var(--bw) solid var(--c-ink); border-radius: var(--radius-pill); box-shadow: var(--shadow-1); }
.topbar__title .ico { width: 34px; height: 34px; flex: none; }
.topbar__title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar__tools { margin-left: auto; display: flex; gap: var(--sp-2); }

/* ---------- Biểu tượng SVG (HC.art) ---------- */
.ico { display: inline-block; width: 1.4em; height: 1.4em; flex: none; vertical-align: -.3em; }
.ico svg { display: block; width: 100%; height: 100%; overflow: visible; }
.mascot { display: block; width: 120px; max-width: 100%; }
.mascot svg { display: block; width: 100%; height: auto; overflow: visible; }
.mascot--bob svg { animation: hc-bob 3.2s ease-in-out infinite; }

/* ---------- Nút: khối 3D bấm lún ---------- */
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: var(--tap); padding: 0 18px;
  border: var(--bw) solid var(--c-ink); border-radius: var(--radius-m);
  background: var(--c-surface); color: var(--c-text); font-weight: 800; text-decoration: none; text-align: center; line-height: 1.15;
  cursor: pointer; box-shadow: var(--shadow-1); transition: transform .09s ease-out, box-shadow .09s ease-out, filter var(--dur);
  -webkit-tap-highlight-color: transparent; touch-action: manipulation; user-select: none; -webkit-user-select: none;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 6px 0 var(--c-ink); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--c-ink); }
.btn[disabled], .btn[aria-disabled="true"] { cursor: not-allowed; transform: none; box-shadow: 0 2px 0 var(--c-ink); filter: grayscale(.75) opacity(.6); }
.btn--primary { background: linear-gradient(180deg, var(--c-primary) 45%, var(--c-primary-deep) 140%); color: var(--c-primary-ink); text-shadow: 0 1px 0 var(--c-primary-deep); }
.btn--primary::before, .btn--play::before, .btn--danger::before {
  content: ""; position: absolute; left: 7px; right: 7px; top: 4px; height: 26%; border-radius: 10px 10px 12px 12px;
  background: linear-gradient(rgba(255, 255, 255, .55), rgba(255, 255, 255, .12)); pointer-events: none;   /* vệt bóng nằm phía trên dòng chữ */
}
/* nút "chơi" vàng (hành động chính của màn hình) */
.btn--play { background: linear-gradient(180deg, var(--c-accent-hi), var(--c-accent) 50%, var(--c-warn-fill)); color: var(--c-accent-ink); text-shadow: 0 1px 0 rgba(255, 255, 255, .5); }
.btn--ghost { background: transparent; border-color: transparent; box-shadow: none; text-decoration: underline; text-underline-offset: 3px; }
.btn--ghost:hover { box-shadow: none; background: var(--c-surface); border-color: var(--c-ink); }
.btn--ghost:active { box-shadow: none; }
.btn--danger { background: linear-gradient(180deg, var(--c-hot) 40%, var(--c-bad-deep) 130%); color: #ffffff; text-shadow: 0 1px 0 var(--c-bad-deep); }
.btn--lg { min-height: 64px; padding: 0 var(--sp-6); font-size: 1.35rem; font-weight: 900; border-radius: 20px; box-shadow: var(--shadow-2); letter-spacing: .01em; }
.btn--lg:hover { box-shadow: 0 8px 0 var(--c-ink); }
.btn--lg:active { transform: translateY(5px); box-shadow: 0 1px 0 var(--c-ink); }
.btn--sm { min-height: 44px; padding: 0 var(--sp-3); font-size: var(--fs-s); border-radius: 14px; }
.btn--icon { min-width: var(--tap); padding: 0; border-radius: 50%; font-size: 1.25rem; }
.btn--icon .ico { width: 26px; height: 26px; }
.btn .ico { width: 1.3em; height: 1.3em; }

/* ---------- Thẻ (card) ---------- */
.card { background: var(--c-surface); border: var(--bw) solid var(--c-ink); border-radius: var(--radius-l); box-shadow: var(--shadow-2); padding: var(--sp-4); }
.card__title { font-size: var(--fs-l); font-weight: 900; }
.card__meta { color: var(--c-muted); font-size: var(--fs-s); }

/* ---------- Chip ---------- */
.chips { display: flex; flex-wrap: wrap; gap: var(--sp-2); justify-content: center; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 14px;
  border: 2.5px solid var(--c-ink); border-radius: var(--radius-pill); background: var(--c-surface); color: var(--c-text);
  font-size: var(--fs-s); font-weight: 700; cursor: pointer; touch-action: manipulation; box-shadow: 0 3px 0 var(--c-ink);
  transition: transform .09s ease-out, box-shadow .09s ease-out, background var(--dur); -webkit-tap-highlight-color: transparent;
}
.chip:hover { transform: translateY(-1px); box-shadow: 0 4px 0 var(--c-ink); }
.chip:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--c-ink); }
.chip[aria-pressed="true"] { background: var(--c-accent); color: var(--c-accent-ink); font-weight: 900; }
.chip[aria-pressed="true"]::before { content: "✓"; font-weight: 900; }
.chip:disabled { opacity: .5; cursor: not-allowed; }
.chip--static { cursor: default; min-height: 28px; padding: 0 10px; border-width: 2px; box-shadow: none; background: var(--c-primary-soft); font-size: var(--fs-xs); font-weight: 800; }
.chip--static:hover, .chip--static:active { transform: none; box-shadow: none; }

/* ---------- Thanh tiến độ ---------- */
.progress { height: 18px; border-radius: var(--radius-pill); background: var(--c-surface-3); overflow: hidden; border: 2.5px solid var(--c-ink); }
.progress__fill {
  height: 100%; width: var(--p, 0%); border-radius: inherit; transition: width .5s cubic-bezier(.2, .9, .3, 1.2);
  background: linear-gradient(rgba(255, 255, 255, .5), rgba(255, 255, 255, 0) 55%), var(--c-primary-hi); box-shadow: 2px 0 0 var(--c-ink);
}
.progress--good .progress__fill { background: linear-gradient(rgba(255, 255, 255, .5), rgba(255, 255, 255, 0) 55%), var(--c-good-fill); }
.progress--warn .progress__fill { background: linear-gradient(rgba(255, 255, 255, .5), rgba(255, 255, 255, 0) 55%), var(--c-warn-fill); }
.progress--xp .progress__fill { background: linear-gradient(rgba(255, 255, 255, .5), rgba(255, 255, 255, 0) 55%), var(--c-xp); }
.progress--time .progress__fill { background: linear-gradient(rgba(255, 255, 255, .5), rgba(255, 255, 255, 0) 55%), var(--c-accent); transition: width .2s linear; }
.progress--lg { height: 22px; }

/* ---------- Form ---------- */
.field { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-3) 0; border-bottom: 2px dashed var(--c-line); }
.field:last-child { border-bottom: 0; }
.field__label { font-weight: 800; flex: 1 1 180px; }
.field__hint { display: block; color: var(--c-muted); font-size: var(--fs-s); font-weight: 500; }
.seg { display: inline-flex; border: var(--bw) solid var(--c-ink); border-radius: var(--radius-m); overflow: hidden; box-shadow: 0 3px 0 var(--c-ink); background: var(--c-surface); }
.seg button { min-height: 44px; min-width: 48px; padding: 0 var(--sp-3); border: 0; background: transparent; cursor: pointer; border-right: 2.5px solid var(--c-ink); font-weight: 800; }
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--c-accent); color: var(--c-accent-ink); }
.switch { position: relative; flex: none; width: 76px; height: 44px; border-radius: var(--radius-pill); border: var(--bw) solid var(--c-ink); background: var(--c-surface-3); cursor: pointer; padding: 0; box-shadow: 0 3px 0 var(--c-ink); transition: background var(--dur); }
.switch::after { content: ""; position: absolute; top: 4px; left: 4px; width: 30px; height: 30px; border-radius: 50%; background: var(--c-surface); border: 2.5px solid var(--c-ink); transition: transform var(--dur) cubic-bezier(.3, 1.4, .5, 1); }
.switch[aria-checked="true"] { background: var(--c-good-fill); }
.switch[aria-checked="true"]::after { transform: translateX(32px); }
.textarea { width: 100%; min-height: 96px; padding: var(--sp-3); border: var(--bw) solid var(--c-ink); border-radius: var(--radius-m); background: var(--c-surface-2); font-family: var(--font-mono); font-size: var(--fs-s); resize: vertical; }
.input { min-height: var(--tap); padding: 0 var(--sp-3); border: var(--bw) solid var(--c-ink); border-radius: var(--radius-m); background: var(--c-surface); }

/* ---------- Banner / toast / badge ---------- */
.banner { padding: var(--sp-3) var(--sp-4); font-size: var(--fs-s); }
.banner--warn { background: var(--c-warn-soft); color: var(--c-warn); border-bottom: var(--bw) solid var(--c-ink); font-weight: 600; }
.toast-wrap { position: fixed; left: 50%; bottom: calc(var(--sp-5) + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: var(--sp-2); z-index: 80; width: min(92vw, 440px); pointer-events: none; }
.toast { display: flex; align-items: center; gap: var(--sp-2); padding: 10px 18px; background: var(--c-surface); color: var(--c-text); border: var(--bw) solid var(--c-ink); border-radius: var(--radius-pill); box-shadow: var(--shadow-1), var(--shadow-soft); text-align: left; font-weight: 700; animation: hc-toast .35s cubic-bezier(.2, 1.4, .4, 1) both; }
.toast .ico { width: 26px; height: 26px; }
.toast--good { background: var(--c-good-soft); }
.toast--bad { background: var(--c-bad-soft); }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: var(--radius-pill); border: 2.5px solid var(--c-ink); background: var(--c-surface-2); font-weight: 900; font-size: var(--fs-s); }
.badge--good { background: var(--c-good-soft); color: var(--c-good); }
.badge--gold { background: var(--c-accent); color: var(--c-accent-ink); }
.badge--hot { background: var(--c-hot); color: #fff; border-color: var(--c-ink); }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: var(--c-overlay); display: flex; align-items: center; justify-content: center; padding: var(--sp-4); z-index: 70; }
.modal { width: min(100%, 480px); max-height: 90vh; overflow: auto; background: var(--c-surface); border: var(--bw) solid var(--c-ink); border-radius: var(--radius-l); box-shadow: var(--shadow-2), var(--shadow-soft); padding: var(--sp-5); animation: hc-pop .25s cubic-bezier(.2, 1.4, .4, 1) both; }
.modal__title { font-size: var(--fs-l); font-weight: 900; margin-bottom: var(--sp-3); }
.modal__body > * + * { margin-top: var(--sp-3); }
.modal__actions { display: flex; flex-wrap: wrap; gap: var(--sp-3); justify-content: flex-end; margin-top: var(--sp-5); }

/* ---------- HUD (tim, điểm, combo...) : dãy viên nang ---------- */
.hud { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: var(--sp-2); padding: 0 var(--sp-3) var(--sp-2); max-width: var(--page-max); margin: 0 auto; }
.hud__item { display: inline-flex; align-items: center; gap: 6px; min-height: 38px; padding: 2px 12px; background: var(--c-surface); border: 2.5px solid var(--c-ink); border-radius: var(--radius-pill); box-shadow: 0 3px 0 var(--c-ink); font-weight: 900; font-size: 1.05rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hud__item .ico { width: 22px; height: 22px; }
.hud__label { color: var(--c-muted); font-size: var(--fs-xs); font-weight: 800; text-transform: uppercase; letter-spacing: .04em; }
.hud__item--score { background: var(--c-accent); color: var(--c-accent-ink); }
.hud__item--score .hud__label { color: var(--c-accent-ink); }
.hud__combo[data-hot="1"] { background: var(--c-hot); color: #fff; animation: hc-pop var(--dur) ease-out; }
.hud__combo[data-hot="1"] .hud__label { color: #fff; }
.hearts { display: inline-flex; gap: 3px; line-height: 1; }
.heart { display: inline-block; width: 26px; height: 26px; transition: transform .25s cubic-bezier(.3, 1.6, .5, 1); }
.heart svg { display: block; width: 100%; height: 100%; overflow: visible; }
.heart .h-fill { fill: var(--c-heart); }
.heart .h-ink { stroke: var(--c-ink); }
.heart--lost { transform: scale(.82); }
.heart--lost .h-fill { fill: var(--c-heart-off); }
.heart--lost .h-shine { opacity: 0; }
.hearts.is-hit { animation: hc-shake .4s; }

/* ---------- Màn hình bắt đầu / kết thúc: một "bảng" lớn ---------- */
.screen { max-width: 680px; margin: 0 auto; padding: var(--sp-2) var(--sp-4) var(--sp-6); }
.panel { position: relative; background: var(--c-surface); border: var(--bw) solid var(--c-ink); border-radius: 28px; box-shadow: 0 8px 0 var(--c-ink), var(--shadow-soft); padding: var(--sp-5); text-align: center; animation: hc-rise .45s cubic-bezier(.2, 1.2, .4, 1) both; }
.panel > * + * { margin-top: var(--sp-4); }
.screen__hero { position: relative; margin: calc(var(--sp-5) * -1) calc(var(--sp-5) * -1) 0; border-radius: 25px 25px 0 0; overflow: hidden; border-bottom: var(--bw) solid var(--c-ink); background: var(--c-surface-3); aspect-ratio: 32 / 11; }
.screen__hero svg { display: block; width: 100%; height: 100%; }
.screen__title { font-size: clamp(2rem, 8vw, 2.9rem); }
.screen__lead { color: var(--c-muted); font-weight: 600; max-width: 46ch; margin-left: auto; margin-right: auto; }
.screen__stat { color: var(--c-muted); font-size: var(--fs-s); font-weight: 600; }
.screen__actions { display: flex; flex-wrap: wrap; gap: var(--sp-3) var(--sp-4); justify-content: center; align-items: center; padding-top: var(--sp-2); }
/* thanh hành động luôn nằm trong tầm tay: dính ở đáy màn hình khi bảng dài hơn màn hình */
.panel > .screen__actions:last-child {
  position: sticky; bottom: 0; z-index: 3; margin: var(--sp-4) calc(var(--sp-5) * -1) calc(var(--sp-5) * -1);
  padding: var(--sp-3) var(--sp-4) calc(var(--sp-4) + env(safe-area-inset-bottom, 0px));
  background: var(--c-surface); border-top: 2.5px dashed var(--c-line); border-radius: 0 0 25px 25px; box-shadow: 0 -10px 14px -12px rgba(5, 10, 34, .35);
}
.screen__actions .btn--lg { min-width: min(100%, 260px); }
/* màn hình bắt đầu gọn: bảng hẹp, nút Chơi ngay rộng hết bảng, tùy chọn cất trong ô đóng sẵn */
.screen--start { max-width: 460px; padding-top: max(var(--sp-2), 4vh); }
.screen--start .panel > * + * { margin-top: var(--sp-3); }
.screen--start .screen__hero { aspect-ratio: 32 / 13; }
.screen__go { width: 100%; justify-content: center; }
.screen__hint { color: var(--c-muted); font-weight: 700; font-size: var(--fs-s); line-height: 1.35; }
.screen__opts { text-align: center; }
.screen__opts > summary { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 var(--sp-3); border-radius: var(--radius-pill); color: var(--c-muted); font-size: var(--fs-s); font-weight: 800; cursor: pointer; list-style: none; }
.screen__opts > summary::-webkit-details-marker { display: none; }
.screen__opts > summary:hover { color: var(--c-text); background: var(--c-surface-2); }
.screen__opts > summary .ico { width: 20px; height: 20px; }
.screen__optnow { color: var(--c-text); }
.screen__opts[open] > summary { color: var(--c-text); }
.screen__opts[open] > * + * { margin-top: var(--sp-3); }
.screen__home { justify-content: center; }
.screen__label { font-size: var(--fs-xs); font-weight: 900; text-transform: uppercase; letter-spacing: .08em; color: var(--c-muted); margin-bottom: var(--sp-2); }
.minis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-2); }
.mini { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: var(--sp-2); border-radius: var(--radius-m); background: var(--c-surface-2); border: 2.5px solid var(--c-ink); }
.mini .ico { width: 26px; height: 26px; }
.mini__num { font-size: var(--fs-l); font-weight: 900; line-height: 1.1; font-variant-numeric: tabular-nums; }
.mini__label { font-size: var(--fs-xs); font-weight: 700; color: var(--c-muted); line-height: 1.2; }

/* kết quả */
.result__top { display: flex; flex-direction: column; align-items: center; gap: var(--sp-2); }
.result__top .mascot { width: 104px; }
.stars { display: flex; justify-content: center; align-items: flex-end; gap: 6px; }
.star { width: 54px; height: 54px; }
.star:nth-child(2) { width: 68px; height: 68px; margin-bottom: 8px; }
.star svg { display: block; width: 100%; height: 100%; overflow: visible; }
.star .s-fill { fill: var(--c-star-off); }
.star .s-ink { stroke: var(--c-ink); }
.star .s-shine { opacity: 0; }
.star.is-on .s-fill { fill: var(--c-star); }
.star.is-on .s-shine { opacity: .7; }
.star.is-on { animation: hc-star .55s cubic-bezier(.2, 1.6, .4, 1) both; animation-delay: calc(var(--i, 0) * .22s + .25s); }
.rank { display: inline-flex; align-items: center; gap: var(--sp-2); padding: 4px 16px; border-radius: var(--radius-pill); border: var(--bw) solid var(--c-ink); background: var(--c-primary); color: #fff; font-weight: 900; letter-spacing: .04em; text-transform: uppercase; box-shadow: 0 3px 0 var(--c-ink); }
.score-big { display: flex; align-items: baseline; justify-content: center; gap: var(--sp-2); font-size: clamp(2.6rem, 11vw, 3.6rem); font-weight: 900; line-height: 1; font-variant-numeric: tabular-nums; }
.score-big__label { font-size: var(--fs-m); font-weight: 800; color: var(--c-muted); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: var(--sp-2); margin: 0; }
.stats__item { background: var(--c-surface-2); border: 2.5px solid var(--c-ink); border-radius: var(--radius-m); padding: var(--sp-2) var(--sp-3); text-align: center; }
.stats__item dt { color: var(--c-muted); font-size: var(--fs-xs); font-weight: 800; text-transform: uppercase; letter-spacing: .03em; }
.stats__item dd { margin: 0; font-weight: 900; font-size: var(--fs-l); font-variant-numeric: tabular-nums; }
.xpline { display: flex; align-items: center; gap: var(--sp-3); text-align: left; padding: var(--sp-3); border-radius: var(--radius-m); border: 2.5px solid var(--c-ink); background: var(--c-surface-2); }
.xpline__lv { flex: none; width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; background: var(--c-xp); color: #fff; border: var(--bw) solid var(--c-ink); font-weight: 900; font-size: var(--fs-l); text-shadow: 0 1px 0 rgba(0, 0, 0, .35); }
.xpline__body { flex: 1 1 auto; min-width: 0; }
.xpline__text { display: flex; justify-content: space-between; gap: var(--sp-2); font-weight: 800; font-size: var(--fs-s); margin-bottom: 4px; }
.xpline__gain { color: var(--c-good); font-weight: 900; }
.result__badges { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--sp-2); }

/* "Từ cần ôn": thẻ sưu tầm */
.review { text-align: left; }
.review__title { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-l); font-weight: 900; margin-bottom: var(--sp-3); }
.review__count { display: inline-grid; place-items: center; min-width: 28px; height: 28px; padding: 0 8px; border-radius: var(--radius-pill); background: var(--c-hot); color: #fff; border: 2.5px solid var(--c-ink); font-size: var(--fs-s); font-weight: 900; }
.review__list { list-style: none; margin: 0; padding: 4px 2px 8px; display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: var(--sp-3); }
.review__item { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: var(--sp-3) var(--sp-2) var(--sp-2); text-align: center; background: var(--c-word-bg); color: var(--c-word-ink); border: var(--bw) solid var(--c-ink); border-radius: 18px; box-shadow: 0 5px 0 var(--c-ink); animation: hc-rise .4s cubic-bezier(.2, 1.2, .4, 1) both; animation-delay: calc(var(--i, 0) * 60ms + .2s); }
.review__item:nth-child(odd) { rotate: -1.2deg; }
.review__item:nth-child(even) { rotate: 1deg; }
.review__item::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 46px; border-radius: 15px 15px 0 0; background: var(--c-card-band); border-bottom: 2.5px dashed var(--c-card-line); }
.review__emoji { position: relative; font-family: var(--font-emoji); font-size: 2.6rem; line-height: 1.15; }
.review__text { position: relative; flex: 1 1 auto; min-width: 0; width: 100%; overflow-wrap: anywhere; display: flex; flex-direction: column; }
.review__text strong { font-size: 1.2rem; font-weight: 900; line-height: 1.2; }
.review__vi { color: var(--c-word-hint); font-size: var(--fs-s); font-weight: 600; }
.review__note { display: block; margin-top: 2px; color: var(--c-word-wrong); font-size: var(--fs-xs); font-weight: 800; }
.review__item .btn--icon { min-width: 44px; min-height: 44px; margin-top: 4px; box-shadow: 0 3px 0 var(--c-ink); background: var(--c-card-band); color: var(--c-word-ink); }
.review__item .btn--icon .ico { --c-ink: #1b2559; --c-surface-3: #dce7fb; }
.review__item--sentence { grid-column: 1 / -1; flex-direction: row; text-align: left; rotate: none !important; padding: var(--sp-3); gap: var(--sp-3); }
.review__item--sentence::before { inset: 0 auto 0 0; width: 10px; height: auto; border-radius: 15px 0 0 15px; border-bottom: 0; background: var(--c-g-sent); }
.review__item--sentence .review__text { padding-left: var(--sp-2); }
.review__item--sentence .btn--icon { margin-top: 0; }
.review__none { display: flex; align-items: center; justify-content: center; gap: var(--sp-2); padding: var(--sp-3); border-radius: var(--radius-m); background: var(--c-good-soft); color: var(--c-good); border: 2.5px solid var(--c-ink); font-weight: 900; text-align: center; }

/* confetti / tia sáng (HC.ui.burst) */
.fx { position: fixed; left: 0; top: 0; width: 0; height: 0; z-index: 90; pointer-events: none; }
.fx i { position: absolute; left: -5px; top: -5px; width: 10px; height: 10px; border-radius: 3px; background: var(--c-accent); border: 1.5px solid var(--c-ink); animation: hc-confetti var(--t, 1s) cubic-bezier(.1, .7, .3, 1) both; }

/* ---------- Hoạt ảnh ---------- */
@keyframes hc-pop { from { transform: scale(.85); opacity: .5; } to { transform: scale(1); opacity: 1; } }
@keyframes hc-shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-7px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(3px); } }
@keyframes hc-wave { 0% { transform: translateY(0); } 40% { transform: translateY(-10px); } 100% { transform: translateY(0); } }
@keyframes hc-rise { from { transform: translateY(18px) scale(.97); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes hc-toast { from { transform: translateY(24px) scale(.9); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes hc-bob { 0%, 100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-7px) rotate(2deg); } }
@keyframes hc-flicker { 0%, 100% { transform: scale(1) rotate(-2deg); } 30% { transform: scale(1.07, .95) rotate(2deg); } 60% { transform: scale(.95, 1.08) rotate(-1deg); } }
@keyframes hc-star { 0% { transform: scale(0) rotate(-40deg); } 70% { transform: scale(1.25) rotate(8deg); } 100% { transform: scale(1) rotate(0); } }
@keyframes hc-drift { from { transform: translateX(-4vw); } to { transform: translateX(6vw); } }
@keyframes hc-confetti { 0% { transform: translate(0, 0) rotate(0) scale(1); opacity: 1; } 100% { transform: translate(var(--dx), var(--dy)) rotate(var(--rot)) scale(.6); opacity: 0; } }
@keyframes hc-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }
@keyframes hc-shine { 0% { transform: translateX(-120%) skewX(-20deg); } 60%, 100% { transform: translateX(320%) skewX(-20deg); } }

/* Giảm chuyển động: công tắc trong cài đặt (data-motion) hoặc hệ điều hành */
html[data-motion="reduce"] *, html[data-motion="reduce"] *::before, html[data-motion="reduce"] *::after {
  animation-duration: .001ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important;
}
html[data-motion="reduce"] .btn:hover, html[data-motion="reduce"] .chip:hover { transform: none; }
@media (prefers-reduced-motion: reduce) {
  html:not([data-motion="full"]) *, html:not([data-motion="full"]) *::before, html:not([data-motion="full"]) *::after {
    animation-duration: .001ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important;
  }
}

@media (max-width: 520px) {
  :root { --fs-xl: 1.5rem; --fs-xxl: 2.1rem; }
  .page { padding: var(--sp-3); }
  .screen { padding: var(--sp-1) var(--sp-3) var(--sp-5); }
  .panel { padding: var(--sp-4); border-radius: 24px; }
  .screen__hero { margin: calc(var(--sp-4) * -1) calc(var(--sp-4) * -1) 0; border-radius: 21px 21px 0 0; }
  .panel > .screen__actions:last-child { margin: var(--sp-3) calc(var(--sp-4) * -1) calc(var(--sp-4) * -1); padding: var(--sp-3) var(--sp-3) calc(var(--sp-3) + env(safe-area-inset-bottom, 0px)); border-radius: 0 0 21px 21px; gap: var(--sp-2) var(--sp-3); }
  .panel > .screen__actions:last-child .btn--lg { width: 100%; min-height: 56px; }
  .panel > .screen__actions:last-child .btn:not(.btn--lg) { min-height: 44px; font-size: var(--fs-s); padding: 0 var(--sp-3); }
  .topbar { padding: var(--sp-2) var(--sp-3); gap: var(--sp-2); }
  .chip { padding: 0 11px; font-size: .84rem; }
  .chips { gap: 6px; }
  .topbar__title { font-size: 1.05rem; }
  .hud { gap: 6px; padding: 0 var(--sp-2) var(--sp-2); }
  .hud__item { padding: 2px 9px; font-size: .98rem; min-height: 34px; }
  .heart { width: 22px; height: 22px; }
  .star { width: 46px; height: 46px; }
  .star:nth-child(2) { width: 58px; height: 58px; }
  .review__list { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: var(--sp-2); }
}
.panel > .stats { margin-top: var(--sp-4); }
.xpline__text { flex-wrap: wrap; }
.xpline__text span:first-child { white-space: nowrap; }
@media (max-width: 520px) {
  .panel > .stats { grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); }
  .panel > .stats dt { font-size: .68rem; letter-spacing: 0; }
}

.screen__best { display: flex; align-items: center; justify-content: center; gap: 8px; font-weight: 700; color: var(--c-muted); }
.screen__best .ico { width: 28px; height: 28px; }
.screen__best strong { color: var(--c-text); font-weight: 900; font-size: 1.15rem; }
