:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-strong: #eef6f3;
  --ink: #1e2530;
  --muted: #687281;
  --line: #dbe2ea;
  --accent: #087f68;
  --accent-strong: #065f4f;
  --danger: #b42318;
  --danger-soft: #fff0ee;
  --warn: #9a6700;
  --warn-soft: #fff7db;
  --dead: #515867;
  --shadow: 0 10px 28px rgba(35, 45, 62, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  line-height: 1.45;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 14px;
  background: var(--ink);
  color: white;
  cursor: pointer;
  font-weight: 700;
}

button:hover {
  filter: brightness(0.96);
}

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

input,
select {
  min-height: 42px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: white;
  color: var(--ink);
}

input:disabled,
select:disabled {
  background: #eef1f5;
  color: #8a94a3;
  cursor: not-allowed;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.app {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 16px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0 16px;
}

.brand {
  display: grid;
  gap: 2px;
}

.brand h1 {
  margin: 0;
  font-size: clamp(24px, 5vw, 40px);
  letter-spacing: 0;
}

.brand span {
  color: var(--muted);
  font-size: 14px;
}

.view-switch {
  display: flex;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.view-switch button {
  min-height: 34px;
  padding: 0 12px;
  background: transparent;
  color: var(--muted);
}

.view-switch button.active {
  background: var(--accent);
  color: white;
}

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: 16px;
  align-items: start;
}

.stack {
  display: grid;
  gap: 16px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 16px;
}

.panel.soft {
  background: var(--panel-strong);
}

.panel h2,
.panel h3 {
  margin: 0 0 12px;
  letter-spacing: 0;
}

.panel h2 {
  font-size: 22px;
}

.panel h3 {
  font-size: 17px;
}

.phase-banner {
  display: grid;
  gap: 12px;
  border-left: 6px solid var(--accent);
}

.phase-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.phase-title strong {
  font-size: clamp(24px, 8vw, 46px);
  line-height: 1.05;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  background: #e6f3ef;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 800;
}

.badge.dead {
  background: #eceff3;
  color: var(--dead);
}

.badge.you {
  border: 1px solid #2563a6;
  background: #e8f1fb;
  color: #174f87;
}

.badge.alive {
  background: #e4f4e8;
  color: #23683a;
}

.badge.known {
  background: #fff1c2;
  color: #755300;
}

.badge.known.team {
  border: 1px solid #d59f20;
}

.badge.danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.timer {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: center;
}

.timer strong {
  min-width: 74px;
  font-size: 34px;
  font-variant-numeric: tabular-nums;
}

.meter {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #d7dee8;
}

.meter span {
  display: block;
  width: var(--value, 0%);
  height: 100%;
  background: var(--accent);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.secondary {
  border-color: var(--line);
  background: white;
  color: var(--ink);
}

.accent {
  background: var(--accent);
}

.danger {
  background: var(--danger);
}

.warn {
  background: var(--warn);
}

.ghost {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

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

.form-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.checkbox {
  display: flex;
  min-height: 42px;
  align-items: center;
  gap: 8px;
  color: var(--ink);
}

.checkbox input {
  min-height: 18px;
  width: 18px;
}

.players {
  display: grid;
  gap: 8px;
}

.player-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: white;
}

.player-row.dead {
  background: #f0f2f5;
  color: var(--dead);
}

.player-name {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  min-width: 0;
  font-weight: 800;
}

.player-name span:first-child {
  overflow-wrap: anywhere;
}

.player-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.player-actions button {
  min-height: 34px;
  padding: 0 10px;
  font-size: 13px;
}

.advanced-actions {
  width: 100%;
  color: var(--muted);
  font-size: 13px;
}

.advanced-actions summary {
  cursor: pointer;
  text-align: right;
}

.advanced-actions .button-row {
  justify-content: flex-end;
  margin-top: 6px;
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 8px;
}

.choice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 58px;
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
}

.choice.selected {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.team-choice-panel {
  display: grid;
  gap: 8px;
  border: 2px dashed #9aa6b5;
  border-radius: 8px;
  background: #f4f6f8;
  padding: 12px;
}

.team-choice-panel h3,
.team-choice-panel p {
  margin: 0;
}

.team-choice-panel p {
  color: var(--muted);
  font-size: 13px;
}

.readonly-choice {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 10px;
}

.readonly-choice.completed {
  border-color: #76a886;
  background: #eef8f1;
}

.readonly-choice strong {
  color: var(--accent-strong);
}

.readonly-choice-state {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
  text-align: right;
}

.badge.choice-complete {
  min-height: 24px;
  padding: 0 8px;
  background: #d8efdf;
  color: #23683a;
  font-size: 12px;
}

.choice-pending {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.scoreboard {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.scoreboard span {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 7px 10px;
}

.role-card {
  display: grid;
  gap: 8px;
  min-height: 140px;
  place-items: center;
  text-align: center;
  border-radius: 8px;
  background: #17202c;
  color: white;
  padding: 18px;
}

.role-card strong {
  font-size: clamp(34px, 12vw, 64px);
  line-height: 1;
}

.role-card p {
  max-width: 560px;
  margin: 0;
  color: #dbe5ef;
}

.notice {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  color: var(--muted);
}

.notice.warn {
  border-color: #f3d279;
  background: var(--warn-soft);
  color: #5f4700;
}

.address-list {
  display: grid;
  gap: 8px;
}

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

.address code {
  overflow-wrap: anywhere;
  color: var(--accent-strong);
}

.timeline {
  display: grid;
  gap: 8px;
}

.event {
  border-left: 4px solid var(--line);
  padding: 8px 10px;
  background: white;
}

.event.secret {
  border-left-color: var(--warn);
  background: #fffbeb;
}

.event.undone {
  border-left-color: #9aa6b5;
  background: #f4f6f8;
  color: var(--muted);
}

.badge.undone {
  min-height: 22px;
  margin-left: 5px;
  padding: 0 7px;
  background: #dfe4ea;
  color: #52606d;
  font-size: 11px;
}

.event small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.event-content {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.detail-button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 13px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(18, 24, 33, 0.62);
  padding: 16px;
}

.modal {
  width: min(520px, 100%);
  max-height: min(680px, calc(100vh - 32px));
  overflow: auto;
  border-radius: 8px;
  background: white;
  padding: 16px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.24);
}

.modal-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.modal-heading h2,
.modal-heading small {
  margin: 0;
}

.detail-list {
  display: grid;
  gap: 8px;
}

.detail-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  padding: 9px 2px;
}

.detail-person,
.detail-choice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.detail-choice {
  justify-content: flex-end;
}

.summary-table {
  width: 100%;
  border-collapse: collapse;
}

.summary-table th,
.summary-table td {
  border-bottom: 1px solid var(--line);
  padding: 9px 6px;
  text-align: left;
}

.summary-table th {
  color: var(--muted);
  font-size: 13px;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 10;
  max-width: min(360px, calc(100vw - 32px));
  transform: translateY(20px);
  border-radius: 8px;
  background: var(--ink);
  color: white;
  padding: 12px 14px;
  opacity: 0;
  pointer-events: none;
  transition: 160ms ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

@media (max-width: 820px) {
  .app {
    padding: 12px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .grid,
  .form-grid,
  .form-grid.three {
    grid-template-columns: 1fr;
  }

  .panel {
    padding: 14px;
  }

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

  .player-actions {
    justify-content: flex-start;
  }

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