/* =========================================================
   RatoLibre — Serpientes y escaleras (estilos propios)
   ========================================================= */

/* ---------- Barra de opciones ---------- */

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

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

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

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

/* ---------- Distribución ---------- */

.serp-cuerpo {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}

@media (min-width: 900px) {
  .serp-cuerpo {
    grid-template-columns: minmax(0, 600px) minmax(260px, 1fr);
    align-items: start;
  }
}

/* En el celular el tablero ocupa todo el ancho de la pantalla:
   así cada casilla mide más de 34 px. */
@media (max-width: 479px) {
  .serp-area {
    max-width: none;
    margin-left: -16px;
    margin-right: -16px;
    padding: 12px 0 16px;
    border-left: 0;
    border-right: 0;
    border-radius: 0;
  }

  .serp-lateral,
  .serp-panel {
    margin-left: 16px;
    margin-right: 16px;
  }

  .serp-tablero {
    border-left-width: 0;
    border-right-width: 0;
    border-radius: 0;
  }
}

/* ---------- Tablero ---------- */

.serp-tablero {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  grid-template-rows: repeat(10, minmax(0, 1fr));
  width: 100%;
  max-width: 600px;
  aspect-ratio: 1 / 1;
  margin: 0 auto;
  border: 3px solid var(--text);
  border-radius: 10px;
  overflow: hidden;
  background: #fdf3dc;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.serp-casilla {
  min-width: 0;
  min-height: 0;
  padding: 2px 0 0 2px;
  line-height: 1;
}

.serp-casilla.es-clara {
  background: #fdf3dc;
}

.serp-casilla.es-oscura {
  background: #dfeaf6;
}

.serp-casilla.es-salida {
  background: #d9efd8;
}

.serp-casilla.es-meta {
  background: #fde39a;
}

/* El número va encima de los dibujos, con un fondo claro para que se lea. */
.serp-num {
  position: relative;
  z-index: 2;
  display: inline-block;
  padding: 1px 3px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--text);
  font-size: 16px;
  font-weight: 800;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

@media (min-width: 480px) {
  .serp-num {
    font-size: 17px;
  }
}

@media (min-width: 720px) {
  .serp-num {
    font-size: 18px;
  }
}

.serp-dibujos {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* ---------- Fichas ---------- */

.serp-ficha {
  position: absolute;
  z-index: 3;
  transition-property: left, top, width, height;
  transition-duration: 240ms;
  transition-timing-function: linear;
  pointer-events: none;
  filter: drop-shadow(0 1px 1.5px rgba(17, 24, 39, 0.55));
}

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

.serp-ficha.es-activa {
  z-index: 4;
}

.serp-ficha.es-libre {
  z-index: 5;
}

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

.serp-lateral {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.serp-turno {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0;
  padding: 8px 14px;
  border: 3px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  font-size: 1.2rem;
  font-weight: 800;
}

.serp-turno-ficha {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
}

.serp-turno-ficha svg {
  display: block;
  width: 100%;
  height: 100%;
}

.serp-tiro {
  display: flex;
  align-items: center;
  gap: 14px;
}

.serp-dado {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  place-items: center;
  width: 72px;
  height: 72px;
  padding: 10px;
  border: 4px solid var(--text);
  border-radius: 16px;
  background: #ffffff;
  box-shadow: var(--shadow);
  transition: transform 0.07s linear;
}

.serp-dado.vacio {
  border-style: dashed;
  background: var(--bg);
}

.serp-dado.rodando {
  animation: serp-rodar 0.28s linear infinite;
}

@keyframes serp-rodar {
  0% { transform: rotate(0deg) translateY(0); }
  25% { transform: rotate(-12deg) translateY(-4px); }
  50% { transform: rotate(0deg) translateY(0); }
  75% { transform: rotate(12deg) translateY(-4px); }
  100% { transform: rotate(0deg) translateY(0); }
}

.serp-punto {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--text);
}

.serp-punto.p0 { grid-area: 1 / 1; }
.serp-punto.p1 { grid-area: 1 / 2; }
.serp-punto.p2 { grid-area: 1 / 3; }
.serp-punto.p3 { grid-area: 2 / 1; }
.serp-punto.p4 { grid-area: 2 / 2; }
.serp-punto.p5 { grid-area: 2 / 3; }
.serp-punto.p6 { grid-area: 3 / 1; }
.serp-punto.p7 { grid-area: 3 / 2; }
.serp-punto.p8 { grid-area: 3 / 3; }

.serp-tirar {
  flex: 1 1 auto;
  min-height: 64px;
  padding-left: 12px;
  padding-right: 12px;
}

.serp-tirar.es-esperando,
.serp-tirar.es-esperando:hover {
  opacity: 1;
  background: var(--bg);
  border-color: var(--border);
  color: var(--muted);
  cursor: default;
}

.serp-mensaje {
  min-height: 3em;
  margin: 0;
  padding: 10px 14px;
  border-left: 5px solid var(--accent-2);
  border-radius: 6px;
  background: var(--accent-2-soft);
  font-weight: 600;
}

.serp-mensaje:empty {
  display: none;
}

.serp-rotulo {
  margin: 6px 0 -4px;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}

.serp-jugadores {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.serp-jugador {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 6px 10px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

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

.serp-jugador-ficha {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
}

.serp-jugador-ficha svg {
  display: block;
  width: 100%;
  height: 100%;
}

.serp-jugador-texto {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.serp-jugador-texto .detalle {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
}

.serp-historial {
  margin: 0;
  padding: 0 0 0 1.4em;
  font-size: 0.85rem;
  color: var(--muted);
}

.serp-historial li {
  margin: 2px 0;
}

.serp-historial li:first-child {
  color: var(--text);
  font-weight: 600;
}

.serp-historial li.vacio {
  list-style: none;
  margin-left: -1.4em;
  font-weight: 400;
  color: var(--muted);
}

/* ---------- Reglas de la mesa ---------- */

.serp-reglas {
  margin: 4px 0 0;
  padding: 10px 14px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}

.serp-reglas legend {
  padding: 0 6px;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}

.serp-regla {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-height: 48px;
  padding: 8px 0;
  font-size: 0.85rem;
  line-height: 1.4;
  cursor: pointer;
}

.serp-regla + .serp-regla {
  border-top: 1px solid var(--border);
}

.serp-regla input {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  margin: 0;
  accent-color: var(--accent-2);
  cursor: pointer;
}

.serp-regla strong {
  display: block;
  font-size: 1rem;
}

/* ---------- Marcador ---------- */

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

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

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

.serp-estado strong {
  font-size: 1.35rem;
  font-variant-numeric: tabular-nums;
}

/* ---------- Paneles ---------- */

.serp-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: serp-entrar 0.35s ease-out;
}

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

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

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

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

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

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

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

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

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

/* ---------- Movimiento reducido ---------- */

@media (prefers-reduced-motion: reduce) {
  .serp-panel,
  .serp-dado.rodando {
    animation: none;
  }

  .serp-ficha,
  .serp-dado {
    transition: none;
  }
}
