/* ============ 侠影江湖 · 水墨武侠风 ============ */
:root {
  --ink: #12100e;
  --ink2: #1b1815;
  --panel: #211d18;
  --panel2: #2a251f;
  --line: #4a3f30;
  --gold: #d4a94e;
  --gold2: #f0cf8a;
  --text: #e8dcc3;
  --muted: #9a8c72;
  --red: #c25450;
  --green: #7fae62;
  --blue: #6a9ec2;
  --purple: #a67ec2;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  background: var(--ink);
  color: var(--text);
  font-family: "Noto Serif SC", "STKaiti", "KaiTi", "SimSun", serif;
  font-size: 16px;
  overflow: hidden;
}
.screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; }
.hidden { display: none !important; }

/* ---------- 按钮 ---------- */
.btn {
  background: var(--panel2); color: var(--text);
  border: 1px solid var(--line); border-radius: 4px;
  padding: 7px 16px; font-family: inherit; font-size: 16px;
  cursor: pointer; transition: all .15s;
}
.btn:hover { border-color: var(--gold); color: var(--gold2); background: #332c22; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-lg { font-size: 21px; padding: 12px 38px; letter-spacing: 4px; }
.btn-sm { font-size: 14px; padding: 5px 10px; }
.btn-primary { border-color: var(--gold); color: var(--gold2); }
.btn-story { border-color: var(--gold); color: var(--gold2); animation: pulse 1.6s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 rgba(212,169,78,0);} 50% { box-shadow: 0 0 12px rgba(212,169,78,.6);} }

/* ---------- 主菜单 ---------- */
#screen-menu {
  background: radial-gradient(ellipse at 50% 30%, #2a2118 0%, #12100e 70%);
}
.menu-box { text-align: center; }
.game-title {
  font-size: 76px; letter-spacing: 26px; color: var(--gold);
  text-shadow: 0 0 30px rgba(212,169,78,.35); font-weight: 700;
  padding-left: 26px;
}
.game-sub { color: var(--muted); letter-spacing: 8px; margin: 14px 0 44px; }
.menu-btns { display: flex; flex-direction: column; gap: 16px; align-items: center; }
.menu-saves { margin-top: 26px; color: var(--muted); font-size: 13px; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.menu-foot { margin-top: 60px; color: #5a4f3d; letter-spacing: 3px; }

/* ---------- 创建角色 ---------- */
.create-box {
  width: 760px; max-height: 92vh; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 28px 34px;
}
.create-box h2 { color: var(--gold); letter-spacing: 8px; margin-bottom: 18px; text-align: center; }
.create-row { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.create-row input {
  background: var(--ink2); border: 1px solid var(--line); color: var(--text);
  padding: 8px 12px; border-radius: 4px; font-family: inherit; font-size: 15px; width: 220px;
}
.create-section-title { color: var(--gold); margin: 16px 0 10px; letter-spacing: 3px; font-size: 17px; }
.origin-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.origin-card {
  background: var(--ink2); border: 1px solid var(--line); border-radius: 6px;
  padding: 12px; cursor: pointer; transition: all .15s;
}
.origin-card:hover { border-color: var(--gold); }
.origin-card.sel { border-color: var(--gold); background: #2e2818; box-shadow: 0 0 10px rgba(212,169,78,.25) inset; }
.origin-card .oc-name { color: var(--gold2); font-size: 18px; margin-bottom: 6px; }
.origin-card .oc-desc { color: var(--muted); font-size: 14px; line-height: 1.6; }
.alloc-rows { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px 20px; }
.alloc-row { display: flex; align-items: center; justify-content: space-between; background: var(--ink2); padding: 7px 12px; border-radius: 4px; }
.alloc-row .ar-name { font-size: 16px; width: 80px; }
.alloc-row .ar-val { color: var(--gold2); width: 30px; text-align: center; }
.alloc-row button { width: 26px; height: 26px; }
.create-btns { margin-top: 24px; display: flex; justify-content: space-between; }

/* ---------- 游戏主界面 ---------- */
#screen-game { display: flex; flex-direction: column; align-items: stretch; justify-content: stretch; }
#topbar {
  display: flex; justify-content: space-between; align-items: center;
  background: linear-gradient(#241f19, #1b1815);
  border-bottom: 1px solid var(--line);
  padding: 8px 16px; font-size: 16px;
}
.top-left, .top-right { display: flex; align-items: center; gap: 16px; }
#hud-time { color: var(--gold2); }
#hud-weather { color: var(--blue); }
#hud-loc { color: var(--text); }
#hud-money { color: var(--gold); }
#hud-chapter { color: var(--muted); font-size: 15px; }

#main-grid {
  flex: 1; display: grid; min-height: 0;
  grid-template-columns: 240px 1fr 320px;
  gap: 10px; padding: 10px;
}
#left-panel, #right-panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px;
  padding: 12px; overflow-y: auto; min-height: 0;
}
#center-panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px;
  display: flex; flex-direction: column; min-height: 0; overflow: hidden;
}

.panel-title {
  color: var(--gold); font-size: 18px; letter-spacing: 3px;
  border-bottom: 1px solid var(--line); padding-bottom: 4px; margin: 12px 0 8px;
}
.panel-title:first-child { margin-top: 0; }

/* 左栏 */
.bars { display: flex; flex-direction: column; gap: 6px; }
.bar-row { display: flex; align-items: center; gap: 6px; font-size: 14px; }
.bar-label { width: 30px; color: var(--muted); }
.bar { flex: 1; height: 10px; background: #0d0b09; border: 1px solid var(--line); border-radius: 5px; overflow: hidden; }
.bar i { display: block; height: 100%; transition: width .3s; }
.bar.hp i { background: linear-gradient(90deg, #8e3b38, var(--red)); }
.bar.mp i { background: linear-gradient(90deg, #37628e, var(--blue)); }
.bar.sp i { background: linear-gradient(90deg, #8e6d37, var(--gold)); }
.bar.ep i { background: linear-gradient(90deg, #4a7e3a, var(--green)); }
.bar-num { width: 76px; text-align: right; color: var(--muted); font-size: 13px; }
.lp-attrs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 10px; font-size: 15px; margin-top: 10px; }
.lp-attrs span b { color: var(--gold2); }
.lp-misc { font-size: 15px; color: var(--muted); margin-top: 10px; line-height: 1.8; }
.lp-misc b { color: var(--text); }
.travel-hint { color: var(--gold); font-size: 16px; letter-spacing: 2px; }
.move-list { display: flex; flex-direction: column; gap: 5px; }
.move-list .btn { text-align: left; font-size: 16px; padding: 7px 14px; }
.act-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.act-btns .btn { font-size: 16px; padding: 8px 10px; text-align: center; }

/* 中栏 */
#objective-bar {
  flex-shrink: 0; padding: 8px 16px; font-size: 15px; line-height: 1.7;
  background: #262017; border-bottom: 1px solid var(--line); color: var(--text);
}
#objective-bar .ob-tag {
  display: inline-block; margin-right: 8px; padding: 1px 8px; border-radius: 3px;
  background: var(--gold); color: #241d10; font-size: 13px; letter-spacing: 2px;
}
#stage {
  position: relative; height: 190px; flex-shrink: 0;
  background: linear-gradient(180deg, #2d3644 0%, #3a3a34 55%, #26221c 56%, #1a1713 100%);
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}
#stage .stage-loc {
  position: absolute; top: 8px; left: 12px; color: rgba(240,207,138,.85);
  font-size: 18px; letter-spacing: 4px; text-shadow: 0 1px 4px #000;
}
#stage canvas { position: absolute; bottom: 6px; image-rendering: pixelated; cursor: default; }
#stage canvas.npc { cursor: pointer; filter: drop-shadow(0 3px 3px rgba(0,0,0,.5)); }
#stage canvas.npc:hover { filter: drop-shadow(0 0 8px rgba(212,169,78,.8)); }
#stage .npc-name {
  position: absolute; color: var(--gold2); font-size: 13px; text-align: center;
  text-shadow: 0 1px 3px #000; pointer-events: none;
}

#log {
  flex: 1; overflow-y: auto; padding: 12px 16px; font-size: 17px; line-height: 1.9; min-height: 0;
}
#log .l-line { margin-bottom: 2px; }
#log .l-sys { color: var(--gold2); }
#log .l-battle { color: #d98f6a; }
#log .l-story { color: var(--text); }
#log .l-dim { color: var(--muted); font-size: 15px; }

#choices { padding: 10px 16px 14px; border-top: 1px dashed var(--line); display: flex; flex-direction: column; gap: 7px; flex-shrink: 0; max-height: 220px; overflow-y: auto; }
.choice-btn {
  text-align: left; padding: 9px 16px; font-size: 16px;
  background: var(--ink2);
}
.choice-btn .key-hint { color: var(--gold); margin-right: 8px; }

/* 战斗面板 */
#battle-panel { background: #241410; border-bottom: 2px solid #7e3d30; padding: 10px 16px; }
.bp-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.bp-vs { display: flex; gap: 20px; align-items: center; }
.bp-side { flex: 1; }
.bp-name { font-size: 16px; margin-bottom: 4px; }
.bp-name.enemy { color: var(--red); }
.bp-name.me { color: var(--green); }
.bp-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.bp-sub { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; padding: 6px; background: #1a0f0b; border-radius: 4px; }

/* 右栏 tabs */
.tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 10px; }
.tab {
  flex: 0 0 auto; padding: 6px 10px; background: var(--ink2); border: 1px solid var(--line); border-bottom: none;
  color: var(--muted); cursor: pointer; font-family: inherit; font-size: 14px;
  border-radius: 4px 4px 0 0;
}
.tab.active { color: var(--gold2); background: var(--panel2); border-color: var(--gold); }
#tab-content { font-size: 15px; line-height: 1.7; }
.item-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 8px; border-bottom: 1px dashed #352d22; gap: 6px;
}
.item-row .ir-name { flex: 1; }
.item-row .ir-name { font-size: 15px; }
.item-row .ir-grade-1 { color: #b0a58f; } .item-row .ir-grade-2 { color: #9fc78a; }
.item-row .ir-grade-3 { color: #7db8d9; } .item-row .ir-grade-4 { color: #c39be0; }
.item-row .ir-grade-5 { color: var(--gold2); } .item-row .ir-grade-6 { color: #f28c5a; }
.skill-card { background: var(--ink2); border-radius: 4px; padding: 8px 10px; margin-bottom: 8px; }
.skill-card .sc-head { display: flex; justify-content: space-between; }
.skill-card .sc-prof { color: var(--muted); font-size: 14px; margin-top: 3px; }
.skill-card .sc-stage { color: var(--gold); font-size: 14px; }
.npc-list-row { display: flex; align-items: center; gap: 10px; padding: 6px; border-bottom: 1px dashed #352d22; cursor: pointer; }
.npc-list-row:hover { background: var(--ink2); }
.npc-list-row canvas { image-rendering: pixelated; }
.npc-list-row { font-size: 15px; }
.npc-detail { padding: 4px; }
.npc-detail h3 { color: var(--gold2); margin-bottom: 6px; }
.npc-detail .bio { color: var(--muted); font-size: 14px; margin-top: 6px; }
.bio li { list-style: none; margin-bottom: 3px; }
.quest-line { margin-bottom: 6px; }
.quest-line.done { color: var(--muted); text-decoration: line-through; }
.quest-line.cur { color: var(--gold2); }
.ach-row { padding: 4px 0; border-bottom: 1px dashed #352d22; }
.ach-row.locked { color: #55503f; }
.ach-row .ach-name { color: var(--gold); }

/* 弹窗 */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal-box {
  background: var(--panel); border: 1px solid var(--gold); border-radius: 8px;
  padding: 18px 22px; width: 420px; max-height: 80vh; overflow-y: auto;
}
.modal-box h3 { color: var(--gold2); margin-bottom: 4px; }
.modal-box .m-role { color: var(--muted); font-size: 15px; margin-bottom: 10px; }
.modal-box .m-sprite { display: flex; justify-content: center; margin: 8px 0; }
.modal-box .m-sprite canvas { image-rendering: pixelated; }
.dialog-box {
  background: var(--ink2); border: 1px solid var(--line); border-left: 3px solid var(--gold);
  border-radius: 4px; padding: 12px 14px; font-size: 16px; line-height: 1.9;
  min-height: 64px; margin: 10px 0; color: var(--text);
}
.modal-btns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.modal-btns .btn { font-size: 15px; }
.modal-close { margin-top: 14px; width: 100%; }

#tab-content .ir-name { font-size: 15px; }
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: #2e2818; border: 1px solid var(--gold); color: var(--gold2);
  padding: 9px 24px; border-radius: 6px; z-index: 99; font-size: 16px;
}

/* 结局 */
#screen-ending { background: radial-gradient(ellipse at 50% 40%, #2a2118 0%, #0d0b09 75%); }
.ending-box { text-align: center; max-width: 640px; padding: 30px; }
.ending-title { font-size: 56px; color: var(--gold); letter-spacing: 14px; margin-bottom: 24px; }
.ending-text { font-size: 18px; line-height: 2.2; color: var(--text); margin-bottom: 26px; }
.ending-stats { color: var(--muted); font-size: 15px; margin-bottom: 30px; line-height: 2; }

/* 滚动条 */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--ink); }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold); }
