:root {
  --bg: #0d1210; --bar: #131a17; --panel: #18211d; --panel-2: #212c27; --line: #2b3832;
  --text: #edf1ee; --muted: #93a39a; --felt: #1c6b46; --felt-2: #12503a; --rail: #3a2617;
  --gold: #f2c14e; --gold-ink: #241a03; --red: #e24c4b; --blue: #3b82f6; --green: #2fb36f;
  --card: #fbfbf8; --card-red: #d42a2a; --card-black: #17191c; --focus: #7dd3fc;
  --seat-w: 118px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden; user-select: none; }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.sub { color: var(--muted); font-size: 12px; }
[hidden] { display: none !important; }

#app { height: 100%; display: flex; flex-direction: column; }

/* ---------- top bar */
.bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 12px;
  padding-top: max(8px, env(safe-area-inset-top)); background: var(--bar); border-bottom: 1px solid var(--line); }
.bar-left, .bar-right { display: flex; align-items: center; gap: 10px; min-width: 0; }
.bar-title { min-width: 0; }
.bar-title #tName { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }
.logo { font-size: 22px; color: var(--gold); }
.logo.big { font-size: 46px; }
.stat { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.1; }
.stat b { font-variant-numeric: tabular-nums; }
.ghost { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; }

/* ---------- table */
#stage { position: relative; flex: 1; min-height: 0; }
#tableWrap { position: absolute; inset: 8px; }
.felt { position: absolute; left: 13%; right: 13%; top: 17%; bottom: 17%; border-radius: 999px;
  background: radial-gradient(ellipse at center, var(--felt) 0%, var(--felt-2) 75%);
  border: 12px solid var(--rail); box-shadow: inset 0 0 40px rgba(0,0,0,.45), 0 10px 30px rgba(0,0,0,.5);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; }
.portrait .felt { left: 16%; right: 16%; top: 13%; bottom: 15%; }
.felt-brand { position: absolute; top: 18%; font-weight: 800; letter-spacing: .35em; color: rgba(255,255,255,.08); font-size: 18px; }
.pot { font-weight: 700; background: rgba(0,0,0,.35); padding: 3px 12px; border-radius: 999px; font-variant-numeric: tabular-nums; min-height: 1em; }
.pot:empty { visibility: hidden; }
.board { display: flex; gap: 5px; min-height: 64px; }
.result { font-weight: 700; color: var(--gold); text-align: center; padding: 0 12px; min-height: 1.3em; text-shadow: 0 1px 2px #000; }

.tableTag { position: absolute; left: 12px; bottom: 6px; color: var(--muted); font-size: 12px; }

/* ---------- cards */
.card { width: 44px; height: 62px; border-radius: 6px; background: var(--card); color: var(--card-black);
  display: flex; flex-direction: column; align-items: center; justify-content: center; font-weight: 800;
  box-shadow: 0 2px 5px rgba(0,0,0,.45); position: relative; animation: deal .25s ease-out; }
.card .r { font-size: 20px; line-height: 1; }
.card .s { font-size: 18px; line-height: 1; }
.card.red { color: var(--card-red); }
.card.back { background: repeating-linear-gradient(45deg, #8a1c1c 0 6px, #a82727 6px 12px); border: 3px solid #f4f0e6; }
.card.dim { filter: brightness(.45); }
.card.hi { box-shadow: 0 0 0 3px var(--gold), 0 2px 6px rgba(0,0,0,.5); }
@keyframes deal { from { transform: translateY(-8px) scale(.9); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- seats */
#seats { position: absolute; inset: 0; pointer-events: none; }
.seat { position: absolute; width: var(--seat-w); transform: translate(-50%, -50%); display: flex; flex-direction: column;
  align-items: center; pointer-events: auto; transition: opacity .2s; }
.seat .card, .board.still .card { animation: none; }
.seat .hole { display: flex; gap: 3px; height: 50px; margin-bottom: -14px; z-index: 1; }
.seat .hole .card { width: 36px; height: 50px; }
.seat .hole .card .r { font-size: 16px; } .seat .hole .card .s { font-size: 14px; }
.seat.me .hole .card { width: 44px; height: 62px; }
.seat.me .hole { height: 62px; }
.seat.me .hole .card .r { font-size: 20px; } .seat.me .hole .card .s { font-size: 18px; }
.plate { position: relative; z-index: 2; width: 100%; display: flex; align-items: center; gap: 6px; padding: 5px 7px;
  background: rgba(12,16,14,.92); border: 2px solid var(--line); border-radius: 12px; }
.seat.acting .plate { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(242,193,78,.25); }
.seat.me .plate { background: rgba(20,32,26,.95); }
.seat.folded { opacity: .5; }
.seat.out .plate { border-style: dashed; }
.seat.winner .plate { border-color: var(--green); box-shadow: 0 0 14px rgba(47,179,111,.6); }
.ava { width: 32px; height: 32px; border-radius: 50%; flex: none; background: var(--panel-2); object-fit: cover;
  display: grid; place-items: center; font-weight: 700; font-size: 13px; overflow: hidden; }
.who { min-width: 0; flex: 1; }
.who .nm { font-weight: 600; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who .ch { font-variant-numeric: tabular-nums; font-size: 12.5px; color: var(--gold); }
.tag { position: absolute; top: -14px; right: -4px; z-index: 3; font-size: 10.5px; font-weight: 700; padding: 1px 6px;
  border-radius: 6px; background: var(--panel-2); border: 1px solid var(--line); text-transform: uppercase; letter-spacing: .03em; }
.tag.allin { background: var(--red); border-color: var(--red); }
.tag.win { background: var(--green); border-color: var(--green); }
.timer { position: absolute; left: 6px; right: 6px; bottom: -6px; height: 4px; border-radius: 4px; background: rgba(255,255,255,.12); overflow: hidden; z-index: 3; }
.timer i { display: block; height: 100%; background: var(--gold); transform-origin: left; }
.timer.bank i { background: var(--red); }
.handname { font-size: 11px; color: var(--gold); margin-top: 3px; text-shadow: 0 1px 2px #000; white-space: nowrap; }
.empty-seat { position: absolute; transform: translate(-50%, -50%); width: 40px; height: 40px; border-radius: 50%;
  border: 2px dashed rgba(255,255,255,.08); }

.bet { position: absolute; transform: translate(-50%, -50%); display: flex; align-items: center; gap: 4px; font-weight: 700;
  font-size: 12.5px; background: rgba(0,0,0,.5); padding: 2px 8px 2px 3px; border-radius: 999px; font-variant-numeric: tabular-nums; }
.chip { width: 14px; height: 14px; border-radius: 50%; background: var(--gold); border: 2px dashed #fff8; }
.dealer { position: absolute; transform: translate(-50%, -50%); width: 22px; height: 22px; border-radius: 50%;
  background: #fff; color: #111; font-weight: 800; font-size: 12px; display: grid; place-items: center; box-shadow: 0 1px 3px #0008; }

/* ---------- actions */
#actions { background: var(--bar); border-top: 1px solid var(--line); padding: 8px 10px; padding-bottom: max(8px, env(safe-area-inset-bottom)); min-height: 58px; }
.waiting { color: var(--muted); text-align: center; padding: 10px; }
.controls { display: flex; flex-direction: column; gap: 8px; max-width: 720px; margin: 0 auto; }
.main-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.act { border: 0; border-radius: 10px; padding: 13px 8px; font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; }
.act:disabled { opacity: .35; cursor: default; }
.fold { background: #3a4540; }
.call { background: var(--blue); color: #fff; }
.raise { background: var(--gold); color: var(--gold-ink); }
.raise-row { display: flex; flex-direction: column; gap: 6px; }
.quick { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.quick button { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 2px; font-size: 12.5px; font-weight: 600; }
.slider { display: flex; align-items: center; gap: 6px; }
.slider input[type=range] { flex: 1; accent-color: var(--gold); }
.slider .step { width: 34px; height: 34px; border-radius: 8px; background: var(--panel-2); border: 1px solid var(--line); font-size: 18px; }
.slider input[type=number] { width: 96px; padding: 7px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font: inherit; font-weight: 700; }
.sitout { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; }
.sitout .act { padding: 10px 22px; }

/* ---------- drawer */
#drawer { position: absolute; top: 0; right: 0; bottom: 0; width: min(380px, 100%); background: var(--panel);
  border-left: 1px solid var(--line); z-index: 20; display: flex; flex-direction: column; box-shadow: -10px 0 30px rgba(0,0,0,.4); }
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px; border-bottom: 1px solid var(--line); }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs button { background: none; border: 0; padding: 6px 10px; border-radius: 7px; color: var(--muted); font-weight: 600; }
.tabs button.on { background: var(--panel-2); color: var(--text); }
.drawer-body { overflow: auto; padding: 10px 12px 20px; flex: 1; user-select: text; }
.rows { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.rows td, .rows th { padding: 6px 4px; border-bottom: 1px solid var(--line); text-align: left; }
.rows th { color: var(--muted); font-weight: 600; font-size: 12px; }
.rows td.n { text-align: right; }
.rows tr.mine td { color: var(--gold); font-weight: 700; }
.logline { padding: 3px 0; border-bottom: 1px solid rgba(255,255,255,.04); }
.logline.sys { color: var(--muted); font-size: 12px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.watch { background: var(--panel-2); border: 1px solid var(--line); border-radius: 7px; padding: 4px 10px; }

/* ---------- overlay screens */
#screen { position: absolute; inset: 0; z-index: 30; background: rgba(8,11,10,.94); display: grid; place-items: center; padding: 16px; overflow: auto; }
.screen-card { max-width: 460px; width: 100%; text-align: center; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 26px 20px; }
.screen-card h1 { margin: 6px 0; font-size: 22px; }
.screen-card h2 { font-size: 15px; margin: 18px 0 6px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.screen-card .btn { display: inline-block; margin-top: 14px; background: #5865f2; color: #fff; text-decoration: none; font-weight: 700;
  padding: 11px 18px; border-radius: 9px; border: 0; }
.screen-card .btn.alt { background: var(--panel-2); border: 1px solid var(--line); }
.pill-list { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 8px; max-height: 40vh; overflow: auto; }
.pill { background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px 3px 3px; display: flex; align-items: center; gap: 6px; font-size: 13px; }
.pill .ava { width: 22px; height: 22px; font-size: 10px; }
.big-count { font-size: 34px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--gold); }
.prizes { text-align: left; margin: 6px auto 0; max-width: 320px; padding-left: 22px; }
.place-big { font-size: 44px; font-weight: 800; color: var(--gold); }

.toast { position: absolute; left: 50%; top: 10px; transform: translateX(-50%); background: var(--red); color: #fff; padding: 8px 14px;
  border-radius: 8px; font-weight: 600; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 25; max-width: 90%; text-align: center; }
.toast.show { opacity: 1; }
.toast.info { background: var(--panel-2); border: 1px solid var(--line); }

/* ---------- small screens */
@media (max-width: 640px) {
  :root { --seat-w: 92px; }
  .hide-sm { display: none; }
  .card { width: 36px; height: 51px; } .card .r { font-size: 16px; } .card .s { font-size: 14px; }
  .board { min-height: 51px; gap: 3px; }
  .seat .hole .card { width: 28px; height: 40px; } .seat .hole { height: 40px; margin-bottom: -10px; }
  .seat .hole .card .r { font-size: 13px; } .seat .hole .card .s { font-size: 11px; }
  .seat.me .hole .card { width: 40px; height: 56px; } .seat.me .hole { height: 56px; }
  .ava { width: 24px; height: 24px; font-size: 10px; }
  .who .nm, .who .ch { font-size: 11px; }
  .plate { padding: 4px 5px; gap: 4px; }
  .felt { border-width: 8px; }
  .act { padding: 12px 4px; font-size: 14px; }
  .quick button { font-size: 11.5px; }
}
@media (prefers-reduced-motion: reduce) { .card { animation: none; } }
