/* Couchquake: a velvet couch at night, with cushions in every colour */
:root {
  --night: #201A4F;
  --velvet: #2C2470;
  --velvet-hi: #3B3192;
  --ink: #1B1540;
  --paper: #FFF4DF;
  --muted: #C9C1F0;
  --mustard: #F4B740;
  --mustard-dark: #B9832A;
  --tomato: #FF5A4E;
  --mint: #4BD6A8;
  --sky: #5BC0FF;
  --display: "Bricolage Grotesque", "Arial Rounded MT Bold", system-ui, sans-serif;
  --body: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;
  --cushion: 28% 34% 30% 26% / 32% 26% 30% 28%;
  --puff: inset 0 -0.12em 0 rgba(0, 0, 0, 0.2), inset 0 0.08em 0 rgba(255, 255, 255, 0.35), 0 0.1em 0 rgba(0, 0, 0, 0.25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background-color: var(--night);
  /* tufted upholstery: one button every 64px */
  background-image: radial-gradient(circle, rgba(255, 255, 255, 0.07) 0 3px, transparent 4px);
  background-size: 64px 64px;
  background-position: 32px 32px;
  color: var(--paper);
  font-family: var(--body);
  line-height: 1.45;
}
h1, h2, h3 { font-family: var(--display); font-weight: 800; line-height: 1.05; margin: 0 0 0.4em; letter-spacing: -0.01em; }
p { margin: 0 0 0.6em; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--sky); outline-offset: 3px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-block;
  border: 0;
  border-radius: 999px;
  padding: 0.7em 1.4em;
  font-family: var(--display);
  font-weight: 800;
  text-decoration: none;
  background: var(--mustard);
  color: var(--ink);
  box-shadow: 0 0.25em 0 var(--mustard-dark);
  transition: transform 0.08s, box-shadow 0.08s;
}
.btn:active { transform: translateY(0.15em); box-shadow: 0 0.1em 0 var(--mustard-dark); }
.btn.ghost { background: transparent; color: var(--paper); box-shadow: inset 0 0 0 2px rgba(255, 244, 223, 0.35); }
.btn.small { padding: 0.45em 1em; font-size: 0.85em; }
.btn.big { width: 100%; padding: 0.9em; font-size: 1.2em; }
button[disabled] { opacity: 0.4; cursor: not-allowed; }

.note { color: var(--muted); text-align: center; }
.lead { font-size: 1.6em; color: var(--muted); margin: 0; }
.alert { background: var(--tomato); color: var(--ink); padding: 0.6em 0.9em; border-radius: 12px; font-weight: 700; }
.boss { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 1em; }
.spacer { flex: 1; }

.offline {
  display: none;
  position: fixed; inset: 0 0 auto; z-index: 20;
  background: var(--tomato); color: var(--ink);
  text-align: center; font-weight: 700; padding: 4px calc(env(safe-area-inset-right) + 8px) 4px;
  padding-top: calc(env(safe-area-inset-top) + 4px);
}
.is-offline .offline { display: block; }

.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 24px); transform: translateX(-50%);
  background: var(--paper); color: var(--ink); padding: 0.7em 1.2em; border-radius: 999px;
  font-weight: 700; max-width: 90vw; z-index: 30; text-align: center;
}

/* ---------- Timer ---------- */
.timer {
  display: inline-grid; place-items: center;
  min-width: 2.2em; height: 2.2em; padding: 0 0.3em;
  border-radius: 999px; background: var(--paper); color: var(--ink);
  font-family: var(--display); font-weight: 800;
}
.timer.low { background: var(--tomato); }

/* ---------- Player chips ---------- */
.dots { list-style: none; display: flex; flex-wrap: wrap; gap: 0.5em; padding: 0; margin: 0; }
.dots li, .chip {
  display: inline-block; padding: 0.25em 0.8em; border-radius: 999px;
  box-shadow: inset 0 0 0 2px var(--c); color: var(--c); font-weight: 700;
}
.dots li.done, .chip { background: var(--c); color: var(--ink); }

/* ---------- Shared game pieces ---------- */
.intro { margin: auto 0; }
.intro h1 { font-size: 4.5em; }
.intro p { font-size: 1.7em; max-width: 34ch; color: var(--muted); }

.verdict { text-align: center; }
.verdict h2 { font-size: 2.6em; }
.verdict p { color: var(--muted); font-size: 1.15em; }
.verdict.good h2 { color: var(--mint); }
.verdict.bad h2 { color: var(--tomato); }

.final h1 { font-size: 3.4em; }
.board { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.5em; max-width: 42em; }
.board li {
  display: grid; grid-template-columns: 1.6em 1fr auto auto; gap: 0.8em; align-items: center;
  background: var(--velvet); border-radius: 0.8em; padding: 0.55em 1em;
  border-left: 0.4em solid var(--c, var(--muted));
}
.board li:first-child { background: var(--mustard); color: var(--ink); }
.board .place { font-family: var(--display); font-weight: 800; }
.board .nm { font-weight: 700; overflow-wrap: anywhere; }
.board .pts { font-family: var(--display); font-weight: 800; }
.board .tot { opacity: 0.75; font-size: 0.85em; }

.blank { display: inline-block; min-width: 3.5em; border-bottom: 0.12em solid var(--mustard); vertical-align: baseline; }
.fill { color: var(--mint); }

/* =================================================================
   TV
   ================================================================= */
.tv { font-size: clamp(14px, 1.35vw, 34px); overflow: hidden; }
.tv main { min-height: 100vh; padding: 3vh 4vw; display: flex; flex-direction: column; gap: 2.5vh; }
.tv .note { font-size: 1.6em; margin: auto; }

.lobby { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr); gap: 4vw; align-items: start; }
.how { font-size: 1.8em; }

/* The room code: four tilted cushions. This is the one loud thing on screen. */
.code { display: flex; gap: 0.18em; font-family: var(--display); font-weight: 800; font-size: min(8.5vw, 15vh); }
.code span {
  display: grid; place-items: center; width: 1.12em; height: 1.12em;
  background: var(--c); color: var(--ink); border-radius: var(--cushion);
  transform: rotate(var(--r)); box-shadow: var(--puff);
}

.join .row { display: flex; gap: 1.4em; align-items: center; margin-top: 3vh; }
#qr { background: var(--paper); padding: 0.6em; border-radius: 0.9em; line-height: 0; flex: none; }
#qr img, #qr canvas { width: min(12vw, 22vh); height: auto; image-rendering: pixelated; }
.url { font-size: 1.25em; color: var(--muted); margin: 0; }
.url b { color: var(--paper); }

.couch h2 { font-size: 2.2em; }
.cushions { list-style: none; padding: 0; margin: 1em 0 0; display: grid; grid-template-columns: repeat(5, 1fr); gap: 1.6vw 1.2vw; }
.cushions li {
  position: relative; aspect-ratio: 1.15;
  display: grid; place-items: center; text-align: center; padding: 0.4em;
  background: var(--c); color: var(--ink); border-radius: var(--cushion);
  font-family: var(--display); font-weight: 800; font-size: 1.3em; line-height: 1.1;
  transform: rotate(var(--r)); box-shadow: var(--puff); overflow-wrap: anywhere;
}
.cushions li.empty { background: transparent; box-shadow: inset 0 0 0 3px rgba(255, 244, 223, 0.12); }
.cushions li.off { opacity: 0.4; }
.cushions .crown { position: absolute; top: -0.75em; font-size: 1.1em; }
.cushions li.new { animation: plop 0.6s cubic-bezier(0.3, 1.6, 0.5, 1); }

@keyframes plop {
  from { transform: translateY(-50%) scale(0.5) rotate(var(--r)); opacity: 0; }
  to { transform: rotate(var(--r)); opacity: 1; }
}
.quake main { animation: quake 0.45s; }
@keyframes quake {
  20% { transform: translate(-6px, 2px); }
  40% { transform: translate(5px, -3px); }
  60% { transform: translate(-4px, 2px); }
  80% { transform: translate(2px, -1px); }
}

.picker { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0.9vw; }
.gamecard {
  display: grid; grid-template-columns: auto 1fr; column-gap: 0.6em; align-content: start;
  border: 0; border-radius: 1em; padding: 0.75em 0.9em; text-align: left;
  background: var(--velvet); color: var(--paper);
  box-shadow: inset 0 0 0 2px rgba(255, 244, 223, 0.08);
}
.gamecard:hover:not([disabled]) { background: var(--velvet-hi); }
.gamecard .emoji { font-size: 1.6em; grid-row: span 2; line-height: 1.1; }
.gamecard h3 { font-size: 1.15em; margin: 0.15em 0 0.2em; }
.gamecard p { color: var(--muted); margin: 0; font-size: 0.85em; line-height: 1.3; }
.gamecard .meta { grid-column: 2; color: var(--mustard); padding-top: 0.4em; font-weight: 700; }
.hint { color: var(--muted); margin: 0; }

.bar { display: flex; align-items: center; gap: 1em; font-family: var(--display); font-weight: 800; font-size: 1.4em; }
.bar .progress { color: var(--muted); font-weight: 600; }
.bar .room { color: var(--muted); font-weight: 600; }
.stage > h2 { font-size: 2em; margin: 0; }
.stage { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 3vh; }
.tvctl { display: flex; gap: 0.8em; justify-content: flex-end; opacity: 0.6; }

.question { font-size: 3.1em; max-width: 30ch; }
.opts { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 1.2vw; }
.opt {
  display: flex; align-items: center; gap: 0.7em;
  background: var(--c); color: var(--ink); border-radius: 0.6em; padding: 0.7em 1em;
  font-size: 1.8em; font-weight: 700; transition: opacity 0.3s;
}
.opt .shape { font-size: 0.9em; }
.opt .count { margin-left: auto; font-family: var(--display); font-weight: 800; }
.opt.wrong { opacity: 0.28; }
.opt.right { box-shadow: 0 0 0 0.18em var(--paper); }

.prompt { font-size: 3em; max-width: 26ch; }
.answers { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(14em, 1fr)); gap: 1vw; }
.answers li { background: var(--velvet); border-radius: 0.8em; padding: 0.7em 1em; font-size: 1.5em; font-weight: 700; overflow-wrap: anywhere; }
.answers li.truth { background: var(--mint); color: var(--ink); }
.answers li.truth .chip { box-shadow: 0 0 0 2px var(--ink); }
.answers .who { display: block; font-size: 0.62em; font-weight: 400; margin-top: 0.3em; opacity: 0.85; }
.answers .voters { display: flex; flex-wrap: wrap; gap: 0.3em; margin-top: 0.5em; font-size: 0.6em; }

.light {
  flex: 1; min-height: 50vh; border-radius: 2rem;
  display: grid; place-items: center;
  font-family: var(--display); font-weight: 800; font-size: 7em; color: var(--ink);
}
.light.red { background: var(--tomato); }
.light.green { background: var(--mint); }

/* =================================================================
   Phone controller
   ================================================================= */
.phone { font-size: 18px; overscroll-behavior: none; }
.phone main {
  min-height: 100dvh; display: flex; flex-direction: column;
  padding: calc(env(safe-area-inset-top) + 14px) calc(env(safe-area-inset-right) + 16px)
           calc(env(safe-area-inset-bottom) + 16px) calc(env(safe-area-inset-left) + 16px);
}
.phone main > .note { margin: auto; }
.pbody .note { margin: 0; }
.me { display: flex; align-items: center; gap: 0.5em; font-family: var(--display); font-weight: 800; font-size: 1.1em; }
.me .swatch { width: 1.4em; height: 1.4em; border-radius: var(--cushion); background: var(--c); box-shadow: var(--puff); }
.me .score { color: var(--muted); font-weight: 600; }
.me .timer { font-size: 0.85em; }
.pbody { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 1em; padding: 1em 0 0; }
.pbody > h2 { font-size: 2em; margin: 0; }
.pbody > .btn.small { align-self: center; }

.joinform { display: flex; flex-direction: column; gap: 1em; margin: auto 0; }
.logo { font-size: clamp(2.6em, 12vw, 5em); text-align: center; color: var(--mustard); text-shadow: 0 0.06em 0 var(--mustard-dark); }
.field { display: grid; gap: 0.3em; font-weight: 700; }
.field input {
  width: 100%; padding: 0.8em; border-radius: 14px; border: 0;
  background: var(--paper); color: var(--ink); font-size: 1.15em;
}
.joinform input[name="room"] { text-transform: uppercase; letter-spacing: 0.3em; font-family: var(--display); font-weight: 800; font-size: 1.6em; text-align: center; }

.pad4 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; flex: 1; max-height: 70vh; }
.padbtn {
  border: 0; border-radius: 20px; background: var(--c); color: var(--ink);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.3em;
  padding: 0.6em; font-weight: 700; min-height: 8em; overflow-wrap: anywhere;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.3); touch-action: manipulation;
}
.padbtn:active { transform: translateY(4px); box-shadow: 0 2px 0 rgba(0, 0, 0, 0.3); }
.padbtn .shape { font-size: 2.4em; line-height: 1; }

.list { display: grid; gap: 10px; }
.listbtn {
  display: flex; gap: 0.7em; align-items: center; text-align: left;
  border: 0; border-radius: 16px; background: var(--velvet-hi); color: var(--paper);
  padding: 0.9em 1em; font-weight: 700; font-size: 1.1em; overflow-wrap: anywhere;
}
.listbtn small { display: block; font-weight: 400; font-size: 0.8em; color: var(--muted); }
.listbtn.own { opacity: 0.45; }
.listbtn.game .emoji { font-size: 1.8em; }
.prompt-sm { font-family: var(--display); font-weight: 800; font-size: 1.5em; line-height: 1.15; }
.fib { display: flex; flex-direction: column; gap: 1em; }

.tapbtn {
  width: min(78vw, 58vh); aspect-ratio: 1; margin: auto; border: 0; border-radius: 50%;
  background: var(--mustard); color: var(--ink); box-shadow: 0 12px 0 var(--mustard-dark);
  font-family: var(--display); font-weight: 800; font-size: 3em;
  touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.tapbtn:active { transform: translateY(8px); box-shadow: 0 4px 0 var(--mustard-dark); }

.phone .final h1 { font-size: 2.2em; }
.phone .board li { font-size: 0.95em; }

/* =================================================================
   Landing page
   ================================================================= */
.home main { max-width: 46rem; margin: 0 auto; padding: 12vh 1.5rem 3rem; }
.home .logo { text-align: left; font-size: clamp(3em, 11vw, 6em); }
.pitch { font-size: 1.3em; color: var(--muted); max-width: 36ch; }
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 1rem; margin-top: 2rem; }
.choice {
  display: grid; gap: 0.4em; text-decoration: none; padding: 1.4em; border-radius: var(--cushion);
  background: var(--c); color: var(--ink); box-shadow: var(--puff);
}
.choice b { font-family: var(--display); font-size: 1.6em; line-height: 1.1; }
.choice:nth-child(1) { transform: rotate(-1.5deg); }
.choice:nth-child(2) { transform: rotate(1.2deg); }

/* ---------- Emoji Decoder ---------- */
.question.big { font-size: 7em; letter-spacing: 0.1em; line-height: 1.1; }
.emojiq { font-size: 3.2em; text-align: center; margin: 0; }

/* ---------- Doodle Dash ---------- */
.wordhint { font-family: var(--display); color: var(--mustard); letter-spacing: 0.08em; margin-left: 0.4em; }
.drawwrap { display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(0, 1fr); gap: 2vw; align-items: start; }
.sheet { width: 100%; max-height: 66vh; aspect-ratio: 4 / 3; background: var(--paper); border-radius: 1.2em; display: block; }
.side { display: flex; flex-direction: column; gap: 1em; }
.feed { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.35em; font-size: 1.2em; }
.feed li { color: var(--muted); overflow-wrap: anywhere; }
.feed li b { color: var(--paper); }
.feed li.ok { color: var(--mint); font-weight: 700; }
.drawword { font-size: 1.3em; margin: 0; text-align: center; }
.drawword b { color: var(--mustard); font-family: var(--display); }
canvas.pad { width: 100%; aspect-ratio: 4 / 3; border-radius: 16px; touch-action: none; background: var(--paper); }
.tools { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.ink { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--c); box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.25); }
.ink.on { box-shadow: 0 0 0 3px var(--night), 0 0 0 6px var(--paper); }
.size.on { background: var(--paper); color: var(--ink); }

/* ---------- Couch Court ---------- */
.bars { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.5em; max-width: 46em; }
.bars li {
  display: flex; justify-content: space-between; padding: 0.5em 0.9em; border-radius: 0.6em; font-size: 1.4em; font-weight: 700;
  background: linear-gradient(90deg, var(--c) var(--w), var(--velvet) var(--w)); color: var(--ink);
}
.bars .n { font-family: var(--display); background: var(--paper); color: var(--ink); border-radius: 999px; padding: 0 0.55em; }
.listbtn.person { border-left: 0.5em solid var(--c); display: block; }

/* ---------- Herd Mind ---------- */
.opt { flex-wrap: wrap; }
.opt .voters { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 0.3em; font-size: 0.5em; }
.opt .voters:empty { display: none; }

/* ---------- Close Call ---------- */
.bignum { font-size: 7em; color: var(--mustard); margin: 0; }

/* ---------- Cash Out ---------- */
.pot {
  display: grid; place-items: center; min-height: 40vh; border-radius: 2rem;
  background: var(--mustard); color: var(--ink);
  font-family: var(--display); font-weight: 800; font-size: 9em; font-variant-numeric: tabular-nums;
}
.pot.calm { background: var(--velvet); color: var(--paper); font-size: 5em; }
.pot.burst { background: var(--tomato); font-size: 5em; }
.tapbtn.cash { display: grid; place-content: center; font-size: 2.4em; line-height: 1.1; }
.tapbtn.cash small { font-size: 0.6em; font-variant-numeric: tabular-nums; }

/* ---------- Letter Rush ---------- */
.letterrow { display: flex; gap: 3vw; align-items: flex-start; }
.bigletter {
  flex: none; display: grid; place-items: center; width: 1.3em; height: 1.3em;
  font-family: var(--display); font-weight: 800; font-size: 10em;
  background: var(--sky); color: var(--ink); border-radius: var(--cushion); box-shadow: var(--puff); transform: rotate(-3deg);
}
.bigletter.small { font-size: 5em; }
.cats { margin: 0; padding-left: 1.2em; font-size: 2.4em; font-family: var(--display); font-weight: 800; display: grid; gap: 0.3em; }
.catgrid { flex: 1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.4vw; }
.catgrid section { background: var(--velvet); border-radius: 1em; padding: 0.8em 1em; }
.catgrid h3 { font-size: 1.3em; }
.catgrid ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.3em; font-size: 1.15em; }
.catgrid li { border-left: 0.35em solid var(--c); padding-left: 0.5em; font-weight: 700; overflow-wrap: anywhere; }
.catgrid li small { font-weight: 400; color: var(--muted); }
.catgrid li.shared { opacity: 0.7; }
.catgrid li.none { border: 0; color: var(--muted); font-weight: 400; }

@media (max-width: 900px) {
  .picker { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .drawwrap, .letterrow { grid-template-columns: 1fr; flex-direction: column; }
  .tv { overflow: auto; }
  .lobby { grid-template-columns: 1fr; }
}

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