/* Hangman (static/js/games/hangman.js): the scene on a canvas (a landscape, the gallows, the figure on its rope), the
   clocks over it, the word in tiles under it and the letters' keyboard at the bottom — one screen, nothing scrolls. */

/* ---------- the page: the table on one screen, the whole width ---------- */
html:has(body.game-hangman[data-page="table"]) { overflow: hidden; }
body.game-hangman[data-page="table"] .site-foot { display: none; }
body.game-hangman[data-page="table"] .chat-fab { display: none !important; }
body.game-hangman[data-page="table"] #table.page { max-width: none; height: calc(100dvh - var(--top)); box-sizing: border-box; overflow: hidden; padding: 10px 14px; }
body.game-fs .hm-wrap { height: 100%; }
.hm-wrap { position: relative; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto auto; gap: 8px; height: 100%; width: 100%;
  max-width: 1180px; margin: 0 auto; }

/* ---------- the bar above ---------- */
.hm-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-width: 0; padding: 6px 8px 6px 14px; border-radius: 16px;
  background: linear-gradient(160deg, rgba(24,24,34,.94), rgba(10,10,16,.96)); border: 1px solid rgba(255,255,255,.1); box-shadow: 0 10px 22px -14px rgba(0,0,0,.9); }
.hm-meta { display: flex; align-items: center; gap: 10px; min-width: 0; }
.hm-info { min-width: 0; font-size: 12.5px; font-weight: 800; color: rgba(255,255,255,.78); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hm-chips { flex: none; display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px 0 6px; border-radius: 13px; font: 800 12.5px/1 'Inter', system-ui, sans-serif;
  color: #ffe3a3; background: rgba(242,190,90,.12); border: 1px solid rgba(242,190,90,.3); font-variant-numeric: tabular-nums; }
.hm-free { flex: none; font-size: 11px; font-weight: 700; color: rgba(255,255,255,.55); white-space: nowrap; }
.hm-free.ok { color: #8fe3b4; }
.hm-free.hidden { display: none; }
.hm-tools { flex: none; display: flex; align-items: center; gap: 6px; }
.hm-tool { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; padding: 0; border-radius: 12px; cursor: pointer;
  color: #f1eef8; background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.14); }
.hm-tool:hover { border-color: rgba(242,196,109,.6); }
.hm-tool svg.i { width: 17px; height: 17px; }
.hm-tool.hidden { display: none; }
.hm-tool.hm-leave:hover { border-color: rgba(255,90,78,.6); color: #ffb3ab; }
.hm-mute .tv-snd-off { display: none; }
body.tv-muted .hm-mute .tv-snd-off { display: inline; } body.tv-muted .hm-mute .tv-snd-on { display: none; }

/* ---------- the scene ---------- */
.hm-stage { position: relative; min-height: 0; border-radius: 22px; overflow: hidden; isolation: isolate; background: #0a0a10;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.1), 0 26px 50px -18px rgba(0,0,0,.95); }
.hm-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; user-select: none; -webkit-user-select: none; }
.hm-stage canvas.can-grab { cursor: grab; }
.hm-stage canvas.grabbing { cursor: grabbing; }
.hm-stage::after { content: ''; position: absolute; inset: 0; z-index: 3; pointer-events: none; border-radius: inherit; opacity: 0; transition: opacity .8s ease;
  background: radial-gradient(ellipse 80% 75% at 50% 45%, transparent 40%, rgba(150,10,25,.55)); }
.hm-stage.lost::after { opacity: 1; }
.hm-stage.saved::after { background: radial-gradient(ellipse 80% 75% at 50% 45%, transparent 45%, rgba(242,190,90,.35)); animation: hmSaved 1.8s ease forwards; }
@keyframes hmSaved { 0% { opacity: 0; } 25% { opacity: 1; } 100% { opacity: 0; } }
.hm-stage.jolt { animation: hmJolt .38s cubic-bezier(.3,.7,.3,1); }
@keyframes hmJolt { 0% { transform: translate(0, 0); } 20% { transform: translate(-5px, 2px); } 45% { transform: translate(4px, -2px); } 70% { transform: translate(-2px, 1px); } 100% { transform: none; } }
.hm-stage > .hm-banner { position: absolute; left: 50%; top: 42%; z-index: 6; transform: translateX(-50%); width: max-content; max-width: min(90%, 520px); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; pointer-events: none; }
.hm-stage > .hm-banner.blank { display: none; }

/* the clocks and the mistakes, over the scene */
.hm-hud { position: absolute; z-index: 4; top: 12px; display: flex; align-items: center; gap: 10px; padding: 7px 12px 7px 7px; border-radius: 16px; pointer-events: none;
  background: rgba(8,8,14,.55); border: 1px solid rgba(255,255,255,.12); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.hm-hud.l { left: 12px; }
.hm-hud.r { right: 12px; padding: 8px 12px; flex-direction: column; align-items: flex-end; gap: 6px; }
.hm-timer { position: relative; width: 50px; height: 50px; flex: none; }
.hm-timer svg { width: 50px; height: 50px; transform: rotate(-90deg); }
.hm-timer circle { fill: none; stroke-width: 4; }
.hm-timer .bg { stroke: rgba(255,255,255,.12); }
.hm-timer .fg { stroke: #f2c46d; stroke-linecap: round; transition: stroke-dashoffset .25s linear, stroke .3s; filter: drop-shadow(0 0 4px rgba(242,196,109,.55)); }
.hm-timer b { position: absolute; inset: 0; display: grid; place-items: center; font: 900 16px/1 'Inter', system-ui, sans-serif; color: #fff; font-variant-numeric: tabular-nums; }
.hm-timer.warn .fg { stroke: #ff5a6a; filter: drop-shadow(0 0 5px rgba(255,90,106,.7)); }
.hm-timer.warn b { color: #ffb3ba; animation: hmPulse .5s ease-in-out infinite alternate; }
.hm-timer.idle .fg { stroke: rgba(255,255,255,.25); filter: none; }
@keyframes hmPulse { to { transform: scale(1.12); } }
.hm-hud .lbl { display: grid; line-height: 1.15; }
.hm-hud small { font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: rgba(255,255,255,.55); }
.hm-hud .clock { display: flex; align-items: baseline; gap: 8px; }
.hm-hud .clock b { font: 900 18px/1 'Inter', system-ui, sans-serif; color: #fff; font-variant-numeric: tabular-nums; }
.hm-hud .clock.warn b { color: #ff8a95; }
.hm-lives { display: flex; gap: 4px; }
.hm-lives i { width: 9px; height: 9px; border-radius: 50%; background: rgba(255,255,255,.18); box-shadow: inset 0 0 0 1px rgba(255,255,255,.2); transition: background .3s, transform .3s; }
.hm-lives i.on { background: #ff5a6a; box-shadow: 0 0 8px rgba(255,90,106,.75); transform: scale(1.1); }
.hm-drag { position: absolute; z-index: 4; left: 50%; bottom: 14px; transform: translateX(-50%); max-width: calc(100% - 24px); padding: 7px 14px; border-radius: 12px; pointer-events: none;
  font-size: 12px; font-weight: 700; color: rgba(255,255,255,.9); background: rgba(8,8,14,.6); border: 1px solid rgba(255,255,255,.14); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  animation: hmIn .5s ease both; }
.hm-drag.hidden { display: none; }
@keyframes hmIn { from { opacity: 0; transform: translate(-50%, 8px); } }

/* ---------- the word ---------- */
.hm-wordbar { display: grid; justify-items: center; gap: 4px; padding: 10px 10px 8px; border-radius: 18px;
  background: linear-gradient(160deg, rgba(24,24,34,.9), rgba(10,10,16,.94)); border: 1px solid rgba(255,255,255,.08); }
.hm-word { --n: 8; --tw: min(52px, calc((100vw - 64px) / var(--n) - 6px)); display: flex; justify-content: center; gap: 6px; flex-wrap: nowrap; }
.hm-tile { position: relative; width: var(--tw); height: calc(var(--tw) * 1.22); border-radius: 10px; display: grid; place-items: center; perspective: 300px;
  background: linear-gradient(180deg, rgba(255,255,255,.07), rgba(255,255,255,.02)); box-shadow: inset 0 0 0 1px rgba(255,255,255,.12), inset 0 -3px 0 rgba(255,255,255,.08); }
.hm-tile::after { content: ''; position: absolute; left: 18%; right: 18%; bottom: 14%; height: 2px; border-radius: 2px; background: rgba(255,255,255,.35); }
.hm-tile b { font: 900 calc(var(--tw) * .56)/1 'Inter', system-ui, sans-serif; color: #fff; letter-spacing: 0; }
.hm-tile.open { background: linear-gradient(180deg, #2b2a3a, #1a1925); box-shadow: inset 0 0 0 1px rgba(242,196,109,.35), 0 6px 14px -8px rgba(0,0,0,.9); }
.hm-tile.open::after { opacity: 0; }
.hm-tile.given b { color: #e9e4ff; }
.hm-tile.new { animation: hmFlip .55s cubic-bezier(.3,1.4,.5,1) var(--d, 0ms) both; }
.hm-tile.new b { color: #ffd98a; text-shadow: 0 0 12px rgba(242,196,109,.7); }
@keyframes hmFlip { 0% { transform: rotateX(90deg) scale(.9); } 100% { transform: none; } }
.hm-tile.miss { background: linear-gradient(180deg, rgba(255,70,90,.22), rgba(120,10,25,.25)); box-shadow: inset 0 0 0 1px rgba(255,90,106,.55); animation: hmFlip .5s ease var(--d, 0ms) both; }
.hm-tile.miss::after { opacity: 0; }
.hm-tile.miss b { color: #ffb3ba; }
.hm-word.solved .hm-tile { box-shadow: inset 0 0 0 1px rgba(242,196,109,.75), 0 0 18px -4px rgba(242,196,109,.6); animation: hmWave .7s ease calc(var(--i) * 45ms) both; }
@keyframes hmWave { 40% { transform: translateY(-8px); } 100% { transform: none; } }
.hm-word.deal .hm-tile { animation: hmDeal .45s cubic-bezier(.3,1.3,.5,1) calc(var(--i) * 40ms) both; }
@keyframes hmDeal { from { opacity: 0; transform: translateY(10px) scale(.85); } }
.hm-dock { min-height: 16px; font-size: 12px; font-weight: 700; color: rgba(255,255,255,.55); text-align: center; }

/* ---------- the keyboard ---------- */
.hm-keys { --cols: 9; display: grid; gap: 6px; justify-items: center; width: 100%; max-width: 720px; margin: 0 auto; transition: opacity .3s; }
.hm-keys.off { opacity: .6; }
.hm-krow { display: flex; justify-content: center; gap: 6px; width: 100%; }
.hm-key { flex: 0 1 calc((100% - (var(--cols) - 1) * 6px) / var(--cols)); max-width: 64px; height: 46px; padding: 0; border-radius: 11px; cursor: pointer;
  font: 800 18px/1 'Inter', system-ui, sans-serif; color: #f4f1fb;
  background: linear-gradient(180deg, #2a2a38, #1b1b26); border: 1px solid rgba(255,255,255,.12); box-shadow: 0 3px 0 rgba(0,0,0,.5), inset 0 1px 0 rgba(255,255,255,.08);
  transition: transform .08s, background .2s, color .2s, opacity .2s; }
.hm-key:hover:not(:disabled) { border-color: rgba(242,196,109,.6); background: linear-gradient(180deg, #33324a, #20202d); }
.hm-key:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0,0,0,.5); }
.hm-key:disabled { cursor: default; }
.hm-key.hit { color: #1d1405; background: linear-gradient(180deg, #ffe08f, #e6b04a); border-color: transparent; box-shadow: 0 3px 0 #8a5d16; }
.hm-key.miss { color: rgba(255,170,180,.55); background: rgba(80,20,30,.35); border-color: rgba(255,90,106,.25); box-shadow: none; }
.hm-key.miss span { text-decoration: line-through; text-decoration-thickness: 2px; }
.hm-key.busy { opacity: .6; }
.hm-key.nope { animation: hmNope .35s ease; }
@keyframes hmNope { 25% { transform: translateX(-4px); } 50% { transform: translateX(4px); } 75% { transform: translateX(-2px); } }

/* ---------- the end ---------- */
.hm-res { position: absolute; inset: 0; z-index: 900; display: grid; place-items: center; padding: 12px; background: rgba(4,4,10,.55); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.hm-res.hidden { display: none; }
.hm-res-in { width: min(400px, 100%); box-sizing: border-box; padding: 22px 20px 18px; border-radius: 24px; text-align: center; animation: hmPop .45s cubic-bezier(.3,1.3,.5,1) both;
  background: linear-gradient(165deg, rgba(30,29,42,.97), rgba(12,12,18,.98)); border: 1px solid rgba(255,255,255,.12); box-shadow: 0 30px 70px -20px rgba(0,0,0,.95); }
@keyframes hmPop { from { opacity: 0; transform: translateY(14px) scale(.95); } }
.hm-res-n { display: grid; justify-items: center; gap: 2px; margin-bottom: 6px; }
.hm-res-n b { font: 900 46px/1 'Inter', system-ui, sans-serif; background: linear-gradient(180deg, #ffe7a8, #e6ad45); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hm-res-n span { font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: rgba(255,255,255,.55); }
.hm-res-in h3 { margin: 4px 0 12px; font-size: 20px; font-weight: 900; color: #fff; }
.hm-res-in.lost h3 { color: #ffb3ba; }
.hm-res-was { margin: 0 0 14px; }
.hm-res-was small { display: block; margin-bottom: 7px; font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: rgba(255,255,255,.5); }
.hm-res-word { display: flex; justify-content: center; flex-wrap: wrap; gap: 4px; }
.hm-res-word i { font-style: normal; display: grid; place-items: center; width: 28px; height: 34px; border-radius: 7px; font: 900 17px/1 'Inter', system-ui, sans-serif; color: #fff;
  background: rgba(255,255,255,.07); box-shadow: inset 0 0 0 1px rgba(255,255,255,.14); animation: hmDeal .4s ease calc(var(--i) * 50ms) both; }
.hm-res-chips { display: inline-flex; align-items: center; gap: 8px; margin: 0 0 16px; padding: 8px 16px; border-radius: 14px; font: 900 19px/1 'Inter', system-ui, sans-serif;
  color: #ffe3a3; background: rgba(242,190,90,.12); border: 1px solid rgba(242,190,90,.35); }
.hm-coin { width: 20px; height: 20px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff3c4, #f2c14e 45%, #a8741a); box-shadow: inset 0 0 0 2px rgba(120,80,10,.45); }
.hm-res-acts { display: flex; justify-content: center; gap: 8px; }
.hm-rb { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 40px; padding: 0 16px 0 12px; border-radius: 12px; cursor: pointer;
  font: 800 13.5px/1 'Inter', system-ui, sans-serif; color: #f4f1fb; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.16); }
.hm-rb:hover { border-color: rgba(242,196,109,.6); }
.hm-rb svg.i { width: 16px; height: 16px; }
.hm-rb.go { color: #2a1800; border-color: transparent; background: linear-gradient(180deg, #ffe58f 0%, #f6c84a 48%, #e3a61f 100%); box-shadow: 0 6px 18px -6px rgba(246,200,74,.85); }

/* ---------- the home page ---------- */
.logo-hm { width: 36px; height: 36px; flex: none; } .logo-hm svg { width: 36px; height: 36px; display: block; filter: drop-shadow(0 3px 5px rgba(0,0,0,.45)); }
.hm-art { display: grid; place-items: center; margin: -6px 0 4px; }
.hm-art svg { width: 100%; max-width: 240px; height: auto; overflow: visible; filter: drop-shadow(0 18px 30px rgba(0,0,0,.55)); }
.hm-art .sway { transform-box: view-box; transform-origin: 120px 24px; animation: hmSway 4.2s ease-in-out infinite alternate; }
@keyframes hmSway { from { transform: rotate(-4deg); } to { transform: rotate(4deg); } }
@media (prefers-reduced-motion: reduce) { .hm-art .sway, .hm-stage.jolt, .hm-timer.warn b { animation: none; } }

/* ---------- phones ---------- */
@media (max-width: 640px) {
  body.game-hangman[data-page="table"] #table.page { padding: 6px 8px; }
  .hm-wrap { gap: 6px; }
  .hm-top { padding: 4px 6px 4px 10px; }
  .hm-tool { width: 34px; height: 34px; }
  .hm-free { display: none; }
  .hm-stage { border-radius: 16px; }
  .hm-hud { top: 8px; padding: 5px 9px 5px 5px; gap: 7px; }
  .hm-hud.l { left: 8px; } .hm-hud.r { right: 8px; padding: 6px 9px; }
  .hm-timer, .hm-timer svg { width: 40px; height: 40px; }
  .hm-timer b { font-size: 14px; }
  .hm-hud .lbl small { display: none; }
  .hm-hud .clock b { font-size: 15px; }
  .hm-lives i { width: 7px; height: 7px; }
  .hm-wordbar { padding: 8px 6px 6px; border-radius: 14px; }
  .hm-word { --tw: min(44px, calc((100vw - 34px) / var(--n) - 4px)); gap: 4px; }
  .hm-keys, .hm-krow { gap: 4px; }
  .hm-key { flex-basis: calc((100% - (var(--cols) - 1) * 4px) / var(--cols)); height: 42px; font-size: 16px; border-radius: 9px; }
}
@media (max-height: 640px) and (min-width: 641px) {
  .hm-key { height: 38px; font-size: 16px; }
  .hm-word { --tw: min(40px, calc((100vw - 64px) / var(--n) - 6px)); }
}
