/* ui.css - Diseño Profesional y Limpio */
:root {
  --bg-primary: #0a0e1a;
  --bg-secondary: #111827;
  --bg-tertiary: #1a2332;

  --surface: rgba(255, 255, 255, 0.04);
  --surface-hover: rgba(255, 255, 255, 0.06);
  --border: rgba(255, 255, 255, 0.1);
  --border-focus: rgba(59, 130, 246, 0.5);

  --text-primary: rgba(255, 255, 255, 0.95);
  --text-secondary: rgba(255, 255, 255, 0.7);
  --text-muted: rgba(255, 255, 255, 0.5);

  --accent-primary: #3b82f6;
  --accent-secondary: #10b981;
  --accent-danger: #ef4444;
  --accent-warning: #f59e0b;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --ring: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

* {
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  min-height: 100vh;
  color: var(--text-primary);
  padding: 24px;
  background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
  display: grid;
  place-items: center;
}

/* Fondo sutil y profesional */
.ui-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  background: radial-gradient(circle at 20% 30%, rgba(59, 130, 246, 0.08) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(16, 185, 129, 0.06) 0%, transparent 50%);
}

.ui-bg::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to right, rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 40px 40px;
  opacity: 0.5;
  mask-image: radial-gradient(circle at 50% 50%, black 20%, transparent 80%);
}

.wrap {
  width: 100%;
  max-width: 760px;
  display: grid;
  gap: 20px;
}

/* Header */
.header {
  padding: 8px 4px;
  text-align: left;
}

.title {
  margin: 0;
  font-size: clamp(1.75rem, 3vw, 2.25rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.subtitle {
  margin: 12px 0 0;
  color: var(--text-secondary);
  line-height: 1.6;
  font-size: 0.95rem;
  max-width: 65ch;
}

/* Card principal */
.card {
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.card-inner {
  padding: 28px;
  display: grid;
  gap: 20px;
}

/* Grid responsive */
.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

/* Desktop: 2 columnas */
@media (min-width: 720px) {
  .grid.cols-2 {
    grid-template-columns: 1.3fr 0.7fr;
    align-items: start;
  }

  /* Jugadores ocupa todo el ancho en desktop */
  .grid.cols-2 .field-full {
    grid-column: 1 / -1;
  }
}

/* Campos de formulario */
.field {
  display: grid;
  gap: 8px;
  text-align: left;
}

label {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-primary);
  letter-spacing: 0.01em;
}

.hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: -4px;
}

/* Inputs */
input[type="text"],
input[type="number"],
select {
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: rgba(10, 14, 26, 0.9);
  color: var(--text-primary);
  font-size: 0.95rem;
  outline: none;
  transition: all 0.2s ease;
}

select option {
  background: #1a2332;
  color: var(--text-primary);
  padding: 8px;
}

input::placeholder {
  color: var(--text-muted);
}

input:focus,
select:focus {
  border-color: var(--border-focus);
  box-shadow: var(--ring);
  background: rgba(255, 255, 255, 0.06);
}

input:hover:not(:focus),
select:hover:not(:focus) {
  border-color: rgba(255, 255, 255, 0.16);
}

/* Inputs de impostores (NO usar .row aquí) */
.impostor-inputs {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.hidden {
  display: none;
}

/* Botones */
.row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
}

/* Toggle */
.toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
  cursor: pointer;
  user-select: none;
  transition: all 0.2s ease;
}

.toggle:hover {
  border-color: rgba(255, 255, 255, 0.16);
  background: var(--surface-hover);
}

.toggle input {
  cursor: pointer;
}

/* Botones profesionales */
.btn {
  border: 0;
  border-radius: var(--radius-md);
  padding: 12px 24px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  color: white;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.95), rgba(15, 23, 42, 1));
  border: 1px solid rgba(59, 130, 246, 0.25);
}

.btn::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), transparent);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.btn:hover::before {
  opacity: 1;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

.btn:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

.btn.primary,
.btn.start {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.25);
}

.btn.primary:hover,
.btn.start:hover {
  background: linear-gradient(135deg, #34d399 0%, #10b981 100%);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn.secondary {
  background: rgba(30, 41, 59, 0.9);
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: #e0e7ff;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.1);
}

.btn.secondary:hover {
  background: rgba(51, 65, 85, 0.95);
  border-color: rgba(59, 130, 246, 0.5);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

/* Mensajes de alerta */
.msg {
  display: none;
  border-radius: var(--radius-md);
  border: 1px solid rgba(245, 158, 11, 0.3);
  padding: 14px 16px;
  background: rgba(245, 158, 11, 0.1);
  align-items: flex-start;
  gap: 12px;
}

.msg.show {
  display: flex;
}

.msg .icon {
  font-size: 1.2rem;
  line-height: 1;
}

.msg .content {
  flex: 1;
}

.msg .content strong {
  display: block;
  margin-bottom: 4px;
  font-weight: 600;
  color: var(--text-primary);
}

.msg .close {
  background: transparent;
  border: 0;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1.4rem;
  line-height: 1;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
}

.msg .close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

/* Footer */
.app-footer {
  position: relative;
  margin-top: 40px;
  padding: 20px 24px;
  background: linear-gradient(to top, rgba(10, 14, 26, 0.98), rgba(10, 14, 26, 0.85));
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-lg);
  z-index: 1;
}

.footer-content {
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.footer-creator {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-weight: 500;
  letter-spacing: 0.02em;
}

.footer-creator .highlight {
  color: var(--accent-primary);
  font-weight: 700;
  background: linear-gradient(135deg, #3b82f6, #10b981);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.footer-links {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.footer-version {
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.2);
  color: #93c5fd;
  font-weight: 600;
  font-size: 0.8rem;
}

.footer-separator {
  opacity: 0.5;
}

.footer-year {
  font-weight: 500;
}

/* Responsive */
@media (max-width: 640px) {
  body {
    padding: 16px;
  }

  .card-inner {
    padding: 20px;
  }

  .footer-content {
    flex-direction: column;
    text-align: center;
    gap: 8px;
  }

  /* Impostor inputs en columna */
  .impostor-inputs {
    flex-direction: column;
    gap: 10px;
  }

  /* Botones en columna */
  .row.actions {
    flex-direction: column;
    align-items: stretch;
  }

  .row.actions .btn {
    width: 100%;
  }
}

/* Jugadores: textarea premium con scroll bonito */
.players-input {
  width: 100%;
  resize: none;               /* no permitir arrastrar la esquina */
  overflow: auto;             /* activa scrollbar cuando haga falta */
  line-height: 1.45;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: rgba(10, 14, 26, 0.9);
  color: var(--text-primary);
  font-size: 0.95rem;
  outline: none;
  transition: all 0.2s ease;
}

/* hover/focus igual que inputs */
.players-input:focus {
  border-color: var(--border-focus);
  box-shadow: var(--ring);
  background: rgba(255, 255, 255, 0.06);
}

.players-input:hover:not(:focus) {
  border-color: rgba(255, 255, 255, 0.16);
}

.players-input::placeholder {
  color: var(--text-muted);
}

/* Scrollbar bonita (Chrome/Edge/Safari) */
.players-input::-webkit-scrollbar {
  height: 10px;
  width: 10px;
}

.players-input::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.06);
  border-radius: 999px;
}

.players-input::-webkit-scrollbar-thumb {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.55), rgba(16, 185, 129, 0.45));
  border-radius: 999px;
  border: 2px solid rgba(10, 14, 26, 0.9); /* para que se vea “integrada” */
}

.players-input::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.75), rgba(16, 185, 129, 0.65));
}

/* Scrollbar en Firefox */
.players-input {
  scrollbar-width: thin;
  scrollbar-color: rgba(59, 130, 246, 0.6) rgba(255, 255, 255, 0.06);
}


/* =========================
   SHARED UI (roles/role/vote)
   ========================= */

/* Panel genérico */
.panel {
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.2);
  padding: 20px;
}

/* Pills / badges */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.875rem;
  border: 1px solid var(--border);
  background: var(--surface);
  width: fit-content;
}

.pill.impostor {
  border-color: rgba(239, 68, 68, 0.3);
  background: rgba(239, 68, 68, 0.1);
  color: #fca5a5;
}

.pill.civil {
  border-color: rgba(16, 185, 129, 0.3);
  background: rgba(16, 185, 129, 0.1);
  color: #6ee7b7;
}

/* Tipografías utilitarias */
.big {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.25;
}

.muted {
  color: var(--text-secondary);
  line-height: 1.5;
}

/* =========================
   ROLE PAGE (reveal)
   ========================= */

.reveal {
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.2);
  padding: 24px;
  display: grid;
  gap: 16px;
}

.tap {
  position: relative;
  overflow: hidden;
  cursor: pointer;
  user-select: none;
  text-align: center;
  padding: 40px 32px;
  border-radius: var(--radius-lg);
  border: 2px solid rgba(59, 130, 246, 0.25);
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.9), rgba(15, 23, 42, 0.95));
  color: var(--text-primary);
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: 0.02em;
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.tap::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 50%, rgba(59, 130, 246, 0.2), transparent 60%);
  opacity: 0.45;
  animation: tapPulse 2.5s ease-in-out infinite;
  pointer-events: none;
}

.tap:hover {
  transform: translateY(-2px) scale(1.01);
  border-color: rgba(59, 130, 246, 0.4);
  box-shadow: 0 8px 24px rgba(59, 130, 246, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.tap:active {
  transform: translateY(-1px) scale(1);
}

/* Ripple (si tu JS lo usa) */
.ripple {
  position: absolute;
  border-radius: 999px;
  transform: translate(-50%, -50%) scale(0);
  animation: ripple 0.6s ease-out forwards;
  background: rgba(59, 130, 246, 0.3);
  pointer-events: none;
}

@keyframes ripple {
  to {
    transform: translate(-50%, -50%) scale(20);
    opacity: 0;
  }
}

@keyframes tapPulse {
  0%, 100% {
    opacity: 0.25;
    transform: scale(1);
    filter: blur(0px) brightness(1);
  }
  50% {
    opacity: 0.6;
    transform: scale(1.02);
    filter: blur(12px) brightness(1.35);
  }
}

/* Animaciones de reveal (si role.js aplica clases) */
@keyframes revealOut {
  0% { opacity: 1; transform: scale(1); filter: blur(0px) brightness(1); }
  50% { opacity: 0.5; transform: scale(1.03); filter: blur(12px) brightness(1.35); }
  100% { opacity: 0; transform: scale(1.08); filter: blur(25px) brightness(1.5); }
}

@keyframes revealIn {
  0% { opacity: 0; transform: scale(0.95) translateY(10px); filter: blur(20px) brightness(0.75); }
  50% { opacity: 0.5; filter: blur(10px) brightness(1.1); }
  100% { opacity: 1; transform: scale(1) translateY(0); filter: blur(0px) brightness(1); }
}

.tap.revealing {
  animation: revealOut 0.7s cubic-bezier(0.6, 0, 0.4, 1) forwards;
  pointer-events: none;
}

#roleContent.revealed {
  display: grid;
  gap: 16px;
  animation: revealIn 0.9s cubic-bezier(0.16, 1, 0.3, 1);
}

/* =========================
   PLAYERS GRID (roles + vote)
   ========================= */

.players-panel {
  max-height: 480px;
  overflow: auto;
}

.players-panel::-webkit-scrollbar {
  width: 8px;
}
.players-panel::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 999px;
}
.players-panel::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 999px;
}
.players-panel::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

.players-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

/* Botón jugador (clase ideal) */
.player-btn {
  position: relative;
  aspect-ratio: 1 / 1;
  width: 100%;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.8), rgba(15, 23, 42, 0.9));
  color: var(--text-primary);
  font-weight: 800;
  font-size: 1rem;
  cursor: pointer;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 16px;
  transition: all 0.2s ease;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.player-btn:hover {
  transform: translateY(-2px);
  border-color: rgba(59, 130, 246, 0.4);
  box-shadow: 0 6px 16px rgba(59, 130, 246, 0.2);
}

.player-btn.used,
.player-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  filter: grayscale(0.5);
}

/* Fallback: si JS no pone .player-btn */
#players button {
  all: unset;
  box-sizing: border-box;
  position: relative;
  aspect-ratio: 1 / 1;
  width: 100%;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.8), rgba(15, 23, 42, 0.9));
  color: var(--text-primary);
  font-weight: 800;
  font-size: 1rem;
  cursor: pointer;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 16px;
  transition: all 0.2s ease;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* =========================
   CARD FOOTER (roles + vote)
   ========================= */

.card > .footer {
  padding: 16px 28px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  background: rgba(0, 0, 0, 0.2);
}

/* =========================
   MOBILE
   ========================= */

@media (max-width: 640px) {
  .players-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .card > .footer {
    padding: 14px 20px;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .card > .footer .btn {
    width: 100%;
  }

  .tap {
    padding: 28px 18px;
    font-size: 1.05rem;
  }
}

/* Forzar estilo de deshabilitado (aunque exista all: unset) */
.player-btn.used,
.player-btn:disabled,
#players button.used,
#players button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  filter: grayscale(0.7);
  transform: none !important;
  box-shadow: none !important;
  border-color: var(--border) !important;
}

/* Quitar hover cuando está deshabilitado */
.player-btn.used:hover,
.player-btn:disabled:hover,
#players button.used:hover,
#players button:disabled:hover {
  transform: none !important;
  box-shadow: none !important;
}

