/* hangman (public/arcade/hangman.js). Arcade tokens come from arcade.css. Everything is scoped to its stage.
   Black CRT, a pixel gallows in indigo with a warm white figure, the word in big Jersey 10 letters,
   a QWERTY grid of dark square keys, and a little monitor (top right) of the opponent working on your word. */
.ag-stage[data-kind="hangman"] .hm {
  --hm-red: #3340a0; --hm-deep: #222b73; --hm-pink: #b3bcff; --hm-white: #f6f7ff; --hm-dim: #2f3466; --hm-line: #262a52;
  --hm-mute: #9ea3c6; --hm-key: #22264a; --hm-key-edge: #111330;
  position: absolute; inset: 0; display: flex; flex-direction: column; color: var(--hm-white);
  font-family: var(--ac-pixel, "Jersey 10"); container: hm / size;
}
.ag-stage[data-kind="hangman"] .hm [hidden] { display: none !important; }
.ag-stage[data-kind="hangman"] .hm p { margin: 0; }

/* ---------- letters on underscores ---------- */
.ag-stage[data-kind="hangman"] .hm-word { display: flex; justify-content: center; gap: .12em; font-size: var(--fs); line-height: 1; }
.ag-stage[data-kind="hangman"] .hm-l { width: .72em; height: 1.04em; display: grid; justify-items: center; align-items: end;
  border-bottom: .09em solid var(--hm-dim); }
.ag-stage[data-kind="hangman"] .hm-l b { display: block; font-weight: 400; line-height: .9; }
.ag-stage[data-kind="hangman"] .hm-l.rev b { color: var(--hm-pink); }
.ag-stage[data-kind="hangman"] .hm-l.pop b { animation: hm-pop .36s steps(3, end); }
@keyframes hm-pop { from { transform: translateY(-.25em) scale(1.6); color: var(--pc); } }
.ag-stage[data-kind="hangman"] .hm-l b { transform-origin: 50% 80%; }

/* ---------- picking a word ---------- */
.ag-stage[data-kind="hangman"] .hm-set { flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column; align-items: center;
  padding: 16px 14px; text-align: center; }
.ag-stage[data-kind="hangman"] .hm-set::before, .ag-stage[data-kind="hangman"] .hm-set::after { content: ""; flex: 1 1 0; } /* centered, but scrolls from the top when the phone keyboard squeezes it */
.ag-stage[data-kind="hangman"] .hm-pick, .ag-stage[data-kind="hangman"] .hm-mine { width: min(100%, 380px); display: flex; flex-direction: column; align-items: center; }
.ag-stage[data-kind="hangman"] .hm-h { margin: 0; font: 400 42px/1 var(--ac-pixel); letter-spacing: .02em; color: var(--hm-white); overflow-wrap: anywhere; }
.ag-stage[data-kind="hangman"] .hm-sub { margin-top: 6px; font: 400 16px/1.35 var(--font); color: var(--hm-mute); }
.ag-stage[data-kind="hangman"] .hm-form { display: flex; gap: 10px; width: 100%; margin-top: 18px; }
.ag-stage[data-kind="hangman"] .hm-in { flex: 1; min-width: 0; height: 58px; padding: 0 14px; border: 2px solid var(--hm-dim); border-radius: 10px;
  background: #000; color: var(--hm-white); caret-color: var(--hm-red); font: 400 32px/1 var(--ac-pixel); letter-spacing: .14em; text-transform: uppercase;
  -webkit-appearance: none; appearance: none; }
.ag-stage[data-kind="hangman"] .hm-in::placeholder { color: var(--hm-dim); letter-spacing: .04em; text-transform: none; opacity: 1; }
.ag-stage[data-kind="hangman"] .hm-in:focus { outline: none; border-color: var(--hm-red); }
.ag-stage[data-kind="hangman"] .hm-rand { margin-top: 12px; }
.ag-stage[data-kind="hangman"] .hm-err { min-height: 1.35em; margin-top: 10px; font: 400 16px/1.35 var(--font); color: var(--hm-pink); }
.ag-stage[data-kind="hangman"] .hm-note { margin-top: 6px; font: 400 22px/1.1 var(--ac-pixel); color: var(--oc); }
.ag-stage[data-kind="hangman"] .hm-lab { font: 400 22px/1 var(--ac-pixel); color: var(--hm-mute); }
.ag-stage[data-kind="hangman"] .hm-mineword { --fs: min(58px, calc((100cqw - 40px) / (var(--n) * .86))); margin: 14px 0 18px; }
.ag-stage[data-kind="hangman"] .hm-mineword .hm-l { border-color: var(--pc); }
.ag-stage[data-kind="hangman"] .hm-wait { font: 400 24px/1.1 var(--ac-pixel); color: var(--hm-white); }
.ag-stage[data-kind="hangman"] .hm-cur { display: inline-block; width: .42em; height: .8em; margin-left: .2em; vertical-align: -.05em; background: var(--hm-red);
  animation: hm-cur 1.06s steps(1) infinite; }
@keyframes hm-cur { 50% { opacity: 0; } }

/* ---------- guessing ---------- */
.ag-stage[data-kind="hangman"] .hm-play { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.ag-stage[data-kind="hangman"] .hm-top { flex: 1 1 0; min-height: 80px; display: flex; gap: 8px; padding: 10px 10px 0; }
.ag-stage[data-kind="hangman"] .hm-gal { position: relative; flex: 1; min-width: 0; }
.ag-stage[data-kind="hangman"] .hm-gal svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.ag-stage[data-kind="hangman"] .hm-post { fill: var(--hm-red); }
.ag-stage[data-kind="hangman"] .hm-fig, .ag-stage[data-kind="hangman"] .hm-eye { fill: var(--hm-white); }
.ag-stage[data-kind="hangman"] .hm-new { animation: hm-blink .48s steps(1); }
@keyframes hm-blink { 0% { opacity: 0; } 25% { opacity: 1; } 50% { opacity: 0; } 75% { opacity: 1; } }
.ag-stage[data-kind="hangman"] .hm-play.hm-in-anim .hm-top { animation: hm-blink .3s steps(1); }

/* the opponent's little monitor: them on your word */
.ag-stage[data-kind="hangman"] .hm-pip { flex: none; align-self: flex-start; min-width: 104px; max-width: 44cqw; padding: 6px 8px 7px; border: 2px solid var(--hm-line);
  border-radius: 8px; background: #000; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.ag-stage[data-kind="hangman"] .hm-pip-h { display: flex; align-items: center; gap: 6px; max-width: 100%; }
.ag-stage[data-kind="hangman"] .hm-pip-face { flex: none; width: 24px; height: 24px; }
.ag-stage[data-kind="hangman"] .hm-pip-face .mface, .ag-stage[data-kind="hangman"] .hm-pip-face img, .ag-stage[data-kind="hangman"] .hm-pip-face svg { display: block; width: 100%; height: 100%; }
.ag-stage[data-kind="hangman"] .hm-pip-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 20px; line-height: 1; color: var(--oc); }
.ag-stage[data-kind="hangman"] .hm-pip-gal { width: 100%; height: 54px; }
.ag-stage[data-kind="hangman"] .hm-pip-gal svg { display: block; width: 100%; height: 100%; }
.ag-stage[data-kind="hangman"] .hm-pip-word { --fs: min(18px, calc((44cqw - 16px) / (var(--n) * .84))); gap: .1em; margin-top: 2px; }
.ag-stage[data-kind="hangman"] .hm-pip-word .hm-l { border-bottom-width: 2px; }
.ag-stage[data-kind="hangman"] .hm-pip-word .hm-l:not(.rev) b { color: var(--oc); }
.ag-stage[data-kind="hangman"] .hm-pip-miss { font-size: 18px; line-height: 1; color: var(--hm-mute); }
.ag-stage[data-kind="hangman"] .hm-pip-miss.ok { color: var(--oc); }
.ag-stage[data-kind="hangman"] .hm-pip-miss.dead { color: var(--hm-pink); }

.ag-stage[data-kind="hangman"] .hm-puzzle { --fs: min(60px, calc((100cqw - 24px) / (var(--n) * .86))); flex: none; padding: 12px 12px 2px; }
.ag-stage[data-kind="hangman"] .hm-puzzle.solved .hm-l { border-color: var(--pc); }

.ag-stage[data-kind="hangman"] .hm-info { position: relative; flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 32px; padding: 6px 14px 4px; font-size: 20px; line-height: 1; color: var(--hm-mute); }
.ag-stage[data-kind="hangman"] .hm-pips { flex: none; display: flex; align-items: center; gap: 4px; }
.ag-stage[data-kind="hangman"] .hm-pips i { width: 12px; height: 12px; border: 2px solid var(--hm-dim); }
.ag-stage[data-kind="hangman"] .hm-pips i.on { background: var(--hm-red); border-color: var(--hm-red); }
.ag-stage[data-kind="hangman"] .hm-pips b { margin-left: 6px; font-weight: 400; }
.ag-stage[data-kind="hangman"] .hm-tried { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ag-stage[data-kind="hangman"] .hm-tried s { color: var(--hm-pink); text-decoration-thickness: 2px; }
.ag-stage[data-kind="hangman"] .hm-flash { position: absolute; inset: 0; display: grid; place-items: center; padding: 0 12px; background: #000;
  color: var(--hm-pink); font-size: 22px; text-align: center; }
.ag-stage[data-kind="hangman"] .hm-flash:empty { display: none; }

/* keyboard: three QWERTY rows of dark square keys, sized to fit 320px */
.ag-stage[data-kind="hangman"] .hm-bottom { position: relative; flex: none; padding: 4px 6px 12px; }
.ag-stage[data-kind="hangman"] .hm-kb { --kw: min(46px, calc((100cqw - 57px) / 10)); --kh: 46px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.ag-stage[data-kind="hangman"] .hm-kb.gone, .ag-stage[data-kind="hangman"] .hm-kb.under { visibility: hidden; }
.ag-stage[data-kind="hangman"] .hm-row { display: flex; justify-content: center; gap: 5px; }
.ag-stage[data-kind="hangman"] .hm-key { position: relative; flex: none; width: var(--kw); height: var(--kh); padding: 0; border: 0; border-radius: 6px;
  background: var(--hm-key); color: var(--hm-white); font: 400 26px/1 var(--ac-pixel); box-shadow: inset 0 -4px 0 var(--hm-key-edge);
  touch-action: manipulation; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.ag-stage[data-kind="hangman"] .hm-key:active:not(:disabled) { transform: translateY(2px); box-shadow: inset 0 -2px 0 var(--hm-key-edge); }
.ag-stage[data-kind="hangman"] .hm-key:disabled { cursor: default; }
.ag-stage[data-kind="hangman"] .hm-key.pend { opacity: .45; }
.ag-stage[data-kind="hangman"] .hm-key.hit { background: #000; color: var(--pc); box-shadow: inset 0 0 0 2px var(--pc); }
.ag-stage[data-kind="hangman"] .hm-key.miss { background: #120608; color: var(--hm-dim); box-shadow: none; }
.ag-stage[data-kind="hangman"] .hm-key.miss::after { content: ""; position: absolute; left: 16%; right: 16%; top: calc(50% - 1px); height: 2px;
  background: var(--hm-red); transform: rotate(-38deg); }
.ag-stage[data-kind="hangman"] .hm-solvekey { width: calc(var(--kw) * 2 + 5px); background: var(--hm-red); color: #fff; font-size: 22px; box-shadow: inset 0 -4px 0 var(--hm-deep); }
.ag-stage[data-kind="hangman"] .hm-solvekey:active:not(:disabled) { box-shadow: inset 0 -2px 0 var(--hm-deep); }
.ag-stage[data-kind="hangman"] .hm-solvekey:disabled { opacity: .4; }

/* guessing the whole word: a sheet over the keyboard */
.ag-stage[data-kind="hangman"] .hm-sheet { position: absolute; inset: 0 8px 12px; display: flex; flex-direction: column; justify-content: center; gap: 8px; background: #000; }
.ag-stage[data-kind="hangman"] .hm-sheet-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; font: 400 15px/1.3 var(--font); color: var(--hm-mute); }
.ag-stage[data-kind="hangman"] .hm-x { flex: none; min-height: 40px; padding: 0 14px; border: 2px solid var(--hm-line); border-radius: 10px; background: transparent;
  color: var(--hm-white); font: 700 15px/1 var(--font); cursor: pointer; }
.ag-stage[data-kind="hangman"] .hm-x:active { background: var(--hm-line); }
.ag-stage[data-kind="hangman"] .hm-sheet-r { display: flex; gap: 10px; }
.ag-stage[data-kind="hangman"] .hm-serr { min-height: 1.3em; margin: 0; }

/* done, waiting for the other player */
.ag-stage[data-kind="hangman"] .hm-done { position: absolute; inset: 0; display: grid; place-content: center; gap: 6px; padding: 0 16px; text-align: center; }
.ag-stage[data-kind="hangman"] .hm-big { font-size: 56px; line-height: .9; color: var(--pc); }
.ag-stage[data-kind="hangman"] .hm-big.dead { color: var(--hm-pink); }
.ag-stage[data-kind="hangman"] .hm-small { font: 400 16px/1.35 var(--font); color: var(--hm-mute); }

/* short screens (small phones, landscape) */
@container hm (max-height: 470px) {
  .ag-stage[data-kind="hangman"] .hm-kb { --kh: 40px; gap: 5px; }
  .ag-stage[data-kind="hangman"] .hm-puzzle { --fs: min(46px, calc((100cqw - 24px) / (var(--n) * .86))); padding-top: 8px; }
  .ag-stage[data-kind="hangman"] .hm-pip-gal { height: 36px; }
  .ag-stage[data-kind="hangman"] .hm-bottom { padding-bottom: 8px; }
  .ag-stage[data-kind="hangman"] .hm-h { font-size: 34px; }
  .ag-stage[data-kind="hangman"] .hm-form { margin-top: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .ag-stage[data-kind="hangman"] .hm-l.pop b, .ag-stage[data-kind="hangman"] .hm-new,
  .ag-stage[data-kind="hangman"] .hm-play.hm-in-anim .hm-top, .ag-stage[data-kind="hangman"] .hm-cur { animation: none; }
}
