/* ============================================================
   Ahorcado — panel de tinta (oscuro en los dos temas, como la
   Olimpiada), grabado en trazo crema y oro viejo, letras en la serif
   del sitio y teclado de papel envejecido. Nada caricaturesco: la
   figura no tiene rostro y el dibujo completo está siempre insinuado
   a lápiz; cada error lo entinta con un trazo que se dibuja solo.
   ============================================================ */
.ah {
  --ah-bg: #17130F;
  --ah-bg-2: #221C16;
  --ah-ink: #EFE6D4;          /* tinta clara */
  --ah-ink-2: rgba(239, 230, 212, .68);
  --ah-ink-3: rgba(239, 230, 212, .42);
  --ah-gold: #CDAE6E;
  --ah-gold-2: rgba(205, 174, 110, .35);
  --ah-miss: #B9675A;         /* error: rojo óxido, sobrio */
  --ah-line: rgba(239, 230, 212, .14);
  position: relative; isolation: isolate;
  width: 100%;
  display: flex; flex-direction: column; gap: clamp(14px, 2.4vw, 22px);
  padding: clamp(16px, 3vw, 32px);
  border-radius: var(--r-xl);
  color: var(--ah-ink);
  background:
    radial-gradient(80% 90% at 85% 0%, rgba(205, 174, 110, .12) 0%, transparent 60%),
    linear-gradient(160deg, var(--ah-bg-2) 0%, var(--ah-bg) 70%);
  box-shadow: var(--shadow-md), inset 0 0 0 1px rgba(205, 174, 110, .18);
  overflow: hidden;
}
/* grano de papel muy suave */
.ah::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none; opacity: .5;
  background-image: repeating-linear-gradient(115deg, rgba(255,255,255,.012) 0 2px, transparent 2px 5px);
}
.ah-host { display: block; padding: 2px 0 8px; }

/* ---------- cabecera: categoría y errores ---------- */
.ah-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 10px 20px;
  padding-bottom: 12px; border-bottom: 1px solid var(--ah-line); }
.ah-cat { margin: 0; display: flex; flex-direction: column; gap: 2px; }
.ah-cat-l, .ah-lives-l, .ah-used-l, .ah-clue-l {
  font-family: var(--font-ui); font-size: .7rem; font-weight: 600; letter-spacing: .16em; text-transform: uppercase;
  color: var(--ah-gold);
}
.ah-cat-v { font-family: var(--font-display); font-size: clamp(1.2rem, 2.4vw, 1.5rem); font-weight: 500; letter-spacing: .01em; }
.ah-lives { display: grid; grid-template-columns: auto auto; align-items: center; gap: 4px 10px; justify-items: end; }
.ah-lives-l { grid-column: 1 / -1; }
.ah-lives-n { font-family: var(--font-num); font-size: 1.35rem; font-weight: 500; line-height: 1; }
.ah-pips { display: inline-flex; gap: 5px; }
.ah-pip { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid var(--ah-gold); background: var(--ah-gold);
  transition: background-color .3s ease, border-color .3s ease; }
.ah-pip.is-spent { background: transparent; border-color: var(--ah-ink-3); }

/* ---------- grabado + palabra ---------- */
.ah-stagebox { display: grid; grid-template-columns: minmax(150px, 230px) minmax(0, 1fr); gap: clamp(16px, 3vw, 36px); align-items: center; }
.ah-artbox { position: relative; }
.ah-art { display: block; width: 100%; height: auto; max-height: 300px; overflow: visible; }
.ah-art path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.ah-ghost path { stroke: var(--ah-ink); stroke-opacity: .09; stroke-width: 1.2; stroke-dasharray: 2 3.5; }
.ah-stage .ah-ink { stroke: var(--ah-ink); stroke-width: 2.4; stroke-dasharray: 1; stroke-dashoffset: 1; opacity: 0; }
.ah-stage .ah-hatch { stroke: var(--ah-gold); stroke-width: .9; stroke-opacity: 0; transition: stroke-opacity .6s ease .35s; }
.ah-stage.is-on .ah-ink { opacity: 1; animation: ah-draw .7s cubic-bezier(.4, 0, .2, 1) forwards; }
.ah-stage.is-on .ah-hatch { stroke-opacity: .55; }
.ah-stage.is-on.no-anim .ah-ink { animation: none; stroke-dashoffset: 0; }
.ah-stage.is-on.no-anim .ah-hatch { transition: none; }
@keyframes ah-draw { to { stroke-dashoffset: 0; } }
/* la estructura es madera: un poco más gruesa y en oro viejo */
.ah-stage-0 .ah-ink { stroke: var(--ah-gold); stroke-width: 2; }

.ah-side { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.ah-clue { margin: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px;
  font-family: var(--font-display); font-style: italic; font-size: 1.05rem; color: var(--ah-ink-2);
  animation: ah-fade .4s ease both; }
.ah-clue-l { font-style: normal; }

.ah-word { --slot: clamp(26px, 5.2vw, 46px); display: flex; flex-wrap: wrap; gap: clamp(5px, 1vw, 9px); }
.ah-slot {
  position: relative; width: var(--slot); height: calc(var(--slot) * 1.25);
  display: grid; place-items: end center; padding-bottom: 6px; box-sizing: border-box;
  font-family: var(--font-display); font-size: calc(var(--slot) * .82); font-weight: 500; line-height: 1;
  color: var(--ah-ink);
}
.ah-slot::after { content: ""; position: absolute; left: 8%; right: 8%; bottom: 0; height: 2px; border-radius: 1px;
  background: var(--ah-ink-3); transition: background-color .3s ease; }
.ah-slot.is-filled::after { background: var(--ah-gold); }
.ah-slot.is-new .ah-ch { animation: ah-in .45s cubic-bezier(.2, .7, .2, 1) both; }
.ah-slot.is-missed { color: var(--ah-miss); }
.ah-slot.is-missed .ah-ch { animation: ah-fade .5s ease both; }
@keyframes ah-in { from { opacity: 0; transform: translateY(5px); filter: blur(2px); } to { opacity: 1; transform: none; filter: none; } }
@keyframes ah-fade { from { opacity: 0; } to { opacity: 1; } }
.ah-word.is-nope { animation: ah-nudge .32s ease-in-out; }
@keyframes ah-nudge { 30% { transform: translateX(-3px); } 70% { transform: translateX(3px); } }
.ah-count { margin: -6px 0 0; font-family: var(--font-num); font-size: .75rem; color: var(--ah-ink-3); }

.ah-used { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 12px; min-height: 1.6em; }
.ah-used-v { display: inline-flex; flex-wrap: wrap; gap: 6px; font-family: var(--font-num); font-size: .95rem; }
.ah-used-ch.is-hit { color: var(--ah-ink); }
.ah-used-ch.is-miss { color: var(--ah-miss); text-decoration: line-through; text-decoration-thickness: 1.5px; }
.ah-used-none { color: var(--ah-ink-3); font-family: var(--font-ui); font-size: .85rem; }

.ah-result { margin: 0; padding: 10px 14px; border-radius: var(--r-md); font-size: 1rem; line-height: 1.4;
  border: 1px solid var(--ah-line); background: rgba(0, 0, 0, .18); animation: ah-fade .5s ease both; }
.ah-result.is-win { font-family: var(--font-display); font-size: 1.25rem; color: var(--ah-gold); }
.ah-result.is-loss strong { font-family: var(--font-display); font-weight: 600; letter-spacing: .04em; color: var(--ah-ink); }

/* ---------- teclado de papel ---------- */
.ah-kb { display: flex; flex-direction: column; align-items: center; gap: 7px; padding-top: 4px; }
.ah-kb-row { --kg: 6px; display: flex; justify-content: center; gap: var(--kg); width: 100%; max-width: 520px; }
.ah-key {
  /* todas las teclas miden lo mismo: una décima parte de la fila */
  flex: 0 0 calc((100% - 9 * var(--kg)) / 10); min-width: 0; height: 50px; padding: 0;
  border: 1px solid rgba(205, 174, 110, .28); border-radius: var(--r-sm);
  background: linear-gradient(180deg, #EDE3CF 0%, #DCCFB4 100%);
  color: #2A2017; font-family: var(--font-display); font-size: 1.2rem; font-weight: 600;
  box-shadow: 0 1px 0 rgba(0, 0, 0, .35);
  cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  transition: background-color .2s ease, opacity .2s ease, transform .08s ease;
}
.ah-key:hover:not(:disabled) { background: linear-gradient(180deg, #F5ECDA 0%, #E3D7BE 100%); }
.ah-key:active:not(:disabled) { transform: translateY(1px); box-shadow: none; }
.ah-key:focus-visible { outline: 2px solid var(--ah-gold); outline-offset: 2px; }
.ah-key.is-pending { opacity: .7; }
.ah-key:disabled { cursor: default; }
.ah-key[data-state="hit"] { background: var(--ah-gold); border-color: transparent; color: #241A10; opacity: .95; }
.ah-key[data-state="miss"] {
  background: transparent; border-color: var(--ah-line); color: var(--ah-ink-3); box-shadow: none;
  text-decoration: line-through; text-decoration-color: var(--ah-miss); text-decoration-thickness: 2px;
}
.ah.is-done .ah-key:not([data-state]) { opacity: .45; }

.ah-help-note { margin: 10px 0 0; font-size: var(--t-sm); color: var(--muted); }

@media (max-width: 720px) {
  .ah { border-radius: var(--r-lg); }
  .ah-stagebox { grid-template-columns: minmax(96px, 34%) minmax(0, 1fr); gap: 14px; }
  .ah-art { max-height: 190px; }
  .ah-word { --slot: clamp(20px, 6.4vw, 34px); gap: 4px; }
  .ah-key { height: 46px; font-size: 1.05rem; }
  .ah-kb-row { --kg: 4px; }
}
@media (max-width: 420px) {
  .ah { padding: 14px 12px; }
  .ah-stagebox { grid-template-columns: minmax(0, 1fr); }
  .ah-artbox { max-width: 150px; margin: 0 auto; }
  .ah-art { max-height: 160px; }
  .ah-word { justify-content: center; }
  .ah-count, .ah-clue { text-align: center; justify-content: center; }
  .ah-used { justify-content: center; }
  .ah-kb-row { --kg: 3px; }
  .ah-key { height: 44px; border-radius: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  .ah-stage.is-on .ah-ink { animation: none; stroke-dashoffset: 0; }
  .ah-slot.is-new .ah-ch, .ah-word.is-nope, .ah-clue, .ah-result, .ah-slot.is-missed .ah-ch { animation: none; }
}
