/* =====================================================================
   La Racha · fifteen.css · Puzzle de 15 (§14)
   Todo con el prefijo "jf-" para no pisar a los demás juegos. Mobile-first:
   el tablero cabe entero en 360 px y las fichas pasan de 44 px de lado.
   ===================================================================== */

.jf {
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
}

.jf-tablero {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  aspect-ratio: 1;
  width: 100%;
  padding: 6px;
  background: var(--principal-suave);
  border: 1px solid var(--linea);
  border-radius: var(--radio);
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;   /* nada de zoom por doble toque al jugar */
}

.jf-casilla {
  appearance: none;
  -webkit-appearance: none;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 44px;             /* objetivo táctil mínimo */
  padding: 0;
  border: 1px solid var(--linea);
  border-radius: 8px;
  background: var(--papel);
  color: var(--tinta);
  font-family: var(--mono);
  font-size: clamp(20px, 6.5vw, 30px);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 1px 0 rgba(27, 31, 36, .07);
  transition: background .12s ease, border-color .12s ease, transform .1s ease;
}

.jf-casilla--movible {
  border-color: var(--principal);
  color: var(--principal);
}

.jf-casilla:hover:not(:disabled) { background: #f9fafb; }
.jf-casilla:active:not(:disabled) { transform: scale(.95); }
.jf-casilla:focus-visible {
  outline: 3px solid rgba(31, 78, 121, .35);
  outline-offset: 2px;
}

.jf-casilla--hueco {
  background: transparent;
  border-style: dashed;
  border-color: #c3cedb;
  box-shadow: none;
  color: transparent;
  cursor: default;
}

/* --- Pie del tablero --------------------------------------------- */
.jf-pie {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--tinta-suave);
}
.jf-pie .jf-cuenta { font-family: var(--mono); font-weight: 700; color: var(--tinta); }
.jf-meta { font-size: 12px; text-align: right; }

.jf-estado {
  min-height: 21px;
  margin: 6px 0 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--verde);
}
.jf-estado--aviso { color: var(--rojo); }

/* --- Salida del atasco: volver al tablero inicial ------------------ */
.jf-mandos { margin: 8px 0 0; }

.jf-reiniciar {
  appearance: none;
  -webkit-appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;             /* cómodo con el pulgar, sin robar protagonismo */
  padding: 8px 14px;
  border: 1px solid var(--linea);
  border-radius: 8px;
  background: var(--papel);
  color: var(--tinta-suave);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.jf-reiniciar:hover { background: #f9fafb; border-color: #c5ccd4; color: var(--tinta); }
.jf-reiniciar:active { transform: translateY(1px); }
.jf-reiniciar:focus-visible {
  outline: 3px solid rgba(31, 78, 121, .35);
  outline-offset: 2px;
}

/* El JS lo esconde si no puede saber cuál era el tablero inicial; sin esto,
   el display de arriba le ganaría al [hidden] de la hoja del navegador. */
.jf [hidden] { display: none !important; }

.jf-ayuda { margin: 6px 0 4px; }

/* --- El botón «Comprobar» cuando el tablero ya está ordenado ------- */
.btn.jf-listo {
  background: var(--verde);
  border-color: var(--verde);
  color: #fff;
  animation: jf-latido 1.5s ease-in-out 3;
}
.btn.jf-listo:hover { background: #19652f; border-color: #19652f; }

@keyframes jf-latido {
  0%, 100% { box-shadow: 0 0 0 0 rgba(30, 123, 58, .40); }
  50%      { box-shadow: 0 0 0 7px rgba(30, 123, 58, 0); }
}

@media (min-width: 560px) {
  .jf-tablero { gap: 8px; padding: 8px; }
  .jf-casilla { font-size: 30px; }
}

@media (prefers-reduced-motion: reduce) {
  .jf-casilla { transition: none; }
  .jf-reiniciar { transition: none; }
  .jf-reiniciar:active { transform: none; }
  .btn.jf-listo { animation: none; }
}
