/* Snowman — English Room Games */

:root {
  --bg: #1d2452;
  --bg-2: #252d63;
  --ink: #fff8e7;
  --muted: #b9c0ea;
  --muted-2: #8790c4;
  --line: rgba(255, 255, 255, .14);
  --gold: #ffc93c;
  --gold-dark: #c99a1c;
  --red: #ef6461;
  --red-dark: #b8393a;
  --yellow: #ffc93c;
  --yellow-dark: #c99a1c;
  --blue: #2f6fd8;
  --blue-dark: #1d4ea3;
  --display: 'Fredoka', 'Nunito', sans-serif;
  --body: 'Nunito', sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--body); color: var(--ink); background-color: var(--bg);
  background-image:
    linear-gradient(45deg, rgba(255,255,255,.03) 25%, transparent 25%, transparent 75%, rgba(255,255,255,.03) 75%),
    linear-gradient(45deg, rgba(255,255,255,.03) 25%, transparent 25%, transparent 75%, rgba(255,255,255,.03) 75%);
  background-size: 64px 64px; background-position: 0 0, 32px 32px;
  min-height: 100dvh;
}
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* top bar */
.topbar { display: flex; align-items: center; gap: 10px; padding: 8px 14px; padding-top: calc(8px + env(safe-area-inset-top, 0px)); border-bottom: 1px solid var(--line); background: rgba(20, 26, 64, .8); }
.brand { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.brand h1 { margin: 0; font: 700 26px var(--display); white-space: nowrap; }
.brand .site { font-size: 11.5px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--muted-2); text-decoration: none; white-space: nowrap; }
.brand .site:hover { color: var(--gold); }
.spacer { flex: 1; }
.iconbtn { width: 38px; height: 38px; flex-shrink: 0; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 10px; background: rgba(255,255,255,.05); color: var(--muted); cursor: pointer; text-decoration: none; }
.iconbtn:hover { color: var(--ink); border-color: var(--gold); }
.iconbtn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.iconbtn[aria-pressed="false"] .wave { display: none; }

.controls { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: rgba(255,255,255,.07); border-radius: 12px; padding: 10px 16px; font-weight: 800; font-size: 1rem; cursor: pointer; min-height: 44px; }
.btn:hover:not(:disabled) { background: rgba(255,255,255,.13); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn.primary { background: var(--gold); color: var(--bg); border-color: transparent; box-shadow: 0 4px 0 var(--gold-dark); font-family: var(--display); font-weight: 600; font-size: 1.12rem; }
.btn.primary:hover { background: #ffd35e; }
.btn.primary:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--gold-dark); }
.btn.wide { width: 100%; margin-top: 8px; }
.tip { margin: 0; color: var(--muted-2); font-size: .9rem; text-align: center; }

/* overlays */
.overlay { position: fixed; inset: 0; z-index: 100; background: rgba(10, 14, 40, .75); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; padding: 14px; }
.card { position: relative; width: min(480px, 100%); max-height: calc(100dvh - 28px); overflow: auto; background: var(--bg-2); border: 1px solid var(--line); border-radius: 20px; padding: 22px; box-shadow: 0 30px 70px rgba(0,0,0,.5); }
.card h2 { margin: 0 0 6px; font: 700 2rem var(--display); }
.card h3 { margin: 16px 0 6px; font: 600 1.15rem var(--display); color: var(--gold); }
.card p { line-height: 1.5; margin: 0 0 12px; }
.card .big { font-size: 1.08rem; }
.kicker { font: 600 .8rem var(--display); letter-spacing: .12em; text-transform: uppercase; color: var(--gold); }
.kicker a { color: inherit; text-decoration: none; }
.close { position: absolute; top: 10px; right: 12px; width: 36px; height: 36px; border: 0; border-radius: 50%; background: rgba(255,255,255,.08); font-size: 1.6rem; line-height: 1; cursor: pointer; color: var(--muted); }
.field { margin-bottom: 14px; }
.label { display: flex; align-items: center; gap: 6px; font: 600 .8rem var(--display); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.dot.red { background: var(--red); } .dot.yellow { background: var(--yellow); }
.choice { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choice button { text-align: left; padding: 11px 14px; border-radius: 14px; cursor: pointer; border: 2px solid var(--line); background: rgba(0,0,0,.25); }
.choice button b { display: block; font-size: 1.05rem; }
.choice button span { color: var(--muted); font-size: .88rem; }
.choice button[aria-pressed="true"] { border-color: var(--gold); background: rgba(255, 201, 60, .1); }
.names { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.names input { width: 100%; font: 700 1rem var(--body); color: var(--ink); background: rgba(0,0,0,.3); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.names input:focus { outline: none; border-color: var(--gold); }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; background: rgba(0,0,0,.25); padding: 4px; border-radius: 12px; border: 1px solid var(--line); }
.seg button { border: 0; background: transparent; border-radius: 9px; padding: 9px 6px; font-weight: 800; cursor: pointer; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--gold); color: var(--bg); }
.steps { padding-left: 20px; margin: 4px 0; line-height: 1.55; }

.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 150; overflow: hidden; }
.confetti i { position: absolute; top: -20px; width: 10px; height: 14px; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

@media (max-width: 520px) {
  .brand .site { display: none; }
  .brand h1 { font-size: 22px; }
  .names { grid-template-columns: 1fr; }
  .card { padding: 18px 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ---------- Snowman ---------- */
.pill-stat { display: flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: rgba(0,0,0,.25); border: 1px solid var(--line); font: 700 1.1rem var(--display); color: var(--gold); }
.pill-label { font: 800 .7rem var(--body); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }

.layout { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 14px 12px 22px; }
.scene-wrap { position: relative; width: min(440px, 100%, calc((100dvh - 430px) * 1.2)); min-width: 240px; }
.scene { display: block; width: 100%; height: auto; border-radius: 18px; box-shadow: 0 14px 30px rgba(0,0,0,.35); }
.sky { transition: fill .6s; }
#sky-top, #sky-bottom { transition: stop-color .8s; }
.sun { transform-box: fill-box; transform-origin: center; transition: transform .8s cubic-bezier(.3,1.4,.6,1); }
.part, .head-group, .ball { transform-box: fill-box; transform-origin: center; transition: transform .7s ease-in, opacity .7s ease-in; }
.part.gone { opacity: 0; transform: translateY(70px) rotate(35deg); }
.p-arm-l.gone { transform: translate(-10px, 90px) rotate(-60deg); }
.p-hat.gone { transform: translate(40px, 140px) rotate(70deg); }
.puddle { transform-box: fill-box; transform-origin: center; transition: transform .8s; }
.snowman.melted .head-group { transform: translateY(70px) scale(.4); opacity: 0; }
.snowman.melted .middle { transform: translateY(60px) scale(.5, .3); opacity: .4; }
.snowman.melted .base { transform: translateY(36px) scale(1.2, .35); opacity: .7; }
.snowman.melted .part { opacity: 0; }
.snowman.happy { animation: hop .5s ease-in-out 3; transform-box: fill-box; transform-origin: bottom center; }
@keyframes hop { 50% { transform: translateY(-14px); } }
.flake { fill: #fff; opacity: .9; }

.chances { position: absolute; left: 10px; top: 10px; display: flex; gap: 4px; }
.chances i { width: 12px; height: 12px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: background .3s, transform .3s; }
.chances i.used { background: rgba(255,255,255,.25); transform: scale(.75); }

.clue { min-height: 1.3em; color: var(--muted); font-weight: 800; text-align: center; }
.clue b { color: var(--gold); }
.word { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; max-width: 100%; }
.word .ch { --s: min(46px, calc((100vw - 40px) / var(--n) - 6px)); width: var(--s); height: calc(var(--s) * 1.18); display: grid; place-items: center; border-bottom: 4px solid var(--muted); font: 700 calc(var(--s) * .72) var(--display); text-transform: uppercase; }
.word .ch.shown { border-color: var(--gold); animation: pop .3s; }
.word .ch.missed { color: var(--red); border-color: var(--red); }
.word .ch.space { border-color: transparent; }
@keyframes pop { 40% { transform: scale(1.25); } }
.msg { min-height: 1.4em; font: 600 1.05rem var(--display); text-align: center; color: var(--muted); }
.msg.good { color: #6ee7a8; } .msg.bad { color: var(--red); }

.keyboard { display: flex; flex-direction: column; gap: 6px; width: min(560px, 100%); user-select: none; -webkit-user-select: none; touch-action: manipulation; }
.keyboard .row { display: flex; justify-content: center; gap: 5px; }
.key { flex: 1 1 0; max-width: 50px; height: 52px; border: 0; border-radius: 10px; background: #e8ecff; color: var(--bg); font: 700 1.25rem var(--display); text-transform: uppercase; cursor: pointer; box-shadow: 0 3px 0 #9ea8dc; }
.key:hover:not(:disabled) { background: #fff; }
.key:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 #9ea8dc; }
.key.right { background: #3bb273; color: #fff; box-shadow: 0 3px 0 #23804f; }
.key.wrong { background: rgba(255,255,255,.1); color: rgba(255,255,255,.35); box-shadow: none; }
.key:disabled { cursor: default; }

.result { width: min(460px, 100%); text-align: center; background: rgba(0,0,0,.22); border: 1px solid var(--line); border-radius: 18px; padding: 14px; }
.result-title { font: 700 1.5rem var(--display); color: var(--gold); }
.result-title.lost { color: #9fd3f7; }
.result-word { display: flex; align-items: center; justify-content: center; gap: 10px; font: 700 2rem var(--display); margin: 4px 0 10px; letter-spacing: .04em; }
.listen { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: rgba(255,255,255,.1); display: grid; place-items: center; cursor: pointer; color: var(--ink); }
.listen:hover { border-color: var(--gold); }
.listen svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.text-in { width: 100%; font: 700 1.05rem var(--body); color: var(--ink); background: rgba(0,0,0,.3); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; }
.text-in:focus { outline: none; border-color: var(--gold); }
.secret-msg { min-height: 1.2em; color: var(--red); font-weight: 800; font-size: .92rem; }

.snow { position: fixed; inset: 0; pointer-events: none; z-index: 150; overflow: hidden; }
.snow i { position: absolute; top: -20px; width: 10px; height: 10px; border-radius: 50%; background: #fff; opacity: .9; animation: snowfall linear forwards; }
@keyframes snowfall { to { transform: translate(var(--dx, 0), 110vh); } }

@media (max-width: 520px) {
  .key { height: 46px; font-size: 1.1rem; border-radius: 8px; }
  .keyboard .row { gap: 4px; }
  .pill-label { display: none; }
}
@media (max-height: 700px) {
  .scene-wrap { width: min(340px, 100%); }
}
