/* ============ Juego: El ahorcado ============ */
.ah-card {
  position: relative;
}

.ah-no {
  font-size: 1rem;
  font-weight: 600;
}

.ah-modes {
  margin-top: 0;
  margin-bottom: 14px;
}

.ah-subbar {
  margin-bottom: 14px;
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.ah-free-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
}

.ah-free-row .field {
  flex: 1 1 200px;
}

.ah-free-row .btn {
  height: 44px;
}

/* Configuración 2 jugadores */
.ah-p2-setup {
  max-width: 480px;
  margin: 8px auto;
  padding: 18px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.ah-p2-setup h2 {
  margin: 0 0 6px;
  font-size: 1.15rem;
}

.ah-p2-setup p {
  margin: 0 0 14px;
  font-size: 0.92rem;
}

.ah-pass-wrap {
  display: flex;
  gap: 8px;
}

.ah-pass-wrap input {
  flex: 1;
  padding: 10px 12px;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
}

.ah-pass-wrap input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 25%, transparent);
}

.ah-pass-toggle {
  padding: 0 12px;
  flex: 0 0 auto;
}

.ah-p2-err {
  color: var(--bad);
  font-size: 0.88rem;
  font-weight: 600;
  margin-top: 8px;
  min-height: 1.3em;
}

/* Cabecera de estado + dibujo SVG */
.ah-top-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.ah-cat-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--primary-50);
  color: var(--primary);
  font-size: 0.88rem;
  font-weight: 700;
}

.ah-lives {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.92rem;
  font-weight: 700;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
}

.ah-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 12px;
}

.ah-figure-wrap {
  width: 176px;
  height: 168px;
  display: grid;
  place-items: center;
  color: var(--text);
}

@media (max-width: 440px) {
  .ah-figure-wrap {
    width: 150px;
    height: 144px;
  }
}

.ah-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.ah-gallows {
  stroke: var(--muted);
  stroke-width: 5;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.ah-rope {
  stroke: var(--warn);
  stroke-width: 3.5;
  stroke-linecap: round;
}

.ah-part {
  stroke: var(--text);
  stroke-width: 4.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  opacity: 0;
  transform-origin: center;
  transition: opacity 0.22s ease, stroke 0.22s ease;
}

.ah-part.is-visible {
  opacity: 1;
}

.ah-svg.is-lost .ah-part.is-visible {
  stroke: var(--bad);
}

.ah-svg.is-won .ah-part.is-visible {
  stroke: var(--ok);
}

.ah-face-dead {
  stroke: var(--bad);
  stroke-width: 2.4;
  stroke-linecap: round;
  fill: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.ah-svg.is-lost .ah-face-dead {
  opacity: 1;
}

/* Pista textual */
.ah-clue-box {
  margin: 6px auto 4px;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 0.9rem;
  color: var(--muted);
  text-align: center;
  max-width: 100%;
}

.ah-clue-box strong {
  color: var(--text);
}

/* Huecos de la palabra */
.ah-word-area {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 12px 20px;
  margin: 16px 0 18px;
  min-height: 50px;
}

.ah-word-group {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 5px;
}

.ah-slot {
  width: clamp(21px, 6.2vw, 34px);
  height: clamp(32px, 8.2vw, 44px);
  display: inline-grid;
  place-items: center;
  border-bottom: 3px solid var(--text);
  font-size: clamp(1.08rem, 4.3vw, 1.5rem);
  font-weight: 800;
  color: var(--text);
  text-transform: uppercase;
  user-select: none;
  transition: transform 0.14s, color 0.15s, border-color 0.15s;
}

.ah-slot.is-revealed {
  border-bottom-color: var(--primary);
  animation: ahPop 0.18s ease-out;
}

.ah-slot.is-missed {
  color: var(--bad);
  border-bottom-color: var(--bad);
}

.ah-slot.is-punct {
  width: auto;
  padding: 0 3px;
  border-bottom-color: transparent;
  color: var(--muted);
}

@keyframes ahPop {
  50% {
    transform: translateY(-4px) scale(1.08);
  }
}

/* Mensaje en vivo */
.ah-status {
  min-height: 24px;
  text-align: center;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 10px;
}

.ah-status.is-ok {
  color: var(--ok);
}

.ah-status.is-bad {
  color: var(--bad);
}

/* Panel de fin de partida */
.ah-end-banner {
  width: 100%;
  max-width: 520px;
  margin: 0 auto 16px;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--primary-50);
  border: 1px solid color-mix(in srgb, var(--primary) 35%, transparent);
  text-align: center;
}

.ah-end-banner.is-lost {
  background: color-mix(in srgb, var(--bad) 10%, var(--surface));
  border-color: color-mix(in srgb, var(--bad) 35%, var(--border));
}

.ah-end-banner h2 {
  margin: 0 0 6px;
  font-size: 1.25rem;
}

.ah-end-banner p {
  margin: 4px 0;
}

.ah-end-banner .btn-row {
  justify-content: center;
}

/* Teclado español en pantalla */
.ah-keyboard {
  width: 100%;
  max-width: 540px;
  margin: 0 auto;
  display: grid;
  gap: 6px;
  user-select: none;
}

.ah-krow {
  display: flex;
  justify-content: center;
  gap: 5px;
}

.ah-key {
  flex: 1 1 0;
  max-width: 46px;
  height: 46px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.12s, color 0.12s, transform 0.06s, opacity 0.15s;
}

.ah-key:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
}

.ah-key:active:not(:disabled) {
  transform: scale(0.95);
}

.ah-key.is-hit {
  background: var(--ok);
  border-color: var(--ok);
  color: #fff;
  cursor: default;
}

.ah-key.is-miss {
  background: color-mix(in srgb, var(--bad) 14%, var(--bg));
  border-color: color-mix(in srgb, var(--bad) 30%, var(--border));
  color: var(--muted);
  text-decoration: line-through;
  opacity: 0.62;
  cursor: default;
}

.ah-key:disabled {
  cursor: default;
}

/* Acciones inferiores */
.ah-actions {
  justify-content: center;
  margin-top: 16px;
}

/* Diálogo de estadísticas */
.ah-dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 24px;
  width: min(440px, calc(100% - 32px));
  box-shadow: var(--shadow);
}

.ah-dialog::backdrop {
  background: rgba(0, 0, 0, 0.5);
}

@media (max-width: 440px) {
  .ah-card {
    padding: 12px;
  }
  .ah-krow {
    gap: 4px;
  }
  .ah-key {
    height: 43px;
    font-size: 0.94rem;
    border-radius: 6px;
  }
  .ah-word-group {
    gap: 3px;
  }
  .ah-slot {
    width: clamp(18px, 5.5vw, 28px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .ah-slot.is-revealed {
    animation: none !important;
  }
}
