:root {
  --bg: #0b0d12;
  --bg-2: #0f1219;
  --panel: #151922;
  --panel-2: #1a1f2b;
  --line: #252b39;
  --line-2: #313849;
  --text: #e9ecf4;
  --muted: #8c94a8;
  --dim: #626a7d;
  --gold: #d8b26a;
  --gold-2: #f0d59b;
  --blue: #00bfff;
  --wine: #a35568;
  --wolf: #d4515f;
  --good: #5fbf8f;
}

* { box-sizing: border-box; }

/* hidden 属性必须真的隐藏。
   .result-mask / .modal-mask 这类容器本身写了 display:flex，
   作者样式会压过 UA 的 [hidden]{display:none}，导致「空遮罩盖住整页」——
   表现就是房间页一片黑、只有模糊的轮廓。 */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--gold); text-decoration: none; }
a:hover { color: var(--gold-2); }
.mono { font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; letter-spacing: .4px; }
.dim { color: var(--dim); }

/* ---------- 通用控件 ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line-2);
  background: var(--panel-2);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: .16s ease;
  white-space: nowrap;
}
.btn:hover { border-color: #46506a; background: #212736; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.block { display: flex; width: 100%; }
.btn.sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.btn.primary {
  background: linear-gradient(180deg, #e0bd7b, #c9a05a);
  border-color: #a87f3f;
  color: #2a2011;
  font-weight: 600;
}
.btn.primary:hover { background: linear-gradient(180deg, #eccd90, #d4ab63); }
.btn.outline { background: transparent; border-color: var(--gold); color: var(--gold); }
.btn.ghost { background: transparent; }

.card {
  background: linear-gradient(180deg, rgba(26,31,43,.96), rgba(20,24,33,.98));
  border: 1px solid var(--line);
  border-radius: 16px;
}

/* ---------- 头像 / 身份标记 ---------- */

.avatar {
  width: 44px; height: 44px; flex: 0 0 auto;
  border-radius: 50%;
  overflow: hidden;
  display: inline-block;
  background: #fff;
  position: relative;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.xl { width: 96px; height: 96px; }
.ring-fish { box-shadow: 0 0 0 3px var(--blue), 0 0 14px rgba(0, 191, 255, .3); }
.ring-admin { box-shadow: 0 0 0 3px var(--wine), 0 0 14px rgba(163, 85, 104, .3); }

.tag { font-weight: 700; }
.sep { color: var(--dim); margin: 0 3px; }
.nick { color: var(--text); }

.chip {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 5px 12px 5px 6px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(21, 25, 34, .8);
  color: var(--text);
  transition: .16s;
}
.chip:hover { border-color: var(--line-2); background: #1b2130; color: var(--text); }
.chip-name { font-size: 14px; white-space: nowrap; }

/* ---------- 认证页 ---------- */

.auth-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 32px 16px;
  background:
    radial-gradient(900px 500px at 50% -10%, rgba(216, 178, 106, .10), transparent 60%),
    radial-gradient(700px 500px at 90% 110%, rgba(0, 191, 255, .07), transparent 60%),
    var(--bg);
}
.auth-wrap { width: 100%; max-width: 420px; }
.auth-wrap.wide { max-width: 520px; }
.auth-brand {
  text-align: center; color: var(--muted); font-size: 13px;
  letter-spacing: 3px; margin-bottom: 18px;
}
.auth-brand .moon { color: var(--gold); font-size: 15px; }
.auth-card { padding: 30px 28px; }
.auth-card h1 { margin: 0 0 6px; font-size: 24px; letter-spacing: 1px; }
.auth-card .sub { margin: 0 0 22px; color: var(--muted); font-size: 13px; }

.field { display: block; margin-bottom: 16px; position: relative; }
.field > span { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 7px; letter-spacing: .5px; }
.field > span em { font-style: normal; color: var(--dim); margin-left: 6px; font-size: 11.5px; }
.field input[type=text], .field input[type=password], .field input:not([type]) {
  width: 100%;
  background: #0f131b;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 11px 13px;
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: .16s;
}
.field input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(216, 178, 106, .12); }
.counter {
  position: absolute; right: 12px; top: 36px;
  font-size: 11px; color: var(--dim); font-style: normal;
}
.counter.over { color: var(--wolf); }

.form-error { color: var(--wolf); font-size: 13px; min-height: 18px; margin: 4px 0 10px; }
.auth-switch { text-align: center; font-size: 13px; color: var(--muted); margin-top: 16px; }

.avatar-row { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }
.avatar-pick {
  width: 74px; height: 74px; border-radius: 50%; padding: 0;
  border: none; background: #fff; overflow: hidden; cursor: pointer;
  position: relative; flex: 0 0 auto;
  box-shadow: 0 0 0 3px var(--blue);
  transition: box-shadow .2s;
}
.avatar-pick img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-hint {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, .55); color: #fff; font-size: 10px;
  padding: 3px 0; opacity: 0; transition: .2s;
}
.avatar-pick:hover .avatar-hint { opacity: 1; }
.avatar-note { font-size: 12.5px; color: var(--muted); display: flex; flex-direction: column; gap: 3px; }
.avatar-note strong { color: var(--text); font-size: 13px; }

.ident-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ident-card {
  text-align: left;
  background: #0f131b;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px 14px;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
  display: flex; flex-direction: column; gap: 4px;
  transition: .16s;
  font-size: 12px;
}
.ident-card strong { color: var(--text); font-size: 14px; }
.ident-card:hover { border-color: var(--line-2); }
.ident-card.active { border-color: var(--gold); background: rgba(216, 178, 106, .07); }
.ident-dot { width: 10px; height: 10px; border-radius: 50%; display: block; margin-bottom: 2px; }
.warn { color: #c98b63; font-size: 12px; margin: 8px 0 0; }

.auth-diag { margin-top: 14px; text-align: center; font-size: 12px; color: var(--dim); }
.auth-diag a { color: var(--dim); text-decoration: underline; }
.auth-diag .dim { margin-left: 4px; }
.diag-out {
  margin-top: 10px; padding: 10px 12px; border-radius: 10px;
  background: #0b0f16; border: 1px solid var(--line);
  font-size: 11.5px; line-height: 1.5; color: var(--muted);
  max-height: 240px; overflow: auto; white-space: pre-wrap;
}

.boot-error {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
  z-index: 99; max-width: 460px; padding: 20px 24px;
  background: #1a1f2b; border: 1px solid #4a3a2a; border-radius: 14px;
  color: #e8d9c6; font-size: 13px; line-height: 1.7; text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,.6);
}

.modal-mask {
  position: fixed; inset: 0; background: rgba(5, 7, 11, .78);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; z-index: 50;
}
.modal-card { padding: 28px; max-width: 400px; width: 100%; }
.modal-card h2 { margin: 0 0 4px; font-size: 20px; }
.modal-card .sub { color: var(--muted); font-size: 13px; margin: 0 0 16px; }
.wid-box {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: #0b0f16; border: 1px dashed var(--gold);
  border-radius: 12px; padding: 14px 16px; margin-bottom: 10px;
}
.wid-box span { font-family: ui-monospace, Consolas, monospace; font-size: 24px; letter-spacing: 3px; color: var(--gold-2); }

/* ---------- 应用页 ---------- */

.app-page { min-height: 100vh; background: radial-gradient(1000px 600px at 20% -10%, rgba(216,178,106,.06), transparent 60%), var(--bg); }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 20px;
  background: rgba(11, 13, 18, .86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  height: 62px;
}
.topbar-title { flex: 1; display: flex; align-items: center; gap: 12px; font-weight: 600; letter-spacing: 2px; color: var(--muted); }
.topbar-right { display: flex; gap: 8px; }
.room-code { color: var(--dim); font-size: 13px; letter-spacing: 1px; }

.page { max-width: 1080px; margin: 0 auto; padding: 26px 20px 90px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 14px; }
.section-head h2 { font-size: 16px; margin: 0; letter-spacing: 1px; font-weight: 600; }
.hint { font-size: 12px; color: var(--dim); }

.room-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.room-card {
  background: linear-gradient(180deg, #161b25, #131720);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  display: flex; flex-direction: column; gap: 10px;
  transition: .18s;
}
.room-card:hover { border-color: var(--line-2); transform: translateY(-2px); }
.room-card.progress { border-color: rgba(216, 178, 106, .25); }
.room-card-top { display: flex; align-items: center; justify-content: space-between; }
.badge { font-size: 11px; padding: 2px 9px; border-radius: 999px; letter-spacing: .5px; }
.badge.waiting { background: rgba(95, 191, 143, .13); color: var(--good); border: 1px solid rgba(95,191,143,.3); }
.badge.playing { background: rgba(216, 178, 106, .13); color: var(--gold); border: 1px solid rgba(216,178,106,.3); }
.badge.training { background: rgba(106, 169, 255, .12); color: #6aa9ff; border: 1px solid rgba(106,169,255,.35); }
.room-phase { font-size: 14px; color: var(--text); min-height: 21px; }
.room-stats { font-size: 12.5px; color: var(--muted); }
.room-stats b { color: var(--text); font-size: 15px; }
.empty {
  grid-column: 1 / -1;
  text-align: center; color: var(--muted);
  padding: 60px 20px; border: 1px dashed var(--line); border-radius: 14px;
  font-size: 14px; line-height: 2;
}

.fab {
  position: fixed; right: 26px; bottom: 26px; z-index: 30;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 14px 22px;
  border-radius: 999px;
  border: 1px solid #a87f3f;
  background: linear-gradient(180deg, #e0bd7b, #c9a05a);
  color: #2a2011; font-weight: 700; font-size: 15px;
  cursor: pointer; font-family: inherit;
  box-shadow: 0 8px 28px rgba(200, 160, 90, .28);
  transition: .18s;
}
.fab:hover { transform: translateY(-2px); box-shadow: 0 12px 34px rgba(200, 160, 90, .36); }
.fab span { font-size: 18px; line-height: 1; }

.toast {
  position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%);
  background: #232a38; border: 1px solid var(--line-2);
  color: var(--text); padding: 10px 18px; border-radius: 10px;
  font-size: 13.5px; z-index: 60; box-shadow: 0 10px 30px rgba(0,0,0,.4);
}

/* ---------- 主页 ---------- */

.profile-hero {
  display: grid; grid-template-columns: 1fr auto; gap: 24px;
  align-items: center;
  background:
    radial-gradient(500px 200px at 0% 0%, rgba(216,178,106,.08), transparent 70%),
    linear-gradient(180deg, #171c26, #131720);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 28px;
  margin-bottom: 26px;
  min-height: 220px;
}
.hero-left { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.hero-name { font-size: 22px; margin-top: 8px; }
.hero-wid { font-size: 13px; color: var(--muted); }
.hero-wid b { color: var(--gold-2); letter-spacing: 2px; font-size: 14px; }
.hero-ident { font-size: 12px; letter-spacing: 2px; }
.hero-stats { display: flex; gap: 12px; }
.stat-cell {
  min-width: 108px; text-align: center;
  background: rgba(11, 14, 20, .6);
  border: 1px solid var(--line);
  border-radius: 14px; padding: 16px 12px;
  display: flex; flex-direction: column; gap: 4px;
}
.stat-cell b { font-size: 26px; color: var(--gold-2); font-weight: 600; }
.stat-cell span { font-size: 12px; color: var(--muted); }

.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  text-align: left; color: var(--dim); font-weight: 500; font-size: 12px;
  padding: 10px 12px; border-bottom: 1px solid var(--line); letter-spacing: 1px;
}
.table td { padding: 12px; border-bottom: 1px solid rgba(37, 43, 57, .6); }
.table tr:last-child td { border-bottom: none; }
.empty-cell { text-align: center; color: var(--dim); padding: 40px !important; }

.role-pill { font-size: 12px; padding: 2px 9px; border-radius: 6px; border: 1px solid var(--line-2); }
.role-WOLF { color: var(--wolf); border-color: rgba(212, 81, 95, .4); }
.role-SEER { color: #6aa9ff; border-color: rgba(106, 169, 255, .4); }
.role-WITCH { color: #b06ad4; border-color: rgba(176, 106, 212, .4); }
.role-VILLAGER { color: #9aa2b6; }
.result.win { color: var(--good); }
.result.lose { color: var(--wolf); }

/* ---------- 房间 ---------- */

.room-page { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
.room-page .topbar { position: static; flex: 0 0 auto; }

.phase-pill {
  font-size: 12px; padding: 3px 12px; border-radius: 999px;
  background: rgba(216, 178, 106, .1); color: var(--gold);
  border: 1px solid rgba(216, 178, 106, .28);
  letter-spacing: 1px;
}
.timer { font-family: ui-monospace, Consolas, monospace; font-size: 13px; color: var(--muted); min-width: 42px; }
.timer.urgent { color: var(--wolf); }

.spec-strip {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 14px;
  padding: 8px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(15, 18, 25, .7);
  min-height: 58px;
  overflow: hidden;
}
.spec-label { font-size: 12px; color: var(--dim); white-space: nowrap; letter-spacing: 1px; }
.spec-label b { color: var(--muted); }
.spec-list { display: flex; gap: 8px; overflow-x: auto; padding: 2px; scrollbar-width: thin; }
.spec-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px 3px 3px; border-radius: 999px;
  background: #12161f; border: 1px solid var(--line);
  font-size: 11.5px; white-space: nowrap; color: var(--muted);
}
.spec-chip .avatar { width: 24px; height: 24px; }
.spec-empty { font-size: 12px; color: var(--dim); }

.stage {
  flex: 1 1 auto; min-height: 0;
  display: grid;
  grid-template-columns: minmax(190px, 230px) minmax(0, 1fr) minmax(190px, 230px);
  gap: 16px;
  padding: 14px 20px;
}
.seat-col { display: flex; flex-direction: column; justify-content: space-between; gap: 10px; min-height: 0; }

.pcard {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  background: linear-gradient(180deg, #161b26, #12161f);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  transition: .2s;
  min-height: 72px;
}
.pcard .avatar { width: 46px; height: 46px; }
.pcard-info { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pcard-name { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pcard-role { font-size: 11px; color: var(--dim); letter-spacing: 1px; }
.pcard.dead { opacity: .42; filter: grayscale(1); }
.pcard.empty-seat { background: transparent; border-style: dashed; opacity: .55; cursor: pointer; }
.pcard.empty-seat:hover { opacity: .9; border-color: var(--gold); }
.seat-empty { font-size: 12px; color: var(--dim); letter-spacing: 2px; padding: 10px 0; }
.spec-strip.can-switch { cursor: pointer; }
.spec-strip.can-switch:hover { background: #141923; }
.spec-hint { margin-left: auto; font-size: 11.5px; color: var(--gold); white-space: nowrap; opacity: .85; }
.pcard.speaking { border-color: var(--gold); box-shadow: 0 0 0 1px rgba(216,178,106,.35), 0 0 26px rgba(216,178,106,.14); }
.pcard.you { border-color: rgba(216,178,106,.45); }
.pcard.voted::after {
  content: '已投'; position: absolute; top: -7px; right: 10px;
  font-size: 10px; color: var(--good); background: #101720;
  border: 1px solid rgba(95,191,143,.35); border-radius: 999px; padding: 1px 7px;
}
.seat-no {
  position: absolute; top: -8px; left: -8px;
  width: 24px; height: 24px; border-radius: 50%;
  background: #0b0e14; border: 1px solid var(--line-2);
  color: var(--gold); font-size: 12px; font-weight: 700;
  display: grid; place-items: center;
  z-index: 2;
}
.vote-badge {
  position: absolute; right: 8px; bottom: 8px;
  font-size: 10px; color: var(--gold); background: rgba(216,178,106,.12);
  border-radius: 999px; padding: 1px 7px;
}

.table-center { display: flex; flex-direction: column; min-height: 0; gap: 10px; }
.feed {
  flex: 1 1 auto; min-height: 0; overflow-y: auto;
  background: rgba(13, 16, 22, .7);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  display: flex; flex-direction: column; gap: 7px;
  scrollbar-width: thin;
}
.feed::-webkit-scrollbar { width: 8px; }
.feed::-webkit-scrollbar-thumb { background: #262d3c; border-radius: 4px; }

.msg { font-size: 13px; line-height: 1.55; color: #b9c0d2; }
.msg.system { color: var(--dim); font-size: 12px; text-align: center; font-style: italic; }
.msg.phase { color: var(--gold); text-align: center; font-size: 12.5px; letter-spacing: 2px; margin: 8px 0; }
.msg.death { color: var(--wolf); text-align: center; font-size: 12.5px; }
.msg.chat { display: flex; gap: 8px; }
.msg.chat .who { color: var(--gold); flex: 0 0 auto; font-size: 12px; padding-top: 1px; }
.msg.chat .what { color: #c7cddd; }
.msg.role { color: #7fb2e8; font-size: 12.5px; }

.section-label {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px; color: var(--dim); letter-spacing: 2px;
  margin: 10px 0 2px;
}
.section-label::after { content: ''; flex: 1; height: 1px; background: var(--line); }

.composer { flex: 0 0 auto; display: flex; flex-direction: column; gap: 8px; }
.composer textarea {
  width: 100%; resize: none; height: 62px;
  background: #0f131b; border: 1px solid var(--line);
  border-radius: 12px; color: var(--text);
  padding: 10px 12px; font-family: inherit; font-size: 13.5px; outline: none;
}
.composer textarea:focus { border-color: var(--gold); }
.composer-row { display: flex; gap: 8px; align-items: center; }
.composer-row .grow { flex: 1; }
.composer-hint { font-size: 11.5px; color: var(--dim); }

.dock {
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  flex-wrap: wrap;
  padding: 10px 20px 14px;
  min-height: 62px;
  border-top: 1px solid var(--line);
  background: rgba(11, 13, 18, .9);
}
.dock-label { font-size: 12px; color: var(--dim); margin-right: 4px; letter-spacing: 1px; }
.dock .btn { min-width: 92px; }
.target-btn {
  width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--line-2); background: #171c26; color: var(--text);
  font-family: inherit; font-size: 14px; cursor: pointer; transition: .15s;
}
.target-btn:hover { border-color: var(--gold); color: var(--gold); }
.my-role {
  font-size: 12.5px; color: var(--gold);
  border: 1px solid rgba(216,178,106,.3); background: rgba(216,178,106,.08);
  padding: 5px 12px; border-radius: 999px; letter-spacing: 1px;
}

.result-mask {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(6, 8, 12, .82);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.result-card { width: 100%; max-width: 560px; padding: 28px; }
.result-card h2 { margin: 0 0 4px; font-size: 24px; }
.result-card .sub { color: var(--muted); font-size: 13px; margin: 0 0 18px; }
.result-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 18px; }
.result-row {
  display: flex; align-items: center; gap: 8px;
  background: #10141c; border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 10px; font-size: 12.5px;
}
.result-row .avatar { width: 28px; height: 28px; }
.result-row .r-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }

/* ---------- 自适应 ---------- */

@media (max-width: 860px) {
  .stage { grid-template-columns: 1fr; grid-template-rows: auto minmax(0,1fr) auto; }
  .seat-col { flex-direction: row; justify-content: center; }
  .seat-col .pcard { flex: 1; }
  .spec-strip { min-height: 50px; }
  .profile-hero { grid-template-columns: 1fr; }
  .hero-stats { width: 100%; }
  .stat-cell { flex: 1; min-width: 0; }
  .result-list { grid-template-columns: 1fr; }
  .room-page { height: auto; min-height: 100vh; overflow: auto; }
}
