/* BELT BRAWL — hộp cơm thiếc cổ điển + băng chuyền bưu kiện cơ khí */
:root {
  --orange: #E06D3B; --cream: #FAF3E0; --teal: #2A7B76; --ink: #3B2F2F;
  --iron: #2b2626; --iron2: #3a3331; --gold: #D4A64A; --gold2: #8a6424; --red: #8E2B22; --paper: #efe3c6;
  --f-disp: 'Alfa Slab One', 'Rockwell', 'Noto Serif SC', 'Noto Serif JP', 'Noto Naskh Arabic', 'Noto Serif Devanagari', serif;
  --f-text: 'Nunito', 'Segoe UI', 'PingFang SC', 'Hiragino Sans', 'Microsoft YaHei', 'Malgun Gothic', 'Noto Sans CJK SC', 'Noto Sans Arabic', 'Noto Sans Devanagari', 'Nirmala UI', 'Tahoma', sans-serif;
  --sa-t: env(safe-area-inset-top, 0px); --sa-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--iron); color: var(--ink); font-family: var(--f-text); font-weight: 700; overflow: hidden; overscroll-behavior: none; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
img { -webkit-user-drag: none; }
[hidden] { display: none !important; }
#app { position: fixed; inset: 0; display: flex; justify-content: center; }
.screen { position: absolute; inset: 0; display: none; flex-direction: column; max-width: 560px; margin: 0 auto; }
.screen.on { display: flex; }
:lang(ar) .ribbon span, :lang(hi) .ribbon span, :lang(ar) h1, :lang(hi) h1 { letter-spacing: 0 !important; }

/* ---------- chất liệu ---------- */
.plate { border: 12px solid transparent; border-image: url(../assets/ui/panel_cream.webp) 44 fill / 12px stretch; color: var(--ink); }
.plate-cream { border: 22px solid transparent; border-image: url(../assets/ui/panel_cream.webp) 44 fill / 22px stretch; }
.dpanel { border: 14px solid transparent; border-image: url(../assets/ui/panel_dark.webp) 46 fill / 14px stretch; color: var(--cream); }
.ribbon { display: flex; justify-content: center; }
.ribbon span { font-family: var(--f-disp); letter-spacing: .04em; text-transform: uppercase; line-height: 1; white-space: nowrap; }
.ribbon.red span { color: var(--cream); padding: 9px 30px 10px; border: 12px solid transparent; border-image: url(../assets/ui/ribbon_red.webp) 40 70 fill / 12px 26px stretch; text-shadow: 0 2px 0 #4d120c; font-size: 20px; }
.ribbon.gold span { color: var(--ink); padding: 8px 26px; background: linear-gradient(#f6dc93, #d4a64a 55%, #b9882f); border: 2px solid var(--gold2); border-radius: 6px; box-shadow: 0 0 0 3px var(--iron), 0 3px 0 4px #0003; font-size: 17px; }
.ribbon.gold.sm span { font-size: 15px; padding: 6px 20px; }
.ribbon.left { justify-content: flex-start; }
.btn-orange { border: 14px solid transparent; border-image: url(../assets/ui/btn_orange.webp) 70 fill / 14px stretch; color: var(--cream); font-family: var(--f-disp); text-shadow: 0 2px 0 #7a2c10; transition: transform .08s, filter .15s; }
.btn-orange:active, .btn-play:active, .plate.btn:active, .btn-gold:active { transform: translateY(2px) scale(.98); filter: brightness(.92); }
.btn-orange.sm { font-size: 15px; padding: 2px 10px; border-width: 10px; border-image-width: 10px; }
.btn-orange[disabled], .btn-orange.off { filter: grayscale(.8) brightness(.75); pointer-events: none; }
.ico-btn { width: 42px; height: 42px; display: grid; place-items: center; color: var(--gold); background: var(--iron); border: 2px solid var(--gold2); border-radius: 10px; box-shadow: inset 0 0 0 2px #0006; flex: none; }
.ico-btn svg { width: 24px; height: 24px; }
.ico-btn.lang-btn { position: relative; z-index: 55; width: auto; min-width: 42px; max-width: 124px; padding: 0 9px; display: inline-flex; align-items: center; justify-content: center; gap: 3px; font-size: 12px; font-weight: 800; color: var(--cream); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px 0 4px; background: var(--iron); color: var(--cream); border: 2px solid var(--gold2); border-radius: 18px; font-size: 16px; }
.pill img { width: 28px; height: 28px; object-fit: contain; }

/* ---------- sảnh ---------- */
.lobby { background: #f3e8cd url(../assets/ui/bg_lobby.webp) center / cover; }
.topbar { display: flex; align-items: center; gap: 8px; padding: calc(8px + var(--sa-t)) 10px 8px; background: var(--iron); border-bottom: 3px solid var(--gold2); color: var(--cream); }
.me { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; overflow: hidden; text-align: start; }
.crest { width: 44px; height: 44px; border-radius: 50%; overflow: hidden; border: 3px solid var(--gold); background: var(--cream); flex: none; }
.crest img { width: 100%; height: 100%; object-fit: cover; }
.me-txt { display: flex; flex-direction: column; min-width: 0; overflow: hidden; line-height: 1.1; }
.me-txt b { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-txt small { color: var(--gold); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 420px) {
  .topbar { gap: 4px; padding-inline: 6px; }
  .me { gap: 5px; }
  .crest { width: 34px; height: 34px; border-width: 2px; }
  .me-txt b { font-size: 13.5px; }
  .me-txt small { font-size: 11.5px; }
  .pill { height: 30px; padding: 0 7px 0 3px; gap: 4px; font-size: 13px; }
  .pill img { width: 20px; height: 20px; }
  .ico-btn { width: 34px; height: 34px; }
  .ico-btn svg { width: 20px; height: 20px; }
  .ico-btn.lang-btn { height: 34px; padding: 0 6px; font-size: 11.5px; max-width: 98px; }
}
.lobby-body { flex: 1; overflow-y: auto; padding: 10px 16px 14px; }
.tabpage { display: none; flex-direction: column; gap: 10px; min-height: 100%; }
.tabpage.on { display: flex; }
.logo { text-align: center; padding: 10px 10px 8px; border: 26px solid transparent; border-image: url(../assets/ui/stamp_frame.webp) 70 fill / 22px stretch; }
.logo h1 { margin: 0; font-family: var(--f-disp); font-weight: 400; font-size: clamp(32px, 9.5vw, 54px); line-height: .95; color: #5a2a1c; letter-spacing: .02em; text-shadow: 0 3px 0 #c9b48c; }
.logo .sub { margin: 6px 0 0; font-family: var(--f-disp); font-size: 15px; letter-spacing: .18em; color: var(--ink); }
.showcase { position: relative; }
.showcase .ribbon { position: relative; z-index: 2; margin-bottom: -16px; }
.preview-slot { position: relative; height: clamp(170px, 27vh, 330px); border: 14px solid transparent; border-image: url(../assets/ui/panel_cream.webp) 44 fill / 14px stretch; overflow: hidden; }
.preview-slot canvas, .stage-slot canvas { position: absolute; inset: 0; width: 100% !important; height: 100% !important; display: block; }
.tagline { display: flex; align-items: center; gap: 10px; margin: 2px 0; font-size: 17px; font-weight: 900; text-align: center; justify-content: center; }
.tagline::before, .tagline::after { content: ''; flex: 1; max-width: 50px; height: 2px; background: var(--ink); }
.qm { display: flex; align-items: center; gap: 10px; padding: 2px 8px; font-size: 17px; }
.qm .sep { flex: 1; border-inline-end: 2px solid #3b2f2f55; align-self: stretch; margin: 2px 0; }
.qm .online { font-size: 15px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--teal); margin-inline-end: 4px; box-shadow: 0 0 0 2px #2a7b7633; animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 5px #2a7b7600; } }
.btn-play { display: flex; flex-direction: column; align-items: center; padding: 6px 0 10px; border: 22px solid transparent; border-image: url(../assets/ui/btn_orange.webp) 70 fill / 22px stretch; color: var(--cream); text-shadow: 0 3px 0 #7a2c10; transition: transform .08s; }
.btn-play b { font-family: var(--f-disp); font-weight: 400; font-size: clamp(40px, 12vw, 58px); line-height: 1; }
.btn-play small { font-size: 18px; font-weight: 900; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.plate.btn { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 6px 4px; font-family: var(--f-disp); font-size: 18px; }
.plate.btn svg { width: 28px; height: 28px; }
.bottomnav { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--iron); border-top: 3px solid var(--gold2); padding-bottom: var(--sa-b); }
.bottomnav button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 7px; color: #cdb98c; font-size: 13px; font-family: var(--f-disp); letter-spacing: .03em; border-bottom: 4px solid transparent; }
.bottomnav button svg { width: 30px; height: 30px; color: var(--gold); }
.bottomnav button.on { color: var(--cream); border-bottom-color: var(--orange); }
.sec-h { margin: 6px 0 0; font-family: var(--f-disp); font-weight: 400; font-size: 17px; }
.skins { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.skin { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 4px 2px; text-align: center; font-size: 13px; }
.skin canvas, .skin .sw { width: 60px; height: 60px; }
.skin.eq { outline: 3px solid var(--teal); outline-offset: -6px; }
.skin .cost { display: inline-flex; align-items: center; gap: 3px; font-size: 13px; }
.skin .cost img { width: 16px; height: 16px; }
.ups { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.up { display: grid; grid-template-columns: 64px 1fr; grid-template-rows: auto auto auto; gap: 0 8px; padding: 2px; align-items: center; font-size: 13px; }
.up img { grid-row: 1 / 4; width: 64px; height: 64px; object-fit: contain; }
.up b { font-size: 15px; }
.up small { opacity: .8; }
.up .btn-orange { justify-self: start; margin-top: 4px; display: inline-flex; align-items: center; gap: 4px; }
.up .btn-orange img { width: 18px; height: 18px; grid-row: auto; }
.boxrow { display: flex; align-items: center; gap: 10px; padding: 2px 4px; }
.boxrow img { width: 54px; height: 54px; object-fit: contain; }
.boxrow > div { flex: 1; display: flex; flex-direction: column; }
.boxrow small { font-size: 12px; opacity: .75; }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--iron); border: 2px solid var(--gold2); border-radius: 10px; padding: 3px; margin-top: 6px; }
.seg button { padding: 8px; border-radius: 7px; color: var(--cream); font-size: 15px; }
.seg button.on { background: var(--orange); }
.lb-note { margin: 0; font-size: 13px; text-align: center; opacity: .75; }
.lb { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.lb li, .lb-me { display: grid; grid-template-columns: 34px 34px 1fr auto; gap: 8px; align-items: center; padding: 5px 10px; background: #fffaf0; border: 2px solid #3b2f2f22; border-radius: 6px; font-size: 15px; }
.lb li:nth-child(1) { background: #f6dc93; } .lb li:nth-child(2) { background: #e8e1d2; } .lb li:nth-child(3) { background: #ecc7a4; }
.lb .n { font-family: var(--f-disp); text-align: center; }
.lb img, .lb-me img { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; border: 2px solid var(--gold2); background: var(--cream); }
.lb .nm, .lb-me .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb .nm small, .lb-me .nm small { font-size: 11px; color: var(--teal); margin-inline-start: 4px; }
.lb .v, .lb-me .v { font-family: var(--f-disp); font-size: 15px; }
.lb-me { position: sticky; bottom: 0; border: 12px solid transparent; }

/* ---------- trong ván ---------- */
.game { background: var(--iron) url(../assets/ui/bg_game.webp) center / cover; display: none; flex-direction: column; color: var(--ink); }
.game.on { display: grid; grid-template-rows: auto 1fr; }
.game .g-side { display: contents; }
.g-title { position: relative; padding: calc(4px + var(--sa-t)) 56px 0; grid-row: 1; }
.g-title .ribbon.red span { font-size: 18px; padding: 7px 26px; }
.g-title .ico-btn { position: absolute; inset-inline-end: 8px; top: calc(4px + var(--sa-t)); width: 38px; height: 38px; }
.g-stats { display: grid; grid-template-columns: 1fr 1.05fr 1fr; gap: 6px; padding: 4px 8px 0; align-items: center; }
.stat { text-align: center; display: flex; flex-direction: column; justify-content: center; min-height: 58px; padding: 0 2px; line-height: 1; }
.stat small { font-family: var(--f-disp); font-size: 12px; letter-spacing: .05em; }
.stat b { font-family: var(--f-disp); font-weight: 400; font-size: 28px; }
.stat.time { color: var(--cream); border: 12px solid transparent; border-image: url(../assets/ui/btn_orange.webp) 70 fill / 12px stretch; filter: hue-rotate(-12deg) saturate(1.1) brightness(.8); }
.stat.time.hurry b { animation: blink .5s infinite alternate; }
@keyframes blink { to { color: #ffd27a; } }
.g-board { display: grid; grid-template-columns: repeat(4, 1fr); margin: 4px 8px 0; padding: 0; border-width: 8px; border-image-width: 8px; font-size: 13px; }
.g-board .pl { display: flex; align-items: center; gap: 4px; padding: 2px 4px; min-width: 0; border-inline-end: 1px solid #3b2f2f33; }
.g-board .pl:last-child { border: 0; }
.g-board .rk { flex: none; width: 20px; height: 22px; display: grid; place-items: center; color: var(--cream); font-family: var(--f-disp); font-size: 12px; background: var(--teal); clip-path: polygon(0 0, 100% 0, 100% 70%, 50% 100%, 0 70%); }
.g-board .pl.me .rk { background: var(--red); }
.g-board .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.g-board .sc { font-family: var(--f-disp); font-size: 13px; }
.g-stage { position: relative; grid-row: 2; min-height: 0; }
.stage-slot { position: absolute; inset: 0; }
.stage-slot canvas { touch-action: none; }
.opp { position: absolute; z-index: 3; pointer-events: none; display: flex; flex-direction: column; align-items: center; transition: transform .2s; }
.opp[data-pos=top] { top: 6px; left: 50%; transform: translateX(-50%); }
.opp[data-pos=top] { top: 4px; }
.opp[data-pos=left] { left: 3px; top: 4px; }
.opp[data-pos=right] { right: 3px; top: 4px; }
.opp .tag { display: flex; align-items: center; gap: 4px; margin-bottom: -5px; z-index: 1; padding: 2px 8px 2px 2px; background: var(--red); color: var(--cream); border: 2px solid var(--gold); border-radius: 12px; font-size: 12px; max-width: 112px; }
.opp .tag img { width: 20px; height: 20px; border-radius: 50%; object-fit: cover; background: var(--cream); }
.opp .tag span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.opp .tag em { font-style: normal; font-size: 10px; opacity: .8; }
.opp .tray { display: flex; gap: 3px; padding: 2px; border: 8px solid transparent; border-image: url(../assets/ui/panel_cream.webp) 44 fill / 8px stretch; }
.slot-s { position: relative; width: 31px; height: 31px; background: #fffaf0; border: 2px solid #3b2f2f33; border-radius: 4px; display: grid; place-items: center; }
.slot-s img { width: 28px; height: 28px; object-fit: contain; }
.slot-s.done img { filter: saturate(.7); }
.slot-s.done::after, .slot-l.done::after { content: ''; position: absolute; right: -3px; bottom: -3px; width: 16px; height: 16px; border-radius: 50%; background: #3f8a3a url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5 10 17l9-10'/%3E%3C/svg%3E") center / 70% no-repeat; border: 2px solid #fff; }
.slot-s.jam, .slot-l.jam { background: #f3d6c6; }
.slot-s.jam img, .slot-l.jam img.it { opacity: .25; }
.slot-s.jam::before, .slot-l.jam::before { content: ''; position: absolute; inset: 8%; background: url(../assets/ui/lockbox.webp) center / contain no-repeat; z-index: 1; }
.opp.leader .tag::after { content: ''; width: 14px; height: 12px; background: var(--gold); clip-path: polygon(0 100%, 0 20%, 25% 55%, 50% 0, 75% 55%, 100% 20%, 100% 100%); }
.opp.hit { animation: shake .4s; }
@keyframes shake { 25% { translate: -5px 0; } 50% { translate: 5px 0; } 75% { translate: -3px 0; } }
.g-order { padding: 0 8px; }
.ord-head { display: flex; align-items: center; justify-content: center; gap: 6px; margin-bottom: -10px; position: relative; z-index: 2; }
.ord-head .ribbon.red span { font-size: 18px; padding: 6px 22px; }
.ord-n { font-family: var(--f-disp); font-size: 17px; padding: 0 10px; border-width: 9px; border-image-width: 9px; }
.ord-slots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 18px 16px 10px; border: 16px solid transparent; border-image: url(../assets/ui/panel_cream.webp) 44 fill / 16px stretch; }
.slot-l { position: relative; aspect-ratio: 1.12; background: #fffaf0; border: 3px solid #3b2f2f44; border-radius: 6px; display: grid; place-items: center; box-shadow: inset 0 0 0 3px #e9dcbc; transition: transform .15s; }
.slot-l img.it { width: 84%; height: 84%; object-fit: contain; }
.slot-l.done::after { width: 26px; height: 26px; right: -6px; bottom: -6px; }
.slot-l.need { animation: needpulse 1.4s infinite; }
@keyframes needpulse { 50% { box-shadow: inset 0 0 0 3px var(--orange); } }
.slot-l.pop { transform: scale(1.12); }
.slot-l .nm { position: absolute; bottom: 2px; left: 0; right: 0; text-align: center; font-size: 11px; color: #3b2f2f99; }
.ord-hint { margin: -12px auto 0; width: max-content; max-width: 92%; font-size: 15px; font-style: italic; padding: 0 12px; border-width: 9px; border-image-width: 9px; position: relative; z-index: 2; text-align: center; }
.g-actions { display: grid; grid-template-columns: 1.15fr .8fr 1.2fr; gap: 6px; padding: 6px 8px 0; align-items: stretch; }
.act-lock { display: flex; align-items: center; gap: 4px; padding: 4px 6px; color: var(--cream); border: 12px solid transparent; border-image: url(../assets/ui/panel_dark.webp) 46 fill / 12px stretch; }
.act-lock img { width: 42px; height: 42px; object-fit: contain; }
.act-lock span { display: flex; flex-direction: column; align-items: center; flex: 1; line-height: 1.05; }
.act-lock b { font-family: var(--f-disp); font-size: 14px; text-align: center; }
.act-lock i { font-style: normal; font-family: var(--f-disp); font-size: 16px; background: var(--red); border: 2px solid var(--gold); border-radius: 6px; padding: 0 12px; margin-top: 2px; }
.act-lock.ready { animation: ready 0.9s infinite alternate; }
@keyframes ready { to { filter: brightness(1.25) drop-shadow(0 0 6px #e06d3b); } }
.act-lock.empty { filter: grayscale(.6) brightness(.8); }
.act-orders { display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; padding: 0; }
.act-orders b { font-family: var(--f-disp); font-size: 22px; }
.act-orders small { font-family: var(--f-disp); font-size: 11px; }
.act-grab { font-size: clamp(28px, 9vw, 40px); padding: 0; min-height: 64px; }
.act-grab.hot { animation: ready .4s infinite alternate; }
.g-tip { margin: 4px 8px calc(6px + var(--sa-b)); text-align: center; font-size: 13px; font-style: italic; color: var(--cream); opacity: .9; }
/* bố cục dọc: xếp theo thứ tự của thiết kế */
@media (orientation: portrait), (max-aspect-ratio: 1/1) {
  .game.on { grid-template-rows: auto auto auto 1fr auto auto auto; }
  .g-title { grid-row: 1; } .g-stats { grid-row: 2; } .g-board { grid-row: 3; } .g-stage { grid-row: 4; }
  .g-order { grid-row: 5; } .g-actions { grid-row: 6; } .g-tip { grid-row: 7; }
}
/* bố cục ngang riêng: băng chuyền bên trái, bảng điều khiển bên phải */
@media (orientation: landscape) and (min-aspect-ratio: 1/1) {
  .screen.game { max-width: none; }
  .game.on { grid-template-columns: 1fr minmax(330px, 38%); grid-template-rows: 1fr; }
  .game .g-side { display: flex; flex-direction: column; grid-column: 2; grid-row: 1; overflow-y: auto; padding: 0 0 6px; background: #2b262688; border-inline-start: 3px solid var(--gold2); justify-content: space-between; }
  .g-stage { grid-column: 1; grid-row: 1; }
  .ord-slots { padding: 14px 12px 8px; }
  .slot-l { aspect-ratio: 1.9; min-width: 0; }
  .ord-slots { gap: 5px; } .ord-slots > * { min-width: 0; }
  .g-side { gap: 2px; }
  .g-title { position: absolute; z-index: 6; left: 6px; bottom: 6px; padding: 0; }
  .g-title .ribbon { display: none; }
  .g-title .ico-btn { position: static; }
  .g-stats { padding-top: 6px; }
  .ord-hint { font-size: 13px; }
  .g-actions { padding-bottom: 4px; }
  .lobby #tab-home .tagline { display: none; }
  .lobby .logo { padding: 4px; } .lobby .logo .sub { font-size: 12px; }
  .stat { min-height: 44px; } .stat b { font-size: 22px; }
  .g-title .ribbon.red span { font-size: 15px; padding: 5px 20px; }
  .act-grab { min-height: 50px; font-size: 26px; } .act-lock img { width: 32px; height: 32px; }
  .g-tip { display: none; }
  .screen.lobby, .screen.result { max-width: 760px; }
  .lobby #tab-home { display: none; }
  .lobby #tab-home.on { display: grid; grid-template-columns: 1.15fr 1fr; grid-template-rows: auto auto auto auto 1fr; column-gap: 16px; align-content: start; }
  .lobby #tab-home .logo { grid-column: 2; grid-row: 1; }
  .lobby #tab-home .showcase { grid-column: 1; grid-row: 1 / 6; }
  .lobby #tab-home .preview-slot { height: calc(100vh - 150px); min-height: 220px; }
  .lobby #tab-home .tagline { grid-column: 2; } .lobby #tab-home .qm, .lobby #tab-home .btn-play, .lobby #tab-home .row2 { grid-column: 2; }
  .logo h1 { font-size: 30px; } .btn-play b { font-size: 34px; } .btn-play small { font-size: 14px; } .btn-play { padding: 0 0 4px; }
}
.tug-ui { position: absolute; z-index: 5; left: 50%; bottom: 8px; transform: translateX(-50%); display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 2px 8px; width: min(300px, 86%); padding: 6px 14px; background: var(--orange); color: var(--cream); border: 3px solid var(--gold); border-radius: 8px; font-family: var(--f-disp); font-size: 18px; box-shadow: 0 4px 0 #0005; }
.tug-ui small { width: 100%; text-align: center; font-family: var(--f-text); font-size: 12px; }
.tug-bar { width: 100%; height: 10px; display: flex; background: var(--iron); border-radius: 5px; overflow: hidden; }
.tug-bar i { display: block; height: 100%; transition: width .1s; }
#tug-l { background: var(--teal); width: 50%; } #tug-r { background: #c9402c; width: 50%; }
.jam-ui { position: absolute; z-index: 5; left: 50%; bottom: 8px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; padding: 6px 16px; background: var(--red); color: var(--cream); border: 3px solid var(--gold); border-radius: 8px; font-family: var(--f-disp); animation: shake .5s; }
.jam-ui small { font-family: var(--f-text); font-size: 12px; }
.banner { position: absolute; z-index: 6; left: 50%; top: 42%; transform: translate(-50%, -50%); padding: 10px 24px; font-family: var(--f-disp); font-size: clamp(22px, 7vw, 34px); color: var(--cream); background: var(--red); border: 3px solid var(--gold); border-radius: 8px; white-space: nowrap; text-shadow: 0 2px 0 #4d120c; box-shadow: 0 6px 0 #0006; animation: bannerIn .35s cubic-bezier(.2, 1.6, .4, 1); pointer-events: none; }
.banner.teal { background: var(--teal); } .banner.orange { background: var(--orange); }
@keyframes bannerIn { from { transform: translate(-50%, -50%) scale(.3); opacity: 0; } }
.countdown { position: absolute; z-index: 6; inset: 0; display: grid; place-items: center; font-family: var(--f-disp); font-size: 110px; color: var(--cream); text-shadow: 0 6px 0 var(--red), 0 0 30px #000a; pointer-events: none; }

/* ---------- kết quả ---------- */
.result { background: #1d1a19 url(../assets/ui/bg_game.webp) center / cover; color: var(--cream); overflow-y: auto; padding: calc(6px + var(--sa-t)) 10px calc(10px + var(--sa-b)); gap: 8px; }
.result.on { display: flex; }
.r-top { display: flex; align-items: center; justify-content: center; position: relative; }
.r-brand { display: flex; align-items: center; gap: 8px; padding: 6px 22px; font-family: var(--f-disp); font-size: 20px; color: var(--gold); background: var(--iron); border: 2px solid var(--gold2); border-radius: 8px; }
.r-top .ico-btn { position: absolute; inset-inline-end: 0; }
.r-hero { text-align: center; position: relative; padding-top: 4px; }
.r-hero h2 { margin: 0; font-family: var(--f-disp); font-weight: 400; font-size: clamp(38px, 12vw, 58px); line-height: 1; color: #f2cf73; text-shadow: 0 3px 0 #6b4a17, 0 6px 12px #000a; }
.r-sub { display: inline-block; margin-top: 4px; padding: 3px 26px; background: linear-gradient(#f6dc93, #c79a3c); color: var(--ink); font-weight: 900; border-radius: 4px; border: 2px solid var(--gold2); }
.r-belt { position: relative; height: 120px; margin-top: 4px; background: linear-gradient(transparent 52%, var(--teal) 52%, var(--teal) 66%, #1b1716 66%, #1b1716 72%, transparent 72%); }
.r-belt::before { content: ''; position: absolute; left: 0; right: 0; top: 52%; height: 14%; background: repeating-linear-gradient(90deg, #0003 0 3px, transparent 3px 14px); animation: beltmove .6s linear infinite; }
@keyframes beltmove { to { background-position: 14px 0; } }
.r-medal { position: absolute; left: 50%; top: 0; height: 120px; transform: translateX(-50%); animation: medal 1s cubic-bezier(.2, 1.5, .4, 1); filter: drop-shadow(0 6px 8px #000a); }
@keyframes medal { from { transform: translateX(-50%) translateY(-60px) scale(.4) rotate(-30deg); opacity: 0; } }
.r-stats { display: grid; grid-template-columns: repeat(3, 1fr); }
.r-stats div { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 8px; align-items: center; padding: 0 6px; border-inline-end: 1px solid #d4a64a55; }
.r-stats div:last-child { border: 0; }
.r-stats svg { grid-row: 1 / 3; width: 36px; height: 36px; color: var(--gold); }
.r-stats b { font-family: var(--f-disp); font-size: 24px; line-height: 1; }
.r-stats small { font-size: 13px; }
.dpanel .ribbon { margin: -2px 0 6px; }
.r-table { display: flex; flex-direction: column; gap: 3px; font-size: 15px; }
.r-row { display: grid; grid-template-columns: 36px minmax(0, 1fr) 64px 72px; align-items: center; gap: 6px; padding: 5px 8px; background: #ffffff0d; border-radius: 4px; }
.r-row > span:nth-child(n+3) { text-align: end; font-family: var(--f-disp); }
.r-head { background: none; padding-block: 0; font-size: 12px; color: #cdb98c; }
.r-head > span { font-family: var(--f-text) !important; font-weight: 800; }
.r-row.me { background: linear-gradient(#f2d17c, #c99a3b); color: var(--ink); }
.r-table .rk { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; font-family: var(--f-disp); color: var(--ink); background: #bdbdbd; border: 2px solid #fff6; }
#r-rows .r-row:nth-child(1) .rk { background: #f2cf73; } #r-rows .r-row:nth-child(3) .rk { background: #c7804f; }
.r-table .who { display: flex; align-items: center; gap: 6px; min-width: 0; } .r-table .who > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.r-table .who img { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; background: var(--cream); flex: none; }
.r-table .who small { font-size: 11px; opacity: .7; }
.r-rew { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.rew { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 8px; align-items: center; padding: 6px; background: #ffffff0a; border: 1px solid #d4a64a55; border-radius: 6px; }
.rew img { grid-row: 1 / 3; width: 58px; height: 58px; object-fit: contain; }
.rew b { font-family: var(--f-disp); font-size: 26px; line-height: 1; }
.ups-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.ups-head .ribbon { margin: 0; }
.pill.dark { background: #0005; }
.result .up { background: #ffffff0a; border: 1px solid #d4a64a55; border-radius: 6px; padding: 4px; color: var(--cream); }
.r-btns { display: grid; grid-template-columns: 1.6fr 1fr; gap: 10px; margin-top: 4px; }
.btn-gold, .btn-darkgold { font-family: var(--f-disp); font-size: clamp(20px, 6.5vw, 30px); padding: 12px 6px; border-radius: 10px; border: 3px solid var(--gold2); }
.btn-gold { background: linear-gradient(#f6dc93, #d4a64a 55%, #a87a2a); color: var(--ink); box-shadow: inset 0 2px 0 #fff8, 0 4px 0 #0007; }
.btn-darkgold { background: var(--iron); color: #f2cf73; box-shadow: inset 0 0 0 2px #0008, 0 4px 0 #0007; }
.r-next { text-align: center; margin: 0; font-size: 14px; color: #cdb98c; }

/* ---------- hộp thoại ---------- */
.modal, .searching { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: #1b1716cc; }
.sheet { width: min(440px, 100%); max-height: 86vh; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; color: var(--ink); }
.sheet h3 { margin: 0; font-family: var(--f-disp); font-weight: 400; font-size: 22px; text-align: center; }
.sheet .muted, .muted { opacity: .75; font-size: 14px; text-align: center; margin: 0; }
.sheet .row { display: flex; gap: 8px; align-items: center; }
.sheet input { flex: 1; min-width: 0; font: inherit; font-size: 17px; padding: 10px 12px; border: 2px solid #3b2f2f55; border-radius: 6px; background: #fffaf0; color: var(--ink); }
.sheet .opt { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 4px; border-bottom: 1px dashed #3b2f2f33; font-size: 16px; }
.sheet .opt svg { color: var(--teal); }
.sheet .avs { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.sheet .avs button { border-radius: 50%; overflow: hidden; border: 3px solid transparent; aspect-ratio: 1; background: var(--cream); }
.sheet .avs button.on { border-color: var(--orange); }
.sheet .avs img { width: 100%; height: 100%; object-fit: cover; }
.sheet .rlist { display: flex; flex-direction: column; gap: 5px; }
.sheet .rm { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; padding: 7px 10px; background: #fffaf0; border: 2px solid #3b2f2f22; border-radius: 6px; font-size: 13px; }
.sheet .rm .ppl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet .rm .st { font-family: var(--f-disp); color: var(--teal); }
.sheet .code { font-family: var(--f-disp); font-size: 40px; text-align: center; letter-spacing: .2em; color: var(--red); }
.sheet .steps { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sheet .step { padding: 6px; background: #fffaf0; border: 2px solid #3b2f2f22; border-radius: 6px; font-size: 13px; text-align: center; }
.sheet .step b { display: block; font-family: var(--f-disp); font-weight: 400; font-size: 15px; color: var(--red); }
.sheet .step img { width: 54px; height: 54px; object-fit: contain; }
.switch { width: 52px; height: 30px; border-radius: 15px; background: #bbb; position: relative; transition: background .2s; }
.switch::after { content: ''; position: absolute; top: 3px; inset-inline-start: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch.on { background: var(--teal); } .switch.on::after { transform: translateX(22px); }
:lang(ar) .switch.on::after { transform: translateX(-22px); }
.seats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.seat { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px; text-align: center; }
.seat .a { width: 62px; height: 62px; border-radius: 50%; border: 3px dashed #3b2f2f55; background: #fffaf0; overflow: hidden; display: grid; place-items: center; }
.seat.in .a { border: 3px solid var(--teal); animation: pop .3s; }
.seat .a img { width: 100%; height: 100%; object-fit: cover; }
.seat span { max-width: 74px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@keyframes pop { from { transform: scale(.4); } }
.toast { position: fixed; z-index: 60; left: 50%; top: calc(70px + var(--sa-t)); transform: translateX(-50%); padding: 8px 18px; background: var(--ink); color: var(--cream); border: 2px solid var(--gold); border-radius: 8px; font-size: 15px; max-width: 90%; text-align: center; animation: bannerIn .25s; }
.boot { position: fixed; inset: 0; z-index: 99; display: grid; place-items: center; background: var(--iron); transition: opacity .4s; }
.boot.done { opacity: 0; pointer-events: none; }
.boot-in { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.boot img { width: 90px; animation: bob 1s ease-in-out infinite alternate; }
@keyframes bob { to { transform: translateY(-8px); } }
.boot .bar { width: 180px; height: 10px; border: 2px solid var(--gold2); border-radius: 6px; overflow: hidden; }
.boot .bar i { display: block; height: 100%; width: 5%; background: var(--orange); transition: width .2s; }
/* popup ngôn ngữ dùng chung — đổi sang chất liệu của game */
#vds-lang-pop { font-family: var(--f-text) !important; background: #1b1716cc !important; }
#vds-lang-pop > div { background: var(--cream) !important; color: var(--ink) !important; border: 4px solid var(--gold2) !important; border-radius: 10px !important; }
#vds-lang-pop button { background: #fffaf0 !important; color: var(--ink) !important; border: 2px solid #3b2f2f33 !important; font-weight: 800; }
#vds-lang-pop button[style*="6366f1"] { background: var(--orange) !important; color: var(--cream) !important; border-color: var(--gold2) !important; }
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01ms !important; } }

.r-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.r-share { font-size: 15px; padding: 2px 10px; }
.r-share svg { width: 20px; height: 20px; }
.emote-bar { position: absolute; z-index: 6; inset-inline-end: 8px; bottom: 8px; display: flex; flex-direction: column-reverse; align-items: flex-end; gap: 6px; }
.emote-btn { width: 44px; height: 44px; display: grid; place-items: center; color: var(--cream); background: var(--teal); border: 2px solid var(--gold); border-radius: 50%; box-shadow: 0 3px 0 #0006; }
.emote-pick { display: flex; flex-direction: column; gap: 4px; }
.emote-pick button, .stamp { font-family: var(--f-disp); font-size: 14px; color: var(--red); background: var(--cream); padding: 5px 12px; border: 2px dashed var(--red); outline: 3px solid var(--cream); border-radius: 3px; white-space: nowrap; }
.stamp { position: absolute; z-index: 7; pointer-events: none; transform: rotate(-8deg); animation: stampIn .25s cubic-bezier(.2, 1.8, .4, 1), stampOut .4s 1.8s forwards; box-shadow: 0 3px 0 #0005; }
@keyframes stampIn { from { transform: rotate(-8deg) scale(2.2); opacity: 0; } }
@keyframes stampOut { to { opacity: 0; transform: rotate(-8deg) translateY(-10px); } }

/* ---- lượt 2: sửa lỗi tab Bộ sưu tập / Xếp hạng (báo cáo soi luồng C/D) ---- */
.ups { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 420px) and (orientation: portrait) { .tabpage .ups { grid-template-columns: minmax(0, 1fr); } }
.up { min-width: 0; } .up b, .up small { min-width: 0; overflow-wrap: anywhere; }
.up .btn-orange { white-space: nowrap; }
.boxrow .cnt { display: flex; align-items: baseline; gap: 5px; }
.skin b { min-height: 2.4em; display: flex; align-items: center; justify-content: center; line-height: 1.15; }
.skin .cost { margin-top: auto; }
.lb li.mine { background: #d8ece9; outline: 3px solid var(--teal); outline-offset: -3px; }
.lb .n, .lb-me .n { font-family: var(--f-disp); text-align: center; font-size: 14px; }
.lb li, .lb-me { grid-template-columns: 44px 34px minmax(0, 1fr) auto; }
.lb-me { grid-template-columns: 44px 34px minmax(0, 1fr) auto auto; border-style: solid; border-color: transparent; border-width: 12px; border-image: url(../assets/ui/panel_cream.webp) 44 fill / 12px stretch; background: none; bottom: -14px; z-index: 2; }
.lb-me .you { font-size: 11px; color: var(--cream); background: var(--teal); padding: 1px 6px; border-radius: 4px; }
.lb .nm small { margin-inline-start: 4px; }
.lb .v, .lb-me .v { unicode-bidi: isolate; }
bdi { unicode-bidi: isolate; }
:lang(ar) .ribbon span, :lang(ar) .sec-h, :lang(ar) h1, :lang(ar) .btn-play b, :lang(ar) .stat b, :lang(ar) .bottomnav button,
:lang(zh-Hans) .ribbon span, :lang(zh-Hant) .ribbon span, :lang(ja) .ribbon span, :lang(ko) .ribbon span, :lang(hi) .ribbon span,
:lang(zh-Hans) .sec-h, :lang(zh-Hant) .sec-h, :lang(ja) .sec-h, :lang(ko) .sec-h, :lang(hi) .sec-h { font-weight: 900; }
:lang(ar) { --f-disp: 'Lalezar', 'Alfa Slab One', 'Noto Kufi Arabic', 'Segoe UI', sans-serif; }
.tug-ui, .jam-ui { bottom: auto; top: 82px; }
@media (orientation: landscape) and (min-aspect-ratio: 1/1) {
  .lobby-body { padding-inline: 40px; }
  .skins { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .lb, .lb-me, .seg, .lb-note { max-width: 640px; margin-inline: auto; width: 100%; }
  .lb-me { padding-block: 0; }
  .tabpage .ups { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (orientation: landscape) and (max-height: 430px) {
  .topbar { padding-block: 4px; } .crest { width: 34px; height: 34px; }
  .lobby #tab-home .logo { border-width: 16px; border-image-width: 16px; padding: 0 4px; }
  .lobby #tab-home .logo h1 { font-size: 24px; } .lobby #tab-home .logo .sub { display: none; }
  .lobby #tab-home .preview-slot { height: calc(100vh - 140px); }
  .lobby #tab-home .qm { font-size: 14px; } .lobby #tab-home .row2 .plate.btn { font-size: 14px; padding: 0; }
  .lobby #tab-home .btn-play { border-width: 14px; border-image-width: 14px; }
  .lobby .tabpage { gap: 6px; } .bottomnav button { padding: 3px 0; flex-direction: row; justify-content: center; gap: 6px; } .bottomnav button svg { width: 22px; height: 22px; }
}
