:root {
  --bg-dark: #1a1c20;
  --bg-panel: #2b2f36;
  --felt-green: #35654d;
  --wood-border: #5c3a1e;
  --gold: #f1c40f;
  --text-light: #ecf0f1;
  --text-dim: #bdc3c7;
  --btn-primary: #3498db;
  --btn-danger: #e74c3c;
  --btn-secondary: #2ecc71;
  --btn-tertiary: #9b59b6;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-light);
  overflow: hidden;
  height: 100vh;
}

.screen {
  display: none;
  height: 100vh;
  width: 100vw;
}
.screen.active { display: flex; flex-direction: column; align-items: center; justify-content: center; }

#screen-home,
#screen-host,
#screen-join,
#screen-rules {
  background: radial-gradient(ellipse at center, #1e3a2e 0%, #1a1c20 70%);
}
.home-container { text-align: center; z-index: 1; }
.logo { font-size: 4rem; font-weight: 800; margin-bottom: 0.5rem; letter-spacing: -1px; }
.logo span { color: var(--gold); }
.tagline { color: var(--text-dim); font-size: 1rem; margin-bottom: 2.5rem; }
.menu-buttons { display: flex; flex-direction: column; gap: 1rem; width: 300px; margin: 0 auto; }

.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  color: white;
  transition: filter 0.2s, transform 0.1s;
  white-space: nowrap;
}
.btn:hover { filter: brightness(1.15); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.35; cursor: not-allowed; }
.btn-primary { background: var(--btn-primary); }
.btn-secondary { background: var(--btn-secondary); }
.btn-tertiary { background: var(--btn-tertiary); }
.btn-danger { background: var(--btn-danger); }
.btn-allin { background: #d35400; }
.btn-full { width: 100%; margin-top: 0.75rem; }
.btn-tiny { padding: 6px 10px; font-size: 0.85rem; background: var(--bg-panel); border: 1px solid #555; border-radius: 4px; min-width: 36px; }
.btn-tiny:hover { filter: brightness(1.2); }
.btn-back { background: transparent; color: var(--text-dim); margin-bottom: 0.75rem; padding: 0; font-size: 0.9rem; }
.btn-back:hover { color: var(--text-light); }

.form-container, .rules-container {
  width: 90%;
  max-width: 380px;
  background: var(--bg-panel);
  padding: 1.5rem;
  border-radius: 12px;
  max-height: 90vh;
  overflow-y: auto;
  box-sizing: border-box;
}
.form-group { margin-bottom: 0.85rem; display: flex; flex-direction: column; }
.form-row { display: flex; gap: 0.75rem; }
.form-row .form-group { flex: 1; min-width: 0; }
.checkbox-group { display: flex; flex-direction: column; gap: 4px; }
.checkbox-group label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.checkbox-group small { color: var(--text-dim); font-size: 0.8rem; margin-left: 22px; }
label { margin-bottom: 0.4rem; font-size: 0.85rem; color: var(--text-dim); }
label small { color: #7f8c8d; }
input, select {
  padding: 9px 10px;
  border-radius: 6px;
  border: 1px solid #444;
  background: #1a1c20;
  color: white;
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  width: 100%;
  box-sizing: border-box;
}
input[type="checkbox"] { width: auto; }
.divider { text-align: center; margin: 1.25rem 0; color: var(--text-dim); position: relative; font-size: 0.85rem; }
.divider::before, .divider::after { content: ""; position: absolute; top: 50%; width: 40%; height: 1px; background: #444; }
.divider::before { left: 0; } .divider::after { right: 0; }

.rules-container { max-width: 500px; }
.rules-container h2 { margin-bottom: 1rem; font-size: 1.5rem; }
.rules-content p { line-height: 1.6; margin-bottom: 0.75rem; font-size: 0.92rem; color: var(--text-light); }
.rules-content .rules-intro { margin-bottom: 1.25rem; padding: 10px; background: rgba(52, 152, 219, 0.1); border-left: 3px solid var(--btn-primary); border-radius: 4px; }
.rules-content h3 { margin-top: 1.5rem; margin-bottom: 0.6rem; color: var(--gold); font-size: 1.05rem; }
.rules-content ol { padding-left: 1.8rem; margin-bottom: 1rem; }
.rules-content ol li { margin-bottom: 0.4rem; line-height: 1.5; font-size: 0.9rem; }
.rules-content ul { padding-left: 1.5rem; margin-bottom: 1rem; list-style: disc; }
.rules-content ul li { margin-bottom: 0.35rem; line-height: 1.5; font-size: 0.9rem; }

.rooms-list { margin-top: 0.75rem; max-height: 300px; overflow-y: auto; }
.room-item {
  background: #1a1c20;
  padding: 10px 12px;
  margin-bottom: 8px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid #3a3d44;
  transition: border-color 0.2s, background 0.2s;
}
.room-item:hover { background: #2b2f36; border-color: var(--btn-primary); }
.room-info-item { flex: 1; min-width: 0; }
.room-info-item b { font-size: 0.9rem; }
.room-info-item small { color: var(--text-dim); font-size: 0.78rem; }
.no-rooms { text-align: center; color: var(--text-dim); padding: 1.5rem; font-size: 0.9rem; }

#screen-game { display: none; flex-direction: row; height: 100vh; background: var(--bg-dark); overflow: hidden; align-items: stretch; justify-content: flex-start; }
#screen-game.active { display: flex; align-items: stretch; justify-content: flex-start; }

#sidebar {
  width: 200px;
  flex-shrink: 0;
  background: var(--bg-panel);
  border-right: 1px solid #3a3d44;
  padding: 12px;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.sidebar-section h3 { font-size: 0.8rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 8px; }
.sidebar-player, .sidebar-spectator {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 8px;
  margin-bottom: 4px;
  background: #1a1c20;
  border-radius: 4px;
  font-size: 0.82rem;
  overflow: hidden;
  gap: 4px;
}
.sidebar-player.me { border-left: 3px solid var(--gold); }
.sidebar-player .sp-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }
.sidebar-player .sp-chips { color: var(--gold); font-size: 0.78rem; flex-shrink: 0; }
.sidebar-player.folded .sp-name { opacity: 0.4; text-decoration: line-through; }
.sidebar-player .sp-status { font-size: 0.65rem; color: var(--text-dim); }
.sidebar-spectator { flex-wrap: wrap; }
.sidebar-spectator .sp-name { color: var(--btn-tertiary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }
.sidebar-spectator.wants-join { background: rgba(155, 89, 182, 0.2); }
.sidebar-spectator .join-tag { font-size: 0.6rem; color: var(--btn-tertiary); flex-shrink: 0; }
#spectator-join-area, #rebuy-area, #rebuy-pending-area { margin-top: auto; padding-top: 8px; border-top: 1px solid #3a3d44; }
.btn-small-text { font-size: 0.8rem; padding: 8px 6px; line-height: 1.2; }

/* NOTIFICATION BADGE on settings gear */
.btn-notification-wrapper { position: relative; display: inline-block; }
.notification-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--btn-danger);
  color: white;
  font-size: 0.6rem;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  box-shadow: 0 0 6px rgba(231, 76, 60, 0.8);
  animation: badge-pulse 1.5s infinite;
  z-index: 10;
}
.notification-badge.show { display: flex; }
@keyframes badge-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

#table-container { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: space-between; position: relative; min-height: 0; gap: 0; padding: 0; }

#top-bar { display: flex; justify-content: space-between; padding: 10px 20px; background: var(--bg-panel); align-items: center; z-index: 10; flex-shrink: 0; border-bottom: 1px solid #3a3d44; gap: 24px; width: 100%; border-radius: 0; }
.room-info { font-size: 0.85rem; color: var(--text-dim); display: flex; align-items: center; gap: 10px; }
.room-info span { white-space: nowrap; }
.top-actions { display: flex; gap: 8px; flex-shrink: 0; }

#poker-table {
  width: min(70vw, 700px);
  height: min(55vh, 450px);
  background: var(--felt-green);
  border: 6px solid var(--wood-border);
  border-radius: 50%;
  position: relative;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  flex-shrink: 0;
}

#community-cards { display: flex; gap: 4px; position: absolute; top: 42%; left: 50%; transform: translate(-50%, -50%); }
#pot-display { position: absolute; top: 62%; left: 50%; transform: translate(-50%, 0); font-weight: 800; color: var(--gold); font-size: 1.1rem; text-shadow: 0 2px 4px rgba(0,0,0,0.5); white-space: nowrap; }

.start-overlay {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  z-index: 30;
}
.start-overlay.hidden { display: none; }
.btn-start {
  background: var(--btn-secondary);
  font-size: 1.3rem;
  padding: 14px 40px;
  border-radius: 10px;
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(46, 204, 113, 0.5); }
  50% { box-shadow: 0 0 0 12px rgba(46, 204, 113, 0); }
}
.waiting-text { color: var(--text-dim); font-size: 1rem; margin-top: 10px; }
.next-hand-text { color: var(--gold); font-size: 1.2rem; font-weight: 700; margin-bottom: 8px; }

.next-hand-overlay {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  z-index: 40;
}
.next-hand-overlay.hidden { display: none; }
.next-hand-box {
  background: rgba(26, 28, 32, 0.92);
  border: 2px solid var(--gold);
  border-radius: 12px;
  padding: 24px 32px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0,0,0,0.7);
  max-width: 320px;
}

.card { width: 46px; height: 64px; background: white; border-radius: 4px; display: flex; flex-direction: column; justify-content: space-between; padding: 3px; color: black; box-shadow: 0 2px 4px rgba(0,0,0,0.2); font-weight: 600; }
.card.red { color: #e74c3c; }
.card-back { background: #2c3e50; border: 2px solid #34495e; }
.card-back::after { content: ""; }
.card-rank { font-size: 14px; }
.card-suit { font-size: 18px; text-align: right; }

.seat {
  position: absolute;
  width: 85px;
  background: rgba(0,0,0,0.65);
  border-radius: 8px;
  padding: 4px;
  text-align: center;
  transition: all 0.3s ease;
  border: 2px solid transparent;
}
.seat.active { border-color: var(--gold); box-shadow: 0 0 12px var(--gold); }
.seat.folded { opacity: 0.3; }
.seat.empty { background: rgba(0,0,0,0.3); border: 2px dashed #555; }
.seat.empty .seat-name { color: var(--text-dim); font-style: italic; }
.seat-cards { display: flex; gap: 2px; justify-content: center; margin-bottom: 3px; }
.seat-cards .card { width: 26px; height: 36px; padding: 1px; }
.seat-cards .card .card-rank { font-size: 9px; }
.seat-cards .card .card-suit { font-size: 11px; }
.seat-name { font-size: 0.72rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seat-chips { font-size: 0.72rem; color: var(--gold); }
.seat-bet { position: absolute; background: #111; padding: 2px 6px; border-radius: 10px; font-size: 0.65rem; color: var(--gold); bottom: -16px; left: 50%; transform: translateX(-50%); white-space: nowrap; }
.dealer-button { position: absolute; top: -8px; right: -8px; width: 18px; height: 18px; background: white; color: black; border-radius: 50%; font-size: 10px; font-weight: bold; display: flex; align-items: center; justify-content: center; }

#action-bar { width: 100%; max-width: 580px; padding: 10px 14px; background: var(--bg-panel); border-radius: 0; flex-shrink: 0; margin: 0 auto; }
.turn-indicator {
  text-align: center;
  color: var(--gold);
  font-weight: 800;
  font-size: 1rem;
  padding: 4px;
  animation: blink 1s infinite;
}
.turn-indicator.hidden { display: none; }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
.action-status { text-align: center; font-size: 0.82rem; color: var(--text-dim); margin-bottom: 6px; min-height: 1.2em; }
#timer-bar-container { position: relative; width: 100%; height: 20px; background: #444; border-radius: 10px; margin-bottom: 8px; overflow: hidden; display: none; }
#timer-bar { height: 100%; width: 100%; background: var(--btn-secondary); transition: background 0.3s; }
#timer-text { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); font-size: 0.75rem; font-weight: 700; color: white; text-shadow: 0 1px 2px rgba(0,0,0,0.8); }
.actions-row { display: flex; gap: 8px; align-items: center; justify-content: center; flex-wrap: wrap; min-height: 44px; }
.raise-control { display: flex; gap: 4px; align-items: center; }
.raise-control input { width: 70px; text-align: center; }

#chat-container { position: fixed; right: 0; top: 0; height: 100vh; width: 280px; background: var(--bg-panel); border-left: 1px solid #444; display: flex; flex-direction: column; transform: translateX(100%); transition: transform 0.3s; z-index: 150; }
#chat-container.active { transform: translateX(0); }
.chat-header { display: flex; justify-content: space-between; align-items: center; padding: 10px; border-bottom: 1px solid #444; flex-shrink: 0; }
.chat-header h3 { font-size: 0.95rem; }
#chat-messages { flex: 1; overflow-y: auto; padding: 10px; }
.chat-msg { margin-bottom: 6px; font-size: 0.85rem; line-height: 1.4; word-wrap: break-word; }
.chat-msg b { color: var(--btn-primary); }
.chat-msg.spectator b { color: var(--btn-tertiary); }
.chat-input-row { display: flex; padding: 8px; gap: 4px; flex-shrink: 0; }
.chat-input-row input { flex: 1; min-width: 0; }
.chat-spectator-notice { padding: 10px; font-size: 0.78rem; color: var(--text-dim); text-align: center; font-style: italic; flex-shrink: 0; border-top: 1px solid #444; }
.emoji-picker { display: grid; grid-template-columns: repeat(5, 1fr); padding: 8px; gap: 4px; flex-shrink: 0; }
.emoji-picker span { font-size: 22px; cursor: pointer; text-align: center; }

@keyframes floatUp { 0% { transform: translateY(0) scale(0.5); opacity: 0; } 20% { opacity: 1; transform: translateY(-20px) scale(1.5); } 100% { transform: translateY(-80px) scale(1); opacity: 0; } }
.floating-emoji { position: absolute; font-size: 32px; pointer-events: none; animation: floatUp 2s forwards; z-index: 100; }

.win-banner {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: linear-gradient(135deg, #f1c40f, #e67e22);
  color: #1a1c20;
  padding: 6px 16px;
  border-radius: 16px;
  font-weight: 700;
  font-size: 0.85rem;
  max-width: 90%;
  text-align: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 50;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.win-banner.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.modal {
  display: none;
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  background: rgba(0,0,0,0.75);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
.modal.show { display: flex; }
.modal-content {
  background: var(--bg-panel);
  padding: 1.5rem;
  border-radius: 12px;
  width: 90%;
  max-width: 380px;
  max-height: 85vh;
  overflow-y: auto;
  box-sizing: border-box;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.modal-header h2 { font-size: 1.3rem; }
.settings-group { margin-bottom: 1.25rem; padding-bottom: 1.25rem; border-bottom: 1px solid #3a3d44; }
.settings-group:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.settings-group h3 { font-size: 0.95rem; margin-bottom: 4px; }
.setting-desc { font-size: 0.8rem; color: var(--text-dim); margin-bottom: 8px; line-height: 1.4; }
.setting-status { font-size: 0.85rem; margin-bottom: 8px; }
.setting-status span { font-weight: 700; color: var(--gold); }
.settings-group select { margin-bottom: 10px; }
.settings-action-btn { margin-top: 10px; }

.host-notifications { display: flex; flex-direction: column; gap: 8px; }
.notification-card {
  background: #1a1c20;
  border: 1px solid var(--gold);
  border-radius: 8px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.notification-card .notif-title { font-size: 0.85rem; font-weight: 600; color: var(--gold); }
.notification-card .notif-detail { font-size: 0.8rem; color: var(--text-dim); }
.notification-card .notif-actions { display: flex; gap: 6px; align-items: center; }
.notification-card .notif-actions input { width: 70px; text-align: center; padding: 4px 6px; font-size: 0.8rem; }
.notification-card .notif-actions button { padding: 4px 10px; font-size: 0.78rem; }
.no-notifications { text-align: center; color: var(--text-dim); font-size: 0.82rem; padding: 8px; }

.rebuy-modal-content { max-width: 340px; }
.rebuy-amount-input { font-size: 1.5rem; text-align: center; padding: 12px; }

@media (max-width: 768px) {
  #sidebar { width: 140px; padding: 8px; }
  .sidebar-player, .sidebar-spectator { font-size: 0.72rem; padding: 4px 6px; }
  #poker-table { width: 85vw; height: 40vh; }
  .seat { width: 72px; }
  .seat-name { font-size: 0.65rem; }
  .seat-chips { font-size: 0.65rem; }
  #chat-container { width: 100%; height: 60vh; bottom: 0; top: auto; }
  .raise-control input { width: 55px; }
  .btn { padding: 8px 14px; font-size: 0.88rem; }
  .logo { font-size: 3rem; }
  .actions-row { gap: 4px; }
}