:root {
  --bg: #111318;
  --panel: #1b1f2a;
  --panel2: #242a38;
  --text: #f6f7fb;
  --muted: #aab1c5;
  --line: #343b4f;
  --primary: #8ab4ff;
  --primaryText: #07111f;
  --danger: #ff7b8a;
  --warning: #ffd166;
  --ok: #66d19e;
  --shadow: rgba(0, 0, 0, 0.28);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: radial-gradient(circle at top left, #25304a, var(--bg) 45%);
  color: var(--text);
  min-height: 100vh;
}

button, input, select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 14px;
  padding: 0.72rem 1rem;
  cursor: pointer;
  font-weight: 700;
  transition: transform 0.08s ease, opacity 0.12s ease, background 0.12s ease;
}

button:active { transform: translateY(1px); }
button:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

input, select {
  width: 100%;
  border: 1px solid var(--line);
  background: #111722;
  color: var(--text);
  border-radius: 12px;
  padding: 0.72rem 0.8rem;
  outline: none;
}

input:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(138, 180, 255, 0.16);
}

h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(1.5rem, 6vw, 2.3rem); margin-bottom: 0.25rem; }
h2 { font-size: 1.25rem; margin-bottom: 1rem; }
h3 { font-size: 1rem; color: var(--muted); }
p, li { color: var(--muted); line-height: 1.5; }

.shell {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 1rem;
}

.shell.narrow { width: min(760px, 100%); }

.hero, .topbar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  padding: 1rem 0;
}

.card {
  background: linear-gradient(180deg, rgba(255,255,255,0.035), rgba(255,255,255,0.01)), var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 1rem;
  box-shadow: 0 14px 36px var(--shadow);
  margin-bottom: 1rem;
}

.grid {
  display: grid;
  gap: 1rem;
}

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

.wide { grid-column: 1 / -1; }

.field {
  display: grid;
  gap: 0.35rem;
  margin-bottom: 0.8rem;
}

.field span {
  color: var(--muted);
  font-size: 0.92rem;
}

.field.compact {
  min-width: 150px;
  margin: 0;
}

.check-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
  margin: 0.6rem 0 1rem;
}

.check-grid label {
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.72rem;
  color: var(--text);
}

.check-grid input { width: auto; margin-right: 0.45rem; }

.primary { background: var(--primary); color: var(--primaryText); }
.secondary { background: var(--panel2); color: var(--text); border: 1px solid var(--line); }
.danger { background: var(--danger); color: #24070b; }
.warning { background: var(--warning); color: #211500; }
.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.mark-on { background: var(--ok); color: #062012; }
.full { width: 100%; }
.tiny { padding: 0.38rem 0.58rem; border-radius: 10px; font-size: 0.82rem; }

.button-row {
  display: flex;
  gap: 0.55rem;
  align-items: center;
}

.button-row.wrap { flex-wrap: wrap; }

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
  color: var(--muted);
  font-size: 0.92rem;
  margin-top: 0.25rem;
}

.right-tools {
  display: grid;
  gap: 0.6rem;
  justify-items: end;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.22rem 0.55rem;
  background: var(--panel2);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 800;
  vertical-align: middle;
}
.badge.ok { background: rgba(102, 209, 158, 0.15); color: var(--ok); border-color: rgba(102, 209, 158, 0.35); }
.badge.danger { background: rgba(255, 123, 138, 0.15); color: var(--danger); border-color: rgba(255, 123, 138, 0.35); }
.badge.phase { background: rgba(138, 180, 255, 0.14); color: var(--primary); border-color: rgba(138, 180, 255, 0.35); }

.notice {
  border: 1px solid rgba(255, 209, 102, 0.45);
  background: rgba(255, 209, 102, 0.13);
  color: #ffe3a0;
  padding: 0.85rem 1rem;
  border-radius: 18px;
  margin-bottom: 1rem;
  font-weight: 800;
}

.secret {
  background: #101620;
  border: 1px dashed rgba(138, 180, 255, 0.45);
  border-radius: 18px;
  padding: 1rem;
  margin: 1rem 0;
}

.secret.hidden-role {
  filter: blur(0.2px);
}

.secret .label {
  color: var(--muted);
  font-size: 0.9rem;
}

.role-name {
  font-size: 1.45rem;
  font-weight: 900;
  margin-top: 0.25rem;
}

.player-list, .gm-list {
  display: grid;
  gap: 0.6rem;
}

.row {
  display: flex;
  justify-content: space-between;
  gap: 0.7rem;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: 0.55rem 0;
}

.compact-list .row {
  flex-wrap: wrap;
}

.player-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 0.85rem;
}

.player-card.gm {
  border-color: rgba(138, 180, 255, 0.5);
}

.player-main {
  display: flex;
  justify-content: space-between;
  gap: 0.7rem;
  align-items: flex-start;
}

.player-main h3 { color: var(--text); margin-bottom: 0.35rem; }
.player-main p { margin-bottom: 0.4rem; }
.seat-tools { display: flex; gap: 0.35rem; }
.muted { color: var(--muted); }

.instruction {
  font-size: 1.2rem;
  font-weight: 900;
  line-height: 1.45;
  background: #101620;
  border-radius: 18px;
  padding: 1rem;
  margin-bottom: 0.8rem;
}

.mini-alert {
  margin-top: 0.5rem;
  background: rgba(255, 209, 102, 0.12);
  border: 1px solid rgba(255, 209, 102, 0.34);
  border-radius: 14px;
  padding: 0.55rem;
  color: #ffe5a8;
  display: flex;
  gap: 0.5rem;
  align-items: center;
  justify-content: space-between;
}
.mini-alert.used {
  background: rgba(102, 209, 158, 0.12);
  border-color: rgba(102, 209, 158, 0.34);
  color: #bdf1d9;
}

.night-marks {
  margin: 0.5rem 0;
}

.alert-card {
  border-color: rgba(255, 209, 102, 0.36);
}

.pending {
  display: flex;
  justify-content: space-between;
  gap: 0.7rem;
  align-items: center;
  border-top: 1px solid var(--line);
  padding: 0.75rem 0;
}

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; border-bottom: 1px solid var(--line); padding: 0.6rem; }
th { color: var(--muted); font-size: 0.86rem; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 1rem;
  transform: translateX(-50%);
  background: #f6f7fb;
  color: #101318;
  padding: 0.8rem 1rem;
  border-radius: 16px;
  box-shadow: 0 12px 28px var(--shadow);
  font-weight: 800;
  z-index: 50;
  max-width: calc(100vw - 2rem);
}

@media (max-width: 820px) {
  .grid.two { grid-template-columns: 1fr; }
  .hero, .topbar { flex-direction: column; }
  .right-tools { justify-items: stretch; width: 100%; }
  .field.compact { width: 100%; }
  .check-grid { grid-template-columns: 1fr; }
  .button-row { align-items: stretch; }
  .button-row.wrap, .button-row { flex-wrap: wrap; }
  .button-row > button, .button-row > select { flex: 1 1 auto; }
  .player-main { flex-direction: column; }
  .seat-tools { width: 100%; }
  .seat-tools button { flex: 1; }
  .pending { flex-direction: column; align-items: stretch; }
}

.rules-box {
  max-height: 460px;
  overflow: auto;
  padding-right: 0.35rem;
}

.rule-section {
  border-bottom: 1px solid var(--line);
  padding: 0.65rem 0;
}

.rule-section:last-child {
  border-bottom: 0;
}

.rule-section h4 {
  margin: 0 0 0.45rem;
  color: var(--text);
  font-size: 1rem;
}

.rule-section p {
  margin-bottom: 0.55rem;
}
