/* ==========================================================================
   Damas contra la máquina - Estilos canónicos y diseño responsive 3D
   Fijate Tools • Normas de accesibilidad, ebanistería noble y 60 FPS
   ========================================================================== */

:root {
  --bg-primary: #0b0f17;
  --bg-surface: #151d2a;
  --bg-surface-alt: #1f2b3e;
  --bg-card: rgba(21, 29, 42, 0.92);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(212, 175, 55, 0.6);

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --accent-gold: #d4af37;
  --accent-gold-hover: #b89726;
  --accent-amber: #f59e0b;
  --accent-success: #10b981;
  --accent-danger: #ef4444;
  --accent-info: #0284c7;

  --board-max-size: 880px;

  --shadow-card: 0 12px 30px -6px rgba(0, 0, 0, 0.5), 0 6px 12px -4px rgba(0, 0, 0, 0.3);
  --radius-lg: 1rem;
  --radius-md: 0.75rem;
  --radius-sm: 0.5rem;
}

[data-theme="light"] {
  --bg-primary: #f4f6fa;
  --bg-surface: #ffffff;
  --bg-surface-alt: #e9eef6;
  --bg-card: rgba(255, 255, 255, 0.96);
  --border-subtle: rgba(0, 0, 0, 0.09);
  --border-focus: rgba(184, 151, 38, 0.7);

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;

  --shadow-card: 0 12px 30px -6px rgba(0, 0, 0, 0.08), 0 6px 12px -4px rgba(0, 0, 0, 0.04);
}

/* Tipografías corporativas */
body {
  margin: 0;
  padding: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  overflow-x: clip;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, h4, h5, h6, .brand-title, .modal-title, .section-title {
  font-family: 'Outfit', sans-serif;
  margin: 0;
  font-weight: 700;
}

button, input, select, textarea {
  font-family: inherit;
}

code, pre, .mono-digits, .checkers-timer, .score-badge {
  font-family: 'JetBrains Mono', monospace;
}

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

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

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

/* Sidebar para AdSense desktop >= 1536px */
.tool-ad-sidebar {
  display: none;
  width: 300px;
  flex-shrink: 0;
  position: sticky;
  top: 1.5rem;
}

@media (min-width: 1536px) {
  .tool-ad-sidebar {
    display: block;
  }
}

/* Cabecera de la herramienta */
.tool-header-block {
  margin-bottom: 1.5rem;
  text-align: center;
}

.tool-title {
  font-size: 2.15rem;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  margin-bottom: 0.4rem;
}

.tool-subtitle {
  font-size: 1.05rem;
  color: var(--text-secondary);
  max-width: 760px;
  margin: 0 auto;
}

/* Cuadrícula de juego */
.game-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

@media (min-width: 1024px) {
  .game-grid {
    grid-template-columns: minmax(0, 1fr) 340px;
  }
}

/* Contenedor del tablero 3D */
.viewport-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
}

.checkers-3d-stage {
  width: 100%;
  height: 520px;
  min-height: 460px;
  position: relative;
  background: radial-gradient(circle at center, #182333 0%, #0b0f17 100%);
  cursor: grab;
  touch-action: none;
}

.checkers-3d-stage:active {
  cursor: grabbing;
}

@media (min-width: 768px) {
  .checkers-3d-stage {
    height: 640px;
  }
}

/* Barra flotante de presets de cámara */
.camera-floating-toolbar {
  position: absolute;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 0.35rem;
  background: rgba(11, 15, 23, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 0.3rem 0.4rem;
  border-radius: 2rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  z-index: 10;
}

.cam-btn {
  background: transparent;
  border: none;
  color: #cbd5e1;
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 1.5rem;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 32px;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.cam-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

/* Barra de evaluación de ventaja */
.eval-bar-wrapper {
  height: 8px;
  background: #1e293b;
  width: 100%;
  position: relative;
  overflow: hidden;
}

.eval-bar-fill {
  height: 100%;
  width: 50%;
  background: linear-gradient(90deg, #d4af37 0%, #ffffff 100%);
  transition: width 0.35s ease;
}

/* Panel de control y HUD */
.controls-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* Tarjetas de jugadores (HUD) */
.hud-players {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.player-card {
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  position: relative;
}

.player-card.active-turn {
  border-color: var(--accent-gold);
  box-shadow: 0 0 12px rgba(212, 175, 55, 0.25);
}

.player-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.player-name {
  font-weight: 700;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.player-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.5);
}

.player-dot.white {
  background: #f5ebd7;
  border: 1px solid #c9bda5;
}

.player-dot.black {
  background: #1e2025;
  border: 1px solid #4a4f58;
}

.score-badge {
  background: rgba(0, 0, 0, 0.3);
  padding: 0.2rem 0.55rem;
  border-radius: 1rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent-gold);
}

.checkers-timer {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary);
  text-align: right;
  letter-spacing: 0.04em;
}

/* Indicador de turno central */
.turn-status-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.turn-pill {
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.35rem 0.85rem;
  border-radius: 1.5rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.turn-pill.white-active {
  background: rgba(245, 235, 215, 0.15);
  color: #f5ebd7;
  border: 1px solid rgba(245, 235, 215, 0.3);
}

.turn-pill.black-active {
  background: rgba(30, 32, 37, 0.35);
  color: #cbd5e1;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.turn-pill.thinking {
  background: rgba(245, 158, 11, 0.18);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.4);
  animation: pulse-thinking 1.2s infinite ease-in-out;
}

.turn-pill.game-over {
  background: rgba(16, 185, 129, 0.18);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

@keyframes pulse-thinking {
  0%, 100% { opacity: 0.8; }
  50% { opacity: 1; filter: brightness(1.2); }
}

/* Grupos de configuración */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: none;
}

/* Selectores canónicos conformes a la regla general */
.custom-select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  height: 42px;
  min-height: 42px;
  background-color: var(--bg-surface-alt);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0 40px 0 0.85rem;
  font-size: 0.92rem;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.custom-select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.18);
}

.custom-select option {
  background-color: #1e293b;
  color: #f8fafc;
}

[data-theme="light"] .custom-select option {
  background-color: #ffffff;
  color: #0f172a;
}

/* Botones de acción */
.actions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

.btn-primary, .btn-secondary, .btn-danger, .btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  height: 42px;
  min-height: 42px;
  padding: 0 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  box-sizing: border-box;
}

.btn-primary {
  background: linear-gradient(135deg, #d4af37 0%, #b89726 100%);
  color: #111827;
}

.btn-primary:hover {
  filter: brightness(1.08);
}

.btn-secondary {
  background: var(--bg-surface-alt);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--border-focus);
}

.btn-secondary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

.btn-block {
  width: 100%;
}

/* Modales canónicos accesibles (sin window.alert) */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(11, 15, 23, 0.78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
  box-sizing: border-box;
}

.modal-overlay.active {
  display: flex;
}

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
  width: 100%;
  max-width: 480px;
  padding: 1.75rem;
  box-sizing: border-box;
  animation: modal-enter 0.25s ease-out;
}

@keyframes modal-enter {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-title {
  font-size: 1.5rem;
  color: var(--text-primary);
  margin-bottom: 0.6rem;
}

.modal-desc {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.55;
  margin-bottom: 1.5rem;
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}

@media (max-width: 480px) {
  .modal-actions {
    flex-direction: column-reverse;
  }
  .modal-actions button {
    width: 100%;
  }
}

/* Bloque educativo SEO y Acordeón canónico */
.seo-section {
  margin-top: 3.5rem;
  border-top: 1px solid var(--border-subtle);
  padding-top: 2.5rem;
}

.seo-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  margin-bottom: 1.75rem;
}

.seo-title {
  font-size: 1.65rem;
  margin-bottom: 1rem;
  color: var(--text-primary);
}

.seo-grid-3 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
  margin-top: 1.25rem;
}

@media (min-width: 768px) {
  .seo-grid-3 {
    grid-template-columns: repeat(3, 1fr);
  }
}

.rule-card {
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.2rem;
}

.rule-title {
  font-size: 1.1rem;
  color: var(--accent-gold);
  margin-bottom: 0.5rem;
}

.rule-desc {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Acordeón FAQ */
.faq-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.faq-item {
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
}

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

.faq-icon {
  transition: transform 0.25s ease;
  flex-shrink: 0;
}

.faq-item.open .faq-icon {
  transform: rotate(180deg);
}

.faq-answer {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, padding 0.3s ease;
  padding: 0 1.25rem;
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.6;
}

.faq-item.open .faq-answer {
  max-height: 300px;
  padding: 0 1.25rem 1.25rem;
}

/* Ubicación de anuncios AdSense canónicos */
.tools-ad-banner-section {
  width: 100%;
  margin: 1.5rem 0;
  text-align: center;
  overflow: hidden;
  box-sizing: border-box;
}

.tools-ad-banner-top {
  margin-bottom: 1.75rem;
}
