/* Hangman — page-specific styles */

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.page-head h1 {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 700;
  font-size: clamp(28px, 4.4vw, 40px);
  letter-spacing: -0.02em;
  margin: 0;
  line-height: 1.05;
}
.page-head .sub {
  color: var(--ink-soft);
  margin: 6px 0 0;
  font-size: 14px;
  min-height: 1.4em;
}
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.play {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}

.hangman-grid {
  display: grid;
  grid-template-columns: minmax(220px, 280px) 1fr;
  gap: 28px;
  align-items: start;
}

@media (max-width: 720px) {
  .hangman-grid {
    grid-template-columns: 1fr;
    gap: 22px;
  }
}

.gallows-wrap {
  display: flex;
  justify-content: center;
  padding: 8px;
  background:
    repeating-linear-gradient(
      to bottom,
      transparent 0,
      transparent 27px,
      rgba(31, 58, 95, 0.06) 27px,
      rgba(31, 58, 95, 0.06) 28px
    ),
    var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.gallows {
  width: 100%;
  max-width: 240px;
  height: auto;
  display: block;
}

.gallows .part {
  stroke: var(--accent);
  stroke-width: 4;
  stroke-linecap: round;
  fill: none;
  opacity: 0;
  transition: opacity 260ms ease;
}
.gallows #part-hand-l,
.gallows #part-hand-r {
  fill: var(--accent);
  stroke: none;
}
/* The gallows structure is always shown — only the person's body appears
   as the player accumulates wrong guesses. */
.gallows #part-base,
.gallows #part-post,
.gallows #part-beam,
.gallows #part-noose {
  opacity: 0.85;
  stroke-width: 5;
}
.gallows .part.is-shown {
  opacity: 1;
}

.side {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
}

.word-display {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 12px;
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 700;
  font-size: clamp(26px, 5vw, 38px);
  letter-spacing: 0.04em;
  line-height: 1;
  color: var(--ink);
  min-height: 1.4em;
}

.word-display .slot {
  display: inline-flex;
  align-items: flex-end;
  justify-content: center;
  min-width: 0.7em;
  padding: 4px 2px 6px;
  border-bottom: 3px solid var(--line-strong);
  transition: color 200ms ease;
}
.word-display .slot.revealed {
  color: var(--accent);
  animation: hg-letter-pop 260ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes hg-letter-pop {
  0%   { transform: scale(0.4) translateY(6px); opacity: 0; }
  60%  { transform: scale(1.15) translateY(0); opacity: 1; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}

/* Gallows shake on a wrong guess */
@keyframes hg-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}
.gallows-wrap.is-shake { animation: hg-shake 260ms ease; }

/* New body-part draw — pen-in stroke effect */
@keyframes hg-part-in {
  from { opacity: 0; transform: scale(0.7); }
  to   { opacity: 1; transform: scale(1); }
}
.gallows .part.is-shown {
  animation: hg-part-in 380ms cubic-bezier(0.34, 1.56, 0.64, 1);
  transform-origin: center;
  transform-box: fill-box;
}

@media (prefers-reduced-motion: reduce) {
  .word-display .slot.revealed, .gallows-wrap.is-shake, .gallows .part.is-shown { animation: none; }
}
.word-display .slot.space {
  border-bottom: 0;
  width: 0.4em;
}
.word-display .slot.miss {
  color: var(--danger);
  border-bottom-color: var(--danger);
}

.meta-row {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
}
.meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1 1 140px;
}
.meta-label {
  font: 600 11px 'Inter', sans-serif;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.meta-value {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 700;
  font-size: 22px;
  color: var(--ink);
}
.meta-value.wrong {
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.18em;
  color: var(--danger);
  text-transform: uppercase;
  word-break: break-all;
}

.keyboard {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 6px;
}
@media (max-width: 480px) {
  .keyboard { grid-template-columns: repeat(7, minmax(0, 1fr)); }
}

.key {
  appearance: none;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font: 600 14px 'Inter', sans-serif;
  padding: 10px 0;
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease, border-color 140ms ease, transform 100ms ease;
}
.key:hover:not(:disabled) {
  background: var(--accent-soft);
}
.key:active:not(:disabled) { transform: translateY(1px); }
.key:disabled {
  cursor: default;
  opacity: 0.45;
  background: var(--bg-2);
  color: var(--muted);
}
.key.is-hit {
  background: var(--accent);
  color: var(--paper);
  border-color: var(--accent);
  opacity: 0.85;
}
.key.is-miss {
  background: transparent;
  color: var(--danger);
  border-color: rgba(192, 57, 43, 0.4);
  opacity: 0.7;
}

/* Win / lose overlay */
.win-overlay {
  position: fixed; inset: 0; background: rgba(28, 42, 58, 0.55);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.win-overlay[hidden] { display: none; }
.win-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px 30px;
  text-align: center;
  box-shadow: var(--shadow-lift);
  max-width: 360px;
}
.win-card h2 {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 700;
  font-size: 28px;
  margin: 0 0 8px;
  letter-spacing: -0.01em;
}
.win-card p {
  color: var(--ink-soft);
  margin: 0 0 18px;
  font-size: 15px;
  line-height: 1.5;
}
.win-card p strong {
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.04em;
}

.aside-info { margin-top: 22px; }
.aside-info details {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 16px;
  box-shadow: var(--shadow);
}
.aside-info summary {
  cursor: pointer;
  font: 700 14px 'Inter', sans-serif;
  color: var(--ink);
}
.aside-info .help-body {
  margin-top: 10px;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.55;
}
.aside-info .help-body p { margin: 0 0 8px; }
.aside-info .help-body ul { margin: 0; padding-left: 18px; }
.aside-info .help-body li { margin: 4px 0; }
