/* =========================================================================
   Velvet Ace — premium casino poker UI
   ========================================================================= */

:root {
  --bg-void: #0a0b0e;
  --bg-panel: #14161c;
  --bg-panel-2: #1b1e26;
  --felt-1: #0e4d3a;
  --felt-2: #0a3a2b;
  --felt-edge: #062c20;
  --wood-1: #5a3a22;
  --wood-2: #3c2415;
  --wood-hi: #8a5a34;
  --gold: #d4af37;
  --gold-bright: #f3d979;
  --gold-dim: #9c7f2e;
  --burgundy: #7a1f2b;
  --burgundy-bright: #9c2c3a;
  --cream: #f3ecd9;
  --ink: #cfd3dc;
  --ink-dim: #8b8f9c;
  --danger: #d9483f;
  --success: #3fae6a;
  --info: #4a90c9;
  --radius-lg: 20px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-deep: 0 20px 60px rgba(0,0,0,0.55);
  --font-display: "Playfair Display", Georgia, "Times New Roman", serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  /* ---------- fluid card / seat scale ----------
     Everything below is driven off the viewport's *smaller* dimension
     (vmin) rather than fixed pixels or width-only breakpoints, so cards
     stay large and correctly proportioned whether the window is short-and-
     wide (ultrawide) or narrow-and-tall, and grow smoothly instead of
     jumping at a couple of hard breakpoints. Community/hole cards keep the
     source art's ~1:1.41 aspect ratio at every size. */
  --card-w: clamp(104px, 12vmin, 196px);
  --card-h: calc(var(--card-w) * 1.41);
  --card-sm-w: clamp(70px, 7.5vmin, 126px);
  --card-sm-h: calc(var(--card-sm-w) * 1.41);
  /* The viewer's own hole cards — the ones actually being read to decide
     an action — get their own, larger scale instead of sharing the small
     size used for the five opponent seats; every other seat stays compact
     so up to 6 still fit around the table without crowding. */
  --card-self-w: clamp(92px, 10.5vmin, 172px);
  --card-self-h: calc(var(--card-self-w) * 1.41);
  --seat-w: clamp(158px, 16vmin, 248px);
  --avatar-size: clamp(40px, 4.2vmin, 62px);
}

/* light-mode isn't a target for this app (casino UI reads dark by design),
   but keep body painted explicitly so nothing borrows a host theme */
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg-void);
  color: var(--ink);
  font-family: var(--font-body);
  overflow: hidden;
}
body { position: relative; }
img { -webkit-user-drag: none; user-select: none; }
button { font-family: inherit; cursor: pointer; }
input { font-family: inherit; }
::selection { background: var(--gold-dim); color: #000; }

/* ---------- screens ---------- */
.screen {
  position: fixed; inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.screen.active { display: flex; }

/* ---------- buttons ---------- */
.btn {
  border: none;
  border-radius: var(--radius-md);
  padding: 12px 22px;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.02em;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.15s ease, opacity 0.15s ease;
  color: var(--cream);
}
.btn:active { transform: translateY(1px) scale(0.99); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.btn--primary {
  background: linear-gradient(160deg, var(--gold-bright), var(--gold) 55%, var(--gold-dim));
  color: #241b02;
  box-shadow: 0 6px 20px rgba(212,175,55,0.35);
}
.btn--primary:hover:not(:disabled) { box-shadow: 0 8px 26px rgba(212,175,55,0.5); transform: translateY(-1px); }
.btn--ghost {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.14);
  color: var(--cream);
}
.btn--ghost:hover:not(:disabled) { background: rgba(255,255,255,0.12); }
.btn--xl { padding: 18px 36px; font-size: 18px; border-radius: var(--radius-lg); }
.btn--lg { padding: 14px 26px; font-size: 16px; width: 100%; margin-top: 6px; }
.btn--sm { padding: 8px 14px; font-size: 13px; }
.btn-icon { margin-right: 8px; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.06);
  color: var(--cream);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 16px;
}
.icon-btn:hover { background: rgba(255,255,255,0.14); }

/* =========================================================================
   LANDING
   ========================================================================= */
.screen--landing {
  background:
    radial-gradient(1200px 700px at 50% -10%, rgba(212,175,55,0.10), transparent 60%),
    radial-gradient(1000px 800px at 50% 120%, rgba(122,31,43,0.18), transparent 60%),
    var(--bg-void);
}
.landing-glow {
  position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(115deg, rgba(255,255,255,0.015) 0 2px, transparent 2px 6px);
}
.brand { text-align: center; margin-bottom: 46px; position: relative; z-index: 1; }
.brand-mark {
  display: inline-block; font-size: 46px; color: var(--gold);
  text-shadow: 0 0 30px rgba(212,175,55,0.6);
  margin-bottom: 4px;
}
.brand h1 {
  font-family: var(--font-display);
  font-size: 64px; margin: 0; color: var(--cream);
  letter-spacing: 0.02em;
  text-shadow: 0 4px 30px rgba(0,0,0,0.6);
}
.brand-tag { color: var(--ink-dim); margin-top: 8px; font-size: 15px; letter-spacing: 0.03em; }
.landing-actions { display: flex; gap: 22px; position: relative; z-index: 1; }
.landing-footer { position: absolute; bottom: 26px; color: var(--ink-dim); font-size: 12px; letter-spacing: 0.03em; }

/* =========================================================================
   FORMS (create / join / created)
   ========================================================================= */
.screen--form { background: var(--bg-void); }
.form-card {
  width: 440px; max-width: 92vw;
  background: linear-gradient(180deg, var(--bg-panel-2), var(--bg-panel));
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-lg);
  padding: 30px 32px 26px;
  box-shadow: var(--shadow-deep);
  position: relative;
}
.form-card--center { text-align: center; }
.form-card h2 {
  font-family: var(--font-display);
  color: var(--cream); font-size: 26px; margin: 6px 0 20px;
}
.back-btn {
  position: absolute; top: 18px; left: 20px;
  background: none; border: none; color: var(--ink-dim); font-size: 13px;
}
.back-btn:hover { color: var(--cream); }
.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-dim); margin-bottom: 6px; }
.field em { color: var(--ink-dim); font-style: normal; opacity: 0.7; }
.field input[type="text"], .field input[type="number"] {
  width: 100%; padding: 12px 14px;
  background: rgba(0,0,0,0.35);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius-sm);
  color: var(--cream); font-size: 15px;
  outline: none;
}
.field input:focus { border-color: var(--gold-dim); box-shadow: 0 0 0 3px rgba(212,175,55,0.15); }
.code-input { letter-spacing: 0.3em; text-transform: uppercase; font-family: var(--font-display); font-size: 20px !important; text-align: center; }
.field-error { color: var(--danger); font-size: 13px; min-height: 18px; margin-top: 10px; text-align: center; }

.avatar-picker { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.avatar-preview {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--bg-panel);
  border: 2px solid var(--gold-dim);
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; overflow: hidden; flex-shrink: 0;
}
.avatar-preview img { width: 100%; height: 100%; object-fit: cover; }
.avatar-grid { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; }
.avatar-chip {
  width: 34px; height: 34px; border-radius: 50%; font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.06); border: 1px solid transparent;
}
.avatar-chip:hover { border-color: var(--gold-dim); }
.avatar-chip.selected { border-color: var(--gold); background: rgba(212,175,55,0.15); }
.avatar-upload-btn { flex-shrink: 0; }

.table-image-picker { display: flex; align-items: center; gap: 12px; }
.table-image-preview {
  width: 72px; height: 46px; border-radius: var(--radius-sm);
  background: var(--bg-panel); border: 1px dashed rgba(255,255,255,0.2);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: var(--ink-dim); overflow: hidden; flex-shrink: 0;
}
.table-image-preview img { width: 100%; height: 100%; object-fit: cover; }

.table-code-display {
  font-family: var(--font-display); font-size: 48px; letter-spacing: 0.2em;
  color: var(--gold-bright); margin: 14px 0; text-shadow: 0 0 24px rgba(212,175,55,0.4);
}
.muted { color: var(--ink-dim); font-size: 13px; }

/* =========================================================================
   LOBBY
   ========================================================================= */
.screen--lobby { background: var(--bg-void); }
.lobby-card {
  width: 480px; max-width: 92vw;
  background: linear-gradient(180deg, var(--bg-panel-2), var(--bg-panel));
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-lg);
  padding: 26px 28px;
  box-shadow: var(--shadow-deep);
}
.lobby-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 18px; }
.lobby-title-row { display: flex; align-items: center; gap: 12px; }
.lobby-table-thumb {
  width: 48px; height: 48px; border-radius: var(--radius-sm); overflow: hidden;
  border: 1px solid rgba(212,175,55,0.35); flex-shrink: 0;
  background: var(--bg-panel);
}
.lobby-table-thumb img { width: 100%; height: 100%; object-fit: cover; }
.lobby-header h2 { font-family: var(--font-display); margin: 0; color: var(--cream); font-size: 24px; }
.lobby-code { color: var(--ink-dim); font-size: 13px; margin-top: 4px; letter-spacing: 0.05em; }
.lobby-code strong { color: var(--gold-bright); letter-spacing: 0.15em; }
.lobby-count {
  background: rgba(212,175,55,0.12); color: var(--gold-bright);
  border: 1px solid rgba(212,175,55,0.3);
  padding: 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 700;
  white-space: nowrap;
}
.lobby-players { list-style: none; margin: 0 0 20px; padding: 0; display: flex; flex-direction: column; gap: 8px; max-height: 320px; overflow-y: auto; }
.lobby-players li {
  display: flex; align-items: center; gap: 12px;
  background: rgba(255,255,255,0.04);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.lobby-players .lp-avatar {
  width: 36px; height: 36px; border-radius: 50%; overflow: hidden;
  background: var(--bg-panel); display: flex; align-items: center; justify-content: center; font-size: 18px;
  flex-shrink: 0;
}
.lobby-players .lp-avatar img { width: 100%; height: 100%; object-fit: cover; }
.lobby-players .lp-name { flex: 1; font-weight: 600; color: var(--cream); }
.lobby-players .lp-tag { font-size: 11px; color: var(--gold-dim); border: 1px solid var(--gold-dim); border-radius: 999px; padding: 2px 8px; }
.lobby-players .lp-status { font-size: 12px; color: var(--ink-dim); }
.lobby-players li.empty { opacity: 0.5; font-style: italic; }
.lp-kick { width: 26px; height: 26px; font-size: 12px; flex-shrink: 0; }
.lp-kick:hover { background: rgba(217,72,63,0.25); border-color: var(--danger); }
.lobby-actions { display: flex; flex-direction: column; gap: 8px; }
.lobby-hint { text-align: center; color: var(--ink-dim); font-size: 12px; margin: 12px 0 0; }

/* =========================================================================
   TABLE — topbar
   ========================================================================= */
.screen--table { background: var(--bg-void); justify-content: flex-start; }
.table-topbar {
  width: 100%; height: 56px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px;
  background: linear-gradient(180deg, #131620, #0d0f16);
  border-bottom: 1px solid rgba(255,255,255,0.07);
  position: relative; z-index: 30;
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.topbar-table-name {
  font-family: var(--font-display); font-size: 18px; color: var(--cream);
  max-width: 32vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topbar-code { font-size: 12px; color: var(--gold-dim); letter-spacing: 0.15em; border: 1px solid rgba(212,175,55,0.3); padding: 2px 8px; border-radius: 999px; }
.topbar-center { display: flex; gap: 10px; }
.blind-pill, .hand-pill {
  background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1);
  padding: 5px 12px; border-radius: 999px; font-size: 12px; color: var(--ink);
}
.topbar-right { display: flex; align-items: center; gap: 8px; position: relative; }
.volume-pop {
  position: absolute; top: 46px; right: 44px;
  background: var(--bg-panel-2); border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-sm); padding: 12px 14px; display: none; flex-direction: column; gap: 10px;
  box-shadow: var(--shadow-deep); z-index: 40; width: 170px;
}
.volume-pop.open { display: flex; }
.volume-pop label { font-size: 11px; color: var(--ink-dim); display: flex; flex-direction: column; gap: 4px; }

/* =========================================================================
   TABLE ARENA / FELT
   ========================================================================= */
.table-arena {
  flex: 1; width: 100%; position: relative;
  display: flex; align-items: center; justify-content: center;
  padding: 8px 8px 0;
  min-height: 0;
  overflow: hidden; /* belt-and-suspenders: never let the felt push a seat behind the action bar */
}
.felt {
  position: relative;
  width: min(2200px, 99vw);
  /* Sized against the space .table-arena actually has left (100%), not a
     raw viewport-height percentage — 86vh ignored how tall the topbar and
     action bar are, so on common laptop heights (1366×768 and similar)
     the felt could be taller than the space available and push the
     bottom seat's pod behind the action bar. .table-arena's height is
     already correct (flexbox subtracts its fixed-height siblings), so
     sizing off it directly is what actually guarantees a fit. */
  /* Leave real headroom below 100% — the seat pods positioned near the top
     /bottom of the ellipse (see ellipsePosition() in render.js) extend
     well past their anchor point (cards + name/stack/status pod + the
     bet-chip pill hanging off its bottom edge), so the felt itself must
     stay noticeably smaller than the arena or that overhang gets clipped
     by .table-arena's overflow:hidden instead of just fitting. */
  height: min(960px, 82%);
  background:
    radial-gradient(ellipse at 50% 38%, rgba(255,255,255,0.05), transparent 60%),
    radial-gradient(ellipse at 50% 50%, var(--felt-1), var(--felt-2) 70%, var(--felt-edge) 100%);
  border-radius: 50% / 50%;
  border: 18px solid transparent;
  border-image: linear-gradient(155deg, var(--wood-hi), var(--wood-1) 40%, var(--wood-2) 100%) 1;
  box-shadow:
    inset 0 0 90px rgba(0,0,0,0.55),
    inset 0 0 18px rgba(0,0,0,0.5),
    0 30px 70px rgba(0,0,0,0.6);
}
.felt-rim {
  position: absolute; inset: 10px;
  border-radius: 50% / 50%;
  border: 2px solid rgba(212,175,55,0.18);
  pointer-events: none;
}

.croupier-box {
  /* Deliberately anchored ABOVE the felt (outside the seat ellipse) so the
     dealer never collides with the top-center opponent seat in heads-up.
     Both the size and how far above the felt it sits scale with the same
     vmin unit as the cards/seats, so the dealer stays proportionate to the
     table instead of looking tiny (fixed px) once the felt grows. */
  position: absolute; top: clamp(-190px, -15vmin, -92px); left: 50%; transform: translateX(-50%);
  width: clamp(120px, 12vmin, 220px); height: clamp(120px, 12vmin, 220px);
  display: flex; align-items: flex-end; justify-content: center;
  filter: drop-shadow(0 10px 16px rgba(0,0,0,0.5));
  z-index: 3;
  pointer-events: none;
}
.croupier-box img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* The pot and the community cards are grouped and centered as one block
   instead of each being pinned to its own guessed top:X% — with the
   community cards now sized off the same fluid card scale as everything
   else, a fixed percentage stopped leaving reliable clearance from the
   pot above it (or from the top seat's bet-chip pill, at 6 players) as
   soon as the card size changed. A flex column with a real gap grows
   from its own vertical center instead, so the spacing stays correct at
   every card size and every seat count. */
.table-center {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center;
  gap: clamp(14px, 2.4vmin, 34px);
  z-index: 4;
}
.community-cards {
  display: flex; gap: clamp(6px, 1vmin, 16px);
}
.pot-display {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.pot-label { font-size: 11px; letter-spacing: 0.15em; color: var(--gold-dim); }
.pot-amount {
  font-family: var(--font-display); font-size: 26px; font-weight: 700;
  color: var(--gold-bright); text-shadow: 0 2px 12px rgba(0,0,0,0.6);
  transition: transform 0.25s ease;
}
.pot-amount.bump { transform: scale(1.18); }

.hand-result-banner {
  position: absolute; top: 14%; left: 50%; transform: translate(-50%, -20px);
  background: rgba(10,11,14,0.88); border: 1px solid var(--gold-dim);
  color: var(--gold-bright); padding: 10px 22px; border-radius: 999px;
  font-weight: 700; font-size: 15px; letter-spacing: 0.03em;
  opacity: 0; pointer-events: none; transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 20; white-space: nowrap;
}
.hand-result-banner.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- playing cards ---------- */
.card {
  width: var(--card-w); height: var(--card-h);
  border-radius: clamp(8px, 0.9vmin, 14px);
  background-size: cover; background-position: center;
  box-shadow: 0 4px 10px rgba(0,0,0,0.5);
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.45s cubic-bezier(.2,.7,.3,1), opacity 0.3s ease, width 0.15s ease, height 0.15s ease;
}
.card.dealt-in { animation: cardDeal 0.4s ease both; }
@keyframes cardDeal {
  from { opacity: 0; transform: translateY(-30px) scale(0.7) rotate(-8deg); }
  to { opacity: 1; transform: translateY(0) scale(1) rotate(0); }
}
.card.flip { transform: rotateY(180deg); }
.card--sm { width: var(--card-sm-w); height: var(--card-sm-h); border-radius: clamp(5px, 0.6vmin, 9px); }

/* =========================================================================
   SEATS
   ========================================================================= */
#seats-layer { position: absolute; inset: 0; z-index: 6; }
.seat {
  position: absolute;
  width: var(--seat-w);
  transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center;
  gap: 6px;
}
.seat-cards { display: flex; gap: clamp(4px, 0.7vmin, 8px); justify-content: center; height: var(--card-sm-h); }
.seat.self .seat-cards { height: var(--card-self-h); gap: clamp(6px, 1vmin, 12px); }
.seat.self .seat-cards .card--sm { width: var(--card-self-w); height: var(--card-self-h); }
.seat-pod {
  width: 100%;
  background: linear-gradient(180deg, rgba(27,30,38,0.94), rgba(15,17,22,0.94));
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  padding: 8px 10px;
  display: flex; align-items: center; gap: 8px;
  box-shadow: 0 8px 18px rgba(0,0,0,0.4);
  position: relative;
}
.seat.acting .seat-pod {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(212,175,55,0.35), 0 8px 18px rgba(0,0,0,0.4);
  animation: actingPulse 1.4s ease-in-out infinite;
}
@keyframes actingPulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(212,175,55,0.28), 0 8px 18px rgba(0,0,0,0.4); }
  50% { box-shadow: 0 0 0 6px rgba(212,175,55,0.45), 0 8px 18px rgba(0,0,0,0.4); }
}
.seat.folded .seat-pod { opacity: 0.42; filter: grayscale(0.6); }
.seat.eliminated .seat-pod { opacity: 0.4; filter: grayscale(1); }
.seat.eliminated .seat-cards { display: none; }
.seat.disconnected .seat-pod { opacity: 0.5; }
.seat.disconnected .lp-avatar::after { content: "⌁"; }

.seat-avatar {
  width: var(--avatar-size); height: var(--avatar-size); border-radius: 50%; overflow: hidden; flex-shrink: 0;
  background: var(--bg-panel); display: flex; align-items: center; justify-content: center; font-size: clamp(16px, 1.8vmin, 24px);
  border: 2px solid rgba(255,255,255,0.12);
}
.seat-avatar img { width: 100%; height: 100%; object-fit: cover; }
.seat.self .seat-avatar { border-color: var(--gold); }

.seat-info { flex: 1; min-width: 0; }
.seat-name { font-weight: 700; font-size: 13px; color: var(--cream); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seat-stack { font-size: 13px; color: var(--gold-bright); font-weight: 700; }
.seat-status { font-size: 11px; color: var(--ink-dim); min-height: 14px; }

.seat-timer {
  position: absolute; top: -8px; right: -8px;
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--bg-panel); border: 2px solid var(--gold);
  display: none; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800; color: var(--gold-bright);
}
.seat.acting .seat-timer { display: flex; }
.seat-timer.urgent { border-color: var(--danger); color: var(--danger); animation: tick 0.6s infinite; }
@keyframes tick { 50% { transform: scale(1.12); } }

.seat-marker {
  position: absolute; width: 26px; height: 26px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff, #e8dcb0 40%, #b99a3c 100%);
  color: #241b02; font-size: 8px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 3px 6px rgba(0,0,0,0.5);
  bottom: -6px; left: -6px;
  border: 1px solid #7a5f1c;
}
.seat-marker.sb { background: radial-gradient(circle at 35% 30%, #cfe6ff, #6fa8d8 60%, #35617f 100%); color: #06202f; left: 20px; }
.seat-marker.bb { background: radial-gradient(circle at 35% 30%, #ffd0d0, #d87070 60%, #7f3535 100%); color: #2f0606; left: 46px; }

.seat-bet-chip {
  position: absolute; bottom: -26px; left: 50%; transform: translateX(-50%);
  background: rgba(10,11,14,0.85); border: 1px solid var(--gold-dim);
  color: var(--gold-bright); font-size: 11px; font-weight: 700;
  padding: 3px 9px; border-radius: 999px; white-space: nowrap;
}
.seat-action-flag {
  position: absolute; bottom: -26px; left: 50%; transform: translateX(-50%);
  background: rgba(10,11,14,0.85); color: var(--ink); font-size: 10px;
  padding: 3px 9px; border-radius: 999px; white-space: nowrap; text-transform: uppercase; letter-spacing: 0.05em;
}
.seat-action-flag.fold { color: var(--danger); }
.seat-action-flag.allin { color: var(--burgundy-bright); font-weight: 800; }
.seat-action-flag.call, .seat-action-flag.check { color: var(--success); }
.seat-action-flag.bet, .seat-action-flag.raise { color: var(--gold-bright); }

/* seat position variables set inline by JS: --sx / --sy (percent) */
.seat { left: var(--sx); top: var(--sy); }
/* The viewer's own seat (always bottom-center — see rotateSeatsAroundSelf())
   carries noticeably bigger hole cards than the other five, so it needs a
   bit more clearance below its anchor point than the shared ellipse radius
   budgets for. Nudging it toward the felt's center by a fixed amount is
   simpler and safer than re-deriving the ellipse per seat, and only this
   one seat's footprint actually grew. */
.seat.self { transform: translate(-50%, -50%) translateY(clamp(-46px, -4.2vmin, -22px)); }

/* ---------- chip stack render on seat pod ---------- */
.chip-stack-icon { display: inline-flex; align-items: center; }

/* =========================================================================
   CHIP + CARD FX LAYERS (absolute, animated projectiles)
   ========================================================================= */
#chip-fx-layer, #card-fx-layer { position: absolute; inset: 0; pointer-events: none; z-index: 15; }
.chip-fx {
  position: absolute; width: 22px; height: 22px; border-radius: 50%;
  transition: transform 0.55s cubic-bezier(.2,.7,.2,1), opacity 0.55s ease;
}
.card-fx {
  position: absolute; width: var(--card-sm-w); height: var(--card-sm-h); border-radius: clamp(5px, 0.6vmin, 9px);
  background-size: cover; background-position: center;
  transition: transform 0.5s cubic-bezier(.2,.7,.2,1), opacity 0.4s ease;
  box-shadow: 0 4px 10px rgba(0,0,0,0.5);
}

/* =========================================================================
   ACTION BAR
   ========================================================================= */
.action-bar {
  flex-shrink: 0; width: 100%;
  background: linear-gradient(0deg, #0d0f16, #131620);
  border-top: 1px solid rgba(255,255,255,0.07);
  padding: 10px 18px 14px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 30;
}

/* Shown instead of the action bar for a player who's busted out but the
   game continues without them — no action buttons at all, just a clear
   "you're watching now" state, in the exact spot the action bar occupied. */
.spectator-banner {
  display: none; flex-shrink: 0; width: 100%;
  background: linear-gradient(0deg, #0d0f16, #131620);
  border-top: 1px solid rgba(255,255,255,0.07);
  padding: 18px; text-align: center;
  color: var(--ink-dim); font-weight: 600; font-size: 14px; letter-spacing: 0.02em;
  z-index: 30;
}
.spectator-banner.show { display: block; }
.bet-controls {
  display: none; align-items: center; gap: 12px;
  background: rgba(255,255,255,0.04); border-radius: var(--radius-md); padding: 10px 14px;
}
.bet-controls.open { display: flex; }
.bet-presets { display: flex; gap: 6px; flex-wrap: wrap; }
.bet-preset-btn {
  background: rgba(255,255,255,0.07); border: 1px solid rgba(255,255,255,0.12);
  color: var(--cream); border-radius: 999px; padding: 5px 12px; font-size: 12px; font-weight: 700;
}
.bet-preset-btn:hover { background: rgba(255,255,255,0.15); }
#bet-slider { flex: 1; accent-color: var(--gold); }
.bet-amount-input {
  width: 110px; padding: 8px 10px; background: rgba(0,0,0,0.4);
  border: 1px solid rgba(255,255,255,0.15); border-radius: var(--radius-sm); color: var(--gold-bright);
  font-weight: 700; font-size: 15px; text-align: right;
}
.action-buttons { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.action-buttons.busy { cursor: wait; }
.action-btn {
  min-width: 118px; padding: 14px 16px; border-radius: var(--radius-md);
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.12);
  font-size: clamp(12px, 1.1vmin, 14px); font-weight: 800; letter-spacing: 0.02em;
  white-space: nowrap;
}
.action-btn:disabled { opacity: 0.28; cursor: not-allowed; }
.action-btn--fold { color: #ff9d95; }
.action-btn--fold:hover:not(:disabled) { background: rgba(217,72,63,0.18); border-color: var(--danger); }
.action-btn--check, .action-btn--call { color: #8be0ac; }
.action-btn--check:hover:not(:disabled), .action-btn--call:hover:not(:disabled) { background: rgba(63,174,106,0.18); border-color: var(--success); }
.action-btn--bet, .action-btn--raise { color: var(--gold-bright); }
.action-btn--bet:hover:not(:disabled), .action-btn--raise:hover:not(:disabled) { background: rgba(212,175,55,0.18); border-color: var(--gold); }
.action-btn--allin {
  color: #fff; background: linear-gradient(160deg, var(--burgundy-bright), var(--burgundy));
  border-color: var(--burgundy-bright);
}
.action-btn--allin:hover:not(:disabled) { box-shadow: 0 0 16px rgba(156,44,58,0.6); }
.action-btn--confirm { display: none; color: #241b02; background: linear-gradient(160deg, var(--gold-bright), var(--gold)); }
.action-btn--confirm.show { display: inline-block; }
.action-btn.hidden { display: none; }
.action-bar.is-spectator { display: none; }

/* =========================================================================
   CHAT
   ========================================================================= */
.chat-panel {
  position: fixed; top: 66px; right: -320px; width: 300px; bottom: 90px;
  background: var(--bg-panel-2); border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-md); z-index: 35;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-deep);
  transition: right 0.25s ease;
}
.chat-panel.open { right: 16px; }
.chat-header { padding: 10px 14px; font-weight: 700; color: var(--cream); border-bottom: 1px solid rgba(255,255,255,0.08); display: flex; justify-content: space-between; align-items: center; font-size: 13px; }
.chat-log { flex: 1; overflow-y: auto; padding: 10px 14px; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.chat-msg .chat-name { color: var(--gold-bright); font-weight: 700; }
.chat-msg.system { color: var(--ink-dim); font-style: italic; }
.chat-form { display: flex; gap: 6px; padding: 10px; border-top: 1px solid rgba(255,255,255,0.08); }
.chat-form input { flex: 1; padding: 8px 10px; background: rgba(0,0,0,0.35); border: 1px solid rgba(255,255,255,0.12); border-radius: var(--radius-sm); color: var(--cream); outline: none; }

/* =========================================================================
   GAME OVER OVERLAY
   ========================================================================= */
.game-over-overlay {
  position: fixed; inset: 0;
  background: rgba(6,7,10,0.82);
  backdrop-filter: blur(3px);
  display: none; align-items: center; justify-content: center;
  z-index: 200;
}
.game-over-overlay.show { display: flex; }
.game-over-card {
  width: 420px; max-width: 92vw; text-align: center;
  background: linear-gradient(180deg, var(--bg-panel-2), var(--bg-panel));
  border: 1px solid rgba(212,175,55,0.35);
  border-radius: var(--radius-lg);
  padding: 36px 32px 30px;
  box-shadow: var(--shadow-deep), 0 0 60px rgba(212,175,55,0.15);
}
.game-over-trophy { font-size: 56px; filter: drop-shadow(0 4px 14px rgba(212,175,55,0.5)); margin-bottom: 6px; }
.game-over-card h2 { font-family: var(--font-display); color: var(--gold-bright); font-size: 30px; margin: 4px 0 8px; }
.game-over-card p#game-over-subtitle { color: var(--cream); font-size: 15px; margin: 0 0 22px; }
.game-over-card .btn--lg { margin-bottom: 10px; }
.game-over-card .muted { margin: 0 0 14px; font-size: 13px; }

/* =========================================================================
   TOASTS
   ========================================================================= */
.toast-root { position: fixed; top: 70px; left: 50%; transform: translateX(-50%); z-index: 999; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: rgba(15,17,22,0.95); border: 1px solid var(--danger);
  color: var(--cream); padding: 10px 18px; border-radius: 999px; font-size: 13px;
  box-shadow: var(--shadow-deep);
  animation: toastIn 0.25s ease both;
}
.toast.info { border-color: var(--info); }
.toast.success { border-color: var(--success); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

/* =========================================================================
   RESPONSIVE
   Card/seat sizing itself is fluid (vmin-driven custom properties, top of
   file) so it already scales continuously across 1280×720 up through
   2560×1440, 3840×2160 and ultrawide monitors without needing a breakpoint
   per resolution. What's left here is layout that needs to actually
   *reflow* below a certain size — the felt's aspect ratio, chat panel
   width, and the action bar wrapping onto two rows — plus raising the
   vmin ceiling a bit further on very large/tall viewports so cards keep
   growing instead of plateauing too early.
   ========================================================================= */

/* Large desktop monitors and 4K: let cards/seats grow a bit more than the
   default clamp ceiling allows, since there's plenty of felt to spare. */
@media (min-width: 1600px) {
  :root {
    --card-w: clamp(96px, 11vmin, 210px);
    --seat-w: clamp(158px, 17vmin, 270px);
  }
}

/* Ultrawide (21:9+) monitors: vmin is the *height*, which stays modest on
   these, so the fluid scale alone would leave cards smaller than the huge
   horizontal footprint warrants. Nudge the ceiling up using vh instead. */
@media (min-aspect-ratio: 2/1) {
  :root {
    --card-w: clamp(96px, 13vh, 200px);
    --seat-w: clamp(158px, 19vh, 260px);
  }
}

@media (max-width: 900px) {
  .felt { width: 97vw; }
  :root {
    --card-w: clamp(64px, 9vmin, 110px);
    --card-sm-w: clamp(46px, 6vmin, 78px);
    --seat-w: clamp(120px, 15vmin, 190px);
    --avatar-size: clamp(32px, 4vmin, 48px);
  }
  .action-btn { min-width: 88px; padding: 12px 10px; }
  .chat-panel { width: min(300px, 90vw); }
  /* The topbar's three groups (name+code, blinds/hand pills, volume/chat/
     leave) stop fitting on one line well before the felt itself needs to
     shrink — wrap it onto two rows instead of letting anything overflow
     or the table name break mid-word. */
  .table-topbar { flex-wrap: wrap; height: auto; min-height: 56px; padding: 8px 12px; row-gap: 6px; }
  .topbar-center { order: 3; width: 100%; justify-content: center; flex-wrap: wrap; }
}

@media (max-width: 560px) {
  .action-buttons { gap: 6px; }
  .action-btn { min-width: 30%; flex: 1 1 30%; padding: 10px 6px; }
  .bet-controls { flex-wrap: wrap; }
}
