*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  /* 深海の夜：グラデーションと星の瞬きを1つに統合 */
  background: 
    radial-gradient(1px 1px at 20px 30px, #fff, rgba(0,0,0,0)),
    radial-gradient(1px 1px at 100px 250px, #fff, rgba(0,0,0,0)),
    radial-gradient(circle at center, #0a1020 0%, #030510 100%);
  background-color: #030510;
  background-attachment: fixed;
  background-size: 250px 250px;
  color: #f7f7ff;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  justify-content: center;
}

.app-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 8px;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px; /* 少し余白を調整してスマートに */
  border-radius: 14px;
  /* ▼ ここからデザインの変更 ▼ */
  /* 深海の底のような、透け感のあるダークグラデーション */
  background: linear-gradient(135deg, rgba(15, 20, 45, 0.75), rgba(30, 25, 60, 0.75));
  
  /* すりガラス効果（背景のチャットがスクロールで通ると美しくボケる） */
  backdrop-filter: blur(12px); 
  -webkit-backdrop-filter: blur(12px);
  
  /* 天体指名カードと同じ、極細のミスティック・パープルの枠線 */
  border: 1px solid rgba(157, 130, 255, 0.3); 
  
  /* 影を落として少し浮き上がらせる */
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  /* ▲ ここまで ▲ */
}

.app-title {
  font-size: 1.1rem;
  font-weight: 600;
}

.app-subtitle {
  font-size: 0.8rem;
  opacity: 0.8;
}

/* --- 創造的破壊ボタンの基本スタイル --- */
.header-button {
  background: rgba(25, 30, 60, 0.6);
  color: #fdfcff;
  border: 1px solid rgba(150, 100, 255, 0.4);
  border-radius: 999px; /* 丸みを持たせる */
  cursor: pointer;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.header-button:hover {
  background: rgba(40, 45, 80, 0.8);
  box-shadow: 0 0 10px rgba(150, 100, 255, 0.3);
  transform: translateY(-2px);
}

/* ★ アイコン専用の丸いボタン */
.header-icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%; /* 完全な真ん丸にする */
  border: 1px solid rgba(150, 100, 255, 0.4); /* 薄い紫の枠線 */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 1.1rem; /* 絵文字を見やすいサイズに */
  cursor: pointer;
  background: rgba(25, 30, 60, 0.6); /* 少し暗い深海色 */
  color: #fdfcff;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition: all 0.2s ease;
}

.header-icon-btn:hover {
  background: rgba(40, 45, 80, 0.8);
  box-shadow: 0 0 10px rgba(150, 100, 255, 0.3);
  transform: translateY(-2px);
}

.chat-scroll-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.chat-scroll-wrap::-webkit-scrollbar {
  width: 6px;
}

.chat-scroll-wrap::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.16);
  border-radius: 999px;
}

.command-palette {
  flex-shrink: 0;
  display: flex;
  gap: 6px;
  padding: 8px 4px 6px;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
  /* ▼ ここから変更（背景と線を完全に消し去る） ▼ */
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border-top: none;
  /* ▲ ここまで ▲ */
}

.command-palette::-webkit-scrollbar {
  height: 4px;
}

.command-palette::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15); /* スクロールバーも少しだけ控えめに */
  border-radius: 999px;
}

.command-btn {
  white-space: nowrap;
  flex-shrink: 0;
  border-radius: 999px;
  border: none;
  padding: 6px 10px;
  font-size: 0.75rem;
  cursor: pointer;
  background: rgba(12, 19, 52, 0.9);
  color: #f8f6ff;
  border: 1px solid rgba(157, 130, 255, 0.3);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  gap: 4px;
}

.command-btn:hover {
  background: rgba(33, 45, 100, 0.9);
}

/* ★ 追加：選択中（アクティブ）のコマンドボタンの発光スタイル */
.command-btn.active {
  background: rgba(157, 130, 255, 0.3); /* 少し明るい紫 */
  border-color: rgba(157, 130, 255, 0.8); /* 枠線をくっきり */
  color: #fff;
  box-shadow: 0 0 12px rgba(157, 130, 255, 0.5), inset 0 0 8px rgba(157, 130, 255, 0.3);
  transform: translateY(-1px); /* 少しだけ浮き上がる */
}

.chat-main {
  flex: 0 1 auto;
  margin-top: 4px;
  margin-bottom: 4px;
  padding: 8px 4px;
}

.chat-messages {
  flex: 1;
  padding-right: 4px;
  padding-bottom: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.16);
  border-radius: 999px;
}

.chat-input-area {
  padding: 6px 4px 8px;
}

#chat-form {
  display: flex;
  gap: 8px; /* ボタンとの隙間を少し広げる */
  /* ▼ ここから変更 ▼ */
  /* 背景より少しだけ明るい、透け感のあるネイビーに */
  background: rgba(25, 30, 60, 0.85); 
  
  /* ヘッダーや天体カードと同じ「ミスティック・パープル」の枠線を追加 */
  border: 1px solid rgba(157, 130, 255, 0.4); 
  
  border-radius: 16px; /* 少しだけ丸みを強める */
  padding: 10px 12px; /* 内側の余白を広げて窮屈さをなくす */
  
  /* すりガラス効果で、後ろのスクロールテキストを美しくボカす */
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  
  /* 影を落として、画面からしっかり浮き上がらせる */
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
  /* ▲ ここまで ▲ */
}

#user-input {
  flex: 1;
  resize: none;
  background: transparent;
  border: none;
  color: #fdfcff;
  font-size: 0.9rem;
  line-height: 1.4;
  min-height: 68px;
}

#send-button {
  align-self: flex-end; 
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  padding: 0;
  font-size: 2.2rem; 
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, #ffb347, #ff6e7f);
  color: #1b0a23;
  font-weight: 800;
  box-shadow: 0 4px 12px rgba(255, 110, 127, 0.3);
  margin-bottom: 2px;
}

#user-input:focus {
  outline: none;
}

#user-input::-webkit-scrollbar {
  background: transparent; /* レール部分は完全に透明に */
}

#user-input::-webkit-scrollbar-thumb {
  /* 枠線と同じ「ミスティック・パープル」を半透明にして採用 */
  background: rgba(157, 130, 255, 0.4); 
  border-radius: 999px; /* 角を丸くする */
}

#user-input::-webkit-scrollbar-thumb:hover {
  background: rgba(157, 130, 255, 0.7); /* カーソルを乗せた時だけ少し光る */
}

/* 無効化時の見た目（ここも少し暗めにして沈ませます） */
#send-button:disabled {
  opacity: 0.3;
  cursor: default;
  filter: grayscale(1); /* 色を抜いて「今は押せない」感を出す */
}

/* --- レイアウトの隙間をGemini風に広げる --- */
.message-row {
  display: flex;
  gap: 16px; /* 6pxから12pxへ。アイコンと吹き出しに呼吸を */
  margin-bottom: 28px !important;
}

/* --- アバターは「議長の美学」を維持しつつ、画像用に調整 --- */
.message-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%; /* 完全に丸くする */
  object-fit: cover;   /* 画像を歪ませずに丸枠へ収める（追加） */
  flex-shrink: 0;
  margin-top: 4px;
  /* background関連は画像を表示するため削除 */
}

/* 天体用の発光 */
.message-avatar.planet {
  border: 1px solid rgba(157, 130, 255, 0.4);
  box-shadow: 0 0 12px rgba(157, 130, 255, 0.4);
}

/* 命（神様）用の発光 */
.message-avatar.god {
  border: 1px solid rgba(181, 255, 252, 0.5);
  box-shadow: 0 0 15px rgba(181, 255, 252, 0.5);
}

/* 名前の横並びを整える */
.message-body {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: 75% !important; /* アイコンが大きくなった分少し削る */
}

.message-meta {
  font-size: 0.75rem;
  color: #d1d5db; /* 少し暗いグレーから、明るく神々しいシルバーへ */
  letter-spacing: 0.05em; /* 字間を広げて威厳を出す */
  margin-bottom: 5px;
  margin-left: 4px;
  font-weight: 500;
}

/* --- 吹き出し（Gemini仕様の核心） --- */
.message-bubble {
  max-width: 82%;
  padding: 12px 18px; /* 余白を増やして「高級感」を出す */
  border-radius: 20px; /* Gemini風の大きな丸み */
  font-size: 15px;      /* Geminiの標準サイズに合わせる */
  line-height: 1.65;    /* 行間を広げて、AIの長文を読みやすく */
  word-wrap: break-word;
  white-space: pre-wrap;
  letter-spacing: -0.01em; /* Gemini特有のわずかな字詰め */
}

/* 議長（ユーザー）の吹き出し：Geminiのダークモード風の青 */
/* --- 議長（ユーザー）側の行の設定 --- */
.message-row.user {
  display: flex !important;
  justify-content: flex-end !important; /* 右寄せを確定 */
  padding-left: 20%; /* 左側に大きな余白を作り、長文でも右側に寄せて見せる */
  margin-bottom: 24px;
}

/* --- 議長（ユーザー）側の吹き出し：Gemini完全同期スタイル --- */
.message-row.user .message-bubble {
  /* 1. 配色の最適化：きつい青を廃止し、Geminiのグレーへ */
  background-color: #2f2f2f; /* Geminiのダークモードのバブル色 */
  color: #e3e3e3; /* 目に優しいオフホワイト */
  
  /* 2. フォント：ボールドを解除し、知的なウェイトへ */
  font-weight: 400; 
  letter-spacing: 0.015rem;
  
  /* 3. 形状のハッキング：右下を丸く戻し、右上を尖らせる */
  border-radius: 22px; /* 基本は大きな丸み */
  border-top-right-radius: 4px;    /* 右上を尖らせる（Gemini仕様） */
  border-bottom-right-radius: 22px; /* 右下は丸く戻す */
  
  /* 4. 装飾の引き算：影を消し、ごく薄い境界線のみ */
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: none;
  
  padding: 12px 20px;
  margin-left: auto;
}

/* 神様（エージェント）の吹き出し：深海に溶け込む半透明 */
.message-row.agent .message-bubble {
  background: rgba(255, 255, 255, 0.04); /* 背景を透かしつつ存在感を出す */
  color: #f1f5f9;
  border: 1px solid rgba(157, 130, 255, 0.25); /* 極細の紫ライン */
  border-bottom-left-radius: 4px; /* 左下を尖らせる */
}


.streaming-cursor {
  display: inline-block;
  width: 7px;
  background: rgba(255, 255, 255, 0.7);
  animation: blink 1s infinite;
}

@keyframes blink {
  0%,
  50% {
    opacity: 0;
  }
  51%,
  100% {
    opacity: 1;
  }
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(1, 2, 15, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.modal-overlay.hidden {
  display: none;
}

.modal {
  width: 100%;
  max-width: 520px;
  /* ★ 追加：スマホでもはみ出さないよう高さを制限し、Flexboxで構成 */
  max-height: 90dvh; 
  display: flex;
  flex-direction: column;
  background: radial-gradient(circle at top, #252a4c 0%, #0a0e1f 60%);
  border-radius: 18px;
  padding: 18px 18px 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.9);
  color: #f6f4ff;
}

.modal h2 {
  margin-top: 0;
  margin-bottom: 4px;
}

.modal-description {
  font-size: 0.8rem;
  opacity: 0.9;
  margin-bottom: 10px;
}

.form-group {
  display: flex;
  flex-direction: column;
  margin-bottom: 8px;
}

.form-group label {
  font-size: 0.8rem;
  margin-bottom: 2px;
}

.form-group input,
.form-group textarea {
  border-radius: 10px;
  border: 1px solid rgba(180, 170, 255, 0.4);
  padding: 6px 8px;
  background: rgba(3, 5, 15, 0.85);
  color: #fdfcff;
  font-size: 0.85rem;
}

.form-row {
  display: flex;
  gap: 8px;
}

.manual-natal {
  margin-top: 8px;
  font-size: 0.8rem;
}

.manual-natal summary {
  cursor: pointer;
}

.manual-natal textarea {
  width: 100%;
  margin-top: 4px;
}

.time-unknown {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  margin-top: 4px;
  opacity: 0.9;
}

.hint {
  font-size: 0.75rem;
  opacity: 0.8;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

.modal-actions button {
  border-radius: 999px;
  border: none;
  padding: 6px 14px;
  font-size: 0.8rem;
  cursor: pointer;
  background: linear-gradient(135deg, #ffb347, #ff6e7f);
  color: #180716;
  font-weight: 600;
}

.planet-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  margin-top: 12px;
  /* ★ 追加：リスト部分だけがスクロールするようにする */
  flex-grow: 1;
  overflow-y: auto;
  padding-right: 4px; /* スクロールバー用の隙間 */
  margin-bottom: 10px; /* キャンセルボタンとの隙間 */
}

/* スクロールバーの装飾 */
.planet-list::-webkit-scrollbar {
  width: 4px;
}
.planet-list::-webkit-scrollbar-thumb {
  background: rgba(157, 130, 255, 0.4);
  border-radius: 999px;
}

/* --- 1. カード本体（進化版） --- */
.planet-item {
  position: relative; /* 背景アイコンを配置するために必須 */
  overflow: hidden;   /* はみ出したアイコンをカット */
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-radius: 12px;
  padding: 10px; 
  min-height: 110px; /* ★ 修正：見切れないよう少し高さを確保 */
  height: 100%;      /* ★ 追加：グリッド内で均等に広げる */
  border: 1px solid rgba(157, 130, 255, 0.4);
  background: linear-gradient(135deg, rgba(10, 15, 40, 0.9), rgba(20, 25, 60, 0.9));
  cursor: pointer;
  color: #fdfcff;
  text-align: left;
  transition: all 0.2s ease;
}

.planet-item:hover {
  background: linear-gradient(135deg, rgba(24, 33, 76, 0.95), rgba(40, 30, 80, 0.95));
  transform: translateY(-2px); /* フワッと浮き上がる */
  box-shadow: 0 4px 12px rgba(157, 130, 255, 0.2);
}

/* --- 2. 新規追加：背景の星座ウォーターマーク --- */
.planet-bg-icon {
  position: absolute;
  right: 8px;       /* 右端から少し内側に入れる */
  bottom: -2px;     /* 下端のめり込みを最小限にする */
  font-size: 3.5rem; /* サイズを少し小さくして全体を見せる */
  font-family: "Segoe UI Symbol", "Apple Symbols", sans-serif; /* 絵文字化をさらにブロック */
  color: rgba(170, 150, 255, 0);
  pointer-events: none;
  z-index: 0;
  transition: all 0.3s ease; /* 0.3秒かけてフワッと変化させる魔法 */
}

.planet-item:hover .planet-bg-icon {
  color: rgba(170, 150, 255, 0.15); /* 綺麗な紫の透かしとして浮かび上がる */
  transform: scale(1.05); /* ほんの少しだけ大きく迫ってくるトキメキ演出 */
}

/* --- 3. メイン情報（名前と度数） --- */
.planet-content {
  position: relative;
  z-index: 1;
}

/* 新規追加：本来の天体名（属性表記） */
.real-planet-name {
  font-size: 0.65rem;
  color: #ffcf71; /* ハウス番号と同じ星の光（ゴールド） */
  margin-bottom: 2px;
  letter-spacing: 0.5px;
  opacity: 0.9;
  font-weight: 600;
}

.planet-name {
  font-weight: 700;
  font-size: 0.78rem;
  white-space: nowrap; /* 改行させない（維持） */
  margin-bottom: 4px;
}

.planet-sign-deg {
  font-size: 0.75rem;
  opacity: 0.8;
}

/* --- 4. 新規追加：右下のハウスバッジ --- */
.planet-house-badge {
  position: relative;
  z-index: 1;
  align-self: flex-end; /* 右下に寄せる */
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.1);
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.7rem;
}

.house-num {
  font-weight: 700;
}

.house-name {
  opacity: 0.9;
  white-space: nowrap;
}

@media (max-width: 600px) {
  body {
    align-items: stretch;
    height: 100dvh;
  }

  .app-container {
    padding: 6px 6px 8px;
    height: 100dvh;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }

  .app-header {
    padding: 8px 10px;
  }

  /* ★ ヘッダーの文字サイズの微調整と、サブタイトルの非表示 */
  .app-title {
    font-size: 0.95rem;
    letter-spacing: -0.02em;
  }

  .app-subtitle {
    display: none; /* スマホでは窮屈なのでサブタイトルを消す */
  }

  .command-palette {
    padding-top: 4px;
    padding-bottom: 2px;
    scrollbar-width: none;
    flex-wrap: nowrap;
  }

  .command-palette::-webkit-scrollbar {
    height: 0; /* WebKit: effectively hide bar but keep scroll */
    background: transparent;
  }

  #chat-form {
    padding: 8px 10px;
  }

  #user-input {
    font-size: 0.9rem;
    min-height: 44px; /* タップしやすい高さ */
  }

  #send-button {
    padding: 0 14px;
    font-size: 0.6rem;
  }

  .message-bubble {
    max-width: 82%;
    padding: 8px 11px;
    font-size: 0.9rem;
  }

  .modal {
    margin: 0 10px;
  }

  .form-row {
    flex-direction: column;
  }
  
  /* ★ ここに移動してきました */
  .message-actions {
    opacity: 0.6;
  }
  
  /* ★ 新しく迷子をお引越しさせてきました！ */
  .desktop-only {
    display: none;
  }
  
  /* ★ スマホ版のみ、スクロールボタンを上に逃がす（コマンド被り防止） */
  .scroll-nav {
    bottom: 170px !important; /* ★修正: 高さをさらに上げ、!important で上書きを絶対阻止 */
    right: 12px;
  }
} /* ← 既存のスマホ用クエリの閉じカッコ */

/* ローディングアニメーション（思考中... + 星の瞬き） */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(15, 18, 40, 0.8);
  border-radius: 12px;
  width: fit-content;
  margin-bottom: 8px;
  border: 1px solid rgba(159, 140, 255, 0.2);
}

.typing-label {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.8);
  margin-right: 4px;
}

.typing-dot {
  width: 6px;
  height: 6px;
  background: #ffb347;
  border-radius: 50%;
  animation: star-blink 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes star-blink {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); box-shadow: 0 0 0 transparent; }
  40% { opacity: 1; transform: scale(1.2); box-shadow: 0 0 8px #ffb347; }
}

/* --- 浮上・潜行（スクロール）ボタン --- */
.app-container {
  position: relative; /* ボタンを画面右下に固定するための基準 */
}

.scroll-nav {
  position: absolute;
  right: 16px;
  bottom: 110px; /* 入力エリアのすぐ上に配置 */
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 50;
}

.scroll-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(10, 15, 30, 0.4); /* 普段はかなり薄く存在を消す */
  border: 1px solid rgba(157, 130, 255, 0.2);
  color: rgba(255, 255, 255, 0.5);
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: all 0.3s ease;
  
  /* 初期状態は透明にしてクリック判定も消す */
  opacity: 0; 
  pointer-events: none; 
}

/* スクロール条件を満たした時だけフワッと表示 */
.scroll-btn.visible {
  opacity: 1;
  pointer-events: auto;
}

/* マウスを乗せた時のトキメキ演出 */
.scroll-btn:hover {
  background: rgba(40, 45, 80, 0.8);
  color: #fff;
  border-color: rgba(157, 130, 255, 0.8);
  box-shadow: 0 0 15px rgba(157, 130, 255, 0.4);
  transform: translateY(-2px);
}
/* =========================================
   🔑 ペイウォール（課金誘導）専用スタイル
========================================= */

/* 1. モーダルの外枠（ガラスパネル）の調整 */
#paywall-modal .modal-content {
  width: 100%;
  max-width: 520px;
  /* 画面の高さの90%を最大とし、はみ出させない */
  max-height: 90dvh; 
  background: radial-gradient(circle at top, #252a4c 0%, #0a0e1f 60%);
  border-radius: 18px;
  /* 内側の余白を少しスマートに */
  padding: 20px 0 10px; 
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.9);
  color: #f6f4ff;
  border-top: 4px solid #d8b4fe;
  
  /* 内部を縦並びのFlexboxにして制御 */
  display: flex;
  flex-direction: column;
  overflow: hidden; /* ガラスパネル自体はスクロールさせない */
}

/* 2. 固定タイトル */
#paywall-modal .modal-title {
  text-align: center; /* タイトルは真ん中が美しい */
  font-size: 1.3rem;
  margin: 0 20px 15px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* 3. 🌟 新設：中身だけスクロールする器 🌟 */
.modal-scroll-body {
  flex: 1; 
  overflow-y: auto; 
  padding: 0 25px; 
}

/* スクロールバーのデザイン（Webkit系） */
.modal-scroll-body::-webkit-scrollbar { 
  width: 6px; 
}
.modal-scroll-body::-webkit-scrollbar-thumb { 
  background: rgba(216, 180, 254, 0.3); 
  border-radius: 999px; 
}

/* 4. 文章の調整 */
.modal-desc {
  /* 💡 ご要望：文章を左寄せ */
  text-align: left; 
  font-size: 0.9rem;
  line-height: 1.7;
  opacity: 0.9;
  margin-bottom: 25px;
  /* カギ括弧などが右端に綺麗に揃うように調整 */
  word-break: break-all; 
}

/* 5. 💡 ご要望：ボタンや入力を真ん中寄せるための共通クラス */
.center-box {
  display: flex;
  flex-direction: column;
  align-items: center; /* 横方向の中央寄せ */
  justify-content: center;
  text-align: center;
  width: 100%;
}

/* 6. 購入ボタンの装飾 */
.paywall-action {
  margin: 25px 0;
}

.buy-license-btn {
  display: inline-block;
  background: linear-gradient(135deg, #a855f7 0%, #7e22ce 100%);
  color: #fff !important; /* 文字色は白を強制 */
  padding: 14px 28px;
  border-radius: 999px; /* 完全に丸く */
  text-decoration: none;
  font-weight: bold;
  font-size: 0.95rem;
  transition: all 0.3s ease;
  box-shadow: 0 6px 20px rgba(168, 85, 247, 0.5);
}

.buy-license-btn:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 8px 25px rgba(168, 85, 247, 0.7);
}

/* 7. 区切り線 */
.modal-divider {
  border: 0;
  height: 1px;
  background: linear-gradient(to right, transparent, rgba(255,255,255,0.1), transparent);
  margin: 25px 0;
  width: 100%;
}

/* 8. ライセンス入力エリア */
.license-input-area label {
  font-size: 0.8rem;
  opacity: 0.8;
  margin-bottom: 8px;
}

.license-input-area input {
  width: 100%;
  max-width: 350px; /* 入力欄が広がりすぎないように制限 */
  padding: 12px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  border-radius: 8px;
  text-align: center;
  font-family: monospace;
  font-size: 1rem;
  margin-bottom: 15px;
}

.license-input-area input:focus {
  outline: none;
  border-color: rgba(216, 180, 254, 0.6);
  background: rgba(0, 0, 0, 0.5);
}

.verify-btn {
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.85rem;
}

.verify-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.4);
}
/* エラーメッセージの調整（隙間・中央寄せ・色） */
#license-error-msg {
  margin-top: 16px;    /* ボタンとの間に約1行分のスペースを空ける */
  text-align: center;  /* テキストを中央寄せにする */
  width: 100%;
  color: #ff8b94;      /* 深海に馴染む、少し柔らかい警告の赤 */
  font-size: 0.85rem;
  font-weight: 500;
}
/* 修正後 */
/* ★ 追加：汎用カスタムアラート専用の強調スタイル */
#custom-alert-modal {
  z-index: 20000 !important; /* 書庫(10000番台)よりも確実に一番上に出す絶対命令 */
}

#custom-alert-modal .glass-panel {
  background: rgba(15, 20, 35, 0.95); /* 背景色を濃い深海色にして透け感をほぼ無くす */
  border: 1px solid rgba(150, 100, 255, 0.4); /* 怪しく光る紫のフチ取り（天王星/冥王星のイメージ） */
  box-shadow: 0 15px 50px rgba(0, 0, 0, 0.9), 0 0 20px rgba(150, 100, 255, 0.15); /* 漆黒の強い影と、微かな発光で画面から浮かせる */
  backdrop-filter: blur(12px); /* 後ろの要素を強めにぼかす */
  padding: 40px 30px; /* 余白を少し広げて窮屈さをなくす */
  max-width: 450px; /* 横幅が広がりすぎないようにスタイリッシュに調整 */
}

#custom-alert-modal .modal-title {
  color: #ffb7b2; /* 警告（⚠️）に合う、少し赤みがかった美しい色 */
  font-size: 1.4rem;
  margin-bottom: 20px;
}
/* --- メッセージ・アクション領域（コピーボタン用） --- */
.message-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 4px;
  opacity: 0; /* 普段は隠す */
  transition: opacity 0.2s ease;
}

/* 行にホバーした時、またはモバイルの場合は常に少し表示 */
.message-row:hover .message-actions,
.message-row:active .message-actions {
  opacity: 1;
}

.copy-btn {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.copy-btn:hover {
  color: rgba(255, 255, 255, 0.9);
  background: rgba(255, 255, 255, 0.1);
}

.copy-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}
/* --- 🔮 ホロスコープ画像モーダル専用スタイル（スマホ対応） --- */
#map-modal-content {
  max-width: 550px;
  /* ★ 追加：スマホ画面からはみ出さないよう高さを制限し、Flexboxで構成 */
  max-height: 90dvh; 
  display: flex;
  flex-direction: column;
  padding: 18px 18px 15px; /* 余白調整 */
}

/* ★ 追加：リスト部分だけがスクロールするようにする */
#map-scroll-area {
  flex-grow: 1;
  overflow-y: auto;
  padding-right: 4px; /* スクロールバー用の隙間 */
  margin-bottom: 10px; /* ボタンとの隙間 */
}

/* スクロールバーの装飾（天体指名モーダルと同じ） */
#map-scroll-area::-webkit-scrollbar {
  width: 4px;
}
#map-scroll-area::-webkit-scrollbar-thumb {
  background: rgba(157, 130, 255, 0.4);
  border-radius: 999px;
}

/* ★ アクションボタンのデザインブラッシュアップ */
.verify-btn.cancel-style {
  background: rgba(20, 25, 45, 0.6); /* 透明から、うっすら背景色を付けて視認性向上 */
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #ddd;
}
.verify-btn.cancel-style:hover {
  background: rgba(40, 45, 80, 0.9);
  border-color: rgba(255, 255, 255, 0.5);
  color: #fff;
}

.verify-btn.success-style {
  background: linear-gradient(135deg, #a855f7, #7e22ce);
  border: none;
  color: #fff;
  box-shadow: 0 4px 15px rgba(168, 85, 247, 0.4);
}
.verify-btn.success-style:hover {
  box-shadow: 0 0 20px rgba(168, 85, 247, 0.6);
  transform: translateY(-2px);
}

/* =========================================
   📖 魂の書庫（サイレント配達とカルーセル）
========================================= */

/* 淡い紫の呼吸（点滅）アニメーション */
@keyframes mystic-breathe {
  0% { box-shadow: 0 0 0px rgba(157, 130, 255, 0); border-color: rgba(150, 100, 255, 0.4); }
  50% { box-shadow: 0 0 15px rgba(157, 130, 255, 0.8); border-color: rgba(180, 150, 255, 0.8); background: rgba(50, 40, 90, 0.8); }
  100% { box-shadow: 0 0 0px rgba(157, 130, 255, 0); border-color: rgba(150, 100, 255, 0.4); }
}

.header-icon-btn.has-new-book {
  animation: mystic-breathe 3s infinite ease-in-out;
}

/* カルーセル（本棚）の構造 */
.library-carousel {
  display: flex;
  width: 100%;
  max-width: 400px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none;  /* IE and Edge */
  padding: 0 20px;
  gap: 20px;
}
.library-carousel::-webkit-scrollbar {
  display: none; /* Chrome, Safari */
}

/* 本（アイテム）のデザイン */
.book-item {
  flex: 0 0 100%;
  scroll-snap-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s ease;
}

/* 表紙の画像枠（文字なし） */
.book-cover {
  width: 240px;
  height: 360px; /* 約2:3の比率 */
  border-radius: 8px;
  background: #111;
  box-shadow: 0 15px 35px rgba(0,0,0,0.8), inset 0 0 0 1px rgba(255,255,255,0.1);
  overflow: hidden;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  
  /* ★ここから追加：スマホの長押しメニュー（選択・コールアウト）を無効化 */
  -webkit-touch-callout: none; 
  -webkit-user-select: none;   
  user-select: none;           
  /* ★ここまで追加 */
}

.book-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
  
  /* ★ここを追加：画像そのものを「触れない（長押し保存させない）」ようにする */
  pointer-events: none; 
}

/* 少しの遊び心（装丁の光沢感） */
.book-cover::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(to right, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0) 10%, rgba(255,255,255,0) 90%, rgba(0,0,0,0.4) 100%);
  pointer-events: none;
}

/* スワイプ位置のインジケーター */
.carousel-indicators {
  display: flex;
  gap: 8px;
  margin-top: 25px;
}

.indicator-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  transition: all 0.3s ease;
}

.indicator-dot.active {
  background: #d8b4fe;
  box-shadow: 0 0 8px rgba(216, 180, 254, 0.6);
  transform: scale(1.5);
}

/* =========================================
   🌊 限界水圧のエフェクト（溶けゆく最古の記憶）
========================================= */
.book-item.dissolving {
  opacity: 0.5;
  filter: blur(2px) grayscale(60%);
  animation: float-dissolve 4s infinite ease-in-out;
}

/* 海へ還りそうな儚い揺らぎアニメーション */
@keyframes float-dissolve {
  0%, 100% { transform: translateY(0) scale(0.95); opacity: 0.5; filter: blur(2px); }
  50% { transform: translateY(-8px) scale(0.95); opacity: 0.7; filter: blur(1px); }
}

/* 溶けかけの本を長押し（ホールド）した時は実体化して赤く警告 */
.book-item.dissolving .book-cover.pressing {
  opacity: 1 !important;
  filter: blur(0) grayscale(0) !important;
  box-shadow: 0 0 30px rgba(255, 100, 100, 0.6), inset 0 0 0 2px rgba(255, 100, 100, 0.8) !important;
  transform: scale(0.98);
}

/* =========================================
   💻 PC 表示専用ルール（すべてここに統合）
========================================= */
@media (min-width: 601px) {
  /* --- 📖 魂の書庫（本棚のレイアウト） --- */
  .library-carousel {
    max-width: 800px; /* 幅を広げて3冊入るようにする */
    overflow-x: visible;
    scroll-snap-type: none;
    justify-content: center;
    gap: 30px;
    padding: 0;
  }

  .book-item {
    flex: 0 0 auto; /* 1画面1冊の縛りを解除 */
  }

  .book-cover {
    width: 220px;
    height: 330px;
    transition: box-shadow 0.3s ease;
  }
  
  /* PC限定：ホバーした時のトキメキ演出と発光強化 */
  .book-item:hover {
    transform: translateY(-10px);
  }
  .book-item:hover .book-cover {
    box-shadow: 0 25px 50px rgba(0,0,0,0.9), inset 0 0 0 1px rgba(157, 130, 255, 0.4);
  }
  .book-item.is-filled:hover .book-cover {
    box-shadow: 0 25px 50px rgba(0,0,0,0.9),
                0 0 40px rgba(216, 180, 254, 0.4),
                inset 0 0 0 1px rgba(216, 180, 254, 0.8);
  }

  /* PCでは全て一覧できるためインジケーターは消す */
  .carousel-indicators {
    display: none; 
  }

  /* --- 🔭 魂の地図（ドラッグ移動可能なコックピットUI） --- */
  #map-modal.modal-overlay {
    background: transparent !important;
    pointer-events: none; /* 背景のクリック判定を消し、チャット可能に */
  }
  
  #map-modal-content {
    position: absolute;
    top: 70px;
    right: 20px;
    width: 340px;
    pointer-events: auto; /* パネル自体は操作可能 */
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(157, 130, 255, 0.5);
    cursor: grab;
  }
  
  #map-modal-content:active {
    cursor: grabbing;
  }
  
  #map-close-btn {
    padding: 10px;
    font-size: 0.9rem;
  }
}