@font-face {
  font-family: "Unbounded";
  src: url("fonts/unbounded-variable.woff2") format("woff2");
  font-style: normal;
  font-weight: 200 900;
  font-display: swap;
}

@font-face {
  font-family: "Bricolage Grotesque";
  src: url("fonts/bricolage-variable.woff2") format("woff2");
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg: #140c33;
  --bg-deep: #0b0620;
  --card: #2b1c7a;
  --card-raised: #3a2a98;
  --card-soft: #22156a;
  --ink: #07031a;
  --text: #fff8ee;
  --muted: #cbbff2;
  --faint: #9a8cd0;
  --pink: #ff3e9a;
  --red: #ff3b5c;
  --mint: #2cf0a6;
  --lime: #b8ff3a;
  --sun: #ffd43b;
  --cyan: #38d6ff;
  --orange: #ff8a3a;
  --violet: #a77bff;
  --tone: var(--sun);
  --display: "Unbounded", "Arial Black", system-ui, sans-serif;
  --body: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --radius-xl: 32px;
  --radius-lg: 24px;
  --radius: 16px;
  --edge: 3px;
  --lift: 6px;
  --header-height: 68px;
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --out: cubic-bezier(0.22, 1, 0.36, 1);
}

[data-tone="pink"] { --tone: var(--pink); }
[data-tone="red"] { --tone: var(--red); }
[data-tone="mint"] { --tone: var(--mint); }
[data-tone="lime"] { --tone: var(--lime); }
[data-tone="sun"] { --tone: var(--sun); }
[data-tone="cyan"] { --tone: var(--cyan); }
[data-tone="orange"] { --tone: var(--orange); }
[data-tone="violet"] { --tone: var(--violet); }

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  scroll-padding-top: calc(var(--header-height) + 12px);
  scroll-padding-bottom: 120px;
  background: var(--bg-deep);
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

body {
  min-width: 320px;
  min-height: 100dvh;
  margin: 0;
  overflow-x: hidden;
  background: transparent;
  color: var(--text);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.45;
  transition: background-color 0.6s ease;
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  touch-action: manipulation;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: var(--display);
  font-weight: 800;
  line-height: 1.04;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

p {
  margin: 0;
  text-wrap: pretty;
}

svg {
  flex: none;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 4px solid var(--sun);
  outline-offset: 3px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 200;
  padding: 10px 16px;
  border: var(--edge) solid var(--ink);
  border-radius: 12px;
  background: var(--sun);
  color: var(--ink);
  font-weight: 800;
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: none;
}

/* Backdrop: drifting colour blobs, dots, and grain behind everything. */

.backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 120%, rgb(167 123 255 / 0.25), transparent 60%),
    var(--bg);
  transition: background-color 0.6s ease;
}

.backdrop::before {
  position: absolute;
  inset: -40px;
  background-image: radial-gradient(rgb(255 248 238 / 0.09) 1.4px, transparent 1.6px);
  background-size: 26px 26px;
  content: "";
  animation: dots-pan 40s linear infinite;
}

.blob {
  position: absolute;
  width: 70vmax;
  height: 70vmax;
  border-radius: 50%;
  opacity: 0.7;
  will-change: transform;
  transition: background-color 0.8s ease;
  animation: drift 24s ease-in-out infinite alternate;
}

.blob-a {
  top: -32vmax;
  left: -26vmax;
  background: radial-gradient(circle, var(--blob-a, var(--pink)) 0, transparent 62%);
}

.blob-b {
  right: -30vmax;
  bottom: -36vmax;
  background: radial-gradient(circle, var(--blob-b, var(--cyan)) 0, transparent 62%);
  animation-duration: 29s;
  animation-direction: alternate-reverse;
}

.blob-c {
  top: 24%;
  left: 30%;
  width: 50vmax;
  height: 50vmax;
  opacity: 0.5;
  background: radial-gradient(circle, var(--blob-c, var(--violet)) 0, transparent 62%);
  animation-duration: 34s;
}

.backdrop-grain {
  position: absolute;
  inset: 0;
  opacity: 0.16;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

body[data-phase="answering"] { --blob-a: var(--violet); --blob-b: var(--cyan); --blob-c: var(--pink); }
body[data-phase="revealing"] { --blob-a: var(--sun); --blob-b: var(--pink); --blob-c: var(--cyan); }
body[data-phase="voting"] { --blob-a: var(--red); --blob-b: var(--pink); --blob-c: var(--orange); }
body[data-phase="results"] { --blob-a: var(--sun); --blob-b: var(--mint); --blob-c: var(--pink); }

@keyframes drift {
  0% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(8vmax, 6vmax, 0) scale(1.12); }
  100% { transform: translate3d(-6vmax, 10vmax, 0) scale(0.94); }
}

@keyframes dots-pan {
  to { transform: translate3d(26px, 26px, 0); }
}

/* Layout shell */

.site-shell {
  position: relative;
  min-height: 100dvh;
  overflow-x: clip;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  min-height: var(--header-height);
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding:
    max(10px, env(safe-area-inset-top))
    max(14px, env(safe-area-inset-right))
    10px
    max(14px, env(safe-area-inset-left));
  background: linear-gradient(rgb(20 12 51 / 0.92), rgb(20 12 51 / 0));
  backdrop-filter: blur(6px);
}

.brand {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
}

.brand-mascot {
  display: block;
  width: 62px;
  height: 46px;
}

.brand-mascot .mascot,
.hero-mascot .mascot,
.waiting-mascot .mascot {
  filter:
    drop-shadow(2px 0 0 var(--text))
    drop-shadow(-2px 0 0 var(--text))
    drop-shadow(0 2px 0 var(--text))
    drop-shadow(0 -2px 0 var(--text))
    drop-shadow(0 6px 0 var(--ink));
}

.brand-mascot .mascot {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.brand-name {
  font-family: var(--display);
  font-size: 1.05rem;
  font-weight: 900;
  letter-spacing: -0.03em;
  white-space: nowrap;
}

.brand-name span {
  color: var(--pink);
}

.header-tools {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
}

.room-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.room-code-button,
.room-exit-button,
.room-lobby-button,
.icon-button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 12px;
  border: var(--edge) solid var(--ink);
  border-radius: 14px;
  background: var(--card-raised);
  box-shadow: 0 4px 0 var(--ink);
  color: var(--text);
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background-color 0.2s ease;
}

.room-code-button {
  font-family: var(--display);
  font-size: 0.9rem;
  letter-spacing: 0.08em;
}

.room-code-button svg,
.room-exit-button svg,
.room-lobby-button svg,
.icon-button svg {
  width: 18px;
  height: 18px;
}

.icon-button {
  width: 44px;
  padding: 0;
}

.room-code-button:active,
.room-exit-button:active,
.room-lobby-button:active,
.icon-button:active {
  transform: translateY(4px);
  box-shadow: 0 0 0 var(--ink);
}

.room-exit-button span,
.room-lobby-button span {
  display: none;
}

.room-lobby-button {
  width: 44px;
  padding: 0;
  background: var(--sun);
  color: var(--ink);
}

.room-exit-button {
  width: 44px;
  padding: 0;
  background: var(--red);
  color: var(--ink);
}

#sound-toggle[aria-pressed="false"] {
  background: var(--card-soft);
  color: var(--faint);
}

.connection-status[data-state="connected"] {
  display: none;
}

.connection-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.connection-label {
  display: none;
}

.connection-dot {
  width: 12px;
  height: 12px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 0 0 rgb(44 240 166 / 0.6);
  animation: ping 2s ease-out infinite;
}

.connection-status[data-state="retrying"] .connection-dot {
  background: var(--orange);
  animation-duration: 0.7s;
}

.connection-status[data-state="retrying"] .connection-label {
  display: inline;
  color: var(--orange);
}

@keyframes ping {
  0% { box-shadow: 0 0 0 0 rgb(44 240 166 / 0.55); }
  70%, 100% { box-shadow: 0 0 0 10px rgb(44 240 166 / 0); }
}

main {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding:
    6px
    max(16px, env(safe-area-inset-right))
    max(28px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
}

/* Buttons */

.primary-button,
.secondary-button,
.danger-button {
  position: relative;
  display: inline-flex;
  min-height: 56px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 22px;
  overflow: hidden;
  border: var(--edge) solid var(--ink);
  border-radius: 18px;
  box-shadow: 0 var(--lift) 0 var(--ink);
  font-family: var(--display);
  font-size: 0.98rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.1;
  text-align: center;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.2s ease, background-color 0.2s ease;
}

.primary-button {
  background: var(--sun);
  color: var(--ink);
}

.secondary-button {
  background: var(--text);
  color: var(--ink);
}

.danger-button {
  background: var(--red);
  color: var(--ink);
}

.primary-button.big,
.secondary-button.big,
.danger-button.big {
  min-height: 64px;
  padding: 0 28px;
  font-size: 1.08rem;
}

.primary-button svg,
.secondary-button svg,
.danger-button svg {
  width: 22px;
  height: 22px;
  stroke-width: 2.6;
}

@media (hover: hover) {
  .primary-button:hover:not(:disabled),
  .secondary-button:hover:not(:disabled),
  .danger-button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 calc(var(--lift) + 2px) 0 var(--ink);
    filter: brightness(1.06);
  }

  .room-code-button:hover,
  .icon-button:hover {
    background: #4a38b4;
  }
}

.primary-button:active:not(:disabled),
.secondary-button:active:not(:disabled),
.danger-button:active:not(:disabled) {
  transform: translateY(var(--lift));
  box-shadow: 0 0 0 var(--ink);
}

.primary-button:disabled,
.secondary-button:disabled,
.danger-button:disabled {
  background: #4b3a9e;
  color: #ddd3fb;
  cursor: not-allowed;
}

.shine:not(:disabled)::after {
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 35%, rgb(255 255 255 / 0.65) 50%, transparent 65%);
  content: "";
  transform: translateX(-120%);
  animation: shine 3.2s ease-in-out infinite;
}

@keyframes shine {
  0%, 55% { transform: translateX(-120%); }
  80%, 100% { transform: translateX(120%); }
}

.text-button {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  cursor: pointer;
}

.text-button svg {
  width: 20px;
  height: 20px;
}

/* Shared text pieces */

.stage-kicker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.kicker-chip {
  display: inline-flex;
  padding: 4px 10px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--tone);
  color: var(--ink);
  font-family: var(--display);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  transform: rotate(-3deg);
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.tag svg {
  width: 13px;
  height: 13px;
}

.tag-host {
  background: var(--sun);
  color: var(--ink);
}

.tag-you {
  background: var(--text);
  color: var(--ink);
}

.tag-impostor {
  margin-left: 8px;
  background: var(--red);
  color: var(--ink);
}

.section-heading {
  margin: 34px 0 14px;
}

.section-heading h2 {
  font-size: clamp(1.3rem, 5vw, 1.7rem);
}

.section-heading.inline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.count-pill {
  padding: 5px 12px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--card-raised);
  font-family: var(--display);
  font-size: 0.8rem;
  font-weight: 700;
}

.progress-copy {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

.form-error:empty {
  display: none;
}

.form-error {
  min-height: 1.4em;
  color: #ff8fa3;
  font-size: 0.92rem;
  font-weight: 700;
}

/* Home */

.home-view {
  padding: 4px 0 24px;
}

.home-hero {
  position: relative;
  padding: 6px 0 26px;
}

.hero-mascot {
  width: min(56vw, 240px);
  margin: 0 0 12px 8px;
  animation: hero-pop 0.8s var(--spring) both;
}

.hero-mascot .mascot {
  width: 100%;
  height: auto;
  overflow: visible;
}

.hero-kicker {
  display: inline-flex;
  justify-self: start;
  width: max-content;
  max-width: 100%;
  margin-bottom: 14px;
  padding: 6px 12px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--card-raised);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.hero-title {
  display: grid;
  font-size: clamp(2.7rem, 13.5vw, 6.2rem);
  font-weight: 900;
  line-height: 0.92;
  letter-spacing: -0.045em;
}

.hero-line {
  display: block;
  animation: line-in 0.7s var(--out) both;
}

.hero-line:nth-child(2) {
  animation-delay: 0.08s;
}

.hero-lie {
  position: relative;
  width: max-content;
  color: var(--pink);
  text-shadow: 4px 4px 0 var(--ink);
  animation: line-in 0.7s var(--out) 0.16s both, wobble 3.6s ease-in-out 1s infinite;
  transform-origin: 10% 80%;
}

.hero-copy {
  max-width: 34ch;
  margin-top: 16px;
  color: var(--muted);
  font-size: 1.1rem;
  font-weight: 600;
}

@keyframes hero-pop {
  from { opacity: 0; transform: scale(0.6) rotate(-10deg); }
  to { opacity: 1; transform: none; }
}

@keyframes line-in {
  from { opacity: 0; transform: translateY(0.4em) skewY(4deg); }
  to { opacity: 1; transform: none; }
}

@keyframes wobble {
  0%, 82%, 100% { transform: rotate(0); }
  86% { transform: rotate(-4deg) scale(1.04); }
  90% { transform: rotate(3deg); }
  94% { transform: rotate(-2deg); }
}

.entry-layout {
  display: grid;
  gap: 26px;
}

.entry-panel {
  padding: 16px;
  border: var(--edge) solid var(--ink);
  border-radius: var(--radius-xl);
  background: var(--card);
  box-shadow: 0 10px 0 var(--ink);
  animation: card-up 0.7s var(--spring) 0.2s both;
}

.entry-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 18px;
  padding: 6px;
  border: var(--edge) solid var(--ink);
  border-radius: 20px;
  background: var(--card-soft);
}

.entry-tabs button {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: var(--muted);
  font-family: var(--display);
  font-size: 0.95rem;
  font-weight: 800;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease, transform 0.25s var(--spring);
}

.entry-tabs button svg {
  width: 18px;
  height: 18px;
}

.entry-tabs button[aria-selected="true"] {
  background: var(--pink);
  color: var(--ink);
  box-shadow: inset 0 -4px 0 rgb(7 3 26 / 0.3);
  transform: rotate(-1.5deg);
}

.entry-form {
  display: grid;
  gap: 14px;
}

.entry-form .primary-button {
  width: 100%;
  min-height: 62px;
  font-size: 1.08rem;
}

.field {
  display: grid;
  gap: 8px;
}

.field label,
.answer-form label {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.field input,
.answer-input {
  width: 100%;
  min-height: 60px;
  padding: 0 18px;
  border: var(--edge) solid var(--ink);
  border-radius: 18px;
  background: var(--text);
  box-shadow: inset 0 4px 0 rgb(7 3 26 / 0.12);
  color: var(--ink);
  font-size: 1.15rem;
  font-weight: 700;
  transition: box-shadow 0.2s ease, transform 0.2s var(--spring);
}

.field input::placeholder,
.answer-input::placeholder {
  color: #8a80a8;
  font-weight: 600;
}

.field input:focus-visible,
.answer-input:focus-visible {
  outline: none;
  box-shadow: inset 0 4px 0 rgb(7 3 26 / 0.12), 0 0 0 4px var(--sun);
  transform: scale(1.01);
}

.code-input {
  font-family: var(--display) !important;
  font-size: 1.6rem !important;
  font-weight: 800 !important;
  letter-spacing: 0.32em;
  text-align: center;
  text-transform: uppercase;
}

.how-to {
  display: grid;
  gap: 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.how-step {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 14px;
  align-items: center;
  padding: 16px 18px;
  border: var(--edge) solid var(--ink);
  border-radius: var(--radius-lg);
  background: var(--card-soft);
  box-shadow: 0 6px 0 var(--ink);
  animation: card-up 0.7s var(--spring) both;
}

.how-step:nth-child(1) { animation-delay: 0.3s; transform: rotate(-1deg); }
.how-step:nth-child(2) { animation-delay: 0.4s; transform: rotate(0.8deg); }
.how-step:nth-child(3) { animation-delay: 0.5s; transform: rotate(-0.6deg); }

.how-icon {
  display: grid;
  grid-row: span 2;
  width: 52px;
  height: 52px;
  place-items: center;
  border: var(--edge) solid var(--ink);
  border-radius: 16px;
  background: var(--tone);
  color: var(--ink);
  transform: rotate(-6deg);
}

.how-icon svg {
  width: 26px;
  height: 26px;
}

.how-step strong {
  font-family: var(--display);
  font-size: 1rem;
  font-weight: 800;
}

.how-step > span:last-child {
  color: var(--muted);
  font-size: 0.95rem;
}

.how-number {
  position: absolute;
  top: -12px;
  left: -10px;
  display: grid;
  width: 30px;
  height: 30px;
  transform: rotate(-10deg);
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--text);
  color: var(--ink);
  font-family: var(--display);
  font-size: 0.8rem;
  font-weight: 900;
}

@keyframes card-up {
  from { opacity: 0; transform: translateY(26px) scale(0.96); }
}

/* Mascot */

.mascot-brow,
.mascot-frame {
  fill: none;
  stroke: var(--ink);
  stroke-linecap: round;
  stroke-width: 10;
}

.mascot-lens {
  fill: var(--text);
  stroke: var(--ink);
  stroke-width: 8;
}

.mascot-pupil {
  fill: var(--ink);
}

.mascot-glint {
  fill: var(--text);
}

.mascot-nose {
  fill: #ff8fa3;
  stroke: var(--ink);
  stroke-width: 6;
}

.mascot-stache {
  fill: var(--ink);
}

.mascot-eyes {
  animation: look-around 6s ease-in-out infinite;
}

.mascot-brow {
  transform-box: fill-box;
  transform-origin: center;
  animation: brow-wiggle 6s ease-in-out infinite;
}

.mascot-bob {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  animation: bob 3s ease-in-out infinite;
}

.mascot[data-mood="sus"] .mascot-eyes {
  animation: side-eye 3.4s ease-in-out infinite;
}

.mascot[data-mood="sus"] .mascot-brow-left {
  animation: none;
  transform: rotate(12deg) translateY(6px);
}

.mascot[data-mood="sus"] .mascot-brow-right {
  animation: none;
  transform: rotate(-6deg) translateY(-4px);
}

@keyframes look-around {
  0%, 18% { transform: translate(0, 0); }
  24%, 42% { transform: translate(-10px, 2px); }
  48%, 66% { transform: translate(9px, -2px); }
  72%, 100% { transform: translate(0, 0); }
}

@keyframes side-eye {
  0%, 40% { transform: translate(-11px, 3px); }
  50%, 90% { transform: translate(11px, 3px); }
  100% { transform: translate(-11px, 3px); }
}

@keyframes brow-wiggle {
  0%, 70%, 100% { transform: translateY(0); }
  74% { transform: translateY(-9px); }
  78% { transform: translateY(0); }
  82% { transform: translateY(-9px); }
  86% { transform: translateY(0); }
}

@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(0); }
  50% { transform: translateY(-5px) rotate(-1.5deg); }
}

/* Avatars */

.avatar {
  --p: var(--pink);
  display: inline-grid;
  width: var(--avatar-size, 56px);
  height: var(--avatar-size, 56px);
  flex: none;
  place-items: center;
}

.avatar svg {
  width: 100%;
  height: 100%;
  overflow: visible;
  filter: drop-shadow(0 4px 0 var(--ink));
}

.avatar[data-size="sm"] { --avatar-size: 38px; }
.avatar[data-size="md"] { --avatar-size: 56px; }
.avatar[data-size="lg"] { --avatar-size: 72px; }
.avatar[data-size="xl"] { --avatar-size: 120px; }
.avatar[data-size="xxl"] { --avatar-size: min(60vw, 260px); }

[data-color="0"] { --p: #ff3e9a; }
[data-color="1"] { --p: #38d6ff; }
[data-color="2"] { --p: #ffd43b; }
[data-color="3"] { --p: #2cf0a6; }
[data-color="4"] { --p: #ff8a3a; }
[data-color="5"] { --p: #a77bff; }
[data-color="6"] { --p: #b8ff3a; }
[data-color="7"] { --p: #ff6b6b; }
[data-color="8"] { --p: #6b9bff; }
[data-color="9"] { --p: #ffb38a; }
[data-color="10"] { --p: #e05cff; }
[data-color="11"] { --p: #f2ead8; }
[data-color="12"] { --p: #1fb5a6; }
[data-color="13"] { --p: #d4a35a; }
[data-color="14"] { --p: #8f9bb3; }

.av-body {
  fill: var(--p);
  stroke: var(--ink);
  stroke-width: 5;
  stroke-linejoin: round;
}

.av-ink { fill: var(--ink); }
.av-white { fill: var(--text); stroke: var(--ink); stroke-width: 3; }
.av-tongue { fill: #ff8fa3; }
.av-cheek { fill: rgb(255 255 255 / 0.35); }
.av-line { fill: none; stroke: var(--ink); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }
.av-hat { fill: var(--sun); stroke: var(--ink); stroke-width: 4; stroke-linejoin: round; }
.av-hat-stripe { fill: none; stroke: var(--pink); stroke-width: 4; stroke-linecap: round; }
.av-hat-stripe-fill { fill: var(--text); stroke: var(--ink); stroke-width: 4; }
.av-pom { fill: var(--text); stroke: var(--ink); stroke-width: 4; }
.av-bow { fill: var(--pink); stroke: var(--ink); stroke-width: 4; stroke-linejoin: round; }
.av-bow-knot { fill: var(--sun); stroke: var(--ink); stroke-width: 4; }
.av-leaf { fill: var(--mint); stroke: var(--ink); stroke-width: 4; stroke-linejoin: round; }
.av-stem-out { fill: none; stroke: var(--ink); stroke-width: 10; stroke-linecap: round; }
.av-stem { fill: none; stroke: var(--p); stroke-width: 4; stroke-linecap: round; }
.av-tuft { fill: none; stroke: var(--sun); stroke-width: 4; stroke-linecap: round; }
.av-crown { fill: var(--sun); stroke: var(--ink); stroke-width: 4; stroke-linejoin: round; }
.av-lens { fill: var(--text); stroke: var(--ink); stroke-width: 5; }
.av-frame,
.av-brow { fill: none; stroke: var(--ink); stroke-width: 5; stroke-linecap: round; }
.av-brow { stroke-width: 6; }
.av-nose { fill: #ff8fa3; stroke: var(--ink); stroke-width: 4; }

/* Game stage and transitions */

.game-view {
  position: relative;
  padding-top: 4px;
}

.game-stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
}

.stage-enter > * {
  animation: stage-in 0.55s var(--out) both;
}

.stage-enter > *:nth-child(2) { animation-delay: 0.05s; }
.stage-enter > *:nth-child(3) { animation-delay: 0.1s; }
.stage-enter > *:nth-child(4) { animation-delay: 0.15s; }
.stage-enter > *:nth-child(5) { animation-delay: 0.2s; }
.stage-enter > *:nth-child(n + 6) { animation-delay: 0.25s; }

@keyframes stage-in {
  from { opacity: 0; transform: translateY(22px); }
}

.stage-header h1 {
  font-size: clamp(2rem, 9vw, 3.4rem);
  font-weight: 900;
  letter-spacing: -0.035em;
}

.stage-header p:not(.stage-kicker) {
  margin-top: 10px;
  color: var(--muted);
  font-size: 1.05rem;
  font-weight: 600;
}

.stage-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 20px;
}

.stage-actions .secondary-button {
  min-height: 52px;
  padding: 0 12px;
  font-size: 0.82rem;
  white-space: nowrap;
}

.action-bar {
  position: sticky;
  bottom: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 14px calc(max(16px, env(safe-area-inset-left)) * -1) calc(max(28px, env(safe-area-inset-bottom)) * -1);
  padding: 14px max(22px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(22px, env(safe-area-inset-left));
  border-top: var(--edge) solid var(--ink);
  border-radius: 26px 26px 0 0;
  background: var(--bg-deep);
  box-shadow: 0 -10px 30px rgb(11 6 32 / 0.55);
}

.action-bar > span {
  min-width: 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.action-bar > span + span {
  text-align: right;
}

.action-bar > span:first-child {
  flex: 1 1 auto;
}

.action-bar .primary-button,
.action-bar .secondary-button,
.action-bar .danger-button {
  flex: 0 0 auto;
}

.action-bar .bar-fill {
  flex: 1 1 auto;
}

/* Lobby */

.lobby-hero {
  padding: 18px 16px 18px;
  border: var(--edge) solid var(--ink);
  border-radius: var(--radius-xl);
  background:
    repeating-linear-gradient(-45deg, rgb(255 255 255 / 0.04) 0 14px, transparent 14px 28px),
    var(--card);
  box-shadow: 0 10px 0 var(--ink);
  text-align: center;
}

.lobby-hero .stage-kicker {
  justify-content: center;
}

.lobby-code {
  display: flex;
  justify-content: center;
  gap: clamp(4px, 1.6vw, 10px);
  font-size: clamp(1.7rem, 9vw, 3rem);
  font-weight: 900;
}

.code-tile {
  display: grid;
  width: 1.45em;
  height: 1.7em;
  place-items: center;
  border: var(--edge) solid var(--ink);
  border-radius: 0.3em;
  background: var(--text);
  box-shadow: 0 5px 0 var(--ink);
  color: var(--ink);
  animation: tile-flip 0.6s var(--spring) var(--delay, 0ms) both;
}

.code-tile:nth-child(odd) { transform: rotate(-3deg); }
.code-tile:nth-child(even) { transform: rotate(2.5deg); }
.code-tile:nth-child(3n) { background: var(--sun); }
.code-tile:nth-child(4) { background: var(--pink); }

@keyframes tile-flip {
  from { opacity: 0; transform: rotateX(90deg) translateY(-20px); }
}

.lobby-help {
  max-width: 36ch;
  margin: 16px auto 0;
  color: var(--muted);
  font-weight: 600;
}

.lobby-players .section-heading {
  margin-top: 26px;
}

.player-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

.player-row,
.player-slot {
  position: relative;
  display: grid;
  min-height: 150px;
  align-content: center;
  justify-items: center;
  gap: 6px;
  padding: 16px 8px 14px;
  border: var(--edge) solid var(--ink);
  border-radius: var(--radius-lg);
  background: var(--card);
  box-shadow: 0 6px 0 var(--ink);
  text-align: center;
}

.player-row {
  background: var(--p);
  color: var(--ink);
}

.avatar-plate {
  display: grid;
  width: 92px;
  height: 92px;
  place-items: center;
  border: var(--edge) solid var(--ink);
  border-radius: 50%;
  background: var(--text);
}

.player-row:nth-child(3n + 1) { transform: rotate(-1.2deg); }
.player-row:nth-child(3n + 2) { transform: rotate(0.9deg); }

.player-row[data-me="true"] {
  outline: 3px dashed var(--text);
  outline-offset: 4px;
}

.player-row[data-new="true"] {
  animation: player-pop 0.6s var(--spring) both;
}

.player-row .avatar svg {
  animation: bob 2.6s ease-in-out infinite;
  transform-box: fill-box;
}

.player-row:nth-child(2n) .avatar svg {
  animation-delay: -1.3s;
}

@keyframes player-pop {
  0% { opacity: 0; transform: scale(0.3) rotate(-14deg); }
  70% { opacity: 1; transform: scale(1.08) rotate(3deg); }
  100% { transform: scale(1); }
}

.player-name {
  max-width: 100%;
  overflow: hidden;
  font-family: var(--display);
  font-size: 0.98rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px;
  min-height: 22px;
}

.player-remove {
  position: absolute;
  top: -10px;
  right: -8px;
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: var(--edge) solid var(--ink);
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 3px 0 var(--ink);
  color: var(--ink);
  cursor: pointer;
}

.player-remove svg {
  width: 18px;
  height: 18px;
  stroke-width: 3;
}

.player-slot {
  border-style: dashed;
  border-color: var(--muted);
  background: rgb(255 248 238 / 0.04);
  box-shadow: none;
  color: var(--muted);
  font-weight: 800;
}

.slot-face {
  display: grid;
  width: 64px;
  height: 64px;
  place-items: center;
  border: 3px dashed var(--muted);
  border-radius: 50%;
  animation: slot-breathe 2.4s ease-in-out infinite;
}

.slot-face svg {
  width: 26px;
  height: 26px;
}

@keyframes slot-breathe {
  50% { transform: scale(0.9); opacity: 0.6; }
}

.waiting-card {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 18px;
  padding: 18px;
  border: var(--edge) solid var(--ink);
  border-radius: var(--radius-lg);
  background: var(--card-soft);
  box-shadow: 0 6px 0 var(--ink);
}

.waiting-card h2 {
  font-size: 1.1rem;
}

.waiting-card p {
  margin-top: 6px;
  color: var(--muted);
}

.waiting-mascot {
  display: block;
  width: 96px;
  flex: none;
}

.waiting-mascot .mascot {
  width: 100%;
  height: auto;
  overflow: visible;
}

/* Round setup */

.round-setup {
  margin-top: 6px;
}

.round-setup .section-heading {
  margin-top: 28px;
}

.mode-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.mode-card {
  position: relative;
  display: grid;
  align-content: start;
  gap: 8px;
  padding: 16px 14px 18px;
  border: var(--edge) solid var(--ink);
  border-radius: var(--radius-lg);
  background: var(--card-raised);
  box-shadow: 0 6px 0 var(--ink);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: transform 0.35s var(--spring), background-color 0.25s ease, box-shadow 0.2s ease;
}

.mode-card strong {
  font-family: var(--display);
  font-size: 1.05rem;
  font-weight: 800;
}

.mode-card > span:not(.mode-card-icon):not(.mode-check) {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.3;
}

.mode-card-icon {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border: var(--edge) solid var(--ink);
  border-radius: 14px;
  background: var(--tone);
  color: var(--ink);
}

.mode-card-icon svg {
  width: 26px;
  height: 26px;
}

.mode-check {
  position: absolute;
  top: 10px;
  right: 10px;
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: var(--edge) solid var(--ink);
  border-radius: 50%;
  background: var(--sun);
  color: var(--ink);
  opacity: 0;
  transform: scale(0.3);
  transition: opacity 0.2s ease, transform 0.35s var(--spring);
}

.mode-check svg {
  width: 20px;
  height: 20px;
  stroke-width: 3.4;
}

.mode-card[aria-pressed="true"] {
  background: var(--tone);
  color: var(--ink);
  transform: rotate(-1.5deg) translateY(-4px);
  box-shadow: 0 10px 0 var(--ink);
}

.mode-card[data-tone="cyan"][aria-pressed="true"] {
  transform: rotate(1.5deg) translateY(-4px);
}

.mode-card[aria-pressed="true"] > span:not(.mode-card-icon):not(.mode-check) {
  color: rgb(7 3 26 / 0.78);
}

.mode-card[aria-pressed="true"] .mode-card-icon {
  background: var(--text);
}

.mode-card[aria-pressed="true"] .mode-check {
  opacity: 1;
  transform: scale(1);
}

.mode-settings {
  display: grid;
  gap: 22px;
  margin-top: 24px;
}

.setup-control {
  display: grid;
  gap: 12px;
}

.setup-label {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.setup-label small {
  color: var(--faint);
  font-size: 0.85rem;
  letter-spacing: 0;
  text-transform: none;
}

.category-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.category-option {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  gap: 8px;
  padding: 0 14px 0 6px;
  border: var(--edge) solid var(--ink);
  border-radius: 999px;
  background: var(--card);
  box-shadow: 0 4px 0 var(--ink);
  color: var(--text);
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.3s var(--spring), background-color 0.2s ease, box-shadow 0.15s ease;
}

.category-option-icon {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--tone);
  color: var(--ink);
}

.category-option-icon svg {
  width: 18px;
  height: 18px;
}

.category-option[aria-pressed="true"] {
  background: var(--tone);
  color: var(--ink);
  transform: translateY(-3px) rotate(-2deg);
  box-shadow: 0 7px 0 var(--ink);
}

.category-option[aria-pressed="true"] .category-option-icon {
  background: var(--text);
}

.category-option:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--ink);
}

.genre-option {
  min-height: 42px;
  padding: 0 14px;
  font-size: 0.92rem;
}

.word-artist {
  margin-top: 6px;
  font-weight: 700;
  color: var(--muted);
}

.word-secret-card .word-artist {
  font-size: 1.1rem;
  color: rgb(7 3 26 / 0.75);
}

.group-question-card .word-artist {
  margin-top: 2px;
  color: rgb(7 3 26 / 0.7);
}

.prompt-comparison .word-artist {
  margin-top: 2px;
  font-family: inherit;
  font-size: 0.9rem;
}

.peek-secret small {
  display: block;
  font-family: var(--body);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--muted);
}

.response-round-segment {
  display: flex;
  gap: 10px;
}

.response-round-segment button {
  color: var(--text);
  display: grid;
  width: 60px;
  height: 60px;
  place-items: center;
  border: var(--edge) solid var(--ink);
  border-radius: 50%;
  background: var(--card);
  box-shadow: 0 5px 0 var(--ink);
  font-family: var(--display);
  font-size: 1.3rem;
  font-weight: 900;
  cursor: pointer;
  transition: transform 0.3s var(--spring), background-color 0.2s ease;
}

.response-round-segment button[aria-pressed="true"] {
  background: var(--cyan);
  color: var(--ink);
  transform: translateY(-4px) scale(1.08);
}

/* Secret cards */

.secret-card {
  perspective: 1200px;
}

.secret-card-back {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 12px;
  min-height: 58dvh;
  align-content: center;
  padding: 30px 22px 26px;
  overflow: hidden;
  border: var(--edge) solid var(--ink);
  border-radius: var(--radius-xl);
  background: var(--pink);
  box-shadow: 0 12px 0 var(--ink);
  color: var(--ink);
  text-align: center;
  transform: rotate(-1deg);
}

.secret-pattern {
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='64' height='64'><text x='10' y='40' font-family='Arial Black,Arial' font-weight='900' font-size='34' fill='rgba(7,3,26,0.12)'>?</text><text x='42' y='60' font-family='Arial Black,Arial' font-weight='900' font-size='18' fill='rgba(255,248,238,0.2)'>?</text></svg>");
  background-size: 64px 64px;
  animation: dots-pan 6s linear infinite;
}

.secret-card-back > *:not(.secret-pattern) {
  position: relative;
}

.secret-card-back h2 {
  font-size: clamp(1.6rem, 7vw, 2.2rem);
  font-weight: 900;
}

.secret-card-back p {
  max-width: 28ch;
  font-weight: 700;
}

.secret-card-back .primary-button {
  margin-top: 8px;
  background: var(--sun);
}

.secret-mascot {
  display: block;
  width: min(60vw, 230px);
  animation: card-wiggle 4s ease-in-out infinite;
}

.secret-mascot.small {
  width: 150px;
  justify-self: center;
}

.secret-mascot .mascot {
  width: 100%;
  height: auto;
  overflow: visible;
}

@keyframes card-wiggle {
  0%, 100% { transform: rotate(-1deg); }
  50% { transform: rotate(1deg) translateY(-3px); }
}

.question-card {
  display: grid;
  gap: 16px;
  padding: 20px;
  border: var(--edge) solid var(--ink);
  border-radius: var(--radius-xl);
  background: var(--text);
  box-shadow: 0 12px 0 var(--ink);
  color: var(--ink);
}

.question-card[data-impostor="true"] {
  background:
    repeating-linear-gradient(-45deg, rgb(7 3 26 / 0.1) 0 16px, transparent 16px 32px),
    var(--red);
}

.question-card .question-help,
.question-card .answer-form label,
.question-card .text-button {
  color: rgb(7 3 26 / 0.75);
}

.question-card[data-impostor="true"] .question-help,
.question-card[data-impostor="true"] .answer-form label,
.question-card[data-impostor="true"] .text-button {
  color: var(--ink);
}

.question-card .answer-input {
  background: #fff;
}

.question-card .form-error {
  color: #a10026;
}

.flip-in {
  animation: flip-in 0.75s var(--spring) both;
  transform-origin: 50% 50%;
}

@keyframes flip-in {
  0% { opacity: 0; transform: perspective(1200px) rotateY(-100deg) scale(0.9); }
  60% { opacity: 1; }
  100% { transform: perspective(1200px) rotateY(0); }
}

.role-banner {
  display: inline-flex;
  width: max-content;
  max-width: 100%;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border: var(--edge) solid var(--ink);
  border-radius: 999px;
  background: var(--mint);
  box-shadow: 0 4px 0 var(--ink);
  color: var(--ink);
  font-family: var(--display);
  font-size: 0.95rem;
  font-weight: 900;
  letter-spacing: -0.01em;
  transform: rotate(-2deg);
}

.role-banner svg {
  width: 22px;
  height: 22px;
}

.role-banner[data-impostor="true"] {
  background: var(--ink);
  color: var(--red);
  animation: glitch 2.4s steps(1) infinite;
}

@keyframes glitch {
  0%, 86%, 100% { transform: rotate(-2deg); text-shadow: none; }
  88% { transform: rotate(-2deg) translate(-3px, 1px); text-shadow: 3px 0 var(--cyan); }
  90% { transform: rotate(-2deg) translate(3px, -1px); text-shadow: -3px 0 var(--sun); }
  92% { transform: rotate(-2deg) translate(-1px, 0); text-shadow: 2px 0 var(--cyan); }
}

.question-card h2 {
  font-size: clamp(1.5rem, 6.4vw, 2.3rem);
  font-weight: 800;
  line-height: 1.12;
}

.word-secret-card h2 {
  font-size: clamp(1.6rem, calc((min(100vw, 760px) - 110px) / (var(--len, 6) * 0.8)), 5rem);
  font-weight: 900;
  line-height: 1.22;
  overflow-wrap: normal;
}

.word-secret-card[data-impostor="false"] h2 {
  color: var(--pink);
  text-shadow: min(4px, 0.08em) min(4px, 0.08em) 0 var(--ink);
}

.word-secret-card[data-impostor="true"] h2 {
  font-size: clamp(1.9rem, 9vw, 3rem);
  color: var(--text);
  text-shadow: 3px 3px 0 var(--ink);
}

.question-help {
  color: var(--muted);
  font-size: 1.02rem;
  font-weight: 600;
}

.answer-form {
  display: grid;
  gap: 10px;
}

.answer-input {
  min-height: 66px;
  font-size: 1.35rem;
}

.answer-form-actions {
  display: flex;
  flex-direction: row-reverse;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
}

.answer-form-actions .primary-button {
  flex: 1 1 220px;
  white-space: nowrap;
}

.answer-confirm-preview {
  margin: 16px 0 12px;
  padding: 18px;
  border: var(--edge) solid var(--ink);
  border-radius: var(--radius);
  background: var(--sun);
  color: var(--ink);
  font-family: var(--display);
  font-size: 1.5rem;
  font-weight: 900;
  overflow-wrap: anywhere;
  transform: rotate(-1deg);
}

/* Waiting states */

[data-pop] {
  background: var(--tone) !important;
  color: var(--ink);
}

[data-pop] p,
[data-pop] .progress-copy {
  color: rgb(7 3 26 / 0.78) !important;
}

.waiting-panel.tall {
  min-height: max(300px, 46dvh);
}

.wait-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--card-raised);
  color: var(--text) !important;
  font-size: 0.85rem;
  font-weight: 800;
}

.wait-pill::before {
  width: 10px;
  height: 10px;
  flex: none;
  border-radius: 50%;
  background: var(--sun);
  content: "";
  animation: blink 0.9s ease-in-out infinite;
}

.waiting-panel {
  display: grid;
  place-items: center;
  padding: 26px 18px;
  border: var(--edge) solid var(--ink);
  border-radius: var(--radius-xl);
  background: var(--card);
  box-shadow: 0 10px 0 var(--ink);
  text-align: center;
}

.waiting-panel > div {
  display: grid;
  justify-items: center;
  gap: 14px;
}

.waiting-panel h2 {
  font-size: clamp(1.5rem, 6vw, 2rem);
}

.waiting-panel p {
  max-width: 34ch;
  color: var(--muted);
  font-weight: 600;
}

.lock-burst {
  display: grid;
  width: 88px;
  height: 88px;
  place-items: center;
  border: var(--edge) solid var(--ink);
  border-radius: 28px;
  background: var(--sun);
  box-shadow: 0 6px 0 var(--ink);
  color: var(--ink);
  animation: lock-slam 0.7s var(--spring) both;
}

.lock-burst svg {
  width: 44px;
  height: 44px;
  stroke-width: 2.4;
}

.lock-burst svg.lucide-loader-circle {
  animation: spin 1s linear infinite;
}

@keyframes lock-slam {
  0% { transform: scale(2.2) rotate(-25deg); opacity: 0; }
  60% { transform: scale(0.9) rotate(6deg); opacity: 1; }
  100% { transform: rotate(-4deg); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.locked-answer {
  max-width: 100%;
  padding: 12px 22px;
  border: var(--edge) solid var(--ink);
  border-radius: 16px;
  background: var(--text);
  box-shadow: 0 5px 0 var(--ink);
  color: var(--ink);
  font-family: var(--display);
  font-size: clamp(1.3rem, 6vw, 1.9rem);
  font-weight: 900;
  overflow-wrap: anywhere;
  transform: rotate(-2deg);
}

.progress-avatars {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 6px;
}

.progress-avatar {
  position: relative;
  display: inline-grid;
  justify-items: center;
  gap: 4px;
  width: 68px;
  transition: opacity 0.3s ease, transform 0.4s var(--spring);
}

.progress-name {
  max-width: 100%;
  overflow: hidden;
  font-size: 0.78rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress-avatar[data-done="false"] {
  opacity: 0.5;
}

.progress-avatar[data-done="false"] .avatar svg {
  animation: think 1.4s ease-in-out infinite;
}

.progress-avatar[data-done="true"] {
  transform: translateY(-4px);
}

.progress-check {
  position: absolute;
  top: -4px;
  right: 0;
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--mint);
  color: var(--ink);
  opacity: 0;
  transform: scale(0);
  transition: opacity 0.2s ease, transform 0.35s var(--spring);
}

.progress-check svg {
  width: 13px;
  height: 13px;
  stroke-width: 4;
}

.progress-avatar[data-done="true"] .progress-check {
  opacity: 1;
  transform: scale(1);
}

@keyframes think {
  50% { transform: rotate(-8deg); }
}

/* Reveal and discussion */

.group-question-card {
  position: relative;
  padding: 18px 20px;
  border: var(--edge) solid var(--ink);
  border-radius: var(--radius-lg);
  background: var(--sun);
  box-shadow: 0 8px 0 var(--ink);
  color: var(--ink);
  transform: rotate(-0.8deg);
}

.group-question-card .stage-kicker {
  color: rgb(7 3 26 / 0.7);
}

.group-question-card h2 {
  font-size: clamp(1.25rem, 5.4vw, 1.8rem);
  font-weight: 800;
  line-height: 1.15;
}

.group-question-card[data-impostor="true"] {
  background: var(--red);
}

.group-question-card.compact {
  padding: 14px 18px;
}

.group-question-card.compact h2 {
  font-size: clamp(1.05rem, 4.6vw, 1.4rem);
}

.group-question-note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 2px dashed rgb(7 3 26 / 0.35);
  font-weight: 800;
}

.group-question-note svg {
  width: 20px;
  height: 20px;
  margin-top: 2px;
}

.countdown {
  position: relative;
  display: grid;
  width: 104px;
  height: 104px;
  place-items: center;
  border: var(--edge) solid var(--ink);
  border-radius: 50%;
  background: var(--pink);
  box-shadow: 0 6px 0 var(--ink);
  font-family: var(--display);
  font-size: 3rem;
  font-weight: 900;
  color: var(--ink);
}

.countdown span {
  position: absolute;
  opacity: 0;
  animation: count 3s steps(1) infinite;
}

.countdown span:nth-child(2) { animation-delay: 1s; }
.countdown span:nth-child(3) { animation-delay: 2s; }

@keyframes count {
  0% { opacity: 1; transform: scale(1.2); }
  33.3%, 100% { opacity: 0; }
}

.reveal-ready-panel .primary-button {
  margin-top: 6px;
}

/* Word turns */

.word-turn-panel {
  display: grid;
  min-height: 46dvh;
  align-content: center;
  justify-items: center;
  gap: 14px;
  padding: 26px 20px 28px;
  border: var(--edge) solid var(--ink);
  border-radius: var(--radius-xl);
  background: var(--cyan);
  color: var(--ink);
  box-shadow: 0 10px 0 var(--ink);
  text-align: center;
}

.word-turn-panel h2 {
  font-size: clamp(1.4rem, 6vw, 2rem);
}

.word-turn-panel p {
  max-width: 32ch;
  color: rgb(7 3 26 / 0.75);
  font-weight: 600;
}

.speaker {
  position: relative;
  display: grid;
  width: 180px;
  height: 180px;
  place-items: center;
}

.speaker-rings span {
  position: absolute;
  inset: 20px;
  border: 4px solid var(--ink);
  border-radius: 50%;
  animation: ring 2.4s ease-out infinite;
}

.speaker-rings span:nth-child(2) { animation-delay: 0.8s; }
.speaker-rings span:nth-child(3) { animation-delay: 1.6s; }

@keyframes ring {
  from { opacity: 0.9; transform: scale(0.7); }
  to { opacity: 0; transform: scale(1.35); }
}

.speaker .avatar {
  position: relative;
  animation: talk 0.5s ease-in-out infinite alternate;
}

@keyframes talk {
  to { transform: translateY(-6px) rotate(2deg); }
}

.speaker-mic {
  position: relative;
  display: grid;
  width: 130px;
  height: 130px;
  place-items: center;
  border: 4px solid var(--ink);
  border-radius: 50%;
  background: var(--sun);
  box-shadow: 0 8px 0 var(--ink);
  color: var(--ink);
  animation: mic-pulse 1s ease-in-out infinite;
}

.speaker-mic svg {
  width: 64px;
  height: 64px;
  stroke-width: 2.4;
}

@keyframes mic-pulse {
  50% { transform: scale(1.08) rotate(-4deg); }
}

.word-turn-panel[data-my-turn="true"] {
  background: var(--lime);
  color: var(--ink);
  transform: rotate(-1deg);
}

.word-turn-panel[data-my-turn="true"] p {
  color: rgb(7 3 26 / 0.75);
}

.word-turn-panel[data-my-turn="true"] .speaker-rings span {
  border-color: var(--ink);
}

.speaking-rules {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.speaking-rule {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--text);
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 800;
  white-space: nowrap;
}

.speaking-rule svg {
  width: 16px;
  height: 16px;
}

@keyframes blink {
  50% { opacity: 0.4; }
}

.peek-button {
  display: grid;
  justify-items: center;
  gap: 4px;
  min-height: 64px;
  padding: 10px 16px;
  border: var(--edge) dashed var(--faint);
  border-radius: var(--radius-lg);
  background: rgb(7 3 26 / 0.25);
  color: var(--muted);
  font-weight: 800;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  cursor: pointer;
}

.peek-button svg {
  width: 22px;
  height: 22px;
}

.peek-secret {
  display: none;
  font-family: var(--display);
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--sun);
}

.peek-button[data-peeking="true"] {
  border-style: solid;
  border-color: var(--ink);
  background: var(--card-raised);
}

.peek-button[data-peeking="true"] .peek-secret {
  display: block;
}

.peek-button[data-peeking="true"] .peek-hint,
.peek-button[data-peeking="true"] svg {
  display: none;
}

/* Voting */

.vote-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
  gap: 14px 12px;
}

.vote-option {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 18px 8px 14px;
  border: var(--edge) solid var(--ink);
  border-radius: var(--radius-lg);
  background: var(--p);
  box-shadow: 0 6px 0 var(--ink);
  color: var(--ink);
  cursor: pointer;
  animation: card-up 0.5s var(--spring) var(--delay, 0ms) both;
  transition: transform 0.3s var(--spring), background-color 0.2s ease;
}

.vote-option strong {
  display: -webkit-box;
  max-width: 100%;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  font-family: var(--display);
  font-size: 0.9rem;
  font-weight: 800;
  line-height: 1.15;
  text-align: center;
  overflow-wrap: anywhere;
  hyphens: auto;
}

.vote-label {
  max-width: 100%;
  padding: 3px 8px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--text);
  color: var(--ink);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.vote-avatar {
  position: relative;
  display: grid;
  place-items: center;
}

.crosshair {
  position: absolute;
  inset: -6px;
  border: 4px solid var(--red);
  border-radius: 50%;
  opacity: 0;
  transform: scale(1.6) rotate(-45deg);
  transition: opacity 0.2s ease, transform 0.4s var(--spring);
}

.crosshair::before,
.crosshair::after {
  position: absolute;
  background: var(--red);
  content: "";
}

.crosshair::before {
  top: 50%;
  left: -8px;
  right: -8px;
  height: 4px;
  margin-top: -2px;
  background: linear-gradient(90deg, var(--red) 0 14px, transparent 14px calc(100% - 14px), var(--red) calc(100% - 14px));
}

.crosshair::after {
  left: 50%;
  top: -8px;
  bottom: -8px;
  width: 4px;
  margin-left: -2px;
  background: linear-gradient(var(--red) 0 14px, transparent 14px calc(100% - 14px), var(--red) calc(100% - 14px));
}

.vote-option[aria-pressed="true"] {
  background: var(--ink);
  color: var(--text);
  outline: 4px solid var(--red);
  outline-offset: 2px;
  transform: translateY(-4px);
}

.vote-option[aria-pressed="true"] .crosshair {
  opacity: 1;
  transform: scale(1) rotate(0);
}

.vote-option[aria-pressed="true"] .vote-label {
  background: var(--red);
  color: var(--ink);
}

.vote-option[aria-pressed="true"] .avatar svg {
  animation: shake 0.4s ease-in-out;
}

@keyframes shake {
  25% { transform: translateX(-4px) rotate(-4deg); }
  50% { transform: translateX(4px) rotate(4deg); }
  75% { transform: translateX(-2px); }
}

.voted-target {
  position: relative;
  display: grid;
  margin-bottom: 18px;
  place-items: center;
}

.target-stamp {
  position: absolute;
  bottom: -18px;
  padding: 4px 12px;
  border: var(--edge) solid var(--ink);
  border-radius: 8px;
  background: var(--red);
  color: var(--ink);
  font-family: var(--display);
  font-size: 0.85rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transform: rotate(-8deg);
  animation: stamp 0.5s var(--spring) 0.3s both;
}

@keyframes stamp {
  from { opacity: 0; transform: scale(2.6) rotate(-20deg); }
}

/* Results */

.result-hero {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 26px 18px 24px;
  overflow: hidden;
  border: var(--edge) solid var(--ink);
  border-radius: var(--radius-xl);
  background: var(--mint);
  box-shadow: 0 12px 0 var(--ink);
  color: var(--ink);
  text-align: center;
}

.result-hero[data-outcome="impostor"] {
  background: var(--red);
}

.result-burst {
  position: absolute;
  top: 40%;
  left: 50%;
  width: 900px;
  height: 900px;
  margin: -450px 0 0 -450px;
  background: repeating-conic-gradient(rgb(255 255 255 / 0.22) 0 10deg, transparent 10deg 20deg);
  animation: rays 24s linear infinite;
}

.result-hero > *:not(.result-burst) {
  position: relative;
}

.result-hero .avatar {
  animation: hero-pop 0.8s var(--spring) both;
}

.result-hero .stage-kicker {
  margin: 4px 0 0;
  color: rgb(7 3 26 / 0.7);
}

.result-hero h1 {
  font-size: clamp(2.4rem, 12vw, 4.4rem);
  font-weight: 900;
  color: var(--text);
  text-shadow: 4px 4px 0 var(--ink);
}

.result-hero p {
  max-width: 34ch;
  font-weight: 700;
}

.result-name {
  font-weight: 900;
}

.result-personal {
  margin-top: 4px;
  padding: 8px 14px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--text);
  font-family: var(--display);
  font-size: 0.88rem;
}

@keyframes rays {
  to { transform: rotate(360deg); }
}

.prompt-comparison {
  display: grid;
  gap: 12px;
}

.prompt-comparison > div {
  padding: 16px 18px;
  border: var(--edge) solid var(--ink);
  border-radius: var(--radius-lg);
  background: var(--card);
  box-shadow: 0 6px 0 var(--ink);
}

.prompt-comparison > div[data-impostor="true"] {
  background: #4a1240;
}

.prompt-comparison span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.prompt-comparison span svg {
  width: 16px;
  height: 16px;
}

.prompt-comparison p {
  margin-top: 8px;
  font-family: var(--display);
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.25;
}

.prompt-comparison .big-word {
  color: var(--sun);
  font-size: clamp(1.4rem, 7vw, 2rem);
  font-weight: 900;
}

.score-note {
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
  text-align: center;
}

.answer-results {
  display: grid;
  gap: 10px;
}

.answer-result {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border: var(--edge) solid var(--ink);
  border-radius: var(--radius-lg);
  background: var(--card);
  box-shadow: 0 5px 0 var(--ink);
  animation: slide-in 0.5s var(--out) var(--delay, 0ms) both;
}

.answer-result[data-impostor="true"] {
  background: #4a1240;
  outline: 3px solid var(--red);
  outline-offset: 3px;
}

@keyframes slide-in {
  from { opacity: 0; transform: translateX(-30px); }
}

.answer-result-body {
  display: grid;
  min-width: 0;
  gap: 6px;
}

.answer-result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.answer-result-name {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  font-weight: 800;
}

.vote-count {
  flex: none;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 800;
}

.answer-result-text {
  font-family: var(--display);
  font-size: 1.15rem;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.vote-bar {
  display: flex;
  min-height: 16px;
  gap: 4px;
}

.vote-pip {
  width: 16px;
  height: 16px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--red);
  animation: pip 0.4s var(--spring) both;
  animation-delay: calc(var(--delay, 0ms) + 400ms);
}

@keyframes pip {
  from { transform: scale(0); }
}

.vote-cast {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.vote-cast strong {
  color: var(--text);
  overflow-wrap: anywhere;
}

.vote-cast svg {
  flex: none;
  width: 16px;
  height: 16px;
}

.vote-cast[data-hit="true"],
.vote-cast[data-hit="true"] strong {
  color: var(--mint);
}

.score-list {
  display: grid;
  gap: 8px;
}

.score-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border: var(--edge) solid var(--ink);
  border-radius: 18px;
  background: var(--card);
  box-shadow: 0 4px 0 var(--ink);
  animation: slide-in 0.5s var(--out) var(--delay, 0ms) both;
}

.score-row[data-me="true"] {
  background: var(--card-raised);
  outline: 3px dashed var(--cyan);
  outline-offset: 3px;
}

.score-row[data-leader="true"] {
  background: var(--sun);
  color: var(--ink);
}

.score-row .player-name {
  flex: 1;
  font-size: 0.95rem;
}

.score-rank {
  width: 22px;
  font-family: var(--display);
  font-weight: 900;
  opacity: 0.6;
}

.score-plus {
  padding: 2px 8px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--mint);
  color: var(--ink);
  font-family: var(--display);
  font-size: 0.78rem;
  font-weight: 900;
  animation: plus 0.9s var(--spring) 0.6s both;
}

@keyframes plus {
  from { opacity: 0; transform: translateY(14px) scale(0.4); }
}

.score-value {
  min-width: 36px;
  font-family: var(--display);
  font-size: 1.5rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* Full-screen moments */

.splash {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  pointer-events: none;
  animation: splash-life 1.5s ease both;
}

.splash-stripes {
  position: absolute;
  inset: -20%;
  background: repeating-linear-gradient(-30deg, var(--tone) 0 46px, color-mix(in srgb, var(--tone) 78%, white) 46px 92px);
  animation: splash-wipe 1.5s var(--out) both;
}

.splash-content {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 12px;
  color: var(--ink);
  text-align: center;
  animation: splash-text 1.5s var(--spring) both;
}

.splash-icon {
  display: grid;
  width: 84px;
  height: 84px;
  place-items: center;
  border: 4px solid var(--ink);
  border-radius: 26px;
  background: var(--text);
  box-shadow: 0 6px 0 var(--ink);
  transform: rotate(-8deg);
}

.splash-icon svg {
  width: 46px;
  height: 46px;
}

.splash-title {
  font-family: var(--display);
  font-size: clamp(3rem, 17vw, 8rem);
  font-weight: 900;
  line-height: 0.95;
  letter-spacing: -0.04em;
  color: var(--text);
  -webkit-text-stroke: 3px var(--ink);
  paint-order: stroke fill;
  text-shadow: 6px 6px 0 var(--ink);
}

.splash-subtitle {
  padding: 6px 14px;
  border: 3px solid var(--ink);
  border-radius: 999px;
  background: var(--text);
  font-family: var(--display);
  font-size: 1rem;
  font-weight: 800;
}

@keyframes splash-life {
  0%, 85% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes splash-wipe {
  0% { clip-path: polygon(0 0, 0 0, 0 100%, 0 100%); }
  22%, 78% { clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%); }
  100% { clip-path: polygon(100% 0, 100% 0, 100% 100%, 100% 100%); }
}

@keyframes splash-text {
  0%, 12% { opacity: 0; transform: scale(0.3) rotate(-12deg); }
  32% { opacity: 1; transform: scale(1.05) rotate(2deg); }
  40%, 78% { opacity: 1; transform: scale(1) rotate(0); }
  100% { opacity: 0; transform: scale(1.4); }
}

.reveal-overlay {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 14px;
  padding: 24px;
  overflow: hidden;
  background: var(--bg-deep);
  color: var(--text);
  text-align: center;
  cursor: pointer;
  animation: fade-in 0.3s ease both;
}

.reveal-rays {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 1600px;
  height: 1600px;
  margin: -800px 0 0 -800px;
  background: repeating-conic-gradient(rgb(255 62 154 / 0.42) 0 8deg, rgb(56 214 255 / 0.22) 8deg 16deg);
  animation: rays 18s linear infinite;
  transition: background 0.4s ease;
}

.reveal-overlay > *:not(.reveal-rays) {
  position: relative;
}

.reveal-kicker {
  font-family: var(--display);
  font-size: clamp(1.3rem, 6vw, 2rem);
  font-weight: 800;
  letter-spacing: -0.02em;
}

.reveal-slot {
  position: relative;
  display: grid;
  min-height: min(60vw, 260px);
  place-items: center;
}

.reveal-slot::before {
  position: absolute;
  width: 130%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, rgb(255 212 59 / 0.95) 0, rgb(255 62 154 / 0.45) 38%, transparent 68%);
  animation: glow-pulse 0.9s ease-in-out infinite alternate;
  content: "";
}

.reveal-slot .avatar {
  position: relative;
}

.reveal-overlay[data-step="spin"] .reveal-slot .avatar {
  animation: slot-tick 0.12s ease-out;
}

@keyframes slot-tick {
  from { transform: translateY(-18px) scale(0.92); opacity: 0.4; }
}

.reveal-name {
  font-family: var(--display);
  font-size: clamp(2.2rem, 12vw, 4.4rem);
  font-weight: 900;
  letter-spacing: -0.04em;
  opacity: 0;
}

.reveal-outcome {
  padding: 10px 22px;
  border: 4px solid var(--ink);
  border-radius: 20px;
  background: var(--mint);
  box-shadow: 0 8px 0 var(--ink);
  color: var(--ink);
  font-family: var(--display);
  font-size: clamp(1.6rem, 8vw, 3rem);
  font-weight: 900;
  opacity: 0;
  transform: rotate(-4deg) scale(0.4);
}

.reveal-overlay[data-outcome="impostor"] .reveal-outcome {
  background: var(--red);
}

@keyframes glow-pulse {
  to { transform: scale(1.12); }
}

.reveal-sub {
  max-width: 30ch;
  color: var(--text);
  font-size: 1.1rem;
  font-weight: 700;
  opacity: 0;
}

.reveal-skip {
  position: absolute !important;
  bottom: max(24px, env(safe-area-inset-bottom));
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
}

.reveal-overlay[data-step="land"] .reveal-slot .avatar,
.reveal-overlay[data-step="outcome"] .reveal-slot .avatar {
  animation: slam 0.6s var(--spring) both;
}

.reveal-overlay[data-step="land"] .reveal-name,
.reveal-overlay[data-step="outcome"] .reveal-name {
  animation: name-in 0.5s var(--spring) both;
}

.reveal-overlay[data-step="outcome"] .reveal-outcome {
  animation: outcome-in 0.6s var(--spring) both;
}

.reveal-overlay[data-step="outcome"] .reveal-sub {
  animation: fade-in 0.4s ease 0.3s both;
}

.reveal-overlay[data-step="outcome"][data-outcome="crew"] .reveal-rays {
  background: repeating-conic-gradient(rgb(44 240 166 / 0.4) 0 8deg, rgb(255 212 59 / 0.16) 8deg 16deg);
}

.reveal-overlay[data-step="outcome"][data-outcome="impostor"] .reveal-rays {
  background: repeating-conic-gradient(rgb(255 59 92 / 0.42) 0 8deg, rgb(255 138 58 / 0.14) 8deg 16deg);
}

.reveal-overlay[data-step="outcome"][data-outcome="impostor"] {
  animation: alarm 0.5s ease 3;
}

@keyframes slam {
  0% { transform: scale(2.4) rotate(-14deg); opacity: 0; }
  60% { transform: scale(0.9) rotate(4deg); opacity: 1; }
  100% { transform: scale(1); }
}

@keyframes name-in {
  from { opacity: 0; transform: translateY(30px) scale(0.6); }
  to { opacity: 1; transform: none; }
}

@keyframes outcome-in {
  from { opacity: 0; transform: rotate(-20deg) scale(0.3); }
  to { opacity: 1; transform: rotate(-4deg) scale(1); }
}

@keyframes alarm {
  50% { background: #5c0f22; }
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.confetti-canvas {
  position: fixed;
  inset: 0;
  z-index: 130;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* Answer board */

.answer-board {
  position: fixed;
  inset: 0;
  z-index: 80;
  width: 100vw;
  min-height: 100dvh;
  overflow: hidden;
  overscroll-behavior: contain;
  background: var(--p, var(--sun));
  color: var(--ink);
}

.answer-board-content {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 100dvh;
  padding:
    max(16px, env(safe-area-inset-top))
    max(24px, env(safe-area-inset-right))
    max(16px, env(safe-area-inset-bottom))
    max(24px, env(safe-area-inset-left));
  background-image: radial-gradient(rgb(7 3 26 / 0.12) 2px, transparent 2.4px);
  background-size: 28px 28px;
}

.answer-board-topline {
  display: flex;
  min-height: 56px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding-right: 64px;
  font-family: var(--display);
  font-size: 1.05rem;
  font-weight: 900;
}

.board-who {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

#board-avatar .avatar {
  --avatar-size: 48px;
}

#board-avatar .av-body {
  stroke-width: 6;
}

.board-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 3px solid var(--ink);
  border-radius: 999px;
  background: var(--text);
  font-size: 0.85rem;
}

.board-status svg {
  width: 16px;
  height: 16px;
}

.answer-board-text {
  display: grid;
  min-width: 0;
  min-height: 0;
  place-items: center;
  padding: 18px 4vw;
  font-family: var(--display);
  font-size: 120px;
  font-weight: 900;
  line-height: 0.95;
  letter-spacing: -0.03em;
  text-align: center;
  overflow-wrap: anywhere;
  animation: board-in 0.6s var(--spring) both;
}

@keyframes board-in {
  from { transform: scale(0.5) rotate(-6deg); opacity: 0; }
}

.board-close {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  right: max(16px, env(safe-area-inset-right));
  z-index: 3;
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  border: var(--edge) solid var(--ink);
  border-radius: 16px;
  background: var(--text);
  box-shadow: 0 4px 0 var(--ink);
  color: var(--ink);
  cursor: pointer;
}

.board-close svg {
  width: 24px;
  height: 24px;
  stroke-width: 2.6;
}

.rotate-device {
  display: none;
}

.rotate-phone {
  position: relative;
  width: 70px;
  height: 120px;
  border: 5px solid var(--ink);
  border-radius: 16px;
  background: var(--text);
  animation: rotate-hint 2.2s var(--spring) infinite;
}

.rotate-phone::before {
  position: absolute;
  inset: 8px 6px 20px;
  border-radius: 6px;
  background: var(--cyan);
  content: "";
}

.rotate-visual {
  position: relative;
  display: grid;
  width: 190px;
  height: 190px;
  place-items: center;
}

.rotate-arrow {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  opacity: 0.5;
}

.rotate-arrow svg {
  width: 190px;
  height: 190px;
  stroke-width: 1.4;
  animation: spin 4s linear infinite;
}

.rotate-phone::after {
  position: absolute;
  bottom: 8px;
  left: 50%;
  width: 18px;
  height: 5px;
  margin-left: -9px;
  border-radius: 999px;
  background: var(--ink);
  content: "";
}

@keyframes rotate-hint {
  0%, 20% { transform: rotate(0); }
  55%, 85% { transform: rotate(-90deg); }
  100% { transform: rotate(0); }
}

@media (orientation: portrait) and (max-width: 900px) {
  .answer-board .answer-board-content {
    display: none;
  }

  .answer-board .rotate-device {
    position: absolute;
    inset: 0;
    display: grid;
    align-content: center;
    justify-items: center;
    gap: 22px;
    padding: 32px;
    text-align: center;
  }

  .rotate-device strong {
    font-family: var(--display);
    font-size: 2.2rem;
    font-weight: 900;
  }

  .rotate-device > span:last-child {
    font-weight: 700;
  }
}

/* Dialogs, toast, loading */

dialog {
  width: min(520px, calc(100% - 28px));
  padding: 0;
  border: var(--edge) solid var(--ink);
  border-radius: var(--radius-xl);
  background: var(--card);
  box-shadow: 0 12px 0 var(--ink);
  color: var(--text);
  overscroll-behavior: contain;
}

dialog[open] {
  animation: dialog-pop 0.45s var(--spring) both;
}

dialog::backdrop {
  background: rgb(11 6 32 / 0.72);
  backdrop-filter: blur(4px);
}

@keyframes dialog-pop {
  from { opacity: 0; transform: scale(0.8) translateY(30px) rotate(-3deg); }
}

.dialog-content {
  position: relative;
  padding: 26px 22px 22px;
}

.dialog-close {
  position: absolute;
  top: 14px;
  right: 14px;
}

.dialog-label {
  display: inline-flex;
  margin-bottom: 10px;
  padding: 4px 10px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--pink);
  color: var(--ink);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.dialog-content h2 {
  padding-right: 48px;
  font-size: 1.6rem;
}

.dialog-content > p:not(.dialog-label) {
  margin-top: 10px;
  color: var(--muted);
  font-weight: 600;
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}

.dialog-actions > button {
  flex: 1 1 140px;
}

.qr-dialog-content {
  text-align: center;
}

.qr-dialog-content .dialog-label {
  margin-inline: auto;
}

.qr-dialog-content h2 {
  padding: 0 40px;
}

.qr-code-frame {
  width: min(280px, 100%);
  margin: 18px auto 14px;
  padding: 12px;
  border: var(--edge) solid var(--ink);
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 8px 0 var(--ink);
  transform: rotate(-1.5deg);
}

.qr-code-frame img {
  display: block;
  width: 100%;
  height: auto;
}

.qr-room-label strong {
  font-family: var(--display);
  letter-spacing: 0.12em;
  color: var(--sun);
}

.toast {
  position: fixed;
  left: 50%;
  top: max(10px, env(safe-area-inset-top));
  z-index: 150;
  width: max-content;
  max-width: calc(100% - 24px);
  padding: 10px 16px;
  border: var(--edge) solid var(--ink);
  border-radius: 18px;
  background: var(--text);
  box-shadow: 0 6px 0 var(--ink);
  color: var(--ink);
  font-weight: 800;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -20px) scale(0.9);
  transition: opacity 0.2s ease, transform 0.35s var(--spring);
}

.toast.visible {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}

.loading-gate {
  position: fixed;
  inset: 0;
  z-index: 140;
  display: grid;
  place-items: center;
  background: rgb(11 6 32 / 0.2);
  animation: fade-in 0.3s ease 0.15s both;
}

.loading-dots {
  display: flex;
  gap: 8px;
  padding: 14px 18px;
  border: var(--edge) solid var(--ink);
  border-radius: 999px;
  background: var(--text);
  box-shadow: 0 5px 0 var(--ink);
}

.loading-dots span {
  width: 14px;
  height: 14px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--pink);
  animation: dot-bounce 0.7s ease-in-out infinite alternate;
}

.loading-dots span:nth-child(2) { background: var(--sun); animation-delay: 0.15s; }
.loading-dots span:nth-child(3) { background: var(--cyan); animation-delay: 0.3s; }

@keyframes dot-bounce {
  to { transform: translateY(-10px); }
}

/* Larger screens */

@media (max-width: 559px) {
  body:not([data-phase="home"]) .brand-name {
    display: none;
  }
}

@media (min-width: 560px) {
  .room-lobby-button {
    width: auto;
    padding: 0 14px;
  }

  .room-lobby-button span {
    display: inline;
  }

  .room-exit-button {
    width: auto;
    padding: 0 14px;
  }

  .room-exit-button span {
    display: inline;
  }

  .stage-actions {
    display: flex;
    justify-content: center;
  }

  .question-card,
  .secret-card-back {
    padding: 30px;
  }
}

@media (min-width: 900px) {
  main {
    padding-top: 16px;
  }

  .home-view {
    padding-top: 10px;
  }

  .home-hero {
    display: grid;
    grid-template-columns: auto 1fr;
    column-gap: 30px;
    align-items: end;
  }

  .hero-mascot {
    grid-row: span 3;
    width: 280px;
    align-self: center;
  }

  .entry-layout {
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
    align-items: start;
    gap: 36px;
  }

  .entry-panel {
    padding: 22px;
  }

  .game-stage {
    width: min(760px, 100%);
    margin: 0 auto;
  }

  .action-bar {
    margin-inline: 0;
    padding-inline: 26px;
    border: var(--edge) solid var(--ink);
    border-bottom: 0;
  }

  .prompt-comparison {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 479px) {
  .dialog-actions {
    flex-direction: column-reverse;
  }

  .dialog-actions > button {
    flex-basis: auto;
    width: 100%;
  }
}

@media (max-width: 380px) {
  .brand-name {
    display: none;
  }

  .mode-cards {
    grid-template-columns: 1fr;
  }

  .player-list,
  .vote-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .blob,
  .backdrop::before {
    animation: none !important;
  }
}
