/* ==========================================================================
   Estilos principales del juego de gemas y joyas match 3 arcade
   Paleta: Midnight Slate, Cosmic Blue, Oro puro y acentos de gemas facetadas
   Tipografías canónicas: Inter (cuerpo), Outfit (títulos), JetBrains Mono (cifras)
   ========================================================================== */

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

  /* Paleta cromática */
  --bg-dark: #070a12;
  --bg-card: rgba(15, 23, 42, 0.75);
  --bg-card-border: rgba(255, 255, 255, 0.08);
  --bg-board-frame: linear-gradient(145deg, #1e293b, #0f172a);

  --accent-gold: #ffd700;
  --accent-gold-glow: rgba(255, 215, 0, 0.4);
  --accent-cyan: #00e5ff;
  --accent-purple: #d500f9;
  --accent-ruby: #ff1744;

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

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --------------------------------------------------------------------------
   Reset y contención global
   -------------------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
}

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

/* --------------------------------------------------------------------------
   Layout canónico con sidebar para AdSense
   -------------------------------------------------------------------------- */
.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%;
}

/* --------------------------------------------------------------------------
   Cabecera superior del juego y selector de modos
   -------------------------------------------------------------------------- */
.game-top-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
}

.mode-tabs-group {
  display: flex;
  gap: 0.4rem;
  background: rgba(0, 0, 0, 0.4);
  padding: 4px;
  border-radius: var(--radius-full);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.mode-tab {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.88rem;
  padding: 0.45rem 1rem;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.mode-tab:hover {
  color: #ffffff;
}

.mode-tab.active {
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  color: #ffffff;
  box-shadow: 0 2px 10px rgba(37, 99, 235, 0.4);
}

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

.btn-game-action {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-main);
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.84rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  min-height: 38px;
}

.btn-game-action:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
}

.btn-game-action.muted {
  opacity: 0.55;
  color: var(--text-dim);
}

.btn-game-action.btn-hint-highlight {
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.18), rgba(255, 171, 0, 0.28));
  border-color: rgba(255, 215, 0, 0.45);
  color: #fff9c4;
}

.btn-game-action.btn-hint-highlight:hover {
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.3), rgba(255, 171, 0, 0.45));
}

/* --------------------------------------------------------------------------
   Panel HUD: Puntuación, Récord, Nivel / Tiempo y Multiplicador
   -------------------------------------------------------------------------- */
.hud-panel-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.85rem;
  margin-bottom: 1.25rem;
}

.hud-card {
  background: var(--bg-card);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.hud-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
}

.hud-card-score::before {
  background: linear-gradient(90deg, transparent, var(--accent-gold), transparent);
}

.hud-card-best::before {
  background: linear-gradient(90deg, transparent, var(--accent-cyan), transparent);
}

.hud-card-title {
  font-family: var(--font-heading);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.hud-val {
  font-family: var(--font-mono);
  font-size: 1.55rem;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.1;
  transition: transform 0.15s ease, color 0.15s ease;
}

.hud-val.pulse {
  transform: scale(1.15);
  color: var(--accent-gold);
}

.hud-val.danger {
  color: var(--accent-ruby);
  animation: timerWarning 0.8s infinite alternate;
}

@keyframes timerWarning {
  from { transform: scale(1); }
  to { transform: scale(1.12); }
}

.hud-card-combo.active .hud-val {
  color: var(--accent-purple);
  text-shadow: 0 0 12px rgba(213, 0, 249, 0.6);
}

/* --------------------------------------------------------------------------
   Barra de progreso de nivel
   -------------------------------------------------------------------------- */
.progress-bar-container {
  margin-bottom: 1.5rem;
  position: relative;
}

.progress-bar-track {
  height: 10px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: var(--radius-full);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  position: relative;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #2563eb, #00e5ff, #ffd700);
  border-radius: var(--radius-full);
  transition: width 0.3s ease;
  box-shadow: 0 0 10px rgba(0, 229, 255, 0.5);
}

.progress-bar-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.35rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* --------------------------------------------------------------------------
   Escenario del tablero y contenedor de Canvas
   -------------------------------------------------------------------------- */
.game-stage-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 2rem;
  width: 100%;
}

.board-container {
  position: relative;
  border-radius: var(--radius-lg);
  padding: 8px;
  background: var(--bg-board-frame);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.7),
              0 0 0 1px rgba(255, 255, 255, 0.1),
              0 0 32px rgba(0, 229, 255, 0.15);
  display: flex;
  justify-content: center;
  align-items: center;
  max-width: 100%;
}

#canvas-board {
  display: block;
  border-radius: calc(var(--radius-lg) - 6px);
  cursor: pointer;
  touch-action: none; /* Desactiva el scroll del navegador al deslizar */
  background: #090d16;
}

/* --------------------------------------------------------------------------
   Modales accesibles de juego (Pausa, Fin de Partida, Instrucciones)
   -------------------------------------------------------------------------- */
.game-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

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

.game-modal-card {
  background: #0f172a;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-lg);
  padding: 2rem;
  width: 100%;
  max-width: 480px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.8), 0 0 40px rgba(0, 229, 255, 0.2);
  transform: translateY(20px) scale(0.95);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.game-modal-overlay.active .game-modal-card {
  transform: translateY(0) scale(1);
}

.modal-icon-badge {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  margin: 0 auto 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.2), rgba(255, 171, 0, 0.3));
  border: 1px solid rgba(255, 215, 0, 0.4);
  color: var(--accent-gold);
}

.game-modal-title {
  font-family: var(--font-heading);
  font-size: 1.65rem;
  font-weight: 800;
  margin: 0 0 0.5rem;
  color: #ffffff;
}

.game-modal-desc {
  font-size: 0.95rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0 0 1.5rem;
}

.modal-score-highlight {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-bottom: 1.5rem;
}

.modal-score-label {
  font-family: var(--font-heading);
  font-size: 0.8rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.modal-score-val {
  font-family: var(--font-mono);
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--accent-gold);
}

.modal-actions-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.btn-modal-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  border: none;
  color: #ffffff;
  padding: 0.85rem 1.5rem;
  border-radius: var(--radius-md);
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  min-height: 48px;
}

.btn-modal-primary:hover {
  background: linear-gradient(135deg, #1d4ed8, #2563eb);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.45);
}

.btn-modal-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text-main);
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  min-height: 44px;
}

.btn-modal-secondary:hover {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.28);
}

/* Lista de controles para el modal de ayuda */
.controls-guide-list {
  text-align: left;
  list-style: none;
  padding: 0;
  margin: 0 0 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.controls-guide-list li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.controls-badge {
  display: inline-block;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: #ffffff;
  min-width: 65px;
  text-align: center;
}

/* --------------------------------------------------------------------------
   Guía de gemas especiales (Visual Info Card)
   -------------------------------------------------------------------------- */
.special-gems-legend-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-top: 1.5rem;
  margin-bottom: 2.5rem;
}

.special-gem-card {
  background: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-md);
  padding: 1rem;
  text-align: center;
}

.special-gem-icon {
  font-size: 1.8rem;
  margin-bottom: 0.5rem;
}

.special-gem-title {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 0.25rem;
}

.special-gem-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin: 0;
}

/* --------------------------------------------------------------------------
   Sección SEO / Acordeón de preguntas frecuentes
   -------------------------------------------------------------------------- */
.seo-guide-section {
  margin-top: 3rem;
  border-top: 1px solid var(--bg-card-border);
  padding-top: 2.5rem;
}

.seo-guide-title {
  font-family: var(--font-heading);
  font-size: 1.6rem;
  font-weight: 800;
  color: #ffffff;
  margin: 0 0 1rem;
}

.seo-guide-lead {
  font-size: 1.05rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 1.75rem;
}

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

.seo-accordion-item {
  background: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color var(--transition-fast);
}

.seo-accordion-item:hover {
  border-color: rgba(255, 255, 255, 0.16);
}

.seo-accordion-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.1rem 1.25rem;
  background: none;
  border: none;
  color: #ffffff;
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.seo-accordion-icon {
  transition: transform 0.25s ease;
  color: var(--text-dim);
}

.seo-accordion-item.open .seo-accordion-icon {
  transform: rotate(180deg);
  color: var(--accent-cyan);
}

.seo-accordion-content {
  padding: 0 1.25rem 1.25rem;
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.6;
  display: none;
}

.seo-accordion-item.open .seo-accordion-content {
  display: block;
}

/* --------------------------------------------------------------------------
   Responsive: Móviles y Tablets
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  .game-top-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .mode-tabs-group {
    justify-content: center;
    width: 100%;
  }

  .mode-tab {
    flex: 1;
    text-align: center;
    padding: 0.45rem 0.6rem;
    font-size: 0.8rem;
  }

  .top-bar-actions {
    justify-content: space-between;
    width: 100%;
  }

  .btn-game-action {
    flex: 1;
    justify-content: center;
    padding: 0.45rem 0.5rem;
    font-size: 0.78rem;
  }

  .btn-game-action span {
    display: inline;
  }

  .hud-panel-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.6rem;
  }

  .hud-val {
    font-size: 1.35rem;
  }

  .special-gems-legend-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .board-container {
    padding: 4px;
    border-radius: var(--radius-md);
  }

  #canvas-board {
    border-radius: calc(var(--radius-md) - 3px);
  }
}
