:root {
  --bg: #1b2233;
  --panel: #243049;
  --panel2: #2e3c5a;
  --accent: #ffcf4d;
  --text: #e8eefc;
  --muted: #9fb0d0;
  --red: #ff5a5a;
  --green: #54d98c;
  --white: #f2f4f8;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%;
  background: #0d1018; color: var(--text);
  font-family: -apple-system, system-ui, "PingFang SC", "Microsoft YaHei", sans-serif;
  overflow: hidden;
}

#app {
  position: relative;
  width: 100%; max-width: 480px;
  height: 100%; max-height: 100vh;
  margin: 0 auto;
  background: var(--bg);
  overflow: hidden;
  display: flex; flex-direction: column;
}

.screen { position: absolute; inset: 0; display: flex; flex-direction: column; }
.hidden { display: none !important; }

/* ---------- 主城：顶栏 ---------- */
.top-bar {
  display: flex; justify-content: space-between; align-items: center;
  padding: calc(var(--safe-top) + 8px) 12px 8px;
  background: linear-gradient(180deg, #2a3550, #1b2233);
}
.tb-left #tb-level { font-weight: 700; color: var(--accent); }
.tb-right span { margin-left: 10px; font-size: 13px; }

.mc-body { flex: 1; padding: 16px; overflow: auto; }
.mc-hero { font-size: 18px; font-weight: 700; }
.mc-tip { color: var(--muted); line-height: 1.7; margin-top: 10px; }

.bottom-bar {
  display: flex; gap: 8px;
  padding: 8px 8px calc(var(--safe-bottom) + 8px);
  background: #161c2b;
}
.bb-btn {
  flex: 1; min-width: 0; padding: 12px 0; border: none; border-radius: 12px;
  background: var(--panel2); color: var(--text);
  font-size: 13px; font-weight: 600; white-space: nowrap;
}
.bb-btn:active { transform: scale(.97); }

/* ---------- 战斗 ---------- */
.battle-top {
  display: flex; align-items: center; gap: 10px;
  padding: calc(var(--safe-top) + 8px) 12px 8px;
  background: #2a3550; font-size: 14px;
}
.battle-stage { position: relative; flex: 1; min-height: 0; }
.battle-canvas { width: 100%; height: 100%; display: block; background: #0f1626; }

.battle-command {
  position: absolute; left: 0; right: 0;
  bottom: calc(var(--safe-bottom) + 8px);
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: center;
  padding: 8px;
  background: rgba(13, 16, 24, .88);
}
.cmd {
  min-width: 76px; padding: 12px 10px; border: none; border-radius: 10px;
  background: var(--panel2); color: var(--text); font-size: 14px; font-weight: 600;
}
.cmd:active { transform: scale(.96); }
.cmd.atk { background: #3a4d6b; }
.cmd.sk.red { background: #5a2b34; color: #ffb3b3; }
.cmd.sk.green { background: #234a36; color: #a7ffcf; }
.cmd.sk.white { background: #3a4255; }
.cmd.def { background: #444; }

.battle-log {
  position: absolute; top: 6px; left: 8px; right: 8px;
  font-size: 12px; color: var(--muted);
  pointer-events: none; max-height: 34%; overflow: hidden;
}
.battle-log div { margin: 2px 0; }

.mini-btn {
  padding: 6px 10px; border: none; border-radius: 8px;
  background: var(--panel2); color: var(--text); font-size: 13px;
}
#bt-focus.active { background: #7a2b2b; color: #ffd0d0; }

.target-hint {
  width: 100%; text-align: center; font-size: 14px; font-weight: 600;
  color: var(--accent); padding: 4px 0 2px;
}

/* ---------- 弹窗面板 ---------- */
.modal {
  position: absolute; inset: 0; z-index: 20;
  background: rgba(0, 0, 0, .6);
  display: flex; align-items: center; justify-content: center;
}
.modal-card {
  width: 90%; max-height: 80%; background: var(--panel);
  border-radius: 14px; display: flex; flex-direction: column; overflow: hidden;
}
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 14px; border-bottom: 1px solid #3a4a6a; font-weight: 700;
}
.modal-body { padding: 14px; overflow: auto; line-height: 1.7; }

.kv { margin: 4px 0; }
.muted { color: var(--muted); }
hr { border: none; border-top: 1px solid #3a4a6a; margin: 10px 0; }

.attr-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; }
.attr-grid div { font-size: 13px; }

.skill-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.skill {
  padding: 6px 10px; border-radius: 8px; font-size: 13px;
  background: #3a4255; color: var(--white);
}
.skill.red { background: #5a2b34; color: #ffb3b3; }
.skill.green { background: #234a36; color: #a7ffcf; }
.skill.white { background: #3a4255; }

.pet { padding: 8px; border: 1px solid #3a4a6a; border-radius: 10px; margin-bottom: 8px; font-size: 13px; }
.tag { display: inline-block; padding: 1px 6px; border-radius: 6px; background: #6a4b1f; color: var(--accent); font-size: 11px; }

/* ---------- 装备强化交互 ---------- */
.sec-title { font-weight: 700; margin: 6px 0 8px; color: var(--accent); }
.tip { font-size: 12px; margin-top: 10px; }

.eq-list { display: flex; flex-direction: column; gap: 8px; }
.eq-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; border-radius: 10px;
  background: var(--panel2); border: 1px solid #3a4a6a;
}
.eq-row[data-eq-act="detail"] { cursor: pointer; }
.eq-row[data-eq-act="detail"]:active { transform: scale(.985); background: #36456a; }
.eq-row.empty { opacity: .6; }
.eq-info { display: flex; flex-direction: column; gap: 2px; }
.eq-name { font-weight: 600; font-size: 14px; }
.eq-slot { font-size: 11px; color: var(--muted); }
.eq-lv { font-size: 13px; font-weight: 700; color: var(--accent); }
.eq-lv.maxed { color: var(--green); }

.btn-back {
  display: inline-block; margin-bottom: 10px; padding: 6px 12px;
  border: none; border-radius: 8px; background: var(--panel2); color: var(--text); font-size: 13px;
}
.btn-back:active { transform: scale(.97); }
.eq-title { font-size: 17px; font-weight: 700; margin-bottom: 4px; }

.enh-bar { height: 8px; border-radius: 6px; background: #1a2236; overflow: hidden; margin: 8px 0 12px; }
.enh-fill { height: 100%; background: linear-gradient(90deg, #ffcf4d, #ff9a3c); transition: width .25s ease; }

.stat-block { background: #1a2236; border-radius: 10px; padding: 8px 10px; }
.stat-line { display: flex; align-items: baseline; gap: 8px; padding: 3px 0; font-size: 13px; }
.stat-line > span:first-child { color: var(--muted); min-width: 56px; }
.stat-now { font-weight: 700; }
.stat-up { color: var(--green); font-weight: 700; }

.cost { margin: 12px 0 8px; font-size: 13px; }
.cost-ok { color: var(--text); }
.cost-bad { color: var(--red); }
.btn-enh {
  width: 100%; padding: 12px 0; border: none; border-radius: 10px;
  background: linear-gradient(180deg, #ffd24d, #f0a92e); color: #2a1d00;
  font-size: 15px; font-weight: 700;
}
.btn-enh:active { transform: scale(.985); }
.btn-enh.disabled, .btn-enh:disabled { background: #3a4255; color: var(--muted); }

.toast {
  margin-top: 10px; min-height: 18px; text-align: center; font-size: 13px;
  font-weight: 600; opacity: 0; transition: opacity .2s;
}
.toast.show { opacity: 1; }
.toast.ok { color: var(--green); }
.toast.bad { color: var(--red); }
.silver { color: var(--accent); }

/* ---------- 宠物 / 出战 ---------- */
.mc-pet { margin-top: 8px; font-size: 14px; color: var(--muted); }
.mc-pet span { color: var(--green); font-weight: 600; }

.pet-summary { background: #1a2236; border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; }
.pet-active { color: var(--green); }
.pet-cards { display: flex; flex-direction: column; gap: 10px; }
.pet-card {
  border: 1px solid #3a4a6a; border-radius: 12px; padding: 10px 12px;
  background: var(--panel2);
}
.pet-card.active { border-color: var(--green); box-shadow: 0 0 0 1px rgba(84,217,140,.35) inset; }
.pet-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 14px; }
.pet-head .tag { margin-left: auto; }
.pet-apt { display: flex; flex-direction: column; gap: 3px; margin: 6px 0; }
.apt-row { display: flex; align-items: center; gap: 8px; font-size: 11px; }
.apt-row > span:first-child { width: 30px; color: var(--muted); flex: none; }
.apt-row b { width: 38px; text-align: right; font-size: 11px; }
.apt-bar { flex: 1; height: 6px; border-radius: 4px; background: #141b2b; overflow: hidden; }
.apt-fill { height: 100%; background: linear-gradient(90deg, #54d98c, #ffcf4d); }
.exp-fill { height: 100%; background: linear-gradient(90deg, #49d0ff, #8ab6ff); transition: width .25s ease; }
.pet-skills { display: flex; flex-wrap: wrap; gap: 5px; margin: 8px 0; }
.skill-tag { padding: 2px 8px; border-radius: 6px; font-size: 11px; background: #3a4255; color: var(--white); }
.pet-btns, .pet-ops { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pet-ops { margin-top: 8px; }
.pet-state { color: var(--green); font-size: 13px; font-weight: 700; }
.btn-sm {
  padding: 7px 14px; border: none; border-radius: 8px;
  background: var(--panel); color: var(--text); font-size: 13px; font-weight: 600;
}
.btn-sm:active { transform: scale(.97); }
.btn-sm.deploy { background: linear-gradient(180deg, #ffd24d, #f0a92e); color: #2a1d00; }
.btn-sm.rest { background: #4a3550; color: #ffc7d8; }
.btn-sm.disabled, .btn-sm:disabled { background: #333b4d; color: var(--muted); }

/* ---------- 技能 / 流派 ---------- */
.sk-summary { background: #1a2236; border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; }
.sk-tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.sk-tab {
  flex: 1; padding: 8px 0; border: none; border-radius: 8px;
  background: var(--panel2); color: var(--muted); font-size: 13px; font-weight: 600;
}
.sk-tab.active { background: var(--accent); color: #2a1d00; }
.sk-content { display: flex; flex-direction: column; gap: 8px; }
.sk-card, .school-card {
  border: 1px solid #3a4a6a; border-radius: 10px; padding: 9px 11px;
  background: var(--panel2); cursor: pointer;
}
.sk-card:active { transform: scale(.99); }
.sk-card.equipped { border-color: var(--green); box-shadow: 0 0 0 1px rgba(84,217,140,.3) inset; }
.sk-card.fixed { cursor: default; opacity: .8; }
.school-card.active { border-color: var(--accent); }
.sk-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 14px; }
.sk-red { color: #ff8a8a; }
.sk-green { color: #8affc0; }
.sk-white { color: var(--text); }
.sk-meta { font-size: 11px; color: var(--muted); margin-top: 3px; }
.sk-desc { font-size: 12px; color: #c8d4ee; margin-top: 4px; line-height: 1.5; }
.sk-ops { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }

/* ---------- 宠物捕捉 / 孵化 / 全局提示 ---------- */
.mc-eggs { margin-top: 4px; font-size: 13px; color: var(--muted); }
.mc-eggs span { color: var(--accent); font-weight: 600; }
.mc-stamina { margin-top: 4px; font-size: 13px; color: var(--muted); }
.mc-stamina span { color: #8ab6ff; font-weight: 600; }
.notice {
  position: absolute; left: 50%; top: 14%; transform: translateX(-50%);
  z-index: 40; padding: 10px 18px; border-radius: 10px;
  background: rgba(20, 28, 45, .95); border: 1px solid var(--accent);
  color: var(--accent); font-size: 14px; font-weight: 600;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .45);
  max-width: 88%; text-align: center; white-space: normal; line-height: 1.5;
}
.pet-stat-bar {
  background: #1a2236; border-radius: 8px; padding: 7px 10px;
  font-size: 12px; color: var(--muted);
}
.pet-stat-bar b { color: var(--text); }
.area-card { border: 1px solid #3a4a6a; border-radius: 10px; padding: 10px 12px; background: var(--panel2); }
.pet-pool { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.pool-tag { padding: 2px 7px; border-radius: 6px; font-size: 11px; background: #313c56; color: #c8d4ee; }

/* ---------- 编队 / 图鉴 / 进阶标签 ---------- */
.pet-badges { display: inline-flex; gap: 4px; margin-left: auto; }
.pet-head .pet-badges .tag { margin-left: 0; }
.tag.stage { background: #3a5a8f; color: #cfe4ff; }
.tag.mutated { background: #6a3a8f; color: #f0d4ff; }
.slot-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.slot-card { border: 1px solid #3a4a6a; border-radius: 10px; padding: 9px 11px; background: var(--panel2); }
.slot-card.filled { border-color: var(--green); }
.slot-card.locked { opacity: .55; }
.dex-card { border: 1px solid #3a4a6a; border-radius: 10px; padding: 9px 11px; background: var(--panel2); }
.dex-card.locked { opacity: .45; }
.synergy-card { border: 1px solid #3a4a6a; border-radius: 10px; padding: 9px 11px; background: var(--panel2); opacity: .6; }
.synergy-card.on { border-color: var(--green); opacity: 1; box-shadow: 0 0 0 1px rgba(84,217,140,.25) inset; }
.equip-slot { border: 1px solid #3a4a6a; border-radius: 10px; padding: 9px 11px; margin-bottom: 8px; background: #1a2236; }
.enh-lv { color: var(--accent); font-size: 12px; font-weight: 700; }
.mini-x {
  margin-left: 6px; padding: 1px 6px; border: none; border-radius: 5px;
  background: #4a5a7d; color: #e8eefc; font-size: 10px;
}
.mini-x:active { transform: scale(.95); }

/* ---------- 启动状态 ---------- */
#boot-status {
  position: absolute; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  text-align: center; padding: 24px;
  background: var(--bg); color: var(--muted); font-size: 14px;
}
