:root {
  color-scheme: light;
  --bg: #f4f7f5;
  --surface: #ffffff;
  --surface-strong: #eef3f0;
  --ink: #171918;
  --muted: #5b6560;
  --line: #d8e1dc;
  --accent: #b13d4a;
  --accent-dark: #792334;
  --accent-soft: #f7dfe3;
  --focus: #197c70;
  --shadow: 0 18px 45px rgb(31 43 37 / 12%);
}

* {
  box-sizing: border-box;
}

body {
  position: relative;
  min-height: 100vh;
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #071326;
  color: var(--ink);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.92;
  background:
    linear-gradient(180deg, rgb(7 19 38 / 4%) 0%, rgb(7 19 38 / 18%) 64%, rgb(7 19 38 / 34%) 100%),
    url("assets/night-village-background.png") center top / cover no-repeat;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 24%, rgb(255 255 255 / 8%) 0 16%, transparent 38%),
    linear-gradient(180deg, rgb(7 19 38 / 6%) 0%, transparent 42%, rgb(7 19 38 / 22%) 100%);
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 48px;
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

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

.app-shell {
  position: relative;
  z-index: 1;
  width: min(100%, 560px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 2px;
}

.top-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: 190px;
  flex: 0 0 190px;
  align-items: end;
}

.language-control {
  display: grid;
  min-width: 0;
}

.language-control label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.language-control select {
  width: 100%;
  min-height: 46px;
  border: 1px solid rgb(255 255 255 / 58%);
  border-radius: 8px;
  background: rgb(255 255 255 / 92%);
  color: var(--ink);
  padding: 10px 11px;
  font-weight: 800;
  box-shadow: 0 10px 24px rgb(0 0 0 / 16%);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 2.15rem;
  line-height: 1.02;
  letter-spacing: 0;
}

.brand-title {
  display: inline-block;
  max-width: 100%;
  color: #fff1f4;
  font-family: "Kunstler Script", "Apple Chancery", "Snell Roundhand", "Brush Script MT", cursive;
  font-size: 2.95rem;
  font-weight: 400;
  overflow-wrap: anywhere;
  text-shadow:
    0 2px 0 rgb(86 22 42 / 55%),
    0 10px 24px rgb(0 0 0 / 34%);
}

h2 {
  font-size: 1.45rem;
  line-height: 1.15;
  letter-spacing: 0;
}

.eyebrow {
  margin-bottom: 7px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.panel {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 20px;
}

.ad-slot {
  display: grid;
  gap: 6px;
  margin-top: 18px;
  border: 1px dashed rgb(121 35 52 / 36%);
  border-radius: 8px;
  background: linear-gradient(180deg, rgb(255 248 242 / 88%) 0%, rgb(247 223 227 / 72%) 100%);
  color: var(--muted);
  padding: 14px;
  text-align: center;
}

.ad-slot .eyebrow {
  margin-bottom: 0;
}

.ad-slot p:not(.eyebrow) {
  font-size: 0.9rem;
  line-height: 1.4;
}

.victory-ad {
  margin-top: 12px;
  background: rgb(255 255 255 / 62%);
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px 14px;
  padding: 6px 4px 14px;
  color: #f8d5dc;
  font-size: 0.82rem;
  font-weight: 800;
  text-align: center;
  text-shadow: 0 2px 10px rgb(0 0 0 / 35%);
}

.site-footer a {
  color: #fff8f2;
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
}

.legal-body {
  min-height: 100vh;
}

.legal-shell {
  position: relative;
  z-index: 1;
  width: min(100%, 680px);
  margin: 0 auto;
  padding: 28px 18px;
}

.legal-header {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.back-link {
  justify-self: start;
  border: 1px solid rgb(255 255 255 / 58%);
  border-radius: 8px;
  background: rgb(255 255 255 / 92%);
  color: var(--ink);
  padding: 10px 13px;
  font-weight: 900;
  text-decoration: none;
  box-shadow: 0 10px 24px rgb(0 0 0 / 16%);
}

.legal-card {
  display: grid;
  gap: 16px;
}

.legal-card section {
  display: grid;
  gap: 7px;
}

.legal-card h3 {
  margin: 0;
  font-size: 1.02rem;
  line-height: 1.2;
}

.legal-card p {
  color: var(--muted);
  line-height: 1.5;
}

.section-heading {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.section-heading p,
.handoff p,
.done p,
.role-note {
  color: var(--muted);
  line-height: 1.45;
}

.players-form {
  display: grid;
  gap: 16px;
}

.count-control {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 12px;
}

.count-control label {
  color: var(--ink);
  font-weight: 800;
}

.count-control select {
  min-width: 92px;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
}

.role-preview {
  display: grid;
  gap: 4px;
  border-left: 4px solid var(--accent);
  background: var(--surface-strong);
  padding: 12px 14px;
}

.role-preview .eyebrow {
  margin-bottom: 0;
}

.role-preview p:last-child {
  color: var(--muted);
  line-height: 1.4;
}

.players-grid {
  display: grid;
  gap: 10px;
}

.player-field {
  display: grid;
  gap: 6px;
}

.player-field label {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.player-field input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 12px 13px;
}

.player-field input::placeholder {
  color: #9b9386;
}

.primary-button,
.secondary-button,
.small-button {
  border-radius: 8px;
  font-weight: 800;
  letter-spacing: 0;
}

.primary-button {
  width: 100%;
  background: var(--accent);
  color: #fff;
  padding: 13px 16px;
}

.primary-button:active {
  background: var(--accent-dark);
}

.secondary-button {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface-strong);
  color: var(--ink);
  padding: 13px 16px;
}

.small-button {
  width: 100%;
  min-width: 0;
  min-height: 46px;
  background: rgb(255 255 255 / 92%);
  border: 1px solid rgb(255 255 255 / 58%);
  color: var(--ink);
  padding: 10px 13px;
  box-shadow: 0 10px 24px rgb(0 0 0 / 16%);
}

#rulesButton {
  grid-column: 1 / -1;
  background: rgb(255 248 242 / 96%);
  border-color: rgb(255 255 255 / 70%);
}

#resetButton {
  background: rgb(247 223 227 / 94%);
  border-color: rgb(247 223 227 / 72%);
  color: var(--accent-dark);
}

.handoff,
.done,
.reveal {
  min-height: calc(100vh - 132px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
}

.handoff h2,
.done h2,
.reveal h2 {
  font-size: 2.45rem;
  line-height: 0.96;
}

.role-box {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--accent-soft);
  padding: 18px;
}

.role-box p {
  color: var(--accent-dark);
  font-weight: 800;
}

.role-box strong {
  font-size: 2.45rem;
  line-height: 0.95;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.button-row {
  display: grid;
  gap: 10px;
}

.narrator {
  display: grid;
  gap: 14px;
}

.narrator.hidden {
  display: none;
}

.narrator-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
}

.narrator-header p {
  color: var(--muted);
  line-height: 1.45;
}

.status-pill {
  min-width: 82px;
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--ink);
  padding: 8px 11px;
  font-size: 0.82rem;
  font-weight: 900;
  text-align: center;
}

.status-pill.is-finished {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.score-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.score-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 11px;
}

.score-item span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.score-item strong {
  display: block;
  margin-top: 4px;
  font-size: 1.55rem;
  line-height: 1;
}

.narrator-card {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}

.hunter-card {
  border-color: #d8c7a4;
  background: #fffdf8;
}

.night-result-card {
  border-color: var(--accent);
  background: #fff7f8;
}

.night-result-card .eyebrow {
  margin-bottom: 0;
}

.night-result-card p {
  color: var(--ink);
  font-weight: 800;
  line-height: 1.4;
}

.night-result-card ul {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 19px;
  color: var(--muted);
  line-height: 1.4;
}

.narrator-card h3 {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.15;
}

.helper-text {
  color: var(--muted);
  line-height: 1.45;
}

.narrator-fields {
  display: grid;
  gap: 8px;
}

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

.narrator-fields label,
.vote-row label {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.narrator-fields select,
.vote-row select {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
}

.vote-list,
.alive-list,
.turn-log {
  display: grid;
  gap: 8px;
}

.vote-row {
  display: grid;
  gap: 6px;
}

.vote-summary {
  min-height: 42px;
  border-left: 4px solid var(--focus);
  background: var(--surface-strong);
  color: var(--ink);
  padding: 10px 12px;
  line-height: 1.4;
}

.player-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px;
}

.player-status div {
  display: grid;
  gap: 3px;
}

.player-status span,
.player-status em {
  color: var(--muted);
  font-size: 0.86rem;
  font-style: normal;
}

.player-status.is-out {
  border-color: #5f1728;
  background: #7a2133;
  color: #fff7f8;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 10%);
}

.player-status.is-out strong {
  color: #fff;
  text-decoration: line-through;
}

.player-status.is-out span,
.player-status.is-out em {
  color: #f8d5dc;
}

.log-entry {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 11px;
}

.log-entry .eyebrow {
  margin-bottom: 0;
}

.log-entry p:not(.eyebrow),
.log-entry li {
  color: var(--muted);
  line-height: 1.42;
}

.log-entry ul {
  display: grid;
  gap: 4px;
  margin: 0;
  padding-left: 19px;
}

.victory-screen {
  display: grid;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  min-height: 360px;
  align-content: center;
  text-align: center;
}

.victory-screen h2 {
  font-size: 3.2rem;
  line-height: 0.95;
}

.victory-screen p:not(.eyebrow) {
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.45;
}

.victory-screen.wolf-victory {
  border-color: #6f1d2f;
  background: linear-gradient(180deg, #fff8f8 0%, #f7dfe3 100%);
}

.victory-screen.village-victory {
  border-color: #0f4f3f;
  background: linear-gradient(180deg, #e7f3ec 0%, #8bbda4 100%);
}

.victory-screen.village-victory h2 {
  color: #0f3f33;
}

.victory-screen.village-victory .eyebrow,
.victory-screen.village-victory p:not(.eyebrow) {
  color: #174f40;
}

.victory-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.victory-stat {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgb(255 255 255 / 72%);
  padding: 12px;
}

.victory-stat span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.victory-stat strong {
  display: block;
  margin-top: 4px;
  font-size: 1.55rem;
  line-height: 1;
}

.error {
  min-height: 22px;
  color: #9d1f2f;
  font-weight: 800;
  line-height: 1.35;
}

.rules-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgb(23 25 24 / 56%);
  padding: 16px;
}

.rules-card {
  width: min(100%, 560px);
  max-height: calc(100vh - 32px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 18px;
}

.rules-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.rules-content {
  display: grid;
  gap: 18px;
}

.rules-content h3 {
  margin: 0 0 10px;
  font-size: 1rem;
  line-height: 1.2;
}

.rules-content ol,
.rules-content ul {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 22px;
  color: var(--muted);
  line-height: 1.45;
}

.role-rules strong {
  color: var(--ink);
}

.hidden {
  display: none;
}

@media (min-width: 560px) {
  .app-shell {
    padding: 28px 20px;
  }

  h1 {
    font-size: 3.25rem;
  }

  .handoff h2,
  .done h2,
  .reveal h2,
  .role-box strong {
    font-size: 3.55rem;
  }

  .players-grid {
    grid-template-columns: 1fr 1fr;
  }

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

  .button-row {
    grid-template-columns: 1fr 1fr;
  }

  .top-actions {
    width: 214px;
    flex-basis: 214px;
  }

  .score-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .victory-stats {
    grid-template-columns: repeat(4, 1fr);
  }

  .vote-row {
    grid-template-columns: minmax(100px, 0.8fr) 1.2fr;
    align-items: center;
  }
}

@media (max-width: 430px) {
  .topbar {
    flex-direction: column;
  }

  .top-actions {
    width: 100%;
    flex-basis: auto;
  }
}
