:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --line: #e4e7ec;
  --text: #1b2430;
  --muted: #667085;
  --accent: #334155;
  --c-white: #9ca3af;
  --c-green: #16a34a;
  --c-blue: #2563eb;
  --c-purple: #7c3aed;
  --c-gold: #d97706;
  --c-red: #dc2626;
  --c-black: #1e293b;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

code {
  background: #eef1f5;
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 12px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 10px 20px;
  flex-wrap: wrap;
}

.brand { font-size: 18px; font-weight: 800; letter-spacing: 1px; }

.top-stats {
  display: flex;
  gap: 18px;
  font-size: 13px;
  color: var(--muted);
  flex: 1;
  flex-wrap: wrap;
}

.stat b { color: var(--text); font-weight: 700; }

.tabs { display: flex; gap: 6px; }

.tab-btn {
  border: 0;
  background: transparent;
  padding: 8px 16px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  color: var(--muted);
  transition: background .15s, color .15s;
}

.tab-btn:hover { background: #eef1f5; color: var(--text); }

.tab-btn.active { background: var(--accent); color: #fff; }

main { max-width: 1100px; margin: 20px auto; padding: 0 20px 60px; }

.tab { display: none; }
.tab.active { display: block; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 20px;
  margin-bottom: 16px;
}

.panel h3 { font-size: 15px; margin-bottom: 10px; }

.panel p { color: var(--muted); font-size: 13px; margin-bottom: 8px; }

h3 { font-size: 15px; color: var(--text); margin: 14px 0 8px; }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }

.btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 10px;
  padding: 8px 16px;
  cursor: pointer;
  font-size: 13px;
  transition: all .15s;
}

.btn:hover { border-color: #c8cdd6; background: #f9fafb; }

.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary:hover { background: #1e293b; }

.btn.danger { color: var(--c-red); border-color: #fecaca; }
.btn.danger:hover { background: #fef2f2; }

.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: #eef1f5; }

.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:disabled:hover { background: #fff; border-color: var(--line); }
.btn.primary:disabled:hover { background: var(--accent); }

.hint { font-size: 12px; color: var(--muted); }

.battle-layout { display: grid; grid-template-columns: 1fr 300px; gap: 20px; align-items: start; }

.battle-stage { text-align: center; }

.monster-box { padding: 18px 0 6px; }

#monster-img {
  width: 150px;
  height: 150px;
  object-fit: contain;
  cursor: pointer;
  transition: width .5s, height .5s;
}

#monster-img.m-hit { animation: mHit .3s ease; }

@keyframes mHit {
  0% { transform: scale(1); }
  40% { transform: scale(.82); }
  100% { transform: scale(1); }
}

.monster-timer { margin: 8px 0 2px; font-size: 13px; color: var(--muted); }

.monster-timer b { color: var(--text); }

.monster-name { margin: 6px 0; color: var(--muted); font-size: 14px; }

.hpbar {
  width: 260px;
  max-width: 80vw;
  height: 12px;
  margin: 0 auto;
  background: #e8ebf0;
  border-radius: 99px;
  overflow: hidden;
}

.hpbar-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #34d399, #10b981);
  border-radius: 99px;
  transition: width .15s linear;
}

.row-caption { margin-top: 18px; font-size: 12px; color: var(--muted); }

.battle-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  justify-content: center;
  min-height: 130px;
  padding: 30px 10px 10px;
}

.mini-card {
  width: 58px;
  border-radius: 10px;
  padding: 2px;
  transition: transform .2s;
}

.mini-card.center {
  transform: translateY(-18px) scale(1.28);
  z-index: 2;
  box-shadow: 0 8px 20px rgba(15, 23, 42, .18);
}

.frame { border-radius: 10px; padding: 3px; }
.frame-white { background: var(--c-white); }
.frame-green { background: var(--c-green); }
.frame-blue { background: var(--c-blue); }
.frame-purple { background: var(--c-purple); }
.frame-gold { background: var(--c-gold); }
.frame-red { background: var(--c-red); }
.frame-black { background: var(--c-black); }
.frame-rainbow { position: relative; overflow: hidden; }
.codex-cell.frame-rainbow { padding: 7px; }

.frame-rainbow::before {
  content: '';
  position: absolute;
  inset: -60%;
  background: conic-gradient(from 0deg, #f43f5e, #f59e0b, #84cc16, #22c55e, #0ea5e9, #8b5cf6, #f43f5e);
  animation: egg-spin 3.5s linear infinite;
}

.frame-rainbow .frame-inner {
  position: relative;
  z-index: 1;
  box-shadow: 0 0 12px rgba(139, 92, 246, .5);
}

.frame-rainbow .frame-inner::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    repeating-linear-gradient(115deg, rgba(255, 255, 255, .08) 0 2px, rgba(255, 255, 255, 0) 2px 10px),
    conic-gradient(from 0deg,
      rgba(244, 63, 94, .20), rgba(245, 158, 11, .17), rgba(132, 204, 22, .17),
      rgba(34, 197, 94, .17), rgba(14, 165, 233, .19), rgba(139, 92, 246, .20),
      rgba(236, 72, 153, .19), rgba(244, 63, 94, .20));
  animation: laser-slide 6s linear infinite, laser-hue 12s linear infinite;
}

@keyframes laser-slide {
  from { background-position: 0 0, 0 0; }
  to { background-position: 200px 0, 0 0; }
}

@keyframes laser-hue {
  from { filter: hue-rotate(0deg); }
  to { filter: hue-rotate(360deg); }
}

body.dark .frame-rainbow .frame-inner::after {
  background:
    repeating-linear-gradient(115deg, rgba(255, 255, 255, .06) 0 2px, rgba(255, 255, 255, 0) 2px 12px),
    conic-gradient(from 0deg,
      rgba(244, 63, 94, .12), rgba(245, 158, 11, .10), rgba(132, 204, 22, .10),
      rgba(34, 197, 94, .10), rgba(14, 165, 233, .11), rgba(139, 92, 246, .12),
      rgba(236, 72, 153, .11), rgba(244, 63, 94, .12));
}

.frame-inner {
  background: #fff;
  border: 1px solid #eef0f3;
  border-radius: 8px;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
}

.frame-white .frame-inner { border-color: var(--c-white); }
.frame-green .frame-inner { border-color: var(--c-green); }
.frame-blue .frame-inner { border-color: var(--c-blue); }
.frame-purple .frame-inner { border-color: var(--c-purple); }
.frame-gold .frame-inner { border-color: var(--c-gold); }
.frame-red .frame-inner { border-color: var(--c-red); }
.frame-black .frame-inner { border-color: var(--c-black); }
.frame-rainbow .frame-inner { border-color: #8b5cf6; }

.mini-art {
  height: 64px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  background: #fafbfc;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.mini-name {
  font-size: 10px;
  text-align: center;
  padding: 2px 0;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.egg-art {
  width: 100%;
  height: 100%;
  border-radius: 50% 50% 50% 50% / 58% 58% 42% 42%;
  position: relative;
  box-shadow: inset -4px -6px 10px rgba(0, 0, 0, .15);
}

.egg-art::before {
  content: '';
  position: absolute;
  left: 22%;
  top: 10%;
  width: 24%;
  height: 14%;
  border-radius: 50%;
  background: rgba(255, 255, 255, .75);
  filter: blur(1px);
}

.emoji-art { font-size: 40px; line-height: 1; }

.art-img { width: 100%; height: 100%; object-fit: contain; }

@keyframes egg-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

.quick-actions { display: flex; gap: 14px; align-items: center; justify-content: center; margin: 14px 0; }

.battle-log {
  text-align: left;
  border-top: 1px dashed var(--line);
  padding-top: 10px;
  max-height: 220px;
  overflow-y: auto;
}

.log-empty { color: var(--muted); font-size: 12px; text-align: center; padding: 10px; }

.log-entry {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 12px;
  padding: 5px 0;
  border-bottom: 1px dashed var(--line);
}

.log-time { color: var(--muted); font-size: 11px; }

.r-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.r-white { background: var(--c-white); }
.r-green { background: var(--c-green); }
.r-blue { background: var(--c-blue); }
.r-purple { background: var(--c-purple); }
.r-gold { background: var(--c-gold); }
.r-red { background: var(--c-red); }
.r-black { background: var(--c-black); }
.r-rainbow { background: conic-gradient(from 0deg, #f43f5e, #f59e0b, #22c55e, #0ea5e9, #8b5cf6, #f43f5e); }

.r-tag {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 99px;
  color: #fff;
  vertical-align: 2px;
}

.r-tag.r-white { background: var(--c-white); }
.r-tag.r-green { background: var(--c-green); }
.r-tag.r-blue { background: var(--c-blue); }
.r-tag.r-purple { background: var(--c-purple); }
.r-tag.r-gold { background: var(--c-gold); }
.r-tag.r-red { background: var(--c-red); }
.r-tag.r-black { background: var(--c-black); }
.r-tag.r-rainbow { background: conic-gradient(from 0deg, #f43f5e, #f59e0b, #22c55e, #0ea5e9, #8b5cf6, #f43f5e); }

.side h3:first-child { margin-top: 0; }

.fhead { font-weight: 700; margin-bottom: 8px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.fbody { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }

.frow { font-size: 12px; display: flex; gap: 6px; align-items: center; }
.frow.ok { color: #15803d; }
.frow.miss { color: #b91c1c; }

.fnote { font-size: 12px; color: var(--muted); border-top: 1px dashed var(--line); padding-top: 8px; }

.kv { display: flex; justify-content: space-between; font-size: 13px; padding: 4px 0; color: var(--muted); }
.kv b { color: var(--text); }
.rate-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  line-height: 1;
  padding: 5px 0;
}

.rate-row span:nth-child(2) { flex: 1; }

.rate-row b { font-weight: 600; }

.filter-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }

.chip {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 99px;
  padding: 6px 14px;
  font-size: 12px;
  cursor: pointer;
  transition: all .15s;
}

.chip:hover { border-color: #c8cdd6; }

.chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.chip-count { opacity: .7; font-size: 11px; }

.sort-label { font-size: 12px; color: var(--muted); align-self: center; }

.chip.dir { min-width: 76px; text-align: center; }

.num-input { width: 76px; padding: 6px 8px; font-size: 12px; border: 1px solid var(--line); border-radius: 8px; }

.search-input { flex: 1; min-width: 150px; max-width: 240px; padding: 6px 10px; font-size: 12px; border: 1px solid var(--line); border-radius: 8px; }

.star-btn { display: inline-block; text-decoration: none; font-weight: 600; }

.range-sep { color: var(--muted); font-size: 12px; }

.codex-head { margin-bottom: 14px; }

.codex-progress { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--muted); }

.bar { flex: 1; height: 8px; background: #e8ebf0; border-radius: 99px; overflow: hidden; }

.bar-fill { height: 100%; background: linear-gradient(90deg, #60a5fa, #a855f7); border-radius: 99px; transition: width .3s; }

.codex-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 14px;
}

.codex-cell {
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
  text-align: left;
  border-radius: 10px;
}

.codex-cell .frame-inner {
  padding: 10px 8px;
  gap: 3px;
  min-height: 150px;
  position: relative;
  transition: transform .15s;
}

.codex-cell:hover .frame-inner { transform: translateY(-3px); }

.cell-art {
  width: 62px;
  height: 62px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 2px auto;
  background: #fafbfc;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.cell-art .egg-art, .cell-art .art-img { width: 100%; height: 100%; }
.cell-art .emoji-art { font-size: 42px; }

.cell-no { font-size: 11px; color: var(--muted); }

.cell-name { font-size: 13px; font-weight: 600; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.cell-count { font-size: 11px; color: var(--muted); }

.cell-lock {
  font-size: 11px;
  color: #fff;
  background: var(--muted);
  padding: 1px 8px;
  border-radius: 99px;
  position: absolute;
  top: 8px;
  right: 8px;
}

.locked { filter: grayscale(1); opacity: .55; }

.bag-row { border-radius: 12px; padding: 2px; margin-bottom: 12px; }

.bag-inner {
  flex-direction: row;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  text-align: left;
}

.bag-art {
  width: 62px;
  height: 62px;
  cursor: pointer;
  flex-shrink: 0;
  background: #fafbfc;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.bag-art .egg-art, .bag-art .art-img { width: 100%; height: 100%; }
.bag-art .emoji-art { font-size: 42px; }

.bag-info { flex: 1; min-width: 0; }

.bag-title { font-weight: 700; font-size: 14px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.active-tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--accent);
  color: #fff;
}

.bag-sub { color: var(--muted); font-size: 12px; margin-top: 4px; }

.bag-formation { font-size: 12px; margin-top: 6px; }
.ok-text { color: #15803d; }

.miss-text { color: #b91c1c; }

.f-line { display: flex; flex-wrap: wrap; gap: 4px; }

.f-mem { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; padding: 1px 7px; border-radius: 99px; border: 1px solid var(--line); background: #fff; }

.f-mem.miss { border-color: #fecaca; background: #fef2f2; }

.f-summary { margin-top: 3px; font-size: 12px; }

.bag-actions { display: flex; flex-direction: column; gap: 8px; flex-shrink: 0; }

#toasts {
  position: fixed;
  top: 70px;
  right: 16px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: #fff;
  border: 1px solid var(--line);
  border-left: 4px solid var(--muted);
  padding: 10px 16px;
  border-radius: 10px;
  box-shadow: 0 6px 18px rgba(15, 23, 42, .12);
  font-size: 13px;
  animation: toast-in .25s ease;
  min-width: 200px;
  max-width: 320px;
}

.toast.out { opacity: 0; transform: translateX(10px); transition: all .4s; }

.toast.rc-white { border-left-color: var(--c-white); }
.toast.rc-green { border-left-color: var(--c-green); }
.toast.rc-blue { border-left-color: var(--c-blue); }
.toast.rc-purple { border-left-color: var(--c-purple); }
.toast.rc-gold { border-left-color: var(--c-gold); }
.toast.rc-red { border-left-color: var(--c-red); }
.toast.rc-black { border-left-color: var(--c-black); }
.toast.rc-rainbow { border-left-color: #8b5cf6; }

@keyframes toast-in { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

.viewer {
  position: fixed;
  inset: 0;
  z-index: 9010;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.viewer.hidden { display: none; }

.viewer-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, .55); }

.viewer-stage {
  position: relative;
  width: 240px;
  height: 340px;
  perspective: 1200px;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.viewer-stage:active { cursor: grabbing; }

.vcard { position: absolute; inset: 0; transform-style: preserve-3d; }

.vface-wrap {
  position: absolute;
  inset: 0;
  border-radius: 16px;
  padding: 3px;
  backface-visibility: hidden;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .35);
}

.vback-wrap { transform: rotateY(180deg); }

.vface {
  border-radius: 13px;
  padding: 16px;
  gap: 6px;
  overflow-y: auto;
  justify-content: flex-start;
  height: 100%;
}

.v-art {
  width: 130px;
  height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 6px;
  background: #fafbfc;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.v-art .egg-art, .v-art .art-img { width: 100%; height: 100%; }
.v-art .emoji-art { font-size: 76px; }

.v-no { font-size: 11px; color: var(--muted); letter-spacing: 1px; }

.v-name { font-size: 20px; font-weight: 800; }

.v-line { font-size: 12px; color: var(--muted); }
.v-line b { color: var(--text); }

.v-sec { font-size: 12px; color: var(--muted); text-align: left; width: 100%; }
.v-sec b { color: var(--text); }

.v-sec-title { font-size: 12px; font-weight: 700; text-align: left; width: 100%; margin-top: 6px; }

.v-mems { display: flex; flex-wrap: wrap; gap: 4px; }

.v-mem { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; padding: 1px 7px; border-radius: 99px; border: 1px solid var(--line); }
.v-mem.ok { color: #15803d; border-color: #bbf7d0; background: #f0fdf4; }
.v-mem.miss { color: #b91c1c; border-color: #fecaca; background: #fef2f2; }

.v-desc { font-size: 12px; color: var(--text); text-align: left; width: 100%; margin-top: 6px; }

.v-flavor { font-size: 11px; color: var(--muted); font-style: italic; text-align: left; width: 100%; }

.v-unowned { font-size: 12px; color: #b91c1c; margin-top: 4px; }

.viewer-hint {
  position: absolute;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, .85);
  font-size: 12px;
  background: rgba(15, 23, 42, .4);
  padding: 6px 14px;
  border-radius: 99px;
}

.viewer-close {
  position: absolute;
  top: 20px;
  right: 20px;
  background: rgba(255, 255, 255, .15);
  border-color: rgba(255, 255, 255, .3);
  color: #fff;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 16px;
  padding: 0;
}

.viewer-close:hover { background: rgba(255, 255, 255, .3); }

.formula { font-size: 13px; margin-bottom: 8px; color: var(--text); }
.formula b { color: var(--accent); }

.rate-table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 13px; }

.rate-table th, .rate-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }

.rate-table th { color: var(--muted); font-weight: 600; font-size: 12px; }

.rate-name { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.rn-white { color: #6b7280; }
.rn-green { color: var(--c-green); }
.rn-blue { color: var(--c-blue); }
.rn-purple { color: var(--c-purple); }
.rn-gold { color: var(--c-gold); }
.rn-red { color: var(--c-red); }
.rn-black { color: var(--c-black); }
.rn-rainbow { background: conic-gradient(from 0deg, #f43f5e, #f59e0b, #22c55e, #0ea5e9, #8b5cf6, #f43f5e); -webkit-background-clip: text; background-clip: text; color: transparent; }

@media (max-width: 900px) {
  .battle-layout { grid-template-columns: 1fr; }
  .topbar { gap: 10px; }
  .brand { font-size: 16px; }
  .bag-inner { flex-wrap: wrap; }
  .bag-actions { flex-direction: row; }
}

/* ===== 新手引导 ===== */

#tut-mask {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: rgba(10, 18, 36, .55);
  pointer-events: none;
}

#tut-ring {
  position: fixed;
  z-index: 9021;
  pointer-events: none;
  border: 3px solid #3b82f6;
  border-radius: 10px;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, .9);
  display: none;
}

#tut-bubble {
  position: fixed;
  z-index: 9022;
  max-width: min(92vw, 360px);
  background: #fff;
  border: 2px solid #3b82f6;
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .28);
  font-size: 14px;
  line-height: 1.65;
  display: none;
}

#tut-bubble .tut-title { font-weight: 800; font-size: 15px; color: #1d4ed8; margin-bottom: 6px; }
#tut-bubble .tut-body { color: #334155; }
#tut-bubble .tut-progress { color: #1d4ed8; font-weight: 700; }

#tut-bubble .tut-btns { display: flex; gap: 8px; margin-top: 12px; justify-content: flex-end; align-items: center; }

#tut-bubble .tut-btn {
  border: 1px solid #bfdbfe;
  background: #eff6ff;
  color: #1d4ed8;
  border-radius: 8px;
  padding: 6px 14px;
  cursor: pointer;
  font-size: 13px;
  min-height: 36px;
}

#tut-bubble .tut-btn.primary { background: #2563eb; border-color: #2563eb; color: #fff; }
#tut-bubble .tut-btn.primary:hover { background: #1d4ed8; }
#tut-bubble .tut-skip { border: 0; background: transparent; color: #94a3b8; margin-right: auto; }
#tut-bubble .tut-skip:hover { color: #64748b; background: transparent; }

/* ===== 移动端适配 ===== */

@media (max-width: 560px) {
  main { margin: 12px auto; padding: 0 10px 70px; }
  .topbar { padding: 8px 12px; gap: 8px; }
  .brand { font-size: 16px; }
  .top-stats { order: 3; width: 100%; gap: 10px; font-size: 12px; justify-content: space-between; }
  .tabs { order: 2; width: 100%; overflow-x: auto; }
  .tab-btn { flex: 1; min-width: 0; padding: 8px 6px; font-size: 13px; white-space: nowrap; }
  .panel { padding: 12px 14px; border-radius: 12px; }
  .battle-layout { gap: 12px; }
  .quick-actions { flex-wrap: wrap; }
  .quick-actions .btn { flex: 1 1 auto; min-width: 130px; }
  .codex-grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
  .codex-cell .frame-inner { min-height: 128px; }
  .bag-inner { gap: 10px; padding: 10px 12px; }
  .bag-actions { width: 100%; justify-content: flex-end; }
  .bag-actions .btn { flex: 1; }
  .battle-row { gap: 6px; padding: 24px 4px 8px; min-height: 110px; }
  .mini-card { width: 48px; }
  .mini-card.center { transform: translateY(-14px) scale(1.25); }
  .monster-timer { font-size: 12px; }
  #toasts { top: auto; bottom: 12px; right: 10px; left: 10px; }
  .toast { font-size: 12px; padding: 8px 12px; }
  .viewer-hint { display: none; }
  .kv { font-size: 13px; }
  #tut-bubble { padding: 12px 14px; font-size: 13px; }
  #tut-bubble .tut-btn { padding: 8px 14px; }
}

/* ===== 暗黑模式：仅覆盖背景+卡片底色+文字 ===== */

body.dark {
  --bg: #0f172a;
  --panel: #1e293b;
  --line: #334155;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #3b82f6;
  background: #0f172a;
  color: #e2e8f0;
}

body.dark .topbar { background: rgba(15, 23, 42, .92); border-bottom-color: #334155; }
body.dark .stat b { color: #e2e8f0; }
body.dark .top-stats { color: #94a3b8; }

body.dark .panel { background: #1e293b; border-color: #334155; }
body.dark .panel p { color: #94a3b8; }

body.dark .btn { background: #1e293b; border-color: #334155; color: #e2e8f0; }
body.dark .btn:hover { background: #283548; border-color: #475569; }
body.dark .btn.primary { background: #3b82f6; border-color: #3b82f6; color: #fff; }
body.dark .btn.primary:hover { background: #2563eb; }
body.dark .btn.danger { color: #f87171; border-color: #7f1d1d; }
body.dark .btn.danger:hover { background: #3a1d22; }
body.dark .btn:disabled { opacity: .5; }
body.dark .btn:disabled:hover { background: #1e293b; border-color: #334155; }

body.dark .tab-btn { color: #cbd5e1; }
body.dark .tab-btn:hover { background: #334155; color: #fff; }
body.dark .tab-btn.active { background: #3b82f6; color: #fff; }

body.dark code { background: #334155; }

body.dark .frame-inner { background: #1e293b; border-color: #334155; }
body.dark .frame-rainbow .frame-inner { border-color: #8b5cf6; }
body.dark .frame-white .frame-inner { border-color: #6b7280; }
body.dark .frame-green .frame-inner { border-color: #16a34a; }
body.dark .frame-blue .frame-inner { border-color: #2563eb; }
body.dark .frame-purple .frame-inner { border-color: #7c3aed; }
body.dark .frame-gold .frame-inner { border-color: #d97706; }
body.dark .frame-red .frame-inner { border-color: #dc2626; }
body.dark .frame-black .frame-inner { border-color: #94a3b8; }

body.dark .mini-art { background: #162136; border-color: #334155; }
body.dark .mini-name { color: #e2e8f0; }
body.dark .cell-art { background: #162136; border-color: #334155; }
body.dark .bag-art { background: #162136; border-color: #334155; }
body.dark .v-art { background: #162136; border-color: #334155; }

body.dark .hpbar { background: #334155; }
body.dark .bar { background: #334155; }
body.dark .monster-name { color: #94a3b8; }
body.dark .monster-timer { color: #94a3b8; }
body.dark .monster-timer b { color: #e2e8f0; }
body.dark .hint { color: #94a3b8; }
body.dark .row-caption { color: #94a3b8; }
body.dark .kv { color: #94a3b8; }
body.dark .kv b { color: #e2e8f0; }

body.dark .chip { background: #1e293b; border-color: #334155; color: #e2e8f0; }
body.dark .chip:hover { border-color: #475569; color: #fff; }
body.dark .chip.active { background: #3b82f6; border-color: #3b82f6; color: #fff; }

body.dark .f-mem { background: #1e293b; border-color: #334155; }
body.dark .f-mem.miss { background: #3a1d22; border-color: #7f1d1d; }
body.dark .frow.ok { color: #4ade80; }
body.dark .frow.miss { color: #f87171; }
body.dark .ok-text { color: #4ade80; }
body.dark .miss-text { color: #f87171; }
body.dark .v-mem.ok { color: #4ade80; border-color: #166534; background: #123524; }
body.dark .v-mem.miss { color: #f87171; border-color: #7f1d1d; background: #3a1d22; }
body.dark .v-unowned { color: #f87171; }
body.dark .v-flavor { color: #94a3b8; }

body.dark .egg-art::before { background: rgba(30, 41, 59, .75); }

body.dark .toast { background: #1e293b; border-color: #334155; }
body.dark .log-entry { border-bottom-color: #334155; }
body.dark .battle-log { border-top-color: #334155; }
body.dark .fnote { border-top-color: #334155; }

body.dark .fhead { color: #e2e8f0; }
body.dark .bag-title { color: #e2e8f0; }
body.dark .bag-sub { color: #94a3b8; }
body.dark .cell-name { color: #e2e8f0; }
body.dark .cell-no { color: #94a3b8; }
body.dark .cell-count { color: #94a3b8; }
body.dark .cell-lock { background: #94a3b8; }
body.dark .active-tag { background: #3b82f6; }
body.dark .sort-label { color: #94a3b8; }
body.dark .rate-row { color: #94a3b8; }
body.dark .rate-row b { color: #e2e8f0; }
body.dark .num-input { background: #1e293b; border-color: #334155; color: #e2e8f0; }
body.dark .search-input { background: #1e293b; border-color: #334155; color: #e2e8f0; }

body.dark .rn-white { color: #9ca3af; }
body.dark .rn-black { color: #94a3b8; }

body.dark #tut-bubble { background: #1e293b; border-color: #3b82f6; }
body.dark #tut-bubble .tut-title { color: #60a5fa; }
body.dark #tut-bubble .tut-body { color: #e2e8f0; }
body.dark #tut-bubble .tut-progress { color: #60a5fa; }
body.dark #tut-bubble .tut-btn { background: #1e3a5f; border-color: #1d4ed8; color: #60a5fa; }
body.dark #tut-bubble .tut-btn.primary { background: #2563eb; border-color: #2563eb; color: #fff; }
body.dark #tut-bubble .tut-btn.primary:hover { background: #3b82f6; }

body.dark .v-name { color: #e2e8f0; }
body.dark .v-line { color: #94a3b8; }
body.dark .v-line b { color: #e2e8f0; }
body.dark .v-sec { color: #94a3b8; }
body.dark .v-sec b { color: #e2e8f0; }
body.dark .v-desc { color: #e2e8f0; }

body.dark .formula { color: #e2e8f0; }
body.dark .formula b { color: #3b82f6; }
body.dark .rate-table th { color: #94a3b8; }
body.dark .rate-table td { border-bottom-color: #334155; }

/* ===== 防老板模式 ===== */

body.boss-mode header,
body.boss-mode main,
body.boss-mode #toasts,
body.boss-mode .viewer,
body.boss-mode #tut-mask,
body.boss-mode #tut-bubble,
body.boss-mode #tut-ring {
  display: none !important;
}

body.boss-mode { background: #fff !important; }

#boss-panel.hidden { display: none; }

#boss-panel {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: #fff;
  display: flex;
  flex-direction: column;
}

#boss-panel .boss-titlebar {
  background: #f3f3f3;
  border-bottom: 1px solid #d9d9d9;
  padding: 7px 12px;
  font-size: 12px;
  color: #333;
  font-weight: 600;
  user-select: none;
  flex-shrink: 0;
}

#boss-panel #boss-note {
  flex: 1;
  border: 0;
  outline: none;
  resize: none;
  padding: 8px 12px;
  font-size: 14px;
  line-height: 1.5;
  font-family: Consolas, "Microsoft YaHei", monospace;
  background: #fff;
  color: #1b2430;
}

#boss-panel .boss-status {
  border-top: 1px solid #d9d9d9;
  background: #f3f3f3;
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 5px 12px;
  font-size: 11px;
  color: #666;
  flex-shrink: 0;
}

#boss-panel .boss-status b { color: #333; }

#boss-panel .boss-link {
  border: 0;
  background: transparent;
  color: #2563eb;
  cursor: pointer;
  font-size: 11px;
  padding: 0;
}

#boss-panel .boss-link:hover { text-decoration: underline; }

#boss-panel .boss-status span { white-space: nowrap; }