/* =====================================
   テーマ変数定義
===================================== */

/* ライトモードのデフォルト変数 */
:root {
  /* フォント設定 */
  --font-family-base:
    ui-monospace, "SF Mono", "Cascadia Code", "Consolas", "Menlo", "Monaco",
    "Courier New", monospace;
  --font-weight-base: 450;

  /* 背景色 */
  --bg-primary: #ffffff;
  --bg-secondary: #f5f5f5;
  --bg-tertiary: #e8e8e8;
  --bg-input: #ffffff;
  --bg-message-user: #ff91c7;
  --bg-message-assistant: #f0f0f0;
  --bg-header: #f8f8f8;
  --bg-system-message: #e8f5e9;
  --bg-code-inline: #f6f8fa;
  --bg-code-block: #f6f8fa;
  --bg-blockquote: rgba(255, 145, 199, 0.05);
  --bg-table-header: #f0f0f0;
  --bg-table-row-even: rgba(0, 0, 0, 0.02);

  /* テキスト色 */
  --text-primary: #1a1a1a;
  --text-secondary: #666666;
  --text-tertiary: #999999;
  --text-message-user: #ffffff;
  --text-message-assistant: #1a1a1a;
  --text-system-message: #2e7d32;
  --text-code-inline: #d73a49;
  --text-heading: #1a1a1a;
  --text-link: #0366d6;
  --text-link-visited: #6f42c1;
  --text-strong: #000000;
  --text-blockquote: #666666;
  --text-del: #6a737d;

  /* ボーダー色 */
  --border-primary: #d0d0d0;
  --border-secondary: #e0e0e0;
  --border-message: #d0d0d0;
  --border-input: #c0c0c0;
  --border-input-focus: #ff91c7;
  --border-code: #e1e4e8;
  --border-table: #d0d7de;
  --border-blockquote: #ff91c7;

  /* アクセント色（共通） */
  --accent-blue: #ff91c7;
  --accent-blue-hover: #e07ab0;
  --accent-green: #4caf50;
  --accent-red: #e74c3c;
  --accent-red-hover: #c0392b;

  /* スクロールバー */
  --scrollbar-track: #f0f0f0;
  --scrollbar-thumb: #c0c0c0;
  --scrollbar-thumb-hover: #a0a0a0;

  /* プログレスバー */
  --progress-bg: #e0e0e0;
  --progress-fill: linear-gradient(90deg, #ff91c7, #4caf50);

  /* その他 */
  --shadow-color: rgba(0, 0, 0, 0.1);
  --overlay-bg: rgba(0, 0, 0, 0.05);
}

/* ダークモード変数 */
[data-theme="dark"] {
  /* 背景色 */
  --bg-primary: rgb(55, 55, 55);
  --bg-secondary: #3a3a3a;
  --bg-tertiary: #2a2a2a;
  --bg-input: #2a2a2a;
  --bg-message-user: #ff91c7;
  --bg-message-assistant: #3a3a3a;
  --bg-header: #3a3a3a;
  --bg-system-message: #2d5016;
  --bg-code-inline: #2a2a2a;
  --bg-code-block: #0d1117;
  --bg-blockquote: rgba(255, 145, 199, 0.05);
  --bg-table-header: #161b22;
  --bg-table-row-even: rgba(110, 118, 129, 0.05);

  /* テキスト色 */
  --text-primary: rgb(222, 222, 222);
  --text-secondary: #aaa;
  --text-tertiary: #888;
  --text-message-user: #ffffff;
  --text-message-assistant: #ddd;
  --text-system-message: #a5d6a7;
  --text-code-inline: #e06c75;
  --text-heading: #e0e0e0;
  --text-link: #58a6ff;
  --text-link-visited: #8e96f0;
  --text-strong: #fff;
  --text-blockquote: #aaa;
  --text-del: #888;

  /* ボーダー色 */
  --border-primary: #555;
  --border-secondary: #444;
  --border-message: #555;
  --border-input: #555;
  --border-input-focus: #ff91c7;
  --border-code: #30363d;
  --border-table: #30363d;
  --border-blockquote: #ff91c7;

  /* スクロールバー */
  --scrollbar-track: #2a2a2a;
  --scrollbar-thumb: #555;
  --scrollbar-thumb-hover: #666;

  /* プログレスバー */
  --progress-bg: #333;
  --progress-fill: linear-gradient(90deg, #ff91c7, #4caf50);

  /* その他 */
  --shadow-color: rgba(0, 0, 0, 0.3);
  --overlay-bg: rgba(255, 255, 255, 0.05);
}

/* 基本スタイル */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-family-base);
  font-weight: var(--font-weight-base);
  height: 100vh;
  height: 100dvh;
  height: calc(var(--vh, 1vh) * 100);
  overflow: hidden;
  transition:
    background-color 0.3s ease,
    color 0.3s ease;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.hidden {
  display: none !important;
}

/* =====================================
   タイトル画面
===================================== */
#title-screen {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  height: 100dvh;
  height: calc(var(--vh, 1vh) * 100);
  width: 100%;
}

.title-container {
  text-align: center;
  max-width: 600px;
  padding: 2em;
}

.app-title {
  font-size: 3em;
  margin-bottom: 0.3em;
  color: var(--accent-blue);
  font-weight: bold;
  letter-spacing: 2px;
}

.app-subtitle {
  font-size: 1.2em;
  margin-bottom: 1.2em;
  color: var(--text-secondary);
}

.ai-character {
  width: 180px;
  height: 180px;
  margin: 1.2em auto 1.2em auto;
  display: block;
}

.ai-features {
  font-size: 0.95em;
  line-height: 1.8;
  color: var(--text-primary);
  margin: 1em auto 1.5em auto;
  text-align: center;
  max-width: 400px;
  background: linear-gradient(
    135deg,
    rgba(255, 145, 199, 0.2),
    rgba(255, 145, 199, 0.12)
  );
  padding: 1.2em 1.5em;
  border-radius: 12px;
  border: 1px solid rgba(255, 145, 199, 0.4);
  box-shadow: 0 2px 8px rgba(255, 145, 199, 0.15);
}

.company-link {
  font-size: 0.9em;
  color: var(--text-secondary);
  margin: 0 auto 1.5em auto;
  text-align: center;
}

.company-link a {
  color: var(--accent-blue);
  text-decoration: none;
  font-weight: 600;
  margin-left: 0.3em;
  transition: all 0.3s ease;
  border-bottom: 2px solid transparent;
}

.company-link a:hover {
  color: var(--accent-blue-hover);
  border-bottom-color: var(--accent-blue-hover);
}

.btn-start {
  background-color: var(--accent-blue);
  color: white;
  border: none;
  padding: 0.8em 2.5em;
  font-size: 1.5em;
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.3s ease;
  margin-bottom: 0.5em;
  font-weight: 600;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
  letter-spacing: 0.3px;
}

.btn-start:hover:not(:disabled) {
  background-color: var(--accent-blue-hover);
  transform: scale(1.05);
}

.btn-start:disabled {
  background-color: #666;
  cursor: not-allowed;
  opacity: 0.6;
}

.model-info {
  font-size: 1em;
  color: var(--text-secondary);
  margin-bottom: 1em;
}

/* ローディング表示 */
.loading-container {
  margin-top: 0.5em;
}

.loading-text {
  font-size: 1.2em;
  color: var(--accent-green);
  margin-bottom: 1em;
}

.progress-bar {
  width: 100%;
  height: 30px;
  background-color: var(--progress-bg);
  border-radius: 15px;
  overflow: hidden;
  margin-bottom: 0.5em;
}

.progress-fill {
  height: 100%;
  background: var(--progress-fill);
  width: 0%;
  transition: width 0.3s ease;
}

.loading-details {
  font-size: 0.9em;
  color: var(--text-secondary);
}

/* =====================================
   チャット画面
===================================== */
#chat-screen {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  height: calc(var(--vh, 1vh) * 100);
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  border-left: 1px solid var(--border-primary);
  border-right: 1px solid var(--border-primary);
}

/* ヘッダー */
.chat-header {
  background-color: var(--bg-header);
  padding: 1em 1.5em;
  border-bottom: 2px solid var(--accent-blue);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
  transition: background-color 0.3s ease;
}

.chat-header-left {
  display: flex;
  flex-direction: column;
  gap: 0.3em;
}

.chat-title {
  font-size: 1.5em;
  color: var(--accent-blue);
  margin: 0;
  letter-spacing: 2px;
  font-weight: bold;
}

.chat-model-info {
  font-size: 0.9em;
  color: var(--text-secondary);
}

/* ヘッダーボタン群 */
.chat-header > div:last-child {
  display: flex;
  gap: 0.8em;
  align-items: center;
}

.btn-theme-toggle {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-primary);
  padding: 0.6em 1em;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1.2em;
  transition: all 0.3s ease;
  white-space: nowrap;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 50px;
}

.btn-theme-toggle:hover {
  background-color: var(--bg-secondary);
  transform: scale(1.05);
}

.theme-icon {
  display: block;
  line-height: 1;
}

.btn-clear {
  background-color: var(--accent-red);
  color: white;
  border: none;
  padding: 0.6em 1.2em;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9em;
  transition: all 0.3s ease;
  white-space: nowrap;
  font-weight: 600;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
  letter-spacing: 0.3px;
}

.btn-clear:hover:not(:disabled) {
  background-color: var(--accent-red-hover);
}

.btn-clear:disabled {
  background-color: #666;
  cursor: not-allowed;
  opacity: 0.5;
}

.btn-save {
  background-color: var(--accent-green);
  color: white;
  border: none;
  padding: 0.6em 1.2em;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9em;
  transition: all 0.3s ease;
  white-space: nowrap;
  font-weight: 600;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
  letter-spacing: 0.3px;
}

.btn-save:hover:not(:disabled) {
  background-color: #45a049;
}

.btn-save:disabled {
  background-color: #666;
  cursor: not-allowed;
  opacity: 0.5;
}

/* チャット履歴エリア */
.chat-history {
  flex: 1;
  overflow-y: auto;
  padding: 1.5em;
  display: flex;
  flex-direction: column;
  gap: 1em;
  position: relative; /* absolute の基準にする */
}

/* スクロールバーのスタイル */
.chat-history::-webkit-scrollbar {
  width: 8px;
}

.chat-history::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
}

.chat-history::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 4px;
}

.chat-history::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
}

/* メッセージバブル */
.message {
  max-width: 70%;
  padding: 0.8em 1.2em;
  border-radius: 12px;
  word-wrap: break-word;
  line-height: 1.5;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message.user {
  align-self: flex-end;
  background-color: var(--bg-message-user);
  color: var(--text-message-user);
  margin-left: auto;
  white-space: pre-wrap;
}

.message.assistant {
  align-self: flex-start;
  background-color: var(--bg-message-assistant);
  color: var(--text-message-assistant);
  border: 1px solid var(--border-message);
  transition:
    background-color 0.3s ease,
    border-color 0.3s ease;
}

.system-message {
  align-self: center;
  background-color: var(--bg-system-message);
  color: var(--text-system-message);
  padding: 0.6em 1em;
  border-radius: 8px;
  font-size: 0.9em;
  text-align: center;
  max-width: 80%;
  transition:
    background-color 0.3s ease,
    color 0.3s ease;
}

.message.generating {
  opacity: 0.8;
}

/* タイピングインジケーター */
.typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  margin-left: 0.2em;
}

.typing-indicator .dot {
  width: 0.35em;
  height: 0.35em;
  background-color: var(--text-secondary);
  border-radius: 50%;
  animation: typing-dot 1.4s infinite;
}

.typing-indicator .dot:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-indicator .dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing-dot {
  0%,
  60%,
  100% {
    opacity: 0.3;
    transform: scale(0.8);
  }
  30% {
    opacity: 1;
    transform: scale(1.2);
  }
}

/* 入力エリア */
.chat-input-container {
  background-color: var(--bg-header);
  padding: 1em 1.5em;
  border-top: 1px solid var(--border-primary);
  flex-shrink: 0;
  transition: background-color 0.3s ease;
}

.input-area {
  display: flex;
  gap: 0.8em;
}

.message-input {
  flex: 1;
  background-color: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-input);
  padding: 0.8em 1em;
  border-radius: 8px;
  font-size: 1em;
  transition:
    border-color 0.3s ease,
    background-color 0.3s ease,
    color 0.3s ease;

  /* textarea用のスタイル */
  font-family: inherit;
  resize: none;
  min-height: 2.8em;
  max-height: 8em;
  line-height: 1.4;
  overflow-y: auto;
}

.message-input:focus {
  outline: none;
  border-color: var(--border-input-focus);
}

.message-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-send {
  background-color: var(--accent-blue);
  color: white;
  border: none;
  padding: 0.8em 2em;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1em;
  transition: all 0.3s ease;
  font-weight: 600;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
  letter-spacing: 0.3px;
}

.btn-send:hover:not(:disabled) {
  background-color: var(--accent-blue-hover);
}

.btn-send:disabled {
  background-color: #666;
  cursor: not-allowed;
  opacity: 0.5;
}

.btn-stop {
  background-color: #f44336;
  color: white;
  border: none;
  padding: 0.8em 2em;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1em;
  transition: all 0.3s ease;
  font-weight: 600;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
  letter-spacing: 0.3px;
}

.btn-stop:hover {
  background-color: #d32f2f;
}

.btn-stop:active {
  background-color: #b71c1c;
  transform: scale(0.98);
}

/* レスポンシブデザイン */
@media (max-width: 768px) {
  .title-container {
    padding: 1.5em 1em;
  }

  .app-title {
    font-size: 2em;
  }

  .ai-character {
    width: 140px;
    height: 140px;
    margin: 1em auto 1em auto;
  }

  .ai-features {
    font-size: 0.85em;
    line-height: 1.7;
    margin: 0.8em auto 1.2em auto;
    max-width: 100%;
    padding: 1em 1.2em;
  }

  .company-link {
    font-size: 0.85em;
    margin: 0 auto 1.2em auto;
  }

  .btn-start {
    padding: 0.8em 2em;
    font-size: 1.2em;
  }

  .message {
    max-width: 85%;
  }

  .chat-header {
    flex-direction: row;
    align-items: center;
    gap: 0.5em;
    padding: 0.8em 1em;
  }

  .chat-header-left {
    flex-shrink: 0;
  }

  .chat-title {
    font-size: 1.1em;
    letter-spacing: 1px;
  }

  .chat-header > div:last-child {
    display: flex;
    gap: 0.4em;
    margin-left: auto;
    flex-shrink: 0;
  }

  .btn-theme-toggle {
    padding: 0.5em 0.7em;
    min-width: 42px;
  }

  .btn-save {
    padding: 0.5em 0.7em;
    font-size: 0.8em;
  }

  .btn-clear {
    padding: 0.5em 0.7em;
    font-size: 0.8em;
  }

  .input-area {
    flex-direction: column;
  }

  .btn-send,
  .btn-stop {
    width: 100%;
  }
}

/* =====================================
   Markdownレンダリング用スタイル
===================================== */

/* AIメッセージ内のMarkdown要素 */
.message.assistant h1,
.message.assistant h2,
.message.assistant h3,
.message.assistant h4,
.message.assistant h5,
.message.assistant h6 {
  margin: 0.8em 0 0.4em 0;
  color: var(--text-heading);
  font-weight: bold;
  line-height: 1.3;
}

.message.assistant h1 {
  font-size: 1.5em;
  border-bottom: 1px solid var(--border-secondary);
  padding-bottom: 0.3em;
}

.message.assistant h2 {
  font-size: 1.3em;
  border-bottom: 1px solid var(--border-secondary);
  padding-bottom: 0.3em;
}

.message.assistant h3 {
  font-size: 1.1em;
}
.message.assistant h4 {
  font-size: 1em;
}
.message.assistant h5 {
  font-size: 0.9em;
}
.message.assistant h6 {
  font-size: 0.85em;
  color: var(--text-secondary);
}

/* 段落 */
.message.assistant p {
  margin: 0.6em 0;
  line-height: 1.6;
}

/* リスト */
.message.assistant ul,
.message.assistant ol {
  margin: 0.5em 0;
  padding-left: 1.8em;
}

.message.assistant li {
  margin: 0.3em 0;
  line-height: 1.5;
}

.message.assistant ul ul,
.message.assistant ol ul,
.message.assistant ul ol,
.message.assistant ol ol {
  margin: 0.2em 0;
}

/* 引用 */
.message.assistant blockquote {
  border-left: 4px solid var(--border-blockquote);
  padding-left: 1em;
  margin: 0.8em 0;
  color: var(--text-blockquote);
  font-style: italic;
  background-color: var(--bg-blockquote);
  padding: 0.5em 1em;
  border-radius: 0 4px 4px 0;
}

.message.assistant blockquote p {
  margin: 0.3em 0;
}

/* インラインコード */
.message.assistant code {
  background-color: var(--bg-code-inline);
  color: var(--text-code-inline);
  padding: 0.2em 0.4em;
  border-radius: 3px;
  font-size: 1.25em;
  border: 1px solid var(--border-code);
  transition:
    background-color 0.3s ease,
    border-color 0.3s ease;
}

/* コードブロック */
.message.assistant pre {
  background-color: var(--bg-code-block);
  border: 1px solid var(--border-code);
  border-radius: 6px;
  padding: 1em;
  margin: 0.8em 0;
  overflow-x: auto;
  position: relative;
  transition:
    background-color 0.3s ease,
    border-color 0.3s ease;
}

.message.assistant pre code {
  background-color: transparent;
  color: inherit;
  padding: 0;
  border-radius: 0;
  font-size: 1.2em;
  line-height: 1.5;
  border: none;
  display: block;
}

/* コードブロックのスクロールバー */
.message.assistant pre::-webkit-scrollbar {
  height: 8px;
}

.message.assistant pre::-webkit-scrollbar-track {
  background: var(--bg-code-block);
  border-radius: 4px;
}

.message.assistant pre::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 4px;
}

.message.assistant pre::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
}

/* 水平線 */
.message.assistant hr {
  border: none;
  border-top: 2px solid var(--border-code);
  margin: 1.2em 0;
}

/* テーブル */
.message.assistant table {
  border-collapse: collapse;
  width: 100%;
  margin: 0.8em 0;
  font-size: 0.9em;
}

.message.assistant th,
.message.assistant td {
  border: 1px solid var(--border-table);
  padding: 0.5em 0.8em;
  text-align: left;
}

.message.assistant th {
  background-color: var(--bg-table-header);
  font-weight: bold;
  color: var(--text-heading);
}

.message.assistant tr:nth-child(even) {
  background-color: var(--bg-table-row-even);
}

/* リンク */
.message.assistant a {
  color: var(--text-link);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease;
}

.message.assistant a:hover {
  border-bottom-color: var(--text-link);
}

.message.assistant a:visited {
  color: var(--text-link-visited);
}

/* 太字・斜体 */
.message.assistant strong {
  font-weight: bold;
  color: var(--text-strong);
}

.message.assistant em {
  font-style: italic;
  color: var(--text-heading);
}

/* チェックボックスリスト（タスクリスト） */
.message.assistant input[type="checkbox"] {
  margin-right: 0.5em;
}

/* 削除線 */
.message.assistant del {
  text-decoration: line-through;
  color: var(--text-del);
}

/* 画像 */
.message.assistant img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  margin: 0.5em 0;
}

/* 最初と最後の要素のマージン調整 */
.message.assistant > *:first-child {
  margin-top: 0;
}

.message.assistant > *:last-child {
  margin-bottom: 0;
}

/* =====================================
   進捗表示（トークン生成）
===================================== */

/* 進捗表示コンテナ */
.generation-progress {
  margin-top: 0.8em;
  padding-top: 0.8em;
  border-top: 1px solid var(--overlay-bg);
}

/* プロンプト処理中のスタイル */
.generation-progress.prompt-processing .progress-bar-container {
  display: none; /* プログレスバーは非表示 */
}

.generation-progress.prompt-processing .progress-text {
  text-align: center;
  font-size: 1em;
  color: var(--accent-blue);
  font-weight: normal;
  line-height: 1.6; /* 2行表示のための行間調整 */
}

/* =====================================
   ミニゲームコンテナ（思考中表示）
===================================== */

/* ミニゲームコンテナ - 基本スタイル */
.mini-game-container {
  display: none; /* デフォルトは非表示 */
  width: 220px;
  height: 220px;
  margin: 0 auto 1em auto; /* 中央配置、下にマージン */
  border: 2px dashed var(--border-color);
  border-radius: 12px;
  background-color: var(--bg-secondary);
  position: relative;
  overflow: hidden;
}

/* プロンプト処理中のみゲームコンテナを表示 */
.generation-progress.prompt-processing .mini-game-container {
  display: block;
}

/* スコア表示 */
.game-score {
  position: absolute;
  top: 4px;
  right: 8px;
  font-size: 14px;
  font-weight: bold;
  color: #555;
  z-index: 5;
  user-select: none;
  pointer-events: none;
}

[data-theme="dark"] .game-score {
  color: #ccc;
}

/* ハイスコア表示 */
.game-high-score {
  position: absolute;
  bottom: 4px;
  right: 6px;
  font-size: 10px;
  font-weight: normal;
  color: #999;
  z-index: 5;
  user-select: none;
  pointer-events: none;
  opacity: 0.7;
}

[data-theme="dark"] .game-high-score {
  color: #777;
}

/* レベル表示 */
.game-level {
  position: absolute;
  top: 4px;
  left: 8px;
  font-size: 14px;
  font-weight: bold;
  color: #ff6b9d;
  z-index: 5;
  user-select: none;
  pointer-events: none;
}

[data-theme="dark"] .game-level {
  color: #ff91c7;
}

/* Castle（防御壁）画像 */
.game-castle-image {
  z-index: 3;
  pointer-events: none;
}

/* Crab（カニ防御）画像 */
.game-crab-image {
  z-index: 3;
  pointer-events: none;
}

/* Dino（恐竜防御）画像 */
.game-dino-image {
  z-index: 3;
  pointer-events: none;
}

/* カウントダウンオーバーレイ */
.game-countdown-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10;
  pointer-events: none;
}

/* ゲームタイトル */
.game-title {
  font-size: 22px;
  font-weight: 900;
  color: #e91e63;
  margin-bottom: 8px;
  letter-spacing: 2px;
  user-select: none;
  text-shadow: 0 2px 4px rgba(233, 30, 99, 0.4);
  animation: titleAppear 0.5s ease-out, titlePulse 2s ease-in-out 0.5s infinite;
}

[data-theme="dark"] .game-title {
  color: #ff4081;
  text-shadow: 0 2px 6px rgba(255, 64, 129, 0.5);
}

/* タイトル登場アニメーション */
@keyframes titleAppear {
  0% {
    opacity: 0;
    transform: scale(0.8);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/* タイトル脈動アニメーション */
@keyframes titlePulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

/* カウントダウンテキストコンテナ */
.countdown-text-container {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* カウントダウンテキスト（数字） */
.countdown-text {
  font-size: 48px;
  font-weight: bold;
  color: #ff6b9d;
  animation: countdownPop 0.65s ease-out forwards;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  user-select: none;
}

/* Start!/Restart! のスタイル */
.countdown-text.countdown-go {
  font-size: 28px;
  color: #4caf50;
}

/* Game Over のスタイル */
.countdown-text.countdown-gameover {
  font-size: 28px;
  color: #f44336;
  animation: gameOverAppear 0.5s ease-out forwards;
}

/* Game Over アニメーション */
@keyframes gameOverAppear {
  0% {
    transform: scale(0.5);
    opacity: 0;
  }
  60% {
    transform: scale(1.1);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* カウントダウンアニメーション */
@keyframes countdownPop {
  0% {
    transform: scale(0.3);
    opacity: 0;
  }
  40% {
    transform: scale(1.15);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 0.7;
  }
}

/* プログレスバーコンテナ */
.progress-bar-container {
  display: none !important; /* 常に非表示 */
}

/* プログレスバー本体 */
.progress-bar-fill {
  height: 100%;
  background: var(--progress-fill);
  border-radius: 3px;
  transition: width 0.2s ease-out;
  box-shadow: 0 0 10px rgba(255, 145, 199, 0.5);
}

/* 進捗テキスト */
.progress-text {
  font-size: 0.9em;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
  text-align: left; /* デフォルトは左揃え */
}

/* 生成完了後のスタイル */
.generation-progress.completed {
  margin-top: 0.5em;
  padding-top: 0.5em;
  border-top: 1px solid var(--overlay-bg);
}

.generation-progress.completed .progress-text {
  font-size: 0.8em;
  color: var(--text-tertiary);
  text-align: right; /* 右揃え */
  font-weight: normal;
}

/* アニメーション: プログレスバーの光沢効果 */
@keyframes progress-shimmer {
  0% {
    background-position: -200% center;
  }
  100% {
    background-position: 200% center;
  }
}

.progress-bar-fill.active {
  background: linear-gradient(
    90deg,
    #ff91c7 0%,
    #ffb3db 25%,
    #ff91c7 50%,
    #ffb3db 75%,
    #ff91c7 100%
  );
  background-size: 200% 100%;
  animation: progress-shimmer 2s linear infinite;
}

/* =====================================
   モーダルウィンドウ
===================================== */

/* モーダルコンテナ */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: center;
  animation: fadeIn 0.2s ease;
}

/* 背景オーバーレイ */
.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
}

/* モーダルコンテンツ */
.modal-content {
  position: relative;
  background-color: var(--bg-primary);
  border: 2px solid var(--accent-blue);
  border-radius: 12px;
  padding: 2em;
  max-width: 500px;
  width: 90%;
  box-shadow: 0 4px 20px var(--shadow-color);
  animation: slideIn 0.3s ease;
  z-index: 1001;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* モーダルタイトル */
.modal-title {
  font-size: 1.4em;
  color: var(--accent-blue);
  margin-bottom: 0.8em;
  text-align: center;
}

/* モーダルメッセージ */
.modal-message {
  font-size: 1em;
  color: var(--text-primary);
  margin-bottom: 1.5em;
  text-align: center;
  line-height: 1.5;
}

/* ボタンコンテナ */
.modal-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.8em;
}

/* モーダルボタン共通スタイル */
.modal-btn {
  padding: 0.8em 1.5em;
  border: none;
  border-radius: 8px;
  font-size: 1em;
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: 600;
  letter-spacing: 0.3px;
}

/* プライマリボタン（保存してクリア） */
.modal-btn-primary {
  background-color: var(--accent-blue);
  color: white;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

.modal-btn-primary:hover {
  background-color: var(--accent-blue-hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(255, 145, 199, 0.3);
}

/* セカンダリボタン（保存せずにクリア） */
.modal-btn-secondary {
  background-color: var(--accent-red);
  color: white;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

.modal-btn-secondary:hover {
  background-color: var(--accent-red-hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(231, 76, 60, 0.3);
}

/* キャンセルボタン */
.modal-btn-cancel {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-primary);
}

.modal-btn-cancel:hover {
  background-color: var(--bg-secondary);
  transform: translateY(-2px);
}

/* レスポンシブ対応 */
@media (min-width: 500px) {
  .modal-buttons {
    flex-direction: row;
  }

  .modal-btn {
    flex: 1;
  }
}

/* =====================================
   プロンプト例
===================================== */

.prompt-examples {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1em;
  margin: 2em auto;
  max-width: 90%;
  animation: fadeIn 0.5s ease;
}

.prompt-examples-title {
  font-size: 1em;
  color: var(--text-secondary);
  text-align: center;
  font-weight: 500;
}

.prompt-examples-buttons {
  display: flex;
  gap: 1em;
  flex-wrap: wrap;
  justify-content: center;
  width: 100%;
}

.prompt-example-btn {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  border: 2px solid var(--accent-blue);
  padding: 0.8em 1.5em;
  border-radius: 12px;
  cursor: pointer;
  font-size: 0.95em;
  transition: all 0.3s ease;
  white-space: nowrap;
  box-shadow: 0 2px 8px var(--shadow-color);
  font-weight: 500;
  min-width: 200px;
  text-align: center;
}

.prompt-example-btn:hover {
  background-color: var(--accent-blue);
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(255, 145, 199, 0.4);
  font-weight: 600;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
  letter-spacing: 0.3px;
}

.prompt-example-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(255, 145, 199, 0.3);
}

/* レスポンシブ対応：モバイル */
@media (max-width: 768px) {
  .prompt-examples-buttons {
    flex-direction: column;
    align-items: stretch;
  }

  .prompt-example-btn {
    width: 100%;
    min-width: auto;
  }
}

/* =====================================
   AIキャラクター画像（画面固定表示）
===================================== */

/* デフォルト：中央配置（初期状態） */
.ai-character-fixed {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 280px;
  width: 150px;
  height: 150px;
  z-index: 100;
  pointer-events: none;
  transition: all 0.3s ease;
}

/* メッセージ送信後：最新のAIメッセージに追従 */
.ai-character-fixed.positioned {
  /* JavaScriptで動的に top, left を設定 */
  top: auto;
  bottom: 0;
  left: 0;
  transform: none;
  width: 120px;
  height: 120px;
}

/* モバイル対応 */
@media (max-width: 768px) {
  .ai-character-fixed {
    width: 100px;
    height: 100px;
    bottom: 150px;
  }

  .ai-character-fixed.positioned {
    width: 64px;
    height: 64px;
  }
}

/* タブレット対応 */
@media (min-width: 769px) and (max-width: 1023px) {
  .ai-character-fixed {
    width: 130px;
    height: 130px;
    bottom: 300px;
  }

  .ai-character-fixed.positioned {
    width: 96px;
    height: 96px;
  }
}

/* フェードインアニメーション */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* =====================================
   ゲーム選択オーバーレイ
===================================== */

/* 選択オーバーレイ */
.game-selection-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 20;
  animation: fadeIn 0.3s ease;
  padding: 10px;
  box-sizing: border-box;
}

/* 選択タイトル */
.game-selection-title {
  font-size: 20px;
  font-weight: 900;
  color: #ffeb3b;
  margin-bottom: 4px;
  text-shadow: 0 2px 4px rgba(255, 235, 59, 0.5);
  animation: titlePulse 1.5s ease-in-out infinite;
}

/* 選択サブタイトル */
.game-selection-subtitle {
  font-size: 12px;
  color: #fff;
  margin-bottom: 12px;
  opacity: 0.9;
}

/* 選択ボタンコンテナ */
.game-selection-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 100%;
}

/* 選択ボタン（防御選択用） */
.game-selection-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #4a4a4a, #2a2a2a);
  border: 2px solid #ff91c7;
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 55px;
  box-shadow: 0 2px 8px rgba(255, 145, 199, 0.3);
}

.game-selection-btn:hover {
  transform: scale(1.05);
  border-color: #ffeb3b;
  box-shadow: 0 4px 12px rgba(255, 235, 59, 0.4);
}

.game-selection-btn:active {
  transform: scale(0.98);
}

/* 選択ボタンの絵文字 */
.selection-emoji {
  font-size: 24px;
  line-height: 1;
  margin-bottom: 2px;
}

/* 選択ボタンの名前 */
.selection-name {
  font-size: 10px;
  color: #fff;
  font-weight: 600;
}

/* 成長選択ボタン */
.game-growth-btn {
  min-width: 60px;
  padding: 6px 8px;
}

.game-growth-btn .selection-emoji {
  font-size: 18px;
}

.game-growth-btn .selection-name {
  font-size: 9px;
  margin-bottom: 2px;
}

/* 成長値表示 */
.selection-value {
  font-size: 8px;
  color: #4caf50;
  font-weight: 500;
}

/* 成長レベル表示 */
.selection-level {
  font-size: 7px;
  color: #aaa;
  margin-top: 1px;
}

/* 無効化されたボタン */
.game-selection-btn.disabled {
  opacity: 0.4;
  cursor: not-allowed;
  border-color: #555;
  box-shadow: none;
}

.game-selection-btn.disabled:hover {
  transform: none;
  border-color: #555;
  box-shadow: none;
}

.game-selection-btn.disabled .selection-value {
  color: #888;
}
