/* ── Reset & base ─────────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #0f0f13;
  --surface: #1a1a24;
  --surface2: #22222f;
  --border: #2e2e3e;
  --accent: #7c6af7;
  --accent-hover: #9585ff;
  --accent-dim: rgba(124, 106, 247, 0.15);
  --text: #f0f0f5;
  --text-muted: #8888aa;
  --success: #4ade80;
  --danger: #f87171;
  --radius: 16px;
  --radius-sm: 10px;
  --font: 'Inter', system-ui, sans-serif;
}

/* Per-role colors are NOT CSS variables — they live in games/lobo.js's
   ROLES (one `color` field per role) and are turned into CSS at runtime by
   public/js/role-styles.js. See [[08 - Juego Lobo]] in Obsidian. */

html,
body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ── Layout ────────────────────────────────────────────────────────────── */
.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 20px;
}

.card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
}

/* ── Logo / Brand ──────────────────────────────────────────────────────── */
.logo {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -1px;
  color: var(--text);
  margin-bottom: 4px;
}

.logo span {
  color: var(--accent);
}

.tagline {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 32px;
}

/* ── Typography ────────────────────────────────────────────────────────── */
h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 20px;
}

.section-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}

/* Boxed group of roles by team (Lobos/Pueblo/Libres) — used in both the role
   picker (lobo.settings.js) and the instructions modal (lobo.js). */
.team-box {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 10px 12px;
  margin-bottom: 10px;
}

.team-box:last-child {
  margin-bottom: 0;
}

.team-box .section-label {
  margin-bottom: 8px;
}

.team-box .option-row+.option-row {
  margin-top: 6px;
}

/* ── Forms ─────────────────────────────────────────────────────────────── */
.field {
  margin-bottom: 16px;
}

input[type="text"] {
  width: 100%;
  padding: 14px 16px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 1rem;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.15s;
}

input[type="text"]:focus {
  border-color: var(--accent);
}

input[type="text"]::placeholder {
  color: var(--text-muted);
}

/* Code input — big letters */
.code-input {
  text-transform: uppercase;
  letter-spacing: 0.3em;
  font-size: 1.5rem;
  font-weight: 700;
  text-align: center;
}

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:not(:disabled):hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:not(:disabled):hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover {
  color: var(--text);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

/* ── Divider ────────────────────────────────────────────────────────────── */
.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── Room code display ─────────────────────────────────────────────────── */
.room-code {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 18px;
  margin-bottom: 16px;
}

.room-code-letters {
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: 0.2em;
  color: var(--accent);
}

.copy-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
  transition: color 0.15s;
}

.copy-btn:hover {
  color: var(--accent);
}

/* ── Player list ────────────────────────────────────────────────────────── */
.player-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
  max-height: 260px;
  overflow-y: auto;
}

.player-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  animation: slideIn 0.2s ease;
}

.player-item .avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
}

.player-item .player-name {
  flex: 1;
}

.player-item .host-badge {
  font-size: 0.65rem;
  background: var(--accent-dim);
  color: var(--accent);
  border-radius: 4px;
  padding: 2px 6px;
  font-weight: 600;
}

/* ── Player count ───────────────────────────────────────────────────────── */
.player-count {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

/* ── Game picker ────────────────────────────────────────────────────────── */
.game-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.game-item {
  padding: 14px 16px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.game-item:hover,
.game-item.selected {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.game-item-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.game-item-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.game-item-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── Game options (config controls) ─────────────────────────────────────── */
.game-options {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.option-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.option-row+.option-row {
  margin-top: 6px;
}

.option-label {
  font-size: 0.9rem;
  font-weight: 500;
}

/* Stepper (number) */
.stepper {
  display: flex;
  align-items: center;
  gap: 4px;
}

.stepper button {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, color 0.15s;
}

.stepper button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.stepper-value {
  min-width: 34px;
  text-align: center;
  font-weight: 700;
  font-size: 1rem;
  -moz-appearance: textfield;
}

.stepper-value::-webkit-outer-spin-button,
.stepper-value::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Toggle (boolean) */
.toggle {
  width: 48px;
  height: 28px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  position: relative;
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s;
  flex-shrink: 0;
}

.toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: transform 0.18s, background 0.18s;
}

.toggle.on {
  background: var(--accent-dim);
  border-color: var(--accent);
}

.toggle.on::after {
  transform: translateX(20px);
  background: var(--accent);
}

/* Segmented (select) */
.segmented {
  display: flex;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
}

.segmented button {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.segmented button.on {
  background: var(--accent);
  color: #fff;
}

/* ── Toast ──────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 20px;
  font-size: 0.875rem;
  color: var(--text);
  transition: transform 0.25s ease;
  z-index: 1000;
  white-space: nowrap;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

.toast.success {
  border-color: var(--success);
  color: var(--success);
}

.toast.error {
  border-color: var(--danger);
  color: var(--danger);
}

/* ── QR ─────────────────────────────────────────────────────────────────── */
.qr-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.qr-wrap img {
  width: 160px;
  height: 160px;
  border-radius: var(--radius-sm);
  background: #fff;
  padding: 8px;
}

/* ── Status dot ─────────────────────────────────────────────────────────── */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 6px var(--success);
  animation: pulse 2s infinite;
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.4;
  }
}

/* ── Game area ──────────────────────────────────────────────────────────── */
.game-area {
  width: 100%;
  max-width: 420px;
  padding: 0 20px 40px;
}

/* ── Animations ─────────────────────────────────────────────────────────── */
@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.fade-in {
  animation: fadeIn 0.3s ease;
}

/* ── Global menu ────────────────────────────────────────────────────────── */
.menu-btn {
  position: fixed;
  top: 16px;
  right: 16px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 900;
}

.menu-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

#instructions-btn {
  right: 68px;
}

.menu-overlay {
  position: fixed;
  inset: 0;
  z-index: 950;
}

.menu-panel {
  position: fixed;
  top: 64px;
  right: 16px;
  min-width: 200px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
}

.menu-item {
  text-align: left;
  background: none;
  border: none;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.95rem;
  padding: 11px 14px;
  border-radius: 8px;
  cursor: pointer;
}

.menu-item:hover {
  background: var(--surface2);
}

.menu-item.danger {
  color: var(--danger);
}

/* ── Menu collapsible groups ────────────────────────────────────────────── */
.menu-group {
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid var(--border);
  padding-bottom: 4px;
  margin-bottom: 4px;
}

.menu-group:last-of-type {
  border-bottom: none;
  padding-bottom: 0;
  margin-bottom: 0;
}

.menu-group-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  user-select: none;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}

.menu-group-header:hover {
  background: var(--surface2);
  color: var(--text);
}

.menu-group-header .menu-group-chevron {
  font-size: 0.8rem;
  transition: transform 0.2s ease;
}

.menu-group.collapsed .menu-group-chevron {
  transform: rotate(-90deg);
}

.menu-group-items {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-left: 8px;
  max-height: 500px;
  opacity: 1;
  overflow: hidden;
  transition: max-height 0.25s ease-out, opacity 0.2s ease-out, padding 0.2s ease-out;
}

.menu-group.collapsed .menu-group-items {
  max-height: 0;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
  pointer-events: none;
}


/* ── Generic overlay / modal ────────────────────────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 15, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
  animation: fadeIn 0.15s ease;
}

.overlay-panel {
  width: 100%;
  max-width: 380px;
  max-height: 80vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.overlay-panel .player-list button {
  width: 100%;
}

.instructions p {
  font-size: 0.9rem;
  line-height: 1.5;
  margin-bottom: 10px;
}

.instructions strong {
  color: var(--text);
}

/* ── Role card (Lobo) ───────────────────────────────────────────────────── */
.role-card {
  position: relative;
  min-height: 180px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
  margin-top: 8px;
}

.role-card.covered {
  border-color: var(--accent) !important;
}

/* Per-role border/name colors are generated at runtime by public/js/role-styles.js
   from each role's own `color` field in games/lobo.js's ROLES — see
   [[08 - Juego Lobo]] in Obsidian for why this replaced ~120 lines of
   hand-duplicated per-role CSS. */

.role-reveal {
  padding: 24px;
  text-align: center;
}

.role-name {
  font-size: 1.6rem;
  font-weight: 800;
}

.role-desc {
  margin-top: 8px;
}

.role-cover {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.95rem;
}

.role-card:not(.covered) .role-cover {
  display: none;
}

.role-card.covered .role-reveal {
  visibility: hidden;
}

.confirm-row {
  display: flex;
  gap: 8px;
}

.confirm-row .btn {
  flex: 1;
}

/* ── Roster (narrator) ──────────────────────────────────────────────────── */
.roster-row {
  cursor: pointer;
}

.roster-row:hover {
  border: 1px solid var(--border);
}

.roster-row.dead {
  opacity: 0.45;
}

.roster-row.dead .player-name {
  text-decoration: line-through;
}

.role-tag {
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: 5px;
  padding: 3px 8px;
}

/* Per-role .role-tag background/color also generated by role-styles.js */

/* Start screen badge colors */
.start-role-badge {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 0.85rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  transition: all 0.2s ease;
}

.start-role-badge strong {
  color: var(--text);
}

.start-role-badge:hover {
  transform: translateY(-1px);
}

.role-badge-probable {
  border-style: dashed;
}

/* Per-role .role-badge-X border-color also generated by role-styles.js */

.start-screen-card {
  animation: fadeInStart 0.4s ease-out;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
}

@keyframes fadeInStart {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.seer-result {
  text-align: center;
  padding: 16px 0;
}

/* Presentación grande para Vidente y Muerte */
.player-name-large {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
}

.text-es {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 6px 0;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.text-era {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  font-weight: 600;
}

.role-reveal-large {
  font-size: 2.8rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: -0.5px;
  margin: 12px 0;
}

/* Per-role .role-reveal-large color/glow also generated by role-styles.js —
   this used to hand-list only 7 of ~28 roles here (the rest silently had no
   glow); generating it from the same source as everything else fixes that. */

.dead-role-reveal {
  padding: 16px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
}

/* ── Lobo settings ──────────────────────────────────────────────────────── */
.lobo-budget {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.lobo-budget.over {
  color: var(--danger);
  font-weight: 600;
}

.lobo-warning {
  font-size: 0.8rem;
  color: var(--danger);
  margin-top: 8px;
  min-height: 1em;
}

.select {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-family: var(--font);
  font-size: 0.9rem;
  outline: none;
}

.select:focus {
  border-color: var(--accent);
}

/* ── Profile bar ───────────────────────────────────────────────────────── */
.profile-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface2);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.profile-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar-sm {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent);
}

.profile-name-text {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.profile-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s;
}

.profile-btn:hover {
  color: var(--accent);
}

/* ── Tabs (Rooms / Scoreboard Navigation) ─────────────────────────── */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  gap: 8px;
}

.tab-btn {
  flex: 1;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  padding: 12px 0;
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.tab-btn:hover {
  color: var(--text);
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-content.hidden {
  display: none !important;
}

/* ── Scoreboard / Group Ranking ────────────────────────────────────────── */
.score-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.select-sm {
  padding: 4px 8px;
  font-size: 0.8rem;
  border-radius: 6px;
}

.scoreboard-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
}

.scoreboard-table th,
.scoreboard-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.scoreboard-table th {
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.05em;
}

.scoreboard-table tr:last-child td {
  border-bottom: none;
}

.scoreboard-table td.pos {
  font-weight: 700;
  color: var(--accent);
  width: 30px;
}

.scoreboard-table td.name {
  font-weight: 600;
}

.scoreboard-table td.wins {
  text-align: right;
  font-weight: 700;
}

.wins-split {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Emoji selector (Group Creation) ────────────────────────────────────── */
.emoji-selector {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin: 12px 0;
}

.emoji-option {
  font-size: 1.5rem;
  padding: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  text-align: center;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.emoji-option:hover,
.emoji-option.selected {
  background: var(--accent-dim);
  border-color: var(--accent);
}

/* ── Group settings list ────────────────────────────────────────────────── */
.group-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 6px;
}

.group-list-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.9rem;
}

.group-list-code {
  font-size: 0.75rem;
  font-family: monospace;
  color: var(--accent);
  background: var(--accent-dim);
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.05em;
}

/* ── Utilities ──────────────────────────────────────────────────────────── */
.mt-8 {
  margin-top: 8px;
}

.mt-12 {
  margin-top: 12px;
}

.mt-16 {
  margin-top: 16px;
}

.mt-20 {
  margin-top: 20px;
}

.mt-24 {
  margin-top: 24px;
}

.mt-32 {
  margin-top: 32px;
}

.mb-8 {
  margin-bottom: 8px;
}

.mb-12 {
  margin-bottom: 12px;
}

.mb-16 {
  margin-bottom: 16px;
}

.mb-20 {
  margin-bottom: 20px;
}

.mb-24 {
  margin-bottom: 24px;
}

.mb-32 {
  margin-bottom: 32px;
}

.text-center {
  text-align: center;
}

.text-muted {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.hidden {
  display: none !important;
}

/* ── Dev utilities ──────────────────────────────────────────────────────── */
.dev-actions-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
}

.btn-dev-subtle {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.725rem;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.btn-dev-subtle:hover {
  color: var(--text);
  border-color: var(--text-muted);
  background: var(--surface2);
}

/* ── Kick buttons ───────────────────────────────────────────────────────── */
.kick-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  margin-left: auto;
  padding: 4px 8px;
  transition: color 0.15s;
}

.kick-btn:hover {
  color: var(--danger);
}

/* ── Offline players ────────────────────────────────────────────────────── */
.player-item.offline {
  opacity: 0.55;
  border-style: dashed;
}

.player-item.offline .player-name {
  color: var(--text-muted);
}

.offline-badge {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-left: 8px;
}

/* ── Countdown overlay ──────────────────────────────────────────────────── */
.countdown-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 15, 19, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.countdown-num {
  font-size: 10rem;
  font-weight: 800;
  color: var(--accent);
  text-shadow: 0 0 30px var(--accent-dim);
  animation: countdown-pulse 0.8s ease-in-out infinite;
}

@keyframes countdown-pulse {
  0% {
    transform: scale(0.5);
    opacity: 0;
  }

  15% {
    transform: scale(1.15);
    opacity: 1;
  }

  75% {
    transform: scale(1);
    opacity: 1;
  }

  100% {
    transform: scale(0.85);
    opacity: 0;
  }
}

/* ── Victory overlay ────────────────────────────────────────────────────── */
.victory-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 24px;
  animation: fade-in 0.3s ease-out forwards;
}

.victory-overlay.victory-pueblo {
  background: radial-gradient(circle, rgba(67, 56, 202, 0.95) 0%, rgba(15, 15, 19, 0.98) 100%);
  border-top: 5px solid var(--accent);
}

.victory-overlay.victory-lobos {
  background: radial-gradient(circle, rgba(127, 29, 29, 0.95) 0%, rgba(15, 15, 19, 0.98) 100%);
  border-top: 5px solid var(--danger);
}

.victory-title {
  font-size: 2.5rem;
  font-weight: 900;
  letter-spacing: -1px;
  margin-bottom: 12px;
  text-align: center;
  animation: slide-up 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.victory-overlay.victory-pueblo .victory-title {
  color: #c7d2fe;
  text-shadow: 0 0 20px rgba(99, 102, 241, 0.5);
}

.victory-overlay.victory-lobos .victory-title {
  color: #fca5a5;
  text-shadow: 0 0 20px rgba(239, 68, 68, 0.5);
}

.victory-desc {
  font-size: 1.125rem;
  color: var(--text-muted);
  margin-bottom: 32px;
  text-align: center;
  max-width: 320px;
  line-height: 1.5;
  animation: slide-up 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.victory-overlay .btn {
  max-width: 200px;
  animation: slide-up 0.7s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes slide-up {
  0% {
    transform: translateY(20px);
    opacity: 0;
  }

  100% {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ── Poker Game styles ────────────────────────────────────────────────── */
.poker-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
}

.poker-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 12px 16px;
  border-radius: var(--radius);
}

.poker-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.85rem;
}

.poker-phase-badge {
  background: var(--accent-dim);
  color: var(--accent);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 800;
  border: 1px solid rgba(124, 106, 247, 0.3);
}

.poker-table-wrapper {
  position: relative;
  width: 100%;
  padding-bottom: 74%;
  /* Aspect ratio wrapper */
  background: transparent;
  margin-bottom: 24px;
  /* Push the action panel down so it doesn't clash with the bottom seat */
}

.poker-table {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle, #1a4f32 0%, #0d2c1b 100%);
  border: 12px solid #5c3a21;
  /* Wood trim */
  border-radius: 50%;
  /* Oval shape — 50% always fits a true ellipse to the box's actual aspect
     ratio, unlike a fixed px radius (120px) which only lines up with the
     inner dashed line at one specific box size and drifts off-contour at
     others. */
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.8), 0 8px 16px rgba(0, 0, 0, 0.4);
  overflow: visible;
  /* Let player nodes extend slightly out */
}

.poker-felt {
  position: absolute;
  /* Same percentage on all four sides (not a flat px margin, and not
     different percentages per axis) keeps this an exactly scaled-down copy
     of .poker-table's ellipse — same center, same aspect ratio — so the
     dashed line stays evenly parallel to the outer border all the way
     around, including at the pointed oval ends. */
  inset: 2%;
  border: 2px dashed rgba(255, 255, 255, 0.12);
  /* Betting line */
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.poker-pot-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #facc15;
  padding: 8px 16px;
  border-radius: 24px;
  border: 1px solid #eab308;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
}

.poker-pot-title {
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  font-weight: 700;
  color: #111111;
}

.poker-pot-amount {
  font-size: 1.15rem;
  font-weight: 800;
  color: #111111;
}

.poker-seat {
  position: absolute;
  transform: translate(-50%, -50%) scale(var(--seat-scale, 1));
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 72px;
  z-index: 10;
  transition: opacity 0.3s, transform 0.3s;
}

.poker-seat.folded {
  opacity: 0.4;
}

.poker-seat.offline {
  opacity: 0.5;
}

.poker-avatar {
  position: relative;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--surface2);
  border: 2px solid var(--border);
  color: var(--text);
  font-size: 1.1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.25);
  transition: all 0.2s ease-in-out;
}

.poker-seat.active-turn .poker-avatar {
  border-color: var(--accent);
  box-shadow: 0 0 12px var(--accent);
  animation: turn-pulse 1.5s infinite alternate;
}

@keyframes turn-pulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 4px var(--accent);
  }

  100% {
    transform: scale(1.08);
    box-shadow: 0 0 14px var(--accent);
  }
}

.poker-dealer-badge {
  position: absolute;
  bottom: -4px;
  right: -4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  color: #1a1a24;
  border: 1px solid #777;
  font-size: 0.65rem;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.poker-allin-badge {
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--danger);
  color: #fff;
  font-size: 0.55rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.5px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.poker-player-info {
  background: rgba(15, 15, 19, 0.95);
  border: 1px solid var(--border);
  padding: 6px 6px;
  border-radius: 8px;
  margin-top: 4px;
  width: 80px;
  text-align: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.poker-player-name {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.poker-player-stack {
  font-size: 0.7rem;
  font-weight: 700;
  color: #facc15;
}

.poker-player-bet {
  font-size: 0.8rem;
  font-weight: 800;
  color: #111;
  background: #facc15;
  border-radius: 6px;
  margin-top: 5px;
  padding: 3px 8px;
  display: inline-block;
  line-height: 1.15;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

.poker-bet-bubble {
  position: absolute;
  transform: translate(-50%, -50%);
  background: #facc15;
  color: #111;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 12px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4);
  border: 1px solid #eab308;
  display: flex;
  align-items: center;
  gap: 2px;
  z-index: 5;
}

.poker-actions-panel {
  width: 100%;
}

.poker-decision-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.poker-decision-row {
  display: flex;
  gap: 12px;
}

.poker-raise-section {
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.poker-raise-readout {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
}

.poker-slider {
  width: 100%;
  accent-color: var(--accent);
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  outline: none;
}

.poker-quick-raise-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.poker-quick-raise-row .btn {
  padding: 6px 0;
  font-size: 0.75rem;
  margin: 0;
  flex: 1;
}

.poker-host-panel {
  width: 100%;
}

.host-controls-card {
  background: var(--surface);
  border: 1px dashed var(--accent);
  border-radius: var(--radius);
  padding: 16px;
}

.poker-winners-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 180px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px;
}

.poker-winner-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.poker-winner-checkbox {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.poker-winner-name {
  font-size: 0.85rem;
  font-weight: 600;
}

.poker-select {
  width: 100%;
  padding: 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  outline: none;
  font-family: var(--font);
}

.poker-input {
  width: 100%;
  padding: 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  outline: none;
  font-family: var(--font);
}

/* Responsive Mobile Adjustments */
@media (max-width: 480px) {
  .card {
    padding: 16px 12px !important;
  }

  /* Horizontal scrollable action list */
  .poker-decision-row {
    display: flex !important;
    flex-direction: row !important;
    overflow-x: auto !important;
    white-space: nowrap !important;
    gap: 8px !important;
    padding-bottom: 6px !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }

  .poker-decision-row::-webkit-scrollbar {
    height: 4px;
  }

  .poker-decision-row::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
  }

  .poker-decision-row .btn {
    flex: 0 0 auto !important;
    width: auto !important;
    min-width: 130px !important;
    margin: 0 !important;
    padding: 10px 14px !important;
  }

  /* Horizontal scrollable quick raise list */
  .poker-quick-raise-row {
    display: flex !important;
    flex-direction: row !important;
    overflow-x: auto !important;
    white-space: nowrap !important;
    gap: 8px !important;
    padding-bottom: 6px !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }

  .poker-quick-raise-row::-webkit-scrollbar {
    height: 4px;
  }

  .poker-quick-raise-row::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
  }

  .poker-quick-raise-row .btn {
    flex: 0 0 auto !important;
    min-width: 90px !important;
    padding: 6px 10px !important;
    font-size: 0.75rem !important;
    margin: 0 !important;
  }
}

/* Poker community cards container */
.poker-community-cards {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 12px 0 16px 0;
}

.poker-card {
  width: 48px;
  height: 70px;
  perspective: 1000px;
  position: relative;
  box-sizing: border-box;
}

/* Card Slot / Placeholder */
.poker-card.placeholder {
  border: 2px dashed rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.02);
  border-radius: 6px;
}

/* Inner container for 3D rotation */
.poker-card-inner {
  position: absolute;
  width: 100%;
  height: 100%;
  text-align: center;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  transform-style: preserve-3d;
}

/* Trigger flip animation */
.poker-card.face-up .poker-card-inner {
  transform: rotateY(180deg);
}

/* Card faces: front and back */
.poker-card-back,
.poker-card-front {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: 6px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Card Back (Face-down) */
.poker-card-back {
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  border: 2px solid #ffffff;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.poker-card-back::after {
  content: "★";
  font-size: 1.2rem;
  color: rgba(255, 255, 255, 0.4);
}

/* Card Front (Face-up) - Generic / No value */
.poker-card-front {
  background: #ffffff;
  border: 2px solid #ffffff;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
  transform: rotateY(180deg);
  /* Start rotated for flip logic */
}

.poker-card-front::after {
  content: attr(data-suit);
  font-size: 2rem;
  font-weight: bold;
}

.poker-card-front[data-suit="♥"],
.poker-card-front[data-suit="♦"] {
  color: #ef4444;
  /* Red suits */
}

.poker-card-front[data-suit="♠"],
.poker-card-front[data-suit="♣"] {
  color: #0f172a;
  /* Dark suits */
}

/* Blue background for pending blind indicators */
.poker-player-bet.pending-blind {
  background: #2563eb !important;
  color: #ffffff !important;
}

/* ── Poker combinations drawer ────────────────────────────────────────── */
.poker-drawer-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
  z-index: 998;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.poker-drawer-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.poker-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 90vw;
  max-width: 450px;
  height: 100vh;
  background: rgba(17, 17, 22, 0.85);
  backdrop-filter: blur(20px);
  border-left: 1px solid var(--border);
  box-shadow: -5px 0 25px rgba(0, 0, 0, 0.5);
  z-index: 999;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
}

.poker-drawer.open {
  transform: translateX(0);
}

.poker-drawer-toggle {
  position: absolute;
  top: 50%;
  left: -44px;
  transform: translateY(-50%);
  width: 44px;
  height: 64px;
  background: rgba(17, 17, 22, 0.85);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-right: none;
  border-radius: var(--radius) 0 0 var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text);
  box-shadow: -4px 0 10px rgba(0, 0, 0, 0.3);
  transition: background-color 0.2s, color 0.2s;
  outline: none;
  z-index: 1000;
}

.poker-drawer-toggle:hover {
  background: rgba(30, 30, 40, 0.9);
  color: var(--accent);
}

.poker-drawer-toggle .arrow {
  font-size: 1.25rem;
  font-weight: 800;
  display: inline-block;
  transition: transform 0.3s ease;
  user-select: none;
}

.poker-drawer.open .poker-drawer-toggle .arrow {
  transform: rotate(180deg);
}

.poker-drawer-content {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.poker-drawer-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.2);
}

.poker-drawer-header h4 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  text-align: center;
}

.poker-drawer-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.poker-drawer-body img {
  width: 100%;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  background: var(--surface);
}

/* Card deal animation for Blackjack and Poker */
.card-deal-anim {
  animation: card-deal-in 0.4s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards;
}

@keyframes card-deal-in {
  0% {
    transform: scale(0) translateY(-20px);
    opacity: 0;
  }

  100% {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

/* Blackjack dealer panel active button light up */
.bj-seat-options button.active[data-res="lose"] {
  background-color: #ef4444 !important;
  color: #ffffff !important;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.4);
}

.bj-seat-options button.active[data-res="push"] {
  background-color: #9ca3af !important;
  color: #111111 !important;
  box-shadow: 0 0 10px rgba(156, 163, 175, 0.4);
}

.bj-seat-options button.active[data-res="win"] {
  background-color: #10b981 !important;
  color: #ffffff !important;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.4);
}

.bj-seat-options button.active[data-res="blackjack"] {
  background-color: #a855f7 !important;
  color: #ffffff !important;
  box-shadow: 0 0 10px rgba(168, 85, 247, 0.4);
}

/* Poker cost glow style */
.poker-cost-glow {
  color: #facc15 !important;
  font-weight: 800;
  text-shadow: 0 0 8px rgba(250, 204, 21, 0.7);
  font-size: 1rem;
}