/* ==========================================================================
   Tobagus Poker — a private card room under one overhead lamp.
   Physical things (felt, rail, cards, chips, dealer button) get depth and
   light; interface chrome stays flat and quiet.
   ========================================================================== */

:root {
  --room: #1e1411;
  --room-deep: #140d0b;
  --room-lamp: #3b2820;
  --rail: #4a2c1c;
  --rail-hi: #7d4c2f;
  --rail-lo: #2a170e;
  --felt: #6b1f2a;
  --felt-hi: #93303c;
  --felt-lo: #3b1017;
  --brass: #d4af6a;
  --brass-hi: #ecd29b;
  --brass-lo: #9b7738;
  --ivory: #f7f0e1;
  --ivory-lo: #e4d9c2;
  --ink: #1d1a1f;
  --card-red: #b3262e;
  --text: #f1e7d3;
  --text-dim: #bcaa8e;
  --text-faint: #8a7a63;
  --panel: rgba(22, 14, 11, 0.9);
  --line: rgba(212, 175, 106, 0.2);
  --danger: #c8443e;

  --font-display: 'Bodoni Moda', 'Didot', Georgia, serif;
  --font-ui: 'Barlow Semi Condensed', 'Avenir Next Condensed', 'Arial Narrow', system-ui, sans-serif;

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --u: 1;
  color-scheme: dark;
}

body[data-felt='green'] { --felt: #1f5a3d; --felt-hi: #2f7d55; --felt-lo: #0f2f1f; }
body[data-felt='navy'] { --felt: #1d3658; --felt-hi: #2d5285; --felt-lo: #0d1a2e; }
body[data-felt='charcoal'] { --felt: #33363a; --felt-hi: #4c5056; --felt-lo: #191a1c; }

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  background:
    radial-gradient(ellipse 70% 60% at 50% 38%, var(--room-lamp) 0%, var(--room) 55%, var(--room-deep) 100%);
  background-color: var(--room);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}

[hidden] { display: none !important; }

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.55; }

:focus-visible {
  outline: 2px solid var(--brass-hi);
  outline-offset: 2px;
}

/* ---------- buttons & fields ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 12px;
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 17px;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.btn-lg { min-height: 54px; font-size: 19px; padding: 0 24px; }
.btn-small { min-height: 36px; font-size: 15px; padding: 0 12px; border-radius: 10px; }

.btn-brass {
  background: linear-gradient(180deg, var(--brass-hi), var(--brass) 45%, var(--brass-lo));
  color: #2a1a0c;
  border-color: #f3dfb0;
  box-shadow: 0 2px 0 #6e5226, 0 6px 16px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}
.btn-brass:active { transform: translateY(1px); box-shadow: 0 1px 0 #6e5226, 0 3px 8px rgba(0, 0, 0, 0.35); }

.btn-wood {
  background: linear-gradient(180deg, #4a2f22, #34201a);
  color: var(--text);
  border-color: rgba(212, 175, 106, 0.28);
  box-shadow: 0 2px 0 #1a0f0b, inset 0 1px 0 rgba(255, 255, 255, 0.07);
}
.btn-wood:active { transform: translateY(1px); }

.btn-danger {
  background: linear-gradient(180deg, #d4554f, #a5322d);
  color: #fff;
  border-color: #e17a74;
  box-shadow: 0 2px 0 #5d1a17;
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 15px; font-weight: 600; color: var(--text-dim); }
.field input, .field select {
  min-height: 52px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid rgba(212, 175, 106, 0.3);
  background: rgba(10, 6, 5, 0.55);
  font-size: 19px; /* 16px+ stops iOS zooming on focus */
  font-weight: 600;
  color: var(--ivory);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.45);
}
.field input::placeholder { color: rgba(241, 231, 211, 0.3); }
.field input:focus, .field select:focus { outline: none; border-color: var(--brass); box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.45), 0 0 0 3px rgba(212, 175, 106, 0.25); }
.field select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--brass) 50%), linear-gradient(135deg, var(--brass) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 36px; }

.icon-btn {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-dim);
}
.icon-btn svg { width: 24px; height: 24px; fill: currentColor; }
.icon-btn:hover { color: var(--text); background: rgba(255, 255, 255, 0.05); }
.icon-btn .i-off { display: none; }
.icon-btn.is-off .i-on { display: none; }
.icon-btn.is-off .i-off { display: block; }
.badge {
  position: absolute;
  top: 4px;
  right: 3px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--brass);
  color: #2a1a0c;
  font-size: 12px;
  font-weight: 700;
  line-height: 18px;
}

/* ==========================================================================
   Lobby
   ========================================================================== */

.lobby {
  height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: center;
  overflow-x: hidden;
  gap: 24px;
  padding: calc(24px + var(--safe-t)) calc(24px + var(--safe-r)) calc(24px + var(--safe-b)) calc(24px + var(--safe-l));
  overflow-y: auto;
  background:
    radial-gradient(ellipse 55% 50% at 30% 52%, color-mix(in srgb, var(--felt-hi) 70%, transparent) 0%, transparent 70%);
}

.lobby-scene {
  --s: 1;
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: calc(var(--s) * 18px);
  min-width: 0;
}
.lobby-hand { position: relative; flex: none; width: calc(var(--s) * 290px); height: calc(var(--s) * 270px); }
.lobby-hand .card {
  --cw: calc(var(--s) * 150px);
  position: absolute;
  top: calc(var(--s) * 18px);
  box-shadow: 0 calc(var(--s) * 30px) calc(var(--s) * 50px) rgba(0, 0, 0, 0.55), 0 2px 0 var(--ivory-lo);
}
.lobby-hand .card.l1 { left: calc(var(--s) * 8px); rotate: -10deg; }
.lobby-hand .card.l2 { left: calc(var(--s) * 118px); top: calc(var(--s) * 40px); rotate: 9deg; }
.lc { flex: none; display: block; margin-bottom: calc(var(--s) * -6px); }
.lc svg { display: block; width: auto; height: calc(var(--s) * var(--h)); }
.lc1 { --h: 150px; }
.lc2 { --h: 104px; }
.lobby-panel { max-width: 460px; width: 100%; }
.wordmark {
  margin: 0 0 12px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(46px, 6.4vw, 80px);
  line-height: 0.95;
  letter-spacing: -0.01em;
  color: var(--ivory);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.4);
}
.wordmark span { display: block; color: var(--brass); }
.lobby-lede { margin: 0 0 28px; color: var(--text-dim); font-size: 19px; line-height: 1.4; max-width: 30em; }
.lobby-form { display: flex; flex-direction: column; gap: 18px; }
.lobby-actions .btn { width: 100%; }
.lobby-divider { display: flex; align-items: center; gap: 12px; color: var(--text-faint); font-size: 15px; }
.lobby-divider::before, .lobby-divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.join-row { display: flex; gap: 12px; align-items: flex-end; }
.field input, .field select { width: 100%; min-width: 0; }
.field-code { flex: 1; }
.field-code input { letter-spacing: 0.3em; text-transform: uppercase; }
.form-error { min-height: 22px; margin: 0; color: #f19a8f; font-weight: 600; }

.lobby.is-invite #create-block, .lobby.is-invite #join-divider { display: none; }
.lobby.is-invite #join-btn {
  background: linear-gradient(180deg, var(--brass-hi), var(--brass) 45%, var(--brass-lo));
  color: #2a1a0c;
  border-color: #f3dfb0;
}

/* ==========================================================================
   Game shell
   ========================================================================== */

.game {
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: calc(6px + var(--safe-t)) calc(10px + var(--safe-r)) 6px calc(12px + var(--safe-l));
  z-index: 10;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar-right { gap: 2px; }
.brand-mini { font-family: var(--font-display); font-size: 22px; color: var(--ivory); }
.table-code {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 6px 0 12px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.25);
}
.table-code-label { color: var(--text-faint); font-size: 14px; }
.table-code-value { font-weight: 700; font-size: 18px; letter-spacing: 0.14em; color: var(--ivory); }
.table-code-cta { padding: 3px 10px; border-radius: 14px; background: var(--brass); color: #2a1a0c; font-weight: 700; font-size: 14px; }
.blinds-chip { color: var(--text-dim); font-size: 15px; white-space: nowrap; }

.conn-banner {
  position: fixed;
  top: calc(56px + var(--safe-t));
  left: 50%;
  translate: -50% 0;
  z-index: 40;
  padding: 8px 16px;
  border-radius: 10px;
  background: var(--danger);
  color: #fff;
  font-weight: 600;
}

.room { position: relative; display: flex; min-height: 0; }

/* ==========================================================================
   Table
   ========================================================================== */

.table-area {
  --u: 1;
  position: relative;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.rail {
  position: absolute;
  inset: 15.5% 10.5% 15% 10.5%;
  border-radius: 9999px;
  padding: calc(var(--u) * 20px);
  background:
    radial-gradient(ellipse 60% 40% at 50% 0%, rgba(255, 220, 170, 0.18), transparent 70%),
    repeating-linear-gradient(100deg, rgba(0, 0, 0, 0.07) 0 2px, transparent 2px 9px, rgba(255, 210, 160, 0.04) 9px 11px, transparent 11px 17px),
    linear-gradient(180deg, var(--rail-hi), var(--rail) 35%, var(--rail-lo));
  box-shadow:
    0 calc(var(--u) * 26px) calc(var(--u) * 60px) rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(0, 0, 0, 0.6),
    inset 0 2px 0 rgba(255, 220, 170, 0.25),
    inset 0 -3px 6px rgba(0, 0, 0, 0.5);
}
.table-area[data-layout='tall'] .rail { inset: 9% 14% 10.5% 14%; }
.table-area[data-layout='phone'] .rail { inset: 11% 16% 12.5% 16%; padding: calc(var(--u) * 14px); }

.felt {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 9999px;
  background-color: var(--felt);
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .16 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"),
    radial-gradient(ellipse 60% 55% at 50% 42%, var(--felt-hi) 0%, var(--felt) 55%, var(--felt-lo) 100%);
  box-shadow: inset 0 0 calc(var(--u) * 40px) rgba(0, 0, 0, 0.55), inset 0 calc(var(--u) * 6px) calc(var(--u) * 14px) rgba(0, 0, 0, 0.5);
  overflow: hidden;
}
.felt-line {
  position: absolute;
  inset: 11% 7%;
  border-radius: 9999px;
  border: 1.5px solid color-mix(in srgb, var(--brass) 28%, transparent);
}
.table-area[data-layout='tall'] .felt-line, .table-area[data-layout='phone'] .felt-line { inset: 7% 11%; }
.felt-mark {
  position: absolute;
  left: 50%;
  top: 9%;
  translate: -50% 0;
  font-family: var(--font-display);
  font-style: italic;
  font-size: calc(var(--u) * 30px);
  color: rgba(255, 240, 210, 0.08);
  white-space: nowrap;
}
.table-area[data-layout='tall'] .felt-mark, .table-area[data-layout='phone'] .felt-mark { top: 14%; }

/* ---------- cards ---------- */

.card {
  --cw: calc(var(--u) * 40px);
  position: relative;
  width: var(--cw);
  height: calc(var(--cw) * 1.4);
  flex: none;
  border-radius: calc(var(--cw) * 0.1);
  background: linear-gradient(160deg, #fffaf0 0%, var(--ivory) 55%, var(--ivory-lo) 100%);
  box-shadow:
    0 1px 0 rgba(0, 0, 0, 0.2),
    0 calc(var(--cw) * 0.06) calc(var(--cw) * 0.16) rgba(0, 0, 0, 0.45),
    inset 0 0 0 1px rgba(0, 0, 0, 0.08);
  color: var(--ink);
}
.card.red { color: var(--card-red); }
.card svg { fill: currentColor; display: block; }
.card-idx {
  position: absolute;
  top: 5%;
  left: 7%;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 38%;
}
.card-rank {
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: calc(var(--cw) * 0.42);
  line-height: 0.95;
  letter-spacing: -0.04em;
}
.card-suit { width: calc(var(--cw) * 0.26); height: calc(var(--cw) * 0.26); margin-top: 3%; }
.card-pip { position: absolute; right: 8%; bottom: 7%; width: calc(var(--cw) * 0.52); height: calc(var(--cw) * 0.52); }

.card.back {
  background:
    repeating-linear-gradient(45deg, rgba(236, 210, 155, 0.22) 0 1px, transparent 1px calc(var(--cw) * 0.11)),
    repeating-linear-gradient(-45deg, rgba(236, 210, 155, 0.22) 0 1px, transparent 1px calc(var(--cw) * 0.11)),
    linear-gradient(160deg, #6c1c27, #3c0e15);
  border: calc(var(--cw) * 0.07) solid var(--ivory);
}

.card-sm { --cw: calc(var(--u) * 32px); }
.card-md { --cw: calc(var(--u) * 44px); }
.card-lg { --cw: calc(var(--u) * 70px); }
.card-board { --cw: calc(var(--u) * 62px); }

.card.deal { animation: deal 0.5s cubic-bezier(0.2, 0.8, 0.3, 1) both; animation-delay: var(--d, 0ms); }
@keyframes deal {
  0% { transform: translate(var(--from-x, 0), var(--from-y, 0)) rotate(-30deg) scale(0.5); opacity: 0; }
  20% { opacity: 1; }
  100% { transform: none; }
}
.card.flip { animation: flip 0.45s cubic-bezier(0.3, 0.7, 0.3, 1) both; animation-delay: var(--d, 0ms); }
@keyframes flip {
  0% { transform: perspective(500px) rotateY(95deg) translateY(-6%); opacity: 0.4; }
  100% { transform: none; opacity: 1; }
}
.card.hl { translate: 0 -10%; box-shadow: 0 0 0 calc(var(--u) * 2.5px) var(--brass-hi), 0 8px 22px rgba(0, 0, 0, 0.5); }
.card.dim { filter: brightness(0.55) saturate(0.6); }

/* ---------- board & pot ---------- */

.board {
  position: absolute;
  translate: -50% -50%;
  display: flex;
  gap: calc(var(--u) * 8px);
  z-index: 2;
}
.board-slot {
  width: calc(var(--u) * 62px);
  height: calc(var(--u) * 62px * 1.4);
  border-radius: calc(var(--u) * 6px);
  box-shadow: inset 0 0 0 1px rgba(255, 240, 210, 0.07);
}
.board.is-idle .board-slot { box-shadow: none; }

.pot {
  position: absolute;
  translate: -50% -50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  z-index: 2;
  opacity: 0;
  transition: opacity 0.2s;
}
.pot.show { opacity: 1; }
.pot-chips svg { display: block; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.35)); }
.pot-label, .bet-num {
  padding: 2px calc(var(--u) * 10px);
  border-radius: 999px;
  background: rgba(10, 5, 4, 0.55);
  color: var(--ivory);
  font-weight: 700;
  font-size: calc(var(--u) * 15px);
  white-space: nowrap;
}

.table-message {
  position: absolute;
  translate: -50% -50%;
  width: min(60%, calc(var(--u) * 460px));
  text-align: center;
  font-family: var(--font-display);
  font-style: italic;
  font-size: calc(var(--u) * 22px);
  line-height: 1.3;
  color: var(--ivory);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  z-index: 2;
  opacity: 0;
  transition: opacity 0.25s;
  pointer-events: none;
}
.table-message.show { opacity: 1; }
.table-message.is-result {
  margin-top: calc(var(--u) * 78px);
  font-size: calc(var(--u) * 19px);
  color: var(--brass-hi);
}

/* ---------- bets ---------- */

.bet {
  position: absolute;
  translate: -50% -50%;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  z-index: 3;
}
.bet.show { display: flex; }
.bet-chips svg { display: block; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.3)); }
.bet-num { font-size: calc(var(--u) * 13.5px); }
.bet.push { animation: push 0.38s cubic-bezier(0.25, 0.8, 0.3, 1) both; }
@keyframes push {
  0% { transform: translate(var(--from-x), var(--from-y)) scale(0.7); opacity: 0; }
  25% { opacity: 1; }
  100% { transform: none; }
}

.fx { position: absolute; inset: 0; pointer-events: none; z-index: 6; }
.flying { position: absolute; }
.flying svg { display: block; }

/* ---------- seats ---------- */

.seats { position: absolute; inset: 0; z-index: 4; pointer-events: none; }
.seat {
  --hue: 30;
  position: absolute;
  translate: -50% -50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: auto;
}

.plate {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: calc(var(--u) * 9px);
  width: calc(var(--u) * 150px);
  padding: calc(var(--u) * 5px) calc(var(--u) * 12px) calc(var(--u) * 5px) calc(var(--u) * 5px);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(36, 24, 19, 0.95), rgba(16, 10, 8, 0.95));
  border: 1px solid rgba(212, 175, 106, 0.22);
  box-shadow: 0 calc(var(--u) * 6px) calc(var(--u) * 16px) rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  transition: border-color 0.2s, box-shadow 0.2s, opacity 0.2s;
}
.avatar {
  position: relative;
  flex: none;
  display: grid;
  place-items: center;
  width: calc(var(--u) * 44px);
  height: calc(var(--u) * 44px);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, hsl(var(--hue) 40% 46%), hsl(var(--hue) 38% 26%));
  box-shadow: inset 0 -2px 4px rgba(0, 0, 0, 0.35), 0 0 0 2px rgba(0, 0, 0, 0.35);
  font-family: var(--font-display);
  font-size: calc(var(--u) * 22px);
  color: #fff8ea;
}
.seat.is-bot .avatar {
  border-radius: 28%;
  background: linear-gradient(145deg, #57504a, #2a2522);
  box-shadow: inset 0 0 0 calc(var(--u) * 2px) rgba(212, 175, 106, 0.35), 0 0 0 2px rgba(0, 0, 0, 0.35);
}
.seat.is-bot .avatar-letter { font-family: var(--font-ui); font-weight: 700; color: var(--brass-hi); }
.timer {
  position: absolute;
  inset: calc(var(--u) * -5px);
  width: calc(100% + var(--u) * 10px);
  height: calc(100% + var(--u) * 10px);
  rotate: -90deg;
  display: none;
  overflow: visible;
}
.timer circle {
  fill: none;
  stroke: var(--brass-hi);
  stroke-width: 6;
  stroke-linecap: round;
  stroke-dasharray: 100;
  stroke-dashoffset: 0;
}
.seat.has-timer .timer { display: block; }
.seat.has-timer .timer circle {
  animation: drain var(--turn-ms, 30000ms) linear var(--turn-delay, 0ms) forwards;
}
@keyframes drain {
  0% { stroke-dashoffset: 0; stroke: var(--brass-hi); }
  70% { stroke: var(--brass-hi); }
  85% { stroke: #f08a4b; }
  100% { stroke-dashoffset: 100; stroke: #e0443c; }
}

.plate-text { min-width: 0; flex: 1; }
.plate-name {
  font-weight: 600;
  font-size: calc(var(--u) * 16px);
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--ivory);
}
.plate-stack { display: flex; align-items: center; gap: calc(var(--u) * 5px); min-height: calc(var(--u) * 20px); }
.stack-chips svg { display: block; height: calc(var(--u) * 20px); width: auto; }
.stack-num { font-weight: 700; font-size: calc(var(--u) * 15px); color: var(--brass-hi); white-space: nowrap; }

.dealer-btn {
  position: absolute;
  top: calc(var(--u) * -9px);
  right: calc(var(--u) * -4px);
  display: grid;
  place-items: center;
  width: calc(var(--u) * 26px);
  height: calc(var(--u) * 26px);
  border-radius: 50%;
  background: radial-gradient(circle at 40% 30%, #ffffff, var(--ivory) 60%, var(--ivory-lo));
  color: var(--ink);
  font-weight: 700;
  font-size: calc(var(--u) * 14px);
  box-shadow: 0 calc(var(--u) * 3px) 0 #b9ab8f, 0 calc(var(--u) * 5px) calc(var(--u) * 8px) rgba(0, 0, 0, 0.55);
  z-index: 2;
}

.seat-tag {
  margin-top: calc(var(--u) * 5px);
  padding: calc(var(--u) * 2px) calc(var(--u) * 10px);
  border-radius: 999px;
  background: rgba(10, 5, 4, 0.6);
  color: var(--text);
  font-weight: 600;
  font-size: calc(var(--u) * 13.5px);
  white-space: nowrap;
  max-width: calc(var(--u) * 220px);
  overflow: hidden;
  text-overflow: ellipsis;
}
.seat-tag.tag-fold, .seat-tag.tag-dim { color: var(--text-faint); }
.seat-tag.tag-raise, .seat-tag.tag-bet { background: rgba(212, 175, 106, 0.2); color: var(--brass-hi); }
.seat-tag.tag-allin { background: #9f2c27; color: #fff; }
.seat-tag.tag-hand { background: rgba(247, 240, 225, 0.92); color: var(--ink); }
.seat-tag.tag-win { background: linear-gradient(180deg, var(--brass-hi), var(--brass)); color: #2a1a0c; }

.seat-cards {
  position: absolute;
  bottom: calc(100% - var(--u) * 16px);
  left: 50%;
  translate: -50% 0;
  display: flex;
  justify-content: center;
  z-index: 0;
}
.seat-cards .card-sm:nth-child(1) { rotate: -7deg; translate: 18% 2%; }
.seat-cards .card-sm:nth-child(2) { rotate: 7deg; translate: -18% 2%; }
.seat-cards .card-md + .card-md { margin-left: calc(var(--u) * -10px); }
.seat-cards .card-md:nth-child(1) { rotate: -5deg; }
.seat-cards .card-md:nth-child(2) { rotate: 5deg; }
.seat-cards.mucked { opacity: 0.38; filter: grayscale(0.5); }

.seat.is-me .seat-cards { bottom: calc(100% - var(--u) * 12px); }
.seat.is-me .seat-cards .card-lg + .card-lg { margin-left: calc(var(--u) * -14px); }
.seat.is-me .seat-cards .card-lg:nth-child(1) { rotate: -5deg; }
.seat.is-me .seat-cards .card-lg:nth-child(2) { rotate: 5deg; translate: 0 2%; }
.seat.is-me .seat-tag { position: absolute; left: calc(100% + var(--u) * 8px); top: 50%; translate: 0 -50%; margin: 0; }
.seat.is-me .plate { border-color: rgba(212, 175, 106, 0.45); }

.seat.is-turn .plate {
  border-color: var(--brass-hi);
  box-shadow: 0 0 0 calc(var(--u) * 2px) rgba(236, 210, 155, 0.35), 0 0 calc(var(--u) * 26px) rgba(236, 210, 155, 0.35), 0 calc(var(--u) * 6px) calc(var(--u) * 16px) rgba(0, 0, 0, 0.5);
}
.seat.is-turn.is-bot .avatar { animation: think 1.1s ease-in-out infinite; }
@keyframes think { 50% { box-shadow: inset 0 -2px 4px rgba(0, 0, 0, 0.35), 0 0 0 calc(var(--u) * 4px) rgba(236, 210, 155, 0.45); } }
.seat.is-folded .plate, .seat.is-out .plate { opacity: 0.55; }
.seat.is-away .avatar { filter: grayscale(1) brightness(0.7); }
.seat.is-winner .plate {
  border-color: var(--brass-hi);
  box-shadow: 0 0 0 calc(var(--u) * 2px) var(--brass), 0 0 calc(var(--u) * 34px) rgba(236, 210, 155, 0.5);
}

/* empty seats */
.seat.is-empty .seat-cards, .seat.is-empty .plate, .seat.is-empty .seat-tag { display: none; }
.seat-open { display: none; }
.seat.is-empty .seat-open {
  display: flex;
  gap: calc(var(--u) * 6px);
  align-items: center;
  justify-content: center;
  width: calc(var(--u) * 118px);
  min-height: calc(var(--u) * 54px);
  padding: calc(var(--u) * 5px);
  border-radius: 999px;
  border: 1.5px dashed rgba(212, 175, 106, 0.25);
  background: rgba(0, 0, 0, 0.18);
}
.seat-open-label { color: var(--text-faint); font-size: calc(var(--u) * 14px); }
.seat-btn {
  min-height: 40px;
  min-width: 44px;
  padding: 0 calc(var(--u) * 12px);
  border-radius: 999px;
  border: 1px solid rgba(212, 175, 106, 0.4);
  background: rgba(30, 20, 16, 0.9);
  color: var(--brass-hi);
  font-weight: 700;
  font-size: calc(var(--u) * 15px);
  white-space: nowrap;
}
.seat-btn:hover { background: rgba(60, 40, 30, 0.95); }

/* ==========================================================================
   Action dock
   ========================================================================== */

.dock {
  position: relative;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 76px;
  padding: 10px calc(14px + var(--safe-r)) calc(10px + var(--safe-b)) calc(16px + var(--safe-l));
  background: linear-gradient(180deg, rgba(30, 20, 16, 0.96), rgba(18, 12, 10, 0.98));
  border-top: 1px solid var(--line);
}
.dock-info { min-width: 0; flex: 1; }
.dock-hand {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 20px;
  color: var(--ivory);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dock-status { color: var(--text-dim); font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dock.is-turn .dock-status { color: var(--brass-hi); font-weight: 600; }
.dock-controls { display: flex; gap: 10px; flex: none; }

.act {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 56px;
  min-width: 112px;
  padding: 0 20px;
  border-radius: 14px;
  border: 1px solid transparent;
  font-weight: 700;
  font-size: 19px;
  letter-spacing: 0.01em;
  white-space: nowrap;
  transition: transform 0.08s;
}
.act:active { transform: translateY(2px); }
.act kbd {
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 5px;
  border: 1px solid currentColor;
  opacity: 0.45;
}
@media (pointer: coarse) { .act kbd { display: none; } }
.act-fold {
  background: linear-gradient(180deg, #3d2b25, #2a1d19);
  color: #e6d6bf;
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: 0 3px 0 #140c0a;
}
.act-call {
  background: linear-gradient(180deg, var(--felt-hi), var(--felt));
  color: var(--ivory);
  border-color: color-mix(in srgb, var(--brass) 50%, transparent);
  box-shadow: 0 3px 0 var(--felt-lo), inset 0 1px 0 rgba(255, 255, 255, 0.15);
}
.act-raise {
  background: linear-gradient(180deg, var(--brass-hi), var(--brass) 45%, var(--brass-lo));
  color: #2a1a0c;
  border-color: #f3dfb0;
  box-shadow: 0 3px 0 #6e5226, inset 0 1px 0 rgba(255, 255, 255, 0.5);
}
.act-raise.is-confirm { min-width: 170px; }
.act-quiet {
  background: transparent;
  color: var(--text-dim);
  border-color: var(--line);
  min-width: 0;
  font-size: 17px;
}

.raise-tray {
  position: absolute;
  right: calc(12px + var(--safe-r));
  bottom: calc(100% + 8px);
  width: min(470px, calc(100% - 24px));
  padding: 12px;
  border-radius: 18px;
  background: rgba(20, 13, 11, 0.97);
  border: 1px solid var(--line);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: tray 0.18s ease-out;
}
@keyframes tray { from { opacity: 0; translate: 0 10px; } }
.raise-presets { display: flex; gap: 8px; }
.preset {
  flex: 1;
  min-height: 46px;
  border-radius: 12px;
  border: 1px solid rgba(212, 175, 106, 0.3);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-weight: 700;
  font-size: 17px;
}
.preset.is-on { background: rgba(212, 175, 106, 0.22); border-color: var(--brass); color: var(--brass-hi); }
.raise-slider { display: flex; align-items: center; gap: 10px; }
.step-btn {
  flex: none;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--ivory);
  font-size: 26px;
  line-height: 1;
}

/* The slider handle is a chip. */
#raise-range {
  --fill: 0%;
  flex: 1;
  height: 48px;
  margin: 0;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
}
#raise-range::-webkit-slider-runnable-track {
  height: 10px;
  border-radius: 5px;
  background: linear-gradient(90deg, var(--brass) var(--fill), rgba(255, 255, 255, 0.12) var(--fill));
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.6);
}
#raise-range::-moz-range-track {
  height: 10px;
  border-radius: 5px;
  background: linear-gradient(90deg, var(--brass) var(--fill), rgba(255, 255, 255, 0.12) var(--fill));
}
#raise-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 38px;
  height: 38px;
  margin-top: -14px;
  border-radius: 50%;
  border: 0;
  background:
    radial-gradient(circle, #f7e6bc 0 32%, #e3a21f 33% 50%, transparent 51%),
    repeating-conic-gradient(#e3a21f 0 22.5deg, #2a1d12 22.5deg 45deg);
  box-shadow: 0 3px 0 #a36f0c, 0 5px 10px rgba(0, 0, 0, 0.5);
}
#raise-range::-moz-range-thumb {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 0;
  background:
    radial-gradient(circle, #f7e6bc 0 32%, #e3a21f 33% 50%, transparent 51%),
    repeating-conic-gradient(#e3a21f 0 22.5deg, #2a1d12 22.5deg 45deg);
  box-shadow: 0 3px 0 #a36f0c, 0 5px 10px rgba(0, 0, 0, 0.5);
}

/* ==========================================================================
   Drawer (chat + history)
   ========================================================================== */

.drawer {
  flex: none;
  width: 340px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: rgba(20, 13, 11, 0.97);
  border-left: 1px solid var(--line);
  padding-right: var(--safe-r);
}
.drawer-tabs { display: flex; align-items: center; gap: 4px; padding: 8px 8px 0 12px; border-bottom: 1px solid var(--line); }
.drawer-tab {
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--text-dim);
  font-weight: 600;
  font-size: 16px;
}
.drawer-tab[aria-selected='true'] { color: var(--ivory); border-bottom-color: var(--brass); }
.drawer-close { margin-left: auto; }
.drawer-panel { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.chat-list, .log-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  margin: 0;
  padding: 12px 14px;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  -webkit-overflow-scrolling: touch;
  user-select: text;
  -webkit-user-select: text;
}
.chat-list li { font-size: 16px; line-height: 1.35; overflow-wrap: anywhere; }
.chat-list b { color: var(--brass-hi); font-weight: 700; }
.chat-list li.is-mine b { color: var(--text-dim); }
.log-list { gap: 4px; }
.log-list li { font-size: 15px; color: var(--text-dim); }
.log-list li.log-hand { margin-top: 10px; color: var(--ivory); font-weight: 700; }
.log-list li.log-hand:first-child { margin-top: 0; }
.chat-form { display: flex; gap: 8px; padding: 10px 12px calc(10px + var(--safe-b)); border-top: 1px solid var(--line); }
.chat-form input {
  flex: 1;
  min-width: 0;
  min-height: 46px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid rgba(212, 175, 106, 0.3);
  background: rgba(10, 6, 5, 0.55);
  font-size: 16px;
}

@media (max-width: 1099px) {
  .drawer {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(360px, 92vw);
    z-index: 20;
    box-shadow: -20px 0 40px rgba(0, 0, 0, 0.5);
  }
}

/* ==========================================================================
   Dialogs & toast
   ========================================================================== */

.sheet {
  width: min(540px, calc(100% - 24px));
  max-height: calc(100% - 40px);
  padding: 0;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: #22170f;
  color: var(--text);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}
.sheet::backdrop { background: rgba(8, 4, 3, 0.65); backdrop-filter: blur(3px); }
.sheet-small { width: min(420px, calc(100% - 24px)); }
.sheet-body { padding: 20px 22px 22px; display: flex; flex-direction: column; gap: 16px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet h2 { margin: 0; font-family: var(--font-display); font-weight: 600; font-size: 28px; color: var(--ivory); }
.sheet h3 { margin: 0 0 8px; font-size: 17px; color: var(--text-dim); font-weight: 600; }
.sheet-note { margin: 0; color: var(--text-dim); }
.sheet-foot { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.settings-grid .check { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 12px; min-height: 44px; font-size: 17px; }
.check input { width: 24px; height: 24px; accent-color: var(--brass); }

.felt-picker { border: 0; margin: 0; padding: 0; }
.felt-picker legend { padding: 0; margin-bottom: 8px; font-size: 15px; font-weight: 600; color: var(--text-dim); }
.felt-swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch { display: flex; flex-direction: column; align-items: center; gap: 4px; cursor: pointer; }
.swatch input { position: absolute; opacity: 0; pointer-events: none; }
.swatch-dot { width: 52px; height: 36px; border-radius: 18px; border: 3px solid transparent; box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5); }
.swatch[data-felt='claret'] .swatch-dot { background: #7a2632; }
.swatch[data-felt='green'] .swatch-dot { background: #276b48; }
.swatch[data-felt='navy'] .swatch-dot { background: #24436e; }
.swatch[data-felt='charcoal'] .swatch-dot { background: #404348; }
.swatch input:checked + .swatch-dot { border-color: var(--brass-hi); }
.swatch input:focus-visible + .swatch-dot { outline: 2px solid var(--brass-hi); outline-offset: 2px; }
.swatch-name { font-size: 14px; color: var(--text-dim); }

.player-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.player-list li {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  border-bottom: 1px solid rgba(212, 175, 106, 0.1);
}
.player-list li.pl-stand { display: flex; border: 0; padding-top: 10px; }
.pl-name { font-weight: 600; }
.pl-name em { font-style: normal; font-weight: 500; color: var(--text-faint); margin-left: 4px; }
.pl-stack { color: var(--brass-hi); font-weight: 700; }

.toast {
  position: fixed;
  left: 50%;
  top: calc(62px + var(--safe-t));
  z-index: 50;
  max-width: min(520px, calc(100% - 32px));
  padding: 12px 18px;
  border-radius: 14px;
  background: rgba(247, 240, 225, 0.97);
  color: var(--ink);
  font-weight: 600;
  font-size: 16px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
  translate: -50% -10px;
  opacity: 0;
  transition: opacity 0.2s, translate 0.2s;
  pointer-events: none;
}
.toast.show { opacity: 1; translate: -50% 0; }

/* ==========================================================================
   Responsive
   ========================================================================== */

/* Portrait tablets & phones */
@media (max-width: 860px) and (orientation: portrait), (max-width: 640px) {
  .lobby { grid-template-columns: minmax(0, 1fr); align-content: start; gap: 8px; }
  .lobby-scene { --s: 0.62; padding-top: 8px; gap: 6px; }
  .lc1 { --h: 100px; }
  .lc2 { --h: 74px; }
  .lobby-panel { justify-self: center; }
}
@media (min-width: 600px) and (max-width: 860px) and (orientation: portrait) {
  .lobby { align-content: center; }
  .lobby-scene { --s: 0.85; }
}

@media (max-width: 700px) {
  .brand-mini, .blinds-chip, .table-code-label { display: none; }
  .dock { flex-wrap: wrap; gap: 8px; padding-top: 8px; }
  .dock-info { flex-basis: 100%; display: flex; gap: 10px; align-items: baseline; }
  .dock-hand { font-size: 17px; }
  .dock-status { font-size: 15px; }
  .dock-controls { flex: 1; justify-content: flex-end; }
  .dock-controls .act { flex: 1; min-width: 0; padding: 0 10px; font-size: 17px; }
  .dock-controls .act-quiet { flex: none; padding: 0 18px; }
  .act-raise.is-confirm { min-width: 0; }
  .raise-tray { left: 8px; right: 8px; width: auto; }
  .preset { font-size: 15px; }
}

@media (max-height: 520px) and (orientation: landscape) {
  .topbar { padding-top: calc(2px + var(--safe-t)); padding-bottom: 2px; }
  .dock { min-height: 60px; padding-top: 6px; padding-bottom: calc(6px + var(--safe-b)); }
  .act { min-height: 48px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .seat.has-timer .timer circle { animation-duration: var(--turn-ms, 30000ms) !important; }
}

/* ---------- compact seats on phones ---------- */
.table-area[data-layout='phone'] .plate {
  width: calc(var(--u) * 112px);
  gap: 6px;
  padding: 3px 8px 3px 3px;
}
.table-area[data-layout='phone'] .avatar { width: calc(var(--u) * 34px); height: calc(var(--u) * 34px); font-size: max(15px, calc(var(--u) * 18px)); }
.table-area[data-layout='phone'] .plate-name { font-size: max(13px, calc(var(--u) * 14px)); }
.table-area[data-layout='phone'] .stack-num { font-size: max(13px, calc(var(--u) * 13px)); }
.table-area[data-layout='phone'] .stack-chips { display: none; }
.table-area[data-layout='phone'] .seat-tag { font-size: max(12px, calc(var(--u) * 12px)); max-width: calc(var(--u) * 150px); }
.table-area[data-layout='phone'] .pot-label,
.table-area[data-layout='phone'] .bet-num { font-size: max(12px, calc(var(--u) * 13px)); }
.table-area[data-layout='phone'] .seat.is-me .seat-tag { position: static; translate: none; margin-top: 4px; }
.table-area[data-layout='phone'] .card-board { --cw: calc(var(--u) * 56px); }
.table-area[data-layout='phone'] .board-slot { width: calc(var(--u) * 56px); height: calc(var(--u) * 56px * 1.4); }
.table-area[data-layout='phone'] .table-message { width: 60%; font-size: max(15px, calc(var(--u) * 18px)); }
.table-area[data-layout='phone'] .table-message.is-result { margin-top: calc(var(--u) * 92px); }
.table-area[data-layout='phone'] .seat.is-empty .seat-open { width: calc(var(--u) * 96px); }

body.raise-open .seat.is-me .seat-tag { visibility: hidden; }

/* ---------- short landscape (phones sideways) ---------- */
.table-area[data-short] .seat-cards,
.table-area[data-short] .seat.is-me .seat-cards {
  bottom: auto;
  top: 50%;
  left: calc(100% + 3px);
  translate: 0 -50%;
}
.table-area[data-short] .seat.on-right .seat-cards { left: auto; right: calc(100% + 3px); }
.table-area[data-short] .card-lg { --cw: calc(var(--u) * 56px); }
.table-area[data-short] .seat.is-me .seat-tag { display: none; }
.table-area[data-short] .pot { flex-direction: row; gap: 6px; }
.table-area[data-short] .table-message.is-result { margin-top: calc(var(--u) * 70px); }
