/* ============================================================
   Secuencias — lista de 6 series; cada serie es una fila de fichas
   numéricas con un hueco. La serie activa lleva el hueco en acento;
   al acertar se llena en verde y aparece la regla (muted) debajo.
   En pantallas táctiles/estrechas, teclado numérico propio pegado
   abajo (sticky) para no depender del teclado del sistema.
   ============================================================ */
.sq-host { display: flex; justify-content: center; padding: 2px 0 8px; }
.sq { width: 100%; max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }

.sq-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.sq-row {
  display: grid; grid-template-columns: 28px 1fr; gap: 12px; align-items: start;
  padding: 12px 16px 12px 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: border-color var(--dur), background var(--dur), box-shadow var(--dur);
}
@media (hover: hover) { .sq-row:not(.is-active):not(.is-solved):not(.is-revealed):hover { border-color: var(--line-2); } }
.sq-row.is-active { border-color: var(--sel); box-shadow: 0 0 0 3px color-mix(in srgb, var(--sel) 16%, transparent); }
.sq-row.is-solved, .sq-row.is-revealed { cursor: default; background: color-mix(in srgb, var(--surface) 55%, var(--bg)); }

.sq-num {
  display: grid; place-items: center; width: 26px; height: 26px; margin-top: 10px;
  font-family: var(--font-num); font-size: var(--t-xs); font-weight: 600; color: var(--muted);
  border: 1px solid var(--line-2); border-radius: 50%;
  transition: background var(--dur), color var(--dur), border-color var(--dur);
}
.sq-row.is-active .sq-num { background: var(--sel); border-color: var(--sel); color: var(--on-ink); }
.sq-row.is-solved .sq-num { background: var(--success-weak); border-color: transparent; color: var(--success); }
.sq-row.is-revealed .sq-num { background: var(--sel-weak); border-color: transparent; color: var(--sel-ink); }

.sq-body { min-width: 0; }
.sq-terms { display: flex; flex-wrap: wrap; gap: 6px; }
.sq-tile {
  display: inline-grid; place-items: center;
  min-width: 46px; height: 46px; padding: 0 10px; box-sizing: border-box;
  font-family: var(--font-num); font-size: 1.12rem; font-weight: 500; letter-spacing: -.02em;
  font-variant-numeric: tabular-nums; color: var(--ink);
  background: var(--surface-2); border: 1px solid transparent; border-radius: 10px;
}
.sq-hole {
  background: var(--surface); border: 1.5px dashed var(--line-2); color: var(--ink);
  min-width: 56px; font-weight: 600;
}
.sq-hole.is-empty::before { content: "?"; color: var(--muted); font-weight: 400; }
.sq-row.is-active .sq-hole {
  border-style: solid; border-color: var(--sel);
  background: color-mix(in srgb, var(--sel) 8%, var(--surface));
}
/* cursor que parpadea en el hueco activo */
.sq-row.is-active .sq-hole::after {
  content: ""; width: 1.5px; height: 1.1em; margin-left: 2px; background: var(--sel);
  animation: sq-caret 1.1s steps(1) infinite;
}
.sq-row.is-active .sq-hole.is-empty::before { content: ""; }
.sq-row.is-active .sq-hole { grid-auto-flow: column; }
@keyframes sq-caret { 50% { opacity: 0; } }
.sq-row.is-solved .sq-hole { border: 1px solid transparent; background: var(--success-weak); color: var(--success); }
.sq-row.is-revealed .sq-hole { border: 1px solid transparent; background: var(--sel-weak); color: var(--sel-ink); }
.sq-hole.is-wrong { animation: sq-shake .38s var(--ease); border-color: var(--danger) !important; }
.sq-hole.is-hit { animation: sq-hit .45s var(--ease); }
@keyframes sq-shake {
  15%, 55% { transform: translateX(-5px); }
  35%, 75% { transform: translateX(5px); }
}
@keyframes sq-hit { 40% { transform: scale(1.08); } }

.sq-note {
  margin: 0; max-height: 0; opacity: 0; overflow: hidden;
  font-size: var(--t-sm); line-height: 1.4; color: var(--muted);
  transition: opacity .3s var(--ease), max-height .3s var(--ease), margin .3s var(--ease);
}
.sq-note.is-shown { max-height: 5em; opacity: 1; margin-top: 10px; }
.sq-note.is-hint { color: var(--warn); }

/* teclado numérico en pantalla (táctil o estrecho) */
.sq-pad {
  display: none;
  position: sticky; bottom: 0; z-index: 5;
  grid-template-columns: repeat(5, 1fr); gap: 6px;
  padding: 10px 0 calc(8px + env(safe-area-inset-bottom));
  background: linear-gradient(to bottom, transparent, var(--bg) 14px);
}
.sq-key {
  height: 46px; min-width: 40px; padding: 0;
  display: grid; place-items: center;
  font-family: var(--font-ui); font-size: 1.15rem; font-weight: 500; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-sm);
  cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  transition: background var(--dur), transform .06s ease;
}
.sq-key svg { width: 22px; height: 22px; color: var(--ink-2); }
.sq-key:active { background: var(--sel-weak); transform: translateY(1px); }
.sq-key:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.sq-key-enter {
  grid-column: span 3; font-size: var(--t-sm); font-weight: 600;
  background: var(--ink); color: var(--on-ink); border-color: var(--ink);
}
.sq-key-enter:active { background: var(--ink-2); }
@media (hover: none), (max-width: 640px) {
  .sq-pad { display: grid; }
}
.sq.is-done .sq-pad { display: none; }

/* móvil: la serie cabe en UNA línea — las fichas se reparten el ancho
   (las de números largos se llevan más) y el número de serie pasa a
   ser una marca pequeña en la esquina */
@media (max-width: 640px) {
  .sq { gap: 8px; }
  .sq-list { gap: 6px; }
  .sq-row { position: relative; grid-template-columns: 1fr; gap: 0; padding: 14px 8px 9px; }
  .sq-num {
    position: absolute; top: -1px; left: 12px; width: auto; height: auto; margin: 0;
    padding: 0 5px; border: 0; border-radius: 0 0 5px 5px; font-size: .62rem; line-height: 13px;
    background: var(--surface-2);
  }
  .sq-row.is-active .sq-num { background: var(--sel); }
  .sq-terms { flex-wrap: nowrap; gap: 4px; }
  .sq-tile {
    flex: 1 1 auto; min-width: 0; height: 42px; padding: 0 3px;
    font-size: clamp(.8rem, 3.9vw, 1rem); letter-spacing: -.04em; border-radius: 8px;
  }
  .sq-hole { flex-basis: 44px; min-width: 44px; }
  .sq-note.is-shown { margin-top: 7px; }
}
@media (prefers-reduced-motion: reduce) {
  .sq-hole.is-wrong, .sq-hole.is-hit { animation: none; }
  .sq-row.is-active .sq-hole::after { animation: none; }
}
