/* W-npc: 동물 친구 대화 상자 · 이름표 · 상주 도크(다음 할 일·동물 친구·두런이 상담). 아늑한 섬 파스텔 톤.
   색: 크림 #fff8ee · 피치 #ffb4a2 · 민트 #9ed9c5 · 레몬 #ffe38a · 글자 #3b3049(대비 4.5:1 이상) */
:root {
  --npc-cream: #fff8ee;
  --npc-ink: #3b3049;
  --npc-sub: #5f5468;
  --npc-lemon: #ffe38a;
  --npc-mint: #9ed9c5;
  --npc-peach: #ffb4a2;
  --npc-edge: #f0e1c8;
  --npc-shadow: 0 18px 36px -16px rgba(80, 50, 30, .45);
}

/* ── 이름표(3D 위 DOM) ─────────────────────── */
.npc-tags { position: fixed; inset: 0; z-index: 12; pointer-events: none; overflow: hidden; }
.npc-tag {
  position: absolute; left: 0; top: 0; display: none; pointer-events: auto;
  flex-direction: column; align-items: center; gap: 1px;
  border: 3px solid #fff; background: var(--npc-cream); color: var(--npc-ink);
  border-radius: 18px; padding: 5px 13px 7px; box-shadow: var(--npc-shadow);
  font-size: 12px; line-height: 1.25; white-space: nowrap; will-change: transform;
}
.npc-tag.is-on { display: flex; }
.npc-tag b { font-family: var(--display); font-weight: 400; font-size: 17px; color: var(--npc-ink); }
.npc-tag b small { font-family: var(--body); font-size: 11.5px; font-weight: 700; color: var(--npc-sub); }
.npc-tag-org { color: var(--npc-sub); font-size: 11.5px; }
.npc-tag-ai { font-size: 10px; font-weight: 800; color: var(--npc-ink); background: color-mix(in srgb, var(--npc-color) 28%, #fff); border-radius: 999px; padding: 1px 8px; margin-top: 2px; }
.npc-tag-cta { display: none; margin-top: 5px; font-family: var(--display); font-size: 15px; color: var(--npc-ink); background: var(--npc-lemon); border-radius: 999px; padding: 3px 12px; box-shadow: 0 3px 0 #e8c65a; }
.npc-tag-cta kbd { font-family: var(--body); font-size: 11px; font-weight: 800; background: #fff; border-radius: 6px; padding: 0 5px; margin-right: 4px; }
.npc-tag.is-near { z-index: 2; }
.npc-tag.is-near .npc-tag-cta { display: inline-block; animation: npc-bob 1.4s ease-in-out infinite; }
.npc-tag-emote {
  position: absolute; top: -28px; left: 50%; transform: translateX(-50%) scale(.6); opacity: 0;
  min-width: 30px; height: 30px; padding: 0 7px; display: grid; place-items: center;
  background: #fff; border-radius: 15px 15px 15px 4px; box-shadow: var(--npc-shadow);
  font-family: var(--display); font-size: 17px; color: var(--npc-ink); transition: .25s cubic-bezier(.3, 1.6, .5, 1);
}
.npc-tag.has-emote .npc-tag-emote { opacity: 1; transform: translateX(-50%) scale(1); }
@keyframes npc-bob { 50% { transform: translateY(-3px); } }

/* ── 대화 상자(게임식) ─────────────────────── */
.npc-box {
  --npc-color: #9ed9c5;
  position: fixed; left: 50%; bottom: 18px; z-index: 40; transform: translateX(-50%);
  width: min(800px, calc(100vw - 36px));
  display: grid; grid-template-columns: 124px 1fr; gap: 6px 18px; align-items: start;
  padding: 26px 22px 18px 20px; color: var(--npc-ink);
  background: var(--npc-cream); border-radius: 30px;
  border: 4px solid #fff; box-shadow: 0 0 0 2px var(--npc-edge), 0 30px 60px -30px rgba(80, 50, 30, .55);
  animation: npc-in .35s cubic-bezier(.2, 1.3, .4, 1);
}
@keyframes npc-in { from { opacity: 0; transform: translate(-50%, 24px) scale(.96); } }
.npc-portrait { position: relative; margin-top: -54px; }
.npc-face {
  width: 124px; height: 140px; border-radius: 28px; overflow: hidden; background: #fff;
  border: 4px solid #fff; box-shadow: 0 0 0 2px var(--npc-edge), 0 12px 22px -12px rgba(80, 50, 30, .6);
  animation: npc-breathe 3.2s ease-in-out infinite;
}
.npc-face svg { display: block; width: 100%; height: 100%; }
.npc-box.is-typing .npc-face { animation: npc-talk .32s ease-in-out infinite alternate; }
@keyframes npc-breathe { 50% { transform: translateY(-2px) scale(1.01); } }
@keyframes npc-talk { to { transform: translateY(-2px) scaleY(1.02); } }
.npc-emote:not(:empty) {
  position: absolute; right: -10px; top: -12px; min-width: 34px; height: 34px; padding: 0 8px; display: grid; place-items: center;
  background: #fff; border-radius: 17px 17px 17px 5px; box-shadow: var(--npc-shadow);
  font-family: var(--display); font-size: 19px; color: var(--npc-ink); animation: npc-pop .3s cubic-bezier(.3, 1.8, .5, 1);
}
@keyframes npc-pop { from { transform: scale(.3); } }
.npc-main { min-width: 0; }
.npc-nametag { position: absolute; top: -20px; left: 160px; margin: 0; display: flex; align-items: center; gap: 8px; }
.npc-nametag b {
  font-family: var(--display); font-weight: 400; font-size: 22px; line-height: 1; color: var(--npc-ink);
  background: color-mix(in srgb, var(--npc-color) 55%, #fff); border: 3px solid #fff; border-radius: 16px; padding: 7px 16px 6px;
  box-shadow: 0 6px 14px -8px rgba(80, 50, 30, .6); transform: rotate(-2deg);
}
.npc-nametag b small { font-family: var(--body); font-size: 13px; font-weight: 700; color: var(--npc-ink); }
.npc-badge { font-size: 11px; font-weight: 800; color: #fff; background: var(--npc-ink); border-radius: 999px; padding: 3px 10px; white-space: nowrap; }
.npc-org { margin: 8px 0 4px; font-size: 12.5px; color: var(--npc-sub); }
.npc-say { position: relative; cursor: pointer; outline: none; min-height: 3.2em; padding-right: 22px; }
.npc-text { margin: 0; font-size: 19px; line-height: 1.6; word-break: keep-all; }
.npc-more { position: absolute; right: 0; bottom: 2px; font-size: 14px; color: var(--npc-sub); opacity: 0; }
.npc-box.has-next .npc-more { opacity: 1; animation: npc-bob 1s ease-in-out infinite; }
.npc-box.is-crisis .npc-text { color: #5a1d12; font-weight: 700; }
.npc-box.is-crisis { box-shadow: 0 0 0 2px #f3c7bf, 0 30px 60px -30px rgba(80, 50, 30, .55); }

.npc-cards { display: grid; gap: 8px; margin-top: 8px; }
.npc-cards:empty { display: none; }
.npc-you { margin: 0; font-size: 14px; color: var(--npc-sub); }
.npc-you span { display: inline-block; font-weight: 800; color: #fff; background: var(--npc-sub); border-radius: 8px; padding: 0 6px; margin-right: 6px; font-size: 12px; }
.npc-card { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 12px; background: #fff; border: 2px dashed var(--npc-edge); border-radius: 18px; padding: 10px 14px; }
.npc-card b { font-size: 15px; line-height: 1.4; grid-column: 1; }
.npc-card p { margin: 0; font-size: 13.5px; color: var(--npc-sub); grid-column: 1 / -1; }
.npc-card-tag { grid-column: 1 / -1; justify-self: start; font-size: 11.5px; font-weight: 800; color: var(--npc-ink); background: var(--npc-lemon); border-radius: 999px; padding: 1px 9px; }
.npc-btn { grid-column: 2; grid-row: 2; display: inline-flex; align-items: center; border: 0; text-decoration: none; background: var(--npc-mint); color: var(--npc-ink); font-weight: 800; font-size: 14px; border-radius: 14px; padding: 8px 14px; box-shadow: 0 3px 0 #7cc0aa; }
.npc-prog { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; }
.npc-prog-bar { flex: 1; height: 10px; border-radius: 999px; background: #f1e9dd; overflow: hidden; }
.npc-prog-bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--npc-lemon), var(--npc-peach)); }
.npc-prog em { font-style: normal; font-size: 12.5px; font-weight: 800; color: var(--npc-sub); }

.npc-ask { display: flex; gap: 8px; margin-top: 10px; }
.npc-input { flex: 1; min-width: 0; border: 2px solid var(--npc-edge); border-radius: 16px; padding: 11px 15px; font-size: 16px; background: #fff; color: var(--npc-ink); }
.npc-input:focus { outline: none; border-color: var(--npc-color); box-shadow: 0 0 0 4px color-mix(in srgb, var(--npc-color) 30%, transparent); }
.npc-send { flex: none; border: 0; border-radius: 16px; padding: 0 18px; background: var(--npc-lemon); color: var(--npc-ink); font-family: var(--display); font-size: 17px; box-shadow: 0 3px 0 #e8c65a; }

.npc-choices { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.npc-choices:empty { display: none; }
.npc-choice {
  display: inline-flex; align-items: center; gap: 8px; border: 2px solid var(--npc-edge); background: #fff; color: var(--npc-ink);
  border-radius: 18px; padding: 9px 16px 9px 10px; font-family: var(--display); font-size: 17px; line-height: 1.2;
  box-shadow: 0 3px 0 var(--npc-edge); transition: transform .12s, box-shadow .12s;
}
.npc-choice kbd { font-family: var(--body); font-size: 11px; font-weight: 800; color: var(--npc-sub); background: #f6efe4; border-radius: 7px; padding: 2px 6px; }
.npc-choice:hover, .npc-choice:focus-visible { transform: translateY(-2px); box-shadow: 0 5px 0 var(--npc-edge); }
.npc-choice.is-main { background: var(--npc-lemon); border-color: #f1d36b; box-shadow: 0 3px 0 #e8c65a; }
.npc-choice.is-main kbd { background: #fff6cf; }
.npc-x { position: absolute; right: 12px; top: 10px; width: 36px; height: 36px; border: 0; border-radius: 12px; background: transparent; font-size: 26px; line-height: 1; color: var(--npc-sub); }
.npc-x:hover { background: #f6efe4; color: var(--npc-ink); }

body.npc-open .guide, body.npc-open .enter-prompt, body.npc-open .dock, body.npc-open .npc-dock, body.npc-open .minimap { opacity: 0; pointer-events: none; transition: opacity .2s; }

/* 공용 병아리 상담 위젯이 있으면 그 병아리가 상담 버튼(도크의 두런이 버튼 숨김) */
body.has-chick-agent .npc-dock-duron { display: none; }
body.has-chick-agent .npc-dock { bottom: 362px; }  /* 3D 데스크톱: 병아리가 미니맵 위(약 230~320px)로 올라가므로 그 위로 */
body.has-chick-agent .npc-dir { bottom: 496px; }
body.has-chick-agent.mode-2d .npc-dock, body.has-chick-agent.panel-open .npc-dock, body.has-chick-agent.mode-text .npc-dock { bottom: 124px; } /* 병아리(88px) 위로 */
body.has-chick-agent.mode-2d .npc-dir, body.has-chick-agent.panel-open .npc-dir { bottom: 236px; }

/* ── 상주 도크 ─────────────────────────── */
.npc-dock { position: fixed; right: 18px; bottom: 232px; z-index: 19; display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
body.mode-2d .npc-dock, body.panel-open .npc-dock { bottom: 18px; }
body.panel-open .npc-dock { right: calc(var(--panel-w) + 30px); }
body.panel-open .npc-chip-next, body.panel-open .npc-dock-people { display: none; } /* 존 패널이 열리면 두런이 버튼만(아래 바로가기와 겹침 방지) */
body.wchat-open .npc-dock, body.intro-open .npc-dock, body.poster .npc-dock, body.is-loading .npc-dock, body.poster-shot .npc-dock { opacity: 0; pointer-events: none; }
.npc-chip-next {
  display: flex; align-items: center; gap: 8px; max-width: 250px; text-align: left; border: 3px solid #fff; border-radius: 20px; padding: 4px 12px 4px 4px;
  background: var(--npc-cream); color: var(--npc-ink); box-shadow: var(--npc-shadow);
}
.npc-chip-next img { width: 36px; height: 36px; border-radius: 12px; flex: none; }
.npc-chip-next span { display: grid; min-width: 0; }
.npc-chip-next em { font-style: normal; font-size: 11px; font-weight: 800; color: var(--npc-sub); }
.npc-chip-next b { font-size: 13.5px; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.npc-dock-people {
  display: flex; align-items: center; gap: 8px; border: 3px solid #fff; border-radius: 999px; padding: 4px 14px 4px 4px;
  background: var(--npc-cream); box-shadow: var(--npc-shadow); font-size: 13.5px; font-weight: 800; color: var(--npc-ink);
}
.npc-dock-faces { display: flex; }
.npc-dock-faces i { width: 30px; height: 30px; border-radius: 50%; overflow: hidden; display: grid; place-items: center; background: #fff; box-shadow: 0 0 0 2px #fff; margin-right: -8px; }
.npc-dock-faces i:last-child { margin-right: 0; }
.npc-dock-faces svg { margin-top: 5px; }
.npc-dock-duron {
  position: relative; width: 70px; height: 70px; border: 0; border-radius: 50%; padding: 0;
  background: #fff8e1; box-shadow: 0 14px 26px -12px rgba(80, 50, 30, .7), 0 0 0 4px #fff, 0 0 0 7px var(--npc-mint);
  transition: transform .2s;
}
.npc-dock-duron img { width: 70px; height: 70px; border-radius: 50%; display: block; object-fit: cover; }
.npc-dock-duron:hover { transform: translateY(-2px) scale(1.05) rotate(-3deg); }
.npc-dock-label {
  position: absolute; right: 82px; top: 50%; transform: translateY(-50%); white-space: nowrap;
  background: var(--npc-ink); color: #fff; font-family: var(--display); font-size: 15px; border-radius: 14px; padding: 6px 12px;
}
.npc-dock-duron::after { content: ""; position: absolute; right: 2px; top: 2px; width: 13px; height: 13px; border-radius: 50%; background: #2fbf71; box-shadow: 0 0 0 3px #fff; }

.npc-dir {
  position: fixed; right: 18px; bottom: 400px; z-index: 41; width: min(350px, calc(100vw - 36px));
  background: var(--npc-cream); color: var(--npc-ink); border: 4px solid #fff; border-radius: 26px; box-shadow: 0 0 0 2px var(--npc-edge), var(--npc-shadow); padding: 14px;
  animation: npc-pop .25s ease-out;
}
body.mode-2d .npc-dir, body.panel-open .npc-dir { bottom: 186px; }
.npc-dir header { display: flex; justify-content: space-between; align-items: center; font-family: var(--display); font-size: 19px; }
.npc-dir header b { font-weight: 400; }
.npc-dir-lead { margin: 4px 2px 10px; font-size: 12.5px; color: var(--npc-sub); line-height: 1.5; }
.npc-dir ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.npc-dir li button { width: 100%; display: flex; align-items: center; gap: 10px; text-align: left; border: 0; background: transparent; border-radius: 16px; padding: 6px 8px; color: var(--npc-ink); }
.npc-dir li button:hover, .npc-dir li button:focus-visible { background: color-mix(in srgb, var(--npc-color) 18%, #fff); }
.npc-dir li i { width: 44px; height: 50px; border-radius: 14px; overflow: hidden; flex: none; }
.npc-dir li span:first-of-type { flex: 1; min-width: 0; display: grid; }
.npc-dir li b { font-family: var(--display); font-weight: 400; font-size: 17px; }
.npc-dir li b small { font-family: var(--body); font-size: 12px; color: var(--npc-sub); font-weight: 700; }
.npc-dir li em { font-style: normal; font-size: 12px; color: var(--npc-sub); }
.npc-div { flex: none; font-size: 11px; font-weight: 800; color: var(--npc-ink); background: color-mix(in srgb, var(--npc-color) 30%, #fff); border-radius: 999px; padding: 2px 9px; }

/* ── 존 패널 안 '여기 있는 동물 친구' ── */
.npc-hint { display: grid; gap: 6px; margin: 10px 0 14px; }
.npc-hint button {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; color: var(--npc-ink);
  border: 2px solid color-mix(in srgb, var(--npc-color) 45%, #fff); border-radius: 18px; padding: 7px 10px 7px 7px;
  background: color-mix(in srgb, var(--npc-color) 12%, #fff8ee); font-size: 14px;
}
.npc-hint i { width: 38px; height: 43px; border-radius: 12px; overflow: hidden; flex: none; }
.npc-hint span:first-of-type { flex: 1; min-width: 0; line-height: 1.35; }
.npc-hint em { display: block; font-style: normal; font-size: 12px; color: var(--npc-sub); }
.npc-hint-go { flex: none; font-family: var(--display); font-size: 15px; color: var(--npc-ink); background: var(--npc-lemon); border-radius: 999px; padding: 5px 12px; box-shadow: 0 3px 0 #e8c65a; }

/* ── 모바일 ─────────────────────────────── */
@media (max-width: 760px) {
  .npc-dock { right: 10px; bottom: 84px; gap: 8px; }
  body.mode-2d .npc-dock, body.panel-open .npc-dock { bottom: 84px; right: 10px; }
  body.panel-open .npc-dock { opacity: 0; pointer-events: none; }
  .npc-dock-label { display: none; }
  .npc-dock-duron, .npc-dock-duron img { width: 58px; height: 58px; }
  .npc-dock-people { padding: 4px; }
  .npc-dock-people > span:last-child { display: none; }
  .npc-chip-next { max-width: 210px; }
  .npc-dir, body.mode-2d .npc-dir { right: 10px; left: 10px; width: auto; bottom: 250px; }
  .guide { max-width: calc(100vw - 110px); }
  body.has-chick-agent .npc-dock, body.has-chick-agent.mode-2d .npc-dock { bottom: 160px; } /* 모바일 병아리(64px)·하단 바 위로 */
  body.has-chick-agent .npc-dir, body.has-chick-agent.mode-2d .npc-dir { bottom: 270px; }
  .npc-box {
    left: 0; right: 0; bottom: 0; transform: none; width: auto; max-height: 82vh; overflow-y: auto;
    grid-template-columns: 76px 1fr; gap: 6px 12px; padding: 16px 14px calc(14px + env(safe-area-inset-bottom)); border-radius: 26px 26px 0 0;
    animation-name: npc-in-m;
  }
  @keyframes npc-in-m { from { opacity: 0; transform: translateY(24px); } }
  .npc-portrait { margin-top: 0; grid-row: 1 / span 2; }
  .npc-face { width: 76px; height: 86px; border-radius: 20px; }
  .npc-nametag { position: static; grid-column: 2; flex-wrap: wrap; gap: 6px; }  /* 넘침 스크롤 상자 안에서는 위로 걸치지 않게 */
  .npc-nametag b { font-size: 19px; padding: 6px 12px 5px; transform: none; }
  .npc-x { top: 8px; right: 8px; }
  .npc-emote:not(:empty) { right: -6px; top: -6px; }
  .npc-badge { font-size: 10px; padding: 2px 8px; }
  .npc-text { font-size: 17px; }
  .npc-main { display: contents; }
  .npc-org { grid-column: 2; margin: 2px 0 0; }
  .npc-say, .npc-live { grid-column: 1 / -1; }
  .npc-cards, .npc-ask, .npc-choices { grid-column: 1 / -1; }
  .npc-choices { display: grid; grid-template-columns: 1fr 1fr; }
  .npc-choices:empty { display: none; }
  .npc-choice { justify-content: center; font-size: 16px; padding: 11px 10px; }
  .npc-tag { padding: 4px 10px 6px; }
  .npc-tag-org { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .npc-box, .npc-dir, .npc-face, .npc-emote, .npc-tag.is-near .npc-tag-cta, .npc-box.has-next .npc-more { animation: none !important; }
}
