/* ── Reset ──────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Telegram theme variables ───────────────────────────────────────────────── */
:root {
  --bg:           var(--tg-theme-bg-color,           #1b2a1b);
  --text:         var(--tg-theme-text-color,          #e8f5e9);
  --btn:          var(--tg-theme-button-color,        #2e7d32);
  --btn-text:     var(--tg-theme-button-text-color,   #ffffff);
  --secondary-bg: var(--tg-theme-secondary-bg-color,  #14201f);
  --hint:         var(--tg-theme-hint-color,          #81c784);
  --link:         var(--tg-theme-link-color,          #4caf50);

  --table-felt:   #153920;
  --table-rim:    #0d1f10;
  --card-radius:  7px;
  --card-w:       50px;
  --card-h:       70px;
  --seat-size:    52px;
  --gold:         #ffd600;
  --red-suit:     #d32f2f;
  --black-suit:   #1a1a1a;
  --pot-color:    #a5d6a7;
  --bet-chip:     #fff59d;
  --fold-bg:      #b71c1c;
  --check-bg:     #1b5e20;
  --call-bg:      #0d47a1;
  --raise-bg:     #e65100;
  --card-back-bg: #1a237e;
  --card-back-border: #3949ab;

  --min-touch: 44px;
}

@media (prefers-color-scheme: light) {
  :root:not([data-tg-theme]) {
    --bg:           #1b2a1b;
    --text:         #e8f5e9;
    --btn:          #2e7d32;
    --btn-text:     #ffffff;
    --secondary-bg: #14201f;
    --hint:         #81c784;
    --link:         #4caf50;
  }
}

/* ── Base ───────────────────────────────────────────────────────────────────── */
html {
  height: 100%;
  padding: env(safe-area-inset-top)
           env(safe-area-inset-right)
           env(safe-area-inset-bottom)
           env(safe-area-inset-left);
}

body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* ── Screens ────────────────────────────────────────────────────────────────── */
.screen { display: none; position: fixed; inset: 0; overflow: hidden; }
.screen.active {
  display: flex;
  flex-direction: column;
  animation: screenFadeIn 0.22s ease forwards;
}

@keyframes screenFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Shared button base ─────────────────────────────────────────────────────── */
.btn {
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  min-height: var(--min-touch);
  padding: 0 18px;
  cursor: pointer;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active  { transform: scale(0.97); opacity: 0.85; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none !important; }

.btn-primary   { background: var(--btn);  color: var(--btn-text); }
.btn-secondary {
  background: rgba(255,255,255,0.1);
  color: var(--text);
  border: 1.5px solid rgba(255,255,255,0.15);
}

/* Small button variant */
.btn-sm {
  min-height: 36px;
  font-size: 13px;
  padding: 0 14px;
  width: auto;
}

/* ── LOGIN SCREEN ───────────────────────────────────────────────────────────── */

/* ── LOBBY SCREEN ───────────────────────────────────────────────────────────── */
#lobby-screen {
  background:
    repeating-linear-gradient(
      -45deg,
      transparent 0px, transparent 3px,
      rgba(255,255,255,0.012) 3px, rgba(255,255,255,0.012) 4px
    ),
    repeating-linear-gradient(
      45deg,
      transparent 0px, transparent 3px,
      rgba(255,255,255,0.008) 3px, rgba(255,255,255,0.008) 4px
    ),
    var(--bg);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.lobby-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  padding-top: calc(16px + env(safe-area-inset-top, 0px));
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
  gap: 10px;
}

.lobby-title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.3px;
  padding-left: 10px;
  border-left: 3px solid var(--gold);
}

.lobby-player-info {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  min-width: 0;
}

.lobby-username {
  font-size: 13px;
  color: var(--hint);
  font-weight: 600;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lobby-balance {
  font-size: 12px;
  font-weight: 700;
  color: #66bb6a;
  letter-spacing: 0.2px;
}

/* ── Lobby header right side ─────────────────────────────────────────────── */
.lobby-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.lobby-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  border: 1.5px solid rgba(255,255,255,0.1);
  color: var(--text);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.icon-btn:active { background: rgba(255,255,255,0.16); transform: scale(0.92); }

/* ── Sub-screens (profile, leaderboard) ──────────────────────────────────── */
#profile-screen,
#leaderboard-screen {
  background: var(--bg);
  flex-direction: column;
}

.sub-screen-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  background: rgba(0,0,0,0.25);
  border-bottom: 1px solid rgba(255,255,255,0.07);
  flex-shrink: 0;
}
.sub-screen-header h2 {
  font-size: 18px;
  font-weight: 700;
}

.sub-screen-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: env(safe-area-inset-bottom, 16px);
}

/* ── Profile stats grid ───────────────────────────────────────────────────── */
.profile-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  padding: 16px 16px 8px;
}

.stat-card {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 14px;
  padding: 16px 12px;
  text-align: center;
}

.stat-value {
  font-size: 22px;
  font-weight: 800;
  color: #66bb6a;
  letter-spacing: -0.5px;
}

.stat-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--hint);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ── Daily bonus button ───────────────────────────────────────────────────── */
.bonus-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: calc(100% - 32px);
  margin: 12px 16px;
  padding: 14px 20px;
  background: linear-gradient(135deg, #c850c0 0%, #f5576c 100%);
  color: #fff;
  border: none;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.bonus-btn:active { opacity: 0.85; transform: scale(0.97); }
.bonus-btn:disabled {
  background: rgba(255,255,255,0.08);
  border: 1.5px solid rgba(255,255,255,0.1);
  color: var(--hint);
  cursor: not-allowed;
  transform: none;
}

.bonus-timer {
  font-size: 13px;
  font-weight: 600;
  opacity: 0.85;
}

/* ── Transaction list ─────────────────────────────────────────────────────── */
.section-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--hint);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 8px 16px 6px;
}

.transactions-list {
  padding-bottom: 8px;
}

.transaction-item {
  display: grid;
  grid-template-columns: 24px 1fr auto auto;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}

.tx-icon  { font-size: 16px; text-align: center; }
.tx-desc  { font-size: 13px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-amount { font-size: 13px; font-weight: 700; white-space: nowrap; }
.tx-amount.positive { color: #66bb6a; }
.tx-amount.negative { color: #ef5350; }
.tx-date  { font-size: 11px; color: var(--hint); white-space: nowrap; }

.tx-empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--hint);
  font-size: 13px;
}

/* ── Leaderboard ──────────────────────────────────────────────────────────── */
.leaderboard-list {
  padding-top: 8px;
}

.leaderboard-item {
  display: grid;
  grid-template-columns: 36px 1fr auto auto;
  align-items: center;
  gap: 8px;
  padding: 11px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  transition: background 0.1s;
}
.leaderboard-item.me {
  background: rgba(76,175,80,0.1);
  border-left: 3px solid #66bb6a;
}

.lb-rank { font-size: 18px; text-align: center; }
.lb-name { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-chips { font-size: 13px; font-weight: 700; color: #ffd600; white-space: nowrap; }
.lb-wr   { font-size: 11px; color: var(--hint); white-space: nowrap; }

.lb-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--hint);
  font-size: 13px;
}

/* My table banner */
.my-table-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 12px 16px 0;
  padding: 12px 16px;
  background: rgba(46,125,50,0.18);
  border: 1.5px solid rgba(76,175,80,0.4);
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--link);
  flex-shrink: 0;
}
.my-table-banner.hidden { display: none !important; }

/* Tables list */
.tables-list {
  padding: 12px 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tables-empty {
  color: var(--hint);
  font-size: 13px;
  text-align: center;
  padding: 32px 0;
}
.tables-empty::before {
  content: '♠  ♥  ♦  ♣';
  display: block;
  font-size: 28px;
  color: rgba(255,255,255,0.06);
  margin-bottom: 12px;
  letter-spacing: 10px;
}

/* Table card */
.table-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: linear-gradient(160deg, rgba(255,255,255,0.05) 0%, var(--secondary-bg) 40%);
  border-radius: 16px;
  padding: 14px 16px;
  border: 1.5px solid rgba(255,255,255,0.09);
  box-shadow: 0 2px 8px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.04);
  transition: border-color 0.2s, box-shadow 0.15s, transform 0.1s;
}
.table-card:active {
  transform: scale(0.985);
  box-shadow: 0 1px 4px rgba(0,0,0,0.35);
  opacity: 1;
}

.table-card-mine {
  border-color: rgba(76,175,80,0.4);
  background: rgba(46,125,50,0.12);
}

.table-card-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.table-name {
  font-size: 16px;
  font-weight: 700;
}

.table-players {
  font-size: 12px;
  color: var(--hint);
}

.table-status {
  font-size: 11px;
  font-weight: 600;
  margin-top: 2px;
}
.status-waiting  { color: var(--hint); }
.status-starting { color: var(--gold); }
.status-playing  { color: #ef9a9a; }

.table-card-action {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex-shrink: 0;
}

.table-badge-here {
  font-size: 10px;
  font-weight: 700;
  color: var(--link);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.table-pips {
  display: flex;
  gap: 4px;
  margin-top: 5px;
}
.table-pip {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}
.table-pip.filled {
  background: var(--link);
  border-color: rgba(76,175,80,0.4);
  box-shadow: 0 0 4px rgba(76,175,80,0.35);
}


/* ── TABLE VIEW SCREEN ──────────────────────────────────────────────────────── */
#table-view-screen {
  flex-direction: column;
  background: var(--bg);
  overflow: clip;
}

.tv-header {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  background: rgba(0,0,0,0.3);
  backdrop-filter: blur(6px);
  flex-shrink: 0;
  min-height: 52px;
}

.btn-back {
  background: none;
  border: none;
  color: var(--text);
  font-size: 22px;
  cursor: pointer;
  padding: 4px 8px;
  min-width: 40px;
  min-height: 40px;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-back:active { opacity: 0.65; }

.tv-header-center {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  overflow: hidden;
}

.tv-header-center h2 {
  font-size: 17px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.tv-status-badge {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.4px;
}

.btn-tv-leave {
  background: rgba(183,28,28,0.4);
  border: 1px solid rgba(183,28,28,0.6);
  border-radius: 7px;
  color: #ef9a9a;
  font-size: 11px;
  font-weight: 700;
  padding: 5px 10px;
  cursor: pointer;
  min-height: 28px;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.15s;
}
.btn-tv-leave:active { opacity: 0.65; }

.tv-table-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tv-table-oval {
  position: relative;
  width: min(82vw, 340px);
  aspect-ratio: 1.6;
  background: radial-gradient(ellipse at center, #1e5c2e 0%, var(--table-felt) 65%, var(--table-rim) 100%);
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.1);
  box-shadow: 0 8px 40px rgba(0,0,0,0.6);
  overflow: visible;
}

.tv-center-info {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

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

.tv-pot-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--pot-color);
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
}

.tv-hand-num {
  font-size: 10px;
  color: rgba(255,255,255,0.4);
}

/* Seat positions around the oval */
.tv-seat {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
}

#tv-seat-0 { bottom: -32px; left: 50%; transform: translateX(-50%); }
#tv-seat-1 { bottom: 4%;   left: -12px; }
#tv-seat-2 { top: 50%;    left: -12px; transform: translateY(-50%); }
#tv-seat-3 { top: -32px;  left: 7%; }
#tv-seat-4 { top: -32px;  right: 7%; }
#tv-seat-5 { top: 50%;    right: -12px; transform: translateY(-50%); }

.tv-seat-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  cursor: default;
  background: rgba(0,0,0,0.55);
  border: 1.5px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  padding: 6px 8px;
  min-width: 68px;
  max-width: 80px;
  text-align: center;
  backdrop-filter: blur(4px);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.tv-seat-card.tv-seat-empty {
  border-style: dashed;
  border-color: rgba(255,255,255,0.2);
  cursor: pointer;
}
.tv-seat-card.tv-seat-empty:active { opacity: 0.7; }

.tv-seat-card.tv-seat-active {
  border-color: rgba(255,255,255,0.25);
}

.tv-seat-card.tv-seat-current {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(255,214,0,0.35);
}

.tv-seat-card.tv-seat-folded {
  opacity: 0.35;
  filter: grayscale(0.5);
}

.tv-seat-card.tv-seat-me {
  border-color: var(--btn);
  background: rgba(46,125,50,0.25);
}

.tv-seat-card.tv-seat-pending {
  border-color: rgba(255,214,0,0.4);
  background: rgba(255,214,0,0.08);
}

.tv-seat-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  border: 1.5px solid rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
}

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

.tv-seat-chips {
  font-size: 9px;
  color: var(--hint);
}

.tv-seat-badge {
  font-size: 8px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.tv-dealer-badge {
  color: var(--gold);
}

.tv-pending-badge {
  color: var(--gold);
  font-size: 9px;
}

.btn-sit-here {
  background: var(--btn);
  color: var(--btn-text);
  border: none;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 700;
  padding: 5px 10px;
  cursor: pointer;
  min-height: 28px;
  margin-top: 2px;
  -webkit-tap-highlight-color: transparent;
}
.btn-sit-here:active { opacity: 0.75; }

.tv-waiting-banner {
  margin: 8px 16px;
  padding: 10px 16px;
  background: rgba(255,214,0,0.1);
  border: 1.5px solid rgba(255,214,0,0.3);
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--gold);
  text-align: center;
  flex-shrink: 0;
}
.tv-waiting-banner.hidden { display: none; }

/* ── MODAL OVERLAY ──────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.15s ease;
}
.modal-overlay.hidden { display: none !important; }

.modal-box {
  background: var(--secondary-bg);
  border-radius: 18px;
  padding: 24px 24px 20px;
  width: min(320px, 88vw);
  box-shadow: 0 12px 48px rgba(0,0,0,0.6);
  border: 1.5px solid rgba(255,255,255,0.08);
  animation: popIn 0.2s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.modal-box h3 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
  text-align: center;
}

.modal-msg {
  font-size: 13px;
  color: var(--hint);
  text-align: center;
  margin-bottom: 20px;
  line-height: 1.4;
}

.modal-actions {
  display: flex;
  gap: 10px;
}

/* ── Small community card variants for TV center ────────────────────────────── */
.tv-card-mini {
  width: 28px;
  height: 40px;
  border-radius: 4px;
  background: #fff;
  border: 1px solid rgba(0,0,0,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 800;
}
.tv-card-mini.red   { color: var(--red-suit); }
.tv-card-mini.black { color: var(--black-suit); }

.tv-card-back-mini {
  width: 28px;
  height: 40px;
  border-radius: 4px;
  background: var(--card-back-bg);
  border: 1px solid var(--card-back-border);
}

/* ── GAME SCREEN ────────────────────────────────────────────────────────────── */
#game-screen {
  background: radial-gradient(ellipse 90% 80% at 50% 45%,
    #1e5c2e 0%, var(--table-felt) 65%, var(--table-rim) 100%);
  flex-direction: column;
  height: 100%;
  height: 100dvh;
  max-height: 100dvh;
}

/* Stage bar */
#stage-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(6px);
  flex-shrink: 0;
  gap: 8px;
  min-height: 40px;
}
.stage-name {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: #000;
  background: var(--gold);
  padding: 3px 10px;
  border-radius: 20px;
  flex-shrink: 0;
}
.pot-display {
  font-size: 14px;
  font-weight: 700;
  color: var(--pot-color);
}
.bet-display {
  font-size: 12px;
  color: var(--hint);
  flex: 1;
  text-align: center;
}
.btn-leave-game {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 7px;
  color: rgba(255,255,255,0.38);
  font-size: 10px;
  font-weight: 700;
  padding: 4px 9px;
  cursor: pointer;
  min-height: 26px;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.15s, border-color 0.15s;
}
.btn-leave-game:active {
  color: #ef9a9a;
  border-color: rgba(183,28,28,0.5);
  opacity: 1;
}

/* Players area */
#players-area {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
#players-area::before {
  content: '';
  position: absolute;
  inset: 8px 4px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.06);
  pointer-events: none;
  z-index: 1;
}

/* Community cards */
#community-area {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  z-index: 2;
}
.community-cards { display: flex; gap: 4px; }
.hand-number { font-size: 10px; color: rgba(255,255,255,0.35); text-align: center; }

/* Seat positions */
.seat {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
}
.seat-pos-bottom    { bottom: 4px;  left: 50%;  transform: translateX(-50%); }
.seat-pos-bot-left  { bottom: 14%;  left: 4%;   }
.seat-pos-mid-left  { top:  50%;    left: 1%;   transform: translateY(-50%); }
.seat-pos-top-left  { top:  6%;     left: 7%;   }
.seat-pos-top-right { top:  6%;     right: 7%;  }
.seat-pos-mid-right { top:  50%;    right: 1%;  transform: translateY(-50%); }

.seat-empty {
  width: var(--seat-size);
  height: var(--seat-size);
  border-radius: 50%;
  border: 1.5px dashed rgba(255,255,255,0.13);
}

.seat-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  position: relative;
  transition: opacity 0.3s;
}
.seat-inner.seat-folded { opacity: 0.3; filter: grayscale(0.5); }
.seat-inner.seat-active .avatar {
  box-shadow: 0 0 0 3px var(--gold), 0 0 16px rgba(255,214,0,0.55);
}

.avatar {
  width: var(--seat-size);
  height: var(--seat-size);
  border-radius: 50%;
  background: rgba(255,255,255,0.13);
  border: 2px solid rgba(255,255,255,0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  transition: box-shadow 0.3s;
}
.seat-me .avatar {
  background: rgba(46,125,50,0.35);
  border-color: var(--btn);
}

.seat-name {
  font-size: 10px;
  font-weight: 600;
  color: var(--text);
  max-width: 66px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
  text-shadow: 0 1px 4px rgba(0,0,0,0.9);
}
.seat-chips {
  font-size: 9px;
  color: var(--hint);
  text-shadow: 0 1px 4px rgba(0,0,0,0.9);
}
.seat-bet {
  font-size: 9px;
  font-weight: 700;
  color: var(--bet-chip);
  text-shadow: 0 1px 4px rgba(0,0,0,0.9);
}

.dealer-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--gold);
  color: #000;
  font-size: 10px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 4;
  box-shadow: 0 1px 4px rgba(0,0,0,0.5);
}
.allin-badge {
  font-size: 8px;
  font-weight: 700;
  color: #ff5252;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* Mini opponent cards */
.seat-cards { display: flex; gap: 2px; margin-top: 3px; }
.mini-card {
  width: 20px;
  height: 28px;
  border-radius: 3px;
  font-size: 8px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.mini-card.card-face          { background: #fff; border: 1px solid rgba(0,0,0,0.1); }
.mini-card.card-face.red      { color: var(--red-suit);   }
.mini-card.card-face.black    { color: var(--black-suit); }
.mini-card.card-back {
  background: var(--card-back-bg);
  border: 1px solid var(--card-back-border);
  position: relative;
  overflow: hidden;
}
.mini-card.card-back::after {
  content: '';
  position: absolute;
  inset: 2px;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 2px;
  pointer-events: none;
}

/* ── CARDS ──────────────────────────────────────────────────────────────────── */
.card-slot {
  width: var(--card-w);
  height: var(--card-h);
  border-radius: var(--card-radius);
  background: rgba(0,0,0,0.32);
  border: none;
  box-shadow:
    inset 0 2px 6px rgba(0,0,0,0.7),
    inset 0 1px 2px rgba(0,0,0,0.5),
    0 1px 0 rgba(255,255,255,0.04);
  flex-shrink: 0;
}

.card {
  width: var(--card-w);
  height: var(--card-h);
  border-radius: var(--card-radius);
  position: relative;
  user-select: none;
  flex-shrink: 0;
}

.card.card-face {
  background: #fff;
  border: 1px solid rgba(0,0,0,0.12);
  box-shadow: 0 3px 10px rgba(0,0,0,0.45);
  display: grid;
  place-items: center;
}
.card.card-face.red   { color: var(--red-suit);  }
.card.card-face.black { color: var(--black-suit); }

.card-corner {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
  gap: 0;
}
.card-corner.card-tl { top: 3px; left: 4px; }
.card-corner.card-br {
  bottom: 3px;
  right: 4px;
  transform: rotate(180deg);
}

.card-rank       { font-size: 12px; font-weight: 800; line-height: 1; }
.card-suit-small { font-size: 10px; line-height: 1; }
.card-suit-center { font-size: 22px; line-height: 1; display: block; }
.card-dot {
  position: absolute;
  top: 2px;
  right: 3px;
  font-size: 7px;
  line-height: 1;
  opacity: 0.75;
}

.card.card-large { width: 62px; height: 88px; }
.card.card-large .card-rank        { font-size: 15px; }
.card.card-large .card-suit-small  { font-size: 12px; }
.card.card-large .card-suit-center { font-size: 30px; }
.card.card-large .card-dot         { font-size: 9px; }

.card.card-back {
  background: linear-gradient(145deg,
    #1a237e 0%, #283593 40%, #1e237e 60%, #1a237e 100%);
  border: 1.5px solid var(--card-back-border);
  box-shadow: 0 3px 10px rgba(0,0,0,0.55);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.card-back-inner {
  width: 100%;
  height: 100%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--card-radius);
  overflow: hidden;
}
.card-back-pattern {
  position: absolute;
  inset: 0;
  background-image:
    repeating-linear-gradient(
      45deg,
      rgba(255,255,255,0.05) 0, rgba(255,255,255,0.05) 1.5px,
      transparent 1.5px, transparent 9px
    ),
    repeating-linear-gradient(
      -45deg,
      rgba(255,255,255,0.05) 0, rgba(255,255,255,0.05) 1.5px,
      transparent 1.5px, transparent 9px
    );
}
.card-back-center {
  position: relative;
  font-size: 20px;
  color: rgba(255,255,255,0.25);
  text-shadow: 0 0 6px rgba(255,255,255,0.15);
  z-index: 1;
}
.card.card-large .card-back-center { font-size: 28px; }

@keyframes cardDeal {
  from { opacity: 0; transform: translateY(-20px) scale(0.82); }
  to   { opacity: 1; transform: translateY(0)      scale(1);   }
}
.card-anim { animation: cardDeal 0.25s cubic-bezier(0.22, 1, 0.36, 1) forwards; }
#cc-1 .card-anim { animation-delay: 0.04s; }
#cc-2 .card-anim { animation-delay: 0.08s; }
#cc-3 .card-anim { animation-delay: 0.12s; }
#cc-4 .card-anim { animation-delay: 0.16s; }

/* My cards */
#my-cards-area {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 6px 0 4px;
  flex-shrink: 0;
  background: rgba(0,0,0,0.28);
}
.my-cards { display: flex; gap: 10px; }
.my-card-slot {
  width: 62px;
  height: 88px;
  border-radius: var(--card-radius);
  background: rgba(0,0,0,0.28);
  border: none;
  box-shadow:
    inset 0 3px 8px rgba(0,0,0,0.8),
    inset 0 1px 3px rgba(0,0,0,0.5),
    0 1px 0 rgba(255,255,255,0.03);
}

/* ── ACTION PANEL ───────────────────────────────────────────────────────────── */
.actions-panel {
  flex-shrink: 0;
  padding: 6px 10px;
  padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px));
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.bet-input-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.bet-amount-input {
  flex: 1;
  min-height: var(--min-touch);
  padding: 0 10px;
  border-radius: 10px;
  border: 1.5px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.08);
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  outline: none;
  -moz-appearance: textfield;
}
.bet-amount-input::-webkit-inner-spin-button,
.bet-amount-input::-webkit-outer-spin-button { -webkit-appearance: none; }
.bet-amount-input:focus { border-color: var(--raise-bg); }

.btn-stepper {
  width: var(--min-touch);
  height: var(--min-touch);
  border-radius: 10px;
  border: 1.5px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.1);
  color: var(--text);
  font-size: 22px;
  font-weight: 300;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  line-height: 1;
  -webkit-tap-highlight-color: transparent;
}
.btn-stepper:active { opacity: 0.65; }

.action-buttons { display: flex; gap: 8px; }
.action-buttons .btn {
  flex: 1;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.3px;
  min-height: 48px;
  padding: 0 4px;
  border-radius: 12px;
  border-top: none;
  border-left: none;
  border-right: none;
  border-bottom-width: 3px;
  border-bottom-style: solid;
  text-shadow: 0 1px 2px rgba(0,0,0,0.35);
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.08s ease, opacity 0.1s;
}
.action-buttons .btn:active {
  transform: translateY(2px);
  border-bottom-width: 1px;
  opacity: 0.92;
}
.action-buttons .btn:disabled {
  opacity: 0.32;
  transform: none !important;
  border-bottom-width: 3px;
}

.btn-fold {
  background: linear-gradient(180deg, #c62828 0%, #b71c1c 55%, #a31515 100%);
  border-bottom-color: #6e0f0f;
  color: rgba(255,255,255,0.9);
}
.btn-check {
  background: linear-gradient(180deg, #388e3c 0%, #2e7d32 55%, #1b5e20 100%);
  border-bottom-color: #104b14;
  color: #fff;
  flex: 1.15;
}
.btn-call {
  background: linear-gradient(180deg, #1976d2 0%, #1565c0 55%, #0d47a1 100%);
  border-bottom-color: #083378;
  color: #fff;
  flex: 1.15;
}
.btn-raise {
  background: linear-gradient(180deg, #f4511e 0%, #e64a19 55%, #d84315 100%);
  border-bottom-color: #9c2700;
  color: #fff;
}

/* ── SHOWDOWN EFFECTS ───────────────────────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.table-darken {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.55);
  z-index: 50;
  pointer-events: none;
  animation: fadeIn 0.3s ease;
}

.seat-inner.seat-winner {
  box-shadow: 0 0 28px rgba(255,215,0,0.8), 0 0 56px rgba(255,215,0,0.4);
  border: 2px solid #FFD700;
  animation: winnerPulse 1.5s ease-in-out infinite;
  transform: scale(1.05);
  z-index: 60;
  position: relative;
}

@keyframes winnerPulse {
  0%, 100% { box-shadow: 0 0 28px rgba(255,215,0,0.8), 0 0 56px rgba(255,215,0,0.4); }
  50%       { box-shadow: 0 0 44px rgba(255,215,0,1),   0 0 80px rgba(255,215,0,0.6); }
}

.card.card-winner, .mini-card.card-winner {
  border: 2px solid #FFD700 !important;
  box-shadow: 0 0 14px rgba(255,215,0,0.7) !important;
  animation: cardLift 0.5s ease forwards;
  position: relative;
  z-index: 20;
}

@keyframes cardLift {
  0%   { transform: translateY(0)    scale(1);    }
  50%  { transform: translateY(-8px) scale(1.08); }
  100% { transform: translateY(-5px) scale(1.04); }
}

.winner-badge {
  position: absolute;
  top: -22px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, #FFD700, #FFA500);
  color: #000;
  padding: 4px 12px;
  border-radius: 20px;
  font-weight: bold;
  font-size: 12px;
  white-space: nowrap;
  box-shadow: 0 3px 12px rgba(255,215,0,0.5);
  animation: badgePop 0.4s ease;
  z-index: 70;
}

@keyframes badgePop {
  0%   { transform: translateX(-50%) scale(0);    opacity: 0; }
  70%  { transform: translateX(-50%) scale(1.15);             }
  100% { transform: translateX(-50%) scale(1);    opacity: 1; }
}

.win-info {
  position: fixed;
  bottom: 22%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(10,25,10,0.92);
  border: 2px solid #FFD700;
  border-radius: 14px;
  padding: 14px 22px;
  text-align: center;
  z-index: 100;
  animation: slideUp 0.4s ease;
  pointer-events: none;
}

.win-info h3 {
  color: #FFD700;
  margin: 0 0 6px 0;
  font-size: 20px;
  font-weight: 700;
}

.win-info .combination {
  color: #fff;
  font-size: 16px;
  margin: 3px 0;
  font-style: italic;
}

.win-info .amount {
  color: #4CAF50;
  font-size: 18px;
  font-weight: bold;
  margin: 6px 0 0 0;
}

@keyframes slideUp {
  from { transform: translateX(-50%) translateY(24px); opacity: 0; }
  to   { transform: translateX(-50%) translateY(0);    opacity: 1; }
}

.next-hand-timer {
  position: fixed;
  top: 64px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.82);
  color: #FFD700;
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 15px;
  font-weight: bold;
  z-index: 90;
  border: 1px solid rgba(255,215,0,0.5);
  pointer-events: none;
}

/* ── TOAST ──────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  background: rgba(20,20,20,0.96);
  color: #fff;
  padding: 10px 22px;
  border-radius: 22px;
  font-size: 13px;
  z-index: 300;
  pointer-events: none;
  box-shadow: 0 4px 20px rgba(0,0,0,0.45);
  white-space: nowrap;
  max-width: 88vw;
  text-overflow: ellipsis;
  overflow: hidden;
  animation: fadeIn 0.18s ease;
}
.toast.hidden { display: none; }

/* ── Utility ────────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Reconnect banner ───────────────────────────────────────────────────────── */
.reconnect-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 999;
  background: rgba(183, 28, 28, 0.96);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 12px 16px calc(12px + env(safe-area-inset-top, 0px));
  backdrop-filter: blur(8px);
  box-shadow: 0 2px 20px rgba(0,0,0,0.5);
  animation: slideDown 0.2s ease;
}
@keyframes slideDown {
  from { transform: translateY(-100%); opacity: 0; }
  to   { transform: translateY(0);     opacity: 1; }
}

.reconnect-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 600;
}

.reconnect-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

.btn-restart {
  background: rgba(255,255,255,0.2);
  border: 1.5px solid rgba(255,255,255,0.5);
  border-radius: 8px;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  min-height: var(--min-touch);
  padding: 0 20px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btn-restart:active { opacity: 0.75; }

/* ── PLAYER INFO BAR ────────────────────────────────────────────────────────── */
.player-info-bar {
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 3px 6px 2px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.info-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0px;
  min-width: 60px;
  border-right: 1px solid rgba(255,255,255,0.06);
  padding: 0 8px;
}
.info-item:last-child { border-right: none; }
.info-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--hint);
}
.info-value {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
}

/* ── BET PRESET BUTTONS ─────────────────────────────────────────────────────── */
.bet-presets {
  display: flex;
  gap: 5px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 1px;
}
.bet-presets::-webkit-scrollbar { display: none; }
.btn-preset {
  flex-shrink: 0;
  min-width: 52px;
  min-height: 30px;
  border: 1.5px solid rgba(255,255,255,0.18);
  border-radius: 8px;
  background: rgba(255,255,255,0.07);
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.12s, background 0.12s;
  white-space: nowrap;
}
.btn-preset:active { opacity: 0.6; background: rgba(255,255,255,0.14); }
.btn-preset-allin {
  background: rgba(230,81,0,0.2);
  border-color: rgba(230,81,0,0.55);
  color: #ff8a50;
}
.btn-preset-allin:active { background: rgba(230,81,0,0.35); }
.btn-preset-bb {
  border-color: rgba(255,215,0,0.35);
  color: #FFD700;
}
.btn-preset-bb:active { background: rgba(255,215,0,0.12); }

/* ── BET SLIDER ──────────────────────────────────────────────────────────────── */
.bet-slider-row { display: flex; flex-direction: column; gap: 4px; }
.bet-slider {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: rgba(255,255,255,0.15);
  outline: none;
  -webkit-appearance: none;
  cursor: pointer;
}
.bet-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--raise-bg);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}
.bet-slider::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--raise-bg);
  cursor: pointer;
  border: none;
}
.bet-slider-labels {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--hint);
}

/* ── DEBUG OVERLAY ──────────────────────────────────────────────────────────── */
#debug-overlay {
  position: fixed;
  top: 50px;
  left: 10px;
  right: 10px;
  z-index: 500;
  background: rgba(0,0,0,0.93);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 12px;
  padding: 14px 16px;
  font-family: 'Courier New', monospace;
  font-size: 11px;
  color: #a5d6a7;
  line-height: 1.75;
  backdrop-filter: blur(8px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
}

/* ── DEBUG PANEL ────────────────────────────────────────────────────────────── */
.debug-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1000;
  width: min(340px, 92vw);
  background: rgba(5, 15, 5, 0.97);
  border: 1px solid rgba(100, 200, 100, 0.35);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(0,0,0,0.7);
  backdrop-filter: blur(12px);
}
.debug-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(100,200,100,0.15);
  font-size: 13px;
  font-weight: 700;
  color: #a5d6a7;
}
.debug-close-btn {
  background: none;
  border: none;
  color: var(--hint);
  font-size: 16px;
  cursor: pointer;
  padding: 4px 8px;
}
.debug-panel-body {
  padding: 10px 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.btn-debug-action {
  background: rgba(100,200,100,0.1);
  border: 1px solid rgba(100,200,100,0.25);
  border-radius: 8px;
  color: #a5d6a7;
  font-size: 12px;
  padding: 6px 12px;
  cursor: pointer;
}
.btn-debug-action:active { background: rgba(100,200,100,0.2); }
.debug-panel-output {
  padding: 8px 14px 12px;
  font-family: 'Courier New', monospace;
  font-size: 11px;
  color: rgba(165,214,167,0.75);
  line-height: 1.6;
  max-height: 120px;
  overflow-y: auto;
  border-top: 1px solid rgba(100,200,100,0.1);
}
