/* Design tokens: copied verbatim from .ai/output/design-system/tokens.css (17/11/2026). Keep in sync until a shared tokens file ships. */
:root {
  /* ---- Màu nền + chữ (lớp áo phẳng: cổng, cửa hàng, danh sách) ---- */
  --ds-bg: #f2f4f5;
  --ds-surface: #ffffff;
  --ds-surface-2: #f7f8f9;
  --ds-line: #e3e5e8;
  --ds-line-strong: #c9ccd1;
  --ds-text: #191b1d;
  --ds-text-muted: #606368;

  /* ---- Màu hành động ---- */
  --ds-primary: #335fff;       /* Nút chính, đang chọn */
  --ds-primary-soft: #eef2ff;
  --ds-play: #00a862;          /* Nút Chơi, thành công */
  --ds-play-dark: #008f53;
  --ds-danger: #e5374f;
  --ds-warn: #ffb020;
  --ds-brand: #6c4dff;         /* Tím logo: chỉ làm điểm nhấn nhỏ */

  /* ---- Tiền tệ ---- */
  --ds-coin: #b87400;
  --ds-gem: #0a8fd0;

  /* ---- Huy chương bục xếp hạng (17/11/2026, chủ dự án yêu cầu bảng xếp hạng có bục 3 người — Cá Lớn Nuốt Cá Bé). Chữ trên huy chương dùng --ds-text ---- */
  --ds-medal-1: #f5b800;
  --ds-medal-2: #b4bcc6;
  --ds-medal-3: #d08a4e;

  /* ---- Độ hiếm ---- */
  --ds-r-common: #7d8590;
  --ds-r-rare: #335fff;
  --ds-r-epic: #8a5cff;
  --ds-r-legend: #f09a1c;
  --ds-r-mythic: #e5374f;

  /* ---- Loại chế độ chơi (vạch trái thẻ .big) ---- */
  --ds-m-online: #335fff;
  --ds-m-ai: #e5374f;
  --ds-m-local: #00a862;
  --ds-m-resume: #ffb020;
  --ds-m-practice: #8a5cff;
  --ds-m-ladder: #ff7a1a;

  /* ---- Lớp áo tranh vẽ (trang chủ game toàn màn hình, HUD trong trận) ---- */
  --ds-ink: #4a2a14;                       /* Viền nâu đậm của hình vẽ */
  --ds-glass: rgba(20, 60, 90, .78);       /* Chip xu / kim cương trên tranh */
  --ds-glass-line: rgba(255, 255, 255, .55);
  --ds-glass-soft: rgba(5, 38, 70, .22);   /* Thẻ thông tin trong trận: nhỏ, trong suốt */
  --ds-wood: #7a4a1c;
  --ds-gold: #d8a13a;
  /* Nút tròn nền kem trên tranh (18/11/2026, chủ dự án duyệt: nút cúp + icon sách của Làng Quê Đại Chiến đã dùng màu này; viền --ds-gold, icon nét --ds-cream-ink) */
  --ds-cream: #fff8e0;
  --ds-cream-ink: #a8661a;
  --ds-playpill: linear-gradient(#8aea5a, #2fae2a 60%, #238a22);
  --ds-playpill-ink: #1d6a1d;
  --ds-plus: linear-gradient(#ffd36a, #f09a1c);
  --ds-stroke-dark: #1d3a5a;               /* Viền chữ trắng trên tranh */

  /* ---- Chữ ---- */
  --ds-font: "Builder Sans", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --ds-font-display: "Arial Rounded MT Bold", system-ui, sans-serif;
  --ds-fs-xs: 12px;   /* Nhỏ nhất người chơi phải đọc */
  --ds-fs-sm: 13px;
  --ds-fs-md: 15px;
  --ds-fs-lg: 17px;
  --ds-fs-xl: 22px;
  --ds-fs-2xl: 30px;

  /* ---- Khoảng cách (bội số 4) ---- */
  --ds-s1: 4px; --ds-s2: 8px; --ds-s3: 12px; --ds-s4: 16px; --ds-s5: 24px; --ds-s6: 32px;

  /* ---- Bo góc: thang các game đang dùng thật (8 / 14 / 18 có ở gần như mọi game) ---- */
  --ds-r-xs: 6px;     /* Chip, nhãn */
  --ds-r-sm: 8px;     /* Ô nhỏ, hàng giá trong thẻ món */
  --ds-r-md: 10px;    /* Nút nhỏ */
  --ds-r-lg: 12px;    /* Thẻ, nút chế độ */
  --ds-r-xl: 14px;    /* Nút phụ kiểu cũ, thanh nổi */
  --ds-r-2xl: 16px;   /* Thẻ món */
  --ds-r-3xl: 18px;   /* Hộp thoại */
  --ds-r-pill: 999px;
  /* Cỡ lẻ (2, 3, 4, 5, 7, 9, 11, 13, 15…) làm tròn về bậc gần nhất khi sửa tới file đó */

  /* ---- Bóng ---- */
  --ds-sh-0: none;                                   /* Lớp áo phẳng: không bóng */
  --ds-sh-pop: 0 10px 30px rgba(0, 0, 0, .18);       /* Hộp thoại, bảng nổi */
  --ds-sh-art: 0 3px 6px rgba(0, 0, 0, .4);          /* Vật trên tranh */

  /* ---- Kích thước chạm ---- */
  --ds-tap: 44px;        /* Ô chạm tối thiểu trên điện thoại */
  --ds-tap-small: 32px;  /* Nút phụ vẽ nhỏ, vùng chạm vẫn nới ra 44px */

  /* ---- Lớp xếp chồng (đang dùng trong shell + game) ---- */
  --ds-z-home: 5;      /* Trang chủ tranh vẽ phủ màn */
  --ds-z-bar: 45;      /* Thanh cập nhật, thanh nổi */
  --ds-z-rotate: 70;   /* Nút quay lại khi trang bị xoay */
  --ds-z-modal: 80;
  --ds-z-toast: 90;

  /* ---- Vùng an toàn (sdk/land.js đặt lại khi trang bị xoay) ---- */
  --ds-safe-l: var(--sal, env(safe-area-inset-left));
  --ds-safe-t: var(--sat, env(safe-area-inset-top));
  --ds-safe-r: var(--sar, env(safe-area-inset-right));
  --ds-safe-b: var(--sab, env(safe-area-inset-bottom));

  /* ---- Trạng thái độ chín / đồng hồ (Quán Nhỏ Ven Đường là nguồn) ---- */
  --ds-st-wait: #ffb020;   /* Chưa xong */
  --ds-st-ok: #00a862;     /* Đúng lúc */
  --ds-st-bad: #e5374f;    /* Quá tay */

  /* ---- Phần chung bổ sung (chủ dự án duyệt 19/11/2026, sau khi chuyển 22 game cũ sang bố cục chuẩn) ---- */
  /* Tranh nền sau mọi màn (19/11/2026, game cờ): lớp màn phủ trên tranh trang chủ */
  --ds-scene-veil: rgba(242, 244, 245, .66);
  --ds-dot: 16px;            /* Chấm báo đỏ trống trên ô đáy (Nhiệm vụ có thưởng / việc chưa xong) */
  --ds-dot-c: #e5374f;       /* = --ds-danger */
  --ds-strip-h: 44px;        /* Dải lối tắt dưới CHƠI: nền --ds-glass, viền 2px --ds-glass-line, bo --ds-r-pill */
  --ds-strip-fs: 13px;       /* Chữ nút trong dải (icon vẽ 32px bên trái) */
  --ds-bar-thin: 44px;       /* Khung app khi điện thoại cầm ngang: một thanh mảnh ‹ + tên màn */
  --ds-land-low: 560px;      /* Cao ≤ mức này + cầm ngang = "ngang thấp": trang chủ chia hai cột */
  --ds-land-rotate: 820px;   /* sdk/land.js chỉ xoay trang khi cạnh ngắn màn < mức này (điện thoại) */

  /* ---- Trang chủ cổng bản 2 (chủ dự án chọn "bản 2" 29/11/2026: cổng bắt mắt hơn, ngoại lệ có chủ đích của luật "không gradient").
     Chỉ dùng trên trang chủ cổng (frontend/index.html), KHÔNG dùng trong game. ---- */
  /* --ds-portal-top (gradient thanh trên) ĐÃ BỎ 29/11/2026: chủ dự án thấy logo trên nền gradient không rõ, thanh trên về nền trắng chữ đen như cũ */
  --ds-friend-av: 52px;   /* Hàng bạn bè ngay dưới lời chào trên trang chủ cổng (29/11/2026): avatar tròn */
  --ds-portal-gift: linear-gradient(135deg, #ffb347, #ff6a3d); /* Ô icon quà trên dải "Quà hôm nay" */
  --ds-streak-on: #ff8a3d;   /* Vạch ngày đã nhận của chuỗi 7 ngày (vạch chưa nhận = --ds-line) */
  --ds-live: #2fe07a;        /* Chấm "đang chơi" trên thẻ game (nền chip rgba(0,0,0,.55), chữ trắng) */
  --ds-row-card: 140px;      /* Thẻ vuông trong hàng cuộn ngang */
  --ds-row-big: 228px;       /* Thẻ to (có video) đầu hàng "Đang hot" */

  /* ---- Chuyển động ---- */
  --ds-t-fast: .12s;
  --ds-t-mid: .25s;
  --ds-press: scale(.96);
}
/* ================= Ghép Hình — MonBlock (base copied from Dò Mìn) ================= */
:root {
  --bg: #0d1117;
  --panel: #151c26;
  --panel-2: #1b2431;
  --line: #2b3646;
  --txt: #e8eef6;
  --muted: #93a3b8;
  --accent: #ffcf5a;
}

* { 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: 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ủ ---------- */
.xpbar { height: 6px; border-radius: var(--ds-r-pill); background: var(--panel-2); overflow: hidden; }
.xpbar i { display: block; height: 100%; width: 0; background: #4f86ff; border-radius: var(--ds-r-pill); }

.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-daily.done small { color: #00a862; }


/* ---------- 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: var(--ds-gem); }
.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: 1px solid var(--ds-line); border-radius: 16px; background: var(--panel); text-align: center; }
.item.locked .pv, .item.locked .pay { opacity: .55; }
.item b { font-size: 14px; }
.item .rar { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px; }
.item .act { padding: 2px 8px; border-radius: 6px; font-size: 13px; font-weight: 800; color: var(--muted); }
.gem { color: var(--ds-gem); }
.buyprev { display: flex; justify-content: center; margin: 4px 0 8px; }

/* ---------- xếp hạng ---------- */
.tabs { display: flex; gap: 6px; margin: 6px 0 10px; }
.tabs button { flex: 1; min-height: var(--ds-tap); padding: 10px 6px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); font-weight: 800; font-size: 14px; }
.rank .row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.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: #b87400; }

.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); }
.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; font-variant-numeric: tabular-nums; }
.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 { min-height: var(--ds-tap); padding: 10px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2); font-weight: 800; }
.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; }
.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; font-weight: 800; }

h2 { font-size: 16px; margin: 16px 0 8px; }
.big-resume { --bar: #ffb020; }
.big-play { --bar: #00a862; }
.big-daily.done small { color: #00a862; }
.item { position: relative; }
.item .pay { margin-top: auto; display: flex; flex-direction: column; align-items: center; gap: 2px; width: 100%; }
.item .pr { font-size: 13px; font-weight: 800; color: #191b1d; }
.item .pr.on { color: #00a862; }
.item .pr.g { color: var(--ds-gem); }
.item .pr.gh { color: var(--muted); font-weight: 600; font-size: 12px; }
.item.poor .pay { opacity: .5; }

/* ---------- hộp kết quả ---------- */
.dialog.win { text-align: center; }
.dialog.win .wm { display: block; width: 104px; height: 104px; margin: -4px auto 0; animation: cheer 1.4s ease-in-out infinite; }
@keyframes cheer { 50% { transform: translateY(-6px) rotate(3deg); } }
.dialog.win h3 { margin: 4px 0 2px; font-size: 30px; font-weight: 900; color: var(--ds-play); }
.dialog.win .ans { margin: 0 0 8px; font-size: 22px; font-weight: 900; color: var(--ds-text); }
.wstars { display: flex; justify-content: center; gap: 6px; margin: 4px 0 6px; }
.wstars .mbi { width: 44px; height: 44px; opacity: .25; filter: grayscale(1); }
.wstars .mbi.on { opacity: 1; filter: none; animation: starIn .5s ease backwards; }
.wstars .mbi.on:nth-child(2) { animation-delay: .15s; } .wstars .mbi.on:nth-child(3) { animation-delay: .3s; }
@keyframes starIn { from { transform: scale(0) rotate(-40deg); } }
.wchips { display: flex; justify-content: center; gap: 8px; margin: 2px 0 6px; flex-wrap: wrap; }
.wc { display: flex; align-items: center; gap: 4px; padding: 5px 11px 5px 7px; border-radius: 999px; background: var(--ds-surface); border: 1px solid var(--ds-line-strong); font-size: 17px; color: var(--ds-text); }
.wc i { font-style: normal; font-size: 20px; line-height: 1; }
.wc i .mb-coin { width: 22px; height: 22px; vertical-align: -4px; }
.wc .mbi { width: 22px; height: 22px; }
.wc b { font-weight: 900; }
.wc small { font-size: 12px; font-weight: 800; color: var(--ds-text-muted); }
.wtags { display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; margin-bottom: 4px; }
.wtags span { padding: 3px 10px; border-radius: 999px; background: var(--ds-primary-soft); color: var(--ds-primary); font-size: 12px; font-weight: 800; }
.dialog .evtag, .item .evtag { font-size: 12px; font-weight: 800; padding: 2px 8px; border-radius: 999px; background: var(--ds-primary-soft); color: var(--ds-primary); }
.dialog.win .more { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; margin-top: 16px; padding: 14px; border: 0; border-radius: 999px;
  background: linear-gradient(#7ed957, #2f9e2a); color: #fff; font-size: 20px; font-weight: 900; box-shadow: inset 0 3px 0 rgba(255, 255, 255, .45), 0 5px 0 #1d6b18; text-shadow: 0 2px 0 #1d6b18; }
.dialog.win .more:active { transform: translateY(3px); box-shadow: inset 0 3px 0 rgba(255, 255, 255, .45), 0 2px 0 #1d6b18; }
.dialog.win .more .mbi { width: 30px; height: 30px; flex: none; }
.wbtns { display: flex; gap: 8px; margin-top: 14px; }
.dialog.win .wbtns .more { flex: 1; margin-top: 0; }
.wshare { flex: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; width: 76px; padding: 6px 4px; border: 0; border-radius: 18px;
  background: linear-gradient(#5aa8ff, #2f6fe0); color: #fff; font-size: 13px; font-weight: 900; box-shadow: inset 0 3px 0 rgba(255, 255, 255, .4), 0 5px 0 #1a4aa8; }
.wshare:active { transform: translateY(3px); box-shadow: inset 0 3px 0 rgba(255, 255, 255, .4), 0 2px 0 #1a4aa8; }
.wshare .mbi { width: 26px; height: 26px; }
.wshare .mbi * { stroke: #fff; }
.modal:has(.dialog.win) { place-items: safe center; overflow-y: auto; }
.dialog.win { background: var(--ds-surface); }
.dialog.win .wsub { margin: 0 0 6px; font-size: 14px; color: var(--ds-text-muted); font-weight: 700; }
.dialog .buyprev { display: flex; justify-content: center; margin: 6px 0 10px; }
.dialog .buyprev .boostpv { width: 100px; height: 100px; }
.dialog .stuck-tip { margin: 6px 0; color: var(--ds-text-muted); font-weight: 700; }


/* ===== 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: #2a1a10; 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: var(--ds-surface); border: 3px solid var(--ds-line); color: var(--ds-text); font: 700 28px/1 system-ui; padding-bottom: 4px; }
.hm-gear { right: max(10px, env(safe-area-inset-right)); border-radius: var(--ds-r-lg); 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 var(--ds-gold); background: var(--ds-cream); 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: var(--ds-wood); border: 2px solid var(--ds-gold); 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: var(--ds-glass); border: 2px solid var(--ds-glass-line); }
.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: var(--ds-playpill); border: 4px solid #e8f7ff; 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 var(--ds-playpill-ink); 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 var(--ds-playpill-ink); 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 var(--ds-stroke-dark); 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: var(--ds-r-pill); 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 .dropsvg { width: 78%; height: 78%; display: block; }
#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: 50cqh; max-width: 30cqw; }
  .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); }
}

/* Painted art corner behind every screen (design system "Tranh nền sau mọi màn") */
:root { --ts: 64px; }
body.mb-light { --mb-scene: url(/ghephinh/img/home-bg.webp); --mb-scene-on: ''; }
#btnSound .mbi { width: 22px; height: 22px; display: block; }
.big-daily .mbi { width: 22px; height: 22px; }

/* ---------- dải lối tắt dưới CHƠI (design system "Phần chung bổ sung" 1) ---------- */
/* ===== Design system: sub-screen header + result buttons (22/11/2026) ===== */
body.mb-light.gh-sub { color: var(--ds-text); --mb-scene-veil: var(--ds-scene-veil, rgba(242, 244, 245, .66)); }
.sc-bar { position: fixed; left: 0; right: 0; top: 0; z-index: 50; display: flex; align-items: center; gap: var(--ds-s3); min-height: 56px; padding: var(--ds-s2) max(var(--ds-s3), var(--ds-safe-r)) var(--ds-s2) max(var(--ds-s3), var(--ds-safe-l)); padding-top: max(var(--ds-s2), var(--ds-safe-t)); background: var(--ds-surface); border-bottom: 1px solid var(--ds-line); color: var(--ds-text); }
.sc-bar.hidden { display: none !important; }
.sc-back { flex: none; width: var(--ds-tap); height: var(--ds-tap); display: grid; place-items: center; padding: 0 0 4px; border: 1px solid var(--ds-line); border-radius: 50%; background: var(--ds-surface); color: var(--ds-text); font: 700 28px/1 system-ui; }
.sc-back:active { transform: var(--ds-press); }
.sc-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--ds-fs-xl); font-weight: 800; }
.sc-chips { display: flex; gap: var(--ds-s2); }
.sc-chips.hidden { display: none; }
.sc-chip { display: flex; align-items: center; gap: var(--ds-s1); height: 34px; padding: 0 var(--ds-s3) 0 var(--ds-s2); border-radius: var(--ds-r-pill); background: var(--ds-surface-2); border: 1px solid var(--ds-line); font-size: var(--ds-fs-lg); }
.sc-chip img { width: 22px; height: auto; }
.sc-chip b { color: var(--ds-coin); font-weight: 800; }
.sc-chip.gem-chip b { color: var(--ds-gem); }
body.gh-sub .wrap { padding-top: calc(56px + max(var(--ds-s2), var(--ds-safe-t)) + var(--ds-s3)); padding-bottom: calc(var(--ds-s6) + var(--ds-safe-b)); padding-left: max(14px, var(--ds-safe-l)); padding-right: max(14px, var(--ds-safe-r)); }

/* Result boxes: Về · Chơi lại · main button last on the right */
.dialog .wbtns { display: flex; gap: var(--ds-s2); margin-top: var(--ds-s3); }
.dialog .wbtns button { min-height: var(--ds-tap); border-radius: var(--ds-r-pill); font-size: var(--ds-fs-md); font-weight: 800; }
.dialog .wbtns .wsec { flex: none; padding: 0 var(--ds-s4); border: 1px solid var(--ds-line-strong); background: var(--ds-surface); color: var(--ds-text); }
.dialog .wbtns .more, .dialog.win .wbtns .more { flex: 1; display: flex; align-items: center; justify-content: center; margin: 0; padding: 0 var(--ds-s3); border: 0; background: var(--ds-play); color: #fff; box-shadow: none; text-shadow: none; font-size: var(--ds-fs-lg); }
.dialog .wbtns .more:disabled { opacity: .5; }
.dialog .wbtns .more:active, .dialog .wbtns .wsec:active { transform: var(--ds-press); box-shadow: none; }
.dialog .wshare { display: flex; flex-direction: row; align-items: center; justify-content: center; gap: var(--ds-s2); width: 100%; min-height: var(--ds-tap); margin-top: var(--ds-s2); padding: 0 var(--ds-s3); border: 1px solid var(--ds-primary); border-radius: var(--ds-r-pill); background: var(--ds-surface); color: var(--ds-primary); font-size: var(--ds-fs-md); font-weight: 800; box-shadow: none; }
.dialog .wshare:active { transform: var(--ds-press); box-shadow: none; }
.dialog .wshare:disabled { opacity: .5; }
.dialog .wshare .mbi { width: 22px; height: 22px; }
.dialog .wshare .mbi * { stroke: var(--ds-primary); }
.dialog .pz button { border-color: var(--ds-line-strong); border-radius: var(--ds-r-md, 12px); }
.dialog .pz button.pri { border-color: var(--ds-play); background: var(--ds-play); }
@media (orientation: landscape) and (max-height: 560px) {
  .dialog .wshare { margin-top: 4px; }
  .dialog .wbtns { margin-top: 6px; }
}

/* 2. Dialog radius + shadow from tokens (beats game-light.css) */
body.mb-light .dialog { border-radius: var(--ds-r-3xl, 18px); box-shadow: var(--ds-sh-pop, 0 10px 30px rgba(0, 0, 0, .18)); }
/* 3. Result box colours from tokens */
body.mb-light .dialog.win h3 { color: var(--ds-play); }
body.mb-light .dialog.lose h3 { color: var(--ds-danger); }
body.mb-light .dialog.win .wsub, body.mb-light .dialog.lose .why { color: var(--ds-text-muted); }
/* 6. Shop: lock reason is a corner label */
.item .lock { position: absolute; top: 6px; right: 6px; z-index: 2; padding: 2px 8px; border-radius: var(--ds-r-md); background: var(--ds-text); color: #fff; font-size: var(--ds-fs-xs); font-weight: 800; }
.item .lock .mbi, .item .lock img { width: 14px; height: 14px; vertical-align: -2px; }
/* Landscape: thin 44 px sub-screen bar */
@media (orientation: landscape) and (max-height: 560px) {
  .sc-bar { min-height: var(--ds-bar-thin, 44px); padding-top: max(2px, var(--ds-safe-t)); padding-bottom: 2px; }
  .sc-title { font-size: var(--ds-fs-lg); }
  body.gh-sub .wrap { padding-top: calc(var(--ds-bar-thin, 44px) + max(2px, var(--ds-safe-t)) + var(--ds-s3)); }
}

/* ================= Bé Tô Màu — màn tô (tờ giấy vuông, hàng dụng cụ, hộp màu) ================= */
.pv { position: relative; display: flex; justify-content: center; align-items: center; width: 100%; min-height: 96px; pointer-events: none; }
.pv .dots { flex-wrap: wrap; justify-content: center; max-width: 120px; gap: 4px; }
.pv .dots i { width: 22px; height: 22px; }
.dialog.win .art { position: relative; width: min(230px, 62vw); margin: 0 auto 4px; animation: dance 1.2s ease-in-out infinite; }
.dialog.win .art .frame { padding-top: 6px; }
@keyframes dance { 0%, 100% { transform: rotate(-4deg) translateY(0); } 25% { transform: rotate(3deg) translateY(-8px) scale(1.03); } 50% { transform: rotate(-2deg) translateY(0); } 75% { transform: rotate(4deg) translateY(-6px) scale(1.02); } }
.confetti { position: fixed; top: -20px; z-index: 79; width: 10px; height: 14px; pointer-events: none; animation: fall var(--d, 2.4s) linear forwards; }
@keyframes fall { to { transform: translate(var(--dx, 0), 110vh) rotate(var(--r, 540deg)); } }
/* Phone held sideways: picture on the left, title / rewards / buttons on the right, all in one screen. */
@media (orientation: landscape) and (max-height: 560px) {
  .dialog.win { width: min(640px, 100%); display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 18px; align-items: center; }
  .dialog.win > * { grid-column: 2; }
  .dialog.win > .art { grid-column: 1; grid-row: 1 / span 7; width: min(220px, 56vh); margin: 0; }
  .dialog.win .wshare { margin-top: 6px; }
}
/* Crayon tiles sit straight on the scene: drop the white card that game-light.css gives every .tools button. */
body.mb-light .item { border-radius: var(--ds-r-2xl, 16px); }
.toast { background: var(--ds-text); color: #fff; }


/* ================= Ghép Hình — mẫu A "bàn gỗ ấm cúng" (chủ dự án chọn 30/11/2026) ================= */
.hm-av .av-def { display: grid; place-items: center; width: 80%; height: 80%; }
.hm-av .av-def .mbi { width: 100%; height: 100%; }
#scHome .hm-top, #scHome .hm-back { z-index: 2; }

/* ---------- bộ tranh ---------- */
#albumList { display: flex; flex-direction: column; gap: var(--ds-s3); }
.album { padding: var(--ds-s3); border: 1px solid var(--ds-line); border-radius: var(--ds-r-2xl, 16px); background: var(--ds-surface); }
.album-h { display: flex; flex-direction: column; gap: 2px; margin-bottom: var(--ds-s2); }
.album-h b { font-size: var(--ds-fs-lg); }
.album-h small { color: var(--ds-text-muted); font-size: var(--ds-fs-sm); }
.picgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--ds-s2); }
@media (min-width: 600px) { .picgrid { grid-template-columns: repeat(6, 1fr); } }
body.mb-light #albumList .pic { position: relative; display: flex; flex-direction: column; gap: 4px; padding: 0 0 6px; border: 1px solid var(--ds-line); border-radius: var(--ds-r-lg, 12px); background: var(--ds-surface-2); overflow: hidden; color: var(--ds-text); text-align: center; }
.pic img { display: block; width: 100%; height: auto; aspect-ratio: 1; object-fit: cover; }
.pic small { padding: 0 4px; font-size: var(--ds-fs-xs); font-weight: 700; line-height: 1.25; }
.pic .pbest { position: absolute; top: 6px; left: 6px; padding: 2px 8px; border-radius: var(--ds-r-pill); background: var(--ds-text); color: #fff; font-size: var(--ds-fs-xs); font-weight: 800; }
.pic .st { position: absolute; top: 36px; left: 7px; display: flex; font-size: 14px; line-height: 1; }
.pic .st i { font-style: normal; color: rgba(255, 255, 255, .7); -webkit-text-stroke: 2px #4a2a14; paint-order: stroke fill; }
.pic .st i.on { color: #ffd24a; }
body.mb-light #albumList .pic.next { border-color: var(--ds-play); box-shadow: 0 0 0 3px rgba(0, 168, 98, .3); }
body.mb-light #albumList .pic.lock img { filter: grayscale(.85) brightness(.75); }
.pic .plock { position: absolute; left: 50%; top: 38%; transform: translate(-50%, -50%); display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: rgba(25, 27, 29, .72); }
.pic .plock .mbi { width: 22px; height: 22px; }
.pic:active { transform: var(--ds-press); }

/* ---------- chọn số mảnh (hộp nổi) ---------- */
#scSize { display: flex; flex-direction: column; gap: var(--ds-s3); }
#scSize > * + *, #scQuests > * + * { margin-top: var(--ds-s3); }
.sz-pic { display: flex; align-items: center; gap: var(--ds-s3); }
.sz-pic img { flex: none; width: 72px; height: 72px; border-radius: var(--ds-r-lg, 12px); object-fit: cover; border: 1px solid var(--ds-line); }
.sz-pic div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sz-pic b { font-size: var(--ds-fs-lg); }
.sz-pic small { color: var(--ds-text-muted); font-size: var(--ds-fs-sm); }
.sz-resume { display: flex; align-items: center; justify-content: center; gap: var(--ds-s2); width: 100%; min-height: 52px; margin-bottom: var(--ds-s3); border: 0; border-radius: var(--ds-r-lg); background: var(--ds-play); color: #fff; font: 800 var(--ds-fs-md)/1.2 var(--ds-font); cursor: pointer; }
.sz-resume.hidden { display: none; }
.sz-resume .ic { display: grid; place-items: center; width: 28px; height: 28px; }
.sz-resume .ic .mbi { width: 26px; height: 26px; }
.picgrid .pic .psave { align-self: center; padding: 0 var(--ds-s2); white-space: nowrap; max-width: 100%; border-radius: var(--ds-r-pill); background: var(--ds-play); color: #fff; font: 800 var(--ds-fs-xs)/1.5 var(--ds-font); overflow: hidden; text-overflow: ellipsis; }
.sz-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--ds-s2); }
body.mb-light .sz-grid .sz { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 60px; padding: 6px 2px; border: 1px solid var(--ds-line-strong); border-radius: var(--ds-r-lg, 12px); background: var(--ds-surface); color: var(--ds-text); }
.sz b { font-size: var(--ds-fs-xl); font-weight: 900; line-height: 1.05; }
.sz small { color: var(--ds-text-muted); font-size: var(--ds-fs-xs); font-weight: 700; }
body.mb-light .sz-grid .sz.on { border: 2px solid var(--ds-primary); background: var(--ds-primary-soft); }
.sz.got::after { content: '✓'; position: absolute; top: 2px; left: 6px; color: var(--ds-play); font-weight: 900; font-size: 13px; }
.sz .szgem { position: absolute; top: -6px; right: -4px; font-style: normal; font-size: 13px; }
.sz:active { transform: var(--ds-press); }
#scSize .note { margin: var(--ds-s3) 0 0; }

/* ---------- màn chơi ---------- */
#scPlay { position: fixed; inset: 0; z-index: 5; padding: 0; max-width: none; animation: none; }
#scPlay .field { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; overflow: hidden;
  background: linear-gradient(rgba(30, 18, 8, .35), rgba(30, 18, 8, .55)), url(../img/home-bg.webp) center / cover, #2a1a10; }
#scPlay .top { position: relative; z-index: 3; flex: none; display: grid; grid-template-columns: 46px auto minmax(74px, 1fr) auto 46px; align-items: center; gap: 6px; width: 100%; max-width: 640px;
  padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) 4px max(10px, env(safe-area-inset-left)); }
.wbtn { position: relative; display: flex; align-items: center; justify-content: center; min-width: var(--ds-tap); min-height: var(--ds-tap); padding: 0; border: 2px solid #8a5a2a; border-radius: 50%;
  background: linear-gradient(#f0d3a0, #cfa066); box-shadow: 0 3px 0 #7a4a1c, inset 0 1px 0 rgba(255, 245, 225, .7); color: #4a2a14; }
.wbtn.round { width: 46px; height: 46px; }
.wbtn.round svg { width: 22px; height: 22px; fill: none; stroke: #4a2a14; stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; }
.wbtn:active { transform: translateY(2px); box-shadow: 0 1px 0 #7a4a1c; }
body.mb-light #scPlay .wbtn, body.mb-light #scPlay .wbtn:hover { background: linear-gradient(#f0d3a0, #cfa066); border-color: #8a5a2a; color: #4a2a14; }
.chip { display: flex; align-items: center; gap: 3px; height: 36px; padding: 0 10px 0 4px; border-radius: 18px; background: var(--ds-glass, rgba(20, 60, 90, .78)); border: 2px solid var(--ds-glass-line, rgba(255, 255, 255, .55)); }
.chip img, .chip svg, .chip .ic { width: 24px; height: 24px; flex: none; object-fit: contain; }
.chip .ic .mbi { width: 24px; height: 24px; display: block; }
.chip b { color: #fff; font: 900 16px/1 system-ui, sans-serif; font-variant-numeric: tabular-nums; }
.lvcard { min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 3px 6px; border-radius: 12px; background: var(--ds-glass-soft, rgba(5, 38, 70, .22)); border: 1px solid rgba(255, 255, 255, .35); }
.lvcard b, .lvcard small { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, .6); }
.lvcard b { font: 900 14px/1.2 system-ui, sans-serif; }
.lvcard small { font: 800 12px/1.2 system-ui, sans-serif; opacity: .92; }

.stage { position: relative; z-index: 2; flex: 1 1 auto; min-height: 0; width: 100%; display: grid; place-items: center; overflow: hidden; }
/* Desk mat under the board (shop item "Thảm bàn"). */
.mat { padding: 14px; border-radius: var(--ds-r-3xl, 18px); background: #2f5a3a center / cover; box-shadow: inset 0 0 0 2px rgba(0, 0, 0, .25), inset 0 0 24px rgba(0, 0, 0, .35), 0 10px 22px rgba(0, 0, 0, .45); }
/* Board frame (shop item "Khung tranh"). */
.frame { position: relative; padding: 12px; border-radius: var(--ds-r-xl, 14px); box-shadow: inset 0 0 0 2px rgba(0, 0, 0, .35), 0 6px 14px rgba(0, 0, 0, .45); }
.fr-go { background: linear-gradient(135deg, #a8743f, #6a3f1a 55%, #8f5a2c); }
.fr-tre { background: repeating-linear-gradient(90deg, #e9c46a 0 18px, #d4a843 18px 20px), #e2b856; box-shadow: inset 0 0 0 2px #9a7420, inset 0 0 0 5px #f6dc8e, 0 6px 14px rgba(0, 0, 0, .45); }
.fr-sonmai { background: linear-gradient(135deg, #b3261e, #7a120e 60%, #a01d16); box-shadow: inset 0 0 0 2px #5a0d0a, inset 0 0 0 5px #e0b44a, 0 6px 14px rgba(0, 0, 0, .45); }
.fr-bac { background: linear-gradient(135deg, #f4f6f8, #a9b1ba 45%, #e4e8ec 60%, #8c949e); box-shadow: inset 0 0 0 2px #6b737c, 0 6px 14px rgba(0, 0, 0, .45); }
.fr-vang { background: linear-gradient(135deg, #fff0a8, #d8a13a 40%, #fbe38a 60%, #a8741c); box-shadow: inset 0 0 0 2px #7a5212, inset 0 0 0 6px #fff3c4, inset 0 0 0 8px #b8862a, 0 6px 14px rgba(0, 0, 0, .45); }
.fr-hoadao { background: radial-gradient(circle at 10px 10px, #fff 0 2px, #ff9fbf 3px 5px, transparent 6px) 0 0 / 40px 40px, linear-gradient(135deg, #ffd3e0, #f28aac 55%, #ffc2d4); box-shadow: inset 0 0 0 2px #b8426c, 0 6px 14px rgba(0, 0, 0, .45); }
.frame.shine { animation: shine 1.2s ease; }
@keyframes shine { 30% { box-shadow: 0 0 0 4px #ffe36a, 0 0 40px 12px rgba(255, 220, 80, .8); transform: scale(1.02); } }
.board { position: relative; border-radius: var(--ds-r-xs); overflow: hidden; background: #1c140c; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.board canvas { display: block; }
.board .peek { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; animation: peekIn .2s ease; pointer-events: none; }
@keyframes peekIn { from { opacity: 0; } }

/* Tray of loose pieces on a wooden strip + the three buttons. */
.dock { position: relative; z-index: 3; flex: none; width: 100%; display: flex; flex-direction: column; align-items: center;
  background: linear-gradient(#8a5a2c, #6a4120); border-top: 3px solid #b07a42; box-shadow: 0 -6px 14px rgba(0, 0, 0, .35); padding-bottom: max(8px, env(safe-area-inset-bottom)); }
.tray { display: flex; align-items: center; width: 100%; max-width: 760px; height: 118px; padding: 0 12px; overflow-x: auto; overflow-y: hidden; touch-action: pan-x; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.tray::-webkit-scrollbar { display: none; }
.tray .tload { margin: 0 auto; color: #f6e6c8; font-size: var(--ds-fs-sm); font-weight: 700; }
body.mb-light .tray .pc { flex: none; position: relative; margin: 0 -6px; padding: 0; border: 0; border-radius: 0; background: none; box-shadow: none; transform: rotate(var(--rot, 0deg)); touch-action: pan-x; }
.pc canvas { display: block; filter: drop-shadow(0 3px 3px rgba(0, 0, 0, .45)); pointer-events: none; }
.pc.sel { z-index: 1; }
.pc.sel canvas { filter: drop-shadow(0 0 3px #ffe36a) drop-shadow(0 0 6px #ffd24a) drop-shadow(0 3px 3px rgba(0, 0, 0, .45)); }
body.mb-light .tray .pc.sel { transform: rotate(0deg) translateY(-6px) scale(1.06); }
.pc.lifted { opacity: .25; }
.pc.hinted canvas { animation: hintGlow .45s ease-in-out 2; }
@keyframes hintGlow { 50% { filter: drop-shadow(0 0 6px #ffe36a) drop-shadow(0 0 12px #ffd24a); } }
.pc.nudge { animation: nudge .3s ease; }
@keyframes nudge { 25% { translate: -4px 0; } 75% { translate: 4px 0; } }
.acts { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 2px 12px 0; }
body.mb-light #scPlay .tbtn { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; min-width: 76px; min-height: 52px; padding: 4px 10px;
  border: 2px solid #f3dcb0; border-radius: var(--ds-r-xl, 14px); background: linear-gradient(#f6e2bb, #d9b47a); box-shadow: 0 3px 0 #5a3616; color: #4a2a14; }
.tbtn .ic, .tbtn .ic .mbi { display: block; width: 26px; height: 26px; }
.tbtn small { font-size: 12px; font-weight: 900; line-height: 1.1; }
body.mb-light #scPlay .tbtn.on { border-color: #fff5cf; background: linear-gradient(#8aea5a, #2fae2a 60%, #238a22); color: #fff; }
body.mb-light #scPlay .hintbtn { min-width: 92px; min-height: 58px; border-color: #fff5cf; background: linear-gradient(#ffe27a, #f2b52a 60%, #d48f12); }
.hintbtn .cnt { position: absolute; top: -8px; right: -8px; min-width: 22px; height: 22px; padding: 0 5px; border-radius: var(--ds-r-pill); background: var(--ds-dot-c, #e5374f); border: 2px solid #fff3d6;
  color: #fff; font: 900 12px/18px system-ui, sans-serif; font-style: normal; text-align: center; }
.tbtn:active { transform: translateY(2px); }

/* Piece being dragged: fixed layer moved with transform only. */
.drag { position: fixed; left: 0; top: 0; z-index: 60; pointer-events: none; will-change: transform; transform-origin: 50% 50%; }
.drag canvas { display: block; filter: drop-shadow(0 8px 8px rgba(0, 0, 0, .5)); }
.drag.back { transition: transform .18s ease-in; }

/* Phone held sideways: info + buttons on the left, board in the middle, tray as a column on the right. */
@media (orientation: landscape) and (max-height: 560px) {
  #scPlay .field { display: grid; grid-template-columns: min(220px, 28vw) minmax(0, 1fr) min(132px, 17vw); grid-template-rows: auto auto minmax(0, 1fr) auto;
    grid-template-areas: 'back card pause' 'chips stage tray' '. stage tray' 'acts stage tray'; align-items: center; column-gap: 8px; row-gap: 8px;
    padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); }
  #scPlay .top, #scPlay .dock { display: contents; }
  #btnQuit { grid-area: back; justify-self: start; } #btnPause { grid-area: pause; justify-self: end; }
  .lvcard { grid-area: card; justify-self: center; max-width: 100%; }
  #scPlay .top .chip { grid-area: chips; justify-self: start; } #scPlay .top .chip:nth-of-type(2) { justify-self: end; }
  .stage { grid-area: stage; height: 100%; }
  .tray { grid-area: tray; flex-direction: column; height: 100%; width: 100%; padding: 8px 0; overflow-x: hidden; overflow-y: auto; touch-action: pan-y; border-radius: var(--ds-r-2xl, 16px);
    background: linear-gradient(90deg, #8a5a2c, #6a4120); border: 3px solid #b07a42; }
  body.mb-light .tray .pc { margin: -6px 0; touch-action: pan-y; }
  .acts { grid-area: acts; padding: 0; gap: 6px; }
  body.mb-light #scPlay .tbtn { min-width: 0; flex: 1; padding: 4px 4px; }
  .mat { padding: 8px; } .frame { padding: 8px; }
  .dialog.win { width: min(640px, 100%); display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 18px; align-items: center; }
  .dialog.win > * { grid-column: 2; }
  .dialog.win > .wm { grid-column: 1; grid-row: 1 / span 8; width: min(190px, 44vh); max-height: none; margin: 0; }
  .toast { bottom: auto; top: max(12px, env(safe-area-inset-top)); }
}

/* ---------- ô xem thử cửa hàng: thảm + khung + góc tranh đang ghép, cùng lớp với màn chơi ---------- */
.pv { position: relative; display: flex; justify-content: center; align-items: center; width: 100%; min-height: 96px; pointer-events: none; }
.mini { display: grid; place-items: center; width: 104px; height: 104px; padding: 10px; border-radius: var(--ds-r-lg, 12px); background: #2f5a3a center / cover; box-shadow: inset 0 0 12px rgba(0, 0, 0, .35); }
.mini.lg { width: 160px; height: 160px; padding: 16px; }
.mini .frame { padding: 7px; border-radius: var(--ds-r-sm, 8px); }
.mini.lg .frame { padding: 10px; }
.mini .mboard { position: relative; display: block; width: 56px; height: 56px; overflow: hidden; border-radius: var(--ds-r-xs); }
.mini.lg .mboard { width: 92px; height: 92px; }
.mini .mboard img { display: block; width: 100%; height: 100%; object-fit: cover; }
.mini .hole { position: absolute; right: 0; bottom: 0; width: 40%; height: 40%; background: rgba(28, 20, 12, .78); border-top-left-radius: 30% 30%; }
.bst { display: flex; flex-direction: column; align-items: center; justify-content: center; width: 64px; height: 72px; border-radius: var(--ds-r-lg, 12px); background: #fff7e6; border: 2px solid #d8a13a; }
.bst .mbi { width: 32px; height: 32px; }
.bst b { font-size: 15px; color: var(--ds-ink); }
.dialog.win .wm { display: block; width: 130px; height: 130px; object-fit: cover; margin: -4px auto 6px; border-radius: var(--ds-r-lg, 12px); border: 4px solid #d8a13a; animation: none; }
.dialog.win .ans { font-size: 17px; margin: 0 0 4px; }

.toast { pointer-events: none; }
@media (max-width: 370px) { .hm-bar { min-width: 0; } .hm-top { gap: 6px; } }
@media (max-width: 400px) and (orientation: portrait) {
  #scPlay .top { grid-template-columns: 44px auto minmax(60px, 1fr) auto 44px; gap: 4px; padding-left: max(8px, env(safe-area-inset-left)); padding-right: max(8px, env(safe-area-inset-right)); }
  .lvcard { padding: 3px 4px; }
  .lvcard b { font-size: 13px; letter-spacing: -.2px; }
  #scPlay .wbtn.round { width: 44px; height: 44px; }
  #scPlay .top .chip { padding: 0 8px 0 3px; }
  #scPlay .top .chip svg, #scPlay .top .chip .ic { width: 20px; height: 20px; }
  #scPlay .top .chip b { font-size: 14px; }
}
.dlg-btns { flex-wrap: nowrap; }
.dlg-btns button { padding: 10px 12px; white-space: nowrap; }
.dlg-btns button:first-child { flex: none; }
.dialog .pz { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.dialog .pz button { min-height: var(--ds-tap, 44px); padding: 10px 14px; border: 1px solid var(--ds-line-strong, #c9ccd1); border-radius: var(--ds-r-md, 12px); background: #fff; color: var(--ds-text, #191b1d); font-size: 16px; font-weight: 800; }
.dialog .pz button.pri { border-color: var(--ds-play, #00a862); background: var(--ds-play, #00a862); color: #fff; }
body { font-family: var(--ds-font, "Builder Sans", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif); }

/* ================= Trang chủ bản 2 — đúng ảnh mẫu chủ dự án 30/11/2026 (ngoại lệ đã duyệt trong design system):
   nút gỗ tròn, một thanh kem gom avatar + xu + 💎, thảm nỉ có tranh ghép dở, 4 ô kem có chữ ================= */
#scHome .gh-wood, #scHome .hm-back { width: 48px; height: 48px; border-radius: 50%; padding: 0; background: radial-gradient(circle at 35% 30%, #b8834c, #8a5a2c 55%, #6a401c); border: 3px solid var(--ds-ink); color: #fff3d6; box-shadow: inset 0 2px 0 rgba(255, 230, 190, .45), 0 4px 0 #3a200e, 0 6px 8px rgba(0, 0, 0, .35); font: inherit; }
#scHome .gh-wood svg, #scHome .hm-back svg { width: 26px; height: 26px; display: block; }
#scHome .hm-back svg { fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
#scHome .hm-book { top: calc(max(10px, env(safe-area-inset-top)) + 58px); }
#scHome .gh-wood:active, #scHome .hm-back:active { transform: translateY(2px); box-shadow: inset 0 2px 0 rgba(255, 230, 190, .45), 0 2px 0 #3a200e; }
#scHome .gh-pill { left: calc(max(10px, env(safe-area-inset-left)) + 58px); right: calc(max(10px, env(safe-area-inset-right)) + 58px); height: 48px; padding: 0 8px 0 3px; gap: 6px; border-radius: var(--ds-r-pill); background: linear-gradient(#fffaf0, #f3e3c3); border: 3px solid #c99a5a; box-shadow: 0 4px 0 #8a5a2c, 0 6px 8px rgba(0, 0, 0, .3); }
#scHome .gh-pill .hm-av { width: 46px; height: 46px; margin: -4px 0 0 -6px; }
#scHome .gh-pill .hm-bar { flex: 1 1 0; min-width: 0; height: 32px; padding: 0 8px 0 3px; background: rgba(138, 90, 44, .14); border: 0; border-radius: var(--ds-r-pill); }
#scHome .gh-pill .hm-bar b { color: var(--ds-ink) !important; font-size: 15px; text-align: left; white-space: nowrap; }
#scHome .gh-pill .hm-coin { flex-grow: 1.4; }
@container (max-width: 375px) { #scHome .gh-pill { gap: 4px; padding-right: 5px; } #scHome .gh-pill .hm-bar { padding-right: 4px; gap: 2px; } #scHome .gh-pill .hm-bar img { width: 20px; } #scHome .gh-pill .hm-bar b { font-size: 14px; } }
#scHome .hm-stack { top: calc(max(10px, env(safe-area-inset-top)) + 70px); bottom: calc(max(14px, env(safe-area-inset-bottom)) + min(25cqw, 112px) + 18px); justify-content: flex-start; gap: 0; padding: 0 4cqw; }
#scHome .hm-logo { position: relative; z-index: 2; flex: none; max-height: 22cqh; max-width: 64cqw; margin-bottom: -6cqh; }
#scHome .hm-mat { position: relative; flex: 0 1 auto; min-height: 0; width: min(86cqw, 520px); display: flex; flex-direction: column; align-items: center; gap: 1.2cqh; padding: 5.4cqh 3cqw 1.6cqh; border-radius: var(--ds-r-3xl); isolation: isolate; background: #6a8d58; border: 2px solid rgba(40, 26, 12, .35); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .14), 0 8px 16px rgba(0, 0, 0, .35); }
#scHome .hm-mat::before { content: ''; position: absolute; inset: 8px; border: 2px solid rgba(255, 250, 235, .3); border-radius: var(--ds-r-xl); pointer-events: none; }
/* Flat mat on the home screen (owner mockup 30/11/2026: calm, not busy): solid mat colour, texture at 14%, soft edge. */
#scHome .hm-mat::after { content: ''; position: absolute; inset: 0; z-index: -1; border-radius: inherit; background: var(--mat) center / cover; opacity: .14; pointer-events: none; }
#scHome .hm-mat[data-mat='kraft'] { background-color: #c29a6c; }
#scHome .hm-mat[data-mat='nido'] { background-color: #a8443e; }
#scHome .hm-mat[data-mat='gosoi'] { background-color: #c8955c; }
#scHome .hm-mat[data-mat='kraft'], #scHome .hm-mat[data-mat='gosoi'] { border-color: var(--ds-ink); }
#scHome .hm-mat[data-mat='thocam'] { background-color: #7a5058; }
#scHome .hm-mat[data-mat='nitim'] { background-color: #7c5282; }
#scHome .hm-mat[data-mat='tuyet'] { background-color: #3f5272; }
#scHome .hm-herobox { position: relative; flex: 0 1 auto; min-height: 0; width: 100%; aspect-ratio: 10 / 7; }
#scHome .hm-hero { position: absolute; left: 0; top: 0; max-width: none; max-height: none; filter: none; }
#scHome .hm-play { position: relative; width: min(44cqw, 220px); padding: 1cqh 3cqw 1.2cqh; }
#scHome .hm-play b { font-size: clamp(24px, 4.2cqh, 34px); letter-spacing: 1px; }
#scHome .hm-play small { display: none; }
html.gh-home, html.gh-home body { background: #3b2414 !important; }
#scHome .hm-row { width: min(86cqw, 520px); justify-content: space-between; gap: 2.4cqw; }
#scHome .gh-tile { flex: 1 1 0; min-width: 0; width: auto; max-width: 112px; padding: 6px 4px 7px; border-radius: var(--ds-r-xl); background: linear-gradient(#fffaf0, #f3e3c3); border: 3px solid #e2c79a; box-shadow: 0 4px 0 #b08a5a, 0 6px 8px rgba(0, 0, 0, .3); }
#scHome .gh-tile img { width: 64%; margin: 0 auto; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .25)); }
#scHome .gh-tile span { margin-top: 3px; color: var(--ds-ink); -webkit-text-stroke: 0; font: 800 13px/1.15 var(--ds-font); }
@container (max-width: 375px) { #scHome .hm-row { gap: 2cqw; } #scHome .gh-tile { padding: 6px 2px 7px; } #scHome .gh-tile span { font-size: 12px; } }
#scHome .gh-tile .hm-dot-s { top: -4px; right: -4px; }
@container (orientation: landscape) {
  #scHome .hm-stack { justify-content: center; top: calc(max(8px, env(safe-area-inset-top)) + 64px); bottom: calc(max(8px, env(safe-area-inset-bottom)) + min(19cqh, 86px) + 12px); padding: 0 8cqw; }
  #scHome .gh-pill { right: auto; width: min(50cqw, 440px); }
  #scHome .hm-logo { max-height: 19cqh; max-width: 30cqw; margin-bottom: -4cqh; }
  #scHome .hm-mat { width: min(70cqw, 640px); display: grid; grid-template-columns: 1fr auto; grid-template-rows: 1fr auto auto 1fr; column-gap: 3cqw; row-gap: 2cqh; padding: 4.6cqh 3cqw 2.4cqh; }
  #scHome .hm-mat { flex: 1 1 auto; }
  #scHome .hm-herobox { grid-column: 1; grid-row: 1 / 5; height: 100%; aspect-ratio: auto; }
  #scHome .hm-play { grid-column: 2; grid-row: 2 / 4; align-self: center; width: min(28cqw, 220px); }
  #scHome .hm-play b { font-size: clamp(22px, 7cqh, 32px); }
  #scHome .hm-row { width: min(70cqw, 560px); }
  #scHome .gh-tile { display: flex; align-items: center; justify-content: center; gap: 6px; max-width: none; height: min(19cqh, 86px); padding: 4px 8px; }
  #scHome .gh-tile img { width: auto; height: 78%; margin: 0; }
  #scHome .gh-tile span { margin: 0; }
}

/* 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; }
