/* game.css — Khu Rừng Trò Chơi: màu tươi, khối bo tròn, nút to cho bé tiểu học */
:root {
  --ink: #2f3b57;
  --ink-soft: #5b6a86;
  /* Bộ màu "my favorite colors" — dùng chung cho toàn bộ khu trò chơi */
  --leaf: #a6e23d;
  --leaf-d: #6fa823;
  --sun: #f5e45f;
  --sun-d: #d9b83a;
  --berry: #ff68bd;
  --berry-d: #d43f93;
  --orange: #fd7a39;
  --orange-d: #d85a1a;
  --sky: #07bdff;
  --sky-d: #0091c9;
  --grape: #a890ff;
  --grape-d: #7c5be0;
  --mint: #00c69e;
  --mint-d: #00967a;
  --wood: #c48a52;
  --wood-d: #93602f;
  --cream: #fff8e6;
  --card: #ffffff;
  --font-title: "Comfortaa", "Baloo 2", "Segoe UI", system-ui, sans-serif;
  --shadow: 0 6px 0 rgba(47, 59, 87, .14), 0 14px 26px rgba(47, 59, 87, .14);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Baloo 2", "Nunito", "Segoe UI", system-ui, sans-serif;
  font-weight: 500;
  color: var(--ink);
  background: linear-gradient(#a9e7ff 0%, #d9f6d0 55%, #b8ec8f 100%);
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
:focus-visible { outline: 4px solid var(--sky-d); outline-offset: 3px; }
.skip-link { position: fixed; top: -80px; left: 16px; z-index: 100; background: #fff; padding: 12px 16px; border-radius: 12px; }
.skip-link:focus { top: 12px; }

/* ---------- Nền rừng ---------- */
.forest { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.hills { position: absolute; left: 0; bottom: 0; width: 100%; height: 42vh; min-height: 220px; }
.sun { position: absolute; top: 4vh; right: 7vw; width: 96px; height: 96px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff6a8, var(--sun)); box-shadow: 0 0 0 14px rgba(255, 224, 90, .35), 0 0 0 30px rgba(255, 224, 90, .18); animation: sun-breathe 5s ease-in-out infinite; }
.cloud { position: absolute; height: 46px; width: 130px; background: #fff; border-radius: 40px; opacity: .92; animation: drift linear infinite; }
.cloud::before, .cloud::after { content: ""; position: absolute; background: #fff; border-radius: 50%; }
.cloud::before { width: 60px; height: 60px; left: 18px; top: -26px; }
.cloud::after { width: 46px; height: 46px; left: 66px; top: -18px; }
.c1 { top: 9vh; left: -160px; animation-duration: 70s; }
.c2 { top: 20vh; left: -160px; animation-duration: 95s; animation-delay: -40s; transform: scale(.75); }
.c3 { top: 5vh; left: -160px; animation-duration: 120s; animation-delay: -80s; transform: scale(.55); }
.fly { position: absolute; font-size: 26px; animation: flutter 9s ease-in-out infinite; }
.f1 { left: 12%; top: 46%; }
.f2 { left: 78%; top: 58%; animation-delay: -3s; animation-duration: 11s; }
.f3 { left: 55%; top: 34%; animation-delay: -6s; animation-duration: 13s; font-size: 20px; }
@keyframes drift { to { left: 110vw; } }
@keyframes sun-breathe { 50% { transform: scale(1.06); } }
@keyframes flutter { 0%, 100% { transform: translate(0, 0) rotate(-6deg); } 25% { transform: translate(40px, -26px) rotate(8deg); } 50% { transform: translate(90px, 8px) rotate(-4deg); } 75% { transform: translate(30px, 24px) rotate(6deg); } }

.screen { min-height: 100dvh; display: flex; flex-direction: column; padding: 14px 16px 24px; max-width: 1100px; margin: 0 auto; }

/* ---------- Nút chung ---------- */
.pill-link, .round-btn { display: inline-flex; align-items: center; gap: 8px; border: 0; background: #fff; color: var(--ink); font-weight: 800; box-shadow: 0 4px 0 rgba(47, 59, 87, .16); }
.pill-link { min-height: 48px; padding: 6px 18px; border-radius: 26px; font-size: 18px; }
.round-btn { justify-content: center; width: 48px; height: 48px; border-radius: 50%; font-size: 22px; }
.pill-link:active, .round-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(47, 59, 87, .16); }
.big-btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 64px; padding: 8px 34px; border: 0; border-radius: 34px; font-size: 26px; font-weight: 800; color: #fff; box-shadow: 0 7px 0 var(--btn-d, #1d7a32); background: var(--btn, var(--leaf)); transition: transform .12s, box-shadow .12s, filter .2s; }
.big-btn:hover:not(:disabled) { filter: brightness(1.06); }
.big-btn:active:not(:disabled) { transform: translateY(5px); box-shadow: 0 2px 0 var(--btn-d, #1d7a32); }
.big-btn:disabled, .big-btn.go:disabled { --btn: #c9d3c2; --btn-d: #a9b4a2; color: #f4f7f1; cursor: not-allowed; }
.big-btn.go { --btn: var(--leaf); --btn-d: var(--leaf-d); }
.big-btn.next { --btn: var(--orange); --btn-d: var(--orange-d); animation: pop-in .35s ease both; }
.big-btn.learn { --btn: var(--sky); --btn-d: var(--sky-d); font-size: 22px; }
.big-btn.home { --btn: var(--berry); --btn-d: var(--berry-d); font-size: 22px; }

/* ---------- Khu chọn trò ---------- */
.hub-top, .play-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.hub-head { text-align: center; margin-top: 4px; }
.sign { display: inline-block; position: relative; padding: 10px 40px 12px; border-radius: 22px; font-size: clamp(30px, 6vw, 52px); font-weight: 800; color: #fff7dc; background: linear-gradient(#d09a5f, var(--wood)); border: 4px solid var(--wood-d); box-shadow: 0 8px 0 rgba(120, 76, 30, .35); text-shadow: 0 3px 0 rgba(90, 52, 16, .45); transform: rotate(-1.5deg); animation: sign-sway 6s ease-in-out infinite; }
.sign::before, .sign::after { content: ""; position: absolute; top: 50%; width: 12px; height: 12px; margin-top: -6px; border-radius: 50%; background: var(--wood-d); }
.sign::before { left: 14px; } .sign::after { right: 14px; }
@keyframes sign-sway { 50% { transform: rotate(1.5deg); } }
.hub-hello { margin: 14px 0 6px; font-size: clamp(18px, 3vw, 24px); font-weight: 700; }
.level-row { display: flex; justify-content: center; gap: 10px; margin: 10px 0 22px; flex-wrap: wrap; }
.level-chip { min-height: 52px; padding: 4px 22px; border: 3px solid transparent; border-radius: 28px; background: rgba(255, 255, 255, .85); font-size: 20px; font-weight: 800; box-shadow: 0 4px 0 rgba(47, 59, 87, .14); }
.level-chip[aria-checked="true"] { background: var(--sun); border-color: var(--sun-d); transform: translateY(-2px); }
.game-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 20px; align-items: stretch; }
.gcard { position: relative; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 22px 20px 24px; border-radius: 32px; background: var(--card); text-align: center; box-shadow: var(--shadow); border: 0; transition: transform .18s; }
.gcard:hover:not(.locked) { transform: translateY(-6px) rotate(-.6deg); }
.gcard-art { display: grid; place-items: center; width: 116px; height: 116px; border-radius: 50%; font-size: 64px; background: var(--art, #ffdece); animation: bob 3.4s ease-in-out infinite; }
.gcard strong { font-size: 26px; line-height: 1.1; }
.gcard p { margin: 0 0 8px; font-size: 17px; color: var(--ink-soft); font-weight: 500; }
.gcard .go-tag { margin-top: auto; padding: 8px 26px; border-radius: 24px; color: #fff; font-weight: 800; font-size: 20px; background: var(--leaf); box-shadow: 0 5px 0 var(--leaf-d); }
.gcard.music .gcard-art { --art: #ffd9ef; }
.gcard.music .go-tag { background: var(--berry); box-shadow: 0 5px 0 var(--berry-d); }
.gcard.fraction .gcard-art { --art: #ffdece; }
.gcard.soroban .gcard-art { --art: #c0efff; }
.gcard.multiplication .gcard-art { --art: #ffe3b8; }
.gcard.multiplication .go-tag { background: var(--orange); box-shadow: 0 5px 0 var(--orange-d); }
.gcard.soroban .go-tag { background: var(--sky); box-shadow: 0 5px 0 var(--sky-d); }
/* Trang danh sách: hàng Toán (3 ô) và hàng Giải trí (canh giữa) */
.hub-group { margin: 26px 0 12px; text-align: center; font: 700 22px var(--font-title); color: var(--ink); }
.hub-group:first-of-type { margin-top: 14px; }
@media (min-width: 900px) { .game-cards.math { grid-template-columns: repeat(3, 1fr); } }
.game-cards.other { display: flex; flex-wrap: wrap; justify-content: center; }
.game-cards.other .gcard { flex: 0 1 min(360px, 100%); }
.gcard.locked { opacity: .78; filter: grayscale(.35); cursor: default; }
.gcard.locked .go-tag { background: #b9c3d3; box-shadow: 0 5px 0 #97a3b8; }
.gcard.spotlight { animation: pulse-ring 1.6s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-8px); } }
@keyframes pulse-ring { 50% { box-shadow: var(--shadow), 0 0 0 10px rgba(255, 207, 61, .55); } }

/* ---------- Màn chơi ---------- */
.trail { display: flex; gap: 6px; margin: 0; padding: 8px 14px; list-style: none; background: rgba(255, 255, 255, .8); border-radius: 30px; box-shadow: 0 4px 0 rgba(47, 59, 87, .12); overflow: hidden; min-width: 0; }
.trail li { display: grid; place-items: center; flex: none; width: 30px; height: 30px; border-radius: 50%; font-size: 18px; background: #e6efd9; color: #8ba073; font-weight: 800; }
.trail li.current { background: var(--sun); color: var(--ink); box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--sun-d); animation: bob 1.2s ease-in-out infinite; }
.trail li.ok, .trail li.half, .trail li.miss { background: transparent; font-size: 24px; }
.play-body { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 48px; margin-top: 10px; }
.coach { display: flex; align-items: center; justify-content: center; gap: 16px; flex-wrap: wrap; text-align: center; }
.mascot { flex: none; display: grid; place-items: center; width: 76px; height: 76px; border-radius: 50%; font-size: 46px; background: radial-gradient(circle at 35% 30%, #fffbe0, #ffe27d); border: 5px solid #fff; box-shadow: 0 6px 0 rgba(47, 59, 87, .16); animation: breathe 3s ease-in-out infinite; }
.mascot.happy { animation: jump .7s ease both; }
.mascot.sad { animation: wobble .5s ease both; }
@keyframes breathe { 50% { transform: scale(1.05); } }
@keyframes jump { 0% { transform: translateY(0); } 30% { transform: translateY(-28px) rotate(-8deg); } 60% { transform: translateY(0) rotate(6deg); } 80% { transform: translateY(-10px); } 100% { transform: translateY(0); } }
@keyframes wobble { 20% { transform: rotate(-10deg); } 45% { transform: rotate(9deg); } 70% { transform: rotate(-5deg); } }
/* Câu hỏi: chữ to, đứng ngay trên khu vực chơi, không còn khung bong bóng nhỏ */
.question { margin: 0; max-width: 780px; font-size: clamp(28px, 4.6vw, 46px); font-weight: 800; line-height: 1.3; color: var(--ink); text-shadow: 0 2px 0 #fff; }
.question.pop { animation: pop-in .4s cubic-bezier(.3, 1.6, .5, 1) both; }

/* Khu vực chơi: không còn khung/nền, chỉ là chỗ xếp các lựa chọn cho gọn */
.stage { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 18px; padding: 4px; }
.stage.locked { pointer-events: none; }
.rim { pointer-events: none; }
.stage.shake { animation: shake .45s ease; }
.stage.enter > * { animation: pop-in .4s ease both; }
@keyframes shake { 20%, 60% { transform: translateX(-9px); } 40%, 80% { transform: translateX(9px); } }
@keyframes pop-in { from { opacity: 0; transform: scale(.85) translateY(12px); } to { opacity: 1; transform: none; } }

/* Nút ngay dưới khu chơi (cách ~24px). column-reverse: nút ở trên, lời phản hồi ở dưới nên nút không bị đẩy dịch khi có phản hồi */
.play-actions { position: relative; display: flex; flex-direction: column; align-items: center; gap: 14px; margin-top: -24px; min-height: 64px; padding-bottom: 96px; }
/* lời phản hồi nằm dưới nút, không chiếm chỗ (đã dành sẵn khoảng trống) nên nút đứng yên khi có phản hồi */
.play-actions .verdict { position: absolute; top: calc(64px + 14px); left: 0; right: 0; margin-inline: auto; width: max-content; }
.verdict { max-width: 100%; padding: 8px 26px 10px; border-radius: 30px; text-align: center; color: #fff; font-size: clamp(22px, 4vw, 32px); font-weight: 800; line-height: 1.15; animation: pop-in .35s cubic-bezier(.3, 1.6, .5, 1) both; }
.verdict small { display: block; font-size: 17px; font-weight: 600; opacity: .95; }
.verdict.good { background: var(--leaf); box-shadow: 0 6px 0 var(--leaf-d); }
.verdict.try { background: var(--orange); box-shadow: 0 6px 0 var(--orange-d); }
.verdict.show { background: var(--sky); box-shadow: 0 6px 0 var(--sky-d); }

/* ---------- Phân số: thẻ chữ ---------- */
.frac { display: inline-flex; flex-direction: column; align-items: center; vertical-align: middle; margin: 0 .12em; line-height: .95; font-weight: 800; }
.frac .n { padding: 0 .28em .04em; border-bottom: .09em solid currentColor; }
.frac .d { padding: .04em .28em 0; }

/* ---------- Hình minh họa ---------- */
.shape svg { display: block; width: 100%; height: auto; overflow: visible; }
/* Hình minh họa: cam, dưa hấu, bánh tét, bánh chưng (SVG do người dùng vẽ). Phần chưa tô mờ, phần được tô đủ màu */
.art-off { filter: grayscale(1) brightness(1.75) contrast(.45); opacity: .85; }
.slice { opacity: 0; transition: opacity .18s; }
.slice.on { opacity: 1; }
.seps line { stroke: #fff; stroke-width: 3.5; stroke-linecap: round; pointer-events: none; }
.shape.tappable .slice { cursor: pointer; }
.shape.tappable .slice:not(.on):hover { opacity: .45; }
.shape.pie, .shape.sq { width: clamp(200px, 22vw, 320px); }
.shape.bar { width: clamp(280px, 30vw, 460px); max-width: 88vw; }
.shape.small.pie, .shape.small.sq { width: clamp(120px, 14vw, 200px); }
.shape.small.bar { width: clamp(170px, 20vw, 300px); }
.shape.pop .slice.on { animation: slice-pop .3s ease; }
@keyframes slice-pop { 50% { opacity: .7; } }

/* Lựa chọn: không còn thẻ nền trắng — chỉ hình + viền màu khi chạm/đúng/gợi ý */
.opts { display: flex; flex-wrap: wrap; justify-content: center; gap: 26px; width: 100%; }
.opt { display: grid; place-items: center; padding: 10px; border: 5px solid transparent; border-radius: 28px; background: transparent; box-shadow: none; transition: transform .12s, border-color .15s, background-color .15s; }
.opt:hover:not(:disabled) { transform: translateY(-4px); border-color: var(--sky); background: #ffffff90; }
.opt:active:not(:disabled) { transform: translateY(1px); }
.opt:disabled { opacity: .4; }
.opt.right { border-color: var(--leaf); background: #eefadb; opacity: 1; animation: pop-in .35s ease both; }
.opt.hint { border-color: var(--sun-d); background: #fdf6d2; opacity: 1; }
.opt .shape.small.pie, .opt .shape.small.sq { width: clamp(130px, 20vw, 250px); }
.opt .shape.small.bar { width: clamp(220px, 28vw, 380px); max-width: 74vw; }
.target-frac { font-size: clamp(46px, 9vw, 74px); color: var(--berry-d); width: 100%; text-align: center; }

/* Trục số */
.line-wrap { position: relative; width: min(1040px, 98%); padding: 140px 3% 92px; touch-action: none; user-select: none; -webkit-user-select: none; }
/* Cây tre nằm ngang: ghép b "đốt tre" (file DotTre.svg của người dùng) nối liền nhau, hai đầu đốt tạo thành mấu tre.
   Lá tre (LaTre.svg) là nút kéo duy nhất. Phần lá đã đi qua giữ nguyên màu, phần phía trước phủ lớp sáng mờ. */
.line-track { --h: 64px; position: relative; height: var(--h); filter: drop-shadow(0 7px 0 rgba(31, 90, 50, .2)); }
.seg-row { position: absolute; inset: 0; }
/* thân đốt giãn theo chiều ngang; mỗi mấu tre là MỘT đầu đốt nằm đè lên chỗ nối hai đốt (không bị đôi) */
.bb { position: absolute; top: 0; height: 100%; display: block; }
.bcap { position: absolute; top: 0; height: 100%; display: block; width: calc(var(--h) * 17 / 94.89); margin-left: calc(var(--h) * -8.5 / 94.89); }
.bcap.first { margin-left: 0; }
.bcap.end { width: calc(var(--h) * 20.59 / 94.89); margin-left: calc(var(--h) * -20.59 / 94.89); }
.veil { position: absolute; top: 0; bottom: 0; left: var(--p, 0%); right: 0; background: rgba(255, 255, 255, .16); transition: left .18s cubic-bezier(.3, 1.5, .5, 1); pointer-events: none; }
.line-track.drag .veil { transition: none; }
/* các nút vạch chỉ để bàn phím và trình đọc màn hình; nhìn thấy là mấu tre */
.tick { position: absolute; top: 0; width: 24px; height: 100%; margin-left: -12px; padding: 0; border: 0; background: transparent; }
.tick::after { content: ""; position: absolute; inset: -12px -10px; }
.tick-label { position: absolute; top: calc(var(--h) + 18px); transform: translateX(-50%); padding: 2px 16px 3px; border-radius: 16px; color: #fff; background: var(--berry); box-shadow: 0 3px 0 var(--berry-d); font: 700 24px var(--font-title); pointer-events: none; }
.tick-label:last-of-type { background: var(--sky); box-shadow: 0 3px 0 var(--sky-d); }
/* lá tre: cuống lá (cạnh trái ảnh, khoảng 15% chiều rộng) đặt đúng vào vị trí đang chọn */
.line-track { --lh: 113px; }
.acorn { position: absolute; top: calc(var(--h) * .1 - var(--lh)); height: var(--lh); width: calc(var(--lh) * .546); margin-left: calc(var(--lh) * -.082); cursor: grab; touch-action: none; transition: left .18s cubic-bezier(.3, 1.5, .5, 1); filter: drop-shadow(0 5px 0 rgba(31, 90, 50, .22)); }
.acorn::before { content: ""; position: absolute; inset: -8px -12px -14px; }
.acorn img { display: block; width: 100%; height: 100%; transform-origin: 15% 100%; animation: sway 2.8s ease-in-out infinite; pointer-events: none; -webkit-user-drag: none; }
.acorn.dragging { transition: none; cursor: grabbing; }
.acorn.dragging img { animation: none; transform: scale(1.1); }
.acorn.hint img { animation: bob .8s ease-in-out infinite; }
@keyframes sway { 0%, 100% { transform: rotate(-4deg); } 50% { transform: rotate(4deg); } }

/* Bộ tăng giảm */
.stepper { display: inline-flex; align-items: center; gap: 12px; }
.step-btn { width: 60px; height: 60px; border: 0; border-radius: 50%; color: #fff; font-size: 34px; font-weight: 800; line-height: 1; background: var(--sky); box-shadow: 0 5px 0 var(--sky-d); }
.step-btn:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 var(--sky-d); }
.step-btn:disabled { background: #c7d3e0; box-shadow: 0 5px 0 #a4b2c4; }
.step-val { min-width: 84px; padding: 2px 8px; border-radius: 20px; text-align: center; font-size: 56px; font-weight: 800; background: var(--cream); border: 4px solid var(--sun); line-height: 1.1; }
.cut-panel { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.friends { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px; max-width: 420px; font-size: 42px; }
.slice-count { font-size: 22px; font-weight: 700; color: var(--ink-soft); }

/* Gọi tên phân số */
.name-panel { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.name-bar { width: 200px; height: 10px; border-radius: 6px; background: var(--ink); }
.name-label { font-size: 18px; font-weight: 700; color: var(--ink-soft); }

/* So sánh */
.cmp { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 14px; width: 100%; }
.cmp-card { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 10px; font-size: 44px; }
.cmp-sign { display: grid; place-items: center; width: 84px; height: 84px; border-radius: 50%; font-size: 52px; font-weight: 800; background: var(--cream); border: 5px dashed var(--sun-d); color: var(--berry-d); }
.cmp-sign.set { border-style: solid; background: #e6ffe9; border-color: var(--leaf); color: var(--leaf-d); animation: pop-in .3s ease both; }
.sign-row { display: flex; justify-content: center; gap: 18px; width: 100%; }
.sign-btn { width: 84px; height: 84px; border: 0; border-radius: 50%; font-size: 52px; font-weight: 800; color: #fff; background: var(--sky); box-shadow: 0 7px 0 var(--sky-d); }
.sign-btn:nth-child(2) { background: var(--orange); box-shadow: 0 7px 0 var(--orange-d); }
.sign-btn:nth-child(3) { background: var(--berry); box-shadow: 0 7px 0 var(--berry-d); }
.sign-btn:active:not(:disabled) { transform: translateY(5px); box-shadow: 0 2px 0 rgba(0, 0, 0, .2); }
.sign-btn:disabled { opacity: .35; }

/* ---------- Kết quả ---------- */
#screen-result { align-items: center; justify-content: center; }
.result-card { width: min(560px, 100%); padding: 26px 24px 30px; border-radius: 38px; text-align: center; background: #fff; box-shadow: var(--shadow); }
.result-mascot { display: inline-grid; place-items: center; width: 120px; height: 120px; margin-top: -70px; border-radius: 50%; font-size: 76px; background: radial-gradient(circle at 35% 30%, #fffbe0, #ffe27d); border: 6px solid #fff; box-shadow: 0 6px 0 rgba(47, 59, 87, .16); animation: jump 1s ease both; }
.result-card h1 { margin: 8px 0 0; font-size: clamp(34px, 7vw, 46px); color: var(--leaf-d); }
.result-score { margin: 4px 0; font-size: 34px; letter-spacing: 2px; line-height: 1.3; }
.result-score { display: flex; justify-content: center; gap: 5px; flex-wrap: wrap; }
.result-paper-icon { width: 36px; height: 36px; object-fit: contain; vertical-align: middle; }
.trail .result-paper-icon { width: 26px; height: 26px; }
.action-paper-icon { width: 32px; height: 32px; object-fit: contain; flex: 0 0 32px; }
.result-line { margin: 0; font-size: 24px; font-weight: 800; }
.result-detail { margin: 6px 0 18px; font-size: 18px; color: var(--ink-soft); }
.result-actions { display: flex; flex-direction: column; align-items: stretch; gap: 14px; }

/* Hoa lá rơi */
.confetti { position: fixed; inset: 0; z-index: 50; pointer-events: none; overflow: hidden; }
.confetti span { position: absolute; top: -40px; font-size: 30px; animation: confetti-fall var(--dur, 2.4s) linear forwards; }
@keyframes confetti-fall { to { transform: translate(var(--dx, 0), 110vh) rotate(var(--rot, 360deg)); opacity: .9; } }

/* ---------- Điện thoại ---------- */
@media (max-width: 640px) {
  .screen { padding: 10px 12px 18px; }
  .coach { gap: 10px; }
  .mascot { width: 56px; height: 56px; font-size: 34px; }
  .stage { padding: 8px; gap: 12px; }
  .play-body { gap: 32px; }
  .play-actions { margin-top: -16px; padding-bottom: 92px; }
  .big-btn { min-height: 60px; font-size: 24px; padding: 8px 28px; }
  .sun { width: 64px; height: 64px; }
  .cmp-card { font-size: 36px; padding: 10px 12px; }
  .opts { gap: 12px; }
  .opt { padding: 10px; }
  .opt .shape.small.pie, .opt .shape.small.sq { width: 112px; }
  .opt .shape.small.bar { width: 200px; }
  .shape.small.pie, .shape.small.sq { width: 100px; }
  .shape.small.bar { width: 140px; }
  .friends { font-size: 30px; }
  .play-top { flex-wrap: wrap; }
  .trail { order: 3; flex: 1 0 100%; justify-content: center; padding: 6px 8px; }
  .level-chip { padding: 4px 14px; font-size: 18px; }
  .gcard { flex-direction: row; flex-wrap: wrap; justify-content: center; padding: 16px; gap: 4px 14px; }
  .gcard-art { width: 84px; height: 84px; font-size: 46px; }
  .gcard strong { font-size: 22px; align-self: center; }
  .gcard p { flex-basis: 100%; }
  .game-cards { gap: 14px; }
  .cmp-sign, .sign-btn { width: 70px; height: 70px; font-size: 42px; }
  .trail li { width: 26px; height: 26px; font-size: 15px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* Font tiêu đề: Comfortaa Bold (chữ thân vẫn Baloo 2) */
.sign, .gcard strong, .question, .result-card h1 { font-family: var(--font-title); font-weight: 700; }

/* Chữ trong các nút và lời phản hồi dùng cùng font với tiêu đề (Comfortaa Bold) */
.big-btn, .level-chip, .go-tag, .pill-link, .verdict, .verdict small, .trail li { font-family: var(--font-title); font-weight: 700; }

/* Rừng Phép Nhân: mâm rổ đựng quả, nút số, phép tính lớn */
.groups { display: flex; flex-wrap: wrap; justify-content: center; gap: 16px; width: 100%; }
.tray { display: flex; flex-wrap: wrap; justify-content: center; align-content: center; gap: 8px; max-width: 330px; padding: 10px 12px; border-radius: 24px; background: #fff8e6cc; border: 4px dashed #d9a35a; box-shadow: 0 5px 0 rgba(217, 163, 90, .35); }
.tray.array { display: grid; grid-template-columns: repeat(var(--cols), auto); max-width: none; gap: 8px; }
.mi { flex: none; width: clamp(30px, 4.2vw, 48px); height: auto; display: block; user-select: none; }
.tray.small { gap: 6px; max-width: 290px; padding: 8px 10px; }
.tray.small .mi { width: clamp(24px, 3.2vw, 36px); }
.num-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 22px; width: 100%; }
.num-btn { min-width: 112px; height: 96px; padding: 0 22px; border: 0; border-radius: 32px; color: #fff; font: 700 52px var(--font-title); background: var(--sky); box-shadow: 0 8px 0 var(--sky-d); transition: transform .12s, box-shadow .12s; }
.num-btn:nth-child(2) { background: var(--orange); box-shadow: 0 8px 0 var(--orange-d); }
.num-btn:nth-child(3) { background: var(--berry); box-shadow: 0 8px 0 var(--berry-d); }
.num-btn:nth-child(4) { background: var(--violet, #a890ff); box-shadow: 0 8px 0 #7e66d9; }
.num-btn:hover:not(:disabled) { transform: translateY(-4px); }
.num-btn:active:not(:disabled) { transform: translateY(5px); box-shadow: 0 2px 0 rgba(0, 0, 0, .2); }
.num-btn:disabled { opacity: .35; }
.num-btn.right { outline: 6px solid var(--leaf); opacity: 1; animation: pop-in .35s ease both; }
.num-btn.hint { outline: 6px solid var(--sun-d); opacity: 1; }
.num-row.big .num-btn { min-width: 128px; height: 112px; font-size: 60px; }
.eq { display: inline-block; padding: 0 10px; border-radius: 16px; background: #fff8e6; color: var(--berry-d); white-space: nowrap; }
.big-eq { width: 100%; text-align: center; font: 700 clamp(44px, 8vw, 72px) var(--font-title); color: var(--berry-d); }
.big-eq .guess { display: inline-block; min-width: 1.3em; padding: 0 10px; border-radius: 18px; color: var(--orange-d); background: #fff8e6; border: 4px solid var(--sun); }
@media (max-width: 640px) {
  .num-row { gap: 12px; }
  .num-btn { min-width: 84px; height: 76px; font-size: 38px; padding: 0 14px; border-radius: 26px; }
  .num-row.big .num-btn { min-width: 92px; height: 88px; font-size: 44px; }
  .tray { max-width: 170px; padding: 8px; }
  .mi { width: 28px; }
}

/* Trang danh sách game: bỏ hết khung, chữ to và nổi bật trên nền trời. Chỗ bấm được chỉ sáng nhẹ khi rê chuột. */
#screen-hub .sign { padding: 0; border: 0; border-radius: 0; background: none; box-shadow: none; transform: none; animation: none; color: #fff; font-size: clamp(40px, 7vw, 68px); text-shadow: 0 3px 0 #3f8a2a, 0 6px 18px rgba(31, 90, 40, .45); }
#screen-hub .sign::before, #screen-hub .sign::after { display: none; }
#screen-hub .hub-hello { font-size: clamp(20px, 3.2vw, 28px); color: #24406b; }
#screen-hub .pill-link, #screen-hub .round-btn { background: transparent; box-shadow: none; transition: background-color .15s; }
#screen-hub .pill-link:hover, #screen-hub .round-btn:hover { background: rgba(255, 255, 255, .45); }
#screen-hub .level-chip { border: 0; background: transparent; box-shadow: none; color: #4b5d7e; font-size: 22px; transition: color .15s, background-color .15s; }
#screen-hub .level-chip:hover { background: rgba(255, 255, 255, .45); }
#screen-hub .hub-ui-icon { display: inline-block; width: 38px; height: 38px; flex: 0 0 38px; vertical-align: middle; object-fit: contain; }
#screen-hub .level-chip { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
#screen-hub .hub-group { display: flex; align-items: center; justify-content: center; gap: 10px; }
#screen-hub .hub-group .hub-ui-icon { width: 44px; height: 44px; flex-basis: 44px; }
@media (max-width: 600px) {
  #screen-hub .level-chip { padding-inline: 10px; gap: 4px; }
  #screen-hub .level-chip .hub-ui-icon { width: 32px; height: 32px; flex-basis: 32px; }
}
#screen-hub .level-chip[aria-checked="true"] { background: transparent; transform: none; color: #24406b; text-decoration: underline; text-decoration-color: var(--sun-d); text-decoration-thickness: 4px; text-underline-offset: 6px; }
#screen-hub .hub-group { font-size: 26px; color: #24406b; margin: 30px 0 6px; }
#screen-hub .gcard { background: transparent; box-shadow: none; padding: 14px 16px 18px; border-radius: 28px; transition: background-color .18s; }
#screen-hub .gcard:hover:not(.locked) { transform: none; background: rgba(255, 255, 255, .3); }
/* Bỏ nút "Chơi nào!": bấm vào cả khu vực thẻ */
#screen-hub .gcard { cursor: pointer; color: inherit; text-decoration: none; font: inherit; }
#screen-hub .gcard:focus-visible { outline: 4px solid #b67744; outline-offset: 4px; }
#screen-hub .gcard strong { font-size: clamp(28px, 2.8vw, 34px); color: #1f3a66; text-shadow: 0 2px 0 rgba(255, 255, 255, .8); }
#screen-hub .gcard p { font-size: 18px; font-weight: 700; color: #34507a; }
#screen-hub .gcard-art { width: 140px; height: 140px; font-size: 96px; background: none; filter: none; animation: none; }
#screen-hub .gcard-art img { display: block; width: 100%; height: 140px; min-height: 0; max-height: 140px; object-fit: contain; transition: transform .25s ease; }
#screen-hub .gcard:hover .gcard-art img { transform: translateY(-4px) rotate(-2deg); }
@media (prefers-reduced-motion: reduce) {
  #screen-hub .gcard-art img { transition: none; }
  #screen-hub .gcard:hover .gcard-art img { transform: none; }
}

/* Phép tính và ô chọn số: bỏ khung, làm nổi bằng màu, cỡ chữ và gạch chân chỗ cần điền */
.eq { padding: 0 4px; background: none; border-radius: 0; color: var(--berry-d); font-weight: 800; }
.big-eq .guess { min-width: 1em; padding: 0 6px; background: none; border: 0; border-radius: 0; color: var(--orange-d); font-size: 1.15em; border-bottom: 6px solid var(--sun-d); line-height: 1; }
.step-val { min-width: 72px; padding: 0 6px; background: none; border: 0; border-radius: 0; font-size: 64px; color: var(--ink); text-shadow: 0 2px 0 rgba(255, 255, 255, .8); }

/* Nền tối giản, nhẹ nhàng cho dễ tập trung: màu ngà ấm pha xanh lá rất nhạt; bỏ đồi, cây, mây, mặt trời, bướm */
body { background: radial-gradient(1200px 700px at 50% -10%, #ffffff 0%, rgba(255, 255, 255, 0) 70%), linear-gradient(180deg, #f7f5ef 0%, #eef3ec 100%); background-attachment: fixed; }
.forest { display: none; }
#screen-hub .sign { color: #24406b; text-shadow: none; letter-spacing: -.01em; }
#screen-hub .hub-hello { color: #5b6a86; }
#screen-hub .gcard:hover:not(.locked) { background: rgba(36, 64, 107, .05); }
/* Soft, tactile play buttons; the enclosing card remains the single click target. */
#screen-hub .gcard { --play-bg: #d9ebbd; --play-edge: #a4be83; --play-ink: #344e2d; }
#screen-hub .gcard.multiplication { --play-bg: #f9d6bd; --play-edge: #d4a583; --play-ink: #70432e; }
#screen-hub .gcard.soroban { --play-bg: #c5e8e6; --play-edge: #8cbdbb; --play-ink: #28575d; }
#screen-hub .gcard.music { --play-bg: #e4d7f1; --play-edge: #b8a0d0; --play-ink: #57416e; }
#screen-hub .gcard .go-tag {
  display: inline-flex; align-items: center; justify-content: center; gap: 12px;
  min-width: 178px; min-height: 54px; padding: 10px 22px 10px 14px;
  border: 1px solid var(--play-edge); border-radius: 18px;
  background: linear-gradient(180deg, #ffffff65, #ffffff00 75%), var(--play-bg);
  color: var(--play-ink); font-size: 18px; line-height: 1.3;
  box-shadow: inset 0 1px 0 #ffffffb3, 0 3px 0 var(--play-edge), 0 6px 12px #263c4910;
  transition: transform .18s ease, box-shadow .18s ease;
}
#screen-hub .gcard .go-tag::before {
  content: ""; flex: 0 0 28px; width: 28px; height: 28px; border-radius: 50%;
  background: #ffffff80 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9 6.5a1 1 0 0 1 1.5-.86l8 4.64a2 2 0 0 1 0 3.44l-8 4.64A1 1 0 0 1 9 17.5Z' fill='%233d5361'/%3E%3C/svg%3E") center / 19px no-repeat;
}
#screen-hub .gcard:hover .go-tag, #screen-hub .gcard:focus-visible .go-tag {
  transform: translateY(-2px);
  box-shadow: inset 0 1px 0 #ffffffb3, 0 5px 0 var(--play-edge), 0 9px 16px #263c4915;
}
#screen-hub .gcard:active .go-tag { transform: translateY(2px); box-shadow: inset 0 1px 0 #ffffff80, 0 1px 0 var(--play-edge); }
@media (prefers-reduced-motion: reduce) {
  #screen-hub .gcard .go-tag { transition: none; }
  #screen-hub .gcard:hover .go-tag, #screen-hub .gcard:active .go-tag { transform: none; }
}
#screen-hub .gcard strong { text-shadow: none; }
#screen-hub .pill-link:hover, #screen-hub .round-btn:hover, #screen-hub .level-chip:hover { background: rgba(36, 64, 107, .06); }
/* Lời chào trên trang Khu Rừng Trò Chơi: cùng font tiêu đề (Comfortaa Bold) */
#screen-hub .hub-hello { font-family: "Comfortaa", "Baloo 2", "Segoe UI", sans-serif; font-weight: 700; }
/* Màn chơi: bỏ con vật cạnh đề bài (giữ ở màn kết quả) */
#screen-play .mascot { display: none; }
/* Bỏ khung nét đứt quanh các khay (mâm, rổ, đĩa, hàng và cột): chỉ còn các hình, cách nhau bằng khoảng trắng */
.tray { padding: 0; background: none; border: 0; box-shadow: none; border-radius: 0; }
.tray.small { padding: 0; }
.groups { gap: 26px 40px; }
.tray.array { gap: 12px 14px; }
/* Rừng Phép Nhân: hình to hơn, khoảng cách hình và ô đáp án rộng hơn, ô đáp án hạ xuống một chút */
.mi { width: clamp(38px, 5.4vw, 64px); }
.tray.small .mi { width: clamp(30px, 4.2vw, 48px); }
.groups { gap: 34px 48px; }
.tray.array .mi, .tray.array img { width: clamp(34px, 4.8vw, 56px); }
#screen-play .stage { margin-bottom: 0; gap: 40px; }
#screen-play .num-row { margin-top: 56px; gap: 26px; }
/* Phép tính trong đề (Rừng Phép Nhân): to và đậm hơn */
#screen-play .question .eq, #screen-play #prompt .eq { font-size: 1.6em; font-weight: 800; letter-spacing: .02em; }
/* Hình minh họa (Rừng Phép Nhân): to hơn, tự xếp theo khung. Màn ngang: các hàng xếp ngang; màn dọc: xếp dọc.
   Dạng "Hàng và cột" giữ đúng số cột/hàng nhưng co hình theo chiều rộng khung để không tràn. */
@media (min-aspect-ratio: 1/1) {
  .tray.array { --cell: clamp(44px, min(6.2vw, 9vh), 74px); }
  .tray.array .mi { width: var(--cell) !important; }
  #screen-play .stage { flex-direction: row; }
}
@media (max-aspect-ratio: 1/1) {
  .tray.array { --cell: clamp(40px, min(12vw, 6.4vh), 72px); }
  .tray.array .mi { width: var(--cell) !important; }
  .groups { flex-direction: column; align-items: center; }
  #screen-play .stage { flex-direction: column; }
}
.tray.array { grid-template-columns: repeat(var(--cols), var(--cell, 56px)); gap: 10px 12px; }
/* Tất cả hình minh họa Rừng Phép Nhân: to lên đáng kể (cỡ theo khung, không tràn) */
.mi { width: clamp(52px, min(7vw, 10vh), 92px) !important; }
.tray.small .mi { width: clamp(46px, min(6.2vw, 9vh), 80px) !important; }
.tray.small { gap: 10px 12px; padding: 0; }
.groups { gap: 40px 56px; }
#screen-play .num-row { margin-top: 64px; }

/* Menu trên Khu Rừng: màn hình rộng hiện thẳng trên thanh, hẹp thì gom vào nút ☰ (src/game/hub-menu.js) */
.hub-nav { position: relative; margin-right: auto; }
.hub-nav-list { display: flex; gap: 4px; margin: 0; padding: 0; list-style: none; }
.hub-nav-list .pill-link { text-decoration: none; }
.hub-menu-btn { display: none; }
@media (max-width: 860px) {
  .hub-top .sfx-toggle { order: 1; margin-left: auto; }
  .hub-nav { order: 2; margin-right: 0; }
  .hub-menu-btn { display: inline-flex; }
  .hub-nav-list { display: none; position: absolute; right: 0; top: calc(100% + 8px); z-index: 20; flex-direction: column; min-width: 230px; padding: 8px; border-radius: 20px; background: #fff; box-shadow: 0 12px 30px rgba(36, 64, 107, .18); }
  .hub-nav.open .hub-nav-list { display: flex; }
  #screen-hub .hub-nav-list .pill-link { width: 100%; }
}
/* Chừa khoảng giữa thanh menu và tên Khu Rừng (người dùng muốn cả phần dưới hạ xuống một chút) */
#screen-hub .hub-head { margin-top: 32px; }
@media (max-width: 860px) { #screen-hub .hub-head { margin-top: 16px; } }
/* Đã bỏ tiêu đề "Toán vui": chừa khoảng giữa hàng độ khó và các trò */
#screen-hub .game-cards.math { margin-top: 40px; }
@media (max-width: 860px) { #screen-hub .game-cards.math { margin-top: 20px; } }

/* Tên trò theo tục ngữ dài hơn: cho xuống dòng trong thẻ, chữ nhỏ lại một chút, không tràn */
#screen-hub .gcard { min-width: 0; }
#screen-hub .gcard strong { white-space: normal; text-wrap: balance; line-height: 1.2; font-size: clamp(24px, 2.3vw, 30px); max-width: 100%; }

/* ── Ba trò đời thường (src/game/daily.js) ── */
.num-row.text-choices .num-btn { min-width: 0; height: auto; min-height: 76px; padding: 10px 22px; font-size: clamp(22px, 2.6vw, 30px); line-height: 1.2; white-space: nowrap; }

/* Đồng hồ kim */
.ck-svg { width: clamp(150px, 22vw, 210px); height: auto; flex: 0 0 auto; }
.ck-svg.big { width: clamp(190px, 28vw, 270px); }
.ck-face { fill: #fffdf6; stroke: var(--wood); stroke-width: 6; }
.ck-tick { stroke: #c9bfa6; stroke-width: 1.4; }
.ck-tick5 { stroke: var(--ink); stroke-width: 3; }
.ck-num { font: 700 17px var(--font-title); fill: var(--ink); text-anchor: middle; }
.ck-hour { stroke: var(--ink); stroke-width: 8; stroke-linecap: round; transition: transform .25s ease; }
.ck-min { stroke: var(--orange); stroke-width: 5; stroke-linecap: round; transition: transform .25s ease; }
.ck-pin { fill: var(--ink); }
.clock-box { display: flex; justify-content: center; }
.dials { display: flex; flex-wrap: wrap; gap: 18px 28px; justify-content: center; }
.dial { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.dial-label { font: 700 18px var(--font-title); color: var(--ink-soft); }
.dial-row { display: flex; align-items: center; gap: 14px; }
.dial .step-val { min-width: 64px; text-align: center; font: 700 40px var(--font-title); color: var(--ink); }

/* Cân đĩa */
.sc-svg { width: min(420px, 92vw); height: auto; }
.scale-box { display: flex; justify-content: center; width: 100%; }
.sc-base, .sc-post { fill: var(--wood-d); }
.sc-beam { fill: var(--wood); }
.sc-rope { stroke: var(--wood-d); stroke-width: 2; }
.sc-pan { fill: #f2d9a8; stroke: var(--wood-d); stroke-width: 2; }
.sc-label { font: 700 15px var(--font-title); fill: var(--ink-soft); text-anchor: middle; }
.wt rect { fill: #5b6a86; }
.wt text { font: 700 15px var(--font-title); fill: #fff; text-anchor: middle; }
.wt.bag path { fill: #f7efd9; stroke: var(--wood-d); stroke-width: 2; }
.wt.bag text { fill: var(--wood-d); font-size: 18px; }
.weights { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; width: 100%; }
.weight-btn { min-width: 86px; min-height: 60px; padding: 8px 16px; border: 0; border-radius: 18px; background: #5b6a86; color: #fff; font: 700 22px var(--font-title); box-shadow: 0 6px 0 #3e4a61; cursor: pointer; }
.weight-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #3e4a61; }
.weight-btn.undo { background: transparent; color: var(--ink-soft); border: 2px dashed #b9c2d3; box-shadow: none; font-size: 18px; }
.sc-svg.paper-scale { width: min(520px, 94vw); overflow: visible; }
.paper-scale .wt text { font-size: 13px; fill: #fff9e9; }
.paper-scale .wt.bag text { fill: #71502d; font-size: 18px; }
.paper-scale .sc-label { font-size: 12px; }
.sc-paper-frame { filter: drop-shadow(0 2px 1px #6e522a22); }
.weight-btn:not(.undo) { padding: 32px 14px 12px; min-height: 90px; background: url('../../assets/game/scale-weight-paper.webp') center / contain no-repeat; border-radius: 0; box-shadow: none; font-size: 19px; color: #fff8e6; }
.weight-btn:not(.undo):active { box-shadow: none; transform: translateY(3px); }

/* Chợ quê: hàng hóa, tờ tiền */
.goods { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; align-items: center; width: 100%; }
.good { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 18px; border-radius: 20px; background: var(--cream); border: 2px solid #efe0b9; }
.good-name { font: 700 19px var(--font-title); color: var(--ink); }
.tag { padding: 3px 12px; border-radius: 999px; background: #fff; border: 2px dashed var(--orange); color: var(--orange-d); font: 700 17px var(--font-title); }
.bill { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; min-width: 108px; height: 56px; padding: 0 10px; border-radius: 8px; border: 2px solid rgba(0, 0, 0, .18); font: 700 19px var(--font-title); color: #2f3b57; box-shadow: inset 0 0 0 4px rgba(255, 255, 255, .35); }
.bill small { font-size: 11px; font-weight: 700; opacity: .75; }
.bill.b1 { background: #d8d2c4; } .bill.b2 { background: #c9b48f; } .bill.b5 { background: #b7c7e6; }
.bill.b10 { background: #e6d48a; } .bill.b20 { background: #9fc3e8; } .bill.b50 { background: #e8a7c2; } .bill.b100 { background: #a8d5a2; }
.wallet { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; width: 100%; }
.bill-btn { padding: 0; border: 0; background: none; border-radius: 10px; cursor: pointer; transition: transform .12s; }
.bill-btn:hover { transform: translateY(-3px); }
.bill-btn:active { transform: translateY(2px); }
.hand { width: 100%; text-align: center; }
.hand-sum { margin: 0 0 8px; font: 700 20px var(--font-title); color: var(--ink-soft); }
.hand-sum strong { color: var(--ink); }
.hand-bills { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; min-height: 60px; }
.hand-bills .bill { cursor: pointer; }
@media (max-width: 560px) {
  .bill { min-width: 88px; height: 48px; font-size: 16px; }
  .num-row.text-choices .num-btn { white-space: normal; }
}

/* Quay kim đồng hồ: nút "Xong rồi!" nằm ngay dưới các nút Giờ/Phút, không khung giấy lớn */
.dials .play-actions.in-dials, .name-panel .play-actions.in-dials { flex-basis: 100%; margin: 6px 0 0; padding: 0; min-height: 0; gap: 10px; }
.dials .play-actions.in-dials .verdict, .name-panel .play-actions.in-dials .verdict { position: static; width: auto; max-width: 260px; font-size: 18px; }
.dials .play-actions.in-dials .big-btn, .name-panel .play-actions.in-dials .big-btn { min-height: 48px; font-size: 18px; padding: 10px 28px; }

/* Đĩa / mâm nằm ngang: bề ngang vừa đúng số quả mỗi hàng (tối đa 2 hàng) */
.tray:not(.array) { --mi: clamp(52px, min(7vw, 10vh), 92px); --tg: 12px; column-gap: var(--tg); }
.tray.small:not(.array) { --mi: clamp(46px, min(6.2vw, 9vh), 80px); }
.tray:not(.array) .mi { width: var(--mi) !important; }
.tray[style*="--per-row"]:not(.array) { box-sizing: content-box; max-width: none; width: calc(var(--per-row) * var(--mi) + (var(--per-row) - 1) * var(--tg)); }

/* Tìm số còn thiếu: số chọn nằm trong ô vuông bo góc ngay trong phép tính; nút − + tròn nhỏ gắn hai mép ô */
.big-eq.has-steps { padding: 6px 0; white-space: nowrap; font-size: clamp(38px, 5.4vw, 60px); }
.guess-slot { position: relative; display: inline-flex; align-items: center; justify-content: center; vertical-align: middle; min-width: 1.6em; height: 1.55em; padding: 0 .45em; margin: 0 .5em; border: 2px solid #c9c3b6; border-radius: .32em; background: #fffdf8; }
.big-eq .guess-slot .guess { min-width: 0; padding: 0 .12em; border: 0; background: none; font-size: 1.1em; line-height: 1; }
.guess-steps { position: absolute; inset: 0; display: flex; align-items: center; justify-content: space-between; gap: 0; pointer-events: none; }
.guess-steps .step-val { display: none; }
.big-eq .guess-steps .step-btn { pointer-events: auto; width: 40px; height: 40px; padding: 0; border-radius: 50%; font: 700 26px/1 var(--font-title); color: var(--ink, #24406b); background: #fff; border: 2px solid #c9c3b6; box-shadow: 0 2px 4px #4c544520; }
.big-eq .guess-steps .step-btn:first-child { transform: translateX(-50%); }
.big-eq .guess-steps .step-btn:last-child { transform: translateX(50%); }
.big-eq .guess-steps .step-btn:hover:not(:disabled) { background: #fffcf4; border-color: #a9a294; }
.big-eq .guess-steps .step-btn:disabled { opacity: .35; }
.big-eq .guess-steps .step-btn:first-child:hover:not(:disabled) { transform: translateX(-50%) translateY(-1px); }
.big-eq .guess-steps .step-btn:last-child:hover:not(:disabled) { transform: translateX(50%) translateY(-1px); }

/* Tờ tiền vẽ mô phỏng, màu na ná tiền Việt Nam (không phải hình tiền thật).
   Bên trái: ô tròn mờ như hình chìm; nền có vân chéo nhẹ; khung viền trong; tờ polymer (10 000 trở lên) có ô trong suốt nhỏ. */
.bill {
  --c1: #d8d2c4; --c2: #b9b19e; --ink: #3b3a33;
  position: relative; overflow: hidden; display: inline-flex; flex-direction: column; align-items: flex-end; justify-content: center;
  width: 140px; min-width: 0; height: 66px; padding: 0 12px 0 50px; border-radius: 6px; border: 1px solid rgba(0, 0, 0, .22);
  color: var(--ink); font: 800 19px/1.05 var(--font-title); letter-spacing: .01em;
  background:
    radial-gradient(ellipse 19px 23px at 27px 50%, rgba(255, 255, 255, .62) 0 92%, rgba(255, 255, 255, 0) 100%),
    repeating-linear-gradient(118deg, rgba(255, 255, 255, .16) 0 1.5px, transparent 1.5px 5px),
    repeating-linear-gradient(62deg, rgba(0, 0, 0, .05) 0 1px, transparent 1px 7px),
    linear-gradient(100deg, var(--c1) 0%, var(--c2) 100%);
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, .38), inset 0 0 0 4px rgba(0, 0, 0, .12), 0 2px 3px rgba(40, 50, 60, .18);
}
.bill::before { content: ''; position: absolute; left: 13px; top: 50%; width: 28px; height: 34px; transform: translateY(-50%); border-radius: 50%; border: 1.5px solid rgba(0, 0, 0, .12); background: radial-gradient(circle at 50% 38%, rgba(0, 0, 0, .1) 0 6px, transparent 7px), radial-gradient(ellipse 11px 7px at 50% 92%, rgba(0, 0, 0, .09) 0 95%, transparent 100%); }
.bill.polymer::after { content: ''; position: absolute; right: 7px; top: 7px; width: 13px; height: 13px; border-radius: 50%; background: rgba(255, 255, 255, .72); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .14); }
.bill .bill-val { display: block; white-space: nowrap; }
.bill small { font-size: 10.5px; font-weight: 700; opacity: .8; text-transform: lowercase; margin-top: 2px; }
.bill.b1 { --c1: #c9c49a; --c2: #a9a477; --ink: #3f3d22; }
.bill.b2 { --c1: #cdb393; --c2: #a8896a; --ink: #44301f; }
.bill.b5 { --c1: #a9aedb; --c2: #7f86bf; --ink: #262c5c; }
.bill.b10 { --c1: #e6c77c; --c2: #c99d52; --ink: #4e3510; }
.bill.b20 { --c1: #9cc4ea; --c2: #6b9fd3; --ink: #173f69; }
.bill.b50 { --c1: #e7a9c9; --c2: #c97aa6; --ink: #5a1d43; }
.bill.b100 { --c1: #a9d6a6; --c2: #74b27a; --ink: #1d4a26; }
.bill.b200 { --c1: #eeb08f; --c2: #d4825f; --ink: #5c2614; }
.bill.b500 { --c1: #9fdbe0; --c2: #6cb8c8; --ink: #134c58; }
@media (max-width: 680px) {
  .bill { width: 108px; height: 52px; padding: 0 9px 0 40px; font-size: 16px; }
  .bill::before { left: 10px; width: 22px; height: 28px; }
}
.bill.b100, .bill.b200, .bill.b500 { font-size: 17px; }
@media (max-width: 680px) { .bill.b100, .bill.b200, .bill.b500 { font-size: 14px; } }
