:root {
  --felt: #0f3d2e;
  --felt-2: #134a38;
  --felt-3: #1a5c46;
  --ink: #f4efe2;
  --muted: #a9bfb3;
  --gold: #e8b74a;
  --gold-2: #f5d27e;
  --red: #d8433a;
  --card: #fffdf7;
  --card-ink: #1b1b1b;
  --line: rgba(255, 255, 255, 0.12);
  --danger: #c2453c;
  --ok: #4fbf7f;
  --r: 14px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: radial-gradient(120% 80% at 50% 0%, var(--felt-3), var(--felt) 60%, #0a2a20); color: var(--ink); font-family: Inter, system-ui, sans-serif; min-height: 100%; }
body { min-height: 100vh; padding-bottom: env(safe-area-inset-bottom); }
h1, h2, h3 { font-family: Fraunces, Georgia, serif; margin: 0; letter-spacing: 0.01em; }
button { font: inherit; }
input, select { font: inherit; color: var(--ink); background: rgba(0, 0, 0, 0.25); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%; }
input:focus, select:focus { outline: 2px solid var(--gold); outline-offset: 1px; }
label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
a { color: var(--gold-2); }
.wrap { max-width: 640px; margin: 0 auto; padding: 12px 12px 120px; }

/* landing */
.hero { text-align: center; padding: 48px 16px 20px; }
.hero h1 { font-size: 44px; font-weight: 800; }
.hero h1 span { color: var(--gold); }
.hero p { color: var(--muted); margin: 8px 0 0; }
.suits { font-size: 22px; letter-spacing: 10px; color: var(--gold); opacity: 0.8; margin-bottom: 8px; }

.panel { background: rgba(0, 0, 0, 0.22); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; margin: 12px 0; }
.panel h3 { font-size: 18px; margin-bottom: 6px; }
.row { display: flex; gap: 8px; align-items: center; }
.row > * { flex: 1; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.muted { color: var(--muted); font-size: 13px; }
.small { font-size: 12px; }
.center { text-align: center; }
.sp { height: 8px; }

.btn { border: 0; border-radius: 12px; padding: 12px 14px; font-weight: 700; background: var(--felt-3); color: var(--ink); cursor: pointer; border: 1px solid var(--line); width: 100%; }
.btn:active { transform: translateY(1px); }
.btn.gold { background: linear-gradient(180deg, var(--gold-2), var(--gold)); color: #2a1d00; border: 0; }
.btn.red { background: var(--danger); border: 0; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 7px 10px; font-size: 13px; width: auto; border-radius: 9px; }
.btn[disabled] { opacity: 0.45; pointer-events: none; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: rgba(255, 255, 255, 0.1); margin: 2px 4px 2px 0; }
.chip.gold { background: var(--gold); color: #2a1d00; }
.chip.red { background: var(--danger); }
.chip.dark { background: rgba(0, 0, 0, 0.35); }
.toggle { display: inline-flex; padding: 7px 11px; border-radius: 9px; border: 1px solid var(--line); margin: 3px; font-weight: 600; cursor: pointer; user-select: none; min-width: 38px; justify-content: center; }
.toggle.on { background: var(--gold); color: #2a1d00; border-color: var(--gold); }

/* top bar + tabs */
.top { position: sticky; top: 0; z-index: 10; background: rgba(10, 42, 32, 0.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.top .bar { max-width: 640px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; }
.top .brand { font-family: Fraunces, serif; font-weight: 800; font-size: 18px; }
.top .code { font-family: ui-monospace, monospace; background: rgba(0, 0, 0, 0.35); padding: 3px 8px; border-radius: 8px; letter-spacing: 2px; margin-left: 6px; font-size: 14px; }
.stack { font-weight: 800; color: var(--gold-2); }
.tabs { display: flex; max-width: 640px; margin: 0 auto; }
.tabs button { flex: 1; background: none; border: 0; color: var(--muted); padding: 9px 0 10px; font-weight: 600; border-bottom: 2px solid transparent; position: relative; }
.tabs button.on { color: var(--ink); border-color: var(--gold); }
.badge { position: absolute; top: 4px; margin-left: 4px; background: var(--danger); color: white; font-size: 10px; border-radius: 999px; padding: 1px 6px; }

/* cards */
.card { width: 46px; height: 66px; border-radius: 7px; background: var(--card); color: var(--card-ink); display: inline-flex; flex-direction: column; align-items: center; justify-content: center; font-weight: 800; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35); position: relative; margin: 2px; flex: none; transition: transform 0.15s; line-height: 1; }
.card .r { font-size: 20px; }
.card .s { font-size: 18px; margin-top: 2px; }
.card.red { color: var(--red); }
.card.back { background: repeating-linear-gradient(45deg, #8a2b25 0 6px, #a3362f 6px 12px); border: 3px solid var(--card); }
.card.empty { background: transparent; border: 1.5px dashed rgba(255, 255, 255, 0.2); box-shadow: none; }
.card.wild { box-shadow: 0 0 0 3px var(--gold), 0 0 14px rgba(232, 183, 74, 0.7); }
.card.wild::after { content: 'WILD'; position: absolute; bottom: -7px; font-size: 8px; background: var(--gold); color: #2a1d00; padding: 1px 4px; border-radius: 4px; letter-spacing: 0.5px; }
.card.dead { opacity: 0.35; filter: grayscale(1); }
.card.dead::before { content: ''; position: absolute; inset: 45% -4px auto; height: 2px; background: var(--danger); transform: rotate(-35deg); }
.card.discarded { opacity: 0.3; transform: scale(0.85); }
.card.side { transform: rotate(90deg); margin: 0 12px; }
.card.sel { transform: translateY(-10px); box-shadow: 0 0 0 3px #6fd3ff, 0 6px 12px rgba(0, 0, 0, 0.4); }
.card.tap { cursor: pointer; }
.card.tap.back:hover, .card.tapme { box-shadow: 0 0 0 3px #6fd3ff; }
.card.lg { width: 58px; height: 84px; }
.card.lg .r { font-size: 26px; }
.card.lg .s { font-size: 22px; }
.card.sm { width: 30px; height: 43px; border-radius: 5px; margin: 1px; }
.card.sm .r { font-size: 13px; }
.card.sm .s { font-size: 12px; margin: 0; }
.card.sm.back { border-width: 2px; }
.card.up-mark::before { content: ''; position: absolute; top: 3px; right: 3px; width: 5px; height: 5px; border-radius: 50%; background: #3aa0ff; }

/* table */
.gamehead { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.gamehead h2 { font-size: 24px; }
.pot { text-align: right; }
.pot .amt { font-family: Fraunces, serif; font-size: 26px; font-weight: 800; color: var(--gold-2); }
.status { margin: 8px 0; padding: 9px 12px; background: rgba(0, 0, 0, 0.28); border-radius: 10px; font-weight: 600; font-size: 14px; }
.status.me { background: var(--gold); color: #2a1d00; animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(232, 183, 74, 0.2); } }
.board { display: flex; justify-content: center; flex-wrap: wrap; padding: 10px 0; min-height: 80px; }
.vboard { display: grid; grid-template-columns: repeat(5, 54px); grid-template-rows: repeat(3, 46px); justify-content: center; padding: 6px 0 30px; }
.rrboard { display: grid; grid-template-columns: 54px 54px 30px 54px; grid-template-rows: repeat(4, 72px); justify-content: center; align-items: center; }
.rrboard .lbl { font-size: 10px; color: var(--muted); grid-column: 3; text-align: center; }
.gbu .lane { display: flex; align-items: center; gap: 8px; margin: 4px 0; }
.gbu .lane .tag { width: 58px; font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; }
.gbu .lane .tag.bad { color: #ff8c84; }
.seat { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; margin: 6px 0; background: rgba(0, 0, 0, 0.18); border: 1px solid transparent; }
.seat.turn { border-color: var(--gold); background: rgba(232, 183, 74, 0.12); }
.seat.folded { opacity: 0.45; }
.seat .who { min-width: 92px; }
.seat .who .n { font-weight: 700; }
.seat .cards { display: flex; flex-wrap: wrap; flex: 1; }
.seat .bet { font-size: 12px; color: var(--gold-2); font-weight: 700; }
.dbtn { display: inline-flex; width: 18px; height: 18px; border-radius: 50%; background: white; color: black; font-size: 11px; font-weight: 800; align-items: center; justify-content: center; margin-left: 4px; }
.mine { background: rgba(0, 0, 0, 0.3); border: 1px solid var(--line); border-radius: 16px; padding: 12px; margin-top: 10px; }
.mine .cards { display: flex; flex-wrap: wrap; justify-content: center; padding: 6px 0 4px; }
.best { text-align: center; font-weight: 700; color: var(--gold-2); margin-top: 4px; }
.actions { position: fixed; left: 0; right: 0; bottom: 0; background: rgba(8, 32, 24, 0.97); border-top: 1px solid var(--line); padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); z-index: 20; }
.actions .in { max-width: 640px; margin: 0 auto; }
.quick { display: flex; gap: 6px; margin: 8px 0; }
.quick button { flex: 1; }
.lives { color: var(--red); letter-spacing: 1px; }
.result { border: 1px solid var(--gold); background: rgba(232, 183, 74, 0.08); }
.log { font-size: 12px; color: var(--muted); max-height: 160px; overflow: auto; }
.log div { padding: 2px 0; border-bottom: 1px dashed rgba(255, 255, 255, 0.06); }
table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
table.t th, table.t td { text-align: right; padding: 6px 4px; border-bottom: 1px solid var(--line); }
table.t th:first-child, table.t td:first-child { text-align: left; }
.pos { color: var(--ok); } .neg { color: #ff8c84; }
.qr { width: 220px; max-width: 80%; border-radius: 12px; background: white; padding: 8px; display: block; margin: 8px auto; }
.req { border-left: 3px solid var(--gold); }
.toast { position: fixed; left: 50%; top: 14px; transform: translate(-50%, -80px); background: #2b0f0d; border: 1px solid var(--danger); padding: 10px 16px; border-radius: 10px; z-index: 50; transition: transform 0.25s; font-weight: 600; max-width: 90%; }
.toast.show { transform: translate(-50%, 0); }
.toast.ok { background: #0e2c1c; border-color: var(--ok); }
details summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.check { padding: 4px 0; }

.timebar { height: 4px; background: rgba(0, 0, 0, 0.25); border-radius: 4px; margin-top: 6px; overflow: hidden; }
.timebar i { display: block; height: 100%; background: currentColor; opacity: 0.7; transition: width 0.25s linear; }
.status .secs { font-variant-numeric: tabular-nums; font-weight: 800; }
.status.hurry .secs { color: var(--danger); }
.status.me.hurry .secs { color: #8b0000; }
.ticker { font-size: 13px; background: rgba(0, 0, 0, 0.3); border-radius: 10px; padding: 7px 10px; margin: 4px 0 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.chatlog { max-height: 55vh; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; margin: 8px 0; padding-right: 2px; }
.msg { background: rgba(255, 255, 255, 0.07); padding: 7px 10px; border-radius: 12px; max-width: 85%; align-self: flex-start; font-size: 14px; word-wrap: break-word; }
.msg.mine { background: rgba(232, 183, 74, 0.22); align-self: flex-end; }
.msg .who { font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.msg.sys { background: none; align-self: center; color: var(--muted); font-size: 12px; text-align: center; max-width: 100%; }
.pref { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.status .row > * { flex: 0 1 auto; }
.vboard { grid-template-columns: repeat(5, 62px); grid-template-rows: repeat(3, 54px); padding-bottom: 40px; }
.vboard > div { display: flex; justify-content: center; }
.vboard .card.side { margin: 0; }
.wrap.has-actions { padding-bottom: 330px; }

.seg { display: flex; background: rgba(0, 0, 0, 0.25); border-radius: 10px; padding: 3px; margin: 6px 0 8px; }
.seg button { flex: 1; background: none; border: 0; color: var(--muted); padding: 8px; border-radius: 8px; font-weight: 600; }
.seg button.on { background: var(--felt-3); color: var(--ink); }
.pick { display: flex; align-items: center; gap: 8px; color: var(--ink); font-size: 15px; padding: 6px 0; margin: 0; border-bottom: 1px solid var(--line); }
.pick input { width: 20px; height: 20px; }
.btn.sm { white-space: nowrap; }

/* table video strip */
#videobar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 19; background: rgba(6, 24, 18, 0.96); border-top: 1px solid var(--line); display: none; padding: 4px 8px 6px; }
#videobar.on { display: block; }
.vb-head { display: flex; justify-content: space-between; align-items: center; max-width: 640px; margin: 0 auto; font-size: 12px; color: var(--muted); }
.vb-btns button { background: rgba(255, 255, 255, 0.08); border: 0; color: var(--ink); border-radius: 8px; padding: 3px 8px; margin-left: 4px; font-size: 14px; }
.vb-tiles { display: flex; gap: 6px; overflow-x: auto; max-width: 640px; margin: 4px auto 0; }
#videobar.collapsed .vb-tiles { display: none; }
.vtile { position: relative; flex: none; width: 96px; height: 72px; border-radius: 8px; overflow: hidden; background: #000; }
.vtile video { width: 100%; height: 100%; object-fit: cover; }
.vtile.self video { transform: scaleX(-1); }
.vtile.camoff video { opacity: 0; }
.vtile .vname { position: absolute; left: 4px; bottom: 3px; font-size: 10px; font-weight: 700; background: rgba(0, 0, 0, 0.55); padding: 1px 5px; border-radius: 4px; }
.vtile.connecting::after { content: 'connecting…'; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 10px; color: var(--muted); }
.vtile.needs-tap::after { content: '🔈 tap for sound'; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 10px; background: rgba(0, 0, 0, 0.5); }
body.has-video .wrap { padding-bottom: 230px; }
body.has-video .wrap.has-actions { padding-bottom: 430px; }
.vtile.watching { background: rgba(255, 255, 255, 0.06); }
.vtile.watching::after { content: '👀 watching'; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 10px; color: var(--muted); }
.vtile.watching.connecting::after { content: '👀 watching'; }

.tbar { position: sticky; top: 96px; z-index: 5; background: rgba(10, 42, 32, 0.95); border: 1px solid var(--gold); border-radius: 12px; padding: 8px 12px; margin: 8px 0; }

.countdown { font-family: Fraunces, serif; font-size: 44px; font-weight: 800; color: var(--gold-2); font-variant-numeric: tabular-nums; margin: 6px 0; }
.countdown.small { font-size: 28px; }
.linkbox { font-family: ui-monospace, monospace; font-size: 13px; background: rgba(0, 0, 0, 0.3); border-radius: 8px; padding: 8px; margin: 6px 0; word-break: break-all; }

.stars { color: var(--gold); font-size: 13px; letter-spacing: 1px; display: inline-block; }
.stars .off { color: rgba(255, 255, 255, 0.18); }
.stars.new { font-size: 10px; letter-spacing: 0; color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 0 5px; text-transform: uppercase; }
.big { font-family: Fraunces, serif; font-size: 26px; font-weight: 800; color: var(--gold-2); }

.panel.alarm { border: 2px solid var(--danger); background: rgba(194, 69, 60, 0.15); }
.panel.alarm h3 { color: #ffb3ad; }

.tables-bar { display: flex; gap: 6px; overflow-x: auto; margin: 6px 0; }
.tables-bar button { flex: none; background: rgba(0, 0, 0, 0.3); border: 1px solid var(--line); color: var(--ink); border-radius: 999px; padding: 6px 12px; font-weight: 600; font-size: 13px; }
.tables-bar button.on { background: var(--gold); color: #2a1d00; border-color: var(--gold); }
.tables-bar button.on .muted { color: #5a4300; }
