/**
 * Estilos visuales de Stratego 3D contra la máquina
 * Diseño táctico premium militar-elegante con tema oscuro y soporte responsivo completo
 */

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

  /* Paleta cromática militar noble */
  --bg-primary: #0a0f18;
  --bg-card: #111827;
  --bg-card-subtle: #1a2234;
  --border-color: #243048;
  --border-gold: #c5a363;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --accent-gold: #d4af37;
  --accent-gold-hover: #f59e0b;
  --accent-blue: #3b82f6;
  --accent-red: #ef4444;
  --accent-green: #22c55e;
}

[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-subtle: #f1f5f9;
  --border-color: #cbd5e1;
  --border-gold: #b48c36;
  --text-main: #0f172a;
  --text-muted: #475569;
  --accent-gold: #b48c36;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

h1, h2, h3, h4, h5, h6,
.brand-title,
.section-title,
.hero-title,
.faq-section-title {
  font-family: var(--font-heading);
}

.mono, code {
  font-family: var(--font-mono);
}

/* Layout principal de herramienta */
.tool-layout {
  width: 100%;
  max-width: 1240px;
  margin: 1rem auto 3rem;
  padding: 0 1rem;
  flex: 1;
}

.stratego-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 1024px) {
  .stratego-grid {
    grid-template-columns: 1fr;
  }
}

/* Contenedor del visor 3D */
.viewport-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
}

.viewport-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.25rem;
  background: rgba(10, 15, 24, 0.65);
  border-bottom: 1px solid var(--border-color);
  backdrop-filter: blur(8px);
  gap: 0.75rem;
  flex-wrap: wrap;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.85rem;
  border-radius: 9999px;
  font-size: 0.85rem;
  font-weight: 600;
  min-height: 36px;
}

.badge-setup {
  background: rgba(212, 175, 55, 0.15);
  color: #ffd700;
  border: 1px solid rgba(212, 175, 55, 0.4);
}

.badge-player {
  background: rgba(59, 130, 246, 0.18);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.4);
}

.badge-ai {
  background: rgba(239, 68, 68, 0.18);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.viewport-controls-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-ctrl {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.45rem 0.75rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  min-height: 40px;
  transition: all 0.2s ease;
}

.btn-ctrl:hover {
  background: var(--border-color);
  border-color: var(--accent-gold);
}

.btn-ctrl.active {
  background: rgba(212, 175, 55, 0.2);
  border-color: var(--accent-gold);
  color: #ffd700;
}

/* Lienzo 3D */
#stratego-viewport-3d {
  width: 100%;
  height: 600px;
  position: relative;
  background: #0a0f18;
  cursor: grab;
  touch-action: none;
}

#stratego-viewport-3d:active {
  cursor: grabbing;
}

@media (max-width: 768px) {
  #stratego-viewport-3d {
    height: 440px;
  }
}

@media (max-width: 480px) {
  #stratego-viewport-3d {
    height: 380px;
  }
}

/* Barra inferior del viewport (fases) */
.viewport-footer {
  padding: 0.85rem 1.25rem;
  background: var(--bg-card);
  border-top: 1px solid var(--border-color);
}

.phase-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.preset-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.preset-group-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 500;
}

.btn-preset-formation {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.4rem 0.75rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  min-height: 38px;
  transition: all 0.15s ease;
}

.btn-preset-formation:hover {
  border-color: var(--accent-gold);
}

.btn-preset-formation.active {
  background: rgba(212, 175, 55, 0.25);
  border-color: var(--accent-gold);
  color: #ffd700;
  font-weight: 600;
}

.btn-action-primary {
  background: linear-gradient(135deg, #d4af37, #b48c36);
  color: #0b0f17;
  border: none;
  border-radius: 8px;
  padding: 0.6rem 1.4rem;
  font-size: 0.95rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  min-height: 42px;
  box-shadow: 0 4px 14px rgba(212, 175, 55, 0.35);
  transition: all 0.2s ease;
}

.btn-action-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(212, 175, 55, 0.5);
}

/* Panel lateral de mando táctico */
.side-panel {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.panel-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.15rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.panel-card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent-gold);
  margin-bottom: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.5rem;
  text-transform: none;
}

.form-group {
  margin-bottom: 0.85rem;
}

.form-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

/* Estilo canónico de selectores desplegables */
.custom-select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  height: 42px;
  padding: 0 40px 0 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background-color: var(--bg-card-subtle);
  color: var(--text-main);
  font-family: var(--font-main);
  font-size: 0.88rem;
  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;
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.custom-select:focus {
  outline: none;
  border-color: var(--accent-gold);
}

.custom-select option {
  background-color: var(--bg-card);
  color: var(--text-main);
}

/* Cementerio de bajas */
.graveyard-section {
  margin-bottom: 0.85rem;
}

.graveyard-label {
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  display: flex;
  justify-content: space-between;
}

.graveyard-chips-box {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  min-height: 38px;
  padding: 0.4rem;
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: 8px;
}

.graveyard-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 4px;
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 0.78rem;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.chip-player {
  background: linear-gradient(135deg, #1c3d70, #0e2344);
  color: #ffd700;
  border: 1px solid #3b82f6;
}

.chip-ai {
  background: linear-gradient(135deg, #7a1924, #3b070c);
  color: #ffffff;
  border: 1px solid #ef4444;
}

.empty-muted {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
  display: flex;
  align-items: center;
  padding: 0.2rem 0.5rem;
}

/* Historial de movimientos */
.history-scroll-box {
  max-height: 190px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding-right: 0.3rem;
}

.history-item {
  display: flex;
  align-items: flex-start;
  gap: 0.45rem;
  font-size: 0.8rem;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  background: var(--bg-card-subtle);
  border-left: 3px solid transparent;
}

.item-player {
  border-left-color: var(--accent-blue);
}

.item-ai {
  border-left-color: var(--accent-red);
}

.history-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
}

.item-player .history-dot {
  background: var(--accent-blue);
}

.item-ai .history-dot {
  background: var(--accent-red);
}

.history-text {
  flex: 1;
  line-height: 1.35;
}

/* Modales canónicos accesibles (sin window.alert) */
.stratego-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(4, 7, 12, 0.85);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  padding: 1rem;
}

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

.modal-dialog {
  background: var(--bg-card);
  border: 1px solid var(--border-gold);
  border-radius: 16px;
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 2rem;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.7);
  animation: modalEnter 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.modal-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--accent-gold);
  margin-bottom: 0.65rem;
  text-align: center;
}

.modal-body-text {
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--text-main);
  margin-bottom: 1.5rem;
  text-align: center;
}

.modal-stats-grid {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.stat-pill {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  padding: 0.4rem 0.85rem;
  border-radius: 8px;
  font-size: 0.85rem;
}

.modal-actions {
  display: flex;
  justify-content: center;
  gap: 1rem;
}

.btn-secondary {
  background: var(--bg-card-subtle);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.6rem 1.25rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 42px;
}

/* Tabla de rangos en modal de reglas */
.ranks-rules-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin-top: 1rem;
  margin-bottom: 1.5rem;
}

.ranks-rules-table th,
.ranks-rules-table td {
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border-color);
  text-align: left;
}

.ranks-rules-table th {
  background: var(--bg-card-subtle);
  color: var(--accent-gold);
  font-weight: 700;
}

/* Sección SEO y acordeones */
.tool-seo-section {
  margin-top: 3.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 2.5rem 2rem;
}

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

.seo-grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2.5rem;
}

.seo-card {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.5rem;
}

.seo-card-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--accent-gold);
  margin-bottom: 0.75rem;
}

.seo-card-text {
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--text-muted);
}
