/* DRAWY – sketchbook style */
@font-face { font-family: 'Caveat'; src: url('fonts/caveat-latin-700-normal.woff2') format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('fonts/inter-latin-400-normal.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('fonts/inter-latin-600-normal.woff2') format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('fonts/inter-latin-800-normal.woff2') format('woff2'); font-weight: 800; font-display: swap; }

:root {
  --paper: #FAF7F0;
  --sheet: #FFFDF7;
  --ink: #1A1A1A;
  --accent: #14A89B;
  --accent-soft: #D9F0EC;
  --danger: #F07167;
  --warn: #F5C542;
  --border: #DCD5C6;
  --muted: #8A8378;
  --good: #2FA84F;
  --wob: 18px 6px 16px 8px / 8px 16px 6px 18px;
  --wob2: 255px 15px 225px 15px / 15px 225px 15px 255px;
  --shadow: 2px 3px 0 rgba(26, 26, 26, .16);
  --hand: 'Caveat', 'Comic Sans MS', cursive;
  --ui: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background-color: var(--paper);
  background-image:
    radial-gradient(rgba(26,26,26,.035) 1px, transparent 1.2px),
    radial-gradient(rgba(26,26,26,.025) 1px, transparent 1.2px);
  background-size: 23px 23px, 37px 37px;
  background-position: 0 0, 11px 17px;
  color: var(--ink);
  font-family: var(--ui);
  font-size: 16px;
  line-height: 1.35;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; line-height: 1.1; }
h2 { font-family: var(--hand); font-size: 1.7rem; font-weight: 700; }
h3 { font-family: var(--hand); font-size: 1.6rem; }
p { margin: .4em 0; }
.muted { color: var(--muted); }
.small { font-size: .85em; }
[hidden] { display: none !important; }

#app { min-height: 100dvh; max-width: 560px; margin: 0 auto; display: flex; flex-direction: column; }
.pad { padding: 10px 14px 24px; display: flex; flex-direction: column; gap: 12px; }

/* ---------- basic pieces */
.card {
  background: var(--sheet);
  border: 2px solid var(--ink);
  border-radius: var(--wob);
  box-shadow: var(--shadow);
  padding: 12px 14px;
}
.card h2 { margin-bottom: 8px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 8px 18px;
  background: var(--accent); color: #fff;
  border: 2.5px solid var(--ink); border-radius: var(--wob2);
  font-weight: 800; letter-spacing: .02em;
  box-shadow: var(--shadow);
  transition: transform .08s;
}
.btn:active:not(:disabled) { transform: translate(1px, 2px); box-shadow: none; }
.btn:disabled { background: var(--border); color: var(--muted); border-color: var(--muted); cursor: default; }
.btn.big { width: 100%; min-height: 58px; font-size: 1.15rem; }
.btn.ghost { background: var(--sheet); color: var(--ink); }
.btn.warn { background: var(--sheet); color: #c43c33; }
.btn.tiny { min-height: 34px; padding: 4px 10px; font-size: .85rem; }
.btn.hub { background: var(--ink); color: #fff; }
.link { background: none; border: 0; padding: 8px; color: var(--ink); text-decoration: underline; text-decoration-style: wavy; text-decoration-color: var(--border); text-underline-offset: 5px; }
.link.small { font-size: .85rem; color: var(--muted); }
.ibtn { width: 44px; height: 44px; border: 2px solid var(--ink); border-radius: 50% 45% 52% 48%; background: var(--sheet); font-size: 1.2rem; display: grid; place-items: center; box-shadow: var(--shadow); padding: 0; }

input, textarea {
  width: 100%; padding: 12px 14px;
  background: #fff; border: 2px solid var(--ink); border-radius: var(--wob);
  font-size: 1.05rem; outline: none;
}
input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: none; }
.shake { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-6px); } 50% { transform: translateX(6px); } 75% { transform: translateX(-3px); } }

.ava { width: 32px; height: 32px; flex: none; display: block; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips.row { flex-wrap: nowrap; overflow-x: auto; padding: 4px 12px 6px; scrollbar-width: none; }
.chips.row::-webkit-scrollbar { display: none; }
.chip {
  position: relative; display: inline-flex; align-items: center; gap: 6px; flex: none;
  padding: 3px 10px 3px 4px; background: #fff;
  border: 2px solid var(--pc, var(--border)); border-radius: 999px 900px 999px 950px;
  font-weight: 600; font-size: .9rem; white-space: nowrap;
}
.chip .ava { width: 28px; height: 28px; }
.chip.me { background: var(--accent-soft); }
.chip.off { opacity: .45; }
.chip .sc { font-weight: 800; color: var(--muted); font-size: .85rem; }
.chip .badge, .badge { font-size: .9rem; }
.chip .crown { font-size: .85rem; }
.chips.big .chip { font-size: 1.15rem; padding: 5px 16px 5px 6px; }
.chips.big .chip .ava { width: 42px; height: 42px; }

/* ---------- top bar */
.top {
  position: sticky; top: 0; z-index: 5;
  display: grid; grid-template-columns: 44px 1fr 48px; align-items: center; gap: 8px;
  padding: 8px 12px; background: var(--paper);
  border-bottom: 2px dashed var(--border);
}
.top .mid { text-align: center; font-weight: 600; display: flex; flex-direction: column; align-items: center; line-height: 1.15; min-width: 0; }
.top .mid > div { display: flex; flex-direction: column; align-items: center; }
.top .rnd { font-size: .72rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.top .brand { font-family: var(--hand); font-size: 1.9rem; font-weight: 700; }
.top .rt { display: flex; justify-content: flex-end; }
.hot { color: #c43c33; font-weight: 800; animation: pulse 1s infinite; }
@keyframes pulse { 50% { transform: scale(1.06); } }

/* ---------- timer */
.timer { position: relative; width: 46px; height: 46px; }
.timer svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.timer circle { fill: none; stroke-width: 4.5; }
.timer .tr-bg { stroke: var(--border); fill: #fff; }
.timer .tr-fg { stroke: var(--accent); stroke-dasharray: 100; stroke-linecap: round; transition: stroke .3s; }
.timer span { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 800; font-size: .95rem; }
.timer.warn .tr-fg { stroke: var(--warn); }
.timer.crit .tr-fg { stroke: var(--danger); }
.timer.crit span { color: #c43c33; animation: pulse .5s infinite; }
.timer.big { width: 96px; height: 96px; }
.timer.big span { font-size: 2rem; }

/* ---------- start */
.start { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; gap: 14px; padding: 24px 20px; }
.logo { text-align: center; }
.logo h1 { font-family: var(--hand); font-size: 5.2rem; font-weight: 700; letter-spacing: .02em; transform: rotate(-3deg); }
.logo .squiggle { width: 180px; height: 18px; display: block; margin: -10px auto 4px; }
.logo p { font-family: var(--hand); font-size: 1.6rem; color: var(--muted); margin: 0; }
.namecard { display: flex; flex-direction: column; gap: 10px; }
.namecard label { font-weight: 600; }
.notice { background: #fff3c4; border: 2px solid var(--warn); border-radius: var(--wob); padding: 8px 12px; text-align: center; }
.tvlink { align-self: center; font-size: .95rem; display: flex; flex-direction: column; align-items: center; }
.tvlink small { color: var(--muted); font-size: .75rem; text-decoration: none; }
.start .muted { text-align: center; }
.start .link.small { align-self: center; }

/* ---------- lobby */
.modes { display: grid; gap: 8px; margin-bottom: 10px; }
.mode {
  display: grid; grid-template-columns: 44px 1fr auto; grid-template-rows: auto auto; column-gap: 10px; text-align: left;
  padding: 10px 12px; background: #fff; border: 2px solid var(--border); border-radius: var(--wob);
}
.mode .mi { grid-row: 1 / 3; font-size: 1.9rem; display: grid; place-items: center; }
.mode .mt { font-family: var(--hand); font-size: 1.6rem; font-weight: 700; line-height: 1; }
.mode .mm { font-size: .72rem; color: var(--muted); align-self: start; }
.mode .md { grid-column: 2 / 4; font-size: .88rem; color: #4b463f; }
.mode.sel { border-color: var(--ink); background: var(--accent-soft); box-shadow: var(--shadow); }
.modes.ro .mode { cursor: default; }
.sets { display: grid; gap: 8px; margin: 6px 0 12px; }
.set { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: .92rem; font-weight: 600; flex-wrap: wrap; }
.seg { display: flex; border: 2px solid var(--ink); border-radius: 10px 4px 10px 4px; overflow: hidden; }
.seg button { border: 0; background: #fff; padding: 6px 10px; min-width: 42px; font-weight: 600; border-left: 1.5px solid var(--border); }
.seg button:first-child { border-left: 0; }
.seg button.on { background: var(--ink); color: #fff; }
.seg button:disabled:not(.on) { color: var(--muted); }
.seg button:disabled { cursor: default; }
.wait { text-align: center; font-family: var(--hand); font-size: 1.5rem; color: var(--muted); }
.dots i { display: inline-block; width: 6px; height: 6px; margin: 0 2px; background: var(--muted); border-radius: 50%; animation: blink 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: .2s; }
.dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 50% { opacity: .2; } }

/* ---------- chat */
.chatcard { display: flex; flex-direction: column; gap: 6px; }
.feed { overflow-y: auto; display: flex; flex-direction: column; gap: 2px; font-size: .92rem; }
.lobby .feed { max-height: 160px; min-height: 40px; }
.cm { padding: 2px 4px; word-break: break-word; }
.cm.sys { color: var(--muted); font-style: italic; font-size: .85rem; }
.cm.sys.priv { color: #8a6a00; background: #fff6d6; border-radius: 6px; font-style: normal; font-weight: 600; }
.cm.ok { color: #1f7a39; font-weight: 800; background: #e4f6e9; border-radius: 6px; }
.cm.inner { color: #1f7a39; }
.chatform { display: flex; gap: 6px; }
.chatform input { padding: 10px 12px; }
.chatform .send { flex: none; width: 46px; height: 46px; border-radius: 12px 8px 14px 6px; background: var(--accent); color: #fff; }

/* ---------- play (phone) */
.play { flex: 1; display: flex; flex-direction: column; gap: 6px; padding: 6px 0 8px; min-height: 0; }
.wordbar { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 40px; padding: 0 12px; flex-wrap: wrap; }
.wordbar .lbl { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.wordbar .word { font-family: var(--hand); font-size: 2.1rem; font-weight: 700; line-height: 1; }
.wordbar .word.sm { font-size: 1.7rem; }
.wordbar .word.ok { color: var(--good); }
.wordbar .cnt { font-size: .8rem; font-weight: 800; color: var(--muted); }
.wordbar .turnc { margin-left: 6px; padding: 2px 8px; border: 1.5px solid var(--border); border-radius: 999px; }
.blanks { display: inline-flex; gap: 5px; font-family: var(--ui); font-weight: 800; font-size: 1.35rem; letter-spacing: 0; }
.blanks i { font-style: normal; text-align: center; line-height: 1.1; }
.blanks i.bx { width: .8em; height: 1.25em; border-bottom: 3px solid var(--ink); }
.blanks i.l { color: var(--accent); }
.blanks i.sp { width: .5em; }

.boardwrap { position: relative; width: min(100% - 16px, calc(50dvh * 4 / 3)); aspect-ratio: 4 / 3; margin: 0 auto; flex: none; }
.boardwrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; background: #FFFDF7; border: 2.5px solid var(--ink); border-radius: 10px 4px 12px 5px / 5px 12px 4px 10px; box-shadow: var(--shadow); touch-action: none; }
.boardwrap canvas.can-draw { cursor: crosshair; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow); }
.boardwrap.ro { width: 100%; }
.ov { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; padding: 10px; background: rgba(250, 247, 240, .82); border-radius: 10px; z-index: 2; }
.ov.on { display: flex; }
.ovbox { background: var(--sheet); border: 2.5px solid var(--ink); border-radius: var(--wob); box-shadow: var(--shadow); padding: 14px 16px; text-align: center; max-width: 100%; max-height: 100%; overflow: auto; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.ovbox .ava { width: 54px; height: 54px; }
.bigword { font-family: var(--hand); font-size: 2.6rem; font-weight: 700; line-height: 1; }
.choices { display: grid; gap: 8px; width: 100%; margin-top: 6px; }
.choices .btn { flex-direction: column; gap: 0; font-size: 1.15rem; }
.choices .btn small { font-weight: 600; font-size: .7rem; opacity: .85; text-transform: uppercase; }
.choices .easy { background: var(--good); }
.choices .mid { background: #e09116; }
.choices .hard { background: #c43c33; }

.tools { display: flex; flex-direction: column; gap: 6px; padding: 0 10px; }
.tools .row { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.colors { display: flex; justify-content: space-between; gap: 4px; }
.sw { flex: 1 1 0; max-width: 34px; aspect-ratio: 1; height: auto; min-width: 0; border-radius: 48% 52% 46% 54%; border: 2px solid var(--ink); background: var(--c); padding: 0; }
.sw.on { box-shadow: 0 0 0 3px var(--paper), 0 0 0 5.5px var(--ink); }
.sw.er { background: #fff; font-size: 1rem; }
.sizes, .acts { display: flex; gap: 6px; }
.sz, .tb { width: 42px; height: 42px; border: 2px solid var(--ink); border-radius: 12px 6px 12px 7px; background: #fff; display: grid; place-items: center; padding: 0; font-size: 1.2rem; }
.sz i { width: var(--z); height: var(--z); max-width: 28px; max-height: 28px; border-radius: 50%; background: var(--ink); display: block; }
.sz.on, .tb.on { background: var(--accent-soft); border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }

.panel { padding: 0 12px; }
.spec { text-align: center; color: var(--muted); font-size: .88rem; }
.play .chatcard { flex: 1; min-height: 120px; padding: 0 10px; display: flex; flex-direction: column; }
.play .feed { flex: 1; min-height: 60px; max-height: 32dvh; background: #fff; border: 2px solid var(--border); border-radius: var(--wob); padding: 6px 8px; }
.ovbox .chip .ava { width: 28px; height: 28px; }
.ovbox .bigword { margin: 0; }
.pts { list-style: none; padding: 0; margin: 6px 0 0; display: grid; gap: 4px; width: 100%; min-width: 180px; }
.pts li { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.pts li .ava { width: 26px; height: 26px; }
.pts li span { flex: 1; text-align: left; }
.pts li b { color: var(--good); }

/* ---------- imposter */
.secret { padding: 0 12px; }
.hold { width: 100%; min-height: 44px; border: 2px dashed var(--ink); border-radius: var(--wob); background: #fff; font-weight: 600; user-select: none; -webkit-user-select: none; touch-action: none; }
.hold.shown { background: var(--accent-soft); border-style: solid; font-size: 1.15rem; }
.hold .imp, .imp-txt { color: #c43c33; }
.role h3 { font-size: 3rem; }
.role.imp { border-color: var(--danger); box-shadow: 0 0 0 4px rgba(240,113,103,.35), var(--shadow); }
.role.imp h3 { color: #c43c33; }
.role.crew { border-color: var(--accent); }
.turns { display: flex; gap: 6px; overflow-x: auto; padding: 4px 0; scrollbar-width: none; }
.tn { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: .75rem; font-weight: 600; opacity: .55; flex: none; min-width: 52px; }
.tn .ava { width: 34px; height: 34px; border-radius: 50%; }
.tn.now { opacity: 1; }
.tn.now .ava { box-shadow: 0 0 0 3px var(--pc); transform: scale(1.12); }
.vote .vlist { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.vbtn { display: flex; align-items: center; gap: 8px; padding: 8px; background: #fff; border: 2px solid var(--pc); border-radius: var(--wob); font-weight: 600; text-align: left; }
.vbtn .ava { width: 34px; height: 34px; }
.vbtn span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vbtn small { font-size: .65rem; color: var(--muted); }
.vbtn.on { background: var(--ink); color: #fff; box-shadow: 0 0 0 3px var(--pc); }
.tally { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 4px; width: 100%; min-width: 200px; }
.tally li { display: flex; align-items: center; gap: 8px; padding: 3px 8px; border-radius: 10px; font-weight: 600; animation: flip .4s both; }
.tally li:nth-child(2) { animation-delay: .25s; } .tally li:nth-child(3) { animation-delay: .5s; } .tally li:nth-child(4) { animation-delay: .75s; } .tally li:nth-child(n+5) { animation-delay: 1s; }
.tally li .ava { width: 28px; height: 28px; }
.tally li span { flex: 1; text-align: left; }
.tally li b { font-size: 1.2rem; }
.tally li.imp { background: rgba(240,113,103,.25); box-shadow: 0 0 0 2px var(--danger); }
@keyframes flip { from { transform: rotateX(90deg); opacity: 0; } to { transform: none; opacity: 1; } }
.good { color: var(--good); }
.bad { color: #c43c33; }
.flash { animation: flash .6s 3; }
@keyframes flash { 50% { color: #fff; text-shadow: 0 0 12px var(--good); } }
h3.shake { animation: shake .35s 2; }
.live { text-align: center; }
.typed { display: flex; justify-content: center; flex-wrap: wrap; gap: 2px; font-family: var(--hand); font-size: 2.6rem; font-weight: 700; min-height: 3rem; }
.typed i { font-style: normal; animation: pop .2s; }
.caret { animation: blink 1s infinite; color: var(--muted); }
@keyframes pop { from { transform: scale(1.6); } }
.guessbox { display: flex; gap: 8px; padding: 0 12px; }
.guessbox .btn { flex: none; }

/* ---------- telephone */
.tel h2 { font-size: 1.6rem; }
.tel textarea { font-size: 1.1rem; }
.tel .boardwrap { width: min(100%, calc(48dvh * 4 / 3)); }
.prompt { background: #fff; border: 2px solid var(--ink); border-radius: var(--wob); padding: 8px 12px; box-shadow: var(--shadow); }
.prompt .lbl { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.prompt p { font-family: var(--hand); font-size: 1.7rem; font-weight: 700; margin: 0; line-height: 1.1; }
.tel .tools { padding: 0; }
.telwait { position: fixed; inset: 0; z-index: 8; display: none; align-items: center; justify-content: center; padding: 20px; background: rgba(250,247,240,.9); }
.telwait.on { display: flex; }
.telwait .chips { justify-content: center; margin-top: 8px; }

/* ---------- show + final */
.show { align-items: stretch; }
.showmain { display: flex; flex-direction: column; gap: 10px; align-items: stretch; width: 100%; }
.gal { width: 100%; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.gal .boardwrap { width: 100%; }
.dots2 { display: flex; gap: 5px; justify-content: center; flex-wrap: wrap; }
.dots2 i { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid var(--ink); }
.dots2 i.past { background: var(--border); }
.dots2 i.on { background: var(--accent); }
.shownav { display: flex; gap: 10px; }
.shownav .btn { flex: 1; }
.chain h2 { margin-bottom: 8px; }
.entries { display: flex; flex-direction: column; gap: 10px; }
.ent { background: #fff; border: 2px solid var(--border); border-radius: var(--wob); padding: 8px 10px; }
.ent.fresh { animation: slidein .45s both; border-color: var(--ink); box-shadow: var(--shadow); }
@keyframes slidein { from { transform: translateY(18px) rotate(-1deg); opacity: 0; } }
.ent .by { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: .85rem; color: var(--pc); }
.ent .by .ava { width: 22px; height: 22px; }
.ent.txt p { font-family: var(--hand); font-size: 1.8rem; font-weight: 700; margin: 2px 0 0; line-height: 1.1; }
.ent .boardwrap { margin-top: 6px; }
.likerow { display: flex; justify-content: center; }
.like { background: #fff; color: #c43c33; min-width: 120px; }
.like.on { background: #c43c33; color: #fff; }
.likes { font-weight: 800; color: #c43c33; font-size: 1.3rem; }
.final { display: flex; flex-direction: column; gap: 12px; align-items: center; text-align: center; }
.tvbig { font-family: var(--hand); font-size: 2.6rem; }
.podium3 { display: flex; align-items: flex-end; justify-content: center; gap: 10px; margin-top: 8px; width: 100%; }
.p3 { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 30%; max-width: 140px; font-weight: 800; }
.p3 .ava { width: 54px; height: 54px; }
.p3 .block { width: 100%; background: var(--pc); border: 2.5px solid var(--ink); border-radius: 10px 10px 0 0; color: #fff; font-family: var(--hand); font-size: 2.2rem; display: grid; place-items: center; box-shadow: var(--shadow); }
.p3.pl1 .block { height: 110px; } .p3.pl2 .block { height: 78px; } .p3.pl3 .block { height: 54px; }
.p3.pl1 .ava { width: 70px; height: 70px; animation: bounce 1s infinite; }
@keyframes bounce { 50% { transform: translateY(-8px) rotate(4deg); } }
.podium { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.pod { display: flex; flex-direction: column; align-items: center; padding: 8px; background: #fff; border: 2px solid var(--pc); border-radius: var(--wob); min-width: 90px; font-weight: 600; }
.stand { list-style: none; padding: 0; margin: 0; display: grid; gap: 5px; width: 100%; }
.stand li { display: flex; align-items: center; gap: 8px; padding: 4px 8px; background: #fff; border: 2px solid var(--border); border-left: 6px solid var(--pc); border-radius: 10px 4px 10px 4px; font-weight: 600; }
.stand li.off { opacity: .5; }
.stand li.cur { border-color: var(--ink); background: var(--accent-soft); }
.stand .pl { font-family: var(--hand); font-size: 1.4rem; width: 1.2em; text-align: center; }
.stand .nm { flex: 1; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stand .ava { width: 28px; height: 28px; }
.stand .plus { color: var(--good); font-weight: 800; font-size: .9rem; }
.stand b { font-weight: 800; min-width: 2.5em; text-align: right; }

/* ---------- menu, banner, toast */
#menu { position: fixed; inset: 0; z-index: 20; background: rgba(26,26,26,.35); display: none; align-items: flex-end; justify-content: center; }
#menu.open { display: flex; }
.sheet { width: min(100%, 520px); max-height: 92dvh; overflow-y: auto; background: var(--paper); border: 2.5px solid var(--ink); border-bottom: 0; border-radius: 22px 18px 0 0; padding: 14px 16px 22px; display: flex; flex-direction: column; gap: 10px; animation: up .2s; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheethead { display: flex; justify-content: space-between; align-items: center; }
.rules { background: #fff; border: 2px solid var(--border); border-radius: var(--wob); padding: 8px 12px; }
.rules summary { font-weight: 600; cursor: pointer; }
.rules ol { margin: 8px 0 0; padding-left: 20px; font-size: .92rem; }
.kick h3 { font-size: 1.4rem; margin-bottom: 6px; }
.kr { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
#banner { position: fixed; top: 0; left: 0; right: 0; z-index: 30; background: var(--warn); color: var(--ink); text-align: center; font-weight: 600; padding: 6px; transform: translateY(-100%); transition: transform .25s; border-bottom: 2px solid var(--ink); }
#banner.show { transform: none; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 40; background: var(--ink); color: #fff; padding: 10px 18px; border-radius: var(--wob2); font-weight: 600; transition: opacity .4s; max-width: 90vw; text-align: center; }
.toast.out { opacity: 0; }

/* ================================================================ TV (landscape, big screen) */
body.tv { overflow: hidden; font-size: 1rem; }
body.tv #app { max-width: none; height: 100vh; }
html:has(body.tv) { font-size: clamp(15px, 1.32vw, 34px); }
body.tv .ava { width: 2.4rem; height: 2.4rem; }
.tvwrap { position: relative; height: 100vh; width: 100vw; display: flex; padding: 1.4rem 1.8rem; gap: 1.6rem; }
.tvmenu { position: absolute; left: .8rem; bottom: .8rem; opacity: .35; }
.tvmenu:hover { opacity: 1; }
.tvh { font-family: var(--hand); font-size: 1.9rem; margin: .3rem 0 .5rem; }
.tvlogo h1 { font-size: 6rem; }
.tvlogo p { font-size: 2rem; }

.tvlobby .tvleft { width: 38%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1rem; }
.tvlobby .tvright { flex: 1; display: flex; flex-direction: column; gap: 1rem; overflow-y: auto; padding: .4rem; }
.qrbox { display: flex; flex-direction: column; align-items: center; padding: 1.2rem 1.6rem; transform: rotate(-1deg); }
.qr { width: min(28vw, 52vh); aspect-ratio: 1; }
.qr svg { width: 100%; height: 100%; display: block; }
.scan { font-family: var(--hand); font-size: 2.6rem; font-weight: 700; margin: .4rem 0 0; }
.url { color: var(--muted); font-weight: 600; margin: 0; }
.tvbtns { display: flex; gap: 1rem; }
.tvlobby .modes { grid-template-columns: repeat(3, 1fr); }
.tvlobby .mode { grid-template-columns: 1fr; text-align: center; justify-items: center; }
.tvlobby .mode .mi { grid-row: auto; font-size: 2.6rem; }
.tvlobby .mode .md, .tvlobby .mode .mm { grid-column: auto; }
.tvlobby .modes.ro { grid-template-columns: 1fr; }
.tvlobby .sets { grid-template-columns: 1fr 1fr; column-gap: 2rem; }

.tvplay .tvmain { flex: 1; display: flex; flex-direction: column; align-items: center; gap: .8rem; min-width: 0; }
.tvhead { display: flex; align-items: center; justify-content: center; gap: 1.6rem; font-size: 1.5rem; font-weight: 600; flex-wrap: wrap; min-height: 3.4rem; }
.tvhead .rnd { font-size: 1rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.tvhead .who { display: inline-flex; align-items: center; gap: .6rem; }
.tvhead .who .ava { width: 3rem; height: 3rem; box-shadow: 0 0 0 4px var(--pc); border-radius: 50%; }
.tvhead .word { font-family: var(--hand); font-size: 2.6rem; }
.tvhead .cnt { color: var(--muted); font-weight: 800; }
.tvbl { font-size: 2.4rem; gap: .5rem; }
.tvplay .boardwrap { width: min(100%, calc((100vh - 7.5rem) * 4 / 3)); }
.tvside { width: 21rem; flex: none; display: flex; flex-direction: column; gap: .4rem; min-height: 0; }
.tvtimer { display: flex; justify-content: center; }
.tvside .stand li { font-size: 1.2rem; padding: .35rem .7rem; }
.tvfeed:empty { visibility: hidden; }
.tvfeed { flex: 1; min-height: 0; overflow: hidden; justify-content: flex-end; font-size: 1.15rem; background: rgba(255,255,255,.6); border-radius: var(--wob); padding: .4rem .6rem; }
.miniqr { display: flex; align-items: center; gap: .6rem; color: var(--muted); font-size: .9rem; font-weight: 600; }
.miniqr > div { width: 5.5rem; height: 5.5rem; }
.miniqr svg { width: 100%; height: 100%; }
.tvb { font-size: 1.3rem; }
.tvb h3, .tvb .bigword { font-size: 3.4rem; }
.tvb .ava { width: 2.6rem; height: 2.6rem; }
body.tv .ovbox .ava { width: 4rem; height: 4rem; }
body.tv .tally li .ava, body.tv .pts li .ava { width: 2.2rem; height: 2.2rem; }
body.tv .typed { font-size: 4.5rem; }
body.tv .turns { flex-wrap: wrap; }
body.tv .tn { font-size: 1rem; min-width: 4.5rem; }
body.tv .tn .ava { width: 3rem; height: 3rem; }

.tvtel { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.4rem; text-align: center; }
.donegrid { display: flex; flex-wrap: wrap; justify-content: center; gap: 1rem; max-width: 80rem; }
.dg { display: flex; flex-direction: column; align-items: center; gap: .3rem; padding: .8rem 1rem; min-width: 9rem; background: #fff; border: 2.5px solid var(--border); border-radius: var(--wob); font-weight: 600; font-size: 1.2rem; }
body.tv .dg .ava { width: 4.6rem; height: 4.6rem; }
.dg b { font-size: 1.6rem; }
.dg.ok { border-color: var(--pc); box-shadow: var(--shadow); }

.tvwrap.show .showmain { flex: 1; align-items: center; justify-content: center; min-width: 0; }
.tvwrap.show .gal .boardwrap { width: min(100%, calc((100vh - 17rem) * 4 / 3)); }
.tvwrap.show .gal .bigword { font-size: 3.6rem; }
.tvwrap.show .gal p { font-size: 1.3rem; }
.tvwrap.show .shownav { width: 30rem; }
.tvchain { width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; }
.tvchain h2 { font-size: 2.6rem; }
.tvchain .entries { display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); align-items: center; gap: 1.2rem; flex: 1; width: 100%; max-width: calc((100vh - 9rem) * 1.9); align-content: center; }
.tvchain .ent { height: 100%; max-height: 42vh; display: flex; flex-direction: column; justify-content: center; }
.tvchain .ent .boardwrap { width: 100%; max-width: calc(30vh * 4 / 3); }
.tvchain .ent.fresh { transform: scale(1.04); }
.tvchain .ent.txt p { font-size: 2.2rem; }
.ent.hid { display: grid; place-items: center; min-height: 8rem; border-style: dashed; color: var(--border); font-family: var(--hand); font-size: 4rem; background: transparent; }
.tvwrap.show .final .podium3 { max-width: 46rem; }
.tvwrap.show .p3 { max-width: 13rem; font-size: 1.4rem; }
.tvwrap.show .p3 .ava { width: 6rem; height: 6rem; }
.tvwrap.show .p3.pl1 .block { height: 12rem; } .tvwrap.show .p3.pl2 .block { height: 8.5rem; } .tvwrap.show .p3.pl3 .block { height: 6rem; }
.tvwrap.show .final .btn.big { width: 26rem; }
.tvwrap.show .final .tvbig { font-size: 4rem; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* TV lobby: easier to read from the sofa */
.tvlobby .mode .md { font-size: 1rem; }
.tvlobby .mode .mt { font-size: 2rem; }
.tvlobby .set { font-size: 1.1rem; }
.tvlobby .seg button { padding: .35rem .8rem; }
.tvlobby .wait { font-size: 1.9rem; }

/* classic: drawing of the game */
.best { width: 100%; text-align: center; background: #fff; border: 2px solid var(--ink); border-radius: var(--wob); box-shadow: var(--shadow); padding: 10px 12px; }
.best h3 { color: #c43c33; margin-bottom: 6px; }
.bestrow { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.bestit { flex: 1 1 140px; max-width: 320px; }
.bestit p { margin: 4px 0 0; font-size: .9rem; }
.tvwrap.show .final { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); width: 100%; align-items: end; column-gap: 2.5rem; row-gap: 1rem; max-height: 100%; }
.tvwrap.show .final > * { grid-column: 1 / -1; justify-self: center; }
.tvwrap.show .final > .podium3 { grid-column: 1; width: 100%; max-width: 34rem; justify-self: end; }
.tvwrap.show .final > .best { grid-column: 2; align-self: end; justify-self: start; }
.tvwrap.show .final:not(:has(.best)) > .podium3 { grid-column: 1 / -1; }
.finalbtns { width: 100%; display: flex; justify-content: center; }
.tvwrap.show .final > .tvbig, .tvwrap.show .final > .finalbtns, .tvwrap.show .final > p { flex-basis: 100%; }
.tvbest { width: 100%; max-width: 26rem; }
.tvbest .boardwrap { width: min(100%, calc(38vh * 4 / 3)); }
.tvbest .bestit { max-width: none; flex-basis: 100%; }
.tvbest:has(.bestit + .bestit) { max-width: 40rem; }
.tvbest:has(.bestit + .bestit) .bestit { flex-basis: 45%; }
.tvbest p { font-size: 1.2rem; }
.gal .like { min-width: 110px; }

/* telephone: likes per entry, time-lapse, top moments */
.enthead { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.elike { font-weight: 800; color: #c43c33; font-size: .9rem; }
.btnlike { border: 2px solid #c43c33; background: #fff; border-radius: 999px; padding: 3px 12px; min-width: 52px; min-height: 34px; }
.btnlike.on { background: #c43c33; color: #fff; }
.drawnow { position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%); background: var(--ink); color: #fff; font-weight: 600; font-size: .85rem; padding: 4px 12px; border-radius: 999px; white-space: nowrap; animation: pulse 1s infinite; }
body.tv .drawnow { font-size: 1.1rem; }
.final.tel h3 { color: #c43c33; }
.moments { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; width: 100%; }
.moment { position: relative; flex: 1 1 140px; max-width: 300px; background: #fff; border: 2.5px solid var(--pc); border-radius: var(--wob); box-shadow: var(--shadow); padding: 10px; }
.moment .medal { position: absolute; top: -14px; left: -10px; font-size: 1.8rem; }
.mtxt { font-family: var(--hand); font-size: 1.7rem; font-weight: 700; line-height: 1.1; margin: 6px 0; }
.mby { margin: 6px 0 0; font-size: .9rem; }
.sharelist { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.sharelist p { flex-basis: 100%; margin: 0; }
.tvwrap.show .final.tel { display: flex; flex-direction: column; align-items: center; }
.tvwrap.show .moments { max-width: 70rem; }
.tvwrap.show .moment { max-width: 22rem; }
.tvwrap.show .mtxt { font-size: 2.4rem; }
.tvwrap.show .mby { font-size: 1.2rem; }

/* ---------- start: draw yourself */
.namecard label { margin-top: 2px; }
.avwrap { position: relative; width: min(230px, 64vw); aspect-ratio: 1; margin: 2px auto 0; }
.avwrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 50%; border: 3px solid var(--ink); background: #FFFDF7; box-shadow: var(--shadow); touch-action: none; }
.avwrap.shake canvas { border-color: var(--danger); }
.namecard .tools { padding: 0; }
.avrow { display: flex; align-items: center; gap: 12px; justify-content: center; }
.avprev .ava { width: 72px; height: 72px; }

/* ---------- lobby: own color */
.mycolor { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; padding-top: 8px; border-top: 2px dashed var(--border); font-weight: 600; font-size: .9rem; flex-wrap: wrap; }
.pal { display: flex; gap: 5px; flex-wrap: wrap; }
.pal .sw { width: 28px; flex: none; }
.pal .sw:disabled { opacity: .18; cursor: default; }

/* ---------- rules before each game */
.intro { display: flex; flex-direction: column; gap: 14px; justify-content: center; }
.introhead { display: flex; align-items: center; gap: 12px; justify-content: center; }
.introhead .mi { font-size: 2.4rem; }
.introhead h2 { font-size: 2.4rem; }
.rulelist { margin: 0; padding: 14px 18px 14px 38px; background: #fff; border: 2px solid var(--ink); border-radius: var(--wob); box-shadow: var(--shadow); display: grid; gap: 8px; font-size: 1.02rem; }
.tvintro { flex: 1; align-items: center; }
.tvintro .introhead .mi { font-size: 4.5rem; }
.tvintro .tvbig { font-size: 5rem; }
.tvintro .rulelist { font-size: 1.7rem; max-width: 62rem; gap: 1rem; padding: 1.6rem 2rem 1.6rem 3.6rem; }
.tvintro .btn { min-width: 18rem; font-size: 1.3rem; }

/* ---------- TV: "Anna, your turn!" */
.announce { position: fixed; left: 50%; top: 38%; transform: translate(-50%, -50%); z-index: 45; display: flex; align-items: center; gap: 1rem; padding: 1rem 2.2rem; background: var(--sheet); border: 4px solid var(--pc); border-radius: var(--wob2); box-shadow: 0 10px 0 rgba(26,26,26,.18); font-size: 2.6rem; font-family: var(--hand); pointer-events: none; animation: popin .25s; transition: opacity .35s, transform .35s; }
.announce .ava { width: 4.5rem !important; height: 4.5rem !important; }
.announce.out { opacity: 0; transform: translate(-50%, -60%); }
@keyframes popin { from { transform: translate(-50%, -50%) scale(.6); opacity: 0; } }

/* ---------- imposter extras */
.passed { text-align: center; color: var(--muted); font-weight: 600; margin: 0 0 4px; }
.tvhead .passed { font-size: 1.1rem; }
.judge { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.judge .bigword { margin: 0; }
.jbtns { display: flex; gap: 10px; width: 100%; margin-top: 6px; }
.jbtns .btn { flex: 1; }
.btn.warnon { background: #c43c33; color: #fff; }
.jcount { font-weight: 800; font-size: 1.2rem; margin: 6px 0 0; }
.tvb .judge .bigword { font-size: 4rem; }
.tvb .jcount { font-size: 2rem; }
.hlkey { display: inline-block; width: 1.4em; height: .6em; border-radius: 999px; background: rgba(240,113,103,.55); vertical-align: middle; }
.play.imposter .chatcard { min-height: 140px; }

/* ---------- phones: portrait only */
#rotate { display: none; }
@media (orientation: landscape) and (max-height: 500px) {
  body:not(.tv) #rotate { display: flex; position: fixed; inset: 0; z-index: 60; flex-direction: column; align-items: center; justify-content: center; gap: 8px; background: var(--paper); font-family: var(--hand); font-size: 2rem; text-align: center; }
  body:not(.tv) #rotate span { font-size: 3.5rem; display: inline-block; animation: turn 1.6s infinite; }
}
@keyframes turn { 50% { transform: rotate(-90deg); } }

/* TV: bigger chat while voting */
.tvside.talk .tvfeed { font-size: 1.5rem; background: #fff; border: 2px solid var(--border); }
.tvhead { flex-wrap: nowrap; }
.tvhead > * { white-space: nowrap; }
