:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --fg: #1d1c1a;
  --muted: #6b6862;
  --border: #dedbd3;
  --accent: #2563a8;
  --hit: #2f7d4f;
  --miss: #b23b2e;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.5 "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
.app { max-width: 820px; margin: 0 auto; padding: 16px; }

.bar { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 24px; margin-bottom: 20px; }
.title { margin: 0; font-size: 28px; line-height: 1.1; font-weight: 650; letter-spacing: -0.01em; }
.controls { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 12px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field-label { font-size: 12px; color: var(--muted); letter-spacing: 0.02em; }
select, .btn {
  min-height: 44px; font: inherit; font-size: 15px; color: var(--fg);
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface); padding: 0 12px;
}
.btn { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; letter-spacing: 0.02em; padding: 0 18px; cursor: pointer; }
.btn:hover { filter: brightness(1.08); }
select:focus-visible, .btn:focus-visible, .key:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.stage { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 32px; align-items: center; margin-bottom: 32px; }
.gallows { width: 100%; max-width: 220px; height: auto; }
.gallows line, .gallows circle { stroke: var(--fg); stroke-width: 6; stroke-linecap: round; fill: none; }
.gallows .body > * { stroke: var(--miss); opacity: 0; transition: opacity 150ms ease-out; }
.gallows .body > .on { opacity: 1; }

.hint { margin: 0 0 12px; color: var(--muted); font-size: 15px; }
.hint strong { color: var(--fg); }
.word { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; min-height: 52px; }
.slot {
  width: 1.4em; height: 1.6em; display: inline-flex; align-items: center; justify-content: center;
  border-bottom: 3px solid var(--fg); font-size: clamp(22px, 6vw, 34px); font-weight: 700; font-family: "Consolas", "Menlo", monospace;
}
.slot.missed { color: var(--miss); }
.lives { margin: 0; font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.message { margin: 12px 0 0; font-size: 15px; min-height: 1.5em; }

.keyboard { display: grid; grid-template-columns: repeat(13, minmax(0, 1fr)); gap: 6px; }
.key {
  min-height: 44px; font: inherit; font-weight: 700; font-size: 16px; letter-spacing: 0.02em;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--fg); cursor: pointer;
}
.key:hover:not(:disabled) { border-color: var(--fg); }
.key:disabled { cursor: default; }
/* color is paired with a mark so a used key never relies on color alone */
.key.hit { background: var(--hit); border-color: var(--hit); color: #fff; }
.key.hit::after { content: " \2713"; font-size: 12px; }
.key.miss { background: transparent; color: var(--muted); text-decoration: line-through; }

@media (max-width: 640px) {
  .stage { grid-template-columns: 1fr; gap: 16px; justify-items: center; text-align: center; }
  .gallows { max-width: 160px; }
  /* 11-letter words must fit one line at 375 px */
  .word { justify-content: center; gap: 4px; }
  .slot { width: 1.2em; font-size: clamp(18px, 5.2vw, 30px); }
  .keyboard { grid-template-columns: repeat(7, minmax(0, 1fr)); }
  .title { font-size: 24px; }
}
@media (prefers-reduced-motion: reduce) { .gallows .body > * { transition: none; } }
