/* ==========================================================================
   NONOGRAMAS DEL CLUB — Estilos Zen & Dark Luxury
   Ecosistema Oficial de Club del Ingenio
   ========================================================================== */

:root {
  --bg-main: #070a13;
  --bg-card: rgba(15, 23, 42, 0.75);
  --bg-card-hover: rgba(30, 41, 59, 0.85);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-gold: rgba(245, 158, 11, 0.4);
  --border-cyan: rgba(56, 189, 248, 0.35);

  --gold-primary: #f59e0b;
  --gold-light: #fbbf24;
  --cyan-primary: #38bdf8;
  --cyan-glow: rgba(56, 189, 248, 0.3);
  --emerald-primary: #10b981;
  --rose-primary: #f43f5e;

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

  --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-serif: 'Cinzel', Georgia, serif;
  --font-mono: 'JetBrains Mono', monospace;

  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 18px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

body {
  background-color: var(--bg-main);
  background-image: 
    radial-gradient(circle at 15% 15%, rgba(56, 189, 248, 0.07) 0%, transparent 40%),
    radial-gradient(circle at 85% 85%, rgba(245, 158, 11, 0.06) 0%, transparent 40%);
  color: var(--text-main);
  font-family: var(--font-sans);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* === CABECERA === */
.app-header {
  background: rgba(7, 10, 19, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 50;
  padding: 0.6rem 1rem;
}

.header-inner {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: inherit;
}

.brand-logo-crest {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.2), rgba(56, 189, 248, 0.2));
  border: 1px solid var(--border-gold);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  box-shadow: 0 0 15px rgba(245, 158, 11, 0.15);
}

.brand-text h1 {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  background: linear-gradient(135deg, #fff 30%, var(--gold-light) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.1;
}

.brand-text p {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-weight: 500;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.btn-header {
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.65rem;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn-header:hover {
  background: rgba(51, 65, 85, 0.8);
  border-color: var(--border-cyan);
  transform: translateY(-1px);
}

.btn-header.club-btn {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.2), rgba(30, 41, 59, 0.8));
  border-color: var(--border-gold);
  color: var(--gold-light);
}

/* === CONTENEDOR PRINCIPAL === */
.main-wrapper {
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  padding: 0.75rem 1rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  flex: 1;
}

/* === BANNER INFORMACIÓN PUZLE === */
.puzzle-info-bar {
  background: var(--bg-card);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.puzzle-title-area {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.puzzle-title {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  color: var(--gold-light);
  letter-spacing: 0.02em;
}

.diff-badge {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.diff-badge.facil {
  background: rgba(16, 185, 129, 0.2);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #34d399;
}

.diff-badge.medio {
  background: rgba(56, 189, 248, 0.2);
  border: 1px solid rgba(56, 189, 248, 0.4);
  color: #38bdf8;
}

.diff-badge.dificil {
  background: rgba(244, 63, 94, 0.2);
  border: 1px solid rgba(244, 63, 94, 0.4);
  color: #fb7185;
}

.puzzle-stats-area {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--text-main);
}

.progress-track {
  width: 70px;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  overflow: hidden;
  display: inline-block;
  vertical-align: middle;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--cyan-primary), var(--gold-light));
  transition: width 0.3s ease;
}

/* === BARRA DE HERRAMIENTAS INTERACTIVA === */
.tools-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.tool-btn {
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tool-btn:hover {
  background: rgba(51, 65, 85, 0.9);
  color: #fff;
}

.tool-btn.active#tool-paint {
  background: rgba(56, 189, 248, 0.2);
  border-color: var(--cyan-primary);
  color: var(--cyan-primary);
  box-shadow: 0 0 12px var(--cyan-glow);
}

.tool-btn.active#tool-cross {
  background: rgba(244, 63, 94, 0.2);
  border-color: var(--rose-primary);
  color: #fb7185;
  box-shadow: 0 0 12px rgba(244, 63, 94, 0.3);
}

.btn-secondary {
  background: rgba(30, 41, 59, 0.5);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.85rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background: rgba(51, 65, 85, 0.8);
  color: var(--gold-light);
  border-color: var(--border-gold);
}

/* === TABLERO DE NONOGRAMAS === */
.board-viewport {
  background: var(--bg-card);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1rem;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: auto;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.nonogram-board {
  display: grid;
  grid-template-columns: auto auto;
  grid-template-rows: auto auto;
  gap: 4px;
  max-width: 100%;
}

/* Esquina */
.board-corner {
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 4px;
}

.corner-icon {
  font-size: 1.1rem;
  opacity: 0.4;
}

/* Pistas de Columnas */
.board-col-clues {
  display: flex;
}

.col-clue-box {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  padding: 4px 2px;
  background: rgba(15, 23, 42, 0.6);
  border-bottom: 2px solid var(--border-gold);
  min-width: 24px;
  width: var(--cell-size, 32px);
  box-sizing: border-box;
}

.col-clue-box.border-subgrid-col {
  border-right: 2px solid rgba(245, 158, 11, 0.5);
}

.col-clue-box.clue-satisfied .clue-num {
  color: var(--gold-light);
  opacity: 0.35;
  text-decoration: line-through;
}

/* Pistas de Filas */
.board-row-clues {
  display: flex;
  flex-direction: column;
}

.row-clue-box {
  display: flex;
  flex-direction: row;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  padding: 2px 8px;
  background: rgba(15, 23, 42, 0.6);
  border-right: 2px solid var(--border-gold);
  height: var(--cell-size, 32px);
  box-sizing: border-box;
}

.row-clue-box.border-subgrid-row {
  border-bottom: 2px solid rgba(245, 158, 11, 0.5);
}

.row-clue-box.clue-satisfied .clue-num {
  color: var(--gold-light);
  opacity: 0.35;
  text-decoration: line-through;
}

.clue-num {
  font-family: var(--font-mono);
  font-size: clamp(0.7rem, 2.2vw, 0.9rem);
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.1;
  text-align: center;
  min-width: 12px;
  transition: opacity 0.2s ease, color 0.2s ease;
}

/* Matriz de Celdas */
.board-grid {
  display: grid;
  background: rgba(30, 41, 59, 0.8);
  border: 2px solid rgba(245, 158, 11, 0.6);
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.grid-cell {
  width: var(--cell-size, 32px);
  height: var(--cell-size, 32px);
  background: #0b1120;
  border: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.1s ease;
}

.grid-cell:hover {
  background: #1e293b;
}

.grid-cell.subgrid-right {
  border-right: 2px solid rgba(245, 158, 11, 0.5);
}

.grid-cell.subgrid-bottom {
  border-bottom: 2px solid rgba(245, 158, 11, 0.5);
}

.grid-cell.filled {
  background: var(--cyan-primary);
  box-shadow: inset 0 0 4px rgba(0, 0, 0, 0.3);
}

.grid-cell.crossed {
  background: #0f172a;
  position: relative;
}

.grid-cell.crossed::after {
  content: '✖';
  color: #64748b;
  font-size: clamp(0.7rem, 2vw, 0.95rem);
  font-weight: 900;
}

/* Ajustes de tamaño responsivo según dificultad */
.size-5 {
  --cell-size: clamp(40px, 9vw, 56px);
}

.size-10 {
  --cell-size: clamp(26px, 5.5vw, 36px);
}

.size-15 {
  --cell-size: clamp(18px, 4vw, 26px);
}

.victory-glow {
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.6) !important;
  animation: pulse-glow 1.5s infinite alternate;
}

@keyframes pulse-glow {
  from { filter: brightness(1); }
  to { filter: brightness(1.25); }
}

/* === MODALES === */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: #0b1120;
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-lg);
  max-width: 650px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.5rem;
  position: relative;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
}

.btn-close-modal {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: rgba(30, 41, 59, 0.5);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-close-modal:hover {
  background: #334155;
  color: #fff;
}

.modal-title {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  color: var(--gold-light);
  margin-bottom: 0.35rem;
}

.modal-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}

/* Pestañas del Catálogo */
.catalog-tabs {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 0.5rem;
}

.catalog-tab-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.catalog-tab-btn.active {
  background: rgba(245, 158, 11, 0.15);
  border-color: var(--border-gold);
  color: var(--gold-light);
}

.catalog-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 0.85rem;
}

.catalog-card {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.85rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.6rem;
  transition: all 0.2s ease;
}

.catalog-card:hover {
  background: rgba(30, 41, 59, 0.9);
  border-color: var(--border-cyan);
  transform: translateY(-2px);
}

.catalog-card.solved {
  border-color: var(--border-gold);
}

.catalog-preview {
  width: 70px;
  height: 70px;
  background: #070a13;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

.lock-icon {
  font-size: 1.3rem;
  color: var(--text-dim);
}

.preview-size {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-muted);
}

.catalog-info h4 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
}

.badge-solved {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--gold-light);
}

.badge-pending {
  font-size: 0.65rem;
  color: var(--text-dim);
}

/* Miniatura Pixel Art */
.thumb-pixel-grid {
  display: grid;
  width: 100%;
  height: 100%;
  padding: 3px;
}

.thumb-pixel {
  width: 100%;
  height: 100%;
  background: transparent;
}

/* Pinacoteca (Galería) */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}

.gallery-frame {
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.8), rgba(15, 23, 42, 0.9));
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
  transition: all 0.2s ease;
}

.gallery-frame:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(245, 158, 11, 0.2);
}

.gallery-art {
  width: 90px;
  height: 90px;
  background: #030712;
  border: 2px solid var(--gold-light);
  border-radius: var(--radius-sm);
  margin-bottom: 0.65rem;
}

.gallery-meta h3 {
  font-family: var(--font-serif);
  font-size: 0.95rem;
  color: var(--gold-light);
  margin-bottom: 0.25rem;
}

.gallery-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.35;
  margin-bottom: 0.65rem;
}

.gallery-footer {
  display: flex;
  justify-content: space-between;
  width: 100%;
  font-size: 0.72rem;
  font-family: var(--font-mono);
  color: var(--text-dim);
}

.gallery-empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* Modal de Idioma */
.lang-modal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.65rem;
}

.lang-select-btn {
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.2s ease;
}

.lang-select-btn:hover {
  background: rgba(51, 65, 85, 0.9);
  border-color: var(--border-cyan);
}

.lang-flag {
  font-size: 1.4rem;
}

.lang-text {
  text-align: left;
}

.lang-text strong {
  display: block;
  font-size: 0.88rem;
}

.lang-text small {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* Toast */
.toast-box {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(50px);
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid var(--border-cyan);
  color: var(--text-main);
  padding: 0.65rem 1.25rem;
  border-radius: 30px;
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 200;
}

.toast-box.active {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast-box.success {
  border-color: var(--emerald-primary);
  color: #34d399;
}

/* === RETO SEMANAL & TALLER DEL CREADOR === */
.btn-header.weekly-btn {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.25), rgba(30, 41, 59, 0.8));
  border-color: var(--border-gold);
  color: var(--gold-light);
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.15);
}

.btn-header.weekly-btn:hover {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.35), rgba(30, 41, 59, 0.95));
  border-color: var(--gold-light);
  box-shadow: 0 0 15px rgba(245, 158, 11, 0.3);
}

.btn-header.editor-btn {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.2), rgba(30, 41, 59, 0.8));
  border-color: var(--border-cyan);
  color: var(--cyan-primary);
}

.btn-header.editor-btn:hover {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.3), rgba(30, 41, 59, 0.95));
  border-color: var(--cyan-primary);
  box-shadow: 0 0 15px var(--cyan-glow);
}

/* Selector de tamaño del editor */
.btn-editor-size {
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.75rem;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-editor-size:hover {
  background: rgba(51, 65, 85, 0.8);
  color: #fff;
}

.btn-editor-size.active {
  background: rgba(56, 189, 248, 0.2);
  border-color: var(--cyan-primary);
  color: var(--cyan-primary);
  box-shadow: 0 0 10px var(--cyan-glow);
}

/* Paleta de colores */
.color-swatch {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.color-swatch:hover {
  transform: scale(1.15);
}

.color-swatch.active {
  border-color: #fff;
  transform: scale(1.2);
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

/* Cuadrícula del editor */
.editor-board {
  display: grid;
  grid-template-columns: auto auto;
  grid-template-rows: auto auto;
  gap: 3px;
  max-width: 100%;
}

.editor-grid {
  display: grid;
  background: rgba(30, 41, 59, 0.9);
  border: 2px solid rgba(245, 158, 11, 0.6);
  border-radius: 4px;
  overflow: hidden;
}

.editor-cell {
  width: var(--editor-cell-size, 30px);
  height: var(--editor-cell-size, 30px);
  background: #0b1120;
  border: 1px solid rgba(255, 255, 255, 0.06);
  cursor: pointer;
  transition: background-color 0.12s ease;
}

.editor-cell:hover {
  background: #1e293b;
}

.editor-cell.active {
  background: var(--active-swatch-color, #f59e0b);
  box-shadow: inset 0 0 4px rgba(0, 0, 0, 0.4);
}

.editor-cell.subgrid-right {
  border-right: 2px solid rgba(245, 158, 11, 0.5);
}

.editor-cell.subgrid-bottom {
  border-bottom: 2px solid rgba(245, 158, 11, 0.5);
}

/* Responsive header tweaks */
@media (max-width: 768px) {
  .header-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.3rem;
  }
  .btn-header {
    padding: 0.35rem 0.5rem;
    font-size: 0.8rem;
  }
}
