:root {
  --bg: #0b0e13;
  --surface: #131820;
  --surface-2: #1a212c;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #eef2f6;
  --text-muted: #8b96a6;
  --accent: #22c55e;
  --accent-dim: rgba(34, 197, 94, 0.16);
  --amber: #f59e0b;
  --danger: #ef4444;
  --danger-dim: rgba(239, 68, 68, 0.15);
  --felt-center: #162e24;
  --felt-edge: #0d1d17;
  --felt-border: #254538;
  --radius: 12px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "PingFang SC", "Helvetica Neue", sans-serif;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.hidden {
  display: none !important;
}

/* Buttons & Inputs */
button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease, opacity 0.15s ease;
}

button:active:not(:disabled) {
  transform: translateY(1px);
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

input[type="text"],
input[type="number"] {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  outline: none;
}

input[type="text"]:focus,
input[type="number"]:focus {
  border-color: var(--accent);
}

.money-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  align-items: center;
}

.flag-seg {
  height: 36px;
  align-items: center;
}

.flag-seg button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 5px 10px;
  white-space: nowrap;
}

.flag-seg .flag {
  font-size: 15px;
  line-height: 1;
}

.input-money {
  display: flex;
  align-items: center;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  padding: 0 10px;
  height: 36px;
}

.input-money:focus-within {
  border-color: var(--accent);
}

.input-money input[type="number"] {
  border: none;
  background: transparent;
  padding: 0 6px;
  height: 100%;
  font-variant-numeric: tabular-nums;
}

.money-prefix,
.money-suffix {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.pnl-pos {
  color: var(--accent) !important;
  font-weight: 600;
}

.pnl-neg {
  color: #f87171 !important;
  font-weight: 600;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
}

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 6px 11px;
  font-size: 12px;
  border-radius: 7px;
}

.btn-primary {
  background: var(--accent);
  color: #06140c;
  font-weight: 600;
}

.btn-primary:hover:not(:disabled) {
  background: #34d36f;
}

.btn-secondary {
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  color: var(--text);
}

.btn-secondary:hover:not(:disabled) {
  background: #232c3a;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.btn-ghost:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--border-strong);
  background: rgba(255, 255, 255, 0.04);
}

.btn-danger-text:hover:not(:disabled) {
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.35);
}

.btn-link {
  font-size: 12px;
  color: var(--text-muted);
}

.btn-link:hover {
  color: var(--text);
}

/* Lobby */
.lobby-view {
  height: 100vh;
  overflow-y: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.lobby-container {
  width: 100%;
  max-width: 440px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.brand {
  text-align: center;
  margin-bottom: 4px;
}

.brand-mark {
  font-size: 30px;
  line-height: 1;
  color: var(--accent);
  margin-bottom: 8px;
}

.brand h1 {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.brand p {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 6px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

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

.field-row.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.segmented {
  display: flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}

.segmented button {
  flex: 1;
  padding: 6px 4px;
  font-size: 12px;
  border-radius: 6px;
  color: var(--text-muted);
}

.segmented button.active {
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
}

.checkbox-row input {
  accent-color: var(--accent);
  width: 15px;
  height: 15px;
}

.join-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--text-muted);
}

.join-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.table-item-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.join-code-row {
  display: flex;
  gap: 8px;
}

.join-code-row input {
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.tables-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.table-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 13px;
}

.table-item-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.table-item-meta small {
  font-size: 11px;
  color: var(--text-muted);
}

.empty-hint {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  padding: 6px 0;
}

/* Table View */
.table-view {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 52px;
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(11, 14, 19, 0.9);
  z-index: 20;
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo-mini {
  color: var(--accent);
  font-size: 18px;
  margin-right: 2px;
}

.pill {
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
}

.pill strong {
  color: var(--text);
  letter-spacing: 0.06em;
}

.pill-copy:hover {
  border-color: var(--accent);
}

.meta-item {
  font-size: 12px;
  color: var(--text-muted);
}

/* Table Stage */
.table-stage {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 24px 16px;
  overflow: hidden;
}

.poker-table {
  position: relative;
  width: min(920px, 92vw);
  height: min(500px, 66vh);
}

.table-felt {
  position: absolute;
  inset: 52px 72px;
  border-radius: 999px;
  background: radial-gradient(ellipse at center, var(--felt-center) 0%, var(--felt-edge) 100%);
  border: 2px solid var(--felt-border);
  box-shadow:
    inset 0 0 60px rgba(0, 0, 0, 0.45),
    0 20px 60px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
}

.board-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  z-index: 2;
}

.pot-display {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  padding: 5px 14px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.pot-label {
  font-size: 11px;
  color: var(--text-muted);
}

.pot-amount {
  font-size: 16px;
  font-weight: 600;
  color: var(--amber);
  font-variant-numeric: tabular-nums;
}

.side-pots {
  display: flex;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
}

.side-pot-tag {
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border);
}

.community-cards {
  display: flex;
  gap: 8px;
  min-height: 76px;
  align-items: center;
}

.table-status {
  min-height: 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
}

.status-banner {
  font-size: 13px;
  color: var(--text);
  background: rgba(11, 14, 19, 0.72);
  padding: 5px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
}

.status-banner strong {
  color: var(--accent);
}

/* Playing Cards */
.card {
  width: 52px;
  height: 74px;
  border-radius: 7px;
  background: #f8fafc;
  color: #111827;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 5px 6px;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  user-select: none;
  position: relative;
}

.card.red {
  color: #dc2626;
}

.card.mini {
  width: 38px;
  height: 54px;
  padding: 3px 4px;
  border-radius: 5px;
}

.card.self-card {
  width: 48px;
  height: 68px;
}

.card-corner {
  display: flex;
  flex-direction: column;
  align-items: center;
  align-self: flex-start;
  line-height: 1.05;
  gap: 2px;
}

.card-rank {
  font-size: 16px;
  letter-spacing: -0.04em;
}

.card-suit {
  font-size: 15px;
}

.card.self-card .card-rank {
  font-size: 15px;
}

.card.self-card .card-suit {
  font-size: 14px;
}

.card.mini .card-rank {
  font-size: 12px;
}

.card.mini .card-suit {
  font-size: 11px;
}

.card.back {
  background: linear-gradient(135deg, #1d2736 0%, #111824 100%);
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.card.back::after {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.card.slot {
  background: rgba(255, 255, 255, 0.03);
  border: 1px dashed rgba(255, 255, 255, 0.1);
  box-shadow: none;
}

.card.dimmed {
  opacity: 0.4;
}

/* Seats */
.seats-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.seat {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 140px;
}

.seat-empty {
  width: 110px;
  height: 56px;
  border-radius: 12px;
  border: 1px dashed rgba(255, 255, 255, 0.14);
  background: rgba(19, 24, 32, 0.55);
  color: var(--text-muted);
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.seat-empty:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(34, 197, 94, 0.08);
}

.seat-cards {
  display: flex;
  gap: 4px;
  margin-bottom: -10px;
  z-index: 2;
}

.seat-box {
  position: relative;
  min-width: 136px;
  padding: 12px 12px 8px;
  border-radius: 11px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.seat.is-turn .seat-box {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim), 0 8px 24px rgba(0, 0, 0, 0.45);
}

.seat.is-winner .seat-box {
  border-color: var(--amber);
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.22);
}

.seat.is-folded {
  opacity: 0.48;
}

.seat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
}

.seat-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 96px;
}

.seat-ai-tag {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-muted);
}

.seat-kick {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  opacity: 0.78;
}

.seat:hover .seat-kick {
  opacity: 1;
}

.seat-kick:hover {
  color: var(--danger);
  border-color: var(--danger);
  background: #2a171c;
}

.seat-chips {
  font-size: 12px;
  color: var(--amber);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: center;
  gap: 5px;
}

.seat-pending-rebuy {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 500;
}

.seat-sub {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-top: 4px;
  min-height: 16px;
}

.seat-action-tag {
  font-size: 11px;
  color: var(--text-muted);
}

.seat-hand-tag {
  font-size: 11px;
  color: var(--accent);
  font-weight: 500;
}

.seat-badges {
  position: absolute;
  top: -9px;
  left: 8px;
  display: flex;
  gap: 4px;
}

.badge {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  line-height: 1.4;
}

.badge-d {
  background: var(--amber);
  color: #111;
}

.badge-sb {
  background: #334155;
  color: #e2e8f0;
}

.badge-bb {
  background: #475569;
  color: #f8fafc;
}

.seat-bet-chip {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
  background: rgba(11, 14, 19, 0.82);
  border: 1px solid rgba(245, 158, 11, 0.4);
  color: var(--amber);
  font-variant-numeric: tabular-nums;
}

.seat-win-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
  background: rgba(34, 197, 94, 0.18);
  border: 1px solid var(--accent);
  color: var(--accent);
}

/* Action Bar */
.action-bar {
  min-height: 82px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}

.action-idle {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--text-muted);
}

.action-controls {
  width: 100%;
  max-width: 780px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.action-buttons {
  display: flex;
  gap: 10px;
}

.btn-fold {
  background: var(--danger-dim);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.3);
  min-width: 84px;
}

.btn-fold:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.26);
}

.btn-call {
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  color: var(--text);
  min-width: 108px;
}

.btn-call:hover:not(:disabled) {
  background: #242f3f;
}

.btn-raise {
  background: var(--accent);
  color: #06140c;
  font-weight: 600;
  min-width: 124px;
}

.btn-raise:hover:not(:disabled) {
  background: #34d36f;
}

.raise-panel {
  flex: 1;
  min-width: 240px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.quick-bets {
  display: flex;
  gap: 6px;
}

.chip-btn {
  flex: 1;
  padding: 4px 8px;
  font-size: 11px;
  border-radius: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.chip-btn:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.slider-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.slider-row input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
}

.raise-value {
  min-width: 48px;
  text-align: right;
  font-size: 13px;
  font-weight: 600;
  color: var(--amber);
  font-variant-numeric: tabular-nums;
}

/* Log Drawer */
.log-drawer {
  position: absolute;
  top: 12px;
  right: 12px;
  bottom: 12px;
  width: 290px;
  background: rgba(19, 24, 32, 0.96);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  z-index: 30;
  backdrop-filter: blur(8px);
}

.log-drawer-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-weight: 600;
}

.btn-icon {
  font-size: 18px;
  color: var(--text-muted);
  padding: 0 4px;
}

.log-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.log-entry {
  line-height: 1.45;
  padding-bottom: 5px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

/* Settlement Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 12, 0.72);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 80;
}

.modal-card {
  width: 100%;
  max-width: 520px;
  max-height: 84vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.modal-header h3 {
  font-size: 16px;
  font-weight: 600;
}

.modal-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
}

.settlement-warning {
  font-size: 12px;
  color: var(--amber);
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: 8px;
  padding: 8px 10px;
}

.settlement-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.settlement-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
}

.transfer-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.transfer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 9px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 13px;
}

.transfer-route {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.transfer-arrow {
  color: var(--text-muted);
  font-size: 12px;
}

.transfer-amount {
  font-weight: 700;
  color: var(--amber);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.ledger-table {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 9px;
  overflow: hidden;
  font-size: 12px;
}

.ledger-row {
  display: grid;
  grid-template-columns: 1.4fr 0.7fr 0.8fr 0.8fr 1fr;
  align-items: center;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  font-variant-numeric: tabular-nums;
}

.ledger-row:last-child {
  border-bottom: none;
}

.ledger-head {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-muted);
  font-weight: 500;
}

.ledger-num {
  text-align: right;
}

.voter-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.voter-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  border-radius: 9px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 13px;
}

.voter-status {
  font-size: 12px;
  color: var(--text-muted);
}

.voter-status.approved {
  color: var(--accent);
  font-weight: 500;
}

.vote-actions {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}

.vote-actions .btn {
  flex: 1;
}

.btn-queued {
  border-color: rgba(245, 158, 11, 0.5) !important;
  color: var(--amber) !important;
}

/* Toast */
.toast {
  position: fixed;
  top: 66px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13px;
  z-index: 100;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

@media (max-width: 720px) {
  .topbar {
    padding: 0 10px;
  }
  .meta-item {
    display: none;
  }
  .table-felt {
    inset: 42px 20px;
  }
  .seat-box {
    min-width: 108px;
    padding: 10px 8px 6px;
  }
  .card {
    width: 42px;
    height: 60px;
  }
}
