:root {
  --grape: #2a1449;
  --grape-2: #3d2066;
  --grape-3: #55308a;
  --paper: #fff6e8;
  --paper-dim: #cdbfe0;
  --lemon: #ffd23f;
  --gum: #ff6fb5;
  --mint: #4fe3b5;
  --ink: #1b0b33;
  --radius-big: 22px;
  --radius-small: 12px;
  --font: "Bricolage Grotesque", system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  min-height: 100dvh;
  background: var(--grape);
  color: var(--paper);
  font-family: var(--font);
  font-size: 18px;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

main {
  max-width: 34rem;
  margin: 0 auto;
  padding: 0 20px 48px;
}

/* ---------- masthead + polygraph needle ---------- */

.masthead {
  max-width: 34rem;
  margin: 0 auto;
  padding: 20px 20px 4px;
}

.logo {
  display: inline-block;
  color: var(--paper);
  text-decoration: none;
  font-weight: 800;
  font-stretch: 75%;
  font-size: 30px;
  letter-spacing: -0.02em;
  line-height: 1;
}

.needle {
  display: block;
  width: 100%;
  height: 34px;
  margin-top: 4px;
}

.needle path {
  fill: none;
  stroke: var(--gum);
  stroke-width: 2.5;
  stroke-linejoin: round;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

/* ---------- type ---------- */

h1, h2, h3 { margin: 0; font-weight: 800; letter-spacing: -0.02em; }

.hero {
  font-size: clamp(40px, 12vw, 60px);
  line-height: 0.95;
  font-stretch: 75%;
  margin: 28px 0 8px;
}

.hero span { display: block; color: var(--paper-dim); font-weight: 500; font-stretch: 100%; font-size: 0.45em; line-height: 1.2; margin-top: 12px; letter-spacing: 0; }

.prompt {
  font-size: clamp(24px, 6.4vw, 30px);
  line-height: 1.2;
  font-weight: 700;
  margin: 8px 0 20px;
  text-wrap: pretty;
}

.prompt .blank {
  display: inline-block;
  min-width: 4.5em;
  border-bottom: 4px solid var(--lemon);
  color: var(--lemon);
  transform: translateY(-0.1em);
}

.meta { color: var(--paper-dim); font-size: 16px; margin: 20px 0 0; }
.meta strong { color: var(--paper); }

.muted { color: var(--paper-dim); }
.small { font-size: 15px; }

/* ---------- controls ---------- */

label { display: block; font-weight: 600; margin: 20px 0 8px; }

input[type="text"] {
  width: 100%;
  font: inherit;
  font-size: 22px;
  font-weight: 600;
  padding: 14px 16px;
  border-radius: var(--radius-small);
  border: 3px solid var(--grape-3);
  background: var(--grape-2);
  color: var(--paper);
  outline: none;
}

input[type="text"]:focus { border-color: var(--lemon); }
input::placeholder { color: #9d89bd; font-weight: 500; }

.code-input { text-transform: uppercase; letter-spacing: 0.3em; text-align: center; font-stretch: 75%; }

button {
  font: inherit;
  cursor: pointer;
  border: 0;
  color: inherit;
  background: none;
}

button:focus-visible, a:focus-visible, input:focus-visible {
  outline: 3px solid var(--lemon);
  outline-offset: 3px;
}

.btn {
  display: block;
  width: 100%;
  padding: 16px 20px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 20px;
  background: var(--lemon);
  color: var(--ink);
  box-shadow: 0 5px 0 #b38a00;
  transition: transform 80ms, box-shadow 80ms;
  margin-top: 14px;
}

.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 #b38a00; }
.btn:disabled { opacity: 0.45; cursor: default; transform: none; }

.btn.ghost {
  background: transparent;
  color: var(--paper);
  box-shadow: inset 0 0 0 3px var(--grape-3);
}

.btn.ghost:active { transform: translateY(2px); }

.row { display: flex; gap: 10px; align-items: stretch; }
.row > * { flex: 1; }
.row .btn { margin-top: 0; }

.or { text-align: center; color: var(--paper-dim); margin: 26px 0 0; }

.link {
  color: var(--paper-dim);
  text-decoration: underline;
  text-underline-offset: 3px;
  font-size: 15px;
  padding: 8px 0;
}

/* ---------- lobby ---------- */

.room-code {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 24px 0 8px;
}

.room-code .code {
  font-size: 64px;
  font-weight: 800;
  font-stretch: 75%;
  letter-spacing: 0.08em;
  line-height: 1;
  color: var(--lemon);
}

.players { list-style: none; padding: 0; margin: 16px 0; display: grid; gap: 8px; }

.player {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--grape-2);
  border-radius: var(--radius-small);
  font-weight: 600;
}

.player .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player .score { font-variant-numeric: tabular-nums; color: var(--paper-dim); }
.player.offline { opacity: 0.5; }
.player .tag { font-size: 13px; font-weight: 600; color: var(--ink); background: var(--paper-dim); border-radius: 6px; padding: 2px 7px; }
.player .tag.host { background: var(--lemon); }
.player .tag.done { background: var(--mint); }
.player .kick { color: var(--paper-dim); font-size: 14px; text-decoration: underline; padding: 4px; }

.dot { width: 12px; height: 12px; border-radius: 50%; flex: none; background: var(--grape-3); }
.dot.on { background: var(--mint); }

.cats { display: grid; gap: 8px; margin: 12px 0; }

.cat {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-small);
  background: var(--grape-2);
  box-shadow: inset 0 0 0 3px var(--grape-3);
}

.cat .box {
  width: 24px; height: 24px; border-radius: 7px; flex: none;
  box-shadow: inset 0 0 0 3px var(--paper-dim);
  display: grid; place-items: center; font-weight: 800; color: var(--ink);
}

.cat[aria-pressed="true"] { box-shadow: inset 0 0 0 3px var(--lemon); }
.cat[aria-pressed="true"] .box { background: var(--lemon); box-shadow: none; }
.cat .t { font-weight: 700; display: block; }
.cat .b { font-size: 14px; color: var(--paper-dim); display: block; }
.cat:disabled { cursor: default; }

.setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 14px 0; }
.stepper { display: flex; align-items: center; gap: 4px; }
.stepper button { width: 44px; height: 44px; border-radius: 50%; background: var(--grape-2); font-size: 24px; font-weight: 800; }
.stepper output { min-width: 2ch; text-align: center; font-weight: 800; font-size: 22px; font-variant-numeric: tabular-nums; }

.switch { width: 58px; height: 34px; border-radius: 999px; background: var(--grape-3); position: relative; flex: none; }
.switch::after { content: ""; position: absolute; top: 4px; left: 4px; width: 26px; height: 26px; border-radius: 50%; background: var(--paper); transition: transform 150ms; }
.switch[aria-checked="true"] { background: var(--mint); }
.switch[aria-checked="true"]::after { transform: translateX(24px); }

/* ---------- round header + timer ---------- */

.round-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 18px 0 4px; color: var(--paper-dim); font-weight: 600; font-size: 16px; }
.round-head .double { color: var(--lemon); }

.timer {
  height: 8px;
  border-radius: 999px;
  background: var(--grape-2);
  overflow: hidden;
  margin: 6px 0 18px;
}

.timer > div { height: 100%; background: var(--gum); border-radius: inherit; transform-origin: left; }
.timer.low > div { background: var(--lemon); }

/* ---------- category pick ---------- */

.choices { display: grid; gap: 12px; margin-top: 18px; }

.choice {
  text-align: left;
  padding: 20px;
  border-radius: var(--radius-big);
  background: var(--grape-2);
  box-shadow: inset 0 0 0 3px var(--grape-3), 0 5px 0 var(--ink);
  font-size: 24px;
  font-weight: 800;
}

.choice:active { transform: translateY(3px); box-shadow: inset 0 0 0 3px var(--lemon), 0 2px 0 var(--ink); }

/* ---------- voting cards ---------- */

.cards { display: grid; gap: 10px; margin-top: 8px; }

.card {
  position: relative;
  text-align: left;
  padding: 16px 18px;
  border-radius: var(--radius-big);
  background: var(--paper);
  color: var(--ink);
  font-weight: 700;
  font-size: 21px;
  line-height: 1.2;
  box-shadow: 0 5px 0 #b9a6d6;
}

.card:active { transform: translateY(3px); box-shadow: 0 2px 0 #b9a6d6; }
.card[aria-pressed="true"] { background: var(--lemon); box-shadow: 0 5px 0 #b38a00; }
.card:disabled { cursor: default; }
.card:disabled:not([aria-pressed="true"]) { opacity: 0.55; }

/* ---------- reveal ---------- */

.reveal-card {
  position: relative;
  padding: 18px 18px 14px;
  border-radius: var(--radius-big);
  background: var(--grape-2);
  margin-top: 14px;
  animation: drop 420ms cubic-bezier(0.2, 0.9, 0.3, 1.3) both;
}

.reveal-card .text { font-size: 24px; font-weight: 800; line-height: 1.15; padding-right: 92px; }
.reveal-card .who { margin-top: 8px; font-size: 16px; color: var(--paper-dim); }
.reveal-card .who strong { color: var(--paper); }
.reveal-card .pts { font-weight: 800; color: var(--lemon); }

.reveal-card.truth { background: var(--mint); color: var(--ink); }
.reveal-card.truth .who, .reveal-card.truth .who strong { color: var(--ink); }
.reveal-card.truth .pts { color: var(--ink); }

.stamp {
  position: absolute;
  top: 14px;
  right: 12px;
  font-weight: 800;
  font-stretch: 75%;
  font-size: 26px;
  line-height: 1;
  padding: 4px 10px 6px;
  border: 3px solid currentColor;
  border-radius: 8px;
  transform: rotate(-9deg);
  color: var(--gum);
  animation: stamp 300ms 260ms cubic-bezier(0.3, 1.6, 0.5, 1) both;
}

.reveal-card.truth .stamp { color: var(--ink); transform: rotate(7deg); }

.fact { margin-top: 12px; font-size: 16px; line-height: 1.45; }

.override { margin-top: 8px; font-size: 15px; text-decoration: underline; text-underline-offset: 3px; color: var(--paper-dim); padding: 4px 0; }

@keyframes drop { from { opacity: 0; transform: translateY(-14px) scale(0.97); } }
@keyframes stamp { from { opacity: 0; transform: rotate(-9deg) scale(2.2); } }

/* ---------- scoreboard ---------- */

.board { list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 8px; }
.board li { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--grape-2); border-radius: var(--radius-small); font-weight: 700; }
.board .rank { width: 1.6em; color: var(--paper-dim); font-variant-numeric: tabular-nums; }
.board .name { flex: 1; }
.board .delta { color: var(--mint); font-size: 15px; }
.board .score { font-variant-numeric: tabular-nums; }
.board li.first { background: var(--lemon); color: var(--ink); }
.board li.first .rank, .board li.first .delta { color: var(--ink); }

/* ---------- misc ---------- */

.notice {
  margin: 14px 0;
  padding: 14px 16px;
  border-radius: var(--radius-small);
  background: var(--grape-2);
  border-left: 5px solid var(--lemon);
  font-weight: 600;
}

.notice.good { border-color: var(--mint); }
.notice.warn { border-color: var(--gum); }

.waiting { text-align: center; margin: 40px 0; font-size: 22px; font-weight: 700; }
.waiting .muted { font-size: 17px; font-weight: 500; margin-top: 8px; }

.banner {
  position: sticky; top: 0; z-index: 5;
  background: var(--gum); color: var(--ink);
  text-align: center; font-weight: 700; padding: 8px 16px; font-size: 16px;
}

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  max-width: calc(100% - 40px);
  background: var(--paper); color: var(--ink);
  padding: 12px 18px; border-radius: var(--radius-small);
  font-weight: 700; font-size: 16px; box-shadow: 0 8px 24px rgba(10, 0, 30, 0.5);
  z-index: 10;
}

[hidden] { display: none !important; }

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