/**
 * Fijate Tools - El juego de la contraseña imposible
 * Estilos prémium, layout canónico, tarjetas dinámicas y adaptación responsive
 */

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

  /* Paleta base modo oscuro (predeterminado) */
  --bg-page: #0b0f17;
  --bg-card: #131a26;
  --bg-card-hover: #182232;
  --bg-input: #0e1520;
  --border-color: #223048;
  --border-focus: #3b82f6;

  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --accent-blue: #3b82f6;
  --accent-indigo: #6366f1;
  --accent-emerald: #10b981;
  --accent-rose: #f43f5e;
  --accent-amber: #f59e0b;
  --accent-purple: #a855f7;

  --card-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
  --glass-bg: rgba(19, 26, 38, 0.88);
  --glass-border: rgba(255, 255, 255, 0.08);

  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
}

[data-theme="light"] {
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --bg-input: #f8fafc;
  --border-color: #e2e8f0;
  --border-focus: #2563eb;

  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #94a3b8;

  --accent-blue: #2563eb;
  --accent-indigo: #4f46e5;
  --accent-emerald: #059669;
  --accent-rose: #e11d48;
  --accent-amber: #d97706;
  --accent-purple: #9333ea;

  --card-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.06), 0 8px 10px -6px rgba(15, 23, 42, 0.04);
  --glass-bg: rgba(255, 255, 255, 0.92);
  --glass-border: rgba(0, 0, 0, 0.06);
}

/* -------------------------------------------------------------
 * Reset y contención canónica obligatoria
 * ------------------------------------------------------------- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.5;
  overflow-x: clip;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

.main-wrapper.tool-layout {
  max-width: 1200px;
  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%;
}

/* -------------------------------------------------------------
 * Banner publicitario superior e inferior
 * ------------------------------------------------------------- */
.tools-ad-banner-section {
  margin-bottom: 2rem;
}

/* -------------------------------------------------------------
 * Hero y presentación de la herramienta
 * ------------------------------------------------------------- */
.game-hero {
  text-align: center;
  margin-bottom: 2rem;
  padding: 1.5rem 1rem;
  background: radial-gradient(circle at top center, rgba(99, 102, 241, 0.15) 0%, transparent 70%);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.85rem;
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 9999px;
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--accent-indigo);
  margin-bottom: 1rem;
  text-transform: none;
}

.game-title {
  font-family: var(--font-heading);
  font-size: clamp(1.8rem, 4vw, 2.75rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin-bottom: 0.75rem;
  color: var(--text-main);
}

.game-title .gradient-text {
  background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 50%, #ec4899 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.game-subtitle {
  font-size: 1.05rem;
  color: var(--text-muted);
  max-width: 700px;
  margin: 0 auto;
  line-height: 1.5;
}

/* -------------------------------------------------------------
 * Barra de juego flotante / Sticky Password Box
 * ------------------------------------------------------------- */
.game-workspace-sticky {
  position: sticky;
  top: 85px;
  z-index: 80;
  background: var(--glass-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--card-shadow);
  padding: 1.25rem;
  margin-bottom: 2rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.game-workspace-sticky.is-invalid {
  border-color: rgba(244, 63, 94, 0.4);
}

.game-workspace-sticky.is-valid {
  border-color: rgba(16, 185, 129, 0.4);
}

/* HUD de estadísticas superior */
.hud-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--border-color);
}

.hud-stats-group {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.hud-stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}

.hud-stat-pill strong {
  color: var(--text-main);
  font-family: var(--font-mono);
  font-weight: 700;
}

.hud-actions-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

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

.btn-hud-action:hover {
  background: var(--bg-card-hover);
  border-color: var(--text-dim);
}

.btn-hud-action.active-sound {
  color: var(--accent-blue);
  border-color: rgba(59, 130, 246, 0.4);
}

/* Área de entrada de la contraseña */
.password-input-wrapper {
  position: relative;
  width: 100%;
}

.password-textarea {
  width: 100%;
  min-height: 85px;
  max-height: 180px;
  background: var(--bg-input);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 1.15rem;
  line-height: 1.5;
  padding: 0.85rem 1rem;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  box-sizing: border-box;
}

.password-textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.password-footer-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.char-counter {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-main);
}

/* Barra de accesos directos rápidos (emojis y caracteres) */
.quick-insert-bar {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--border-color);
}

.quick-insert-label {
  font-size: 0.775rem;
  color: var(--text-dim);
  margin-right: 0.25rem;
}

.btn-quick-char {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 0.95rem;
  padding: 0.25rem 0.55rem;
  cursor: pointer;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.btn-quick-char:hover {
  background: var(--bg-card-hover);
  transform: translateY(-1px);
  border-color: var(--text-muted);
}

/* -------------------------------------------------------------
 * Contenedor y tarjetas de reglas (Rules Stack)
 * ------------------------------------------------------------- */
.rules-container {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-bottom: 2.5rem;
}

.rule-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  box-shadow: var(--card-shadow);
  transition: all 0.25s ease;
  position: relative;
  overflow: hidden;
}

.rule-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 5px;
  height: 100%;
  background: var(--border-color);
  transition: background 0.25s ease;
}

/* Estado: No cumplida / Error */
.rule-card.is-invalid {
  border-color: rgba(244, 63, 94, 0.45);
  background: linear-gradient(to right, rgba(244, 63, 94, 0.05), var(--bg-card) 25%);
}

.rule-card.is-invalid::before {
  background: var(--accent-rose);
}

/* Estado: Cumplida / Éxito */
.rule-card.is-valid {
  border-color: rgba(16, 185, 129, 0.4);
  background: linear-gradient(to right, rgba(16, 185, 129, 0.04), var(--bg-card) 25%);
}

.rule-card.is-valid::before {
  background: var(--accent-emerald);
}

/* Encabezado de la tarjeta */
.rule-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.rule-meta {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.rule-number-badge {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
}

.rule-card.is-invalid .rule-number-badge {
  background: rgba(244, 63, 94, 0.15);
  color: var(--accent-rose);
}

.rule-card.is-valid .rule-number-badge {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-emerald);
}

.rule-title {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
}

.rule-status-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.9rem;
  font-weight: 700;
}

.rule-card.is-invalid .rule-status-icon {
  background: rgba(244, 63, 94, 0.15);
  color: var(--accent-rose);
  border: 1px solid rgba(244, 63, 94, 0.3);
}

.rule-card.is-valid .rule-status-icon {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-emerald);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.rule-description {
  font-size: 0.95rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 0.5rem;
}

/* Píldora de progreso en vivo */
.rule-progress-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.825rem;
  padding: 0.3rem 0.65rem;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  margin-top: 0.4rem;
}

/* -------------------------------------------------------------
 * Widgets interactivos específicos de reglas
 * ------------------------------------------------------------- */
/* Regla 10: Captcha */
.captcha-box-wrapper {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.75rem;
  padding: 0.75rem;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  width: fit-content;
}

.captcha-display {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: 0.35em;
  padding: 0.4rem 0.85rem;
  background: linear-gradient(45deg, #1e293b, #334155);
  color: #38bdf8;
  border-radius: var(--radius-sm);
  user-select: none;
  text-decoration: line-through;
  transform: skewX(-5deg);
}

.btn-captcha-refresh {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-captcha-refresh:hover {
  color: var(--text-main);
  border-color: var(--text-dim);
}

/* Regla 11: Fase lunar */
.moon-widget-box {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  width: fit-content;
}

.moon-emoji-big {
  font-size: 2.2rem;
  line-height: 1;
}

.moon-info {
  display: flex;
  flex-direction: column;
}

.moon-phase-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-main);
}

.moon-phase-instruction {
  font-size: 0.825rem;
  color: var(--text-dim);
}

/* Regla 14: Ajedrez */
.chess-widget-box {
  margin-top: 0.85rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
  padding: 1rem;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.chess-diagram {
  width: 160px;
  height: 160px;
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.chess-info {
  flex: 1;
  min-width: 200px;
}

.chess-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-main);
  margin-bottom: 0.25rem;
}

.chess-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Regla 15: Paco el pollo */
.chicken-widget-box {
  margin-top: 0.85rem;
  padding: 1rem;
  background: var(--bg-input);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

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

.chicken-name-group {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  font-size: 1rem;
}

.chicken-icon-animated {
  font-size: 1.6rem;
  animation: bounceChicken 1.8s infinite ease-in-out;
}

@keyframes bounceChicken {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-4px) scale(1.05);
  }
}

.chicken-hunger-bar-bg {
  width: 100%;
  height: 12px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 9999px;
  overflow: hidden;
  margin: 0.5rem 0;
  border: 1px solid var(--border-color);
}

.chicken-hunger-bar-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #10b981, #f59e0b, #ef4444);
  transition: width 0.3s ease;
  border-radius: 9999px;
}

/* Regla 16: Muestra de color hexadecimal */
.color-preview-swatch {
  display: inline-block;
  width: 20px;
  height: 20px;
  border-radius: 4px;
  vertical-align: middle;
  border: 1px solid rgba(255, 255, 255, 0.2);
  margin-left: 0.4rem;
}

/* -------------------------------------------------------------
 * Modales de notificación (Sin window.alert)
 * ------------------------------------------------------------- */
.game-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(11, 15, 23, 0.85);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.game-modal-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.game-modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 560px;
  width: 100%;
  padding: 2rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  text-align: center;
  position: relative;
  transform: translateY(20px) scale(0.96);
  transition: transform 0.25s ease;
}

.game-modal-backdrop.is-open .game-modal-card {
  transform: translateY(0) scale(1);
}

.modal-icon-big {
  font-size: 3.5rem;
  line-height: 1;
  margin-bottom: 1rem;
}

.modal-title {
  font-family: var(--font-heading);
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 0.75rem;
}

.modal-desc {
  font-size: 0.975rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 1.5rem;
}

.modal-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.75rem;
  background: var(--bg-input);
  padding: 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.modal-stat-box {
  display: flex;
  flex-direction: column;
}

.modal-stat-val {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-main);
}

.modal-stat-lbl {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.modal-buttons-group {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
}

.btn-modal-primary {
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.75rem 1.5rem;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
  min-height: 44px;
}

.btn-modal-primary:hover {
  opacity: 0.92;
  transform: translateY(-1px);
}

.btn-modal-secondary {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1.25rem;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 44px;
}

.btn-modal-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--text-dim);
}

/* -------------------------------------------------------------
 * Guía de reglas y preguntas frecuentes (SEO FAQ)
 * ------------------------------------------------------------- */
.game-seo-accordion-section {
  margin-top: 3.5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border-color);
}

.section-title {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  color: var(--text-main);
}

.faq-accordion {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.faq-item {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color 0.2s ease;
}

.faq-item:hover {
  border-color: rgba(99, 102, 241, 0.3);
}

.faq-question {
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  padding: 1.1rem 1.25rem;
  font-family: var(--font-main);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.faq-icon-arrow {
  transition: transform 0.2s ease;
  color: var(--text-dim);
  flex-shrink: 0;
}

.faq-item.is-open .faq-icon-arrow {
  transform: rotate(180deg);
  color: var(--accent-blue);
}

.faq-answer {
  padding: 0 1.25rem 1.25rem;
  font-size: 0.925rem;
  color: var(--text-muted);
  line-height: 1.6;
  display: none;
}

.faq-item.is-open .faq-answer {
  display: block;
}

/* -------------------------------------------------------------
 * Adaptación móvil (Responsive)
 * ------------------------------------------------------------- */
@media (max-width: 768px) {
  .game-workspace-sticky {
    padding: 1rem;
    top: 80px;
  }

  .hud-bar {
    flex-direction: column;
    align-items: flex-start;
  }

  .hud-stats-group {
    width: 100%;
    justify-content: space-between;
  }

  .password-textarea {
    font-size: 1rem;
    min-height: 75px;
  }

  .modal-stats-grid {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .modal-buttons-group {
    flex-direction: column;
  }

  .btn-modal-primary,
  .btn-modal-secondary {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 640px) {
  .game-workspace-sticky {
    top: 0.5rem;
  }
}