/* =========================================================
   RatoLibre — Damas chinas (estilos propios del juego)
   ========================================================= */

/* ---------- Barra de herramientas ---------- */

.dc-opcion {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  flex: 1 1 auto;
  font-weight: 700;
}

.dc-opcion select {
  flex: 1 1 auto;
  min-height: 48px;
  min-width: 150px;
  padding: 0 40px 0 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface) url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20'%3E%3Cpath fill='none' stroke='%231f2a37' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round' d='M4 7l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center;
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

.dc-opcion select:hover {
  border-color: var(--accent);
}

@media (min-width: 720px) {
  .dc-opcion {
    flex: 0 1 auto;
  }
}

/* ---------- Zona de juego ---------- */

.dc-area {
  padding: 12px 8px;
}

.dc-cuerpo {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dc-principal,
.dc-lateral {
  min-width: 0;
}

@media (min-width: 980px) {
  .dc-area {
    padding: 16px;
  }

  .dc-cuerpo {
    flex-direction: row;
    align-items: flex-start;
    gap: 24px;
  }

  .dc-principal {
    flex: 0 0 600px;
  }

  .dc-lateral {
    flex: 1 1 auto;
    padding-top: 4px;
  }
}

.dc-mensaje {
  min-height: 3em;
  margin: 0 0 10px;
  padding: 8px 12px;
  border-left: 4px solid var(--accent);
  background: var(--bg);
  border-radius: 0 8px 8px 0;
  font-weight: 600;
}

.dc-mensaje.es-pensando {
  border-left-color: var(--accent-2);
}

/* ---------- Marco y tablero ---------- */

.dc-marco {
  position: relative;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  padding: 0;
  border-radius: 14px;
  background: #6b4527;
  box-shadow: var(--shadow);
  scrollbar-width: thin;
  scrollbar-color: #e3c38f #6b4527;
}

.dc-marco.es-desliza {
  /* Sombras en los bordes: avisan que el tablero sigue a los lados. */
  background:
    linear-gradient(90deg, #4a2f1a, rgba(74, 47, 26, 0)) left center / 18px 100% no-repeat,
    linear-gradient(270deg, #4a2f1a, rgba(74, 47, 26, 0)) right center / 18px 100% no-repeat,
    #6b4527;
}

.dc-tablero {
  position: relative;
  margin: 0 auto;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.dc-fondo {
  position: absolute;
  inset: 0;
  display: block;
  max-width: none;
  pointer-events: none;
}

.dc-desliza {
  margin: 8px 0 0;
  font-size: 0.85rem;
  color: var(--muted);
  text-align: center;
}

.dc-desliza[hidden] {
  display: none;
}

/* ---------- Hoyos ---------- */

.dc-hoyo {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--hoyo, 33px);
  height: var(--hoyo, 33px);
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 38%, #8a6236 0%, #a67c4b 55%, #c49a63 100%);
  box-shadow: inset 0 3px 4px rgba(0, 0, 0, 0.4);
  font: inherit;
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.dc-hoyo:focus-visible {
  outline: 4px solid #1f2a37;
  outline-offset: 2px;
  z-index: 3;
}

/* Hoyos de tu meta (la punta de enfrente) */
.dc-hoyo.es-tu-meta {
  outline: 2px dashed #b3261e;
  outline-offset: 2px;
}

.dc-hoyo.es-tu-meta:focus-visible {
  outline: 4px solid #1f2a37;
}

/* Hoyos a los que puede llegar la canica elegida */
.dc-hoyo.es-meta {
  background: #6e4a26;
  z-index: 1;
}

.dc-hoyo.es-meta::before {
  content: "";
  position: absolute;
  width: 46%;
  height: 46%;
  border-radius: 50%;
  background: #ffd54a;
  border: 3px solid #1f2a37;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.75);
  pointer-events: none;
  animation: dc-latir 1.1s ease-in-out infinite;
}

/* Pista */
.dc-hoyo.es-pista {
  background: #2f6f4e;
  box-shadow: 0 0 0 4px #2f6f4e, inset 0 3px 4px rgba(0, 0, 0, 0.4);
}

/* Última jugada de cada computadora: salida punteada y llegada con aro */
.dc-hoyo.es-salida::after,
.dc-hoyo.es-llegada::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  pointer-events: none;
}

.dc-hoyo.es-salida::after {
  border: 3px dashed #1f2a37;
}

.dc-hoyo.es-llegada::after {
  border: 3px solid #1f2a37;
  box-shadow: 0 0 0 2px #fff7e0;
}

/* ---------- Canicas ---------- */

.dc-canica {
  position: relative;
  display: block;
  width: 88%;
  height: 88%;
  border-radius: 50%;
  border: 2px solid rgba(0, 0, 0, 0.55);
  box-shadow: 0 2px 2px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  transition: transform 0.15s ease;
}

/* Figura de cada color, para distinguirlas sin depender del color */
.dc-canica::after {
  content: "";
  position: absolute;
  inset: 24%;
  background: #ffffff;
}

/* Tú: rojas con estrella blanca */
.dc-c0 {
  background: radial-gradient(circle at 35% 30%, #ff9b8c 0%, #d93a2b 45%, #8e1d12 100%);
  border-color: #6b130b;
}

.dc-c0::after {
  inset: 16%;
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}

/* Moradas con rombo */
.dc-c1 {
  background: radial-gradient(circle at 35% 30%, #cfa8ee 0%, #7a3fa6 48%, #46205f 100%);
  border-color: #351748;
}

.dc-c1::after {
  inset: 20%;
  clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
}

/* Verdes con triángulo */
.dc-c2 {
  background: radial-gradient(circle at 35% 30%, #9be09e 0%, #2e7d32 48%, #164a19 100%);
  border-color: #103812;
}

.dc-c2::after {
  inset: 20%;
  clip-path: polygon(50% 6%, 100% 92%, 0% 92%);
}

/* Azules con círculo */
.dc-c3 {
  background: radial-gradient(circle at 35% 30%, #a9c8ff 0%, #1d5fc0 48%, #0d3270 100%);
  border-color: #0a2654;
}

.dc-c3::after {
  inset: 27%;
  border-radius: 50%;
}

/* Amarillas con cuadrado oscuro y borde grueso */
.dc-c4 {
  background: radial-gradient(circle at 35% 30%, #fff6c4 0%, #f2c11d 50%, #b98a00 100%);
  border: 3px solid #5c4300;
}

.dc-c4::after {
  inset: 29%;
  background: #3b2b00;
}

/* Blancas con cruz oscura y borde grueso */
.dc-c5 {
  background: radial-gradient(circle at 35% 30%, #ffffff 0%, #f6f2ea 50%, #c9c1b2 100%);
  border: 3px solid #1f2a37;
}

.dc-c5::after {
  inset: 22%;
  background: #1f2a37;
  clip-path: polygon(38% 0%, 62% 0%, 62% 38%, 100% 38%, 100% 62%, 62% 62%, 62% 100%, 38% 100%, 38% 62%, 0% 62%, 0% 38%, 38% 38%);
}

/* Canica elegida */
.dc-hoyo.es-elegida .dc-canica {
  outline: 4px solid #ffd54a;
  outline-offset: 1px;
  box-shadow: 0 0 0 7px #1f2a37;
  transform: scale(1.08);
}

/* Canica que va saltando */
.dc-vuelo {
  position: absolute;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--hoyo, 33px);
  height: var(--hoyo, 33px);
  pointer-events: none;
  transition-property: left, top;
  transition-timing-function: ease-in-out;
}

.dc-vuelo .dc-canica {
  transform: scale(1.12);
  box-shadow: 0 6px 8px rgba(0, 0, 0, 0.45);
}

/* ---------- Panel lateral ---------- */

.dc-acciones {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.dc-acciones .btn {
  flex: 1 1 140px;
}

.dc-jugadores {
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.dc-jugador {
  display: grid;
  grid-template-columns: 36px 1fr;
  grid-template-rows: auto auto;
  column-gap: 10px;
  align-items: center;
  padding: 8px 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}

.dc-jugador.es-turno {
  border-color: var(--accent-2);
  background: var(--accent-2-soft);
}

.dc-muestra {
  grid-row: 1 / span 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
}

.dc-muestra .dc-canica {
  width: 34px;
  height: 34px;
}

.dc-nombre {
  font-weight: 700;
}

.dc-turno {
  font-weight: 600;
  color: var(--accent-2);
}

.dc-cuenta {
  font-size: 0.85rem;
  color: var(--muted);
}

.dc-cuenta strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* ---------- Resultados ---------- */

.dc-estado {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 28px;
  margin: 16px 0;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.dc-estado .dato {
  display: flex;
  flex-direction: column;
  min-width: 6ch;
}

.dc-estado .etiqueta {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}

.dc-estado strong {
  font-size: 1.2rem;
  font-variant-numeric: tabular-nums;
}

/* ---------- Paneles (final y confirmación) ---------- */

.dc-panel {
  margin: 0 0 16px;
  padding: 20px 16px;
  border: 2px solid var(--accent-2);
  border-radius: var(--radius);
  background: var(--accent-2-soft);
  text-align: center;
  animation: dc-entrar 0.35s ease-out;
}

.dc-panel[hidden] {
  display: none;
}

.dc-panel:focus {
  outline: none;
}

.dc-panel .titulo {
  margin: 0 0 0.4rem;
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1.2;
  color: var(--accent-2);
}

.dc-panel.es-derrota,
.dc-confirmar {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.dc-panel.es-derrota .titulo,
.dc-confirmar .titulo {
  color: var(--accent-dark);
}

.dc-panel p {
  margin: 0 0 0.6rem;
}

.dc-panel .botones {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 12px;
}

.dc-panel .botones .btn {
  flex: 1 1 200px;
  max-width: 320px;
}

/* ---------- Animaciones ---------- */

@keyframes dc-entrar {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}

@keyframes dc-latir {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(0.85); }
}

@media (prefers-reduced-motion: reduce) {
  .dc-panel,
  .dc-hoyo.es-meta::before {
    animation: none;
  }

  .dc-canica,
  .dc-vuelo {
    transition: none;
  }
}
