/* ============ 晨曦大陆 · 暗色奇幻主题 ============ */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #14161d;
  --panel: #1d212c;
  --panel2: #242a38;
  --border: #343c4f;
  --text: #cfd6e4;
  --dim: #7d8699;
  --gold: #e8c364;
  --accent: #6f8ff5;
  --hp: #d05656;
  --exp: #5fb878;
  --mhp: #b8845f;
  --r0: #c9cfdb;
  --r1: #7ec8ff;
  --r2: #ffd76a;
  --r3: #ff8a3c;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  font-size: 14px;
}

/* ---------- 顶栏 ---------- */
#topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 18px;
  background: linear-gradient(180deg, #1b1f2b, #161922);
  border-bottom: 1px solid var(--border);
}
.logo { font-size: 19px; font-weight: bold; color: var(--gold); letter-spacing: 2px; }
.logo .sub { font-size: 12px; color: var(--dim); letter-spacing: 1px; margin-left: 6px; }
.resources .res { margin-left: 18px; color: var(--dim); }
.resources .res b { color: var(--text); margin-left: 3px; }
.res.gold b { color: var(--gold); }
.res.stone b { color: var(--r1); }
.res.feather b { color: #8fe0c8; }
.res.rebirth b { color: #c98ff5; }

/* ---------- 布局 ---------- */
main { display: flex; gap: 14px; padding: 14px; max-width: 1180px; margin: 0 auto; }
#charPanel { width: 280px; flex-shrink: 0; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 14px; align-self: flex-start; }
#mainArea { flex: 1; min-width: 0; }

/* ---------- 角色面板 ---------- */
.char-avatar { display: flex; align-items: center; justify-content: center; margin-bottom: 4px; min-height: 150px; }
.char-avatar .svg-char { filter: drop-shadow(0 3px 5px rgba(0,0,0,.5)); }
.char-head { margin-bottom: 10px; text-align: center; }
.char-name { font-size: 17px; font-weight: bold; }
.char-class { color: var(--dim); font-size: 12px; margin-top: 2px; }

.bar-wrap { margin: 8px 0; }
.bar { position: relative; height: 20px; background: #11131a; border: 1px solid var(--border); border-radius: 4px; overflow: hidden; }
.bar .fill { height: 100%; transition: width .4s; }
.bar.exp .fill { background: linear-gradient(90deg, #3d7a52, var(--exp)); }
.bar.hp .fill { background: linear-gradient(90deg, #8a3535, var(--hp)); }
.bar.mhp .fill { background: linear-gradient(90deg, #7a5235, var(--mhp)); }
.bar span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 11px; text-shadow: 0 1px 2px #000; }

.stat-points { margin: 10px 0 4px; color: var(--gold); font-size: 13px; }
.stats { margin-top: 8px; }
.stat-row { display: flex; align-items: center; padding: 5px 0; border-bottom: 1px dashed #2a3040; }
.stat-row > span:first-child { width: 42px; color: var(--dim); }
.stat-row b { flex: 1; }
.stat-row .plus, .plus { color: var(--exp); font-style: normal; font-size: 12px; margin-left: 4px; }
.alloc button { margin-left: 4px; padding: 1px 6px; font-size: 11px; }

.respec-row { margin-top: 8px; }
.respec-row button { width: 100%; font-size: 12px; padding: 5px 0; }
.inv-tools button { padding: 4px 12px; font-size: 12px; }

.derived { margin-top: 12px; padding-top: 8px; border-top: 1px solid var(--border); }
.d-row { display: flex; justify-content: space-between; padding: 3px 0; font-size: 13px; }
.d-row span { color: var(--dim); }

/* ---------- 页签 ---------- */
#tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.tab {
  padding: 8px 22px; background: var(--panel); color: var(--dim);
  border: 1px solid var(--border); border-radius: 6px 6px 0 0; cursor: pointer; font-size: 14px;
}
.tab.active { background: var(--panel2); color: var(--gold); border-bottom-color: var(--panel2); }
.tab-page { display: none; background: var(--panel2); border: 1px solid var(--border); border-radius: 0 8px 8px 8px; padding: 16px; min-height: 480px; }
.tab-page.active { display: block; }

/* ---------- 战斗页 ---------- */
.combat-top { display: flex; gap: 14px; margin-bottom: 12px; }
.map-info { flex: 1; }
.map-name { font-size: 17px; color: var(--gold); font-weight: bold; }
.kill-stats { color: var(--dim); font-size: 12px; margin-top: 6px; line-height: 1.9; }
.kill-stats b { color: var(--gold); }
.monster-card { flex: 1.4; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 12px; position: relative; overflow: hidden; }
#floatLayer { position: absolute; inset: 0; pointer-events: none; }
.float-dmg {
  position: absolute; bottom: 28%; font-weight: bold; font-size: 14px;
  color: var(--gold); text-shadow: 0 1px 3px #000;
  animation: floatUp .9s ease-out forwards;
}
.float-dmg.skill { color: #7ec8ff; font-size: 16px; }
@keyframes floatUp {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-44px); }
}
.fill.hitflash { animation: hitflash .25s; }
@keyframes hitflash { 0% { filter: brightness(2.2); } 100% { filter: none; } }
.monster-name { font-weight: bold; margin-bottom: 8px; }
.monster-sub { color: var(--dim); font-size: 12px; margin-top: 6px; }
.elite { color: #f58a6f; }

.log-title { color: var(--dim); font-size: 12px; margin: 10px 0 6px; }
#combatLog { height: 330px; overflow-y: auto; background: #161924; border: 1px solid var(--border); border-radius: 6px; padding: 8px 12px; font-size: 13px; line-height: 1.8; }
.log-kill { color: var(--text); }
.log-hit { color: var(--accent); }
.log-drop { color: var(--gold); }
.log-level { color: var(--exp); font-weight: bold; }
.log-death { color: var(--hp); }
.log-sys { color: var(--dim); }

/* ---------- 背包页 ---------- */
.inv-layout { display: flex; gap: 14px; }
.inv-left { flex: 1.6; min-width: 0; }
.inv-right { flex: 1; }
.section-title { color: var(--gold); margin: 4px 0 8px; font-size: 14px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-bottom: 16px; }
.cell {
  background: var(--panel); border: 1px solid var(--border); border-radius: 6px;
  padding: 10px 11px; cursor: pointer; transition: border-color .15s;
}
.cell:hover { border-color: var(--accent); }
.cell.sel { border-color: var(--gold); }
.cell.empty { cursor: default; }
.cell.empty:hover { border-color: var(--border); }
/* 详情面板右上角的大装备图标 */
/* 已装备格子内的小图标 */
.cell-icon { text-align: center; margin-bottom: 2px; }
.cell-icon .svg-item, .cell-icon .svg-wing { display: inline-block; vertical-align: middle; }
/* 详情面板右上角的大装备图标 */
.detail-icon { float: right; margin: -2px 0 6px 10px; }
.detail-icon .svg-item, .detail-icon .svg-wing { display: block; }
/* 翅膀图标横展开，不浮动而是整行居中展示在属性上方 */
.detail-icon-wing { float: none; margin: 4px 0 10px; text-align: center; }
.detail-icon-wing .svg-wing { display: inline-block; }
.cell-name { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-sub { font-size: 11px; color: var(--dim); margin-top: 3px; }
.up { color: var(--exp); font-style: normal; font-weight: bold; margin-right: 3px; }
.down { color: var(--hp); }
.inv-filter { display: flex; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.filter-btn { padding: 4px 12px; font-size: 12px; background: var(--panel); border: 1px solid var(--border); color: var(--dim); }
.filter-btn.active { background: var(--panel2); border-color: var(--gold); color: var(--gold); }
.inv-tools {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  background: var(--panel); border: 1px solid var(--border); border-radius: 6px;
  padding: 8px 12px; margin-bottom: 10px; font-size: 12px;
}
.inv-tools select {
  background: #2c3650; color: var(--text); border: 1px solid #41507a;
  border-radius: 4px; padding: 3px 8px; font-family: inherit; margin-left: 4px;
}
.r0 .cell-name, .detail-name.r0, span.r0, b.r0 { color: var(--r0); }
.r1 .cell-name, .detail-name.r1, span.r1, b.r1 { color: var(--r1); }
.r2 .cell-name, .detail-name.r2, span.r2, b.r2 { color: var(--r2); }
.r3 .cell-name, .detail-name.r3, span.r3, b.r3 { color: var(--r3); }
.r3 .cell-name { text-shadow: 0 0 6px rgba(255,138,60,.5); }

.item-detail { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 14px; line-height: 1.9; font-size: 13px; }
.detail-name { font-size: 15px; font-weight: bold; }
.affix { color: var(--r1); }
.legend-affix { color: var(--r3); font-weight: bold; margin-top: 2px; }
.pet-stars { color: var(--gold); font-size: 12px; letter-spacing: -1px; }
.item-detail hr { border: none; border-top: 1px solid var(--border); margin: 8px 0; }
.item-detail button { margin: 6px 6px 0 0; }
.risk-zero { color: var(--hp); }
.risk-down { color: var(--gold); }
.enh-skip { display: block; margin-top: 8px; font-size: 12px; color: var(--dim); cursor: pointer; }
.enh-skip input { vertical-align: -1px; margin-right: 4px; }

/* ---------- 地图页 ---------- */
/* 章节折叠 */
.chapter { border: 1px solid var(--border); border-radius: 8px; margin-bottom: 12px; overflow: hidden; background: #191d27; }
.chapter.done { border-color: #46603f; }
.chapter-head {
  display: flex; align-items: center; gap: 8px; cursor: pointer;
  padding: 12px 14px; background: linear-gradient(180deg, #222838, #1b202c);
  user-select: none;
}
.chapter-head:hover { background: #262d40; }
.chapter-head b { font-size: 15px; color: var(--gold); }
.chapter-arrow { color: var(--dim); width: 14px; }
.chapter-prog { margin-left: auto; font-size: 12px; }
.chapter-desc { font-size: 12px; padding: 0 14px 10px; }
.chapter.locked .chapter-head b { color: var(--dim); }
.chapter-maps { padding: 4px 14px 12px; }

.map-card { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 14px; margin-bottom: 10px; }
.map-card.current { border-color: var(--gold); }
.map-card.locked { opacity: .55; }
.map-card-head { display: flex; justify-content: space-between; align-items: baseline; }
.map-card-head b { font-size: 15px; color: var(--text); }
.map-desc { font-size: 12px; margin: 6px 0; }
.map-mobs { margin: 8px 0; }
.map-mobs .mob {
  display: inline-block; font-size: 11px; color: var(--dim);
  background: #161924; border: 1px solid var(--border); border-radius: 4px;
  padding: 2px 8px; margin: 0 6px 6px 0;
}
.map-mobs .mob.elite { color: #f58a6f; border-color: #5a3a32; }
.boss-row {
  margin: 4px 0 10px; padding: 7px 10px; font-size: 12px;
  background: #1d1722; border: 1px solid #4a3252; border-radius: 6px;
}
.boss-row b { color: #d9a5f0; }
.boss-btn { margin-left: 8px; background: #46295a; border-color: #6e4a86; }
.boss-btn:hover:not(:disabled) { background: #57356f; }
.boss-tag { color: #d9a5f0; font-weight: bold; }
.set-info {
  font-size: 12px; line-height: 1.8; margin: -6px 0 16px;
  padding: 7px 10px; background: var(--panel); border: 1px solid var(--border); border-radius: 6px;
}

/* ---------- 转生页 / 帮助页 ---------- */
.rebirth-box, .help { max-width: 620px; line-height: 1.9; }
.rebirth-box h3, .help h3 { color: var(--gold); margin-bottom: 10px; }
.help h4 { color: var(--accent); margin: 14px 0 4px; }
.rebirth-box hr { border: none; border-top: 1px solid var(--border); margin: 12px 0; }
.save-tools { margin-top: 16px; }
.save-tools textarea {
  display: block; width: 100%; height: 90px; margin-top: 10px;
  background: #11131a; color: var(--dim); border: 1px solid var(--border);
  border-radius: 6px; padding: 8px; font-size: 11px; resize: vertical;
}

/* ---------- 通用 ---------- */
button {
  background: #2c3650; color: var(--text); border: 1px solid #41507a;
  border-radius: 5px; padding: 6px 16px; cursor: pointer; font-size: 13px;
  font-family: inherit;
}
button:hover:not(:disabled) { background: #38446a; }
button:disabled { opacity: .45; cursor: default; }
button.danger { background: #4a2c2c; border-color: #6e4040; }
button.danger:hover:not(:disabled) { background: #5e3535; }

.dot {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: #e85b5b; margin-left: 5px; vertical-align: 2px;
}
.shop-row {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--panel); border: 1px solid var(--border); border-radius: 6px;
  padding: 9px 12px; margin-bottom: 8px;
}
.shop-buy { white-space: nowrap; color: var(--dim); font-size: 13px; }
.shop-row.locked { opacity: .5; }
.skill-slot {
  display: inline-block; background: #161924; border: 1px solid var(--border);
  border-radius: 4px; padding: 2px 10px; margin-right: 6px; font-size: 12px; color: var(--accent);
}
.shop-buy button { margin-left: 8px; padding: 4px 14px; }

.dim { color: var(--dim); }
.pad { padding: 10px; }
.hidden { display: none !important; }

/* ---------- 弹窗 ---------- */
#modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.65);
  display: flex; align-items: center; justify-content: center; z-index: 10;
}
.modal-box {
  background: var(--panel2); border: 1px solid var(--gold); border-radius: 10px;
  padding: 22px 26px; width: 420px; max-height: 80vh; overflow-y: auto; line-height: 1.9;
}
.modal-box h3 { color: var(--gold); margin-bottom: 10px; }
.modal-box button { margin-top: 14px; width: 100%; }
.modal-items span { display: inline-block; font-size: 12px; margin: 2px 10px 2px 0; }

/* 合成结果弹窗 + 动画 */
#craftModal {
  position: fixed; inset: 0; background: rgba(0,0,0,.7);
  display: flex; align-items: center; justify-content: center; z-index: 11;
}
.craft-result {
  background: var(--panel2); border: 2px solid var(--border); border-radius: 12px;
  padding: 26px 30px; width: 380px; text-align: center; line-height: 1.8;
}
.craft-result h3 { font-size: 22px; margin: 6px 0 10px; }
.craft-result h3.plus { color: var(--gold); }
.craft-result h3.fail { color: var(--hp); }
.craft-result button { margin-top: 16px; width: 100%; }
.craft-icon { font-size: 56px; line-height: 1; }
/* 成功：金光放大 + 边框发光 */
.craft-result.craft-success { border-color: var(--gold); animation: craftWin .6s ease-out; box-shadow: 0 0 30px rgba(232,195,100,.5); }
.craft-result.craft-success .craft-icon { animation: iconPop .6s ease-out; }
@keyframes craftWin {
  0% { transform: scale(.7); opacity: 0; }
  50% { transform: scale(1.08); }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes iconPop {
  0% { transform: scale(0) rotate(-30deg); }
  60% { transform: scale(1.4) rotate(10deg); }
  100% { transform: scale(1) rotate(0); }
}
/* 失败：灰暗 + 抖动 */
.craft-result.craft-fail { border-color: var(--hp); animation: craftFail .5s; }
.craft-result.craft-fail .craft-icon { filter: grayscale(1); opacity: .8; }
@keyframes craftFail {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-12px); }
  30% { transform: translateX(10px); }
  45% { transform: translateX(-7px); }
  60% { transform: translateX(5px); }
  75% { transform: translateX(-3px); }
}

/* 自动刷 Boss 开关 */
.auto-boss { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text); margin-top: 8px; cursor: pointer; }
.auto-boss input { vertical-align: -1px; }
.fail { color: var(--hp); }

/* ---------- 窄屏适配 ---------- */
@media (max-width: 860px) {
  main { flex-direction: column; }
  #charPanel { width: 100%; }
  .inv-layout, .combat-top { flex-direction: column; }
}
