/* ============================================================
   Peones y Monos — CSS
   Tema oscuro estilo QueBot
   ============================================================ */

/* ── Setup Screen ──────────────────────────────────────────── */

.pm-setup {
  max-width: 400px;
  margin: 0 auto;
  padding: 24px 20px;
  text-align: center;
  font-family: system-ui, -apple-system, sans-serif;
}

.pm-setup-title {
  font-size: 2rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: 4px;
}

.pm-setup-subtitle {
  font-size: 0.85rem;
  color: #888;
  margin-bottom: 24px;
}

.pm-setup-section {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 14px;
  text-align: left;
}

.pm-setup-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: #aaa;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}

/* Modo de juego picker */
.pm-mode-picker {
  display: flex;
  gap: 10px;
}

.pm-mode-option {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
}

.pm-mode-option:hover {
  border-color: rgba(74, 158, 255, 0.4);
  background: rgba(74, 158, 255, 0.06);
}

.pm-mode-option.selected {
  border-color: #4a9eff;
  background: rgba(74, 158, 255, 0.1);
}

.pm-mode-icon {
  font-size: 1.3rem;
}

.pm-mode-label {
  font-size: 0.75rem;
  color: #ccc;
  font-weight: 600;
}

/* Toggle row */
.pm-toggle-row {
  display: flex;
  gap: 8px;
}

.pm-toggle-btn {
  flex: 1;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: #ccc;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  user-select: none;
}

.pm-toggle-btn:hover {
  border-color: rgba(74, 158, 255, 0.4);
}

.pm-toggle-btn.selected {
  border-color: #4a9eff;
  background: rgba(74, 158, 255, 0.1);
  color: #4a9eff;
}

/* Botón jugar */
.pm-play-btn {
  width: 100%;
  padding: 14px;
  margin-top: 8px;
  background: linear-gradient(135deg, #4a9eff, #0f3460);
  border: none;
  border-radius: 12px;
  color: #fff;
  font-size: 1.15rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.pm-play-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(74, 158, 255, 0.35);
}

.pm-play-btn:active {
  transform: translateY(0);
}

/* ── Game Wrapper ──────────────────────────────────────────── */

.pm-game {
  max-width: 420px;
  margin: 0 auto;
  padding: 12px;
  font-family: system-ui, -apple-system, sans-serif;
}

/* ── Board Container ───────────────────────────────────────── */

.pm-board-container {
  position: relative;
}

/* Column labels */
.pm-col-labels {
  display: flex;
  padding-left: 22px; /* alinear con el tablero (ancho de row labels) */
}

.pm-col-label {
  flex: 1;
  text-align: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: #666;
  padding: 2px 0;
  user-select: none;
}

/* Board row: row-labels + board side by side */
.pm-board-row {
  display: flex;
}

/* Row labels */
.pm-row-labels {
  display: flex;
  flex-direction: column;
  width: 22px;
  flex-shrink: 0;
}

.pm-row-label {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: #666;
  user-select: none;
}

/* ── Board Grid ────────────────────────────────────────────── */

.pm-board {
  display: grid;
  flex: 1;
  aspect-ratio: 1;
  border-radius: 6px;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

/* ── Cells ─────────────────────────────────────────────────── */

.pm-cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
  user-select: none;
}

.pm-cell.light {
  background: #2a2d3e;
}

.pm-cell.dark {
  background: #1a1c2e;
}

/* Pieza seleccionada */
.pm-cell.selected {
  box-shadow: inset 0 0 0 3px #ffd700;
  z-index: 2;
  background: rgba(255, 215, 0, 0.15);
}

/* Movimiento legal */
.pm-cell.legal-move {
  cursor: pointer;
}

.pm-cell.legal-move::after {
  content: '';
  position: absolute;
  width: 28%;
  height: 28%;
  border-radius: 50%;
  background: rgba(76, 175, 80, 0.55);
  pointer-events: none;
}

/* Movimiento de captura */
.pm-cell.capture-move {
  cursor: pointer;
}

.pm-cell.capture-move::after {
  content: '';
  position: absolute;
  width: 80%;
  height: 80%;
  border-radius: 50%;
  border: 3px solid rgba(255, 74, 74, 0.65);
  background: rgba(255, 74, 74, 0.1);
  pointer-events: none;
  box-sizing: border-box;
}

/* Debug moves */
.pm-cell.debug-move::before {
  content: '';
  position: absolute;
  width: 20%;
  height: 20%;
  border-radius: 50%;
  background: rgba(74, 158, 255, 0.45);
  pointer-events: none;
  z-index: 1;
}

/* Last move highlight */
.pm-cell.last-move {
  background: rgba(74, 158, 255, 0.12) !important;
}

/* Flash de captura */
.pm-cell.pm-capture-flash {
  animation: pm-flash-red 0.4s ease-out;
}

@keyframes pm-flash-red {
  0% { background: rgba(255, 74, 74, 0.5); }
  100% { background: inherit; }
}

/* ── Piezas ────────────────────────────────────────────────── */

.pm-piece {
  font-size: clamp(20px, 8vw, 36px);
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
}

/* Dots para movimientos */
.pm-dot {
  width: 28%;
  height: 28%;
  border-radius: 50%;
  background: rgba(76, 175, 80, 0.55);
  pointer-events: none;
}

.pm-dot-capture {
  width: 80%;
  height: 80%;
  border: 3px solid rgba(255, 74, 74, 0.65);
  background: rgba(255, 74, 74, 0.1);
  box-sizing: border-box;
}

.pm-dot-debug {
  width: 20%;
  height: 20%;
  background: rgba(74, 158, 255, 0.45);
}

/* ── Info Panel ────────────────────────────────────────────── */

.pm-info {
  padding: 10px 12px;
  margin-top: 10px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  align-items: center;
  font-size: 0.82rem;
  color: #ccc;
}

.pm-info-turn {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  color: #e0e0e0;
}

.pm-turn-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.pm-turn-a {
  background: #e0e0e0;
  box-shadow: 0 0 6px rgba(224, 224, 224, 0.5);
}

.pm-turn-b {
  background: #444;
  box-shadow: 0 0 6px rgba(68, 68, 68, 0.5);
  border: 1px solid #666;
}

.pm-info-captures {
  font-size: 0.78rem;
  color: #999;
}

.pm-info-move-count {
  font-size: 0.75rem;
  color: #777;
  margin-left: auto;
}

/* ── Status ────────────────────────────────────────────────── */

.pm-status {
  text-align: center;
  padding: 8px 12px;
  margin-top: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  color: #ccc;
  border-radius: 8px;
  min-height: 1.6em;
}

.pm-status-win {
  color: #4aff88;
  background: rgba(74, 255, 136, 0.08);
  font-size: 1rem;
}

.pm-status-thinking {
  color: #ffaa4a;
}

/* Animación de puntos pensando */
.pm-thinking {
  display: inline-flex;
  align-items: baseline;
  gap: 0;
}

.pm-dots span {
  animation: pm-dot-bounce 1.4s infinite;
  display: inline-block;
}

.pm-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.pm-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes pm-dot-bounce {
  0%, 80%, 100% { opacity: 0.2; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-3px); }
}

/* ── Controls ──────────────────────────────────────────────── */

.pm-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  justify-content: center;
}

.pm-btn {
  padding: 7px 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  color: #ccc;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  user-select: none;
}

.pm-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(74, 158, 255, 0.4);
  color: #fff;
}

.pm-btn:active {
  transform: scale(0.97);
}

.pm-btn-active {
  background: rgba(74, 158, 255, 0.15) !important;
  border-color: #4a9eff !important;
  color: #4a9eff !important;
}

/* ── History Panel ─────────────────────────────────────────── */

.pm-history {
  margin-top: 10px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 10px;
  padding: 10px 14px;
  max-height: 200px;
  overflow: hidden;
}

.pm-history-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: #aaa;
  margin-bottom: 8px;
}

.pm-history-list {
  max-height: 160px;
  overflow-y: auto;
  font-size: 0.78rem;
  color: #bbb;
  font-family: 'SF Mono', 'Consolas', monospace;
  line-height: 1.6;
}

.pm-history-entry {
  padding: 1px 0;
}

.pm-history-empty {
  font-size: 0.8rem;
  color: #666;
  text-align: center;
  padding: 8px;
}

/* Scrollbar estilizada */
.pm-history-list::-webkit-scrollbar {
  width: 5px;
}

.pm-history-list::-webkit-scrollbar-track {
  background: transparent;
}

.pm-history-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}

/* ── Toast ─────────────────────────────────────────────────── */

.pm-toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: rgba(30, 30, 50, 0.95);
  color: #fff;
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 600;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.1);
  z-index: 1000;
  pointer-events: none;
  opacity: 0;
  transition: all 0.3s ease;
  max-width: 90vw;
  text-align: center;
}

.pm-toast-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Responsive ────────────────────────────────────────────── */

@media (max-width: 480px) {
  .pm-game {
    padding: 8px;
    max-width: 100%;
  }

  .pm-info {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .pm-info-move-count {
    margin-left: 0;
  }

  .pm-controls {
    gap: 6px;
  }

  .pm-btn {
    padding: 6px 10px;
    font-size: 0.75rem;
  }

  .pm-col-labels {
    padding-left: 18px;
  }

  .pm-row-labels {
    width: 18px;
  }

  .pm-col-label,
  .pm-row-label {
    font-size: 0.6rem;
  }
}

@media (min-width: 769px) {
  .pm-game {
    max-width: 440px;
  }

  .pm-piece {
    font-size: 38px !important;
  }
}
