:root {
  --bg-dark: #0b1120;
  --bg-panel: #131c31;
  --bg-panel-alt: #1a2640;
  --border-subtle: rgba(255, 255, 255, 0.09);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;

  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --accent: #f59e0b;
  --accent-hover: #d97706;
  --success: #10b981;
  --success-hover: #059669;
  --danger: #ef4444;
  --steal: #8b5cf6;

  --tile-ivory: #fffbeb;
  --tile-border: #d97706;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Outfit', system-ui, -apple-system, sans-serif;
  background: radial-gradient(circle at 50% 0%, #172554 0%, #0b1120 70%);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

.hidden {
  display: none !important;
}

/* ==========================================
   BARRA SUPERIOR
   ========================================== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
  width: 100%;
  max-width: 100vw;
  padding: 0.65rem 1.25rem;
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 50;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}

.brand-logo {
  font-size: 1.65rem;
  background: linear-gradient(135deg, #f59e0b, #ea580c);
  width: 40px;
  height: 40px;
  border-radius: 10px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.35);
}

.brand-title {
  font-size: 1.25rem;
  font-weight: 900;
  letter-spacing: 0.5px;
  line-height: 1.1;
  white-space: nowrap;
}

.brand-title span {
  color: var(--accent);
}

.brand-subtitle {
  font-size: 0.74rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.45rem;
  min-width: 0;
}

.room-badge {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(245, 158, 11, 0.14);
  border: 1px solid rgba(245, 158, 11, 0.4);
  padding: 0.25rem 0.55rem;
  border-radius: 10px;
  white-space: nowrap;
}

.room-badge-label {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.room-badge strong {
  font-size: 0.98rem;
  color: var(--accent);
  letter-spacing: 1.5px;
}

@media (max-width: 900px) {
  .topbar {
    padding: 0.55rem 0.85rem;
  }
  .brand-subtitle {
    display: none;
  }
  .user-chip-stats {
    display: none;
  }
}

@media (max-width: 600px) {
  .topbar {
    justify-content: center;
    padding: 0.5rem 0.65rem;
    gap: 0.45rem;
  }
  .brand {
    width: 100%;
    justify-content: space-between;
  }
  .topbar-actions {
    width: 100%;
    justify-content: center;
    gap: 0.35rem;
  }
  .topbar-actions .btn-sm {
    padding: 0.35rem 0.55rem;
    font-size: 0.78rem;
  }
  .user-chip {
    padding: 0.22rem 0.5rem;
    font-size: 0.78rem;
  }
}

/* ==========================================
   BOTONES Y FORMULARIOS
   ========================================== */
button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  border-radius: 10px;
  font-weight: 700;
  transition: all 0.18s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none !important;
}

.btn-primary {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: #fff;
  padding: 0.7rem 1.25rem;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.5);
}

.btn-accent {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff;
  padding: 0.7rem 1.25rem;
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.35);
}

.btn-accent:hover:not(:disabled) {
  transform: translateY(-2px);
}

.btn-success {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  padding: 0.7rem 1.25rem;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
}

.btn-success:hover:not(:disabled) {
  transform: translateY(-2px);
}

.btn-steal {
  background: linear-gradient(135deg, #8b5cf6, #6d28d9);
  color: #fff;
  padding: 0.7rem 1.25rem;
  box-shadow: 0 4px 16px rgba(139, 92, 246, 0.45);
  animation: pulseSteal 1.6s infinite;
}

@keyframes pulseSteal {
  0%, 100% { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.5); }
  50% { box-shadow: 0 0 0 8px rgba(139, 92, 246, 0); }
}

.btn-danger {
  background: rgba(239, 68, 68, 0.18);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.4);
  padding: 0.55rem 1rem;
}

.btn-danger:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.3);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
  padding: 0.55rem 0.95rem;
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.14);
}

.btn-icon {
  background: transparent;
  color: var(--text-main);
  padding: 0.25rem 0.45rem;
  font-size: 1rem;
}

.btn-sm {
  padding: 0.42rem 0.8rem;
  font-size: 0.85rem;
}

.btn-xs {
  padding: 0.28rem 0.6rem;
  font-size: 0.76rem;
}

.btn-lg {
  padding: 0.85rem 1.45rem;
  font-size: 1rem;
}

.btn-block {
  width: 100%;
}

input[type="text"] {
  width: 100%;
  padding: 0.75rem 0.95rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(15, 23, 42, 0.7);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.96rem;
  outline: none;
  transition: border-color 0.2s;
}

input[type="text"]:focus {
  border-color: var(--accent);
}

.code-input {
  text-transform: uppercase;
  font-weight: 800;
  letter-spacing: 4px;
  text-align: center;
  font-size: 1.2rem !important;
}

/* ==========================================
   CONTENEDOR PRINCIPAL Y PANTALLAS
   ========================================== */
.app-container {
  flex: 1;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
  padding: 1rem 1.25rem;
}

/* ==========================================
   PANTALLA DE BIENVENIDA
   ========================================== */
.hero-card {
  max-width: 920px;
  margin: 1.25rem auto;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  padding: 2rem;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}

.hero-header {
  text-align: center;
  margin-bottom: 2rem;
}

.hero-dice-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.1rem;
  margin-bottom: 1.25rem;
}

.mini-domino {
  width: 52px;
  height: 78px;
  background: var(--tile-ivory);
  color: #1e293b;
  border-radius: 10px;
  border: 2px solid #cbd5e1;
  box-shadow: 0 5px 0 #94a3b8, 0 8px 16px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 0.35rem;
  font-weight: 900;
}

.mini-domino.gold {
  border-color: #f59e0b;
  box-shadow: 0 5px 0 #b45309, 0 8px 16px rgba(245, 158, 11, 0.3);
}

.mini-domino-top {
  font-size: 1.25rem;
}

.mini-domino-divider {
  width: 80%;
  height: 2px;
  background: #cbd5e1;
}

.mini-domino-bottom {
  font-size: 1rem;
  color: #d97706;
}

.mini-die.six-special {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, #f59e0b, #ea580c);
  color: #fff;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 1.6rem;
  line-height: 1;
  box-shadow: 0 5px 0 #9a3412, 0 10px 20px rgba(234, 88, 12, 0.4);
}

.mini-die.six-special span {
  font-size: 0.68rem;
  font-weight: 700;
  margin-top: 2px;
}

.hero-header h2 {
  font-size: 1.75rem;
  margin-bottom: 0.5rem;
}

.hero-header p {
  color: var(--text-muted);
  max-width: 640px;
  margin: 0 auto;
  line-height: 1.5;
}

.welcome-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
}

.panel-box {
  background: var(--bg-panel-alt);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.panel-desc {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-group label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* ==========================================
   PANTALLA DE SALA DE ESPERA (LOBBY)
   ========================================== */
.lobby-card {
  max-width: 880px;
  margin: 1rem auto;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  padding: 1.75rem;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.45);
}

.lobby-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
}

.badge-tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--accent);
  background: rgba(245, 158, 11, 0.14);
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  margin-bottom: 0.35rem;
}

.room-code-box {
  background: var(--bg-panel-alt);
  border: 1px solid rgba(245, 158, 11, 0.35);
  padding: 0.75rem 1.15rem;
  border-radius: 14px;
  text-align: right;
}

.room-code-box > span {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 700;
}

.code-display-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.2rem;
}

.code-display-row strong {
  font-size: 1.8rem;
  letter-spacing: 4px;
  color: var(--accent);
}

.lan-hint {
  display: block;
  margin-top: 0.3rem;
  font-size: 0.75rem;
  color: #60a5fa;
}

.players-lobby-section {
  margin-top: 1.35rem;
}

.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.85rem;
}

.lobby-players-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.lobby-player-item {
  background: var(--bg-panel-alt);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 0.75rem 0.95rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.lobby-player-left {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.player-avatar-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
}

.player-tag {
  font-size: 0.7rem;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
}

.host-controls-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  background: rgba(15, 23, 42, 0.5);
  padding: 0.85rem;
  border-radius: 12px;
  border: 1px dashed var(--border-subtle);
}

.local-add-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  min-width: 260px;
}

.lobby-footer {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.wait-msg {
  color: var(--text-muted);
  font-size: 0.92rem;
}

/* ==========================================
   TABLERO DE JUEGO: LA PARRILLA (16 FICHAS DOMINÓ)
   ========================================== */
.board-section {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  padding: 1rem 1.15rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25);
}

.grill-section {
  margin-bottom: 1rem;
}

.section-header-compact {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}

.section-title-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.section-title-group h3 {
  font-size: 1rem;
  font-weight: 800;
}

.grill-counter {
  font-size: 0.76rem;
  background: rgba(255, 255, 255, 0.08);
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  color: var(--text-muted);
}

.grill-legend {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  font-size: 0.76rem;
  color: var(--text-muted);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
}
.dot.available { background: #fde68a; }
.dot.target { background: #10b981; box-shadow: 0 0 8px #10b981; }
.dot.flipped { background: #475569; }

.grill-domino-row {
  display: grid;
  grid-template-columns: repeat(16, minmax(56px, 1fr));
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.45rem;
}

@media (max-width: 1180px) {
  .grill-domino-row {
    grid-template-columns: repeat(8, minmax(48px, 1fr));
  }
}

@media (max-width: 600px) {
  .grill-domino-row {
    grid-template-columns: repeat(8, minmax(36px, 1fr));
    gap: 0.35rem;
  }
  .domino-tile {
    height: 76px;
    padding: 0.25rem 0.15rem;
  }
  .domino-top {
    font-size: 1.05rem;
  }
  .domino-bottom-number {
    font-size: 0.92rem;
  }
}

/* Ficha de Dominó en la Parrilla (21-36 arriba, 1-4 abajo) */
.domino-tile {
  background: var(--tile-ivory);
  color: #0f172a;
  border-radius: 10px;
  border: 2px solid #cbd5e1;
  box-shadow: 0 5px 0 #94a3b8, 0 6px 12px rgba(0, 0, 0, 0.3);
  height: 96px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 0.35rem 0.25rem;
  position: relative;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  user-select: none;
}

.domino-tile.tier-1 { border-color: #93c5fd; }
.domino-tile.tier-2 { border-color: #6ee7b7; }
.domino-tile.tier-3 { border-color: #fcd34d; }
.domino-tile.tier-4 { border-color: #f87171; }

.domino-top {
  font-size: 1.3rem;
  font-weight: 900;
  line-height: 1.1;
}

.domino-divider {
  width: 82%;
  height: 2px;
  background: #cbd5e1;
  position: relative;
}

.domino-divider::after {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #64748b;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

.domino-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
}

.domino-bottom-number {
  font-size: 1.1rem;
  font-weight: 900;
}

.tier-1 .domino-bottom-number { color: #2563eb; }
.tier-2 .domino-bottom-number { color: #059669; }
.tier-3 .domino-bottom-number { color: #d97706; }
.tier-4 .domino-bottom-number { color: #dc2626; }

.domino-bottom-dots {
  font-size: 0.62rem;
  letter-spacing: 1px;
  opacity: 0.85;
}

/* Estados de la ficha en la parrilla */
.domino-tile.claim-target {
  transform: translateY(-6px);
  border-color: #10b981;
  box-shadow: 0 6px 0 #059669, 0 0 18px rgba(16, 185, 129, 0.75);
  cursor: pointer;
}

.domino-tile.claim-target::before {
  content: 'ELEGIBLE';
  position: absolute;
  top: -10px;
  background: #10b981;
  color: #fff;
  font-size: 0.56rem;
  font-weight: 800;
  padding: 2px 5px;
  border-radius: 4px;
}

.domino-tile.reachable {
  border-color: #34d399;
}

.domino-tile.flipped {
  background: linear-gradient(145deg, #1e293b, #0f172a);
  color: #475569;
  border-color: #334155;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.5);
  opacity: 0.7;
}

.domino-tile.taken {
  background: rgba(15, 23, 42, 0.35);
  border: 2px dashed rgba(255, 255, 255, 0.12);
  box-shadow: none;
  color: rgba(255, 255, 255, 0.2);
}

/* ==========================================
   GRID PRINCIPAL DEL TABLERO (3 COLUMNAS)
   ========================================== */
.game-main-grid {
  display: grid;
  grid-template-columns: 310px 1fr 290px;
  gap: 1rem;
  align-items: start;
}

@media (max-width: 1180px) {
  .game-main-grid {
    grid-template-columns: 280px 1fr;
  }
  .log-section {
    grid-column: 1 / -1;
  }
}

@media (max-width: 820px) {
  .game-main-grid {
    grid-template-columns: 1fr;
  }
}

/* ==========================================
   COLUMNA JUGADORES Y PILAS
   ========================================== */
.players-cards-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.player-stack-card {
  background: var(--bg-panel-alt);
  border: 2px solid transparent;
  border-radius: 14px;
  padding: 0.65rem 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all 0.2s ease;
  position: relative;
}

.player-stack-card.active-turn {
  border-color: var(--accent);
  background: rgba(245, 158, 11, 0.1);
  box-shadow: 0 0 18px rgba(245, 158, 11, 0.2);
}

.player-stack-card.stealable-target {
  border-color: #8b5cf6;
  background: rgba(139, 92, 246, 0.15);
  box-shadow: 0 0 18px rgba(139, 92, 246, 0.45);
  cursor: pointer;
}

.player-info-col {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.player-name-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 0.95rem;
}

.player-sub-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Representación visual de la pila del jugador (solo visible la cima) */
.player-top-domino-wrap {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.stack-depth-badge {
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.07);
  padding: 0.2rem 0.5rem;
  border-radius: 8px;
}

.mini-stack-tile {
  width: 44px;
  height: 64px;
  background: var(--tile-ivory);
  color: #0f172a;
  border-radius: 8px;
  border: 2px solid #cbd5e1;
  box-shadow: 0 4px 0 #94a3b8;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 0.2rem;
  font-weight: 900;
}

.mini-stack-tile .top-num {
  font-size: 1rem;
  line-height: 1;
}

.mini-stack-tile .div-line {
  width: 80%;
  height: 1.5px;
  background: #cbd5e1;
}

.mini-stack-tile .bot-num {
  font-size: 0.85rem;
  color: #d97706;
  line-height: 1;
}

.empty-stack-placeholder {
  width: 44px;
  height: 64px;
  border-radius: 8px;
  border: 1.5px dashed rgba(255, 255, 255, 0.16);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
  color: var(--text-muted);
}

/* ==========================================
   COLUMNA CENTRAL: MESA DE DADOS
   ========================================== */
.turn-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  background: var(--bg-panel-alt);
  border: 1px solid var(--border-subtle);
  padding: 0.85rem 1.15rem;
  border-radius: 14px;
  margin-bottom: 0.85rem;
}

.turn-player-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.turn-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}

.turn-label {
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: 1px;
}

.turn-player-info h2 {
  font-size: 1.35rem;
  line-height: 1.1;
}

.turn-score-box {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.score-pill {
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid var(--border-subtle);
  padding: 0.4rem 0.9rem;
  border-radius: 12px;
  text-align: center;
}

.score-label {
  display: block;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-muted);
}

.score-pill strong {
  font-size: 1.5rem;
  color: #fff;
}

.six-status-badge {
  padding: 0.45rem 0.8rem;
  border-radius: 10px;
  font-size: 0.8rem;
  font-weight: 800;
}

.six-status-badge.missing {
  background: rgba(239, 68, 68, 0.16);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.35);
}

.six-status-badge.ready {
  background: rgba(16, 185, 129, 0.18);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.instruction-bar {
  background: rgba(59, 130, 246, 0.14);
  border: 1px solid rgba(59, 130, 246, 0.35);
  color: #bfdbfe;
  padding: 0.65rem 1rem;
  border-radius: 12px;
  font-size: 0.92rem;
  font-weight: 600;
  margin-bottom: 0.95rem;
  text-align: center;
}

.instruction-bar.busted {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.5);
  color: #fecaca;
}

.dice-zone {
  background: rgba(15, 23, 42, 0.55);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 0.9rem 1rem;
  margin-bottom: 0.9rem;
}

.zone-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.zone-header h4 {
  font-size: 0.92rem;
  font-weight: 700;
}

.zone-hint {
  font-size: 0.76rem;
  color: var(--text-muted);
}

.dice-tray {
  min-height: 82px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.35rem;
}

/* Dado Individual 3D */
.die-card {
  width: 66px;
  height: 66px;
  border-radius: 14px;
  background: #ffffff;
  color: #0f172a;
  border: 2px solid #cbd5e1;
  box-shadow: 0 5px 0 #94a3b8, 0 8px 15px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  position: relative;
  transition: all 0.16s ease;
  animation: popIn 0.25s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

@keyframes popIn {
  0% { transform: scale(0.5) rotate(-12deg); opacity: 0; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

.die-card .die-face-num {
  font-size: 1.65rem;
  font-weight: 900;
  line-height: 1;
}

.die-card .die-face-pts {
  font-size: 0.65rem;
  font-weight: 700;
  color: #64748b;
  margin-top: 2px;
}

/* El dado 6 especial (vale 5 puntos y cumple la condición obligatoria) */
.die-card.face-6 {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  border-color: #f59e0b;
  color: #b45309;
  box-shadow: 0 5px 0 #d97706, 0 8px 15px rgba(245, 158, 11, 0.35);
}

.die-card.face-6 .die-face-pts {
  color: #b45309;
  font-weight: 800;
}

.die-card.selectable:hover,
.die-card.highlight-group {
  transform: translateY(-6px) scale(1.05);
  border-color: #3b82f6;
  box-shadow: 0 7px 0 #2563eb, 0 12px 20px rgba(59, 130, 246, 0.45);
}

.die-card.face-6.selectable:hover,
.die-card.face-6.highlight-group {
  border-color: #f59e0b;
  box-shadow: 0 7px 0 #b45309, 0 12px 22px rgba(245, 158, 11, 0.6);
}

.die-card.already-kept {
  opacity: 0.32;
  cursor: not-allowed;
  filter: grayscale(0.7);
}

.die-card.already-kept::after {
  content: 'YA USADO';
  position: absolute;
  bottom: -8px;
  background: #ef4444;
  color: #fff;
  font-size: 0.52rem;
  font-weight: 800;
  padding: 1px 4px;
  border-radius: 4px;
}

/* Dados Apartados por Símbolo */
.kept-groups-tray {
  min-height: 74px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.kept-symbol-group {
  background: var(--bg-panel-alt);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  padding: 0.5rem 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.kept-symbol-group.is-six {
  border-color: rgba(245, 158, 11, 0.55);
  background: rgba(245, 158, 11, 0.12);
}

.kept-mini-die {
  width: 40px;
  height: 40px;
  border-radius: 9px;
  background: #fff;
  color: #0f172a;
  font-weight: 900;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 0 #94a3b8;
}

.kept-symbol-group.is-six .kept-mini-die {
  background: linear-gradient(135deg, #f59e0b, #ea580c);
  color: #fff;
  box-shadow: 0 3px 0 #9a3412;
}

.kept-group-meta {
  display: flex;
  flex-direction: column;
}

.kept-group-count {
  font-weight: 800;
  font-size: 0.92rem;
}

.kept-group-sum {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.turn-actions-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

/* ==========================================
   COLUMNA DERECHA: HISTORIAL DE JUGADAS
   ========================================== */
.logs-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  max-height: 460px;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.log-item {
  font-size: 0.8rem;
  padding: 0.5rem 0.65rem;
  border-radius: 9px;
  background: rgba(15, 23, 42, 0.55);
  border-left: 3px solid #64748b;
  line-height: 1.35;
}

.log-item.turn { border-left-color: #3b82f6; background: rgba(59, 130, 246, 0.1); }
.log-item.success { border-left-color: #10b981; background: rgba(16, 185, 129, 0.12); }
.log-item.danger { border-left-color: #ef4444; background: rgba(239, 68, 68, 0.12); }
.log-item.warning { border-left-color: #f59e0b; background: rgba(245, 158, 11, 0.12); }

.log-time {
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-right: 0.35rem;
}

/* ==========================================
   MODALES (REGLAS Y FIN DE PARTIDA)
   ========================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.8);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 100;
}

.modal-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  padding: 1.65rem;
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.6);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.rules-content {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.rule-block {
  background: var(--bg-panel-alt);
  padding: 0.95rem 1.15rem;
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
}

.rule-block h4 {
  color: var(--accent);
  margin-bottom: 0.4rem;
}

.rule-block p,
.rule-block li {
  font-size: 0.9rem;
  color: #cbd5e1;
  line-height: 1.5;
}

.rule-block ul {
  padding-left: 1.2rem;
  margin-top: 0.35rem;
}

.winner-highlight {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.2), rgba(234, 88, 12, 0.15));
  border: 1px solid rgba(245, 158, 11, 0.5);
  border-radius: 14px;
  padding: 1.15rem;
  text-align: center;
  margin-bottom: 1.15rem;
}

.rankings-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 1.25rem;
}

.ranking-row {
  background: var(--bg-panel-alt);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* ==========================================
   NOTIFICACIONES TOAST
   ========================================== */
.toast-container {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 200;
}

.toast {
  background: #1e293b;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 0.75rem 1.1rem;
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.45);
  font-size: 0.88rem;
  font-weight: 600;
}


/* ==========================================
   AUTENTICACIÓN, PERFIL DE JUGADOR Y RANKINGS
   ========================================== */
.user-chip {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  background: rgba(59, 130, 246, 0.14);
  border: 1px solid rgba(59, 130, 246, 0.35);
  padding: 0.28rem 0.65rem;
  border-radius: 10px;
  font-size: 0.85rem;
}

.user-chip-stats {
  background: rgba(15, 23, 42, 0.65);
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  color: #93c5fd;
}

.auth-card {
  background: var(--bg-panel-alt);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}

.auth-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 0.75rem;
}

.auth-tab {
  flex: 1;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  padding: 0.65rem 1rem;
  border-radius: 10px;
  font-size: 0.92rem;
}

.auth-tab.active {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: #fff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.auth-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

input[type="email"],
input[type="password"] {
  width: 100%;
  padding: 0.75rem 0.95rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(15, 23, 42, 0.7);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.96rem;
  outline: none;
  transition: border-color 0.2s;
}

input[type="email"]:focus,
input[type="password"]:focus {
  border-color: var(--accent);
}

/* Banner de Estadísticas del Usuario Autenticado */
.profile-stats-banner {
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.9), rgba(15, 23, 42, 0.95));
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 16px;
  padding: 1.25rem 1.4rem;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1.25rem;
}

.profile-user-meta {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.profile-avatar {
  width: 54px;
  height: 54px;
  border-radius: 14px;
  background: rgba(245, 158, 11, 0.18);
  border: 1px solid rgba(245, 158, 11, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
}

.profile-user-meta h3 {
  font-size: 1.35rem;
  line-height: 1.1;
}

.profile-kpi-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
  flex: 1;
  justify-content: flex-end;
}

.kpi-card {
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 0.7rem 1rem;
  min-width: 175px;
}

.kpi-card.highlight {
  border-color: rgba(59, 130, 246, 0.45);
  background: rgba(30, 58, 138, 0.22);
}

.kpi-card.gold {
  border-color: rgba(245, 158, 11, 0.45);
  background: rgba(180, 83, 9, 0.16);
}

.kpi-title {
  display: block;
  font-size: 0.68rem;
  font-weight: 800;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.kpi-main {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.15rem;
}

.kpi-main strong {
  font-size: 1.15rem;
}

.kpi-pill {
  font-size: 0.72rem;
  font-weight: 800;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  background: rgba(16, 185, 129, 0.2);
  color: #6ee7b7;
}

/* Modal de Rankings Globales */
#rankingsModal {
  z-index: 150;
}

.modal-xl {
  max-width: 860px;
}

.ranking-tabs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.1rem;
}

.ranking-tab {
  background: var(--bg-panel-alt);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  padding: 0.8rem 1rem;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  gap: 0.2rem;
}

.ranking-tab small {
  font-size: 0.74rem;
  font-weight: 500;
  opacity: 0.85;
}

.ranking-tab.active {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.25), rgba(37, 99, 235, 0.15));
  border-color: #3b82f6;
  color: #fff;
}

.ranking-info-banner {
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: #bfdbfe;
  padding: 0.65rem 0.95rem;
  border-radius: 10px;
  font-size: 0.84rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.95rem;
}

.ranking-info-banner.gold {
  background: rgba(245, 158, 11, 0.14);
  border-color: rgba(245, 158, 11, 0.4);
  color: #fde68a;
}

.leaderboard-table-wrap {
  overflow-x: auto;
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.leaderboard-table th {
  text-align: left;
  padding: 0.65rem 0.8rem;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
}

.leaderboard-table td {
  padding: 0.75rem 0.8rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.leaderboard-table tr.is-me {
  background: rgba(59, 130, 246, 0.16);
}

.ratio-badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  font-weight: 800;
  font-size: 0.82rem;
  background: rgba(16, 185, 129, 0.18);
  color: #6ee7b7;
}

.wins-pill {
  color: #34d399;
  font-weight: 800;
}

.losses-pill {
  color: #f87171;
  font-weight: 700;
}


/* ==========================================
   BARRA DE TABLERO FINALIZADO (NUEVA PARTIDA / SALIR)
   ========================================== */
.finished-board-banner {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.22), rgba(37, 99, 235, 0.22));
  border: 2px solid var(--accent);
  border-radius: 16px;
  padding: 0.9rem 1.25rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  box-shadow: 0 8px 25px rgba(245, 158, 11, 0.25);
}

.finished-banner-text {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.finished-badge {
  background: var(--accent);
  color: #0f172a;
  font-weight: 900;
  font-size: 0.76rem;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  letter-spacing: 0.5px;
}

.finished-banner-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem;
}
