:root {
  color-scheme: light;
  --bg: #f8f1df;
  --bg-soft: #fffaf0;
  --surface: #fffdf8;
  --surface-strong: #ffffff;
  --text: #253633;
  --text-soft: #66736f;
  --muted: var(--text-soft);
  --line: #d9dfd6;
  --teal: #167d77;
  --teal-deep: #0d625e;
  --teal-soft: #dcefeb;
  --accent: var(--teal);
  --on-accent: #fffaf0;
  --coral: #ed755f;
  --coral-deep: #c94f3c;
  --coral-soft: #ffe3db;
  --night: #243352;
  --danger: #b63838;
  --shadow: 0 16px 45px rgba(48, 62, 56, 0.12);
  --shadow-small: 0 7px 18px rgba(48, 62, 56, 0.1);
  --radius-xl: 30px;
  --radius-lg: 22px;
  --radius-md: 15px;
  --focus: 0 0 0 4px rgba(237, 117, 95, 0.28);
  font-family: "Yu Gothic UI", "Hiragino Kaku Gothic ProN", Meiryo, system-ui, sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #11182b;
  --bg-soft: #18223a;
  --surface: #202c47;
  --surface-strong: #273553;
  --text: #f4f0df;
  --text-soft: #bec8d7;
  --line: #44516b;
  --teal: #5bc4b8;
  --teal-deep: #82d9cf;
  --teal-soft: #263e4a;
  --on-accent: #11182b;
  --coral: #ff947f;
  --coral-deep: #ffad9d;
  --coral-soft: #4b3040;
  --night: #b7c9f7;
  --danger: #ffaaa2;
  --shadow: 0 18px 52px rgba(0, 0, 0, 0.32);
  --shadow-small: 0 8px 22px rgba(0, 0, 0, 0.25);
  --focus: 0 0 0 4px rgba(255, 148, 127, 0.28);
}

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

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-width: 300px;
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  line-height: 1.7;
  transition: color 180ms ease, background-color 180ms ease;
}

:root[data-theme="dark"] body {
  background:
    radial-gradient(circle at 88% 9%, rgb(255 251 220 / 20%) 0 4.3rem, transparent 6.5rem),
    radial-gradient(circle at 88% 9%, #fffbdc 0 2.75rem, #f6d66f 2.8rem 3.25rem, transparent 3.32rem),
    radial-gradient(circle at 73% 15%, rgb(255 255 255 / 65%) 0 1px, transparent 1.5px),
    radial-gradient(circle at 88% 34%, rgb(255 255 255 / 45%) 0 1px, transparent 1.5px),
    radial-gradient(circle at 42% 24%, rgb(255 255 255 / 42%) 0 1px, transparent 1.5px),
    radial-gradient(circle at 20% 42%, rgb(255 255 255 / 35%) 0 1px, transparent 1.5px),
    linear-gradient(165deg, #0b1328 0%, #111d3b 47%, #182a46 72%, #203a4b 100%);
}

:root[data-theme="light"] body {
  background:
    radial-gradient(circle at 88% 9%, rgb(255 249 205 / 88%) 0 2.7rem, rgb(255 187 55 / 28%) 2.8rem 5.8rem, transparent 8rem),
    radial-gradient(ellipse at 14% 112%, #a9cd83 0 43%, transparent 43.3%),
    radial-gradient(ellipse at 78% 116%, #bddb94 0 48%, transparent 48.3%),
    linear-gradient(to bottom, #8dccf0 0%, #bce3f5 40%, #e3f3ee 56%, #dcecc5 56.2%, #c7dfa2 100%);
}

:root[data-theme] body {
  background-attachment: fixed;
  background-repeat: no-repeat;
}

button,
input,
select {
  font: inherit;
}

button,
select,
input[type="checkbox"] {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

[hidden] {
  display: none !important;
}

.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;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 8px;
  left: 8px;
  padding: 10px 16px;
  border-radius: 10px;
  color: #fff;
  background: var(--teal-deep);
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: translateY(0);
}

.app-header {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(1400px, 100%);
  min-height: 72px;
  margin: 0 auto;
  padding: 12px 18px;
}

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

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 50% 50% 45% 55%;
  color: #fff;
  background: var(--teal);
  box-shadow: var(--shadow-small);
  transform: rotate(-5deg);
}

.header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.icon-button {
  display: inline-grid;
  width: 46px;
  height: 46px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--text);
  background: var(--surface);
  font-size: 1.35rem;
}

.app-shell {
  width: min(1360px, calc(100% - 28px));
  margin: 0 auto;
  padding: 18px 0 72px;
}

.mode-screen {
  width: min(1060px, 100%);
  margin: 0 auto;
  padding: clamp(1rem, 3vh, 2.5rem) 0;
}

.mode-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(150px, 28%);
  align-items: center;
  gap: 1rem;
  max-width: 900px;
  margin: 0 auto clamp(1.2rem, 3vh, 2rem);
}

.mode-hero h1 {
  margin: 0.25rem 0 0.75rem;
  font-size: clamp(2.5rem, 7vw, 5.5rem);
  line-height: 1.04;
}

.mode-character {
  display: block;
  width: min(100%, 260px);
  max-height: 32vh;
  object-fit: contain;
  justify-self: center;
}

.mode-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  max-width: 900px;
  margin: 0 auto;
}

.site-information {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(220px, 0.8fr);
  gap: 1rem;
  max-width: 900px;
  margin: clamp(1.2rem, 3vh, 2rem) auto 0;
}

.page-about {
  padding: 1.15rem 1.3rem;
}

.page-about h2 {
  margin: 0 0 0.55rem;
  font-size: 1rem;
}

.page-about p {
  margin: 0.35rem 0;
  color: var(--text-soft);
  font-size: 0.78rem;
  line-height: 1.65;
}

.policy-links {
  display: grid;
  align-content: center;
  gap: 0.55rem;
}

.policy-links a,
.online-policy-links a {
  display: grid;
  min-height: 42px;
  padding: 0.55rem 0.75rem;
  place-items: center;
  color: var(--text);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.35;
  text-align: center;
  text-decoration: none;
}

.policy-links a:hover,
.online-policy-links a:hover {
  color: var(--accent);
  border-color: var(--accent);
  text-decoration: underline;
}

.mode-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.9rem;
  width: 100%;
  min-height: 112px;
  padding: 1.1rem 1.25rem;
  color: var(--text);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid var(--line);
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.mode-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 14px 35px rgb(0 0 0 / 14%);
}

.mode-card-primary {
  border-color: var(--accent);
}

.mode-card-debug {
  grid-column: 1 / -1;
  min-height: 86px;
  border-style: dashed;
}

.mode-icon {
  display: grid;
  place-items: center;
  width: 2.8rem;
  height: 2.8rem;
  color: var(--bg);
  font-size: 1.45rem;
  font-weight: 900;
  background: var(--accent);
  border-radius: 50%;
}

.mode-card strong,
.mode-card small {
  display: block;
}

.mode-card strong {
  margin-bottom: 0.25rem;
  font-size: clamp(1.15rem, 2vw, 1.45rem);
}

.mode-card small {
  color: var(--muted);
  line-height: 1.5;
}

.mode-arrow {
  color: var(--accent);
  font-size: 1.5rem;
  font-weight: 900;
}

.screen {
  animation: screen-in 260ms ease both;
}

.screen-setup {
  display: grid;
  gap: 28px;
  align-items: start;
}

.settings-layout {
  display: grid;
  gap: 28px;
  min-width: 0;
}

.hero-copy {
  padding: 26px 6px 0;
}

.hero-copy h1,
.centered-screen h1 {
  margin: 8px 0 14px;
  font-size: clamp(2rem, 9vw, 4.5rem);
  line-height: 1.18;
  letter-spacing: -0.04em;
}

.hero-copy h1 {
  font-size: clamp(1.55rem, 7.4vw, 3.3rem);
}

.hero-copy h1 .hero-line {
  display: block;
  white-space: nowrap;
}

.hero-copy h1 .hero-line-accent {
  color: var(--teal);
}

.hero-copy > p:not(.eyebrow),
.focus-panel > p,
.topic-hint,
.timer-panel > p,
.reverse-panel > p,
.result-panel > p,
.result-overview > p {
  color: var(--text-soft);
}

.hero-character {
  display: block;
  width: min(310px, 86%);
  height: auto;
  margin: 20px auto -8px;
  object-fit: contain;
  filter: drop-shadow(0 15px 22px rgba(48, 62, 56, 0.14));
}

:root[data-theme="dark"] .hero-character,
:root[data-theme="dark"] .result-character {
  filter: drop-shadow(0 17px 26px rgba(0, 0, 0, 0.34));
}

.eyebrow,
.step-label,
.progress-label {
  margin: 0;
  color: var(--teal-deep);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.panel {
  border: 1px solid color-mix(in srgb, var(--line) 75%, transparent);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.settings-panel {
  padding: 24px 18px;
}

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

.section-heading h2,
.help-dialog h2 {
  margin: 0;
  font-size: 1.45rem;
}

.count-badge,
.phase-badge {
  display: inline-flex;
  min-height: 32px;
  padding: 4px 13px;
  align-items: center;
  justify-content: center;
  border-radius: 99px;
  color: var(--teal-deep);
  background: var(--teal-soft);
  font-size: 0.82rem;
  font-weight: 800;
}

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

.player-row {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 4px;
  border: 1px solid transparent;
  border-radius: 15px;
  transition: border-color 130ms ease, background-color 130ms ease, box-shadow 130ms ease;
}

.player-row.is-dragging {
  z-index: 2;
  border-color: var(--teal);
  background: var(--teal-soft);
  box-shadow: var(--shadow-small);
}

.player-reorder-help {
  margin-top: -5px;
}

.drag-handle {
  display: grid;
  width: 46px;
  min-height: 48px;
  padding: 3px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--teal-deep);
  background: var(--teal-soft);
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.drag-handle:active {
  cursor: grabbing;
}

.drag-grip {
  margin-bottom: -3px;
  color: var(--text-soft);
  font-size: 0.8rem;
  line-height: 1;
}

.player-number {
  display: grid;
  min-width: 26px;
  min-height: 26px;
  place-items: center;
  border-radius: 50%;
  color: inherit;
  font-size: 0.82rem;
  font-weight: 800;
}

.player-name {
  width: 100%;
  min-height: 48px;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: 13px;
  color: var(--text);
  background: var(--surface-strong);
}

.row-actions {
  display: flex;
  gap: 4px;
}

.mini-button {
  min-width: 38px;
  min-height: 44px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--text-soft);
  background: var(--surface-strong);
  font-weight: 800;
}

.mini-button:disabled {
  cursor: not-allowed;
  opacity: 0.35;
}

.button {
  min-height: 46px;
  padding: 10px 17px;
  border: 1px solid transparent;
  border-radius: 14px;
  font-weight: 800;
  transition: transform 130ms ease, box-shadow 130ms ease, background-color 130ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button:active:not(:disabled) {
  transform: translateY(1px);
}

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

.button-primary {
  color: #fff;
  background: var(--teal);
  box-shadow: 0 7px 0 var(--teal-deep);
}

.button-accent {
  color: #fff;
  background: var(--coral);
  box-shadow: 0 7px 0 var(--coral-deep);
}

.button-secondary {
  border-color: var(--line);
  color: var(--text);
  background: var(--surface-strong);
}

.button-quiet {
  color: var(--text);
  background: transparent;
}

.button-text {
  color: var(--text-soft);
  background: transparent;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.button-dashed {
  width: 100%;
  margin-top: 12px;
  border: 1.5px dashed var(--teal);
  color: var(--teal-deep);
  background: transparent;
}

.button-large {
  width: 100%;
  min-height: 56px;
  padding: 13px 22px;
  font-size: 1rem;
}

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

.field-group {
  padding: 0;
  margin: 0 0 22px;
  border: 0;
}

.field-group legend,
.field-label {
  font-weight: 800;
}

.field-help {
  margin: 2px 0 12px;
  color: var(--text-soft);
  font-size: 0.86rem;
}

.chip-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.chip-option {
  position: relative;
}

.chip-option input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.chip-option span {
  display: flex;
  min-height: 48px;
  padding: 9px 12px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 13px;
  color: var(--text-soft);
  background: var(--surface-strong);
  font-size: 0.88rem;
  font-weight: 700;
  text-align: center;
}

.chip-option input:checked + span {
  border-color: var(--teal);
  color: var(--teal-deep);
  background: var(--teal-soft);
}

.chip-option input:focus-visible + span {
  box-shadow: var(--focus);
}

.settings-grid {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.field-card {
  display: grid;
  gap: 6px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-strong);
}

.select-wrap select {
  width: 100%;
  min-height: 46px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--text);
  background: var(--surface);
}

.switch-card {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-strong);
}

.switch-card strong,
.switch-card small {
  display: block;
}

.switch-card small {
  margin-top: 3px;
  color: var(--text-soft);
  line-height: 1.5;
}

.switch-control {
  position: relative;
  flex: 0 0 auto;
}

.switch-control input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.switch-visual {
  display: block;
  width: 54px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: var(--line);
}

.switch-visual::after {
  display: block;
  width: 24px;
  height: 24px;
  margin: 2px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  content: "";
  transition: transform 150ms ease;
}

.switch-control input:checked + .switch-visual {
  border-color: var(--teal);
  background: var(--teal);
}

.switch-control input:checked + .switch-visual::after {
  transform: translateX(24px);
}

.switch-control input:focus-visible + .switch-visual {
  box-shadow: var(--focus);
}

.message {
  padding: 10px 12px;
  border-radius: 11px;
  font-weight: 700;
}

.message-error {
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 11%, transparent);
}

.privacy-note {
  margin: 17px 0 0;
  color: var(--text-soft);
  font-size: 0.78rem;
  text-align: center;
}

.centered-screen {
  display: grid;
  min-height: calc(100vh - 175px);
  align-content: center;
  justify-items: center;
  text-align: center;
}

.centered-screen > .phase-badge {
  margin-bottom: -15px;
  z-index: 1;
}

.phase-badge-accent {
  color: var(--coral-deep);
  background: var(--coral-soft);
}

.phase-badge-night {
  color: var(--surface-strong);
  background: var(--night);
}

:root[data-theme="dark"] .phase-badge-night {
  color: #17213a;
}

.focus-panel,
.topic-panel,
.timer-panel,
.reverse-panel,
.reveal-panel,
.result-panel {
  width: min(620px, 100%);
  padding: 36px 20px 28px;
}

.focus-panel h1,
.topic-panel h1,
.timer-panel h1,
.reverse-panel h1,
.reveal-panel h1,
.result-panel h1 {
  font-size: clamp(1.9rem, 8vw, 3rem);
}

.player-orb,
.mystery-orb {
  display: grid;
  width: 84px;
  height: 84px;
  margin: 0 auto 20px;
  place-items: center;
  border-radius: 46% 54% 48% 52%;
  color: #fff;
  background: var(--teal);
  box-shadow: 0 10px 0 var(--teal-deep);
  font-size: 2rem;
  font-weight: 900;
  transform: rotate(-4deg);
}

.mystery-orb {
  background: var(--coral);
  box-shadow: 0 10px 0 var(--coral-deep);
}

.quit-game {
  margin-top: 18px;
}

.topic-card {
  display: grid;
  min-height: 150px;
  margin: 24px 0;
  padding: 25px;
  place-items: center;
  border: 2px solid var(--teal);
  border-radius: var(--radius-lg);
  color: var(--teal-deep);
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--teal-soft) 75%, transparent), transparent),
    var(--surface-strong);
  box-shadow: inset 0 0 0 8px var(--surface-strong), var(--shadow-small);
  font-size: clamp(2.2rem, 12vw, 4.5rem);
  font-weight: 900;
  letter-spacing: 0.05em;
  animation: card-reveal 450ms ease both;
}

.timer-clock {
  margin: 25px 0;
}

.timer-clock > span {
  display: block;
  color: var(--teal-deep);
  font-size: clamp(3.8rem, 19vw, 7.5rem);
  font-variant-numeric: tabular-nums;
  font-weight: 900;
  letter-spacing: -0.06em;
  line-height: 1;
}

.timer-clock progress {
  width: min(400px, 100%);
  height: 12px;
  margin-top: 20px;
  overflow: hidden;
  border: 0;
  border-radius: 99px;
  color: var(--teal);
  background: var(--line);
}

.timer-clock progress::-webkit-progress-bar {
  border-radius: 99px;
  background: var(--line);
}

.timer-clock progress::-webkit-progress-value {
  border-radius: 99px;
  background: var(--teal);
}

.timer-clock progress::-moz-progress-bar {
  border-radius: 99px;
  background: var(--teal);
}

.timer-actions,
.two-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.timer-actions .button-text {
  grid-column: 1 / -1;
}

.timer-panel.is-time-up {
  border-color: var(--coral);
  background: color-mix(in srgb, var(--coral-soft) 52%, var(--surface));
  animation: time-up 600ms ease both;
}

.time-up-message {
  color: var(--text) !important;
  font-weight: 800;
}

.action-stack {
  display: grid;
  gap: 10px;
}

.suspect-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 26px;
}

.suspect-button {
  min-height: 62px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--text);
  background: var(--surface-strong);
  box-shadow: var(--shadow-small);
  font-weight: 800;
  overflow-wrap: anywhere;
}

.suspect-button:hover {
  border-color: var(--coral);
  color: var(--coral-deep);
  background: var(--coral-soft);
}

.reveal-panel.is-waiting .mystery-orb {
  animation: mystery-pulse 900ms ease-in-out infinite alternate;
}

.reveal-panel.is-revealed {
  border-color: var(--coral);
}

.result-topic span {
  color: var(--text-soft);
  font-size: 0.78rem;
  font-weight: 800;
}

.topic-comparison {
  display: grid;
  gap: 8px;
  align-items: center;
  margin: 25px 0 30px;
}

.result-topic {
  display: grid;
  gap: 4px;
  padding: 16px;
  border-radius: var(--radius-md);
}

.result-topic strong {
  font-size: 1.65rem;
}

.majority-topic {
  color: var(--teal-deep);
  background: var(--teal-soft);
}

.minority-topic {
  color: var(--coral-deep);
  background: var(--coral-soft);
}

.versus {
  color: var(--text-soft);
  font-size: 0.76rem;
  font-weight: 900;
}

.result-panel h2 {
  margin: 0 0 12px;
  font-size: 1.1rem;
}

.result-character {
  display: block;
  width: min(310px, 80%);
  max-height: 235px;
  margin: -14px auto 10px;
  object-fit: contain;
  filter: drop-shadow(0 15px 22px rgba(48, 62, 56, 0.14));
}

.role-list {
  display: grid;
  gap: 8px;
  margin-bottom: 25px;
  text-align: left;
}

.role-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-strong);
}

.role-row strong {
  overflow-wrap: anywhere;
}

.role-detail {
  color: var(--text-soft);
  font-size: 0.78rem;
  font-weight: 800;
  text-align: right;
}

.role-row.is-minority {
  border-color: var(--coral);
  background: var(--coral-soft);
}

.result-actions {
  margin-top: 18px;
}

.confetti {
  position: fixed;
  z-index: -1;
  inset: 85px 0 auto;
  height: 230px;
  overflow: hidden;
  pointer-events: none;
}

.confetti i {
  position: absolute;
  top: -20px;
  left: 8%;
  width: 10px;
  height: 18px;
  border-radius: 3px;
  background: var(--coral);
  animation: confetti-fall 2.7s ease-in infinite;
}

.confetti i:nth-child(2) { left: 16%; animation-delay: 0.5s; background: var(--teal); }
.confetti i:nth-child(3) { left: 25%; animation-delay: 1.1s; }
.confetti i:nth-child(4) { left: 34%; animation-delay: 0.2s; background: #e6bb50; }
.confetti i:nth-child(5) { left: 43%; animation-delay: 1.5s; background: var(--teal); }
.confetti i:nth-child(6) { left: 52%; animation-delay: 0.8s; }
.confetti i:nth-child(7) { left: 60%; animation-delay: 1.7s; background: #e6bb50; }
.confetti i:nth-child(8) { left: 68%; animation-delay: 0.35s; background: var(--teal); }
.confetti i:nth-child(9) { left: 75%; animation-delay: 1.25s; }
.confetti i:nth-child(10) { left: 82%; animation-delay: 0.7s; background: #e6bb50; }
.confetti i:nth-child(11) { left: 89%; animation-delay: 1.8s; background: var(--teal); }
.confetti i:nth-child(12) { left: 95%; animation-delay: 0.95s; }

.help-dialog {
  width: min(620px, calc(100% - 28px));
  max-height: calc(100vh - 40px);
  padding: 24px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  color: var(--text);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.help-dialog::backdrop {
  background: rgba(10, 17, 27, 0.62);
  backdrop-filter: blur(4px);
}

.dialog-header {
  display: flex;
  gap: 18px;
  align-items: center;
  justify-content: space-between;
}

.rules-list {
  display: grid;
  gap: 13px;
  padding: 0;
  margin: 24px 0;
  list-style: none;
  counter-reset: rule;
}

.rules-list li {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  column-gap: 11px;
  counter-increment: rule;
}

.rules-list li::before {
  display: grid;
  grid-row: 1 / 3;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--teal);
  content: counter(rule);
  font-weight: 900;
}

.rules-list span {
  color: var(--text-soft);
  font-size: 0.9rem;
}

.tip-box {
  padding: 15px;
  border-radius: var(--radius-md);
  background: var(--teal-soft);
}

.tip-box p {
  margin: 4px 0 0;
  color: var(--text-soft);
}

.debug-toolbar {
  position: fixed;
  z-index: 90;
  right: 8px;
  bottom: 8px;
  left: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  padding: 8px;
  border: 2px solid #ffdb6e;
  border-radius: 12px;
  color: #241b00;
  background: #fff4c5;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
  font-size: 0.76rem;
}

.debug-toolbar button {
  min-height: 38px;
  border: 1px solid #9d7e19;
  border-radius: 8px;
  color: #241b00;
  background: #fff;
  font-weight: 800;
}

.legal-document-root {
  min-height: 100%;
}

.legal-document {
  min-width: 300px;
  min-height: 100vh;
  padding: 0 0 3rem;
}

.legal-topbar {
  width: min(880px, calc(100% - 28px));
  margin: 0 auto;
  padding: 1rem 0 0;
}

.legal-back-link {
  display: inline-flex;
  min-height: 42px;
  padding: 0.55rem 0.85rem;
  align-items: center;
  color: var(--text);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 0.82rem;
  font-weight: 800;
  text-decoration: none;
}

.legal-back-link:hover {
  color: var(--accent);
  border-color: var(--accent);
  text-decoration: underline;
}

.legal-card {
  width: min(880px, calc(100% - 28px));
  margin: 1rem auto 0;
  padding: clamp(1.25rem, 4vw, 2.25rem);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.legal-card h1 {
  margin: 0 0 0.8rem;
  font-size: clamp(1.7rem, 5vw, 2.4rem);
  line-height: 1.25;
}

.legal-card h2 {
  margin: 2rem 0 0.55rem;
  color: var(--teal-deep);
  font-size: 1.15rem;
  line-height: 1.45;
}

.legal-card h3 {
  margin: 1.1rem 0 0.4rem;
  font-size: 1rem;
}

.legal-card p,
.legal-card li {
  font-size: 0.92rem;
}

.legal-card p {
  margin: 0.55rem 0;
}

.legal-card ul {
  padding-left: 1.35rem;
}

.legal-card a {
  color: var(--teal-deep);
  font-weight: 700;
}

.legal-callout {
  margin: 1rem 0;
  padding: 0.85rem 1rem;
  background: var(--teal-soft);
  border: 1px solid color-mix(in srgb, var(--teal) 45%, var(--line));
  border-radius: var(--radius-md);
}

@keyframes screen-in {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes card-reveal {
  from { opacity: 0; transform: perspective(600px) rotateY(12deg) scale(0.97); }
  to { opacity: 1; transform: perspective(600px) rotateY(0) scale(1); }
}

@keyframes mystery-pulse {
  from { transform: rotate(-4deg) scale(0.96); }
  to { transform: rotate(3deg) scale(1.03); }
}

@keyframes time-up {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.015); }
}

@keyframes confetti-fall {
  0% { opacity: 0; transform: translateY(-20px) rotate(0deg); }
  12% { opacity: 0.9; }
  100% { opacity: 0; transform: translateY(240px) rotate(270deg); }
}

@media (min-width: 850px) {
  .app-header {
    padding-inline: 28px;
  }

  .app-shell {
    padding-top: 38px;
  }

  .screen-setup {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 46px;
  }

  .hero-copy {
    position: sticky;
    top: 30px;
    padding-top: 55px;
  }

  .hero-copy h1 {
    font-size: clamp(1.85rem, 3.5vw, 2.5rem);
  }

  .hero-character {
    width: min(360px, 100%);
  }

  .settings-panel {
    padding: 30px;
  }

  .topic-comparison {
    grid-template-columns: 1fr auto 1fr;
  }

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

  .debug-toolbar {
    right: 14px;
    left: auto;
  }
}

@media (min-width: 900px) {
  .result-panel {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
    gap: 26px;
    width: min(1080px, 100%);
    padding: 24px;
    align-items: stretch;
    text-align: left;
  }

  .result-overview {
    align-self: center;
    text-align: center;
  }

  .result-details {
    display: flex;
    min-width: 0;
    flex-direction: column;
  }

  .result-character {
    width: min(250px, 72%);
    max-height: 175px;
    margin: -8px auto 4px;
  }

  .result-overview h1 {
    margin: 4px 0 8px;
    font-size: clamp(1.8rem, 3vw, 2.5rem);
  }

  .result-overview > p {
    margin: 4px 0;
  }

  .topic-comparison {
    margin: 15px 0 0;
  }

  .result-topic {
    padding: 11px 8px;
  }

  .result-topic strong {
    font-size: 1.2rem;
    overflow-wrap: anywhere;
  }

  .result-details h2 {
    margin-bottom: 8px;
  }

  .role-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
    margin-bottom: 14px;
  }

  .role-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 1px;
    padding: 8px 10px;
  }

  .role-detail {
    font-size: 0.72rem;
    text-align: left;
  }

  .result-actions {
    margin-top: auto;
    padding-top: 18px;
    border-top: 1px solid var(--line);
  }
}

@media (min-width: 1100px) {
  .app-shell {
    padding-top: 16px;
  }

  .screen-setup {
    grid-template-columns: minmax(315px, 0.82fr) minmax(335px, 1fr) minmax(360px, 1.08fr);
    gap: 22px;
  }

  .settings-layout {
    display: contents;
  }

  .hero-copy {
    padding-top: 30px;
  }

  .hero-copy h1 {
    font-size: clamp(1.65rem, 2.2vw, 2rem);
  }

  .hero-character {
    width: min(300px, 92%);
    margin-top: 10px;
  }

  .settings-panel {
    padding: 22px 18px;
  }

  .settings-panel .section-heading {
    margin-bottom: 10px;
  }

  .player-settings-panel .player-list {
    max-height: max(230px, calc(100vh - 315px));
    padding-right: 3px;
    overflow-y: auto;
    scrollbar-gutter: stable;
  }

  .game-settings-panel .chip-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .game-settings-panel .field-group {
    margin-bottom: 14px;
  }

  .game-settings-panel .switch-card {
    margin-bottom: 14px;
  }
}

@media (max-width: 420px) {
  .mode-hero {
    grid-template-columns: minmax(0, 1fr) 90px;
  }

  .mode-options {
    grid-template-columns: 1fr;
  }

  .site-information {
    grid-template-columns: 1fr;
  }

  .page-about {
    padding: 1rem;
  }

  .policy-links {
    grid-template-columns: 1fr;
  }

  .mode-card-debug {
    grid-column: auto;
  }

  .app-header {
    min-height: 64px;
    padding: 10px 14px;
  }

  .header-help {
    padding-inline: 10px;
  }

  .brand {
    font-size: 0.9rem;
  }

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

  .app-shell {
    width: min(100% - 20px, 1040px);
    padding-top: 8px;
  }

  .settings-panel {
    padding: 20px 13px;
    border-radius: 24px;
  }

  .player-row {
    grid-template-columns: 44px minmax(0, 1fr) auto;
  }

  .row-actions {
    grid-column: auto;
  }

  .mini-button {
    min-width: 44px;
  }

  .chip-grid,
  .suspect-grid {
    grid-template-columns: 1fr;
  }

  .focus-panel,
  .topic-panel,
  .timer-panel,
  .reverse-panel,
  .reveal-panel,
  .result-panel {
    padding-inline: 15px;
    border-radius: 24px;
  }

  .two-actions {
    grid-template-columns: 1fr;
  }
}

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