@import url('https://fonts.googleapis.com/css2?family=Zen+Maru+Gothic:wght@400;500;700;900&display=swap');

:root {
  --navy: #0077C0;
  --navy-dark: #005A94;
  --coral: #f96167;
  --coral-dark: #e14a50;
  --gold: #f9e795;
  --cream: #fff9f2;
  --card: #ffffff;
  --border: #efe3d2;
  --dark: #2b2b2b;
  --gray: #746f68;
  --success: #3fa66b;
  --danger: #e14a50;
  --radius-lg: 20px;
  --radius-md: 14px;
  --shadow: 0 6px 20px rgba(0,119,192, 0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--cream);
  color: var(--dark);
  font-family: 'Zen Maru Gothic', 'Hiragino Maru Gothic ProN', sans-serif;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 0 0 40px;
  position: relative;
}

/* ---------- Header ---------- */
.app-header {
  background: var(--navy);
  color: #fff;
  padding: 22px 20px 26px;
  border-radius: 0 0 28px 28px;
  position: relative;
  overflow: hidden;
}
.app-header::after {
  content: "";
  position: absolute;
  right: -30px;
  top: -40px;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
}
.header-mascot {
  position: absolute;
  right: 18px;
  top: 18px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 4px 14px rgba(0,0,0,0.25);
  border: 2px solid rgba(255,255,255,0.6);
  /* コハク成長画像は背景が透過PNGのため、白背景を敷いてヘッダーの色が透けないようにする
     （2026年9月28日追加：全ページ共通のヘッダーアイコン成長反映に伴う対応） */
  background: #fff;
}
.header-mascot-sm {
  width: 50px;
  height: 50px;
  top: 16px;
  right: 16px;
}
.app-header .eyebrow {
  font-size: 13px;
  color: var(--gold);
  font-weight: 700;
  letter-spacing: 0.02em;
}
.app-header h1 {
  margin: 4px 0 0;
  font-size: 26px;
  font-weight: 900;
}
.app-header p {
  margin: 6px 0 0;
  font-size: 13.5px;
  color: #d3e8f7;
}
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #d3e8f7;
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 10px;
}
.back-link:hover { color: #fff; }

/* ---------- Layout ---------- */
.content { padding: 20px; }
.section-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--navy);
  margin: 0 0 12px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 999px;
  padding: 13px 22px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  text-decoration: none;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--navy); color: #fff; box-shadow: 0 6px 16px rgba(0,119,192,0.35); }
.btn-primary:hover { background: var(--navy-dark); }
.btn-secondary { background: #fff; color: var(--navy); border: 1.5px solid var(--border); }
.btn-secondary:hover { border-color: var(--navy); }
.btn-block { width: 100%; }
.btn-ghost {
  background: transparent;
  color: var(--navy);
  border: 1.5px dashed var(--navy);
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.fab {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  max-width: 440px;
  width: calc(100% - 40px);
  z-index: 20;
}

/* ---------- Puzzle cards (index) ---------- */
.puzzle-list { display: flex; flex-direction: column; gap: 12px; padding-bottom: 90px; }
.puzzle-card {
  display: flex;
  gap: 12px;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
  transition: transform 0.12s ease;
}
.puzzle-card:active { transform: scale(0.98); }
.puzzle-card .badge {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--navy);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
}
.puzzle-card .info { flex: 1; min-width: 0; }
.puzzle-card .info h3 {
  margin: 0 0 3px;
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.puzzle-card .info .meta { font-size: 12.5px; color: var(--gray); }
.stars { color: var(--gold); letter-spacing: 1px; filter: drop-shadow(0 1px 0 rgba(0,0,0,0.15)); }
.chevron { color: var(--border); font-size: 20px; }

.empty-state {
  text-align: center;
  padding: 50px 20px;
  color: var(--gray);
}
.empty-state .mascot { width: 120px; margin-bottom: 14px; opacity: 0.9; }
.empty-state .empty-state-photo {
  width: 140px;
  height: 140px;
  object-fit: cover;
  border-radius: 50%;
  margin: 0 auto 16px;
  display: block;
  box-shadow: var(--shadow);
  border: 3px solid #fff;
}
.empty-state p { margin: 4px 0; font-size: 14px; }

/* ---------- Forms (register) ---------- */
.field { margin-bottom: 18px; }
.field label {
  display: block;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 6px;
}
.field .hint-text { font-size: 12px; color: var(--gray); margin-top: 5px; }
input[type="text"], textarea, select {
  width: 100%;
  font-family: inherit;
  font-size: 15px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border);
  background: #fff;
  color: var(--dark);
}
input[type="text"]:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--navy);
}
textarea { resize: vertical; min-height: 78px; line-height: 1.55; }

.ai-box {
  background: #e8f3fb;
  border: 1px solid #d3e8f7;
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 20px;
}
.ai-box .ai-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 8px;
}
.ai-box .ai-label .tag {
  font-size: 10.5px;
  background: var(--gold);
  color: var(--navy-dark);
  padding: 2px 7px;
  border-radius: 999px;
  font-weight: 700;
}
.ai-generate-row { display: flex; gap: 8px; margin-top: 10px; }
.ai-generate-row input { flex: 1; }
.ai-generate-row .btn { flex: 0 0 auto; padding: 12px 18px; font-size: 14px; }
.ai-note { font-size: 11.5px; color: var(--gray); margin-top: 8px; line-height: 1.5; }

.difficulty-select { display: flex; gap: 8px; }
.difficulty-option {
  flex: 1;
  text-align: center;
  padding: 12px 4px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border);
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  color: var(--gray);
  background: #fff;
  transition: all 0.12s ease;
}
.difficulty-option.selected {
  border-color: var(--coral);
  background: #fff2f2;
  color: var(--coral-dark);
}
.difficulty-option.disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* ---------- タブ（ログイン画面のユーザー/運営切り替えなど） ---------- */
.tab-row { display: flex; gap: 8px; margin-bottom: 18px; }
.tab-btn {
  flex: 1;
  text-align: center;
  padding: 11px 6px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border);
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  color: var(--gray);
  background: #fff;
  transition: all 0.12s ease;
}
.tab-btn.active {
  border-color: var(--navy);
  background: #e8f3fb;
  color: var(--navy);
}

/* ---------- ログイン状態表示（謎一覧・謎登録画面） ---------- */
.account-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  background: #e8f3fb;
  border: 1px solid #d3e8f7;
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 16px;
  font-size: 13px;
}
.account-bar .account-info { color: var(--navy); font-weight: 700; }
.account-bar .account-sub { color: var(--gray); font-weight: 500; font-size: 12px; margin-top: 2px; }
.account-bar a { color: var(--navy); }
.account-bar .btn { padding: 8px 14px; font-size: 13px; }

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.5);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  background: var(--navy-dark);
  color: #fff;
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 50;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }

/* ---------- Detail screen ---------- */
.detail-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.detail-card .difficulty-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.detail-card h2 { margin: 0 0 12px; font-size: 20px; }
.detail-card .problem-text {
  font-size: 15.5px;
  line-height: 1.75;
  white-space: pre-wrap;
}
/* お題のタグ・参考出典（2026年10月9日追加） */
.puzzle-meta { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; }
.puzzle-theme-tag {
  font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px;
  background: var(--cream, #fff9f2); border: 1.5px solid var(--gold, #f9e795); color: var(--navy);
}
.puzzle-reference { margin-top: 10px; font-size: 12.5px; line-height: 1.6; color: var(--gray, #6b7280); text-align: left; }
.puzzle-reference a { color: var(--navy); text-decoration: underline; }
.puzzle-reference-license { margin-left: 2px; }
/* 登録画面のお題チップ（運営のみ） */
.theme-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.theme-chip {
  font-size: 14px; font-weight: 700; padding: 8px 14px; min-height: 40px; border-radius: 999px; cursor: pointer;
  background: #fff; color: var(--navy); border: 1.5px solid var(--gold, #f9e795);
}
.theme-chip.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.hint-toggle {
  margin-top: 14px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--navy);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.hint-box {
  margin-top: 10px;
  background: var(--cream);
  border: 1px dashed var(--gold);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font-size: 13.5px;
  color: var(--gray);
  display: none;
}
.hint-box.show { display: block; }

.answer-box textarea, .answer-box input { margin-bottom: 12px; }

.result-banner {
  position: relative;
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
  font-weight: 700;
  font-size: 16px;
  margin-top: 14px;
  display: none;
}
.result-banner.show { display: block; }
.result-banner.correct { background: #e6f6ec; color: var(--success); border: 1.5px solid #b9e6c9; }
.result-banner.incorrect { background: #fdecec; color: var(--danger); border: 1.5px solid #f5c3c5; }
#result-inconclusive { background: #fff8e6; color: #9a7b1f; border: 1.5px solid #f2dfa0; }
.celebration-img {
  display: block;
  width: 110px;
  margin: 0 auto 8px;
}
/* 正解時の発見演出（2026年9月28日追加）。紙吹雪と、宝の写真・タイトルのポップイン演出で、
   「見つけた！」の瞬間をより盛り上げる。 */
.result-banner.correct .celebration-img {
  animation: celebrationPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.result-banner.correct #result-correct-title {
  animation: celebrationPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 0.08s both;
}
@keyframes celebrationPop {
  0% { transform: scale(0.4) rotate(-8deg); opacity: 0; }
  60% { transform: scale(1.12) rotate(3deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}
.confetti-layer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  border-radius: inherit;
}
.confetti-piece {
  position: absolute;
  top: -12px;
  width: 8px;
  height: 14px;
  opacity: 0.9;
  animation-name: confettiFall;
  animation-timing-function: ease-in;
  animation-fill-mode: forwards;
}
@keyframes confettiFall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(160px) rotate(360deg); opacity: 0; }
}
.judge-breakdown {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed rgba(0,0,0,0.12);
  text-align: left;
}
.judge-row {
  font-size: 12.5px;
  padding: 3px 0;
  font-weight: 500;
}
.judge-row.judge-pass { color: var(--success); }
.judge-row.judge-fail { color: var(--danger); }
.judge-row.judge-skip { color: var(--gray); }

.tag-pill {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--gold);
  color: var(--navy-dark);
}

/* ---------- ドラム演出 ---------- */
.drum-overlay {
  display: none;
  text-align: center;
  padding: 28px 20px;
}
.drum-overlay.show { display: block; }
.drum-mascot {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  display: inline-block;
  object-fit: cover;
  object-position: center 30%;
  box-shadow: 0 6px 16px rgba(0,119,192,0.25);
  animation: mascot-bounce 0.6s ease-in-out infinite;
}
@keyframes mascot-bounce {
  0%, 100% { transform: translateY(0) rotate(-6deg); }
  50% { transform: translateY(-14px) rotate(6deg); }
}
.drum-overlay p {
  margin: 10px 0 0;
  color: var(--navy);
  font-weight: 700;
  font-size: 15px;
}

/* ---------- 広告枠プレースホルダー（2026年9月29日追加）
   未成約の広告枠を、コハクの「Coming Soon」演出／絵本シーン誘導で埋める。
   実際の広告が決まった枠から、このプレースホルダーを外して差し替える運用を想定。 ---------- */
.ad-slot {
  position: relative;
  border-radius: var(--radius-md);
  border: 1.5px dashed var(--border);
  background: var(--cream);
  overflow: hidden;
}
.ad-slot-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--gray);
  background: rgba(255,255,255,0.85);
  padding: 2px 8px;
  border-radius: 999px;
  z-index: 2;
}
/* 縦型カード（A・C枠向け） */
.ad-slot-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 18px 14px;
  text-align: center;
}
.ad-slot-card img.ad-slot-mascot {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  object-fit: cover;
  background: #fff;
  box-shadow: var(--shadow);
}
.ad-slot-card .ad-slot-sign {
  display: inline-block;
  background: #fff;
  border: 1.5px solid var(--gold);
  border-radius: 10px;
  padding: 6px 14px;
  font-weight: 800;
  font-size: 13px;
  color: var(--navy-dark);
  transform: rotate(-2deg);
  box-shadow: 0 3px 8px rgba(0,0,0,0.08);
}
.ad-slot-card .ad-slot-note {
  font-size: 11.5px;
  color: var(--gray);
  margin: 0;
  line-height: 1.6;
}
/* 絵本シーン誘導（画像リンク型） */
a.ad-slot-ehon {
  display: block;
  text-decoration: none;
  color: inherit;
}
a.ad-slot-ehon img {
  display: block;
  width: 100%;
  height: auto;
}
a.ad-slot-ehon .ad-slot-ehon-caption {
  padding: 10px 12px;
  font-size: 12.5px;
  color: var(--navy-dark);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
a.ad-slot-ehon .ad-slot-ehon-caption .arrow {
  color: var(--coral);
  font-weight: 900;
}
/* 横型コンパクトバナー（B・D枠向け） */
.ad-slot-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
}
.ad-slot-banner img.ad-slot-mascot-sm {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.12);
  flex-shrink: 0;
}
.ad-slot-banner .ad-slot-banner-text {
  font-size: 11.5px;
  color: var(--navy-dark);
  line-height: 1.4;
  text-align: left;
}
.ad-slot-banner .ad-slot-banner-text strong {
  display: block;
  font-size: 12.5px;
  font-weight: 800;
}

/* 投稿前の確認（2026年10月9日: 大きく・目立つように） */
.consent-box {
  background: #fff8e1;
  border: 3px solid var(--coral, #f96167);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 20px;
}
.consent-title {
  font-size: 17px;
  font-weight: 800;
  color: var(--navy);
  margin-bottom: 12px;
}
.consent-item {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.6;
  color: var(--navy);
  background: #fff;
  border: 2px solid #f3d9a0;
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 10px;
  cursor: pointer;
}
.consent-item:last-child { margin-bottom: 0; }
.consent-item input[type="checkbox"] {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  margin: 0;
  accent-color: var(--coral, #f96167);
}
.consent-item.consent-error {
  border-color: var(--danger, #c0392b);
  background: #fdecea;
  animation: consent-shake 0.4s;
}
@keyframes consent-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

/* くわしい設定（2026年10月9日追加）。最初は閉じておく */
.advanced-settings {
  background: #e8f3fb;
  border: 1px solid #d3e8f7;
  border-radius: var(--radius-md);
  margin-bottom: 20px;
}
.advanced-settings > summary {
  list-style: none;
  cursor: pointer;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
  padding-right: 40px;
}
.advanced-settings > summary::-webkit-details-marker { display: none; }
.advanced-settings > summary::after {
  content: "▼";
  position: absolute;
  right: 14px;
  top: 14px;
  font-size: 13px;
  color: var(--navy);
}
.advanced-settings[open] > summary::after { content: "▲"; }
.advanced-title { font-size: 14px; font-weight: 700; color: var(--navy); }
.advanced-summary { font-size: 13px; color: var(--navy); opacity: .8; line-height: 1.5; }
.advanced-body { padding: 0 14px 14px; }
.advanced-body .field:last-child { margin-bottom: 0; }
.advanced-body > .ai-box { margin-top: 12px; margin-bottom: 0; background: #fff; }

/* コハクの着せ替え（2026年10月10日追加）: 成長段階の絵の上に、部品の絵を重ねる。
   位置・大きさは app.js の renderKohakuAvatar が%で指定する。足もとの部品がはみ出すため、枠に余白を持っている。 */
.kohaku-avatar { position: relative; width: 100%; }
.kohaku-avatar-base, .kohaku-avatar-part { position: absolute; height: auto; display: block; pointer-events: none; }
.kohaku-avatar-part { filter: drop-shadow(1px 2px 2px rgba(40, 40, 40, 0.28)); }
