/**
 * Estilos para Cuatro en raya
 * Estándar canónico Fijate Tools
 */

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

  --bg-body: #0f172a;
  --bg-card: #1e293b;
  --bg-card-secondary: #334155;
  --bg-input: #0f172a;
  --bg-pill: rgba(15, 23, 42, 0.6);
  --border-color: #334155;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --accent-text: #38bdf8;
  --btn-hover-bg: #475569;

  --c4-board-blue: #2563eb;
  --c4-board-border: #1d4ed8;
  --c4-red: #ef4444;
  --c4-red-border: #b91c1c;
  --c4-yellow: #facc15;
  --c4-yellow-border: #ca8a04;
}

[data-theme="light"] {
  --bg-body: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-secondary: #f1f5f9;
  --bg-input: #ffffff;
  --bg-pill: #f1f5f9;
  --border-color: #cbd5e1;
  --text-main: #0f172a;
  --text-muted: #475569;
  --accent-text: #0284c7;
  --btn-hover-bg: #e2e8f0;
}

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

.tool-layout {
  max-width: 1200px;
  margin: 1.5rem auto 3rem;
  padding: 0 1rem;
  box-sizing: border-box;
  flex: 1 0 auto;
}

.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%;
}

/* Barra de mandos superior */
.c4-controls-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: var(--bg-card, #1e293b);
  border: 1px solid var(--border-color, #334155);
  border-radius: 14px;
  padding: 0.85rem 1.25rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
}

.controls-group {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.controls-group label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted, #94a3b8);
}

.game-select {
  background: var(--bg-input, #0f172a);
  color: var(--text-main, #f8fafc);
  border: 1px solid var(--border-color, #334155);
  border-radius: 8px;
  padding: 0.4rem 1.8rem 0.4rem 0.65rem;
  font-size: 0.85rem;
  font-family: var(--font-main);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' 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 0.5rem center;
  background-size: 0.9rem;
}

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

.turn-badge {
  padding: 0.45rem 1rem;
  border-radius: 20px;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.95rem;
  display: inline-flex;
  align-items: center;
}

.turn-rojo { background: #b91c1c; color: #ffffff; }
.turn-amarillo { background: #ca8a04; color: #ffffff; }

.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--bg-pill);
  padding: 0.35rem 0.75rem;
  border-radius: 20px;
  border: 1px solid var(--border-color);
  font-size: 0.85rem;
}

.stat-label {
  color: var(--text-muted);
}

.stat-value {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--accent-text);
}

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

.btn-game-action:hover {
  background: var(--btn-hover-bg);
}

.btn-game-action.btn-primary-action {
  background: #0284c7;
  border-color: #0369a1;
  color: #ffffff;
}

/* Área de juego */
.c4-arena-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 1.5rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

.status-bar {
  width: 100%;
  max-width: 540px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 0.65rem 1rem;
  text-align: center;
  font-size: 0.95rem;
  color: var(--accent-text);
  font-weight: 500;
  margin-bottom: 1rem;
}

/* Fila de indicadores superiores */
.hover-indicators-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  width: 100%;
  max-width: 520px;
  height: 48px;
  margin-bottom: 0.5rem;
  gap: 6px;
}

.hover-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  cursor: pointer;
}

.hover-slot.active.preview-rojo::after {
  content: '';
  width: 38px;
  height: 38px;
  background: var(--c4-red);
  border: 2px solid var(--c4-red-border);
  border-radius: 50%;
  opacity: 0.7;
  animation: bounceMini 0.8s infinite alternate ease-in-out;
}

.hover-slot.active.preview-amarillo::after {
  content: '';
  width: 38px;
  height: 38px;
  background: var(--c4-yellow);
  border: 2px solid var(--c4-yellow-border);
  border-radius: 50%;
  opacity: 0.7;
  animation: bounceMini 0.8s infinite alternate ease-in-out;
}

@keyframes bounceMini {
  from { transform: translateY(0); }
  to { transform: translateY(-4px); }
}

/* Tablero vertical */
.c4-board {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  width: 100%;
  max-width: 520px;
  background: linear-gradient(180deg, #2563eb 0%, #1d4ed8 100%);
  border: 8px solid #1e40af;
  border-radius: 20px;
  padding: 0.75rem;
  gap: 6px;
  box-shadow: inset 0 4px 10px rgba(255,255,255,0.2), 0 16px 36px rgba(0,0,0,0.5);
  box-sizing: border-box;
}

.c4-column {
  display: flex;
  flex-direction: column;
  gap: 6px;
  cursor: pointer;
}

.c4-cell {
  position: relative;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.c4-hole {
  width: 100%;
  height: 100%;
  background: #0f172a;
  border-radius: 50%;
  box-shadow: inset 0 5px 8px rgba(0,0,0,0.6);
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Fichas */
.c4-chip {
  width: 90%;
  height: 90%;
  border-radius: 50%;
  box-shadow: inset 0 -3px 6px rgba(0,0,0,0.3), inset 0 3px 6px rgba(255,255,255,0.4), 0 2px 4px rgba(0,0,0,0.4);
}

.c4-chip.chip-rojo {
  background: radial-gradient(circle at 35% 35%, #f87171 0%, #dc2626 70%, #991b1b 100%);
  border: 2px solid #b91c1c;
}

.c4-chip.chip-amarillo {
  background: radial-gradient(circle at 35% 35%, #fef08a 0%, #eab308 70%, #a16207 100%);
  border: 2px solid #ca8a04;
}

/* Animaciones de caída */
.dropping-row-0 { animation: dropAnim0 0.25s cubic-bezier(0.5, 0, 0.75, 1); }
.dropping-row-1 { animation: dropAnim1 0.3s cubic-bezier(0.5, 0, 0.75, 1); }
.dropping-row-2 { animation: dropAnim2 0.35s cubic-bezier(0.5, 0, 0.75, 1); }
.dropping-row-3 { animation: dropAnim3 0.4s cubic-bezier(0.5, 0, 0.75, 1); }
.dropping-row-4 { animation: dropAnim4 0.45s cubic-bezier(0.5, 0, 0.75, 1); }
.dropping-row-5 { animation: dropAnim5 0.5s cubic-bezier(0.5, 0, 0.75, 1); }

@keyframes dropAnim0 { from { transform: translateY(-70px); } to { transform: translateY(0); } }
@keyframes dropAnim1 { from { transform: translateY(-140px); } to { transform: translateY(0); } }
@keyframes dropAnim2 { from { transform: translateY(-210px); } to { transform: translateY(0); } }
@keyframes dropAnim3 { from { transform: translateY(-280px); } to { transform: translateY(0); } }
@keyframes dropAnim4 { from { transform: translateY(-350px); } to { transform: translateY(0); } }
@keyframes dropAnim5 { from { transform: translateY(-420px); } to { transform: translateY(0); } }

.c4-chip.is-winning {
  animation: winPulse 0.8s infinite alternate ease-in-out;
  box-shadow: 0 0 16px #ffffff, 0 0 24px #38bdf8;
}

@keyframes winPulse {
  0% { transform: scale(0.92); filter: brightness(1); }
  100% { transform: scale(1.05); filter: brightness(1.3); }
}

/* Modal de victoria */
.victory-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(4px);
}

.victory-modal-backdrop[hidden] {
  display: none;
}

.victory-card {
  background: var(--bg-card);
  border: 2px solid var(--accent-text);
  border-radius: 16px;
  padding: 2.5rem;
  max-width: 400px;
  width: 90%;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}

.victory-title {
  font-family: var(--font-heading);
  font-size: 2rem;
  margin: 0 0 0.5rem;
  color: var(--accent-text);
}

/* Guía de estrategia */
.game-guide-section {
  background: var(--bg-card, #1e293b);
  border: 1px solid var(--border-color, #334155);
  border-radius: 14px;
  padding: 1.75rem;
  margin-top: 2rem;
}

.game-guide-section h2 {
  font-family: var(--font-heading);
  font-size: 1.35rem;
  margin-top: 0;
  margin-bottom: 1rem;
}

.guide-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.5rem;
}

.guide-item h3 {
  font-size: 1.05rem;
  margin-top: 0;
  margin-bottom: 0.4rem;
  color: #38bdf8;
}

.guide-item p {
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text-muted, #94a3b8);
  margin: 0;
}
