/* PokerSports mobile client — dark luxury theme */
:root {
  --bg0: #0a0e0c;
  --bg1: #111813;
  --bg2: #17211a;
  --felt: #1c5c3c;
  --felt-dark: #124a30;
  --felt-light: #2a7a51;
  --gold: #d8b45a;
  --gold-dim: #a8863c;
  --text: #f2eee3;
  --muted: #9aa89e;
  --danger: #e2574c;
  --green: #35c07a;
  --card-w: 12.5vw;
  --card-h: 17.4vw;
  --radius: 16px;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background:
    radial-gradient(1200px 700px at 50% -10%, rgba(42, 122, 81, 0.22), transparent 60%),
    radial-gradient(900px 500px at 50% 110%, rgba(216, 180, 90, 0.07), transparent 60%),
    var(--bg0);
  color: var(--text);
  overflow-x: hidden;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.8rem; }
.center { text-align: center; }
.view { min-height: 100dvh; display: flex; flex-direction: column; }

/* ---------- buttons ---------- */
.btn {
  font: inherit;
  border: 1px solid rgba(216, 180, 90, 0.35);
  border-radius: 12px;
  padding: 12px 16px;
  background: linear-gradient(180deg, rgba(216, 180, 90, 0.16), rgba(216, 180, 90, 0.05));
  color: var(--text);
  cursor: pointer;
  transition: transform 0.08s ease, filter 0.15s ease;
  user-select: none;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; }
.btn-primary {
  background: linear-gradient(180deg, #e8c86e, #c59a3f);
  color: #221703;
  font-weight: 700;
  border-color: #f0d792;
}
.btn-danger {
  background: linear-gradient(180deg, #e2574c, #b13a31);
  color: #fff;
  border-color: #ef7a70;
}
.btn-ghost { background: transparent; border-color: rgba(255, 255, 255, 0.18); }
.btn-sm { padding: 8px 12px; font-size: 0.85rem; border-radius: 10px; }
.btn-block { width: 100%; }

/* ---------- login ---------- */
#view-login { align-items: center; justify-content: center; padding: 24px 20px calc(24px + var(--sab)); }
.login-wrap { width: 100%; max-width: 420px; }
.brand { text-align: center; margin-bottom: 26px; }
.brand h1 { margin: 10px 0 2px; font-size: 1.9rem; letter-spacing: 0.5px; }
.brand-mark {
  width: 64px; height: 64px; margin: 0 auto; border-radius: 18px;
  background: linear-gradient(145deg, #d8b45a, #8a6d2c);
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem; color: #241703; box-shadow: var(--shadow);
}
.brand-mark.small { width: 34px; height: 34px; border-radius: 10px; font-size: 1.1rem; margin: 0; }
.form-card { padding: 20px; display: flex; flex-direction: column; gap: 10px; }
.card {
  background: linear-gradient(180deg, var(--bg2), var(--bg1));
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
label { font-size: 0.85rem; color: var(--muted); display: block; margin-top: 6px; }
input[type="text"], input[type="password"], input[type="number"], input[type="search"] {
  font: inherit;
  width: 100%;
  padding: 13px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  outline: none;
}
input:focus { border-color: var(--gold); }
.error-text { color: var(--danger); font-size: 0.85rem; text-align: center; }

/* ---------- topbar / lobby ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
  padding: calc(10px + var(--sat)) 14px 10px;
  background: linear-gradient(180deg, rgba(23, 33, 26, 0.95), rgba(23, 33, 26, 0.75));
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 30;
}
.topbar-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar-title { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.topbar-title strong { font-size: 1.02rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.center-col { align-items: center; text-align: center; flex: 1; }
.topbar-actions { display: flex; gap: 8px; }

.lobby-main { flex: 1; padding: 14px 14px calc(20px + var(--sab)); max-width: 760px; width: 100%; margin: 0 auto; }
.lobby-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.lobby-head h2 { margin: 0; font-size: 1.25rem; }
.pill {
  font-size: 0.72rem; padding: 5px 11px; border-radius: 999px;
  background: rgba(216, 180, 90, 0.13); color: var(--gold); border: 1px solid rgba(216, 180, 90, 0.3);
}
.pill.on { color: var(--green); border-color: rgba(53, 192, 122, 0.4); background: rgba(53, 192, 122, 0.1); }
.table-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }

.table-card {
  display: flex; align-items: center; gap: 14px;
  padding: 14px;
  border-left: 3px solid var(--gold-dim);
  transition: transform 0.1s ease;
}
.table-card:active { transform: scale(0.99); }
.table-card .tc-main { flex: 1; min-width: 0; }
.table-card .tc-name { font-weight: 700; font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.table-card .tc-meta { font-size: 0.82rem; color: var(--muted); margin-top: 3px; display: flex; flex-wrap: wrap; gap: 4px 10px; }
.tc-seats { display: flex; align-items: center; gap: 5px; font-size: 0.85rem; color: var(--muted); }
.seat-dots { display: inline-flex; gap: 3px; }
.seat-dots i {
  width: 8px; height: 8px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.25);
}
.seat-dots i.filled { background: var(--gold); border-color: #f0d792; }
.tc-buy { font-size: 0.78rem; color: var(--gold-dim); margin-top: 4px; }
.tc-action { display: flex; flex-direction: column; align-items: stretch; gap: 6px; }
.badge-wait {
  font-size: 0.68rem; text-align: center; color: var(--muted);
  border: 1px dashed rgba(255, 255, 255, 0.22); border-radius: 8px; padding: 2px 6px;
}
.empty-card { padding: 40px 16px; }

/* ---------- table stage ---------- */
#view-table { position: fixed; inset: 0; background: radial-gradient(120% 90% at 50% 0%, #14261b 0%, #0b120d 65%); z-index: 10; }
.table-topbar { position: relative; }
.table-stage {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 6px 4px 0; min-height: 0;
  touch-action: manipulation;
}
.table-surface {
  position: relative;
  width: min(100vw, 120vh);
  aspect-ratio: 16 / 10;
  max-height: 100%;
  border-radius: 50% / 46%;
  background:
    radial-gradient(ellipse at 50% 42%, rgba(255, 255, 255, 0.10), transparent 55%),
    radial-gradient(ellipse at 50% 50%, var(--felt-light) 0%, var(--felt) 55%, var(--felt-dark) 100%);
  box-shadow:
    inset 0 0 0 clamp(6px, 1.4vw, 16px) #3a2b18,
    inset 0 0 0 clamp(8px, 1.8vw, 20px) #57432a,
    inset 0 0 clamp(30px, 5vw, 80px) rgba(0, 0, 0, 0.5),
    0 14px 60px rgba(0, 0, 0, 0.6);
  border: 2px solid rgba(216, 180, 90, 0.4);
}
.seats { position: absolute; inset: 0; }

.seat {
  position: absolute; transform: translate(-50%, -50%);
  width: clamp(58px, 15.5vw, 104px);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  z-index: 3;
}
.seat .avatar {
  width: clamp(34px, 9.2vw, 60px); height: clamp(34px, 9.2vw, 60px);
  border-radius: 50%;
  background: linear-gradient(150deg, #4b5d52, #2c3a32);
  border: 2px solid rgba(216, 180, 90, 0.55);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: clamp(0.85rem, 2.6vw, 1.25rem);
  color: #f0d792; overflow: hidden;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
}
.seat.mine .avatar { border-color: #fff; box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.25), 0 4px 14px rgba(0, 0, 0, 0.5); }
.seat.acting .avatar { animation: pulse 1.1s ease-in-out infinite; border-color: #ffe08a; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(255, 224, 138, 0.7); } 50% { box-shadow: 0 0 0 8px rgba(255, 224, 138, 0); } }
.seat .pname {
  max-width: 100%; font-size: clamp(0.6rem, 1.9vw, 0.8rem);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  background: rgba(0, 0, 0, 0.55); padding: 1px 8px; border-radius: 999px;
}
.seat .stack { font-size: clamp(0.62rem, 1.9vw, 0.82rem); font-weight: 700; color: #ffe9ad; }
.seat .action-tag {
  font-size: clamp(0.52rem, 1.6vw, 0.7rem);
  background: rgba(0, 0, 0, 0.6); color: #ffd987;
  padding: 1px 7px; border-radius: 999px; max-width: 100%; white-space: nowrap; overflow: hidden;
}
.seat .timer {
  width: 70%; height: 3px; border-radius: 3px; background: rgba(0, 0, 0, 0.5);
  overflow: hidden; margin-top: 1px;
}
.seat .timer i { display: block; height: 100%; background: linear-gradient(90deg, #ffe08a, #e2574c); }
.seat .cards { display: flex; gap: 1px; margin-top: 2px; justify-content: center; }
.seat.empty .avatar {
  border-style: dashed; background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.35); font-size: 1.4rem; cursor: default;
}
.seat.empty { opacity: 0.75; }

/* cards */
.card-face {
  position: relative;
  width: clamp(26px, 7vw, 44px);
  aspect-ratio: 0.72;
  border-radius: 18%;
  background: linear-gradient(160deg, #ffffff, #e8e6df);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45), inset 0 0 0 1px rgba(0, 0, 0, 0.2);
  color: #1b1b1b;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; overflow: hidden;
}
.card-face.red { color: #c62f2f; }
.card-face .rank { font-size: clamp(0.7rem, 2.4vw, 1.15rem); line-height: 1; }
.card-face .suit { font-size: clamp(0.55rem, 2vw, 1rem); line-height: 1; margin-top: -2px; }
.card-face.mini { width: clamp(20px, 5.4vw, 32px); }
.card-back {
  background:
    repeating-linear-gradient(45deg, #26307a 0 4px, #1a2258 4px 8px);
  border: 2px solid #d8b45a;
}
.card-placeholder {
  border: 1px dashed rgba(255, 255, 255, 0.35); background: rgba(0, 0, 0, 0.25); color: transparent;
}
.dealer-btn {
  position: absolute; z-index: 4;
  width: clamp(16px, 4vw, 26px); aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff, #cfc6ad 60%, #9c927a);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
  display: flex; align-items: center; justify-content: center;
  font-size: clamp(0.5rem, 1.5vw, 0.75rem); font-weight: 800; color: #3a2f14;
  transform: translate(-50%, -50%);
}

/* board + pot */
.board {
  position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%);
  display: flex; gap: clamp(2px, 0.8vw, 6px); z-index: 2;
}
.pot-label {
  position: absolute; left: 50%; top: 62%; transform: translate(-50%, -50%);
  font-size: clamp(0.7rem, 2.2vw, 1rem); font-weight: 700; color: #ffe9ad;
  background: rgba(0, 0, 0, 0.5); padding: 2px 12px; border-radius: 999px; z-index: 2;
  text-shadow: 0 1px 2px #000;
}
.table-msg {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  font-size: clamp(0.65rem, 2.2vw, 0.95rem); color: rgba(255, 255, 255, 0.85);
  background: rgba(0, 0, 0, 0.45); padding: 3px 14px; border-radius: 999px;
  z-index: 2; white-space: nowrap;
}
.bet-chip {
  position: absolute; z-index: 3; transform: translate(-50%, 50%);
  display: flex; flex-direction: column; align-items: center; gap: 1px;
}
.bet-chip .chips { display: flex; flex-direction: column-reverse; align-items: center; }
.chip {
  width: clamp(14px, 3.6vw, 24px); aspect-ratio: 1; border-radius: 50%;
  border: clamp(2px, 0.6vw, 3px) dashed rgba(0, 0, 0, 0.35);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  position: relative;
}
.chip + .chip { margin-top: -55%; }
.chip.c1 { background: #d8b45a; } .chip.c2 { background: #9c3b2e; }
.chip.c3 { background: #2f6f9f; } .chip.c4 { background: #3a7d4c; }
.chip.c5 { background: #6d4f9e; } .chip.c6 { background: #55483a; }
.bet-chip .betamt { font-size: clamp(0.6rem, 1.8vw, 0.8rem); font-weight: 700; color: #ffe9ad; text-shadow: 0 1px 2px #000; }

/* ---------- action dock ---------- */
.action-dock {
  padding: 8px 10px calc(10px + var(--sab));
  background: linear-gradient(180deg, rgba(10, 14, 12, 0.4), rgba(10, 14, 12, 0.92));
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex; flex-direction: column; gap: 8px;
}
.raise-bar { display: flex; flex-direction: column; gap: 6px; }
.raise-row { display: flex; align-items: center; gap: 8px; }
.raise-input { flex: 0 0 84px; text-align: center; padding: 9px 6px !important; }
.raise-slider { flex: 1; accent-color: var(--gold); height: 34px; }
.quick-bets { display: flex; gap: 6px; }
.quick-bets .btn { flex: 1; padding: 8px 4px; font-size: 0.78rem; }
.action-buttons { display: flex; gap: 8px; }
.action-buttons .btn { flex: 1; padding: 15px 6px; font-size: 1rem; font-weight: 700; }
.action-buttons .btn.danger { flex: 0 0 30%; }

/* ---------- sheets / chat / toast ---------- */
.sheet {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(0, 0, 0, 0.55);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet-card {
  width: 100%; max-width: 480px; padding: 18px;
  border-radius: 22px 22px 0 0; margin-bottom: 0;
  padding-bottom: calc(18px + var(--sab));
  animation: rise 0.18s ease;
}
@keyframes rise { from { transform: translateY(30px); opacity: 0.4; } to { transform: none; opacity: 1; } }
.sheet h3 { margin: 0 0 6px; }
.buyin-opts { display: flex; gap: 8px; margin: 12px 0; flex-wrap: wrap; }
.radio-pill input { display: none; }
.radio-pill span {
  display: inline-block; padding: 10px 18px; border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.2); color: var(--muted); cursor: pointer;
}
.radio-pill input:checked + span { background: var(--gold); color: #221703; font-weight: 700; border-color: #f0d792; }
.buyin-other { margin-top: 4px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; margin: 8px 0 14px; color: var(--text); }
.checkbox-row input { width: 20px; height: 20px; accent-color: var(--gold); }
.sheet-actions { display: flex; gap: 10px; }
.sheet-actions .btn { flex: 1; }

.chat-panel {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 55;
  max-height: 55dvh; display: flex; flex-direction: column;
  background: linear-gradient(180deg, rgba(17, 24, 19, 0.98), rgba(10, 14, 12, 0.99));
  border-top: 1px solid rgba(216, 180, 90, 0.35);
  border-radius: 18px 18px 0 0;
}
.chat-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid rgba(255, 255, 255, 0.08); }
.chat-log { flex: 1; overflow-y: auto; padding: 10px 14px; font-size: 0.9rem; display: flex; flex-direction: column; gap: 6px; }
.chat-line .who { font-weight: 700; color: var(--gold); }
.chat-line.dealer { color: var(--muted); font-style: italic; }
.chat-input-row { display: flex; gap: 8px; padding: 8px 12px calc(10px + var(--sab)); }

.toast {
  position: fixed; left: 50%; top: calc(58px + var(--sat)); transform: translateX(-50%);
  background: rgba(10, 14, 12, 0.95); border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text); padding: 10px 18px; border-radius: 999px;
  z-index: 90; box-shadow: var(--shadow); font-size: 0.9rem; max-width: 86vw; text-align: center;
}
.table-menu-pop {
  position: fixed; right: 12px; top: calc(54px + var(--sat)); z-index: 70;
  background: var(--bg2); border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; min-width: 200px;
}
.table-menu-pop button {
  display: block; width: 100%; text-align: left; padding: 13px 16px;
  background: transparent; color: var(--text); border: 0; border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font: inherit; font-size: 0.92rem; cursor: pointer;
}
.table-menu-pop button:active { background: rgba(255, 255, 255, 0.06); }

/* landscape / wider screens */
@media (min-aspect-ratio: 4/3) {
  .table-stage { padding: 2px 2px 0; }
  .seat .avatar { width: clamp(38px, 8vw, 72px); height: clamp(38px, 8vw, 72px); }
  .search-wrap { max-width: 560px; }
}
@media (min-width: 720px) {
  .table-grid { grid-template-columns: 1fr 1fr; }
}
