:root {
  color-scheme: dark;
  --bg: #0a0912;
  --surface: #15131f;
  --surface-raised: #1d1a2b;
  --paper: #f7f5eb;
  --muted: #aaa5b8;
  --line: #393447;
  --acid: #dfff00;
  --pink: #ff4fa3;
  --cyan: #52e6ff;
  --orange: #ff8a33;
  --danger: #ff5470;
  --shadow: 8px 8px 0 #000;
  --radius: 22px;
  font-family: "Bricolage Grotesque", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--paper);
  background:
    radial-gradient(circle at 15% 12%, rgba(255, 79, 163, 0.17), transparent 28rem),
    radial-gradient(circle at 92% 38%, rgba(82, 230, 255, 0.12), transparent 30rem),
    var(--bg);
}

button,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

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

.page-noise {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.24;
  background-image: radial-gradient(rgba(255, 255, 255, 0.28) 0.7px, transparent 0.7px);
  background-size: 18px 18px;
  mask-image: linear-gradient(to bottom, black, transparent 82%);
}

.topbar {
  width: min(1180px, calc(100% - 32px));
  min-height: 76px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--paper);
  font-size: 1rem;
  font-weight: 950;
  letter-spacing: 0.12em;
  text-decoration: none;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  transform: rotate(-5deg);
  border: 2px solid #000;
  border-radius: 10px;
  color: var(--bg);
  background: var(--acid);
  box-shadow: 3px 3px 0 #000;
}

.brand-mark svg {
  width: 30px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.6;
}

.brand-mark circle {
  fill: var(--pink);
  stroke: var(--bg);
}

.text-button,
.icon-button {
  min-height: 44px;
  border: 0;
  color: var(--paper);
  background: transparent;
  cursor: pointer;
}

.text-button {
  padding: 8px 0;
  border-bottom: 2px solid var(--acid);
  font-weight: 800;
}

#app {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 38px 0 72px;
}

.setup-shell {
  display: grid;
  grid-template-columns: minmax(280px, 0.82fr) minmax(520px, 1.18fr);
  gap: clamp(34px, 7vw, 96px);
  align-items: start;
}

.setup-intro {
  position: sticky;
  top: 32px;
  padding-top: 26px;
}

h1,
h2,
p {
  overflow-wrap: break-word;
}

h1 {
  max-width: 680px;
  margin: 0;
  font-size: clamp(3.4rem, 7.6vw, 7.2rem);
  line-height: 0.94;
  letter-spacing: -0.055em;
  text-transform: uppercase;
}

h1 em {
  color: var(--pink);
  font-style: normal;
}

.intro-copy {
  max-width: 500px;
  margin: 28px 0 0;
  color: #d7d3df;
  font-size: clamp(1.05rem, 2vw, 1.22rem);
  line-height: 1.6;
}

.rule-strip {
  max-width: 500px;
  margin-top: 36px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-block: 1px solid var(--line);
}

.rule-strip div {
  min-width: 0;
  padding: 18px 12px 18px 0;
  display: flex;
  align-items: center;
  gap: 9px;
}

.rule-strip div + div {
  padding-left: 12px;
  border-left: 1px solid var(--line);
}

.rule-strip b {
  flex: 0 0 auto;
  color: var(--pink);
  font-size: 1.15rem;
}

.rule-strip span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
  line-height: 1.25;
}

.setup-panel {
  padding: clamp(22px, 4vw, 38px);
  border: 2px solid var(--line);
  border-radius: 30px;
  background: rgba(21, 19, 31, 0.96);
  box-shadow: var(--shadow);
}

.setup-section {
  min-width: 0;
}

.section-heading {
  margin-bottom: 20px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.section-heading > div:first-child {
  min-width: 0;
  display: flex;
  align-items: baseline;
}

.section-heading h2 {
  margin: 0;
  font-size: clamp(1.3rem, 3vw, 1.7rem);
  line-height: 1.1;
  letter-spacing: -0.035em;
}

.section-note {
  flex: 0 0 auto;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 750;
}

.player-list {
  display: grid;
  gap: 10px;
}

.player-row {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 44px;
  align-items: center;
  gap: 8px;
}

.player-number {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 900;
  text-align: center;
}

.player-row input {
  width: 100%;
  min-height: 52px;
  padding: 0 15px;
  border: 2px solid var(--line);
  border-radius: 13px;
  color: var(--paper);
  background: #0e0c17;
  font-size: 1rem;
  font-weight: 700;
  transition: border-color 160ms ease, transform 160ms ease;
}

.player-row input::placeholder {
  color: #6f6a7b;
}

.player-row input:focus {
  border-color: var(--cyan);
  transform: translateY(-1px);
}

.remove-player {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 11px;
  color: var(--muted);
  background: transparent;
  font-size: 1.4rem;
  cursor: pointer;
}

.remove-player:hover {
  color: var(--paper);
  background: var(--surface-raised);
}

.add-player {
  min-height: 48px;
  margin: 12px 0 0 46px;
  padding: 0 4px;
  border: 0;
  color: var(--cyan);
  background: transparent;
  font-size: 0.92rem;
  font-weight: 850;
  cursor: pointer;
}

.add-player span {
  margin-right: 5px;
  font-size: 1.15rem;
}

.form-error {
  min-height: 1.25rem;
  margin: 7px 0 0 46px;
  color: #ff8aa0;
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.4;
}

.panel-divider {
  height: 1px;
  margin: 26px 0;
  background: var(--line);
}

.compact-heading {
  align-items: center;
  margin-bottom: 8px;
}

.stepper {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 44px 45px 44px;
  align-items: center;
  border: 2px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: #0e0c17;
}

.stepper button {
  min-height: 46px;
  border: 0;
  color: var(--paper);
  background: transparent;
  font-size: 1.25rem;
  font-weight: 700;
  cursor: pointer;
}

.stepper button:hover:not(:disabled) {
  color: var(--bg);
  background: var(--acid);
}

.stepper button:disabled {
  opacity: 0.28;
  cursor: not-allowed;
}

.stepper output {
  display: grid;
  place-items: center;
  align-self: stretch;
  border-inline: 1px solid var(--line);
  font-size: 1.05rem;
  font-weight: 950;
}

.helper-text {
  margin: 0 0 0 38px;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.45;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.category-card {
  min-width: 0;
  min-height: 126px;
  padding: 13px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  border: 2px solid var(--line);
  border-radius: 16px;
  color: var(--paper);
  background: #0e0c17;
  text-align: left;
  cursor: pointer;
  transition: border-color 150ms ease, transform 150ms ease, box-shadow 150ms ease;
}

.category-card:hover {
  border-color: #6d657e;
  transform: translateY(-2px);
}

.category-card[aria-checked="true"] {
  border-color: var(--acid);
  color: var(--bg);
  background: var(--acid);
  box-shadow: 4px 4px 0 #000;
}

.category-emoji {
  font-size: 1.65rem;
  line-height: 1;
  filter: saturate(1.15);
}

.category-copy {
  min-width: 0;
}

.category-copy b,
.category-copy small {
  display: block;
}

.category-copy b {
  font-size: 0.86rem;
  line-height: 1.15;
}

.category-copy small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.68rem;
  line-height: 1.25;
}

.category-card[aria-checked="true"] small {
  color: rgba(10, 9, 18, 0.72);
}

.primary-button,
.secondary-button {
  min-height: 56px;
  padding: 0 22px;
  border: 2px solid #000;
  border-radius: 14px;
  font-weight: 950;
  cursor: pointer;
  transition: transform 130ms ease, box-shadow 130ms ease, background 130ms ease;
}

.primary-button {
  color: var(--bg);
  background: var(--acid);
  box-shadow: 5px 5px 0 #000;
}

.primary-button:hover {
  transform: translate(-2px, -2px);
  box-shadow: 7px 7px 0 #000;
}

.primary-button:active {
  transform: translate(3px, 3px);
  box-shadow: 2px 2px 0 #000;
}

.secondary-button {
  border-color: var(--line);
  color: var(--paper);
  background: transparent;
}

.secondary-button:hover {
  border-color: var(--paper);
  background: var(--surface-raised);
}

.start-button {
  width: 100%;
  min-height: 64px;
  margin-top: 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 1.05rem;
}

.start-button span:last-child {
  font-size: 1.55rem;
}

.game-shell {
  width: min(680px, 100%);
  margin: 0 auto;
  padding-top: clamp(10px, 5vh, 52px);
}

body[data-screen="game"] #app {
  min-height: calc(100vh - 76px);
}

.game-topline {
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.theme-pill {
  font-size: 0.75rem;
  font-weight: 800;
}

.theme-pill {
  max-width: 230px;
  padding: 8px 11px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--cyan);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.end-game-button {
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid #5b536b;
  border-radius: 11px;
  color: #d3cedc;
  background: transparent;
  font-size: 0.75rem;
  font-weight: 850;
  white-space: nowrap;
  cursor: pointer;
}

.end-game-button:hover {
  border-color: var(--pink);
  color: var(--paper);
  background: rgba(255, 79, 163, 0.1);
}

.progress-track {
  margin-bottom: 18px;
  display: grid;
  grid-template-columns: repeat(var(--players), minmax(3px, 1fr));
  gap: 6px;
}

.progress-track span {
  height: 5px;
  border-radius: 99px;
  background: var(--line);
}

.progress-track span.done {
  background: var(--acid);
}

.progress-track span.current {
  background: var(--pink);
}

.pass-card,
.role-card,
.discussion-card,
.result-card {
  position: relative;
  overflow: hidden;
  padding: clamp(25px, 6vw, 48px);
  border: 2px solid var(--line);
  border-radius: 28px;
  background: var(--surface);
  box-shadow: var(--shadow);
  animation: card-in 260ms ease both;
}

.pass-card::after,
.discussion-card::after,
.result-card::after {
  content: "";
  position: absolute;
  z-index: 0;
  right: -78px;
  top: -78px;
  width: 180px;
  aspect-ratio: 1;
  border: 30px solid rgba(82, 230, 255, 0.08);
  border-radius: 50%;
}

.pass-card > *,
.discussion-card > *,
.result-card > * {
  position: relative;
  z-index: 1;
}

.pass-number {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border: 2px solid var(--pink);
  border-radius: 50%;
  color: var(--pink);
  font-size: 1.05rem;
  font-weight: 950;
}

.pass-card h2,
.role-card h2,
.discussion-card h2,
.result-card h2 {
  margin: 22px 0 12px;
  font-size: clamp(2.3rem, 9vw, 4.8rem);
  line-height: 1;
  letter-spacing: -0.045em;
}

.pass-card > p,
.role-card > p,
.discussion-card > p,
.result-card > p {
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.55;
}

.pass-card .primary-button,
.role-card .primary-button,
.discussion-card .primary-button,
.result-card .primary-button {
  width: 100%;
  margin-top: 32px;
}

.role-card {
  min-height: 500px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  color: var(--paper);
  background: var(--surface);
  border-color: var(--line);
}

.role-card.imposter-card {
  color: var(--paper);
  background: var(--surface);
  border-color: var(--line);
}

.role-card h2 {
  max-width: 100%;
  color: var(--paper);
  font-size: clamp(3rem, 13vw, 6.7rem);
  text-transform: uppercase;
}

.role-card > p {
  color: var(--muted);
  font-size: 1.05rem;
  font-weight: 650;
}

.role-card.imposter-card > p {
  color: var(--muted);
}

.role-card .word-label {
  color: var(--cyan);
  font-size: 1rem;
  font-weight: 800;
}

.secret-word {
  margin: 19px 0 0;
  font-size: clamp(2.8rem, 12vw, 6rem);
  font-weight: 950;
  line-height: 0.93;
  letter-spacing: -0.045em;
  color: var(--paper);
  overflow-wrap: anywhere;
}

.role-theme {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 2px solid var(--line);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.imposter-card .role-theme {
  border-color: var(--line);
}

.role-card .primary-button {
  border-color: #000;
  color: var(--bg);
  background: var(--acid);
}

.imposter-card .primary-button {
  color: var(--bg);
  background: var(--acid);
}

.starter-callout {
  margin: 28px 0;
  padding: 18px;
  border: 2px solid var(--pink);
  border-radius: 16px;
  color: var(--paper);
  background: rgba(255, 79, 163, 0.1);
}

.starter-callout strong {
  display: block;
}

.starter-callout strong {
  font-size: 1.55rem;
}

.clue-steps {
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  list-style: none;
}

.clue-steps li {
  min-height: 106px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  line-height: 1.35;
}

.clue-steps b {
  display: block;
  margin-bottom: 14px;
  color: var(--cyan);
  font-size: 1rem;
}

.game-secondary-action {
  width: 100%;
  margin-top: 12px;
}

.role-roster {
  margin: 27px 0 0;
  display: grid;
  gap: 9px;
}

.role-row {
  padding: 15px 17px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.025);
  font-size: 1.08rem;
  font-weight: 900;
}

.role-row.imposter-role {
  border-color: var(--pink);
  background: rgba(255, 79, 163, 0.1);
}

.role-label {
  color: var(--acid);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
}

.imposter-role .role-label {
  color: var(--pink);
}

.answer-box {
  margin-top: 22px;
  padding: 18px;
  border-radius: 16px;
  color: var(--bg);
  background: var(--acid);
}

.answer-box span,
.answer-box strong,
.answer-box small {
  display: block;
}

.answer-box span {
  font-size: 0.7rem;
  font-weight: 950;
  letter-spacing: 0.12em;
}

.answer-box strong {
  margin: 3px 0;
  font-size: clamp(1.8rem, 8vw, 3.4rem);
  line-height: 1;
  letter-spacing: -0.045em;
}

.answer-box small {
  font-size: 0.77rem;
  font-weight: 750;
  opacity: 0.68;
}

.result-actions {
  margin-top: 30px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.result-actions .primary-button,
.result-actions .secondary-button {
  width: 100%;
  margin: 0;
}

dialog {
  width: min(520px, calc(100% - 32px));
  padding: 28px;
  border: 2px solid var(--line);
  border-radius: 24px;
  color: var(--paper);
  background: var(--surface);
  box-shadow: 10px 10px 0 #000;
}

dialog::backdrop {
  background: rgba(4, 3, 9, 0.82);
  backdrop-filter: blur(6px);
}

.dialog-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.dialog-topline h2 {
  margin: 0;
}

.icon-button {
  width: 44px;
  font-size: 1.7rem;
  cursor: pointer;
}

dialog h2 {
  margin: 0 0 12px;
  font-size: 2.4rem;
  line-height: 1;
  letter-spacing: -0.05em;
}

dialog p,
dialog li {
  color: var(--muted);
  line-height: 1.55;
}

dialog ol {
  padding-left: 22px;
}

dialog li + li {
  margin-top: 10px;
}

dialog li b {
  color: var(--paper);
}

.rules-dialog > .primary-button {
  width: 100%;
  margin-top: 12px;
}

.dialog-actions {
  margin-top: 24px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.danger-button {
  color: var(--paper);
  background: var(--pink);
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 920px) {
  .setup-shell {
    grid-template-columns: 1fr;
    gap: 38px;
  }

  .setup-intro {
    position: static;
    padding-top: 0;
  }

  h1 {
    font-size: clamp(3.7rem, 14vw, 7rem);
  }

}

@media (max-width: 600px) {
  .topbar,
  #app {
    width: min(100% - 24px, 1180px);
  }

  .topbar {
    min-height: 66px;
  }

  #app {
    padding-top: 24px;
  }

  .brand {
    font-size: 0.85rem;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
  }

  .setup-intro h1 {
    font-size: clamp(3.3rem, 18vw, 5.3rem);
  }

  .intro-copy {
    margin-top: 21px;
  }

  .rule-strip {
    margin-top: 28px;
  }

  .rule-strip div {
    padding-block: 15px;
    flex-direction: column;
    align-items: flex-start;
  }

  .setup-panel {
    margin-inline: -2px;
    padding: 20px 16px;
    border-radius: 22px;
    box-shadow: 5px 5px 0 #000;
  }

  .section-heading h2 {
    font-size: 1.23rem;
  }

  .compact-heading {
    align-items: flex-start;
  }

  .compact-heading > div:first-child {
    padding-top: 10px;
  }

  .helper-text {
    margin-left: 0;
  }

  .category-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .category-card {
    min-height: 118px;
  }

  .game-shell {
    padding-top: 12px;
  }

  .theme-pill {
    max-width: min(60%, 230px);
  }

  .pass-card,
  .role-card,
  .discussion-card,
  .result-card {
    padding: 24px 20px;
    border-radius: 23px;
    box-shadow: 5px 5px 0 #000;
  }

  .role-card {
    min-height: min(540px, calc(100vh - 180px));
  }

  .clue-steps {
    grid-template-columns: 1fr;
  }

  .clue-steps li {
    min-height: 0;
    display: grid;
    grid-template-columns: 30px 1fr;
    align-items: center;
  }

  .clue-steps b {
    margin: 0;
  }

  .result-actions,
  .dialog-actions {
    grid-template-columns: 1fr;
  }
}

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