/* 인연 · 대화창 · 회상 갤러리 · 이야기 작전 · 수집 도감 · 전술 시험장 */
.bond { display: grid; gap: var(--gap); min-width: 0; }

/* 인연 목록 — 카드는 모두 같은 높이(86px), 얼굴 칸은 카드 세로 가운데 같은 자리.
   고른 카드의 호감 막대는 글 아래 흐름에서 빼 카드 바닥에 겹쳐 놓는다(그래서 카드 키가 안 커진다). */
.blist { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: thin; padding-bottom: 4px; }
.bcard { position: relative; flex: 0 0 168px; display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 8px; align-items: center; padding: 6px 8px; min-height: 72px;
  background: var(--panel); border: 1px solid var(--line-soft); border-left: 3px solid var(--hc, var(--line)); color: var(--ink); text-align: left; cursor: pointer; font: inherit; }
.bcard.on { border-color: var(--hc, var(--amber)); background: var(--bcard-on); }
.bcard.locked { opacity: .6; }
.bcard .dot { position: absolute; right: 6px; top: 6px; }
.blist > .bcard { grid-template-columns: 56px minmax(0, 1fr); height: 86px; min-height: 86px; padding: 0 8px 6px; overflow: hidden; }
.blist > .bcard .bface { width: 52px; height: 60px; align-self: center; }
.blist > .bcard .bface img { object-fit: cover; object-position: 50% 0; }
.blist > .bcard .binfo { align-self: center; }
.blist > .bcard .bbar { position: absolute; left: 75px; right: 8px; bottom: 5px; height: 4px; margin: 0; }
.bface { width: 52px; height: 60px; overflow: hidden; background: var(--shade-30); display: block; }
.bface img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.bface img.bface-full { object-position: 50% 6%; transform: scale(1.6); transform-origin: 50% 0; }
/* 얼굴 맞추기 — 그림마다 얼굴 가운데 · 얼굴 키를 맞춰 모든 칸에서 얼굴이 같은 크기로 칸 가운데 위쪽에 온다.
   --fx, --fy: 그림 속 얼굴 가운데(0~1), --fs: 얼굴 키(그림 높이 대비). 칸 56px 에서 얼굴 키를 26px 로(머리 · 어깨까지 보이게). */
.bface.fit { position: relative; width: 56px; height: 60px; overflow: hidden; --w: calc(26px / var(--fs, .3)); }
.bface.fit > img { position: absolute; max-width: none; width: var(--w); height: var(--w); object-fit: cover; object-position: 50% 0; transform: none;
  left: calc(28px - var(--w) * var(--fx, .5)); top: calc(24px - var(--w) * var(--fy, .3)); }
.bface.sp { width: 56px; height: 60px; display: grid; place-items: center; font-size: var(--fs-xl); color: var(--tan); background: rgb(var(--tan-rgb) / .08); border: 1px solid rgb(var(--tan-rgb) / .3); }
.binfo { display: grid; gap: 1px; min-width: 0; }
.binfo b { font-weight: 400; color: var(--ink-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.binfo .dim, .binfo .bst { font-size: var(--fs-xs); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bond-unread { font-size: var(--fs-xs); color: var(--amber); }
.bspecial { flex-basis: 200px; grid-template-columns: 1fr; border-left-color: var(--tan); }
.blist > .bspecial { grid-template-columns: 56px minmax(0, 1fr); }
.bbar { position: relative; height: 6px; background: var(--well); border: 1px solid var(--line-soft); }
.bbar i { position: absolute; left: 0; top: 0; bottom: 0; }
.bbar em { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--ink-dim); }
.bbar u { position: absolute; top: 0; bottom: 0; width: 1px; background: rgb(var(--white-rgb) / .15); }

/* 인연 무대 — 큰 그림 + 말풍선 · 오른쪽 글 */
.bmain { display: grid; gap: var(--gap); min-width: 0; }
.bstage { display: grid; gap: var(--gap); border: 1px solid var(--line); background: var(--panel); padding: 12px; }
.bvisual { position: relative; height: 420px; display: grid; place-items: end center; overflow: hidden; background: radial-gradient(ellipse at 50% 80%, color-mix(in srgb, var(--hc) 20%, transparent), transparent 70%), var(--bg-deep); }
.bvisual .bsp.stable-portrait { position: relative; height: 100%; aspect-ratio: var(--portrait-ratio); max-width: 100%; display: block; }
.bvisual img.bsp { height: 100%; object-fit: contain; }
.bond-locked-silhouette { filter: brightness(0) opacity(.6); }
.bgreet { position: absolute; top: 10px; left: 10px; right: 10px; z-index: 2; padding: 8px 12px; background: rgb(var(--veil-3-rgb) / .85); border: 1px solid var(--line-soft); border-left: 3px solid var(--hc); font-size: var(--fs-sm); line-height: 1.6; }
.bside { display: grid; gap: 8px; align-content: start; min-width: 0; }
.bname { font-weight: 400; font-size: var(--fs-xl); color: var(--ink-strong); } .bname .dim { font-size: var(--fs-sm); }
.baff { display: flex; align-items: baseline; gap: 6px; } .baff b { font-weight: 400; font-size: var(--fs-xl); color: var(--hc); }
.bnext { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line-soft); }
.bnext.ready { border-color: var(--hc); } .bnext > span:first-child { flex: 1 1 140px; }
.bacts .btn { flex: 1 1 auto; } .newt { font-style: normal; font-size: var(--fs-xs); color: var(--amber); }
.bbox { display: grid; gap: 4px; padding: 8px 10px; border: 1px solid var(--line-soft); background: var(--shade-20); }
.bbox b { font-weight: 400; color: var(--ink-strong); }
.btitles, .beps { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; font-size: var(--fs-sm); }
.btitle { padding: 1px 6px; border: 1px solid var(--line-soft); font-size: var(--fs-xs); color: var(--ink-dim); } .btitle.own { border-color: var(--hc); color: var(--ink-strong); }
.bgift .panel-head .btn { margin-left: auto; }
.bginv { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr)); gap: 6px; }
.bgi { position: relative; display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 6px; align-items: center; min-height: var(--tap); padding: 4px 8px; background: var(--shade-20); border: 1px solid var(--line-soft); color: var(--ink); text-align: left; cursor: pointer; font: inherit; font-size: var(--fs-sm); }
.bgi.like { border-color: var(--pink-line); } .bgi.on { border-color: var(--amber); background: var(--amber-bg); }
.bgi .ico { width: 34px; height: 34px; } .bgi span { min-width: 0; overflow-wrap: anywhere; } .bgi i { font-style: normal; color: var(--ink-dim); font-size: var(--fs-xs); }
.bgi em { position: absolute; top: 2px; right: 4px; font-style: normal; color: var(--pink); font-size: var(--fs-xs); }
.bgift-foot { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; border-top: 1px solid var(--line-soft); padding-top: 8px; }
.vow-collection-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 160px), 1fr)); gap: 6px; }
.vow-collection-grid .btn { display: grid; justify-items: start; text-align: left; }

/* 대화창 */
.vn { position: relative; display: grid; height: 100%; color: var(--ink); cursor: pointer; user-select: none; }
.vn-stage { position: relative; overflow: hidden; min-height: 0; }
.vnbg { position: absolute; inset: 0; background: center / cover no-repeat; }
.vnbg::after { content: ""; position: absolute; inset: 0; background: linear-gradient(transparent 50%, var(--shade-60)); }
.vn .vnsp.stable-portrait { position: absolute; left: 50%; bottom: 0; transform: translateX(-50%); height: min(88%, 900px); aspect-ratio: 2 / 3; max-width: 96%; }
.stable-portrait .portrait-art { position: absolute; left: 50%; bottom: 0; transform: translateX(-50%); width: var(--portrait-width, 100%); height: var(--portrait-height, 100%); }
.stable-portrait .portrait-body { width: 100%; height: 100%; object-fit: contain; object-position: bottom; display: block; }
.vn-pair { position: absolute; inset: 0; display: flex; justify-content: center; align-items: flex-end; gap: 0; }
.vn-pair .vnsp.stable-portrait { position: relative; left: auto; transform: none; height: 80%; max-width: 50%; opacity: .75; }
.vn-pair .vnsp.speaking { opacity: 1; }
.vntop { position: absolute; top: 0; left: 0; right: 0; z-index: 3; display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: linear-gradient(var(--shade-70), transparent); }
.vnt { flex: 1 1 auto; min-width: 0; color: var(--ink-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-shadow: 0 1px 3px var(--black); }
.vnbox { position: absolute; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 3; display: grid; gap: 6px; padding: 14px 16px; min-height: 120px; max-height: 50%; overflow-y: auto;
  background: rgb(var(--veil-4-rgb) / .92); border: 1px solid var(--line); border-top: 2px solid var(--hc, var(--amber)); cursor: pointer; }
.vnbox.nar { border-top-color: var(--line); font-style: italic; }
.vnname { color: var(--hc, var(--amber)); font-size: var(--fs); }
.vntext { font-size: 16px; line-height: 1.75; color: var(--ink-strong); white-space: pre-line; }
.vnhint { justify-self: end; font-size: var(--fs-xs); color: var(--ink-dim); }
.vnch { display: grid; gap: 6px; } .vnch .btn { justify-content: flex-start; text-align: left; white-space: normal; }
.vnend { display: grid; gap: 8px; justify-items: start; cursor: default; } .vnend b { font-weight: 400; font-size: var(--fs-lg); color: var(--ink-strong); }
.vn-log { display: none; }

/* 회상 갤러리 */
.gallery-memories { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 180px), 1fr)); gap: 8px; }
.gallery-memory { display: grid; gap: 4px; padding: 4px; background: var(--shade-25); border: 1px solid var(--line-soft); color: var(--ink); cursor: pointer; font: inherit; font-size: var(--fs-sm); text-align: left; }
.gallery-memory img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.gallery-lines { display: grid; gap: 4px; } .gallery-lines ul { margin: 6px 0 0; padding-left: 18px; display: grid; gap: 4px; font-size: var(--fs-sm); }

/* 이야기 작전 */
.storyp, .codexp { display: grid; gap: var(--gap); min-width: 0; }
.scene { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 14px; align-items: start; }
.snpc { width: 120px; height: 150px; object-fit: cover; object-position: top; border: 1px solid var(--line); }
.sbody { display: grid; gap: 8px; line-height: 1.75; min-width: 0; }
.schoice { display: grid; gap: 6px; } .schoice .btn { display: grid; justify-items: start; text-align: left; gap: 2px; white-space: normal; }
.schoice .btn b { font-weight: 400; color: var(--ink-strong); }
.sact { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* 수집 도감 — 보상 칸은 한 줄에 다 들어가게(폰에서 3+1 로 갈라지지 않게) */
.cxtabs { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 130px), 1fr)); gap: 6px; }
.cxtab { display: grid; gap: 3px; padding: 6px 8px; min-height: var(--tap); background: var(--panel-2); border: 1px solid var(--line); color: var(--ink); text-align: left; cursor: pointer; font: inherit; }
.cxtab.on { border-color: var(--amber); } .cxtab b { font-weight: 400; } .cxtab span:not(.bar) { font-size: var(--fs-xs); color: var(--ink-dim); }
.cxsteps { display: grid; grid-template-columns: repeat(auto-fit, minmax(62px, 1fr)); gap: 6px; }
.cxstep { display: grid; justify-items: center; gap: 2px; min-width: 0; padding: 6px 4px; border: 1px solid var(--line-soft); font-size: var(--fs-sm); }
.cxstep.ready { border-color: var(--amber); } .cxstep.done { opacity: .6; } .cxstep b { font-weight: 400; color: var(--ink-strong); }
.cxgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 6px; }
.cxcell { display: grid; gap: 2px; justify-items: center; padding: 6px 4px; border: 1px solid var(--line-soft); background: var(--shade-25); font-size: var(--fs-xs); text-align: center; min-width: 0; }
.cxcell:not(.own) .cxi { filter: grayscale(1) brightness(.35); } .cxcell.own { border-color: var(--sage-line); }
.cxi { height: 44px; display: grid; place-items: center; } .cxi .ico, .cxi img { max-width: 100%; max-height: 44px; object-fit: contain; }
.cxcell span { overflow-wrap: anywhere; color: var(--ink-dim); } .cxcell.own span { color: var(--ink); }

/* 전술 시험장 */
.training-config { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); gap: 8px; align-items: end; }
.training-config select, .training-config input { width: 100%; min-height: var(--tap); }
.training-enemies { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 6px; }
.training-enemy { display: grid; gap: 4px; padding: 8px; border: 1px solid var(--line-soft); font-size: var(--fs-sm); } .training-enemy.on { border-color: var(--red); }
.training-enemy b { font-weight: 400; color: var(--ink-strong); }
.training-log { max-height: 240px; overflow-y: auto; }
.training-status { font-size: var(--fs-sm); color: var(--ink-dim); }

@media (min-width: 901px) {
  .bond { grid-template-columns: 240px minmax(0, 1fr); align-items: start; }
  .blist { flex-direction: column; overflow: visible; max-height: calc(100 * var(--vh) - 160px); overflow-y: auto; padding-right: 4px; }
  .bcard { flex: 0 0 auto; }
  /* 큰 그림 칸: 빈 곳 없이 그림 크기만큼, 내리면 따라온다(오른쪽 글이 길어도 그림이 화면에 남는다).
     인물은 키워 바닥에 붙이고(허리 아래는 잘림) 머리가 말풍선 바로 밑에 오게 — 크기는 js/ui/fit.js 가 그림마다 정한다 */
  .bstage { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
  .bvisual { height: 560px; }
  .bstage > .bvisual { position: sticky; top: calc(var(--topbar-h) + 12px); }
  .bstage > .bvisual > .bsp.stable-portrait { position: absolute; left: 50%; bottom: 0; transform: translateX(-50%); height: 100%; max-width: none; }
  .vn { grid-template-columns: minmax(0, 1fr) 320px; }
  .vn-log { display: grid; grid-template-rows: auto minmax(0, 1fr); background: var(--vn-log); border-left: 1px solid var(--line); cursor: default; min-height: 0; }
  .vn-log h3 { font-weight: 400; padding: 12px; border-bottom: 1px solid var(--line-soft); color: var(--ink-strong); }
  .vn-lines { overflow-y: auto; padding: 8px 12px; display: grid; gap: 8px; align-content: start; font-size: var(--fs-sm); }
  .vn-lines b { font-weight: 400; color: var(--amber); } .vn-lines p { line-height: 1.6; }
  .vnbox { left: 50%; transform: translateX(-50%); width: min(820px, calc(100% - 40px)); }
}
/* 폰 · 태블릿 인연 그림 칸 — 말풍선을 그림 위가 아니라 그림 칸 위에 두고, 그림은 그 아래 칸을 채운다 */
@media (max-width: 900px) {
  .bstage > .bvisual { display: flex; flex-direction: column; height: auto; }
  .bstage > .bvisual > .bgreet { position: static; margin: 8px 8px 0; }
  .bstage > .bvisual > .bsp.stable-portrait, .bstage > .bvisual > img.bsp { position: relative; left: auto; bottom: auto; transform: none; height: 300px; align-self: center; }
}
@media (max-width: 600px) {
  .bvisual { height: 300px; }
  .bcard { flex-basis: 196px; }
  .scene { grid-template-columns: 72px minmax(0, 1fr); } .snpc { width: 72px; height: 96px; }
  .vntext { font-size: var(--fs); }
}
