:root {
  --red: #d7263d;
  --red-d: #9e1b2b;
  --red-l: #ff5a6e;
  --gold: #ffc93c;
  --gold-d: #e09b12;
  --gold-l: #ffe58a;
  --green: #2f8f5b;
  --green-d: #1d5e3b;
  --leaf: #4caf50;
  --pink: #ff9ec7;
  --cream: #fff6e5;
  --ink: #3b1a12;
  --ink-2: #7a4a3a;
  --bg: #fff1dc;
  --panel: #fffaf1;
  --line: rgba(59, 26, 18, .12);
  --clay: 6px 8px 18px rgba(120, 40, 20, .22), inset -3px -4px 8px rgba(0, 0, 0, .10), inset 3px 4px 8px rgba(255, 255, 255, .65);
  --clay-sm: 3px 4px 10px rgba(120, 40, 20, .22), inset -2px -2px 5px rgba(0, 0, 0, .10), inset 2px 2px 5px rgba(255, 255, 255, .6);
  --radius: 22px;
  --cw: clamp(46px, 7.2vw, 74px);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: 'Baloo 2', system-ui, 'Segoe UI', sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 10% -10%, #ffd6a0 0%, transparent 60%),
    radial-gradient(900px 500px at 110% 0%, #ffc2cf 0%, transparent 55%),
    var(--bg);
  min-height: 100vh;
  overflow-x: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; }
input { font: inherit; }
.hidden { display: none !important; }
#fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 50; }

/* ---------- buttons ---------- */
.btn {
  border: 0; border-radius: 999px; padding: 10px 18px; font-weight: 700; font-size: 16px; line-height: 1.1;
  box-shadow: var(--clay-sm); transition: transform .12s ease, filter .12s ease; white-space: nowrap;
}
.btn:hover { filter: brightness(1.05); transform: translateY(-1px); }
.btn:active { transform: translateY(1px) scale(.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; filter: grayscale(.4); }
.btn:focus-visible, .tabs button:focus-visible { outline: 3px solid #2563eb; outline-offset: 2px; }
.btn-red { background: linear-gradient(180deg, var(--red-l), var(--red)); color: #fff; }
.btn-gold { background: linear-gradient(180deg, var(--gold-l), var(--gold)); color: var(--ink); }
.btn-green { background: linear-gradient(180deg, #5fd08e, var(--green)); color: #fff; }
.btn-ghost { background: #fff; color: var(--ink); }
.btn-sm { padding: 6px 12px; font-size: 14px; }
.btn-lg { padding: 13px 26px; font-size: 18px; }

/* ---------- topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: linear-gradient(180deg, var(--red), var(--red-d));
  box-shadow: 0 4px 16px rgba(120, 20, 20, .3); color: #fff;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; }
.brand-mark { font-size: 30px; filter: drop-shadow(0 3px 2px rgba(0, 0, 0, .3)); }
.brand-text { display: flex; flex-direction: column; line-height: 1; }
.brand-text b { font-size: 22px; color: var(--gold-l); text-shadow: 0 2px 0 var(--red-d); }
.brand-text small { font-size: 13px; opacity: .9; }
.me-chip {
  display: flex; align-items: center; gap: 8px; border: 0; background: rgba(255, 255, 255, .15); color: #fff;
  border-radius: 999px; padding: 4px 6px 4px 4px; box-shadow: inset 0 0 0 2px rgba(255, 220, 120, .5);
}
.me-chip .av { width: 34px; height: 34px; border-radius: 50%; background: var(--cream); display: grid; place-items: center; font-size: 20px; }
.me-chip .nm { font-weight: 700; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.coin { display: inline-flex; align-items: center; gap: 4px; font-weight: 800; font-variant-numeric: tabular-nums; }
.me-chip .coin { background: var(--gold); color: var(--ink); border-radius: 999px; padding: 2px 10px; }

/* ---------- lobby ---------- */
#lobby { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; padding: 20px; max-width: 1280px; margin: 0 auto; }
.street {
  position: relative; border-radius: 28px; padding: 28px 24px 24px; overflow: hidden;
  background:
    linear-gradient(180deg, transparent 62%, #e9b77d 62%, #d89c5e 100%),
    linear-gradient(180deg, #ffe3b0, #ffcf8a);
  box-shadow: var(--clay);
}
.lanterns { position: absolute; inset: 0 0 auto; height: 90px; display: flex; justify-content: space-around; pointer-events: none; }
.lanterns::before { content: ''; position: absolute; left: 0; right: 0; top: 14px; height: 2px; background: #8a3b1f; opacity: .5; }
.lanterns i {
  position: relative; top: 14px; width: 34px; height: 42px; border-radius: 45%;
  background: radial-gradient(circle at 35% 30%, #ff8a8a, var(--red) 55%, var(--red-d));
  box-shadow: 0 0 22px rgba(255, 80, 60, .55); animation: sway 3.2s ease-in-out infinite; transform-origin: top center;
}
.lanterns i::after { content: ''; position: absolute; left: 50%; bottom: -14px; width: 4px; height: 14px; margin-left: -2px; background: var(--gold); border-radius: 2px; }
.lanterns i:nth-child(2n) { animation-delay: -1.2s; }
@keyframes sway { 0%, 100% { transform: rotate(-5deg); } 50% { transform: rotate(5deg); } }
.street-hero { position: relative; margin-top: 54px; text-align: center; }
.street-hero h1 { margin: 0; font-size: clamp(28px, 4.6vw, 46px); line-height: 1.05; color: var(--red-d); text-shadow: 0 3px 0 #fff3d1; }
.street-hero h1 span { color: var(--green-d); }
.street-hero p { margin: 8px 0 0; color: var(--ink-2); }
.booths { position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 24px; }
.booth { border-radius: 24px; overflow: hidden; background: var(--panel); box-shadow: var(--clay); transition: transform .2s ease; }
.booth:hover { transform: translateY(-4px) rotate(-.4deg); }
.awning {
  height: 34px;
  background: repeating-linear-gradient(90deg, var(--red) 0 34px, #fff4e0 34px 68px);
  border-bottom-left-radius: 50% 14px; border-bottom-right-radius: 50% 14px;
  -webkit-mask: radial-gradient(18px 12px at 17px 100%, transparent 98%, #000) 0 0/34px 100% repeat-x;
          mask: radial-gradient(18px 12px at 17px 100%, transparent 98%, #000) 0 0/34px 100% repeat-x;
}
.booth-tl .awning { background: repeating-linear-gradient(90deg, var(--green) 0 34px, #fff4e0 34px 68px); }
.booth-body { padding: 10px 18px 18px; text-align: center; }
.booth-sign { display: inline-block; padding: 4px 16px; border-radius: 12px; background: var(--red-d); color: var(--gold-l); box-shadow: var(--clay-sm); }
.booth-tl .booth-sign { background: var(--green-d); }
.booth-sign b { font-size: 22px; display: block; line-height: 1.1; }
.booth-art { display: flex; justify-content: center; margin: 14px 0 6px; height: 96px; }
.mini-card {
  width: 62px; height: 88px; margin: 0 -10px; border-radius: 12px; background: #fff; box-shadow: var(--clay-sm);
  display: grid; place-items: center; font-size: 26px; font-weight: 800; color: var(--red); line-height: .9;
  transform: rotate(-10deg); animation: bob 3s ease-in-out infinite;
}
.mini-card i { display: block; font-style: normal; font-size: 26px; }
.mini-card.k { color: var(--ink); transform: rotate(8deg) translateY(4px); animation-delay: -1.5s; }
.mini-card:nth-child(3) { transform: rotate(22deg) translateY(10px); animation-delay: -.7s; }
@keyframes bob { 50% { translate: 0 -6px; } }
.booth p { margin: 6px 0 14px; color: var(--ink-2); font-size: 14px; min-height: 40px; }
.join-form { position: relative; display: flex; gap: 10px; align-items: center; justify-content: center; margin-top: 24px; flex-wrap: wrap; }
.join-form label { font-weight: 700; color: var(--ink); }
.join-form input, .field input {
  width: 150px; padding: 10px 16px; border-radius: 999px; border: 0; background: #fff; text-transform: uppercase;
  box-shadow: inset 2px 3px 6px rgba(0, 0, 0, .12); font-weight: 700; letter-spacing: 2px; color: var(--ink);
}
.side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.panel { background: var(--panel); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--clay); }
.panel h2 { margin: 0 0 10px; font-size: 18px; color: var(--red-d); }
.panel-lixi { background: linear-gradient(160deg, #ffe1a6, #ffd07a); }
.lixi-row { display: flex; gap: 8px; flex-wrap: wrap; }
.hint { margin: 8px 0 0; font-size: 13px; color: var(--ink-2); }
.room-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; max-height: 240px; overflow: auto; }
.room-list li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 14px; background: #fff; box-shadow: var(--clay-sm); }
.room-list .rinfo { flex: 1; min-width: 0; font-size: 14px; line-height: 1.2; }
.room-list .rinfo b { display: block; font-size: 15px; }
.empty { color: var(--ink-2); font-size: 14px; text-align: center; padding: 8px; }
.tabs { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.tabs button { border: 0; border-radius: 999px; padding: 4px 12px; background: #f6e3c8; font-weight: 700; font-size: 14px; }
.tabs button.on { background: var(--red); color: #fff; }
.board { margin: 0; padding: 0; list-style: none; counter-reset: b; }
.board li { counter-increment: b; display: flex; align-items: center; gap: 8px; padding: 6px 4px; border-bottom: 1px dashed var(--line); }
.board li::before { content: counter(b); width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 13px; background: #f6e3c8; }
.board li:nth-child(1)::before { background: var(--gold); }
.board li .v { margin-left: auto; font-weight: 800; font-variant-numeric: tabular-nums; }
.debt-list { list-style: none; margin: 0 0 8px; padding: 0; }
.debt-list li { display: flex; gap: 8px; align-items: center; padding: 4px 0; font-size: 14px; }
.debt-list li b { margin-left: auto; font-variant-numeric: tabular-nums; }
.debt-owe b { color: var(--red); }
.debt-lent b { color: var(--green); }
.debt-h { font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px; color: var(--ink-2); margin: 4px 0; }

/* ---------- room ---------- */
#roomScreen { padding: 12px 16px 0; max-width: 1400px; margin: 0 auto; display: flex; flex-direction: column; min-height: calc(100vh - 64px); }
.room-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.room-title { flex: 1; min-width: 0; font-weight: 700; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px; background: #fff; box-shadow: var(--clay-sm); font-size: 14px; font-weight: 700; }
.tag-red { background: var(--red); color: #fff; }
.tag-gold { background: var(--gold); }
.room-body { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; margin-top: 12px; min-height: 0; }
.table-area { position: relative; min-height: 470px; }
.table3d { position: absolute; inset: 40px 20px 20px; perspective: 1100px; }
.felt {
  position: absolute; inset: 0; border-radius: 50%; transform: rotateX(28deg);
  background:
    radial-gradient(ellipse at 50% 40%, #46b276 0%, #2c8a55 55%, #1f6b41 100%);
  box-shadow: 0 0 0 14px #b8231f, 0 0 0 20px var(--gold-d), 0 28px 40px rgba(80, 20, 10, .35), inset 0 8px 30px rgba(0, 0, 0, .25);
}
.felt::after {
  content: '福'; position: absolute; inset: 0; display: grid; place-items: center; font-size: 140px; color: rgba(255, 230, 140, .10); font-weight: 800;
}
.seat {
  position: absolute; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center;
  gap: 2px; width: 150px; text-align: center; z-index: 2;
}
.seat .avw { position: relative; }
.seat .av {
  width: 62px; height: 62px; border-radius: 50%; display: grid; place-items: center; font-size: 34px;
  background: linear-gradient(160deg, #fff, var(--cream)); box-shadow: var(--clay-sm); position: relative; z-index: 1;
}
.seat.turn .av { box-shadow: 0 0 0 4px var(--gold), 0 0 24px 6px rgba(255, 201, 60, .7); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.06); } }
.seat .ring { position: absolute; inset: -7px; border-radius: 50%; background: conic-gradient(var(--red) calc(var(--p, 0) * 1%), transparent 0); -webkit-mask: radial-gradient(circle, transparent 60%, #000 61%); mask: radial-gradient(circle, transparent 60%, #000 61%); }
.seat .secs { position: absolute; right: -8px; top: -6px; z-index: 2; background: var(--red); color: #fff; border-radius: 999px; font-size: 12px; font-weight: 800; padding: 0 6px; }
.seat .nm { font-weight: 800; font-size: 14px; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: rgba(255, 250, 241, .92); border-radius: 999px; padding: 0 10px; box-shadow: var(--clay-sm); }
.seat .meta { display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; font-size: 12px; }
.badge { padding: 0 7px; border-radius: 999px; font-weight: 800; font-size: 12px; background: #fff; box-shadow: var(--clay-sm); }
.b-dealer { background: var(--gold); }
.b-host { background: #ffe1ec; }
.b-debt { background: var(--red); color: #fff; }
.b-off { background: #ddd; }
.seat.off { opacity: .55; }
.seat .cards-mini { display: flex; justify-content: center; min-height: 10px; margin-top: 2px; }
.seat .cards-mini .card { --cw: 34px; margin: 0 -9px; }
.seat .res { font-size: 13px; font-weight: 800; padding: 1px 10px; border-radius: 999px; background: #fff; box-shadow: var(--clay-sm); max-width: 160px; }
.res.win { background: #d9f7e3; color: var(--green-d); }
.res.lose { background: #ffe0e3; color: var(--red-d); }
.seat .count { font-weight: 800; background: var(--ink); color: #fff; border-radius: 8px; padding: 0 8px; font-size: 13px; }
.seat .count.warn { background: var(--red); animation: pulse 1s infinite; }
.seat .bubble { position: absolute; top: -34px; left: 50%; transform: translateX(-50%); font-size: 30px; animation: pop 2.4s ease forwards; z-index: 5; }
@keyframes pop { 0% { opacity: 0; transform: translate(-50%, 10px) scale(.5); } 15% { opacity: 1; transform: translate(-50%, 0) scale(1.2); } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -20px); } }
.passmark { font-size: 12px; font-weight: 800; color: #fff; background: rgba(0, 0, 0, .45); border-radius: 999px; padding: 0 8px; }

.center {
  position: absolute; left: 50%; top: 52%; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center;
  gap: 6px; z-index: 1; width: min(60%, 460px); text-align: center; pointer-events: none;
}
.center .phase { color: #fff; font-weight: 800; text-shadow: 0 2px 4px rgba(0, 0, 0, .4); font-size: 15px; }
.center .trick { display: flex; justify-content: center; flex-wrap: wrap; }
.center .trick .card { margin: 0 -8px; --cw: clamp(40px, 5vw, 58px); }
.center .big-res { font-size: clamp(22px, 3.4vw, 34px); font-weight: 800; color: var(--gold-l); text-shadow: 0 3px 0 var(--red-d), 0 0 18px rgba(0, 0, 0, .35); animation: pop-in .5s ease; }
@keyframes pop-in { from { transform: scale(.4); opacity: 0; } }
.deck { position: relative; width: 52px; height: 72px; }
.deck .card { position: absolute; --cw: 52px; left: 0; top: 0; }
.deck .card:nth-child(2) { left: 2px; top: -2px; }
.deck .card:nth-child(3) { left: 4px; top: -4px; }

.room-side { display: flex; flex-direction: column; gap: 12px; min-height: 0; }
.log { flex: 1; min-height: 160px; max-height: 420px; overflow: auto; font-size: 13px; line-height: 1.35; display: flex; flex-direction: column; gap: 4px; }
.log div { padding: 4px 8px; background: #fff; border-radius: 10px; }
.reacts { display: flex; gap: 4px; flex-wrap: wrap; }
.reacts button { border: 0; background: #fff; border-radius: 12px; font-size: 20px; width: 38px; height: 38px; box-shadow: var(--clay-sm); }

.hand-area {
  position: sticky; bottom: 0; z-index: 10; margin: 12px -16px 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(255, 241, 220, 0), var(--bg) 18%); display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.hand-info { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: center; font-weight: 700; }
.hand { display: flex; justify-content: center; min-height: calc(var(--cw) * 1.4 + 16px); padding-top: 16px; max-width: 100%; }
.hand .card { margin: 0 calc(var(--cw) * -0.18); cursor: default; }
.hand.selectable .card { cursor: pointer; }
.hand .card.sel { transform: translateY(-16px); box-shadow: 0 0 0 3px var(--gold), 0 10px 18px rgba(0, 0, 0, .25); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.status-line { font-weight: 700; color: var(--ink-2); text-align: center; }

/* ---------- cards ---------- */
.card {
  --h: calc(var(--cw) * 1.4);
  position: relative; width: var(--cw); height: var(--h); flex: none; border-radius: calc(var(--cw) * .16);
  background: linear-gradient(160deg, #fff 0%, #fff8ec 100%); color: #1e1a1a;
  box-shadow: 2px 4px 8px rgba(60, 20, 10, .28), inset -2px -2px 4px rgba(0, 0, 0, .06), inset 2px 2px 3px #fff;
  transition: transform .15s ease, box-shadow .15s ease; user-select: none; font-weight: 800;
}
.card.red { color: var(--red); }
.card .cr { position: absolute; left: 10%; top: 5%; font-size: calc(var(--cw) * .3); line-height: .95; display: flex; flex-direction: column; align-items: center; }
.card .cr i { font-style: normal; font-size: calc(var(--cw) * .24); }
.card .cr.br { left: auto; top: auto; right: 10%; bottom: 5%; transform: rotate(180deg); }
.card .cs { position: absolute; inset: 0; display: grid; place-items: center; font-size: calc(var(--cw) * .55); }
.card.back {
  background:
    radial-gradient(circle at 50% 50%, var(--gold-l) 0 12%, transparent 13%),
    repeating-linear-gradient(45deg, rgba(255, 210, 90, .35) 0 4px, transparent 4px 10px),
    repeating-linear-gradient(-45deg, rgba(255, 210, 90, .35) 0 4px, transparent 4px 10px),
    linear-gradient(160deg, var(--red-l), var(--red-d));
  box-shadow: 2px 4px 8px rgba(60, 20, 10, .28), inset 0 0 0 3px #fff3d6;
}
.card.deal { animation: deal .45s cubic-bezier(.2, .9, .3, 1.2) both; }
@keyframes deal { from { opacity: 0; transform: translateY(-80px) rotate(-25deg) scale(.4); } }
.card.flip { animation: flip .5s ease both; }
@keyframes flip { from { transform: rotateY(90deg); } }

/* ---------- modal / toast ---------- */
.modal { position: fixed; inset: 0; z-index: 55; display: grid; place-items: center; background: rgba(60, 15, 10, .45); padding: 16px; backdrop-filter: blur(3px); }
.modal-card { width: min(440px, 100%); max-height: 92vh; overflow: auto; background: var(--panel); border-radius: 26px; padding: 22px; box-shadow: var(--clay); animation: pop-in .25s ease; }
.modal-card h3 { margin: 0 0 12px; font-size: 22px; color: var(--red-d); }
.modal-card .row { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 14px; }
.modal-card .end { justify-content: flex-end; margin-bottom: 0; }
.chip-opt { border: 0; border-radius: 14px; padding: 8px 14px; background: #fff; box-shadow: var(--clay-sm); font-weight: 700; }
.chip-opt.on { background: var(--red); color: #fff; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; font-weight: 700; }
.field input { width: 100%; text-transform: none; letter-spacing: 0; border-radius: 14px; }
.av-pick { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.av-pick button { border: 0; background: #fff; border-radius: 12px; font-size: 24px; aspect-ratio: 1; box-shadow: var(--clay-sm); }
.av-pick button.on { box-shadow: 0 0 0 3px var(--red); }
.lixi-modal { background: linear-gradient(170deg, var(--red-l), var(--red) 55%, var(--red-d)); color: #fff; text-align: center; position: relative; }
.lixi-modal h3 { color: var(--gold-l); }
.lixi-modal .seal { width: 74px; height: 74px; margin: 4px auto 10px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, var(--gold-l), var(--gold-d)); display: grid; place-items: center; font-size: 34px; color: var(--red-d); font-weight: 800; box-shadow: var(--clay-sm); }
.lixi-modal .amt { font-size: 34px; font-weight: 800; color: var(--gold-l); }
.lixi-modal .row { justify-content: center; }
.qr { display: block; width: 190px; height: 190px; margin: 6px auto 10px; border-radius: 16px; background: #fff8e7; padding: 8px; box-shadow: var(--clay-sm); }
.link-box { display: flex; gap: 6px; }
.link-box input { flex: 1; min-width: 0; padding: 8px 12px; border-radius: 12px; border: 0; background: #fff; box-shadow: inset 2px 2px 5px rgba(0, 0, 0, .1); font-size: 14px; }
.lion-stage { height: 150px; display: grid; place-items: center; font-size: 88px; overflow: hidden; border-radius: 18px; background: linear-gradient(180deg, #ffe3b0, #ffc56e); margin-bottom: 10px; }
.lion-stage span { animation: lion .6s ease-in-out infinite alternate; display: inline-block; }
@keyframes lion { from { transform: translateX(-40px) rotate(-12deg); } to { transform: translateX(40px) rotate(12deg) translateY(-14px); } }
.progress { height: 12px; border-radius: 999px; background: #f2dcc0; overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--gold), var(--red)); }
.rules { font-size: 14px; line-height: 1.45; color: var(--ink-2); }
.rules b { color: var(--ink); }
.rules ul { padding-left: 18px; margin: 6px 0; }

#toasts { position: fixed; z-index: 60; left: 50%; top: 74px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: min(92vw, 420px); }
.toast { pointer-events: auto; background: #fff; color: var(--ink); border-radius: 16px; padding: 10px 16px; font-weight: 700; box-shadow: var(--clay); animation: pop-in .2s ease; text-align: center; }
.toast.error { background: #ffe0e3; color: var(--red-d); }
.toast.success { background: #fff2c2; }

/* ---------- responsive ---------- */
@media (max-width: 1000px) {
  #lobby { grid-template-columns: 1fr; }
  .room-body { grid-template-columns: 1fr; }
  .room-side { order: 2; }
  .log { max-height: 200px; }
}
@media (max-width: 640px) {
  #lobby { padding: 12px 16px; }
  .booths { grid-template-columns: 1fr; }
  .street { padding: 20px 14px 18px; }
  .brand-text small { display: none; }
  .me-chip .nm { display: none; }
  .table-area { min-height: 400px; }
  .table3d { inset: 46px 4px 26px; }
  .felt { box-shadow: 0 0 0 8px #b8231f, 0 0 0 12px var(--gold-d), 0 18px 30px rgba(80, 20, 10, .35), inset 0 8px 30px rgba(0, 0, 0, .25); }
  .seat { width: 96px; }
  .seat .av { width: 46px; height: 46px; font-size: 26px; }
  .seat .nm { font-size: 12px; max-width: 96px; }
  .seat .cards-mini .card { --cw: 26px; margin: 0 -8px; }
  .center { width: 70%; }
  .hand .card { margin: 0 calc(var(--cw) * -0.3); }
  :root { --cw: clamp(40px, 11vw, 56px); }
  .hand.many .card { --cw: clamp(34px, 9.4vw, 50px); margin: 0 calc(var(--cw) * -0.36); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
}

/* đồng coin vẽ bằng CSS (emoji 🪙 thiếu trên nhiều máy Windows) */
.ci {
  display: inline-block; width: 1em; height: 1em; margin-right: .25em; vertical-align: -.14em; border-radius: 50%; flex: none;
  background: radial-gradient(circle at 35% 30%, #fff3b0 0 18%, #ffc93c 40%, #d98c0a 100%);
  box-shadow: inset 0 0 0 .09em #b86f00, 0 1px 1px rgba(0, 0, 0, .25);
}
.board li.empty::before { display: none; }
.tag { white-space: nowrap; }
@media (max-width: 640px) {
  .room-top { gap: 6px; }
  .room-title { order: 5; flex-basis: 100%; gap: 5px; }
  .room-title .tag { font-size: 12px; padding: 1px 8px; }
  .hand.many .card { --cw: 46px; margin: 0 -10.5px; }
  .hand.many .card .cs { display: none; }
}
@media (max-width: 640px) { .table-area { margin-top: 26px; } }

/* ================= CHẾ ĐỘ 3D GÓC NHÌN THỨ NHẤT ================= */
#stage3d { position: fixed; inset: 0; z-index: 1; background: #3a1a10; }
.stage-canvas { display: block; width: 100%; height: 100%; touch-action: none; }
body.playing3d { overflow: hidden; }
body.playing3d #fx { z-index: 50; }
body.playing3d .topbar { background: linear-gradient(180deg, rgba(158, 27, 43, .92), rgba(158, 27, 43, .6)); backdrop-filter: blur(4px); }
#roomScreen.mode3d { position: relative; z-index: 3; pointer-events: none; height: calc(100vh - 64px); min-height: 0; overflow: hidden; }
#roomScreen.mode3d .room-top > *, #roomScreen.mode3d .room-side > *, #roomScreen.mode3d .hand-area .actions > *,
#roomScreen.mode3d .hand-info, #roomScreen.mode3d .status-line { pointer-events: auto; }
#roomScreen.mode3d .room-body { grid-template-columns: minmax(0, 1fr) 240px; }
#roomScreen.mode3d .table-area.hud { min-height: 0; }
#roomScreen.mode3d .room-side { align-items: stretch; }
#roomScreen.mode3d .room-side .panel { background: rgba(255, 250, 241, .82); backdrop-filter: blur(6px); }
#roomScreen.mode3d .room-side .panel h2 { font-size: 15px; margin-bottom: 6px; }
#roomScreen.mode3d .log { max-height: 34vh; }
#roomScreen.mode3d .hand-area { position: absolute; left: 0; right: 0; bottom: 0; margin: 0; background: none; padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
#roomScreen.mode3d .room-title .tag { background: rgba(255, 255, 255, .85); }
#roomScreen.mode3d .room-title .tag-red { background: var(--red); }
#roomScreen.mode3d .room-title .tag-gold { background: var(--gold); }
#roomScreen.mode3d .status-line { color: #fff; text-shadow: 0 2px 4px rgba(0, 0, 0, .6); }
.hud-center { display: flex; flex-direction: column; align-items: center; gap: 4px; margin-top: 4px; text-align: center; }
.hud-center .phase { color: #fff; font-weight: 800; font-size: 17px; text-shadow: 0 2px 6px rgba(0, 0, 0, .65); background: rgba(60, 15, 8, .35); border-radius: 999px; padding: 2px 14px; }
.hud-center .big-res { font-size: clamp(24px, 4vw, 40px); font-weight: 800; color: var(--gold-l); text-shadow: 0 3px 0 var(--red-d), 0 0 18px rgba(0, 0, 0, .5); animation: pop-in .5s ease; }
.log-toggle { align-self: flex-end; }

.stage-overlay { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.l3d { position: absolute; left: 0; top: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; will-change: transform; padding-bottom: 6px; }
.l3d .n3d { font-weight: 800; font-size: 14px; color: var(--ink); background: rgba(255, 250, 241, .94); border-radius: 999px; padding: 1px 10px; box-shadow: var(--clay-sm); white-space: nowrap; display: flex; gap: 6px; align-items: center; }
.l3d.turn .n3d { background: var(--gold); box-shadow: 0 0 0 3px #fff6, 0 0 18px 4px rgba(255, 201, 60, .8); }
.l3d.off { opacity: .55; }
.l3d .c3d { font-weight: 800; font-size: 12px; color: #fff; text-shadow: 0 1px 3px rgba(0, 0, 0, .7); display: flex; align-items: center; }
.l3d .secs { background: var(--red); color: #fff; border-radius: 999px; padding: 0 7px; font-size: 12px; }
.l3d .bds { display: flex; gap: 3px; flex-wrap: wrap; justify-content: center; max-width: 170px; }
.l3d .bd { font-style: normal; font-size: 11px; font-weight: 800; padding: 0 6px; border-radius: 999px; background: rgba(255, 255, 255, .9); }
.l3d .bd.gold { background: var(--gold); }
.l3d .bd.red { background: var(--red); color: #fff; }
.l3d .bd.dark { background: rgba(30, 10, 5, .75); color: #fff; }
.l3d .bd.off { background: #ccc; }
.b3d { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); margin-bottom: 4px; background: #fff; color: var(--ink); font-weight: 800; font-size: 14px; padding: 5px 12px; border-radius: 16px; white-space: nowrap; box-shadow: var(--clay); animation: pop 2.6s ease forwards; }
.b3d::after { content: ''; position: absolute; top: 100%; left: 50%; margin-left: -7px; border: 7px solid transparent; border-top-color: #fff; }
.peek-hint { position: absolute; left: 50%; bottom: 32%; transform: translateX(-50%); background: rgba(40, 10, 5, .72); color: #fff; padding: 8px 16px; border-radius: 999px; font-weight: 700; white-space: nowrap; animation: hintBob 1.6s ease-in-out infinite; }
@keyframes hintBob { 50% { transform: translate(-50%, -6px); } }
.stage-mute { position: absolute; left: 12px; bottom: 12px; pointer-events: auto; z-index: 4; border: 0; width: 42px; height: 42px; border-radius: 50%; font-size: 20px; background: rgba(255, 250, 241, .85); box-shadow: var(--clay-sm); }
@media (max-width: 1000px) {
  #roomScreen.mode3d .room-body { grid-template-columns: 1fr; }
  #roomScreen.mode3d .room-side { position: absolute; right: 12px; top: 120px; width: min(260px, 70vw); }
  #roomScreen.mode3d .room-side .panel:first-child { display: none; }
}
@media (max-width: 640px) {
  .l3d .n3d { font-size: 12px; padding: 0 8px; }
  .l3d .bds { max-width: 110px; }
  .b3d { font-size: 12px; }
  .peek-hint { font-size: 13px; bottom: 34%; }
  #roomScreen.mode3d .hand-area .btn-lg { padding: 10px 18px; font-size: 16px; }
}

/* ---------- HUD 3D: lượt chơi & bài vừa đánh ---------- */
.hud-center { gap: 8px; }
.turn-pill, .trick-pill {
  position: relative; display: flex; align-items: center; gap: 8px; padding: 5px 14px 5px 6px; border-radius: 999px;
  background: rgba(255, 250, 241, .93); box-shadow: var(--clay); font-weight: 700; color: var(--ink); max-width: min(96vw, 620px); overflow: hidden;
}
.turn-pill .tav, .trick-pill .tav { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-size: 22px; background: var(--cream); box-shadow: var(--clay-sm); flex: none; }
.turn-pill .secs { background: var(--red); color: #fff; border-radius: 999px; padding: 0 8px; font-size: 13px; font-weight: 800; min-width: 26px; text-align: center; }
.turn-pill .tbar { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(0, 0, 0, .08); }
.turn-pill .tbar i { display: block; height: 100%; background: linear-gradient(90deg, var(--green), var(--gold)); transform-origin: left; transition: transform .25s linear; }
.turn-pill .tbar i.low { background: var(--red); }
.turn-pill.mine { background: linear-gradient(180deg, var(--gold-l), var(--gold)); font-size: 19px; padding-right: 16px; animation: turnPulse 1s ease-in-out infinite; }
.turn-pill.done { padding: 6px 16px; }
@keyframes turnPulse { 50% { box-shadow: 0 0 0 4px rgba(255, 255, 255, .6), 0 0 26px 8px rgba(255, 201, 60, .85); transform: scale(1.04); } }
.trick-pill { padding-right: 8px; animation: pop-in .35s ease; }
.trick-pill.hot { background: linear-gradient(180deg, #fff1f1, #ffd6da); }
.trick-pill .cname { color: var(--red-d); }
.trick-pill.free { padding: 5px 16px; background: rgba(255, 250, 241, .85); }
.mini-trick { display: flex; padding-left: 6px; }
.mini-trick .card { --cw: 30px; margin-left: -10px; box-shadow: 1px 2px 4px rgba(0, 0, 0, .25); }
.mini-trick .card:first-child { margin-left: 0; }
.mini-trick .card .cs { display: none; }
.mini-trick .card .cr.br { display: none; }
.mini-trick .card .cr { font-size: 13px; left: 4px; top: 2px; }
.mini-trick .card .cr i { font-size: 12px; }
body.playing3d.myturn #stage3d::after {
  content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 2;
  box-shadow: inset 0 0 0 4px rgba(255, 201, 60, .9), inset 0 0 60px 14px rgba(255, 180, 40, .55);
  animation: edgeGlow 1.1s ease-in-out infinite;
}
@keyframes edgeGlow { 50% { opacity: .45; } }
.l3d { transition: opacity .2s; }
.l3d.turn { z-index: 2; }
.l3d.turn .n3d { font-size: 16px; animation: turnPulse 1s ease-in-out infinite; }
@media (max-width: 640px) {
  .turn-pill { font-size: 14px; }
  .turn-pill.mine { font-size: 16px; }
  .trick-pill .ttx { font-size: 13px; }
  .mini-trick .card { --cw: 26px; }
}

.kick3d { pointer-events: auto; border: 0; width: 22px; height: 22px; border-radius: 50%; background: rgba(255, 255, 255, .9); box-shadow: var(--clay-sm); font-size: 12px; font-weight: 800; cursor: pointer; }
@media (max-width: 640px) {
  #roomScreen.mode3d .room-title { display: none; }
  #roomScreen.mode3d .room-top .btn-sm { padding: 5px 10px; font-size: 13px; }
  #roomScreen.mode3d .room-side { top: 58px; right: 8px; width: auto; }
  #roomScreen.mode3d .room-side .log-panel { width: min(280px, 80vw); }
  #roomScreen.mode3d .hud-center { margin-top: 0; }
  .turn-pill, .trick-pill { padding-top: 3px; padding-bottom: 3px; }
  .turn-pill .tav, .trick-pill .tav { width: 28px; height: 28px; font-size: 18px; }
}
/* lá bài trong HUD "ai đánh gì": to, đọc được ngay */
.trick-pill { padding-top: 6px; padding-bottom: 6px; }
.mini-trick .card { --cw: 44px; margin-left: -14px; }
.mini-trick .card .cr { font-size: 18px; left: 5px; top: 3px; }
.mini-trick .card .cr i { font-size: 16px; }
.trick-pill .ttx { font-size: 16px; }
@media (max-width: 640px) {
  .mini-trick .card { --cw: 32px; margin-left: -10px; }
  .mini-trick .card .cr { font-size: 14px; left: 3px; }
  .mini-trick .card .cr i { font-size: 12px; }
  .trick-pill .ttx { font-size: 13px; }
}

/* ---------- tạo hình nhân vật ---------- */
.modal-card.modal-wide { width: min(640px, 100%); }
.look-wrap { display: grid; grid-template-columns: 200px 1fr; gap: 14px; align-items: start; margin-top: 6px; }
.look-prev { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.look-prev canvas { width: 200px; height: 230px; border-radius: 20px; background: radial-gradient(circle at 50% 35%, #fff6e0, #f4d3a3); box-shadow: inset 0 2px 8px rgba(120, 40, 20, .15); }
.look-edit { display: flex; flex-direction: column; gap: 8px; }
.look-row { display: grid; grid-template-columns: 74px 1fr; gap: 8px; align-items: center; font-weight: 700; font-size: 14px; }
.look-opts { display: flex; flex-wrap: wrap; gap: 6px; }
.look-opts .chip-opt { padding: 4px 10px; font-size: 13px; border-radius: 12px; }
.sw { width: 28px; height: 28px; border-radius: 50%; border: 0; background: var(--c); box-shadow: var(--clay-sm); }
.sw.on { box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--red); }
@media (max-width: 560px) {
  .look-wrap { grid-template-columns: 1fr; }
  .look-prev canvas { width: 170px; height: 190px; }
}
/* ---------- xem bài bạn cùng bàn ---------- */
.inspect-cap { position: absolute; left: 50%; top: 16%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 2px; background: rgba(255, 250, 241, .95); padding: 8px 18px; border-radius: 18px; box-shadow: var(--clay); text-align: center; animation: pop-in .25s ease; }
.inspect-cap b { font-size: 18px; }
.inspect-cap span { font-weight: 700; }
.inspect-cap .ires { padding: 0 10px; border-radius: 999px; }
.inspect-cap .ires.win { background: #d9f7e3; color: var(--green-d); }
.inspect-cap .ires.lose { background: #ffe0e3; color: var(--red-d); }
.inspect-cap small { color: var(--ink-2); }
.inspect-cap { top: auto; bottom: 24%; }
.stage-overlay.inspecting .l3d { opacity: 0; }

/* vuốt bài lên bàn */
.stage-overlay.swipe-ready::after { content: 'Thả tay để đánh!'; position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%); background: rgba(255, 201, 60, .95); color: var(--ink); font-weight: 800; font-size: 20px; padding: 8px 20px; border-radius: 999px; box-shadow: var(--clay); animation: pop-in .2s ease; }
#myHand .card { touch-action: none; }

/* ---------- Cờ Caro ---------- */
.booths { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.booth-caro .awning { background: repeating-linear-gradient(90deg, #2c5cc5 0 34px, #fff4e0 34px 68px); }
.booth-caro .booth-sign { background: #1d3f8a; }
.caro-art { display: grid; grid-template-columns: repeat(3, 30px); grid-template-rows: repeat(3, 30px); gap: 2px; width: max-content; margin: 14px auto 6px; height: auto; background: #b9a27a; padding: 2px; border-radius: 8px; box-shadow: var(--clay-sm); }
.caro-art span { background: #fff8e8; display: grid; place-items: center; font-weight: 800; font-size: 18px; color: #c8102e; }
.caro-art span:nth-child(even) { color: #1d3f8a; }
.center.caro2d { width: min(92%, 520px); top: 50%; pointer-events: auto; }
.caro-board { display: grid; grid-template-columns: repeat(var(--n), 1fr); width: min(100%, 64vh); aspect-ratio: 1; background: #c8ad7f; gap: 1px; padding: 1px; border-radius: 8px; box-shadow: var(--clay); }
.caro-board .cc { border: 0; padding: 0; background: #fff8e6; font-weight: 900; font-size: clamp(10px, 2.2vw, 20px); line-height: 1; cursor: default; display: grid; place-items: center; }
.caro-board.mine .cc:not(.x):not(.o) { cursor: pointer; }
.caro-board.mine .cc:not(.x):not(.o):hover { background: #ffe9a8; }
.caro-board .cc.x { color: #c8102e; }
.caro-board .cc.o { color: #1d3f8a; }
.caro-board .cc.last { background: #ffeeb5; }
.caro-board .cc.win { background: #ffd23f; animation: pulse 1s infinite; }
.count.mark-X { background: #c8102e; }
.count.mark-O { background: #1d3f8a; }
/* Caro 2D: bàn nhỏ gọn giữa hai nhân vật, không che ghế */
.center.caro2d { top: 51%; width: min(86%, 330px); }
.center.caro2d .caro-board { width: min(100%, 300px, 42vh); margin: 0 auto; }
.center.caro2d .phase { font-size: 13px; }
.center.caro2d .big-res { font-size: 22px; }

/* ---------- xếp hạng Tiến Lên ---------- */
.rank-pill { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; padding: 4px 14px; border-radius: 999px; background: rgba(255, 250, 241, .9); box-shadow: var(--clay-sm); font-weight: 800; font-size: 14px; }
.hat2d { position: absolute; top: -26px; left: 50%; transform: translateX(-50%) rotate(-8deg); font-size: 34px; z-index: 3; animation: hatDrop .7s cubic-bezier(.3, 1.4, .5, 1) both; filter: drop-shadow(0 3px 2px rgba(0, 0, 0, .3)); }
@keyframes hatDrop { from { transform: translate(-50%, -80px) rotate(-30deg); opacity: 0; } }
.av.kneel2d { transform: translateY(6px) scale(.92); filter: saturate(.7); }

/* ---------- Face Studio ---------- */
.av-img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
.face-row { display: flex; align-items: center; gap: 12px; margin-top: 6px; }
.face-thumb { width: 64px; height: 64px; border-radius: 50%; background: var(--cream); display: grid; place-items: center; font-size: 34px; box-shadow: var(--clay-sm); overflow: hidden; flex: none; }
.face-thumb img { width: 100%; height: 100%; object-fit: cover; }
.face-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.studio { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; background: rgba(60, 15, 10, .55); backdrop-filter: blur(3px); }
.studio-card { width: min(640px, 100%); height: min(100dvh, 900px); max-height: 100dvh; overflow: auto; -webkit-overflow-scrolling: touch; background: var(--panel); border-radius: 26px; padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 10px; box-shadow: var(--clay); }
.studio-top { display: flex; align-items: center; justify-content: space-between; }
.studio-top h3 { margin: 0; color: var(--red-d); }
.studio-main { display: grid; grid-template-columns: minmax(0, 1fr) 150px; gap: 12px; align-items: start; }
.studio-cv-wrap { position: relative; width: 100%; max-width: 380px; aspect-ratio: 1; margin: 0 auto; border-radius: 22px; overflow: hidden; box-shadow: var(--clay-sm); background: #fff; }
.studio-cv { width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; -webkit-user-select: none; user-select: none; }
.studio-guide { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; fill: none; stroke: rgba(60, 20, 10, .22); stroke-width: .8; stroke-dasharray: 2 2; }
.studio-hint { font-size: 13px; color: var(--ink-2); text-align: center; margin-top: 6px; }
.studio-prev { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.studio-3d { width: 150px; height: 190px; border-radius: 18px; background: radial-gradient(circle at 50% 35%, #fff6e0, #f4d3a3); box-shadow: inset 0 2px 8px rgba(120, 40, 20, .15); }
.studio .tools { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; margin-left: 4px; }
.stk { display: flex; gap: 6px; overflow-x: auto; padding: 2px 2px 6px; -webkit-overflow-scrolling: touch; }
.stk button { flex: none; width: 46px; height: 46px; border: 0; border-radius: 14px; background: #fff; box-shadow: var(--clay-sm); font-size: 26px; }
.stk button.on { box-shadow: 0 0 0 3px var(--red); }
.photo-box { display: flex; flex-direction: column; gap: 6px; padding: 10px; border-radius: 16px; background: rgba(255, 201, 60, .18); }
.photo-btn { align-self: flex-start; cursor: pointer; }
.photo-ctl { display: flex; flex-direction: column; gap: 6px; }
.photo-ctl label { display: grid; grid-template-columns: 92px 1fr; align-items: center; font-weight: 700; font-size: 14px; }
.photo-ctl input[type=range] { width: 100%; }
.studio-foot { position: sticky; bottom: 0; padding-top: 6px; background: linear-gradient(180deg, transparent, var(--panel) 30%); }
@media (max-width: 560px) {
  .studio-card { border-radius: 0; height: 100dvh; }
  .studio-main { grid-template-columns: 1fr; }
  .studio-3d { width: 100%; height: 150px; }
}

/* ================= iPhone / iPad ================= */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; overscroll-behavior: none; }
body { -webkit-touch-callout: none; touch-action: manipulation; }
button, .btn, .chip-opt, [data-act], [data-cell], label { touch-action: manipulation; -webkit-user-select: none; user-select: none; }
.card, .stage-canvas, #stage3d, .caro-board, .seat, .center { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
input, textarea { font-size: 16px; } /* iOS tự phóng to khi ô nhập < 16px */
.link-box input { font-size: 16px; }
/* vùng an toàn (tai thỏ, thanh home) */
.topbar { padding-top: calc(10px + env(safe-area-inset-top)); padding-left: calc(16px + env(safe-area-inset-left)); padding-right: calc(16px + env(safe-area-inset-right)); }
#lobby, #roomScreen { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
#roomScreen.mode3d { height: calc(100vh - var(--tb, 64px)); height: calc(100dvh - var(--tb, 64px)); }
#roomScreen { min-height: calc(100vh - var(--tb, 64px)); min-height: calc(100dvh - var(--tb, 64px)); }
.modal-card { max-height: 92vh; max-height: 92dvh; -webkit-overflow-scrolling: touch; }
body.playing3d { height: 100vh; height: 100dvh; overflow: hidden; }
#toasts { top: calc(74px + env(safe-area-inset-top)); }
.stage-mute { left: max(12px, env(safe-area-inset-left)); bottom: max(12px, env(safe-area-inset-bottom)); }
/* cảm ứng không có hover: bỏ hiệu ứng "dính" sau khi chạm */
@media (hover: none) {
  .btn:hover { filter: none; transform: none; }
  .booth:hover { transform: none; }
  .caro-board.mine .cc:not(.x):not(.o):hover { background: #fff8e6; }
}
/* iPhone ngang: gọn lại để còn chỗ cho bàn chơi */
@media (max-height: 460px) and (orientation: landscape) {
  .topbar { padding-top: calc(4px + env(safe-area-inset-top)); padding-bottom: 4px; }
  .brand-text small { display: none; }
  .room-top { gap: 6px; }
  .room-title { display: none; }
  #roomScreen.mode3d .room-body { grid-template-columns: 1fr; }
  #roomScreen.mode3d .room-side { display: none; }
  .hand-info { font-size: 13px; }
  .btn-lg { padding: 8px 18px; font-size: 16px; }
  .turn-pill.mine { font-size: 15px; }
  .studio-card { height: 100dvh; border-radius: 0; }
  .studio-main { grid-template-columns: 1fr 150px; }
}

/* 3D trên màn hình nhỏ/vừa: cảm xúc + nhật ký là hộp nổi, mở bằng nút 💬 trên thanh trên */
.room-chat-btn { display: none; }
@media (max-width: 1000px), (max-height: 460px) and (orientation: landscape) {
  #roomScreen.mode3d .room-chat-btn { display: inline-flex; }
  #roomScreen.mode3d .room-side { display: none !important; position: absolute; right: max(10px, env(safe-area-inset-right)); top: calc(var(--tb, 64px) + 54px); width: min(300px, 88vw); z-index: 6; }
  #roomScreen.mode3d .room-side.open { display: flex !important; }
  #roomScreen.mode3d .room-side .panel:first-child { display: block !important; }
  #roomScreen.mode3d .room-side .log-toggle { display: none; }
  #roomScreen.mode3d .room-side .log-panel { display: flex !important; }
  #roomScreen.mode3d .room-side .log { max-height: 30vh; }
}
@media (max-width: 430px) {
  .room-top { gap: 5px; }
  .room-top .btn-sm { padding: 5px 9px; font-size: 12.5px; }
  #roomScreen { padding-top: 8px; }
}

@media (max-width: 430px) {
  .room-top .tx { display: none; }
  .room-top .btn-sm { padding: 6px 12px; font-size: 15px; }
  .hand-area .actions { gap: 6px; flex-wrap: nowrap; }
  .hand-area .actions .btn { padding: 9px 13px; font-size: 14px; }
  .hand-area .actions .btn-lg { padding: 10px 16px; font-size: 15px; }
  .hand-area { gap: 6px; padding-top: 6px; }
  .l3d .c3d { display: none; }
  .hud-center .phase { font-size: 14px; }
}

.room-mute-btn { display: none; }
@media (max-width: 430px) {
  #roomScreen.mode3d .room-mute-btn { display: inline-flex; }
  .stage-mute { display: none; }
}
/* Face Studio trên điện thoại: khung vẽ vừa phải, xem trước 3D nằm cạnh để thấy cả công cụ */
@media (max-width: 560px) {
  .studio-card { padding: calc(10px + env(safe-area-inset-top)) 12px calc(10px + env(safe-area-inset-bottom)); gap: 8px; }
  .studio-main { grid-template-columns: minmax(0, 1fr) 108px; gap: 8px; }
  .studio-cv-wrap { max-width: min(100%, 38dvh); margin: 0; }
  .studio-3d { width: 108px; height: 150px; }
  .studio-hint { display: none; }
  .studio-prev small { font-size: 11px; text-align: center; }
  .stk button { width: 42px; height: 42px; font-size: 24px; }
  .photo-ctl label { grid-template-columns: 78px 1fr; }
}
@media (max-width: 560px) {
  .look-wrap { grid-template-columns: 116px minmax(0, 1fr); gap: 8px; }
  .look-prev canvas { width: 116px; height: 150px; }
  .look-prev .btn { padding: 5px 8px; font-size: 12px; }
  .look-row { grid-template-columns: 1fr; gap: 2px; font-size: 13px; }
  .look-opts { gap: 5px; }
  .sw { width: 26px; height: 26px; }
  .modal-card { padding: 16px; }
  .av-pick { grid-template-columns: repeat(8, 1fr); gap: 4px; }
  .av-pick button { font-size: 20px; }
}

@media (max-height: 460px) and (orientation: landscape) {
  .hud-center { flex-direction: row; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 0; max-width: 78vw; margin-left: auto; margin-right: auto; }
  .turn-pill, .trick-pill, .rank-pill { padding-top: 2px; padding-bottom: 2px; font-size: 13px; }
  .turn-pill .tav, .trick-pill .tav { width: 24px; height: 24px; font-size: 15px; }
  .mini-trick .card { --cw: 24px; margin-left: -8px; }
  #roomScreen.mode3d .hand-area { gap: 4px; padding-bottom: calc(6px + env(safe-area-inset-bottom)); }
  .hand-area .actions .btn { padding: 6px 14px; font-size: 14px; }
  .room-top .btn-sm { padding: 4px 10px; font-size: 13px; }
  .room-top .tx { display: none; }
  .room-mute-btn, .room-chat-btn { display: inline-flex !important; }
  .stage-mute { display: none; }
}

/* ---------- Bảng xếp hạng phòng ---------- */
.rank-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.rank-list li { display: grid; grid-template-columns: 30px 38px minmax(0, 1fr) auto auto; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 14px; background: #fff; box-shadow: var(--clay-sm); }
.rank-list li.me { background: linear-gradient(90deg, #fff3c4, #fff); box-shadow: 0 0 0 2px var(--gold), var(--clay-sm); }
.rank-list .rk { font-size: 20px; font-weight: 800; text-align: center; }
.rank-list .rav { width: 38px; height: 38px; border-radius: 50%; background: var(--cream); display: grid; place-items: center; font-size: 22px; overflow: hidden; box-shadow: var(--clay-sm); }
.rank-list .rnm { min-width: 0; display: flex; flex-direction: column; line-height: 1.15; font-size: 14px; }
.rank-list .rnm b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-list .rnm small { color: var(--ink-2); font-size: 12px; }
.rank-list .owe { color: var(--red); font-weight: 800; }
.rank-list .rnet { font-variant-numeric: tabular-nums; font-size: 16px; }
.rank-list .rnet.pos { color: var(--green-d); }
.rank-list .rnet.neg { color: var(--red); }
.rank-list i.up { color: var(--green); font-style: normal; font-size: 12px; }
.rank-list i.dn { color: var(--red); font-style: normal; font-size: 12px; }
#roomScreen.mode3d .rank-panel { background: rgba(255, 250, 241, .88); }
@media (max-width: 430px) { .rank-list li { grid-template-columns: 26px 34px minmax(0, 1fr) auto auto; gap: 6px; } }

#netBanner { position: fixed; left: 50%; top: calc(8px + env(safe-area-inset-top)); transform: translateX(-50%); z-index: 90; background: #3b1a12; color: #fff; font-weight: 700; font-size: 14px; padding: 8px 16px; border-radius: 999px; box-shadow: var(--clay); }
/* iOS: chặn kéo-nảy cả trang khi đang chơi 3D (vuốt bài lên không làm trang cuộn) */
body.playing3d { position: fixed; inset: 0; width: 100%; }

/* cảm ứng: vùng bấm tối thiểu ~44px (chuẩn Apple) */
@media (pointer: coarse) {
  .btn { min-height: 44px; }
  .btn-sm { min-height: 40px; padding-left: 14px; padding-right: 14px; }
  .chip-opt, .tabs button { min-height: 40px; }
  .sw { width: 34px; height: 34px; }
  .stk button { min-width: 44px; min-height: 44px; }
  .reacts button { width: 44px; height: 44px; }
  .room-top .btn-sm { min-width: 40px; }
}
.rank-list .nm1 { display: flex; align-items: baseline; gap: 5px; min-width: 0; }
.rank-list .nm1 b { min-width: 0; }

/* ---------- Thanh xếp hạng luôn hiện ---------- */
.rank-bar { display: inline-flex; align-items: center; gap: 4px; max-width: min(98vw, 640px); padding: 4px 8px 4px 6px; border: 0; border-radius: 999px; background: rgba(60, 15, 8, .62); backdrop-filter: blur(6px); box-shadow: var(--clay-sm); color: #fff; font: inherit; cursor: pointer; overflow: hidden; }
.rank-bar .rb-ico { font-size: 17px; margin-right: 2px; }
.rchip { display: inline-flex; align-items: center; gap: 3px; padding: 2px 7px 2px 3px; border-radius: 999px; background: rgba(255, 255, 255, .12); white-space: nowrap; transition: background .3s, transform .3s; }
.rchip .m { font-style: normal; font-size: 14px; width: 20px; text-align: center; }
.rchip .rav { width: 24px; height: 24px; border-radius: 50%; background: var(--cream); display: grid; place-items: center; font-size: 15px; overflow: hidden; flex: none; }
.rchip .rn { font-weight: 700; font-size: 12px; max-width: 64px; overflow: hidden; text-overflow: ellipsis; }
.rchip .rnet { font-size: 13px; font-variant-numeric: tabular-nums; }
.rchip .rnet.pos { color: #8dffb4; }
.rchip .rnet.neg { color: #ff9aa8; }
.rchip.me { background: rgba(255, 201, 60, .38); box-shadow: inset 0 0 0 1.5px var(--gold); }
.rchip.lead { background: rgba(255, 201, 60, .22); }
.rchip.up { animation: rankUp .9s ease; }
@keyframes rankUp { 0% { transform: translateY(8px) scale(.9); background: rgba(80, 220, 130, .6); } 100% { transform: none; } }
#roomScreen.mode3d .rank-bar { pointer-events: auto; }
.rank-bar-2d { position: absolute; top: 0; left: 50%; transform: translateX(-50%); z-index: 4; }
@media (max-width: 560px) { .rchip .rn { display: none; } .rchip { padding-right: 6px; } }
@media (max-height: 460px) and (orientation: landscape) { .rank-bar { padding: 2px 6px 2px 4px; } .rchip .rav { width: 20px; height: 20px; font-size: 12px; } .rchip .rn { display: none; } }
/* bục nhận giải trong cửa sổ chi tiết */
.podium { display: flex; justify-content: center; align-items: flex-end; gap: 8px; margin: 4px 0 12px; }
.pd { display: flex; flex-direction: column; align-items: center; width: 31%; max-width: 120px; text-align: center; position: relative; }
.pd .pav { width: 54px; height: 54px; border-radius: 50%; background: var(--cream); display: grid; place-items: center; font-size: 30px; overflow: hidden; box-shadow: var(--clay-sm); }
.pd.p1 .pav { width: 66px; height: 66px; box-shadow: 0 0 0 3px var(--gold), var(--clay-sm); }
.pd .crown { height: 20px; font-size: 20px; line-height: 1; }
.pd b { font-size: 13px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 4px; }
.pd small { font-weight: 800; font-size: 13px; }
.pd small.pos { color: var(--green-d); } .pd small.neg { color: var(--red); }
.pd .step { display: grid; place-items: center; width: 100%; font-style: normal; font-size: 24px; margin-top: 4px; border-radius: 12px 12px 0 0; background: linear-gradient(180deg, #ffe58a, #f0b429); box-shadow: var(--clay-sm); }
.pd.p1 .step { height: 64px; } .pd.p2 .step { height: 46px; background: linear-gradient(180deg, #f1f3f6, #c4cbd4); } .pd.p3 .step { height: 34px; background: linear-gradient(180deg, #f3c9a0, #cd8b53); }

/* ---------- Chat trực tiếp (khung nổi) ---------- */
#chatDock { position: fixed; right: max(10px, env(safe-area-inset-right)); bottom: calc(var(--hand-h, 120px) + 10px); z-index: 30; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; max-width: calc(100vw - 20px); }
#chatDock.kb-open { bottom: calc(var(--kb, 0px) + 8px); }
.cd-fab { position: relative; width: 50px; height: 50px; border: 0; border-radius: 50%; background: linear-gradient(180deg, var(--gold-l), var(--gold)); box-shadow: var(--clay); font-size: 24px; display: grid; place-items: center; touch-action: manipulation; }
.cd-badge { position: absolute; top: -4px; right: -4px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 999px; background: var(--red); color: #fff; font-style: normal; font-size: 12px; font-weight: 800; display: grid; place-items: center; box-shadow: 0 0 0 2px #fff; animation: pulse 1.2s infinite; }
.cd-panel { width: min(94vw, 360px); height: min(56vh, 420px); display: flex; flex-direction: column; background: rgba(255, 250, 241, .97); border-radius: 22px; box-shadow: var(--clay); overflow: hidden; backdrop-filter: blur(8px); animation: pop-in .2s ease; }
#chatDock.kb-open .cd-panel { height: min(46vh, 340px); }
.cd-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 8px 8px 6px 10px; border-bottom: 1px solid var(--line); }
.cd-tabs { display: flex; gap: 4px; overflow-x: auto; }
.cd-tabs button { border: 0; border-radius: 999px; padding: 5px 11px; background: #f6e3c8; font-weight: 700; font-size: 13px; white-space: nowrap; }
.cd-tabs button.on { background: var(--red); color: #fff; }
.cd-close { border: 0; width: 34px; height: 34px; border-radius: 50%; background: #fff; box-shadow: var(--clay-sm); font-weight: 800; flex: none; }
.cd-body { flex: 1; min-height: 0; position: relative; }
.cd-msgs, .cd-log { position: absolute; inset: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; overscroll-behavior: contain; }
.cd-log div { font-size: 13px; padding: 4px 8px; background: #fff; border-radius: 10px; }
.cd-react { position: absolute; inset: 0; padding: 12px; display: flex; flex-wrap: wrap; gap: 10px; align-content: flex-start; justify-content: center; }
.cd-react button { width: 52px; height: 52px; border: 0; border-radius: 16px; background: #fff; box-shadow: var(--clay-sm); font-size: 28px; }
.cm { display: flex; gap: 8px; align-items: flex-start; max-width: 92%; }
.cm.mine { flex-direction: row-reverse; align-self: flex-end; }
.cm .cav { width: 30px; height: 30px; border-radius: 50%; background: var(--cream); display: grid; place-items: center; font-size: 18px; overflow: hidden; flex: none; box-shadow: var(--clay-sm); }
.cm .cb { display: flex; flex-direction: column; background: #fff; border-radius: 14px; padding: 5px 10px; box-shadow: var(--clay-sm); min-width: 0; }
.cm.mine .cb { background: #ffe9a8; }
.cm .cb b { font-size: 12px; color: var(--ink-2); }
.cm .cb span { font-size: 14px; line-height: 1.3; overflow-wrap: anywhere; user-select: text; -webkit-user-select: text; }
.cd-foot { padding: 6px 8px calc(8px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: rgba(255, 255, 255, .6); }
#chatDock.kb-open .cd-foot { padding-bottom: 8px; }
.cd-quick { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; -webkit-overflow-scrolling: touch; }
.cd-quick button { flex: none; border: 0; border-radius: 999px; padding: 5px 11px; background: #f6e3c8; font-size: 12.5px; font-weight: 700; white-space: nowrap; }
.cd-form { display: flex; gap: 6px; }
.cd-form input { flex: 1; min-width: 0; border: 0; border-radius: 999px; padding: 10px 14px; background: #fff; box-shadow: inset 2px 2px 5px rgba(0, 0, 0, .12); font-size: 16px; color: var(--ink); -webkit-user-select: text; user-select: text; }
.cd-form input:focus { outline: 3px solid #2563eb; outline-offset: 1px; }
/* bong bóng thoại dài (chat) trên đầu nhân vật */
.b3d.say { white-space: normal; max-width: 210px; text-align: center; font-size: 13px; line-height: 1.25; overflow-wrap: anywhere; z-index: 6; }
.seat .bubble.say { font-size: 13px; font-weight: 800; background: #fff; color: var(--ink); padding: 4px 10px; border-radius: 14px; box-shadow: var(--clay-sm); width: max-content; max-width: 180px; white-space: normal; text-align: center; top: -54px; }
@media (max-width: 430px) { .cd-panel { width: calc(100vw - 20px); } }
@media (max-height: 460px) and (orientation: landscape) { .cd-panel { height: 78vh; } #chatDock { bottom: calc(var(--hand-h, 60px) + 6px); } }
body.playing3d #chatDock { z-index: 30; }
.rchip .rn { display: inline-block; white-space: nowrap; max-width: 76px; vertical-align: middle; }
@media (max-width: 560px) { .rchip .rn { display: none; } }

/* bong bóng chat dài: rộng theo nội dung (trước đây bị bẻ từng chữ theo bề ngang nhãn tên rất hẹp) */
.b3d.say { width: max-content; max-width: min(210px, 70vw); }

/* ---- khôi phục tài khoản ---- */
.panel-warn { border: 2px solid #e8b44c; }
.panel-warn h2 { margin-top: 0; }
.rec-code { font: 700 22px/1.4 ui-monospace, Menlo, Consolas, monospace; letter-spacing: 1px; text-align: center; padding: 12px 8px; margin: 10px 0; border-radius: 12px; background: #fff8e7; color: #8b0f14; user-select: all; word-break: break-all; }
.rec-input { width: 100%; font: 600 18px ui-monospace, Menlo, Consolas, monospace; letter-spacing: 1px; text-transform: uppercase; text-align: center; }
.link-btn { background: none; border: 0; padding: 4px; color: var(--ink-2); text-decoration: underline; font: inherit; font-size: 14px; cursor: pointer; }
.rec-err { color: #b3261e; font-size: 14px; min-height: 18px; margin: 6px 0 0; }

/* ================= Lô tô ================= */
.booth-loto .awning { background: repeating-linear-gradient(90deg, #c8102e 0 34px, #ffd24a 34px 68px); }
.booth-loto .booth-sign { background: #8a1c4a; }
.loto-art { display: flex; justify-content: center; align-items: center; gap: 6px; }
.lball { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; font-weight: 800; font-size: 18px; color: #2b1810;
  background: radial-gradient(circle at 50% 50%, #fff8e7 0 52%, transparent 53%), var(--lb, #d7263d); box-shadow: inset -3px -4px 6px rgba(0,0,0,.28), var(--clay-sm); line-height: 1; }
.lball.c0 { --lb: #d7263d; } .lball.c1 { --lb: #f4a300; } .lball.c2 { --lb: #1b998b; } .lball.c3 { --lb: #2e86ab; } .lball.c4 { --lb: #7b2cbf; }
.lball.c5 { --lb: #e76f51; } .lball.c6 { --lb: #3a7d44; } .lball.c7 { --lb: #c1121f; } .lball.c8 { --lb: #0077b6; }
.lball.big { width: 92px; height: 92px; font-size: 46px; } .lball.sm { width: 32px; height: 32px; font-size: 15px; } .lball.xs { width: 26px; height: 26px; font-size: 12px; }
.lball.empty { --lb: #b9a27a; opacity: .6; }
.lball.pop { animation: lpop .55s cubic-bezier(.2,1.6,.4,1); }
@keyframes lpop { from { transform: scale(.2) rotate(-200deg); opacity: 0; } to { transform: none; opacity: 1; } }
.loto2d { display: flex; flex-direction: column; align-items: center; gap: 8px; width: min(96%, 560px); }
.loto-cast { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: center; }
.lhist { display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; max-width: 300px; }
.lnext { font-weight: 700; font-size: 14px; display: grid; gap: 4px; justify-items: center; color: var(--ink-2); }
.lnext .tbar { display: block; width: 160px; height: 6px; border-radius: 4px; background: rgba(0,0,0,.12); overflow: hidden; }
.lnext .tbar i { display: block; height: 100%; width: 100%; background: var(--gold, #e8b44c); transform-origin: left; }
.lboard { display: grid; grid-template-columns: repeat(10, 1fr); gap: 2px; width: 100%; padding: 4px; border-radius: 10px; background: rgba(255,248,231,.85); box-shadow: var(--clay-sm); }
.lboard i { font-style: normal; text-align: center; font-size: clamp(9px, 2.4vw, 13px); line-height: 1.7; border-radius: 4px; color: #b9a27a; font-weight: 700; }
.lboard i.on { background: #c8102e; color: #fff8e7; } .lboard i.last { background: #ffc93c; color: #2b1810; outline: 2px solid #c8102e; }
.tickets { display: grid; gap: 8px; width: min(100%, 460px); margin: 0 auto; }
.ticket { display: grid; gap: 2px; padding: 6px; border-radius: 10px; background: #f6e3b4; box-shadow: var(--clay-sm); border: 2px solid #c8102e; }
.lrow { display: grid; grid-template-columns: repeat(9, 1fr); gap: 2px; border-radius: 6px; padding: 1px; }
.lrow.done { background: linear-gradient(90deg, #ffe08a, #ffc93c); box-shadow: 0 0 0 2px #e8a317; }
.lrow.win { animation: lwin .8s ease-in-out infinite alternate; }
@keyframes lwin { to { box-shadow: 0 0 0 3px #c8102e, 0 0 16px 4px rgba(255,200,60,.9); } }
.lc { aspect-ratio: 1 / 1.05; min-width: 0; padding: 0; border: 0; border-radius: 5px; font: 800 clamp(13px, 3.8vw, 18px)/1 inherit; color: #2b1810; background: #fffaf0; display: grid; place-items: center; cursor: pointer; }
.lc.blank { background: repeating-linear-gradient(45deg, #ecd9a3 0 4px, #f3e4b8 4px 8px); cursor: default; }
.lc.call { animation: lcall .9s ease-in-out infinite alternate; background: #ffe9a8; }
@keyframes lcall { to { transform: scale(1.1); box-shadow: 0 0 0 2px #c8102e; } }
.lc.hit { background: radial-gradient(circle, #d7263d 0 58%, #fffaf0 60%); color: #fffaf0; }
.tag-btn { border: 0; cursor: pointer; font: inherit; }
.kinh { font-size: 20px; letter-spacing: .5px; min-width: 150px; }
.kinh.ready { animation: kready .5s ease-in-out infinite alternate; box-shadow: 0 0 0 4px rgba(255,200,60,.8), 0 0 22px 6px rgba(255,120,40,.7); }
@keyframes kready { to { transform: scale(1.08); } }
.turn-pill.loto .lball { margin: 0 4px; }
.lhist-pill { gap: 4px; }
#roomScreen.mode3d .tickets { width: min(100%, 420px); }
#roomScreen.mode3d .ticket { background: rgba(246,227,180,.94); }
@media (max-width: 520px) { .lball.big { width: 72px; height: 72px; font-size: 36px; } }

.table-area.loto-t { min-height: 660px; }
.loto2d .lboard { max-width: 520px; }
@media (max-width: 520px) {
  .table-area.loto-t { min-height: 640px; }
  .loto2d { gap: 4px; }
  .loto2d .lball.big { width: 56px; height: 56px; font-size: 28px; }
  .loto2d .lhist { max-width: 190px; gap: 3px; }
  .loto2d .lhist .lball.sm { width: 26px; height: 26px; font-size: 12px; }
  .loto2d .lboard { padding: 2px; gap: 1px; }
  .loto2d .lboard i { line-height: 1.4; font-size: 10px; }
  .loto2d .lnext { font-size: 12px; }
}

.hand-area.loto-h { background: linear-gradient(180deg, rgba(255, 241, 220, 0), var(--bg) 7%); }
#roomScreen.mode3d .hand-area.loto-h { background: none; }
.lnext .secs { position: static; display: inline; background: none; color: inherit; padding: 0; font-size: inherit; }

/* viên gạch nhỏ đặt che lên ô khi dò số */
.lc { position: relative; isolation: isolate; }
.lc.hit { background: #fffaf0; color: #fff5da; text-shadow: 0 1px 1px rgba(0, 0, 0, .45); }
.lc.hit::before { content: ''; position: absolute; inset: 1px; z-index: -1; border-radius: 4px; transform: rotate(var(--r, 0deg));
  background: linear-gradient(145deg, #e0453a 0%, #b01f26 58%, #7c1015 100%);
  box-shadow: inset 0 0 0 2px #f4c14e, inset 0 -3px 0 rgba(0, 0, 0, .28), 0 2px 3px rgba(0, 0, 0, .4); }
.lc.hit.fresh::before { animation: tiledrop .4s cubic-bezier(.3, 1.4, .5, 1); }
@keyframes tiledrop { 0% { transform: translateY(-26px) scale(1.7) rotate(-20deg); opacity: 0; } 55% { opacity: 1; } 100% { transform: rotate(var(--r, 0deg)); } }
.win-ticket .lc.hit::before { filter: saturate(1.15); }
.draw-btn { min-width: 150px; font-size: 18px; }

.table-area.loto-t.loto-done { min-height: 820px; }
@media (max-width: 520px) { .table-area.loto-t.loto-done { min-height: 800px; } }

img.brand-mark { width: 38px; height: 38px; display: block; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .3)); }

/* ===== tờ lô tô giấy màu + đống gạch ===== */
.sheet-wrap { display: flex; gap: 10px; align-items: flex-start; justify-content: center; width: min(100%, 540px); }
.sheet { --sc: #b87333; flex: 1; min-width: 0; padding: 5px; border-radius: 10px; background: var(--sc); display: grid; gap: 4px;
  box-shadow: var(--clay-sm), inset 0 0 0 2px rgba(255, 255, 255, .4); --ch: clamp(21px, 3.5vh, 34px); --cf: clamp(12px, 1.95vh, 17px); }
.sheet-wrap.small .sheet { --ch: clamp(15px, 2.3vh, 22px); --cf: clamp(9px, 1.4vh, 12px); }
.sheet-head { display: flex; justify-content: space-between; align-items: center; padding: 0 4px; font: 800 11px/1.2 inherit; letter-spacing: 1.5px; color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, .5); }
.sheet-head b { font-size: 12px; }
.vtk { display: grid; gap: 2px; padding: 3px; border-radius: 6px; background: rgba(255, 255, 255, .92); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .15); }
.sheet .lrow { grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 2px; padding: 0; background: none; box-shadow: none; border-radius: 3px; }
.sheet .lc { height: var(--ch); aspect-ratio: auto; border-radius: 3px; font: 800 var(--cf)/1 inherit; color: #14110d; background: #fffdf4; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12); }
.sheet .lc.blank { background: var(--sc); background-image: linear-gradient(135deg, rgba(255, 255, 255, .22) 0 50%, rgba(0, 0, 0, .1) 50%); box-shadow: none; }
.sheet .lrow.done .lc:not(.blank) { box-shadow: inset 0 0 0 2px #e8a317; }
.sheet .lrow.win { animation: lwin .8s ease-in-out infinite alternate; }
.sheet .lc.call { background: #ffe9a8; }
.sheet .lc.hit { background: #fffdf4; color: #fff5da; }
.sheet .lc.hov { outline: 3px solid #ffc93c; transform: scale(1.18); z-index: 3; }
.sheet-wrap.holding .lc.call { animation: lcall .5s ease-in-out infinite alternate; box-shadow: 0 0 0 3px #c8102e; }
#roomScreen.mode3d .sheet-wrap { width: min(100%, 520px); }
/* đống gạch */
.tile-pile { width: 62px; flex: none; display: grid; justify-items: center; gap: 3px; touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none; text-align: center; padding: 4px 2px; border-radius: 12px; }
.tile-pile small { font-size: 10px; line-height: 1.15; font-weight: 700; color: var(--ink-2); }
.pile-n { font-size: 12px; font-weight: 800; background: var(--ink); color: #fff; border-radius: 8px; padding: 0 7px; }
.pile-stack { position: relative; width: 54px; height: 62px; }
.pile-stack i { position: absolute; left: calc(var(--x) * 1px); bottom: calc(var(--i) * 6px); width: 44px; height: 30px; border-radius: 5px; transform: rotate(var(--rot));
  background: linear-gradient(145deg, #e0453a, #b01f26 58%, #7c1015); box-shadow: inset 0 0 0 2px #f4c14e, inset 0 -3px 0 rgba(0, 0, 0, .28), 0 2px 3px rgba(0, 0, 0, .4); }
.tile-pile.holding { background: rgba(255, 201, 60, .3); box-shadow: 0 0 0 3px #ffc93c; }
.tile-pile:active .pile-stack i:last-child { transform: rotate(var(--rot)) translateY(-4px); }
.tile-ghost { position: fixed; z-index: 9999; width: 40px; height: 32px; border-radius: 5px; pointer-events: none; transform: translate(-50%, -50%) rotate(-8deg) scale(1.2);
  background: linear-gradient(145deg, #e0453a, #b01f26 58%, #7c1015); box-shadow: inset 0 0 0 2px #f4c14e, 0 10px 14px rgba(0, 0, 0, .4); }
body.dragging-tile { cursor: grabbing; }
body.dragging-tile .lc.call { animation: lcall .5s ease-in-out infinite alternate; box-shadow: 0 0 0 3px #c8102e; }

img.brand-mark { width: 40px; height: 40px; border-radius: 10px; box-shadow: 0 2px 6px rgba(0, 0, 0, .35); filter: none; }

/* tờ của người khác / phóng to */
.sheet-btn { border: 0; cursor: pointer; font: inherit; font-size: 13px; background: var(--gold, #ffc93c); color: var(--ink); }
.zoom-meta { display: flex; gap: 8px; align-items: center; justify-content: center; flex-wrap: wrap; margin: 4px 0 10px; }
.sheet-wrap.zoom { width: min(100%, 560px); margin: 0 auto; }
.sheet-wrap.zoom .sheet { --ch: clamp(30px, 5.2vh, 46px); --cf: clamp(16px, 2.6vh, 22px); }
.sheet .lc:not(button) { cursor: default; }

/* ===== số vừa bốc ra hiện lớn + hướng dẫn lắc bao ===== */
.lball.md { width: 46px; height: 46px; font-size: 22px; }
.lball.huge { width: 150px; height: 150px; font-size: 76px; box-shadow: inset -8px -10px 16px rgba(0, 0, 0, .3), 0 0 0 6px rgba(255, 255, 255, .85), 0 0 50px 16px rgba(255, 201, 60, .85), 0 14px 30px rgba(0, 0, 0, .45); }
.big-num { position: fixed; z-index: 70; left: 50%; top: 24%; transform: translateX(-50%); display: grid; justify-items: center; gap: 6px; pointer-events: none; animation: bigin .6s cubic-bezier(.2, 1.5, .4, 1); }
.big-num small { font: 800 15px/1 inherit; letter-spacing: 2px; color: #fff; padding: 5px 14px; border-radius: 999px; background: rgba(138, 17, 36, .9); box-shadow: var(--clay-sm); }
.big-num.out { opacity: 0; transform: translateX(-50%) translateY(-24px) scale(.7); transition: opacity .6s, transform .6s; }
@keyframes bigin { from { transform: translateX(-50%) scale(.1) rotate(-240deg); opacity: 0; } to { transform: translateX(-50%); opacity: 1; } }
.shake-hud { position: fixed; z-index: 65; left: 50%; top: 22%; transform: translateX(-50%); width: min(92vw, 420px); display: grid; gap: 8px; justify-items: center; padding: 10px 14px; border-radius: 18px;
  background: rgba(255, 246, 225, .94); box-shadow: var(--clay); font-weight: 700; text-align: center; font-size: 15px; }
.shake-hud.prompt { top: 24%; width: auto; padding: 8px 16px; pointer-events: none; animation: pulse 1.4s ease-in-out infinite; }
.shake-hud.prompt .sh-bar, .shake-hud.prompt .sh-x { display: none; }
.sh-bar { width: 100%; height: 12px; border-radius: 8px; background: rgba(0, 0, 0, .14); overflow: hidden; }
.sh-bar i { display: block; height: 100%; width: 100%; transform-origin: left; background: linear-gradient(90deg, #ffc93c, #ff6a3d, #c8102e); transition: transform .08s linear; }
body.shaking .hand-area { transform: translateY(105%); transition: transform .35s ease; pointer-events: none; }
body.shaking #roomScreen.mode3d .room-top { opacity: .35; }
@media (max-width: 520px) { .lball.huge { width: 118px; height: 118px; font-size: 60px; } .big-num { top: 22%; } }
/* hướng dẫn lắc: nằm phía dưới (tờ dò đã trượt đi) để không che bao */
.shake-hud:not(.prompt) { top: auto; bottom: calc(18px + env(safe-area-inset-bottom)); }

/* 3D: vùng bài vốn "xuyên thấu" để chạm xuống cảnh 3D -> tờ và đống gạch phải nhận chạm */
#roomScreen.mode3d .sheet-wrap, #roomScreen.mode3d .tile-pile, #roomScreen.mode3d .sheet-btn { pointer-events: auto; }
/* gạch bay vào ô */
.sheet .lc.hit.fly::before { opacity: 0; animation: none; }
.sheet .lc.hit.fresh::before { animation: none; }
.sheet .lc.hit.land::before { animation: tilepop .28s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes tilepop { 0% { transform: rotate(var(--r, 0deg)) scale(1.35); } 100% { transform: rotate(var(--r, 0deg)) scale(1); } }

/* chuyển quyền chủ phòng */
.pass-list { list-style: none; margin: 8px 0; padding: 0; display: grid; gap: 8px; }
.pass-list li { display: flex; align-items: center; gap: 10px; background: #fff; border-radius: 12px; padding: 8px 10px; box-shadow: var(--clay-sm); }
.pass-list li b { flex: 1; }
.host-req { position: fixed; z-index: 66; left: 50%; top: 16%; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center; width: min(94vw, 460px);
  padding: 10px 14px; border-radius: 16px; background: rgba(255, 246, 225, .97); box-shadow: var(--clay); font-weight: 700; animation: bigin .4s cubic-bezier(.2, 1.4, .4, 1); }

/* Lì xì cho dev */
.panel-donate { border: 2px dashed #e8b44c; background: linear-gradient(180deg, #fff8e7, #fff1dc); }
.panel-donate h2 { margin-top: 0; }
.donate-card { display: grid; justify-items: center; gap: 10px; margin: 10px 0; }
.donate-card img { width: min(78vw, 260px); height: auto; border-radius: 14px; box-shadow: var(--clay); background: #fff; }
.donate-acc { display: grid; gap: 2px; text-align: center; }
.donate-acc span { font-size: 13px; color: var(--ink-2); }
.donate-acc .acc-no { font: 800 22px/1.3 ui-monospace, Menlo, Consolas, monospace; letter-spacing: 1px; color: var(--ink); user-select: all; }

/* ===== biểu tượng nổi "xin lì xì" – hiện ở mọi màn hình ===== */
.don-fab { position: fixed; z-index: 48; right: 10px; top: calc(var(--tb, 56px) + 10px); display: flex; align-items: center; justify-content: flex-end; gap: 6px; pointer-events: none; }
body.in-room .don-fab { top: calc(var(--tb, 56px) + 104px); }
.don-fab[hidden] { display: none; }
.don-main { pointer-events: auto; position: relative; width: 58px; height: 58px; border: 0; border-radius: 50%; cursor: pointer; padding: 0; font: inherit;
  background: radial-gradient(circle at 35% 30%, #fff3b0, #ffc93c 55%, #e29a12); box-shadow: 0 6px 0 #a8620a, 0 10px 18px rgba(0, 0, 0, .35), inset 0 2px 0 rgba(255, 255, 255, .6); animation: donbob 2.4s ease-in-out infinite; -webkit-tap-highlight-color: transparent; }
.don-main:active { transform: translateY(3px); box-shadow: 0 3px 0 #a8620a, 0 5px 10px rgba(0, 0, 0, .3); }
.don-face { position: absolute; left: 50%; top: 2px; transform: translateX(-50%); font-size: 30px; line-height: 1; filter: drop-shadow(0 1px 0 rgba(0, 0, 0, .25)); animation: donface 3.6s ease-in-out infinite; }
.don-bowl { position: absolute; left: 50%; bottom: -2px; transform: translateX(-50%); font-size: 26px; line-height: 1; transform-origin: 50% 80%; animation: donbowl 1.1s ease-in-out infinite; }
.don-coin { position: absolute; left: 50%; top: 40%; font-style: normal; font-size: 15px; opacity: 0; pointer-events: none; }
.don-fab.beg .don-coin.c1 { animation: doncoin 1.3s ease-out infinite; }
.don-fab.beg .don-coin.c2 { animation: doncoin2 1.3s ease-out .35s infinite; }
.don-fab.beg .don-coin.c3 { animation: doncoin3 1.3s ease-out .7s infinite; }
.don-tip { order: -1; pointer-events: none; max-width: min(62vw, 230px); padding: 7px 12px; border-radius: 16px 16px 4px 16px; background: #fff; color: #7a0f1c; font: 800 13px/1.25 inherit; text-align: center;
  box-shadow: var(--clay-sm), 0 6px 14px rgba(0, 0, 0, .25); opacity: 0; transform: translateX(14px) scale(.8); transform-origin: right center; transition: opacity .25s, transform .3s cubic-bezier(.2, 1.5, .4, 1); }
.don-tip.on { opacity: 1; transform: none; }
.don-x { pointer-events: auto; position: absolute; right: -4px; top: -8px; width: 20px; height: 20px; border: 0; border-radius: 50%; background: rgba(60, 15, 10, .75); color: #fff; font: 700 14px/20px inherit; padding: 0; cursor: pointer; opacity: .7; }
@keyframes donbob { 0%, 100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(-5px) rotate(3deg); } }
@keyframes donface { 0%, 80%, 100% { transform: translateX(-50%) scale(1); } 86% { transform: translateX(-50%) scale(1.15) rotate(-8deg); } 92% { transform: translateX(-50%) scale(1.15) rotate(8deg); } }
@keyframes donbowl { 0%, 100% { transform: translateX(-50%) rotate(-14deg); } 50% { transform: translateX(-50%) rotate(14deg); } }
@keyframes doncoin { 0% { opacity: 0; transform: translate(-50%, 6px) scale(.5); } 15% { opacity: 1; } 100% { opacity: 0; transform: translate(-26px, -46px) rotate(260deg) scale(1.1); } }
@keyframes doncoin2 { 0% { opacity: 0; transform: translate(-50%, 6px) scale(.5); } 15% { opacity: 1; } 100% { opacity: 0; transform: translate(10px, -56px) rotate(-200deg) scale(1.1); } }
@keyframes doncoin3 { 0% { opacity: 0; transform: translate(-50%, 6px) scale(.5); } 15% { opacity: 1; } 100% { opacity: 0; transform: translate(-6px, -36px) rotate(180deg) scale(1.2); } }
body.shaking .don-fab { display: none; }
@media (max-width: 520px) { .don-main { width: 52px; height: 52px; } .don-face { font-size: 27px; } .don-bowl { font-size: 23px; } }
@media (prefers-reduced-motion: reduce) { .don-main, .don-face, .don-bowl, .don-fab.beg .don-coin { animation: none !important; } }

/* ===== số người online + trạng thái tải ===== */
.cap-chip { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; margin-right: 8px; padding: 4px 11px; border-radius: 999px; background: rgba(255, 246, 225, .95); color: var(--ink);
  font-weight: 800; font-size: 13px; box-shadow: var(--clay-sm); white-space: nowrap; }
.cap-chip[hidden] { display: none; }
.cap-chip small { font-weight: 700; font-size: 12px; color: var(--ink-2); }
.cap-chip .dot { width: 10px; height: 10px; border-radius: 50%; background: #2fb344; box-shadow: 0 0 0 3px rgba(47, 179, 68, .25); animation: pulse 2s ease-in-out infinite; }
.cap-chip.lv-busy .dot { background: #f2a600; box-shadow: 0 0 0 3px rgba(242, 166, 0, .28); }
.cap-chip.lv-full .dot { background: #d7263d; box-shadow: 0 0 0 3px rgba(215, 38, 61, .28); }
@media (max-width: 520px) { .cap-chip { padding: 3px 8px; } .cap-chip small { display: none; } }
.cap-banner { margin: 12px auto 0; max-width: 560px; padding: 10px 14px; border-radius: 14px; font-weight: 700; text-align: center; box-shadow: var(--clay-sm); }
.cap-banner.lv-busy { background: #fff4cc; color: #6b4a00; }
.cap-banner.lv-full { background: #ffe1e1; color: #7a0f1c; }
.cap-banner.hidden { display: none; }
body.cap-full [data-create] { opacity: .55; filter: grayscale(.5); }
.full-overlay { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 20px; background: rgba(60, 15, 10, .8); backdrop-filter: blur(4px); }
.full-card { max-width: 380px; text-align: center; background: var(--cream, #fff6e0); color: var(--ink); border-radius: 22px; padding: 22px; box-shadow: var(--clay); }
.full-card h3 { margin: 6px 0; } .full-card p { margin: 0 0 14px; line-height: 1.5; }
