:root {
  --bg: #0b0d10;
  --panel: #14181d;
  --panel-2: #1b2128;
  --line: #2a323c;
  --ink: #dfe6ee;
  --ink-dim: #8b98a8;
  --accent: #d98b3a;
  --accent-2: #4fb3a8;
  --danger: #c2503f;
  --purple: #a98bd9;
  --color-base-100: #0b0d10;
  --color-base-200: #1b2128;
  --color-base-300: #2a323c;
  --color-base-content: #dfe6ee;
  --color-primary: #7fd8cd;
  --color-primary-content: #0b201e;
  --color-secondary: #8fb8ff;
  --color-secondary-content: #102136;
  --color-accent: #d98b3a;
  --color-accent-content: #201409;
  --color-neutral: #222a33;
  --color-neutral-content: #dfe6ee;
  --color-info: #8fb8ff;
  --color-info-content: #102136;
  --color-success: #7fd8cd;
  --color-success-content: #0b201e;
  --color-warning: #e0a35c;
  --color-warning-content: #291907;
  --color-error: #c2503f;
  --color-error-content: #fff0ed;
  --radius-selector: .25rem;
  --radius-field: .25rem;
  --radius-box: .5rem;
  --size-selector: .25rem;
  --size-field: .25rem;
  --border: 1px;
  --depth: 0;
  --noise: 0;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  overflow: hidden;
}

#app {
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 0;
}

/* ---------- 顶部 HUD ---------- */
#hud {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 9px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.hud-title { font-size: 15px; letter-spacing: 2px; white-space: nowrap; }
.hud-title .ver {
  font-size: 11px; color: var(--ink-dim); letter-spacing: 0; margin-left: 6px;
}

#zone-badge {
  font-size: 13px;
  padding: 3px 12px;
  border-radius: 3px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  letter-spacing: 1px;
  white-space: nowrap;
}

#resources { display: flex; gap: 15px; font-size: 12px; margin-left: auto; flex-wrap: wrap; }
#resources .res { display: flex; align-items: baseline; gap: 4px; white-space: nowrap; }
#resources .val { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
#resources .src .val { color: var(--accent-2); }
#resources .mat .val { color: var(--accent); }
#resources .und .val { color: var(--purple); }

#layer-badge {
  font-size: 12px; padding: 4px 12px; border-radius: 3px;
  border: 1px solid var(--line); background: var(--panel-2);
  letter-spacing: 1px; white-space: nowrap;
}
#layer-badge.inner { color: #ffb4a0; border-color: #6b2f26; background: #2a1512; }

/* ---------- 舞台 ---------- */
#stage {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 292px;
  min-height: 0;
  overflow: hidden;
}

#viewport {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #05070a;
  overflow: hidden;
  min-width: 0;
}

/* 固定逻辑分辨率，由容器等比缩放 */
#game {
  display: block;
  flex-shrink: 0;
  max-width: 100%;
  max-height: 100%;
}

#layer-wash {
  position: absolute; inset: 0; pointer-events: none;
  transition: opacity .35s ease; opacity: 0;
}
#layer-wash.on {
  opacity: 1;
  background: radial-gradient(circle at 50% 45%, rgba(90,20,10,0) 22%, rgba(30,6,4,.7) 100%);
  mix-blend-mode: multiply;
}

/* 浮动提示 */
#toasts {
  position: absolute;
  top: 14px; left: 50%;
  transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 6px;
  align-items: center; pointer-events: none;
  z-index: 5;
}
.toast {
  background: rgba(10, 13, 17, .92);
  border: 1px solid var(--accent-2);
  border-radius: 4px;
  padding: 6px 14px;
  font-size: 13px;
  white-space: nowrap;
  animation: toastIn .18s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; } }

/* ---------- 侧栏 ---------- */
#side {
  background: var(--panel);
  border-left: 1px solid var(--line);
  padding: 11px;
  display: flex; flex-direction: column; gap: 9px;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.card {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 11px;
  flex-shrink: 0;
}
.card.grow { flex: 1 1 auto; min-height: 90px; display: flex; flex-direction: column; }
.card h3 {
  margin: 0 0 7px; font-size: 11px; font-weight: 600;
  color: var(--ink-dim); letter-spacing: 1px;
}
.card h3 small { font-weight: 400; opacity: .7; margin-left: 5px; letter-spacing: 0; }

/* 位置 */
#zone-info .zone-name { font-size: 15px; font-weight: 600; }
#zone-info .zone-theme { font-size: 11px; color: var(--ink-dim); margin: 2px 0 5px; }
#zone-info .zone-danger { font-size: 11px; letter-spacing: 1px; }
#zone-info .hint { font-size: 11px; color: var(--ink-dim); margin-top: 4px; }

#quest { font-size: 12.5px; line-height: 1.62; }
#quest .qnum { color: var(--accent); }
#quest .qdone { color: #5f9e5f; }

#ascension { font-size: 12px; }
#ascension .stage-name { font-size: 14px; color: var(--accent-2); margin-bottom: 5px; }
#ascension .bar { height: 5px; background: #0c0f13; border-radius: 3px; overflow: hidden; margin: 5px 0; }
#ascension .bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent-2), #7fd8cd); transition: width .3s ease; }
#ascension .hint, .hint { color: var(--ink-dim); line-height: 1.5; font-size: 11px; }

/* 权能清单 */
.ab-row {
  display: flex; align-items: center; gap: 7px;
  padding: 4px 0; border-bottom: 1px dashed #222a33;
}
.ab-row:last-child { border-bottom: none; }
.ab-glyph {
  flex: 0 0 22px; height: 22px; line-height: 22px; text-align: center;
  background: #0f1418; border: 1px solid #35404b; border-radius: 4px;
  font-size: 12px; color: var(--accent-2);
}
.ab-body { flex: 1 1 auto; min-width: 0; }
.ab-body b { display: block; font-size: 12px; font-weight: 600; }
.ab-body b em {
  font-style: normal; font-size: 10px; color: var(--accent);
  margin-left: 5px; border: 1px solid #4a3a20; border-radius: 3px; padding: 0 3px;
}
.ab-body i {
  display: block; font-style: normal; font-size: 10.5px; color: var(--ink-dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ab-cd { font-size: 11px; color: var(--danger); font-variant-numeric: tabular-nums; }

/* 势力 */
.fac-row { display: flex; align-items: center; gap: 7px; padding: 3px 0; font-size: 11.5px; }
.fac-name { flex: 0 0 56px; color: var(--ink-dim); }
.fac-bar { flex: 1 1 auto; height: 5px; background: #0c0f13; border-radius: 3px; overflow: hidden; }
.fac-bar > i { display: block; height: 100%; transition: width .3s ease; }
.fac-val { flex: 0 0 30px; text-align: right; font-variant-numeric: tabular-nums; }

/* 日志 */
#log {
  font-size: 11.5px; line-height: 1.55;
  flex: 1 1 auto; min-height: 0; overflow-y: auto;
  color: var(--ink-dim);
}
#log div { padding: 2px 0; border-bottom: 1px dashed #1f262d; }
#log div:last-child { border-bottom: none; }
#log .hl { color: var(--ink); }
#log .warn { color: #e0a35c; }
#log .bad { color: var(--danger); }

/* ---------- 底部 ---------- */
#controls {
  display: flex; align-items: center; gap: 18px;
  padding: 7px 16px;
  background: var(--panel);
  border-top: 1px solid var(--line);
  font-size: 11.5px; color: var(--ink-dim);
  min-height: 0;
}
#keys { display: flex; gap: 16px; margin-left: auto; flex-wrap: wrap; }
kbd {
  display: inline-block; min-width: 19px; padding: 1px 5px; margin-right: 3px;
  text-align: center; background: #0c0f13;
  border: 1px solid var(--line); border-bottom-width: 2px;
  border-radius: 3px; color: var(--ink); font-size: 10.5px;
}

/* 热键栏 */
#hotbar { display: flex; gap: 6px; }
.slot {
  position: relative;
  display: flex; align-items: center; gap: 6px;
  padding: 4px 9px 4px 6px;
  background: #0f1418;
  border: 1px solid #35404b;
  border-radius: 5px;
  overflow: hidden;
  min-width: 76px;
}
.slot.empty { opacity: .42; }
.slot .key {
  flex: 0 0 auto; font-size: 10px; color: var(--ink-dim);
  border: 1px solid #2a323c; border-radius: 3px; padding: 0 4px;
}
.slot .glyph { font-size: 13px; color: var(--accent-2); font-weight: 600; }
.slot .nm { font-size: 11.5px; white-space: nowrap; }
.slot .cool {
  position: absolute; left: 0; bottom: 0; height: 100%;
  background: rgba(0,0,0,.62); pointer-events: none;
  transition: width .1s linear;
}
.slot.cooling { border-color: #5a3a2a; }

/* ---------- 互动提示 ---------- */
#prompt {
  position: absolute; left: 50%; bottom: 20px;
  transform: translateX(-50%);
  background: rgba(10, 12, 15, .9);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 6px 15px;
  font-size: 12.5px;
  opacity: 0; transition: opacity .18s ease;
  pointer-events: none; white-space: nowrap;
  z-index: 4;
}
#prompt.on { opacity: 1; }

/* ---------- 对话框 ---------- */
#dialog {
  position: absolute; left: 50%; bottom: 40px;
  transform: translateX(-50%);
  width: 820px; max-width: calc(100% - 32px);
  max-height: calc(100% - 70px);
  display: flex; gap: 0;
  background: rgba(12, 15, 19, .97);
  border: 1px solid #3a4550;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 14px 40px rgba(0, 0, 0, .7);
  z-index: 10;
}
/* 对话立绘：说话人从 Q 版变成写实半身像 */
#dialog-portrait {
  flex: 0 0 auto;
  width: 240px; height: 320px;
  display: block;
  background: #0a0c10;
  border-right: 1px solid #2a323c;
}
#dialog-portrait.off { display: none; }
#dialog-main {
  flex: 1 1 auto;
  min-width: 0;
  padding: 16px 18px;
  display: flex; flex-direction: column;
  max-height: inherit;
  overflow-y: auto;
}
#dialog-body { font-size: 13.5px; line-height: 1.78; margin-bottom: 13px; }
#dialog-body .who { color: var(--accent-2); margin-right: 8px; font-weight: 600; }
#dialog-choices { display: flex; flex-direction: column; gap: 6px; }
.choice {
  text-align: left; padding: 8px 12px;
  background: #1a2027; border: 1px solid var(--line);
  border-radius: 5px; color: var(--ink);
  font-size: 12.5px; cursor: pointer; font-family: inherit;
  transition: background .12s, border-color .12s;
}
.choice:hover { background: #232c35; border-color: var(--accent-2); }
.choice .cost { color: var(--ink-dim); font-size: 11px; margin-left: 8px; }

/* ---------- 建造菜单 ---------- */
#build-menu {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: 470px; max-width: calc(100% - 40px);
  background: rgba(12, 15, 19, .97);
  border: 1px solid #3a4550;
  border-radius: 8px;
  padding: 15px 17px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, .65);
  z-index: 10;
}
#build-menu h3 { margin: 0 0 11px; font-size: 13.5px; }
#build-menu h3 small { color: var(--ink-dim); font-weight: 400; font-size: 11px; margin-left: 8px; }
#build-list { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.build-item {
  text-align: left; padding: 9px 11px;
  background: #1a2027; border: 1px solid var(--line);
  border-radius: 5px; color: var(--ink);
  cursor: pointer; font-family: inherit; font-size: 11.5px; line-height: 1.5;
}
.build-item:hover:not(:disabled) { background: #232c35; border-color: var(--accent); }
.build-item:disabled { opacity: .38; cursor: not-allowed; }
.build-item b { display: block; font-size: 12.5px; margin-bottom: 2px; }
.build-item .c { color: var(--accent); font-size: 11px; }
.build-item .c::before { content: '· '; opacity: .5; }
#build-list .locked {
  grid-column: 1 / -1; font-size: 12.5px; line-height: 1.7; color: var(--ink-dim);
}
#build-list .locked b { color: var(--accent-2); }

.hidden { display: none !important; }

/* 滚动条 */
::-webkit-scrollbar { width: 7px; }
::-webkit-scrollbar-track { background: #0c0f13; }
::-webkit-scrollbar-thumb { background: #2a323c; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #3a4550; }

/* ---------- 改造菜单 ---------- */
#mod-menu {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: 660px; max-width: calc(100% - 40px);
  max-height: calc(100% - 60px);
  display: flex; flex-direction: column;
  background: rgba(12, 15, 19, .97);
  border: 1px solid #3a4550;
  border-radius: 8px;
  padding: 15px 17px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, .65);
  z-index: 11;
}
#mod-menu h3 { margin: 0 0 11px; font-size: 13.5px; flex: 0 0 auto; }
#mod-menu h3 small { color: var(--ink-dim); font-weight: 400; font-size: 11px; margin-left: 8px; }
#mod-list { overflow-y: auto; min-height: 0; flex: 1 1 auto; }
#mod-list .locked { font-size: 12.5px; line-height: 1.7; color: var(--ink-dim); padding: 8px 2px; }
#loadout-slots { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; flex-shrink: 0; }
.loadout-slot { display: flex; min-width: 0; gap: 2px; padding: 4px; border: 1px solid #2a3b3b; background: #111a1d; }
.loadout-slot.selected { border-color: var(--accent-2); background: #152622; }
.loadout-slot .btn { font-family: inherit; font-size: 10.5px; height: 28px; padding: 0 5px; min-width: 0; }
.loadout-slot-choice { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.loadout-remove { flex-shrink: 0; color: var(--ink-dim); }
.loadout-remove:disabled { opacity: .3; }
#loadout-hint { margin: 8px 0 13px; font-size: 10.5px; line-height: 1.6; color: #a8b8c2; flex-shrink: 0; }
.loadout-ability-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 7px 0 9px; }
.loadout-ability-row > span { color: var(--ink-dim); font-size: 10.5px; line-height: 1.5; }
.loadout-equip { height: 28px; font-family: inherit; font-size: 11px; border-color: #3b5a50; flex-shrink: 0; }
.loadout-equip.equipped:disabled { color: #7fd8cd; background: #16241f; opacity: .9; border-color: #355b4a; }
.slot-cd { z-index: 1; color: #edba7d; font-size: 10px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.slot .key, .slot .glyph, .slot .nm { position: relative; z-index: 1; }

.mod-group { margin-bottom: 12px; }
.mod-head {
  display: flex; align-items: baseline; gap: 7px;
  padding-bottom: 5px; margin-bottom: 6px;
  border-bottom: 1px solid #232b33;
}
.mod-glyph {
  flex: 0 0 20px; text-align: center; font-size: 12px;
  color: var(--accent-2); background: #0f1418;
  border: 1px solid #35404b; border-radius: 4px;
}
.mod-head b { font-size: 13px; }
.mod-slots {
  font-size: 10.5px; color: var(--accent);
  border: 1px solid #4a3a20; border-radius: 3px; padding: 0 4px;
}
.mod-head i {
  flex: 1 1 auto; font-style: normal; font-size: 11px;
  color: var(--ink-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mod-items { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
.mod-item {
  text-align: left; padding: 8px 10px;
  background: #1a2027; border: 1px solid var(--line);
  border-radius: 5px; color: var(--ink);
  cursor: pointer; font-family: inherit; font-size: 11px; line-height: 1.45;
}
.mod-item:hover:not(:disabled) { background: #232c35; border-color: var(--accent); }
.mod-item:disabled { opacity: .42; cursor: not-allowed; }
.mod-item.owned { opacity: .82; border-color: #3d6b5f; background: #16241f; }
.mod-item b { display: block; font-size: 12px; margin-bottom: 3px; }
.mod-item b .c { color: var(--accent); font-size: 10px; margin-left: 5px; }
.mod-item i { display: block; font-style: normal; color: var(--ink-dim); }
.mod-item .why { display: block; margin-top: 3px; font-style: normal; font-size: 10px; color: #c2503f; }
.ab-body b em.mod { border-color: #3d6b5f; color: #7fd8cd; }

/* ---------- 任务面板：章节 / 支线 / 结算 ---------- */
#quest .q-progress {
  font-size: 11px; color: var(--ink-dim);
  padding-bottom: 6px; margin-bottom: 6px;
  border-bottom: 1px solid #232b33;
  font-variant-numeric: tabular-nums;
}
#quest .q-chapter {
  display: flex; align-items: baseline; gap: 6px;
  font-size: 11.5px; font-weight: 600;
  color: var(--ink-dim);
  margin: 8px 0 3px;
  padding-left: 2px;
  border-left: 2px solid #2a323c;
  padding-left: 6px;
}
#quest .q-chapter.active { color: var(--accent-2); border-left-color: var(--accent-2); }
#quest .q-chapter.done { color: #5f9e5f; border-left-color: #3d6b45; }
#quest .q-chapter i {
  font-style: normal; font-weight: 400; font-size: 10.5px; color: var(--ink-dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#quest .q-item {
  font-size: 12px; line-height: 1.55;
  padding: 1px 0 1px 8px;
}
#quest .q-item.qdone { color: #5f9e5f; }
#quest .q-item.q-side b { color: var(--accent); font-weight: 600; margin-right: 2px; }
#quest .q-item.q-side.qdone b { color: #5f9e5f; }
#quest .q-reward {
  margin-top: 9px; padding: 7px 9px;
  font-size: 11.5px; line-height: 1.55;
  background: #1a1710;
  border: 1px solid #4a3a20;
  border-radius: 5px;
  color: var(--accent);
}
#quest .q-reward.claimed {
  background: #16241f; border-color: #3d6b5f; color: #7fd8cd;
}

/* 结算奖励对话框：金色描边，和普通抉择区分开 */
#dialog.reward { border-color: #6b5426; box-shadow: 0 0 0 1px #3a2e14, 0 14px 40px rgba(0,0,0,.7); }
#dialog.reward #dialog-body .who { color: var(--accent); }

/* ---------- 存档 ---------- */
#save-state {
  font-size: 11px;
  color: var(--ink-dim);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 3px 9px;
  white-space: nowrap;
  transition: color .3s, border-color .3s;
}
#save-state.saved { color: #7fd8cd; border-color: #3d6b5f; }
#save-state.fail { color: var(--danger); border-color: #7a2a22; }
#save-state.saving { color: var(--accent); border-color: #4a3a20; }

.hud-btn {
  font-family: inherit;
  font-size: 11.5px;
  color: var(--ink);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 4px 12px;
  cursor: pointer;
  transition: border-color .12s, background .12s;
}
.hud-btn:hover { background: #232c35; border-color: var(--accent-2); }
.hud-btn.danger:hover { border-color: var(--danger); }

/* ---------- 结局 ---------- */
#dialog.ending {
  border-color: #6b5426;
  box-shadow: 0 0 0 1px #3a2e14, 0 18px 60px rgba(0,0,0,.8);
  background: linear-gradient(180deg, rgba(18,15,10,.98), rgba(10,12,16,.98));
}
#dialog.ending #dialog-body {
  font-size: 14px;
  line-height: 1.95;
  color: #e8e0d0;
}
#dialog.ending #dialog-body .who { color: var(--accent); }

/* 结局 / 长文本：对话框内部滚动，避免撑破屏幕 */
#dialog-main { max-height: min(70vh, 560px); overflow-y: auto; }
#dialog-body { white-space: pre-wrap; }

/* ---------- 游戏内时钟 ---------- */
#clock-badge {
  font-size: 11.5px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 3px 10px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  background: var(--panel-2);
}
#clock-badge.night { color: #9fb8ff; border-color: #33406b; }
#clock-badge.dusk { color: #ffb07a; border-color: #6b4a2f; }
#clock-badge.day { color: #ffe0a8; border-color: #6b5a2f; }

/* ---------- 势力领地 ---------- */
.fac-mod {
  font-style: normal;
  font-size: 9px;
  margin-left: 4px;
  padding: 0 3px;
  border: 1px solid #6b5426;
  border-radius: 2px;
  color: #ffd27a;
  vertical-align: middle;
}
.fac-ctrl { margin-top: 8px; padding-top: 7px; border-top: 1px solid var(--line); }
.fac-ctrl-title { font-size: 10.5px; color: #6f7c8a; margin-bottom: 5px; letter-spacing: .5px; }
.zone-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.zone-chip {
  font-size: 10px;
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 3px;
  color: #8b98a8;
  white-space: nowrap;
}
.fac-hint {
  margin-top: 6px;
  font-size: 10.5px;
  color: #7fd8cd;
  animation: facPulse 1.8s ease-in-out infinite;
}
@keyframes facPulse { 0%,100% { opacity: .55; } 50% { opacity: 1; } }

/* ---------- 赛季 ---------- */
.season-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 5px; }
.season-name { font-size: 12.5px; font-weight: 600; }
.season-pct { font-size: 11px; color: #6f7c8a; font-variant-numeric: tabular-nums; }
.season-bar { height: 4px; background: #1b2129; border-radius: 2px; overflow: hidden; margin-bottom: 6px; }
.season-bar i { display: block; height: 100%; transition: width .4s ease; }
.season-desc { font-size: 11px; color: #8b98a8; line-height: 1.6; }
.season-relics { margin-top: 5px; font-size: 10.5px; color: #b08a5a; }
.season-hist {
  margin-top: 7px; padding-top: 6px; border-top: 1px solid var(--line);
  font-size: 10.5px; color: #7f8b99; line-height: 1.65;
}
.season-hist.empty { color: #5c6673; font-style: normal; }

/* ---------- 体验层：城市手记、生命与操作面板 ---------- */
#hud { flex-wrap: wrap; gap: 9px; min-width: 0; }
#resources { min-width: 0; gap: 12px; }
.hud-actions { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.hud-actions .hud-btn { height: 28px; padding: 0 9px; white-space: nowrap; font-weight: 500; }
#btn-side { display: none; }
button:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 3px; }
.hud-btn[aria-pressed="true"] { color: var(--accent); border-color: #70552e; }

#objective-overlay {
  position: absolute; top: 16px; left: 16px; z-index: 3;
  width: min(326px, calc(100% - 32px)); padding: 12px 14px;
  background: linear-gradient(100deg, rgba(15, 21, 26, .95), rgba(15, 21, 26, .78));
  border: 1px solid #33413f; border-left: 3px solid var(--accent-2);
  box-shadow: 0 6px 20px rgba(0, 0, 0, .22);
  pointer-events: none; transition: opacity .16s ease;
}
.objective-top { display: flex; gap: 10px; justify-content: space-between; margin-bottom: 8px; }
.objective-label { font-size: 10px; letter-spacing: 2px; color: var(--accent-2); }
#objective-progress { font-size: 10px; color: var(--ink-dim); font-variant-numeric: tabular-nums; }
#objective-title { margin: 0 0 6px; font-size: 14px; line-height: 1.5; font-weight: 600; }
#objective-detail { margin: 0; font-size: 11px; line-height: 1.65; color: #a8b8c2; overflow-wrap: anywhere; }

#player-vitals {
  position: absolute; left: 16px; bottom: 16px; z-index: 3;
  width: min(250px, calc(100% - 32px)); padding: 10px 12px;
  background: rgba(12, 18, 22, .9); border: 1px solid #30413f; pointer-events: none;
}
.vital-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.vital-head > span { font-size: 10px; letter-spacing: 2px; color: var(--ink-dim); }
.vital-head strong { font-size: 12px; font-variant-numeric: tabular-nums; }
.vital-track { height: 5px; background: #253033; overflow: hidden; }
.vital-track i { display: block; height: 100%; width: 100%; background: var(--accent-2); transition: width .16s ease, background .16s ease; }
#player-vitals.low .vital-track i { background: var(--danger); }
#player-vitals.low .vital-head strong { color: #ffb4a0; }
#vital-layer { margin: 7px 0 0; font-size: 10px; line-height: 1.5; color: #a8b8c2; }
#player-vitals.inner { border-color: #644337; }
#player-vitals.inner #vital-layer { color: #e1a895; }
#viewport:has(#dialog:not(.hidden)) #objective-overlay,
#viewport:has(#dialog:not(.hidden)) #player-vitals { opacity: .16; }

#experience-panel {
  position: fixed; inset: 0; z-index: 50; display: flex;
  align-items: center; justify-content: center; padding: 24px;
  background: rgba(3, 7, 10, .84); backdrop-filter: blur(5px);
}
.experience-sheet {
  width: min(610px, 100%); max-height: calc(100dvh - 48px); overflow-y: auto;
  background: linear-gradient(145deg, #172428 0, #11191f 43%, #0d1319 100%);
  border: 1px solid #35534d; border-top: 3px solid var(--accent-2);
  box-shadow: 0 24px 80px rgba(0, 0, 0, .55); padding: 26px 30px 22px;
}
.experience-frequency { display: flex; justify-content: space-between; gap: 12px; color: var(--ink-dim); font-size: 10px; letter-spacing: 2px; }
.experience-frequency span:last-child { color: var(--accent-2); }
.experience-signal { display: flex; align-items: center; gap: 5px; height: 28px; margin: 20px 0 12px; }
.experience-signal i { display: block; height: 8px; width: 2px; background: var(--accent-2); opacity: .65; }
.experience-signal i:nth-child(2n) { height: 18px; }
.experience-signal i:nth-child(3n) { height: 28px; opacity: 1; }
#experience-panel-title { margin: 0 0 16px; font-size: clamp(23px, 3vw, 30px); line-height: 1.45; letter-spacing: 1px; font-weight: 600; }
#experience-panel-body { color: #aebec7; font-size: 13px; line-height: 1.8; }
#experience-panel-body p { margin: 0 0 13px; }
#experience-panel-body strong { color: var(--ink); font-weight: 600; }
.experience-route { display: grid; gap: 8px; margin: 18px 0 20px; padding: 14px 0; border-block: 1px solid #293d3e; }
.experience-route > div { display: flex; align-items: baseline; gap: 12px; }
.experience-route b { color: var(--accent); font-size: 10px; font-variant-numeric: tabular-nums; }
.experience-route span { font-size: 12px; }
.experience-key-list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 18px; padding: 15px 0 18px; }
.experience-key-list div { display: flex; gap: 7px; align-items: flex-start; font-size: 12px; }
.experience-key-list kbd { flex-shrink: 0; line-height: 1.5; }
.experience-note { padding: 11px 13px; background: #182623; border-left: 2px solid #537c6f; font-size: 12px; }
.experience-reset-note { background: #281b17; border-left-color: var(--danger); }
#experience-panel-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 21px; }
#experience-panel-actions .btn { font-family: inherit; min-height: 38px; font-size: 12px; }
#experience-panel-actions .btn-primary { font-weight: 700; }
.experience-footnote { color: #667a83; margin: 20px 0 0; font-size: 10px; letter-spacing: 1px; }
#experience-panel[data-mode="reset"] .experience-sheet { border-top-color: var(--danger); }
#experience-panel[data-mode="reset"] .experience-signal i { background: var(--danger); }
body.experience-open #app { pointer-events: none; }

/* 菜单在较矮窗口中内部滚动，标题始终留在视口内。 */
#build-menu { display: flex; flex-direction: column; max-height: calc(100% - 32px); }
#build-menu h3 { flex-shrink: 0; }
#build-list { min-height: 0; overflow-y: auto; }
#mod-menu { max-height: calc(100% - 32px); }
#controls { flex-wrap: wrap; gap: 7px 14px; min-width: 0; }
#keys { gap: 5px 12px; }
.toast { max-width: min(500px, calc(100vw - 36px)); white-space: normal; text-align: center; overflow-wrap: anywhere; }
#prompt { max-width: calc(100% - 28px); white-space: normal; text-align: center; line-height: 1.5; }

@media (max-width: 1279px) {
  #resources { order: 3; flex: 1 0 100%; margin-left: 0; }
  #keys { font-size: 10px; }
}

@media (max-width: 900px) {
  #stage { grid-template-columns: minmax(0, 1fr); }
  #btn-side { display: inline-flex; }
  #side {
    position: absolute; top: 0; right: 0; bottom: 0; z-index: 20;
    width: min(320px, calc(100% - 24px)); transform: translateX(100%);
    visibility: hidden; transition: transform .2s ease, visibility .2s;
    box-shadow: -12px 0 35px rgba(0, 0, 0, .5);
  }
  body.side-open #side { transform: translateX(0); visibility: visible; }
  #dialog-portrait { width: 180px; height: 240px; }
  #controls { padding: 7px 10px; }
  #keys { display: none; }
  #hotbar { width: 100%; justify-content: center; }
}

@media (max-width: 760px) {
  #hud { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 6px; padding: 8px 10px; }
  .hud-title { grid-column: 1; grid-row: 1; font-size: 14px; letter-spacing: 1px; }
  .hud-title .ver { display: none; }
  #zone-badge { grid-column: 2; grid-row: 1; font-size: 11px; padding: 3px 7px; }
  #layer-badge { grid-column: 3; grid-row: 1; font-size: 11px; padding: 3px 7px; }
  #clock-badge { grid-column: 1; grid-row: 2; justify-self: start; font-size: 10px; padding: 2px 6px; }
  #save-state { grid-column: 2 / 4; grid-row: 2; justify-self: end; font-size: 10px; padding: 2px 6px; max-width: 100%; overflow-wrap: anywhere; white-space: normal; }
  .hud-actions { grid-column: 1 / -1; grid-row: 3; margin-left: 0; justify-content: space-between; }
  .hud-actions .hud-btn { min-width: 0; flex: 1; padding: 0 5px; font-size: 11px; }
  #resources { grid-column: 1 / -1; grid-row: 4; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 4px 8px; }
  #resources .res { flex-wrap: wrap; gap: 1px 4px; font-size: 10px; }
  #resources .val { font-size: 13px; }
  #objective-overlay { top: 10px; left: 10px; width: min(326px, calc(100% - 20px)); padding: 9px 11px; }
  #objective-title { font-size: 12px; }
  #objective-detail { font-size: 10px; }
  #toasts { top: 126px; width: calc(100% - 24px); }
  #player-vitals { left: 10px; bottom: 10px; width: 230px; padding: 8px 10px; }
  #prompt { bottom: 87px; font-size: 11px; }
  #dialog { bottom: 10px; max-width: calc(100% - 20px); max-height: calc(100% - 20px); }
  #dialog-main { max-height: inherit; padding: 11px 12px; }
  #dialog-body { font-size: 12px; line-height: 1.7; }
  .choice { padding: 8px; font-size: 11px; }
  .choice .cost { display: block; margin: 3px 0 0; line-height: 1.5; }
  #mod-menu, #build-menu { max-width: calc(100% - 20px); padding: 12px; }
  #mod-menu h3 small, #build-menu h3 small { display: block; margin: 4px 0 0; }
  .mod-head { flex-wrap: wrap; }
  .mod-items { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  #loadout-slots { grid-template-columns: 1fr; gap: 4px; }
  .loadout-slot .btn { height: 26px; }
  .loadout-slot-choice { justify-content: flex-start; }
  .loadout-ability-row { flex-wrap: wrap; }
  .loadout-equip { margin-left: auto; }
  .slot { flex-wrap: wrap; }
  .slot-cd { flex-basis: 100%; padding-left: 20px; font-size: 9px; }
  #resources { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  #resources .res { flex-wrap: nowrap; }
  #dialog-portrait { width: 76px; height: 102px; }
  #dialog-main { padding: 10px; }
  #build-list { grid-template-columns: 1fr; }
  .slot { min-width: 0; flex: 1; padding: 5px; gap: 4px; }
  .slot .nm { font-size: 10px; }
  #experience-panel { padding: 12px; }
  .experience-sheet { padding: 18px 17px; max-height: calc(100dvh - 24px); }
  .experience-frequency { font-size: 9px; letter-spacing: 1px; }
  #experience-panel-title { font-size: 22px; }
  #experience-panel-body { font-size: 12px; }
  .experience-key-list { grid-template-columns: 1fr; gap: 8px; }
  #experience-panel-actions { display: grid; grid-template-columns: 1fr 1fr; }
  #experience-panel-actions .btn-primary { grid-column: 1 / -1; }
}

@media (max-height: 560px) and (min-width: 761px) {
  #objective-overlay { padding: 8px 11px; }
  #objective-detail { font-size: 10px; }
  #player-vitals { padding: 7px 10px; }
  #vital-layer { display: none; }
  #dialog { bottom: 10px; max-height: calc(100% - 20px); }
  #dialog-portrait { width: 150px; height: 200px; }
  #dialog-main { max-height: inherit; }
}

@media (max-height: 520px) {
  #mod-menu { display: block; overflow-y: auto; }
  #mod-list { overflow-y: visible; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
