/* ========================================
   キャラクターシステム
   テーマ変数: --body-bg, --card-bg, --text-primary,
   --text-secondary, --text-muted, --border-color, --accent
   ======================================== */

/* --- フッター固定アイコン --- */
.character-icon {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 1000;
  cursor: pointer;
  transition: transform 0.2s;
}
.character-icon:hover {
  transform: scale(1.15);
}
.character-icon__canvas {
  width: 48px;
  height: 48px;
  image-rendering: pixelated;
  border-radius: 50%;
  border: 2px solid var(--border-color);
  background: var(--card-bg);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}
/* PixelArtがない場合のプレースホルダー */
.character-icon__placeholder {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid var(--border-color);
  background: var(--card-bg);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
}

/* --- 世界カラーマーカー --- */
.character-icon__world-marker {
  position: absolute;
  bottom: -1px;
  left: 50%;
  transform: translateX(-50%);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--body-bg);
  pointer-events: none;
}

/* --- 完了通知バッジ --- */
.character-icon__badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 12px;
  height: 12px;
  background: var(--accent);
  border-radius: 50%;
  border: 2px solid var(--body-bg);
  pointer-events: none;
}

/* --- アイコン吹き出し --- */
.character-icon__bubble {
  position: absolute;
  bottom: 100%;
  right: 0;
  margin-bottom: 8px;
  padding: 6px 12px;
  background: var(--card-bg);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  font-size: 0.8rem;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
.character-icon__bubble.show {
  opacity: 1;
  transform: translateY(0);
}

/* --- オーバーレイ --- */
.character-overlay {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 1099;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
.character-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

/* --- パネル --- */
.character-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 360px;
  max-width: 100vw;
  height: 100vh;
  background: var(--body-bg);
  color: var(--text-primary);
  z-index: 1100;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 16px rgba(0, 0, 0, 0.15);
}
.character-panel.open {
  transform: translateX(0);
}

/* === 上部: 操作 + システム情報（固定） === */

/* パネルヘッダー（コンパクト） */
.character-panel__header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 6px 12px;
  background: var(--card-bg);
  min-height: 36px;
  flex-shrink: 0;
}
.character-panel__close {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px 6px;
}
.character-panel__close:hover {
  color: var(--text-primary);
}

/* 情報パネル（上部固定 — システム情報） */
.character-panel__info {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  background: var(--card-bg);
  flex-shrink: 0;
}
.character-info__header {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}
.character-info__bar {
  height: 4px;
  background: var(--border-color);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 8px;
}
.character-info__bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.5s ease;
}
.character-info__mission {
  padding: 4px 0;
  font-size: 0.8rem;
  color: var(--text-secondary);
}
.character-info__mission + .character-info__mission {
  border-top: 1px solid var(--border-color);
}
.character-info__mission--done {
  color: var(--text-muted);
}
.character-info__mission-narrative {
  font-size: 0.8em;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.character-info__mission-title {
  margin-bottom: 4px;
}
.character-info__mission-detail {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 20px;
}
.character-info__mission-nums {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  min-width: 3.5em;
}
.character-info__mission-bar {
  flex: 1;
  height: 4px;
  background: var(--border-color);
  border-radius: 2px;
  overflow: hidden;
}
.character-info__mission-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.5s ease;
}
.character-info__reward {
  font-size: 0.8rem;
  color: var(--accent);
  font-weight: 600;
  margin-top: 6px;
  text-align: right;
}

/* === 下部: 演出エリア（スクロール） === */

.character-panel__stage {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

/* キャラクター画像 + 背景 */
.character-panel__portrait {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px 16px;
  background:
    radial-gradient(ellipse at center bottom, var(--accent), transparent 70%),
    var(--body-bg);
  background-blend-mode: soft-light;
  flex-shrink: 0;
}
.character-panel__portrait-img {
  width: 128px;
  height: 128px;
  object-fit: cover;
  border-radius: 12px;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.3));
}
.character-panel__portrait-canvas {
  width: 128px;
  height: 128px;
  image-rendering: pixelated;
  border-radius: 12px;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.3));
}
.character-panel__portrait-placeholder {
  width: 128px;
  height: 128px;
  border-radius: 12px;
  background: var(--card-bg);
  border: 2px dashed var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  color: var(--text-muted);
}

/* 会話エリア */
.character-panel__conversations {
  flex: 1;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* 吹き出し */
.character-bubble {
  background: var(--card-bg);
  color: var(--text-primary);
  padding: 10px 14px;
  border-radius: 16px 16px 16px 4px;
  border: 1px solid var(--border-color);
  font-size: 0.9rem;
  line-height: 1.5;
  max-width: 85%;
  animation: bubble-appear 0.3s ease;
}

@keyframes bubble-appear {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 会話内アクションボタン */
.character-action-btn {
  display: block;
  margin: 8px 0;
  padding: 10px 20px;
  border: none;
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  animation: bubble-appear 0.3s ease;
}
.character-action-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.character-action-btn--accept {
  background: var(--accent);
  color: #fff;
}
.character-action-btn--accept:hover:not(:disabled) { opacity: 0.9; }
.character-action-btn--reward {
  background: var(--accent);
  color: #fff;
}
.character-action-btn--reward:hover:not(:disabled) { opacity: 0.9; }
.character-action-btn--abandon {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border-color);
  font-size: 0.8rem;
  padding: 6px 14px;
}

/* システムメッセージ（報酬獲得等） */
.character-system-message {
  text-align: center;
  color: var(--accent);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 6px 0;
  animation: bubble-appear 0.3s ease;
}

/* --- ステップ情報 --- */
.character-step-info { text-align: center; color: var(--text-muted); font-size: 0.8rem; padding: 8px 12px; background: var(--card-bg); border-radius: 12px; border: 1px dashed var(--border-color); animation: bubble-appear 0.3s ease; }

/* --- モバイル・狭幅全画面対応 --- */
@media (max-width: 640px) {
  .character-panel {
    width: 100vw;
  }
  .character-panel__portrait {
    padding: 16px 12px 12px;
  }
  .character-panel__portrait-img,
  .character-panel__portrait-canvas,
  .character-panel__portrait-placeholder {
    width: 96px;
    height: 96px;
  }
}
