/* ── 人物关系图 ── */

#screen-relations {
  background:
    radial-gradient(ellipse at 50% 0%, rgba(60, 30, 80, 0.2) 0%, transparent 55%),
    linear-gradient(180deg, #120a14 0%, #0a0608 100%);
}

#screen-relations .page-lead {
  color: rgba(201, 168, 76, 0.55);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-align: center;
  font-style: italic;
  padding: 8px 0;
  border-bottom: 1px solid rgba(201, 168, 76, 0.1);
  border-left: none;
  background: none;
  margin-bottom: 12px;
}

.graph-frame {
  position: relative;
  width: 100%;
  min-height: 480px;
  border-radius: 8px;
  border: 2px solid rgba(212, 175, 55, 0.42);
  background:
    linear-gradient(rgba(18, 10, 28, 0.18), rgba(18, 10, 28, 0.28)),
    url('../images/人物关系背景图.png') center/cover no-repeat;
  overflow: hidden;
  box-shadow:
    inset 0 0 0 1px rgba(255, 235, 200, 0.06),
    0 8px 32px rgba(0, 0, 0, 0.45);
}

.graph-frame::before {
  content: '';
  position: absolute;
  inset: 10px;
  border: 1px solid rgba(212, 175, 55, 0.22);
  border-radius: 4px;
  pointer-events: none;
  z-index: 10;
  box-shadow: inset 0 0 24px rgba(0, 0, 0, 0.25);
}

.graph-particles {
  display: none;
}

.graph-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  pointer-events: none;
  overflow: visible;
}

#graph-nodes {
  position: absolute;
  inset: 0;
  z-index: 8;
}

#graph-labels {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  overflow: visible;
}

/* SVG 连线 */
.graph-edge {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.graph-edge--love {
  stroke: #c0392b;
  stroke-width: 2;
  stroke-dasharray: none;
}

.graph-edge--love-halo {
  stroke: #c0392b;
  stroke-width: 6;
  opacity: 0.15;
  stroke-dasharray: none;
}

.graph-edge--marriage {
  stroke: #d4af37;
  stroke-width: 2;
}

.graph-edge--family {
  stroke: #7b68ee;
  stroke-width: 2;
}

.graph-edge--rival {
  stroke: #aaaaaa;
  stroke-width: 1.5;
  stroke-dasharray: 5 4;
  animation: graph-blink 2s ease-in-out infinite;
}

/* enemy 别名（与 rival 同义） */
.graph-edge--enemy {
  stroke: #aaaaaa;
  stroke-width: 1.5;
  stroke-dasharray: 5 4;
  animation: graph-blink 2s ease-in-out infinite;
}

.graph-edge--social {
  stroke: #6b8e23;
  stroke-width: 2;
}

.graph-edge--crush {
  stroke: #ffb6c1;
  stroke-width: 2;
  marker-end: url(#graphArrowCrush);
}

@keyframes graph-blink {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 1; }
}

/* 连线标签 — 关系类型（小胶囊、轻量） */
.edge-label,
.graph-edge-label {
  position: absolute;
  transform: translate(-50%, -50%);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 4px;
  white-space: nowrap;
  line-height: 1.25;
  font-family: 'Noto Serif SC', serif;
  font-style: normal;
  color: #5c4a3a;
  background: rgba(255, 250, 242, 0.88);
  border: 1px dashed rgba(184, 146, 46, 0.42);
  box-shadow: 0 1px 4px rgba(61, 46, 40, 0.12);
  z-index: 4;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.edge-label--love { color: #8b1a1a; background: rgba(255, 242, 242, 0.92); border-color: rgba(192, 57, 43, 0.45); }
.edge-label--marriage { color: #6b4e12; background: rgba(255, 248, 230, 0.92); border-color: rgba(201, 168, 76, 0.5); }
.edge-label--family { color: #4a3a8b; background: rgba(245, 242, 255, 0.92); border-color: rgba(123, 104, 238, 0.4); }
.edge-label--rival { color: #555; background: rgba(248, 246, 244, 0.9); border-color: rgba(140, 140, 140, 0.45); }
.edge-label--social { color: #3d5018; background: rgba(242, 248, 236, 0.92); border-color: rgba(107, 142, 35, 0.4); }
.edge-label--crush { color: #8b4a5a; background: rgba(255, 244, 247, 0.92); border-color: rgba(255, 182, 193, 0.55); }

/* 标签微调：嫂子居线中、情敌下移 */
.edge-label[data-edge="anna-dolly"] {
  transform: translate(calc(-50% + 16px), -50%);
}

.edge-label[data-edge="karenin-vronsky"] {
  transform: translate(-50%, calc(-50% + 18px));
}

/* 节点 */
.graph-node {
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 48px;
  position: absolute;
  z-index: 8;
  transform: translate(-50%, -50%);
}

.graph-node--active {
  z-index: 14;
}

.graph-node:active .char-avatar {
  transform: scale(0.94);
}

.graph-node--active .char-avatar {
  box-shadow:
    0 0 0 2px color-mix(in srgb, var(--node-accent, #d4af37) 70%, transparent),
    0 0 18px color-mix(in srgb, var(--node-accent, #d4af37) 45%, transparent),
    inset 0 0 10px rgba(0, 0, 0, 0.8),
    0 0 0 1px rgba(0, 0, 0, 0.35);
}

#screen-relations .char-avatar {
  width: 56px;
  height: 56px;
  position: relative;
  z-index: 1;
}

#screen-relations .graph-node--anna .char-avatar--lg {
  width: 56px;
  height: 56px;
  transform: scale(1.3);
}

#screen-relations .graph-node--anna:active .char-avatar--lg {
  transform: scale(1.22);
}
#screen-relations .char-name-tag,
#screen-relations .graph-name-label {
  position: relative;
  z-index: 20;
  font-size: 12px;
  font-weight: 700;
  color: #2b2118;
  text-align: center;
  line-height: 1.25;
  padding: 5px 12px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 252, 248, 0.98) 0%, rgba(243, 230, 200, 0.72) 100%);
  border: 1.5px solid rgba(184, 146, 46, 0.55);
  box-shadow:
    0 2px 8px rgba(61, 46, 40, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  font-family: 'Noto Serif SC', serif;
  letter-spacing: 0.08em;
  white-space: nowrap;
  text-shadow: none;
}

#screen-relations .graph-node--anna .char-name-tag,
#screen-relations .graph-node--anna .graph-name-label {
  z-index: 22;
  color: #722f37;
  border-color: rgba(158, 58, 74, 0.45);
  background: linear-gradient(180deg, rgba(255, 248, 248, 0.99) 0%, rgba(243, 220, 220, 0.75) 100%);
}

/* 点击弹卡：挂 #app 下，跟随头像且限制在手机框内 */
.graph-popup {
  position: fixed;
  z-index: 200;
  width: calc(100% - 32px);
  max-width: 360px;
  max-height: min(52vh, calc(100dvh - 48px));
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  box-sizing: border-box;
  padding: 16px;
  border-radius: 14px;
  background: linear-gradient(145deg, rgba(28, 18, 10, 0.97), rgba(18, 10, 6, 0.99));
  border: 1px solid rgba(201, 168, 76, 0.25);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(201, 168, 76, 0.08);
  backdrop-filter: blur(12px);
  pointer-events: auto;
  animation: graph-popup-in 0.22s ease;
}

.graph-popup::before {
  content: '';
  display: block;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(201, 168, 76, 0.4), transparent);
  margin-bottom: 10px;
}

.graph-popup.hidden {
  display: none;
}

@keyframes graph-popup-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.graph-popup__head {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
}

.graph-popup__avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px var(--node-accent, #c9a84c);
}

.graph-popup__name {
  font-size: 14px;
  font-weight: 700;
  color: #f0e6d3;
  line-height: 1.3;
}

.graph-popup__summary {
  font-size: 12px;
  line-height: 1.65;
  color: rgba(201, 168, 76, 0.65);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 10px;
}

.graph-popup__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 10px;
}

.graph-popup__tag {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(201, 168, 76, 0.1);
  border: 1px solid rgba(201, 168, 76, 0.25);
  color: #c9a84c;
}

.graph-popup__actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.graph-popup__btn {
  flex: 1 1 45%;
  min-width: 0;
  min-height: 34px;
  border-radius: 8px;
  border: 1px solid rgba(201, 168, 76, 0.3);
  background: rgba(8, 4, 4, 0.6);
  color: #a89070;
  font-size: 11px;
  cursor: pointer;
}

.graph-popup__btn--primary {
  background: linear-gradient(135deg, #8b1a1a, #c0392b);
  border-color: transparent;
  color: #fff;
}

.graph-popup__btn:active {
  opacity: 0.85;
}

/* 图例横排样本条 */
.graph-legend {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  padding: 10px 16px;
  background: rgba(15, 8, 4, 0.8);
  border: 1px solid rgba(201, 168, 76, 0.12);
  border-radius: 10px;
  margin-top: 8px;
}

.graph-legend__item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: #a89070;
}

.graph-legend__sample {
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.graph-legend__sample svg {
  display: block;
  overflow: visible;
}

.graph-legend__text {
  font-size: 11px;
  color: #a89070;
  white-space: nowrap;
  letter-spacing: 0.04em;
  font-family: 'Noto Serif SC', serif;
}
