/* === 纪元黎明：呢喃求生 - 样式 === */
* { box-sizing: border-box; margin: 0; padding: 0; user-select: none; }
html, body {
  height: 100%;
  background: #0b1018;
  color: #cfd9e4;
  font-family: "Consolas", "Microsoft YaHei", monospace;
  overflow: hidden;
}

#game-root {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 50% 30%, #16243a 0%, #0a1018 70%),
    #060a12;
}

/* === 主菜单（初始界面，参考版样式） === */
#menu-screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 100;
  background: radial-gradient(ellipse at center, rgba(10,20,30,0.92) 0%, rgba(0,0,0,0.97) 100%);
}
#menu-screen.hidden { display: none; }

#menu-screen h1 {
  font-size: 42px;
  color: #4da6ff;
  text-shadow: 0 0 20px rgba(77,166,255,0.6);
  margin-bottom: 10px;
  letter-spacing: 10px;
  font-weight: bold;
}
#menu-screen .subtitle {
  font-size: 14px;
  color: #6b7d95;
  margin-bottom: 48px;
  letter-spacing: 6px;
}
#menu-screen .menu-btn {
  font-family: inherit;
  font-size: 16px;
  padding: 14px 40px;
  margin: 8px 0;
  border: 2px solid #4da6ff;
  background: transparent;
  color: #4da6ff;
  cursor: pointer;
  letter-spacing: 4px;
  transition: all 0.2s;
  min-width: 280px;
  text-align: center;
}
#menu-screen .menu-btn:hover {
  background: #4da6ff;
  color: #000;
  box-shadow: 0 0 20px rgba(77,166,255,0.4);
}
#menu-screen .menu-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
#menu-screen .menu-btn:disabled:hover {
  background: transparent;
  color: #4da6ff;
  box-shadow: none;
}
#menu-screen .menu-link {
  margin-top: 22px;
  color: #59d98c;
  font-size: 13px;
  letter-spacing: 2px;
  text-decoration: none;
  border-bottom: 1px dashed rgba(89,217,140,0.5);
  padding-bottom: 2px;
}
#menu-screen .menu-link:hover { color: #8df0b4; border-bottom-color: #8df0b4; }

/* ===== 读取界面（像素字动画 + 磁盘同步） ===== */
#loading-screen {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, #0a141f 0%, #05080d 100%);
  transition: opacity 0.6s ease;
}
#loading-screen.fade-out { opacity: 0; }
#loading-screen.hidden { display: none; }
#loading-screen .load-inner { display: flex; flex-direction: column; align-items: center; }
/* 标题框：仅作为画布尺寸容器（白描边已改为「纪元黎明」文字本身的描边，见 #intro-canvas-outline） */
#loading-screen .title-frame {
  position: relative;
  width: min(82vw, 560px);
  height: 200px;
  display: flex; align-items: center; justify-content: center;
}
/* 白描边画布：把「纪元黎明」用白色描边（透明填充）绘出，作为像素字的轮廓导引。
   0% 时只有这根白边可见；进度推进时蓝色像素在其内部填充；100% 后本层淡出，只留蓝色像素字。 */
#loading-screen #intro-canvas-outline {
  position: absolute; inset: 0;
  width: 100% !important; height: 100% !important;
  display: block; z-index: 1; pointer-events: none;
  transition: opacity 0.6s ease;
}
/* 像素动画完成后由 boot.js 加上：白描边淡出，蓝像素字成为标题 */
#loading-screen #intro-canvas-outline.fade-outline { opacity: 0; }
/* 蓝色像素字画布：叠在白描边之上，逐格点亮填充内部 */
#loading-screen #intro-canvas {
  position: absolute; inset: 0;
  width: 100% !important; height: 100% !important;
  image-rendering: pixelated; display: block;
  z-index: 2; pointer-events: none;
}
#loading-screen .load-sub {
  margin-top: 18px; color: #4da6ff; opacity: 0.55;
  font-size: 15px; letter-spacing: 8px; text-shadow: 0 0 10px rgba(77,166,255,0.4);
}
/* 磁盘同步进度条（与像素字显现进度同源） */
#loading-screen .load-bar {
  margin-top: 30px; width: 320px; max-width: 70vw; height: 4px;
  background: rgba(77,166,255,0.12); border-radius: 3px; overflow: hidden;
}
#loading-screen .load-bar-fill {
  width: 0%; height: 100%; border-radius: 3px;
  background: linear-gradient(90deg, #2a6fb0, #4da6ff);
  box-shadow: 0 0 8px rgba(77,166,255,0.55);
  transition: width 0.08s linear;
}
#loading-screen .load-status {
  margin-top: 14px; color: #6b7d95; font-size: 13px; letter-spacing: 2px;
  min-height: 18px;
}
#loading-screen .load-status.ok { color: #5ed27a; }
#loading-screen .load-status.err { color: #ff9d3a; }

#topbar {
  width: 960px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 12px;
  background: linear-gradient(180deg, #14253c, #0d1a2c);
  border: 1px solid #2a3a55;
  border-bottom: 2px solid #1d3050;
  font-size: 13px;
  letter-spacing: 1px;
}

.bar-item { display: flex; align-items: center; gap: 6px; }
.bar-item .lbl { color: #6f87a8; }
.bar-item .val { color: #ffd180; font-weight: bold; }
.bar-item.right { margin-left: auto; }

#ui-hp-wrap, #ui-exp-wrap {
  display: inline-block;
  width: 90px;
  height: 10px;
  background: #1a2438;
  border: 1px solid #2c3d5c;
  position: relative;
}
#ui-hp { display: block; height: 100%; background: linear-gradient(90deg, #b14a4a, #d76a6a); transition: width 0.2s; }
#ui-exp { display: block; height: 100%; background: linear-gradient(90deg, #2d7a4e, #6fd093); width: 0%; transition: width 0.2s; }

#ui-hp-wrap::after, #ui-exp-wrap::after {
  content: '';
  position: absolute;
  inset: 0;
  border: 1px solid #2c3d5c;
}

#btn-save, #btn-reset {
  background: #1d2c45;
  color: #cfd9e4;
  border: 1px solid #3a4f72;
  padding: 3px 10px;
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
}
#btn-save:hover { background: #2a3e60; }
#btn-reset:hover { background: #5a3030; }

#game-canvas {
  background: #0a1018;
  border-left: 1px solid #1d3050;
  border-right: 1px solid #1d3050;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  display: block;
}

#bottombar {
  width: 960px;
  display: flex;
  justify-content: space-between;
  padding: 4px 12px;
  background: linear-gradient(180deg, #0d1a2c, #14253c);
  border: 1px solid #2a3a55;
  border-top: 2px solid #1d3050;
  font-size: 12px;
  min-height: 24px;
}

.crystals { display: flex; gap: 8px; align-items: center; }
.crystals .cry {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 6px;
  background: #1a2438;
  border: 1px solid #2c3d5c;
}
.cry .dot { width: 8px; height: 8px; border-radius: 50%; box-shadow: 0 0 6px currentColor; }
.cry .n { font-weight: bold; color: #fff; }

.talents { color: #92c4ff; }

/* === 通用面板 === */
.panel {
  position: fixed;
  inset: 0;
  background: rgba(4, 8, 14, 0.78);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
}
.panel.hidden { display: none; }

.panel-inner {
  width: 560px;
  max-height: 80vh;
  overflow-y: auto;
  background: linear-gradient(180deg, #14253c, #0a1525);
  border: 2px solid #2c3d5c;
  padding: 18px 22px;
  box-shadow: 0 0 30px rgba(0,0,0,0.7);
  font-size: 13px;
}

.panel-inner h2 {
  color: #ffd180;
  margin-bottom: 10px;
  font-size: 18px;
  border-bottom: 1px solid #2c3d5c;
  padding-bottom: 6px;
}
.panel-inner h3 { color: #92c4ff; margin: 12px 0 6px; font-size: 14px; }

/* ===== 角色面板（背包 / 属性技能 / 宠物 三合一标签页） ===== */
#panel-char .panel-inner { width: 600px; }
.ch-tabs { display: flex; gap: 6px; margin: -4px 0 12px; border-bottom: 1px solid #2c3d5c; padding-bottom: 8px; }
.ch-tab {
  flex: 1 1 0; background: #0d1a2b; color: #8aa0bd; border: 1px solid #2c3d5c; border-radius: 6px;
  padding: 7px 4px; font-family: inherit; font-size: 13px; cursor: pointer; transition: all .15s;
}
.ch-tab:hover { background: #16273f; color: #cfe8ff; }
.ch-tab.on { background: linear-gradient(180deg, #24406b, #172b47); color: #ffd180; border-color: #4a6b9c; box-shadow: 0 0 8px rgba(74,107,156,0.5); }
.ch-page.hidden { display: none; }
.ch-page h2 { margin-top: 0; }

/* 宠物标签页 */
.pt-empty { color: #6f87a8; font-size: 13px; text-align: center; padding: 28px 10px; line-height: 1.8; }
.pt-empty small { color: #55698a; font-size: 11.5px; }
.pt-card { background: rgba(10,20,32,0.6); border: 1px solid #2c3d5c; border-left: 3px solid #9fe0ff; border-radius: 7px; padding: 10px 12px; margin-bottom: 10px; }
.pt-card:last-child { margin-bottom: 0; }
.pt-title { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; font-size: 14px; }
.pt-title .pt-lv { color: #8aa0bd; font-size: 12px; }
.pt-ok { color: #5ed27a; font-size: 12px; }
.pt-warn { color: #ffd180; font-size: 12px; }
.pt-bad { color: #ff8a8a; font-size: 12px; }
.pt-bars { display: flex; flex-direction: column; gap: 4px; margin-bottom: 7px; }
.pt-bar { display: flex; align-items: center; gap: 7px; font-size: 11.5px; color: #8aa0bd; }
.pt-bar > span { flex: 0 0 34px; }
.pt-bar > i { flex: 1 1 auto; height: 7px; background: rgba(0,0,0,0.55); border-radius: 4px; overflow: hidden; }
.pt-bar > i > b { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, #5ed27a, #8fe3a0); transition: width .25s; }
.pt-bar > em { flex: 0 0 auto; font-style: normal; color: #cfe8ff; min-width: 78px; text-align: right; }
.pt-exp > i > b { background: linear-gradient(90deg, #4a86d8, #92c4ff); }
.pt-loy > i > b { background: linear-gradient(90deg, #d8548c, #ff9ec4); }
.pt-stats { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: #8aa0bd; margin-bottom: 5px; }
.pt-stats b { color: #cfe8ff; }
.pt-src { font-size: 11.5px; color: #6f87a8; margin-bottom: 8px; }
.pt-btns { display: flex; gap: 8px; }
.pt-feed, .pt-release { background: #1d2c45; color: #9fe0ff; border: 1px solid #2f5a6b; border-radius: 5px; padding: 4px 12px; font-size: 12px; cursor: pointer; font-family: inherit; }
.pt-feed:hover { background: #2a3f63; }
.pt-release { color: #ff8a8a; border-color: #5c2f38; }
.pt-release:hover { background: #3a1f25; }

.row { display: flex; justify-content: space-between; padding: 4px 0; }
.row b { color: #ffd180; }

.attr-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.attr-row {
  display: grid;
  grid-template-columns: 60px 36px 28px 1fr;
  gap: 6px;
  align-items: center;
  background: #14253c;
  padding: 4px 8px;
  border: 1px solid #2c3d5c;
  font-size: 12px;
}
.attr-row b { color: #92c4ff; }
.attr-row .v { color: #ffd180; font-weight: bold; text-align: center; }
.attr-row small { color: #6f87a8; font-size: 10px; }
.attr-row button.plus {
  background: #1d2c45;
  color: #6fd093;
  border: 1px solid #3a4f72;
  cursor: pointer;
  font-size: 12px;
}
.attr-row button.plus:disabled { color: #555; cursor: not-allowed; }

.skill-list, .talent-list { display: flex; flex-direction: column; gap: 4px; }
.skill-item, .talent-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  padding: 5px 8px;
  background: #14253c;
  border: 1px solid #2c3d5c;
  font-size: 12px;
}
.skill-item b, .talent-item b { color: #92c4ff; }
.skill-item small, .talent-item small { color: #6f87a8; }
.skill-item button, .talent-item button {
  background: #1d2c45;
  color: #6fd093;
  border: 1px solid #3a4f72;
  cursor: pointer;
}
.skill-item button:disabled, .talent-item button:disabled { color: #555; cursor: not-allowed; }

/* ===== 城市地图碰撞编辑器 ===== */
#collision-editor { position: fixed; inset: 0; background: rgba(0,0,0,0.92); display: flex; align-items: center; justify-content: center; z-index: 60; }
#collision-editor.hidden { display: none; }
.col-tool-hint { background: rgba(255,193,7,.14); color: #ffd166; border: 1px solid rgba(255,193,7,.5); border-radius: 6px; padding: 6px 12px; margin: 4px 14px 0; font-size: 12px; line-height: 1.5; }
.col-tool-hint.hidden { display: none; }
#collision-editor .col-wrap { display: flex; flex-direction: column; align-items: center; gap: 10px; }
#collision-canvas { background: #0b0e14; border: 1px solid #2a3650; cursor: crosshair; max-width: 96vw; max-height: 76vh; image-rendering: pixelated; }
#collision-editor .col-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; color: #cfe8ff; background: rgba(20,30,46,0.95); padding: 10px 14px; border: 1px solid #2a3650; border-radius: 8px; max-width: 96vw; }
#collision-editor .col-toolbar b { color: #ffd166; }
#collision-editor .col-toolbar label { display: flex; align-items: center; gap: 4px; cursor: pointer; }
#collision-editor .col-toolbar small { color: #7e93ac; width: 100%; }
/* 地图编辑器：顶部 Tab（遮罩编辑 / 怪物树） */
.col-tabs { display: flex; gap: 6px; margin-bottom: 2px; }
.col-tab { background: #1b2740; color: #9fb6d6; border: 1px solid #2a3650; border-radius: 8px 8px 0 0; padding: 8px 16px; cursor: pointer; font-size: 14px; transition: all .12s; }
.col-tab:hover { background: #223354; color: #cfe8ff; }
.col-tab.on { background: #2d4a7a; color: #fff; border-color: #3f6db0; box-shadow: 0 -2px 0 #ffd166 inset; }
/* 怪物树面板：覆盖在画布区上的抽屉 */
#collision-editor .col-wrap { position: relative; }
.mt-panel { position: absolute; inset: 0; background: rgba(12,18,28,0.97); border: 1px solid #2a3650; border-radius: 8px; padding: 12px 14px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.mt-panel.hidden { display: none; }
.mt-head { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #243450; padding-bottom: 8px; }
.mt-head b { color: #ffd166; font-size: 15px; }
.mt-status { color: #6fd093; font-size: 12px; }
.mt-sec { background: rgba(20,30,46,0.6); border: 1px solid #243450; border-radius: 8px; padding: 10px 12px; }
.mt-sec-title { color: #cfe8ff; font-size: 13px; font-weight: 600; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.mt-add { background: #234a32; color: #cfe8ff; border: 1px solid #2f6b46; border-radius: 6px; padding: 3px 10px; cursor: pointer; font-size: 12px; }
.mt-add:hover { background: #2c5c3f; }
#mt-clear-ch { background: #4a3f1f; color: #ffe0a0; border-color: #6b5a2f; }
#mt-clear-ch:hover { background: #5c4e26; }
#mt-clear-all { background: #4a2330; color: #ffb0b0; border-color: #6b2f3f; }
#mt-clear-all:hover { background: #5c2c3a; }
.mt-capture-lbl { display: inline-flex; align-items: center; gap: 3px; color: #9fe0ff; font-size: 12px; }
.mt-capture-lbl input { width: 44px; background: #14253c; color: #cfe8ff; border: 1px solid #3a4f72; border-radius: 5px; padding: 3px 5px; font-size: 12px; }
.mt-fixed-kind { background: #14253c; color: #ffd180; border: 1px solid #3a4f72; border-radius: 5px; padding: 3px 5px; font-size: 12px; }
.mt-bubble-lbl { display: inline-flex; align-items: center; gap: 3px; color: #9fe0ff; font-size: 12px; }
.mt-bubble-lbl input { width: 130px; background: #14253c; color: #cfe8ff; border: 1px solid #3a4f72; border-radius: 5px; padding: 3px 5px; font-size: 12px; }
.mt-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.mt-row label { color: #cfe8ff; font-size: 13px; }
.mt-hint { color: #7e93ac; font-size: 11px; line-height: 1.5; }
.mt-types { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 4px 10px; max-height: 190px; overflow-y: auto; padding: 6px; background: rgba(8,12,20,0.5); border-radius: 6px; }
.mt-types label { display: flex; align-items: center; gap: 6px; font-size: 12px; color: #bcd2ee; cursor: pointer; }
.mt-types input { accent-color: #ffd166; }
.mt-type.on { color: #ffd166; font-weight: 600; }
.mt-count-lbl { color: #cfe8ff; font-size: 12px; }
.mt-empty { color: #7e93ac; font-size: 12px; padding: 6px 2px; }
.mt-tags { display: flex; flex-direction: row; flex-wrap: wrap; gap: 6px; }
.mt-tags-hint { color: #9fb6d4; font-size: 11px; width: 100%; margin-bottom: 2px; }
.mt-tag { display: inline-block; background: rgba(35,74,50,0.55); border: 1px solid #2f6b46; color: #cfe8ff; border-radius: 999px; padding: 3px 10px; font-size: 12px; white-space: nowrap; }
.mt-tag:nth-child(even) { background: rgba(40,60,92,0.55); border-color: #3a5a8c; }
.mt-loc-sec.hidden, #mt-chapter-sec.hidden { display: none; }
.mt-fixed-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.mt-chapter-sec { border-color: #4a3a6b; background: rgba(34,24,52,0.5); }
.mt-chapter-sel { background: #1a1430; color: #e3d0ff; border: 1px solid #4a3a6b; border-radius: 5px; padding: 3px 6px; font-family: inherit; font-size: 12px; max-width: 200px; }
.mt-chapter-sec .mt-hint { color: #9b8bc4; }
.mt-chapter-sec .mt-types input { accent-color: #b56bff; }
.mt-chapter-sec .mt-type.on { color: #cda6ff; }
.mt-rule { background: rgba(20,14,38,0.7); border: 1px solid #4a3a6b; border-left: 3px solid #b56bff; border-radius: 6px; padding: 8px 10px; margin: 6px 0 10px; color: #d7c9f2; font-size: 12px; line-height: 1.6; white-space: pre-line; }
.mt-fixed-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; background: rgba(8,12,20,0.5); border: 1px solid #243450; border-radius: 6px; padding: 6px 8px; }
.mt-refresh-lbl { display: inline-flex; align-items: center; gap: 3px; color: #cfe8ff; font-size: 12px; }
.mt-refresh-lbl input { width: 48px; background: #14253c; color: #cfe8ff; border: 1px solid #3a4f72; border-radius: 5px; padding: 3px 5px; font-size: 12px; }
.mt-reset-cb { display: inline-flex; align-items: center; gap: 4px; color: #ffd9a0; font-size: 12px; cursor: pointer; }
.mt-reset-cb input { accent-color: #ffb020; }
.mt-fixed-row select, .mt-fixed-row input { background: #14253c; color: #cfe8ff; border: 1px solid #3a4f72; border-radius: 5px; padding: 4px 6px; font-size: 12px; }
.mt-area-btn { background: #3a2f4a; color: #cfe8ff; border: 1px solid #5a4a7a; border-radius: 6px; padding: 4px 8px; cursor: pointer; font-size: 12px; }
.mt-area-btn:hover { background: #4a3c5e; }
.mt-area-btn.active { background: #6a4aaa; color: #fff; border-color: #8a6acc; }
.mt-del { background: #4a1d1d; color: #ffd9d4; border: 1px solid #7a2e2e; border-radius: 6px; padding: 4px 8px; cursor: pointer; font-size: 12px; }
.mt-del:hover { background: #5e2626; }
/* 任务系统 */
#quest-panel { border-color: #2f5a6b; }
.mt-q-row { background: rgba(8,16,22,0.6); border: 1px solid #244a5a; border-radius: 6px; padding: 8px 10px; margin-bottom: 8px; }
.mt-q-name { font-size: 13px; color: #cfe8ff; margin-bottom: 3px; }
.mt-q-desc { font-size: 12px; color: #9fb6c4; line-height: 1.5; margin-bottom: 6px; }
.mt-q-row .mt-count-lbl { color: #cfe8ff; font-size: 12px; }
.mt-q-row .mt-q-count { background: #14253c; color: #cfe8ff; border: 1px solid #3a4f72; border-radius: 5px; padding: 3px 6px; width: 56px; margin-left: 4px; }
/* HUD 任务追踪条 */
#quest-tracker { position: fixed; left: 14px; bottom: 14px; max-width: 320px; background: rgba(10,18,28,0.86); border: 1px solid #2f5a6b; border-left: 3px solid #46c8ff; border-radius: 8px; padding: 8px 12px; color: #dff4ff; font-size: 13px; z-index: 60; box-shadow: 0 4px 18px rgba(0,0,0,0.4); }
#quest-tracker b { color: #8fe3ff; }
#quest-tracker .qt-prog { margin-top: 3px; color: #cfe8ff; font-size: 12px; }
#quest-tracker .qt-req { margin-top: 3px; color: #9ff0c0; font-size: 12px; }
#quest-prompt { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); background: rgba(20,40,30,0.92); border: 1px solid #4cd964; border-radius: 22px; padding: 8px 20px; color: #d6ffe2; font-size: 14px; font-weight: bold; z-index: 60; box-shadow: 0 4px 18px rgba(0,0,0,0.45); pointer-events: none; }
#quest-prompt::before { content: '🆆 '; }
.mt-area-info { color: #8fb0d8; font-size: 11px; }
/* 固定投放：等级 + 高级属性（阶层/属性覆盖） */
.mt-level-lbl { display: inline-flex; align-items: center; gap: 3px; color: #ffd180; font-size: 12px; }
.mt-level-lbl input { width: 48px; background: #14253c; color: #cfe8ff; border: 1px solid #3a4f72; border-radius: 5px; padding: 3px 5px; font-size: 12px; }
.mt-adv-btn { background: #2a3a52; color: #cfe8ff; border: 1px solid #3a5a8c; border-radius: 6px; padding: 4px 8px; cursor: pointer; font-size: 12px; margin-left: 2px; }
.mt-adv-btn:hover { background: #34486a; }
.mt-adv-btn.active { background: #3a6a9a; color: #fff; border-color: #4f8acc; }
.mt-fixed-adv { flex-basis: 100%; background: rgba(6,10,18,0.6); border: 1px dashed #3a5a8c; border-radius: 6px; padding: 7px 9px; margin-top: 2px; }
.mt-adv-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.mt-adv-row:last-child { margin-bottom: 0; }
.mt-adv-cap { color: #9fb6d4; font-size: 11px; width: 100%; margin-bottom: 2px; }
.mt-fixed-adv .mt-types { display: flex; flex-wrap: wrap; gap: 4px 10px; max-height: none; padding: 0; background: none; }
.mt-fixed-adv .mt-type { font-size: 11px; }
.mt-fixed-stat { display: inline-flex; align-items: center; gap: 3px; color: #cfe8ff; font-size: 11px; margin-right: 8px; }
.mt-fixed-stat input { width: 60px; background: #14253c; color: #cfe8ff; border: 1px solid #3a4f72; border-radius: 5px; padding: 3px 5px; font-size: 12px; }
/* 固定投放：阶层单选 chips + 属性手改标记 */
.mt-tier-opt { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border: 1px solid #3a4f72; border-radius: 12px; cursor: pointer; }
.mt-tier-opt.on { border-color: #4da6ff; background: rgba(77,166,255,0.15); color: #cfe8ff; }
.mt-tier-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; box-shadow: 0 0 5px currentColor; }
.mt-fixed-stat.cus input { border-color: #e8b24d; color: #ffe0a0; }
.mt-cus { color: #e8b24d; margin-left: 6px; font-weight: 600; }
.mt-stat-reset { background: #1d3350; color: #9fd0ff; border: 1px solid #3a5a8c; border-radius: 5px; padding: 3px 8px; font-size: 11px; cursor: pointer; }
.mt-stat-reset:hover { background: #26456b; }
.mt-adv-tip { color: #7d93b0; font-size: 10px; line-height: 1.5; margin-top: 4px; }
#collision-editor .col-toolbar button { background: #23314d; color: #cfe8ff; border: 1px solid #3a4f72; border-radius: 6px; padding: 6px 10px; cursor: pointer; }
#collision-editor .col-toolbar button:hover { background: #2d3f63; }
#collision-editor .col-toolbar .close-btn { background: #3a2a2a; border-color: #6b3a3a; }
#collision-editor .col-toolbar .col-persist-sep { color: #46566f; margin: 0 2px; }
#collision-editor .col-toolbar .persist-status {
  padding: 4px 8px; border: 1px dashed #3a4f72; border-radius: 4px;
  background: rgba(255,255,255,0.05); margin-left: 4px;
  font-size: 11px; line-height: 1.2;
}
#collision-editor .col-toolbar .persist-status.ok {
  border-color: #6fd093; background: rgba(111,208,147,0.10); color: #6fd093 !important;
}

.close-btn {
  margin-top: 14px;
  background: #1d2c45;
  color: #cfd9e4;
  border: 1px solid #3a4f72;
  padding: 6px 16px;
  cursor: pointer;
  font-family: inherit;
}

/* ===== 素材库（遮罩编辑器内） ===== */
#item-lib { position: fixed; right: 14px; top: 14px; width: 252px; max-height: 92vh; overflow-y: auto;
  background: rgba(18,28,44,0.97); border: 1px solid #2a3650; border-radius: 10px; padding: 10px 12px;
  color: #cfe8ff; z-index: 70; box-shadow: 0 6px 26px rgba(0,0,0,0.5); font-size: 12px; }
#item-lib.hidden { display: none; }
#item-lib .il-head { display: flex; align-items: center; gap: 6px; }
#item-lib .il-head b { color: #ffd166; flex: 1; font-size: 13px; }
#item-lib .il-head button { background: #23314d; color: #cfe8ff; border: 1px solid #3a4f72; border-radius: 5px; cursor: pointer; padding: 2px 8px; }
#item-lib .il-head button:hover { background: #2d3f63; }
#item-lib .il-dirty { color: #ffb24d; font-size: 11px; font-weight: bold; padding: 1px 6px; border: 1px solid #6b4a1a; border-radius: 10px; background: rgba(255,178,77,0.12); }
#item-lib #btn-item-clear { background: #3a2a2a; color: #ffb3b3; border-color: #6b3a3a; }
#item-lib #btn-item-clear:hover { background: #4a3333; }
#item-lib .il-hint { color: #8fa6c2; line-height: 1.5; margin: 8px 0; background: rgba(255,255,255,0.04); padding: 6px 8px; border-radius: 6px; }
#item-lib .il-sub { color: #7e93ac; margin: 8px 0 4px; }
#item-lib .il-sep { border-top: 1px dashed #2a3650; padding-top: 8px; }
#item-lib .il-thumbs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
#item-lib .il-thumb { background: #0e1828; border: 1px solid #2a3650; border-radius: 6px; padding: 4px; cursor: pointer; text-align: center; transition: border-color .15s; }
#item-lib .il-thumb:hover { border-color: #ffd166; }
#item-lib .il-thumb-empty { background: #141d2e; border-style: dashed; border-color: #3a4d70; display: flex; align-items: center; justify-content: center; }
#item-lib .il-thumb-empty span { color: #9fc0e6; font-weight: bold; font-size: 11px; }
#item-lib .il-mini-empty { display: inline-flex; align-items: center; justify-content: center; background: #141d2e; border: 1px dashed #3a4d70; border-radius: 4px; color: #9fc0e6; font-weight: bold; font-size: 12px; line-height: 1; }
#item-lib .il-mini-empty { width: 30px; height: 30px; background: #141d2e; border: 1px dashed #3a4d70; border-radius: 4px; }
#item-lib .il-thumb img { width: 100%; height: 52px; object-fit: contain; background: #060b14; border-radius: 4px; display: block; }
#item-lib .il-thumb span { display: block; font-size: 10px; color: #8fa6c2; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* 素材库缩略图分组标题（空素材 / 载具素材 / 图片素材 栏目头） */
#item-lib .il-thumb-head { grid-column: 1 / -1; color: #ffd166; font-size: 11px; font-weight: bold; margin: 6px 0 2px; padding-top: 5px; border-top: 1px dashed #2a3650; line-height: 1.4; }
#item-lib .il-thumb-head:first-of-type { border-top: 0; margin-top: 0; padding-top: 0; }
/* 精灵库暂无角色包时的占位提示 */
#item-lib .il-thumb-none { grid-column: 1 / -1; color: #8fa6c2; font-size: 10px; line-height: 1.5; background: rgba(255,255,255,0.04); border: 1px dashed #2a3650; border-radius: 6px; padding: 6px 8px; }
/* 载具素材（角色包）缩略图 */
#item-lib .il-thumb-veh { display: flex; flex-direction: column; align-items: center; gap: 2px; }
#item-lib .il-thumb-veh canvas { width: 100%; height: 62px; object-fit: contain; background: #060b14; border-radius: 4px; display: block; image-rendering: pixelated; }
#item-lib .il-thumb-veh.sel { border-color: #ffd166; box-shadow: 0 0 0 1px #ffd166 inset; }
/* 已放置列表里的载具小图 */
#item-lib .il-mini-veh { width: 30px; height: 30px; object-fit: contain; background: #060b14; border-radius: 4px; image-rendering: pixelated; }

/* ===== 载具素材：四方向碰撞 / 隐藏区域画笔 ===== */
#item-lib .ili-vm-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; color: #cfe0f0; background: #0e1828; border: 1px solid #2a3650; border-radius: 6px; padding: 5px 7px; }
#item-lib .ili-vm-tools label { display: flex; align-items: center; gap: 4px; cursor: pointer; font-size: 11px; }
#item-lib .ili-vm-tools input[type=radio] { accent-color: #ffd166; }
#item-lib .ili-vm-tools b { color: #ffd166; font-size: 11px; min-width: 10px; text-align: center; }
#item-lib .ili-vm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
#item-lib .ili-vm-cell { background: #0e1828; border: 1px solid #2a3650; border-radius: 6px; padding: 4px; display: flex; flex-direction: column; gap: 3px; }
#item-lib .ili-vm-cell.cur { border-color: #ffd166; box-shadow: 0 0 0 1px #ffd166 inset; }
#item-lib .ili-vm-cell b { color: #9fc0e6; font-size: 10px; font-weight: bold; }
#item-lib .ili-vm-cell.cur b { color: #ffd166; }
#item-lib .ili-vm-cell canvas { width: 100%; height: auto; aspect-ratio: 1 / 1; background: #060b14; border: 1px solid #1b2740; border-radius: 4px; cursor: crosshair; display: block; image-rendering: pixelated; touch-action: none; }
#item-lib .ili-vm-act { background: #0e1828; border: 1px solid #2a3650; border-radius: 6px; padding: 4px; display: flex; flex-direction: column; gap: 3px; margin-top: 6px; }
#item-lib .ili-vm-act b { color: #9fc0e6; font-size: 10px; font-weight: bold; }
#item-lib .ili-vm-act.cur b, #item-lib .ili-vm-act b.cur { color: #ffd166; }
#item-lib .ili-vm-act-cv { width: 100%; height: auto; aspect-ratio: 1 / 1; background: #060b14; border: 1px solid #1b2740; border-radius: 4px; cursor: crosshair; display: block; image-rendering: pixelated; touch-action: none; }
#item-lib .ili-vm-act-cv.cur { border-color: #ffd166; box-shadow: 0 0 0 1px #ffd166 inset; }
#item-lib .il-placed { display: flex; flex-direction: column; gap: 5px; }
#item-lib .il-empty { color: #5d6f88; font-size: 11px; padding: 4px 0; }
/* file:// 打开时的警示横幅 */
.file-warning { position: fixed; top: 0; left: 0; right: 0; z-index: 9999; display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: #3a1d1d; color: #ffd9d9; border-bottom: 2px solid #b5484b; font-size: 13px; line-height: 1.5; box-shadow: 0 2px 10px rgba(0,0,0,.4); }
.file-warning.hidden { display: none; }
.file-warning .fw-icon { font-size: 16px; flex-shrink: 0; }
.file-warning .fw-text { flex: 1; }
.file-warning .fw-text code { background: rgba(255,255,255,.12); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.file-warning .fw-close { margin-left: 8px; background: transparent; border: 1px solid #ff9a9a; color: #ffd9d9; border-radius: 6px; width: 26px; height: 26px; cursor: pointer; flex-shrink: 0; line-height: 1; }
.file-warning .fw-close:hover { background: rgba(255,255,255,.1); }
#item-lib .il-loc-hint { color: #ffd166; background: rgba(255,209,102,0.08); border: 1px solid rgba(255,209,102,0.35); border-radius: 6px; padding: 6px 8px; margin: 4px 0 8px; font-size: 11px; line-height: 1.5; }
#item-lib .il-row { display: flex; align-items: center; gap: 6px; background: #0e1828; border: 1px solid #2a3650; border-radius: 6px; padding: 4px 6px; cursor: pointer; }
#item-lib .il-row.sel { border-color: #ffd166; box-shadow: 0 0 0 1px #ffd166 inset; }
#item-lib .il-mini { width: 30px; height: 30px; object-fit: contain; background: #060b14; border-radius: 4px; }
#item-lib .il-name { flex: 1; font-size: 10px; color: #b9cbe0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#item-lib .il-ctrl { display: flex; align-items: center; gap: 3px; flex-wrap: wrap; }
#item-lib .il-ctrl button { background: #23314d; color: #cfe8ff; border: 1px solid #3a4f72; border-radius: 4px; cursor: pointer; width: 20px; height: 20px; line-height: 1; padding: 0; font-size: 12px; }
#item-lib .il-ctrl button:hover { background: #2d3f63; }
#item-lib .il-ctrl .il-layer { min-width: 14px; text-align: center; color: #ffd166; }
#item-lib .il-del { color: #ff9b9b !important; }
#item-lib .il-near { display: inline-flex; align-items: center; gap: 3px; background: #14233a; border: 1px solid #34507e; border-radius: 4px; padding: 2px 5px; flex-shrink: 0; cursor: text; }
#item-lib .il-near-lbl { color: #8fd6ff; font-size: 11px; user-select: none; }
#item-lib .il-near-in { width: 34px; min-width: 34px; height: 24px; min-height: 24px; background: #0a1422; color: #cfe8ff; border: 1px solid #34507e; border-radius: 4px; font-size: 13px; text-align: center; padding: 2px 4px; outline: none; cursor: text; -webkit-user-select: text; user-select: text; }
#item-lib .il-near-in:focus { border-color: #ffd166; box-shadow: 0 0 0 1px #ffd166 inset; background: #10203a; }

/* ===== 素材交互配置面板 ===== */
#item-lib .il-interaction { margin: 10px 0 4px; border-top: 1px dashed #2a3650; padding-top: 8px; display: flex; flex-direction: column; gap: 8px; }
#item-lib .il-interaction.hidden { display: none; }
#item-lib .ili-title { color: #ffd166; font-weight: bold; font-size: 12px; }
#item-lib .ili-row { display: flex; align-items: center; gap: 6px; color: #cfe0f0; font-size: 11px; flex-wrap: wrap; }
#item-lib .ili-lbl { color: #8fa6c2; font-size: 11px; min-width: 56px; }
#item-lib .ili-input { background: #0a1422; color: #cfe8ff; border: 1px solid #34507e; border-radius: 4px; padding: 3px 6px; font-size: 12px; flex: 1; min-width: 0; outline: none; }
#item-lib .ili-input:focus { border-color: #ffd166; }
#item-lib .ili-sub2 { color: #7e93ac; font-size: 11px; margin-top: 2px; }
#item-lib .ili-step { background: #0e1828; border: 1px solid #2a3650; border-radius: 6px; padding: 6px; display: flex; flex-direction: column; gap: 5px; }
#item-lib .ili-step-h { color: #ffb24d; font-size: 11px; font-weight: bold; }
#item-lib .ili-vis { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
#item-lib .ili-vis-lbl { color: #8fa6c2; font-size: 11px; width: 100%; }
#item-lib .ili-cb { display: inline-flex; align-items: center; gap: 3px; color: #b9cbe0; font-size: 10px; background: #14233a; border: 1px solid #2a3650; border-radius: 4px; padding: 1px 5px; cursor: pointer; }
#item-lib .ili-give, #item-lib .ili-txt { display: flex; align-items: center; gap: 6px; }
#item-lib .ili-select { background: #0a1422; color: #cfe8ff; border: 1px solid #34507e; border-radius: 4px; padding: 3px; font-size: 11px; flex: 1; min-width: 0; }
#item-lib .ili-select optgroup { color: #ffd166; font-weight: bold; background: #0e1828; }
#item-lib .ili-select option { color: #cfe8ff; background: #0a1422; }
#item-lib .ili-del { background: #3a1f24; color: #ff9b9b; border: 1px solid #6b2a2a; border-radius: 4px; cursor: pointer; padding: 3px 8px; font-size: 11px; align-self: flex-start; }
#item-lib .ili-add { background: #1d3350; color: #cfe8ff; border: 1px solid #34507e; border-radius: 4px; cursor: pointer; padding: 4px 8px; font-size: 11px; }
#item-lib .ili-note { color: #7e93ac; font-size: 10px; line-height: 1.5; background: rgba(255,255,255,0.03); padding: 5px 7px; border-radius: 6px; }
/* 已选素材标签上的 ✕ 移除按钮 */
#item-lib .ili-chip-x { background: transparent; color: #ff9b9b; border: 0; cursor: pointer; font-size: 11px; line-height: 1; padding: 0 0 0 4px; }
#item-lib .ili-chip-x:hover { color: #ff6a6a; }
/* 载具「变身预览」画布 */
#item-lib .ili-vprev { width: 100%; max-width: 236px; background: #0c1626; border: 1px solid #2a3650; border-radius: 6px; display: block; image-rendering: pixelated; }
.primary {
  margin-top: 14px;
  background: #2e7d4f;
  color: #eafff1;
  border: 1px solid #46b06f;
  padding: 6px 16px;
  cursor: pointer;
  font-family: inherit;
  font-weight: bold;
}
.primary:hover { background: #37935e; }
.unsaved {
  margin-top: 14px;
  color: #ffb454;
  font-size: 12px;
  font-family: inherit;
}

/* === 背包 === */
.bag-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
  margin-bottom: 10px;
}
.bag-cell {
  background: #14253c;
  border: 1px solid #2c3d5c;
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  text-align: center;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.bag-cell.empty { color: #445; }
.bag-cell .ic { width: 26px; height: 26px; border-radius: 4px; }
.bag-cell .ic-img { width: 34px; height: 34px; object-fit: contain; image-rendering: pixelated; }
.bag-cell .nm { margin-top: 2px; color: #cfd9e4; font-size: 9px; }
.bag-cell .ct { position: absolute; bottom: 1px; right: 2px; color: #ffd180; font-weight: bold; }
.bag-cell:hover { background: #1d2c45; }

.equip-row { display: flex; gap: 6px; }
.equip-slot {
  flex: 1;
  background: #14253c;
  border: 1px solid #2c3d5c;
  padding: 6px;
  text-align: center;
  font-size: 11px;
}
.equip-slot .ev-img { width: 30px; height: 30px; object-fit: contain; image-rendering: pixelated; margin: 0 auto; }
.equip-slot .en { color: #92c4ff; }
.equip-slot .ev { color: #ffd180; font-weight: bold; margin-top: 4px; }

/* === 合成 === */
#craft-list { display: flex; flex-direction: column; gap: 6px; }
.craft-item {
  background: #14253c;
  border: 1px solid #2c3d5c;
  padding: 8px 10px;
}
.craft-item b { color: #92c4ff; }
.craft-item small { color: #6f87a8; display: block; margin-top: 4px; }
.craft-item button {
  margin-top: 4px;
  background: #1d2c45;
  color: #6fd093;
  border: 1px solid #3a4f72;
  padding: 3px 10px;
  cursor: pointer;
}
.craft-item button:disabled { color: #555; cursor: not-allowed; }

/* === 对话框 === */
#dialogue {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  width: 700px;
  z-index: 40;
}
#dialogue.hidden { display: none; }
.dlg-inner {
  background: linear-gradient(180deg, rgba(20,37,60,0.96), rgba(10,21,37,0.96));
  border: 2px solid #92c4ff;
  padding: 12px 18px;
  box-shadow: 0 0 20px rgba(146,196,255,0.3);
}
.dlg-title { color: #ffd180; font-size: 13px; margin-bottom: 4px; }
.dlg-text { color: #cfd9e4; font-size: 14px; line-height: 1.7; min-height: 50px; white-space: pre-wrap; }
#dlg-next {
  margin-top: 6px;
  background: transparent;
  color: #92c4ff;
  border: 1px solid #92c4ff;
  padding: 3px 12px;
  cursor: pointer;
  font-family: inherit;
}

/* === 任务交付面板（提交要求勾选：交出 or 保留） === */
#quest-submit-panel {
  /* 之前是 position:fixed（相对视口），移到 #app 内后会被旋转的 #app 框架带偏。
     改为 position:absolute，使面板在 #app（已旋转 90°）内绝对定位，连带一起转成横屏。 */
  position: absolute; inset: 0; z-index: 220;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
#quest-submit-panel.hidden { display: none; }
.qsp-mask {
  position: absolute; inset: 0;
  background: rgba(2,8,16,0.78);
  backdrop-filter: blur(2px);
}
.qsp-inner {
  position: relative;
  width: 480px; max-width: 96vw; max-height: 88vh;
  display: flex; flex-direction: column;
  background: linear-gradient(180deg, rgba(20,37,60,0.98), rgba(10,21,37,0.98));
  border: 2px solid #92c4ff;
  border-radius: 10px;
  padding: 20px 22px 18px;
  box-shadow: 0 8px 40px rgba(77,166,255,0.35), 0 0 60px rgba(0,0,0,0.5);
  overflow: hidden;
}
.qsp-title { color: #ffd180; font-size: 18px; font-weight: bold; margin-bottom: 8px; letter-spacing: 1px; }
.qsp-sub   { color: #8aa0bd; font-size: 12.5px; line-height: 1.55; margin-bottom: 14px; padding: 8px 10px; background: rgba(10,20,32,0.6); border-left: 3px solid #6fd093; border-radius: 4px; }
.qsp-list  { flex: 1 1 auto; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 4px 2px 8px; min-height: 0; }
.qsp-row {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(10,20,32,0.55);
  border: 1px solid #2c3d5c; border-radius: 7px;
}
.qsp-row.checked { border-color: #6fd093; background: rgba(20,40,30,0.5); }
.qsp-row .qsp-cb { width: 22px; height: 22px; cursor: pointer; accent-color: #6fd093; }
.qsp-row .qsp-info { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.qsp-row .qsp-name { color: #e8eef5; font-size: 14px; font-weight: bold; }
.qsp-row .qsp-cur  { color: #8aa0bd; font-size: 11.5px; }
.qsp-row .qsp-cur b { color: #ffd180; }
.qsp-row .qsp-qty-wrap { display: flex; align-items: center; gap: 6px; color: #8aa0bd; font-size: 12px; }
.qsp-row .qsp-qty-btn {
  width: 28px; height: 28px; border-radius: 5px;
  background: #1d2c45; color: #cfe8ff; border: 1px solid #3a4f72;
  font-family: inherit; font-size: 16px; line-height: 1; cursor: pointer;
}
.qsp-row .qsp-qty-btn:hover { background: #2a3e60; }
.qsp-row .qsp-qty-btn:disabled { color: #555; cursor: not-allowed; background: #14253c; }
.qsp-row .qsp-qty-input {
  width: 50px; height: 28px; box-sizing: border-box; text-align: center;
  background: #0e1c30; color: #ffd180; border: 1px solid #3a4f72; border-radius: 5px;
  font-family: inherit; font-size: 14px; font-weight: bold;
}
.qsp-row .qsp-qty-input:disabled { color: #555; background: #14253c; }
.qsp-row .qsp-pet-tag { color: #9fe0ff; font-size: 11.5px; }
.qsp-actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; justify-content: flex-end; }
.qsp-btn {
  font-family: inherit; font-size: 14px; padding: 10px 18px;
  border-radius: 6px; cursor: pointer;
  border: 1px solid #2c3d5c;
  background: #1d2c45; color: #cfe8ff;
  letter-spacing: 1px;
  transition: all .15s ease;
  min-height: 44px;
}
.qsp-btn:hover { background: #2a3e60; }
.qsp-btn.qsp-cancel { border-color: #5c2f38; color: #ff9d9d; background: #2c1620; }
.qsp-btn.qsp-cancel:hover { background: #3a1f25; }
.qsp-btn.qsp-confirm { border-color: #6fd093; color: #b5f0c5; background: #163a25; }
.qsp-btn.qsp-confirm:hover { background: #1d4d30; }
.qsp-btn:disabled { color: #555; background: #14253c; cursor: not-allowed; border-color: #2c3d5c; }
/* 移动端：交付面板全宽显示，按钮全宽布局 */
@media (max-width: 760px), (pointer: coarse) and (max-width: 1024px) {
  #quest-submit-panel { padding: 10px; align-items: flex-end; }
  .qsp-inner { width: 100%; max-width: 100%; max-height: 92vh; padding: 16px 14px 14px; }
  .qsp-title { font-size: 16px; }
  .qsp-row { grid-template-columns: 32px 1fr; gap: 8px; padding: 10px; }
  .qsp-row .qsp-qty-wrap { grid-column: 1 / -1; padding-left: 0; margin-top: 4px; }
  .qsp-actions { flex-direction: column-reverse; gap: 8px; }
  .qsp-btn { width: 100%; min-height: 50px; font-size: 15px; }
}

/* === 任务提示 === */
#quest-toast {
  position: fixed;
  top: 60px;
  right: 16px;
  width: 260px;
  background: linear-gradient(180deg, rgba(20,37,60,0.95), rgba(10,21,37,0.95));
  border: 1px solid #ffd180;
  padding: 10px 14px;
  z-index: 30;
  font-size: 12px;
}
#quest-toast.hidden { display: none; }
.toast-title { color: #ffd180; font-size: 12px; margin-bottom: 4px; }
#quest-text { color: #cfd9e4; line-height: 1.5; }

/* === 浮动伤害文字 === */
.dmg-float {
  position: absolute;
  pointer-events: none;
  color: #ffd180;
  font-weight: bold;
  text-shadow: 1px 1px 0 #000;
  z-index: 20;
}

/* === 怪物 / 主角 属性编辑器 === */
/* 弹窗容器：自身不滚动，由内部列表滚动（避免双重滚动条） */
#panel-monsters .panel-inner {
  width: min(1240px, 96vw);
  max-height: 94vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 16px 20px;
}
#panel-monsters .panel-inner h2 { flex: 0 0 auto; }
#panel-monsters .row, #panel-monsters .persist-row { flex: 0 0 auto; }
.me-hint { flex: 0 0 auto; margin: 0 0 8px; }
.me-hint summary { cursor: pointer; color: #6fd093; font-size: 12px; user-select: none; }
.me-hint .hint { font-size: 12px; line-height: 1.5; color: #8aa0bd; margin-top: 4px; }
/* 列表：多列平铺卡片，内部滚动（全弹窗唯一滚动条） */
.monster-list {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(560px, 1fr));
  align-content: start;
  gap: 12px;
  overflow-y: auto;
  padding: 4px 6px 4px 2px;
  margin: 0;
}
.mcard { display: grid; grid-template-columns: 1fr auto; grid-template-areas: "head head" "fields shape"; gap: 8px 12px; background: #0e1c30; border: 1px solid #2c3d5c; border-radius: 8px; padding: 10px 12px; }
.mcard-player { border-color: #ffd180; box-shadow: 0 0 0 1px rgba(255,209,128,0.25); }
.mcard-head { grid-area: head; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mcard-head b { color: #92c4ff; font-size: 14px; }
.mcard-kind { color: #6f87a8; font-size: 12px; background: #14253c; border: 1px solid #2c3d5c; padding: 1px 6px; border-radius: 4px; }
.mcard-kind-sel { background: #14253c; color: #cfd9e4; border: 1px solid #3a4f72; padding: 1px 4px; font-family: inherit; }
.mcard-ai-sel { background: #14253c; color: #6fd093; border: 1px solid #3a4f72; padding: 1px 4px; font-family: inherit; }
.mcard-lock { color: #ff9d3a; font-size: 11px; margin-left: auto; }
.mcard-del { margin-left: auto; background: #3a1d22; color: #ff8a8a; border: 1px solid #6a2c33; padding: 2px 8px; cursor: pointer; font-family: inherit; }
.mcard-grid { grid-area: fields; display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px 12px; align-content: start; }
.mcard-player .mcard-grid { grid-template-columns: repeat(2, 1fr); }
.mf { display: flex; flex-direction: column; font-size: 11px; color: #8aa0bd; gap: 2px; }
.mf span { white-space: nowrap; }
.mf input, .mf select { background: #14253c; color: #e8eef5; border: 1px solid #3a4f72; padding: 3px 5px; font-family: inherit; font-size: 12px; width: 100%; box-sizing: border-box; }
.mf input:disabled { color: #6f87a8; background: #0b1626; cursor: not-allowed; }

/* 形状可视化编辑器 */
.mcard-shape { grid-area: shape; display: flex; align-items: flex-start; gap: 10px; margin: 0; padding: 0; border-top: none; }
.shape-cv { background: #0a1422; border: 1px solid #2c3d5c; border-radius: 6px; cursor: crosshair; flex: 0 0 auto; touch-action: none; }
.shape-ctrls { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.shape-ctrls .mf { width: 110px; }
.shape-tip { font-size: 11px; color: #6f87a8; line-height: 1.4; max-width: 150px; }
.me-showcol { flex-direction: row; align-items: center; gap: 4px; font-size: 11px; color: #8aa0bd; }
.me-showcol input { width: auto; box-sizing: content-box; }
#btn-monsters, #btn-editor-menu { cursor: pointer; }
#btn-monsters { background: #1d2c45; color: #6fd093; border: 1px solid #3a4f72; padding: 2px 10px; font-family: inherit; }

/* ============ 新旅途流程 ============ */
.ng-screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 200;
  background: radial-gradient(ellipse at center, rgba(10,20,30,0.96) 0%, rgba(0,0,0,0.98) 100%);
}
/* 全局隐藏类：确保任意元素（任务编辑器触发点 label、删除按钮等）加 .hidden 都能隐藏，
   覆盖 .q-lbl{display:flex} 等默认 display 规则 */
.hidden { display: none !important; }
.ng-screen.hidden { display: none; }

/* ============ 任务系统编辑器 ============ */
#quest-screen {
  justify-content: flex-start;
  align-items: stretch;
  background: radial-gradient(ellipse at top, rgba(10,20,30,0.97) 0%, rgba(0,0,0,0.98) 100%);
  padding: 0;
  overflow: auto;
}
.q-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 28px; border-bottom: 1px solid #2c3d5c; flex: 0 0 auto;
}
.q-head h1 { font-size: 26px; color: #4da6ff; letter-spacing: 4px; margin: 0; text-shadow: 0 0 16px rgba(77,166,255,0.5); }
.q-body { display: flex; gap: 18px; padding: 18px 28px; flex: 1 1 auto; align-items: stretch; min-height: 0; }
.q-list-wrap { flex: 0 0 320px; display: flex; flex-direction: column; min-height: 0; background: rgba(14,28,48,0.5); border: 1px solid #2c3d5c; border-radius: 8px; padding: 12px; }
.q-list-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.q-list-head span { color: #92c4ff; font-size: 14px; letter-spacing: 2px; }
.q-list { display: flex; flex-direction: column; gap: 10px; overflow: auto; flex: 1 1 auto; padding-right: 4px; }
.q-item { background: rgba(10,20,32,0.6); border: 1px solid #2c3d5c; border-radius: 6px; padding: 10px 12px; }
.q-item-main { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.q-item-main b { color: #e8eef5; font-size: 14px; }
.q-item-sub { color: #6b7d95; font-size: 12px; margin: 5px 0 8px; line-height: 1.4; }
.q-item-btns { display: flex; gap: 8px; }
.q-empty { color: #6b7d95; font-size: 13px; text-align: center; padding: 20px 0; }
.q-badge { font-size: 11px; padding: 1px 8px; border-radius: 10px; color: #0a1422; font-weight: bold; }
.q-badge-rescue { background: #6fd093; }
.q-badge-kill { background: #ff7b7b; }
.q-badge-find { background: #ffd180; }
.q-badge-path { background: #4da6ff; }
.q-form-wrap { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; background: rgba(14,28,48,0.5); border: 1px solid #2c3d5c; border-radius: 8px; padding: 12px 16px; overflow: auto; }
.q-form-head { color: #92c4ff; font-size: 15px; letter-spacing: 2px; margin-bottom: 12px; border-bottom: 1px dashed #2c3d5c; padding-bottom: 8px; }
.q-form { display: flex; flex-direction: column; gap: 12px; }
.q-lbl { display: flex; flex-direction: column; gap: 5px; color: #8aa0bd; font-size: 13px; }
.q-lbl input, .q-lbl select, .q-lbl textarea {
  font-family: inherit; font-size: 14px; padding: 8px 10px;
  background: #0e1c30; color: #e8eef5; border: 1px solid #2c3d5c; border-radius: 5px;
  width: 100%; box-sizing: border-box; resize: vertical;
}
.q-lbl input:focus, .q-lbl select:focus, .q-lbl textarea:focus { outline: none; border-color: #4da6ff; box-shadow: 0 0 8px rgba(77,166,255,0.35); }
.q-obj { background: rgba(10,20,32,0.5); border: 1px solid #243650; border-radius: 6px; padding: 10px 12px; display: flex; flex-direction: column; gap: 10px; }
.q-obj.hint { color: #6f87a8; font-size: 12px; line-height: 1.5; }
.q-obj.hidden { display: none; }
.q-form-btns { display: flex; gap: 10px; margin-top: 4px; flex-wrap: wrap; }
.menu-btn.q-close { margin: 0; }
.menu-btn.q-add { margin: 0; padding: 4px 12px; font-size: 13px; }
.menu-btn.q-del { background: #3a1f25; color: #ff8a8a; border-color: #5c2f38; }
.menu-btn.q-cancel { background: #1d2c45; color: #9fb4d0; border-color: #3a4f72; }
.q-hint { color: #6f87a8; font-size: 11.5px; line-height: 1.5; }
/* 任务奖励（多选物品） */
.q-rewards { background: rgba(8,16,28,0.5); border: 1px solid #2c3d5c; border-radius: 6px; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.q-reward-row { display: flex; align-items: center; gap: 8px; }
.q-reward-row select { flex: 1 1 auto; min-width: 0; }
.q-reward-n { width: 56px; background: #14253c; color: #cfe8ff; border: 1px solid #3a4f72; border-radius: 5px; padding: 5px 6px; font-size: 13px; }
.q-reward-add { margin: 0; padding: 5px 12px; font-size: 13px; background: #163a25; color: #9ff0c0; border-color: #2c6b45; }
.q-reward-add:hover { background: #1d4d30; }
.q-reward-list { display: flex; flex-wrap: wrap; gap: 6px; }
.q-reward-chip { display: inline-flex; align-items: center; gap: 4px; background: #14253c; color: #cfe8ff; border: 1px solid #3a4f72; border-radius: 14px; padding: 3px 8px 3px 10px; font-size: 12.5px; }
.q-reward-del { background: transparent; border: none; color: #ff8a8a; cursor: pointer; font-size: 12px; padding: 0 2px; line-height: 1; }
.q-reward-del:hover { color: #ff5a5a; }
.q-reward-empty { color: #6f87a8; font-size: 11.5px; font-style: italic; }

/* 任务：提交要求（结束点交付条件） */
.q-requires { margin: 10px 0 4px; padding: 10px 12px; background: rgba(10,20,32,0.5); border: 1px dashed #4a6b3a; border-radius: 6px; }
.q-requires.hidden { display: none; }
.q-req-chip { border-color: #4a6b3a; background: #16281a; color: #cdefc9; }
.q-req-del { background: transparent; border: none; color: #ff8a8a; cursor: pointer; font-size: 12px; padding: 0 2px; line-height: 1; }
.q-req-del:hover { color: #ff5a5a; }

/* 任务环节导航（链式任务：第1环=含触发点，第2+环=连续任务无触发点） */
.q-step-nav { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; padding: 8px 10px; background: rgba(10,20,32,0.5); border: 1px dashed #2c3d5c; border-radius: 6px; }
.q-step-nav.hidden { display: none; }
.q-step-nav .q-step-lbl { color: #92c4ff; font-size: 12px; letter-spacing: 1px; }
.q-step-btn { background: #14253c; color: #9fb4d0; border: 1px solid #2c3d5c; border-radius: 5px; padding: 3px 10px; font-size: 12px; cursor: pointer; font-family: inherit; }
.q-step-btn:hover { background: #1d2c45; }
.q-step-btn.on { background: #1d3a5c; color: #fff; border-color: #4da6ff; box-shadow: 0 0 8px rgba(77,166,255,0.35); }
.menu-btn.q-addstep { background: #1d3a5c; color: #9fe0ff; border-color: #2f5a6b; }
.menu-btn.q-addstep:hover { background: #2a4a6b; }

/* 宠物面板（HUD 左下，任务追踪条上方） */
#pet-panel { position: fixed; left: 14px; bottom: 58px; max-width: 340px; background: rgba(10,18,28,0.86); border: 1px solid #2f5a6b; border-left: 3px solid #9fe0ff; border-radius: 8px; padding: 8px 12px; color: #dff4ff; font-size: 13px; z-index: 60; box-shadow: 0 4px 18px rgba(0,0,0,0.4); }
#pet-panel.hidden { display: none; }
#pet-panel .pet-head { color: #9fe0ff; font-weight: bold; margin-bottom: 6px; font-size: 13px; }
#pet-panel .pet-row { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
#pet-panel .pet-row:last-child { margin-bottom: 0; }
#pet-panel .pet-row.pet-down { opacity: 0.6; }
#pet-panel .pet-row.pet-down .pet-name { color: #ff9a9a; }
#pet-panel .pet-name { flex: 0 0 auto; color: #e8eef5; font-size: 12px; white-space: nowrap; }
#pet-panel .pet-name small { color: #8aa0bd; }
#pet-panel .pet-hpbar { flex: 1 1 auto; height: 6px; background: rgba(0,0,0,0.55); border-radius: 3px; overflow: hidden; }
#pet-panel .pet-hpfill { display: block; height: 100%; background: linear-gradient(90deg, #5ed27a, #8fe3a0); border-radius: 3px; transition: width 0.2s; }
#pet-panel .pet-feed, #pet-panel .pet-release { flex: 0 0 auto; background: #1d2c45; color: #9fe0ff; border: 1px solid #2f5a6b; border-radius: 5px; padding: 2px 8px; font-size: 11px; cursor: pointer; font-family: inherit; }
#pet-panel .pet-feed:hover { background: #2a3f63; }
#pet-panel .pet-release { color: #ff8a8a; border-color: #5c2f38; }
#pet-panel .pet-release:hover { background: #3a1f25; }
.ng-step { display: flex; flex-direction: column; align-items: center; width: 100%; }
.ng-step.hidden { display: none; }
.ng-step h1 {
  font-size: 38px;
  color: #4da6ff;
  text-shadow: 0 0 20px rgba(77,166,255,0.6);
  letter-spacing: 8px;
  margin-bottom: 8px;
  font-weight: bold;
}
.ng-sub { color: #6b7d95; font-size: 14px; letter-spacing: 2px; margin-bottom: 28px; }
#ng-name-input {
  font-family: inherit;
  font-size: 18px;
  padding: 12px 16px;
  width: 280px;
  text-align: center;
  background: #0e1c30;
  color: #e8eef5;
  border: 2px solid #2c3d5c;
  border-radius: 6px;
  margin-bottom: 18px;
  letter-spacing: 2px;
}
#ng-name-input:focus { outline: none; border-color: #4da6ff; box-shadow: 0 0 12px rgba(77,166,255,0.4); }
.ng-back { margin-top: 18px; }
.ng-back a, .ng-reroll { color: #6b7d95; font-size: 12px; text-decoration: none; border-bottom: 1px dashed rgba(107,125,149,0.5); cursor: pointer; }
.ng-back a:hover, .ng-reroll:hover { color: #9fb4d0; }
/* 移动版属性分配摘要条（未分配 / 重新掷骰 / 折叠衍生属性）—— 桌面+移动都显示 */
.ng-mobile-summary { display: flex; }
.ng-toggle-derived { color: #6fd093; font-size: 12px; text-decoration: none; border-bottom: 1px dashed rgba(111,208,147,0.4); cursor: pointer; }
.ng-toggle-derived:hover { color: #b5f0c5; }
.ng-derived-wrap { background: rgba(14,28,48,0.6); border: 1px solid #2c3d5c; border-radius: 8px; padding: 14px 16px; margin-top: 14px; }
.ng-derived-title { color: #92c4ff; font-size: 13px; letter-spacing: 2px; margin-bottom: 10px; text-align: center; }
.ng-step-actions { display: flex; flex-direction: column; align-items: center; margin-top: 18px; }
/* 移动端：默认折叠衍生属性（玩家点 📊 衍生属性 按钮切换） */
@media (max-width: 760px), (pointer: coarse) and (max-width: 1024px) {
  .ng-derived-wrap { display: block; }
  .ng-derived-wrap.collapsed { display: none; }
  .ng-mobile-summary .ng-toggle-derived { display: inline-block; }
}
.ng-grid { display: flex; gap: 36px; margin: 12px 0 26px; align-items: flex-start; }
.ng-col { background: rgba(14,28,48,0.6); border: 1px solid #2c3d5c; border-radius: 8px; padding: 16px 20px; min-width: 240px; }
.ng-col h3 { color: #92c4ff; font-size: 14px; margin: 0 0 12px; letter-spacing: 2px; text-align: center; }
.ng-attr-list { display: flex; flex-direction: column; gap: 8px; }
.ng-attr-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: rgba(20,37,60,0.5); border-radius: 6px; }
.ng-attr-row b { color: #92c4ff; width: 40px; font-size: 14px; }
.ng-attr-row .v { color: #ffd180; font-weight: bold; width: 28px; text-align: center; font-size: 16px; }
.ng-attr-row button {
  width: 30px; height: 30px; border-radius: 6px; cursor: pointer;
  background: #1d2c45; color: #6fd093; border: 1px solid #3a4f72;
  font-family: inherit; font-size: 18px; line-height: 1;
}
.ng-attr-row button:hover { background: #2a3e60; }
.ng-attr-row button.ng-minus { color: #ff9d6a; }
.ng-remain { color: #6f87a8; font-size: 13px; margin-top: 14px; text-align: center; }
.ng-remain b { color: #ffd180; font-size: 16px; }
.ng-derived-list { display: flex; flex-direction: column; gap: 7px; min-width: 180px; }
.ng-d { display: flex; justify-content: space-between; font-size: 13px; padding: 4px 8px; background: rgba(20,37,60,0.5); border-radius: 5px; }
.ng-d span { color: #8aa0bd; }
.ng-d b { color: #ffd180; }

/* 新旅途 步骤3：地图选择 */
.ng-map-btns { display: flex; gap: 24px; margin-top: 22px; }
.ng-map-btn {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  width: 220px; padding: 22px 16px;
  background: rgba(18,32,54,0.85);
  border: 1px solid #31486b; border-radius: 10px;
  color: #cfe0f5; font-family: inherit; cursor: pointer;
  transition: all 0.15s ease;
}
.ng-map-btn:hover {
  background: rgba(29,53,88,0.95); border-color: #5aa8ff;
  box-shadow: 0 0 14px rgba(90,168,255,0.35); transform: translateY(-2px);
}
.ng-map-btn .ng-map-icon { font-size: 34px; line-height: 1; }
.ng-map-btn b { font-size: 16px; letter-spacing: 2px; color: #ffd180; }
.ng-map-btn small { font-size: 11px; color: #7f93af; line-height: 1.5; }

/* 新旅途按钮：套用主题按钮样式（默认 .menu-btn 仅在 #menu-screen 内生效，这里为新旅途补上） */
.ng-screen .menu-btn {
  font-family: inherit; font-size: 16px; padding: 13px 40px; margin: 8px 0;
  border: 2px solid #4da6ff; background: transparent; color: #4da6ff; cursor: pointer;
  letter-spacing: 4px; transition: all 0.2s; min-width: 260px; text-align: center; border-radius: 6px;
}
.ng-screen .menu-btn:hover { background: #4da6ff; color: #000; box-shadow: 0 0 20px rgba(77,166,255,0.4); }
.ng-screen .menu-btn:active { transform: translateY(1px); }

/* ===== 移动端：新旅途（属性分配 / 地图选择）适配 =====
   问题：原 .ng-screen 用 justify-content:center 且无滚动，竖屏内容超出视口时顶部被裁、底部「下一步」按钮落到屏幕外点不到。
   修复：允许纵向滚动、内容靠上排布、属性行变全宽可点、衍生属性可折叠、「下一步」按钮位置 sticky 始终可见。 */
@media (max-width: 760px), (pointer: coarse) and (max-width: 1024px) {
  .ng-screen {
    justify-content: flex-start;
    align-items: stretch;
    overflow-y: auto;
    padding: 18px 14px 100px;   /* 底部留空给 sticky 按钮 */
    -webkit-overflow-scrolling: touch;
  }
  .ng-step { width: 100%; max-width: 480px; margin: 0 auto; }
  .ng-step h1 { font-size: 24px; letter-spacing: 4px; margin-bottom: 6px; }
  .ng-sub { font-size: 13px; margin-bottom: 12px; text-align: center; padding: 0 6px; color: #8aa0bd; }
  #ng-name-input { width: 100%; max-width: 360px; }

  /* ===== 步骤2 属性分配：完全重写为移动友好的纵向布局 ===== */
  /* 隐藏旧的 ng-grid 双列布局（已重构为单列 + 折叠衍生属性） */
  .ng-grid { display: none; }
  /* 移动版摘要条：未分配 + 重新掷骰 + 折叠衍生属性 */
  .ng-mobile-summary {
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 8px 14px;
    width: 100%;
    padding: 10px 14px;
    margin: 0 0 14px;
    background: linear-gradient(180deg, rgba(36,64,107,0.45), rgba(23,43,71,0.45));
    border: 1px solid #2c3d5c;
    border-radius: 8px;
    font-size: 13px;
  }
  .ng-mobile-summary .ng-sum-lbl { color: #8aa0bd; letter-spacing: 1px; }
  .ng-mobile-summary .ng-sum-val { color: #ffd180; font-size: 20px; font-weight: bold; min-width: 28px; text-align: center; }
  .ng-mobile-summary .ng-reroll { color: #6fd093; font-size: 12px; }
  /* 属性行：2 行 × 3 列紧凑网格，每格独立堆叠「属性名 / 数值 / ±按钮」，6 个属性 + 标题 + 摘要条 + 「下一步」全部塞得下 */
  .ng-attr-list {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }
  .ng-attr-row {
    display: grid;
    grid-template-areas:
      "name name name"
      "minus v plus";
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    justify-items: center;
    gap: 4px;
    padding: 8px 4px;
    background: rgba(20,37,60,0.55);
    border: 1px solid #2c3d5c;
    border-radius: 8px;
    text-align: center;
  }
  .ng-attr-row b { grid-area: name; font-size: 13px; letter-spacing: 1px; }
  .ng-attr-row .v { grid-area: v; font-size: 18px; min-width: 28px; }
  .ng-attr-row button {
    width: 36px; height: 36px;
    font-size: 18px;
    touch-action: manipulation;
  }
  /* 步骤2操作区：固定底部，水平方向（按钮占满宽度），永远可见不挡属性 */
  .ng-step-actions {
    position: fixed; left: 0; right: 0; bottom: 0;
    margin: 0;
    padding: 10px 14px calc(env(safe-area-inset-bottom, 0) + 10px);
    background: linear-gradient(180deg, rgba(10,21,37,0.95) 0%, rgba(10,21,37,0.98) 100%);
    border-top: 1px solid #2c3d5c;
    z-index: 210;
    box-shadow: 0 -4px 18px rgba(0,0,0,0.45);
  }
  /* 移动端隐藏步骤2里的「返回姓名」链接（用户无需回退） */
  .ng-step-actions .ng-back { display: none; }
  /* 给滚动区底部留空，避免最后一行属性被底部按钮遮住 */
  #ng-step-attrs { padding-bottom: 100px; }

  .ng-screen .menu-btn,
  #ng-name-next, #ng-start {
    width: 100%; max-width: 480px; min-width: 0;
    min-height: 52px; font-size: 16px; padding: 14px 20px;
    letter-spacing: 3px; touch-action: manipulation;
  }

  .ng-map-btns { flex-direction: column; gap: 14px; width: 100%; max-width: 480px; }
  .ng-map-btn { width: 100%; padding: 18px 14px; }

  .ng-back { margin-top: 12px; text-align: center; }
}

/* ===== 角色面板属性技能页 / 宠物页：移动端单列布局 ===== */
@media (max-width: 760px), (pointer: coarse) and (max-width: 1024px) {
  #panel-char .panel-inner { width: 100%; max-width: 100%; max-height: 100vh; border-radius: 0; }
  .ch-tabs { gap: 4px; }
  .ch-tab { font-size: 12.5px; padding: 8px 4px; }
  .attr-grid { grid-template-columns: 1fr; gap: 8px; }
  .attr-row {
    grid-template-columns: 60px 44px 44px 1fr;
    gap: 8px;
    padding: 8px 10px;
    font-size: 13px;
  }
  .attr-row button.plus { width: 36px; height: 36px; font-size: 16px; }
  .skill-item, .talent-item { padding: 8px 10px; }
  .pt-card { padding: 10px; }
  .pt-stats { gap: 8px; font-size: 11.5px; }
  .panel-content { padding: 12px 12px; max-height: 78vh; }
}

/* 怪物编辑器：对比主角大小按钮 */
.mcard-cmp {
  margin-top: 6px;
  font-family: inherit;
  font-size: 11px;
  padding: 5px 8px;
  background: #1d2c45;
  color: #9fd0ff;
  border: 1px solid #3a6fb0;
  border-radius: 5px;
  cursor: pointer;
}
.mcard-cmp:hover { background: #2a4570; }
.mcard-cmp.active { background: #2a4570; color: #cfe8ff; border-color: #5aa8ff; box-shadow: 0 0 8px rgba(90,168,255,0.5); }

/* 怪物编辑器：永久化存档文件夹 */
.persist-row { margin-top: 8px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; border-top: 1px dashed #2c3d5c; padding-top: 8px; }
.persist-row button {
  font-family: inherit; font-size: 11px; padding: 4px 9px; cursor: pointer;
  background: #1d2c45; color: #9fd0ff; border: 1px solid #3a4f72; border-radius: 5px;
}
.persist-row button:hover { background: #2a3e60; }
.persist-status { font-size: 11px; color: #6f87a8; }
.persist-status.ok { color: #6fd093; }
/* ===================== 装备库编辑器 ===================== */
/* 装备库从主菜单打开，主菜单 z-index=100，必须高于它才能盖在前面 */
#equip-library { z-index: 110; }
.el-inner { width: 900px; max-width: 96vw; }
.el-body { display: flex; gap: 14px; min-height: 460px; }
.el-side { width: 180px; flex: 0 0 180px; display: flex; flex-direction: column; gap: 6px; }
.el-side-title { color: #7e93ac; font-size: 12px; margin: 2px 0 4px; }
.el-cats { display: flex; flex-direction: column; gap: 4px; }
.el-cat { padding: 7px 10px; border-radius: 6px; background: #14253c; color: #cfe8ff; cursor: pointer; font-size: 13px; display: flex; justify-content: space-between; align-items: center; border: 1px solid transparent; }
.el-cat:hover { background: #1d2f4c; }
.el-cat.active { background: #234064; border-color: #5aa8ff; box-shadow: 0 0 6px rgba(90,168,255,0.4); }
.el-cat-n { background: #0e1c30; color: #9fd0ff; border-radius: 9px; padding: 0 7px; font-size: 11px; }
.el-main { flex: 1; display: flex; gap: 12px; min-width: 0; }
.el-list-wrap { width: 220px; flex: 0 0 220px; display: flex; flex-direction: column; }
.el-list-title { color: #7e93ac; font-size: 12px; margin-bottom: 6px; }
.el-list { flex: 1; overflow-y: auto; background: #0e1c30; border: 1px solid #23344f; border-radius: 6px; padding: 6px; max-height: 420px; }
.el-list-empty { color: #6f87a8; font-size: 12px; padding: 10px; }
.el-item { display: flex; align-items: center; gap: 8px; padding: 6px; border-radius: 5px; cursor: pointer; }
.el-item:hover { background: #16263f; }
.el-item.active { background: #234064; }
.el-thumb { width: 30px; height: 30px; object-fit: contain; background: #0a1422; border-radius: 4px; flex: 0 0 30px; }
.el-thumb-none { display: flex; align-items: center; justify-content: center; color: #567; font-size: 10px; }
.el-item-name { font-size: 13px; color: #dce8f6; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.el-edit { flex: 1; overflow-y: auto; max-height: 420px; padding-right: 6px; }
.el-empty { color: #6f87a8; font-size: 13px; padding: 20px; }
.el-field { display: flex; align-items: center; gap: 8px; margin: 5px 0; }
.el-field label { width: 150px; flex: 0 0 150px; color: #9fb3cc; font-size: 12px; text-align: right; }
.el-field input, .el-field select { flex: 1; background: #0e1c30; color: #dce8f6; border: 1px solid #2c3d5c; border-radius: 5px; padding: 5px 7px; font-family: inherit; font-size: 13px; }
.el-field input:focus, .el-field select:focus { border-color: #5aa8ff; outline: none; }
.el-file-row { display: flex; gap: 6px; flex: 1; align-items: center; }
.el-file-row input[type=file] { flex: 1; font-size: 11px; color: #9fb3cc; }
.el-minmax { display: flex; gap: 5px; flex: 1; }
.el-minmax input { width: 60px; }
.el-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.el-sec-title { color: #ffd166; font-size: 12px; margin: 12px 0 4px; border-top: 1px dashed #2c3d5c; padding-top: 8px; }
.el-prev-wrap { margin: 8px 0; display: flex; flex-direction: column; align-items: center; gap: 6px; }
#el-preview { background: #0c1626; border: 1px solid #23344f; border-radius: 8px; }
.el-prev-ctrl { color: #9fb3cc; font-size: 12px; display: flex; align-items: center; gap: 8px; }
.el-prev-ctrl input[type=range] { width: 220px; }
.el-prev-ctrl .el-scale-input { width: 64px; background: #0a1422; color: #cfe8ff; border: 1px solid #34507e; border-radius: 4px; padding: 2px 5px; font-size: 12px; }
.el-prev-ctrl .el-scale-hint { color: #6f87a3; font-size: 11px; }
.el-effects { display: flex; flex-direction: column; gap: 5px; margin-bottom: 6px; }
.el-effect-row { display: flex; gap: 6px; }
.el-effect-row input { flex: 1; background: #0e1c30; color: #dce8f6; border: 1px solid #2c3d5c; border-radius: 5px; padding: 4px 7px; font-size: 12px; }

/* ===================== 彩蛋：本地 base64 图片体检 / 压缩 ===================== */
.menu-egg { color: #5f7790; font-size: 11px !important; opacity: 0.55; }
.menu-egg:hover { opacity: 1; color: #8df0b4; border-bottom-color: #8df0b4; }
.b64-modal { position: fixed; inset: 0; z-index: 120; background: rgba(4,9,18,0.78); display: flex; align-items: center; justify-content: center; padding: 18px; }
.b64-modal.hidden { display: none; }
.b64-panel { width: 780px; max-width: 96vw; height: 88vh; max-height: 88vh; background: #0c1626; border: 1px solid #2c3d5c; border-radius: 12px; display: flex; flex-direction: column; box-shadow: 0 18px 50px rgba(0,0,0,0.55); }
.b64-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid #1d2c45; }
.b64-title { font-size: 17px; font-weight: 700; color: #cfe8ff; white-space: nowrap; }
.b64-sub { font-size: 11px; color: #6f87a8; flex: 1; line-height: 1.4; }
.b64-close { background: #1b2a44; color: #cfe8ff; border: 1px solid #34507e; border-radius: 6px; width: 30px; height: 30px; font-size: 14px; cursor: pointer; }
.b64-close:hover { background: #2a3e60; }
.b64-summary { padding: 8px 16px; font-size: 12px; color: #9fb3cc; background: #0e1c30; border-bottom: 1px solid #1d2c45; }
.b64-summary b { color: #ffd166; }
.b64-list { flex: 1; overflow-y: auto; padding: 12px 16px; display: flex; flex-direction: column; gap: 12px; }
.b64-group-title { font-size: 13px; color: #7e93ac; margin: 4px 0 -2px; border-top: 1px dashed #23344f; padding-top: 8px; }
.b64-card { display: flex; gap: 12px; background: #0e1c30; border: 1px solid #23344f; border-radius: 8px; padding: 10px; }
.b64-thumb { width: 110px; flex: 0 0 110px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.b64-thumb canvas, .b64-thumb img { width: 96px; height: 96px; object-fit: contain; background: #060d18; border: 1px solid #23344f; border-radius: 6px; image-rendering: pixelated; }
.b64-thumb .b64-thumb-tag { font-size: 10px; color: #6f87a8; }
.b64-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.b64-meta { font-size: 12px; color: #9fb3cc; line-height: 1.6; }
.b64-meta b { color: #cfe8ff; }
.b64-meta .b64-path { color: #7fd0ff; word-break: break-all; }
.b64-meta .b64-big { color: #ff9d8a; font-weight: 700; }
.b64-edit { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
.b64-edit label { font-size: 12px; color: #9fb3cc; }
.b64-edit input[type=number] { width: 72px; background: #0a1422; color: #cfe8ff; border: 1px solid #34507e; border-radius: 4px; padding: 3px 6px; font-size: 12px; }
.b64-edit .b64-scale { color: #6f87a3; font-size: 11px; min-width: 54px; }
.b64-edit button { font-family: inherit; font-size: 12px; padding: 4px 10px; cursor: pointer; background: #1d2c45; color: #9fd0ff; border: 1px solid #3a4f72; border-radius: 5px; }
.b64-edit button:hover { background: #2a3e60; }
.b64-edit button.applied { background: #1c3a28; color: #6fd093; border-color: #2e6b46; }
.b64-edit button.b64-sync { background: #3a2e16; color: #ffcf6f; border-color: #6b532e; }
.b64-edit button.b64-sync:hover { background: #4d3c1d; }
.b64-edit button.b64-sync:disabled { opacity: 0.4; cursor: not-allowed; }
.b64-edit button.b64-sync.applied { background: #1c3a28; color: #6fd093; border-color: #2e6b46; }
.b64-foot { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-top: 1px solid #1d2c45; }
.b64-status { font-size: 12px; color: #6f87a8; flex: 1; }
.b64-status.ok { color: #6fd093; }
.b64-save { padding: 8px 16px !important; font-size: 13px !important; }
.b64-save:disabled { opacity: 0.45; cursor: not-allowed; }

/* ===== 移动端：横屏虚拟手柄 ===== */
#touch-ui { display: none; }

/* 触摸设备进入对局时：显示虚拟手柄 */
body.touch.gaming #touch-ui {
  display: block; position: fixed; inset: 0; z-index: 130;
  pointer-events: none;            /* 容器不挡画面，仅按钮可点 */
  font-family: inherit;
}
/* 触摸设备：游戏框自适应屏幕，画布高度撑满整个视口，宽度按 960:600 位图比例自适应；
   横向超出部分由 #game-root 居中裁剪；顶/底栏改为绝对定位叠在画布上。 */
body.touch #game-root {
  width: 100vw; max-width: 100vw;
  height: 100vh; height: 100dvh;
  display: block; position: relative; overflow: hidden;
}
body.touch #game-canvas {
  /* 画布填满父级（= 整个视口）。
     之前用的 object-fit:contain 在手机竖屏旋转后被 960:600 比例框住，横向留大块黑边；
     改为直接拉伸填满整个旋转后的横屏，绘制坐标仍 960×600，视觉上仅轻微变形。 */
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  width: 100% !important; height: 100% !important;
  display: block; touch-action: none;  /* 防止手势误触发页面滚动/缩放 */
  background: #0a1018;
}
body.touch #topbar, body.touch #bottombar {
  position: absolute; left: 0; right: 0;
  width: 100%; max-width: 100vw; box-sizing: border-box;
  z-index: 120;
  background: linear-gradient(180deg, rgba(13,26,44,0.92), rgba(20,37,60,0.92));
}
body.touch #topbar { top: 0; }
body.touch #bottombar { bottom: 0; }

/* 左侧方向键（十字） */
.tc-left { position: absolute; left: max(14px, 2vw); bottom: max(18px, 3vh); pointer-events: none; }
.dpad {
  display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr);
  width: 38vw; max-width: 196px; aspect-ratio: 1 / 1; gap: 6px;
}
.db {
  pointer-events: auto; border: none; border-radius: 14px;
  background: rgba(20,40,66,0.55); color: #cfe8ff; font-size: 22px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 10px rgba(0,0,0,0.45), inset 0 0 0 1px rgba(120,170,230,0.25);
  -webkit-user-select: none; user-select: none; touch-action: none;
}
.db:active, .db.on { background: rgba(70,200,255,0.55); color: #fff; }
.db-up    { grid-area: 1 / 2; }
.db-left  { grid-area: 2 / 1; }
.db-mid   { grid-area: 2 / 2; background: rgba(20,40,66,0.30); box-shadow: none; pointer-events: none; }
.db-right { grid-area: 2 / 3; }
.db-down  { grid-area: 3 / 2; }

/* 右侧动作键 */
.tc-right {
  position: absolute; right: max(14px, 2vw); bottom: max(18px, 3vh);
  display: flex; flex-direction: column; align-items: flex-end; gap: 12px; pointer-events: none;
}
.tc-acts-top { display: flex; gap: 10px; pointer-events: none; }
.ab {
  pointer-events: auto; border: none; border-radius: 50%;
  width: 56px; height: 56px; font-size: 18px; font-weight: 800; color: #eaf6ff;
  background: rgba(20,40,66,0.55); box-shadow: 0 2px 10px rgba(0,0,0,0.45), inset 0 0 0 1px rgba(120,170,230,0.25);
  -webkit-user-select: none; user-select: none; touch-action: none;
}
.ab:active, .ab.on { background: rgba(120,180,255,0.6); color: #fff; }
.ab-atk {
  width: 92px; height: 92px; font-size: 22px; border-radius: 50%;
  background: linear-gradient(160deg, rgba(255,90,70,0.7), rgba(180,40,40,0.7));
  box-shadow: 0 3px 14px rgba(0,0,0,0.5), inset 0 0 0 1px rgba(255,170,150,0.4);
}
.ab-atk:active, .ab-atk.on { background: linear-gradient(160deg, rgba(255,120,90,0.95), rgba(220,60,60,0.95)); }
.ab-c { background: rgba(40,70,120,0.6); }
.ab-i { background: rgba(40,70,120,0.6); }
.ab-e { background: rgba(60,110,90,0.6); }

/* 窄屏（小手机横屏）时适当缩小按钮，避免挡视野 */
@media (max-height: 420px) {
  .dpad { width: 30vw; max-width: 150px; }
  .ab { width: 48px; height: 48px; font-size: 15px; }
  .ab-atk { width: 74px; height: 74px; font-size: 18px; }
}

/* ===== 移动端「真横屏」：竖屏手机时把整个应用旋转 90° 成 16:9 横屏 =====
   #app 默认 display:contents（桌面端/普通情况不产生布局盒子，不影响原布局）；
   仅在「手机且竖屏」时变为固定定位盒子并旋转，使读取界面/画布/UI/虚拟手柄整体转为横屏。 */
#app { display: contents; }
@media (max-width: 900px) and (orientation: portrait) {
  html, body { overflow: hidden; }
  #app {
    display: block;
    position: fixed; top: 0; left: 0;
    width: 100vh; height: 100vw;          /* 旋转后视觉上即 16:9 横屏 */
    transform-origin: 0 0;
    transform: translateX(100vw) rotate(90deg);
    overflow: hidden;
    background: #0b1018;
  }
  /* 游戏框/画布铺满旋转后的横屏区域；topbar/bottombar 改为覆盖叠放。
     画布不再用 object-fit:contain（会被 960:600 比例字面框住，留大块黑边），
     改为 width:100%/height:100% 直接拉伸填满整个横屏，绘制坐标仍是 960×600，视觉上仅轻微变形但占满全屏。 */
  #app #game-root { width: 100%; height: 100%; }
  #app #game-canvas {
    width: 100% !important; height: 100% !important;
    max-width: 100%; max-height: 100%;
    border-left: none; border-right: none;
  }
  #app #topbar, #app #bottombar {
    position: absolute; left: 0; width: 100%; max-width: 100%;
    z-index: 120; box-sizing: border-box;
  }
  #app #topbar { top: 0; }
  #app #bottombar { bottom: 0; }
  /* 所有 absolute-friendly 弹窗（菜单/角色/碰撞编辑/任务交付/新旅途/图体检）：
     基类都是 position:fixed（相对视口），搬到 #app 内后会被旋转的 #app 框架带偏；
     必须改成 position:absolute 使其在 #app（已旋转 90°）内绝对定位，连带一起转成横屏。
     桌面端 #app 是 display:contents 不产生盒子，absolute 的参照仍是视口，行为与 fixed 一致。 */
  #app #menu-screen,
  #app #ng-screen,
  #app #panel-char,
  #app #collision-editor,
  #app #quest-submit-panel,
  #app #b64-modal,
  #app #quest-toast,
  #app #quest-tracker,
  #app #quest-prompt,
  #app #pet-panel {
    position: absolute;
  }
  /* 虚拟手柄按旋转后视口（长边）缩放，确保横屏下清晰好点 */
  #app .dpad { width: min(26vmax, 210px); }
  #app .tc-left { left: 3.5%; bottom: 4%; }
  #app .tc-right { right: 3.5%; bottom: 4%; }
  #app .ab { width: 60px; height: 60px; font-size: 19px; }
  #app .ab-atk { width: 98px; height: 98px; font-size: 23px; }
}
