:root {
  --felt: #0f4f63;
  --felt-dark: #06222c;
  --gold: #f5b700;
  --gold-deep: #c98a00;
  --ink: #1d1d1f;
  --red: #c8102e;
  --paper: #fffdf6;
  --panel: rgba(4, 22, 30, 0.82);
  --text: #f7efe6;
  --muted: #b9d0d6;
  --win: #4be08c;
  --lose: #ff6b6b;
  --cw: 64px;
  --ch: 91px;
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; font-family: "Trebuchet MS", "Segoe UI", system-ui, -apple-system, sans-serif; color: var(--text); background: var(--felt-dark); -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
input { -webkit-user-select: text; user-select: text; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }

/* ---------- home / lobby ---------- */
.screen { position: fixed; inset: 0; }
#home, #lobby { overflow-y: auto; background: radial-gradient(ellipse at 50% 20%, #177089 0%, var(--felt) 40%, var(--felt-dark) 100%); }
.home-wrap { max-width: 560px; margin: 0 auto; padding: 18px 16px 48px; }
.back-link { display: inline-block; color: var(--muted); text-decoration: none; font-weight: 700; font-size: 15px; padding: 4px 0; }
.brand { text-align: center; margin: 4px 0 18px; }
.brand h1 { font-family: Georgia, "Times New Roman", serif; font-size: 42px; margin: 6px 0 0; text-shadow: 0 3px 0 rgba(0,0,0,.35); }
.brand h1 em { color: var(--gold); font-style: normal; }
.brand.small h1 { font-size: 30px; }
.brand .tag { margin: 4px 0 0; color: var(--muted); font-style: italic; }
.brand-art { position: relative; height: 72px; width: 170px; margin: 0 auto; }
.brand-art span { position: absolute; top: 6px; width: 46px; height: 64px; border-radius: 6px; background: var(--paper); color: var(--ink); display: grid; place-items: center; font: 800 20px Georgia, serif; box-shadow: 0 3px 8px rgba(0,0,0,.4); }
.brand-art span:nth-child(1) { left: 30px; transform: rotate(-12deg); }
.brand-art span:nth-child(2) { left: 62px; transform: rotate(0deg); }
.brand-art span:nth-child(3) { left: 94px; transform: rotate(12deg); }
.brand-art .red { color: var(--red); }
.panel { background: var(--panel); border: 1px solid rgba(255,255,255,.08); border-radius: 16px; padding: 16px; margin: 14px 0; box-shadow: 0 8px 24px rgba(0,0,0,.3); }
.panel h2 { margin: 0 0 8px; font-size: 20px; display: flex; align-items: center; gap: 8px; }
.hint { color: var(--muted); margin: 6px 0; }
.hint.small { font-size: 13px; }
.field { display: block; margin: 8px 0 4px; }
.field span { display: block; font-size: 14px; color: var(--muted); margin-bottom: 4px; }
.field input { width: 100%; font-size: 20px; padding: 12px 14px; border-radius: 12px; border: 2px solid rgba(255,255,255,.15); background: rgba(0,0,0,.3); color: var(--text); outline: none; }
.field input:focus { border-color: var(--gold); }
.row { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.row.center { justify-content: center; }
.center { text-align: center; }
.btn { border: 0; border-radius: 12px; padding: 12px 18px; font-size: 17px; font-weight: 700; background: rgba(255,255,255,.12); text-decoration: none; display: inline-block; text-align: center; }
.btn:active { transform: translateY(1px); }
.btn.gold { background: linear-gradient(#ffd24a, var(--gold) 50%, var(--gold-deep)); color: #3a2800; box-shadow: 0 3px 0 #8a5d00; }
.btn:disabled { filter: grayscale(.8); opacity: .55; }
.btn.big { width: 100%; font-size: 20px; padding: 14px; }
.btn.ghost { background: transparent; border: 2px solid rgba(255,255,255,.25); }
.btn.danger { background: #a3242f; }
.btn.small { padding: 7px 12px; font-size: 14px; }
.mode-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 6px 0 12px; }
.mode-picker button { text-align: left; padding: 10px 12px; border-radius: 12px; border: 2px solid rgba(255,255,255,.2); background: rgba(0,0,0,.25); }
.mode-picker button b { display: block; font-size: 16px; }
.mode-picker button small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.mode-picker button.on { border-color: var(--gold); background: rgba(245,183,0,.18); }
.count-picker { display: flex; gap: 8px; margin: 6px 0 14px; }
.count-picker button { flex: 1; font-size: 20px; font-weight: 700; padding: 9px 0; border-radius: 12px; border: 2px solid rgba(255,255,255,.2); background: rgba(0,0,0,.25); }
.count-picker button.on { border-color: var(--gold); background: rgba(245,183,0,.2); color: var(--gold); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--win); box-shadow: 0 0 8px var(--win); animation: pulse 1.6s infinite; }
.game-list { display: flex; flex-direction: column; gap: 8px; }
.game-item { display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 12px; background: rgba(255,255,255,.06); }
.game-item .gi-main { flex: 1; min-width: 0; }
.game-item .gi-title { font-weight: 700; font-size: 17px; }
.game-item .gi-sub { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.code { font-family: ui-monospace, Menlo, Consolas, monospace; background: rgba(0,0,0,.35); padding: 2px 6px; border-radius: 6px; font-size: 13px; margin-left: 6px; }
.icon-del { border: 0; background: rgba(0,0,0,.25); border-radius: 10px; width: 36px; height: 36px; font-size: 16px; flex: none; }
.code-row { display: flex; align-items: baseline; justify-content: space-between; }
.code-row strong { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 30px; color: var(--gold); letter-spacing: 4px; }
.mode-line { margin: 6px 0; font-weight: 700; }
.seat-list { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-direction: column; gap: 8px; }
.seat-list li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: rgba(255,255,255,.06); }
.seat-list li.empty { opacity: .5; border: 2px dashed rgba(255,255,255,.2); background: transparent; }
.seat-list .avatar { width: 34px; height: 34px; font-size: 16px; }
.seat-list .nm { flex: 1; font-weight: 700; font-size: 17px; }
.seat-list .tag { font-size: 12px; color: var(--muted); }
.seat-list .mini-btn { width: 36px; height: 36px; border-radius: 10px; border: 0; background: rgba(255,255,255,.12); font-size: 16px; }
.seat-list .mini-btn:disabled { opacity: .25; }
.avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; color: #fff; font-size: 17px; border: 2px solid rgba(255,255,255,.9); box-shadow: 0 2px 6px rgba(0,0,0,.4); flex: none; text-shadow: 0 1px 2px rgba(0,0,0,.4); }
.offline .avatar { filter: grayscale(1) brightness(.7); }

/* ---------- table ---------- */
#table { overflow: hidden; touch-action: none; }
.felt { position: absolute; inset: 0; background: radial-gradient(ellipse at 50% 45%, rgba(255,255,255,.08), transparent 60%), repeating-radial-gradient(circle at 30% 30%, rgba(0,0,0,.03) 0 2px, transparent 2px 4px), radial-gradient(ellipse at 50% 40%, #177089 0%, var(--felt) 45%, var(--felt-dark) 100%); }
.felt::after { content: ""; position: absolute; left: 50%; top: 44%; width: 60vw; height: 46vh; transform: translate(-50%, -50%); border: 2px solid rgba(245,183,0,.25); border-radius: 50%; pointer-events: none; }
.topbar { position: absolute; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: center; padding: 6px calc(10px + var(--safe-r)) 0 calc(10px + var(--safe-l)); z-index: 5; pointer-events: none; }
.topbar > * { pointer-events: auto; }
.round-info { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; text-shadow: 0 1px 2px rgba(0,0,0,.5); }
.bank-pill { background: linear-gradient(#ffd24a, var(--gold-deep)); color: #3a2800; padding: 4px 12px; border-radius: 999px; font-size: 15px; font-weight: 900; box-shadow: 0 0 12px rgba(245,183,0,.6); text-shadow: none; }
.top-buttons { display: flex; gap: 6px; }
.icon-btn { height: 34px; min-width: 34px; padding: 0 8px; border-radius: 10px; border: 0; background: rgba(0,0,0,.35); font-size: 16px; display: flex; align-items: center; gap: 4px; }
.icon-btn span { font-size: 13px; font-weight: 700; }
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }

/* seats */
.seat { position: absolute; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; width: 104px; z-index: 2; }
.seat .seat-top, .me-seat .av-wrap { position: relative; }
.seat .name { margin-top: 2px; font-size: 13px; font-weight: 700; max-width: 104px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: rgba(0,0,0,.4); padding: 1px 8px; border-radius: 999px; }
.seat .chips, .me-seat .chips { font-size: 12px; color: var(--gold); font-weight: 800; }
.seat .seat-status { font-size: 11px; color: var(--muted); font-weight: 700; min-height: 14px; }
.seat .seat-status.done { color: var(--win); }
.seat.out { opacity: .45; }
.bank-badge { position: absolute; right: -14px; top: -8px; font-size: 18px; filter: drop-shadow(0 1px 2px rgba(0,0,0,.6)); }
.seat.bank .avatar, .me-seat.bank .avatar { box-shadow: 0 0 0 3px var(--gold), 0 0 14px 4px rgba(245,183,0,.6); }
.seat.comparing { z-index: 6; }
.seat.comparing .avatar { animation: glow 1s ease-in-out infinite; }
.mini-fan { position: relative; height: 24px; width: 70px; }
.mini-fan .mb { position: absolute; bottom: 0; left: 50%; width: 15px; height: 21px; margin-left: -7px; border-radius: 3px; transform-origin: 50% 120%; }
.bet-spot { min-height: 26px; display: flex; align-items: center; justify-content: center; }
.result-badge { font-size: 13px; font-weight: 900; padding: 2px 8px; border-radius: 999px; animation: pop .35s ease-out; }
.result-badge.win { background: var(--win); color: #053; }
.result-badge.lose { background: var(--lose); color: #400; }
.result-badge.push { background: #ddd; color: #333; }

/* chips */
.pchip { position: relative; width: 26px; height: 26px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 9px; font-weight: 900; color: #fff; border: 3px dashed rgba(255,255,255,.85); box-shadow: 0 2px 4px rgba(0,0,0,.5), inset 0 0 0 2px rgba(0,0,0,.2); }
.pchip.c20 { background: #2166c4; }
.pchip.c100 { background: #1a1a1a; }
.pchip.c200 { background: #7b2cbf; }
.pchip.c500 { background: #e0a800; color: #3a2800; }
.bet-stack { display: flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 800; }
.chip-fly { position: fixed; left: 0; top: 0; z-index: 35; pointer-events: none; }

/* center */
#center { position: absolute; left: 50%; top: 43%; transform: translate(-50%, -50%); z-index: 3; display: flex; flex-direction: column; align-items: center; gap: 8px; max-width: 78vw; }
.center-msg { background: rgba(0,0,0,.45); padding: 8px 14px; border-radius: 12px; font-weight: 700; text-align: center; font-size: 14px; }
.deck { position: relative; width: 44px; height: 62px; }
.deck .card { position: absolute; inset: 0; --w: 44px; width: 44px; height: 62px; }
.dealer-spot { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.dealer-spot .who { font-size: 13px; font-weight: 800; background: rgba(0,0,0,.45); padding: 2px 10px; border-radius: 999px; }
.dealer-fan { display: flex; }
.dealer-fan .card { --w: 28px; width: 28px; height: 40px; }
.dealer-fan .card + .card { margin-left: -14px; }
.bet-panel { background: rgba(0,0,0,.5); border: 2px solid rgba(245,183,0,.5); border-radius: 16px; padding: 10px 14px; display: flex; flex-direction: column; align-items: center; gap: 8px; box-shadow: 0 8px 20px rgba(0,0,0,.4); }
.bet-amount { display: flex; align-items: baseline; gap: 8px; }
.bet-amount .lbl { color: var(--muted); font-size: 13px; font-weight: 700; }
.bet-amount b { font-size: 28px; color: var(--gold); }
.chip-row { display: flex; gap: 10px; }
.chip-row .pchip { width: 46px; height: 46px; font-size: 13px; border-width: 4px; }
.chip-row .pchip:active { transform: scale(.92); }
.bet-actions { display: flex; gap: 8px; }
.bet-actions .btn { padding: 8px 14px; font-size: 15px; }

/* showdown compare */
.compare { display: flex; align-items: stretch; gap: 14px; background: rgba(0,0,0,.45); padding: 8px 12px; border-radius: 16px; box-shadow: 0 8px 24px rgba(0,0,0,.4); }
.compare .side { display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 150px; }
.compare .who { font-size: 13px; font-weight: 800; white-space: nowrap; }
.compare .hrow { display: flex; align-items: center; gap: 6px; padding: 2px 4px; border-radius: 8px; transition: background .3s, opacity .3s; }
.compare .hrow .cards { display: flex; }
.compare .hrow .card { --w: 26px; width: 26px; height: 37px; }
.compare .hrow .card + .card { margin-left: -6px; }
.compare .hrow .hname { font-size: 10px; color: var(--muted); max-width: 90px; line-height: 1.1; }
.compare .hrow.won { background: rgba(75,224,140,.25); box-shadow: 0 0 0 2px var(--win); }
.compare .hrow.lost { opacity: .5; }
.compare .vs { align-self: center; font: 900 20px Georgia, serif; color: var(--gold); }
.compare .outcome { align-self: center; font-size: 16px; font-weight: 900; min-height: 22px; }
.compare .outcome.win { color: var(--win); } .compare .outcome.lose { color: var(--lose); }
.card.flip-in { animation: flipIn .45s ease-out both; }
.skip-btn { border: 0; border-radius: 999px; padding: 4px 12px; font-size: 12px; font-weight: 800; background: rgba(0,0,0,.45); }
.summary { display: flex; flex-direction: column; align-items: center; gap: 6px; background: rgba(0,0,0,.45); padding: 10px 16px; border-radius: 16px; }
.summary .line { font-size: 14px; font-weight: 700; }
.summary .big { font-size: 22px; font-weight: 900; }
.summary .big.win { color: var(--win); } .summary .big.lose { color: var(--lose); }
.summary .acts { display: flex; gap: 8px; margin-top: 4px; }
.summary .acts .btn { padding: 8px 14px; font-size: 15px; }

/* status */
.status { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(var(--ch) + 40px + var(--safe-b)); z-index: 4; font-size: 14px; font-weight: 700; padding: 5px 14px; border-radius: 999px; background: rgba(0,0,0,.45); white-space: nowrap; max-width: 70vw; overflow: hidden; text-overflow: ellipsis; }
.status:empty { display: none; }
.status.mine { background: var(--gold); color: #3a2800; box-shadow: 0 0 16px rgba(245,183,0,.7); }

/* me */
.me-seat { position: absolute; left: calc(8px + var(--safe-l)); bottom: calc(10px + var(--safe-b)); display: flex; flex-direction: column; align-items: flex-start; gap: 2px; z-index: 4; max-width: 120px; }
.me-seat .me-row { display: flex; align-items: center; gap: 6px; }
.me-seat .me-name { font-size: 13px; font-weight: 700; }
.me-seat .avatar { width: 34px; height: 34px; font-size: 15px; }

/* my hand */
.my-area { position: absolute; left: 50%; bottom: calc(8px + var(--safe-b)); transform: translateX(-50%); display: flex; gap: 22px; align-items: flex-end; z-index: 4; }
.zone { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.zone-label { font-size: 12px; font-weight: 800; color: var(--muted); white-space: nowrap; min-height: 15px; }
.zone-label b { color: var(--text); }
.zone-label.foul { color: var(--lose); }
.zone-label .res { margin-left: 4px; }
.zone-cards { display: flex; min-height: var(--ch); padding: 4px; border-radius: 12px; }
.low-zone .zone-cards { background: rgba(0,0,0,.25); border: 2px dashed rgba(245,183,0,.55); gap: 6px; }
.high-zone .zone-cards { background: rgba(0,0,0,.15); border: 2px dashed rgba(255,255,255,.2); }
.high-zone .zone-cards .card + .card { margin-left: calc(var(--cw) * -0.22); }
.zone-cards .card { width: var(--cw); height: var(--ch); cursor: pointer; }
.slot { width: var(--cw); height: var(--ch); border-radius: calc(var(--cw) * .1); border: 2px dashed rgba(255,255,255,.3); display: grid; place-items: center; font-size: 11px; color: var(--muted); text-align: center; padding: 4px; }
.zone.won .zone-cards { box-shadow: 0 0 0 3px var(--win), 0 0 18px rgba(75,224,140,.6); }
.zone.lost .zone-cards { opacity: .6; }
.hand-tools { position: absolute; right: calc(8px + var(--safe-r)); bottom: calc(10px + var(--safe-b)); display: flex; flex-direction: column; gap: 8px; align-items: stretch; z-index: 4; }
.hand-tools .btn { padding: 10px 14px; font-size: 15px; }
.chip-btn { border: 0; border-radius: 999px; padding: 7px 12px; font-size: 13px; font-weight: 800; background: rgba(0,0,0,.45); }
.chip-btn:active { background: rgba(245,183,0,.4); }

/* ---------- cards ---------- */
.card { --w: var(--cw); position: relative; border-radius: calc(var(--w) * .1); background: var(--paper); box-shadow: 0 1px 0 rgba(0,0,0,.15), 0 3px 8px rgba(0,0,0,.35); color: var(--ink); overflow: hidden; font-family: Georgia, "Times New Roman", serif; border: 1px solid rgba(0,0,0,.15); flex: none; }
.card .c-rank { position: absolute; left: 7%; top: 3%; font-weight: 800; font-size: calc(var(--w) * .34); line-height: 1; letter-spacing: -1px; }
.card .c-suit { position: absolute; left: 8%; top: calc(3% + var(--w) * .36); font-size: calc(var(--w) * .26); line-height: 1; }
.card .c-big { position: absolute; left: 0; right: 0; bottom: 8%; text-align: center; font-size: calc(var(--w) * .6); line-height: 1; }
.card.red { color: var(--red); }
.card.joker { background: linear-gradient(135deg, #fff6d8, #ffe08a 40%, #ffc6e0 70%, #c8e4ff); color: #6a1b9a; }
.card.joker .c-rank { font-size: calc(var(--w) * .16); letter-spacing: 0; writing-mode: vertical-rl; text-orientation: upright; top: 6%; }
.card.joker .c-big { font-size: calc(var(--w) * .5); bottom: 16%; }
.card.back, .mb { background: radial-gradient(circle at 50% 50%, rgba(245,183,0,.9) 0 12%, transparent 13%), repeating-linear-gradient(45deg, rgba(255,255,255,.08) 0 4px, transparent 4px 8px), linear-gradient(135deg, #0f3b6e, #1d5fa8 50%, #0b2a52); border: 2px solid #fff; box-shadow: 0 2px 5px rgba(0,0,0,.4); }
.card.back > * { display: none; }
.card.pending { visibility: hidden; }
.mini .card, .card.mini { --w: 22px; width: 22px; height: 31px; border-radius: 3px; }
.mini .card .c-big { display: none; }

/* flying */
#fx { position: absolute; inset: 0; pointer-events: none; z-index: 30; }
.fly { position: fixed; left: 0; top: 0; will-change: transform; perspective: 600px; }
.fly .flip { position: absolute; inset: 0; transform-style: preserve-3d; }
.fly .flip > .card { position: absolute; inset: 0; width: 100%; height: 100%; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.fly .flip > .card.face { transform: rotateY(180deg); }

/* dice */
.dice-show { position: fixed; left: 50%; top: 42%; transform: translate(-50%, -50%); z-index: 31; display: flex; flex-direction: column; align-items: center; gap: 10px; pointer-events: none; }
.dice-row { display: flex; gap: 14px; }
.die { width: 56px; height: 56px; border-radius: 12px; background: linear-gradient(145deg, #e0223f, #9c0f24); color: #fff; font-size: 50px; line-height: 56px; text-align: center; box-shadow: 0 6px 14px rgba(0,0,0,.5), inset 0 -3px 0 rgba(0,0,0,.25); }
.die.rolling { animation: tumble .25s linear infinite; }
.dice-label { background: rgba(0,0,0,.6); padding: 6px 16px; border-radius: 999px; font-weight: 800; font-size: 16px; animation: pop .35s ease-out; }
.seat.first .avatar, .me-seat.first .avatar { animation: glow .6s ease-in-out 3; }
.hand-intro { position: fixed; left: 50%; top: 42%; transform: translate(-50%, -50%); z-index: 31; text-align: center; pointer-events: none; animation: zoomIn .4s cubic-bezier(.2,1.6,.4,1) both; }
.hand-intro.out { animation: fadeOut .3s ease-in forwards; }
.hand-intro .hi-big { font-family: Georgia, serif; font-size: 10vh; font-weight: 900; text-shadow: 0 4px 0 rgba(0,0,0,.35); }
.hand-intro .hi-bank { display: inline-block; margin-top: 4px; font-size: 4.5vh; font-weight: 900; padding: 4px 18px; border-radius: 999px; background: linear-gradient(#ffd24a, var(--gold-deep)); color: #3a2800; box-shadow: 0 0 30px rgba(245,183,0,.9); }

/* ---------- overlays ---------- */
.overlay { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.6); display: grid; place-items: center; padding: 12px; animation: fade .2s ease-out; }
#standings, #results, #menu { z-index: 65; }
.sheet { position: relative; background: #0a2b36; border: 1px solid rgba(255,255,255,.12); border-radius: 18px; padding: 16px 18px; max-width: 94vw; max-height: 92vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.6); animation: rise .25s ease-out; }
.sheet.narrow { width: 440px; }
.sheet.wide { width: 900px; }
.sheet h2 { margin: 0 0 10px; font-family: Georgia, serif; }
.sheet .close { position: absolute; right: 10px; top: 10px; width: 34px; height: 34px; border-radius: 50%; border: 0; background: rgba(255,255,255,.1); font-size: 16px; }
.sheet > .btn.ghost, .sheet > .btn.danger, .linkbtn { width: 100%; margin-top: 8px; }
.rules { margin-top: 14px; font-size: 13px; color: var(--muted); }
.rules h3 { color: var(--text); margin: 0 0 4px; font-size: 15px; }
.rules p { margin: 4px 0; }
.claim-list { display: flex; flex-direction: column; gap: 8px; }
.claim-list button { padding: 10px; border-radius: 12px; border: 0; background: rgba(255,255,255,.08); font-size: 17px; font-weight: 700; text-align: left; }
.stand-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; background: rgba(255,255,255,.06); margin-bottom: 6px; }
.stand-row.lead { background: rgba(245,183,0,.15); border: 1px solid rgba(245,183,0,.5); }
.stand-row .nm { flex: 1; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.stand-row .avatar { width: 28px; height: 28px; font-size: 13px; }
.stand-row .amt { font-weight: 900; color: var(--gold); font-size: 17px; }
.stand-row .chg { width: 60px; text-align: right; font-size: 13px; font-weight: 800; }
.chg.up { color: var(--win); } .chg.down { color: var(--lose); }
.res-row { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 12px; background: rgba(255,255,255,.05); margin-bottom: 6px; flex-wrap: wrap; }
.res-row.bank { background: rgba(245,183,0,.12); border: 1px solid rgba(245,183,0,.4); }
.res-row .who { width: 110px; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.res-row .who .avatar { width: 26px; height: 26px; font-size: 12px; }
.res-row .hand { display: flex; flex-direction: column; gap: 2px; }
.res-row .hand .cards { display: flex; gap: 2px; }
.res-row .hand small { color: var(--muted); font-size: 11px; }
.res-row .hand.won .cards { outline: 2px solid var(--win); border-radius: 4px; }
.res-row .out { margin-left: auto; font-weight: 900; }
.out.win { color: var(--win); } .out.lose { color: var(--lose); }
.winner-banner { text-align: center; font-size: 20px; margin: 4px 0 12px; }
.winner-banner .big { font-size: 46px; display: block; animation: float 1.4s ease-in-out infinite; }
.history-list { display: flex; flex-direction: column; gap: 8px; }
.history-item { display: flex; align-items: center; gap: 10px; background: rgba(255,255,255,.06); border-radius: 12px; padding: 10px 12px; }
.history-item .hi-main { flex: 1; min-width: 0; }
.history-item .hi-date { font-size: 12px; color: var(--muted); }
.history-item .hi-title { font-size: 16px; margin: 2px 0; }
.history-item .hi-sub { font-size: 13px; color: var(--muted); }
.win-tally { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.win-chip { background: rgba(245,183,0,.15); border: 1px solid rgba(245,183,0,.5); border-radius: 999px; padding: 4px 12px; font-size: 14px; }
.win-chip b { color: var(--gold); margin-left: 4px; }

.rotate { display: none; }
@media (orientation: portrait) {
  body.in-game .rotate { display: flex; position: fixed; inset: 0; z-index: 100; flex-direction: column; align-items: center; justify-content: center; background: var(--felt-dark); font-size: 20px; text-align: center; padding: 24px; }
  .rotate-phone { font-size: 80px; animation: turn 2s ease-in-out infinite; }
}
.toast { position: fixed; left: 50%; top: 14px; transform: translateX(-50%); z-index: 90; background: #222; color: #fff; padding: 10px 16px; border-radius: 12px; font-weight: 700; box-shadow: 0 8px 20px rgba(0,0,0,.5); max-width: 90vw; }
.toast.err { background: #a3242f; }
.celebrate { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 70; pointer-events: none; }
.turn-flash { position: absolute; inset: 0; z-index: 25; pointer-events: none; box-shadow: inset 0 0 60px 10px rgba(245,183,0,.7); animation: fadeOut 1.2s ease-out forwards; }

@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .45; } }
@keyframes glow { 0%,100% { box-shadow: 0 0 0 3px var(--gold), 0 0 10px 3px rgba(245,183,0,.6); } 50% { box-shadow: 0 0 0 3px var(--gold), 0 0 24px 9px rgba(245,183,0,.95); } }
@keyframes float { 0%,100% { transform: none; } 50% { transform: translateY(-8px); } }
@keyframes zoomIn { from { transform: translate(-50%, -50%) scale(0); opacity: 0; } to { transform: translate(-50%, -50%) scale(1); opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }
@keyframes rise { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes pop { 0% { transform: scale(.6); } 70% { transform: scale(1.12); } 100% { transform: scale(1); } }
@keyframes flipIn { from { transform: rotateY(90deg); } to { transform: none; } }
@keyframes tumble { 0% { transform: rotate(0) translateY(0); } 50% { transform: rotate(180deg) translateY(-14px); } 100% { transform: rotate(360deg) translateY(0); } }
@keyframes turn { 0%,20% { transform: rotate(0); } 50%,80% { transform: rotate(-90deg); } 100% { transform: rotate(0); } }
.compare .side.mid { min-width: 0; justify-content: center; gap: 6px; }

/* Showdown compare: sized to the screen so the hands are easy to read */
.compare { --cmpw: clamp(34px, 9.5vh, 90px); gap: clamp(10px, 3vw, 28px); padding: 10px 18px 12px; border: 2px solid rgba(245,183,0,.45); }
.compare .side { min-width: 0; gap: 6px; }
.compare .who { font-size: clamp(14px, 4vh, 22px); }
.compare .hrow { flex-direction: column; gap: 2px; padding: 4px 6px; }
.compare .hrow .card { --w: var(--cmpw); width: var(--cmpw); height: calc(var(--cmpw) * 1.42); }
.compare .hrow .card + .card { margin-left: calc(var(--cmpw) * -0.16); }
.compare .hrow .hname { font-size: clamp(11px, 3vh, 17px); font-weight: 700; color: var(--text); max-width: none; white-space: nowrap; }
.compare .vs { font-size: clamp(22px, 7vh, 44px); }
.compare .outcome { font-size: clamp(15px, 4.6vh, 28px); text-align: center; max-width: 30vw; }
.skip-btn { font-size: clamp(12px, 3vh, 16px); padding: 5px 14px; }

/* Showdown: the bank lays its cards out in a row, then splits them */
#center.showdown { top: 40%; }
.compare .lay { display: flex; gap: 4px; }
.compare .lay:empty { display: none; }
.compare .lay .card { --w: var(--cmpw); width: var(--cmpw); height: calc(var(--cmpw) * 1.42); }
.compare .side.laying .hrow { display: none; }
.compare .nav { display: flex; align-items: center; gap: 10px; }
.navb { border: 0; border-radius: 50%; width: clamp(30px, 8vh, 44px); height: clamp(30px, 8vh, 44px); font-size: clamp(13px, 3.4vh, 18px); background: rgba(255,255,255,.14); }
.navb:active { background: rgba(245,183,0,.45); }
.counter { font-size: 12px; color: var(--muted); font-weight: 700; min-height: 14px; }
.showdown-wrap { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.summary-bar { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 12px; background: rgba(0,0,0,.5); padding: 6px 12px; border-radius: 14px; }
.summary-bar .line { font-size: 14px; font-weight: 700; }
.summary-bar .big { font-size: clamp(15px, 4.4vh, 22px); font-weight: 900; }
.summary-bar .big.win { color: var(--win); } .summary-bar .big.lose { color: var(--lose); }
.summary-bar .acts { display: flex; gap: 8px; }
.summary-bar .btn { padding: 7px 12px; font-size: 14px; }

/* Bigger names, chip counts and bets around the table (scale with the screen) */
.seat { width: clamp(110px, 16vw, 170px); }
.seat .name { font-size: clamp(15px, 4.4vh, 22px); max-width: 100%; padding: 2px 10px; }
.seat .chips, .me-seat .chips { font-size: clamp(14px, 4.2vh, 21px); text-shadow: 0 1px 2px rgba(0,0,0,.6); }
.seat .seat-status { font-size: clamp(12px, 3.4vh, 16px); min-height: 1.2em; }
.seat .avatar { width: clamp(38px, 10vh, 54px); height: clamp(38px, 10vh, 54px); font-size: clamp(17px, 4.6vh, 24px); }
.bank-badge { font-size: clamp(18px, 5vh, 26px); right: -18px; }
.bet-spot { min-height: clamp(28px, 8vh, 40px); }
.bet-stack { font-size: clamp(14px, 4.4vh, 22px); gap: 6px; text-shadow: 0 1px 2px rgba(0,0,0,.6); }
.bet-stack .pchip { width: clamp(24px, 7vh, 36px); height: clamp(24px, 7vh, 36px); }
.result-badge { font-size: clamp(14px, 4.2vh, 20px); padding: 3px 10px; }
.me-seat { max-width: 180px; }
.me-seat .me-name { font-size: clamp(15px, 4.4vh, 22px); }
.me-seat .avatar { width: clamp(34px, 9vh, 48px); height: clamp(34px, 9vh, 48px); font-size: clamp(15px, 4.2vh, 22px); }

/* ---------- Blackjack ---------- */
.card.back, .mb { background: radial-gradient(circle at 50% 50%, rgba(245,183,0,.9) 0 12%, transparent 13%), repeating-linear-gradient(45deg, rgba(255,255,255,.08) 0 4px, transparent 4px 8px), linear-gradient(135deg, #7a1422, #b3263a 50%, #4a0b15); }
#center { top: 38%; gap: 10px; }
.dealer-zone { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.dealer-zone .who { font-size: clamp(14px, 4vh, 21px); font-weight: 800; background: rgba(0,0,0,.45); padding: 2px 12px; border-radius: 999px; }
.dz-row { display: flex; align-items: center; gap: 18px; }
.dealer-cards { display: flex; min-height: calc(var(--dw) * 1.42); min-width: calc(var(--dw) * 2); }
.dealer-zone { --dw: clamp(36px, 10vh, 84px); }
.dealer-cards .card { --w: var(--dw); width: var(--dw); height: calc(var(--dw) * 1.42); }
.dealer-cards .card + .card { margin-left: calc(var(--dw) * -0.28); }
.dealer-total { font-size: clamp(14px, 4.2vh, 22px); font-weight: 900; min-height: 1.3em; text-shadow: 0 1px 3px rgba(0,0,0,.6); }
.dealer-total.bj { color: var(--gold); } .dealer-total.bust { color: var(--win); }
.dealer-total.checking { color: var(--muted); animation: pulse .8s ease-in-out infinite; }
.shoe { position: relative; width: calc(var(--dw) * .8); height: calc(var(--dw) * 1.1); border-radius: 8px; background: linear-gradient(#3a2a1a, #1e140a); box-shadow: 0 4px 10px rgba(0,0,0,.5), inset 0 2px 0 rgba(255,255,255,.15); }
.shoe .card { position: absolute; left: 6%; top: -12%; --w: calc(var(--dw) * .7); width: calc(var(--dw) * .7); height: calc(var(--dw) * .98); transform: rotate(-8deg); }
.shoe small { position: absolute; bottom: -1.4em; left: 50%; transform: translateX(-50%); font-size: 11px; color: var(--muted); white-space: nowrap; }
#below { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.dealer-hit { font-size: clamp(16px, 4.6vh, 22px); padding: 10px 26px; }

/* my hands */
.my-hands { position: absolute; left: 50%; bottom: calc(8px + var(--safe-b)); transform: translateX(-50%); display: flex; gap: 18px; align-items: flex-end; z-index: 4; max-width: calc(100vw - 330px); }
.bj-hand { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 4px 6px; border-radius: 12px; transition: box-shadow .2s, background .2s; }
.bj-hand.current { background: rgba(245,183,0,.14); box-shadow: 0 0 0 2px var(--gold), 0 0 16px rgba(245,183,0,.5); }
.bj-hand .hand-label { font-size: clamp(13px, 3.8vh, 19px); font-weight: 900; white-space: nowrap; text-shadow: 0 1px 2px rgba(0,0,0,.6); }
.bj-hand .hand-label small { font-weight: 700; color: var(--muted); font-size: .8em; margin-left: 4px; }
.bj-hand .hand-cards { display: flex; }
.bj-hand .hand-cards .card { width: var(--cw); height: var(--ch); }
.bj-hand .hand-cards .card + .card { margin-left: calc(var(--cw) * -0.45); }
.bj-hand.many .hand-cards .card + .card { margin-left: calc(var(--cw) * -0.62); }
.bj-hand .hand-res { min-height: 1.4em; }
.actions { position: absolute; right: calc(8px + var(--safe-r)); bottom: calc(10px + var(--safe-b)); display: grid; grid-template-columns: 1fr 1fr; gap: 8px; z-index: 5; }
.actions .btn { padding: clamp(8px, 2.6vh, 14px) clamp(10px, 2vw, 18px); font-size: clamp(14px, 4vh, 19px); }
.actions .btn.hint { grid-column: span 2; background: rgba(0,0,0,.4); font-size: 13px; padding: 6px; }
.actions .btn.suggest { box-shadow: 0 0 0 3px #fff, 0 0 20px #fff; animation: pulse .8s ease-in-out 3; }

/* settle: each player's cards are turned over in turn */
.player-row { display: flex; align-items: center; gap: 14px; background: rgba(0,0,0,.5); border: 2px solid rgba(245,183,0,.45); padding: 8px 14px; border-radius: 16px; --pw: clamp(34px, 9.5vh, 80px); }
.player-row .who { font-size: clamp(14px, 4vh, 21px); font-weight: 800; white-space: nowrap; }
.player-row .p-hands { display: flex; gap: 14px; }
.player-row .p-hand { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.player-row .p-hand .cards { display: flex; min-height: calc(var(--pw) * 1.42); }
.player-row .p-hand .card { --w: var(--pw); width: var(--pw); height: calc(var(--pw) * 1.42); }
.player-row .p-hand .card + .card { margin-left: calc(var(--pw) * -0.3); }
.player-row .p-hand .tot { font-size: clamp(12px, 3.4vh, 17px); font-weight: 800; }
.player-row .p-hand .res { font-size: clamp(12px, 3.4vh, 17px); font-weight: 900; min-height: 1.2em; }
.res.win, .res.blackjack { color: var(--win); } .res.lose, .res.bust { color: var(--lose); } .res.push { color: #ddd; }
.player-row .nav { display: flex; gap: 8px; }
.result-badge.blackjack { background: var(--gold); color: #3a2800; }
.center-msg.mine { background: linear-gradient(#ffd24a, var(--gold) 50%, var(--gold-deep)); color: #3a2800; font-size: clamp(14px, 4vh, 20px); box-shadow: 0 0 16px rgba(245,183,0,.7); }
