:root {
  --bg: #0b0d11;
  --bg2: #0f1218;
  --panel: #14181f;
  --panel2: #1a1f28;
  --line: #242b36;
  --line2: #2f3846;
  --text: #e7e9ee;
  --dim: #8d97a8;
  --dim2: #5f6878;
  --red: #d4574d;
  --red2: #b8433c;
  --amber: #e0a458;
  --green: #4f9f78;
  --blue: #5a86b8;
  --purple: #8b6fb0;
  --r: 10px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: radial-gradient(1200px 600px at 20% -10%, #161a22 0%, var(--bg) 60%);
  color: var(--text);
  font: 14px/1.65 "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: .02em; }
button { font-family: inherit; font-size: inherit; color: inherit; cursor: pointer; }
input { font-family: inherit; }

.screen { position: fixed; inset: 0; display: none; overflow: auto; }
.screen.on { display: block; }

/* ---------------------------------------------------------- 按钮 */
.btn {
  background: var(--panel2);
  border: 1px solid var(--line2);
  color: var(--text);
  padding: 7px 14px;
  border-radius: 8px;
  transition: .15s;
  white-space: nowrap;
}
.btn:hover { background: #222833; border-color: #3c475a; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(180deg, #b8453c, #9e3830); border-color: #c2544a; color: #fff; }
.btn.primary:hover { background: linear-gradient(180deg, #c85046, #ac3f36); }
.btn.ghost { background: transparent; border-color: var(--line2); color: var(--dim); }
.btn.ghost:hover { color: var(--text); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .38; cursor: not-allowed; }
.link { background: none; border: 0; color: var(--dim); text-decoration: underline; padding: 0 4px; }
.link:hover { color: var(--amber); }

/* ---------------------------------------------------------- 登录 */
.auth-wrap {
  min-height: 100%; display: flex; align-items: center; justify-content: center;
  gap: 60px; padding: 40px 24px; flex-wrap: wrap;
}
.auth-brand { max-width: 460px; }
.auth-brand h1 {
  font-size: 46px; letter-spacing: .12em;
  background: linear-gradient(180deg, #fff 10%, #b9bec9 90%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.auth-brand .sub { color: var(--amber); margin: 10px 0 24px; letter-spacing: .08em; }
.auth-brand .blurb { color: var(--dim); font-size: 15px; line-height: 2; }
.auth-card {
  width: 320px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 22px; box-shadow: 0 24px 60px rgba(0,0,0,.5);
}
.tabs { display: flex; gap: 6px; margin-bottom: 18px; }
.tab {
  flex: 1; background: transparent; border: 0; border-bottom: 2px solid transparent;
  color: var(--dim); padding: 8px 0;
}
.tab.on { color: var(--text); border-color: var(--red); }
.auth-card label { display: block; font-size: 12px; color: var(--dim); margin: 12px 0 6px; }
.auth-card input {
  width: 100%; background: var(--bg2); border: 1px solid var(--line2);
  border-radius: 8px; padding: 10px 12px; color: var(--text); outline: none;
}
.auth-card input:focus { border-color: var(--amber); }
.auth-card .btn { margin-top: 18px; padding: 10px; }
.auth-msg { min-height: 20px; font-size: 12px; color: var(--red); margin: 10px 0 0; }
.auth-note { font-size: 11px; color: var(--dim2); margin: 6px 0 0; }

/* ---------------------------------------------------------- 菜单 */
.menu-wrap { max-width: 1000px; margin: 0 auto; padding: 40px 24px; }
.menu-head { display: flex; align-items: baseline; justify-content: space-between; border-bottom: 1px solid var(--line); padding-bottom: 16px; }
.menu-head h2 { font-size: 26px; letter-spacing: .1em; }
.who { color: var(--dim); font-size: 13px; }
.menu-body { display: flex; gap: 24px; margin-top: 24px; flex-wrap: wrap; }
.slots { flex: 1 1 520px; display: grid; gap: 12px; }
.slot {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
  padding: 16px 18px; display: flex; align-items: center; gap: 16px; transition: .15s;
}
.slot:hover { border-color: var(--line2); background: var(--panel2); }
.slot.empty { color: var(--dim2); }
.slot .s-main { flex: 1; min-width: 0; }
.slot .s-title { font-size: 15px; }
.slot .s-sub { font-size: 12px; color: var(--dim); margin-top: 2px; }
.slot .s-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line2); }
.slot .s-dot.live { background: var(--green); box-shadow: 0 0 8px var(--green); }
.slot .s-dot.dead { background: var(--red); }
.slot .tools { display: flex; gap: 6px; }
.slot .tools .btn { padding: 4px 10px; font-size: 12px; }
.menu-side { flex: 0 0 280px; }
.rules { margin-top: 20px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; }
.rules h4 { font-size: 13px; color: var(--amber); margin-bottom: 8px; letter-spacing: .06em; }
.rules ul { margin: 0; padding-left: 18px; color: var(--dim); font-size: 12.5px; line-height: 1.9; }

/* ---------------------------------------------------------- HUD */
#scr-game { display: none; flex-direction: column; height: 100%; }
#scr-game.on { display: flex; }
#hud {
  flex: 0 0 auto; display: flex; align-items: center; gap: 18px;
  padding: 10px 18px; border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #121620, #0d1015);
}
.hud-left { display: flex; align-items: center; gap: 10px; }
.hud-av { width: 26px; height: 34px; object-fit: contain; filter: drop-shadow(0 2px 4px rgba(0,0,0,.6)); }
.hud-title { font-size: 15px; letter-spacing: .14em; color: var(--text); }
.hud-meta { font-size: 12px; color: var(--dim); margin-top: 1px; }
.hud-bars { flex: 1; display: flex; gap: 14px; flex-wrap: wrap; }
.bar { min-width: 92px; }
.bar .b-top { display: flex; justify-content: space-between; font-size: 11px; color: var(--dim); margin-bottom: 3px; }
.bar .b-top b { color: var(--text); font-weight: 600; }
.bar-track { height: 5px; background: #1c222c; border-radius: 3px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 3px; transition: width .3s; }
.hud-right { display: flex; align-items: center; gap: 10px; }
.ap { display: flex; gap: 4px; }
.apdot { width: 9px; height: 9px; border-radius: 50%; background: #232a35; }
.apdot.on { background: var(--amber); box-shadow: 0 0 6px rgba(224,164,88,.6); }

/* ---------------------------------------------------------- 布局 */
.layout {
  flex: 1; display: grid; grid-template-columns: 256px 1fr 268px;
  min-height: 0; overflow: hidden;
}
.panel { background: var(--bg2); border-right: 1px solid var(--line); overflow: auto; padding: 14px 12px; }
#logPanel { border-right: 0; border-left: 1px solid var(--line); }
.panel-title { font-size: 11px; color: var(--dim2); letter-spacing: .12em; margin-bottom: 10px; }

/* NPC 卡 */
.npc {
  display: flex; gap: 9px; align-items: flex-start;
  padding: 8px 9px; border-radius: 9px; border: 1px solid transparent;
  margin-bottom: 4px; transition: .15s; cursor: pointer;
}
.npc:hover { background: var(--panel); border-color: var(--line2); }
.npc .av-wrap { flex: 0 0 auto; padding-top: 1px; }
.npc .n-body { flex: 1; min-width: 0; }

/* 头像：源图是椭圆，直接用不裁 */
.av {
  display: block; width: 42px; height: 56px; object-fit: contain;
  filter: drop-shadow(0 2px 5px rgba(0,0,0,.55));
}
.av.ph {
  width: 34px; height: 34px; border-radius: 50%; margin-top: 4px;
  background: #1b222c; border: 1px solid var(--line2);
  color: var(--dim2); font-size: 14px;
  display: flex; align-items: center; justify-content: center;
}
.av.big { width: 108px; height: 142px; }
.npc.hidden .av-wrap { opacity: .45; }
.npc-empty { color: var(--dim2); font-size: 11.5px; padding: 4px 2px 8px; }
.npc-unknown { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; padding: 8px 2px 4px; }
.npc-unknown i {
  width: 15px; height: 18px; border-radius: 50% / 40%;
  background: #171d26; border: 1px solid #232b36;
  color: #3d4655; font-size: 9px; font-style: normal;
  display: inline-flex; align-items: center; justify-content: center;
}
.npc-unknown span { color: var(--dim2); font-size: 10.5px; margin-left: 4px; }

.npc .n-top { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; }
.npc .n-name { font-size: 13px; }
.npc .n-tag { font-size: 10px; color: var(--dim2); flex: 0 0 auto; }
.npc .n-bar { height: 3px; background: #1c222c; border-radius: 2px; margin-top: 6px; overflow: hidden; }
.npc .n-fill { height: 100%; background: var(--red); transition: width .3s; }
.npc .n-meta { font-size: 10.5px; color: var(--dim2); margin-top: 4px; display: flex; justify-content: space-between; gap: 6px; }
.npc.self .n-name { color: var(--text); }
.npc.hidden .n-name { color: var(--dim2); }
.npc.hot { border-color: rgba(212,87,77,.4); background: rgba(212,87,77,.06); }

/* 人物档案 */
.pf .pf-top { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 16px; }
.pf .pf-av { flex: 0 0 auto; }
.pf .pf-info { flex: 1; min-width: 0; }
.pf .pf-role { color: var(--amber); font-size: 13px; margin-bottom: 8px; }
.pf .pf-desc { color: var(--dim); font-size: 12.5px; line-height: 1.9; }
.pf-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 1px 30px; border-top: 1px solid var(--line); padding-top: 12px; }
.pf-row { display: flex; justify-content: space-between; font-size: 12.5px; padding: 5px 0; border-bottom: 1px dashed #1c222c; }
.pf-row span { color: var(--dim); }
.pf-row b { color: var(--text); font-weight: 600; }

/* 舞台 */
#stage { overflow: auto; padding: 22px 26px 40px; }
.stage-inner { max-width: 720px; margin: 0 auto; }
.scene {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 20px 22px; margin-bottom: 18px; min-height: 96px;
  line-height: 1.95; color: #d3d7df;
}
.scene .s-flavor { color: var(--dim); font-size: 13px; }
.scene .s-strong { color: var(--amber); }

/* 事件卡 */
.event .ev-kicker { font-size: 11px; color: var(--red); letter-spacing: .14em; margin-bottom: 6px; }
.event .ev-title { font-size: 17px; margin-bottom: 12px; }
.event .ev-text { color: #cfd4dd; line-height: 2; }
.ev-choices { display: grid; gap: 8px; margin-top: 18px; }
.ev-choices .btn { text-align: left; white-space: normal; padding: 11px 14px; line-height: 1.6; }
.ev-choices .btn:hover { border-color: var(--red); background: #1e1a1c; }

.actions { display: grid; grid-template-columns: repeat(auto-fill, minmax(214px, 1fr)); gap: 10px; }
.act {
  text-align: left; background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px 14px; transition: .15s; position: relative;
  white-space: normal;
}
.act:hover:not(:disabled) { border-color: var(--red); background: #191c24; transform: translateY(-1px); }
.act .a-top { display: flex; justify-content: space-between; align-items: baseline; }
.act .a-name { font-size: 14px; }
.act .a-ap { font-size: 11px; color: var(--amber); }
.act .a-desc { font-size: 11.5px; color: var(--dim); margin-top: 4px; line-height: 1.6; }
.act .a-note { font-size: 11px; color: var(--green); margin-top: 3px; }
.act:disabled { opacity: .42; }
.act:disabled .a-desc { color: var(--dim2); }

/* 周报 */
.report { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 20px 22px; }
.report h3 { font-size: 16px; margin-bottom: 4px; }
.report .r-sub { font-size: 12px; color: var(--dim); margin-bottom: 14px; }
.wr-line { padding: 7px 0; border-bottom: 1px dashed #1e242e; font-size: 13.5px; line-height: 1.8; color: #cfd4dd; }
.wr-line:last-child { border-bottom: 0; }
.wr-line.bad { color: #e59a94; }
.wr-line.good { color: #8fcfa9; }
.wr-line.sys { color: var(--dim); font-size: 12.5px; }
.wr-line.warn { color: var(--amber); }

/* 日志 */
.log-list { font-size: 12.5px; }
.log-item { padding: 6px 0; border-bottom: 1px solid #171c24; color: #a9b0bd; line-height: 1.7; }
.log-item.bad { color: #d99b95; }
.log-item.good { color: #8bc7a5; }
.log-item.sys { color: var(--dim2); }
.log-item.warn { color: var(--amber); }
.log-item .w { color: var(--dim2); margin-right: 5px; font-size: 11px; }

/* ---------------------------------------------------------- 小游戏 */
.mg-mask {
  position: fixed; inset: 0; background: rgba(5,7,10,.82); backdrop-filter: blur(3px);
  display: none; align-items: center; justify-content: center; z-index: 90; padding: 20px;
}
.mg-mask.on { display: flex; }
.mg-box {
  width: min(680px, 100%); max-height: 92vh; overflow: auto;
  background: var(--panel); border: 1px solid var(--line2); border-radius: 14px;
  box-shadow: 0 30px 80px rgba(0,0,0,.65); display: flex; flex-direction: column;
}
.mg-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.mg-head h3 { font-size: 15px; letter-spacing: .08em; }
.mg-timer { color: var(--amber); font-variant-numeric: tabular-nums; font-size: 14px; }
.mg-body { padding: 18px 20px; }
.mg-foot { padding: 0 20px 18px; display: flex; gap: 8px; justify-content: flex-end; }
.mg-hint { color: var(--dim); font-size: 12.5px; margin: 0 0 14px; line-height: 1.8; }
.mg-q { font-size: 17px; line-height: 1.8; margin-bottom: 16px; }
.mg-idx { font-size: 11px; color: var(--dim2); margin-right: 10px; }
.mg-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mg-opts .opt { text-align: left; padding: 11px 14px; white-space: normal; line-height: 1.55; }
.mg-opts .opt:hover:not(:disabled) { border-color: var(--amber); background: #1d222b; }
.mg-bar { height: 3px; background: #1c222c; margin-top: 16px; border-radius: 2px; }
.mg-bar { position: relative; }
.mg-bar::after {
  content: ''; position: absolute; inset: 0; border-radius: 2px;
  background: var(--amber); width: 0; transition: width .2s;
}
.mg-tip { margin-top: 14px; font-size: 12.5px; color: var(--dim); line-height: 1.7; min-height: 20px; }
.mg-tip.good { color: var(--green); }
.mg-num { display: flex; gap: 8px; grid-column: 1 / -1; }
.mg-num input {
  flex: 1; background: var(--bg2); border: 1px solid var(--line2); border-radius: 8px;
  padding: 10px 14px; color: var(--text); font-size: 16px; outline: none;
}
.mg-num input:focus { border-color: var(--amber); }
.mg-tip.bad { color: var(--red); }
.mg-slots { display: grid; gap: 5px; margin-bottom: 14px; }
.mg-slot { padding: 8px 12px; background: var(--bg2); border: 1px dashed var(--line2); border-radius: 7px; font-size: 12.5px; color: var(--dim2); }
.mg-slot.filled { border-style: solid; border-color: var(--green); color: #b9c2cf; }
.mg-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mg-cards .opt { text-align: left; padding: 10px 12px; white-space: normal; line-height: 1.55; font-size: 13px; }
.mg-cards .opt.sm { font-size: 12.5px; }
.mg-cards .opt.on { border-color: var(--amber); background: #201c17; }
.mg-cards .opt.ok { border-color: var(--green); background: rgba(79,159,120,.12); }
.mg-cards .opt.bad { border-color: var(--red); background: rgba(212,87,77,.12); }
.mg-cards .opt.gift { display: flex; flex-direction: column; gap: 4px; }
.mg-cards .opt.gift b { color: var(--amber); font-weight: 600; }
.mg-cards .opt.gift span { color: var(--dim); font-size: 11.5px; }
.mg-forest { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.mg-cell {
  aspect-ratio: 1; background: #182028; border: 1px solid var(--line2);
  border-radius: 7px; color: var(--dim2); font-size: 14px;
}
.mg-cell:hover:not(:disabled) { border-color: var(--amber); }
.mg-cell.empty { background: #12161c; color: #3d4552; }
.mg-cell.found { background: rgba(224,164,88,.18); border-color: var(--amber); color: var(--amber); font-weight: 700; }
.shake { animation: shk .3s; }
@keyframes shk { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

/* ---------------------------------------------------------- 象棋 */
.xq-wrap { display: flex; justify-content: center; }
.xq-board {
  position: relative; display: grid; grid-template-columns: repeat(9, var(--cell, 40px));
  grid-template-rows: repeat(10, var(--cell, 40px));
  background: #1a1510; border: 2px solid #3a2d1e; border-radius: 6px; padding: 2px;
}
.xq-cell { position: relative; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.xq-cell.dark { background: rgba(255,255,255,.02); }
.xq-cell::after {
  content: ''; position: absolute; inset: 0;
  border-right: 1px solid rgba(120,90,50,.35); border-bottom: 1px solid rgba(120,90,50,.35);
}
.xq-pc {
  width: 84%; height: 84%; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: calc(var(--cell, 40px) * .46); font-weight: 600; background: #efe3cd;
  border: 1.5px solid #8a7048; z-index: 2; user-select: none;
}
.xq-pc.red { color: #b2352c; }
.xq-pc.black { color: #23262b; }
.xq-cell.sel { background: rgba(224,164,88,.22); }
.xq-cell.dot::before {
  content: ''; position: absolute; width: 10px; height: 10px; border-radius: 50%;
  background: rgba(224,164,88,.75); z-index: 3;
}
.xq-river {
  position: absolute; left: 0; right: 0; top: 50%; transform: translateY(-50%);
  text-align: center; color: rgba(180,140,90,.45); font-size: 13px;
  letter-spacing: .5em; pointer-events: none; z-index: 0;
}

/* ---------------------------------------------------------- toast */
.toast {
  position: fixed; left: 50%; bottom: 42px; transform: translate(-50%, 20px);
  background: #1e242e; border: 1px solid var(--line2); color: var(--text);
  padding: 10px 18px; border-radius: 9px; opacity: 0; pointer-events: none;
  transition: .25s; z-index: 200; max-width: 80vw; font-size: 13px;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ---------------------------------------------------------- 响应式 */
@media (max-width: 1180px) {
  .layout { grid-template-columns: 200px 1fr; }
  #logPanel { display: none; }
}
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  #npcPanel { display: flex; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 8px; }
  #npcPanel .panel-title { display: none; }
  .npc { min-width: 152px; margin: 0 6px 0 0; }
  #stage { padding: 14px 14px 40px; }
  #hud { flex-wrap: wrap; gap: 10px; padding: 8px 12px; }
  .hud-bars { order: 3; width: 100%; gap: 10px; }
  .bar { min-width: 76px; }
  .mg-opts, .mg-cards { grid-template-columns: 1fr; }
  .auth-wrap { gap: 28px; }
  .auth-brand h1 { font-size: 34px; }
}
