:root {
  color-scheme: light;
  --bg: #f4efe6;
  --bg-elev: #fffdf8;
  --ink: #1c1714;
  --muted: #5c5348;
  --line: #e0d3c2;
  --accent: #e4572e;
  --accent-ink: #1c1714;
  --card: #fffdf8;
  --shadow: 0 18px 50px rgba(48, 28, 12, 0.08);
  --radius: 1.25rem;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --max: 46rem;
  --stage: 34rem;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #141210;
  --bg-elev: #1e1b17;
  --ink: #f6f1e8;
  --muted: #cbbfb2;
  --line: #3a332c;
  --accent: #ff8a5c;
  --accent-ink: #1c1714;
  --card: #221e1a;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] {
    color-scheme: dark;
    --bg: #141210;
    --bg-elev: #1e1b17;
    --ink: #f6f1e8;
    --muted: #cbbfb2;
    --line: #3a332c;
    --accent: #ff8a5c;
    --accent-ink: #1c1714;
    --card: #221e1a;
    --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  }
}

*,
*::before,
*::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 1.125rem;
  line-height: 1.5;
  background: var(--bg);
  color: var(--ink);
  text-rendering: optimizeLegibility;
}

body.is-playing { overflow: hidden; }

img { max-width: 100%; }

a { color: inherit; }

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

.skip {
  position: absolute;
  left: 1rem;
  top: -5rem;
  background: var(--ink);
  color: var(--bg);
  padding: 0.7rem 1rem;
  border-radius: 0.7rem;
  z-index: 100;
}

.skip:focus { top: 0.75rem; }

.site-header,
.site-footer {
  width: min(100% - 1.5rem, var(--max));
  margin-inline: auto;
}

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  padding: 0.75rem 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 800;
  text-decoration: none;
  letter-spacing: -0.03em;
  font-size: 1.15rem;
  min-height: 3rem;
}

.logo { display: block; }

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.35rem;
  margin-left: auto;
}

.nav a,
.footer-nav a,
.theme-toggle,
#open-consent {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 3rem;
  padding: 0.35rem 0.75rem;
  text-decoration: none;
  font-weight: 650;
  font-size: 1rem;
  border-radius: 999px;
}

.nav a[aria-current="page"] { background: var(--card); box-shadow: inset 0 0 0 2px var(--line); }

.theme-toggle,
#open-consent,
.btn,
.chip,
.stepper button,
select,
.secret-card {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.theme-toggle {
  border: 2px solid var(--line);
  background: var(--card);
}

main {
  width: min(100% - 1.5rem, var(--max));
  margin: 0 auto 3rem;
}

.eyebrow,
.kicker {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

h1, h2, h3 { line-height: 1.15; letter-spacing: -0.03em; }

h1 { font-size: clamp(2.3rem, 8vw, 3.6rem); margin: 0.35rem 0 0.75rem; }

.lede { font-size: 1.2rem; margin-top: 0; max-width: 38rem; }

.setup,
.panel,
.prose section,
.legal {
  margin-top: 1.5rem;
}

.setup {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
}

fieldset {
  border: 0;
  margin: 0 0 1.15rem;
  padding: 0;
  min-inline-size: 0;
}

legend {
  font-weight: 800;
  padding: 0;
  margin-bottom: 0.55rem;
}

.setup-grid {
  display: grid;
  gap: 0.5rem 1rem;
}

.stepper {
  display: grid;
  grid-template-columns: 3.25rem 1fr 3.25rem;
  gap: 0.5rem;
  align-items: stretch;
}

.stepper button,
.stepper input,
select,
.btn,
.secret-card {
  border-radius: 0.9rem;
}

.stepper button,
.stepper input,
select {
  min-height: 3.25rem;
  border: 2px solid var(--line);
  background: var(--bg);
  text-align: center;
}

.stepper button { font-size: 1.6rem; background: var(--bg-elev); }
.stepper button:disabled {
  opacity: 0.38;
  cursor: not-allowed;
  background: var(--bg);
  color: var(--muted);
}
.stepper input { font-size: 1.5rem; font-weight: 800; width: 100%; }

.field-help,
.stage-detail,
.fine,
.ad-label,
.consent-row-detail,
.choice small,
.select-label {
  color: var(--muted);
  font-size: 0.98rem;
}

.field-help { margin: 0.45rem 0 0; }

.chips,
.mode-row,
.footer-nav,
.consent-actions,
.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chip {
  min-height: 2.85rem;
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  border: 2px solid var(--line);
  background: var(--bg);
  font-weight: 700;
}

.chip[aria-checked="true"],
.chip[aria-pressed="true"] {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}

.choice-grid { display: grid; gap: 0.6rem; }

.choice,
.checkline {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  min-height: 3.25rem;
}

.choice {
  padding: 0.85rem;
  border: 2px solid var(--line);
  border-radius: 1rem;
  background: var(--bg);
}

.choice:has(input:checked) { border-color: var(--ink); background: var(--bg-elev); }

.choice span,
.checkline span { display: grid; gap: 0.15rem; }

.choice strong { font-size: 1.05rem; }
.choice small { display: block; }

.choice input,
.checkline input {
  width: 1.35rem;
  height: 1.35rem;
  margin-top: 0.2rem;
  accent-color: var(--accent);
}

.select-label { display: block; margin-bottom: 0.45rem; }

select {
  width: 100%;
  text-align: left;
  padding: 0 0.9rem;
  background: var(--bg);
}

.name-fields {
  display: grid;
  gap: 0.55rem;
  margin-top: 0.75rem;
}

.name-label { display: grid; gap: 0.25rem; font-size: 0.95rem; font-weight: 700; }

.name-label input,
textarea {
  width: 100%;
  min-height: 3.1rem;
  border: 2px solid var(--line);
  border-radius: 0.8rem;
  background: var(--bg);
  color: inherit;
  font: inherit;
  font-size: 1.05rem;
  padding: 0.55rem 0.75rem;
}

textarea { min-height: 9rem; resize: vertical; }

.form-error {
  margin: 0;
  padding: 0;
  color: var(--accent-ink);
  border-radius: 0.7rem;
}

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

.form-error:not(:empty) {
  padding: 0.7rem 0.85rem;
  background: color-mix(in srgb, var(--accent) 28%, var(--card));
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid transparent;
  min-height: 3.1rem;
  padding: 0.65rem 1rem;
  font-weight: 800;
  text-decoration: none;
  text-align: center;
  touch-action: manipulation;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  width: 100%;
}

.btn-xl { min-height: 3.6rem; font-size: 1.15rem; }

.btn-equal {
  flex: 1 1 8rem;
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}

.btn-text {
  background: transparent;
  color: inherit;
  width: 100%;
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

/* Empty until AdSense is switched on. The commented hook in consent.js
   adds body.ads-enabled when that loader is uncommented. */
.ad-slot {
  display: none;
  margin: 0;
  min-height: 0;
  padding: 0;
  border: 0;
}

body.ads-enabled .ad-slot {
  min-height: 100px;
  margin: 1.25rem 0;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 0.9rem;
}

body.ads-enabled .ad-slot--mid { min-height: 250px; }

.ad-label {
  margin: 0;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.72rem;
}

body.is-playing .ad-slot {
  display: none !important;
}

.stage {
  position: fixed;
  inset: 0;
  z-index: 80;
  overflow: auto;
  background:
    radial-gradient(circle at 15% 0%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 32rem),
    var(--bg);
  padding: calc(1rem + env(safe-area-inset-top)) 1rem calc(1.5rem + env(safe-area-inset-bottom));
}

.stage-inner {
  width: min(100%, var(--stage));
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.stage-progress {
  margin: 0;
  font-weight: 800;
  color: var(--muted);
  font-size: 0.95rem;
}

#panel-pass,
#panel-peek,
#panel-discuss,
#panel-result {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

#panel-pass[hidden],
#panel-peek[hidden],
#panel-discuss[hidden],
#panel-result[hidden],
.stage[hidden],
.consent[hidden],
.name-fields[hidden],
#custom-field[hidden] {
  display: none !important;
}

.stage h2 { font-size: clamp(2.8rem, 12vw, 4.5rem); margin: 0; }

/* Crew and imposter reveals share this card. Only the text changes. */
.secret-card {
  width: 100%;
  min-height: 18rem;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.45rem;
  text-align: left;
  background: var(--card);
  border: 2px solid var(--ink);
  box-shadow: inset 0 0 0 7px var(--card), inset 0 0 0 9px var(--ink);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.secret-kicker {
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.secret-word {
  font-size: clamp(2.4rem, 10vw, 4.2rem);
  font-weight: 850;
  letter-spacing: -0.04em;
  line-height: 1.02;
  text-wrap: balance;
}

.secret-hint { font-size: 1.15rem; max-width: 22rem; }

.timer-block { display: grid; gap: 0.55rem; justify-items: start; }

.timer-digits {
  margin: 0;
  font-size: 3.2rem;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.04em;
}

.result-word {
  margin: 0;
  font-size: clamp(2.6rem, 11vw, 4.4rem);
  font-weight: 850;
  letter-spacing: -0.045em;
  line-height: 0.98;
}

.result-list {
  margin: 0;
  padding-left: 1.2rem;
  font-size: 1.35rem;
  font-weight: 800;
}

.prose h2 { font-size: clamp(1.7rem, 4vw, 2.15rem); margin: 2.4rem 0 0.6rem; }
.prose h3 { font-size: 1.25rem; margin: 0 0 0.4rem; }
.prose p,
.prose li { font-size: 1.06rem; }
.prose ul,
.prose ol { padding-left: 1.2rem; }
.prose li + li { margin-top: 0.35rem; }

.steps,
.tip-grid,
.split,
.faq-list { display: grid; gap: 0.8rem; }

.steps li,
.card,
.faq-item {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: 0.95rem 1rem;
  list-style: none;
}

.steps { list-style: none; padding: 0; counter-reset: step; }

.steps li { counter-increment: step; }

.steps h3::before {
  content: counter(step) ". ";
  color: var(--accent);
}

.faq-item h3 { font-size: 1.12rem; }

.noscript {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 0.8rem;
  padding: 0.8rem 1rem;
}

.site-footer {
  padding-bottom: calc(2rem + env(safe-area-inset-bottom));
  display: grid;
  gap: 0.4rem;
}

.footer-nav { gap: 0.15rem 0.4rem; }

.fine { margin: 0.2rem 0 0; font-size: 0.95rem; }

#open-consent {
  justify-self: start;
  border: 2px solid var(--line);
  background: var(--card);
}

.consent {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 60;
  padding: 0.5rem;
  padding-bottom: calc(0.5rem + env(safe-area-inset-bottom));
  pointer-events: none;
}

.consent-panel {
  width: min(100%, var(--max));
  margin: 0 auto;
  max-height: min(22rem, 58vh);
  overflow: auto;
  background: var(--card);
  color: var(--ink);
  border: 2px solid var(--ink);
  border-radius: 1.1rem;
  box-shadow: var(--shadow);
  padding: 0.7rem 0.85rem;
  display: grid;
  gap: 0.45rem;
  pointer-events: auto;
}

.consent-title { margin: 0; font-size: 1.05rem; }
.consent-desc { margin: 0; font-size: 0.95rem; }

.consent-manage { display: grid; gap: 0.55rem; }

.consent-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.7rem;
  align-items: start;
  padding: 0.7rem;
  border: 1px solid var(--line);
  border-radius: 0.8rem;
}

.consent-row input { width: 1.35rem; height: 1.35rem; margin-top: 0.2rem; accent-color: var(--accent); }
.consent-row-text { display: grid; }
.consent-row-label { font-weight: 800; }

.consent-actions { flex-wrap: nowrap; }
.consent-actions .btn-equal,
.dialog-actions .btn-equal { min-height: 3.25rem; }
.consent-actions .btn-equal {
  flex: 1 1 0;
  min-width: 0;
  padding-inline: 0.35rem;
  font-size: 0.95rem;
}

dialog {
  width: min(100% - 1.5rem, 28rem);
  border: 2px solid var(--ink);
  border-radius: 1.1rem;
  background: var(--card);
  color: var(--ink);
  padding: 1rem;
}

dialog::backdrop { background: rgba(20, 18, 16, 0.62); }

dialog h2 { margin: 0 0 0.4rem; font-size: 1.5rem; }
dialog p { margin: 0 0 1rem; }

.dialog-actions .btn-equal { flex: 1; }

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

@media (min-width: 42rem) {
  .setup { padding: 1.25rem 1.35rem 1.4rem; }
  .setup-grid,
  .choice-grid,
  .tip-grid,
  .split { grid-template-columns: 1fr 1fr; }
  .name-fields { grid-template-columns: 1fr 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; animation: none !important; }
}
