/**
 * Fijate Tools - Quién es quién (quien-es-quien)
 * Hoja de estilos interactiva, 3D CSS y temas claro/oscuro
 */

:root {
  --font-main: 'Inter', system-ui, -apple-system, sans-serif;
  --font-heading: 'Outfit', 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Colores tablero clásico vintage azul / rojo */
  --board-blue-base: #1e3a8a;
  --board-blue-frame: #2563eb;
  --board-blue-surface: #1d4ed8;
  --board-red-base: #991b1b;
  --board-red-frame: #dc2626;

  /* Colores de UI */
  --bg-app: #f8fafc;
  --bg-card: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --radius-card: 16px;
  --radius-sm: 8px;
}

body.dark-mode {
  --bg-app: #0b0f17;
  --bg-card: #151b28;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --border-color: #1e293b;
  --primary: #3b82f6;
  --primary-hover: #60a5fa;
  --primary-light: #1e293b;

  --board-blue-base: #0f172a;
  --board-blue-frame: #1e3a8a;
  --board-blue-surface: #172554;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-app);
  color: var(--text-main);
  overflow-x: clip;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

h1,
h2,
h3,
h4,
h5,
h6,
.brand-title,
.section-title,
.hero-title,
.card-title {
  font-family: var(--font-heading);
}

.mono {
  font-family: var(--font-mono);
}

/* Layout institucional */
.main-wrapper.tool-layout {
  max-width: 1240px;
  margin: 1.5rem auto 3rem;
  padding: 0 1rem;
  box-sizing: border-box;
  flex: 1 0 auto;
  width: 100%;
}

.tool-with-sidebar {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
  width: 100%;
}

.tool-main-content {
  flex: 1 1 0%;
  min-width: 0;
  width: 100%;
}

/* Barra superior de controles del juego */
.game-toolbar {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 0.6rem 0.85rem;
  margin-bottom: 0.85rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
  justify-content: space-between;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.toolbar-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

.custom-select {
  padding: 0.35rem 1.8rem 0.35rem 0.6rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background-color: var(--bg-card);
  color: var(--text-main);
  font-family: var(--font-main);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2364748b' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.65rem center;
}

.custom-select:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.btn-game {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-main);
  font-family: var(--font-main);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 36px;
}

.btn-game:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

.btn-game-primary {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

.btn-game-primary:hover {
  background: var(--primary-hover);
  color: #ffffff;
}

.btn-game-accent {
  background: #f59e0b;
  color: #ffffff;
  border-color: #d97706;
}

.btn-game-accent:hover {
  background: #d97706;
  color: #ffffff;
}

/* Escenario de juego unificado en dos columnas (Tablero + Consola) */
.game-arena {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: 1rem;
  align-items: start;
  margin-bottom: 1.5rem;
}

@media (max-width: 980px) {
  .game-arena {
    grid-template-columns: 1fr;
    gap: 0.85rem;
  }
}

.game-arena-board {
  min-width: 0;
}

.game-arena-console {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Cuadro de estado compacto en la consola */
.console-status-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 0.65rem 0.85rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.status-top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Tarjeta del personaje secreto del jugador */
.secret-card-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--primary-light);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.25rem 0.5rem;
  position: relative;
}

.secret-card-avatar {
  width: 34px;
  height: 40px;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  background: #ffffff;
  flex-shrink: 0;
}

.secret-card-avatar svg {
  width: 100%;
  height: 100%;
  display: block;
}

.secret-card-info {
  display: flex;
  flex-direction: column;
}

.secret-badge {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--primary);
}

.secret-name {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0;
}

.secret-card-blur {
  filter: blur(8px);
  user-select: none;
  transition: filter 0.2s ease;
}

.secret-card-blur.is-revealed {
  filter: none;
}

.btn-toggle-eye {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.2rem;
  display: flex;
  align-items: center;
  border-radius: 4px;
}

.btn-toggle-eye:hover {
  color: var(--primary);
}

/* Contadores compactos */
.counter-group {
  display: flex;
  gap: 0.4rem;
}

.counter-pill {
  background: var(--bg-app);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.25rem 0.5rem;
  text-align: center;
  min-width: 65px;
}

.counter-val {
  font-size: 0.95rem;
  font-weight: 800;
  font-family: var(--font-heading);
  color: var(--primary);
  display: block;
  line-height: 1.1;
}

.counter-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* Indicador central de turno */
.turn-banner {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding-top: 0.35rem;
  border-top: 1px solid var(--border-color);
}

.turn-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.7rem;
  font-weight: 700;
  flex-shrink: 0;
}

.turn-pill.turn-player {
  background: #dbeafe;
  color: #1e40af;
}

.turn-pill.turn-ai {
  background: #fee2e2;
  color: #991b1b;
}

.turn-text-block {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.turn-heading {
  font-size: 0.84rem;
  font-weight: 700;
  margin: 0;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.turn-subtext {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Tablero clásico interactivo 3D compacto (3 filas × 8 columnas) */
.board-container {
  background: linear-gradient(135deg, var(--board-blue-base) 0%, var(--board-blue-surface) 100%);
  border-radius: 14px;
  padding: 0.65rem 0.75rem;
  box-shadow: 0 10px 24px -6px rgba(30, 58, 138, 0.35), inset 0 1px 2px rgba(255, 255, 255, 0.2);
  border: 3px solid var(--board-blue-frame);
  position: relative;
  perspective: 1000px;
}

.board-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.45rem;
  color: #ffffff;
}

.board-title-group {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.board-title {
  font-size: 0.92rem;
  font-weight: 800;
  margin: 0;
  letter-spacing: -0.01em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.board-legend {
  font-size: 0.68rem;
  opacity: 0.9;
  background: rgba(0, 0, 0, 0.25);
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
}

/* Rejilla de los 24 personajes: 8 columnas × 3 filas */
.board-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 0.35rem;
  perspective: 800px;
}

@media (max-width: 980px) {
  .board-grid {
    grid-template-columns: repeat(6, 1fr);
    gap: 0.35rem;
  }
}

@media (max-width: 500px) {
  .board-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 0.28rem;
  }

  .board-container {
    padding: 0.5rem;
  }
}

/* Celda con solapa abatible */
.board-card-wrapper {
  aspect-ratio: 1 / 1.18;
  perspective: 600px;
  cursor: pointer;
  user-select: none;
}

.board-card {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.35s cubic-bezier(0.25, 1, 0.5, 1), opacity 0.25s ease;
  transform-origin: bottom center;
}

/* Efecto de solapa abatida hacia atrás */
.board-card.is-flipped {
  transform: rotateX(84deg) translateZ(-5px);
  opacity: 0.22;
}

.board-card:hover:not(.is-flipped) {
  transform: translateY(-2px);
}

/* Cara frontal (personaje visible) */
.card-front {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  background: #ffffff;
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12), inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.card-avatar-wrap {
  flex: 1 1 auto;
  position: relative;
  width: 100%;
  overflow: hidden;
  background: #f1f5f9;
  min-height: 0;
}

.card-avatar-wrap svg {
  width: 100%;
  height: 100%;
  display: block;
}

.card-name-bar {
  background: #ffffff;
  padding: 1px 2px;
  text-align: center;
  border-top: 1px solid #e2e8f0;
  flex-shrink: 0;
  height: 17px;
  line-height: 17px;
  overflow: hidden;
}

.card-name {
  font-family: var(--font-heading);
  font-size: 0.68rem;
  font-weight: 700;
  color: #0f172a;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

/* Cara trasera (tapa de plástico abatida) */
.card-back {
  position: absolute;
  inset: 0;
  transform: rotateY(180deg);
  backface-visibility: hidden;
  background: linear-gradient(135deg, #1e3a8a, #0f172a);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.3);
  font-size: 1.1rem;
  font-weight: 800;
  box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.5);
}

/* Bisagra física inferior vintage */
.card-hinge {
  position: absolute;
  bottom: -2px;
  left: 15%;
  right: 15%;
  height: 3px;
  background: #0f172a;
  border-radius: 2px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

/* Panel interactivo de preguntas compacto */
.question-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 0.65rem 0.85rem;
  box-shadow: var(--shadow-sm);
}

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

.question-panel-title {
  font-size: 0.9rem;
  font-weight: 700;
  margin: 0;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.question-panel-hint {
  font-size: 0.68rem;
  color: var(--text-muted);
}

/* Categorías de preguntas (pestañas) */
.category-tabs {
  display: flex;
  gap: 0.28rem;
  overflow-x: auto;
  padding-bottom: 0.3rem;
  margin-bottom: 0.5rem;
  scrollbar-width: thin;
}

.tab-btn {
  padding: 0.25rem 0.55rem;
  border-radius: 9999px;
  border: 1px solid var(--border-color);
  background: var(--bg-app);
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.tab-btn:hover {
  color: var(--text-main);
  border-color: var(--primary);
}

.tab-btn.is-active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

/* Lista de chips de preguntas */
.questions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.38rem;
  max-height: 185px;
  overflow-y: auto;
  scrollbar-width: thin;
  padding-right: 2px;
}

.question-chip {
  padding: 0.4rem 0.55rem;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-app);
  color: var(--text-main);
  font-family: var(--font-main);
  font-size: 0.78rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  transition: all 0.15s ease;
  min-height: 36px;
  line-height: 1.2;
}

.question-chip:hover:not(:disabled) {
  border-color: var(--primary);
  background: var(--primary-light);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.question-chip:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.question-chip-help {
  font-size: 0.65rem;
  font-weight: 500;
  color: var(--text-muted);
}

/* Bocadillo de respuesta animado */
.speech-bubble {
  background: var(--primary-light);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 0.55rem 0.75rem;
  margin-top: 0.55rem;
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  animation: fadeIn 0.25s ease;
}

border: 1px solid var(--border-color);
border-radius: 16px;
padding: 1.25rem;
margin-top: 1.25rem;
display: flex;
align-items: flex-start;
gap: 1rem;
animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.speech-bubble-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--primary);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.speech-bubble-content {
  flex: 1 1 auto;
}

.speech-bubble-speaker {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: 0.25rem;
}

.speech-bubble-text {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-main);
  margin: 0 0 0.5rem 0;
}

.speech-bubble-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* Modales personalizados accesibles */
.quien-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 9999;
  animation: fadeIn 0.2s ease;
}

.quien-modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  max-width: 540px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  animation: modalPop 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalPop {
  from {
    opacity: 0;
    transform: scale(0.92);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

.quien-modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.quien-modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0;
  color: var(--text-main);
}

.quien-modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1 1 auto;
}

.quien-modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  flex-shrink: 0;
}

/* Galería de selección para adivinar */
.guess-gallery {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
}

@media (max-width: 500px) {
  .guess-gallery {
    grid-template-columns: repeat(3, 1fr);
  }
}

.guess-card-opt {
  border: 2px solid var(--border-color);
  border-radius: 12px;
  padding: 0.5rem;
  background: var(--bg-app);
  cursor: pointer;
  text-align: center;
  transition: all 0.15s ease;
}

.guess-card-opt:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
}

.guess-card-opt.is-selected {
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: 0 0 0 2px var(--primary);
}

.guess-avatar {
  width: 100%;
  aspect-ratio: 1 / 1.1;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 0.35rem;
}

.guess-avatar svg {
  width: 100%;
  height: 100%;
  display: block;
}

.guess-name {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Historial de la partida */
.history-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-card);
  padding: 1.25rem 1.5rem;
  margin-bottom: 2rem;
}

.history-title {
  font-size: 1rem;
  font-weight: 700;
  margin: 0 0 1rem 0;
  color: var(--text-main);
}

.history-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 200px;
  overflow-y: auto;
}

.history-item {
  font-size: 0.85rem;
  color: var(--text-muted);
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.history-item-time {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  opacity: 0.7;
}

/* Sección SEO y Guía técnica */
.seo-guide-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-card);
  padding: 2rem;
  margin-top: 3rem;
  margin-bottom: 2rem;
}

.seo-guide-section h2 {
  font-size: 1.5rem;
  margin-top: 0;
  margin-bottom: 1rem;
  color: var(--text-main);
}

.seo-guide-section h3 {
  font-size: 1.15rem;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
  color: var(--text-main);
}

.seo-guide-section p,
.seo-guide-section li {
  color: var(--text-muted);
  line-height: 1.6;
  font-size: 0.95rem;
}

.seo-guide-section ul {
  padding-left: 1.25rem;
}