/* ── 채널 대화(좌하단) ── */
.chat {
  position: absolute; left: 12px; bottom: calc(12px + var(--safe-b));
  /* 너비: 직접 조절한 값(--chat-w)이 없으면 가운데 체력 구슬에 닿지 않는 너비 */
  width: var(--chat-w, clamp(240px, calc(50vw - 285px), 400px)); max-width: calc(100vw - 24px);
  display: flex; flex-direction: column; gap: 6px;
  pointer-events: none;
}
.chat-log {
  max-height: 200px; overflow-y: hidden; display: flex; flex-direction: column; gap: 3px;
  padding: 6px 8px; border-radius: 10px; background: transparent;
  pointer-events: none;
}
.chat-log > :first-child { margin-top: auto; } /* 줄이 적으면 아래쪽에 붙인다 */
.chat-line {
  align-self: flex-start; max-width: 100%;
  font-size: 15px; line-height: 1.45; color: #f2ece2; text-shadow: 0 1px 2px #000;
  padding: 2px 8px; border-radius: 6px; background: rgba(0, 0, 0, 0.5);
  word-break: break-all; animation: chat-fade 0.8s ease 10s forwards;
}
.chat-name { font-weight: 700; color: var(--accent-2); margin-right: 6px; }
.chat-line.is-me .chat-name { color: var(--sky); }
.chat-line.is-system { color: #bfb5a6; font-style: italic; }
@keyframes chat-fade { to { opacity: 0.15; } }
.chat-row { display: none; }
.chat.is-open { pointer-events: auto; }
.chat.is-open .chat-log {
  height: var(--chat-h, 240px); max-height: none; overflow-y: auto;
  background: rgba(10, 10, 12, 0.72); border: 1px solid var(--line); pointer-events: auto;
}
/* 크기 조절 손잡이(오른쪽 위 모서리): 열려 있을 때만 */
.chat-resize { display: none; }
.chat.is-open .chat-resize {
  display: block; position: absolute; right: -7px; top: -7px; width: 18px; height: 18px; z-index: 1;
  border-radius: 50%; background: var(--panel-2); border: 1px solid var(--accent); cursor: nesw-resize; touch-action: none;
}
.chat.is-open .chat-resize::after {
  content: ''; position: absolute; inset: 4px; border-top: 2px solid var(--accent-2); border-right: 2px solid var(--accent-2);
}
.chat.is-open .chat-line { animation: none; opacity: 1; }
.chat.is-open .chat-row { display: flex; }
.chat-input { flex: 1; min-width: 0; font-size: 15px; padding: 8px 10px; }
.icon-btn-chat .chat-icon {
  width: 22px; height: 16px; border-radius: 6px; border: 2px solid var(--text); position: relative;
}
.icon-btn-chat .chat-icon::after {
  content: ''; position: absolute; left: 3px; bottom: -6px; border: 4px solid transparent; border-top-color: var(--text);
}
/* 좁은 화면: 아래 기술 칸 위로 올린다 */
@media (max-width: 1000px) { .chat { bottom: calc(130px + var(--safe-b)); width: var(--chat-w, min(320px, 60vw)); } }
/* 터치: 왼쪽 아래는 조이스틱 자리라 대화는 그 위로 */
.is-touch .chat { bottom: auto; top: 46%; width: var(--chat-w, min(300px, 60vw)); }
.is-touch .chat-log { max-height: 110px; }
.is-touch .chat.is-open .chat-log { height: var(--chat-h, 160px); }
