/* ================= Cờ Cá Ngựa — MonBlock (base copied from Ô Ăn Quan) ================= */
: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ủ ---------- */
.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: var(--panel); }
.me-tile { position: relative; display: grid; place-items: center; width: 60px; height: 60px; flex: none; border-radius: 12px; border: 3px solid var(--frame, #2b3a55); background: var(--cell-img, none), var(--cell, #fff); }
.me-num { font-size: 24px; font-weight: 800; line-height: 1; color: var(--user, #335fff); }
.me-tile .me-avemo { position: absolute; inset: 0; display: grid; place-items: center; font-size: 34px; line-height: 1; }
.me-tile.has-av .me-num { display: none; }
.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: 999px; background: var(--panel-2); overflow: hidden; }
.xpbar i { display: block; height: 100%; width: 0; background: var(--ds-primary, #335fff); border-radius: 999px; }
.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-daily.done small { color: #00a862; }
.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; }

/* ---------- chọn độ khó ---------- */
.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: 30px; 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: #b87400; font-size: 12px; font-style: normal; font-weight: 800; }

/* ---------- 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.locked { 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: #7fd8ff; }
.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; 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 { 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; }

/* ================= chọn mức, sảnh online ================= */
.big-sprint { --bar: #ffb020; }
.big-room { --bar: #8a5cff; }
.big-sprint.done small { color: #00a862; }
.today { display: flex; align-items: center; gap: 10px; margin: -4px 0 12px; padding: 10px 14px; border: 1px dashed #c9d2e0; border-radius: 14px; background: #fff; font-size: 14px; }
.today b { font-size: 17px; color: #335fff; }
.today small { color: var(--muted); }
h2 { font-size: 16px; margin: 16px 0 8px; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.seg button { flex: 1; min-width: 0; padding: 10px 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); font-weight: 800; font-size: 14px; }
.joinrow { display: flex; gap: 8px; margin: 4px 0 8px; }
.joinrow input { flex: 1; min-width: 0; padding: 12px 14px; border: 1px solid #c9d2e0; border-radius: 12px; font: inherit; font-size: 16px; font-weight: 700; letter-spacing: 2px; }
.joinrow button { padding: 0 18px; border: 0; border-radius: 12px; background: #335fff; color: #fff; font-weight: 800; }
.roomcode { margin: 6px 0; font-size: 44px; font-weight: 900; letter-spacing: 8px; text-align: center; color: #335fff; }


/* ---------- thẻ món cửa hàng: giá dính đáy, hai hàng cố định (🪙 / 💎) để mọi thẻ thẳng hàng ---------- */
.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: #1a8fd8; }
.item .pr.gh { color: var(--muted); font-weight: 600; font-size: 12px; }
.item.poor .pay { opacity: .5; }
.item .lock { position: absolute; top: 6px; right: 6px; z-index: 2; padding: 1px 6px; border-radius: 8px; background: #191b1d; color: #fff; font-size: 12px; font-weight: 800; }
.item.active { border-color: #335fff; }
.item .evtag { font-size: 12px; font-weight: 800; padding: 2px 8px; border-radius: 999px; background: #e4f3ff; border: 1px solid #9fd0ff; color: #1d5f99; }

/* ===== 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: var(--ds-danger, #e5374f); 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: 999px; 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; }
.big-hist { margin-top: 12px; }
/* Guest avatar = a horse of the set in use, account avatar once logged in; quest dot without a number; quest sheet */
.hm-av .me-num { position: absolute; inset: 0; display: grid; place-items: center; border-radius: 50%; overflow: hidden; background: radial-gradient(circle at 40% 35%, #d39a55, #9a5f2c); }
.hm-av .me-num svg { width: 40px; height: 40px; }
.hm-av.has-av .me-num { display: none; }
.hm-dot-s { min-width: 16px; width: 16px; height: 16px; padding: 0; top: 4px; right: 8px; }
#scQuest { display: flex; flex-direction: column; gap: 10px; }
#scQuest .today { margin: 0; }
#scQuest .big { margin: 0; }
#scQuest .note { margin: 0; }
#scQuest .today { margin: 0 0 12px; padding: 12px 16px; border: 1px solid var(--skin-card-line, #e3e5e8); border-radius: 12px; background: var(--skin-card, #f7f8f9); font-size: 14px; line-height: 1.4; }
#scQuest .today b { font-size: 16px; color: #191b1d; }
#scQuest .today small { color: #606368; font-size: 14px; }

/* ================= Cờ Cá Ngựa: trang chủ (logo có ngựa, không có hình chính riêng) ================= */
#scHome .hm-logo { max-height: 34cqh; max-width: 90cqw; }
.hm-av .me-num { background: radial-gradient(circle at 40% 35%, #fff3d6, #f0c98a); }
.hm-av .me-num svg { width: 36px; height: 42px; }

/* ================= chọn ván (hộp nổi): số người, màu, mức máy, luật ================= */
#scSetup { display: flex; flex-direction: column; gap: 4px; }
#scSetup h2, #scOnline h2 { margin: 10px 0 6px; font-size: 15px; }
.cg-opt { display: flex; align-items: center; gap: 10px; margin: 0 0 8px; }
.cg-opt > span { flex: none; width: 88px; color: #606368; font-size: 13px; font-weight: 700; }
.cg-opt .seg { flex: 1; margin: 0; flex-wrap: nowrap; }
.seg button { min-height: 44px; }
.seg button.active { border-color: #335fff; background: #335fff; color: #fff; }
.swatches { display: flex; gap: 10px; }
.sw { width: 44px; height: 44px; padding: 0; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 2px #e3e5e8; background: var(--pc); }
.sw.active { box-shadow: 0 0 0 3px #191b1d; }
.sw.c0, .pcard.c0, .seat.c0, .seatrow.c0 { --pc: #e5374f; }
.sw.c1, .pcard.c1, .seat.c1, .seatrow.c1 { --pc: #2f7de1; }
.sw.c2, .pcard.c2, .seat.c2, .seatrow.c2 { --pc: #f2b705; }
.sw.c3, .pcard.c3, .seat.c3, .seatrow.c3 { --pc: #2fae4a; }
.levels { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.lvl { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-height: 56px; padding: 8px 12px; border: 1px solid #e3e5e8; border-radius: 12px; background: #fff; text-align: left; }
.lvl b { font-size: 15px; }
.lvl small { color: #b87400; font-size: 12px; font-weight: 800; }
.lvl.active { border-color: #335fff; box-shadow: inset 0 0 0 1px #335fff; }
.seatrow { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.seatrow i { flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--pc); border: 2px solid #191b1d; }
.seatrow .seg { flex: 1; margin: 0; }
.go-btn { width: 100%; min-height: 52px; margin-top: 6px; border: 0; border-radius: 999px; background: var(--ds-play, #00a862); color: #fff; font-size: 18px; font-weight: 900; }
.go-btn:disabled { opacity: .5; }
.setup-note { margin: 2px 0 6px; }

/* ================= nhiệm vụ ================= */
.quests { display: flex; flex-direction: column; gap: 8px; }
.quest { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid #e3e5e8; border-radius: 12px; background: #f7f8f9; }
.quest .qt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; font-size: 14px; font-weight: 700; }
.quest .qbar { height: 6px; border-radius: 6px; background: #e3e5e8; overflow: hidden; }
.quest .qbar i { display: block; height: 100%; background: #00a862; transform-origin: 0 50%; }
.quest button { flex: none; min-height: 44px; min-width: 88px; padding: 0 12px; border: 0; border-radius: 12px; background: #00a862; color: #fff; font-weight: 900; }
.quest button:disabled { background: #e3e5e8; color: #606368; }

/* ================= sảnh online ================= */
.seats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 8px 0; }
.seat { display: flex; align-items: center; gap: 8px; min-height: 52px; padding: 6px 10px; border-radius: 12px; border: 2px solid var(--pc); background: #fff; font-size: 14px; font-weight: 700; min-width: 0; }
.seat .av { flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; overflow: hidden; background: #f2f4f5; font-size: 20px; }
.seat .av img, .seat .av svg { width: 100%; height: 100%; }
.seat span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat.empty { border-style: dashed; color: #606368; }
#onWait .dlg-btns button { min-height: 44px; }
#onWait .dlg-btns .pri { background: #00a862; border-color: #00a862; color: #fff; }

/* ================= màn chơi: bàn vuông giữa, 4 thẻ ở 4 góc, nút GIEO XÚC XẮC ================= */
#scPlay { position: fixed; inset: 0; z-index: 5; max-width: none; margin: 0; padding: 0; animation: none; }
#scPlay.hidden { display: none !important; }
body.cg-play { background: #b86b45; }
.table { position: absolute; inset: 0; display: grid; gap: 6px 8px; overflow: hidden;
  padding: calc(6px + env(safe-area-inset-top)) calc(8px + env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) calc(8px + env(safe-area-inset-left));
  grid-template-columns: 1fr 1fr; grid-template-rows: auto auto minmax(0, 1fr) auto auto auto;
  grid-template-areas: "top top" "a0 a1" "bd bd" "a3 a2" "st st" "rl rl";
  background: #c98a5a url(../img/bg-play.webp) center / cover no-repeat; }
.ptop { grid-area: top; display: flex; align-items: center; gap: 8px; min-width: 0; }
.pbtn { flex: none; width: 44px; height: 44px; padding: 0 0 3px; display: grid; place-items: center; border-radius: 50%; border: 3px solid #e3e5e8; background: #fff; color: #191b1d; font: 700 28px/1 system-ui; box-shadow: 0 3px 6px rgba(0, 0, 0, .3); }
.pbtn .mbi { width: 24px; height: 24px; }
.ptitle { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center; color: #fff; font-size: 15px; font-weight: 800; text-shadow: 0 1px 3px rgba(0, 0, 0, .6); }
.pcard { position: relative; display: flex; align-items: center; gap: 8px; min-width: 0; min-height: 52px; padding: 5px 10px 9px 5px; border-radius: 14px;
  background: rgba(255, 252, 244, .95); border: 3px solid var(--pc, #c08a52); box-shadow: 0 3px 0 rgba(60, 25, 5, .35), 0 6px 12px rgba(40, 15, 0, .25); color: #3b2410; transition: transform .2s, box-shadow .2s; }
.pcard.c0 { grid-area: a0; }
.pcard.c1 { grid-area: a1; flex-direction: row-reverse; padding: 5px 5px 9px 10px; text-align: right; }
.pcard.c2 { grid-area: a2; flex-direction: row-reverse; padding: 5px 5px 9px 10px; text-align: right; }
.pcard.c3 { grid-area: a3; }
.pcard.off { visibility: hidden; }
.pcard.on { transform: scale(1.03); box-shadow: 0 0 0 4px rgba(255, 210, 63, .9), 0 3px 0 rgba(60, 25, 5, .35), 0 6px 14px rgba(40, 15, 0, .3); }
.pcard.won { background: #fff6cc; }
.pcard .av { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; overflow: hidden; background: #fff3d6; border: 3px solid var(--pc); font-size: 22px; }
.pcard .av img, .pcard .av svg { width: 100%; height: 100%; }
.pcard .av .hzav { width: 82%; height: 90%; margin-top: 4%; }
.pcard .pn { flex: 1; display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.pcard .pn b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.pcard .pn small { display: flex; align-items: center; gap: 3px; color: #8a6a48; font-size: 12px; font-weight: 800; white-space: nowrap; }
.pcard.c1 .pn small, .pcard.c2 .pn small { justify-content: flex-end; }
.pcard .pn small svg { width: 14px; height: 16px; flex: none; }
.pcard .away { color: #c42840; }
.tbar { position: absolute; left: 12px; right: 12px; bottom: 3px; height: 4px; border-radius: 4px; background: rgba(0, 0, 0, .08); overflow: hidden; }
.tbar > i { display: block; height: 100%; width: 100%; background: #00a862; transform-origin: 0 50%; transform: scaleX(0); }
.tbar > i.mid { background: #ffb020; }
.tbar > i.low { background: #e5374f; }

.boardwrap { grid-area: bd; min-height: 0; min-width: 0; display: grid; place-items: center; }
.board { position: relative; width: 300px; height: 300px; }
.bd-base, .bd-base > svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.pcs, .dests { position: absolute; inset: 0; pointer-events: none; }
/* Horses: left/top 0, placed with translate(% of own size) — no layout work while they run (art.js horseAt) */
.hz { position: absolute; left: 0; top: 0; width: 8.6%; aspect-ratio: 64 / 76; padding: 0; border: 0; background: none; pointer-events: auto; transition: transform .13s ease-out; -webkit-tap-highlight-color: transparent; }
.hz::after { content: ''; position: absolute; inset: -8px -10px -4px; }
.hz svg { width: 100%; height: 100%; display: block; overflow: visible; }
.hz.can svg { animation: bob .55s ease-in-out infinite alternate; filter: drop-shadow(0 0 5px #fff36a) drop-shadow(0 0 2px #fff); }
.hz.fly { transition: transform .5s cubic-bezier(.3, 1.3, .5, 1); }
.hz.fly svg { animation: spin .5s ease-out; }
.hz.home svg { animation: homeGlow .7s ease 2; }
@keyframes bob { to { transform: translateY(-14%); } }
@keyframes spin { 50% { transform: scale(1.35) rotate(180deg); } }
@keyframes homeGlow { 50% { transform: scale(1.3); filter: drop-shadow(0 0 10px #fff36a); } }
.dest { position: absolute; left: 0; top: 0; width: 6.4%; aspect-ratio: 1; padding: 0; display: grid; place-items: center; border-radius: 50%; border: 3px dashed #fff; background: rgba(255, 210, 63, .75); color: #4a2a14; font-size: 13px; font-weight: 900; pointer-events: auto; animation: destIn .25s ease; }
.dest::after { content: ''; position: absolute; inset: -10px; }
@keyframes destIn { from { opacity: 0; } }
.dice { position: absolute; left: 50%; top: 50%; z-index: 1; display: flex; justify-content: center; gap: 1%; width: 17%; transform: translate(-50%, -50%); pointer-events: none; }
.dice.two { width: 19%; }
.dice .die { flex: 1; min-width: 0; }
.dice .die svg { width: 100%; height: auto; display: block; }
.dice.rolling .die { animation: dieRoll .16s linear infinite; }
.dice.idle .die { opacity: .6; }
.dice.bonus .die { filter: drop-shadow(0 0 6px #fff36a); }
@keyframes dieRoll { 25% { transform: rotate(18deg) translateY(-8%); } 75% { transform: rotate(-18deg) translateY(4%); } }
.spark { position: absolute; left: 0; top: 0; width: 10%; aspect-ratio: 1; pointer-events: none; z-index: 3; }
.spark i { position: absolute; left: 45%; top: 45%; width: 10%; height: 10%; border-radius: 50%; background: #ffd23f; animation: sparkOut .7s ease-out forwards; }
@keyframes sparkOut { to { transform: translate(var(--dx), var(--dy)) scale(.4); opacity: 0; } }

.table .nstat { grid-area: st; justify-self: center; min-height: 24px; max-width: 100%; padding: 3px 12px; border-radius: 999px; background: rgba(255, 250, 236, .94); color: #3b2410; text-align: center; font-size: 14px; font-weight: 800; }
.table .nstat:empty { visibility: hidden; }
.nstat.bad { color: #c42840; }
.nstat.good { color: #00804a; }
.roll { grid-area: rl; justify-self: center; width: min(82vw, 340px); min-height: 56px; padding: 6px 16px; border-radius: 999px; 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); }
.roll b { display: block; font: 900 22px/1.1 "Arial Rounded MT Bold", system-ui, sans-serif; letter-spacing: 1px; -webkit-text-stroke: .12em #1d6a1d; paint-order: stroke fill; }
.roll:disabled { filter: grayscale(.8); opacity: .7; }
.roll.pulse { animation: rollPulse 1s ease-in-out infinite; }
.roll:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 2px 0 #1b6b1a; }
@keyframes rollPulse { 50% { transform: scale(1.04); } }

/* Phone held sideways / desktop: board in the middle column, two cards each side, status + roll button under them */
@media (orientation: landscape) {
  .table { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); grid-template-rows: auto 1fr 1fr auto; gap: 8px 14px;
    grid-template-areas: "top bd ." "a0 bd a1" "a3 bd a2" "st bd rl"; }
  .boardwrap { width: min(calc(100dvh - 20px - env(safe-area-inset-top) - env(safe-area-inset-bottom)), 58vw); height: 100%; }
  .pcard { align-self: start; max-width: 240px; }
  .pcard.c1, .pcard.c2 { justify-self: end; width: 100%; }
  .pcard.c3, .pcard.c2 { align-self: end; }
  .pcard.c0, .pcard.c3 { width: 100%; }
  .ptop { align-self: start; }
  .ptitle { text-align: left; }
  #btnPlaySound { margin-left: auto; }
  .table .nstat { align-self: end; justify-self: stretch; border-radius: 12px; }
  .roll { width: 100%; max-width: 240px; justify-self: end; align-self: end; }
  .roll b { font-size: 19px; }
}
@media (prefers-reduced-motion: reduce) {
  .hz.can svg, .roll.pulse, .dice.rolling .die { animation: none; }
}

/* ================= cửa hàng: ô xem thử dùng đúng hàm vẽ của bàn (js/art.js) ================= */
.pv { width: 100%; display: grid; place-items: center; pointer-events: none; }
.pv-board svg { width: 100%; max-width: 150px; height: auto; display: block; }
.pv-horse svg, .pv-dice svg { width: 100%; max-width: 150px; height: auto; display: block; }
.pv-horse, .pv-dice { min-height: 80px; border-radius: 12px; background: linear-gradient(#f3d49c, #dcae6a); }
.buyprev .pv-board svg { max-width: 260px; }
.buyprev .pv-horse svg, .buyprev .pv-dice svg { max-width: 260px; }

/* Result: finishing order (the medal icon already numbers it) */
.dialog .order { list-style: none; margin: 4px 0 8px; padding: 0; display: grid; gap: 4px; }
.dialog .order li { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 10px; background: #f2f4f5; font-weight: 700; }
.dialog .order li.c0 { box-shadow: inset 4px 0 #e5374f; }
.dialog .order li.c1 { box-shadow: inset 4px 0 #2f7de1; }
.dialog .order li.c2 { box-shadow: inset 4px 0 #f2b705; }
.dialog .order li.c3 { box-shadow: inset 4px 0 #2fae4a; }
.dialog .score small { font-size: 20px; color: #606368; }

/* Painted home scene behind shop / rank / lobby / setup (design system "Phần chung bổ sung" 6). */
body.mb-light { --mb-scene: url(/cangua/img/home-bg.webp); --mb-scene-on: ''; }
#scSetup .sticky-go { position: sticky; bottom: 0; padding: 8px 0 calc(8px + env(safe-area-inset-bottom)); background: none; box-shadow: none; }
/* 3D throw (main.js rollDice): cube of six faces, perspective on the die, soft shadow under it. */
.dice.throw { z-index: 100; overflow: visible; }
.dice.throw .die { position: relative; aspect-ratio: 1; perspective: 600px; }
.dice.throw .d3 { position: absolute; inset: 0; z-index: 1; }
.dice.throw .cube { position: absolute; inset: 0; transform-style: preserve-3d; }
.dice.throw .face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.dice.throw .face svg { width: 100%; height: 100%; display: block; }
.dice.throw .dsh { position: absolute; left: 8%; right: 8%; bottom: -8%; height: 18%; border-radius: 50%; background: rgba(40, 20, 5, .55); filter: blur(3px); }

/* 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; }
