:root {
  --bg: #11151d;
  --panel: rgba(16, 20, 29, 0.86);
  --panel-deep: rgba(10, 13, 20, 0.94);
  --border: rgba(204, 173, 114, 0.34);
  --border-hi: rgba(240, 205, 136, 0.72);
  --gold: #ebd19d;
  --gold-dim: #b49867;
  --crimson: #cc4c3f;
  --ice: #7eeeff;
  --ink-text: #f4ecdc;
  --font-serif: "Songti SC", "STSong", "Noto Serif SC", "SimSun", Georgia, serif;
  --font-sans: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; user-select: none; -webkit-user-select: none; }

html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink-text);
  font-family: var(--font-sans);
}

[hidden] { display: none !important; }

/* 首页封面 */
.screen-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    radial-gradient(circle at 50% 30%, rgba(154, 44, 38, 0.16), transparent 56%),
    radial-gradient(circle at 50% 50%, rgba(18, 24, 36, 0.92), #0c0f16);
  z-index: 40;
}

.title-card {
  width: min(520px, 94vw);
  padding: 28px 26px 24px;
  background: var(--panel-deep);
  border: 1px solid var(--border-hi);
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.7), inset 0 0 0 1px rgba(255, 255, 255, 0.04);
  text-align: center;
}

.title-hero-art {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin-bottom: 14px;
}

.title-portrait {
  width: 78px;
  height: 78px;
  border: 1px solid var(--border-hi);
  box-shadow: 0 0 24px rgba(214, 88, 64, 0.28);
  object-fit: cover;
}

.deco-lantern {
  width: 34px;
  height: auto;
  opacity: 0.92;
  filter: drop-shadow(0 0 10px rgba(255, 188, 92, 0.45));
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 11px;
  letter-spacing: 0.26em;
  color: var(--gold-dim);
}

.title-card h1 {
  margin: 0 0 10px;
  font-family: var(--font-serif);
  font-size: 38px;
  letter-spacing: 0.18em;
  color: #f8e7c3;
  text-shadow: 0 3px 18px rgba(204, 76, 63, 0.35);
}

.subtitle {
  margin: 0 auto 20px;
  max-width: 420px;
  font-size: 13px;
  line-height: 1.7;
  color: rgba(235, 224, 202, 0.82);
}

.subtitle strong { color: var(--gold); }

.title-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 18px;
}

.btn-primary {
  width: 100%;
  padding: 12px 16px;
  background: rgba(28, 34, 48, 0.9);
  border: 1px solid var(--border);
  color: var(--ink-text);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  transition: transform 0.12s, border-color 0.15s, background 0.15s;
}

.btn-primary strong {
  font-family: var(--font-serif);
  font-size: 17px;
  letter-spacing: 0.12em;
  color: #f9e8c4;
}

.btn-primary small {
  font-size: 11px;
  color: var(--gold-dim);
}

.btn-primary:hover {
  border-color: var(--border-hi);
  background: rgba(38, 46, 64, 0.95);
  transform: translateY(-1px);
}

.btn-gold {
  background: linear-gradient(135deg, rgba(132, 38, 32, 0.92), rgba(44, 28, 32, 0.94));
  border-color: rgba(242, 198, 120, 0.72);
  box-shadow: 0 0 22px rgba(204, 76, 63, 0.25);
}

.btn-gold:hover {
  background: linear-gradient(135deg, rgba(154, 46, 38, 0.96), rgba(58, 34, 38, 0.96));
}

.records-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid rgba(204, 173, 114, 0.2);
}

.rec-item {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(204, 173, 114, 0.16);
  padding: 7px 6px;
}

.rec-item span { display: block; font-size: 10px; color: var(--gold-dim); margin-bottom: 2px; }
.rec-item strong { font-size: 13px; color: var(--gold); font-variant-numeric: tabular-nums; }

.last-run-box {
  margin-top: 10px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px dashed rgba(204, 173, 114, 0.26);
  font-size: 11px;
  color: rgba(235, 224, 202, 0.78);
  line-height: 1.55;
}

/* 战场主画布 */
#arena { position: relative; width: 100%; height: 100%; overflow: hidden; }
#field { position: absolute; inset: 0; display: block; width: 100%; height: 100%; touch-action: none; }

/* 顶部 HUD */
.hud-top {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  left: 12px;
  right: 12px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  pointer-events: none;
  z-index: 10;
}

.hero-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 11px 6px 6px;
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(8px);
  pointer-events: auto;
  cursor: pointer;
  min-width: 256px;
}

.hero-card:hover { border-color: var(--border-hi); }

.portrait-frame {
  position: relative;
  width: 52px;
  height: 52px;
  border: 1px solid var(--border-hi);
  background: #10141c;
  flex-shrink: 0;
  overflow: hidden;
}

.portrait-frame img { width: 100%; height: 100%; display: block; object-fit: cover; }

.realm-badge {
  position: absolute;
  right: 0;
  bottom: 0;
  padding: 1px 4px;
  font-size: 10px;
  line-height: 1.2;
  background: rgba(145, 36, 30, 0.92);
  color: #ffe6b8;
  border-top: 1px solid rgba(235, 198, 132, 0.55);
  border-left: 1px solid rgba(235, 198, 132, 0.55);
  font-family: var(--font-serif);
}

.hero-stats { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.hero-row { display: flex; align-items: baseline; gap: 6px; white-space: nowrap; }
.hero-name { font-family: var(--font-serif); font-size: 14px; font-weight: 700; color: var(--ink-text); }
.hero-title { font-family: var(--font-serif); font-size: 11px; color: #e99a7e; }
.hero-lv { margin-left: auto; font-size: 12px; font-weight: 700; color: var(--gold); font-variant-numeric: tabular-nums; }

.bar {
  position: relative;
  width: 100%;
  background: rgba(6, 9, 14, 0.85);
  border: 1px solid rgba(204, 173, 114, 0.25);
  overflow: hidden;
}
.hp-bar { height: 14px; }
.hp-bar .bar-fill {
  position: absolute; inset: 0; transform-origin: left center;
  background: linear-gradient(90deg, #3c8e61, #6dc894);
  transition: transform 0.14s ease-out;
}
.bar-text {
  position: relative; z-index: 1; display: block; text-align: center;
  font-size: 10px; line-height: 12px; font-weight: 700; color: #f7f3ea;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.85); font-variant-numeric: tabular-nums;
}
.xp-bar { height: 4px; }
.xp-bar .bar-fill {
  position: absolute; inset: 0; transform-origin: left center;
  background: linear-gradient(90deg, #b9893d, #f5d890);
}
.next-realm-row {
  display: flex; justify-content: space-between; font-size: 10px;
  color: rgba(226, 206, 166, 0.78);
}
.tap-stats { color: var(--gold); }

/* 顶部中央 & 多 Boss 血条 */
.center-stack { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.run-pill {
  display: flex; align-items: center; gap: 9px; padding: 6px 13px;
  background: var(--panel); border: 1px solid var(--border);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4); backdrop-filter: blur(8px);
  font-size: 12px; color: var(--gold); font-variant-numeric: tabular-nums; white-space: nowrap;
}
.run-item { display: inline-flex; align-items: center; gap: 4px; }
.run-item svg { width: 14px; height: 14px; color: var(--gold-dim); }
.run-item strong { color: var(--ink-text); }
.sep { width: 1px; height: 12px; background: rgba(204, 173, 114, 0.28); }
.wave-text { color: #e8cc98; font-family: var(--font-serif); letter-spacing: 0.04em; }

.boss-bars { display: flex; flex-direction: column; gap: 4px; width: min(360px, 52vw); }
.boss-bar-row {
  background: rgba(14, 16, 24, 0.88);
  border: 1px solid rgba(224, 92, 82, 0.55);
  padding: 3px 6px 4px;
}
.boss-bar-head {
  display: flex; justify-content: space-between; font-size: 11px;
  color: #ffc5bd; font-family: var(--font-serif); margin-bottom: 2px;
}
.boss-track { height: 6px; background: rgba(0,0,0,0.65); overflow: hidden; }
.boss-fill { height: 100%; background: linear-gradient(90deg, #a82328, #f05d4e); transform-origin: left center; }

/* 右上角工具栏 */
.hud-actions { display: flex; align-items: center; gap: 5px; pointer-events: auto; }
.pill-btn, .pill-select, .icon-btn {
  height: 33px; background: var(--panel); border: 1px solid var(--border);
  color: var(--gold); cursor: pointer; backdrop-filter: blur(8px);
  font-family: inherit; font-size: 12px; white-space: nowrap; flex-shrink: 0;
}
.pill-btn { padding: 0 10px; }
.pill-btn[aria-pressed="true"] { background: rgba(148, 42, 34, 0.84); border-color: var(--border-hi); color: #ffeed2; }
.pill-select { padding: 0 6px; outline: none; }
.pill-select option { background: #141923; color: var(--ink-text); }
.icon-btn { width: 33px; display: inline-grid; place-items: center; }
.icon-btn svg { width: 16px; height: 16px; }
.pill-btn:hover, .icon-btn:hover { background: rgba(34, 41, 56, 0.92); border-color: var(--border-hi); }

/* 8 项基础属性抽屉 */
.stats-drawer {
  position: absolute;
  top: 90px;
  left: 12px;
  width: 264px;
  padding: 10px;
  background: var(--panel-deep);
  border: 1px solid var(--border);
  backdrop-filter: blur(10px);
  z-index: 12;
}
.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.stat-cell {
  display: flex; align-items: center; gap: 6px; padding: 5px 6px;
  background: rgba(255, 255, 255, 0.03); border: 1px solid rgba(204, 173, 114, 0.16);
  font-size: 11px;
}
.stat-cell img { width: 18px; height: 18px; image-rendering: pixelated; }
.stat-cell span { color: var(--gold-dim); }
.stat-cell strong { margin-left: auto; color: var(--ink-text); font-variant-numeric: tabular-nums; }

/* 横幅与侧边自动加点飘条 */
.banner {
  position: absolute;
  top: 92px;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 20px;
  background: linear-gradient(90deg, rgba(16, 20, 30, 0.2), rgba(112, 30, 28, 0.92) 20%, rgba(112, 30, 28, 0.92) 80%, rgba(16, 20, 30, 0.2));
  border-top: 1px solid rgba(242, 205, 132, 0.65);
  border-bottom: 1px solid rgba(242, 205, 132, 0.65);
  font-family: var(--font-serif);
  font-size: 15px;
  letter-spacing: 0.1em;
  color: #ffefc8;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.85);
  white-space: nowrap;
  pointer-events: none;
  z-index: 15;
}

.toast-stack {
  position: absolute;
  right: 14px;
  top: 56px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
  pointer-events: none;
  z-index: 12;
}
.toast-item {
  padding: 4px 10px;
  background: rgba(16, 21, 31, 0.82);
  border-right: 2px solid var(--gold);
  font-size: 11px;
  color: #f3dfb3;
}

/* 底部 HUD */
.hud-bottom {
  position: absolute;
  left: 12px; right: 12px;
  bottom: max(10px, env(safe-area-inset-bottom));
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 10px; pointer-events: none; z-index: 10;
}

.skills { display: flex; flex-wrap: wrap; gap: 5px; max-width: 56vw; pointer-events: auto; }
.slot {
  position: relative; width: 38px; height: 38px;
  background: var(--panel-deep); border: 1px solid var(--border);
  display: grid; place-items: center;
}
.slot.awakened { border-color: rgba(236, 186, 108, 0.72); box-shadow: inset 0 0 10px rgba(126, 238, 255, 0.14); }
.slot img { width: 26px; height: 26px; image-rendering: pixelated; }
.slot-rank {
  position: absolute; right: 2px; bottom: 1px; font-style: normal;
  font-size: 9px; font-weight: 700; color: var(--gold); text-shadow: 0 1px 2px #000;
}

.hint-pill {
  padding: 5px 12px; background: rgba(14, 18, 26, 0.74);
  border: 1px solid rgba(204, 173, 114, 0.22);
  font-size: 11px; color: rgba(235, 224, 200, 0.82);
}

.ult-btn {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 6px 12px 6px 8px;
  background: linear-gradient(135deg, rgba(52, 22, 24, 0.94), rgba(18, 23, 34, 0.95));
  border: 1px solid rgba(232, 184, 110, 0.68);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.55);
  color: var(--ink-text); cursor: pointer; pointer-events: auto;
}
.ult-btn:disabled { opacity: 0.55; cursor: not-allowed; border-color: var(--border); }
.ult-btn:not(:disabled):hover { border-color: #ffe3a3; transform: translateY(-1px); }
.ult-seal {
  width: 30px; height: 30px; display: grid; place-items: center;
  background: linear-gradient(180deg, #b83d32, #7a211d);
  border: 1px solid #ecc98e; color: #fff2cf;
  font-family: var(--font-serif); font-size: 17px; font-weight: 700;
}
.ult-meta { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.2; }
.ult-meta strong { font-family: var(--font-serif); font-size: 14px; color: #f8e4bc; letter-spacing: 0.06em; }
.ult-meta small { font-size: 10px; color: #d6b681; }
.ult-btn kbd {
  padding: 2px 5px; font-size: 10px; color: var(--gold);
  background: rgba(0, 0, 0, 0.45); border: 1px solid rgba(204, 173, 114, 0.35);
}

/* 通用模态框 */
.modal-shade {
  position: fixed; inset: 0; z-index: 80;
  display: grid; place-items: center; padding: 18px;
  background: rgba(6, 9, 15, 0.72);
  backdrop-filter: blur(7px);
}
.modal-card {
  width: min(640px, 95vw);
  padding: 22px 22px 18px;
  background: var(--panel-deep);
  border: 1px solid var(--border-hi);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.75);
}
.modal-card.breakthrough { border-color: #ffe294; box-shadow: 0 0 42px rgba(232, 168, 72, 0.28); }
.modal-head { text-align: center; margin-bottom: 14px; }
.modal-head .kicker { font-size: 11px; letter-spacing: 0.22em; color: var(--gold-dim); margin: 0 0 4px; }
.modal-head h2 { margin: 0 0 6px; font-family: var(--font-serif); font-size: 26px; letter-spacing: 0.12em; color: #fae8c2; }
.modal-head p { margin: 0; font-size: 12px; color: rgba(235, 224, 202, 0.84); line-height: 1.6; }

.choice-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.choice-btn {
  display: flex; flex-direction: column; align-items: flex-start; text-align: left;
  gap: 8px; padding: 12px;
  background: rgba(24, 30, 44, 0.88); border: 1px solid var(--border);
  color: var(--ink-text); cursor: pointer; transition: transform 0.12s, border-color 0.15s, background 0.15s;
}
.choice-btn:hover { border-color: var(--border-hi); background: rgba(36, 44, 62, 0.96); transform: translateY(-2px); }
.choice-top { display: flex; align-items: center; gap: 8px; width: 100%; }
.choice-top img { width: 28px; height: 28px; image-rendering: pixelated; border: 1px solid rgba(204, 173, 114, 0.3); background: #0f131c; padding: 2px; }
.choice-key { margin-left: auto; font-size: 10px; padding: 1px 5px; color: var(--gold); border: 1px solid var(--border); }
.choice-btn strong { font-family: var(--font-serif); font-size: 15px; color: #fae7be; }
.choice-tag { font-size: 10px; color: #8beeff; }
.choice-desc { font-size: 11px; line-height: 1.55; color: rgba(235, 224, 202, 0.84); }

.modal-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding-top: 10px; border-top: 1px solid rgba(204, 173, 114, 0.2);
  font-size: 12px; color: var(--gold-dim);
}
.inline-check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; color: var(--gold); }
.btn-row { display: flex; gap: 10px; justify-content: center; margin-top: 14px; }
.btn-row .btn-primary { width: auto; min-width: 150px; padding: 10px 18px; }

.summary-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 14px 0;
}
.sum-cell {
  padding: 9px 6px; text-align: center;
  background: rgba(255, 255, 255, 0.03); border: 1px solid rgba(204, 173, 114, 0.2);
}
.sum-cell span { display: block; font-size: 10px; color: var(--gold-dim); margin-bottom: 3px; }
.sum-cell strong { font-size: 15px; color: #fae7be; font-variant-numeric: tabular-nums; }

/* 多存档位玉简管理列表 */
.save-slot-list {
  display: flex; flex-direction: column; gap: 8px;
  margin: 12px 0;
}
.save-slot-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 12px;
  background: rgba(24, 30, 44, 0.88);
  border: 1px solid var(--border);
  transition: border-color 0.15s, background 0.15s;
}
.save-slot-row.active-slot {
  border-color: rgba(242, 198, 120, 0.78);
  background: rgba(46, 36, 36, 0.86);
}
.save-slot-row.empty-slot {
  border-style: dashed;
  background: rgba(16, 20, 30, 0.65);
}
.save-slot-info {
  display: flex; flex-direction: column; gap: 3px; min-width: 0; text-align: left;
}
.save-slot-top {
  display: flex; align-items: center; gap: 7px; flex-wrap: wrap;
}
.slot-badge {
  font-size: 10px; padding: 1px 6px;
  background: rgba(204, 173, 114, 0.16);
  border: 1px solid rgba(204, 173, 114, 0.45);
  color: var(--gold);
  font-family: var(--font-serif);
}
.slot-badge.current {
  background: rgba(160, 46, 38, 0.88);
  border-color: rgba(255, 224, 148, 0.72);
  color: #fff2cc;
}
.save-slot-title {
  font-family: var(--font-serif); font-size: 14px; font-weight: 700; color: #fae7be;
}
.save-slot-meta {
  font-size: 11px; color: rgba(235, 224, 202, 0.72); font-variant-numeric: tabular-nums;
}
.save-slot-actions {
  display: flex; align-items: center; gap: 6px; flex-shrink: 0;
}
.slot-btn {
  padding: 6px 10px; font-size: 11px; white-space: nowrap;
  background: rgba(28, 36, 52, 0.92); color: var(--ink-text);
  border: 1px solid var(--border); cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.slot-btn:hover { border-color: var(--border-hi); background: rgba(42, 52, 74, 0.96); }
.slot-btn-gold {
  background: linear-gradient(135deg, rgba(132, 38, 32, 0.92), rgba(52, 30, 34, 0.94));
  border-color: rgba(242, 198, 120, 0.72); color: #fff2cc;
}
.slot-btn-gold:hover { background: linear-gradient(135deg, rgba(156, 48, 40, 0.96), rgba(66, 38, 42, 0.96)); }
.slot-btn-danger { color: #ff9c94; border-color: rgba(224, 86, 78, 0.42); }
.slot-btn-danger:hover { border-color: rgba(255, 120, 112, 0.82); background: rgba(96, 28, 28, 0.85); }
.save-tip-msg {
  margin-bottom: 8px; padding: 7px 10px; text-align: center; font-size: 12px;
  color: #ffe39b; background: rgba(140, 56, 32, 0.28); border: 1px solid rgba(242, 198, 120, 0.45);
}

@media (max-width: 760px) {
  .hud-top { flex-wrap: wrap; }
  .center-stack { order: 3; width: 100%; }
  .choice-list { grid-template-columns: 1fr; }
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .save-slot-row { flex-direction: column; align-items: stretch; }
  .save-slot-actions { justify-content: flex-end; flex-wrap: wrap; }
  .hint-pill, .ult-btn kbd { display: none; }
}
