/* ============================================================
   Imaginary Hangman — "Doodle on paper" art direction
   Grid notebook paper, pencil-sketch gallows, hand-lettered
   title with a blue underline stroke, sketchy red buttons.
   Fonts: Patrick Hand / Patrick Hand SC. Ink: graphite #33333a.
   ============================================================ */
@font-face{font-family:"Patrick Hand";font-style:normal;font-weight:400;font-display:swap;
  src:url("./assets/fonts/patrick-hand.woff2") format("woff2");}
@font-face{font-family:"Patrick Hand SC";font-style:normal;font-weight:400;font-display:swap;
  src:url("./assets/fonts/patrick-hand-sc.woff2") format("woff2");}
:root{
  --paper:#fbfaf4;
  --paper-dim:#f3f1e8;
  --grid:rgba(112,158,214,.22);
  --ink:#33333a;
  --ink-mid:#4a4a52;
  --ink-soft:#77777f;
  --graphite:rgba(51,51,58,.16);
  --red:#e0313f;
  --red-dk:#b2202e;
  --blue:#2f6fd6;
  --blue-dk:#245ab1;
  --note:#fff8c4;
  /* the classic wobbly hand-drawn border trick */
  --wobble-lg:255px 15px 225px 15px/15px 225px 15px 255px;
  --wobble-md:14px 60px 16px 55px/55px 14px 60px 16px;
  --wobble-sm:8px 12px 9px 11px/11px 8px 12px 10px;
  --hand:"Patrick Hand","Comic Sans MS",cursive,sans-serif;
  --hand-sc:"Patrick Hand SC","Patrick Hand","Comic Sans MS",cursive,sans-serif;
}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent;}
html,body{margin:0;height:100%;}
body{
  /* lined grid notebook paper */
  background:
    linear-gradient(var(--grid) 1px,transparent 1px),
    linear-gradient(90deg,var(--grid) 1px,transparent 1px),
    var(--paper);
  background-size:22px 22px,22px 22px,auto;
  color:var(--ink);
  font-family:var(--hand);
  display:flex;flex-direction:column;
  min-height:100dvh;
  overflow:hidden;
  user-select:none;
  -webkit-user-select:none;
}
/* soft paper vignette + a hint of page shading */
body::before{
  content:"";position:fixed;inset:0;pointer-events:none;z-index:0;
  background:
    radial-gradient(120% 90% at 50% 30%,transparent 60%,rgba(120,110,90,.10) 100%),
    linear-gradient(105deg,rgba(120,110,90,.05),transparent 18%);
}
/* subtle paper grain for a richer pencil-on-paper feel */
body::after{content:"";position:fixed;inset:0;pointer-events:none;z-index:0;
  opacity:.22;mix-blend-mode:multiply;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");}

/* secret YES zone — must stay invisible */
.top-tap-zone{position:fixed;top:52px;left:0;right:0;height:30vh;z-index:20;
  background:transparent;border:none;}

/* ---------- top bar: hand-lettered title + red doodle gear ---------- */
.topbar{
  display:flex;align-items:flex-start;justify-content:center;
  padding:10px 16px 0;position:relative;z-index:40;
}
.title-wrap{display:flex;flex-direction:column;align-items:stretch;gap:0;width:fit-content;margin:0 auto;}
.topbar h1{
  margin:0;line-height:1;
  font-family:var(--hand-sc);font-weight:400;
  font-size:1.9rem;letter-spacing:.34em;text-indent:.34em;
  color:var(--ink);
}
.topbar h1 span{display:inline-block;}
.topbar h1 span:nth-child(odd){transform:rotate(-2.5deg) translateY(-1px);}
.topbar h1 span:nth-child(even){transform:rotate(2deg) translateY(1px);}
.topbar h1 span:nth-child(4){transform:rotate(-1deg) translateY(2px);}
.title-underline{width:100%;height:12px;color:var(--blue);margin-top:1px;}
.icon-btn{
  position:absolute;right:12px;top:8px;
  width:42px;height:42px;padding:7px;
  border-radius:46% 54% 52% 48%/53% 47% 55% 45%;
  background:var(--red);color:#fff;
  border:2.5px solid var(--red-dk);
  cursor:pointer;z-index:40;
  box-shadow:2px 3px 0 var(--graphite);
  transform:rotate(3deg);
  transition:transform .1s,box-shadow .1s;
}
.icon-btn svg{width:100%;height:100%;display:block;}
.icon-btn:active{transform:rotate(3deg) translateY(2px);box-shadow:0 1px 0 var(--graphite);}
/* help "?" button — mirrors the gear, top-left, in blue pencil */
.help-btn{position:absolute;left:12px;top:8px;
  width:42px;height:42px;padding:0;
  border-radius:52% 48% 55% 45%/48% 52% 45% 55%;
  background:var(--blue);color:#fff;border:2.5px solid var(--blue-dk);
  font-family:var(--hand-sc);font-size:1.55rem;line-height:1;
  cursor:pointer;z-index:40;box-shadow:2px 3px 0 var(--graphite);
  transform:rotate(-3deg);transition:transform .1s,box-shadow .1s;}
.help-btn:active{transform:rotate(-3deg) translateY(2px);box-shadow:0 1px 0 var(--graphite);}

/* ---------- layout ---------- */
main{flex:1;display:flex;flex-direction:column;align-items:center;
  padding:0 12px calc(14px + env(safe-area-inset-bottom));gap:8px;min-height:0;
  position:relative;z-index:1;}

/* ---------- the sketch scene ---------- */
.stage{position:relative;width:100%;max-width:360px;flex:1;min-height:0;
  display:flex;align-items:flex-end;justify-content:center;}
#gallows{width:auto;height:100%;max-height:37vh;overflow:visible;}

/* scenery ink */
.scenery .ink-line{stroke:var(--ink-mid);stroke-width:2.2;}
.scenery .ink-line.thin{stroke:var(--ink-soft);stroke-width:1.6;}
.cloud{transform-box:fill-box;animation:drift 8s ease-in-out infinite alternate;}
.cloud-b{animation-duration:11s;animation-delay:-4s;}
@keyframes drift{from{transform:translateX(-4px)}to{transform:translateX(4px)}}

/* classic hangman, sketched one wobbly pencil stroke per wrong guess */
.part{opacity:0;}
.part.on{opacity:1;}
.draw{stroke-dasharray:100;stroke-dashoffset:100;}
.part.on.draw,.part.on .draw{animation:drawStroke .5s ease forwards;}
@keyframes drawStroke{to{stroke-dashoffset:0;}}
.figure-head .face{opacity:0;}
.part.on .face{animation:faceIn .25s ease .5s forwards;}
@keyframes faceIn{to{opacity:1;}}
#figure .wood{stroke:#3a3a41;stroke-width:5;}
#figure .rope{stroke:#55555e;stroke-width:2.6;}
#figure .limb{stroke:var(--ink);stroke-width:3.4;}
#pen{transform-box:fill-box;pointer-events:none;}

/* the win: the little figure does a happy hop */
#gallows.yay #figure{animation:happyHop .5s cubic-bezier(.3,1.5,.6,1) infinite alternate;}
@keyframes happyHop{from{transform:translateY(0)}to{transform:translateY(-6px)}}

/* performance-mode "ready" — a soft red-pencil pulse around the sketch */
#gallows.reveal-ready{animation:readyPulse 1.4s ease-in-out infinite;}
@keyframes readyPulse{
  0%,100%{filter:drop-shadow(0 0 4px rgba(224,49,63,.30))}
  50%{filter:drop-shadow(0 0 11px rgba(224,49,63,.60))}
}

/* ---------- scribbled letter burst ---------- */
.burst{position:fixed;inset:0;pointer-events:none;z-index:15;overflow:hidden;}
.burst-letter{position:absolute;font-family:var(--hand-sc);font-weight:400;
  font-size:1.5rem;color:var(--ink);
  will-change:transform,opacity;}
.burst-letter.out{animation:burstOut .65s cubic-bezier(.2,.8,.4,1) forwards;}
.burst-letter.in{animation:burstIn .5s ease-in forwards;}
@keyframes burstOut{from{transform:translate(0,0) scale(1) rotate(0)}
  to{transform:translate(var(--fx),var(--fy)) scale(.3) rotate(40deg);opacity:0}}
@keyframes burstIn{from{transform:translate(var(--tx),var(--ty)) scale(.3);opacity:0}
  50%{opacity:1} to{transform:translate(0,0) scale(1);opacity:0}}

/* ---------- the word: pencil blanks on the paper ---------- */
.word-row{display:flex;flex-wrap:wrap;gap:8px;justify-content:center;
  min-height:2.7rem;align-items:flex-end;}
.slot{
  width:1.8rem;height:2.5rem;
  display:flex;align-items:flex-end;justify-content:center;
  border-bottom:3px solid var(--ink-mid);
  border-radius:2px 40%/3px;
  font-family:var(--hand-sc);
  font-size:1.75rem;line-height:1.15;color:var(--ink);
  text-transform:uppercase;
  background:transparent;
}
.slot:nth-child(odd){transform:rotate(-1.2deg);}
.slot:nth-child(even){transform:rotate(1deg) translateY(1px);}
.slot.filled{
  border-bottom-color:var(--ink);
  animation:penIn .3s cubic-bezier(.3,1.6,.5,1);
}
@keyframes penIn{from{transform:scale(.4) rotate(-9deg);opacity:0}
  to{transform:scale(1) rotate(0);opacity:1}}

/* ---------- hint + message ---------- */
.meta-hint{min-height:1.5rem;font-size:.95rem;color:var(--ink);
  background:var(--note);
  border:2px solid var(--ink-mid);border-radius:var(--wobble-sm);
  padding:2px 14px;opacity:0;transform:scale(.85) rotate(-1deg);
  text-align:center;max-width:330px;transition:opacity .2s,transform .2s;
  box-shadow:2px 3px 0 var(--graphite);}
.meta-hint.show{opacity:1;transform:scale(1) rotate(-1deg);}
.meta-hint:empty{background:transparent;border-color:transparent;box-shadow:none;}
.message{min-height:1.6rem;font-size:1.3rem;font-family:var(--hand);
  opacity:0;transform:scale(.85) rotate(-1.5deg);transition:opacity .25s,transform .25s;
  color:var(--ink);}
.message.show{opacity:1;transform:scale(1) rotate(-1.5deg);}
.message.win{color:var(--blue-dk);}
.message.lose{color:var(--red-dk);}

/* ---------- keyboard: little hand-drawn paper keys ---------- */
.keyboard{display:flex;flex-direction:column;gap:7px;width:100%;max-width:420px;}
.kb-row{display:flex;gap:5px;justify-content:center;}
.key{
  --tilt:0deg;
  position:relative;
  flex:1;max-width:38px;height:46px;
  border:2px solid var(--ink);
  border-radius:var(--wobble-sm);
  background:rgba(255,255,255,.88);color:var(--ink);
  font-family:var(--hand-sc);font-size:1.25rem;font-weight:400;
  text-transform:uppercase;line-height:1;
  cursor:pointer;padding:0;
  box-shadow:2px 2.5px 0 var(--graphite);
  transform:rotate(var(--tilt));
  transition:transform .08s,box-shadow .08s,background .15s;
}
.kb-row .key:nth-child(3n){--tilt:.8deg;}
.kb-row .key:nth-child(3n+1){--tilt:-.7deg;}
.kb-row:nth-child(2) .key:nth-child(3n){--tilt:-.6deg;}
.kb-row:nth-child(2) .key:nth-child(3n+2){--tilt:.7deg;}
.key:active{transform:rotate(var(--tilt)) translateY(2px);box-shadow:0 0 0 var(--graphite);}
.key:disabled{cursor:default;}
/* right guess: circled in blue pencil */
.key.hit{background:#eaf2fd;color:var(--blue-dk);border-color:#4a7fc1;
  box-shadow:2px 2.5px 0 rgba(47,111,214,.22);opacity:1;}
/* wrong guess: crossed out in red pencil */
.key.miss{background:var(--paper-dim);color:var(--ink-soft);border-color:var(--ink-soft);
  box-shadow:1px 1.5px 0 var(--graphite);opacity:.8;}
.key.miss::after{content:"";position:absolute;left:12%;right:12%;top:47%;height:2.5px;
  background:var(--red);border-radius:3px;transform:rotate(-10deg);opacity:.85;}
/* performer cue — invisible to anyone who doesn't know the tell.
   The cued key alone loses its little sketch shadow (sits "flat on the
   paper") and takes a barely-there graphite smudge. Obvious once you know
   to scan for the flat key; reads as nothing to an audience.
   Tune --cue-tint toward #fff to make it fainter, or darker to make it easier. */
.key.cue{
  --cue-tint:#f2efe4;
  background:var(--cue-tint);
  box-shadow:1px 1px 0 rgba(51,51,58,.10);
  transition:none;
}

/* ---------- sketchy buttons (the red "PLAY" treatment) ---------- */
.controls{display:flex;gap:14px;justify-content:center;align-items:center;
  margin-top:4px;position:relative;z-index:30;}
.wrong-btn{
  background:var(--red);color:#fff;
  border:3px solid var(--red-dk);
  border-radius:var(--wobble-lg);
  padding:11px 34px;font-family:var(--hand-sc);
  font-size:1.35rem;letter-spacing:.08em;text-transform:uppercase;cursor:pointer;
  transform:rotate(-1.3deg);
  box-shadow:inset 0 0 0 2px rgba(255,255,255,.22),3px 4px 0 var(--graphite);
  transition:transform .08s,box-shadow .08s;
}
.wrong-btn:active{transform:rotate(-1.3deg) translateY(3px);
  box-shadow:inset 0 0 0 2px rgba(255,255,255,.22),0 1px 0 var(--graphite);}
.ghost-btn{
  background:rgba(255,255,255,.85);color:var(--blue-dk);
  border:2.5px solid var(--ink);
  border-radius:var(--wobble-md);
  padding:9px 22px;font-family:var(--hand-sc);
  font-size:1.15rem;letter-spacing:.05em;cursor:pointer;
  transform:rotate(.8deg);
  box-shadow:2px 3px 0 var(--graphite);
  transition:transform .08s,box-shadow .08s;
}
.ghost-btn:active{transform:rotate(.8deg) translateY(3px);box-shadow:0 0 0 var(--graphite);}
.undo-btn{padding:9px 16px;font-size:1.5rem;line-height:1;transform:rotate(-.6deg);}
.undo-btn:active{transform:rotate(-.6deg) translateY(3px);box-shadow:0 0 0 var(--graphite);}

/* ---------- settings: a paper card slid up from the bottom ---------- */
.panel{position:fixed;inset:auto 0 0 0;z-index:70;
  background:
    linear-gradient(var(--grid) 1px,transparent 1px),
    linear-gradient(90deg,var(--grid) 1px,transparent 1px),
    var(--paper);
  background-size:22px 22px,22px 22px,auto;
  color:var(--ink);
  border:3px solid var(--ink);border-bottom:none;
  border-radius:26px 60px 0 0/40px 26px 0 0;
  padding:18px 22px calc(20px + env(safe-area-inset-bottom));
  box-shadow:0 -8px 30px rgba(60,60,70,.25);
  transition:transform .28s cubic-bezier(.3,1.3,.6,1);}
.panel h2{margin:0 0 10px;font-family:var(--hand-sc);font-weight:400;
  font-size:1.5rem;letter-spacing:.1em;transform:rotate(-.8deg);
  text-decoration:underline;text-decoration-color:var(--blue);
  text-decoration-thickness:2.5px;text-underline-offset:5px;}
.panel.hidden{transform:translateY(115%);}
.switch-row{display:flex;align-items:center;justify-content:space-between;
  font-size:1.1rem;padding:8px 0;}
.hint-text{color:var(--ink-soft);font-size:.95rem;margin:6px 0 16px;}
/* help panel content */
.help-body{max-height:60vh;overflow-y:auto;font-size:1.02rem;line-height:1.42;
  margin-bottom:12px;-webkit-overflow-scrolling:touch;}
.help-body p{margin:6px 0 10px;}
.help-body ul{margin:6px 0 12px;padding-left:20px;}
.help-body li{margin:3px 0;}
.help-tip{background:var(--note);border:2px solid var(--ink-mid);
  border-radius:var(--wobble-sm);padding:9px 13px;
  box-shadow:2px 3px 0 var(--graphite);}
.cat-list{list-style:none;padding:2px 0 0;margin:8px 0 4px;
  display:grid;grid-template-columns:1fr 1fr;gap:2px 16px;}
.cat-list li{position:relative;padding-left:16px;}
.cat-list li::before{content:"\2022";position:absolute;left:2px;color:var(--blue);}

/* reveal: a small, dim performer-side scrawl in the corner — NOT a billboard.
   Read it at arm's length; an audience at a distance or angle can't. */
.reveal-overlay{position:fixed;right:16px;bottom:58px;z-index:80;
  display:flex;align-items:flex-end;justify-content:flex-end;text-align:right;
  max-width:58vw;background:transparent;color:var(--ink);
  font-family:var(--hand-sc);
  font-size:1.2rem;text-transform:uppercase;letter-spacing:.04em;
  opacity:0;pointer-events:none;transition:opacity .12s;
  transform:rotate(-3deg);}
.reveal-overlay.show{opacity:.72;pointer-events:auto;}

/* performance mode shows the blank pencil dashes too (they just never fill) */

/* second secret input zone (bottom) — only live during the meta step, for NO */
.bot-tap-zone{position:fixed;left:0;right:0;bottom:0;height:34vh;z-index:19;
  background:transparent;pointer-events:none;}
body.meta-step .bot-tap-zone{pointer-events:auto;}
/* never let the invisible tap zones swallow taps meant for the settings panel */
body.settings-open .top-tap-zone,
body.settings-open .bot-tap-zone{pointer-events:none;}
/* performance mode: poking the keyboard does nothing and shows nothing */
body.perf-mode .key{cursor:default;}
body.perf-mode .key:active{transform:rotate(var(--tilt));box-shadow:2px 2.5px 0 var(--graphite);}
/* invisible undo hotspot (bottom-left), live only in performance */
.undo-zone{position:fixed;left:0;bottom:0;width:64px;height:64px;z-index:21;background:transparent;}

/* covert confirmation dot for the secret repeating-letter answer
   (reads as a stray pencil dot in the page corner) */
.meta-dot{position:fixed;top:14px;left:14px;width:9px;height:9px;
  border-radius:52% 48% 55% 45%/48% 52% 45% 55%;
  background:transparent;opacity:0;z-index:45;transition:opacity .15s;pointer-events:none;}
.meta-dot.show{opacity:.5;background:var(--ink);}
.meta-dot.pos-yes{left:14px;right:auto;}
.meta-dot.pos-no{left:auto;right:14px;}
.meta-dot.ready{opacity:.5;background:var(--ink);top:auto;bottom:16px;left:auto;right:16px;}
.meta-dot.warn{opacity:.65;background:var(--red);top:auto;bottom:16px;left:auto;right:16px;}

/* settings toggle — clear on/off tick box */
.toggle{display:flex;align-items:center;gap:10px;}
.perf-state{color:var(--ink-soft);min-width:26px;text-align:right;}
.switch-row input[type=checkbox]{width:26px;height:26px;accent-color:var(--blue);}
