:root {
  --felt: #3a2466;
  --felt-dark: #150c2a;
  --gold: #f5b700;
  --gold-deep: #c98a00;
  --ink: #1d1d1f;
  --red: #c8102e;
  --paper: #fffdf6;
  --panel: rgba(18, 10, 36, 0.82);
  --text: #f7efe6;
  --muted: #c9bfe0;
  --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%, #54348f 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%, #54348f 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: #221540; 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); }

/* Fortune Bonus side bet */
.fortune-row { display: flex; align-items: center; gap: 6px; }
.fortune-row .lbl { color: var(--muted); font-size: 13px; font-weight: 700; margin-right: 2px; }
.fchip { border: 2px solid rgba(255,255,255,.3); background: rgba(0,0,0,.3); border-radius: 999px; padding: 4px 10px; font-weight: 800; font-size: 13px; }
.fchip.on { border-color: #4be08c; background: rgba(75,224,140,.25); color: #fff; }
.fchip:disabled { opacity: .35; }
.fortune-tag { margin-left: 6px; font-size: .8em; color: #7dffb0; }
.fortune-line { font-size: clamp(12px, 3.4vh, 17px); font-weight: 800; color: #7dffb0; margin-top: 2px; }
.fortune-row #fortAmt { font-size: 20px; color: #7dffb0; min-width: 44px; text-align: center; }
.fortune-row .pchip { width: 38px; height: 38px; font-size: 12px; }
.fortune-row .pchip:disabled { opacity: .35; }

/* ---------- Splendor ---------- */
:root {
  --gw: #f4f1ea; --gu: #1f6fd1; --gg: #1f9a53; --gr: #d6283a; --gk: #2b2b2b; --gx: #f5b700;
}
.felt::after { display: none; }
.brand-gems { display: flex; justify-content: center; gap: 8px; margin-bottom: 6px; }
.brand-gems .gem { width: 28px; height: 28px; }

/* gems (tokens) */
.gem { display: inline-block; width: 22px; height: 22px; border-radius: 50%; position: relative; flex: none;
  box-shadow: inset 0 -3px 0 rgba(0,0,0,.25), inset 0 2px 0 rgba(255,255,255,.45), 0 2px 4px rgba(0,0,0,.45); border: 2px solid rgba(255,255,255,.85); }
.gem::after { content: ""; position: absolute; inset: 22%; border-radius: 50%; border: 1.5px dashed rgba(255,255,255,.55); }
.g-w { background: radial-gradient(circle at 35% 30%, #fff, #d9d4c7); border-color: #9a927f; }
.g-w::after { border-color: rgba(0,0,0,.25); }
.g-u { background: radial-gradient(circle at 35% 30%, #6fb0ff, var(--gu)); }
.g-g { background: radial-gradient(circle at 35% 30%, #6fe0a0, var(--gg)); }
.g-r { background: radial-gradient(circle at 35% 30%, #ff7b8a, var(--gr)); }
.g-k { background: radial-gradient(circle at 35% 30%, #777, #111); }
.g-x { background: radial-gradient(circle at 35% 30%, #fff1a8, var(--gx)); border-color: #fff4c2; }

/* layout */
.layout { position: absolute; left: 0; right: 0; top: 40px; bottom: 0; display: grid; grid-template-columns: minmax(200px, 1fr) auto auto; gap: 10px; padding: 0 calc(8px + var(--safe-r)) calc(6px + var(--safe-b)) calc(8px + var(--safe-l)); }
.players { display: flex; flex-direction: column; gap: 6px; overflow-y: auto; min-width: 0; }
.board { display: flex; flex-direction: column; gap: 6px; justify-content: center; --cw: clamp(44px, calc((100vh - 72px) / 4.96), 130px); --chh: calc(var(--cw) * 1.38); }
.bank-col { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; }

/* player panels */
.pp { background: rgba(0,0,0,.35); border: 2px solid rgba(255,255,255,.08); border-radius: 12px; padding: 5px 8px; display: flex; flex-direction: column; gap: 4px; }
.pp.turn { border-color: var(--gold); box-shadow: 0 0 14px rgba(245,183,0,.5); }
.pp.me { background: rgba(255,255,255,.08); }
.pp-head { display: flex; align-items: center; gap: 6px; }
.pp-head .avatar { width: 26px; height: 26px; font-size: 13px; }
.pp-name { font-weight: 800; font-size: clamp(13px, 3.8vh, 18px); flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pp-pts { font-weight: 900; font-size: clamp(16px, 5vh, 26px); color: var(--gold); }
.pp-pts small { font-size: .55em; color: var(--muted); font-weight: 700; }
.pp-nobles { font-size: 13px; }
.pp-row { display: flex; gap: 4px; align-items: flex-end; flex-wrap: wrap; }
.pp-col { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 26px; }
.bon { width: 22px; height: 28px; border-radius: 4px; display: grid; place-items: center; font-size: 13px; font-weight: 900; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.7); box-shadow: 0 1px 3px rgba(0,0,0,.4); }
.bon.b-w { background: var(--gw); color: #333; text-shadow: none; } .bon.b-u { background: var(--gu); } .bon.b-g { background: var(--gg); } .bon.b-r { background: var(--gr); } .bon.b-k { background: var(--gk); }
.bon.zero { opacity: .25; }
.tok { display: flex; align-items: center; gap: 2px; font-size: 12px; font-weight: 800; }
.tok .gem { width: 16px; height: 16px; border-width: 1.5px; }
.tok.zero { opacity: .3; }
.pp-res { display: flex; gap: 3px; align-items: center; font-size: 12px; color: var(--muted); }
.pp-res .mini-card, .pp-res .mini-back { width: 26px; height: 36px; border-radius: 4px; cursor: pointer; }
.mini-back { background: linear-gradient(135deg, #54348f, #2a1650); border: 1.5px solid #c9a5ff; display: grid; place-items: center; font-size: 10px; font-weight: 900; color: #e7d6ff; }
.pp-total { font-size: 11px; color: var(--muted); margin-left: auto; }

/* development cards */
.tier { display: flex; gap: 6px; align-items: center; }
.deck { width: var(--cw); height: var(--chh); border-radius: 8px; display: flex; flex-direction: column; align-items: center; justify-content: center; font-weight: 900; color: #fff; cursor: pointer; box-shadow: 0 3px 8px rgba(0,0,0,.45); border: 2px solid rgba(255,255,255,.5); }
.deck.t1 { background: linear-gradient(135deg, #2f8f4e, #155c2e); } .deck.t2 { background: linear-gradient(135deg, #c9921a, #7a5308); } .deck.t3 { background: linear-gradient(135deg, #2f6fc9, #163f7a); }
.deck .dots { font-size: calc(var(--cw) * .2); letter-spacing: 2px; }
.deck .n { font-size: calc(var(--cw) * .2); opacity: .85; }
.deck.empty { opacity: .25; cursor: default; }
.scard { --w: var(--cw); position: relative; width: var(--cw); height: var(--chh); border-radius: 8px; overflow: hidden; cursor: pointer; box-shadow: 0 3px 8px rgba(0,0,0,.45); border: 2px solid rgba(255,255,255,.75); display: flex; flex-direction: column; justify-content: space-between; flex: none; }
.scard.slot-empty { background: rgba(255,255,255,.06); border: 2px dashed rgba(255,255,255,.2); box-shadow: none; cursor: default; }
.scard.b-w { background: linear-gradient(160deg, #fffdf7, #d8d2c4); } .scard.b-u { background: linear-gradient(160deg, #8fc1ff, #1f5fb8); } .scard.b-g { background: linear-gradient(160deg, #8ee6b1, #1a7d44); } .scard.b-r { background: linear-gradient(160deg, #ff9aa6, #b21d2e); } .scard.b-k { background: linear-gradient(160deg, #6b6b6b, #1a1a1a); }
.scard .top { display: flex; justify-content: space-between; align-items: flex-start; padding: 3px 4px; background: rgba(255,255,255,.55); }
.scard.b-k .top { background: rgba(255,255,255,.2); }
.scard .pts { font: 900 calc(var(--w) * .34)/1 Georgia, serif; color: #fff; text-shadow: 0 0 3px #000, 0 1px 2px #000; min-width: 1em; }
.scard .gem { width: calc(var(--w) * .3); height: calc(var(--w) * .3); }
.scard .costs { display: flex; flex-direction: column-reverse; align-items: flex-start; gap: 2px; padding: 3px; }
.cost { width: calc(var(--w) * .27); height: calc(var(--w) * .27); border-radius: 50%; display: grid; place-items: center; font-weight: 900; font-size: calc(var(--w) * .18); color: #fff; text-shadow: 0 1px 1px rgba(0,0,0,.8); border: 1.5px solid rgba(255,255,255,.9); box-shadow: 0 1px 2px rgba(0,0,0,.5); }
.cost.c-w { background: var(--gw); color: #222; text-shadow: none; border-color: #999; } .cost.c-u { background: var(--gu); } .cost.c-g { background: var(--gg); } .cost.c-r { background: var(--gr); } .cost.c-k { background: var(--gk); }
.scard.can-buy { box-shadow: 0 0 0 3px #4be08c, 0 0 14px rgba(75,224,140,.8); }
.scard.flip-in { animation: flipIn .5s ease-out both; }
.scard.pending { visibility: hidden; }
.mini-card { --w: 26px; }
.mini-card .top { padding: 1px 2px; } .mini-card .costs { display: none; } .mini-card .pts { font-size: 11px; }
.mini-card .gem { width: 9px; height: 9px; border-width: 1px; } .mini-card .gem::after { display: none; }

/* nobles */
.nobles { display: flex; gap: 6px; justify-content: center; }
.noble { --n: calc(var(--cw) * .82); width: var(--n); height: var(--n); border-radius: 8px; background: linear-gradient(160deg, #f3e3c3, #c9a46a); border: 2px solid #fff3d6; box-shadow: 0 3px 8px rgba(0,0,0,.45); display: flex; gap: 3px; padding: 3px; position: relative; flex: none; }
.noble .npts { font: 900 calc(var(--n) * .3)/1 Georgia, serif; color: #5a3a00; }
.noble .needs { display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; margin-left: auto; }
.noble .need { width: calc(var(--n) * .24); height: calc(var(--n) * .28); border-radius: 3px; display: grid; place-items: center; font-size: calc(var(--n) * .19); font-weight: 900; color: #fff; text-shadow: 0 1px 1px rgba(0,0,0,.8); }
.noble .crown { position: absolute; left: 4px; bottom: 2px; font-size: calc(var(--n) * .3); }
.need.b-w { background: var(--gw); color: #222; text-shadow: none; } .need.b-u { background: var(--gu); } .need.b-g { background: var(--gg); } .need.b-r { background: var(--gr); } .need.b-k { background: var(--gk); }

/* bank */
.bank { display: flex; flex-direction: column; gap: 6px; }
.stack { display: flex; align-items: center; gap: 6px; cursor: pointer; padding: 2px 6px 2px 2px; border-radius: 999px; }
.stack .gem { width: clamp(30px, 9vh, 48px); height: clamp(30px, 9vh, 48px); }
.stack .cnt { font-weight: 900; font-size: clamp(14px, 4vh, 20px); min-width: 1.2em; }
.stack.empty { opacity: .3; cursor: default; }
.stack.picked { background: rgba(245,183,0,.3); box-shadow: 0 0 0 2px var(--gold); }
.stack.gold-stack { cursor: default; }
.take-box { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.picked { display: flex; gap: 3px; min-height: 22px; }
.take-box .btn { padding: 8px 16px; font-size: 16px; }

/* status pill */
.turn-pill { background: rgba(0,0,0,.4); padding: 3px 12px; border-radius: 999px; font-size: clamp(13px, 3.8vh, 17px); }
.turn-pill.mine { background: linear-gradient(#ffd24a, var(--gold) 50%, var(--gold-deep)); color: #3a2800; box-shadow: 0 0 14px rgba(245,183,0,.7); }
.turn-pill.final { background: #a3242f; color: #fff; }

/* card detail */
.big-card { --cw: 150px; --chh: 207px; display: flex; justify-content: center; margin: 4px 0 10px; }
.pay-line { font-size: 15px; margin: 4px 0; }
.pay-line .tok { display: inline-flex; margin: 0 3px; font-size: 14px; }
.return-row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; min-height: 34px; margin: 6px 0; }
.return-row .gem { width: 30px; height: 30px; cursor: pointer; }
.return-row.back { background: rgba(0,0,0,.3); border-radius: 12px; padding: 6px; }
.banner { 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; background: rgba(0,0,0,.65); border: 2px solid var(--gold); border-radius: 18px; padding: 14px 24px; }
.banner.out { animation: fadeOut .3s ease-in forwards; }
.banner .b-big { font: 900 clamp(22px, 7vh, 40px) Georgia, serif; }
.banner .b-sub { font-size: clamp(14px, 4vh, 20px); color: var(--muted); margin-top: 4px; }
.fly-tok { position: fixed; left: 0; top: 0; z-index: 35; pointer-events: none; }
.bot-tag { font-size: 12px; font-weight: 700; color: var(--muted); margin-left: 4px; }
.seat-list li.can-bot { opacity: 1; flex-wrap: wrap; }
.seat-list li.can-bot .btn { padding: 6px 10px; font-size: 14px; }
