/* 秘密ダンジョン — Phase 4〜6: 会話 / 今日の積み重ね / ぼくたちのれきし
   少ない色・少ない要素・静かなUI。 */

:root {
  --bg: #0d0b14;
  --fg: #cfc9e0;
  --dim: #6b647f;
  --accent: #7a6cc4;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}
body {
  background: var(--bg);
  color: var(--fg);
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

#app {
  position: relative;
  width: 100%;
  max-width: 480px;
  height: 100dvh;
  margin: 0 auto;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
  -webkit-user-select: none;
  user-select: none;
}

.mute {
  position: absolute;
  top: calc(8px + env(safe-area-inset-top));
  right: calc(10px + env(safe-area-inset-right));
  z-index: 10;
  background: transparent; border: none;
  color: var(--dim); font-size: 18px; padding: 6px; line-height: 1;
}
.mute.off { opacity: 0.55; }

.screen {
  display: none;
  width: 100%;
  height: 100%;
  flex-direction: column;
  align-items: center;
}
.screen.is-active { display: flex; animation: fade 0.4s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* 上部バー */
.topbar {
  position: relative;
  width: 100%;
  padding: 16px 18px 6px;
  text-align: center;
  min-height: 44px;
}
.topbar.with-back { text-align: center; }
.place { color: var(--dim); font-size: 12px; letter-spacing: 0.12em; }
.title { color: var(--dim); font-size: 13px; letter-spacing: 0.14em; }
.back {
  position: absolute;
  left: 14px; top: 12px;
  background: transparent; color: var(--dim);
  border: none; font-size: 14px; padding: 4px 8px;
}

/* モンスターの居る場所 */
.stage { flex: 1; width: 100%; display: flex; align-items: center; justify-content: center; }
[data-screen="home"] .stage {
  background: radial-gradient(ellipse 48% 35% at 50% 65%, var(--cave-light, transparent), transparent);
}
#app[data-cave-light="day"] { --cave-light: rgba(129, 119, 166, 0.075); }
#app[data-cave-light="evening"] { --cave-light: rgba(183, 118, 77, 0.15); }
#app[data-cave-light="night"] { --cave-light: rgba(126, 104, 185, 0.17); }
#monster, #monsterBig, #biteMonster {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  filter: drop-shadow(0 0 12px rgba(122, 108, 196, 0.22));
}
#monster { width: 200px; height: 200px; }
#biteMonster { width: min(200px, 68vw, 45dvh); height: auto; }
.bite-actions { padding: 0 16px calc(24px + env(safe-area-inset-bottom)); }
.tappable { cursor: pointer; }
.stage-big #monsterBig { width: min(260px, 70vw, 47dvh); height: auto; }
#monsterBig[data-gesture="nod"] { animation: talk-nod 420ms ease-in-out; }
#monsterBig[data-gesture="lean"] { animation: talk-lean 700ms ease-in-out; }
@keyframes talk-nod {
  45% { transform: translateY(5px) rotate(3deg); }
}
@keyframes talk-lean {
  50% { transform: translate(4px, 2px) rotate(3deg); }
}

/* 名前・出会い */
.meta { width: 100%; text-align: center; min-height: 46px; }
.name {
  background: transparent; color: var(--dim);
  border: 1px dashed #2f2b40; border-radius: 999px;
  padding: 6px 16px; font-size: 14px; letter-spacing: 0.08em;
}
.name.named { color: var(--fg); border-style: solid; border-color: #2f2b40; }
.name-input {
  width: 8em; text-align: center;
  background: #1a1626; color: var(--fg);
  border: 1px solid var(--accent); border-radius: 999px;
  padding: 6px 12px; font-size: 15px; letter-spacing: 0.15em; outline: none;
}
.met { margin: 6px 0 0; color: #3f3a51; font-size: 11px; letter-spacing: 0.12em; }

.status {
  min-height: 1.4em; margin: 10px 0 14px;
  font-size: 15px; color: var(--fg); letter-spacing: 0.08em;
  transition: opacity 0.6s ease;
}

.hint { color: #4a4560; font-size: 12px; letter-spacing: 0.14em; margin: 0 0 10px; }

/* 下部ナビ（控えめ） */
.nav { display: flex; gap: 26px; padding: 0 0 26px; }
.nav-btn {
  background: transparent; color: var(--dim);
  border: none; font-size: 13px; letter-spacing: 0.12em; padding: 6px 8px;
}

/* 会話 */
.reaction {
  min-height: 1.5em; margin: 4px 0 14px;
  font-size: 16px; color: var(--fg); letter-spacing: 0.06em;
  transition: opacity 0.6s ease;
}
.talk-input {
  width: 100%; display: flex; gap: 8px;
  padding: 0 16px calc(20px + env(safe-area-inset-bottom));
}
.talk-input input {
  flex: 1; min-width: 0; background: #1a1626; color: var(--fg);
  border: 1px solid #2f2b40; border-radius: 999px;
  padding: 12px 16px; font-size: 15px; outline: none;
}
.send {
  background: transparent; color: var(--fg);
  border: 1px solid var(--dim); border-radius: 999px;
  padding: 12px 18px; font-size: 15px; white-space: nowrap;
}
.send:disabled { color: var(--dim); border-color: #2a2637; }
.send.wide { width: 100%; }
.ex-menu { width: 100%; padding: 30px 24px; display: flex; flex-direction: column; gap: 14px; }

/* データ（バックアップ） */
.data-box { width: 100%; padding: 22px 22px calc(22px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 14px; }
.data-note { color: var(--dim); font-size: 13px; line-height: 1.7; margin: 0 0 6px; }
.data-msg { color: var(--fg); font-size: 13px; min-height: 1.2em; }

/* 今日の積み重ね */
.check-list {
  width: 100%; padding: 8px 20px; display: flex; flex-direction: column; gap: 10px;
  flex: 1; overflow-y: auto;
}
.check-row {
  width: 100%; text-align: left;
  background: transparent; color: var(--dim);
  border: 1px solid #2a2637; border-radius: 12px;
  padding: 14px 16px; font-size: 15px; letter-spacing: 0.06em;
}
.check-row.done { color: var(--fg); border-color: var(--accent); }
.note { color: var(--dim); font-size: 12px; margin-top: 14px; }

/* ぼくたちのれきし：モンスターのアルバム */
.gallery {
  width: 100%; display: flex; flex-wrap: wrap; gap: 12px; justify-content: center;
  padding: 12px 18px 6px; max-height: 42vh; overflow-y: auto;
}
.mon {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  width: 60px; cursor: pointer; background: transparent; border: 0; padding: 0;
  color: inherit; font: inherit;
}
.mon:focus-visible { outline: 1px solid var(--accent); outline-offset: 2px; }
.mon canvas { width: 56px; height: 56px; image-rendering: pixelated; image-rendering: crisp-edges; }
.mon-name { font-size: 11px; color: var(--fg); opacity: 0.85; }
.mon-tag { font-size: 10px; color: var(--accent); letter-spacing: 0.1em; }

/* ぼくたちのれきし（本のような静かなリスト） */
.memory-list {
  width: 100%; list-style: none; margin: 0;
  padding: 10px 22px calc(20px + env(safe-area-inset-bottom));
  overflow-y: auto; flex: 1;
  display: flex; flex-direction: column; gap: 8px;
}
.memory-list li { font-size: 14px; color: var(--fg); opacity: 0.9; }
.memory-list .memo-date { color: var(--dim); margin-right: 10px; font-size: 12px; }
.memory-list .memo-empty { color: var(--dim); text-align: center; }
[data-screen="view"] { overflow-y: auto; }
[data-screen="view"] .stage { flex: 1 0 auto; min-height: 144px; }
#viewCanvas { width: min(160px, 38dvh); height: auto; image-rendering: pixelated; }
.view-memories { width: 100%; max-width: 340px; margin-top: 14px; }
.view-memories h2 {
  margin: 0; padding: 0 22px; color: var(--fg); font-size: 12px; font-weight: normal; letter-spacing: 0.08em;
}
.view-memories .memory-list { overflow: visible; overflow-wrap: anywhere; }

/* ごはん（ミニゲーム） */
.feed-count { color: var(--fg); font-size: 14px; letter-spacing: 0.1em; margin: 4px 0 0; min-height: 1.3em; }
.feed-wrap { flex: 1; width: 100%; display: flex; align-items: stretch; justify-content: center; padding: 8px 12px; }
.feed-canvas {
  width: 100%; max-width: 440px; height: 100%;
  background: #0a0812; border-radius: 14px;
  touch-action: none;                 /* スワイプでスクロールさせない */
}

/* 動きを減らしたい設定のときは静止させる（省電力・アクセシビリティ） */
@media (prefers-reduced-motion: reduce) {
  .screen.is-active { animation: none; }
  #monsterBig[data-gesture] { animation: none; }
  .reaction, .status { transition: none; }
}
