:root {
  --ink: #1d1147; --violet: #3a148f; --violet2: #5a24d6; --pink: #ff4fa3; --yellow: #ffd23f; --orange: #ff8a2a;
  --mint: #2fd39a; --red: #ff5a6a; --card: #fff8ec; --muted: #cbbcff;
  --font: ui-rounded, "SF Pro Rounded", "Nunito", "Varela Round", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #24105e; color: #fff; font-family: var(--font); }
body { touch-action: manipulation; user-select: none; -webkit-user-select: none; }
button { font-family: inherit; cursor: pointer; }
input, textarea { font-family: inherit; user-select: text; -webkit-user-select: text; }
#app { position: fixed; inset: 0; display: flex; flex-direction: column;
  background: #2a0f78 url(img/bg.webp) center / cover no-repeat; }
#bar { display: flex; align-items: center; gap: 8px; padding: 8px 10px; padding-top: max(8px, env(safe-area-inset-top));
  background: rgba(20, 8, 60, .45); backdrop-filter: blur(4px); z-index: 5; }
.bar-title { font-weight: 900; font-size: 18px; letter-spacing: .3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp { flex: 1; }
.icon-btn { width: 42px; height: 42px; border-radius: 14px; border: 2.5px solid var(--ink); background: #fff; color: var(--ink);
  display: grid; place-items: center; box-shadow: 0 3px 0 var(--ink); padding: 0; flex: none; }
.icon-btn svg { width: 24px; height: 24px; }
.icon-btn .slash { display: none; }
.icon-btn.off .slash { display: inline; } .icon-btn.off .wave { display: none; } .icon-btn.off { background: #d9d3ee; }
.icon-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }

#screens { position: relative; flex: 1; min-height: 0; }
.screen { position: absolute; inset: 0; display: flex; flex-direction: column; animation: pop .28s ease-out; }
.screen[hidden] { display: none; }
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }
.center { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 12px 16px 20px;
  max-width: 560px; width: 100%; margin: 0 auto; overflow-y: auto; }
.scroll { flex: 1; overflow-y: auto; padding: 12px 14px 28px; max-width: 620px; width: 100%; margin: 0 auto;
  display: flex; flex-direction: column; gap: 12px; -webkit-overflow-scrolling: touch; }

/* home */
.home { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  padding: 6px 16px 14px; max-width: 520px; margin: 0 auto; text-align: center; }
.mascot { width: min(200px, 26vh); height: auto; filter: drop-shadow(0 8px 0 rgba(0,0,0,.25)); }
.mascot.small { width: 120px; }
.bob { animation: bob 2.6s ease-in-out infinite; transform-origin: 50% 100%; }
@keyframes bob { 0%,100% { transform: rotate(-3deg) translateY(0); } 50% { transform: rotate(3deg) translateY(-6px); } }
.logo { margin: 0; font-size: clamp(38px, 9vw, 58px); font-weight: 900; line-height: 1; color: var(--yellow);
  text-shadow: 0 4px 0 var(--ink), 3px 0 0 var(--ink), -3px 0 0 var(--ink), 0 -3px 0 var(--ink), 3px 4px 0 var(--ink), -3px 4px 0 var(--ink);
  letter-spacing: 1px; text-transform: uppercase; }
.logo span { color: #fff; }
.logo.small { font-size: clamp(30px, 7vw, 42px); text-align: center; }
.intro { margin: 2px 0 4px; font-size: 15px; line-height: 1.35; color: #efe9ff; max-width: 440px; font-weight: 600; }
.keys-hint { font-size: 12px; color: var(--muted); margin: 4px 0 0; }
.home-row { display: flex; gap: 10px; width: 100%; justify-content: center; flex-wrap: wrap; }
.home-row > * { flex: 1 1 140px; max-width: 240px; }
.home-row.small > * { flex: 0 1 auto; }

.big, .mid, .ghost { border: 3px solid var(--ink); border-radius: 20px; font-weight: 900; color: var(--ink); }
.big { width: 100%; max-width: 420px; padding: 16px 18px; font-size: 24px; background: var(--yellow); box-shadow: 0 6px 0 var(--ink);
  display: flex; flex-direction: column; align-items: center; line-height: 1.1; }
.big small { font-size: 13px; font-weight: 800; opacity: .75; margin-top: 3px; }
.big.primary { background: linear-gradient(#ffe36b, #ffc21a); }
.big:disabled { background: #b9b0d6; color: #554b7d; box-shadow: 0 6px 0 #3b2f6e; cursor: default; }
.big:not(:disabled):active, .mid:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--ink); }
.mid { padding: 12px 14px; font-size: 17px; background: #fff; box-shadow: 0 4px 0 var(--ink); }
.mid.alt { background: #8ff0c8; } .mid.good { background: #8ff0c8; } .mid.bad { background: #ffb3bb; }
.ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,.5); padding: 9px 14px; font-size: 15px; box-shadow: none; }
.ghost:active { background: rgba(255,255,255,.12); }
.pulse { animation: pulse 1.3s ease-in-out infinite; }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.04); } }

/* setup */
.panel { background: rgba(255,255,255,.96); color: var(--ink); border: 3px solid var(--ink); border-radius: 22px; padding: 12px;
  box-shadow: 0 5px 0 var(--ink); }
.ph { font-weight: 900; font-size: 18px; margin-bottom: 8px; } .ph.sub { font-size: 15px; margin: 12px 0 6px; }
.muted { color: #7a6fa6; font-weight: 700; } .tiny { font-size: 12.5px; margin: 6px 0 0; }
.plist { display: flex; flex-direction: column; gap: 6px; }
.prow { display: flex; align-items: center; gap: 8px; }
.prow canvas { width: 38px; height: 38px; flex: none; }
.prow input { flex: 1; min-width: 0; font-size: 17px; font-weight: 800; padding: 9px 10px; border: 2.5px solid #d6cdf5; border-radius: 12px; color: var(--ink); background: #faf8ff; }
.prow input:focus { outline: none; border-color: var(--violet2); }
.prow .x { width: 36px; height: 36px; border-radius: 12px; border: 2.5px solid var(--ink); background: #ffd5da; color: var(--ink); font-weight: 900; font-size: 18px; flex: none; }
.add { width: 100%; margin-top: 8px; background: #efe9ff; }
.stepper { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.stepper button { width: 44px; height: 44px; border-radius: 14px; border: 3px solid var(--ink); background: var(--yellow); font-size: 24px; font-weight: 900; color: var(--ink); box-shadow: 0 3px 0 var(--ink); }
.stepper b { font-size: 26px; min-width: 26px; text-align: center; }
.chk { display: inline-flex; align-items: center; gap: 7px; font-weight: 800; font-size: 14.5px; color: inherit; margin-top: 6px; cursor: pointer; }
.chk input { width: 20px; height: 20px; accent-color: var(--violet2); }
.big-chk { font-size: 16px; margin: 0 0 8px; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button { flex: 1 1 auto; padding: 10px 10px; border-radius: 14px; border: 2.5px solid var(--ink); background: #fff; color: var(--ink); font-weight: 800; font-size: 14.5px; }
.seg button.on { background: var(--violet2); color: #fff; box-shadow: inset 0 -3px 0 rgba(0,0,0,.25); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 8px 11px; border-radius: 999px; border: 2.5px solid var(--ink); background: #fff; color: var(--ink); font-weight: 800; font-size: 14px; }
.chip.on { background: var(--c, var(--violet2)); color: #fff; text-shadow: 0 1px 0 rgba(0,0,0,.35); }
textarea { width: 100%; border: 2.5px solid #d6cdf5; border-radius: 12px; padding: 9px; font-size: 15px; color: var(--ink); background: #faf8ff; resize: vertical; }
.sticky { position: sticky; bottom: 4px; margin: 4px auto 0; z-index: 2; }

/* pass + card */
.step { font-weight: 900; font-size: 14px; letter-spacing: 1px; text-transform: uppercase; color: var(--yellow); background: rgba(20,8,60,.55);
  padding: 5px 12px; border-radius: 999px; }
.who { display: flex; align-items: center; gap: 12px; }
.av { border-radius: 50%; }
.av-big { width: 64px; height: 64px; } .av-huge { width: 120px; height: 120px; }
.who-name { font-size: 30px; font-weight: 900; text-shadow: 0 3px 0 var(--ink); word-break: break-word; }
.flip { width: min(330px, 84vw); height: min(380px, 46vh); perspective: 1100px; position: relative; cursor: pointer; outline: none; }
.flip .face { position: absolute; inset: 0; border-radius: 28px; border: 4px solid var(--ink); box-shadow: 0 8px 0 var(--ink);
  backface-visibility: hidden; -webkit-backface-visibility: hidden; transition: transform .5s cubic-bezier(.3,1.4,.5,1);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 18px; text-align: center; }
.flip .back { background: repeating-linear-gradient(45deg, #ff5fa8 0 22px, #ff7cb9 22px 44px); color: #fff; }
.flip .back .q { width: 110px; height: 110px; border-radius: 50%; background: #fff; color: var(--pink); border: 4px solid var(--ink);
  font-size: 76px; font-weight: 900; display: grid; place-items: center; box-shadow: 0 5px 0 var(--ink); }
.flip .back .tap { font-size: 26px; font-weight: 900; text-shadow: 0 3px 0 var(--ink); }
.flip .back .tiny { font-size: 14px; font-weight: 800; background: rgba(29,17,71,.55); padding: 5px 10px; border-radius: 99px; }
.flip .front { background: var(--card); color: var(--ink); transform: rotateY(180deg); }
.flip.open .back { transform: rotateY(-180deg); } .flip.open .front { transform: rotateY(0); }
.flip:not(.open):hover .back { transform: rotateY(-8deg); }
.front .lbl { font-size: 14px; font-weight: 900; letter-spacing: 1px; text-transform: uppercase; color: #7a6fa6; }
.front .word { font-size: clamp(34px, 9vw, 50px); font-weight: 900; line-height: 1.05; word-break: break-word; color: var(--violet2); }
.front .cat { display: inline-block; padding: 5px 12px; border-radius: 999px; color: #fff; font-weight: 900; font-size: 14px; border: 2px solid var(--ink); }
.front .note { font-size: 14px; font-weight: 700; color: #6c6290; }
.front.imp { background: linear-gradient(#2b1269, #170838); color: #fff; }
.front.imp img { width: 120px; height: auto; }
.front.imp .word { color: var(--red); text-shadow: 0 3px 0 #000; }
.front.imp .note { color: #e8e0ff; }
.front .hint { background: var(--yellow); color: var(--ink); border: 2.5px solid var(--ink); border-radius: 14px; padding: 6px 12px; font-weight: 900; font-size: 18px; }

/* clue */
.starter { display: flex; align-items: center; gap: 12px; background: rgba(20,8,60,.5); padding: 10px 16px; border-radius: 22px; }
.lead { text-align: center; font-size: 16.5px; font-weight: 700; line-height: 1.35; margin: 0; max-width: 460px; }
.timer { position: relative; width: min(190px, 24vh); height: min(190px, 24vh); }
.timer svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.tr-bg { fill: rgba(20,8,60,.6); stroke: rgba(255,255,255,.18); stroke-width: 12; }
.tr-fg { fill: none; stroke: var(--yellow); stroke-width: 12; stroke-linecap: round; transition: stroke-dashoffset .25s linear, stroke .3s; }
.t-num { position: absolute; inset: 0; display: grid; place-items: center; font-size: clamp(34px, 6vh, 46px); font-weight: 900; text-shadow: 0 3px 0 var(--ink); }
.timer.low .tr-fg { stroke: var(--red); } .timer.low .t-num { animation: pulse .5s infinite; }
.timer.off .t-num { font-size: 22px; }

/* vote grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 9px; width: 100%; }
.tile { background: #fff; color: var(--ink); border: 3px solid var(--ink); border-radius: 18px; box-shadow: 0 4px 0 var(--ink);
  padding: 8px 4px; display: flex; flex-direction: column; align-items: center; gap: 4px; font-weight: 900; font-size: 15px; position: relative; }
.tile canvas { width: 54px; height: 54px; }
.tile span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 4px; }
.tile:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.tile.picked { background: var(--yellow); animation: stamp .35s ease-out; }
.tile .badge { position: absolute; top: -8px; right: -6px; background: var(--red); color: #fff; border: 2.5px solid var(--ink); border-radius: 999px; min-width: 28px; height: 28px; display: grid; place-items: center; font-size: 15px; }
@keyframes stamp { 0% { transform: scale(1.25) rotate(-6deg); } 100% { transform: none; } }

/* reveal */
.verdict { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.verdict.shake canvas { animation: shake .12s infinite; }
@keyframes shake { 0% { transform: translate(-3px, 1px) rotate(-3deg); } 50% { transform: translate(3px, -1px) rotate(3deg); } 100% { transform: translate(-3px, 1px) rotate(-3deg); } }
.v-name { font-size: 34px; font-weight: 900; text-shadow: 0 3px 0 var(--ink); }
.v-tag { font-size: 26px; font-weight: 900; padding: 8px 18px; border-radius: 16px; border: 3px solid var(--ink); background: #fff; color: var(--ink); box-shadow: 0 5px 0 var(--ink); }
.v-tag.good { background: var(--mint); } .v-tag.bad { background: var(--red); color: #fff; }
.v-tag.zoom { animation: zoom .45s cubic-bezier(.3,1.6,.5,1); }
@keyframes zoom { from { transform: scale(.2); opacity: 0; } to { transform: none; opacity: 1; } }
.rev-info { background: rgba(255,255,255,.96); color: var(--ink); border: 3px solid var(--ink); border-radius: 20px; padding: 12px 14px;
  text-align: center; font-weight: 800; font-size: 16px; line-height: 1.4; max-width: 440px; width: 100%; box-shadow: 0 5px 0 var(--ink); }
.rev-info:empty { display: none; }
.rev-info .w { font-size: 28px; color: var(--violet2); font-weight: 900; }
.rev-info .res { font-size: 22px; font-weight: 900; margin-top: 4px; }

/* scores */
.table { display: flex; flex-direction: column; gap: 6px; }
.row { display: flex; align-items: center; gap: 10px; background: rgba(255,255,255,.96); color: var(--ink); border: 3px solid var(--ink);
  border-radius: 16px; padding: 7px 12px; font-weight: 900; box-shadow: 0 3px 0 var(--ink); }
.row canvas { width: 38px; height: 38px; flex: none; }
.row .rk { width: 26px; text-align: center; font-size: 18px; color: #7a6fa6; }
.row .nm { flex: 1; font-size: 18px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .role { font-size: 12px; background: var(--red); color: #fff; padding: 2px 7px; border-radius: 99px; }
.row .gain { color: #18a46c; font-size: 16px; min-width: 34px; text-align: right; }
.row .pts { font-size: 22px; min-width: 38px; text-align: right; }
.row.first { background: #fff3b8; }
.podium { display: flex; justify-content: center; align-items: flex-end; gap: 8px; min-height: 200px; }
.pod { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 104px; font-weight: 900; text-align: center; }
.pod canvas { width: 64px; height: 64px; }
.pod .blk { width: 100%; border: 3px solid var(--ink); border-radius: 14px 14px 0 0; display: grid; place-items: center; font-size: 30px; color: var(--ink); box-shadow: 0 4px 0 var(--ink); }
.pod .nm { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* practice */
.pr-top { display: flex; gap: 8px; font-weight: 900; }
.pr-top span { background: rgba(20,8,60,.6); padding: 5px 12px; border-radius: 99px; }
.pr-top span:empty { display: none; }
.clues { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; width: 100%; }
.clue { display: flex; align-items: center; gap: 8px; background: #fff; color: var(--ink); border: 3px solid var(--ink); border-radius: 18px;
  padding: 8px 10px; box-shadow: 0 4px 0 var(--ink); text-align: left; font-weight: 900; }
.clue canvas { width: 46px; height: 46px; flex: none; }
.clue .cn { font-size: 12px; color: #7a6fa6; } .clue .cw { font-size: 19px; line-height: 1.1; }
.clue.right { background: var(--mint); } .clue.wrong { background: #ffb3bb; } .clue.dim { opacity: .55; }
.clue:not(:disabled):active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.opts { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; width: 100%; }
.opts button { padding: 14px 8px; font-size: 18px; border-radius: 16px; border: 3px solid var(--ink); background: #fff; color: var(--ink); font-weight: 900; box-shadow: 0 4px 0 var(--ink); }
.opts button.right { background: var(--mint); } .opts button.wrong { background: #ffb3bb; }
.pr-msg { min-height: 26px; font-size: 20px; font-weight: 900; text-align: center; text-shadow: 0 2px 0 var(--ink); }
.bigscore { font-size: 64px; font-weight: 900; color: var(--yellow); text-shadow: 0 5px 0 var(--ink); }

/* how / words */
.how { display: flex; flex-direction: column; gap: 9px; }
.how-step { display: flex; gap: 12px; align-items: flex-start; background: rgba(255,255,255,.96); color: var(--ink); border: 3px solid var(--ink);
  border-radius: 18px; padding: 10px 12px; font-size: 15.5px; line-height: 1.38; font-weight: 600; box-shadow: 0 4px 0 var(--ink); }
.how-step .n { flex: none; width: 34px; height: 34px; border-radius: 50%; background: var(--yellow); border: 2.5px solid var(--ink); display: grid; place-items: center; font-weight: 900; font-size: 18px; }
.gen { background: rgba(255,255,255,.96); color: var(--ink); border: 3px solid var(--ink); border-radius: 22px; padding: 14px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 8px; box-shadow: 0 5px 0 var(--ink); }
.gen-cat { font-weight: 900; color: #7a6fa6; text-transform: uppercase; letter-spacing: 1px; font-size: 13px; }
.gen-word { font-size: clamp(34px, 9vw, 48px); font-weight: 900; color: var(--violet2); line-height: 1.1; }
.gen-word.zoom { animation: zoom .35s cubic-bezier(.3,1.6,.5,1); }
.wordlist { display: flex; flex-wrap: wrap; gap: 6px; }
.wordlist span { background: rgba(255,255,255,.92); color: var(--ink); border-radius: 10px; padding: 5px 9px; font-weight: 800; font-size: 14.5px; }

#fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 20; }
#toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 14px;
  font-weight: 800; z-index: 30; border: 2px solid #fff; max-width: 90vw; text-align: center; }
#toast[hidden] { display: none; }

@media (max-height: 700px) {
  .mascot { width: min(150px, 22vh); }
  .intro { font-size: 13.5px; }
  .big { padding: 12px 16px; font-size: 21px; }
  .flip { height: min(330px, 44vh); }
}
@media (min-width: 900px) and (min-height: 640px) {
  .home { flex-direction: column; }
}
.clue > div { min-width: 0; } .clue .cw { word-break: break-word; }
.scroll > .big { align-self: center; } .scroll > .ghost { align-self: center; }
