/*
 * Interfaz nueva de zzl.es.
 *
 * Estas reglas solo se aplican cuando <html> tiene la clase `zzl`, que se
 * añade al abrir p.html con `zzl=1` o con una URL /<tipo>.
 *
 * La guía visual es de tipo producto: lienzo blanco, tipografía muy gruesa en
 * los títulos, botones en forma de píldora y bordes finos. El violeta se usa
 * solo para la marca; las acciones principales son casi negras.
 */

:root {
  /* Colores */
  --zzl-bg: #ffffff;
  --zzl-panel: #f8f9fa;
  --zzl-ink: #202020;
  --zzl-title: #090c1d;
  --zzl-muted: #646464;
  --zzl-ash: #838383;
  --zzl-line: #e8e8e8;
  --zzl-line-strong: #d4d4d4;
  --zzl-brand: #6647f0;
  --zzl-link: #0091ff;
  --zzl-success: #00c07a;

  /* Rejilla: líneas internas claras pero visibles y marco exterior suave. */
  --zzl-grid: #c9ced6;
  --zzl-grid-edge: #b7bec8;
  /* El cursor del motor marca la celda activa con cuatro esquinas. */
  --zzl-cursor: rgba(102, 71, 240, 0.22);

  /* Tipografía. No se descargan fuentes: si no están instaladas se usa la
     fuente del sistema, que mantiene el mismo aspecto general. */
  --zzl-font-display:
    "Plus Jakarta Sans", "Inter", "Segoe UI", system-ui, -apple-system,
    BlinkMacSystemFont, sans-serif;
  --zzl-font-body:
    "Inter", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont,
    sans-serif;
  --zzl-font-mono:
    "Sometype Mono", "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo,
    Consolas, monospace;

  /* Formas y medidas */
  --zzl-touch: 44px;
  --zzl-radius-input: 9px;
  --zzl-radius-card: 12px;
  --zzl-radius-pill: 9999px;
  --zzl-shadow-subtle:
    rgba(0, 0, 0, 0.1) 0px 1px 3px 0px, rgba(0, 0, 0, 0.1) 0px 1px 2px -1px;
}

html.zzl {
  -webkit-text-size-adjust: 100%;
  height: 100%;
}

html.zzl body.zzl-body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  color: var(--zzl-ink);
  /* La interfaz clásica pone un patrón verde en el body; aquí sobra. */
  background: var(--zzl-bg) !important;
  background-image: none !important;
  font-family: var(--zzl-font-body);
  font-size: 16px;
  line-height: 1.5;
  letter-spacing: -0.01px;
}

/* El tablero ocupa la columna derecha (o toda la pantalla en el móvil). */
html.zzl div#main {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 8px;
  width: 100% !important;
  max-width: none;
  height: 100dvh;
  margin: 0;
  padding: max(12px, env(safe-area-inset-top))
    max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom))
    max(12px, env(safe-area-inset-left));
  border: 0;
  background: var(--zzl-bg);
  text-align: center;
  overflow: hidden;
}

html.zzl h2#title2 {
  display: none;
}

html.zzl #quesboard {
  order: 0;
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

html.zzl #divques {
  max-width: 100%;
  max-height: 100%;
  border: 1px solid var(--zzl-grid-edge);
  border-radius: var(--zzl-radius-card);
  background: var(--zzl-bg);
  overflow: hidden;
}

html.zzl #divques canvas {
  display: block;
  max-width: 100%;
  height: auto;
  touch-action: none;
}

/* El resaltado de la celda se coloca sobre el SVG del motor. */
html.zzl #divques > div {
  position: relative;
}

html.zzl .zzl-cell-hover {
  position: absolute;
  display: none;
  pointer-events: none;
  background: var(--zzl-panel);
  /*
   * `multiply` deja las pistas y las líneas oscuras intactas: solo tiñe las
   * zonas blancas de la celda.
   */
  mix-blend-mode: multiply;
  border-radius: 4px;
}

/*
 * El motor dibuja la rejilla y el marco en capas SVG distintas. Se distinguen
 * por `data-pzpr-layer`, añadido en canva.ts, para no alterar las pistas ni
 * las líneas de respuesta.
 */
html.zzl #divques svg g[data-pzpr-layer="grid"] path {
  stroke: var(--zzl-grid);
}

html.zzl #divques svg g[data-pzpr-layer="chassis"] path,
html.zzl #divques svg g[data-pzpr-layer="chassis_ex1"] path {
  fill: var(--zzl-grid-edge);
}

html.zzl #divques svg g[data-pzpr-layer="target_cursor"] path {
  fill: var(--zzl-cursor);
}

/* Con el teclado abierto, la celda que recibe el número se marca más. */
html.zzl.zzl-keypad-open #divques svg g[data-pzpr-layer="target_cursor"] path {
  fill: var(--zzl-brand);
}

html.zzl.zzl-keypad-open #divques svg g[data-pzpr-layer="target_cursor"] {
  filter: drop-shadow(0 0 2px rgba(102, 71, 240, 0.35));
}

/* Botones de la barra inferior: comprobar, deshacer y rehacer. */
html.zzl #btnarea {
  order: 2;
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 0;
  padding: 8px 0 max(8px, env(safe-area-inset-bottom));
  background: transparent;
}

html.zzl #btnarea .btn,
html.zzl .zzl-action,
html.zzl .zzl-complete .btn {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--zzl-touch);
  padding: 12px 20px;
  border: 1px solid var(--zzl-line);
  border-radius: var(--zzl-radius-pill);
  background: var(--zzl-bg);
  color: var(--zzl-ink);
  font-family: var(--zzl-font-display);
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.01em;
  text-decoration: none;
  box-shadow: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition:
    background-color 150ms ease,
    border-color 150ms ease,
    color 150ms ease;
}

html.zzl #btnarea .btn:hover,
html.zzl .zzl-action:hover,
html.zzl .zzl-complete .btn:hover {
  background: var(--zzl-panel);
  border-color: var(--zzl-line-strong);
}

html.zzl #btnarea .btn:active,
html.zzl .zzl-action:active,
html.zzl .zzl-complete .btn:active {
  background: #eeeeee;
}

/* "Comprobar" es una acción secundaria: mismo estilo que Deshacer/Rehacer.
   El botón principal se reserva para el diálogo y "Siguiente reto". */
html.zzl .zzl-action--primary,
html.zzl .zzl-complete .zzl-complete__next {
  border-color: var(--zzl-ink);
  background: var(--zzl-ink);
  color: #ffffff;
}

html.zzl .zzl-action--primary:hover,
html.zzl .zzl-complete .zzl-complete__next:hover {
  border-color: #000000;
  background: #2a2a2a;
}

html.zzl .zzl-action--primary:active,
html.zzl .zzl-complete .zzl-complete__next:active {
  background: #000000;
}

html.zzl #btnarea .btn:disabled {
  opacity: 0.4;
  cursor: default;
}

html.zzl #btnundo,
html.zzl #btnredo {
  min-width: 52px;
  padding-right: 12px;
  padding-left: 12px;
}

/* Los botones de operaciones especiales no caben en la barra mínima. */
html.zzl #btnflush,
html.zzl #btnpresets,
html.zzl #btntrial,
html.zzl #btntrialarea {
  display: none !important;
}

/*
 * Selector de modo de entrada. Solo aparece si el puzzle tiene varios.
 * Se integra como texto: sin caja ni borde, únicamente con una flecha.
 */
html.zzl .zzl-modes {
  display: flex;
  align-items: center;
  margin-top: 8px;
}

html.zzl .zzl-modes__select {
  box-sizing: border-box;
  field-sizing: content;
  max-width: 100%;
  padding: 0 18px 0 0;
  border: 0;
  border-radius: 0;
  appearance: none;
  -webkit-appearance: none;
  background-color: transparent;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6' fill='none' stroke='%23838383' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right center;
  background-size: 12px 12px;
  color: var(--zzl-ink);
  font-family: var(--zzl-font-body);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  cursor: pointer;
}

html.zzl .zzl-modes__select:focus-visible {
  border-radius: 2px;
  outline: 2px solid rgba(0, 145, 255, 0.35);
  outline-offset: 2px;
}

/* ------------------------------------------------------------------------- */
/* Menú lateral                                                              */
/* ------------------------------------------------------------------------- */

html.zzl #zzl-menu {
  box-sizing: border-box;
  width: 100%;
  height: 100dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: max(24px, env(safe-area-inset-top)) 24px
    max(24px, env(safe-area-inset-bottom)) 24px;
  /* Un gris de la guía para separar el menú del tablero blanco. */
  background: var(--zzl-panel);
  border-right: 1px solid var(--zzl-line);
  text-align: left;
}

html.zzl .zzl-info {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

html.zzl .zzl-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

html.zzl .zzl-logo {
  box-sizing: border-box;
  display: block;
  flex: 0 0 auto;
  width: 96px;
  height: 88px;
  padding: 0;
  border-radius: 0;
  background: transparent;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

html.zzl .zzl-logo:focus-visible {
  outline: 2px solid var(--zzl-link);
  outline-offset: 4px;
}

html.zzl .zzl-logo__image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

html.zzl .zzl-heading {
  min-width: 0;
  padding-top: 2px;
}

html.zzl .zzl-type {
  margin: 0;
  color: var(--zzl-title);
  font-family: var(--zzl-font-display);
  font-size: 30px;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.04em;
  overflow-wrap: anywhere;
}

html.zzl .zzl-byline {
  margin: 4px 0 0;
  color: #000;
  font-size: 13px;
  line-height: 1.4;
}

html.zzl .zzl-byline a {
  color: inherit;
  text-decoration: none;
}

html.zzl .zzl-byline a:hover {
  text-decoration: underline;
}

html.zzl .zzl-byline time {
  color: var(--zzl-ash);
  font-variant-numeric: tabular-nums;
}

html.zzl .zzl-time {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-top: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--zzl-line);
}

html.zzl .zzl-time__label {
  color: var(--zzl-ash);
  font-family: var(--zzl-font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

html.zzl .zzl-time__value {
  color: var(--zzl-title);
  font-family: var(--zzl-font-mono);
  font-size: 24px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

/* Progreso: cuatro cifras compactas, en dos columnas también en el móvil. */
html.zzl .zzl-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
}

html.zzl .zzl-stats__item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--zzl-line);
  border-radius: 10px;
  background: var(--zzl-bg);
}

html.zzl .zzl-stats__label {
  color: var(--zzl-ash);
  font-family: var(--zzl-font-mono);
  font-size: 9px;
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

html.zzl .zzl-stats__value {
  overflow: hidden;
  color: var(--zzl-title);
  font-family: var(--zzl-font-display);
  font-size: 19px;
  font-weight: 800;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

html.zzl .zzl-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

html.zzl .zzl-actions__secondary {
  display: flex;
  flex: 1 0 100%;
  flex-wrap: wrap;
  gap: 8px;
}

html.zzl .zzl-action {
  min-height: 40px;
  padding: 10px 16px;
  font-size: 14px;
}

/* El atributo `hidden` debe ganar al `display: inline-flex` de la píldora. */
html.zzl .zzl-action[hidden] {
  display: none;
}

html.zzl .zzl-action:disabled {
  opacity: 0.4;
  cursor: default;
}

html.zzl .zzl-action .zzl-btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

html.zzl .zzl-action .zzl-btn-icon svg {
  display: block;
  width: 18px;
  height: 18px;
}

html.zzl .zzl-action.zzl-icon-btn--text {
  gap: 8px;
}

html.zzl .zzl-action--link {
  background: transparent;
}

/* ------------------------------------------------------------------------- */
/* Icono de menú y fondo en el móvil                                         */
/* ------------------------------------------------------------------------- */

html.zzl .zzl-menu-toggle {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  z-index: 60;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 1px solid var(--zzl-line);
  border-radius: var(--zzl-radius-pill);
  background: rgba(255, 255, 255, 0.96);
  color: var(--zzl-ink);
  box-shadow: var(--zzl-shadow-subtle);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

html.zzl .zzl-menu-toggle:hover {
  border-color: var(--zzl-line-strong);
  background: var(--zzl-panel);
}

html.zzl .zzl-menu-toggle svg {
  width: 22px;
  height: 22px;
}

html.zzl .zzl-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
  background: rgba(0, 0, 0, 0.5);
}

html.zzl body.zzl-body.zzl-menu-open .zzl-backdrop {
  display: block;
}

/* En el móvil el menú es un panel deslizante. */
@media (max-width: 899px), (orientation: portrait) {
  html.zzl #zzl-menu {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 50;
    width: min(88vw, 420px);
    height: 100dvh;
    transform: translateX(-105%);
    transition: transform 180ms ease-out;
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.18);
  }

  html.zzl body.zzl-body.zzl-menu-open #zzl-menu {
    transform: translateX(0);
  }

  html.zzl div#main {
    width: 100% !important;
  }
}

/* En pantalla panorámica el menú queda siempre visible a la izquierda. */
@media (min-width: 900px) and (orientation: landscape) {
  html.zzl body.zzl-body {
    display: grid;
    grid-template-columns: minmax(340px, 50%) minmax(0, 1fr);
    grid-template-rows: 100dvh;
  }

  html.zzl #zzl-menu {
    grid-column: 1;
    grid-row: 1;
    position: static;
    transform: none;
    box-shadow: none;
  }

  html.zzl div#main {
    grid-column: 2;
    grid-row: 1;
  }

  html.zzl .zzl-menu-toggle {
    display: none;
  }

  html.zzl .zzl-backdrop {
    display: none !important;
  }
}

/* ------------------------------------------------------------------------- */
/* Aviso de puzzle resuelto                                                  */
/* ------------------------------------------------------------------------- */

html.zzl .zzl-complete {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.5);
}

html.zzl .zzl-complete[hidden] {
  display: none;
}

html.zzl .zzl-complete__card {
  position: relative;
  box-sizing: border-box;
  width: min(100%, 400px);
  padding: 32px 24px;
  border: 1px solid var(--zzl-line);
  border-radius: var(--zzl-radius-card);
  background: var(--zzl-bg);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.18);
  text-align: center;
}

html.zzl .zzl-complete__close {
  position: absolute;
  top: 12px;
  right: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--zzl-line);
  border-radius: var(--zzl-radius-pill);
  background: var(--zzl-bg);
  color: var(--zzl-ink);
  cursor: pointer;
}

html.zzl .zzl-complete__close:hover {
  background: var(--zzl-panel);
  border-color: var(--zzl-line-strong);
}

html.zzl .zzl-complete__close:focus-visible,
html.zzl .zzl-picker__close:focus-visible {
  outline: 2px solid var(--zzl-link);
  outline-offset: 1px;
}

html.zzl .zzl-complete__close svg {
  width: 18px;
  height: 18px;
}

html.zzl .zzl-complete__title {
  margin: 0 0 8px;
  color: var(--zzl-title);
  font-family: var(--zzl-font-display);
  font-size: 34px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.04em;
}

html.zzl .zzl-complete__text {
  margin: 0 0 24px;
  color: var(--zzl-muted);
  font-size: 16px;
}

html.zzl .zzl-complete__next,
html.zzl .zzl-complete__another {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 4px;
}

/* ------------------------------------------------------------------------- */
/* Avisos y confirmaciones                                                    */
/* ------------------------------------------------------------------------- */

/* Los cuadros clásicos de "Notice" y "Confirmation" ya no se usan. */
html.zzl #notifies {
  display: none !important;
}

html.zzl .zzl-dialog {
  position: fixed;
  inset: 0;
  z-index: 95;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.46);
}

html.zzl .zzl-dialog[hidden] {
  display: none;
}

html.zzl .zzl-dialog__card {
  box-sizing: border-box;
  width: min(100%, 420px);
  padding: 28px 24px 24px;
  border: 1px solid var(--zzl-line);
  border-radius: var(--zzl-radius-card);
  background: var(--zzl-bg);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.2);
}

html.zzl .zzl-dialog__card:focus {
  outline: none;
}

html.zzl .zzl-dialog__title {
  margin: 0;
  color: var(--zzl-title);
  font-family: var(--zzl-font-display);
  font-size: 26px;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.04em;
}

html.zzl .zzl-dialog__text {
  margin-top: 10px;
  color: var(--zzl-muted);
  font-size: 15px;
  line-height: 1.5;
}

html.zzl .zzl-dialog__text > div {
  margin-bottom: 8px;
}

html.zzl .zzl-dialog__text > div:last-child {
  margin-bottom: 0;
}

html.zzl .zzl-dialog__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

html.zzl .zzl-dialog__actions .zzl-action {
  min-height: var(--zzl-touch);
}

/* El botón de menú queda tapado por el diálogo. */
html.zzl body.zzl-dialog-open .zzl-menu-toggle {
  display: none;
}

@media (max-width: 600px) {
  html.zzl .zzl-dialog {
    align-items: flex-end;
    padding: 0;
  }

  html.zzl .zzl-dialog__card {
    width: 100%;
    padding-bottom: max(24px, env(safe-area-inset-bottom));
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 18px 18px 0 0;
  }
}

/* ------------------------------------------------------------------------- */
/* Selector de tamaño de rejilla                                             */
/* ------------------------------------------------------------------------- */

html.zzl .zzl-picker {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.46);
}

html.zzl .zzl-picker[hidden] {
  display: none;
}

html.zzl .zzl-picker__card {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  width: min(100%, 560px);
  max-height: min(82dvh, 720px);
  overflow: hidden;
  border: 1px solid var(--zzl-line);
  border-radius: 16px;
  background: var(--zzl-bg);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.2);
}

html.zzl .zzl-picker__card:focus {
  outline: none;
}

/* El botón de menú queda tapado por el selector. */
html.zzl body.zzl-picker-open .zzl-menu-toggle {
  display: none;
}

html.zzl .zzl-picker__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 20px 8px;
}

html.zzl .zzl-picker__title {
  margin: 0;
  color: var(--zzl-title);
  font-family: var(--zzl-font-display);
  font-size: 26px;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.04em;
}

html.zzl .zzl-picker__close {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--zzl-line);
  border-radius: var(--zzl-radius-pill);
  background: var(--zzl-bg);
  color: var(--zzl-ink);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

html.zzl .zzl-picker__close:hover {
  background: var(--zzl-panel);
  border-color: var(--zzl-line-strong);
}

html.zzl .zzl-picker__close svg {
  width: 18px;
  height: 18px;
}

html.zzl .zzl-picker__hint {
  margin: 0;
  padding: 0 20px 14px;
  color: var(--zzl-muted);
  font-size: 13px;
  line-height: 1.4;
}

html.zzl .zzl-picker__filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 20px 12px;
}

html.zzl .zzl-picker__filters[hidden] {
  display: none;
}

html.zzl .zzl-picker__filter {
  min-height: 34px;
  padding: 6px 12px;
  border: 1px solid var(--zzl-line);
  border-radius: var(--zzl-radius-pill);
  background: var(--zzl-bg);
  color: var(--zzl-ink);
  font-family: var(--zzl-font-body);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

html.zzl .zzl-picker__filter:hover {
  border-color: var(--zzl-line-strong);
  background: var(--zzl-panel);
}

html.zzl .zzl-picker__filter:focus-visible {
  outline: 2px solid var(--zzl-link);
  outline-offset: 1px;
}

html.zzl .zzl-picker__filter.is-active {
  border-color: var(--zzl-ink);
  background: var(--zzl-ink);
  color: #ffffff;
}

html.zzl .zzl-picker__filter:disabled {
  opacity: 0.4;
  cursor: default;
}

html.zzl .zzl-picker__list {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 4px;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 12px 16px;
}

html.zzl .zzl-picker__size {
  box-sizing: border-box;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 58px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--zzl-ink);
  font-family: var(--zzl-font-body);
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

html.zzl .zzl-picker__size:hover {
  border-color: var(--zzl-line);
  background: var(--zzl-panel);
}

html.zzl .zzl-picker__size:focus-visible {
  outline: 2px solid var(--zzl-link);
  outline-offset: 1px;
}

html.zzl .zzl-picker__size.is-current {
  border-color: rgba(102, 71, 240, 0.22);
  background: rgba(102, 71, 240, 0.05);
}

html.zzl .zzl-picker__size:disabled {
  opacity: 0.65;
  cursor: default;
}

html.zzl .zzl-picker__size-labels {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

html.zzl .zzl-picker__size-name {
  color: var(--zzl-title);
  font-family: var(--zzl-font-display);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.2;
}

html.zzl .zzl-picker__size-meta {
  color: var(--zzl-muted);
  font-size: 12px;
  line-height: 1.3;
}

html.zzl .zzl-picker__size-badge {
  padding: 4px 8px;
  border: 1px solid rgba(102, 71, 240, 0.28);
  border-radius: var(--zzl-radius-pill);
  background: rgba(102, 71, 240, 0.08);
  color: var(--zzl-brand);
  font-family: var(--zzl-font-mono);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

html.zzl .zzl-picker__size-arrow {
  display: inline-flex;
  width: 18px;
  height: 18px;
  color: var(--zzl-ash);
}

html.zzl .zzl-picker__size-arrow svg {
  width: 100%;
  height: 100%;
}

html.zzl .zzl-picker__empty {
  margin: 0;
  padding: 24px 12px;
  color: var(--zzl-muted);
  font-size: 14px;
  text-align: center;
}

@media (max-width: 600px) {
  html.zzl .zzl-picker {
    align-items: flex-end;
    padding: 0;
  }

  html.zzl .zzl-picker__card {
    width: 100%;
    max-height: 88dvh;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 18px 18px 0 0;
  }

  html.zzl .zzl-picker__head {
    padding: 20px 16px 8px;
  }

  html.zzl .zzl-picker__hint {
    padding-right: 16px;
    padding-left: 16px;
  }

  html.zzl .zzl-picker__filters {
    padding-right: 16px;
    padding-left: 16px;
  }

  html.zzl .zzl-picker__list {
    padding-right: 8px;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
    padding-left: 8px;
  }
}

/* ------------------------------------------------------------------------- */
/* Página de arranque (index.html)                                           */
/* ------------------------------------------------------------------------- */

html.zzl.zzl-start-page body {
  margin: 0;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--zzl-bg);
  color: var(--zzl-ink);
  font-family: var(--zzl-font-body);
  font-size: 16px;
  line-height: 1.5;
}

html.zzl.zzl-start-page #zzl-start {
  box-sizing: border-box;
  width: min(100%, 440px);
  padding: 40px 24px;
  text-align: center;
}

html.zzl.zzl-start-page h1 {
  margin: 0 0 12px;
  color: var(--zzl-title);
  font-family: var(--zzl-font-display);
  font-size: 80px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.04em;
}

html.zzl.zzl-start-page h1 span {
  color: var(--zzl-brand);
}

html.zzl.zzl-start-page p {
  margin: 0 0 24px;
  color: var(--zzl-muted);
}

html.zzl.zzl-start-page .zzl-start__link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--zzl-touch);
  padding: 12px 24px;
  border-radius: var(--zzl-radius-pill);
  background: var(--zzl-ink);
  color: #ffffff;
  font-family: var(--zzl-font-display);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  transition: background-color 150ms ease;
}

html.zzl.zzl-start-page .zzl-start__link:hover {
  background: #2a2a2a;
}

/* El menú clásico es demasiado denso para la interfaz móvil nueva. */
html.zzl #menuboard {
  display: none !important;
}

html.zzl.zzl-start-page .zzl-start__message-title {
  font-size: 34px;
}

/* Botones con icono: menos texto y más sitio para el tablero. */
html.zzl #btnarea .zzl-icon-btn {
  gap: 0;
  min-width: var(--zzl-touch);
  padding: 0;
}

html.zzl #btnarea .zzl-icon-btn--text {
  gap: 8px;
  min-width: 0;
  padding: 12px 20px;
}

html.zzl #btnarea .zzl-btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

html.zzl #btnarea .zzl-btn-icon svg {
  display: block;
  width: 18px;
  height: 18px;
}

/* En móvil todos los botones del tablero son solo icono para que quepan
   en una sola fila. El texto sigue disponible en aria-label y title. */
@media (max-width: 480px) {
  html.zzl #btnarea {
    flex-wrap: nowrap;
  }

  html.zzl #btnarea .zzl-icon-btn--text {
    gap: 0;
    min-width: var(--zzl-touch);
    padding: 0;
  }

  html.zzl #btnarea .zzl-icon-btn--text .zzl-btn-label {
    display: none;
  }
}

/* El panel numérico muestra solo la rejilla, sin la barra de título clásica. */
html.zzl #keypopup #barkeypopup {
  display: none !important;
}

/*
 * En móvil el panel se ancla al borde inferior. `player.ts` guarda la altura
 * real en `--zzl-keypad-height` para que el tablero le deje sitio y la celda
 * activa no quede tapada.
 */
@media (max-width: 899px), (orientation: portrait) {
  html.zzl.zzl-keypad-open div#main {
    padding-bottom: calc(var(--zzl-keypad-height, 150px) + 24px);
  }

  html.zzl #keypopup {
    position: fixed;
    top: auto !important;
    right: 0;
    bottom: 0;
    left: 0 !important;
    z-index: 30 !important;
    box-sizing: border-box;
    width: auto;
    max-height: 520px;
    max-height: min(60dvh, 520px);
    margin: 0;
    padding: 10px 12px max(10px, env(safe-area-inset-bottom));
    overflow: auto;
    overscroll-behavior: contain;
    border: 0;
    border-top: 1px solid var(--zzl-line);
    border-radius: 16px 16px 0 0;
    background: var(--zzl-bg);
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.1);
  }

  /* Las rejillas pequeñas (paneles especiales) quedan centradas. */
  html.zzl #keypopup .panelbase {
    width: max-content;
    max-width: 100%;
    margin: 0 auto;
  }

  html.zzl #keypopup .kpcellvalid {
    border-radius: 8px;
    background: var(--zzl-panel);
  }

  /* Sudoku y Fillomino: dos filas de teclas que ocupan todo el ancho. */
  html.zzl #keypopup .panelbase.zzl-keypad-wide {
    display: flex !important;
    flex-wrap: wrap;
    align-content: flex-start;
    justify-content: center;
    width: 100%;
  }

  html.zzl #keypopup .zzl-keypad-wide .kpcell {
    flex: 0 0 calc(20% - 2px);
    width: calc(20% - 2px);
    height: 48px;
    margin: 1px;
    line-height: 48px;
  }

  /* Las celdas vacías solo servían para centrar el 0 en la rejilla 3×3. */
  html.zzl #keypopup .zzl-keypad-wide .kpcellempty {
    display: none;
  }
}

/*
 * En escritorio el panel numérico queda al pie del menú lateral. Así sigue
 * siempre a mano sin tapar el tablero ni la columna de juego.
 */
@media (min-width: 900px) and (orientation: landscape) {
  html.zzl.zzl-keypad-open #zzl-menu {
    padding-bottom: calc(var(--zzl-keypad-height, 150px) + 48px);
  }

  html.zzl #keypopup {
    position: fixed;
    top: auto !important;
    right: auto !important;
    bottom: max(24px, env(safe-area-inset-bottom));
    left: max(24px, env(safe-area-inset-left)) !important;
    z-index: 20 !important;
    box-sizing: border-box;
    width: min(420px, calc(50vw - 48px));
    max-height: calc(100dvh - 48px);
    margin: 0;
    padding: 10px;
    overflow: auto;
    overscroll-behavior: contain;
    border: 1px solid var(--zzl-line);
    border-radius: 12px;
    background: var(--zzl-bg);
    box-shadow: var(--zzl-shadow-subtle);
  }

  /* El teclado numérico se estira en dos filas, igual que en el móvil. */
  html.zzl #keypopup .panelbase {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
  }

  html.zzl #keypopup .panelbase.zzl-keypad-wide {
    display: flex !important;
    flex-wrap: wrap;
    align-content: flex-start;
    justify-content: center;
    width: 100%;
  }

  html.zzl #keypopup .zzl-keypad-wide .kpcell {
    flex: 0 0 calc(20% - 2px);
    width: calc(20% - 2px);
    height: 48px;
    margin: 1px;
    line-height: 48px;
  }

  html.zzl #keypopup .kpcellvalid {
    border-radius: 8px;
    background: var(--zzl-panel);
  }

  html.zzl #keypopup .zzl-keypad-wide .kpcellempty {
    display: none;
  }
}

/* ------------------------------------------------------------------------- */
/* Portada de pu.zzl.es                                                      */
/* ------------------------------------------------------------------------- */

html.zzl.zzl-cover-page body.zzl-cover-body {
  min-height: 100%;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  color: var(--zzl-ink);
  background: var(--zzl-bg);
  font-family: var(--zzl-font-body);
  font-size: 16px;
  line-height: 1.5;
}

html.zzl.zzl-cover-page *,
html.zzl.zzl-cover-page *::before,
html.zzl.zzl-cover-page *::after {
  box-sizing: border-box;
}

html.zzl .zzl-cover__main {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: clamp(16px, 3vw, 24px) clamp(12px, 3vw, 24px) 32px;
}

html.zzl .zzl-cover__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}

html.zzl .zzl-cover__type {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  min-width: 0;
  padding: 10px 10px 12px;
  border: 1px solid var(--zzl-line);
  border-radius: 10px;
  background: var(--zzl-bg);
  color: var(--zzl-ink);
  text-align: center;
  text-decoration: none;
  transition:
    border-color 120ms ease,
    box-shadow 120ms ease,
    transform 120ms ease;
}

html.zzl .zzl-cover__type:hover {
  border-color: var(--zzl-line-strong);
  box-shadow: var(--zzl-shadow-subtle);
  transform: translateY(-1px);
}

html.zzl .zzl-cover__type:focus-visible {
  border-color: var(--zzl-link);
  outline: 2px solid rgba(0, 145, 255, 0.2);
  outline-offset: 2px;
}

html.zzl .zzl-cover__type-name {
  display: block;
  width: 100%;
  min-height: 1.2em;
  color: var(--zzl-title);
  font-family: var(--zzl-font-display);
  font-size: 17px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.03em;
  overflow-wrap: anywhere;
}

html.zzl .zzl-cover__logo-card {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid transparent;
  background: var(--zzl-panel);
}

html.zzl .zzl-cover__logo-card img {
  display: block;
  width: 100%;
  height: auto;
}

html.zzl .zzl-cover__message {
  margin: 0;
  padding: 24px 0;
  color: var(--zzl-muted);
}

html.zzl .zzl-cover__sentinel {
  width: 100%;
  height: 1px;
}

@media (max-width: 560px) {
  html.zzl .zzl-cover__grid {
    grid-template-columns: minmax(0, 1fr);
  }

  html.zzl .zzl-cover__type {
    padding: 10px 10px 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html.zzl .zzl-cover__type {
    transition: none;
  }
}

/* ------------------------------------------------------------------------- */
/* Miniaturas animadas de la portada                                         */
/* ------------------------------------------------------------------------- */

html.zzl .zzl-anim {
  display: block;
  flex: 0 0 auto;
  width: 128px;
  height: 128px;
  margin: 8px auto 0;
  overflow: hidden;
  border: 1px solid var(--zzl-line);
  border-radius: 10px;
  background: var(--zzl-panel);
}

html.zzl .zzl-anim__svg {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

html.zzl .zzl-anim__grid {
  fill: none;
  stroke: var(--zzl-line-strong);
  stroke-width: 0.7;
  opacity: 0.85;
}

html.zzl .zzl-anim__cell {
  stroke: none;
}

html.zzl .zzl-anim__cell--ink {
  fill: var(--zzl-title);
}

html.zzl .zzl-anim__cell--brand {
  fill: var(--zzl-brand);
}

html.zzl .zzl-anim__cell--green {
  fill: var(--zzl-success);
}

html.zzl .zzl-anim__cell--gray {
  fill: #b8bdc7;
}

html.zzl .zzl-anim__cell--light {
  fill: #fff0b3;
}

html.zzl .zzl-anim__cell--ice {
  fill: #d9f1ff;
}

html.zzl .zzl-anim__cell--paper {
  fill: var(--zzl-bg);
  stroke: var(--zzl-ash);
  stroke-width: 1;
}

html.zzl .zzl-anim__cell--island {
  fill: var(--zzl-bg);
  stroke: var(--zzl-success);
  stroke-width: 1.2;
}

html.zzl .zzl-anim__line {
  fill: none;
  stroke: var(--zzl-brand);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

html.zzl .zzl-anim__line--green {
  stroke: var(--zzl-success);
}

html.zzl .zzl-anim__room {
  fill: none;
  stroke: var(--zzl-ash);
  stroke-width: 2;
  stroke-linecap: round;
}

html.zzl .zzl-anim__region {
  fill: var(--zzl-brand);
  fill-opacity: 0.18;
  stroke: var(--zzl-brand);
  stroke-width: 1.2;
}

html.zzl .zzl-anim__num {
  fill: var(--zzl-title);
  stroke: var(--zzl-bg);
  stroke-width: 2px;
  font-family: var(--zzl-font-mono);
  font-size: 9.5px;
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: central;
  paint-order: stroke;
}

html.zzl .zzl-anim__num--light {
  fill: #fff;
  stroke: none;
}

html.zzl .zzl-anim__dot {
  fill: var(--zzl-title);
}

html.zzl .zzl-anim__dot--white {
  fill: var(--zzl-bg);
  stroke: var(--zzl-title);
  stroke-width: 1.8;
}

html.zzl .zzl-anim__lamp {
  fill: #ffd166;
  stroke: #d99b00;
  stroke-width: 1;
}

html.zzl .zzl-anim__step {
  opacity: 0;
  animation: zzl-anim-appear 5.2s ease-in-out infinite;
  animation-delay: var(--delay, 0s);
  transform-box: fill-box;
  transform-origin: center;
}

html.zzl .zzl-anim__draw {
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  animation: zzl-anim-draw 5.2s ease-in-out infinite;
  animation-delay: var(--delay, 0s);
}

@keyframes zzl-anim-appear {
  0%,
  6% {
    opacity: 0;
    transform: scale(0.65);
  }

  13%,
  76% {
    opacity: 1;
    transform: scale(1);
  }

  86%,
  100% {
    opacity: 0;
    transform: scale(1);
  }
}

@keyframes zzl-anim-draw {
  0%,
  6% {
    stroke-dashoffset: 100;
    opacity: 1;
  }

  60%,
  76% {
    stroke-dashoffset: 0;
    opacity: 1;
  }

  86%,
  100% {
    stroke-dashoffset: 0;
    opacity: 0;
  }
}

@media (max-width: 560px) {
  html.zzl .zzl-anim {
    width: 112px;
    height: 112px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html.zzl .zzl-anim__step {
    opacity: 1;
    transform: none;
    animation: none;
  }

  html.zzl .zzl-anim__draw {
    stroke-dashoffset: 0;
    opacity: 1;
    animation: none;
  }
}
