:root {
  --bg: #0d111c;
  --surface: #151b2a;
  --surface-2: #1c2436;
  --line: #2a3449;
  --text: #e7eaf3;
  --muted: #8e98b0;
  --accent: #e8b44c;
  --accent-ink: #1a1405;
  --wolf: #e2665e;
  --wolf-bg: rgba(226, 102, 94, .12);
  --good: #63c08f;
  --priv: #a58bf0;
  --priv-bg: rgba(165, 139, 240, .12);
  --god: #5fa8d3;
  --god-bg: rgba(95, 168, 211, .10);
  --radius: 12px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
        "Noto Sans CJK SC", "Source Han Sans SC", sans-serif;
  -webkit-text-size-adjust: 100%;
}
[hidden] { display: none !important; }
button, input, textarea { font: inherit; color: inherit; }
h1, h2 { margin: 0; font-weight: 650; }

#app { height: 100dvh; max-width: 720px; margin: 0 auto; }
.screen { height: 100%; display: flex; flex-direction: column; }
.screen.center { justify-content: center; align-items: center; padding: 16px; }
.pad { padding: 12px 16px; }
.scroll { overflow-y: auto; flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.err { color: var(--wolf); min-height: 1.5em; margin: 8px 0 0; font-size: 14px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card > p:first-child { margin-top: 0; }
.card.narrow { width: 100%; max-width: 360px; text-align: center; }
.card h1 { font-size: 24px; margin: 8px 0 4px; }
.moon {
  width: 56px; height: 56px; margin: 0 auto; border-radius: 50%;
  box-shadow: inset -14px -6px 0 0 var(--accent);
  transform: rotate(-20deg);
}

.field { display: block; text-align: left; margin: 14px 0; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
input, textarea {
  width: 100%; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; outline: none;
}
input:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: none; }

.btn {
  appearance: none; border: 1px solid var(--line); background: var(--surface-2); border-radius: 10px;
  padding: 10px 16px; cursor: pointer; min-height: 44px; white-space: nowrap;
}
.btn:hover { border-color: #3a4763; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 650; }
.btn.danger { background: var(--wolf); border-color: var(--wolf); color: #fff; font-weight: 650; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.btn.block { display: block; width: 100%; margin-top: 10px; }
.btn:focus-visible, .chip:focus-visible, .seat:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: var(--surface-2); border-radius: 999px; padding: 6px 14px;
  cursor: pointer; min-height: 36px;
}
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }

.bar {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px; min-height: 52px;
  border-bottom: 1px solid var(--line); background: var(--surface); flex-shrink: 0;
}
.bar .title { font-size: 18px; flex: 1; padding-left: 4px; }
.phase { flex: 1; text-align: center; font-weight: 600; }
.phase .sub { display: block; font-size: 12px; font-weight: 400; color: var(--muted); }
.role-btn.wolf { border-color: var(--wolf); color: var(--wolf); }
.role-btn.good { border-color: var(--good); color: var(--good); }
.h2 { font-size: 15px; margin: 20px 0 8px; color: var(--muted); }

.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.list li button {
  width: 100%; text-align: left; display: flex; justify-content: space-between; gap: 8px; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; cursor: pointer;
}
.win-good { color: var(--good); }
.win-wolf { color: var(--wolf); }

/* 座位 */
.seats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 8px 12px;
  border-bottom: 1px solid var(--line); flex-shrink: 0;
}
.seat {
  position: relative; display: flex; align-items: center; gap: 6px; min-width: 0; min-height: 40px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 4px 6px;
  text-align: left; cursor: default;
}
.seat .no {
  flex-shrink: 0; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface-2); font-size: 13px; font-weight: 650;
}
.seat .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.seat .badge { flex-shrink: 0; font-size: 11px; padding: 1px 5px; border-radius: 6px; border: 1px solid currentColor; }
.seat .badge.wolf { color: var(--wolf); }
.seat .badge.good { color: var(--good); }
.seat .badge.tag-gold { color: var(--accent); }
.seat.you { border-color: var(--accent); }
.seat.you .no { background: var(--accent); color: var(--accent-ink); }
.seat.dead { opacity: .45; }
.seat.dead .nm { text-decoration: line-through; }
.seat.busy::after {
  content: ""; position: absolute; right: 4px; top: 4px; width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent); animation: blink 1s infinite;
}
.seat.pickable { cursor: pointer; border-color: rgba(232, 180, 76, .6); border-style: dashed; }
.seat.pickable:hover { border-color: var(--accent); }
.seat.picked { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.seat.picked .no { background: var(--accent-ink); color: var(--accent); }
@keyframes blink { 50% { opacity: .2; } }

/* 消息 */
.log { flex: 1; overflow-y: auto; padding: 10px 12px 16px; display: flex; flex-direction: column; gap: 8px; }
.sys { text-align: center; color: var(--muted); font-size: 13px; padding: 0 8px; }
.sys.strong { color: var(--text); }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; margin: 6px 0 2px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.divider.night { color: #8fa3d6; }
.divider.day { color: var(--accent); }
.msg { display: flex; gap: 8px; align-items: flex-start; max-width: 92%; }
.msg .av {
  flex-shrink: 0; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--line); font-size: 13px; font-weight: 650;
}
.msg .who { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.msg .who .lw { color: var(--wolf); margin-left: 4px; }
.msg .bubble {
  background: var(--surface); border: 1px solid var(--line); border-radius: 4px 12px 12px 12px;
  padding: 7px 11px; word-break: break-word; white-space: pre-wrap;
}
.msg.me { align-self: flex-end; flex-direction: row-reverse; }
.msg.me .who { text-align: right; }
.msg.me .av { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.msg.me .bubble { background: #2a2414; border-color: #5a4a22; border-radius: 12px 4px 12px 12px; }
.box { border-radius: 10px; padding: 8px 12px; font-size: 14px; border: 1px solid; }
.box .lbl { font-size: 11px; opacity: .85; display: block; margin-bottom: 2px; }
.box.priv { background: var(--priv-bg); border-color: rgba(165, 139, 240, .35); color: #d9ccff; }
.box.wolfc { background: var(--wolf-bg); border-color: rgba(226, 102, 94, .35); color: #ffd5d1; }
.box.god { background: var(--god-bg); border-color: rgba(95, 168, 211, .35); color: #cfe8f7; }
.box.over { background: rgba(232, 180, 76, .12); border-color: rgba(232, 180, 76, .45); color: var(--text); }
.thought {
  margin: -4px 0 0 38px; font-size: 13px; color: #9fb0cf; border-left: 2px solid var(--line); padding: 2px 0 2px 8px;
}
.thought .lbl { color: var(--muted); font-size: 11px; margin-right: 4px; }
.hide-thoughts .thought { display: none; }

/* 状态 + 操作 */
.status { min-height: 0; padding: 0 12px; font-size: 13px; color: var(--muted); flex-shrink: 0; }
.status:not(:empty) { padding: 6px 12px; border-top: 1px solid var(--line); }
.dots::after { content: "…"; animation: blink 1.2s infinite; }
.action {
  flex-shrink: 0; border-top: 1px solid var(--line); background: var(--surface);
  padding: 10px 12px calc(10px + var(--safe-b));
}
.action:empty { display: none; }
.action .hint { font-size: 14px; margin-bottom: 8px; }
.action .hint b { color: var(--accent); }
.action .row { display: flex; gap: 8px; flex-wrap: wrap; }
.action .row .btn { flex: 1; }
.action textarea { margin-bottom: 8px; }
.sugg { font-size: 13px; color: #ffd5d1; margin: 0 0 8px; padding-left: 16px; }
.sugg li { margin: 2px 0; }

/* 底部弹层 */
.sheet { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); display: flex; align-items: flex-end; justify-content: center; z-index: 10; }
.sheet-card {
  width: 100%; max-width: 720px; background: var(--surface); border-top: 1px solid var(--line);
  border-radius: 16px 16px 0 0; padding: 20px 16px calc(16px + var(--safe-b));
}
.sheet-card h3 { margin: 0 0 6px; font-size: 20px; }
.sheet-card p { margin: 6px 0; }

.toggle { display: flex; align-items: center; gap: 6px; color: var(--muted); cursor: pointer; }
.toggle input { width: auto; }
.rp-roles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 8px; font-size: 13px; }
.rp-roles span { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 4px 6px; }

@media (max-width: 360px) {
  .seat .nm { font-size: 13px; }
  .seat .badge { display: none; }
}
