/* ==============================================================================
   CÁLCULO TÁCTICO RELÁMPAGO — Estilos Oficiales (Dark Luxury & Neón Táctico)
   Ecosistema Oficial de Club del Ingenio
   ============================================================================== */

:root {
  --bg-dark: #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.4);
  
  --gold: #f59e0b;
  --gold-glow: rgba(245, 158, 11, 0.35);
  --cyan: #38bdf8;
  --cyan-glow: rgba(56, 189, 248, 0.35);
  --emerald: #34d399;
  --rose: #f43f5e;
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --font-sans: 'Outfit', -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --font-title: 'Cinzel', serif;
}

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

body {
  background-color: var(--bg-dark);
  background-image: 
    radial-gradient(circle at 50% 15%, rgba(56, 189, 248, 0.12) 0%, transparent 55%),
    radial-gradient(circle at 85% 80%, rgba(245, 158, 11, 0.08) 0%, transparent 50%),
    radial-gradient(circle at 15% 85%, rgba(16, 185, 129, 0.06) 0%, transparent 45%);
  color: var(--text-main);
  font-family: var(--font-sans);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* ==============================================================================
   CABECERA DE LA APP
   ============================================================================== */
.app-header {
  background: rgba(11, 15, 25, 0.85);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.75rem 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

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

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

.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--border-cyan);
  object-fit: cover;
  box-shadow: 0 0 15px var(--cyan-glow);
}

.brand-text h1 {
  font-family: var(--font-title);
  font-size: 1.15rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.brand-text h1 span.highlight {
  color: var(--cyan);
}

.brand-text p {
  font-size: 0.72rem;
  color: var(--gold);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

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

.btn-header {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s ease;
}

.btn-header:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--cyan);
  transform: translateY(-1px);
}

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

/* ==============================================================================
   LAYOUT PRINCIPAL
   ============================================================================== */
.main-wrapper {
  max-width: 800px;
  margin: 0 auto;
  padding: 1rem 1rem 2.5rem;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* Selector de Dificultad y Barra Superior */
.top-bar-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  background: var(--bg-card);
  padding: 0.6rem 0.85rem;
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
  backdrop-filter: blur(12px);
}

.diff-selector-group {
  display: flex;
  gap: 0.35rem;
}

.diff-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.35rem 0.7rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  text-transform: uppercase;
}

.diff-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
}

.diff-btn.active[data-diff="facil"] {
  background: rgba(52, 211, 153, 0.18);
  border-color: #34d399;
  color: #34d399;
}
.diff-btn.active[data-diff="medio"] {
  background: rgba(56, 189, 248, 0.18);
  border-color: #38bdf8;
  color: #38bdf8;
}
.diff-btn.active[data-diff="dificil"] {
  background: rgba(245, 158, 11, 0.18);
  border-color: #f59e0b;
  color: #fbbf24;
}
.diff-btn.active[data-diff="endemoniado"] {
  background: rgba(244, 63, 94, 0.18);
  border-color: #f43f5e;
  color: #fda4af;
}

.duel-seed-badge {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--cyan);
  background: rgba(56, 189, 248, 0.08);
  border: 1px dashed rgba(56, 189, 248, 0.3);
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  letter-spacing: 0.05em;
}

/* ==============================================================================
   PANEL CENTRAL: LA DIANA Y EL CRONÓMETRO
   ============================================================================= */
.target-dashboard {
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.9), rgba(30, 41, 59, 0.7));
  border: 1px solid var(--border-gold);
  border-radius: 20px;
  padding: 1.5rem;
  box-shadow: 0 15px 35px -10px rgba(0, 0, 0, 0.7), 0 0 25px rgba(245, 158, 11, 0.12);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
  position: relative;
  overflow: hidden;
}

.target-dashboard::before {
  content: '';
  position: absolute;
  top: -50%;
  left: 50%;
  width: 200px;
  height: 200px;
  transform: translateX(-50%);
  background: radial-gradient(circle, rgba(245, 158, 11, 0.2), transparent 70%);
  pointer-events: none;
}

.target-column {
  text-align: center;
}

.target-label {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--gold);
  letter-spacing: 0.08em;
  margin-bottom: 0.25rem;
}

.target-display-num {
  font-family: var(--font-title);
  font-size: 3.5rem;
  font-weight: 900;
  color: #fff;
  line-height: 1;
  text-shadow: 0 0 25px rgba(245, 158, 11, 0.5);
  letter-spacing: 0.03em;
}

.timer-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
}

.timer-box {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 0.4rem 0.85rem;
  border-radius: 10px;
  font-family: var(--font-mono);
  font-size: 1.35rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: 0.05em;
  transition: all 0.3s;
}

.timer-box.urgent {
  color: var(--rose);
  border-color: var(--rose);
  box-shadow: 0 0 18px rgba(244, 63, 94, 0.4);
  animation: pulse-urgent 0.8s infinite alternate;
}

@keyframes pulse-urgent {
  0% { transform: scale(1); }
  100% { transform: scale(1.06); }
}

.timer-progress-track {
  width: 110px;
  height: 5px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  overflow: hidden;
}

.timer-progress-bar {
  height: 100%;
  width: 100%;
  background: var(--cyan);
  transition: width 1s linear, background-color 0.4s ease;
}

.best-column {
  text-align: center;
}

.best-label {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--cyan);
  letter-spacing: 0.08em;
  margin-bottom: 0.25rem;
}

.best-display-num {
  font-family: var(--font-title);
  font-size: 2.75rem;
  font-weight: 800;
  color: #cbd5e1;
  line-height: 1;
}

.diff-badge {
  display: inline-block;
  margin-top: 0.4rem;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
}

.diff-badge.exact {
  background: rgba(52, 211, 153, 0.25);
  border: 1px solid #34d399;
  color: #34d399;
  font-weight: 800;
  box-shadow: 0 0 12px rgba(52, 211, 153, 0.4);
}

/* ==============================================================================
   MESA DE FICHAS DISPONIBLES
   ============================================================================== */
.table-section {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 18px;
  padding: 1.25rem;
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.section-caption {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.tiles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
  gap: 0.75rem;
}

.number-tile {
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.85), rgba(15, 23, 42, 0.95));
  border: 1px solid var(--border-cyan);
  border-radius: 14px;
  color: #fff;
  font-family: var(--font-title);
  font-size: 1.85rem;
  font-weight: 800;
  padding: 1rem 0.5rem;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
}

.number-tile:hover {
  transform: translateY(-3px) scale(1.03);
  border-color: var(--cyan);
  box-shadow: 0 10px 25px var(--cyan-glow);
}

.number-tile.selected-a {
  border-color: var(--gold);
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.3), rgba(30, 41, 59, 0.95));
  box-shadow: 0 0 25px var(--gold-glow);
  transform: scale(1.05);
}

.number-tile.selected-b {
  border-color: var(--emerald);
  background: linear-gradient(135deg, rgba(52, 211, 153, 0.3), rgba(30, 41, 59, 0.95));
  box-shadow: 0 0 25px rgba(52, 211, 153, 0.4);
  transform: scale(1.05);
}

/* Barra de Operadores */
.operators-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.6rem;
}

.operator-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 1.75rem;
  font-weight: 700;
  padding: 0.6rem;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.operator-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--gold);
  transform: translateY(-2px);
}

.operator-btn.selected {
  background: linear-gradient(135deg, var(--gold), #d97706);
  color: #000;
  border-color: #fbbf24;
  box-shadow: 0 0 20px var(--gold-glow);
  transform: scale(1.05);
}

/* Previsualización de Fórmula */
.formula-box {
  background: rgba(0, 0, 0, 0.35);
  border: 1px dashed rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  text-align: center;
  font-size: 1rem;
  font-weight: 600;
}

.formula-box.empty {
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.88rem;
}

.formula-box.active {
  color: #fff;
  font-family: var(--font-mono);
  font-size: 1.25rem;
  border-color: var(--cyan);
  box-shadow: 0 0 15px rgba(56, 189, 248, 0.15);
}

/* ==============================================================================
   HISTORIAL DE OPERACIONES Y ACCIONES
   ============================================================================== */
.actions-and-history-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 600px) {
  .actions-and-history-grid {
    grid-template-columns: 1fr;
  }
  .target-dashboard {
    grid-template-columns: 1fr;
    text-align: center;
    gap: 1.25rem;
  }
  .target-display-num {
    font-size: 3rem;
  }
}

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

.history-steps-scroll {
  max-height: 160px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-top: 0.5rem;
  padding-right: 0.3rem;
}

.step-item {
  background: rgba(0, 0, 0, 0.3);
  border-left: 3px solid var(--cyan);
  padding: 0.4rem 0.65rem;
  border-radius: 0 6px 6px 0;
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
}

.step-num {
  color: var(--text-muted);
}

.step-text {
  color: #fff;
  font-family: var(--font-mono);
}

.empty-steps {
  color: var(--text-muted);
  font-size: 0.82rem;
  font-style: italic;
  text-align: center;
  padding: 2rem 0;
}

.tactical-actions-box {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.75rem;
}

.action-row {
  display: flex;
  gap: 0.5rem;
}

.btn-ctrl {
  flex: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #cbd5e1;
  padding: 0.6rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

.btn-ctrl:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.btn-ctrl:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-claim-primary {
  width: 100%;
  background: linear-gradient(135deg, var(--gold), #d97706);
  color: #000;
  font-weight: 800;
  font-size: 1rem;
  padding: 0.85rem;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  box-shadow: 0 10px 25px var(--gold-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.2s;
}

.btn-claim-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 15px 30px rgba(245, 158, 11, 0.5);
}

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

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

.modal-card {
  background: #0b0f19;
  border: 1px solid var(--border-gold);
  border-radius: 20px;
  max-width: 500px;
  width: 100%;
  padding: 2rem;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.8), 0 0 35px var(--gold-glow);
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-card.cyan-theme {
  border-color: var(--border-cyan);
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.8), 0 0 35px var(--cyan-glow);
}

.btn-close-modal {
  position: absolute;
  top: 1.25rem;
  right: 1.25rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  cursor: pointer;
  transition: color 0.2s;
}

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

.modal-title {
  font-family: var(--font-title);
  font-size: 1.5rem;
  font-weight: 800;
  color: #fbbf24;
  margin-bottom: 0.35rem;
}

.modal-card.cyan-theme .modal-title {
  color: var(--cyan);
}

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

/* Veredicto de Juego */
.verdict-rank-badge {
  display: inline-block;
  padding: 0.4rem 1rem;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 800;
  border: 1px solid var(--gold);
  margin-bottom: 1.25rem;
  background: rgba(0, 0, 0, 0.3);
}

.verdict-comparison-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.5rem;
  text-align: center;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 12px;
  padding: 1rem 0.5rem;
  margin-bottom: 1.25rem;
}

.verdict-item strong {
  display: block;
  font-family: var(--font-title);
  font-size: 1.5rem;
  color: #fff;
  margin-top: 0.2rem;
}

.score-breakdown-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
  font-size: 0.88rem;
}

.score-breakdown-table td {
  padding: 0.45rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.score-breakdown-table tr.total-row td {
  border-bottom: none;
  font-size: 1.15rem;
  font-weight: 800;
  padding-top: 0.8rem;
  color: #fbbf24;
}

.modal-footer-btns {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.btn-modal-primary {
  background: linear-gradient(135deg, var(--gold), #d97706);
  color: #000;
  font-weight: 800;
  font-size: 0.95rem;
  padding: 0.75rem;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  box-shadow: 0 8px 20px var(--gold-glow);
}

.btn-modal-secondary {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.65rem;
  border-radius: 10px;
  cursor: pointer;
}

/* Solución Óptima */
.optimal-header-note {
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: 8px;
  padding: 0.75rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  color: #e2e8f0;
}

.optimal-step-item {
  background: rgba(0, 0, 0, 0.3);
  border-left: 3px solid var(--emerald);
  padding: 0.5rem 0.75rem;
  border-radius: 0 6px 6px 0;
  margin-bottom: 0.4rem;
  display: flex;
  justify-content: space-between;
}

/* Historial */
.record-item-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.rec-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.rec-rank-icon {
  font-size: 1.5rem;
}

.rec-status {
  font-size: 0.7rem;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
}

.rec-status.exact {
  background: rgba(52, 211, 153, 0.2);
  color: #34d399;
}

/* Notificación Toast */
.toast-box {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: #0f172a;
  border: 1px solid var(--cyan);
  color: #fff;
  padding: 0.85rem 1.25rem;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
  z-index: 9999;
  opacity: 0;
  transform: translateY(15px);
  pointer-events: none;
  transition: all 0.25s ease;
}

.toast-box.active {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.toast-box.toast-error {
  border-color: var(--rose);
  color: #fecdd3;
}

.toast-box.toast-warning {
  border-color: var(--gold);
  color: #fef3c7;
}

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

/* Modal de Selección de Idioma */
.languages-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}

.lang-select-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  text-align: left;
  color: var(--text-main);
}

.lang-select-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--cyan);
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(56, 189, 248, 0.25);
}

.lang-select-btn.active {
  background: rgba(56, 189, 248, 0.18);
  border-color: var(--cyan);
  box-shadow: 0 0 15px var(--cyan-glow);
}

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

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

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