/* ================= Line 98 — MonBlock ================= */
:root {
  --bg: #0d1117;
  --panel: #151c26;
  --panel-2: #1b2431;
  --line: #2b3646;
  --txt: #e8eef6;
  --muted: #93a3b8;
  --accent: #ffcf5a;
  /* Bi: sáng / màu / tối cho gradient 3D */
  --c1: #ff6a5e; --d1: #a8160e;
  --c2: #4fdc5a; --d2: #157a1f;
  --c3: #4f86ff; --d3: #1532a0;
  --c4: #ffe14a; --d4: #a88a00;
  --c5: #d070ff; --d5: #6a1a9c;
  --c6: #46e6f0; --d6: #087a86;
  --c7: #c98a55; --d7: #6a3a14;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { touch-action: manipulation; -webkit-text-size-adjust: 100%; }
body {
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(900px 500px at 10% -10%, #14283a 0%, transparent 60%),
    radial-gradient(700px 420px at 100% 0%, #2a1430 0%, transparent 55%),
    var(--bg);
  color: var(--txt);
  font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.hidden { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--accent); }
.wrap { max-width: 640px; margin: 0 auto; padding: 8px 14px 28px; }
.screen { animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
h2 { font-size: 17px; margin: 18px 0 10px; }
.note { color: var(--muted); font-size: 13px; line-height: 1.5; }
body.touch .no-touch { display: none; }

/* ---------- trang chủ ---------- */
.me-card { display: flex; align-items: center; gap: 14px; padding: 12px 16px 12px 12px; margin: 6px 0 14px; border: 1px solid var(--line); border-radius: 18px; background: linear-gradient(135deg, #142a3c, var(--panel)); }
.me-balls { position: relative; width: 60px; height: 60px; flex: none; border-radius: 14px; background: var(--cell-img), var(--cell); box-shadow: inset 2px 2px 0 var(--cell-hi), inset -2px -2px 0 var(--cell-lo); }
.me-balls .ball { position: absolute; width: 24px; height: 24px; }
.me-balls .ball:nth-child(1) { left: 6px; top: 6px; }
.me-balls .ball:nth-child(2) { left: 18px; top: 18px; }
.me-balls .ball:nth-child(3) { left: 30px; top: 30px; }
.me-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.me-info b { font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-info span { color: var(--muted); font-size: 13px; font-weight: 600; }
.xpbar { height: 6px; border-radius: 9px; background: var(--panel-2); overflow: hidden; }
.xpbar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #4f86ff, #46e6f0); border-radius: 9px; }
.me-chips { display: flex; flex-direction: column; gap: 4px; align-items: flex-end; font-size: 14px; font-weight: 700; white-space: nowrap; }

.big { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; margin: 0 0 10px; padding: 15px 18px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); font-size: 17px; font-weight: 800; text-align: left; }
.big small { color: var(--muted); font-size: 13px; font-weight: 600; }
.big-resume { background: linear-gradient(135deg, #3d3214, #151c26); border-color: #7a6324; }

.big-shop { background: linear-gradient(135deg, #3a2a10, #151c26); border-color: #7a5a20; }
.big-daily.done small { color: #00a862; }
.big-new { background: linear-gradient(135deg, #14304a, #151c26); border-color: #2a5480; }
.homegrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 4px 0 6px; }
.small { padding: 12px 6px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); font-size: 14px; font-weight: 700; }
.small:disabled { opacity: .4; cursor: default; }
.small.on { border-color: var(--accent); color: var(--accent); }

/* ---------- bàn chơi ---------- */
.hud { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; margin: 4px auto 8px; max-width: 560px; }
.hud small { display: block; color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; }
.hud-box b { font-size: 26px; font-weight: 900; font-variant-numeric: tabular-nums; }
.hud-box.right { text-align: right; }
.hud-box.right b { color: var(--accent); }
.hud-next { text-align: center; }
#nextBalls { display: flex; gap: 6px; justify-content: center; padding: 6px 8px; border-radius: 10px; background: var(--frame); box-shadow: inset 2px 2px 0 var(--frame-lo), inset -2px -2px 0 var(--frame-hi); }
#nextBalls .ball { width: 24px; height: 24px; }

/* ---------- mẫu bàn (L98Catalog.BOARDS): lớp .bd-<id> đặt biến màu, dùng cho bàn thật lẫn ô xem thử ---------- */
.bd-classic { --frame: #7a7a7a; --frame-hi: #d0d0d0; --frame-lo: #4a4a4a; --cell: #b8b8b8; --cell-hi: #ececec; --cell-lo: #6c6c6c; --cell-img: none; }
.bd-wood    { --frame: #6a4220; --frame-hi: #a8763e; --frame-lo: #3a220c; --cell: #d9b07a; --cell-hi: #f2d4a4; --cell-lo: #8a5a2a;
  --cell-img: repeating-linear-gradient(100deg, rgba(120, 70, 20, .12) 0 3px, transparent 3px 9px); }
.bd-grass   { --frame: #2f5a26; --frame-hi: #5a9a4a; --frame-lo: #1a3414; --cell: #7cc36a; --cell-hi: #b4e8a4; --cell-lo: #3f7a32; --cell-img: none; }
.bd-night   { --frame: #0a1020; --frame-hi: #2a3a5e; --frame-lo: #000; --cell: #22304a; --cell-hi: #3a4c6e; --cell-lo: #0c1424;
  --cell-img: radial-gradient(circle at 70% 30%, rgba(255, 255, 255, .5) 0 1px, transparent 2px); }
.bd-candy   { --frame: #d97aa6; --frame-hi: #ffc2dc; --frame-lo: #a04a74; --cell: #ffd6e7; --cell-hi: #fff0f6; --cell-lo: #e59ab8;
  --cell-img: repeating-linear-gradient(45deg, rgba(255, 255, 255, .45) 0 4px, transparent 4px 10px); }
.bd-marble  { --frame: #6b665e; --frame-hi: #b8b2a6; --frame-lo: #3a3630; --cell: #e9e6e0; --cell-hi: #ffffff; --cell-lo: #a9a49a;
  --cell-img: linear-gradient(125deg, transparent 40%, rgba(140, 130, 120, .25) 45%, transparent 52%), linear-gradient(35deg, transparent 60%, rgba(150, 140, 130, .2) 64%, transparent 70%); }
.bd-neon    { --frame: #1a1040; --frame-hi: #6a4aff; --frame-lo: #000; --cell: #0d0b1e; --cell-hi: #3b2a7a; --cell-lo: #000; --cell-img: none; }
.bd-neon .cell, .bd-neon.cell, .prev.bd-neon i { box-shadow: inset 0 0 0 1px rgba(80, 220, 255, .45), inset 0 0 8px rgba(120, 80, 255, .35); }
.bd-gold    { --frame: #7a5a10; --frame-hi: #e8c25a; --frame-lo: #4a3404; --cell: #f2d27a; --cell-hi: #fff1b8; --cell-lo: #a87a1a;
  --cell-img: linear-gradient(135deg, rgba(255, 255, 255, .35), transparent 50%); }
/* Sự kiện "Lễ hội khai mạc": tím đêm hội, lấm tấm pháo giấy */
.bd-lehoi   { --frame: #5a1440; --frame-hi: #ff6fb5; --frame-lo: #2a0820; --cell: #3a1846; --cell-hi: #6a3080; --cell-lo: #1a0822;
  --cell-img: radial-gradient(circle at 25% 30%, #ffd23a 0 1.5px, transparent 2.5px), radial-gradient(circle at 70% 65%, #4fe0ff 0 1.5px, transparent 2.5px), radial-gradient(circle at 80% 20%, #ff6fb5 0 1px, transparent 2px); }
/* Sương sớm: frosty pale blue morning */
.bd-suongsom { --frame: #6f8aa3; --frame-hi: #d6e6f2; --frame-lo: #3e5468; --cell: #dbe8f1; --cell-hi: #ffffff; --cell-lo: #9db4c6;
  --cell-img: radial-gradient(circle at 30% 25%, rgba(255, 255, 255, .9) 0 1px, transparent 2px), linear-gradient(160deg, rgba(255, 255, 255, .55), transparent 55%); }

.board-wrap { display: flex; justify-content: center; }
/* Board fits the screen: width bound + height left after header, HUD, buttons and the bottom nav (phone). */
.board { --size: min(100%, 560px, calc(100dvh - 300px)); position: relative; width: var(--size); min-width: 252px; aspect-ratio: 1; display: grid; grid-template-columns: repeat(9, 1fr); grid-template-rows: repeat(9, 1fr);
  padding: 4px; border-radius: 6px; background: var(--frame); box-shadow: inset 2px 2px 0 var(--frame-lo), inset -2px -2px 0 var(--frame-hi), 0 10px 30px rgba(0, 0, 0, .45); user-select: none; -webkit-user-select: none; }
@media (min-width: 860px) { .board { --size: min(100%, 560px, calc(100dvh - 230px)); } }
.cell { position: relative; display: grid; place-items: center; padding: 0; border: 0; background: var(--cell-img), var(--cell); box-shadow: inset 2px 2px 0 var(--cell-hi), inset -2px -2px 0 var(--cell-lo); }
.cell.cur { outline: 3px solid var(--accent); outline-offset: -3px; z-index: 1; }
.cell.trail::after { content: ''; position: absolute; width: 22%; height: 22%; border-radius: 50%; background: rgba(40, 40, 40, .35); animation: trail .5s ease forwards; }
@keyframes trail { to { opacity: 0; } }
.cell.nope { animation: nope .3s; }
@keyframes nope { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }

/* ---------- kiểu bi (L98Catalog.BALLS): lớp .bs-<id> trên bàn / ô bi sắp ra / ô xem thử ---------- */
.ball { position: relative; display: block; width: 76%; height: 76%; border-radius: 50%; background: radial-gradient(circle at 34% 30%, #fff 0, var(--c) 32%, var(--d) 100%); box-shadow: 1px 3px 4px rgba(0, 0, 0, .35); }
.ball.c1 { --c: var(--c1); --d: var(--d1); } .ball.c2 { --c: var(--c2); --d: var(--d2); } .ball.c3 { --c: var(--c3); --d: var(--d3); }
.ball.c4 { --c: var(--c4); --d: var(--d4); } .ball.c5 { --c: var(--c5); --d: var(--d5); } .ball.c6 { --c: var(--c6); --d: var(--d6); }
.ball.c7 { --c: var(--c7); --d: var(--d7); }
.bs-flat .ball { background: var(--c); box-shadow: inset 0 0 0 3px var(--d); }
.bs-glass .ball { background: radial-gradient(circle at 32% 28%, rgba(255, 255, 255, .95) 0 9%, transparent 11%), radial-gradient(circle at 62% 70%, rgba(255, 255, 255, .35) 0 14%, transparent 30%),
  conic-gradient(from 30deg, var(--c), transparent 25%, var(--c) 50%, transparent 75%, var(--c)), var(--d); opacity: .92; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .35), 1px 3px 4px rgba(0, 0, 0, .3); }
.bs-candy .ball { background: radial-gradient(circle at 34% 30%, rgba(255, 255, 255, .85) 0 10%, transparent 30%), repeating-conic-gradient(var(--c) 0 30deg, #fff 30deg 45deg); box-shadow: inset 0 0 0 2px var(--d), 1px 3px 4px rgba(0, 0, 0, .3); }
.bs-gem .ball { border-radius: 18%; transform: rotate(45deg) scale(.86); background: conic-gradient(from 0deg, var(--c), #fff 12%, var(--c) 25%, var(--d) 37%, var(--c) 50%, #fff 62%, var(--c) 75%, var(--d) 87%, var(--c));
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .5), 1px 3px 4px rgba(0, 0, 0, .35); }
.bs-gem .ball.sel { animation: bounce-gem .5s ease-in-out infinite alternate; }
@keyframes bounce-gem { from { transform: rotate(45deg) scale(.86) translate(4%, 4%); } to { transform: rotate(45deg) scale(.9) translate(-10%, -10%); } }
.bs-fruit .ball { container-type: size; display: grid; place-items: center; background: none; box-shadow: none; }
.bs-fruit .ball::after { font-size: 82cqw; line-height: 1; filter: drop-shadow(1px 2px 1px rgba(0, 0, 0, .35)); }
.bs-fruit .ball.c1::after { content: '🍎'; } .bs-fruit .ball.c2::after { content: '🍏'; } .bs-fruit .ball.c3::after { content: '🫐'; }
.bs-fruit .ball.c4::after { content: '🍋'; } .bs-fruit .ball.c5::after { content: '🍇'; } .bs-fruit .ball.c6::after { content: '🧊'; }
.bs-fruit .ball.c7::after { content: '🥥'; }
/* Bi cầu vồng (Lines.JOKER = 8, kiểu chơi 🌈): cùng một hình ở mọi kiểu bi */
.ball.c8, .bs-flat .ball.c8, .bs-glass .ball.c8, .bs-candy .ball.c8, .bs-gem .ball.c8, .bs-royal .ball.c8, .bs-len .ball.c8 {
  background: radial-gradient(circle at 34% 30%, #fff 0 10%, transparent 34%), conic-gradient(#ff5a52, #ffd23a, #4fdc5a, #46e6f0, #4f86ff, #d070ff, #ff5a52); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .6), 1px 3px 4px rgba(0, 0, 0, .35); }
.bs-fruit .ball.c8 { background: none; box-shadow: none; }
.bs-fruit .ball.c8::after { content: '🌈'; }
.bs-royal .ball { overflow: hidden; background: radial-gradient(circle at 34% 30%, #fff 0, var(--c) 30%, var(--d) 92%); box-shadow: inset 0 0 0 2px #ffd24d, 0 0 0 1px #8a6200, 1px 3px 6px rgba(0, 0, 0, .4); }
.bs-royal .ball::after { content: ''; position: absolute; inset: 0; background: linear-gradient(115deg, transparent 35%, rgba(255, 255, 255, .7) 48%, transparent 60%); animation: shine 2.6s ease-in-out infinite; }
.bs-len .ball { overflow: hidden; background: radial-gradient(circle at 34% 30%, rgba(255, 255, 255, .55) 0, transparent 38%),
  repeating-linear-gradient(-35deg, var(--c) 0 3px, var(--d) 3px 4px), var(--c); box-shadow: inset 0 0 0 2px var(--d), 1px 3px 4px rgba(0, 0, 0, .35); }
.bs-len .ball::after { content: ''; position: absolute; inset: 12% 6%; border-radius: 50%; border: 2px solid transparent; border-top-color: rgba(255, 255, 255, .55); border-bottom-color: rgba(0, 0, 0, .18); transform: rotate(25deg); }
@keyframes shine { 0%, 60% { transform: translateX(-120%); } 100% { transform: translateX(120%); } }

.ball.mini { width: 30%; height: 30%; opacity: .9; }
.ball.sel { animation: bounce .5s ease-in-out infinite alternate; }
@keyframes bounce { from { transform: translateY(6%); } to { transform: translateY(-14%) scale(1.04, .96); } }
.ball.grow { animation: grow .22s ease-out; }
@keyframes grow { from { transform: scale(.35); } to { transform: none; } }
.ball.pop { animation: pop .32s ease-in forwards; }
@keyframes pop { 40% { transform: scale(1.25); filter: brightness(1.6); } to { transform: scale(0); opacity: 0; } }
.plus { position: absolute; z-index: 3; font-size: 22px; font-weight: 900; color: #fff; text-shadow: 0 2px 0 #000, 0 0 8px rgba(0, 0, 0, .6); pointer-events: none; animation: plus .9s ease-out forwards; }
@keyframes plus { to { transform: translateY(-46px); opacity: 0; } }
/* Hiệu ứng nổ (L98Catalog.FX): hạt do main.js tạo + Web Animations */
.fxp { position: absolute; z-index: 4; left: 0; top: 0; pointer-events: none; line-height: 1; will-change: transform, opacity; }
.fxp.dot { width: 8px; height: 8px; border-radius: 50%; }
.fxp.flake { width: 9px; height: 9px; border-radius: 50%; background: radial-gradient(circle, #fff 0 35%, rgba(220, 240, 255, .6) 60%, transparent 72%); }
.fxp.bit { width: 7px; height: 11px; border-radius: 2px; }
.fxflash { position: absolute; z-index: 3; pointer-events: none; background: rgba(255, 255, 220, .9); border-radius: 4px; box-shadow: 0 0 18px 6px rgba(255, 240, 140, .8); }

/* ---------- cửa hàng ---------- */
.shop-top { display: flex; justify-content: flex-end; gap: 16px; margin: 4px 0; font-size: 17px; font-weight: 800; }
.gem-chip b { color: #7fd8ff; }
.shop { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.item { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 8px 12px; border: 2px solid var(--line); border-radius: 16px; background: var(--panel); text-align: center; }
.item.active { border-color: var(--accent); background: #2a2414; }
.item.locked { opacity: .55; }
.item.poor .act.buy { color: var(--muted); }
.item b { font-size: 14px; }
.item .rar { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px; }
.item .act { font-size: 13px; font-weight: 800; color: var(--muted); }
.item .act.buy { color: var(--accent); }
.item.active .act { color: var(--accent); }
.gem { color: #7fd8ff; }
.prev { display: grid; width: 100%; max-width: 132px; aspect-ratio: 1; padding: 3px; border-radius: 6px; background: var(--frame); grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr);
  box-shadow: inset 2px 2px 0 var(--frame-lo), inset -2px -2px 0 var(--frame-hi); }
.prev i { display: grid; place-items: center; background: var(--cell-img), var(--cell); box-shadow: inset 2px 2px 0 var(--cell-hi), inset -2px -2px 0 var(--cell-lo); }
.prev.fxprev { position: relative; place-items: center; grid-template-columns: 1fr; grid-template-rows: 1fr; font-size: 54px; overflow: hidden; }
.buyprev { display: flex; justify-content: center; margin: 4px 0 8px; }
.buyprev .prev { max-width: 170px; }
.ctl { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; max-width: 560px; margin: 10px auto 0; }

/* ---------- chọn kiểu chơi ---------- */
.variants { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; margin-top: 6px; }
.variant { display: flex; align-items: flex-start; gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); text-align: left; }
.variant.on { border-color: #335fff; box-shadow: inset 0 0 0 1px #335fff; }
.variant > i { font-size: 32px; font-style: normal; line-height: 1; }
.variant span { display: flex; flex-direction: column; gap: 3px; }
.variant b { font-size: 16px; }
.variant small { color: var(--muted); font-size: 13px; line-height: 1.4; }
.variant em { color: #335fff; font-size: 12px; font-style: normal; font-weight: 800; }

/* ---------- xếp hạng ---------- */
.tabs { display: flex; gap: 6px; margin: 6px 0 10px; }
.tabs button { flex: 1; padding: 10px 6px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); font-weight: 800; font-size: 14px; }
.tabs button.on { border-color: var(--accent); background: #2a2414; color: var(--accent); }
.rank .row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.rank .row.me { background: #1d2a1d; border-radius: 10px; }
.rank .no { width: 28px; color: var(--muted); font-weight: 800; text-align: center; }
.rank .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.rank .nm small { color: var(--muted); font-weight: 600; }
.rank .sc { font-weight: 900; color: var(--accent); }

.help { line-height: 1.6; }
.help ul { padding-left: 20px; }

/* ---------- hộp thoại ---------- */
.modal { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 16px; background: rgba(5, 8, 12, .72); }
.dialog { width: min(420px, 100%); max-height: calc(100dvh - 32px); overflow: auto; padding: 18px; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); box-shadow: 0 20px 60px rgba(0, 0, 0, .6); }
.dialog h3 { margin: 0 0 8px; font-size: 20px; }
.dialog p { line-height: 1.5; }
.dialog .score { margin: 4px 0; font-size: 40px; font-weight: 900; text-align: center; color: var(--accent); }
.dialog .rw { padding-left: 18px; line-height: 1.8; font-weight: 700; }
.dlg-btns { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.dlg-btns button { padding: 10px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2); font-weight: 800; }
.dlg-btns button.pri { border-color: var(--accent); background: var(--accent); color: #1c1608; }
.toast { position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom)); z-index: 90; transform: translateX(-50%); padding: 10px 16px; border-radius: 12px; background: #222c3a; font-weight: 700; box-shadow: 0 8px 24px rgba(0, 0, 0, .5); }
.updatebar { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 45; display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel-2); }
.updatebar button { padding: 8px 12px; border: 0; border-radius: 10px; background: var(--accent); color: #1c1608; font-weight: 800; }

/* ---------- sự kiện (sdk/events.js): thẻ món giới hạn ---------- */
.evtag { display: inline-block; margin: 2px 0; padding: 1px 8px; border-radius: 999px; background: linear-gradient(90deg, #ff9a3c, #ff4fa0); color: #fff; font-size: 11px; font-style: normal; font-weight: 800; }
.item.ev { border-color: #ff9a3c; box-shadow: 0 0 0 1px rgba(255, 154, 60, .35), 0 0 16px rgba(255, 79, 160, .18); }
/* Account avatar on the player card (logged in): replaces the three balls */
.me-balls .me-avemo { position: absolute; inset: 0; display: grid; place-items: center; font-size: 34px; line-height: 1; }
.me-balls.has-av .ball { display: none; }

/* Phone held sideways (orient-check 19/11/2026): score + next balls on the left, board in the middle sized by the screen
   HEIGHT, tools on the right — the portrait stack (hud, board, tools) was 470 px tall on a 390 px screen. */
@media (orientation: landscape) and (max-height: 500px) {
  #scPlay:not(.hidden) { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 0 18px; max-width: 900px; margin: 0 auto; }
  #scPlay .hud { grid-column: 1; grid-row: 1; grid-template-columns: 1fr; gap: 12px; margin: 0; justify-items: end; text-align: right; }
  #scPlay .board-wrap { grid-column: 2; grid-row: 1; }
  #scPlay .board { --size: calc(100dvh - 64px); min-width: 0; }
  #scPlay .ctl { grid-column: 3; grid-row: 1; grid-template-columns: 1fr; max-width: 170px; margin: 0; }
  #scPlay #keysHint { display: none; }
}

/* ===== Trang chủ tranh vẽ (design system 17/11/2026 — bố cục chuẩn: ‹ trên trái, loa + sách trên phải, logo + CHƠI, 4 ô đáy) ===== */
#scHome { position: fixed; inset: 0; z-index: 5; overflow: hidden; padding: 0; max-width: none; background: #f3e4c4; animation: none; container-type: size; }
#scHome .hm-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center top; }
body:has(#scHome:not(.hidden)) .mb-nav { display: none !important; }
#scHome button { -webkit-appearance: none; appearance: none; font-family: inherit; }
.hm-back, .hm-gear { position: absolute; top: max(10px, env(safe-area-inset-top)); width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; padding: 0; box-shadow: 0 3px 6px rgba(0, 0, 0, .35); }
.hm-back { left: max(10px, env(safe-area-inset-left)); background: #fff; border: 3px solid #e3e5e8; color: #191b1d; font: 700 28px/1 system-ui; padding-bottom: 4px; }
.hm-gear { right: max(10px, env(safe-area-inset-right)); border-radius: 12px; background: linear-gradient(#5ab4ff, #2a6fd8); border: 3px solid #e8f7ff; color: #fff; }
.hm-gear svg { width: 26px; height: 26px; display: block; }
.hm-mute { display: none; position: absolute; left: 7px; right: 7px; top: 50%; height: 3px; background: #ff4d4d; border-radius: 2px; transform: rotate(-45deg); }
.hm-gear.off .hm-mute { display: block; }
.hm-book { top: calc(max(10px, env(safe-area-inset-top)) + 54px); border-radius: 50%; }
.hm-top { position: absolute; left: calc(max(10px, env(safe-area-inset-left)) + 52px); top: max(10px, env(safe-area-inset-top)); display: flex; align-items: center; gap: 8px; }
.hm-av { position: relative; flex: none; width: 52px; height: 52px; padding: 0; border-radius: 50%; border: 3px solid #d8a13a; background: #fff3d6; display: grid; place-items: center; box-shadow: 0 3px 6px rgba(0, 0, 0, .35); cursor: pointer; }
.hm-av .me-avemo { position: absolute; inset: 0; display: grid; place-items: center; font-size: 28px; line-height: 1; border-radius: 50%; overflow: hidden; color: var(--px, #e5484d); font-weight: 900; }
.hm-lv { position: absolute; left: 50%; bottom: -9px; transform: translateX(-50%); padding: 1px 8px; border-radius: 8px; background: #7a4a1c; border: 2px solid #d8a13a; color: #fff; font: 900 12px/1.2 system-ui, sans-serif; white-space: nowrap; }
.hm-name { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.hm-xp, .hm-pts { display: none; }
.hm-bar { display: flex; align-items: center; gap: 4px; min-width: 84px; height: 32px; padding: 0 10px 0 4px; border-radius: 16px; background: rgba(20, 60, 90, .78); border: 2px solid rgba(255, 255, 255, .55); }
.hm-bar img { width: 24px; height: auto; flex: none; }
.hm-bar b { flex: 1; color: #fff !important; font: 900 14px/1 system-ui, sans-serif; text-align: center; }
.hm-stack { position: absolute; left: 0; right: 0; top: calc(max(10px, env(safe-area-inset-top)) + 64px); bottom: 150px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.6cqh; padding: 0 5cqw; }
.hm-logo { flex: 0 1 auto; min-height: 0; max-height: 16cqh; max-width: 84cqw; width: auto; height: auto; filter: drop-shadow(0 5px 6px rgba(0, 0, 0, .3)); pointer-events: none; }
.hm-hero { flex: 0 1 auto; min-height: 0; max-height: 28cqh; max-width: 72cqw; width: auto; height: auto; filter: drop-shadow(0 6px 6px rgba(0, 0, 0, .25)); pointer-events: none; }
.hm-play { flex: none; width: min(70cqw, 330px); padding: 1.2cqh 3cqw 1.4cqh; border-radius: 999px; text-align: center; color: #fff; background: linear-gradient(#8aea5a, #2fae2a 60%, #238a22); border: 4px solid #fff5cf; box-shadow: 0 5px 0 #1b6b1a, 0 9px 12px rgba(0, 0, 0, .35); }
.hm-play b { display: block; font: 900 clamp(26px, 5.2cqh, 44px)/1.05 "Arial Rounded MT Bold", system-ui, sans-serif; -webkit-text-stroke: .12em #1d6a1d; paint-order: stroke fill; letter-spacing: 2px; }
.hm-play small { display: block; font: 900 clamp(12px, 1.8cqh, 15px)/1.2 system-ui, sans-serif; -webkit-text-stroke: .2em #1d6a1d; paint-order: stroke fill; }
.hm-play:active, .hm-ic:active { transform: scale(.96); }
.hm-row { position: absolute; left: 50%; bottom: max(14px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; gap: 2cqw; }
.hm-ic { position: relative; width: min(21cqw, 96px); padding: 0; background: none; border: 0; box-shadow: none; color: #fff; }
.hm-ic img { width: 100%; height: auto; aspect-ratio: 1; object-fit: contain; display: block; filter: drop-shadow(0 3px 3px rgba(0, 0, 0, .4)); }
.hm-ic span { display: block; margin-top: -2px; text-align: center; font: 900 clamp(12px, 1.7cqh, 14px)/1.1 system-ui, sans-serif; -webkit-text-stroke: .22em #4a2a14; paint-order: stroke fill; white-space: nowrap; }
.hm-dot { position: absolute; top: 2px; right: 2px; min-width: 22px; height: 22px; padding: 0 5px; border-radius: 11px; background: #e5374f; border: 2px solid #fff; color: #fff; font: 900 12px/18px system-ui; font-style: normal; }
.hm-dot.hidden { display: none; }
#scHome .hm-seo { position: absolute !important; width: 1px !important; height: 1px !important; margin: 0 !important; padding: 0 !important; overflow: hidden !important; clip: rect(0 0 0 0) !important; white-space: nowrap !important; }
#scBook a.bk-link { display: flex; align-items: center; min-height: 44px; padding: 8px 16px; border: 1px solid var(--skin-card-line, #e3e5e8); border-radius: 12px; background: var(--skin-card, #f7f8f9); color: var(--skin-ink, #191b1d); font-size: 15px; font-weight: 700; text-decoration: none; }
#scBook .bk-list, #scModes { display: flex; flex-direction: column; gap: 8px; }
#scModes .big { margin: 0; }
#scHelp .help ul { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; font-size: 15px; line-height: 1.4; }
.hm-dot-s { min-width: 16px; width: 16px; height: 16px; padding: 0; top: 6px; right: 10px; }
.hm-av .me-avemo .ball { width: 60%; height: 60%; }
#scQuests { display: flex; flex-direction: column; gap: 10px; }
#scQuests .big { margin: 0; }
#scQuests .note { margin: 0; font-size: 14px; }
.qd-card { display: flex; flex-direction: column; gap: 4px; padding: 12px 16px; border: 1px solid #e3e5e8; border-radius: 12px; background: #f7f8f9; }
.qd-card b { font-size: 16px; }
.qd-card small { color: #606368; font-size: 14px; line-height: 1.4; }
.qd-done { margin: 4px 0 0; color: #00a862; font-size: 14px; font-weight: 800; }
/* Khung ngang thấp (điện thoại cầm ngang 844×390): logo + hình chính to hơn, gọn giữa thanh trên và 4 ô (như Người Que) */
@container (orientation: landscape) {
  .hm-stack { top: calc(max(10px, env(safe-area-inset-top)) + 58px); bottom: calc(max(10px, env(safe-area-inset-bottom)) + min(11cqw, 22cqh) + 22px); gap: 1.2cqh; }
  .hm-logo { max-height: 19cqh; max-width: 46cqw; }
  .hm-hero { max-height: 25cqh; max-width: 40cqw; }
  .hm-play { width: min(46cqw, 340px); padding: 0.8cqh 3cqw 1cqh; }
  .hm-play small { white-space: nowrap; font-size: clamp(12px, 3.2cqh, 15px); }
  .hm-play b { font-size: clamp(24px, 7cqh, 40px); }
  .hm-row { bottom: max(10px, env(safe-area-inset-bottom)); gap: 1.6cqw; }
  .hm-ic { width: min(11cqw, 22cqh, 96px); }
  .hm-ic span { font-size: clamp(12px, 3.2cqh, 14px); }
}
/* Home painting behind every screen (owner 19/11/2026, shared rule in sdk/game-light.css) */
body.mb-light { --mb-scene: url(/line98/img/home-bg.webp); --mb-scene-on: ''; --muted: #4c4f54; }
.small:disabled { opacity: .6; }
body.mb-light .hud-box.right b { color: #b87400; }
.item.locked { opacity: .6; }

/* Sheet skin "wood": small sheets take the colours of the painted home (owner 30/11/2026). */
body.mb-light { --skin-frame: #6b3d17; --skin-head: linear-gradient(#93592a, #6b3d17); --skin-head-ink: #fff3d6; --skin-line: #d8a13a;
  --skin-paper: #f4e6c6; --skin-card: #fffaf0; --skin-card-line: #d6b886; --skin-ink: #3a1d0c; --skin-muted: #765536; --skin-hover: #fff3dc; }
