:root {
  /* ── Surfaces (Constellation deep space + Trade Desk terminal) ────── */
  --bg-deep: #080812;
  --bg-base: #0a0a16;
  --bg-panel: #12121f;
  --bg-raised: #1a1a2e;
  --bg-input: #0d0d1c;
  --bg-hover: #1e1e36;
  --bg-active: #24243e;

  /* ── Borders ──────────────────────────────────────────────────────── */
  --border: rgba(255, 255, 255, 0.1);
  --border-strong: rgba(139, 92, 246, 0.4);
  --border-dim: rgba(255, 255, 255, 0.05);
  --border-accent: #33335a;

  /* ── Text ─────────────────────────────────────────────────────────── */
  --text: #e8e8f0;
  --text-strong: #ffffff;
  --text-dim: #d6d6e8;
  --text-muted: #888;
  --text-faint: #6f6f8c;

  /* ── Accents ──────────────────────────────────────────────────────── */
  --violet: #8b5cf6;
  --violet-light: #a78bfa;
  --violet-deep: #6d28d9;
  --cyan: #00e5ff;
  --gold: #ffd700;
  --gold-soft: #fbbf24;
  --magenta: #e94560;
  --magenta-light: #ff8a9c;

  /* ── Semantic ─────────────────────────────────────────────────────── */
  --up: #4ade80;
  --up-bg: #04240f;
  --down: #f87171;
  --down-bg: #04121a;
  --warn: #f59e0b;

  /* ── Felt (table surface) ─────────────────────────────────────────── */
  --felt: #0f2a22;
  --felt-edge: #143b30;
  --felt-glow: rgba(0, 229, 255, 0.06);

  /* ── Geometry ─────────────────────────────────────────────────────── */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);

  --font: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, Menlo, Consolas, monospace;

  --header-h: 56px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%;
  min-height: 100dvh;
  background: var(--bg-deep);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

body {
  background:
    radial-gradient(ellipse at 20% 0%, rgba(139, 92, 246, 0.07), transparent 55%),
    radial-gradient(ellipse at 85% 100%, rgba(0, 229, 255, 0.05), transparent 55%),
    var(--bg-deep);
  padding-bottom: env(safe-area-inset-bottom);
}

a { color: var(--violet-light); text-decoration: none; }
a:hover { color: var(--cyan); }

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

/* ── Header ────────────────────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  background: rgba(8, 8, 18, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.01em;
  color: var(--text-strong);
}

.brand-mark {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--violet), var(--cyan));
  display: grid;
  place-items: center;
  font-size: 0.85rem;
  box-shadow: 0 0 12px rgba(139, 92, 246, 0.4);
}

.brand-sub {
  font-size: 0.62rem;
  font-weight: 500;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-top: 1px;
}

.header-nav {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.header-nav a {
  padding: 7px 13px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: all 0.15s;
}

.header-nav a:hover,
.header-nav a.active {
  background: rgba(139, 92, 246, 0.12);
  color: var(--violet-light);
}

.network-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.3);
  font-size: 0.68rem;
  font-family: var(--mono);
  color: var(--text-muted);
}

.network-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--warn);
  box-shadow: 0 0 6px currentColor;
}

.network-dot.live { background: var(--up); box-shadow: 0 0 8px rgba(74, 222, 128, 0.7); }

/* ── Layout ────────────────────────────────────────────────────────── */
.page {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 20px 64px;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.page-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.01em;
}

.page-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.section-title {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-faint);
  margin: 26px 0 10px;
}

/* ── Cards / panels ────────────────────────────────────────────────── */
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-dim);
  background: rgba(255, 255, 255, 0.015);
}

.panel-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--violet-light);
}

.panel-body { padding: 16px; }

/* ── Stat tiles ────────────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.stat {
  background: var(--bg-panel);
  border: 1px solid rgba(139, 92, 246, 0.18);
  border-radius: var(--radius);
  padding: 13px 15px;
  transition: all 0.15s;
}

.stat:hover {
  background: var(--bg-raised);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.stat-num {
  font-family: var(--mono);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--violet-light);
  line-height: 1.15;
}

.stat-num.gold { color: var(--gold); }
.stat-num.cyan { color: var(--cyan); }
.stat-num.up { color: var(--up); }

.stat-label {
  font-size: 0.66rem;
  color: var(--text-muted);
  margin-top: 3px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.stat-sub {
  font-size: 0.62rem;
  color: var(--text-faint);
  margin-top: 3px;
}

/* ── Tables / lists ────────────────────────────────────────────────── */
.list { display: flex; flex-direction: column; }

.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--border-dim);
  transition: background 0.15s;
}

.list-row:last-child { border-bottom: none; }
.list-row:hover { background: rgba(139, 92, 246, 0.05); }

.list-row .grow { flex: 1; min-width: 0; }

.row-title {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text);
}

.row-meta {
  font-size: 0.68rem;
  color: var(--text-faint);
  margin-top: 2px;
  font-family: var(--mono);
}

/* ── Buttons ───────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 17px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid transparent;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn-primary {
  background: var(--violet);
  color: #fff;
  box-shadow: 0 2px 12px rgba(139, 92, 246, 0.3);
}

.btn-primary:hover { background: var(--violet-light); transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.btn-gold {
  background: var(--gold);
  color: #1a1a2e;
  box-shadow: 0 2px 12px rgba(255, 215, 0, 0.25);
}

.btn-gold:hover { background: #ffed4a; transform: translateY(-1px); }
.btn-gold:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.btn-ghost {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--border);
  color: var(--text-dim);
}

.btn-ghost:hover { background: rgba(255, 255, 255, 0.1); color: var(--text); }

.btn-danger {
  background: var(--magenta);
  color: #fff;
}

.btn-danger:hover { background: #ff5571; }

.btn-sm { padding: 6px 12px; font-size: 0.72rem; }

/* ── Badges ────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 0.65rem;
  font-weight: 600;
  font-family: var(--mono);
  border: 1px solid transparent;
  white-space: nowrap;
}

.badge-running { background: rgba(74, 222, 128, 0.12); border-color: rgba(74, 222, 128, 0.3); color: var(--up); }
.badge-registering { background: rgba(139, 92, 246, 0.12); border-color: rgba(139, 92, 246, 0.3); color: var(--violet-light); }
.badge-completed { background: rgba(0, 229, 255, 0.1); border-color: rgba(0, 229, 255, 0.25); color: var(--cyan); }
.badge-cancelled { background: rgba(255, 255, 255, 0.06); border-color: var(--border); color: var(--text-faint); }
.badge-paid { background: rgba(255, 215, 0, 0.12); border-color: rgba(255, 215, 0, 0.3); color: var(--gold); }
.badge-pending { background: rgba(245, 158, 11, 0.12); border-color: rgba(245, 158, 11, 0.3); color: var(--warn); }
.badge-failed { background: rgba(248, 113, 113, 0.12); border-color: rgba(248, 113, 113, 0.3); color: var(--down); }
.badge-bot { background: rgba(0, 229, 255, 0.08); border-color: rgba(0, 229, 255, 0.2); color: var(--cyan); }

/* ── Forms ─────────────────────────────────────────────────────────── */
.field { margin-bottom: 14px; }

.field label {
  display: block;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.input {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
}

.input:focus {
  outline: none;
  border-color: var(--violet);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.12);
}

.input.mono { font-family: var(--mono); font-size: 0.78rem; }

.form-error {
  font-size: 0.76rem;
  color: var(--down);
  margin-top: 8px;
  min-height: 1.1em;
}

.form-ok {
  font-size: 0.76rem;
  color: var(--up);
  margin-top: 8px;
}

/* ── Poker table ───────────────────────────────────────────────────── */
.table-wrap {
  display: grid;
  grid-template-columns: 1fr 290px;
  gap: 16px;
  align-items: start;
}

.poker-table {
  position: relative;
  background:
    radial-gradient(ellipse at 50% 45%, var(--felt-glow), transparent 70%),
    linear-gradient(160deg, #10332a, var(--felt));
  border: 2px solid var(--felt-edge);
  border-radius: 50%;
  aspect-ratio: 16 / 10;
  min-height: 380px;
  box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.45), var(--shadow-lg);
  overflow: hidden;
}

.board {
  position: absolute;
  top: 46%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  gap: 7px;
}

.card {
  width: 46px;
  height: 64px;
  border-radius: 6px;
  background: linear-gradient(160deg, #f4f4f8, #d8d8e4);
  color: #1a1a2e;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 1.05rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(0, 0, 0, 0.12);
}

.card.red { color: #d91e3f; }
.card.back {
  background: linear-gradient(135deg, var(--violet-deep), var(--violet));
  color: transparent;
  border-color: rgba(255, 255, 255, 0.15);
}
.card.back::after {
  content: '';
  width: 24px;
  height: 24px;
  border-radius: 4px;
  border: 1.5px solid rgba(255, 255, 255, 0.28);
}
.card.placeholder {
  background: rgba(255, 255, 255, 0.04);
  border: 1px dashed rgba(255, 255, 255, 0.12);
  box-shadow: none;
}

.pot-display {
  position: absolute;
  top: 28%;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  padding: 7px 18px;
  border-radius: 20px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 215, 0, 0.25);
  backdrop-filter: blur(6px);
}

.pot-label {
  font-size: 0.58rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-faint);
}

.pot-value {
  font-family: var(--mono);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--gold);
}

/* Seats around the table */
.seat {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(8, 8, 18, 0.75);
  border: 1px solid var(--border);
  backdrop-filter: blur(8px);
  min-width: 132px;
  transition: all 0.2s;
}

.seat.acting {
  border-color: var(--gold);
  box-shadow: 0 0 16px rgba(255, 215, 0, 0.28);
}

.seat.folded { opacity: 0.42; }
.seat.eliminated { opacity: 0.26; filter: grayscale(1); }

.seat-info { min-width: 0; flex: 1; }

.seat-name {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 96px;
}

.seat-chips {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--violet-light);
}

.seat-role {
  font-size: 0.55rem;
  font-family: var(--mono);
  color: var(--gold-soft);
  text-transform: uppercase;
}

.seat-cards { display: flex; gap: 3px; }

.seat-cards .card { width: 26px; height: 36px; font-size: 0.62rem; border-radius: 4px; }
.seat-cards .card.back::after { width: 13px; height: 13px; border-width: 1px; }

.timer-bar {
  height: 2px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  margin-top: 3px;
  overflow: hidden;
}

.timer-fill {
  height: 100%;
  background: var(--gold);
  transition: width 0.9s linear;
}

/* ── Action bar ────────────────────────────────────────────────────── */
.action-bar {
  display: flex;
  gap: 9px;
  padding: 14px 16px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-top: 14px;
  flex-wrap: wrap;
  align-items: center;
}

.action-bar .grow { flex: 1; min-width: 120px; }

.action-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.amount-input {
  width: 110px;
  padding: 8px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.8rem;
}

.amount-input:focus { outline: none; border-color: var(--violet); }

/* ── Side panel ────────────────────────────────────────────────────── */
.side-panel { display: flex; flex-direction: column; gap: 14px; }

.mini-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 0;
  border-bottom: 1px solid var(--border-dim);
  font-size: 0.76rem;
}

.mini-row:last-child { border-bottom: none; }
.mini-row .k { color: var(--text-muted); }
.mini-row .v { font-family: var(--mono); font-weight: 600; color: var(--text-dim); }
.mini-row .v.gold { color: var(--gold); }
.mini-row .v.cyan { color: var(--cyan); }
.mini-row .v.up { color: var(--up); }
.mini-row .v.down { color: var(--down); }

/* ── Tabs ──────────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 3px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
  overflow-x: auto;
}

.tab {
  padding: 9px 15px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: all 0.15s;
}

.tab:hover { color: var(--text-dim); }
.tab.active { color: var(--violet-light); border-bottom-color: var(--violet); }

/* ── Empty state ───────────────────────────────────────────────────── */
.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-faint);
  font-size: 0.82rem;
}

.empty-icon { font-size: 1.8rem; margin-bottom: 10px; opacity: 0.5; }

/* ── Toast ─────────────────────────────────────────────────────────── */
.toast-host {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text);
  box-shadow: var(--shadow);
  max-width: 320px;
  animation: toast-in 0.2s ease-out;
}

.toast.ok { border-color: rgba(74, 222, 128, 0.4); }
.toast.err { border-color: rgba(248, 113, 113, 0.4); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Modal ─────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  z-index: 150;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop.open { display: flex; }

.modal {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 26px;
  width: 440px;
  max-width: 100%;
  box-shadow: var(--shadow-lg);
}

.modal h2 {
  font-size: 1.05rem;
  color: var(--gold);
  margin-bottom: 8px;
}

.modal p { font-size: 0.82rem; color: var(--text-muted); line-height: 1.6; }

.modal-actions { display: flex; gap: 9px; justify-content: flex-end; margin-top: 20px; }

/* ── QR / deposit box ──────────────────────────────────────────────── */
.deposit-box {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px;
  margin: 12px 0;
}

.deposit-line {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 5px 0;
  font-size: 0.72rem;
  border-bottom: 1px solid var(--border-dim);
}

.deposit-line:last-child { border-bottom: none; }
.deposit-line .k { color: var(--text-faint); }
.deposit-line .v { font-family: var(--mono); color: var(--text-dim); word-break: break-all; text-align: right; }

/* ── Responsive ────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .table-wrap { grid-template-columns: 1fr; }
  .poker-table { min-height: 320px; }
  .header-nav a { min-height: 40px; display: inline-flex; align-items: center; }
  .btn-sm { min-height: 40px; }
  .tab { min-height: 40px; display: inline-flex; align-items: center; }
  .input { min-height: 40px; }
}

@media (max-width: 640px) {
  .page { padding: 16px 13px 48px; }

  /* The header must not force horizontal scroll on a phone. Let the nav
     scroll on its own instead of pushing the document wide. */
  .site-header {
    gap: 8px;
    padding: 0 10px;
    overflow: hidden;
  }
  .header-nav {
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .header-nav::-webkit-scrollbar { display: none; }
  .header-nav a {
    padding: 10px 12px;
    font-size: 0.78rem;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }
  .brand-sub { display: none; }
  .network-badge { display: none; }

  /* The table keeps its oval shape but must never exceed the viewport. */
  .poker-table {
    min-height: 0;
    height: 56vw;
    max-height: 260px;
    aspect-ratio: auto;
    width: 100%;
  }
  .seat { min-width: 88px; padding: 4px 8px; }
  .seat-name { max-width: 64px; font-size: 0.68rem; }
  .seat-cards .card { width: 21px; height: 29px; font-size: 0.54rem; }
  .card { width: 38px; height: 53px; font-size: 0.88rem; }
  .board { gap: 5px; }

  /* Comfortable tap targets. */
  .btn { min-height: 44px; padding: 11px 16px; }
  .btn-sm { min-height: 40px; padding: 9px 14px; }
  .tab { padding: 12px 14px; min-height: 44px; display: inline-flex; align-items: center; }
  .input { min-height: 44px; padding: 11px 12px; }
  .amount-input { min-height: 44px; padding: 11px; }
}
