/* Couch Court: one sheet for phones, PCs and the TV. A cosy 2005 patchwork look. */

/* ---------- basics ---------- */
* { box-sizing: border-box; margin: 0; }
[hidden] { display: none !important; }
@font-face { font-family: Chewy; src: url(/art/chewy) format("truetype"); font-display: swap; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
/* In a room the type grows with the screen: phones 15px, a laptop about 22px, a TV 26px. */
html:has(> body:is(.at-lobby, .at-play)) { font-size: clamp(15px, 1.1vw + .9vh, 26px); }
html:has(> body.tv:is(.at-lobby, .at-play)) { font-size: clamp(15px, 1.25vw + 1vh, 30px); }
body {
  --bg: url(/art/bg-menu); --ink: #2b1f45; --soft: #4d4068;
  font-family: Chewy, system-ui, sans-serif; font-synthesis: none; letter-spacing: .02em;
  background: #17122b; color: #fff; min-height: 100vh; min-height: 100dvh; text-align: center; padding: 20px; isolation: isolate;
}
input, button { font: inherit; color: inherit; }
/* What people type stays in a plain font so it is easy to read. */
input { font-family: system-ui, "Segoe UI", sans-serif; letter-spacing: 0; }
button { background: none; border: 0; padding: 0; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; }
button:focus-visible, input:focus-visible { outline: 4px solid #fff; outline-offset: 2px; }
p, h2 { text-shadow: 0 2px 4px #000c; }
.row { display: flex; gap: .5rem; justify-content: center; flex-wrap: wrap; }

/* Picture letters cut from the patchwork alphabet */
.bubble { display: flex; flex-wrap: wrap; justify-content: center; gap: .1em .4em; line-height: 1; }
.bubble span { display: flex; align-items: flex-end; }
.bubble img { height: 1em; width: auto; }

/* ---------- the picture behind everything ---------- */
#bg { position: fixed; inset: 0; z-index: -1; background: linear-gradient(#17122b55, #17122baa), var(--bg) center / cover no-repeat, #17122b; }
.at-joinView #bg, .at-tvView #bg { background: url(/art/join-wide) center / cover no-repeat, #17122b; }
@media (orientation: portrait) { .at-joinView #bg, .at-tvView #bg { background-image: url(/art/join-tall); } }
/* Each game's own quilt, with its light sewn card in the middle. The game sits on that card. */
.at-play #bg { background: var(--bg) center / cover no-repeat, #e6e0ec; }

/* ---------- join screen and the TV's start screen: a quilt behind, every box its own sewn patch ---------- */
.at-joinView, .at-tvView { padding: 20px; }
#joinView, #tvView { min-height: calc(100vh - 40px); min-height: calc(100dvh - 40px); display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 28px; }
#logo, #tvLogo { font-size: min(7.6vw, 5rem); color: #ffd23f; white-space: nowrap; filter: drop-shadow(0 6px 8px #0008); }
#logo.bubble, #tvLogo.bubble { flex-wrap: nowrap; gap: .35em; }
.tvsub { margin-top: -16px; color: #ffe9b0; font-size: 1.3rem; }
#join, #watch { display: flex; flex-direction: column; gap: 18px; width: min(100%, 420px); }
:is(#join, #watch) :is(input, button) {
  width: 100%; min-width: 0; padding: 18px; font-size: 1.45rem; font-weight: 700; color: #17122b;
  border: 4px solid #17122b; outline: 2.5px dashed var(--stitch, #17122b99); outline-offset: -11px;
  box-shadow: 0 0 0 4px #a8558f, 0 9px 0 4px #2b1f63; background: var(--print), var(--cloth);
}
:is(#join, #watch) input { text-align: center; }
#code, #watchCode { --cloth: #fdf0d5; --print: repeating-linear-gradient(90deg, #d9738522 0 12px, #0000 12px 24px), repeating-linear-gradient(0deg, #d9738522 0 12px, #0000 12px 24px); border-radius: 26px 16px 24px 18px; text-transform: uppercase; letter-spacing: .18em; }
#name { --cloth: #e3f1fb; --print: radial-gradient(#5aa9d655 3px, #0000 4px) 0 0 / 22px 22px; border-radius: 16px 26px 18px 24px; }
:is(#join, #watch) ::placeholder { color: #4d4570; text-transform: none; letter-spacing: 0; }
:is(#join, #watch) button { --cloth: #ffc933; --print: radial-gradient(#ffffff55 3px, #0000 4px) 0 0 / 24px 24px; border-radius: 24px 18px 28px 16px; }
:is(#join, #watch) button.second { --cloth: #6a4fc4; --stitch: #ffe9b0cc; --print: repeating-linear-gradient(45deg, #ffffff14 0 10px, #0000 10px 20px); color: #fff; border-radius: 18px 28px 16px 24px; }
:is(#join, #watch) :is(input, button):focus-visible { box-shadow: 0 0 0 5px #fff, 0 9px 0 4px #2b1f63; }
:is(#join, #watch) button:active { transform: translateY(5px); box-shadow: 0 0 0 4px #a8558f, 0 3px 0 4px #2b1f63; }
.or { color: #ffe9b0; font-size: 1.2rem; }
.hint { font-size: 1rem; color: #e6dffc; }
@media (min-height: 561px) and (max-height: 800px) {
  #joinView, #tvView { gap: 18px; }
  #join, #watch { gap: 14px; }
  :is(#join, #watch) :is(input, button):nth-of-type(n) { padding: 12px; font-size: 1.25rem; }
  #join .hint { display: none; }
}
@media (orientation: landscape) and (max-height: 560px) {
  .at-joinView, .at-tvView { padding: 12px; }
  #joinView, #tvView { min-height: calc(100dvh - 24px); gap: 14px; }
  #logo, #tvLogo { font-size: min(11vh, 6vw); }
  #join, #watch { display: grid; grid-template-columns: 1fr 1fr; width: min(100%, 620px); gap: 18px 22px; }
  :is(#join, #watch) :is(input, button):nth-of-type(n) { padding: 12px; font-size: 1.15rem; }
  .or, #join .hint { display: none; }
  #watchCode { grid-column: 1 / -1; }
  .tvsub { margin-top: -8px; font-size: 1rem; }
}
/* The painted patches replace the code-drawn ones once their sheet has loaded */
.patched :is(#join, #watch) :is(input, button):nth-of-type(n) { border: 0; border-radius: 10px; outline: 0; box-shadow: none; background: center / 100% 100% no-repeat; filter: drop-shadow(0 6px 4px #0008); }
.patched :is(#join, #watch) :is(#code, #watchCode) { background-image: var(--patch1); }
.patched #join #name { background-image: var(--patch2); }
.patched :is(#join, #watch) button:nth-of-type(n) { background-image: var(--patch3); }
.patched :is(#join, #watch) button.second:nth-of-type(n) { background-image: var(--patch4); color: #fff; }
.patched :is(#join, #watch) :is(input, button):focus-visible { filter: drop-shadow(0 0 3px #fff) drop-shadow(0 0 6px #fff); }

/* ---------- buttons everywhere else ---------- */
/* Code-drawn patch first; the painted one is stretched over it as a 9-slice, so stitches stay even at any size. */
.btn {
  --cloth: #ffc933;
  display: inline-flex; align-items: center; justify-content: center; gap: .4em;
  min-height: 2.9rem; padding: .5em 1.4em; font-size: 1.2rem; line-height: 1.1; color: #17122b;
  background: radial-gradient(#ffffff55 2px, #0000 3px) 0 0 / 18px 18px, var(--cloth);
  border: 3px solid #17122b; border-radius: 16px 12px 18px 10px;
  outline: 2px dashed #17122b88; outline-offset: -8px; box-shadow: 0 5px 0 #2b1f63;
}
.btn.second { --cloth: #6a4fc4; color: #fff; outline-color: #ffe9b0cc; background: repeating-linear-gradient(45deg, #ffffff14 0 8px, #0000 8px 16px), var(--cloth); }
.btn.plain { background: none; border: 2px dashed currentColor; outline: 0; box-shadow: none; }
.btn.small { min-height: 2.3rem; padding: .35em 1em; font-size: 1rem; }
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 2px 0 #2b1f63; }
.btn:disabled { opacity: .6; }
.patched .btn:not(.plain) { border: 0 solid transparent; outline: 0; box-shadow: none; background: none; border-image: var(--patch3) 80 92 fill / 1.3em 1.5em stretch; filter: drop-shadow(0 4px 3px #0007); }
.patched .btn.second { border-image-source: var(--patch4); }
.patched .btn:not(.plain):active:not(:disabled) { filter: drop-shadow(0 1px 1px #0007); }
.patched .btn:not(.plain):focus-visible { filter: drop-shadow(0 0 3px #fff) drop-shadow(0 0 6px #fff); }

/* On/off switches */
.toggle { display: inline-flex; align-items: center; gap: .5em; min-height: 2.4rem; padding: .35em .9em; font-size: 1rem; color: #fff; background: #17122bcc; border: 2px dashed #ffe9b088; border-radius: 99px; }
.toggle::before { content: ""; display: grid; place-items: center; width: 1.15em; height: 1.15em; border: 2px solid currentColor; border-radius: 5px; font: 900 .85em/1 system-ui, sans-serif; }
.toggle[aria-pressed="true"] { background: #6a4fc4; border: 2px solid #ffd23f; }
.toggle[aria-pressed="true"]::before { content: "✓"; color: #17122b; background: #ffd23f; border-color: #ffd23f; }

.menubtn { display: grid; place-items: center; width: 2.4rem; height: 2.4rem; border-radius: 50%; color: #fff; background: #17122be6; border: 2px solid #ffe9b099; box-shadow: 0 3px 0 #0006; font: 700 1.25rem/1 system-ui, sans-serif; }
.floating { position: fixed; z-index: 5; top: max(10px, env(safe-area-inset-top)); right: max(10px, env(safe-area-inset-right)); }

/* ---------- lobby ---------- */
.at-lobby { padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
#lobby { display: grid; gap: 1rem; max-width: 76rem; margin: 0 auto; align-items: center; }
/* Landscape: the page never scrolls; a long list of seats scrolls inside its own panel and the picker stays put */
@media (orientation: landscape) {
  #lobby { grid-template-columns: minmax(14rem, .8fr) minmax(0, 1.2fr); grid-template-rows: minmax(0, 1fr); height: calc(100vh - 24px); height: calc(100dvh - 24px); }
  .side { max-height: 100%; overflow-y: auto; scrollbar-width: thin; scrollbar-color: #ffe9b066 transparent; }
}
.side { display: flex; flex-direction: column; align-items: center; gap: .45rem; min-width: 0; padding: .8rem; background: #17122bc2; border: 2px dashed #ffe9b055; border-radius: 18px; container-type: inline-size; }
.label { color: #ffe9b0; font-size: .95rem; }
.code { font-size: clamp(2rem, 6vw, 5rem); font-size: min(14.5cqi, 5.5rem); line-height: 1; letter-spacing: .06em; overflow-wrap: anywhere; }
.code.bubble { gap: 0; letter-spacing: 0; }
.joinat { color: #e6dffc; font-size: .95rem; overflow-wrap: anywhere; }
.tv .joinat { color: #fff; font-size: 1.25rem; }
#results { display: flex; flex-direction: column; align-items: center; gap: .25rem; }
.done { font-size: 1.6rem; font-size: min(7cqi, 2.2rem); color: #ffd23f; }
.winner { font-size: 1.25rem; color: #ffd23f; }
#results .rule { padding: .25em .7em; font-size: 1rem; background: #6a4fc4; border-radius: 10px; }
.seats { list-style: none; padding: 0; width: 100%; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .45rem; }
.seat {
  --cloth: #6a4fc4;
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  min-width: 0; min-height: 2.5rem; padding: .3rem 1.8rem; color: #fff;
  background: radial-gradient(#ffffff1f 2px, #0000 3px) 0 0 / 14px 14px, var(--cloth);
  border: 3px solid #17122b; border-radius: 12px 9px 13px 8px; outline: 2px dashed #ffe9b0aa; outline-offset: -7px; box-shadow: 0 4px 0 #0007;
}
.seat:nth-child(4n+2) { --cloth: #b8405a; }
.seat:nth-child(4n+3) { --cloth: #2f7f8f; }
.seat:nth-child(4n) { --cloth: #9a6a1f; }
.seat strong { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 700 1rem/1.15 system-ui, "Segoe UI", sans-serif; letter-spacing: 0; }
.seat :is(em, .pts, .tab, .away) { font-size: .78rem; font-style: normal; line-height: 1.1; }
.seat em { color: #ffe9b0; }
.seat .pts { color: #ffd23f; }
.seat.me { --cloth: #ffc933; color: #17122b; outline-color: #17122b88; }
.seat.me :is(em, .pts) { color: #6a2fb8; }
.seat.off { opacity: .55; }
.kick { position: absolute; top: 50%; right: .3rem; transform: translateY(-50%); display: grid; place-items: center; width: 1.5rem; height: 1.5rem; border-radius: 50%; color: #fff; background: #17122b; border: 2px solid #ffffff66; font: 700 1rem/1 system-ui, sans-serif; }
/* Game picker: one animated room per game, arrows on both sides */
.pick { display: flex; flex-direction: column; align-items: center; gap: .6rem; min-width: 0; }
#rooms { position: relative; width: min(100%, calc((100vh - 8rem) * 16 / 9)); aspect-ratio: 16 / 9; overflow: hidden; background: #17122b; border: 4px solid #ffd23f; border-radius: 18px; box-shadow: 0 8px 0 #0006; container-type: inline-size; }
@supports (height: 100dvh) { #rooms { width: min(100%, calc((100dvh - 8rem) * 16 / 9)); } }
#roomVideo { display: block; width: 100%; height: 100%; object-fit: cover; }
#roomName { position: absolute; top: 4%; left: 0; right: 0; font-size: clamp(1.2rem, 4vw, 2.8rem); font-size: clamp(1.1rem, 6.5cqi, 3.4rem); color: #ffd23f; pointer-events: none; filter: drop-shadow(0 3px 4px #000c); }
.arrow { position: absolute; top: 50%; transform: translateY(-50%); display: grid; place-items: center; width: 3.2rem; height: 3.2rem; border-radius: 50%; color: #17122b; background: #ffd23f; border: 3px dashed #17122b; box-shadow: 0 4px 0 #0007; font: 700 1.4rem/1 system-ui, sans-serif; }
.arrow:active { transform: translateY(calc(-50% + 3px)); box-shadow: 0 1px 0 #0007; }
#prev { left: 8px; }
#next { right: 8px; }
#playRoom { position: absolute; bottom: 5%; left: 50%; transform: translateX(-50%); white-space: nowrap; }
#playRoom:active { transform: translate(-50%, 3px); }
.wait { color: #ffe9b0; font-size: 1.1rem; }

/* ---------- playing ---------- */
.at-play { padding: 0; overflow: hidden; overscroll-behavior: none; }
/* The game card is painted into every mode's background. With "cover" scaling its edges
   land at predictable places, so the layout follows the painting on any screen shape.
   Card in the 1376 x 768 picture: left 85, right 1300, top 120, bottom 640. */
#play {
  --vh: 100vh;
  --s: max(100vw / 1376, var(--vh) / 768);
  --above: calc(var(--vh) / 2 - 264 * var(--s));
  --below: calc(var(--vh) / 2 - 256 * var(--s));
  --left: calc(50vw - 603 * var(--s));
  --right: calc(50vw - 612 * var(--s));
  position: fixed; inset: 0; display: grid; color: var(--ink);
  grid-template-rows: max(var(--above), 2.6rem) minmax(0, 1fr) max(var(--below), 1.5rem);
}
@supports (height: 100dvh) { #play { --vh: 100dvh; } }
#play p, #play h2 { text-shadow: none; }

/* Above the card: what this round is, everyone's score, and the menu */
#top {
  grid-row: 1; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: .6rem; min-height: 0;
  padding: .3rem max(var(--right), env(safe-area-inset-right), .5rem) .3rem max(var(--left), env(safe-area-inset-left), .5rem);
}
#gameTitle { max-width: min(30vw, 16rem); padding: .2em .7em; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #fff; background: #6a4fc4; border: 2px solid #17122b; border-radius: 9px 7px 10px 6px; box-shadow: 0 3px 0 #17122b66; }
.board { list-style: none; padding: 0; display: flex; justify-content: center; align-items: center; gap: .35rem; min-width: 0; overflow: hidden; }
.chip { display: inline-flex; align-items: center; gap: .3em; flex: 0 1 auto; min-width: 0; height: 1.9rem; padding: 0 .55em; font-size: .85rem; white-space: nowrap; color: var(--ink); background: #fffaf0; border: 2px solid var(--ink); border-radius: 8px 6px 9px 5px; box-shadow: 0 2px 0 #2b1f4566; }
.chip .n { min-width: 0; overflow: hidden; text-overflow: ellipsis; font: 700 .95em/1.1 system-ui, "Segoe UI", sans-serif; letter-spacing: 0; }
.chip .pts { color: #6a4fc4; }
.chip .tab { font-size: .8em; color: #a35a00; }
.chip.done { background: #d5f2dc; border-color: #1d7a45; }
.chip.me { background: #ffd23f; }
.chip.waiting { border-style: dashed; animation: waiting 1s ease-in-out infinite alternate; }
.chip.late { border-style: dotted; background: #fffaf0b3; }
.chip.off { opacity: .45; }
.chip.tappable { cursor: pointer; }
@keyframes waiting { to { opacity: .5; } }
/* A phone can't fit eight names and eight scores in one row: names win, and the results list shows every score */
@media (max-width: 900px) and (orientation: landscape) {
  #top { padding-inline: max(env(safe-area-inset-left), .5rem) max(env(safe-area-inset-right), .5rem); }
  #gameTitle { max-width: 24vw; }
  .board:has(> :nth-child(5)) .chip:not(.me) .pts { display: none; }
}
@media (orientation: portrait) {
  #top { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "title menu" "board board"; align-content: center; }
  #gameTitle { grid-area: title; justify-self: start; max-width: 100%; }
  .board { grid-area: board; flex-wrap: wrap; }
  #menuBtn { grid-area: menu; }
}

/* On the card */
#panel {
  grid-row: 2; position: relative; display: flex; flex-direction: column; min-height: 0; border-radius: 20px;
  margin: 0 max(var(--right) + 34 * var(--s), env(safe-area-inset-right), .6rem) 0 max(var(--left) + 34 * var(--s), env(safe-area-inset-left), .6rem);
  padding: clamp(.5rem, 30 * var(--s), 2.6rem) min(40 * var(--s), 1.1rem);
}
#body { flex: 1 1 0; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); gap: .8rem 1.6rem; }
#stage, #pad { display: flex; flex-direction: column; gap: .5rem; min-width: 0; min-height: 0; padding: .35rem .4rem .6rem; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
/* Centred when there's room, still scrollable from the top when there isn't */
#stage > :first-child, #pad > :first-child { margin-top: auto; }
#stage > :last-child, #pad > :last-child { margin-bottom: auto; }
#body.solo { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
#body.wide { grid-template-columns: minmax(0, 1fr); grid-template-rows: fit-content(35%) minmax(0, 1fr); gap: .5rem; }
#body.wide #stage > * { margin: 0; }
#body.wide #pad { overflow: hidden; }
#body.reveal { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); }
@media (orientation: portrait) {
  #body, #body.reveal { grid-template-columns: minmax(0, 1fr); grid-template-rows: fit-content(55%) minmax(0, 1fr); }
  #body.solo { grid-template-rows: minmax(0, 1fr) auto; }
}

.prompt { font-size: 1.55rem; line-height: 1.15; overflow-wrap: anywhere; }
.prompt.long, #body.wide .prompt { font-size: 1.25rem; }
.banner { align-self: center; padding: .2em .9em; font-size: .95rem; color: #fff; background: #6a4fc4; border-radius: 99px; }
.note { font-size: 1.1rem; color: var(--soft); overflow-wrap: anywhere; }
/* Imposter's private line (your word, or that you're the imposter): a stitched tag only you see */
.note.whisper { align-self: center; max-width: 100%; padding: .3em .8em; font-size: 1.3rem; color: var(--ink); background: #fffaf0e6; border: 2px dashed #6a4fc4; border-radius: 14px; }
.signal { font-size: 2.3rem; line-height: 1.05; color: #6a4fc4; }
.signal.draw { font-size: 3.3rem; color: #e0482f; }
.signal.fake { color: #b8405a; }
.signal.fooled { font-size: 1.8rem; color: #c8303f; }
.answer { align-self: center; padding: .2em .8em; font-size: 1.2rem; color: #145c33; background: #3ccf6e2e; border: 2px dashed #1d7a45; border-radius: 10px; }
.lines { list-style: none; padding: 0; display: flex; flex-direction: column; gap: .3rem; }
.lines li { font-size: 1.1rem; line-height: 1.2; overflow-wrap: anywhere; }
.lines .big { font-size: 1.4rem; color: #6a2fb8; }
.lines .small { font-size: .9rem; color: var(--soft); }
.lines .drink { align-self: center; padding: .15em .8em; color: #7a3d00; background: #ffd23f66; border: 2px dashed #a35a00; border-radius: 10px; }
.art { align-self: center; width: auto; height: auto; max-width: 100%; max-height: 11rem; aspect-ratio: 1; background: #fff; border: 3px solid var(--ink); border-radius: 10px; }
.locked { font-size: 1.25rem; color: #1d7a45; }
.status { font-size: .95rem; color: var(--soft); }
.status:empty { display: none; }
#pad .hint { font-size: .95rem; color: var(--soft); }
#pad .big { font-size: 1.3rem; }

/* Answer buttons: one cloth per colour */
.grid { --cols: 2; display: grid; gap: .55rem; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); grid-auto-rows: minmax(3.1rem, auto); container-type: inline-size; }
.grid.n1 { --cols: 1; }
.grid:is(.n3, .n5, .n6) { --cols: 3; }
.grid:is(.n7, .n8) { --cols: 4; }
.grid.long:not(.n1) { --cols: 2; }
@media (orientation: portrait) { .grid:is(.n3, .n5, .n6, .n7, .n8) { --cols: 2; } }
.opt {
  --cloth: #cf4452;
  display: grid; place-items: center; min-width: 0; padding: .45em .6em;
  font-size: 1.2rem; line-height: 1.1; color: #fff; overflow-wrap: anywhere; text-shadow: 0 2px 0 #0005;
  background: var(--print, none), var(--cloth);
  border: 3px solid var(--ink); border-radius: 14px 10px 15px 9px; outline: 2px dashed #ffffffb3; outline-offset: -8px; box-shadow: 0 5px 0 var(--ink);
}
.opt.c0 { --print: radial-gradient(#ffffff2e 3px, #0000 4px) 0 0 / 16px 16px; }
.opt.c1 { --cloth: #2f6fd0; --print: repeating-linear-gradient(90deg, #ffffff1c 0 9px, #0000 9px 18px), repeating-linear-gradient(0deg, #ffffff1c 0 9px, #0000 9px 18px); }
.opt.c2 { --cloth: #23894f; --print: repeating-linear-gradient(45deg, #ffffff1f 0 7px, #0000 7px 14px); }
.opt.c3 { --cloth: #8247c2; --print: radial-gradient(#ffd23f40 2px, #0000 3px) 0 0 / 12px 12px; }
/* Narrow columns get smaller words rather than words broken in half */
.opt { font-size: min(1.2rem, 100cqi / var(--cols) / 6.5); }
.long .opt { font-size: 1rem; font-size: min(1rem, 100cqi / var(--cols) / 7.5); }
:is(#pad, .seatpad) > .btn { align-self: center; }
.blank .opt { font-size: 2rem; }
.opt:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.grid:has(.picked) .opt:not(.picked) { opacity: .5; }
.opt.picked { outline: 3px solid #ffd23f; outline-offset: -9px; box-shadow: 0 0 0 4px #ffd23f, 0 5px 0 var(--ink); }
.opt.wrong { opacity: .35; }
.opt.right { opacity: 1 !important; box-shadow: 0 0 0 5px #3ccf6e, 0 5px 0 var(--ink); }
.toggle.liar { align-self: center; font-size: 1.15rem; color: #c8303f; background: #fff; border: 3px dashed #c8303f; }
.toggle.liar[aria-pressed="true"] { color: #fff; background: #c8303f; border: 3px solid var(--ink); }
.toggle.liar[aria-pressed="true"]::before { color: #c8303f; background: #fff; border-color: #fff; }

/* Drawings to vote on */
.gallery { --cols: 2; flex: 1 1 0; min-height: 0; display: grid; gap: .5rem; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); grid-auto-rows: minmax(0, 1fr); }
/* Landscape: one row up to six, so each drawing stays as big as the height allows */
.gallery.n3 { --cols: 3; }
.gallery:is(.n4, .n7, .n8) { --cols: 4; }
.gallery.n5 { --cols: 5; }
.gallery.n6 { --cols: 6; }
@media (orientation: portrait) { .gallery:not(.n1) { --cols: 2; } }
.frame { display: flex; flex-direction: column; align-items: center; gap: .2rem; min-width: 0; min-height: 0; padding: .35rem; color: var(--ink); background: #fffaf0; border: 3px solid var(--ink); border-radius: 12px 9px 13px 8px; box-shadow: 0 4px 0 #2b1f4566; }
.frame canvas { flex: 1 1 0; min-height: 0; width: 100%; object-fit: contain; }
.frame span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .9rem; }
.frame:active:not(:disabled) { transform: translateY(3px); }
.frame.picked { box-shadow: 0 0 0 4px #ffd23f, 0 4px 0 #2b1f4566; }
.frame.mine { opacity: .45; }

/* Typing */
.textpad { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .5rem; align-items: center; width: 100%; }
.textpad .count { grid-column: 1 / -1; justify-self: end; font-size: .8rem; color: var(--soft); }
#pad input { width: 100%; min-width: 0; padding: .65em 1.3em; font-size: max(16px, 1.1rem); font-weight: 600; color: #17122b; text-align: center; background: #fdf0d5; border: 3px solid var(--ink); border-radius: 12px; outline: 2px dashed #2b1f4566; outline-offset: -8px; }
#pad input::placeholder { color: #6d6390; font-weight: 400; }
#pad input:focus-visible { outline: 3px solid #ffd23f; outline-offset: 2px; }
.patched #pad input { border: 0 solid transparent; border-radius: 0; outline: 0; background: none; border-image: var(--patch1) 80 92 fill / 1.4em 1.6em stretch; }
.patched #pad input:focus-visible { filter: drop-shadow(0 0 3px #ffd23f) drop-shadow(0 0 5px #ffd23f); }
.quizpad { display: grid; gap: .45rem; width: 100%; max-width: 46rem; align-self: center; }
.quizpad .answers { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .45rem; }
#pad .quizpad input { padding-block: .5em; font-size: max(16px, 1rem); }
.seatpad { display: flex; flex-direction: column; gap: .55rem; }

/* Drawing */
.sketch { flex: 1 1 0; min-height: 0; display: flex; align-items: center; justify-content: center; gap: .7rem; container-type: size; }
.sketch canvas { width: min(100%, 15rem); width: min(100cqh, 100cqw - 8rem); height: auto; aspect-ratio: 1; touch-action: none; cursor: crosshair; background: #fff; border: 3px solid var(--ink); border-radius: 10px; box-shadow: 0 4px 0 #2b1f4566; }
.sketch .tools { display: flex; flex-direction: column; gap: .5rem; }
@media (orientation: portrait) {
  .sketch { flex-direction: column; }
  .sketch canvas { width: min(100cqw, 100cqh - 3.6rem); }
  .sketch .tools { flex-direction: row; }
}

/* Results: everyone's standing and the Ready button */
.standings { list-style: none; padding: 0; display: flex; flex-direction: column; gap: .25rem; flex: 0 1 auto; min-height: 0; overflow-y: auto; width: min(100%, 24rem); align-self: center; }
.standings li { display: grid; grid-template-columns: 1.4em minmax(0, 1fr) auto 3em; align-items: center; gap: .4em; padding: .2em .6em; font-size: 1rem; background: #fffaf0d9; border: 2px solid #2b1f4533; border-radius: 8px; }
.standings .rank { font-size: .85em; color: var(--soft); }
.standings .n { text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 700 .95em/1.2 system-ui, "Segoe UI", sans-serif; letter-spacing: 0; }
.standings .gain { font-size: .9em; color: #1d7a45; }
.standings .gain.neg { color: #c8303f; }
.standings .pts { text-align: right; }
.standings .me { background: #ffd23f; border-color: var(--ink); }
@media (max-height: 500px) {
  .standings { gap: .15rem; }
  .standings li { padding: .05em .5em; font-size: .9rem; }
}
#stage, #pad, .standings { scrollbar-color: #6a4fc499 transparent; }
.btn.ready { align-self: center; flex: none; min-width: min(100%, 13rem); font-size: 1.3rem; }
.btn.ready:disabled { opacity: .8; filter: grayscale(.5); }
.patched .btn.ready:disabled { filter: grayscale(.5) drop-shadow(0 4px 3px #0007); }

/* Quick Draw's clock and the flash when it's time to draw */
#clock { position: absolute; top: max(.2rem, 10 * var(--s)); left: 12%; right: 12%; height: .45rem; overflow: hidden; background: #2b1f4526; border-radius: 99px; }
#clock span { display: block; height: 100%; background: #e0482f; transform-origin: left; }
#panel.flash { animation: flash .6s ease-out; }
#panel.flash .signal.draw { animation: pop .35s ease-out; }
@keyframes flash { from { box-shadow: inset 0 0 0 100vmax #ffd23f99; } to { box-shadow: inset 0 0 0 100vmax #ffd23f00; } }
@keyframes pop { from { transform: scale(1.5); } }

/* Below the card: the house rule, and on the TV how to join */
#foot {
  grid-row: 3; display: flex; align-items: center; justify-content: center; gap: 1rem; min-width: 0; min-height: 0; overflow: hidden;
  padding: .2rem max(var(--right), env(safe-area-inset-right), .5rem) max(.2rem, env(safe-area-inset-bottom)) max(var(--left), env(safe-area-inset-left), .5rem);
}
#foot p { min-width: 0; max-width: 100%; padding: .2em .9em; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink); background: #fffaf0e6; border: 2px dashed var(--ink); border-radius: 99px; }
#rule { color: #6a2fb8; }
.tvjoin { font-size: 1.15rem; }
@media (orientation: portrait) {
  #foot { flex-direction: column; gap: .4rem; }
  #foot p { white-space: normal; border-radius: 14px; }
}

/* The TV is read from across the room */
.tv .prompt { font-size: 1.85rem; }
.tv .prompt.long { font-size: 1.5rem; }
.tv .chip { height: 1.9rem; font-size: .85rem; }

/* Typing in landscape: the keyboard takes most of the screen, so only the question and the box stay */
.kb #play { top: var(--kb-top, 0px); bottom: auto; height: var(--kb-h, 100%); grid-template-rows: 0 minmax(0, 1fr) 0; background: #f2edf5; }
.kb #top, .kb #foot, .kb #clock { display: none; }
.kb #panel { margin: 0; padding: .35rem .6rem; }
.kb #body, .kb #body.wide { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); gap: .35rem; }
.kb #stage { gap: .15rem; padding-block: 0; }
.kb #pad { gap: .35rem; padding-block: .1rem .3rem; }
.kb #stage > :not(.prompt, .note) { display: none; }
/* The note stays: it can hold the secret word you're giving a clue for */
.kb #stage > :is(.prompt, .note) { margin: 0; font-size: 1rem; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.kb #stage > .note { font-size: .95rem; -webkit-line-clamp: 1; }
.kb #stage > .note.whisper { -webkit-line-clamp: 2; padding: .1em .6em; } /* the imposter's category must not be cut off */
.kb #pad > :first-child { margin-top: 0; }
.kb :is(.textpad .count, #pad .status) { display: none; }
.kb #pad input { padding-block: .4em; }
/* Writing a hot-seat question: the boxes say what goes where, so the heading steps aside */
.kb #body.wide { grid-template-rows: minmax(0, 1fr); }
.kb #body.wide #stage { display: none; }
.kb #body.wide #pad { overflow-y: auto; }
.kb :is(.quizpad, .quizpad .answers) { gap: .3rem; }
.kb #pad .quizpad input { padding-block: .3em; }
.kb .quizpad .btn { min-height: 2.1rem; padding-block: .2em; font-size: 1rem; }

/* ---------- pop-ups and messages ---------- */
dialog {
  margin: auto; width: min(92vw, 25rem); max-height: 92vh; max-height: 92dvh; overflow-y: auto; padding: 1.3rem 1.2rem 1.1rem; color: #17122b; text-align: center;
  background: radial-gradient(#d9738518 3px, #0000 4px) 0 0 / 22px 22px, #fdf0d5;
  border: 4px solid #17122b; border-radius: 20px 14px 22px 12px; outline: 2.5px dashed #17122b77; outline-offset: -11px; box-shadow: 0 0 0 4px #a8558f, 0 10px 0 4px #2b1f63;
}
dialog::backdrop { background: #0b0816b8; }
dialog :is(p, h2) { text-shadow: none; }
#dialogTitle { font-size: 1.6rem; color: #2b1f63; }
#dialogText { margin-top: .35rem; font-size: 1.05rem; color: #3d3160; }
#dialogInput { width: 100%; margin-top: .9rem; padding: .7em 1.2em; font-size: max(16px, 1.1rem); text-align: center; color: #17122b; background: #fff; border: 3px solid #17122b; border-radius: 12px; }
.patched #dialogInput { border: 0 solid transparent; border-radius: 0; background: none; border-image: var(--patch2) 80 92 fill / 1.4em 1.6em stretch; }
.stack { display: flex; flex-direction: column; gap: .6rem; margin-top: 1.1rem; }
.stack .btn { width: 100%; }
@media (orientation: landscape) and (max-height: 500px) {
  dialog { width: min(92vw, 34rem); padding: .9rem 1rem; }
  .stack { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
#toast {
  position: fixed; left: 50%; bottom: max(14px, env(safe-area-inset-bottom)); z-index: 20; width: max-content; max-width: min(92vw, 30rem);
  padding: .55em 1.1em; font-size: 1rem; color: #fff; background: #17122bf2; border: 2px dashed #ffd23f; border-radius: 14px; text-shadow: none;
  pointer-events: none; opacity: 0; transform: translate(-50%, 140%); transition: opacity .2s, transform .2s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

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