/* El Chivato: la pantalla de juego. Mismo periódico que el críptico: solo variables y clases de styles.css
   (.btn, .hintbox, .stamp, .intentos, .voto…); aquí van las casillas, los soplos y la libreta. La sección de la
   cabecera es la de styles.css. Los nombres propios llevan ch- porque movil.js ya usa .teclado y .tecla para el
   teclado de letras. */

/* --- La hoja --- */
.chivato, #guia-chivato { --ch-c: 38px; --ch-m: 12px; }
.chivato {
  background: var(--sheet); border: 1px solid var(--rule); padding: 22px clamp(16px, 4vw, 36px) 28px;
}
.en-app .chivato { flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: none; padding: 10px 14px; }
.chivato button { touch-action: manipulation; }
.chivato button:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.ch-vacio { padding: 18px 0; text-align: center; color: var(--muted); }
.ch-vacio-t { margin: 0 0 8px; font: italic 24px var(--serif); color: var(--ink); }
.ch-vacio a { color: var(--ink); }
.ch-entrada { margin: 18px 0 16px; font: italic 20px/1.4 var(--serif); }
.ch-entrada strong { font-style: normal; }
.ch-h3 { margin: 0 0 10px; font: 11px var(--mono); text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }

.ch-tablero { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px 32px; align-items: start; }

/* --- Soplos --- */
.ch-soplos { list-style: none; margin: 0; padding: 0; }
.ch-soplo {
  position: relative; display: grid; grid-template-columns: 1.2em auto auto 1fr; align-items: center; column-gap: 10px;
  min-height: 54px; padding: 4px 0; border-bottom: 1px solid var(--tono-2);
}
.ch-soplo:last-child { border-bottom: 0; }
.ch-letra { font: 700 19px var(--serif); }
.ch-cifras { display: inline-flex; padding-left: 1.5px; }
.ch-c {
  width: var(--ch-c); height: var(--ch-c); margin-left: -1.5px; display: grid; place-items: center;
  background: var(--cell); border: 1.5px solid var(--ink); font: 500 calc(var(--ch-c) * .5) var(--mono);
  transition: background .3s, color .3s;
}
/* Las dos cuentas del soplo, cada una con su número: ● en su sitio y ○ en otro sitio. Se distinguen por la forma,
   no por el color. Una cuenta a cero lleva un guion y queda apagada. Con el número al lado no parecen una marca
   por cifra. */
.ch-marcas { display: inline-flex; align-items: center; gap: calc(var(--ch-c) * .4); padding-left: 4px; }
.ch-cuenta { display: inline-flex; align-items: center; gap: 6px; }
.ch-cuenta b { min-width: 1ch; font: 600 calc(var(--ch-c) * .47)/1 var(--mono); font-variant-numeric: tabular-nums; }
.ch-cuenta.cero { opacity: .35; }
.ch-m { width: var(--ch-m); height: var(--ch-m); flex: none; border-radius: 50%; display: block; }
.ch-m-s { background: var(--ink); }
.ch-m-d { box-shadow: inset 0 0 0 1.8px var(--ink); }
.ch-marcas-linea { --ch-m: 10px; gap: 10px; padding-left: 0; vertical-align: middle; }
.ch-marcas-linea .ch-cuenta { gap: 4px; }
.ch-marcas-linea .ch-cuenta b { font-size: 14px; }
.ch-marcas-linea .ch-cuenta.cero { opacity: .5; }

/* La marca del jugador: sin marcar → me lo creo (visto) → miente (cruz roja y la palabra al margen). */
.ch-marca {
  justify-self: end; width: 34px; height: 34px; padding: 0; display: grid; place-items: center;
  background: none; border: 1px solid var(--rule); border-radius: 50%; transition: border-color .15s, background .15s, color .15s;
}
.ch-marca:hover { border-color: var(--ink); background: var(--tono-2); }
/* En bloque: en línea, el hueco de los descendentes lo subía del centro. */
.ch-marca svg { display: block; width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.ch-soplo.creo .ch-marca { border-color: var(--ink); }
/* El visto fijo de la ayuda: relleno, distinto del que pone el jugador. */
.ch-soplo.fiable .ch-marca { background: var(--ink); color: var(--sheet); border-color: var(--ink); cursor: default; }
.ch-soplo.miente .ch-marca { border-color: var(--accent); color: var(--accent); }
/* El soplo que miente, tachado con el subrayado ondulado rojo de la cabecera. */
.ch-soplo.miente .ch-c { color: var(--muted); text-decoration: line-through wavy var(--accent); text-decoration-thickness: 1.5px; }
.ch-leyenda { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 10px 0 0; font-size: 13px; color: var(--muted); }
.ch-leyenda > span { display: inline-flex; align-items: center; gap: 6px; }

/* --- Libreta --- */
.ch-libreta-cab { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.ch-libreta-cab h3 { margin: 0; font: 11px var(--mono); text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.ch-enlace { background: none; border: 0; padding: 4px 0 4px 8px; font-size: 12px; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
.ch-enlace:hover { color: var(--ink); }
.ch-rejilla { display: grid; grid-template-columns: repeat(4, 38px); gap: 2px 3px; }
.ch-pos { text-align: center; font: 11px var(--mono); color: var(--muted); }
.ch-nb { width: 38px; height: 32px; padding: 0; background: none; border: 2px solid transparent; border-radius: 50%; font: 15px var(--mono); }
.ch-nb:hover:not(.fijo) { background: var(--tono-2); }
/* Aquí no va: la cifra atenuada y tachada. Va aquí: rodeada. */
.ch-nb.no { color: var(--muted); opacity: .6; text-decoration: line-through; text-decoration-thickness: 2px; }
.ch-nb.si { border-color: var(--ink); font-weight: 600; }
.ch-nb.fijo { cursor: default; }

/* --- Tu respuesta --- */
.ch-respuesta { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--rule); }
.ch-resp-fila { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 22px; }
.ch-resp-grupo { display: inline-flex; align-items: center; gap: 10px; font: italic 16px var(--serif); }
.ch-casillas { display: inline-flex; padding-left: 2px; }
.ch-r {
  position: relative; width: 44px; height: 48px; margin-left: -2px; padding: 0; display: grid; place-items: center;
  background: var(--cell); border: 2px solid var(--ink); border-radius: 0; font: 600 24px var(--mono); color: var(--ink);
}
button.ch-r { cursor: pointer; }
.ch-r.activa { background: color-mix(in srgb, var(--accent) 12%, var(--cell)); }
.ch-r.activa:empty::after {
  content: ""; position: absolute; left: 22%; right: 22%; bottom: 12%; height: 3px; background: var(--accent);
  animation: cursor 1.1s steps(1) infinite;
}
.ch-r.fija { background: var(--tono-2); cursor: default; }
.ch-miente { margin-left: 0; font: 700 24px var(--serif); color: var(--accent); }
.ch-miente.vacia { color: var(--muted); font-weight: 400; }
.ch-casillas.sacude { animation: shake .4s; }

/* Teclado propio de seis cifras: no se abre el del sistema. */
.ch-teclado { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; max-width: 440px; margin-top: 14px; }
.ch-tecla {
  height: 48px; padding: 0; display: grid; place-items: center; background: var(--cell); border: 1px solid var(--rule);
  border-radius: 2px; font: 500 20px var(--mono); transition: border-color .15s, opacity .15s;
}
.ch-tecla:hover { border-color: var(--ink); }
.ch-tecla:active { background: var(--tono-2); }
/* En bloque: en línea, el hueco de los descendentes lo subía del centro. */
.ch-tecla svg { display: block; width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.ch-tecla.usada { opacity: .4; }
.ch-tecla.fuera { opacity: .3; text-decoration: line-through; text-decoration-thickness: 2px; }
.ch-acciones { margin-top: 16px; align-items: center; }
.ch-acciones .btn { min-height: 44px; }
.ch-acciones .btn-comprobar span { display: inline-flex; }
.ch-respuesta .feedback { margin-top: 10px; font: italic 15px var(--serif); }
.ch-respuesta .feedback.bad { color: var(--accent); }

/* --- Ayudas: la caja de pistas del críptico --- */
.ch-ayudas { margin-top: 26px; }
.ch-ayudas .hint[aria-disabled="true"]:not(:disabled) { cursor: pointer; }
.ch-depura { display: flex; align-items: center; gap: 8px; margin: 18px 0 0; }
.ch-depura .debug-label { margin-right: auto; }

/* --- Resultado --- */
.ch-solution { margin-top: 24px; }
.ch-combinacion { display: flex; padding: 4px 130px 0 2px; }
.ch-fin { width: 50px; height: 56px; font-size: 28px; cursor: default; animation: ch-asienta .5s var(--ease) backwards; }
.ch-fin:nth-child(2) { animation-delay: .1s; } .ch-fin:nth-child(3) { animation-delay: .2s; } .ch-fin:nth-child(4) { animation-delay: .3s; }
@keyframes ch-asienta { from { transform: translateY(-14px); opacity: 0; } }
.ch-perdido { margin: 14px 0 0; font: italic 20px/1.35 var(--serif); }
.ch-resumen { margin: 12px 0 22px; font-size: 15px; }
.ch-comprobacion { margin: 0 0 4px; }
.ch-soplo.final .ch-c.sitio { background: var(--ink); color: var(--sheet); }
.ch-soplo.final .ch-c.desc { background: color-mix(in srgb, var(--ink) 13%, var(--cell)); outline: 1.5px dashed var(--ink); outline-offset: -5px; }
.ch-c-mini { --ch-c: 20px; margin-left: 0; }
.ch-veredicto { justify-self: end; font-size: 13px; color: var(--muted); text-align: right; }
.ch-veredicto.chiv { color: var(--accent); font: italic 15px var(--serif); }
.ch-veredicto.chiv > b { font-weight: 400; }
.ch-en-realidad { color: var(--ink); white-space: nowrap; }
.ch-en-realidad .ch-marcas { margin-left: 4px; }
.ch-soplo.final.miente .ch-c { animation: ch-tacha .7s ease .5s backwards; }
@keyframes ch-tacha { from { text-decoration-color: transparent; } }
.ch-clave { margin: 18px 0 0; padding: 12px 14px; background: var(--bg); border-left: 3px solid var(--accent); font: italic 16px/1.5 var(--serif); }
.ch-clave strong { font-style: normal; }

/* --- Guía: el soplo de ejemplo --- */
.ch-guia-ejemplo { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.ch-guia-ejemplo .ch-cifras { --ch-c: 32px; }
.ch-guia-ejemplo figcaption { flex-basis: 100%; }
.guia-truco { margin: 14px 0 0; padding-top: 12px; border-top: 1px solid var(--rule); font-size: 14px; }

@media (max-width: 680px) {
  .ch-tablero { grid-template-columns: 1fr; }
  .ch-rejilla { grid-template-columns: repeat(4, 44px); gap: 2px 6px; }
  .ch-nb { width: 44px; }
}
@media (max-width: 560px) {
  .ch-combinacion { padding-right: 2px; }
  /* El chivato tachado, con «miente → en realidad…» en su propia línea. */
  .ch-soplo.final .ch-veredicto.chiv { grid-column: 2 / -1; justify-self: start; text-align: left; padding-bottom: 4px; }
  .ch-soplo.final:has(.chiv) { padding-bottom: 6px; }
}
@media (max-width: 440px) {
  .chivato, #guia-chivato { --ch-c: 32px; --ch-m: 10px; }
  .ch-soplo { column-gap: 8px; }
  .ch-entrada { font-size: 18px; margin: 14px 0; }
  .ch-r { width: 40px; height: 46px; font-size: 22px; }
  .ch-resp-grupo { font-size: 15px; }
  .ch-fin { width: 44px; height: 50px; }
}
@media (prefers-reduced-motion: reduce) {
  .chivato *, .chivato *::before, .chivato *::after { animation: none !important; transition: none !important; }
}

/* --- Perfil: el bloque de El Chivato (mismas casillas que el carné) --- */
.carne-chivato { overflow: hidden; }
.carne-chivato .carne-mes-cab { margin: 0; padding: 16px 18px 12px; }
.ch-perfil-cifras { grid-template-columns: repeat(4, 1fr); }
.ch-perfil-cifras .carne-casilla:nth-child(2) { border-right: 1px solid var(--rule); }
.ch-perfil-cifras .carne-casilla:nth-child(-n + 2) { border-bottom: 0; }
.ch-perfil-media { font-size: 12px; }
.ch-perfil-bajo { display: grid; grid-template-columns: 1fr 1fr; gap: 0; border-top: 1px solid var(--rule); }
.ch-perfil-dist, .ch-perfil-ayudas { display: grid; align-content: start; gap: 8px; padding: 16px 18px; }
.ch-perfil-ayudas { border-left: 1px solid var(--rule); }
.ch-perfil-fila { display: grid; grid-template-columns: 7.5em 1fr auto; align-items: center; gap: 10px; font-size: 14px; }
.ch-perfil-ayudas .ch-perfil-fila { grid-template-columns: 1fr auto; }
.ch-perfil-dist .ch-perfil-fila { grid-template-columns: 2em 1fr 2em; }
.ch-perfil-clave { color: var(--muted); font-family: var(--mono); font-size: 12px; }
.ch-perfil-fila b { font: 600 15px var(--mono); text-align: right; }
.ch-perfil-nota { margin: 0; font-size: 13px; color: var(--muted); }
@media (max-width: 640px) {
  .ch-perfil-cifras { grid-template-columns: 1fr 1fr; }
  .ch-perfil-cifras .carne-casilla:nth-child(2) { border-right: 0; }
  .ch-perfil-cifras .carne-casilla:nth-child(-n + 2) { border-bottom: 1px solid var(--rule); }
  .ch-perfil-bajo { grid-template-columns: 1fr; }
  .ch-perfil-ayudas { border-left: 0; border-top: 1px solid var(--rule); }
}

/* --- Manual: el capítulo de El Chivato (js/manual.js) --- */
.manual-chivato { --ch-c: 32px; --ch-m: 12px; }
.manual-texto h3 { margin: 26px 0 8px; font: 700 21px/1.3 var(--serif); }
.manual-chivato .ch-soplos { padding: 0; }
.manual-texto .manual-chivato .ch-soplo { margin: 0; }
.manual-chivato .ch-soplo { min-height: 48px; transition: opacity .25s; }
.manual-chivato .ch-soplo:not(.foco) { opacity: .32; }
.manual-chivato .ch-soplo.miente { opacity: 1; }
.manual-chivato .ch-soplo.miente .ch-c { color: var(--muted); text-decoration: line-through wavy var(--accent); text-decoration-thickness: 1.5px; }
.manual-chivato .ch-veredicto { font-size: 13px; }
.manual-chivato figcaption { min-height: 6.8em; margin-top: 12px; color: var(--ink); }
@media (max-width: 560px) {
  .manual-chivato { --ch-c: 28px; --ch-m: 10px; }
  .manual-chivato .ch-soplo { column-gap: 8px; }
  .manual-chivato .ch-veredicto { grid-column: 2 / -1; justify-self: start; text-align: left; }
  .manual-chivato .ch-veredicto:empty { display: none; }
  .manual-chivato figcaption { min-height: 11em; }
}
