:root {
  color-scheme: dark;
  --ink: #eef6f4;
  --muted: #9fb0ad;
  --line: #202829;
  --paper: #080b0c;
  --panel: #050708;
  --accent: #44b3a4;
  --accent-strong: #8ed8cc;
  --human: #85e1bd;
  --wolf: #ff8d98;
  --gray: #b4bfbd;
  --rival: #ffd38b;
  --inactive: #a9b2b0;
  --shadow: 0 12px 28px rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: #000;
}

body {
  margin: 0;
  color: var(--ink);
  background: #000;
  font-family: "Yu Gothic UI", "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  min-height: 100dvh;
  max-width: 760px;
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 14px calc(88px + env(safe-area-inset-bottom));
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0 14px;
}

.game-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.game-status-badge {
  display: grid;
  place-items: center;
  min-height: 34px;
  padding: 0 10px;
  border-radius: 999px;
  background: #263637;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.game-status-badge.in-progress {
  background: #123f2e;
  color: #8ff0b5;
}

.game-status-badge.finished {
  background: #3b321c;
  color: #ffd38b;
}

.kicker {
  margin: 0 0 3px;
  color: var(--accent-strong);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.app-title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
}

.app-version-badge {
  display: inline-grid;
  place-items: center;
  min-height: 22px;
  padding: 2px 7px;
  border: 1px solid #496264;
  border-radius: 999px;
  background: #1d2d2e;
  color: #a9d9d3;
  font-size: 0.72rem;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
}

.wolf-mode-badge {
  display: inline-grid;
  place-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border: 1px solid #a84450;
  border-radius: 999px;
  background: #4b171e;
  color: #ffb3ba;
  font-size: 0.74rem;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 1.45rem;
  line-height: 1.05;
}

h2 {
  font-size: 1rem;
}

.main-stack {
  display: grid;
  gap: 12px;
}

.board-switcher-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 48px;
  margin-bottom: 12px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  color: var(--ink);
  text-align: left;
}

.board-switcher-button span:first-child {
  display: grid;
  min-width: 0;
}

.board-switcher-button small {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
}

.board-switcher-button strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.board-switcher-button > span:last-child {
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 900;
}

.view-stack {
  display: grid;
  gap: 12px;
}

[hidden] {
  display: none !important;
}

.setup-panel,
.table-panel,
.export-panel {
  border: 1px solid rgba(44, 58, 60, 0.95);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.setup-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
}

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

.perspective-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  border: 1px solid rgba(159, 176, 173, 0.18);
  border-radius: 8px;
  background: #0e1415;
}

.perspective-button {
  min-height: 38px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 900;
}

.perspective-button.active {
  background: #263637;
  color: var(--ink);
  box-shadow: inset 0 0 0 1px rgba(159, 176, 173, 0.18);
}

.wolf-count-badge {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 11px;
  border: 1px solid rgba(185, 75, 87, 0.72);
  border-radius: 7px;
  background: #241114;
  color: #ffd9dc;
  font-size: 0.88rem;
  font-weight: 900;
}

.day-button,
.round-button {
  width: 40px;
  height: 40px;
  border-radius: 7px;
  background: #263637;
  color: var(--ink);
  font-size: 1.2rem;
  font-weight: 900;
}

.entry-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--paper);
  color: var(--ink);
  outline: none;
}

input,
select {
  min-height: 44px;
  padding: 0 12px;
}

textarea {
  min-height: 78px;
  resize: vertical;
  padding: 11px 12px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(21, 94, 99, 0.16);
}

.date-input-wrap {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  gap: 8px;
}

.date-input-wrap:not(.has-date) {
  grid-template-columns: minmax(0, 1fr);
}

.native-date-input {
  position: absolute;
  z-index: 2;
  top: 0;
  left: 0;
  width: calc(100% - 52px);
  min-height: 58px;
  height: 58px;
  opacity: 0;
  cursor: pointer;
}

.date-input-wrap:not(.has-date) .native-date-input {
  width: 100%;
}

.date-display-button {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  min-height: 58px;
  padding: 8px 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--paper);
  color: var(--ink);
  text-align: left;
}

.date-display-copy {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.date-display-copy small {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
}

.date-display-copy strong {
  overflow: hidden;
  font-size: 0.95rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.date-action-text {
  flex: 0 0 auto;
  padding: 5px 8px;
  border-radius: 6px;
  background: #263637;
  color: var(--accent-strong);
  font-size: 0.76rem;
  font-weight: 900;
}

.date-clear-button {
  position: relative;
  z-index: 3;
  min-height: 58px;
  border-radius: 7px;
  background: #263637;
  color: var(--accent-strong);
  font-size: 1.1rem;
  font-weight: 900;
}

.date-input-wrap:not(.locked):active .date-display-button {
  border-color: var(--accent);
  background: #152526;
}

.date-input-wrap:not(.locked):focus-within .date-display-button {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(21, 94, 99, 0.16);
}

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

.tournament-controls select {
  grid-column: 1 / -1;
}

.tournament-controls .secondary-button {
  padding-inline: 10px;
}

.regulation-name-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.regulation-name-controls input {
  min-width: 0;
}

.role-composition-field {
  display: grid;
  gap: 8px;
  padding-top: 2px;
}

.role-set-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.role-composition-summary {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  min-height: 46px;
  padding: 9px 11px;
  border: 1px solid rgba(159, 176, 173, 0.18);
  border-radius: 7px;
  background: #0e1415;
  font-size: 0.8rem;
  line-height: 1.45;
}

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

.role-composition-summary span {
  flex: 0 0 auto;
  color: var(--muted);
  font-weight: 900;
}

.role-composition-summary .mismatch,
.role-composition-total .mismatch {
  color: #ff9ca5;
}

.roster-filter {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.roster-filter button {
  min-height: 40px;
  border-radius: 7px;
  background: #263637;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 900;
}

.roster-filter button.active {
  background: var(--accent);
  color: #071313;
}

.primary-button,
.secondary-button,
.danger-button,
.icon-text-button,
.bottom-bar button {
  min-height: 44px;
  border-radius: 7px;
  padding: 0 14px;
  font-weight: 900;
  white-space: nowrap;
}

.primary-button {
  background: var(--accent);
  color: #071313;
}

.secondary-button,
.icon-text-button {
  background: #263637;
  color: var(--ink);
}

.danger {
  background: #3d2227;
  color: #ff9aa5;
}

.danger-button {
  background: #3d2227;
  color: #ff9aa5;
  min-height: 44px;
  border-radius: 7px;
  padding: 0 14px;
  font-weight: 900;
}

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

.wide {
  width: 100%;
}

.count-badge {
  display: inline-grid;
  place-items: center;
  min-width: 52px;
  padding: 5px 9px;
  border-radius: 999px;
  background: #203433;
  color: var(--accent-strong);
  font-size: 0.82rem;
  font-weight: 900;
  text-align: center;
}

.rope-count-badge {
  min-height: 42px;
  display: grid;
  place-items: center;
  padding: 0 12px;
  border-radius: 999px;
  background: #263637;
  color: var(--accent-strong);
  font-weight: 900;
  white-space: nowrap;
}

.table-panel {
  min-height: 280px;
  overflow: hidden;
}

.player-rows {
  display: grid;
}

.player-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 74px 40px;
  gap: 6px;
  align-items: center;
  min-height: 70px;
  padding: 8px 8px 8px 12px;
  border-bottom: 1px solid var(--line);
  background: #070a0b;
  color: var(--ink);
  text-align: left;
}

.participant-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 124px 40px;
  gap: 6px;
  align-items: center;
  min-height: 58px;
  padding: 8px 8px 8px 12px;
  border-bottom: 1px solid var(--line);
  background: #070a0b;
  color: var(--ink);
}

.participant-row.participant-resting {
  background: #202829;
  color: var(--muted);
}

.participant-row.participant-resting .player-name {
  opacity: 0.72;
}

.participant-row:last-child {
  border-bottom: 0;
}

.participant-row.dragging {
  opacity: 0.48;
}

.participant-row.drop-target {
  outline: 3px solid rgba(21, 94, 99, 0.18);
  outline-offset: -3px;
  background: #203433;
}

.player-row:last-child {
  border-bottom: 0;
}

.player-row:active {
  background: #203433;
}

.player-row.dragging {
  opacity: 0.48;
}

.player-row.drop-target {
  outline: 3px solid rgba(21, 94, 99, 0.18);
  outline-offset: -3px;
  background: #203433;
}

.player-row.player-status-exiled,
.player-row.player-status-attacked {
  border-left: 6px solid var(--inactive);
  background: #202829;
}

.player-row.player-status-exiled {
  border-left-color: #6f7978;
  background: #202829;
}

.player-row.player-status-attacked {
  border-left-color: var(--wolf);
  background: #3a2025;
}

.player-row.player-status-exiled .player-name,
.player-row.player-status-attacked .player-name {
  text-decoration: line-through;
  text-decoration-thickness: 2px;
  text-decoration-color: currentColor;
}

.player-info {
  min-width: 0;
  display: grid;
  grid-template-columns: 216px minmax(0, 1fr);
  gap: 7px;
  align-items: center;
  min-height: 54px;
  border-radius: 7px;
  background: transparent;
  color: inherit;
  text-align: left;
}

.sticky-player-name {
  display: none;
}

.participant-info {
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  min-height: 44px;
  border-radius: 7px;
  background: transparent;
  color: inherit;
  text-align: left;
}

.participant-name-edit-label {
  margin-left: auto;
  color: var(--accent-strong);
  font-size: 0.72rem;
  font-weight: 900;
  white-space: nowrap;
}

.participation-choice {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2px;
  min-width: 0;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #0b1011;
}

.participation-option {
  min-width: 0;
  min-height: 34px;
  padding: 0 5px;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  white-space: nowrap;
}

.participation-option.active[data-participating="true"] {
  background: #123f2e;
  color: #8ff0b5;
}

.participation-option.active[data-participating="false"] {
  background: #343c3d;
  color: #f1f4f3;
}

.membership-count {
  min-height: 38px;
}

.player-info:focus-visible,
.participant-info:focus-visible,
.impression-button:focus-visible,
.status-button:focus-visible,
.order-button:focus-visible {
  outline: 3px solid rgba(21, 94, 99, 0.22);
}

.player-main {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.player-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 1.05rem;
  font-weight: 900;
}

.player-name-row {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
}

.player-name-row .player-name {
  flex: 1 1 0;
  min-width: 0;
}

.player-name-row .role-guess-label {
  flex: 0 0 auto;
  margin-left: auto;
}

.player-ally-marker {
  display: block;
  width: 5px;
  height: 28px;
  flex: 0 0 5px;
  border-radius: 3px;
  background: var(--relation-color);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08);
  align-self: center;
}

.player-enemy-markers {
  display: flex;
  min-width: 0;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  width: 6px;
  height: 28px;
  flex: 0 0 6px;
  align-self: center;
}

.player-enemy-markers i {
  display: block;
  width: 6px;
  min-height: 3px;
  flex: 1 1 auto;
  border-radius: 3px;
  background: var(--relation-color);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.14);
}

.sticky-player-name-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.role-guess-label,
.true-role-label {
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  min-height: 36px;
  padding: 7px 11px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
}

button.role-guess-label {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid transparent;
  font-family: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

.player-name-button {
  appearance: none;
  -webkit-appearance: none;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.role-guess-label {
  width: 112px;
  position: relative;
}

.role-guess-label.wolf-teammate {
  border: 1px solid rgba(255, 112, 126, 0.62);
  box-shadow: inset 0 0 0 1px rgba(255, 112, 126, 0.08);
}

.role-guess-label.black-target {
  border: 1px solid rgba(101, 39, 48, 0.72);
  box-shadow: inset 0 0 0 1px rgba(101, 39, 48, 0.08);
}

.black-target-rank {
  position: absolute;
  top: -5px;
  right: -4px;
  display: grid;
  place-items: center;
  min-width: 17px;
  height: 17px;
  padding: 0 2px;
  border: 1px solid rgba(111, 48, 57, 0.78);
  border-radius: 999px;
  background: #1c1114;
  color: #b97880;
  font-size: 0.62rem;
  font-weight: 900;
  line-height: 1;
}

.true-role-label {
  outline: 2px solid #eef6f4;
  outline-offset: 1px;
}

.impression-label {
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  min-height: 28px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
}

.impression-button {
  min-width: 0;
  width: 100%;
  display: inline-grid;
  place-items: center;
  min-height: 34px;
  padding: 4px 5px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 900;
  line-height: 1.15;
  text-align: center;
}

.impression-villager {
  background: #183755;
  color: #a9d7ff;
}

.impression-werewolf {
  background: #43272c;
  color: var(--wolf);
}

.impression-none {
  background: #263637;
  color: var(--muted);
}

.player-sub {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.seer-grid {
  grid-column: 1 / -1;
  min-width: 0;
  width: 100%;
  display: grid;
  grid-template-columns: repeat(var(--seer-columns), minmax(96px, 1fr));
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 7px;
  background: #263637;
  color: var(--ink);
  overflow-x: auto;
  scrollbar-width: none;
}

.seer-grid::-webkit-scrollbar {
  display: none;
}

.role-title {
  flex: 0 0 auto;
}

.seer-result-label {
  min-width: 0;
  display: grid;
  place-items: center;
  min-height: 36px;
  padding: 8px 10px;
  border-radius: 999px;
  font-size: 1rem;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.seer-result-label.empty {
  min-height: 34px;
  border: 1px dashed rgba(159, 176, 173, 0.28);
  background: transparent;
}

.seer-result-label[data-rival-role],
.seer-result-label[data-seer-id],
.seer-result-label[data-medium-id],
.seer-result-label[data-player-id] {
  cursor: pointer;
}

.role-seer {
  background: #294a38;
  color: #c7f7d6;
}

.role-seer-wolfSide {
  background: linear-gradient(90deg, #294a38 0%, #294a38 58%, #43272c 100%);
  color: #d7f9dd;
  border: 1px solid rgba(255, 141, 152, 0.42);
}

.role-medium {
  background: #35214a;
  color: #d7b8ff;
}

.role-medium-wolfSide {
  background: linear-gradient(90deg, #35214a 0%, #35214a 58%, #43272c 100%);
  color: #efd7ff;
  border: 1px solid rgba(255, 141, 152, 0.45);
}

.role-medium-madman {
  background: linear-gradient(90deg, #35214a 0%, #35214a 58%, #4a243d 100%);
  color: #f2d6ff;
  border: 1px solid rgba(245, 157, 218, 0.48);
}

.role-guard {
  background: #4a2b12;
  color: #ffbd73;
}

.role-guard-madman {
  background: linear-gradient(90deg, #4a2b12 0%, #4a2b12 58%, #4a243d 100%);
  color: #ffd0a0;
  border: 1px solid rgba(245, 157, 218, 0.48);
}

.role-guard-werewolf {
  background: linear-gradient(90deg, #4a2b12 0%, #4a2b12 58%, #521b22 100%);
  color: #ffd0a0;
  border: 1px solid rgba(255, 112, 124, 0.52);
}

.role-guard-wolfSide {
  background: linear-gradient(90deg, #4a2b12 0%, #4a2b12 58%, #43272c 100%);
  color: #ffd0a0;
  border: 1px solid rgba(255, 141, 152, 0.45);
}

.role-hunter {
  background: #123f2e;
  color: #80e8a8;
}

.role-nekomata {
  background: #123f2e;
  color: #80e8a8;
}

.role-gidora,
.role-nekomataGuard {
  background: linear-gradient(90deg, #35214a 0%, #35214a 34%, #4a2b12 34%, #4a2b12 67%, #123f2e 67%);
  color: #ffe0ae;
  border: 1px solid rgba(255, 189, 115, 0.48);
  white-space: nowrap;
}

.gidora-role-section {
  margin: 0;
  border: 1px solid var(--line);
}

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

.gidora-role-options label {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #101718;
  font-size: 0.84rem;
  white-space: nowrap;
}

.gidora-role-options input[type="checkbox"] {
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  margin: 0;
}

.role-madmanHunter {
  background: linear-gradient(90deg, #4b3d12 0%, #4b3d12 55%, #123f2e 100%);
  color: #ffe27a;
  border: 1px solid rgba(128, 232, 168, 0.42);
}

.role-fox {
  background: #4a243d;
  color: #ffaad8;
}

.role-teruteru {
  background: #40345b;
  color: #d9c5ff;
}

.role-queen,
.role-baker,
.role-dictator,
.role-annoyingHunter,
.role-sister,
.role-executioner,
.role-musician,
.role-wanderer,
.role-mason {
  background: #173d38;
  color: #9be8d2;
}

.role-oldWoman,
.role-halfWerewolf,
.role-loneWolf,
.role-alice,
.role-cheshireCat,
.role-phantom {
  background: #512028;
  color: #ffadb5;
}

.role-satan,
.role-hunterB,
.role-angel,
.role-devil,
.role-hangingWitch {
  background: #3d2b55;
  color: #dfc2ff;
}

.role-hunterA {
  background: linear-gradient(90deg, #173d38 0%, #173d38 50%, #3d2b55 50%, #3d2b55 100%);
  color: #d7f5e9;
  border: 1px solid rgba(205, 175, 255, 0.44);
}

.role-villager,
.role-confirmedWhite {
  background: #183755;
  color: #a9d7ff;
}

.role-madman,
.role-whisperingMadman {
  background: #4b3d12;
  color: #ffe27a;
}

.role-wolfSide {
  background: #43272c;
  color: #ff8d98;
}

.role-other {
  background: #273233;
  color: #d4dedc;
}

.role-regulation-villager {
  background: #173d38;
  color: #9be8d2;
}

.role-regulation-werewolf {
  background: #512028;
  color: #ffadb5;
}

.role-regulation-third {
  background: #3d2b55;
  color: #dfc2ff;
}

.role-regulation-other {
  background: #273233;
  color: #d4dedc;
}

.regulation-note {
  margin: 0;
  color: #b9c8c9;
  font-size: 12px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.role-werewolf {
  background: #5a1f27;
  color: #ff9aa5;
}

.role-unknown {
  background: #263637;
  color: var(--muted);
}

.role-none {
  color: var(--muted);
}

.status-button {
  min-width: 0;
  width: 100%;
  min-height: 46px;
  padding: 6px 7px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 900;
  text-align: center;
  line-height: 1.15;
}

.order-actions {
  display: grid;
  gap: 4px;
}

.order-button {
  width: 36px;
  height: 30px;
  border-radius: 7px;
  background: #263637;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 900;
  line-height: 1;
}

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

.judgement-human {
  background: #183755;
  color: #a9d7ff;
}

.judgement-werewolf {
  background: #43272c;
  color: var(--wolf);
}

.judgement-gray {
  background: #263637;
  color: var(--gray);
}

.judgement-rival {
  background: #43272c;
  color: #ff8d98;
}

.role-claim {
  background: #263637;
  color: var(--ink);
}

.status-alive {
  background: #12372f;
  color: var(--human);
}

.status-exiled {
  background: #283233;
  color: var(--inactive);
}

.status-attacked {
  background: #43272c;
  color: var(--wolf);
}

.empty-state {
  min-height: 260px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  color: var(--ink);
  font-size: 1.1rem;
}

.bottom-bar {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 20;
  width: min(760px, 100%);
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: #000;
}

.bottom-bar button {
  background: #263637;
  color: var(--ink);
}

.bottom-bar button.active {
  background: var(--accent);
  color: #071313;
}

.export-panel {
  padding: 12px;
}

.history-panel {
  overflow: hidden;
  border: 1px solid rgba(44, 58, 60, 0.95);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.remote-update-banner {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 44px;
  margin-bottom: 12px;
  padding: 8px 11px;
  border: 1px solid #80652b;
  border-radius: 8px;
  background: #3b321c;
  color: #ffe29a;
  font-weight: 900;
  text-align: left;
}

.remote-update-banner span {
  color: var(--muted);
  font-size: 0.76rem;
}

.sync-panel,
.sync-conflict-panel {
  border: 1px solid rgba(44, 58, 60, 0.95);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.sync-auth-stack,
.sync-account-panel {
  display: grid;
  gap: 10px;
  padding: 0 12px 12px;
}

.sync-auth-form {
  display: grid;
  gap: 8px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.sync-auth-form.compact-form {
  background: transparent;
}

.sync-notice {
  margin: 0 12px 12px;
  padding: 11px;
  border: 1px solid #80652b;
  border-radius: 8px;
  background: #3b321c;
  color: #ffe29a;
  font-weight: 900;
}

.sync-status-badge {
  display: inline-grid;
  place-items: center;
  min-height: 32px;
  padding: 0 10px;
  border-radius: 999px;
  background: #263637;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.sync-status-badge.status-synced {
  background: #123f2e;
  color: #8ff0b5;
}

.sync-status-badge.status-conflict,
.sync-status-badge.status-remote {
  background: #3b321c;
  color: #ffe29a;
}

.sync-status-badge.status-error {
  background: #3d2227;
  color: #ff9aa5;
}

.sync-account-row {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.sync-account-row span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.sync-account-row strong {
  overflow-wrap: anywhere;
}

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

.sync-conflict-panel {
  padding-bottom: 12px;
  border-color: #80652b;
}

.sync-conflict-times {
  display: grid;
  gap: 6px;
  padding: 0 12px 12px;
}

.sync-conflict-times span {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 900;
}

.sync-conflict-actions {
  display: grid;
  gap: 10px;
  padding: 0 12px;
}

.sync-choice-card {
  display: grid;
  gap: 7px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111c1d;
}

.sync-choice-card.danger {
  border-color: rgba(255, 141, 152, 0.36);
  background: #1f1014;
}

.sync-choice-card span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1.45;
}

.history-management-panel {
  border: 1px solid rgba(101, 57, 63, 0.9);
  border-radius: 8px;
  background: #120a0c;
  box-shadow: var(--shadow);
}

.section-heading > div {
  display: grid;
  gap: 4px;
}

.section-note {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.history-management-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 0 12px 12px;
}

.history-selection-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  padding: 0 12px 10px;
}

.history-export-actions {
  padding: 0 12px 10px;
}

.delete-warning {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid #65393f;
  border-radius: 8px;
  background: #2e2023;
  color: #ffb3bb;
}

.delete-warning span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
  line-height: 1.45;
}

.section-heading,
.history-detail-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px;
}

.section-heading.flush {
  padding: 0;
}

.history-detail-actions {
  padding: 0 0 12px;
}

.history-list {
  display: grid;
  gap: 8px;
  padding-bottom: 8px;
}

.history-item-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 7px;
  align-items: stretch;
}

.history-select-checkbox {
  width: 22px;
  min-height: 22px;
  align-self: center;
  justify-self: center;
  accent-color: var(--accent);
}

.history-item {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 64px;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.history-item.active,
.history-item:active {
  background: #203433;
}

.history-item-main {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.history-item-main strong,
.history-item-main span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item-main span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.winner-label {
  max-width: 120px;
  overflow: hidden;
  padding: 5px 10px;
  border-radius: 999px;
  background: #202d2e;
  color: var(--muted);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.78rem;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.winner-label.winner-villager {
  background: rgba(78, 205, 196, 0.18);
  color: #5ce6dc;
  border-color: rgba(78, 205, 196, 0.4);
}

.winner-label.winner-werewolf {
  background: rgba(255, 107, 107, 0.18);
  color: #ff8585;
  border-color: rgba(255, 107, 107, 0.4);
}

.winner-label.winner-other {
  background: rgba(255, 217, 61, 0.18);
  color: #ffd93d;
  border-color: rgba(255, 217, 61, 0.4);
}

.empty-state.compact {
  min-height: 180px;
}

.export-panel pre {
  min-height: 260px;
  max-height: 52dvh;
  margin: 0;
  overflow: auto;
  white-space: pre-wrap;
  color: var(--ink);
  font-family: inherit;
  font-size: 0.88rem;
  line-height: 1.55;
}

.membership-dialog,
.status-dialog,
.board-manager-dialog,
.edit-dialog,
.action-dialog,
.history-edit-dialog,
.impression-dialog,
.role-guess-dialog,
.vote-dialog,
.player-relation-dialog,
.rival-perspective-dialog {
  width: min(760px, 100%);
  max-width: 100%;
  margin: auto auto 0;
  border: 0;
  border-radius: 8px 8px 0 0;
  padding: 0;
  background: transparent;
}

.role-composition-dialog {
  width: min(760px, 100%);
  max-width: 100%;
  margin: auto auto 0;
  border: 0;
  border-radius: 8px 8px 0 0;
  padding: 0;
  background: transparent;
}

.membership-dialog::backdrop,
.status-dialog::backdrop,
.board-manager-dialog::backdrop,
.edit-dialog::backdrop,
.action-dialog::backdrop,
.history-edit-dialog::backdrop,
.impression-dialog::backdrop,
.role-guess-dialog::backdrop,
.vote-dialog::backdrop,
.player-relation-dialog::backdrop,
.rival-perspective-dialog::backdrop {
  background: rgba(22, 35, 38, 0.42);
}

.role-composition-dialog::backdrop {
  background: rgba(22, 35, 38, 0.42);
}

.membership-dialog form,
.status-dialog form,
.board-manager-dialog form,
.edit-dialog form,
.action-dialog form,
.history-edit-dialog form,
.impression-dialog form,
.role-guess-dialog form,
.vote-dialog form,
.player-relation-dialog form,
.rival-perspective-dialog form {
  display: grid;
  gap: 13px;
  max-height: min(84dvh, 720px);
  overflow: auto;
  padding: 10px 14px calc(18px + env(safe-area-inset-bottom));
  border-radius: 8px 8px 0 0;
  background: var(--panel);
}

.role-composition-dialog form {
  display: grid;
  gap: 13px;
  max-height: min(92dvh, 820px);
  overflow: auto;
  padding: 10px 14px calc(18px + env(safe-area-inset-bottom));
  border-radius: 8px 8px 0 0;
  background: var(--panel);
}

.role-composition-editor {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.role-composition-camp {
  display: grid;
  align-content: start;
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(159, 176, 173, 0.18);
  border-radius: 7px;
  background: #0e1415;
}

.role-composition-camp.villager { border-top-color: #4a90e2; }
.role-composition-camp.werewolf { border-top-color: #b94b57; }
.role-composition-camp.third { border-top-color: #9b6bcc; }

.role-composition-rows {
  display: grid;
  gap: 6px;
}

.role-composition-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 40px;
}

.role-composition-row > span {
  overflow-wrap: anywhere;
  font-size: 0.84rem;
  font-weight: 800;
}

.role-count-stepper {
  display: grid;
  grid-template-columns: 34px 34px 34px;
  align-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.role-count-stepper button {
  min-height: 34px;
  background: #263637;
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 900;
}

.role-count-stepper output {
  text-align: center;
  font-weight: 900;
}

.role-composition-total,
.role-composition-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.role-composition-total span {
  font-size: 1rem;
  font-weight: 900;
}

.role-composition-actions > * {
  flex: 1 1 0;
}

@media (max-width: 620px) {
  .role-composition-editor {
    grid-template-columns: 1fr;
  }

  .role-composition-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .role-composition-actions .danger-button {
    grid-column: 1 / -1;
  }
}

.impression-dialog form {
  max-height: 92dvh;
}

.player-relation-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(112px, 0.7fr) auto;
  gap: 8px;
  align-items: end;
}

.relation-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.relation-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.relation-legend i {
  display: inline-block;
  background: #39b8c8;
}

.relation-legend-ally {
  width: 5px;
  height: 20px;
  border-radius: 3px;
}

.relation-legend-enemy {
  width: 16px;
  height: 3px;
  border-radius: 2px;
}

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

.player-relation-item {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  min-height: 46px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--paper);
}

.player-relation-swatch {
  display: block;
  background: var(--relation-color);
}

.player-relation-swatch.ally {
  width: 6px;
  height: 28px;
  border-radius: 3px;
}

.player-relation-swatch.enemy {
  width: 18px;
  height: 4px;
  border-radius: 2px;
}

.player-relation-names {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 900;
}

.player-relation-type {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

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

.board-list-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 6px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.board-list-item.active {
  border-color: var(--accent);
}

.board-select-button {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 4px;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.board-select-button strong,
.board-select-button span,
.board-select-button small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.board-select-button span,
.board-select-button small {
  color: var(--muted);
  font-size: 0.76rem;
}

.board-list-item .secondary-button,
.board-list-item .danger-button {
  min-height: 38px;
  padding-inline: 9px;
  font-size: 0.76rem;
}

@media (max-width: 520px) {
  .board-list-item {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .board-select-button {
    grid-row: span 2;
  }
}

.role-guess-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-role-guess-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.role-guess-camps-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.role-guess-camp-column {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.role-guess-camp-title {
  font-size: 0.78rem;
  font-weight: 900;
  padding: 2px 4px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  margin-bottom: 2px;
}

.villager-camp .role-guess-camp-title {
  color: #7ab8eb;
}

.werewolf-camp .role-guess-camp-title {
  color: #ff8d98;
}

.role-guess-third-camp {
  margin-top: 4px;
  padding-top: 6px;
  border-top: 1px dashed rgba(159, 176, 173, 0.2);
}

.role-guess-third-camp .role-guess-camp-title {
  color: #d9c5ff;
}

.role-guess-third-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-top: 4px;
}

.wolf-mode-entry-hint {
  min-height: 42px;
  display: grid;
  align-items: center;
  padding: 9px 11px;
  border: 1px solid rgba(185, 75, 87, 0.48);
  border-radius: 8px;
  background: #241114;
  color: #ffd9dc;
  font-size: 0.86rem;
  font-weight: 900;
}

.wolf-mode-entry-hint.active {
  border-color: rgba(185, 75, 87, 0.82);
  background: #35191d;
}

.wolf-mode-entry-hint.disabled {
  border-color: var(--line);
  background: var(--paper);
  color: var(--muted);
}

.role-guess-option,
.history-role-guess-option {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 42px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 900;
}

.role-guess-option:has(input:checked),
.history-role-guess-option:has(input:checked) {
  border-color: currentColor;
  filter: brightness(1.15);
}

.role-guess-option input,
.history-role-guess-option input {
  width: 18px;
  min-height: 18px;
  height: 18px;
  padding: 0;
}

.impression-summary {
  display: grid;
  place-items: center;
  min-height: 46px;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 900;
}

.impression-reason-section,
.custom-reason-section {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.impression-reason-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.impression-reason-option,
.history-impression-option {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 42px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 900;
}

.impression-reason-option:has(input:checked),
.history-impression-option:has(input:checked) {
  border-color: currentColor;
}

.impression-reason-option.villager:has(input:checked),
.history-impression-option.villager:has(input:checked) {
  background: #183755;
  color: #a9d7ff;
}

.impression-reason-option.werewolf:has(input:checked),
.history-impression-option.werewolf:has(input:checked) {
  background: #43272c;
  color: var(--wolf);
}

.impression-reason-option input,
.history-impression-option input {
  width: 18px;
  min-height: 18px;
  height: 18px;
  padding: 0;
}

.custom-reason-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px auto;
  gap: 7px;
}

.custom-reason-list {
  display: grid;
  gap: 6px;
}

.custom-reason-item {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 900;
}

.custom-reason-item .danger-button {
  min-height: 34px;
  padding-inline: 10px;
  font-size: 0.78rem;
}

.impression-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}

.impression-dot.villager {
  background: #a9d7ff;
}

.impression-dot.werewolf {
  background: var(--wolf);
}

.history-edit-dialog form {
  max-height: 92dvh;
}

.history-meta-grid,
.history-player-editor,
.history-result-editor,
.history-role-action-editor,
.history-vote-editor,
.role-action-list {
  display: grid;
  gap: 8px;
}

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

.history-player-edit,
.history-result-edit,
.history-role-action-edit,
.vote-edit-row,
.role-action-edit {
  display: grid;
  gap: 7px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.role-action-edit {
  grid-template-columns: 68px minmax(0, 1fr);
}

.role-action-edit [data-field="result"],
.role-action-edit [data-field="note"],
.role-action-edit .danger-button {
  grid-column: 1 / -1;
}

.history-role-action-edit {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.history-role-action-edit [data-field="note"],
.history-role-action-edit .danger-button {
  grid-column: 1 / -1;
}

.vote-entry-grid {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
}

.vote-entry-grid .primary-button {
  min-height: 44px;
}

.vote-mode-notice {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin: 8px 0 10px;
  padding: 9px 11px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.62);
  color: var(--muted);
  font-size: 0.82rem;
}

.vote-mode-notice strong {
  color: #e5e7eb;
  font-size: 0.9rem;
}

.vote-mode-notice.runoff {
  border-color: rgba(245, 158, 11, 0.58);
  background: rgba(59, 50, 28, 0.72);
  color: #fde68a;
}

.runoff-quick-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 8px 0 10px;
  padding: 10px;
  border: 1px solid rgba(245, 158, 11, 0.38);
  border-radius: 8px;
  background: rgba(24, 18, 10, 0.72);
}

.runoff-quick-section {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.runoff-quick-section strong {
  color: #fde68a;
  font-size: 0.8rem;
}

.runoff-helper {
  color: #facc15;
  font-size: 0.78rem;
}

.runoff-target-list,
.runoff-voter-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.runoff-target-button,
.runoff-voter-button {
  min-height: 36px;
  padding: 7px 11px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 999px;
  background: #263637;
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 800;
}

.runoff-target-button.is-selected {
  border-color: rgba(245, 158, 11, 0.84);
  background: #4b3716;
  color: #fde68a;
}

.runoff-voter-button {
  background: #123f2e;
}

.runoff-voter-button.is-selected {
  border-color: rgba(96, 165, 250, 0.72);
  background: #183755;
}

.runoff-voter-button:disabled {
  opacity: 0.48;
}

.runoff-confirm-button {
  align-self: stretch;
  min-height: 40px;
}

.vote-summary-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 10px 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font-size: 0.86rem;
  line-height: 1.45;
}

.vote-day-summary {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 10px 12px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.74);
}

.vote-day-summary.is-current {
  border-color: rgba(96, 165, 250, 0.52);
  box-shadow: inset 0 0 0 1px rgba(96, 165, 250, 0.18);
}

.vote-day-summary-title {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.vote-day-summary-title strong {
  color: #e5e7eb;
  font-size: 0.9rem;
}

.vote-day-summary-title span {
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(96, 165, 250, 0.16);
  color: #bfdbfe;
  font-size: 0.72rem;
  font-weight: 800;
}

.vote-phase-summary {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.vote-phase-summary + .vote-phase-summary {
  margin-top: 8px;
  padding-top: 9px;
  border-top: 1px solid rgba(148, 163, 184, 0.18);
}

.vote-phase-title {
  color: #e5e7eb;
  font-size: 0.82rem;
  font-weight: 900;
}

.vote-history-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  margin: 10px 0 6px;
}

.vote-history-toolbar strong {
  color: var(--muted);
  font-size: 0.82rem;
}

.vote-history-toolbar .ghost-button {
  min-height: 34px;
  padding: 7px 11px;
  font-size: 0.78rem;
}

.vote-summary-panel strong {
  font-size: 0.78rem;
  color: var(--muted);
}

.vote-summary-section {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.vote-summary-section + .vote-summary-section {
  margin-top: 5px;
  padding-top: 9px;
  border-top: 1px solid rgba(148, 163, 184, 0.18);
}

.vote-order-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.vote-order-item {
  display: grid;
  grid-template-columns: 1.6rem minmax(0, 1fr);
  gap: 4px;
  align-items: start;
}

.vote-order-item.no-order {
  grid-template-columns: minmax(0, 1fr);
}

.vote-order-item.is-decisive {
  margin: -2px -4px;
  padding: 4px;
  border-radius: 5px;
  background: rgba(250, 204, 21, 0.13);
  color: #fef3c7;
}

.vote-order-text {
  min-width: 0;
}

.vote-decisive-badge {
  display: inline-block;
  margin-left: 7px;
  padding: 1px 6px;
  border: 1px solid rgba(250, 204, 21, 0.72);
  border-radius: 999px;
  background: rgba(250, 204, 21, 0.2);
  color: #fde68a;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1.35;
}

.vote-order-number {
  color: #f8fafc;
  font-weight: 700;
  text-align: center;
}

.vote-summary-empty {
  color: var(--muted);
}

.vote-name-confirmed-werewolf {
  color: #ff6b78;
  font-weight: 900;
}

.vote-edit-row {
  grid-template-columns: 60px 60px 92px minmax(0, 1fr) minmax(0, 1fr) auto;
  align-items: center;
}

.vote-edit-row.is-runoff {
  grid-template-columns: 60px 92px minmax(0, 1fr) minmax(0, 1fr) auto;
}

.history-player-edit {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.history-player-edit strong,
.history-player-edit [data-field="memo"] {
  grid-column: 1 / -1;
}

.history-player-edit [data-field="name"] {
  grid-column: span 2;
  font-weight: 900;
}

.history-impression-edit {
  grid-column: 1 / -1;
  display: grid;
  gap: 7px;
}

.history-role-guess-edit {
  grid-column: 1 / -1;
  display: grid;
  gap: 8px;
}

.history-role-guess-options {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.history-role-guess-option {
  min-height: 36px;
  font-size: 0.74rem;
}

.history-impression-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.history-impression-option {
  min-height: 36px;
  font-size: 0.74rem;
}

.history-participation {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 44px;
  color: var(--muted);
  font-weight: 900;
}

.history-participation input {
  width: 20px;
  min-height: 20px;
  height: 20px;
  padding: 0;
}

.history-result-edit {
  grid-template-columns: repeat(2, minmax(0, 1fr)) 64px 92px auto;
  align-items: center;
}

.history-result-edit span {
  overflow: hidden;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty-inline {
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.membership-options {
  display: grid;
  gap: 8px;
}

.membership-option {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  font-weight: 900;
}

.membership-option input {
  width: 20px;
  min-height: 20px;
  height: 20px;
  padding: 0;
}

.status-actions {
  display: grid;
  gap: 9px;
}

.board-action-choices {
  display: grid;
  gap: 9px;
}

.board-action-choice {
  display: grid;
  gap: 5px;
  min-height: 72px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  text-align: left;
}

.board-action-choice strong {
  font-size: 1rem;
}

.board-action-choice span {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.board-action-choice.danger {
  border-color: #73373d;
}

.board-action-choice.danger strong {
  color: var(--wolf);
}

.status-choice {
  min-height: 52px;
  border-radius: 8px;
  font-size: 1.05rem;
  font-weight: 900;
}

.status-choice.exiled {
  background: #283233;
  color: var(--inactive);
}

.status-choice.attacked {
  background: #43272c;
  color: var(--wolf);
}

.status-choice.alive {
  background: #12372f;
  color: var(--human);
}

.sheet-handle {
  justify-self: center;
  width: 46px;
  height: 5px;
  border-radius: 999px;
  background: #536160;
}

.sheet-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

.field span,
.field-title {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 900;
}

.field-group {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

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

.adopted-medium-field {
  margin-top: 8px;
}

.seer-perspective-result-list {
  display: grid;
  gap: 8px;
}

.seer-perspective-result-card {
  display: grid;
  gap: 4px;
}

.seer-perspective-result-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(120px, 0.8fr);
  gap: 8px;
  align-items: center;
}

.seer-perspective-result-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 900;
}

.medium-perspective-result-list {
  display: grid;
  gap: 8px;
}

.medium-perspective-result-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(120px, 0.8fr);
  gap: 8px;
  align-items: center;
}

.medium-perspective-result-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 900;
}

.attack-rule-badge {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 11px;
  border: 1px solid rgba(159, 176, 173, 0.28);
  border-radius: 7px;
  background: #151d1e;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.attack-rule-field {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
  margin: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.attack-rule-field legend {
  padding: 0 4px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 900;
}

.attack-rule-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  padding: 6px 9px;
  border: 1px solid rgba(159, 176, 173, 0.22);
  border-radius: 7px;
  background: #111819;
  font-size: 0.82rem;
  font-weight: 800;
}

.attack-rule-toggle input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: #b94b57;
}

.finish-true-role-fields {
  display: grid;
  gap: 8px;
}

.finish-true-role-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(130px, 0.9fr);
  align-items: center;
  gap: 8px;
}

.finish-true-role-field span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 900;
}

.finish-role-actions {
  display: flex;
  justify-content: flex-end;
}

.finish-true-role-field.invalid select,
select.invalid,
input.invalid {
  border-color: #d45b66;
  box-shadow: 0 0 0 2px rgba(212, 91, 102, 0.18);
}

.finish-game-error {
  padding: 11px 12px;
  border: 1px solid #b94b57;
  border-radius: 8px;
  background: #241114;
  color: #ffd9dc;
  font-size: 0.84rem;
  line-height: 1.45;
}

.finish-game-error strong {
  display: block;
  margin-bottom: 5px;
}

.finish-game-error ul {
  margin: 0;
  padding-left: 1.3em;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(76px + env(safe-area-inset-bottom));
  z-index: 30;
  max-width: calc(100% - 28px);
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  padding: 10px 13px;
  border-radius: 999px;
  background: #eef6f4;
  color: #101718;
  font-size: 0.9rem;
  font-weight: 900;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

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

  .setup-panel {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    align-items: center;
  }

  .participant-row {
    grid-template-columns: minmax(0, 1fr) 124px 42px;
  }

  .seer-grid {
    grid-column: auto;
  }

  .order-button {
    width: 36px;
  }

  body[data-active-view="reasoning"] .app-shell {
    max-width: none;
    padding-inline: 16px;
  }

  body[data-active-view="reasoning"] .bottom-bar {
    width: calc(100% - 32px);
  }

  body[data-active-view="reasoning"] .player-row {
    grid-template-columns: minmax(0, 1fr) 74px 38px;
    gap: 6px;
    padding: 6px 8px;
    min-height: 54px;
  }

  body[data-active-view="reasoning"] .player-info {
    grid-template-columns: 216px minmax(0, 1fr);
    gap: 6px;
  }

  body[data-active-view="reasoning"] .player-name {
    font-size: 0.95rem;
  }

  body[data-active-view="reasoning"] .role-guess-label {
    width: 96px;
    min-height: 32px;
    padding: 5px 8px;
    font-size: 0.82rem;
  }

  body[data-active-view="reasoning"] .seer-grid {
    grid-template-columns: repeat(var(--seer-columns), minmax(90px, 1fr));
    gap: 4px;
    padding: 4px 6px;
    min-height: 36px;
    overflow-x: auto;
  }

  body[data-active-view="reasoning"] .seer-result-label {
    min-height: 30px;
    padding: 4px 6px;
    font-size: 0.82rem;
  }

  body[data-active-view="reasoning"] .status-button {
    min-height: 38px;
    font-size: 0.76rem;
    padding: 4px 6px;
  }

  body[data-active-view="reasoning"] .order-actions {
    gap: 3px;
  }

  body[data-active-view="reasoning"] .order-button {
    width: 36px;
    height: 24px;
    font-size: 0.82rem;
  }
}

@media (min-width: 960px) {
  .app-shell {
    padding-inline: 24px;
  }

  body[data-active-view="reasoning"] .app-shell {
    padding-inline: 24px;
  }

  body[data-active-view="reasoning"] .bottom-bar {
    width: calc(100% - 48px);
  }

  body[data-active-view="reasoning"] .player-row {
    grid-template-columns: minmax(0, 1fr) 82px 42px;
    gap: 8px;
    padding: 6px 12px;
  }

  body[data-active-view="reasoning"] .player-info {
    grid-template-columns: 256px minmax(0, 1fr);
    gap: 10px;
  }

  body[data-active-view="reasoning"] .player-name {
    font-size: 1.05rem;
  }

  body[data-active-view="reasoning"] .role-guess-label {
    width: 110px;
    min-height: 36px;
    padding: 6px 10px;
    font-size: 0.88rem;
  }

  body[data-active-view="reasoning"] .seer-grid {
    grid-template-columns: repeat(var(--seer-columns), minmax(116px, 1fr));
    gap: 6px;
    padding: 6px 8px;
    min-height: 40px;
  }

  body[data-active-view="reasoning"] .seer-result-label {
    min-height: 34px;
    padding: 6px 10px;
    font-size: 0.92rem;
  }

  body[data-active-view="reasoning"] .status-button {
    min-height: 44px;
    font-size: 0.82rem;
  }

  body[data-active-view="reasoning"] .order-button {
    width: 40px;
    height: 28px;
    font-size: 0.95rem;
  }
}

@media (max-width: 520px) {
  .app-header {
    align-items: flex-start;
  }

  .game-controls {
    max-width: 190px;
  }

  .game-status-badge {
    width: 100%;
  }

  #reasoningView .table-panel {
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
  }

  #reasoningView .player-rows {
    width: max-content;
    min-width: 100%;
  }

  #reasoningView .player-row {
    width: max-content;
    min-width: 672px;
    grid-template-columns: 92px max-content 76px 38px;
    gap: 4px;
    min-height: 50px;
    padding: 3px 5px 3px 0;
  }

  #reasoningView .sticky-player-name {
    position: sticky;
    left: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 4px;
    width: 92px;
    height: 44px;
    padding: 0 6px 0 8px;
    border-right: 1px solid var(--line);
    border-radius: 0;
    background: #070a0b;
    color: inherit;
    overflow: hidden;
    text-align: left;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.88rem;
    font-weight: 900;
  }

  #reasoningView .sticky-player-name-text {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #reasoningView .sticky-player-name .player-ally-marker {
    height: 24px;
  }

  #reasoningView .sticky-player-name .player-enemy-markers {
    height: 24px;
  }

  #reasoningView .player-status-exiled .sticky-player-name {
    background: #202829;
    text-decoration: line-through;
  }

  #reasoningView .player-status-attacked .sticky-player-name {
    background: #3a2025;
    text-decoration: line-through;
  }

  #reasoningView .player-info {
    width: max-content;
    grid-template-columns: max-content max-content;
    gap: 2px;
    min-height: 42px;
  }

  #reasoningView .player-main {
    grid-template-columns: max-content;
    align-items: center;
    gap: 4px;
  }

  #reasoningView .player-name-row {
    flex-wrap: nowrap;
    gap: 4px;
    overflow: hidden;
  }

  #reasoningView .player-name {
    display: none;
  }

  #reasoningView .player-name-row > .player-ally-marker,
  #reasoningView .player-name-row > .player-enemy-markers {
    display: none;
  }

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

  .player-relation-entry .primary-button {
    min-height: 44px;
  }

  #reasoningView .role-guess-label,
  #reasoningView .true-role-label {
    min-height: 28px;
    padding: 4px 7px;
    font-size: 0.7rem;
  }

  #reasoningView .role-guess-label {
    width: max-content;
    min-width: 84px;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #reasoningView .seer-grid {
    grid-column: auto;
    width: max(380px, calc(var(--seer-columns) * 118px));
    height: 38px;
    grid-template-columns: repeat(var(--seer-columns), minmax(114px, 1fr));
    gap: 3px;
    padding: 3px 4px;
    overflow: hidden;
  }

  #reasoningView .seer-result-label {
    min-height: 30px;
    padding: 4px 6px;
    font-size: 0.72rem;
  }

  #reasoningView .impression-button,
  #reasoningView .status-button {
    min-height: 30px;
    padding: 3px;
    font-size: 0.64rem;
  }

  #reasoningView .order-actions {
    gap: 3px;
  }

  #reasoningView .order-button {
    width: 32px;
    height: 22px;
    font-size: 0.76rem;
  }

  .history-meta-grid,
  .history-player-edit,
  .history-result-edit,
  .vote-entry-grid,
  .vote-edit-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .history-player-edit strong,
  .history-player-edit [data-field="memo"] {
    grid-column: 1 / -1;
  }

  .history-player-edit [data-field="name"] {
    grid-column: 1 / -1;
  }

  .history-result-edit .danger-button {
    grid-column: 1 / -1;
  }

  .vote-edit-row .danger-button {
    grid-column: 1 / -1;
  }

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

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

  .custom-reason-form {
    grid-template-columns: 1fr 1fr;
  }

  .custom-reason-form input {
    grid-column: 1 / -1;
  }

  .history-impression-options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .participant-row .player-name-row {
    flex-wrap: wrap;
  }

  .history-role-guess-options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .history-role-action-edit {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.role-guess-label.impression-villager {
  box-shadow: inset 0 0 0 1.5px rgba(78, 205, 196, 0.7);
}
.role-guess-label.impression-strong_villager {
  box-shadow: inset 0 0 0 2.5px #4ecdc4;
}
.role-guess-label.impression-werewolf {
  box-shadow: inset 0 0 0 1.5px rgba(255, 107, 107, 0.7);
}
.role-guess-label.impression-strong_werewolf {
  box-shadow: inset 0 0 0 2.5px #ff6b6b;
}

/* History detail panel layout */
#historyDetailPanel {
  display: grid;
  gap: 10px;
}

/* History detail board preview in reasoning tab style */
.history-detail-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  padding: 12px 14px;
  border-radius: 7px;
  background: #111a1b;
  border: 1px solid var(--line);
}

.history-meta-title h3 {
  margin: 0 0 3px;
  font-size: 1.05rem;
  color: var(--ink);
}

.history-event-date {
  font-size: 0.78rem;
  color: var(--muted);
}

.history-counts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.winner-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 800;
}

.winner-badge.winner-villager {
  background: rgba(78, 205, 196, 0.16);
  color: #5ce6dc;
  border: 1px solid rgba(78, 205, 196, 0.35);
}

.winner-badge.winner-werewolf {
  background: rgba(255, 107, 107, 0.16);
  color: #ff7b7b;
  border: 1px solid rgba(255, 107, 107, 0.35);
}

.winner-badge.winner-other {
  background: rgba(255, 217, 61, 0.16);
  color: #ffd93d;
  border: 1px solid rgba(255, 217, 61, 0.35);
}

.history-table-panel {
  min-height: auto;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: #070a0b;
}

.history-table-panel .player-rows {
  width: max-content;
  min-width: 100%;
}

.history-table-panel .player-row {
  width: max-content;
  min-width: 630px;
  grid-template-columns: 92px max-content 76px;
  gap: 4px;
  min-height: 48px;
  padding: 3px 5px 3px 0;
  cursor: default;
}

.history-table-panel .sticky-player-name {
  position: sticky;
  left: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 4px;
  width: 92px;
  height: 44px;
  padding: 0 6px 0 8px;
  border-right: 1px solid var(--line);
  background: #070a0b;
  color: inherit;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.88rem;
  font-weight: 900;
}

.history-table-panel .sticky-player-name-text {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-table-panel .player-status-exiled .sticky-player-name {
  background: #202829;
  text-decoration: line-through;
}

.history-table-panel .player-status-attacked .sticky-player-name {
  background: #3a2025;
  text-decoration: line-through;
}

.history-table-panel .player-info {
  width: max-content;
  grid-template-columns: max-content max-content;
  gap: 2px;
  min-height: 42px;
  cursor: default;
}

.history-table-panel .player-main {
  grid-template-columns: max-content;
  align-items: center;
  gap: 4px;
}

.history-table-panel .player-name-row {
  flex-wrap: nowrap;
  gap: 4px;
  overflow: hidden;
}

.history-table-panel .player-name {
  display: none;
}

.history-table-panel .player-name-row > .player-ally-marker,
.history-table-panel .player-name-row > .player-enemy-markers {
  display: none;
}

.history-table-panel .role-guess-label,
.history-table-panel .true-role-label {
  min-height: 28px;
  padding: 4px 7px;
  font-size: 0.7rem;
}

.history-table-panel .role-guess-label {
  width: max-content;
  min-width: 84px;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-table-panel .seer-grid {
  grid-column: auto;
  width: max(380px, calc(var(--seer-columns) * 118px));
  height: 38px;
  grid-template-columns: repeat(var(--seer-columns), minmax(114px, 1fr));
  gap: 3px;
  padding: 3px 4px;
}

.history-timeline-section {
  display: grid;
  gap: 8px;
  margin-top: 6px;
}

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

.history-timeline-day {
  padding: 10px 14px;
  border-radius: 7px;
  background: #111a1b;
  border: 1px solid var(--line);
}

.history-timeline-day h4 {
  margin: 0 0 6px;
  font-size: 0.88rem;
  color: #4ecdc4;
}

.history-timeline-day ul {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 4px;
  font-size: 0.84rem;
  color: var(--ink);
}
