* { box-sizing: border-box; }

.builder-app {
  min-height: calc(100vh - 60px); /* 扣除全站顶栏 60px，避免凭空多一段滚动 */
  background: #0a0c12;
  color: #e6e9f0;
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
}

/* ---------- 顶部栏 ---------- */
.b-header {
  position: sticky;
  top: 60px; /* 吸顶时停在站点顶栏(60px)下方，不再与之重叠 */
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
  background: #11141d;
  border-bottom: 1px solid #232838;
  flex-wrap: wrap;
}
.b-brand h1 { font-size: 18px; margin: 0; }
.b-brand p { margin: 2px 0 0; font-size: 12px; color: #6f7c93; }
.b-controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.b-controls button,
.b-controls select {
  background: #1a1f2b;
  border: 1px solid #2a3040;
  color: #cdd3ea;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
}
.b-controls button:hover { border-color: #4a9eff; }
.b-controls button.primary { background: linear-gradient(135deg,#e8b84b,#c9922f); border-color: #c9922f; color: #1a1206; font-weight: 800; }
.b-controls button.primary:hover { filter: brightness(1.07); }

.b-notice {
  margin: 12px 20px 0;
  padding: 10px 14px;
  background: #14181f;
  border: 1px solid #2a3040;
  border-left: 3px solid #e8b84b;
  border-radius: 8px;
  font-size: 12px;
  color: #9aa3c0;
  line-height: 1.6;
}
.b-notice b { color: #e6e9f0; }

/* ---------- 主体两栏 ---------- */
.b-main {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 16px;
  padding: 16px 20px 40px;
  align-items: start;
}

/* ---------- 左侧库 ---------- */
.b-hero-lib {
  background: #131824;
  border: 1px solid #232838;
  border-radius: 12px;
  padding: 12px;
  position: sticky;
  top: 76px;
  max-height: calc(100vh - 96px);
  display: flex;
  flex-direction: column;
}
.b-lib-tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.b-lib-tabs button {
  flex: 1;
  background: #161b26;
  border: 1px solid #2a3040;
  color: #8b95a8;
  border-radius: 8px;
  padding: 8px;
  font-size: 13px;
  cursor: pointer;
}
.b-lib-tabs button.active { background: rgba(74,158,255,.12); border-color: #4a9eff; color: #4a9eff; }
#libSearch {
  width: 100%;
  background: #0f131c;
  border: 1px solid #232838;
  border-radius: 8px;
  padding: 9px 10px;
  color: #e6e9f0;
  font-size: 13px;
  margin-bottom: 10px;
}
#libSearch:focus { border-color: #4a9eff; outline: none; }
.b-lib-grid {
  display: block;
  overflow-y: auto;
  padding-right: 4px;
}
.lib-group-title { font-size: 11px; color: #8b95a8; margin: 10px 2px 5px; font-weight: 600; letter-spacing: .5px; }
.lib-group { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin-bottom: 4px; }
.lib-empty { color: #5a607a; font-size: 12px; padding: 10px; }
.hero-cell {
  background: #0f131c;
  border: 1px solid #232838;
  border-radius: 8px;
  padding: 4px;
  text-align: center;
  cursor: grab;
  transition: .12s;
  position: relative;
}
.hero-cell:hover { border-color: #e8b84b; transform: translateY(-1px); }
.hero-cell:active { cursor: grabbing; }
.hero-cell img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 5px; }
.hero-cell .nm { font-size: 11px; margin-top: 3px; color: #cdd3ea; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hero-cell.q2 { box-shadow: inset 0 0 0 1px rgba(76,175,80,.5); }
.hero-cell.q3 { box-shadow: inset 0 0 0 1px rgba(33,150,243,.5); }
.hero-cell.q4 { box-shadow: inset 0 0 0 1px rgba(156,39,176,.5); }
.hero-cell.q5 { box-shadow: inset 0 0 0 1px rgba(255,152,0,.6); }

/* ---------- 右侧预览（所见即所得文档） ---------- */
.b-preview-area { min-width: 0; }
.preview-doc {
  max-width: 1000px;
  margin: 0 auto;
  background: #080a10;
  border: 1px solid #1b2232;
  border-radius: 16px;
  padding: 26px 28px 32px;
  color: #e6e9f0;
  box-shadow: 0 18px 50px rgba(0,0,0,.35);
}
.pd-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 18px;
  border-bottom: 1px solid #151b28;
  margin-bottom: 18px;
  position: relative;
}
.pd-header::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: -1px;
  width: 64px;
  height: 3px;
  background: #e8b84b;
  border-radius: 2px;
}
.pd-name {
  background: transparent;
  border: none;
  border-bottom: 1px dashed transparent;
  color: #e8b84b;
  font-size: 30px;
  font-weight: 700;
  font-family: inherit;
  padding: 2px 0;
  width: 70%;
}
.pd-name:focus { outline: none; border-bottom-color: #4a9eff; }
.pd-tier {
  appearance: none;
  -webkit-appearance: none;
  background: #4a6cf7;
  color: #fff;
  border: none;
  border-radius: 8px;
  width: 58px;
  height: 32px;
  font-size: 15px;
  font-weight: 700;
  text-align: center;
  text-align-last: center;
  cursor: pointer;
  flex-shrink: 0;
}
.pd-tier:focus { outline: none; box-shadow: 0 0 0 2px rgba(74,108,247,.4); }
.pd-sub { font-size: 13px; color: #6f7c93; margin: 2px 0 0; }

/* 顶部三段分析 */
.pd-analysis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 8px; }
.pd-block { background: #131824; border: 1px solid #232838; border-radius: 10px; padding: 12px; }
.pd-block h4 { margin: 0 0 8px; font-size: 13px; color: #e8b84b; }
.pd-block .editable { font-size: 12.5px; line-height: 1.7; color: #cdd3ea; min-height: 64px; outline: none; }
.pd-block .editable:empty::before,
.pd-ops .editable:empty::before { content: "点击输入…"; color: #5a607a; }
/* 所有可编辑文字：所见即所得，点哪改哪 */
.editable { cursor: text; border-radius: 4px; transition: background .12s, box-shadow .12s; border: 1px dashed rgba(232,184,75,.28); padding: 5px 7px; }
.editable:hover { background: rgba(232,184,75,.08); box-shadow: inset 0 0 0 1px rgba(232,184,75,.3); }
.editable:focus { background: rgba(232,184,75,.12); box-shadow: inset 0 0 0 1px rgba(232,184,75,.55); outline: none; }

.pd-section-title {
  position: relative;
  color: #e6e9f0;
  font-size: 18px;
  font-weight: 700;
  margin: 24px 0 16px;
  padding-bottom: 8px;
}
.pd-section-title::after {
  content: '';
  position: absolute;
  left: 96px;
  right: 0;
  top: 50%;
  height: 1px;
  background: #232838;
}

/* 阶段卡片：顶部标签 + 居中棋盘/备选 + 底部运营文字 */
.pd-stage {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #0d1018;
  border: 1px solid #1b2232;
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 12px;
}
.pd-stage.active { border-color: rgba(74,158,255,.6); box-shadow: 0 0 0 1px rgba(74,158,255,.15); }
.pd-stage-label { display: flex; align-items: baseline; gap: 10px; position: relative; padding-left: 14px; }
.pd-stage-label::before {
  content: '';
  position: absolute;
  left: 0;
  top: 4px;
  width: 4px;
  height: 18px;
  background: #e8b84b;
  border-radius: 2px;
}
.pd-mid { display: flex; flex-direction: column; gap: 6px; align-items: center; }
.pd-stage-label .nm { font-size: 17px; font-weight: 700; color: #e8b84b; }
.pd-stage-label .sub { font-size: 11px; color: #6f7c93; }
.pd-clear {
  font-size: 11px;
  background: #131824;
  border: 1px solid #232838;
  color: #8b95a8;
  border-radius: 6px;
  padding: 3px 7px;
  cursor: pointer;
  margin-left: auto;
}
.pd-clear:hover { border-color: #e2554b; color: #e2554b; }

.pd-bench-row { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; width: fit-content; margin: 0 auto 4px; }
.pd-bench-row .lab { font-size: 10px; color: #6f7c93; }
.pd-bench { display: flex; gap: 4px; }
.pd-bench .pcell { width: 56px; height: 56px; flex: 0 0 56px; }
.pd-board { display: grid; grid-template-columns: repeat(7, 56px); gap: 4px; }

/* 棋格 */
.pcell {
  position: relative;
  aspect-ratio: 1/1;
  background: #131824;
  border: 1px solid #253044;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: .12s;
}
.pcell.filled { border-color: #34425c; background: #151c2a; }
.pcell:hover { border-color: #e8b84b; }
.pcell.drag-over { background: rgba(74,158,255,.18); border-color: #4a9eff; box-shadow: inset 0 0 0 2px #4a9eff; }
.pcell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pcell .q { position: absolute; left: 3px; top: 3px; font-size: 9px; font-weight: 700; background: rgba(0,0,0,.65); padding: 1px 4px; border-radius: 4px; color: #fff; }
.pcell .nm { position: absolute; left: 0; right: 0; bottom: 0; font-size: 10px; font-weight: 600; text-align: center; background: linear-gradient(transparent, rgba(0,0,0,.65)); padding: 8px 2px 3px; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pcell.mainc { border-color: #e8453c; box-shadow: 0 0 0 1px rgba(232,69,60,.5); }
.pcell .mainc-tag { position: absolute; right: 3px; top: 3px; font-size: 9px; font-weight: 700; background: #e8453c; color: #fff; padding: 1px 4px; border-radius: 4px; line-height: 14px; }

/* 运营思路（卡片底部横向铺满） */
.pd-ops { min-width: 0; width: 100%; background: transparent; border: none; border-radius: 0; padding: 0; color: #cdd3ea; }
.pd-ops h4 { display: none; }
.pd-ops .editable { font-size: 16px; line-height: 1.75; outline: none; min-height: 26px; padding: 8px 10px; border-radius: 6px; }

/* 棋手介绍 */
.pd-player { padding: 0; }
.pd-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.pcard {
  background: #0d1018;
  border: 1px solid #1b2232;
  border-radius: 12px;
  padding: 10px;
  text-align: center;
  cursor: pointer;
  transition: .12s;
  min-height: 138px;
}
.pcard:hover { border-color: #e8b84b; }
.pcard img { width: 56px; height: 56px; object-fit: contain; border-radius: 8px; }
.pcard .cn { font-size: 13px; font-weight: 600; margin-top: 8px; color: #e6e9f0; }
.pcard .cd { font-size: 11px; color: #8b95a8; line-height: 1.45; margin-top: 4px; }
.pcard.empty { display: flex; align-items: center; justify-content: center; color: #5a607a; font-size: 13px; border-style: dashed; }

/* 棋手完整可选卡片 */
.pd-player-card { display: flex; align-items: flex-start; gap: 18px; background: #0d1018; border: 1px solid #1b2232; border-radius: 14px; padding: 16px; margin-bottom: 14px; position: relative; }
.ppc-img { width: 110px; height: 132px; border-radius: 10px; background: #0a0d15; border: 1px solid #2a3450; overflow: hidden; display: flex; align-items: center; justify-content: center; font-size: 34px; color: #e6e9f0; flex-shrink: 0; cursor: pointer; transition: .12s; }
.ppc-img:hover { border-color: rgba(232,184,75,.6); }
.ppc-img img { width: 100%; height: 100%; object-fit: cover; }
.ppc-info { flex: 1; min-width: 0; }
.ppc-name { font-size: 18px; font-weight: 700; color: #e8b84b; }
.ppc-camp { font-size: 12px; color: #6f7c93; margin: 2px 0 12px; }
.ppc-blocks { display: flex; flex-direction: column; gap: 8px; }
.ppc-block { display: flex; align-items: baseline; gap: 4px; font-size: 12px; color: #cdd3ea; line-height: 1.5; }
.ppc-lab { color: #e8b84b; font-weight: 700; flex-shrink: 0; }
.ppc-ico { width: 16px; height: 16px; border-radius: 4px; object-fit: cover; background: #1a2030; box-shadow: 0 0 0 1px #2a3450; flex-shrink: 0; align-self: center; }
.ppc-block .editable { flex: 1; min-width: 0; outline: none; word-break: break-word; }
.ppc-block .editable:empty::before { content: attr(data-ph); color: #5a607a; }
.ppc-change { position: absolute; top: 14px; right: 14px; background: #131824; border: 1px solid #232838; color: #8b95a8; border-radius: 8px; padding: 6px 12px; font-size: 12px; cursor: pointer; transition: .12s; }
.ppc-change:hover { border-color: #4a9eff; color: #4a9eff; }

.pd-footer { text-align: center; color: #5a607a; font-size: 11px; margin-top: 18px; }

/* ---------- 英雄编辑浮层（固定定位，贴合点击的格子） ---------- */
.hero-popover {
  position: fixed;
  z-index: 999;
  width: 240px;
  background: #131824;
  border: 1px solid #e8b84b;
  border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0,0,0,.5);
  display: none;
  flex-direction: column;
  max-height: 360px;
}
.hero-popover.show { display: flex; }
.hp-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-bottom: 1px solid #232838; }
.hp-head #hpName { font-size: 14px; font-weight: 700; }
.hp-close { background: none; border: none; color: #8b95a8; font-size: 20px; cursor: pointer; line-height: 1; }
.hp-body { padding: 12px; overflow-y: auto; }
.b-hero-info { margin-bottom: 10px; }
.b-hero-info b { font-size: 14px; }
.b-hero-info .pill { font-size: 11px; color: #8b95a8; margin-left: 6px; }
.b-hero-info .attrs { font-size: 11px; color: #6f7c93; margin-top: 4px; }
.slot { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; background: #0f131c; border: 1px solid #232838; border-radius: 8px; padding: 8px; cursor: pointer; transition: .12s; }
.slot:hover { border-color: #4a9eff; }
.slot img, .slot .slot-empty { width: 38px; height: 38px; border-radius: 6px; object-fit: cover; flex-shrink: 0; }
.slot .slot-empty { background: #0b0e14; display: flex; align-items: center; justify-content: center; color: #5a607a; font-size: 18px; }
.slot .pick { flex: 1; font-size: 12px; color: #cdd3ea; }
.slot .pick small { display: block; color: #6f7c93; font-size: 11px; }
.ghost { width: 100%; padding: 8px; border-radius: 8px; border: 1px solid #2a3040; background: #0f131c; color: #a8b3c7; cursor: pointer; font-size: 12px; }
.ghost:hover { border-color: #e2554b; color: #e2554b; }

/* ---------- 选择弹窗 ---------- */
.boverlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.boverlay.show { display: flex; }
.picker { width: 90%; max-width: 460px; max-height: 70vh; background: #131824; border: 1px solid #232838; border-radius: 12px; padding: 16px; display: flex; flex-direction: column; }
.picker input { width: 100%; background: #0f131c; border: 1px solid #232838; border-radius: 8px; padding: 9px; color: #e6e9f0; font-size: 13px; margin-bottom: 12px; }
.picker input:focus { border-color: #4a9eff; outline: none; }
.picker .grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; overflow-y: auto; }
.picker .pc { background: #0f131c; border: 1px solid #232838; border-radius: 8px; padding: 6px; text-align: center; cursor: pointer; transition: .12s; }
.picker .pc:hover { border-color: #e8b84b; }
.picker .pc img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 5px; }
.picker .pc .nm { font-size: 11px; margin-top: 3px; color: #cdd3ea; }
.picker .pc .pc-noimg { width: 100%; aspect-ratio: 1; border-radius: 5px; background: #0b0e14; display: flex; align-items: center; justify-content: center; color: #5a607a; font-size: 18px; }

/* 导出用的隐藏画布 */
#exportCanvas { position: fixed; left: -99999px; top: 0; }

@media (max-width: 1000px) {
  .b-main { grid-template-columns: 1fr; }
  .b-hero-lib { position: static; max-height: 360px; }
  .pd-analysis { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .b-header { top: 56px; } /* 移动端站点顶栏 56px */
}

/* 手机端：棋盘/棋格缩小，避免横向溢出（7×56px≈416px 在窄屏会撑破视口） */
@media (max-width: 560px) {
  .preview-doc { padding: 18px 14px 24px; }
  .pd-header { flex-wrap: wrap; gap: 8px; }
  .pd-name { font-size: 24px; width: 100%; }
  .pd-analysis { grid-template-columns: 1fr; }
  .pd-board { grid-template-columns: repeat(7, 40px); gap: 3px; }
  .pd-bench .pcell { width: 40px; height: 40px; flex: 0 0 40px; }
  .pd-bench-row { margin: 0 auto; }
  .pd-section-title { font-size: 16px; }
  .pcell .nm { font-size: 9px; }
  .ppc-img { width: 84px; height: 104px; }
}
