:root {
  color-scheme: light;
  --paper: #f6f2ea;
  --panel: #fffcf5;
  --ink: #21182c;
  --quiet: #63596b;
  --purple: #6741a5;
  --lavender: #e7d9fc;
  --lime: #dcfa86;
  --line: #ded6e2;
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

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

body {
  min-width: 0;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background:
    radial-gradient(ellipse at 5% 4%, #eee4fa 0%, transparent 40rem),
    var(--paper);
}

button, input, output { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
button, input { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, summary:focus-visible {
  outline: 3px solid #7652bd;
  outline-offset: 3px;
}

h1, h2, p { margin: 0; }
h1, h2, strong { overflow-wrap: anywhere; }

.site-header {
  width: min(460px, calc(100% - 36px));
  min-height: 65px;
  margin: auto;
  border-bottom: 1px solid #d8cfdf;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  white-space: nowrap;
  font-weight: 900;
  font-size: 17px;
}

.brand-mark {
  background: var(--ink);
  color: var(--lime);
  border-radius: 10px;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  font-size: 21px;
}

nav { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 8px; }

#app {
  width: min(460px, calc(100% - 36px));
  margin: 0 auto;
  padding: 22px 0 32px;
  outline: 0;
}

.landing {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 23px;
}

.hero { min-width: 0; padding-top: 3px; }
.eyebrow { font-size: .86rem; font-weight: 750; color: var(--purple); letter-spacing: .045em; }
.eyebrow span { margin: 0 .25em; }

.hero h1 {
  font-size: clamp(3rem, 12vw, 4.25rem);
  line-height: 1.13;
  letter-spacing: -.085em;
  font-weight: 950;
  margin: 6px 0;
}

.hero h1 span { color: var(--purple); }
.hero-description { color: var(--quiet); font-size: .94rem; line-height: 1.6; }

.hero-art {
  position: relative;
  overflow: hidden;
  aspect-ratio: 2.05;
  margin-top: 13px;
  border: 2px solid var(--ink);
  border-radius: 22px;
  background: radial-gradient(ellipse at center, #4a3269, #1b142b 65%);
  box-shadow: 4px 4px 0 var(--ink);
}

.hero-art img { position: absolute; z-index: 2; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.art-cards { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.art-cards span {
  display: grid;
  place-items: center;
  width: 21%;
  aspect-ratio: 3/4;
  transform: rotate(-15deg) translateX(14%);
  border: 2px solid var(--ink);
  border-radius: 12%;
  background: var(--lavender);
  font-size: clamp(1.5rem, 5vw, 3.6rem);
  font-weight: 900;
}
.art-cards span:nth-child(2) { z-index: 1; background: var(--lime); transform: translateY(-12%); }
.art-cards span:nth-child(3) { transform: rotate(15deg) translateX(-14%); background: #ffb3a9; }

.panel {
  min-width: 0;
  background: var(--panel);
  border: 2px solid var(--ink);
  border-radius: 23px;
  box-shadow: 5px 5px 0 var(--ink);
  padding: clamp(20px, 4vw, 34px);
}

.setup-panel { padding: 20px; }
.setup-panel h2 { font-size: 1.45rem; font-weight: 900; margin-bottom: 19px; }
.count-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 18px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
.count-row label, legend { font-weight: 800; }
.count-row small { display: block; color: var(--quiet); margin-top: 3px; }

.stepper { display: flex; align-items: center; gap: 5px; font-variant-numeric: tabular-nums; }
.stepper button {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--lavender);
  color: var(--ink);
  font-size: 1.25rem;
  font-weight: 800;
}
.stepper button:disabled { background: #f1ede8; color: #72697a; }
.stepper input, .stepper output {
  width: 51px;
  min-width: 0;
  padding: 4px 2px;
  border: 0;
  border-radius: 6px;
  text-align: center;
  background: transparent;
  color: var(--ink);
  font-size: 1.15rem;
  font-weight: 900;
  appearance: textfield;
}
.stepper input::-webkit-inner-spin-button, .stepper input::-webkit-outer-spin-button {
  appearance: none;
  margin: 0;
}

fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
legend { padding: 0; margin-bottom: 10px; }
.name-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.name-input {
  display: block;
  min-width: 0;
  width: 100%;
  padding: 10px 12px;
  min-height: 45px;
  font-size: 1rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f9f6f8;
  color: var(--ink);
}
.name-input::placeholder { color: #756a7e; }
.form-error { color: #a2233a; font-weight: 700; font-size: .88rem; }
.form-error:not(:empty) { margin: 12px 0 0; }

.button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 10px 16px;
  border: 1px solid var(--ink);
  border-radius: 12px;
  color: var(--ink);
  font-weight: 800;
  line-height: 1.25;
  transition: background .14s, transform .14s;
}
.primary {
  width: 100%;
  min-height: 52px;
  margin-top: 22px;
  background: var(--lime);
  box-shadow: 2px 3px 0 var(--ink);
}
.primary:hover:not([disabled]) { background: #e8ffa8; }
.primary:active:not([disabled]) { transform: translateY(2px); }
.primary:disabled { background: #eae5eb; color: #706777; box-shadow: none; border-color: var(--line); }
.start { justify-content: space-between; }
.start span:last-child { font-size: 1.4rem; }
.header-button, .secondary { background: var(--panel); }
.header-button { min-height: 42px; border-color: #d0c4d7; font-size: .875rem; padding-inline: 12px; }
.header-button.restart-button { color: #92283c; }
.secondary { width: 100%; margin-top: 10px; }
.header-button:hover, .secondary:hover { background: var(--lavender); }

.stage { width: min(100%, 560px); margin: 0 auto; }
.stage h1 {
  margin: 8px 0 10px;
  font-size: clamp(1.8rem, 6vw, 2.7rem);
  font-weight: 900;
  line-height: 1.22;
  letter-spacing: -.045em;
}
.lead { line-height: 1.65; color: var(--quiet); }
.center { text-align: center; }

.single-card {
  display: grid;
  place-items: center;
  aspect-ratio: 3/4;
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: linear-gradient(140deg, #412a65, #251733);
  color: var(--lime);
  font-size: 2.1rem;
  box-shadow: 2px 3px 0 var(--ink);
  width: 100px;
  margin: 22px auto 0;
}

.role-card {
  display: grid;
  justify-items: center;
  gap: 10px;
  margin-top: 14px;
  padding: 34px 16px 25px;
  background: var(--lavender);
  border-radius: 17px;
  border: 1px solid var(--ink);
}
.role-card.blank { background: #f1ece5; }
.role-card.judge { background: var(--lime); }
.role-card.killer { background: #ffd5cd; }

.judge-flip { perspective: 760px; margin-top: 14px; }
.judge-flip-card {
  display: grid;
  transform-style: preserve-3d;
  animation: draw-judge-card .68s cubic-bezier(.22, .73, .2, 1) both;
}
.judge-flip-card > div {
  grid-area: 1 / 1;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}
.judge-flip-card .role-card { margin-top: 0; }
.judge-card-back {
  display: grid;
  place-items: center;
  border: 1px solid var(--ink);
  border-radius: 17px;
  background: linear-gradient(140deg, #48316c, #251733);
  color: var(--lime);
  font-size: 4rem;
  transform: rotateY(180deg);
}
.judge-reveal .primary { animation: cover-after-draw .68s step-end both; }
@keyframes draw-judge-card {
  from { transform: translateY(26px) rotateY(180deg) rotate(-6deg) scale(.82); }
  28% { transform: translateY(-8px) rotateY(180deg) rotate(-3deg) scale(.97); }
  to { transform: translateY(0) rotateY(0) rotate(0) scale(1); }
}
@keyframes cover-after-draw {
  from { visibility: hidden; }
  to { visibility: visible; }
}

.avatar {
  position: relative;
  display: inline-grid;
  flex: 0 0 auto;
  place-items: center;
  width: 37px;
  height: 37px;
  border-radius: 50%;
  border: 1px solid #21182c25;
  color: var(--ink);
  font-size: .95rem;
  font-weight: 850;
}
.avatar.color-0 { background: #e2cfef; }
.avatar.color-1 { background: #dcecae; }
.avatar.color-2 { background: #f7cfb6; }
.avatar.color-3 { background: #c9e5e2; }
.avatar.color-4 { background: #f2d3df; }
.avatar-mark {
  position: absolute;
  right: -4px;
  bottom: -4px;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid var(--panel);
  background: var(--ink);
  color: white;
  font-size: .72rem;
}
.avatar-mark.judge { background: #567123; }
.avatar-mark.boss { background: #6741a5; }
.avatar-mark.killer { background: #a83236; }
.role-card .avatar, .center > .avatar { width: 64px; height: 64px; font-size: 1.65rem; }
.role-card .avatar-mark, .center > .avatar .avatar-mark { width: 25px; height: 25px; font-size: .93rem; }

.roster, .vote-list { list-style: none; margin: 16px 0 0; padding: 0; }
.roster li, .vote-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 57px;
  padding: 6px 3px;
  border-bottom: 1px solid var(--line);
}
.roster strong, .vote-list strong { flex: 1; min-width: 0; }
.role-label { color: var(--quiet); font-size: .85rem; font-weight: 750; }
.role-label.boss { color: var(--purple); }
.role-label.killer { color: #a83236; }
.role-label.judge { color: #496226; }
.muted { color: var(--quiet); font-size: .78rem; }

.private-view { background: #1c142c; color: #fffaf0; }
.private-view .site-header { justify-content: flex-end; border-bottom: 0; }
.private-view .brand { display: none; }
.private-view #app {
  width: min(460px, calc(100% - 36px));
  min-height: calc(100vh - 65px);
  min-height: calc(100dvh - 65px);
  display: grid;
  align-content: center;
  padding: 0 0 24px;
}
.private-view .stage:not(.secret) { color: var(--ink); box-shadow: none; }
.private-view .header-button.restart-button {
  border-color: #685478;
  background: #261b36;
  color: #eee4f6;
}
.private-view .header-button.restart-button:hover { background: #392850; }
.secret {
  min-height: min(610px, 85dvh);
  width: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto;
  align-items: center;
  gap: 18px;
  text-align: center;
  border: 1px solid #5b4a69;
  box-shadow: none;
  background: #261b36;
  padding: clamp(17px, 6vw, 42px);
}
.secret .eyebrow { color: var(--lime); }
.secret h1.secret-text {
  color: #fffaf0;
  font-size: clamp(2.85rem, 12vw, 5.6rem);
  font-weight: 950;
  line-height: 1.23;
  letter-spacing: 0;
}
.secret-instruction {
  margin-top: 16px;
  color: #eee4f6;
  font-size: clamp(1.15rem, 5.3vw, 1.65rem);
  line-height: 1.55;
  text-wrap: balance;
}
.button.light { background: var(--lime); min-height: 52px; }

.dance { padding-top: 22px; }
.timer-card { background: #251932; padding: 20px 17px; border-radius: 16px; color: #fffaf0; margin-bottom: 20px; text-align: center; }
.timer-card .eyebrow { color: var(--lavender); }
.timer-card h1.clock {
  color: var(--lime);
  font-family: "Bahnschrift", ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
  font-size: clamp(3.5rem, 15vw, 5.25rem);
  margin: 7px 0 11px;
  letter-spacing: -.085em;
  line-height: 1;
}
.stats { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid #61526c; padding-top: 13px; gap: 12px; color: #eadff5; font-size: .85rem; }
.stats div + div { border-left: 1px solid #61526c; }
.stats strong { display: block; color: #fffaf0; font-size: 1.25rem; margin-top: 2px; }
.round-info {
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #faf6fd;
}
.round-info summary {
  padding: 11px 12px;
  border-radius: 10px;
  color: var(--purple);
  cursor: pointer;
  font-weight: 800;
}
.round-info dl {
  margin: 0 12px 11px;
  padding-top: 9px;
  border-top: 1px solid var(--line);
}
.round-info dl > div {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 10px;
  padding: 5px 0;
}
.round-info dt, .round-info dd p { color: var(--quiet); font-size: .875rem; line-height: 1.5; }
.round-info dd { margin: 0; overflow-wrap: anywhere; }
.round-info dd p { margin-top: 3px; }
.dance h2 { margin-bottom: 3px; font-size: 1.2rem; }
.target-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 13px; }
.target-row {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  min-height: 52px;
  padding: 6px 8px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--ink);
  background: #faf6fd;
}
.target-row:hover { background: var(--lavender); }
.target-row strong { min-width: 0; flex: 1; }
.target-row > span:last-child { color: var(--purple); }
.judge-players .target-row > span:last-child { font-size: .75rem; white-space: nowrap; }
.judge-players .target-row:disabled { background: #f1ede8; color: var(--quiet); }
.judge-players .target-row:disabled > span:last-child { color: var(--quiet); }
.reveal-line {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 9px;
  padding: 7px 10px;
  margin: 10px 0 14px;
  border-radius: 10px;
  background: #ffe8df;
  color: #732d33;
}
.reveal-line .avatar { width: 30px; height: 30px; }

.verdict {
  display: inline-block;
  margin: 14px 0 7px;
  padding: 6px 16px;
  border-radius: 8px;
  background: #fcd1c7;
  color: #7e2d32;
  font-weight: 900;
}
.verdict.hit { background: var(--lime); color: var(--ink); }
.vote-progress { margin-top: 14px; color: var(--purple); }
.vote-list { margin-top: 8px; }
.vote-list .stepper button { width: 41px; height: 41px; }
.vote-list .stepper output { width: 29px; }
.result-mark {
  display: grid;
  place-items: center;
  width: 90px;
  height: 90px;
  margin: 5px auto 20px;
  border: 2px solid var(--ink);
  border-radius: 27px;
  background: var(--lime);
  font-size: 3.4rem;
  transform: rotate(-7deg);
  box-shadow: 3px 4px 0 var(--ink);
}

dialog {
  max-height: min(78vh, 690px);
  width: min(460px, calc(100% - 32px));
  padding: 21px;
  border: 2px solid var(--ink);
  border-radius: 18px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
}
dialog::backdrop { background: #1c142c99; }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 13px; }
.dialog-heading button {
  width: 43px;
  height: 43px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--lavender);
  color: var(--ink);
  font-size: 1.4rem;
}
.rule-list { padding-left: 1.45rem; margin: 0; color: var(--quiet); line-height: 1.65; }
.rule-list li + li { margin-top: 8px; }

@media (max-width: 365px) {
  .site-header { width: calc(100% - 24px); }
  #app { width: calc(100% - 26px); }
  .brand { font-size: .94rem; }
  .header-button { padding-inline: 8px; }
  nav { gap: 5px; }
  .target-row .avatar { width: 30px; height: 30px; }
}

@media (prefers-reduced-motion: reduce) {
  .button { transition: none; }
  .judge-flip-card, .judge-reveal .primary { animation: none; }
}
