/* ============================================
   POKER LAN - Modern UI v2
   ============================================ */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.12) transparent;
}

/* Global scrollbar */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.12);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.22); }
::-webkit-scrollbar-corner { background: transparent; }

:root {
  --bg: #0f0f1a;
  --bg2: #161625;
  --panel: rgba(25, 30, 56, 0.85);
  --glass: rgba(255, 255, 255, 0.04);
  --glass-border: rgba(255, 255, 255, 0.08);
  --red: #ff4d6a;
  --green: #34d399;
  --gold: #fbbf24;
  --blue: #3b82f6;
  --orange: #f59e0b;
  --text: #e8e8f0;
  --muted: #7a7a9a;
  --dim: #3a3a5a;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --radius: 12px;
}

html,
body {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100%;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
}

.screen {
  display: none;
  width: 100vw;
  height: 100dvh;
}
.screen.active {
  display: flex;
}

button {
  padding: 10px 20px;
  font-size: 0.9rem;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 600;
  transition: all 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  letter-spacing: 0.01em;
}
button:active {
  transform: scale(0.96);
  opacity: 0.9;
}

/* ============================================
   LANGUAGE SWITCHER
   ============================================ */
.lang-switcher {
  position: fixed; top: 24px; right: 20px; z-index: 9000;
}
.lang-select {
  padding: 5px 8px; font-size: 0.7rem; font-weight: 600;
  background: var(--panel); backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border); border-radius: 8px;
  color: var(--text); cursor: pointer; outline: none;
  appearance: auto;
}
.lang-select option { background: var(--bg2); color: var(--text); }

/* ============================================
   TOP BAR (Timer + Help)
   ============================================ */
.top-bar {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-help {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--panel);
  backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
  color: var(--gold);
  font-size: 1rem;
  font-weight: 700;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.global-timer {
  position: relative;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.global-timer svg {
  display: block;
}
.gt-ring-bg {
  fill: none;
  stroke: var(--dim);
  stroke-width: 2.5;
}
.gt-ring-fg {
  fill: none;
  stroke: var(--green);
  stroke-width: 2.5;
  stroke-linecap: round;
  transition:
    stroke-dashoffset 0.25s linear,
    stroke 0.3s;
  transform: rotate(-90deg);
  transform-origin: center;
}
.gt-ring-fg.warning {
  stroke: var(--orange);
}
.gt-ring-fg.danger {
  stroke: var(--red);
}
.gt-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.65rem;
  font-weight: 700;
  color: #fff;
}

/* ============================================
   HELP OVERLAY
   ============================================ */
.help-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.help-content {
  background: var(--bg2);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 20px;
  width: 100%;
  max-width: 400px;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
}
.help-close {
  position: absolute;
  top: 8px;
  right: 10px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.5rem;
  padding: 4px 10px;
}
.help-content h2 {
  color: var(--gold);
  margin-bottom: 14px;
  font-size: 1.15rem;
}
.help-body h3 {
  color: var(--red);
  font-size: 0.85rem;
  margin: 14px 0 6px;
}
.help-body p,
.help-body li {
  font-size: 0.8rem;
  color: var(--text);
  line-height: 1.5;
}
.help-body ol,
.help-body ul {
  padding-left: 20px;
}
.help-body li {
  margin-bottom: 3px;
}

.help-illustration {
  margin: 8px 0;
  overflow-x: auto;
}
.help-ill-row {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}
.help-label {
  font-size: 0.7rem;
  color: var(--muted);
  white-space: nowrap;
}
.h-card {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 38px;
  background: #fff;
  border-radius: 4px;
  font-size: 0.6rem;
  font-weight: 700;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}
.h-card.red {
  color: #dc2626;
}
.h-card.black {
  color: #1e1e1e;
}

.help-flow {
  display: flex;
  align-items: flex-start;
  gap: 4px;
  overflow-x: auto;
  padding: 8px 0;
}
.flow-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 56px;
  text-align: center;
}
.flow-icon {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}
.flow-text {
  font-size: 0.6rem;
  color: var(--text);
  line-height: 1.3;
}
.flow-text b {
  color: var(--gold);
  font-size: 0.65rem;
}
.flow-arrow {
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 4px;
  flex-shrink: 0;
}

.help-actions-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 6px 0;
}
.help-action-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
}
.ha-btn {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 5px;
  font-size: 0.65rem;
  font-weight: 700;
  min-width: 48px;
  text-align: center;
  flex-shrink: 0;
}
.ha-check {
  background: var(--green);
  color: #000;
}
.ha-call {
  background: var(--blue);
  color: #fff;
}
.ha-raise {
  background: var(--orange);
  color: #fff;
}
.ha-fold {
  background: #555;
  color: #fff;
}
.ha-allin {
  background: var(--red);
  color: #fff;
}

.hand-ranks {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}
.hand-rank {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  padding: 8px 10px;
}
.hand-rank-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2px;
}
.hand-rank-name {
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--gold);
}
.hand-rank-odds {
  font-size: 0.6rem;
  font-weight: 600;
  color: var(--green);
  background: rgba(52, 211, 153, 0.1);
  padding: 2px 6px;
  border-radius: 8px;
}
.hand-rank-desc {
  font-size: 0.65rem;
  color: var(--muted);
  margin-bottom: 6px;
}
.hand-rank-cards {
  display: flex;
  gap: 3px;
}

/* ============================================
   LOBBY SHARED
   ============================================ */
.lobby-container {
  margin: auto;
  text-align: center;
  padding: 24px 20px;
  width: 100%;
  max-width: 420px;
}
.lobby-container h1 {
  font-size: 2.4rem;
  margin-bottom: 1.5rem;
  background: linear-gradient(135deg, var(--red), var(--gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-weight: 800;
}

/* ============================================
   LOGIN SCREEN (Telegram)
   ============================================ */
#login-screen {
  flex-direction: column;
  overflow-y: auto;
}
.login-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
  max-width: 360px;
  margin: 0 auto;
  padding: 28px 20px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  backdrop-filter: blur(8px);
}
.login-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
}
.login-subtitle {
  font-size: 0.85rem;
  color: var(--muted);
  text-align: center;
}
.login-status {
  font-size: 0.85rem;
  color: var(--muted);
  padding: 8px 0;
}
.login-widget {
  min-height: 40px;
  display: flex;
  justify-content: center;
  width: 100%;
}
.qr-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
}
.qr-canvas {
  background: #fff;
  padding: 12px;
  border-radius: 12px;
  width: 200px;
  height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}
.qr-canvas svg {
  width: 100%;
  height: 100%;
  display: block;
}
.qr-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: linear-gradient(135deg, #0088cc, #229ed9);
  color: #fff;
  padding: 11px 20px;
  border-radius: 10px;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  width: 100%;
  transition: opacity 0.2s, transform 0.1s;
}
.qr-link:hover { opacity: 0.92; }
.qr-link:active { transform: scale(0.98); }
.qr-link-icon {
  font-size: 1.1rem;
}
.qr-hint {
  font-size: 0.72rem;
  color: var(--muted);
  text-align: center;
  line-height: 1.5;
  padding: 0 8px;
}
.qr-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--gold);
  font-weight: 600;
}
.qr-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
  animation: qrBlink 1.2s ease-in-out infinite;
}
@keyframes qrBlink {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.3; transform: scale(0.8); }
}
.login-error {
  background: rgba(255, 77, 106, 0.1);
  border: 1px solid rgba(255, 77, 106, 0.3);
  color: var(--red);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.8rem;
  text-align: center;
  line-height: 1.5;
}
.login-user-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(52, 211, 153, 0.1);
  border: 1px solid rgba(52, 211, 153, 0.3);
  color: var(--green);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.8rem;
  width: 100%;
}
.login-banner-icon {
  font-weight: 700;
}
.btn-logout {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--glass-border);
  padding: 10px;
  font-size: 0.85rem;
  width: 100%;
  border-radius: var(--radius);
}
.btn-logout:hover {
  color: var(--red);
  border-color: var(--red);
}

/* ============================================
   PROFILE SCREEN
   ============================================ */
#profile-screen {
  flex-direction: column;
  overflow-y: auto;
}

.profile-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
  width: 100%;
  max-width: 320px;
  margin: 0 auto;
}
.profile-form input {
  padding: 14px 16px;
  font-size: 1rem;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  background: var(--glass);
  backdrop-filter: blur(6px);
  color: var(--text);
  width: 100%;
  text-align: center;
  outline: none;
  transition: border-color 0.2s;
}
.profile-form input:focus {
  border-color: var(--gold);
}

#btn-enter {
  background: linear-gradient(135deg, var(--red), #ff6b8a);
  color: #fff;
  width: 100%;
  padding: 14px;
  font-size: 1.05rem;
  border-radius: var(--radius);
  box-shadow: 0 4px 20px rgba(255, 77, 106, 0.3);
}

.avatar-picker {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.avatar-preview {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: var(--bg2);
  border: 3px solid var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.8rem;
  box-shadow: 0 0 30px rgba(251, 191, 36, 0.15);
}
.avatar-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  max-width: 300px;
}
.avatar-option {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--glass);
  border: 2px solid transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  cursor: pointer;
  transition: all 0.15s;
}
.avatar-option:active {
  transform: scale(0.9);
}
.avatar-option.selected {
  border-color: var(--gold);
  background: rgba(251, 191, 36, 0.1);
  box-shadow: 0 0 10px rgba(251, 191, 36, 0.2);
}

.my-profile-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  padding: 14px 20px;
  margin-bottom: 1.2rem;
  width: 100%;
  max-width: 320px;
  margin-left: auto;
  margin-right: auto;
  backdrop-filter: blur(6px);
}
.my-profile-card .profile-avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  flex-shrink: 0;
}
.my-profile-card .profile-details {
  text-align: left;
  flex: 1;
  min-width: 0;
}
.my-profile-card .profile-name {
  font-weight: 700;
  font-size: 1.05rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.my-profile-card .profile-chips {
  color: var(--gold);
  font-size: 0.85rem;
}
.my-profile-card .btn-edit-profile {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  color: var(--muted);
  padding: 6px 10px;
  font-size: 0.7rem;
  border-radius: 8px;
  flex-shrink: 0;
}

/* ============================================
   LOBBY SCREEN
   ============================================ */
#lobby-screen {
  flex-direction: column;
  overflow-y: auto;
}

.lobby-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  width: 100%;
  max-width: 320px;
  margin: 0 auto;
}
#room-name {
  padding: 10px 16px;
  font-size: 0.9rem;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  background: var(--glass);
  color: var(--text);
  width: 100%;
  text-align: center;
  outline: none;
}
#room-name:focus {
  border-color: var(--gold);
}
.btn-toggle-settings {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  color: var(--muted);
  padding: 8px 14px;
  border-radius: var(--radius);
  font-size: 0.82rem;
  cursor: pointer;
  width: 100%;
  transition: all 0.2s;
}
.btn-toggle-settings:hover,
.btn-toggle-settings.active {
  color: var(--gold);
  border-color: var(--gold);
  background: rgba(251, 191, 36, 0.08);
}
.room-settings {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  background: var(--glass);
  animation: fadeSlideDown 0.2s ease;
}
@keyframes fadeSlideDown {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.setting-row label {
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
}
.setting-row select {
  padding: 5px 8px;
  font-size: 0.82rem;
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  background: var(--bg2);
  color: var(--text);
  outline: none;
  cursor: pointer;
  min-width: 100px;
  text-align: center;
}
.setting-row select:focus {
  border-color: var(--gold);
}
#btn-create {
  background: linear-gradient(135deg, var(--red), #ff6b8a);
  color: #fff;
  width: 100%;
  box-shadow: 0 4px 16px rgba(255, 77, 106, 0.25);
}
.join-row {
  display: flex;
  gap: 0.5rem;
}
.join-row input {
  flex: 1;
  padding: 12px 16px;
  font-size: 1rem;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  background: var(--glass);
  color: var(--text);
  text-align: center;
  text-transform: uppercase;
  outline: none;
}
.join-row input:focus {
  border-color: var(--gold);
}
#btn-join {
  background: var(--blue);
  color: #fff;
  white-space: nowrap;
}

/* Room List */
.room-list-section {
  margin-top: 1.5rem;
  width: 100%;
  max-width: 320px;
  margin-left: auto;
  margin-right: auto;
}
.room-list-section h3 {
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 10px;
}
.room-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 220px;
  overflow-y: auto;
}
.room-list-empty {
  color: var(--dim);
  font-size: 0.85rem;
  padding: 16px;
}
.room-list-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  padding: 10px 14px;
  transition: border-color 0.15s;
}
.room-list-item:hover {
  border-color: var(--gold);
}
.room-list-item .room-info {
  text-align: left;
  flex: 1;
  min-width: 0;
}
.room-list-item .room-code {
  color: var(--gold);
  font-weight: 700;
  font-size: 0.9rem;
}
.room-list-item .room-host {
  color: var(--muted);
  font-size: 0.7rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.room-list-item .room-players {
  color: var(--gold);
  font-size: 0.8rem;
  white-space: nowrap;
}
.room-list-item .room-status-badge {
  font-size: 0.6rem;
  padding: 3px 8px;
  border-radius: 20px;
  font-weight: 600;
  text-transform: uppercase;
  white-space: nowrap;
}
.room-status-badge.waiting {
  background: rgba(52, 211, 153, 0.15);
  color: var(--green);
}
.room-status-badge.playing {
  background: rgba(255, 77, 106, 0.15);
  color: var(--red);
}
.room-list-item .btn-quick-join {
  padding: 6px 14px;
  font-size: 0.8rem;
  background: var(--blue);
  color: #fff;
  border-radius: 8px;
  white-space: nowrap;
}
.room-list-item .btn-quick-join:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ============================================
   ROOM SCREEN
   ============================================ */
#room-screen {
  flex-direction: column;
  padding: 12px;
}
.room-header {
  display: flex;
  justify-content: start;
  align-items: center;
  padding: 10px 16px;
  background: var(--glass);
  backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  margin-bottom: 14px;
  gap: 15px;
}
.room-header strong {
  color: var(--gold);
  font-size: 1.1rem;
  letter-spacing: 2px;
}
.room-settings-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin-bottom: 10px;
}
.room-settings-bar .stag {
  font-size: 0.75rem;
  color: var(--muted);
  background: var(--glass);
  border: 1px solid var(--glass-border);
  padding: 3px 10px;
  border-radius: 20px;
  white-space: nowrap;
}
#btn-leave {
  background: var(--glass);
  color: var(--muted);
  padding: 8px 14px;
  font-size: 0.8rem;
  border: 1px solid var(--glass-border);
}

.player-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  flex: 1;
  align-content: center;
  overflow-y: auto;
  min-height: 80px;
}
.room-chat {
  display: flex;
  flex-direction: column;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  margin: 10px 0;
  max-height: 220px;
  min-height: 120px;
  overflow: hidden;
}
.room-chat .chat-messages {
  flex: 1;
  min-height: 0;
}
.room-chat .chat-bubble { max-width: 70%; }
@media (max-width: 768px) {
  .room-chat { max-height: 160px; min-height: 100px; }
}
.player-card {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  padding: 14px 20px;
  text-align: center;
  min-width: 110px;
  backdrop-filter: blur(6px);
  transition: border-color 0.2s;
}
.player-card.ready {
  border-color: var(--green);
  box-shadow: 0 0 15px rgba(52, 211, 153, 0.1);
}
.player-card .player-avatar-small {
  font-size: 2rem;
  margin-bottom: 6px;
}
.player-card .player-name {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 3px;
}
.player-card .player-chips {
  color: var(--gold);
  font-size: 0.8rem;
}
.player-card .player-status {
  margin-top: 6px;
  font-size: 0.7rem;
  color: var(--green);
  font-weight: 600;
}
.player-card.host .player-name::after {
  content: " (Host)";
  color: var(--red);
  font-size: 0.65rem;
}
.btn-kick {
  margin-top: 6px; padding: 4px 12px;
  background: transparent; color: var(--red);
  border: 1px solid var(--red); border-radius: 6px;
  font-size: 0.65rem; font-weight: 600; cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.btn-kick:hover { background: var(--red); color: #fff; }

.room-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 14px;
}
#btn-ready {
  background: linear-gradient(135deg, var(--green), #059669);
  color: #000;
  min-width: 110px;
  font-weight: 700;
}
#btn-ready.is-ready {
  background: linear-gradient(135deg, #666, #444);
  color: #ccc;
}
#btn-start {
  background: linear-gradient(135deg, var(--red), #ff6b8a);
  color: #fff;
  min-width: 130px;
  box-shadow: 0 4px 16px rgba(255, 77, 106, 0.25);
}
#btn-start:disabled {
  opacity: 0.4;
}

/* ============================================
   GAME SCREEN
   ============================================ */
#game-screen {
  flex-direction: row;
  position: relative;
  overflow: hidden;
  background: var(--bg);
}

/* ---- SIDEBAR ---- */
.game-sidebar {
  width: 260px; flex-shrink: 0;
  background: var(--bg2);
  border-right: 1px solid var(--glass-border);
  display: flex; flex-direction: column;
  z-index: 20;
}
.sidebar-header {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--glass-border);
}
.btn-exit-game {
  background: var(--glass); color: var(--muted);
  padding: 6px 12px; font-size: 0.7rem;
  border-radius: 8px; border: 1px solid var(--glass-border);
  cursor: pointer; flex-shrink: 0;
}
.sidebar-room-label {
  font-size: 0.75rem; font-weight: 700; color: var(--gold);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  flex: 1;
}
.btn-sound-toggle {
  background: none; border: none; color: var(--muted);
  font-size: 1.1rem; cursor: pointer; padding: 0 4px; line-height: 1;
}
.btn-sound-toggle:hover { color: var(--gold); }
.btn-close-sidebar {
  display: none; background: none; border: none; color: var(--muted);
  font-size: 1.3rem; cursor: pointer; padding: 0 4px; line-height: 1;
}
.btn-close-sidebar:hover { color: var(--text); }

/* Sidebar backdrop */
.sidebar-backdrop {
  display: none; position: fixed; inset: 0; z-index: 99;
  background: rgba(0,0,0,0.5);
}

/* Tabs */
.sidebar-tabs {
  display: flex; border-bottom: 1px solid var(--glass-border); flex-shrink: 0;
}
.sidebar-tab {
  flex: 1; padding: 9px 6px; font-size: 0.7rem; font-weight: 600;
  background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--muted); cursor: pointer; transition: color 0.2s, border-color 0.2s;
  position: relative;
}
.sidebar-tab:hover { color: var(--text); }
.sidebar-tab.active { color: var(--gold); border-bottom-color: var(--gold); }
.chat-badge {
  background: var(--red); color: #fff; font-size: 0.5rem;
  padding: 1px 5px; border-radius: 8px; margin-left: 4px;
  font-weight: 700; line-height: 1; vertical-align: middle;
}
.chat-badge-pulse { animation: badgePulse 1s ease infinite; }
@keyframes badgePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.25); }
}

/* Chat tab unread highlight */
.sidebar-tab.has-unread { color: var(--red); }

/* Mobile hamburger notification badge */
.mobile-chat-badge {
  position: absolute; top: -6px; right: -6px;
  background: var(--red); color: #fff;
  font-size: 0.55rem; font-weight: 700; line-height: 1;
  padding: 3px 5px; border-radius: 8px; min-width: 16px;
  text-align: center; box-shadow: 0 0 8px var(--red);
  animation: badgePulse 1s ease infinite;
}
/* Panels */
.sidebar-panel { display: none; flex-direction: column; flex: 1; min-height: 0; overflow: hidden; }
.sidebar-panel.active { display: flex; }

/* Chat in sidebar */
.chat-messages {
  flex: 1; overflow-y: auto; padding: 8px 10px;
  display: flex; flex-direction: column; gap: 6px;
}
.chat-msg {
  display: flex; align-items: flex-end; gap: 6px;
  animation: chatMsgIn 0.2s ease;
}
.chat-msg-me { flex-direction: row-reverse; }
.chat-avatar {
  font-size: 1.1rem; flex-shrink: 0;
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
}
.chat-bubble {
  background: rgba(255,255,255,0.07); border-radius: 10px 10px 10px 2px;
  padding: 6px 10px; max-width: 180px; word-break: break-word;
}
.chat-msg-me .chat-bubble {
  background: rgba(74,222,128,0.12); border-radius: 10px 10px 2px 10px;
}
.chat-name {
  display: block; font-size: 0.55rem; font-weight: 700;
  color: var(--gold); margin-bottom: 2px;
}
.chat-msg-me .chat-name { text-align: right; }
.chat-text { font-size: 0.7rem; color: var(--text); line-height: 1.45; display: block; }
.chat-input-row {
  display: flex; border-top: 1px solid var(--glass-border);
  flex-shrink: 0; align-items: center;
}
.chat-input-row input {
  flex: 1; background: transparent; border: none; outline: none;
  color: var(--text); padding: 10px 12px; font-size: 0.75rem; min-width: 0;
}
.chat-input-row input::placeholder { color: var(--dim); }
.chat-input-row button {
  background: var(--green); color: #000; border: none;
  padding: 10px 14px; font-size: 0.7rem; font-weight: 700;
  cursor: pointer; flex-shrink: 0; transition: opacity 0.2s;
}
.chat-input-row button:hover { opacity: 0.85; }
@keyframes chatMsgIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Rules in sidebar */
.sidebar-rules-content {
  padding: 12px 14px; overflow-y: auto; flex: 1;
  font-size: 0.7rem; line-height: 1.6; color: var(--text);
}
.sidebar-rules-content h4 {
  color: var(--gold); font-size: 0.75rem; margin: 12px 0 6px;
  text-transform: uppercase; letter-spacing: 1px;
}
.sidebar-rules-content h4:first-child { margin-top: 0; }
.sidebar-rules-content p { color: var(--muted); margin-bottom: 6px; }
.rules-flow {
  display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-bottom: 4px;
}
.rules-step {
  background: var(--glass); border: 1px solid var(--glass-border);
  padding: 3px 8px; border-radius: 6px; font-size: 0.6rem; font-weight: 600;
}
.rules-arrow { color: var(--dim); font-size: 0.6rem; }
.rules-actions { display: flex; flex-direction: column; gap: 3px; }
.rules-actions div { font-size: 0.65rem; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.ra-tag {
  padding: 2px 8px; border-radius: 6px; font-size: 0.6rem; font-weight: 700;
  display: inline-block; min-width: 48px; text-align: center;
}
.ra-check { background: rgba(52,211,153,0.15); color: var(--green); }
.ra-call { background: rgba(59,130,246,0.15); color: var(--blue); }
.ra-raise { background: rgba(245,158,11,0.15); color: var(--orange); }
.ra-fold { background: rgba(122,122,154,0.15); color: var(--muted); }
.ra-allin { background: rgba(255,77,106,0.15); color: var(--red); }
.rules-ranks { display: flex; flex-direction: column; gap: 6px; }
.rr {
  font-size: 0.65rem; color: var(--text); padding: 6px 8px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px;
  background: var(--glass); border-radius: 8px;
}
.rr-n { color: var(--gold); font-weight: 700; min-width: 20px; flex-shrink: 0; }
.rr-info { flex: 1; min-width: 0; }
.rr-name { font-weight: 700; color: var(--text); display: block; font-size: 0.65rem; }
.rr-d { color: var(--dim); font-size: 0.55rem; display: block; }
.rr-cards {
  width: 100%; display: flex; gap: 3px; margin-top: 4px;
}
.rc {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 36px; border-radius: 4px; font-size: 0.55rem; font-weight: 700;
  background: #fff; border: 1px solid #ddd;
}
.rc.red { color: #e53e3e; }
.rc.black { color: #1a1a2e; }

/* Rank in sidebar */
.rank-list {
  flex: 1; overflow-y: auto; padding: 8px 10px;
  display: flex; flex-direction: column; gap: 4px;
}
.rank-empty {
  color: var(--dim); font-size: 0.75rem; text-align: center; padding: 20px;
}
.rank-progress {
  padding: 10px 10px 8px; margin-bottom: 4px;
  border-bottom: 1px solid var(--glass-border);
}
.rank-progress-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 6px;
}
.rank-progress-leader {
  font-size: 0.7rem; font-weight: 700; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rank-progress-pct {
  font-size: 0.65rem; font-weight: 700; color: var(--gold); flex-shrink: 0;
}
.rank-progress-bar {
  width: 100%; height: 8px; border-radius: 4px;
  background: var(--glass); overflow: hidden;
}
.rank-progress-fill {
  height: 100%; border-radius: 4px;
  background: linear-gradient(90deg, var(--green), var(--gold));
  transition: width 0.5s ease;
}
.rank-progress-fill.rank-progress-hot {
  background: linear-gradient(90deg, var(--orange), var(--red));
  animation: progressPulse 1s ease infinite;
}
.rank-progress-label {
  font-size: 0.6rem; color: var(--muted); margin-top: 4px; text-align: center;
}
@keyframes progressPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}
.rank-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: 10px;
  background: var(--glass); border: 1px solid transparent;
  transition: border-color 0.2s;
}
.rank-me { border-color: var(--gold); background: rgba(251,191,36,0.06); }
.rank-gold { border-color: var(--gold); }
.rank-silver { border-color: #a0a0b0; }
.rank-bronze { border-color: #cd7f32; }
.rank-pos {
  width: 24px; text-align: center; font-size: 0.85rem; font-weight: 800;
  color: var(--muted); flex-shrink: 0;
}
.rank-gold .rank-pos { color: var(--gold); }
.rank-silver .rank-pos { color: #a0a0b0; }
.rank-bronze .rank-pos { color: #cd7f32; }
.rank-avatar { font-size: 1.1rem; flex-shrink: 0; }
.rank-name {
  flex: 1; font-size: 0.75rem; font-weight: 600;
  color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rank-chips {
  font-size: 0.75rem; font-weight: 700; color: var(--gold);
  flex-shrink: 0;
}

/* Log in sidebar */
.log-toolbar {
  padding: 6px 12px; border-bottom: 1px solid var(--glass-border);
  display: flex; gap: 6px; flex-wrap: wrap;
}
.btn-download-log {
  background: var(--glass); color: var(--text); border: 1px solid var(--glass-border);
  border-radius: 6px; padding: 4px 10px; font-size: 0.7rem; cursor: pointer;
  font-weight: 600;
}
.btn-download-log:hover { background: var(--glass-hover, rgba(255,255,255,0.1)); }
.log-pick-title {
  font-size: 0.85rem; font-weight: 600; margin-bottom: 8px; color: var(--text);
}
.log-pick-list {
  display: flex; flex-direction: column; gap: 4px; max-height: 320px; overflow-y: auto;
}
.log-pick-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 12px; border: 1px solid var(--glass-border); border-radius: 6px;
  text-decoration: none; color: var(--text); background: var(--glass);
  font-size: 0.8rem; transition: background 0.15s;
}
.log-pick-item:hover { background: rgba(255,215,0,0.12); border-color: var(--gold); }
.log-pick-name { font-weight: 600; font-family: monospace; }
.log-pick-size { color: var(--dim); font-size: 0.7rem; }
.action-log-list {
  flex: 1; overflow-y: auto; padding: 4px 0;
}
.log-entry {
  padding: 3px 12px; font-size: 0.65rem; color: var(--text); line-height: 1.5;
}
.log-entry .log-name { font-weight: 700; color: var(--gold); }
.log-entry .log-amount { color: var(--green); }
.log-entry.log-stage {
  color: var(--dim); font-weight: 600; text-transform: uppercase; letter-spacing: 1px;
  padding: 6px 12px; font-size: 0.6rem;
  border-top: 1px solid var(--glass-border); margin-top: 2px;
}
.log-entry.log-fold .log-action { color: var(--muted); }
.log-entry.log-call .log-action { color: var(--blue); }
.log-entry.log-raise .log-action { color: var(--orange); }
.log-entry.log-allin .log-action { color: var(--red); }
.log-entry.log-check .log-action { color: var(--green); }
.log-entry.log-newhand {
  color: var(--gold); font-weight: 700; text-align: center; letter-spacing: 2px;
  padding: 8px 12px; font-size: 0.65rem;
  border-top: 2px solid var(--gold); margin-top: 6px;
}
.log-entry.log-result {
  background: rgba(255, 215, 0, 0.08); border-top: 1px solid var(--gold);
  padding: 5px 12px; margin-top: 2px;
}
.log-winner-line { display: flex; flex-direction: column; gap: 3px; font-size: 0.65rem; }
.log-winner-row1 { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.log-winner-row2 { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.log-winner-line .log-amount { color: var(--green); font-weight: 700; }
.log-winner-line .log-hand { color: var(--gold); font-style: italic; font-size: 0.6rem; font-weight: 600; }
.log-winner-line.log-refund { opacity: 0.75; }
.log-winner-line.log-refund .log-name { color: var(--muted); }
.log-winner-line.log-refund .log-amount { color: var(--muted); }
.log-winner-line.log-refund .log-hand { color: var(--muted); }
.log-best-cards { display: flex; gap: 2px; margin-top: 0; }
.log-best-cards .card.card-mini {
  width: 22px; height: 30px; font-size: 0.5rem; padding: 1px;
  min-width: unset; animation: none;
}

/* ---- MAIN GAME AREA ---- */
.game-main {
  flex: 1; display: flex; flex-direction: column;
  position: relative; overflow: hidden; min-width: 0;
}

/* Mobile sidebar toggle */
.btn-toggle-sidebar {
  display: none; position: absolute; top: 10px; left: 10px; z-index: 15;
  background: var(--panel); backdrop-filter: blur(10px);
  color: var(--muted); padding: 7px 12px; font-size: 1rem;
  border-radius: 8px; border: 1px solid var(--glass-border); cursor: pointer;
}

/* Chat Toast Notifications */
.chat-toast-container {
  position: absolute; top: 10px; right: 10px; z-index: 14;
  display: flex; flex-direction: column; gap: 6px;
  pointer-events: none; width: 250px;
}
.chat-toast {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel); backdrop-filter: blur(14px);
  border: 1px solid var(--glass-border); border-radius: 12px;
  padding: 8px 12px; pointer-events: auto; cursor: pointer;
  animation: chatToastIn 0.3s ease;
  transition: opacity 0.4s, transform 0.4s;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}
.chat-toast-hide { opacity: 0; transform: translateX(30px); }
.chat-toast-avatar { font-size: 1.1rem; flex-shrink: 0; }
.chat-toast-body { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.chat-toast-name { font-size: 0.6rem; font-weight: 700; color: var(--gold); }
.chat-toast-text {
  font-size: 0.7rem; color: var(--text); line-height: 1.4;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
@keyframes chatToastIn {
  from { opacity: 0; transform: translateX(30px); }
  to { opacity: 1; transform: translateX(0); }
}

/* Spectator Bar */
.spectator-bar {
  position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%);
  z-index: 20; display: flex; align-items: center; gap: 10px;
  background: rgba(255,152,0,0.12); backdrop-filter: blur(12px);
  border: 1px solid rgba(255,152,0,0.3); border-radius: 12px;
  padding: 8px 18px; white-space: nowrap;
}
.spectator-label {
  color: #ff9800; font-size: 0.75rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1px;
}
.btn-join-next {
  background: var(--green); color: #000; border: none;
  padding: 7px 16px; border-radius: 8px; font-size: 0.75rem;
  font-weight: 700; cursor: pointer; transition: opacity 0.2s;
}
.btn-join-next:hover { opacity: 0.85; }
.spectator-locked {
  color: #ff9800; font-size: 0.75rem; font-weight: 600;
  padding: 4px 10px; border-radius: 8px;
  background: rgba(255,152,0,0.1); border: 1px dashed rgba(255,152,0,0.4);
}
.setting-toggle {
  width: 20px; height: 20px; cursor: pointer; accent-color: var(--gold, #ffc66b);
}

/* ============================================
   POKER TABLE
   ============================================ */
.poker-table {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  overflow: visible;
}
.table-surface {
  width: 86vw;
  max-width: 380px;
  aspect-ratio: 4 / 3;
  background:
    radial-gradient(circle, rgba(0,0,0,0.04) 1px, transparent 1px),
    radial-gradient(
      ellipse at 40% 35%,
      rgba(255, 255, 255, 0.03) 0%,
      transparent 60%
    ),
    radial-gradient(ellipse, #1a6b30 0%, #0e4a1e 50%, #082e12 100%);
  background-size: 4px 4px, 100% 100%, 100% 100%;
  border-radius: 50%;
  border: 6px solid #6d4c2a;
  box-shadow:
    0 0 0 3px rgba(0, 0, 0, 0.4),
    0 0 60px rgba(0, 0, 0, 0.5),
    inset 0 0 60px rgba(0, 0, 0, 0.25),
    inset 0 -10px 30px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
}
.community-cards {
  display: flex;
  gap: 4px;
  margin-bottom: 6px;
  flex-wrap: nowrap;
}
.pot-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.pot-display {
  color: var(--gold);
  font-size: 1rem;
  font-weight: 800;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  letter-spacing: 0.02em;
}
.stage-display {
  color: rgba(255, 255, 255, 0.4);
  font-size: 0.65rem;
  margin-top: 3px;
  text-transform: uppercase;
  letter-spacing: 3px;
  font-weight: 600;
}

/* ============================================
   SEATS
   ============================================ */
.seats {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.seat {
  position: absolute;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  transform: translate(-50%, -50%);
  z-index: 2;
}
.seat-info {
  background: var(--panel);
  backdrop-filter: blur(10px);
  border: 2px solid var(--glass-border);
  border-radius: 10px;
  padding: 5px 10px;
  text-align: center;
  min-width: 72px;
  position: relative;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}
.seat.current .seat-info {
  border-color: var(--gold);
  box-shadow:
    0 0 16px rgba(251, 191, 36, 0.25),
    inset 0 0 12px rgba(251, 191, 36, 0.05);
  animation: seatPulse 1.5s ease-in-out infinite;
}
@keyframes seatPulse {
  0%, 100% { box-shadow: 0 0 16px rgba(251, 191, 36, 0.25), inset 0 0 12px rgba(251, 191, 36, 0.05); }
  50% { box-shadow: 0 0 30px rgba(251, 191, 36, 0.5), 0 0 60px rgba(251, 191, 36, 0.15), inset 0 0 20px rgba(251, 191, 36, 0.1); }
}
.seat.folded .seat-info {
  opacity: 0.3;
}
.seat .seat-avatar {
  font-size: 1.5rem;
  line-height: 1;
}
.seat .seat-name {
  font-weight: 600;
  font-size: 0.75rem;
  white-space: nowrap;
  max-width: 65px;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}
.seat .seat-chips {
  color: var(--gold);
  font-size: 0.7rem;
  font-weight: 700;
}
.seat .seat-bet {
  color: var(--green);
  font-size: 0.65rem;
  margin-top: 1px;
  font-weight: 600;
}

.seat .seat-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  color: #fff;
  font-size: 0.5rem;
  padding: 2px 6px;
  border-radius: 8px;
  font-weight: 700;
  line-height: 1.3;
}
.seat .seat-badge.dealer {
  background: var(--gold);
  color: #000;
}
.seat .seat-badge.sb {
  background: var(--green);
  color: #000;
}
.seat .seat-badge.bb {
  background: var(--red);
}

/* Opponent seats: horizontal layout (info left, cards right) */
.seat:not(.is-me) {
  flex-direction: row;
  align-items: center;
  gap: 4px;
}
.seat:not(.is-me) .seat-cards {
  display: flex;
  /* flex-direction: column; */
  gap: 1px;
}
.seat:not(.is-me) .seat-cards .card {
  width: 22px;
  height: 32px;
  font-size: 0.5rem;
  border-radius: 3px;
}

/* Bet amount inline with cards */
.seat-bet-inline {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 800;
  color: var(--gold);
  background: rgba(251, 191, 36, 0.12);
  border: 1px solid rgba(251, 191, 36, 0.25);
  border-radius: 6px;
  padding: 2px 6px;
  white-space: nowrap;
  min-height: 32px;
}

/* My seat: column layout (cards below, larger) */
.seat.is-me {
  flex-direction: column;
  align-items: center;
}
.seat-cards {
  display: flex;
  gap: 2px;
  margin-top: 3px;
}

/* ============================================
   CARDS
   ============================================ */
.card {
  width: 34px;
  height: 48px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  flex-shrink: 0;
  transition: transform 0.2s;
}
.card.face-up {
  background: linear-gradient(145deg, #fff 0%, #f0f0f0 100%);
  color: #333;
}
.card.face-up.hearts,
.card.face-up.diamonds {
  color: #dc2626;
}
.card.face-up.clubs,
.card.face-up.spades {
  color: #1a1a1a;
}
.card.face-down {
  background: linear-gradient(145deg, #2a3a7a, #1a2555);
  border: 1px solid rgba(100, 120, 200, 0.3);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}
.community-cards .card {
  width: 40px;
  height: 56px;
  font-size: 0.85rem;
  border-radius: 5px;
}

/* ============================================
   GAME ACTIONS
   ============================================ */
.game-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 10px;
  padding-bottom: calc(8px + var(--safe-bottom));
  background: linear-gradient(to top, var(--bg2), var(--bg));
  border-top: 1px solid var(--glass-border);
}
.actions-row {
  display: flex;
  gap: 6px;
}
.actions-row button {
  flex: 1;
  padding: 11px 6px;
  font-size: 0.85rem;
  border-radius: 10px;
}
.btn-fold {
  background: linear-gradient(135deg, #444, #333);
  color: #aaa;
  border: 1px solid rgba(255, 255, 255, 0.05);
}
.btn-check {
  background: linear-gradient(135deg, var(--green), #059669);
  color: #000;
}
.btn-call {
  background: linear-gradient(135deg, var(--blue), #2563eb);
  color: #fff;
}
.btn-allin {
  background: linear-gradient(135deg, var(--red), #dc2626);
  color: #fff;
  box-shadow: 0 2px 12px rgba(255, 77, 106, 0.2);
}

.raise-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  padding: 10px;
}

/* Pot preset buttons */
.pot-buttons {
  display: flex;
  gap: 5px;
}
.btn-pot {
  flex: 1;
  background: var(--bg);
  color: var(--gold);
  border: 1px solid var(--glass-border);
  padding: 10px 4px;
  font-size: 0.75rem;
  border-radius: 8px;
  transition: all 0.15s;
  font-weight: 600;
}
.btn-pot:active {
  background: var(--gold);
  color: #000;
}
.btn-pot.btn-pot-disabled {
  opacity: 0.25;
  cursor: not-allowed;
}
.btn-pot.btn-pot-disabled:active {
  background: var(--bg);
  color: var(--gold);
  transform: none;
}

/* Number input row: -BB [input] +BB */
.raise-input-row {
  display: flex;
  align-items: center;
  gap: 5px;
}
.btn-adjust {
  height: 42px;
  padding: 0 12px;
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--glass-border);
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  white-space: nowrap;
}
.btn-adjust:active {
  background: var(--orange);
  color: #000;
}

.raise-input {
  flex: 1;
  height: 42px;
  text-align: center;
  background: var(--bg);
  color: var(--orange);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  font-size: 1.1rem;
  font-weight: 800;
  outline: none;
  -moz-appearance: textfield;
  appearance: textfield;
}
.raise-input::-webkit-outer-spin-button,
.raise-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.raise-input:focus {
  border-color: var(--orange);
}

/* Slider row: min [slider] max */
.raise-slider-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.raise-min-label,
.raise-max-label {
  font-size: 0.6rem;
  color: var(--muted);
  white-space: nowrap;
  min-width: 24px;
}
.raise-min-label {
  text-align: right;
}
.raise-max-label {
  text-align: left;
}
#raise-slider {
  flex: 1;
  height: 32px;
  accent-color: var(--orange);
}

/* Raise button */
.btn-raise {
  background: linear-gradient(135deg, var(--orange), #d97706);
  color: #fff;
  width: 100%;
  padding: 13px 10px;
  font-size: 1rem;
  border-radius: 10px;
  box-shadow: 0 2px 12px rgba(245, 158, 11, 0.2);
  font-weight: 700;
}
.btn-raise #raise-label {
  font-weight: 800;
}

/* ============================================
   RESULT OVERLAY
   ============================================ */
/* ============================================
   RESULT BAR (inline, not overlay)
   ============================================ */
.result-overlay {
  display: none;
  flex-direction: column;
  gap: 8px;
  padding: 10px 14px;
  padding-bottom: calc(10px + var(--safe-bottom));
  background: linear-gradient(to top, var(--bg2), var(--bg));
  border-top: 1px solid rgba(251, 191, 36, 0.15);
  animation: resultSlideUp 0.3s ease;
}
@keyframes resultSlideUp {
  from { transform: translateY(30px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Winner banner (others folded) */
.result-bar-winner {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  padding: 4px 0;
}
.result-bar-crown { font-size: 1.2rem; line-height: 1; }
.result-bar-avatar { font-size: 1.4rem; line-height: 1; }
.result-bar-name { font-weight: 700; font-size: 1rem; color: var(--text); }
.result-bar-amount { font-weight: 800; font-size: 1.1rem; color: var(--gold); }
.result-bar-reason { font-size: 0.75rem; color: var(--muted); }

/* Showdown title */
.result-bar-title {
  text-align: center;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 2px;
  padding: 2px 0;
}

/* Showdown hands horizontal scroll */
.result-bar-hands {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 2px 0;
  scrollbar-width: none;
}
.result-bar-hands::-webkit-scrollbar { display: none; }

.result-hand-item {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  padding: 6px 10px;
  flex-shrink: 0;
}
.result-hand-item.is-winner {
  border-color: var(--gold);
  background: rgba(251, 191, 36, 0.08);
}
.result-hand-item.is-loser {
  opacity: 0.45;
}
.rhi-avatar { font-size: 1rem; flex-shrink: 0; }
.rhi-info { display: flex; flex-direction: column; min-width: 0; }
.rhi-name { font-size: 0.7rem; font-weight: 700; color: var(--text); white-space: nowrap; }
.rhi-hand { font-size: 0.6rem; color: var(--green); font-weight: 600; }
.rhi-cards { display: flex; gap: 2px; flex-shrink: 0; }
.rhi-cards .card { width: 26px; height: 36px; font-size: 0.5rem; }
.rhi-amount { font-size: 0.8rem; font-weight: 800; color: var(--gold); flex-shrink: 0; white-space: nowrap; }
.rhi-amount.rhi-amount-refund { color: var(--muted); font-weight: 600; font-size: 0.7rem; font-style: italic; }

/* Result footer: countdown + ready */
.result-bar-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}
.ready-countdown {
  font-size: 0.75rem; font-weight: 700;
  color: var(--orange); letter-spacing: 0.5px;
  min-height: 1.2em;
}
.ready-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 5px;
}
.ready-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--dim);
  font-size: 0.85rem;
  opacity: 0.35;
  transition: all 0.2s;
}
.ready-dot.is-ready {
  border-color: var(--green);
  opacity: 1;
  box-shadow: 0 0 10px rgba(52, 211, 153, 0.3);
}
.ready-count {
  width: 100%;
  text-align: center;
  font-size: 0.6rem;
  color: var(--muted);
  margin-top: 1px;
}
.btn-ready-next {
  background: linear-gradient(135deg, var(--green), #059669);
  color: #000;
  padding: 10px 24px;
  font-size: 0.9rem;
  font-weight: 700;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-ready-next:active { transform: scale(0.96); }
.btn-ready-next.btn-waiting {
  background: var(--dim);
  color: var(--muted);
}
.btn-ready-next:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ============================================
   WINNER CELEBRATION (on table)
   ============================================ */
.seat.winner .seat-info {
  border-color: var(--gold) !important;
  animation: winnerGlow 1.2s ease-in-out infinite !important;
}
@keyframes winnerGlow {
  0%, 100% { box-shadow: 0 0 20px rgba(251, 191, 36, 0.5), 0 0 50px rgba(251, 191, 36, 0.15); }
  50% { box-shadow: 0 0 35px rgba(251, 191, 36, 0.7), 0 0 70px rgba(251, 191, 36, 0.25); }
}
.seat.winner::before {
  content: '\1F451';
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 1.1rem;
  z-index: 10;
  animation: crownDrop 0.5s ease both;
  filter: drop-shadow(0 2px 8px rgba(251, 191, 36, 0.6));
}
@keyframes crownDrop {
  from { opacity: 0; transform: translateX(-50%) translateY(-15px) scale(0.3); }
  to { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

/* ============================================
   GAME WON OVERLAY
   ============================================ */
.game-won-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,0.85); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; animation: modalFadeIn 0.3s ease;
}
.gw-content {
  text-align: center; width: 100%; max-width: 360px;
  animation: modalSlideIn 0.4s ease;
}
.gw-title {
  font-size: 1.6rem; font-weight: 800; margin-bottom: 16px;
  background: linear-gradient(135deg, var(--gold), #f59e0b, var(--red));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.gw-winner-avatar {
  font-size: 3.5rem; margin-bottom: 6px;
  animation: gwBounce 0.6s ease;
}
.gw-winner-name {
  font-size: 1.2rem; font-weight: 700; color: var(--text); margin-bottom: 4px;
}
.gw-winner-chips {
  font-size: 1.1rem; font-weight: 800; color: var(--gold); margin-bottom: 20px;
}
.gw-rankings {
  background: var(--bg2); border: 1px solid var(--glass-border);
  border-radius: 14px; padding: 10px; margin-bottom: 14px;
  display: flex; flex-direction: column; gap: 4px;
}
.gw-rank-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: 8px;
}
.gw-gold { background: rgba(251,191,36,0.08); }
.gw-silver { background: rgba(160,160,176,0.08); }
.gw-bronze { background: rgba(205,127,50,0.08); }
.gw-rank-pos {
  width: 22px; text-align: center; font-size: 0.8rem; font-weight: 800; color: var(--muted);
}
.gw-gold .gw-rank-pos { color: var(--gold); }
.gw-silver .gw-rank-pos { color: #a0a0b0; }
.gw-bronze .gw-rank-pos { color: #cd7f32; }
.gw-rank-avatar { font-size: 1rem; }
.gw-rank-name {
  flex: 1; font-size: 0.75rem; font-weight: 600; color: var(--text);
  text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.gw-rank-chips { font-size: 0.75rem; font-weight: 700; color: var(--gold); }
.gw-note {
  font-size: 0.75rem; color: var(--muted); font-style: italic;
}
@keyframes gwBounce {
  0% { transform: scale(0.3); opacity: 0; }
  50% { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}

/* ============================================
   CUSTOM MODAL
   ============================================ */
.app-modal {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,0.7); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: modalFadeIn 0.2s ease;
}
.app-modal-box {
  background: var(--bg2); border: 1px solid var(--glass-border);
  border-radius: 16px; padding: 24px 22px 18px;
  width: 100%; max-width: 340px;
  text-align: center;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
  animation: modalSlideIn 0.2s ease;
}
.app-modal-msg {
  color: var(--text); font-size: 0.9rem; line-height: 1.5;
  margin-bottom: 18px; word-break: break-word;
}
.app-modal-btns {
  display: flex; gap: 8px; justify-content: center;
}
.app-modal-btns button {
  padding: 10px 24px; border-radius: 10px; border: none;
  font-size: 0.85rem; font-weight: 700; cursor: pointer;
  transition: opacity 0.2s;
}
.app-modal-btns button:hover { opacity: 0.85; }
.btn-modal-ok {
  background: linear-gradient(135deg, var(--green), #059669); color: #000;
}
.btn-modal-cancel {
  background: var(--glass); color: var(--muted);
  border: 1px solid var(--glass-border) !important;
}
.btn-modal-cancel:hover { color: var(--text); }
@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes modalSlideIn {
  from { opacity: 0; transform: scale(0.92) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

/* ============================================
   SEAT ACTION LABEL
   ============================================ */
.seat-action {
  font-size: 0.6rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
  text-align: center;
  margin-top: 3px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  animation: actionPop 0.3s ease both;
  white-space: nowrap;
}
@keyframes actionPop {
  from { opacity: 0; transform: scale(0.6); }
  to { opacity: 1; transform: scale(1); }
}
.act-fold { background: rgba(122,122,154,0.2); color: var(--muted); }
.act-call { background: rgba(59,130,246,0.2); color: var(--blue); }
.act-check { background: rgba(52,211,153,0.2); color: var(--green); }
.act-raise { background: rgba(245,158,11,0.2); color: var(--orange); }
.act-allin { background: rgba(255,77,106,0.25); color: var(--red); }
.act-default { background: rgba(255,255,255,0.08); color: var(--muted); }

/* ============================================
   AVATAR TIMER RING (on current player)
   ============================================ */
.seat-avatar-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
}
.seat-avatar-wrapper .seat-avatar {
  position: relative;
  z-index: 1;
}
.seat-timer-svg {
  position: absolute;
  inset: -4px;
  width: calc(100% + 8px);
  height: calc(100% + 8px);
  z-index: 0;
  transform: rotate(-90deg);
  filter: drop-shadow(0 0 4px rgba(52, 211, 153, 0.4));
}
.seat-timer-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.08);
  stroke-width: 2.5;
}
.seat-timer-fg {
  fill: none;
  stroke: var(--green);
  stroke-width: 3;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.25s linear, stroke 0.3s;
}
.seat-timer-fg.timer-warning {
  stroke: var(--orange);
  filter: drop-shadow(0 0 6px rgba(245, 158, 11, 0.5));
}
.seat-timer-fg.timer-danger {
  stroke: var(--red);
  filter: drop-shadow(0 0 8px rgba(255, 77, 106, 0.6));
  animation: timerUrgent 0.5s ease-in-out infinite;
}
@keyframes timerUrgent {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* ============================================
   BET CHIPS (between seat and pot)
   ============================================ */
.seat-bet-chip {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 4px;
  z-index: 3;
  pointer-events: none;
  animation: chipAppear 0.3s ease;
}
.bet-chip-icon {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--green), #059669);
  border: 2px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  flex-shrink: 0;
}
.bet-chip-amount {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--green);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
  white-space: nowrap;
}
@keyframes chipAppear {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.3); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* ============================================
   MY SEAT (is-me) + YOU BADGE
   ============================================ */
.seat.is-me .seat-info {
  border-color: rgba(59, 130, 246, 0.5);
  background: rgba(59, 130, 246, 0.08);
}
.seat.is-me.current .seat-info {
  border-color: var(--gold);
}
.seat.is-me .seat-name {
  color: #fff;
  font-weight: 700;
}
.seat.is-me .seat-cards .card {
  width: 42px;
  height: 60px;
  font-size: 0.8rem;
  border-radius: 5px;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.35);
}
.seat-you-badge {
  font-size: 0.45rem;
  color: var(--blue);
  font-weight: 800;
  letter-spacing: 2px;
  text-transform: uppercase;
  opacity: 0.7;
  margin-top: 1px;
}
.seat-status-allin {
  font-size: 0.6rem;
  font-weight: 800;
  color: #fff;
  background: var(--red);
  padding: 1px 6px;
  border-radius: 4px;
  margin-top: 2px;
  animation: allinPulse 1s ease-in-out infinite;
}
@keyframes allinPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 77, 106, 0.4); }
  50% { box-shadow: 0 0 0 4px rgba(255, 77, 106, 0); }
}

/* ============================================
   CARD ANIMATIONS
   ============================================ */
.card.card-anim {
  animation: cardDealIn 0.4s ease both;
}
@keyframes cardDealIn {
  from { opacity: 0; transform: scale(0.3) translateY(-20px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.community-cards {
  perspective: 600px;
}
.community-cards .card.card-anim {
  animation: cardFlipIn 0.5s ease both;
}
@keyframes cardFlipIn {
  0% { opacity: 0; transform: scale(0.5); }
  60% { opacity: 1; transform: scale(1.05); }
  100% { opacity: 1; transform: scale(1); }
}

/* ============================================
   DESKTOP (min-width: 768px)
   ============================================ */
@media (min-width: 768px) {
  .lobby-container h1 {
    font-size: 3.2rem;
  }
  .profile-form input,
  .join-row input,
  #room-name {
    font-size: 1.05rem;
  }

  .table-surface {
    width: 55vw;
    max-width: 700px;
    aspect-ratio: 2 / 1;
    border-width: 8px;
  }
  .seat-info {
    padding: 6px 14px;
    min-width: 105px;
    border-radius: 12px;
  }
  .seat .seat-avatar {
    font-size: 2rem;
  }
  .seat .seat-name {
    font-size: 0.85rem;
    max-width: 100px;
  }
  .seat .seat-chips {
    font-size: 0.75rem;
  }
  .seat .seat-bet {
    font-size: 0.7rem;
  }
  .seat .seat-badge {
    font-size: 0.55rem;
    padding: 2px 6px;
  }

  .card {
    width: 50px;
    height: 72px;
    font-size: 1rem;
    border-radius: 6px;
  }
  .community-cards .card {
    width: 60px;
    height: 86px;
    font-size: 1.15rem;
  }
  .community-cards {
    gap: 8px;
    margin-bottom: 10px;
  }
  .seat-cards {
    gap: 4px;
  }
  .seat:not(.is-me) .seat-cards .card {
    width: 28px;
    height: 40px;
    font-size: 0.6rem;
  }
  .pot-display {
    font-size: 1.6rem;
  }
  .stage-display {
    font-size: 0.9rem;
  }

  .game-actions {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    padding: 12px 20px;
    max-width: 750px;
    margin: 0 auto;
  }
  .actions-row {
    gap: 8px;
  }
  .actions-row button {
    padding: 12px 28px;
    font-size: 1rem;
    flex: 0 0 auto;
    border-radius: 12px;
  }
  .raise-section {
    flex-direction: row;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    flex: 1;
  }
  .pot-buttons {
    flex-direction: column;
    gap: 3px;
  }
  .btn-pot {
    padding: 6px 14px;
    font-size: 0.7rem;
    flex: 0;
  }
  .raise-input-row {
    flex: 0 0 auto;
  }
  .raise-input {
    width: 90px;
  }
  .raise-slider-row {
    flex: 1;
  }
  .btn-raise {
    width: auto;
    padding: 12px 28px;
    font-size: 1rem;
  }

  .action-log {
    width: 230px;
    max-height: 50vh;
  }
  .log-entry {
    font-size: 0.75rem;
  }
  .player-card {
    padding: 18px 26px;
    min-width: 130px;
  }

  .game-sidebar { width: 300px; }
  .chat-bubble { max-width: 220px; }
  .chat-text { font-size: 0.8rem; }
  .chat-input-row input { font-size: 0.85rem; padding: 12px 14px; }
  .chat-input-row button { padding: 12px 16px; font-size: 0.8rem; }
  .sidebar-rules-content { font-size: 0.8rem; }

  .seat-avatar-wrapper { width: 48px; height: 48px; }
  .seat.is-me .seat-cards .card { width: 56px; height: 80px; font-size: 1.05rem; border-radius: 6px; }
  .bet-chip-icon { width: 20px; height: 20px; }
  .bet-chip-amount { font-size: 0.75rem; }
  .seat-you-badge { font-size: 0.5rem; }
  .seat-status-allin { font-size: 0.65rem; padding: 2px 8px; }
}

/* ============================================
   TABLET (768px - 1024px)
   ============================================ */
@media (min-width: 768px) and (max-width: 1024px) {
  .game-sidebar { width: 220px; }
  .table-surface { width: 60vw; max-width: 500px; }
  .chat-bubble { max-width: 160px; }
  .sidebar-tab { font-size: 0.65rem; padding: 8px 4px; }
  .game-actions { max-width: 600px; }
  .raise-section { gap: 8px; }
  .seat-info { min-width: 90px; }
}

/* ============================================
   MOBILE (max-width: 767px) - sidebar as overlay
   ============================================ */
@media (max-width: 767px) {
  #game-screen { flex-direction: column; }
  .game-sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: 280px; z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 4px 0 24px rgba(0,0,0,0.5);
  }
  .game-sidebar.open { transform: translateX(0); }
  .game-sidebar.open ~ .sidebar-backdrop { display: block; }
  .btn-toggle-sidebar { display: block; }
  .btn-close-sidebar { display: block; }
  .game-main { flex: 1; }

  /* Compact action panel */
  .game-actions { padding: 5px 8px; gap: 4px; }
  .actions-row { gap: 4px; }
  .actions-row button { padding: 10px 4px; font-size: 0.82rem; border-radius: 8px; min-height: 44px; }
  .raise-section { padding: 6px 8px; gap: 4px; }
  .pot-buttons { gap: 3px; }
  .btn-pot { padding: 7px 2px; font-size: 0.65rem; min-height: 32px; }
  .raise-input-row { gap: 3px; }
  .btn-adjust { height: 36px; padding: 0 10px; font-size: 0.7rem; }
  .raise-input { height: 36px; font-size: 0.95rem; }
  #raise-slider { height: 28px; }
  .btn-raise { padding: 10px 8px; font-size: 0.9rem; min-height: 44px; }

  /* Bet chips mobile */
  .bet-chip-icon { width: 12px; height: 12px; }
  .bet-chip-amount { font-size: 0.55rem; }
}

/* ============================================
   LANDSCAPE MOBILE
   ============================================ */
@media (max-height: 500px) and (orientation: landscape) {
  .table-surface { width: 48vw; max-width: 400px; aspect-ratio: 5 / 3; border-width: 4px; }
  .game-actions { padding: 3px 8px; gap: 3px; }
  .actions-row button { padding: 6px 8px; font-size: 0.7rem; }
  #raise-slider { height: 24px; }
  .seat-info { padding: 2px 5px; min-width: 50px; }
  .seat .seat-avatar { font-size: 0.9rem; }
  .seat .seat-name { font-size: 0.5rem; }
  .seat .seat-chips { font-size: 0.45rem; }
  .card { width: 24px; height: 34px; font-size: 0.5rem; }
  .community-cards .card { width: 30px; height: 42px; font-size: 0.65rem; }
  .pot-display { font-size: 0.85rem; }
}

/* ============================================
   SMALL PHONES (max-width: 360px)
   ============================================ */
@media (max-width: 360px) {
  .lobby-container h1 { font-size: 1.9rem; }
  .table-surface { width: 92vw; }
  .card { width: 26px; height: 38px; font-size: 0.55rem; }
  .community-cards .card { width: 32px; height: 46px; font-size: 0.7rem; }
  .seat-info { min-width: 60px; padding: 4px 6px; }
  .seat .seat-name { font-size: 0.65rem; max-width: 52px; }
  .seat .seat-avatar { font-size: 1.2rem; }
  .seat .seat-chips { font-size: 0.6rem; }
  .actions-row button { padding: 9px 4px; font-size: 0.8rem; }
  .game-sidebar { width: 240px; }
}
