:root {
  --bg: #0d1418; --bg-2: #131d23; --panel: #17232a; --panel-2: #1d2c35; --line: #2a3d48;
  --text: #e9f0f2; --muted: #8fa3ad;
  --felt: #1c6b4c; --felt-dark: #114433; --rail: #3a2a1e; --rail-light: #5a4330;
  --gold: #f2c14e; --red: #e5575b; --green: #48c78e; --blue: #4aa3ff;
  --card: #fbfbf8; --card-edge: #d8d8d0;
  --speed: 1;
  font-family: "Inter", "SF Pro Text", -apple-system, "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: radial-gradient(1200px 700px at 50% 20%, #17262e, var(--bg)); color: var(--text); display: flex; flex-direction: column; overflow: hidden; }
[hidden] { display: none !important; }
kbd { font: 600 0.7em/1 inherit; padding: 2px 5px; border-radius: 4px; background: rgba(255,255,255,.14); margin-left: 6px; }

.topbar { display: flex; align-items: center; gap: 24px; padding: 10px 18px; border-bottom: 1px solid var(--line); background: rgba(13,20,24,.7); backdrop-filter: blur(8px); }
.brand { font-weight: 700; letter-spacing: .02em; font-size: 1.05rem; }
.brand-mark { color: var(--gold); margin-right: 4px; }
.stats { display: flex; gap: 22px; margin-left: 8px; }
.stat { display: flex; flex-direction: column; }
.stat-label { font-size: .66rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.stat-value { font-weight: 650; font-variant-numeric: tabular-nums; }
.stat-value.up { color: var(--green); } .stat-value.down { color: var(--red); }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 16px; font-size: .84rem; color: var(--muted); }
.toggle { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.speed select, .field select, .seat-pick select { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; font: inherit; }

.btn { font: 600 .9rem/1 inherit; color: var(--text); background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 16px; cursor: pointer; transition: transform .08s, background .15s, border-color .15s; }
.btn:hover { background: #26404d; } .btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.btn.small { padding: 6px 10px; font-size: .8rem; }
.btn.ghost { background: transparent; }
.btn.primary { background: var(--gold); border-color: var(--gold); color: #1a1405; }
.btn.primary:hover { background: #ffd369; }
.btn:disabled { opacity: .4; cursor: default; }

.layout { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 300px; min-height: 0; }
.stage { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; padding: 6px 16px 10px; min-height: 0; gap: 8px; }
.side { border-left: 1px solid var(--line); background: var(--bg-2); display: flex; flex-direction: column; min-height: 0; }

/* The table */
.table-wrap { position: relative; width: min(94%, calc((100vh - 470px) * 2.05)); aspect-ratio: 2.05 / 1; margin: 58px 0 66px; }
.controls { min-height: 196px; width: 100%; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 6px; }
.rail { position: absolute; inset: 0; border-radius: 50% / 50%; background: linear-gradient(160deg, var(--rail-light), var(--rail) 55%, #24180f); box-shadow: 0 30px 60px rgba(0,0,0,.55), inset 0 2px 0 rgba(255,255,255,.12); padding: 2.6%; }
.felt { position: relative; width: 100%; height: 100%; border-radius: 50%; background: radial-gradient(ellipse at 50% 38%, #2a8a63, var(--felt) 45%, var(--felt-dark) 100%); box-shadow: inset 0 0 60px rgba(0,0,0,.5), inset 0 0 0 2px rgba(0,0,0,.35); }
.felt-line { position: absolute; inset: 9%; border-radius: 50%; border: 2px solid rgba(255,255,255,.09); }
.center { position: absolute; left: 50%; top: 47%; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; gap: 10px; }
.board { display: flex; gap: 8px; min-height: var(--card-h); }
.pot { display: flex; align-items: center; gap: 8px; background: rgba(0,0,0,.38); padding: 5px 14px 5px 8px; border-radius: 999px; font-weight: 700; font-variant-numeric: tabular-nums; }
.street-label { font-size: .68rem; letter-spacing: .14em; text-transform: uppercase; color: rgba(255,255,255,.45); min-height: 1em; }

/* Cards */
.table-wrap { --card-w: clamp(34px, 5.2vw, 62px); --card-h: calc(var(--card-w) * 1.4); }
.card { width: var(--card-w); height: var(--card-h); position: relative; flex: none; }
.card-inner { position: absolute; inset: 0; }
.card.flip .card-inner { animation: flip calc(.36s * var(--speed)) ease-out; }
@keyframes flip { 0% { transform: scaleX(0) translateY(-6px); } 100% { transform: none; } }
.card-face, .card-back { position: absolute; inset: 0; border-radius: 7px; box-shadow: 0 3px 8px rgba(0,0,0,.45); }
.card.down .card-face, .card:not(.down) .card-back { display: none; }
.card-face { background: linear-gradient(180deg, #fff, var(--card)); border: 1px solid var(--card-edge); color: #1b1b1b; display: flex; flex-direction: column; align-items: center; justify-content: center; font-weight: 800; line-height: 1; }
.card-face .rank { font-size: calc(var(--card-w) * .5); letter-spacing: -.04em; }
.card-face .suit { font-size: calc(var(--card-w) * .42); margin-top: 2px; }
.card-face.s { color: #1b1f24; } .card-face.h { color: #d93a3f; } .card-face.d { color: #2a6fd6; } .card-face.c { color: #1e8a4c; }
.card-back { background: repeating-linear-gradient(45deg, #9b2c2c 0 6px, #b33a3a 6px 12px); border: 3px solid #f4efe6; }
.card.winning .card-face { box-shadow: 0 0 0 2px var(--gold), 0 0 18px rgba(242,193,78,.7); }
.card.dim { opacity: .35; }

/* Seats */
.seat { position: absolute; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; width: 150px; transition: opacity .3s; }
.seat .hole { display: flex; gap: 4px; margin-bottom: -14px; z-index: 1; --card-w: clamp(28px, 3.9vw, 46px); min-height: calc(var(--card-w) * 1.4); }
.seat.hero .hole { --card-w: clamp(40px, 5.6vw, 66px); }
.seat .hole .card:nth-child(1) { transform: rotate(-5deg); } .seat .hole .card:nth-child(2) { transform: rotate(5deg); }
.plate { position: relative; z-index: 2; display: flex; align-items: center; gap: 9px; background: linear-gradient(180deg, #24343e, #18242b); border: 1px solid #34505e; border-radius: 12px; padding: 7px 12px 7px 7px; min-width: 132px; box-shadow: 0 6px 14px rgba(0,0,0,.45); }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: .8rem; color: #0d1418; flex: none; }
.who { display: flex; flex-direction: column; min-width: 0; }
.who .name { font-size: .78rem; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 96px; }
.who .stack { font-size: .86rem; font-weight: 750; font-variant-numeric: tabular-nums; color: var(--gold); }
.seat.folded { opacity: .45; }
.seat.acting .plate { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(242,193,78,.55), 0 0 22px rgba(242,193,78,.45); animation: pulse 1.3s ease-in-out infinite; }
.seat.winner .plate { border-color: var(--green); box-shadow: 0 0 0 2px rgba(72,199,142,.7), 0 0 26px rgba(72,199,142,.6); }
@keyframes pulse { 50% { box-shadow: 0 0 0 4px rgba(242,193,78,.25), 0 0 30px rgba(242,193,78,.6); } }
.bubble { position: absolute; top: -8px; left: 50%; transform: translate(-50%, -100%) scale(.6); opacity: 0; background: #0b1114; border: 1px solid var(--line); padding: 4px 10px; border-radius: 999px; font-size: .74rem; font-weight: 700; white-space: nowrap; z-index: 5; transition: transform .18s cubic-bezier(.3,1.5,.5,1), opacity .18s; pointer-events: none; }
.bubble.show { transform: translate(-50%, -100%) scale(1); opacity: 1; }
.bubble.fold { color: var(--muted); } .bubble.raise, .bubble.bet { color: var(--gold); } .bubble.call { color: var(--blue); } .bubble.check { color: var(--text); } .bubble.allin { color: var(--red); }
.tag { position: absolute; right: -8px; top: -8px; font-size: .6rem; font-weight: 800; letter-spacing: .05em; background: var(--red); color: #fff; border-radius: 6px; padding: 2px 5px; z-index: 3; }
.net { position: absolute; left: 100%; top: 50%; margin-left: 10px; white-space: nowrap; transform: translateY(-50%); font-weight: 800; font-size: 1rem; pointer-events: none; z-index: 6; text-shadow: 0 2px 6px rgba(0,0,0,.7); }
.net.up { color: var(--green); } .net.down { color: var(--red); }
.hand-name { font-size: .66rem; font-weight: 700; color: var(--green); white-space: nowrap; }

.bet { position: absolute; transform: translate(-50%, -50%); display: flex; align-items: center; gap: 6px; font-weight: 750; font-size: .82rem; font-variant-numeric: tabular-nums; background: rgba(0,0,0,.4); padding: 3px 10px 3px 5px; border-radius: 999px; z-index: 3; }
.chip-stack { width: 18px; height: 18px; border-radius: 50%; flex: none; background: radial-gradient(circle at 50% 50%, #fff 0 22%, transparent 23%), conic-gradient(var(--chip, #e5575b) 0 12%, #fff 0 16%, var(--chip, #e5575b) 0 37%, #fff 0 41%, var(--chip, #e5575b) 0 62%, #fff 0 66%, var(--chip, #e5575b) 0 87%, #fff 0 91%, var(--chip, #e5575b) 0); box-shadow: 0 2px 0 rgba(0,0,0,.5), 0 4px 0 -1px var(--chip, #e5575b), 0 5px 0 rgba(0,0,0,.5); }
.pot .chip-stack { --chip: #f2c14e; }
.dealer { position: absolute; transform: translate(-50%, -50%); width: 26px; height: 26px; border-radius: 50%; background: #fff; color: #111; font-weight: 800; font-size: .75rem; display: grid; place-items: center; box-shadow: 0 3px 6px rgba(0,0,0,.5); z-index: 3; transition: left calc(.5s * var(--speed)) ease, top calc(.5s * var(--speed)) ease; }
#fx { position: absolute; inset: 0; pointer-events: none; z-index: 8; }
.fly { position: absolute; }

/* Action bar */
.action-bar { display: flex; flex-direction: column; gap: 10px; width: min(760px, 96%); background: linear-gradient(180deg, #1b2a33, #142027); border: 1px solid var(--line); border-radius: 18px; padding: 12px; box-shadow: 0 14px 40px rgba(0,0,0,.5); animation: rise .22s ease; }
@keyframes rise { from { transform: translateY(12px); opacity: 0; } }
.raise-panel { display: flex; flex-direction: column; gap: 10px; }
.presets { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.presets .btn { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 9px 4px; border-radius: 12px; background: #22343f; }
.presets .btn:hover, .presets .btn.on { background: #2d4a5a; border-color: var(--gold); }
.presets .p-label { font-size: .92rem; font-weight: 750; }
.presets .p-amount { font-size: .74rem; color: var(--gold); font-variant-numeric: tabular-nums; font-weight: 650; }
.raise-row { display: flex; align-items: center; gap: 10px; }
.raise-row input[type=range] { flex: 1; height: 28px; accent-color: var(--gold); cursor: pointer; }
.btn.step { width: 40px; height: 40px; padding: 0; font-size: 1.3rem; border-radius: 50%; flex: none; }
.amount-box { display: flex; align-items: center; gap: 8px; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 4px 6px 4px 12px; color: var(--muted); font-size: .78rem; font-weight: 650; white-space: nowrap; }
.amount-box:focus-within { border-color: var(--gold); }
.amount-box input { width: 104px; background: transparent; color: var(--text); border: 0; outline: 0; padding: 7px 4px; font: 800 1.15rem inherit; font-variant-numeric: tabular-nums; text-align: right; }
.main-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.btn.action { font-size: 1.12rem; font-weight: 750; padding: 17px 12px; border-radius: 14px; }
.btn.fold { background: #45262b; border-color: #7a3940; } .btn.fold:hover { background: #5d2f35; }
.btn.call { background: #1f4468; border-color: #3572ab; } .btn.call:hover { background: #295a8a; }
.btn.raise { background: var(--gold); border-color: var(--gold); color: #1a1405; } .btn.raise:hover { background: #ffd369; }
.btn.reveal { background: #2c2440; border-color: #6b55a8; color: #d9ccff; } .btn.reveal:hover { background: #3a2f57; }
.deal-bar { display: flex; gap: 10px; }
.deal-bar { animation: rise .22s ease; }
.status { font-size: .8rem; color: var(--muted); min-height: 1.2em; }

.banner { display: flex; align-items: center; gap: 14px; background: #2a2310; border: 1px solid #6e5a1f; color: var(--gold); padding: 7px 12px; border-radius: 12px; font-size: .84rem; font-weight: 650; }
.replay-controls { display: flex; align-items: center; gap: 6px; }
.replay-controls input[type=range] { width: 180px; accent-color: var(--gold); }

/* Side panel */
.side-tabs { display: flex; border-bottom: 1px solid var(--line); }
.tab { flex: 1; background: none; border: 0; color: var(--muted); font: 650 .82rem inherit; padding: 12px; cursor: pointer; border-bottom: 2px solid transparent; }
.tab.active { color: var(--text); border-bottom-color: var(--gold); }
.panel { flex: 1; overflow-y: auto; min-height: 0; }
.panel ol { list-style: none; margin: 0; padding: 0; }
.empty { color: var(--muted); font-size: .82rem; padding: 18px 16px; }
.hand-item { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 10px; align-items: center; padding: 9px 14px; border-bottom: 1px solid #1c2a32; cursor: pointer; }
.hand-item:hover, .hand-item.active { background: var(--panel-2); }
.hand-item .num { color: var(--muted); font-size: .72rem; font-variant-numeric: tabular-nums; }
.hand-item .mini { display: flex; gap: 2px; align-items: center; flex-wrap: nowrap; overflow: hidden; }
.hand-item .result { font-weight: 750; font-variant-numeric: tabular-nums; font-size: .86rem; }
.result.up { color: var(--green); } .result.down { color: var(--red); } .result.flat { color: var(--muted); }
.mc { font-size: .68rem; white-space: nowrap; font-weight: 800; background: #f6f6f1; border-radius: 3px; padding: 1px 3px; line-height: 1.25; }
.mc.s { color: #1b1f24; } .mc.h { color: #d93a3f; } .mc.d { color: #2a6fd6; } .mc.c { color: #1e8a4c; }
.mini .sep { color: var(--muted); margin: 0 3px; font-size: .7rem; }
#log li { padding: 6px 14px; font-size: .82rem; border-bottom: 1px solid #1c2a32; }
#log li.street { color: var(--gold); font-weight: 700; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; background: #14202680; }
#log .who-name { font-weight: 700; }
#log .eng { color: var(--muted); font-size: .7rem; margin-left: 6px; }

/* Setup dialog */
.modal { position: fixed; inset: 0; background: rgba(5,9,11,.72); display: grid; place-items: center; z-index: 50; backdrop-filter: blur(3px); }
.dialog { width: min(520px, 92vw); max-height: 90vh; overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 22px 24px; box-shadow: 0 30px 80px rgba(0,0,0,.6); }
.dialog h2 { margin: 0 0 16px; font-size: 1.2rem; }
.field { display: grid; grid-template-columns: 90px 1fr; align-items: start; gap: 10px; margin-bottom: 14px; font-size: .88rem; }
.field > label { color: var(--muted); padding-top: 6px; }
.choice { display: flex; flex-direction: column; gap: 6px; }
.seat-picks { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; margin: 0 0 16px 100px; }
.seat-pick { display: flex; flex-direction: column; gap: 3px; font-size: .74rem; color: var(--muted); }
.hint { color: var(--muted); font-size: .8rem; margin: 0 0 14px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; }

.lobby { background: radial-gradient(900px 600px at 50% 30%, rgba(28,107,76,.55), rgba(5,9,11,.92)); }
.lobby-card { text-align: center; padding: 34px 34px 26px; width: min(440px, 92vw); }
.lobby-mark { font-size: 2.6rem; color: var(--gold); line-height: 1; }
.lobby-card h1 { margin: 8px 0 4px; font-size: 1.7rem; letter-spacing: .01em; }
.lobby-sub { color: var(--muted); font-size: .88rem; margin: 0 0 20px; }
.presets-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.preset { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 11px 14px; cursor: pointer; color: var(--text); font: inherit; }
.preset.selected { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold); }
.preset b { font-size: .95rem; } .preset span { color: var(--muted); font-size: .8rem; }
.btn.big { width: 100%; padding: 14px; font-size: 1.02rem; }
.lobby-card .hint { margin: 14px 0 0; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; } .side { display: none; }
  .stats { display: none; }
}
@media (prefers-reduced-motion: reduce) { .seat.acting .plate { animation: none; } }
