:root {
  --bg: #0b100d;
  --panel: #141c17;
  --panel-2: #1b261f;
  --line: #2a3a30;
  --text: #e9f2ec;
  --muted: #93a89a;
  --lime: #9be15d;
  --lime-d: #6fb83a;
  --gold: #f5c542;
  --red: #e5484d;
  --felt-1: #227a4d;
  --felt-2: #0f3f28;
  --rail: #3b2a1c;
  --radius: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(1200px 600px at 50% -10%, #17251c 0%, var(--bg) 60%);
  color: var(--text);
  font: 15px/1.4 'Rubik', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
a { color: var(--lime); }
button { font: inherit; color: inherit; cursor: pointer; }
input, select { font: inherit; color: var(--text); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------- buttons & fields ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--panel-2); font-weight: 600; text-decoration: none; color: var(--text);
  transition: transform .06s ease, background .15s ease;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--lime); color: #10200f; border-color: transparent; }
.btn.primary:hover { background: #aaec6e; }
.btn.gold { background: var(--gold); color: #2a1f00; border-color: transparent; }
.btn.danger { background: #3a1517; border-color: #5c2226; color: #ffb4b6; }
.btn.ghost { background: transparent; }
.btn.discord { background: #5865f2; color: #fff; border-color: transparent; }
.btn.discord:hover { background: #6d78f5; }
.or { display: flex; align-items: center; gap: 10px; margin: 12px 0; font-size: 12.5px; color: var(--muted); }
.or::before, .or::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.btn.block { width: 100%; }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; color: var(--muted); }
.field input, .field select {
  min-height: 46px; padding: 0 12px; border-radius: 12px; background: #0f1612;
  border: 1px solid var(--line); outline: none;
}
.field input:focus, .field select:focus { border-color: var(--lime-d); }
.row { display: flex; gap: 10px; align-items: center; }
.row > * { flex: 1; }
.switch { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; font-size: 14px; }
.switch input { width: 20px; height: 20px; accent-color: var(--lime); }

/* ---------- lobby ---------- */
.wrap { max-width: 560px; margin: 0 auto; padding: 18px 16px calc(40px + var(--safe-b)); }
.brand { display: flex; align-items: center; gap: 12px; margin: 6px 0 18px; }
.brand .logo {
  width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center;
  background: linear-gradient(140deg, var(--lime), #3f8f2a); color: #0d1a0b; font-size: 24px; font-weight: 800;
  box-shadow: 0 6px 20px rgba(155, 225, 93, .25);
}
.brand h1 { font-size: 22px; margin: 0; letter-spacing: .2px; }
.brand p { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px;
}
.card h2 { font-size: 16px; margin: 0 0 12px; }
.user-chip { display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: #23402c; color: var(--lime); font-weight: 700;
}
.user-chip .who { flex: 1; min-width: 0; }
.user-chip .who b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tables { display: grid; gap: 10px; }
.table-item {
  display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 12px;
  background: var(--panel-2); border: 1px solid var(--line); text-decoration: none; color: var(--text);
}
.table-item .info { flex: 1; min-width: 0; }
.table-item .info b { display: block; }
.badge { font-size: 12px; padding: 3px 8px; border-radius: 99px; background: #23402c; color: var(--lime); white-space: nowrap; }
.note { font-size: 12.5px; color: var(--muted); text-align: center; margin-top: 18px; }
.err { color: #ff9a9d; font-size: 13.5px; margin-top: 8px; min-height: 1em; }

/* ---------- table page ---------- */
body.table-page { overflow: hidden; }
.app { position: fixed; inset: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  padding-top: max(10px, env(safe-area-inset-top));
}
.topbar .title { flex: 1; min-width: 0; }
.topbar .title b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .title span { font-size: 12px; color: var(--muted); }
.icon-btn {
  width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--panel); display: grid; place-items: center; font-size: 18px; position: relative;
}
.icon-btn .dot { position: absolute; top: 7px; right: 7px; width: 8px; height: 8px; border-radius: 50%; background: var(--gold); }

.stage { flex: 1; position: relative; min-height: 0; }
.felt {
  position: absolute; inset: 6% 9% 10%;
  border-radius: 46% / 32%;
  background: radial-gradient(ellipse at 50% 40%, var(--felt-1), var(--felt-2) 75%);
  box-shadow: 0 0 0 10px var(--rail), 0 0 0 12px #5a4130, 0 20px 60px rgba(0,0,0,.6), inset 0 0 60px rgba(0,0,0,.45);
}
@media (min-aspect-ratio: 1/1) {
  .felt { inset: 12% 10% 14%; border-radius: 34% / 46%; }
}
.felt-mark {
  position: absolute; left: 50%; top: 30%; transform: translate(-50%, -50%);
  font-weight: 800; letter-spacing: 3px; font-size: 12px; color: rgba(255,255,255,.14); white-space: nowrap;
}
.center {
  position: absolute; left: 50%; top: 47%; transform: translate(-50%, -50%);
  display: grid; justify-items: center; gap: 8px; width: 80%;
}
.pot {
  background: rgba(0,0,0,.35); padding: 4px 12px; border-radius: 99px; font-weight: 700; font-size: 14px;
  display: inline-flex; align-items: center; gap: 6px;
}
.board { display: flex; gap: 4px; justify-content: center; min-height: 58px; }
.status-line { font-size: 13px; color: rgba(255,255,255,.75); text-align: center; min-height: 18px; }

/* cards */
.c {
  --w: 40px;
  width: var(--w); height: calc(var(--w) * 1.42); border-radius: calc(var(--w) * .12);
  background: #fbfbf7; color: #18181b; position: relative; flex: none;
  box-shadow: 0 2px 6px rgba(0,0,0,.35); font-weight: 700; line-height: 1;
  animation: deal .25s ease-out;
}
.c .r { position: absolute; left: 12%; top: 8%; font-size: calc(var(--w) * .42); }
.c .s { position: absolute; right: 10%; bottom: 6%; font-size: calc(var(--w) * .55); }
.c.red { color: #d3262d; }
.c.back {
  background: repeating-linear-gradient(45deg, #2f5d3e 0 4px, #264d33 4px 8px);
  border: 2px solid #f1f5ef;
}
.c.back::after {
  content: 'G'; position: absolute; inset: 0; display: grid; place-items: center;
  color: rgba(255,255,255,.55); font-weight: 800; font-size: calc(var(--w) * .45);
}
.c.dim { filter: brightness(.55); }
.c.win { box-shadow: 0 0 0 2px var(--gold), 0 0 14px rgba(245,197,66,.7); }
.board .c { --w: min(10vw, 54px); }
@keyframes deal { from { transform: translateY(-8px) scale(.9); opacity: 0; } to { transform: none; opacity: 1; } }

/* seats */
.seat {
  position: absolute; transform: translate(-50%, -50%); width: 80px;
  display: grid; justify-items: center; gap: 3px; z-index: 2;
}
.seat .hole { display: flex; gap: 2px; height: 36px; align-items: flex-end; }
.seat .hole .c { --w: 26px; }
.seat.me .hole { height: 66px; }
.seat.me .hole .c { --w: 46px; }
.seat.me { width: 120px; }
.plate {
  width: 100%; background: rgba(10,16,12,.88); border: 1px solid var(--line); border-radius: 12px;
  padding: 5px 6px 6px; text-align: center; position: relative; overflow: hidden;
}
.plate .nm { font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.plate .st { font-size: 13px; font-weight: 700; color: var(--gold); }
.plate .act { font-size: 11px; color: var(--lime); min-height: 13px; text-transform: uppercase; letter-spacing: .4px; }
.seat.turn .plate { border-color: var(--lime); box-shadow: 0 0 0 2px rgba(155,225,93,.35); }
.seat.folded { opacity: .45; }
.seat.offline .nm::after { content: ' ·zz'; color: var(--muted); }
.seat.winner .plate { border-color: var(--gold); box-shadow: 0 0 16px rgba(245,197,66,.55); }
.timer { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--lime); width: 0; }
.timer.low { background: var(--red); }
.empty-seat {
  position: absolute; transform: translate(-50%, -50%); z-index: 2;
  width: 58px; height: 58px; border-radius: 50%; border: 2px dashed rgba(255,255,255,.25);
  background: rgba(0,0,0,.25); color: rgba(255,255,255,.7); font-size: 12px; font-weight: 600;
}
.empty-seat.ghost { pointer-events: none; opacity: .35; }
.dealer {
  position: absolute; right: -6px; bottom: 30px; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; color: #111; font-weight: 800; font-size: 12px; display: grid; place-items: center;
  z-index: 3; box-shadow: 0 2px 4px rgba(0,0,0,.4);
}
.seat.me .dealer { right: -10px; }
.bet {
  position: absolute; transform: translate(-50%, -50%); z-index: 1;
  display: inline-flex; align-items: center; gap: 5px; font-weight: 700; font-size: 13px;
  background: rgba(0,0,0,.45); padding: 2px 9px 2px 3px; border-radius: 99px;
}
.chip {
  width: 16px; height: 16px; border-radius: 50%; background: var(--gold);
  border: 3px dashed #fff8; box-sizing: border-box;
}
.hand-name {
  font-size: 11px; color: var(--gold); font-weight: 600; white-space: nowrap;
  background: rgba(0,0,0,.55); padding: 1px 6px; border-radius: 6px;
}

/* action bar */
.dock {
  padding: 10px 12px calc(12px + var(--safe-b));
  background: linear-gradient(180deg, rgba(11,16,13,0), rgba(11,16,13,.95) 30%);
  display: grid; gap: 8px;
}
.actions { display: grid; grid-template-columns: 1fr 1fr 1.25fr; gap: 8px; }
.actions .btn { min-height: 52px; padding: 0 8px; font-size: 15px; }
.raise-box { display: grid; gap: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 10px; }
.raise-box .presets { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.raise-box .presets .btn { min-height: 38px; font-size: 13px; padding: 0 4px; }
.raise-box input[type=range] { width: 100%; accent-color: var(--lime); height: 28px; }
.raise-box .amt { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--muted); }
.raise-box .amt b { color: var(--text); font-size: 18px; }
.info-bar { text-align: center; color: var(--muted); font-size: 14px; min-height: 22px; }

/* sheets / modals */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 20; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; max-height: 78vh; display: flex; flex-direction: column;
  background: var(--panel); border-top-left-radius: 20px; border-top-right-radius: 20px; border: 1px solid var(--line);
  padding: 8px 14px calc(14px + var(--safe-b)); max-width: 640px; margin: 0 auto; overflow-y: auto;
}
.sheet .grip { width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: 4px auto 10px; }
.sheet h3 { margin: 0 0 10px; font-size: 16px; }
.sheet .menu { display: grid; gap: 8px; }
.messages { flex: 1; overflow-y: auto; display: grid; gap: 6px; align-content: start; padding: 4px 0 10px; min-height: 160px; }
.msg { font-size: 14px; }
.msg b { color: var(--lime); font-weight: 600; }
.msg.sys { color: var(--muted); font-size: 13px; }
.chat-form { display: flex; gap: 8px; }
.chat-form input { flex: 1; min-height: 44px; border-radius: 12px; padding: 0 12px; background: #0f1612; border: 1px solid var(--line); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px; word-break: break-all; color: var(--muted); }
.toast {
  position: fixed; left: 50%; top: calc(64px + env(safe-area-inset-top)); transform: translateX(-50%); z-index: 30;
  background: #2a1416; border: 1px solid #5c2226; color: #ffd0d2; padding: 10px 14px; border-radius: 12px; font-size: 14px;
  max-width: 90vw; text-align: center;
}
.toast.ok { background: #16281b; border-color: #2c5a37; color: #d4f5d9; }
.overlay {
  position: fixed; inset: 0; z-index: 25; display: grid; place-items: center; padding: 20px;
  background: rgba(5,8,6,.82); backdrop-filter: blur(4px);
}
.overlay .card { width: 100%; max-width: 420px; }
.summary-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); }
.pos { color: var(--lime); font-weight: 700; }
.neg { color: #ff9a9d; font-weight: 700; }
