/**
 * Estilos para Parchís clásico online
 * 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;
  --border-color: #334155;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --accent-text: #38bdf8;
  --btn-hover-bg: #475569;

  --p-amarillo: #facc15;
  --p-azul: #3b82f6;
  --p-rojo: #ef4444;
  --p-verde: #22c55e;
  --board-bg: #fffdf5;
}

[data-theme="light"] {
  --bg-body: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-secondary: #f1f5f9;
  --bg-input: #ffffff;
  --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%;
}

/* Panel de control */
.parchis-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.75rem;
  flex-wrap: wrap;
}

.game-select {
  background: var(--bg-input, #0f172a);
  color: var(--text-main, #f8fafc);
  border: 1px solid var(--border-color, #334155);
  border-radius: 8px;
  padding: 0.45rem 2rem 0.45rem 0.75rem;
  font-size: 0.875rem;
  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.6rem center;
  background-size: 1rem;
}

.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;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
  display: inline-flex;
  align-items: center;
}

.turn-amarillo { background: #ca8a04; color: #ffffff; }
.turn-azul { background: #1d4ed8; color: #ffffff; }
.turn-rojo { background: #b91c1c; color: #ffffff; }
.turn-verde { background: #15803d; color: #ffffff; }

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

.btn-game-action.btn-primary-action:hover {
  background: #0369a1;
}

/* Área de juego */
.game-arena {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  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%;
  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;
  min-height: 24px;
}

/* Tablero SVG */
.parchis-board-wrapper {
  width: 100%;
  max-width: 620px;
  aspect-ratio: 1 / 1;
  position: relative;
  background: #2a1810;
  border: 10px solid #452616;
  border-radius: 24px;
  box-shadow: inset 0 0 20px rgba(0,0,0,0.6), 0 12px 35px rgba(0,0,0,0.5);
  overflow: hidden;
}

.parchis-svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* Dados y controles interactivos */
.dice-action-area {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.dice-box {
  width: 58px;
  height: 58px;
  background: #ffffff;
  color: #0f172a;
  border-radius: 12px;
  border: 2px solid #cbd5e1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-size: 2rem;
  font-weight: 800;
  box-shadow: 0 6px 14px rgba(0,0,0,0.3);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.dice-box.rolling {
  animation: diceShake 0.45s ease-in-out infinite;
}

@keyframes diceShake {
  0% { transform: rotate(0deg) scale(1); }
  25% { transform: rotate(-15deg) scale(1.1); }
  50% { transform: rotate(15deg) scale(0.95); }
  75% { transform: rotate(-8deg) scale(1.05); }
  100% { transform: rotate(0deg) scale(1); }
}

.btn-roll {
  padding: 0.75rem 1.5rem;
  font-size: 1.05rem;
  font-weight: 700;
  font-family: var(--font-heading);
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  color: #ffffff;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.4);
  transition: all 0.15s ease;
}

.btn-roll:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(2, 132, 199, 0.5);
}

.btn-roll:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Fichas SVG */
.pawn-group {
  cursor: default;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.pawn-group.is-movable {
  cursor: pointer;
}

.pawn-halo {
  fill: #ffffff;
  opacity: 0.4;
  animation: pawnPulse 0.9s infinite alternate ease-in-out;
}

@keyframes pawnPulse {
  0% { transform: scale(1); opacity: 0.3; }
  100% { transform: scale(1.35); opacity: 0.75; }
}

.pawn-amarillo .pawn-body { fill: #eab308; stroke: #854d0e; stroke-width: 1.5; }
.pawn-azul .pawn-body { fill: #3b82f6; stroke: #1e40af; stroke-width: 1.5; }
.pawn-rojo .pawn-body { fill: #ef4444; stroke: #991b1b; stroke-width: 1.5; }
.pawn-verde .pawn-body { fill: #22c55e; stroke: #166534; stroke-width: 1.5; }

.pawn-highlight {
  fill: #ffffff;
  opacity: 0.55;
}

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

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

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

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

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

/* 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);
}

@media (max-width: 640px) {
  .parchis-controls-bar {
    padding: 0.75rem;
  }
  .parchis-board-wrapper {
    border-width: 6px;
  }
  .dice-box {
    width: 48px;
    height: 48px;
    font-size: 1.6rem;
  }
  .btn-roll {
    padding: 0.6rem 1.2rem;
    font-size: 0.95rem;
  }
}
