@font-face {
  font-family: Manrope;
  src: url("fonts/manrope.woff2") format("woff2");
  font-weight: 400 800;
  font-display: swap;
}

@font-face {
  font-family: Fraunces;
  src: url("fonts/fraunces.woff2") format("woff2");
  font-weight: 600;
  font-display: swap;
}

@font-face {
  font-family: Fraunces;
  src: url("fonts/fraunces-italic.woff2") format("woff2");
  font-weight: 500;
  font-style: italic;
  font-display: swap;
}

:root {
  color-scheme: light;
  --paper: #f7f5f1;
  --surface: #fffdfa;
  --ink: #251d28;
  --muted: #655d63;
  --line: #e6dfd9;
  --plum: #392841;
  --plum-dark: #2a1d32;
  --gold: #f1c487;
  --focus: #80538d;
  --heading: Fraunces, Georgia, serif;
  --body: Manrope, system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1rem/1.55 var(--body);
}

button, input { font: inherit; }
a { color: inherit; text-decoration: none; }
svg { flex: none; vertical-align: middle; }
p, h1, h2, h3 { margin: 0; }
h1, h2 { font: 600 2.25rem/1.08 var(--heading); letter-spacing: -.025em; }
button { cursor: pointer; }
button:disabled { opacity: .5; cursor: default; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

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

.shell { width: min(100% - 2rem, 70rem); margin-inline: auto; }

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  display: flex;
  min-height: 4.125rem;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: .65rem;
  font: 600 1.42rem/1 var(--heading);
  letter-spacing: -.03em;
}

.brand-mark {
  width: 2.2rem;
  height: 2.2rem;
  display: grid;
  place-items: center;
  color: var(--gold);
  background: #271e30;
  border-radius: 9px;
}

.quiet-button, .secondary-button, .primary-button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: .5rem;
  min-height: 2.75rem;
  border-radius: 9px;
  padding: .6rem .85rem;
  font-weight: 750;
  letter-spacing: -.01em;
}

.quiet-button, .secondary-button {
  border: 1px solid var(--line);
  color: var(--plum);
  background: var(--surface);
  font-size: .875rem;
}

@media (hover: hover) {
  .quiet-button:hover, .secondary-button:not(:disabled):hover { background: #f3edf1; }
  .primary-button:hover { background: #503959; }
}

.primary-button {
  min-height: 3.25rem;
  border: 1px solid transparent;
  background: var(--plum);
  color: #fff9f4;
  padding-inline: 1.1rem;
}

.setup { padding-block: 1.1rem 2.5rem; }

.hero {
  isolation: isolate;
  display: flex;
  align-items: center;
  position: relative;
  min-height: 20.5rem;
  overflow: hidden;
  border-radius: 18px;
  background: #201828 url("waldnacht.webp") 72% center / cover no-repeat;
  color: #fff8f0;
}

.hero::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0;
  background: linear-gradient(0deg, #1e1628 0%, #1e1628e8 30%, #1e16286b 78%, #1e162833 100%);
}

.hero-copy { padding: 4.45rem 1.35rem 1.55rem; }
.hero h1 { font-size: clamp(2.1rem, 9.1vw, 4.65rem); line-height: 1.02; }
.hero h1 em { color: var(--gold); font-weight: 500; }
.hero p { max-width: 24rem; margin-block: 1rem 1.25rem; color: #e8dce4; }
.hero-details { padding: 0; margin: 0; list-style: none; display: flex; flex-wrap: wrap; gap: .65rem 1.2rem; }
.hero-details li { display: flex; align-items: center; gap: .4rem; color: #f9eadb; font-size: .875rem; font-weight: 700; }
.hero-details svg { color: var(--gold); }

.setup-content { margin-top: 1.8rem; }
.section-intro { margin-bottom: 1.15rem; }
.section-intro p { color: var(--muted); margin-top: .4rem; }
.setup-grid, .setup-side { display: grid; gap: 1rem; align-content: start; }
.panel { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.player-panel, .role-panel { padding: 1.1rem; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.panel-heading h3 { display: flex; align-items: center; gap: .55rem; font-size: 1.13rem; letter-spacing: -.025em; }
.panel-heading svg { color: #75546f; }
.panel-note { color: var(--muted); font-size: .875rem; margin-top: .25rem; }

.count, .role-count {
  flex: none;
  border-radius: 6px;
  background: #f1ebf0;
  color: #5b405c;
  font-size: .8125rem;
  font-weight: 800;
  white-space: nowrap;
}

.count { padding: .25rem .5rem; }
.role-count { min-width: 2rem; padding: .22rem .25rem; text-align: center; }

.name-list { display: grid; gap: .55rem; margin-block: 1rem .9rem; }
.name-row { position: relative; min-width: 0; }
.name-field { display: flex; align-items: center; gap: .55rem; }
.name-index {
  position: absolute;
  top: 50%;
  left: .75rem;
  transform: translateY(-50%);
  color: #746575;
  font-size: .81rem;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

.name-field input {
  width: 100%;
  min-width: 0;
  min-height: 3rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fcfaf7;
  padding: .55rem 2.55rem .55rem 2.45rem;
  font-size: 1rem;
}

.name-field input::placeholder { color: #766b72; opacity: 1; }
.remove-player {
  display: grid;
  place-items: center;
  position: absolute;
  top: 50%;
  right: 1px;
  transform: translateY(-50%);
  min-width: 2.5rem;
  min-height: 2.75rem;
  border: 0;
  border-radius: 7px;
  color: #746575;
  background: transparent;
}
.remove-player:hover { color: #913f53; }

.role-list { margin-top: .65rem; }
.role-row { display: flex; min-height: 3.6rem; align-items: center; gap: .66rem; padding-block: .42rem; }
.role-row + .role-row { border-top: 1px solid #eee8e3; }
.role-icon, .turn-icon { display: grid; place-items: center; flex: none; border-radius: 8px; background: #eee7f1; color: #65496b; }
.role-icon { width: 2.2rem; height: 2.2rem; }
.wolf { background: #f3e4e8; color: #84475d; }
.villager { background: #f4eadb; color: #785b31; }
.seer { background: #ece5f2; color: #674882; }
.guard { background: #e4ede6; color: #365f48; }
.role-text { display: grid; flex: 1; gap: .04rem; min-width: 0; }
.role-name { font-size: .93rem; font-weight: 800; }
label.role-name { cursor: pointer; }
.role-summary { color: var(--muted); font-size: .825rem; line-height: 1.35; }

.role-switch {
  appearance: none;
  position: relative;
  flex: none;
  width: 2.55rem;
  height: 2.75rem;
  margin: 0;
  border: 0;
  border-radius: 5px;
  cursor: pointer;
}

.role-switch::before, .role-switch::after { position: absolute; content: ""; top: 50%; transform: translateY(-50%); }
.role-switch::before { inset-inline: 0; height: 1.38rem; border-radius: 2rem; background: #a79aa9; }
.role-switch::after { left: .2rem; width: .98rem; height: .98rem; border-radius: 50%; background: white; }
.role-switch:checked::before { background: #654d70; }
.role-switch:checked::after { left: auto; right: .2rem; }

.start-button { width: 100%; }
.setup-hint { display: flex; align-items: center; justify-content: center; gap: .4rem; margin-top: -.45rem; color: var(--muted); font-size: .8125rem; }
.form-error { grid-column: 1 / -1; border: 1px solid #e0acb2; border-radius: 8px; padding: .65rem .85rem; background: #fbe9ec; color: #882d42; }

.game-shell, .reading-shell { max-width: 42rem; padding-block: 1.3rem 2.75rem; }
.game-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .8rem;
  min-height: 4.35rem;
  color: #fff1e2;
  background: linear-gradient(90deg, #211729 10%, #21172988 100%), url("waldnacht.webp") right 34% / cover;
  border-radius: 12px 12px 0 0;
  padding: .9rem 1.15rem;
  font-size: .88rem;
  font-weight: 800;
}

.game-banner span { display: flex; align-items: center; gap: .5rem; }
.game-banner svg { color: var(--gold); }

.turn-panel { border-radius: 0 0 14px 14px; padding: 1.4rem 1.15rem; text-align: center; }
.turn-panel h1 { overflow-wrap: anywhere; }
.turn-panel > p { max-width: 29rem; margin: .65rem auto 0; color: var(--muted); overflow-wrap: anywhere; }
.turn-panel .form-error { margin: 0 auto 1.25rem; color: #882d42; }
.turn-icon { width: 3.5rem; height: 3.5rem; margin: 0 auto 1rem; border-radius: 13px; }
.turn-icon.daytime { background: #f8edda; color: #7e5b32; }
.turn-panel .private-caption { margin: 0 auto .42rem; font-size: .875rem; font-weight: 800; color: #694e6d; }
.turn-panel .private-result { padding: .75rem; background: #f2ebf1; border-radius: 8px; color: var(--plum-dark); }
.turn-form { margin: 1.3rem auto 0; width: min(100%, 29rem); }
.turn-form .primary-button { width: 100%; }

.choices { display: grid; gap: .5rem; margin: 0 0 1rem; padding: 0; border: 0; min-width: 0; text-align: left; }
.choice { display: flex; align-items: center; min-height: 2.9rem; gap: .65rem; padding: .5rem .7rem; border: 1px solid var(--line); border-radius: 8px; background: #fcfaf7; cursor: pointer; overflow-wrap: anywhere; }
.choice:has(:checked) { border-color: #775980; background: #f3edf5; }
.choice input { margin: 0; width: 1.05rem; height: 1.05rem; flex: none; accent-color: var(--plum); }

.candidate-list, .results { width: min(100%, 29rem); list-style: none; padding: 0; margin: 1rem auto 0; }
.candidate-list { display: flex; flex-wrap: wrap; justify-content: center; gap: .4rem; }
.candidate-list li { max-width: 100%; overflow-wrap: anywhere; border-radius: 6px; background: #f1ebf0; padding: .25rem .6rem; }
.results li { display: flex; align-items: center; justify-content: space-between; gap: .55rem; text-align: left; padding: .45rem .6rem; border-bottom: 1px solid var(--line); }
.results strong { min-width: 0; overflow-wrap: anywhere; }
.results span { color: var(--muted); font-size: .875rem; text-align: right; }
.reset { margin-top: 1.1rem; text-align: center; font-size: .875rem; color: var(--muted); }
.reset summary { width: fit-content; margin-inline: auto; cursor: pointer; padding: .5rem; }
.reset form p { margin: .3rem 0 .55rem; }

.reading-shell h1 { margin-bottom: .5rem; }
.reading-lead { color: var(--muted); margin-bottom: 1.2rem; }
.reading-panel { margin-bottom: 1rem; padding: 1.15rem; }
.reading-panel h2 { font-size: 1.6rem; margin-bottom: .55rem; }
.reading-panel p, .rule-steps { color: var(--muted); }
.reading-panel p + h2 { margin-top: 1.3rem; }
.rule-steps { padding-left: 1.35rem; margin: 0; }
.rule-steps li + li { margin-top: .65rem; }
.rule-role { display: flex; gap: .75rem; align-items: flex-start; padding-block: .8rem; }
.rule-role + .rule-role { border-top: 1px solid var(--line); }
.rule-role h3 { font-size: 1rem; }
.team { font-size: .8rem; color: #6d5070; margin-left: .3rem; }

@media (min-width: 35rem) {
  .shell { width: min(100% - 3rem, 70rem); }
  .hero { background-position: center 20%; }
  .hero::before { background: linear-gradient(90deg, #16102078, #16102035 52%, transparent 78%); }
  .hero-copy { padding: 2rem 2.45rem; }
  .hero h1 { font-size: clamp(2.9rem, 7.2vw, 4.65rem); }
  .name-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .turn-panel, .reading-panel { padding: 1.85rem; }
}

@media (min-width: 54rem) {
  .setup { padding-top: 1.55rem; }
  .hero { min-height: 21.2rem; border-radius: 20px; }
  .hero-copy { padding-left: 3rem; }
  .setup-content { margin-top: 2rem; }
  .setup-grid { grid-template-columns: minmax(0, 1.18fr) minmax(0, 1fr); gap: 1.15rem; align-items: start; }
  .player-panel, .role-panel { padding: 1.25rem; }
  .game-shell, .reading-shell { padding-top: 2rem; }
}
