:root {
  --bg:         #f4f3ff;
  --surface:    #ffffff;
  --surface2:   #ede9ff;
  --accent:     #cc3333;
  --accent2:    #b88a00;
  --text:       #1e1840;
  --text-muted: #6a67a0;
  --border:     #d8d5f5;
  --success:    #2d7d32;
  --radius: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Hiragino Sans', 'Noto Sans JP', 'Yu Gothic', sans-serif;
  min-height: 100vh;
  line-height: 1.6;
}

/* Navbar */
.navbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 4px rgba(30,24,64,.06);
}
.logo { font-size: 1.2rem; font-weight: bold; text-decoration: none; color: var(--text); }
.nav-links { display: flex; align-items: center; gap: 14px; }
.nav-links a { color: var(--text-muted); text-decoration: none; font-size: 0.9rem; transition: color .15s; }
.nav-links a:hover { color: var(--text); }
#nav-user { font-size: 0.85rem; font-weight: bold; }

/* Hamburger toggle (mobile only) */
.nav-toggle {
  display: none;
  flex-direction: column; justify-content: center; gap: 5px;
  width: 40px; height: 40px; padding: 9px 8px;
  background: none; border: none; cursor: pointer;
}
.nav-toggle span { display: block; width: 100%; height: 2px; background: var(--text); border-radius: 2px; transition: transform .2s, opacity .2s; }
.nav-toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle.open span:nth-child(2) { opacity: 0; }
.nav-toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Buttons */
.btn {
  padding: 9px 18px; border: none; border-radius: 8px; cursor: pointer;
  font-size: 0.9rem; font-weight: bold; font-family: inherit;
  transition: opacity .15s, transform .1s; display: inline-flex; align-items: center; gap: 6px;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.btn-primary { background: #1e1840; color: #fff; }
.btn-primary:hover:not(:disabled) { background: #2d2a60; }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { border-color: #1e1840; }

.btn-vote {
  background: var(--surface2); color: var(--text-muted); border: 1px solid var(--border);
  padding: 5px 14px; font-size: 0.8rem; border-radius: 20px;
  cursor: pointer; font-family: inherit; font-weight: bold; transition: all .15s;
}
.btn-vote:hover:not(:disabled) { border-color: var(--accent2); color: var(--accent2); }
.btn-vote.voted { background: #fff8e0; border-color: var(--accent2); color: var(--accent2); }
.btn-vote:disabled { opacity: 0.35; cursor: not-allowed; }

/* 自分の回答を削除するボタン */
.btn-del-answer {
  background: none; border: 1px solid var(--border); color: var(--text-muted);
  padding: 4px 10px; font-size: 0.72rem; border-radius: 20px; white-space: nowrap;
  cursor: pointer; font-family: inherit; font-weight: bold; transition: all .15s;
}
.btn-del-answer:hover { border-color: var(--accent); color: var(--accent); background: #fff0f0; }

.btn-logout {
  background: transparent; color: var(--text-muted); border: 1px solid var(--border);
  padding: 4px 10px; font-size: 0.8rem; border-radius: 6px; cursor: pointer; font-family: inherit;
}
.btn-logout:hover { color: var(--text); border-color: var(--text-muted); }

/* Layout */
.container { max-width: 820px; margin: 0 auto; padding: 28px 16px; }
.section-title { font-size: 1.2rem; font-weight: bold; margin-bottom: 18px; display: flex; align-items: center; gap: 8px; }

/* Round card */
.round-card { background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border); margin-bottom: 28px; overflow: hidden; box-shadow: 0 2px 8px rgba(30,24,64,.06); }
.round-header { padding: 16px 20px; background: var(--surface2); border-bottom: 1px solid var(--border); display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.round-theme { font-size: 1.15rem; font-weight: bold; line-height: 1.45; flex: 1; }
.round-meta { font-size: 0.77rem; color: var(--text-muted); margin-top: 4px; }
.badge { padding: 4px 10px; border-radius: 20px; font-size: 0.72rem; font-weight: bold; white-space: nowrap; flex-shrink: 0; margin-top: 3px; }
.badge-both      { background: #fff8e0; color: #b88a00; }
.badge-finished  { background: #ede9ff; color: #6a67a0; }
.round-body { padding: 16px 20px; }

/* Answers */
.answers-list { list-style: none; margin-bottom: 12px; }
.answer-item { display: flex; align-items: flex-start; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.answer-item:last-child { border-bottom: none; }
.answer-item.voted { background: #fff8e0; border-radius: 8px; padding: 12px 10px; }
.answer-content { flex: 1; min-width: 0; }
.answer-author { font-size: 0.77rem; color: var(--text-muted); margin-bottom: 5px; display: flex; align-items: center; gap: 5px; }
/* 過去バトルでAI回答を明示（少し強調） */
.ai-name { display: inline-flex; align-items: center; gap: 3px; background: #3949ab; color: #fff; padding: 2px 9px; border-radius: 6px; font-size: 0.8rem; font-weight: 800; letter-spacing: 0.04em; }
.answer-text { font-size: 1rem; word-break: break-all; }
.answer-image { max-width: 140px; max-height: 140px; border-radius: 8px; object-fit: cover; margin-top: 6px; display: block; }
.vote-col { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 58px; }
.vote-count { font-size: 0.77rem; color: var(--text-muted); }
.answer-count-hint { color: var(--text-muted); font-size: 0.88rem; padding: 10px 0; text-align: center; }

/* Answer form */
.answer-form-wrap { margin-top: 16px; border-top: 1px dashed var(--border); padding-top: 16px; }
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 0.82rem; color: var(--text-muted); margin-bottom: 5px; }
.form-input, .form-textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 13px; color: var(--text); font-size: 0.95rem; font-family: inherit; outline: none; transition: border-color .15s;
}
.form-input:focus, .form-textarea:focus { border-color: #1e1840; }
.form-textarea { resize: vertical; min-height: 72px; }
.file-label {
  display: inline-block; padding: 8px 14px; background: var(--surface2);
  border: 1px dashed var(--border); border-radius: 8px; cursor: pointer;
  font-size: 0.85rem; color: var(--text-muted); transition: border-color .15s;
}
.file-label:hover { border-color: #1e1840; color: var(--text); }
input[type="file"] { display: none; }
/* 選択した画像のプレビュー。枠と「✓ 選択中」表示で、確かに添付できたと分かるようにする */
.image-preview {
  max-width: 180px; max-height: 180px; border-radius: 8px; margin-top: 8px;
  display: none; border: 2px solid var(--success); padding: 3px; background: var(--surface);
}
.image-picked {
  display: none; align-items: center; gap: 6px; margin-top: 6px;
  font-size: 0.78rem; font-weight: bold; color: var(--success);
}
.image-picked .picked-name {
  color: var(--text-muted); font-weight: normal;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 190px;
}
.btn-clear-img { background: none; border: 1px solid var(--accent); color: var(--accent); border-radius: 6px; padding: 4px 10px; font-size: 0.8rem; cursor: pointer; margin-top: 6px; }
.btn-clear-img:hover { background: var(--accent); color: #fff; }
.theme-image { max-width: 100%; max-height: 190px; border-radius: 8px; margin: 10px 0; display: block; object-fit: contain; }

/* Alerts */
.alert { padding: 11px 15px; border-radius: 8px; margin-bottom: 14px; font-size: 0.88rem; }
.alert-error   { background: #fff0f0; color: #c62828; border: 1px solid #ffcdd2; }
.alert-success { background: #f1f8e9; color: #2e7d32; border: 1px solid #c8e6c9; }

/* Toast (transient notifications — replaces native alert()) */
.toast-container {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  z-index: 1000; display: flex; flex-direction: column; gap: 10px;
  width: max-content; max-width: calc(100vw - 32px); pointer-events: none;
}
.toast {
  margin: 0; box-shadow: 0 4px 16px rgba(30,24,64,.18);
  opacity: 0; transform: translateY(12px);
  transition: opacity .2s ease, transform .2s ease; pointer-events: auto;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* Empty state */
.empty-state { text-align: center; padding: 52px 20px; color: var(--text-muted); }
.empty-state .emoji { font-size: 2.8rem; margin-bottom: 14px; }
.empty-state h3 { color: var(--text); margin-bottom: 8px; }

/* Auth */
.auth-container { max-width: 420px; margin: 60px auto; padding: 0 16px; }
.auth-card { background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border); padding: 32px; box-shadow: 0 2px 12px rgba(30,24,64,.08); }
.auth-title { font-size: 1.4rem; font-weight: bold; margin-bottom: 24px; text-align: center; }
.auth-footer { text-align: center; margin-top: 18px; font-size: 0.84rem; color: var(--text-muted); }
.auth-footer a { color: #1e1840; text-decoration: none; font-weight: bold; }

/* Best page */
.best-round-card { background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border); margin-bottom: 28px; overflow: hidden; box-shadow: 0 2px 8px rgba(30,24,64,.06); }
.best-round-header { padding: 14px 20px; background: var(--surface2); border-bottom: 1px solid var(--border); border-left: 3px solid #e6b800; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.best-theme { font-size: 1.05rem; font-weight: bold; flex: 1; }
.best-date { font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; }
.best-body { padding: 14px 20px; }
.rank-item { display: flex; align-items: flex-start; gap: 14px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.rank-item:last-child { border-bottom: none; }
.rank-num { font-size: 1.3rem; font-weight: bold; min-width: 30px; text-align: center; padding-top: 2px; }
.rank-1 { color: #c9a000; }
.rank-2 { color: #7b78b8; }
.rank-3 { color: #b87333; }
.rank-content { flex: 1; }
.best-footer { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: flex-end; }
.like-btn {
  background: transparent; border: 1px solid var(--border); color: var(--text-muted);
  padding: 6px 16px; border-radius: 20px; cursor: pointer; font-size: 0.85rem;
  font-family: inherit; transition: all .15s; display: flex; align-items: center; gap: 6px;
}
.like-btn:hover { border-color: var(--accent); color: var(--accent); }
.like-btn.liked { background: #fff0f0; border-color: var(--accent); color: var(--accent); }

/* お題提案リスト */
.proposals-list { list-style: none; margin-top: 4px; }
.proposal-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 10px; border-bottom: 1px solid var(--border);
  border-radius: 8px; transition: background .15s;
}
.proposal-item:last-child { border-bottom: none; }
.proposal-item.voted { background: #fff8e0; }
.proposal-rank {
  width: 26px; height: 26px; min-width: 26px;
  background: var(--surface2); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.78rem; font-weight: bold; color: var(--text-muted);
  margin-top: 2px;
}
.proposal-body { flex: 1; min-width: 0; }
.proposal-theme { font-size: 0.97rem; font-weight: bold; word-break: break-all; }
.proposal-meta { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }
.proposal-vote-col {
  display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 60px;
}
.proposal-vote-count { font-size: 1.05rem; font-weight: bold; color: var(--accent2); }
.vote-label { font-size: 0.7rem; color: var(--text-muted); }
.btn-proposal-vote {
  background: var(--surface2); color: var(--text-muted); border: 1px solid var(--border);
  padding: 4px 12px; font-size: 0.78rem; border-radius: 20px;
  cursor: pointer; font-family: inherit; font-weight: bold; transition: all .15s; white-space: nowrap;
}
.btn-proposal-vote:hover { border-color: var(--accent2); color: var(--accent2); }
.btn-proposal-vote.my-vote { background: #fff8e0; border-color: var(--accent2); color: var(--accent2); }

/* Loading */
.loading { text-align: center; padding: 48px 20px; color: var(--text-muted); }

/* Responsive */
@media (max-width: 600px) {
  .round-header, .best-round-header { flex-direction: column; }
  .navbar { padding: 0 12px; }
  .logo { font-size: 1.05rem; }

  /* Collapse the nav into a hamburger dropdown */
  .nav-toggle { display: flex; }
  .nav-links {
    position: absolute; top: 56px; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 8px 16px rgba(30,24,64,.1);
    max-height: 0; overflow: hidden;
    transition: max-height .25s ease;
  }
  .nav-links.open { max-height: 80vh; }
  .nav-links > a,
  .nav-links > #nav-user,
  .nav-links > .btn-logout {
    width: 100%; text-align: left;
    padding: 14px 20px; font-size: 0.95rem;
    border-top: 1px solid var(--border);
  }
  .nav-links > #nav-user:empty { display: none; }
  .nav-links > .btn-logout {
    background: none; border-radius: 0; color: var(--text-muted);
    border-left: none; border-right: none; border-bottom: none;
  }
}

/* ── フリップ表示（画像つき回答：画像→直下にキャプション）─────────── */
.flip-card {
  display: inline-flex; flex-direction: column; align-items: center;
  max-width: 100%; margin: 8px 0 0;
}
.flip-image {
  display: block;
  max-width: min(100%, 170px); max-height: 170px;
  width: auto; height: auto;
  border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface2); object-fit: contain;
}
/* キャプションはレイアウトのみ指定。フォントは .answer-text を継承して
   「テキストのみの回答」と同じ見た目に統一する（画像有無で字面が変わらない）。 */
.flip-caption {
  max-width: min(100%, 170px); margin-top: 8px;
  text-align: center;
}

/* 自分の投稿・提案が分かるマーク（匿名表示の中で本人だけ表示） */
.mine-tag { color: var(--accent2); font-weight: bold; }
/* 提案一覧の「あなたの提案」タグは削除ボタンを併記するため横並びにする */
.proposal-meta.mine-tag { display: flex; align-items: center; gap: 8px; }

/* ── 画像プロンプトヘルパー（小さいボタン → モーダル）───────────────── */
.prompt-helper { margin: 2px 0 12px; }
/* フォーム内に置く目立たない小ボタン */
.btn-prompt-open {
  display: inline-flex; align-items: center; gap: 4px;
  background: none; color: var(--text-muted);
  border: 1px solid var(--border); border-radius: 20px;
  padding: 4px 12px; font-size: 0.75rem; font-weight: bold;
  cursor: pointer; font-family: inherit; transition: all .15s;
}
.btn-prompt-open:hover { border-color: var(--accent2); color: var(--accent2); }

/* モーダル（ポップアップ） */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(20,16,50,.55);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-overlay[hidden] { display: none; }
.modal-card {
  width: 100%; max-width: 440px; max-height: 85vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
  box-shadow: 0 12px 40px rgba(20,16,50,.3);
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 12px;
}
.modal-head h3 { font-size: 1rem; font-weight: bold; color: var(--text); }
.modal-close {
  background: none; border: none; cursor: pointer; line-height: 1;
  font-size: 1rem; color: var(--text-muted); padding: 4px 8px; border-radius: 6px;
}
.modal-close:hover { color: var(--text); background: var(--surface2); }

.prompt-hint { font-size: 0.78rem; color: var(--text-muted); line-height: 1.55; margin-bottom: 10px; }
/* スタイル選択：名前だけだと何が出るか分からないので、1行の説明を添える */
.prompt-tpls { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.btn-prompt-tpl {
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
  width: 100%; text-align: left;
  background: var(--surface); color: var(--text-muted);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 8px 12px; font-size: 0.78rem;
  cursor: pointer; font-family: inherit; transition: all .15s;
}
.btn-prompt-tpl:hover { border-color: var(--accent2); background: var(--surface2); }
.btn-prompt-tpl.active { border-color: var(--accent2); background: var(--surface2); }
.tpl-name { font-weight: bold; color: var(--text); white-space: nowrap; }
.btn-prompt-tpl:hover .tpl-name, .btn-prompt-tpl.active .tpl-name { color: var(--accent2); }
.tpl-hint { font-size: 0.74rem; color: var(--text-muted); }

/* 「命令→場面→条件」の3部構成が一目で見渡せる高さを確保する */
.prompt-output {
  min-height: 190px; margin-bottom: 10px; background: var(--bg);
  font-size: 0.8rem; line-height: 1.6;
}
.prompt-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.btn-sm { padding: 6px 12px; font-size: 0.82rem; }

/* 貼り付け先の候補（複数から選べるようにする） */
.prompt-tools { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--border); }
.prompt-tools-head {
  font-size: 0.74rem; font-weight: bold; color: var(--text-muted); margin-bottom: 8px;
}
.prompt-tool {
  display: block; text-decoration: none;
  padding: 8px 10px; border-radius: 8px; transition: background .15s;
}
.prompt-tool:hover { background: var(--surface2); }
.prompt-tool-name { display: block; font-size: 0.82rem; font-weight: bold; color: var(--accent2); }
.prompt-tool-note { display: block; font-size: 0.73rem; color: var(--text-muted); margin-top: 2px; }
.prompt-tools-caution { font-size: 0.71rem; color: var(--text-muted); line-height: 1.6; margin: 8px 0 0; }

/* ── 広告枠 .ad-slot の見た目は base.html の <style> で定義する。
   ADSENSE_CLIENT_ID 未設定時はスタイルごと出力されない作りなので、
   ここに書くと未設定時にも残ってしまう。追加しないこと ── */
