:root {
  --paper: #f4ecda;
  --paper2: #ebe0c8;
  --ink: #2b2433;
  --red: #ff3d4a;
  --yel: #ffc21a;
  --blu: #2f7bff;
  --grn: #19c37d;
  --hand: 'Patrick Hand', 'Comic Sans MS', system-ui, sans-serif;
  --brush: 'Caveat Brush', 'Patrick Hand', cursive;
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .17 0 0 0 0 .14 0 0 0 0 .2 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--paper); color: var(--ink); font-family: var(--hand); }
canvas#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
[hidden] { display: none !important; }
button, input { font-family: var(--hand); font-size: 18px; color: var(--ink); }
button {
  background: var(--paper); border: 2.5px solid var(--ink); border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px;
  padding: 8px 18px; cursor: pointer; box-shadow: 3px 3px 0 var(--ink); transition: transform .08s, box-shadow .08s;
}
button:hover { transform: translate(-1px, -1px) rotate(-.5deg); box-shadow: 5px 5px 0 var(--ink); }
button:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
button.big {
  font-family: var(--brush); font-size: 34px; padding: 8px 30px; width: 100%;
  background: linear-gradient(100deg, #ffe066, #ffb3c7 45%, #9fd3ff); letter-spacing: 1px;
}
input {
  background: #fffaf0; border: 2.5px solid var(--ink); border-radius: 15px 225px 15px 255px / 255px 15px 225px 15px;
  padding: 7px 12px; outline: none;
}
input:focus { box-shadow: 0 0 0 3px #ffe066; }
.dim { opacity: .62; }

/* ───── menu ───── */
#menu { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; overflow-y: auto; padding: 24px 16px;
  background: radial-gradient(ellipse at center, rgba(244, 236, 218, .2) 0%, rgba(244, 236, 218, .75) 70%); }
.menu-inner { width: min(560px, 100%); text-align: center; }
.logo { font-family: var(--brush); font-weight: 400; font-size: clamp(64px, 15vw, 128px); margin: 0; line-height: .9; letter-spacing: 2px;
  text-shadow: 4px 4px 0 rgba(43, 36, 51, .15); }
.logo span { display: inline-block; animation: wob 3s ease-in-out infinite; }
.logo .u { color: var(--ink); -webkit-text-stroke: 2px var(--ink); color: transparent; }
.logo .d { color: var(--red); animation-delay: -.3s; }
.logo .r { color: var(--yel); animation-delay: -.6s; }
.logo .a { color: var(--blu); animation-delay: -.9s; }
.logo .w { color: var(--grn); animation-delay: -1.2s; }
.logo .n { color: #b86bff; animation-delay: -1.5s; }
@keyframes wob { 0%, 100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-6px) rotate(2deg); } }
.tagline { font-size: 20px; margin: 6px 0 18px; line-height: 1.3; }
.card { background: var(--paper) var(--grain); border: 2.5px solid var(--ink); border-radius: 6px 18px 8px 14px; padding: 18px; box-shadow: 6px 6px 0 rgba(43, 36, 51, .85); }
.card.main { display: flex; flex-direction: column; gap: 12px; transform: rotate(-.6deg); }
.namefield { display: flex; align-items: center; gap: 10px; font-size: 20px; }
.namefield input { flex: 1; font-size: 22px; min-width: 0; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: center; }
.row input { width: 96px; text-transform: uppercase; text-align: center; letter-spacing: 3px; }
.or { opacity: .6; }
#joinHint:empty, .msg:empty { display: none; }
#joinHint, .msg { margin: 0; font-size: 18px; }
.msg { color: #c0283a; }
.stats { margin-top: 18px; font-size: 17px; }
.total { margin-bottom: 10px; }
.total b { font-size: 22px; }
.cols { display: flex; gap: 18px; justify-content: center; text-align: left; flex-wrap: wrap; }
.cols > div { min-width: 200px; }
.cols h4 { font-family: var(--brush); font-weight: 400; font-size: 22px; margin: 0 0 4px; }
.cols span { opacity: .5; }
.room { display: block; font-size: 15px; padding: 3px 10px; margin: 4px 0; box-shadow: 2px 2px 0 var(--ink); }
.keys { font-size: 16px; opacity: .8; margin: 18px 0 4px; }
.foot { font-size: 14px; opacity: .55; margin: 0; }

/* ───── HUD ───── */
#hud { position: fixed; inset: 0; pointer-events: none; user-select: none; }
#hud .card, #hud button, #hud input { pointer-events: auto; }
#top { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 4px; }
#pageLbl { font-family: var(--brush); font-size: 30px; letter-spacing: 2px; text-shadow: 0 0 6px var(--paper), 0 0 2px var(--paper); }
#bar { position: relative; width: min(380px, 70vw); height: 22px; border: 2.5px solid var(--ink); background: var(--paper) var(--grain);
  border-radius: 20px 6px 18px 8px; overflow: hidden; box-shadow: 3px 3px 0 rgba(43, 36, 51, .6); }
#fill { position: absolute; inset: 0 auto 0 0; width: 0; transition: width .35s cubic-bezier(.3, 1.6, .5, 1);
  background: linear-gradient(90deg, var(--red), var(--yel), var(--grn), var(--blu), #b86bff); background-size: 380px 100%; }
#barTxt { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 17px; font-weight: bold; text-shadow: 0 0 3px #fff, 0 0 3px #fff; }
#timer { font-family: var(--brush); font-size: 28px; text-shadow: 0 0 6px var(--paper), 0 0 2px var(--paper); }
#timer.urgent { color: var(--red); animation: pulse .5s infinite alternate; }
@keyframes pulse { to { transform: scale(1.15); } }
#combo { opacity: 0; transform: scale(.6); transition: .15s; background: var(--ink); color: #fff; padding: 2px 12px; border-radius: 10px; font-size: 17px; position: relative; overflow: hidden; }
#combo.on { opacity: 1; transform: scale(1); }
#combo b { color: var(--yel); font-size: 20px; }
#combo i { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--yel); }
#muts { position: absolute; top: 14px; left: 14px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.chip { background: var(--ink); color: var(--paper); padding: 3px 12px 3px 8px; border-radius: 4px 14px 6px 12px; font-size: 16px; letter-spacing: 1px; animation: pop .4s cubic-bezier(.3, 1.8, .5, 1); }
.chip span { display: inline-block; width: 20px; text-align: center; margin-right: 4px; color: var(--yel); }
@keyframes pop { from { transform: scale(0) rotate(-10deg); } }
#roster { position: absolute; top: 14px; right: 14px; text-align: right; font-size: 17px; }
#roomCode { margin-bottom: 6px; text-shadow: 0 0 4px var(--paper); }
#roomCode b { letter-spacing: 3px; font-size: 20px; }
#roomCode button { font-size: 14px; padding: 2px 10px; margin-left: 6px; box-shadow: 2px 2px 0 var(--ink); }
.pl { display: flex; align-items: center; justify-content: flex-end; gap: 6px; text-shadow: 0 0 4px var(--paper), 0 0 2px var(--paper); }
.pl i { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--ink); }
.pl.me { font-weight: bold; }
.pl em { font-size: 12px; opacity: .6; }
.pl span { min-width: 34px; display: inline-block; }
#feed { position: absolute; left: 14px; bottom: 60px; width: min(420px, 60vw); display: flex; flex-direction: column; gap: 3px; font-size: 17px; }
.line { background: rgba(244, 236, 218, .88); padding: 2px 10px; border-left: 4px solid var(--ink); border-radius: 0 8px 8px 0; animation: slide .25s; transition: opacity 1s; width: fit-content; max-width: 100%; }
.line.chat { border-left-color: var(--blu); }
.line.fade { opacity: 0; }
@keyframes slide { from { transform: translateX(-20px); opacity: 0; } }
#hint { position: absolute; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(10px); opacity: 0; transition: .2s; background: var(--ink); color: var(--paper);
  padding: 6px 16px; border-radius: 14px 4px 14px 4px; font-size: 18px; white-space: nowrap; max-width: 92vw; overflow: hidden; text-overflow: ellipsis; }
#hint.on { opacity: 1; transform: translateX(-50%); }
#hint b { color: var(--yel); }
#cross { position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px; border-radius: 50%; background: var(--ink); box-shadow: 0 0 0 2px var(--paper); }
#stam { position: absolute; left: 50%; top: 50%; width: 40px; height: 40px; margin: -20px; border-radius: 50%; --v: 1;
  background: conic-gradient(var(--ink) calc(var(--v) * 360deg), transparent 0); -webkit-mask: radial-gradient(circle, transparent 15px, #000 16px); mask: radial-gradient(circle, transparent 15px, #000 16px); opacity: .55; transition: opacity .3s; }
#stam.charge { background: conic-gradient(var(--grn) calc(var(--v) * 360deg), rgba(43, 36, 51, .25) 0); opacity: 1; }
#stam.hide { opacity: 0; }
#banner { position: absolute; top: 24%; left: 50%; transform: translate(-50%, -50%) scale(.7); opacity: 0; transition: .3s cubic-bezier(.3, 1.6, .5, 1); text-align: center; width: min(760px, 94vw); }
#banner.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
#banner h2 { font-family: var(--brush); font-weight: 400; font-size: clamp(48px, 9vw, 96px); margin: 0; line-height: 1; color: var(--ink);
  text-shadow: 3px 3px 0 var(--paper), -2px -2px 0 var(--paper), 2px -2px 0 var(--paper), -2px 2px 0 var(--paper), 6px 6px 0 rgba(43, 36, 51, .2); }
#banner p { font-size: 21px; margin: 6px 0 0; background: rgba(244, 236, 218, .9); display: inline-block; padding: 4px 14px; border-radius: 8px; }
#banner.bloom h2 { background: linear-gradient(90deg, var(--red), var(--yel), var(--grn), var(--blu), #b86bff); -webkit-background-clip: text; background-clip: text; color: transparent; text-shadow: none; filter: drop-shadow(3px 3px 0 var(--ink)); }
#banner.torn h2 { color: var(--paper); text-shadow: 4px 4px 0 var(--ink), -2px -2px 0 var(--ink); transform: rotate(-3deg); }
#banner.stamp h2 { transform: rotate(-4deg); }
#banner .mut { display: block; margin-top: 6px; }
#tags { position: absolute; inset: 0; overflow: hidden; }
.tag { position: absolute; left: 0; top: 0; display: flex; flex-direction: column; align-items: center; transform-origin: 50% 100%; will-change: transform; }
.tag .nm { background: var(--paper); border: 2px solid var(--ink); border-bottom: 4px solid var(--c); padding: 0 8px; border-radius: 8px; font-size: 16px; white-space: nowrap; }
.tag.me .nm { display: none; }
.tag .nm i { font-size: 11px; opacity: .55; }
.tag .bubble { display: none; background: #fff; border: 2px solid var(--ink); border-radius: 14px; padding: 2px 10px; margin-bottom: 6px; font-size: 18px; max-width: 260px; text-align: center; position: relative; }
.tag .bubble.on { display: block; animation: pop .25s cubic-bezier(.3, 1.8, .5, 1); }
.tag .bubble::after { content: ''; position: absolute; left: 50%; bottom: -8px; border: 6px solid transparent; border-top-color: var(--ink); transform: translateX(-50%); }
.tag .rv { width: 34px; height: 34px; margin-top: 4px; border-radius: 50%; --v: 0; background: conic-gradient(var(--grn) calc(var(--v) * 360deg), rgba(43, 36, 51, .25) 0);
  -webkit-mask: radial-gradient(circle, transparent 10px, #000 11px); mask: radial-gradient(circle, transparent 10px, #000 11px); }
.float { position: absolute; left: 0; top: 0; font-family: var(--brush); font-size: 40px; --s: 1; white-space: nowrap; text-shadow: 2px 2px 0 var(--ink), -2px -2px 0 var(--ink), 2px -2px 0 var(--ink), -2px 2px 0 var(--ink); pointer-events: none; }
.float.big { font-size: 56px; background: linear-gradient(90deg, var(--red), var(--yel), var(--blu)); -webkit-background-clip: text; background-clip: text; color: transparent !important; text-shadow: none; filter: drop-shadow(2px 2px 0 var(--ink)) drop-shadow(-1px -1px 0 var(--ink)); }
#vignette { position: absolute; inset: 0; pointer-events: none; box-shadow: inset 0 0 160px 40px rgba(255, 60, 100, .55); opacity: 0; transition: opacity .4s; }
#vignette.on { opacity: 1; animation: beat .8s infinite; }
@keyframes beat { 50% { opacity: .5; } }
#hud.ghost #vignette { opacity: 1; animation: none; box-shadow: inset 0 0 200px 60px rgba(43, 36, 51, .55); }
#flash { position: absolute; inset: 0; opacity: 0; pointer-events: none; }
#flash.go { animation: flash .9s ease-out; }
@keyframes flash { from { opacity: .75; } to { opacity: 0; } }
#chat { position: absolute; left: 14px; bottom: 22px; width: min(420px, 70vw); }
#help { position: absolute; right: 14px; bottom: 14px; font-size: 15px; text-align: right; line-height: 1.45; background: rgba(244, 236, 218, .85); padding: 6px 12px; border-radius: 10px; opacity: 0; transition: .3s; }
#help.show { opacity: 1; }
#story { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: auto; cursor: pointer;
  background: linear-gradient(transparent 55%, rgba(244, 236, 218, .6)); }
#storyLine { font-family: var(--brush); font-size: clamp(30px, 5vw, 56px); text-align: center; margin: 0; padding: 0 20px; text-shadow: 0 0 12px var(--paper), 0 0 4px var(--paper); opacity: 0; }
#storyLine.in { animation: story 2.1s ease-in-out forwards; }
#storyLine em { font-style: normal; background: linear-gradient(90deg, var(--red), var(--yel), var(--blu)); -webkit-background-clip: text; background-clip: text; color: transparent; }
@keyframes story { 0% { opacity: 0; transform: translateY(10px); filter: blur(4px); } 20%, 80% { opacity: 1; transform: none; filter: none; } 100% { opacity: 0; transform: translateY(-8px); filter: blur(3px); } }
#story small { position: absolute; bottom: 24px; opacity: .55; font-size: 16px; }
#pause { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(244, 236, 218, .45); pointer-events: auto; cursor: pointer; padding: 16px; }
#pause .card { max-width: 560px; transform: rotate(-.5deg); cursor: pointer; }
#pause h3 { font-family: var(--brush); font-weight: 400; font-size: 34px; margin: 0 0 6px; text-align: center; }
#pause p { font-size: 19px; text-align: center; margin: 4px 0 10px; }
#pause p b { letter-spacing: 3px; }
#pause button { font-size: 15px; padding: 2px 12px; margin-left: 6px; }
#pause ul { font-size: 18px; padding-left: 20px; margin: 8px 0 12px; line-height: 1.35; }
#pause li { margin: 4px 0; }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--ink); margin-right: 2px; vertical-align: -1px; }
.dot.r { background: var(--red); } .dot.y { background: var(--yel); } .dot.b { background: var(--blu); }
.ghostbtn { display: block; margin: 0 auto !important; }
#awards { position: absolute; left: 50%; top: 58%; transform: translate(-50%, -50%); width: min(820px, 94vw); text-align: center; }
#awards h3 { font-family: var(--brush); font-weight: 400; font-size: 36px; margin: 0 0 8px; text-shadow: 0 0 8px var(--paper); }
#awards .cards { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
#awards .card { width: 180px; padding: 10px; border-top: 8px solid var(--c); opacity: 0; animation: deal .5s cubic-bezier(.3, 1.6, .5, 1) forwards; }
#awards .card:nth-child(odd) { transform: rotate(-2deg); }
#awards .card:nth-child(even) { transform: rotate(2deg); }
@keyframes deal { from { opacity: 0; translate: 0 40px; scale: .7; } to { opacity: 1; translate: 0 0; scale: 1; } }
#awards .t { font-family: var(--brush); font-size: 22px; }
#awards .n { font-size: 20px; font-weight: bold; color: var(--c); -webkit-text-stroke: .4px var(--ink); }
#awards .v { font-size: 16px; }
#awards .v span { opacity: .6; display: block; font-size: 14px; }
@media (max-width: 640px) {
  #muts { top: 110px; }
  #roster { font-size: 14px; }
  #feed { bottom: 70px; font-size: 14px; }
  #hint { font-size: 14px; white-space: normal; text-align: center; }
}
.stats { background: rgba(244, 236, 218, .82); border-radius: 12px; padding: 10px 14px; }
