/* Token thiết kế (thiet_ke/design_tokens.json) — dùng chung mọi màn */
:root {
  --bg: #f8e8dc; --surface: #f4d4b0; --primary: #e7583b; --secondary: #737e54; --accent: #fbb92c;
  --text: #51220c; --muted: #7a6551; --border: #d7aa7f; --danger: #b5312a; --success: #61781b;
  --cream: #faedde; --logo: #6d2911; --paper-tan: #f1d0ac; --paper-pale: #f7e2c9; --paper-edge: #eccfb4;
  --wood: #e6b68a; --wood-amber: #df9d65; --terracotta: #e38359; --rim: #eba976; --track: #695547;
  --badge: #af361f; --ink: #433730; --charcoal: #514239; --timer: #bf5233; --toss: #cb593a; --leader: #e94a1f;
  --row-you: #fad277; --added-bg: #c0c87c; --added-ink: #445e13; --order: #56a051; --trap: #ea604a; --well: #efbe9a;
  --r-sm: 8px; --r-md: 16px; --r-lg: 24px;
  --cjk: 'PingFang SC', 'Hiragino Sans', 'Microsoft YaHei', 'Yu Gothic UI', 'Malgun Gothic', 'Apple SD Gothic Neo', 'Noto Sans CJK SC', sans-serif;
  --font-display: 'Coiny', 'Baloo 2', 'Baloo Bhaijaan 2', var(--cjk);
  --font-heading: 'Baloo 2', 'Baloo Bhaijaan 2', 'Nunito', var(--cjk);
  --font-body: 'Nunito', 'Baloo 2', 'Baloo Bhaijaan 2', var(--cjk);
  --clay-shadow: 0 2px 0 rgba(104,48,23,.28), 0 4px 7px rgba(81,34,12,.23), inset 0 1px 2px rgba(255,246,216,.48);
  --well-shadow: inset 0 2px 3px rgba(112,54,26,.26), inset 0 -1px 0 rgba(255,235,186,.55);
  --btn-edge: inset 0 -4px 0 rgba(60,20,5,.22), inset 0 2px 2px rgba(255,240,210,.35), 0 3px 0 rgba(104,48,23,.3), 0 6px 10px rgba(81,34,12,.22);
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
}
html[lang="ar"] { --font-display: 'Baloo Bhaijaan 2', 'Coiny', sans-serif; --font-heading: 'Baloo Bhaijaan 2', 'Baloo 2', sans-serif; --font-body: 'Baloo Bhaijaan 2', 'Nunito', sans-serif; }
html[lang="hi"] { --font-display: 'Baloo 2', 'Coiny', sans-serif; --font-body: 'Baloo 2', 'Nunito', sans-serif; }
html[lang^="zh"], html[lang="ja"], html[lang="ko"] { --font-display: var(--cjk); }
html[lang^="zh"] .cta-play b, html[lang="ja"] .cta-play b, html[lang="ko"] .cta-play b { font-weight: 900; font-size: 30px; line-height: 1.2; }
html[lang="ar"] .cta-play b, html[lang="hi"] .cta-play b { font-weight: 800; line-height: 1.3; font-size: 32px; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font: 800 13px/1.25 var(--font-body); font-synthesis: none; }
body { background: var(--bg) url(../assets/ui/paper.webp); background-size: 240px; overscroll-behavior: none; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
img { display: block; }
svg { width: 22px; height: 22px; flex: none; }
.num { font-family: var(--font-body); font-weight: 900; font-variant-numeric: tabular-nums lining-nums; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-weight: 700; font-size: 12px; }
.center { text-align: center; }
#app { position: fixed; inset: 0; display: flex; justify-content: center; }
.screen { display: none; position: relative; width: 100%; max-width: 480px; height: 100%; flex-direction: column; }
.screen.active { display: flex; }

/* ---------- Chip, thẻ, nút dùng chung ---------- */
.chip { display: flex; align-items: center; gap: 6px; height: 37px; padding: 0 12px 0 6px; border-radius: var(--r-md); background: var(--surface); box-shadow: var(--clay-shadow); }
.chip img { width: 28px; height: 28px; object-fit: contain; }
.chip b { font-size: 18px; }
.chip.sq { width: 40px; height: 40px; padding: 0; justify-content: center; }
.chip.small { height: 30px; } .chip.small img { width: 22px; height: 22px; } .chip.small b { font-size: 15px; }
.card { background: var(--surface); border-radius: var(--r-md); box-shadow: var(--clay-shadow); }
.card.pad { padding: 12px; }
.sec-pill { display: inline-block; margin: 12px 0 6px; padding: 3px 14px 2px; border-radius: 999px; background: var(--badge); color: var(--cream); font: 800 15px/1.1 var(--font-heading); box-shadow: var(--clay-shadow); }
.btn-room { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 44px; padding: 0 14px; border-radius: var(--r-md); background: var(--surface); box-shadow: var(--btn-edge); font: 800 20px/1.05 var(--font-heading); color: var(--text); transition: transform .08s; }
.btn-room img { width: 34px; height: 34px; object-fit: contain; }
.btn-room em { font-style: normal; margin-inline-start: auto; color: var(--muted); font: 800 14px var(--font-body); }
.btn-room.primary { background: var(--primary); color: var(--cream); }
.btn-room.danger { background: var(--danger); color: var(--cream); }
.btn-room:active, .cta-play:active, .act:active, .cta-again:active, .btn-small:active, .btn-upg:active { transform: translateY(2px) scale(.98); }
.btn-small { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px; border-radius: 12px; background: var(--secondary); color: var(--cream); font: 800 15px var(--font-heading); box-shadow: var(--btn-edge); }
.btn-small svg { width: 18px; height: 18px; }
.well-input { width: 100%; height: 44px; border-radius: var(--r-sm); border: 1px solid var(--border); background: var(--paper-pale); box-shadow: var(--well-shadow); padding: 0 12px; font: 800 16px var(--font-body); color: var(--text); outline: none; user-select: text; -webkit-user-select: text; }
.well-input:focus { border: 2px solid var(--primary); }
.well-input.code { text-align: center; letter-spacing: 6px; font-size: 24px; text-transform: uppercase; }
.lbl { display: block; margin: 8px 0 4px; font: 800 13px var(--font-body); color: var(--muted); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
/* Nút 🌐 của bộ i18n dùng chung: khoác chip đất nặn; main.js gắn nó vào hàng "đầu bếp online" của sảnh
   (luôn thấy ở sảnh, không đè logo). Nếu chưa gắn được thì nằm dưới thanh trên cùng. */
#vds-lang-btn { top: calc(var(--safe-t) + 56px) !important; right: 8px !important; left: auto !important; height: 34px; padding: 0 12px !important; border-radius: 999px !important;
  border: 0 !important; background: var(--surface) !important; color: var(--text) !important; font: 800 13px var(--font-body) !important; box-shadow: var(--clay-shadow); z-index: 30 !important; white-space: nowrap; }
html[dir=rtl] #vds-lang-btn { right: auto !important; left: 8px !important; }
.online #vds-lang-btn { position: static !important; height: 30px; padding: 0 10px !important; font-size: 12px !important; margin-inline-start: auto; }
.online:has(#vds-lang-btn) .dot { margin-inline-start: auto; }
body.in-game #vds-lang-btn, body:not(.on-lobby) #vds-lang-btn { display: none; }

/* ---------- SẢNH ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: calc(var(--safe-t) + 4px) 10px 4px; flex: none; }
.profile { height: 47px; padding: 0 12px 0 0; gap: 6px; min-width: 112px; }
.pf-av { width: 52px; height: 52px; margin: -6px 0 -4px -6px; object-fit: cover; object-position: 50% 6%; border-radius: 14px; background: var(--paper-pale); box-shadow: var(--clay-shadow); }
[dir=rtl] .pf-av { margin: -4px -4px -2px 0; }
.pf-txt { display: flex; flex-direction: column; align-items: flex-start; line-height: 1; }
.pf-txt b { font: 800 15px/1.1 var(--font-heading); max-width: 74px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lv-pill { font-style: normal; background: var(--accent); color: var(--text); border-radius: 999px; padding: 1px 7px; font: 900 12px var(--font-body); margin-top: 2px; }
.money { min-width: 77px; }
.lobby-body { flex: 1; overflow: hidden auto; position: relative; }
.tab { display: none; padding: 0 12px 12px; }
.tab.active { display: block; }
.tab-lobby.active { display: flex; flex-direction: column; min-height: 100%; padding: 0; }
.hero { position: relative; flex: 0 1 auto; min-height: 0; display: flex; align-items: flex-start; justify-content: center; overflow: hidden; }
.hero-box { position: relative; width: min(100%, calc((100dvh - 276px) * 1.164)); aspect-ratio: 900 / 773; margin: -6px auto 0; }
.hero-img { width: 100%; height: 100%; object-fit: contain; -webkit-mask-image: linear-gradient(transparent, #000 9%, #000 90%, transparent); mask-image: linear-gradient(transparent, #000 9%, #000 90%, transparent); }
.tagline { position: absolute; top: 29.2%; left: 50%; transform: translate(-50%, -50%); min-width: 43%; height: 6.4%; display: flex; align-items: center; justify-content: center; white-space: nowrap; background: #f8ead9; border-radius: 999px; padding: 3px 16px 2px; font: 800 14px/1.25 var(--font-body); color: var(--text); box-shadow: 0 2px 0 rgba(104,48,23,.18), inset 0 1px 1px #fff7; }
.top3 { flex: 1 1 auto; display: flex; flex-direction: column; justify-content: center; gap: 6px; padding: 4px 16px; min-height: 0; overflow: hidden; }
.top3 h4 { margin: 0; text-align: center; font: 800 15px/1.1 var(--font-heading); color: var(--badge); }
#top3-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.t3 { display: flex; flex-direction: column; align-items: center; padding: 6px 4px; border-radius: 12px; background: var(--paper-pale); box-shadow: var(--clay-shadow); min-width: 0; }
.t3 img { width: 44px; height: 44px; object-fit: contain; }
.t3 b { font: 800 13px var(--font-heading); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t3 span { font: 900 14px var(--font-body); color: var(--badge); }
.t3 i { font-style: normal; font: 900 12px var(--font-body); background: var(--accent); border-radius: 999px; padding: 0 7px; }
@media (max-height: 760px) { .top3 { display: none; } }
.lobby-actions { margin-top: auto; padding: 0 12px 6px; display: flex; flex-direction: column; gap: 7px; flex: none; }
.rule-pill { display: flex; align-items: center; gap: 12px; justify-content: center; }
.rule-pill::before, .rule-pill::after { content: ''; width: 34px; height: 3px; border-radius: 2px; background: #b8794c; }
.rule-pill span { background: #f8ead9; border-radius: 999px; padding: 4px 16px 3px; box-shadow: var(--clay-shadow); font-size: 13px; }
.cta-play { width: 100%; min-height: 63px; border-radius: var(--r-lg); background: var(--primary); color: var(--cream); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 6px 0; box-shadow: var(--btn-edge); background: var(--primary) url(../assets/ui/clay_grain.webp) center/cover; }
.cta-play b { font: 400 37px/1 var(--font-display); text-shadow: 0 2px 0 rgba(109,41,17,.35); }
.cta-play span { font: 800 17px/1.1 var(--font-heading); }
.room-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.room-row .btn-room { font-size: 18px; }
.online { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 13px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--secondary); box-shadow: inset 0 -2px 0 rgba(0,0,0,.2); }
.bottom-nav { flex: none; display: grid; grid-template-columns: repeat(3, 1fr); margin: 0 4px calc(var(--safe-b) + 4px); height: 48px; border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--clay-shadow); overflow: hidden; }
.bottom-nav button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; font: 800 15px/1 var(--font-heading); border-inline-start: 1px solid var(--border); }
.bottom-nav button:first-child { border: 0; }
.bottom-nav img { height: 22px; width: auto; }
.bottom-nav button.on { background: var(--primary); color: var(--cream); border-radius: var(--r-lg); border: 0; }
.seg { display: inline-flex; margin: 0 0 8px; padding: 3px; gap: 3px; border-radius: 999px; background: var(--paper-tan); box-shadow: var(--well-shadow); }
.seg button { padding: 5px 14px; border-radius: 999px; font: 800 14px var(--font-heading); }
.seg button.on { background: var(--secondary); color: var(--cream); }
.table-card { padding: 4px 8px; }
.tr { display: grid; grid-template-columns: 38px 40px 1fr auto; align-items: center; gap: 8px; min-height: 38px; padding: 2px 6px; border-bottom: 1px solid var(--border); font: 800 16px var(--font-heading); }
.tr:last-child { border-bottom: 0; }
.tr.th { min-height: 26px; font: 800 13px var(--font-body); color: var(--text); }
.tr.th span:last-child { text-align: end; }
.tr .rk { font: 900 18px var(--font-body); text-align: center; }
.tr .sc { font: 900 18px var(--font-body); text-align: end; }
.tr.me { background: var(--row-you); border-radius: 6px; }
.tr.me .rk { color: var(--badge); }
.tr .av { width: 36px; height: 36px; border-radius: 50%; background: var(--paper-pale); box-shadow: var(--well-shadow); overflow: hidden; }
.tr .av img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.tr .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tr .nm small { color: var(--muted); font: 700 11px var(--font-body); margin-inline-start: 6px; }
.name-row { display: flex; gap: 8px; }
.av-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.av-grid button { aspect-ratio: 1; border-radius: 12px; background: var(--paper-pale); box-shadow: var(--well-shadow); overflow: hidden; border: 2px solid transparent; }
.av-grid button.on { border-color: var(--primary); }
.av-grid img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.stats3 { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 10px; padding: 6px 0; }
.stats3 > div { display: flex; flex-direction: column; align-items: center; border-inline-start: 2px solid var(--border); }
.stats3 > div:first-child { border: 0; }
.stats3 b { font-size: 28px; line-height: 1; }
.stats3 b.red { color: var(--badge); }
.stats3 span { font: 800 15px var(--font-heading); }
.shop-list { display: grid; gap: 8px; }
.shop-item { display: grid; grid-template-columns: 56px 1fr auto; gap: 10px; align-items: center; padding: 8px; }
.shop-item .sw { width: 56px; height: 56px; border-radius: 12px; box-shadow: var(--well-shadow); }
.shop-item b { font: 800 16px var(--font-heading); }

/* ---------- PHÒNG ---------- */
#scr-room { justify-content: center; padding: 16px; }
.room-card { position: relative; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.room-logo { width: 60%; margin: 0 auto; }
.room-title { margin: 0; text-align: center; font: 800 20px var(--font-heading); }
.code-box { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; }
.room-code { font: 400 32px/1 var(--font-display); letter-spacing: 4px; color: var(--badge); }
.seats4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.seat { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 2px; border-radius: 12px; background: var(--paper-pale); box-shadow: var(--well-shadow); min-height: 108px; }
.seat img { width: 64px; height: 64px; object-fit: contain; animation: pop .35s cubic-bezier(.3,1.6,.6,1); }
.seat b { font: 800 13px var(--font-heading); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 2px; }
.seat small { font: 700 11px var(--font-body); color: var(--muted); }
.seat.empty img { opacity: .25; filter: grayscale(1); animation: bob 1.2s ease-in-out infinite; }
.count-big { position: absolute; inset: 0; display: grid; place-items: center; font: 400 96px var(--font-display); color: var(--primary); background: rgba(248,232,220,.82); border-radius: var(--r-md); text-shadow: 0 4px 0 rgba(109,41,17,.3); }
@keyframes pop { from { transform: scale(.3); } to { transform: scale(1); } }
@keyframes bob { 50% { transform: translateY(-4px); } }

/* ---------- TRONG VÁN (ảnh 07) ---------- */
#scr-game { background: var(--terracotta) url(../assets/ui/table_tile.webp); background-size: 160px; }
.g-side { flex: none; padding-top: var(--safe-t); background: linear-gradient(var(--bg), var(--bg)) top/100% 40px no-repeat; }
.hud { display: flex; align-items: center; height: 46px; margin: 0 2px; padding: 0 8px; border-radius: 0 0 var(--r-lg) var(--r-lg); background: var(--paper-pale); box-shadow: var(--clay-shadow); }
.hud-logo { height: 32px; width: auto; }
.vbar { width: 1px; height: 26px; background: var(--border); margin: 0 auto; }
.timer { min-width: 108px; height: 32px; border-radius: 999px; background: var(--timer); color: var(--cream); display: grid; place-items: center; font-size: 26px; box-shadow: var(--btn-edge); }
.timer.hot { background: var(--leader); animation: pulse .5s ease-in-out infinite alternate; }
@keyframes pulse { to { transform: scale(1.06); } }
.pause { width: 34px; height: 32px; border-radius: 10px; background: var(--timer); color: var(--cream); display: grid; place-items: center; box-shadow: var(--btn-edge); }
.pause svg { width: 18px; height: 18px; }
/* vùng bấm vô hình ≥ 44×44 (spec mục "Vùng bấm"): hình nhìn thấy giữ đúng ảnh 07 */
.pause, .act { position: relative; }
.pause::after, .act::after { content: ''; position: absolute; left: 50%; top: 50%; width: max(100%, 44px); height: max(100%, 44px); transform: translate(-50%, -50%); }
.scores { display: grid; grid-template-columns: repeat(4, 1fr); gap: 3px; padding: 4px 2px 0; }
.sc-card { min-width: 0; position: relative; display: flex; align-items: center; gap: 4px; height: 54px; padding: 0 4px; border-radius: 12px; background: var(--paper-pale); box-shadow: var(--clay-shadow); transition: transform .2s; }
.sc-card .ring { width: 44px; height: 44px; flex: none; border-radius: 50%; overflow: hidden; background: var(--secondary); box-shadow: inset 0 -2px 0 rgba(0,0,0,.15); }
.sc-card .ring img { width: 100%; height: 100%; object-fit: cover; object-position: top; transform: scale(1.15) translateY(4%); }
.sc-card .who { display: flex; flex-direction: column; min-width: 0; line-height: 1; }
.sc-card .who b { font: 800 13px/1.05 var(--font-heading); text-transform: uppercase; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sc-card .who .num { font-size: 20px; }
.sc-card .flag { position: absolute; top: -7px; inset-inline-start: 36px; height: 15px; width: auto; animation: wave 1s ease-in-out infinite alternate; transform-origin: left; }
.sc-card.locked { outline: 2px dashed var(--danger); }
.sc-card.bump { animation: bump .35s; }
@keyframes bump { 40% { transform: scale(1.08); } }
@keyframes wave { to { transform: rotate(-4deg); } }
.g-table { position: relative; flex: 1 1 auto; min-height: 220px; }
#table { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
.fx-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.float { position: absolute; transform: translate(-50%, -50%); font: 800 18px var(--font-heading); color: var(--cream); padding: 2px 10px; border-radius: 999px; background: var(--order); box-shadow: var(--clay-shadow); white-space: nowrap; animation: floatUp 1.2s ease-out forwards; }
.float.red { background: var(--trap); } .float.gold { background: var(--accent); color: var(--text); } .float.dark { background: var(--charcoal); }
.float.big { font-size: 26px; padding: 4px 16px; }
@keyframes floatUp { 0% { opacity: 0; transform: translate(-50%, -20%) scale(.6); } 15% { opacity: 1; transform: translate(-50%, -50%) scale(1.08); } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -160%) scale(1); } }
.bubble { position: absolute; transform: translate(-50%, -100%); background: var(--cream); color: var(--text); font: 800 15px var(--font-heading); padding: 3px 10px; border-radius: 12px; box-shadow: var(--clay-shadow); animation: pop .25s, fade 1.6s .2s forwards; white-space: nowrap; }
.bubble::after { content: ''; position: absolute; left: 50%; bottom: -6px; border: 6px solid transparent; border-top-color: var(--cream); border-bottom: 0; transform: translateX(-50%); }
@keyframes fade { 80% { opacity: 1; } 100% { opacity: 0; } }
.banner { position: absolute; left: 50%; top: 44%; transform: translate(-50%, -50%); padding: 6px 18px; border-radius: var(--r-md); background: var(--primary); color: var(--cream); font: 400 28px var(--font-display); box-shadow: var(--btn-edge); animation: pop .3s, fade 2.2s forwards; white-space: nowrap; }
.g-panel { flex: none; position: relative; padding: 8px 8px calc(var(--safe-b) + 4px); border-radius: var(--r-lg) var(--r-lg) 0 0; background: var(--paper-pale); box-shadow: 0 -3px 8px rgba(81,34,12,.22), inset 0 2px 2px rgba(255,250,235,.7); }
.tray-head { display: flex; align-items: center; justify-content: space-between; padding: 0 8px 6px; }
.tray-head h3 { margin: 0; font: 800 20px/1.05 var(--font-heading); }
.pts-pill { background: var(--timer); color: var(--cream); border-radius: 999px; padding: 2px 12px; font-size: 20px; box-shadow: var(--btn-edge); }
.tray { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; padding: 6px; border-radius: 12px; background: var(--paper-tan); box-shadow: var(--well-shadow); }
.tray.five { grid-template-columns: repeat(5, 1fr); }
.slot { position: relative; aspect-ratio: 82 / 73; border-radius: var(--r-sm); background: var(--well); box-shadow: var(--well-shadow); display: grid; place-items: center; transition: transform .1s; }
.slot img.pl { width: 86%; height: auto; max-height: 100%; object-fit: contain; filter: drop-shadow(0 3px 2px rgba(81,34,12,.35)); animation: drop .25s cubic-bezier(.3,1.5,.6,1); }
.slot.sel { outline: 3px solid var(--secondary); transform: translateY(-3px); }
.slot.need { outline: 2px solid var(--trap); background: var(--paper-pale); }
.slot .need-t { font: 800 14px/1.05 var(--font-heading); text-align: center; color: var(--text); }
.slot .lk { position: absolute; right: 2px; bottom: 2px; width: 26px; height: auto; }
.slot .lk-t { position: absolute; top: 3px; left: 50%; transform: translateX(-50%); background: var(--danger); color: var(--cream); font: 900 11px var(--font-body); border-radius: 999px; padding: 0 6px; }
.slot.gold::after { content: ''; position: absolute; inset: 3px; border-radius: 6px; box-shadow: inset 0 0 0 2px var(--accent); }
.slot.add { border: 2px dashed var(--border); background: transparent; box-shadow: none; flex-direction: column; color: var(--muted); font: 800 11px var(--font-heading); text-align: center; }
.slot.add svg { width: 18px; height: 18px; color: var(--secondary); }
.slot.flash { animation: flash .45s; }
@keyframes drop { from { transform: translateY(-30px) scale(.7); opacity: 0; } }
@keyframes flash { 50% { background: var(--order); transform: scale(1.06); } }
.tray-hint { display: flex; align-items: center; gap: 10px; padding: 6px 4px 2px; font-size: 13px; }
.tray-hint i { flex: 1; height: 2px; background: var(--border); border-radius: 1px; }
.tray-hint span { white-space: nowrap; }
.tray-hint span.warn { color: var(--danger); }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 6px 4px 0; }
.act { display: flex; align-items: center; justify-content: center; gap: 12px; height: 50px; border-radius: var(--r-lg); color: var(--cream); font: 800 26px/1 var(--font-heading); box-shadow: var(--btn-edge); }
.act img { height: 30px; width: auto; }
.act.grab { background: var(--secondary); }
.act.toss { background: var(--toss); }
.act:disabled { filter: saturate(.4) brightness(.92); }
.foot-hint { margin: 4px 0 0; text-align: center; font-size: 12px; }
.emotes { position: absolute; top: -38px; inset-inline-end: 6px; display: flex; gap: 4px; }
.emotes button { height: 30px; padding: 0 9px; border-radius: 999px; background: var(--cream); box-shadow: var(--clay-shadow); font: 800 13px var(--font-heading); }
.overlay { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(67,55,48,.55); }
.modal { width: 100%; max-width: 360px; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.modal .sec-pill { align-self: center; margin-top: 0; }
.modal.how { max-width: 420px; max-height: 90vh; overflow: auto; }
.how-steps { display: grid; gap: 8px; }
.how-step { display: grid; grid-template-columns: 92px 1fr; gap: 10px; align-items: center; padding: 8px; border-radius: 12px; background: var(--paper-pale); box-shadow: var(--well-shadow); }
.how-step .ill { height: 70px; display: flex; align-items: center; justify-content: center; gap: 2px; }
.how-step .ill img { width: 38px; height: 38px; object-fit: contain; }
.how-step b { display: block; font: 800 16px/1.1 var(--font-heading); color: var(--badge); }
.how-step p { margin: 2px 0 0; font: 700 13px/1.25 var(--font-body); }
.toast { position: fixed; left: 50%; bottom: calc(var(--safe-b) + 90px); transform: translate(-50%, 20px); opacity: 0; pointer-events: none; z-index: 60; background: var(--charcoal); color: var(--cream); padding: 8px 16px; border-radius: 999px; font: 800 14px var(--font-body); transition: .25s; max-width: 90vw; text-align: center; }
body.in-game .toast { bottom: auto; top: calc(var(--safe-t) + 120px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- KẾT QUẢ (ảnh 08) ---------- */
#scr-result { overflow: hidden auto; }
.res-scroll { padding: calc(var(--safe-t) + 4px) 12px calc(var(--safe-b) + 12px); display: flex; flex-direction: column; }
.res-head { position: relative; display: flex; justify-content: center; }
.res-back { position: absolute; inset-inline-start: 0; top: 6px; width: 44px; }
.res-back img { width: 44px; }
[dir=rtl] .res-back img { transform: scaleX(-1); }
.res-logo { width: 42%; max-width: 180px; }
.badge-dark { align-self: center; margin-top: 4px; background: var(--charcoal); color: var(--cream); padding: 3px 18px 2px; border-radius: 999px; font: 800 15px/1.1 var(--font-heading); box-shadow: var(--clay-shadow); }
.res-title { margin: 4px 0 0; text-align: center; font: 400 43px/1.02 var(--font-display); color: var(--badge); text-shadow: 0 3px 0 rgba(109,41,17,.25); }
.res-sub { margin: 0 0 2px; text-align: center; font: 800 14px var(--font-body); color: var(--ink); }
.res-belt { width: 100%; height: auto; }
.res-stats { margin-top: 6px; }
.rewards { display: flex; align-items: center; justify-content: space-around; gap: 4px; min-height: 48px; padding: 4px 10px; }
.rewards > div { display: flex; align-items: center; gap: 6px; font: 900 17px var(--font-body); white-space: nowrap; }   /* không gãy dòng (tiếng Ả Rập) */
.rewards img { width: 36px; height: 36px; object-fit: contain; }
/* vé chỉ hiện khi có (hạng 1-2, thắng trụ lại cuối) — khi đó thay chỗ nhãn "Đã cộng" để hàng vẫn vừa 1 dòng */
.rewards .r-tix, .rewards.has-tix .r-added { display: none; }
.rewards.has-tix .r-tix { display: flex; }
#r-tix { direction: ltr; unicode-bidi: isolate; }
.vline { width: 2px; align-self: stretch; margin: 6px 0; background: var(--border); border-radius: 1px; }
.added { display: inline-flex; align-items: center; gap: 4px; background: var(--added-bg); color: var(--added-ink); border-radius: 999px; padding: 4px 12px; font: 800 15px var(--font-heading); white-space: nowrap; }
.added svg { width: 16px; height: 16px; }
.upg-head { display: flex; align-items: center; justify-content: space-between; }
.upg { display: grid; grid-template-columns: 58px 2px 1fr auto; align-items: center; gap: 10px; padding: 6px 8px; }
.upg img:first-child { width: 64px; border-radius: 10px; }
.upg-txt { display: flex; flex-direction: column; line-height: 1.2; }
.upg-txt b { font: 800 16px var(--font-heading); }
.upg-txt span { font: 700 12px var(--font-body); }
.btn-upg { display: flex; align-items: center; gap: 6px; height: 34px; padding: 0 8px 0 12px; border-radius: 12px; background: var(--danger); color: var(--cream); font: 800 15px var(--font-heading); box-shadow: var(--btn-edge); white-space: nowrap; }
.btn-upg img { width: 22px; height: 22px; }
.btn-upg:disabled { filter: grayscale(.6); }
.link { align-self: center; display: inline-flex; align-items: center; gap: 6px; margin: 2px 0; font: 800 15px var(--font-heading); color: var(--ink); text-decoration: underline; text-underline-offset: 3px; min-height: 36px; }
.link svg { width: 18px; height: 18px; }
[dir=rtl] .link svg { transform: scaleX(-1); }
.cta-again { width: 100%; min-height: 54px; border-radius: var(--r-lg); background: var(--success); color: var(--cream); font: 800 32px/1 var(--font-heading); box-shadow: var(--btn-edge); text-shadow: 0 2px 0 rgba(40,50,10,.35); }

/* ---------- Xoay ngang: bố cục riêng ---------- */
@media (orientation: landscape) and (max-height: 600px) {
  .screen { max-width: none; }
  .topbar { padding-top: 4px; }
  .tab-lobby.active { flex-direction: row; align-items: stretch; gap: 16px; padding: 0 16px; height: 100%; }
  .hero { flex: 1 1 52%; height: 100%; align-items: center; }
  .hero-box { height: 100%; width: auto; max-width: 100%; }
  .top3 { display: none; }
  .lobby-actions { flex: 1 1 44%; max-width: 440px; margin: auto 0; gap: 8px; }
  .cta-play { min-height: 56px; } .cta-play b { font-size: 32px; }
  #scr-lobby .bottom-nav { width: min(520px, 90%); align-self: center; height: 44px; }
  .tab-friends.active, .tab-profile.active { max-width: 640px; margin: 0 auto; }
  #scr-game.active { display: grid; grid-template-columns: 1fr min(42vw, 400px); grid-template-rows: auto 1fr; }
  .g-side { grid-column: 2; grid-row: 1; }
  .g-table { grid-column: 1; grid-row: 1 / 3; }
  .g-panel { grid-column: 2; grid-row: 2; border-radius: var(--r-lg) 0 0 0; align-self: end; }
  .hud { border-radius: 0 0 0 var(--r-lg); }
  .sc-card { height: 46px; } .sc-card .ring { width: 36px; height: 36px; } .sc-card .flag { inset-inline-start: 28px; }
  .act { height: 42px; font-size: 22px; }
  .tray-head h3 { font-size: 17px; }
  .emotes { top: auto; bottom: 100%; margin-bottom: 4px; }
  #scr-result .res-scroll { max-width: 640px; margin: 0 auto; }
  #vds-lang-btn:not(.online #vds-lang-btn) { top: auto !important; bottom: calc(var(--safe-b) + 8px); }
}
@media (max-height: 640px) and (orientation: portrait) {
  .sc-card { height: 46px; } .sc-card .ring { width: 36px; height: 36px; }
  .act { height: 44px; }
  .foot-hint { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01s !important; } }

/* Popup ngôn ngữ (i18n.js dùng chung) — khoác giao diện đất nặn */
#vds-lang-pop { background: rgba(67,55,48,.55) !important; font-family: var(--font-body) !important; }
#vds-lang-pop > div { background: var(--surface) !important; color: var(--text) !important; box-shadow: var(--clay-shadow); border-radius: var(--r-md) !important; }
#vds-lang-pop button { background: var(--paper-pale) !important; color: var(--text) !important; border: 1px solid var(--border) !important; font: 800 15px var(--font-body) !important; box-shadow: var(--well-shadow); }
#vds-lang-pop button[style*="#6366f1"] { background: var(--primary) !important; color: var(--cream) !important; }

/* Bảng giữa oval: MATCH 3 / đơn gấp */
.plaque { position: absolute; transform: translate(-50%, -50%); pointer-events: none; display: flex; flex-direction: column; align-items: center; padding: 6px 16px 5px; border-radius: 18px; background: var(--paper-pale); box-shadow: var(--clay-shadow); text-align: center; }
.plaque b { font: 800 22px/1.05 var(--font-heading); }
.plaque span { display: flex; align-items: center; gap: 4px; font: 800 12px/1.2 var(--font-body); }
.plaque img { width: 26px; height: 26px; }
.plaque.rush { background: var(--accent); animation: pulse .6s ease-in-out infinite alternate; }
.plaque::before, .plaque::after { content: ''; position: absolute; top: 50%; width: 10px; height: 3px; border-radius: 2px; background: var(--badge); box-shadow: 0 -7px 0 var(--badge), 0 7px 0 var(--badge); }
.plaque::before { right: calc(100% + 6px); } .plaque::after { left: calc(100% + 6px); }
/* Chủ đề quán (cửa hàng) */
body[data-theme="night"] #scr-game { background-color: #6b4f63; background-blend-mode: multiply; }
body[data-theme="spring"] #scr-game { background-color: #e9a3a0; background-blend-mode: soft-light; }
.res-scroll .sec-pill, .tab .sec-pill { align-self: flex-start; }

/* Kết quả: nhịp dọc sát ảnh 08 */
#scr-result .sec-pill { margin: 8px 0 4px; }
#scr-result .stats3 { margin-top: 2px; padding: 4px 0; }
#scr-result .stats3 b { font-size: 26px; }
#scr-result .tr { min-height: 30px; padding: 1px 6px; }
#scr-result .tr.th { min-height: 22px; }
#scr-result .tr .av { width: 30px; height: 30px; box-shadow: none; background: none; }
#scr-result .tr .av img { object-fit: contain; }
#scr-result .upg img:first-child { width: 58px; }
.res-belt { margin: -2px 0 0; }
/* Bàn chơi: góc bếp cắt từ ảnh 07 */
.g-table .deco { position: absolute; pointer-events: none; width: 34%; max-width: 190px; height: auto; }
.g-table .deco.tl { top: 0; left: 0; -webkit-mask-image: linear-gradient(to bottom right, #000 55%, transparent 92%); mask-image: linear-gradient(to bottom right, #000 55%, transparent 92%); }
.g-table .deco.tr { top: 0; right: 0; -webkit-mask-image: linear-gradient(to bottom left, #000 55%, transparent 92%); mask-image: linear-gradient(to bottom left, #000 55%, transparent 92%); }
.g-table .deco.bl { bottom: 0; left: 0; width: 22%; -webkit-mask-image: linear-gradient(to top right, #000 55%, transparent 95%); mask-image: linear-gradient(to top right, #000 55%, transparent 95%); }
.g-table .deco.br { bottom: 0; right: 0; width: 18%; -webkit-mask-image: linear-gradient(to top left, #000 55%, transparent 95%); mask-image: linear-gradient(to top left, #000 55%, transparent 95%); }
@media (orientation: landscape) and (max-height: 600px) { .g-table .deco.tl, .g-table .deco.tr { display: none; } .g-table .deco.bl, .g-table .deco.br { width: 12%; } }

/* Kết quả gọn trên màn thấp (390×693 đúng tỉ lệ ảnh 08): cả màn tới "Back to lobby" nằm trong khung, không cuộn.
   Giữ thứ tự/tỉ lệ ảnh 08, chỉ siết nhịp dọc: thẻ số ~49px, hàng hạng ~27px, thẻ thưởng ~38px, Play again 52px.
   Kiểm chứng: tools/result_layout_probe.js (tests/test_result_layout.py) + tools/design_check.py. */
@media (max-height: 740px) and (orientation: portrait) {
  #scr-result .res-scroll { padding-top: calc(var(--safe-t) + 4px); padding-bottom: calc(var(--safe-b) + 4px); }
  #scr-result .res-logo { width: 41%; }
  #scr-result .res-back, #scr-result .res-back img { width: 40px; }
  #scr-result .badge-dark { margin-top: 2px; font-size: 14px; }
  #scr-result .res-title { margin-top: 2px; font-size: 36px; }
  #scr-result .res-sub { font-size: 13px; line-height: 1.3; }
  #scr-result .stats3 { padding: 2px 0; }
  #scr-result .stats3 b { font-size: 24px; }
  #scr-result .stats3 span { font-size: 14px; line-height: 1.2; }
  #scr-result .sec-pill { margin: 5px 0 3px; font-size: 14px; }
  #scr-result .table-card { padding: 2px 8px; }
  #scr-result .tr { min-height: 27px; padding: 0 6px; }
  #scr-result .tr .av { width: 26px; height: 26px; }
  /* số + tiêu đề cột: line-height cố định (font Ả Rập "normal" cao hơn); .nm giữ normal để chữ không bị cắt dọc */
  #scr-result .tr .rk, #scr-result .tr .sc { font-size: 17px; line-height: 1.35; }
  #scr-result .tr.th { min-height: 20px; line-height: 1.35; }
  #scr-result .rewards { min-height: 38px; padding: 2px 8px; }
  #scr-result .rewards img { width: 28px; height: 28px; }
  #scr-result .rewards > div { font-size: 16px; }
  #scr-result .added { padding: 2px 10px; }
  #scr-result .upg-head .chip { height: 26px; }
  #scr-result .upg { gap: 8px; padding: 4px 8px; }
  #scr-result .upg img:first-child { width: 48px; }
  #scr-result .upg-txt b, #scr-result .upg-txt span { line-height: 1.25; }
  #scr-result .link { min-height: 30px; margin: 0; }
  #scr-result .cta-again { min-height: 52px; font-size: 30px; }
}
