html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--page);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
  touch-action: manipulation;
}

.stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: var(--page);
}

.field {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 540px;
  height: 960px;
  overflow: hidden;
  visibility: hidden;
  color: var(--ink);
  background:
    radial-gradient(120% 42% at 50% -8%, color-mix(in srgb, var(--rim) 70%, transparent), transparent 58%),
    var(--page);
  font-family: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.field.is-ready {
  visibility: visible;
}

.field,
.field * {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

[data-screen] {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  min-height: 0;
}

[data-screen="start"],
[data-screen="pass"],
[data-screen="talk"],
[data-screen="vote"],
[data-screen="end"] {
  align-items: center;
  padding: 22px 28px 18px;
  gap: 10px;
  text-align: center;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 72px;
  font-weight: 900;
  line-height: 0.84;
  letter-spacing: -0.05em;
  color: var(--active);
}

h2 {
  max-width: 100%;
  font-size: 52px;
  font-weight: 900;
  line-height: 0.95;
  letter-spacing: -0.04em;
  color: var(--active);
  overflow-wrap: anywhere;
}

.eyebrow,
.progress,
.kicker {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--active);
}

.kicker b,
.progress {
  font-variant-numeric: tabular-nums;
}

.hint,
.record,
.warn,
.unit,
.credit,
.role-note {
  max-width: 440px;
  font-size: 18px;
  font-weight: 650;
  line-height: 1.3;
  color: var(--muted);
}

.warn {
  min-height: 0;
}

.warn.is-alert {
  color: var(--no);
}

.mark {
  display: grid;
  width: 64px;
  height: 64px;
  flex: none;
  place-items: center;
  border-radius: 22px;
  background: var(--no);
  color: var(--no-ink);
  box-shadow: 0 7px 0 var(--line);
  font-size: 42px;
  font-weight: 900;
  line-height: 1;
}

.eye {
  display: grid;
  width: 72px;
  height: 72px;
  flex: none;
  place-items: center;
  border-radius: 50%;
  background: var(--card);
  box-shadow: 0 7px 0 var(--line);
}

.eye i {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--ink);
  animation: look 2.8s ease-in-out infinite;
}

.modes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
  flex: none;
}

.rounds {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
  flex: none;
}

.rounds p {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--active);
}

.stepper {
  display: grid;
  grid-template-columns: 64px 84px 64px;
  gap: 8px;
  align-items: center;
}

.stepper b {
  font-size: 42px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: var(--ink);
}

.stepper button {
  height: 56px;
  border: 0;
  border-radius: 16px;
  background: var(--team);
  color: var(--team-ink);
  box-shadow: 0 6px 0 var(--card-ink);
  font-size: 32px;
  font-weight: 900;
}

.stepper button:active {
  transform: translateY(3px);
  box-shadow: 0 3px 0 var(--card-ink);
}

.modes button,
[data-start],
[data-add],
[data-next],
[data-said],
[data-vote],
[data-again],
.choices button {
  border: 0;
  border-radius: 20px;
  box-shadow: 0 7px 0 var(--card-ink);
  font-size: 24px;
  font-weight: 900;
  letter-spacing: -0.03em;
}

.modes button {
  height: 64px;
  background: var(--team);
  color: var(--team-ink);
}

.modes button.is-on {
  background: var(--active);
  color: var(--card-ink);
}

.modes button:active,
[data-start]:active,
[data-add]:active,
[data-next]:active,
[data-said]:active,
[data-vote]:active,
[data-again]:active,
.choices button:active {
  transform: translateY(4px);
  box-shadow: 0 3px 0 var(--card-ink);
}

[data-start],
[data-add],
[data-vote],
[data-again] {
  background: var(--yes);
  color: var(--yes-ink);
}

[data-next],
[data-said] {
  background: var(--skip);
  color: var(--skip-ink);
}

[data-start],
[data-next],
[data-said],
[data-vote],
[data-again] {
  width: 100%;
  height: 76px;
  flex: none;
}

.name-row {
  display: grid;
  grid-template-columns: 1fr 108px;
  gap: 10px;
  width: 100%;
  flex: none;
}

.name-row input {
  height: 64px;
  min-width: 0;
  padding: 0 16px;
  border: 0;
  border-radius: 18px;
  background: var(--card);
  color: var(--card-ink);
  font-size: 22px;
  font-weight: 800;
  user-select: text;
  -webkit-user-select: text;
}

.name-row input::placeholder {
  color: color-mix(in srgb, var(--card-ink) 42%, var(--card));
}

.name-row input:focus-visible,
button:focus-visible {
  outline: 4px solid var(--active);
  outline-offset: 3px;
}

[data-add] {
  height: 64px;
  font-size: 22px;
}

.roster {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  align-content: start;
  width: 100%;
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.roster:empty {
  flex: none;
  min-height: 0;
}

.roster button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 48px;
  padding: 8px 12px;
  border: 0;
  border-radius: 14px;
  background: var(--team);
  color: var(--team-ink);
  box-shadow: none;
  font-size: 16px;
  font-weight: 800;
  text-align: left;
}

.roster button span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.roster button small {
  flex: none;
  color: var(--active);
  font-size: 13px;
  font-weight: 800;
}

button:disabled {
  opacity: 0.38;
  transform: none;
  cursor: default;
}

.quiet {
  height: 36px;
  flex: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  box-shadow: none;
  font-size: 15px;
  font-weight: 800;
}

.quiet:active {
  transform: none;
  box-shadow: none;
}

[data-screen="pass"] .hint,
[data-screen="talk"] .hint,
[data-screen="vote"] .hint {
  flex: none;
}

.secret {
  position: relative;
  width: 100%;
  flex: 1;
  min-height: 240px;
  perspective: 900px;
  touch-action: none;
}

.secret::before,
.card::before {
  content: "";
  position: absolute;
  top: 16px;
  right: 8px;
  bottom: 8px;
  left: 18px;
  border-radius: 36px;
  background: var(--active);
  transform: rotate(3.5deg);
}

.secret-inner {
  position: relative;
  z-index: 1;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.28s cubic-bezier(0.2, 0.85, 0.2, 1);
}

.secret.is-open .secret-inner {
  transform: rotateY(180deg);
}

.face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 22px 18px;
  border: 8px solid var(--rim);
  border-radius: 36px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  box-shadow: 0 14px 0 var(--line);
}

.face.front {
  background: var(--team);
  color: var(--active);
}

.face.front p {
  font-size: 36px;
  font-weight: 900;
  letter-spacing: -0.04em;
  animation: pulse 1.4s ease-in-out infinite;
}

.face.back {
  background: var(--card);
  color: var(--card-ink);
  transform: rotateY(180deg);
}

.secret.is-spy .face.back {
  background: var(--no);
  color: var(--no-ink);
  border-color: var(--active);
}

.secret.is-spy .face.back .eyebrow,
.secret.is-spy .face.back .role-note {
  color: var(--active);
}

.secret.is-word .face.back h2 {
  color: var(--card-ink);
  animation: pop 0.35s cubic-bezier(0.2, 1.4, 0.36, 1) both;
}

.secret.is-spy .face.back h2 {
  color: var(--no-ink);
  animation: shake 0.42s ease both;
}

.face.back h2.is-long {
  font-size: 36px;
}

.role-hint {
  max-width: 360px;
  padding: 10px 14px;
  border-radius: 14px;
  background: var(--chip);
  color: var(--chip-ink);
  font-size: 18px;
  font-weight: 800;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.secret.is-spy .role-hint {
  background: var(--card);
  color: var(--card-ink);
}

.pips {
  display: flex;
  flex: none;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  max-width: 420px;
}

.pips i {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--team);
}

.pips i.is-done {
  background: var(--rim);
}

.pips i.is-now {
  background: var(--active);
  transform: scale(1.3);
}

.card {
  position: relative;
  display: flex;
  width: 100%;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-height: 0;
  padding: 24px 18px;
}

.card h2,
.card .hint {
  position: relative;
  z-index: 1;
}

.card h2 {
  color: var(--card-ink);
  font-size: 64px;
}

.card .hint {
  color: color-mix(in srgb, var(--card-ink) 72%, var(--card));
}

.card.is-in h2 {
  animation: rise 0.28s ease both;
}

.choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-content: start;
  width: 100%;
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.choices button {
  min-height: 72px;
  padding: 8px 12px;
  background: var(--team);
  color: var(--team-ink);
  overflow-wrap: anywhere;
}

.choices button:last-child:nth-child(odd) {
  grid-column: 1 / -1;
}

.choices button.is-on {
  background: var(--active);
  color: var(--card-ink);
}

[data-screen="end"] {
  position: relative;
  justify-content: center;
  overflow: hidden;
  gap: 14px;
  padding-top: 28px;
  padding-bottom: 28px;
}

[data-screen="end"].is-win [data-end-title] {
  animation: announce 0.7s cubic-bezier(0.2, 1.35, 0.35, 1) both;
}

.result {
  display: flex;
  width: 100%;
  flex: none;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 26px 22px 22px;
  border: 8px solid var(--rim);
  border-radius: 32px;
  background: var(--card);
  color: var(--card-ink);
  box-shadow: 0 14px 0 var(--line);
}

[data-screen="end"].is-win .result {
  border-color: var(--active);
}

[data-screen="end"].is-spy .result {
  border-color: var(--no);
}

.result .kicker {
  margin-top: 12px;
  color: var(--rim);
}

.result .kicker:first-child {
  margin-top: 0;
}

.result h2,
.answer {
  max-width: 100%;
  color: var(--card-ink);
  font-size: 48px;
  font-weight: 900;
  line-height: 1;
  overflow-wrap: anywhere;
}

.answer.is-long,
.result h2.is-long {
  font-size: 34px;
}

[data-screen="end"].is-win [data-impostor-name] {
  animation: lift 0.5s ease both;
}

[data-screen="end"].is-spy [data-impostor-name] {
  animation: shake 0.4s ease both;
}

.picked {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-top: 4px;
  color: color-mix(in srgb, var(--card-ink) 70%, var(--card));
  font-size: 16px;
  font-weight: 800;
}

.picked span {
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.picked b {
  font-size: 22px;
  overflow-wrap: anywhere;
}

.hint-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.hint-row span {
  color: color-mix(in srgb, var(--card-ink) 55%, var(--card));
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.hint-row b {
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--chip);
  color: var(--chip-ink);
  font-size: 18px;
  font-weight: 800;
}

.scoreline {
  display: flex;
  flex: none;
  align-items: baseline;
  justify-content: center;
  gap: 10px;
}

.scoreline [data-score-label] {
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.scoreline b {
  color: var(--active);
  font-size: 56px;
  font-weight: 900;
  line-height: 0.9;
  font-variant-numeric: tabular-nums;
}

.scoreline [data-credit] {
  color: var(--ink);
  font-size: 22px;
  font-weight: 800;
}

.record {
  flex: none;
}

.confetti {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.confetti i {
  position: absolute;
  top: -24px;
  width: 14px;
  height: 22px;
  border-radius: 4px;
  opacity: 0;
}

.confetti i:nth-child(odd) {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.confetti i:nth-child(4n + 1) { background: var(--active); }
.confetti i:nth-child(4n + 2) { background: var(--rim); }
.confetti i:nth-child(4n + 3) { background: var(--line); }
.confetti i:nth-child(4n) { background: var(--no); }

.confetti i:nth-child(1) { left: 6%; }
.confetti i:nth-child(2) { left: 14%; }
.confetti i:nth-child(3) { left: 22%; }
.confetti i:nth-child(4) { left: 31%; }
.confetti i:nth-child(5) { left: 40%; }
.confetti i:nth-child(6) { left: 48%; }
.confetti i:nth-child(7) { left: 57%; }
.confetti i:nth-child(8) { left: 66%; }
.confetti i:nth-child(9) { left: 74%; }
.confetti i:nth-child(10) { left: 82%; }
.confetti i:nth-child(11) { left: 90%; }
.confetti i:nth-child(12) { left: 18%; }
.confetti i:nth-child(13) { left: 36%; }
.confetti i:nth-child(14) { left: 54%; }
.confetti i:nth-child(15) { left: 72%; }
.confetti i:nth-child(16) { left: 88%; }

[data-screen="end"].is-win .confetti i {
  animation: fall 1.8s ease-in forwards;
}

[data-screen="end"].is-win .confetti i:nth-child(2n) { animation-delay: 0.16s; }
[data-screen="end"].is-win .confetti i:nth-child(3n) { animation-delay: 0.34s; }

.field.cut .eye i,
.field.cut .face.front p,
.field.cut .secret-inner,
.field.cut .secret.is-spy .face.back h2,
.field.cut .secret.is-word .face.back h2,
.field.cut .card.is-in h2,
.field.cut .confetti i,
.field.cut [data-screen="end"].is-win [data-end-title],
.field.cut [data-screen="end"].is-win [data-impostor-name],
.field.cut [data-screen="end"].is-spy [data-impostor-name] {
  animation: none;
  transition: none;
}

@keyframes look {
  0%,
  100% { transform: translateX(-6px); }
  50% { transform: translateX(6px); }
}

@keyframes pulse {
  0%,
  100% { opacity: 1; }
  50% { opacity: 0.55; }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(28px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes pop {
  0% { transform: scale(0.6); }
  70% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

@keyframes shake {
  0%,
  100% { transform: translateX(0); }
  20% { transform: translateX(-12px); }
  40% { transform: translateX(10px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(4px); }
}

@keyframes announce {
  0% {
    opacity: 0;
    transform: scale(0.4) rotate(-6deg);
  }
  55% {
    opacity: 1;
    transform: scale(1.08) rotate(2deg);
  }
  100% {
    opacity: 1;
    transform: none;
  }
}

@keyframes lift {
  from { transform: translateY(16px) scale(0.94); }
  to { transform: none; }
}

@keyframes fall {
  0% {
    opacity: 1;
    transform: translateY(0) rotate(0deg);
  }
  100% {
    opacity: 0.2;
    transform: translateY(980px) rotate(280deg);
  }
}
