* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: linear-gradient(#FFF4E0 0%, #FDE7C4 60%, #E9D3A6 100%);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Maru Gothic ProN", "Noto Sans JP", sans-serif;
  color: #4A2E16;
  /* スマホ特有の「長押しメニュー」「文字選択」「ダブルタップ拡大」を止める */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

#app {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: env(safe-area-inset-top) 16px env(safe-area-inset-bottom);
}

/* ---- 画面の切り替え（mode-home：メニュー／mode-play：遊ぶ） ---- */
.mode-home .hint,
.mode-home #back,
.mode-home #play-hearts,
.mode-play #menu,
.mode-play #days,
.mode-name .hint,
.mode-name #back,
.mode-name #play-hearts,
.mode-name #menu,
.mode-name #days { display: none; }
.name-form { display: none; }
.mode-name .name-form { display: flex; }
.mode-name #tanu-area { width: min(70vw, 36vh * 0.8, 360px); }

/* ---- お試し版 ---- */
.demo-bar { display: none; }
.demo .demo-bar {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
}
.demo #back, .demo #play-hearts { display: none; }
.demo-badge {
  font-size: 13px;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .7);
}
.btn-result { font-size: 15px; padding: 9px 16px; }
.btn-result.ready {
  background: #F08A3C;
  color: #fff;
  box-shadow: 0 3px 0 #C8641E;
  animation: nudge 1.6s ease-in-out infinite;
}
@keyframes nudge {
  0%, 70%, 100% { transform: scale(1); }
  80% { transform: scale(1.08); }
  90% { transform: scale(.97); }
}
.res-lead { margin: 0; text-align: center; font-size: 15px; opacity: .7; }
.res-title { margin: 0; text-align: center; font-size: 26px; font-weight: 900; color: #C8641E; }
.res-img { display: block; width: 55%; max-width: 220px; margin: 0 auto; aspect-ratio: 4 / 5; object-fit: contain; }
.res-prev { margin: 0; text-align: center; font-size: 14px; opacity: .75; }
.res-prev.changed { opacity: 1; font-weight: 700; color: #C8641E; }
.res-comment { margin: 0; text-align: center; font-size: 17px; font-weight: 700; }
.btn-main.btn-x { display: block; text-align: center; text-decoration: none; background: #111; box-shadow: 0 4px 0 #444; color: #fff; }
.btn-main.btn-x:active { box-shadow: 0 2px 0 #444; }
.note.center { text-align: center; }
.share-row { display: flex; gap: 8px; }
.btn-follow { display: block; text-align: center; text-decoration: none; font-size: 15px; color: #1D6FD8; }
.share-row .btn { flex: 1; font-size: 14px; padding: 11px 8px; }

/* ---- 呼び名の入力 ---- */
.name-form {
  width: 100%;
  max-width: 360px;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  margin-top: 16px;
}
.name-input {
  border: 2px solid #E9C89A;
  border-radius: 16px;
  padding: 13px 16px;
  font: inherit;
  font-size: 18px;   /* 16px 未満だと iPhone で画面が拡大されてしまう */
  font-weight: 700;
  text-align: center;
  color: inherit;
  background: #fff;
  -webkit-user-select: text;
  user-select: text;
}
.name-input:focus { outline: none; border-color: #F08A3C; }
.link {
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  font-size: 15px;
  opacity: .7;
  text-decoration: underline;
  padding: 6px;
  cursor: pointer;
}
.note.small { font-size: 12px; text-align: center; margin: 0; }
.set-row { display: flex; gap: 8px; }
.set-row .name-input { flex: 1; min-width: 0; padding: 10px 12px; }
.sheet-box h3 { margin: 8px 0 0; font-size: 16px; }

/* ---- 上のバー ---- */
#topbar {
  position: relative;
  width: 100%;
  max-width: 460px;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
}
.days { text-align: center; line-height: 1.3; }
.days-main { font-size: clamp(18px, 5.4vw, 24px); font-weight: 700; }
.days-main b { font-size: 1.5em; color: #C8641E; margin: 0 2px; }
.days-sub { font-size: 13px; opacity: .65; min-height: 1em; }
.back {
  position: absolute;
  left: 0;
  border: 0;
  background: rgba(255, 255, 255, .7);
  color: inherit;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
}
#play-hearts { position: absolute; right: 0; }
.cap-note { position: absolute; right: 0; top: calc(50% + 14px); font-size: 11px; font-weight: 700;
  color: #6B5A9E; background: rgba(255, 255, 255, .75); padding: 1px 8px; border-radius: 999px; white-space: nowrap; }
.cap-note[hidden], .mode-home .cap-note, .mode-name .cap-note, .demo .cap-note { display: none; }
.float-mark { position: fixed; z-index: 30; pointer-events: none; font-size: 22px; }
.hearts { display: inline-flex; gap: 2px; white-space: nowrap; vertical-align: middle; }
.hearts.pop { animation: pop .45s cubic-bezier(.3, 1.6, .5, 1); }
/* ハート1個：白いハートの上に、ピンクのハートを下から「高さ％」だけ重ねる */
.hrt { position: relative; display: inline-block; width: 20px; height: 20px; }
.hrt svg { position: absolute; left: 0; bottom: 0; width: 20px; height: 20px;
  fill: #FFF; stroke: #E9A9BE; stroke-width: 1.6; }
.hrt .fill { position: absolute; left: 0; right: 0; bottom: 0; overflow: hidden; transition: height .35s ease-out; }
.hrt .fill svg { fill: #FF5E95; stroke: #E0457C; }
.hrt.next .fill svg { fill: #FF8DB5; }
/* 次のハート（いま貯めているハート）：少し大きく、ふんわり光らせる */
.hrt.next { transform: scale(1.12); filter: drop-shadow(0 0 3px rgba(255, 94, 149, .55)); }
.hrt.beat { animation: pop .35s cubic-bezier(.3, 1.6, .5, 1); }
.btn-main .hrt svg { stroke: #fff; }
/* さわったときに飛んでいく「+1」のハート */
.fly-heart { position: fixed; z-index: 30; pointer-events: none; width: 26px; height: 26px; }
.fly-heart svg { width: 26px; height: 26px; fill: #FF5E95; stroke: #fff; stroke-width: 1.5;
  filter: drop-shadow(0 2px 3px rgba(224, 69, 124, .4)); }
.fly-heart b { position: absolute; left: 20px; top: -6px; font-size: 13px; color: #E0457C;
  -webkit-text-stroke: 3px #fff; paint-order: stroke fill; }

/* ---- メニューのボタン ---- */
#menu {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 18px;
}
.btn {
  border: 0;
  border-radius: 18px;
  background: #fff;
  color: inherit;
  font: inherit;
  font-size: 17px;
  font-weight: 700;
  padding: 13px 16px;
  box-shadow: 0 3px 0 rgba(74, 46, 22, .18);
  cursor: pointer;
}
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(74, 46, 22, .18); }
.btn-main {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: #F08A3C;
  color: #fff;
  font-size: 21px;
  padding: 16px;
  box-shadow: 0 4px 0 #C8641E;
}
.btn-main:active { box-shadow: 0 2px 0 #C8641E; }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; white-space: nowrap; padding-left: 6px; padding-right: 6px; }
.test-hearts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.test-hearts .btn { font-size: 14px; padding: 9px 4px; border: 2px solid transparent; }
.test-hearts .btn.on { border-color: #F08A3C; }
.wear-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.wear-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 6px;
  border: 2px solid transparent;
  border-radius: 14px;
  background: #fff;
  color: inherit;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  box-shadow: 0 2px 0 rgba(74, 46, 22, .15);
  cursor: pointer;
}
.wear-item.on { border-color: #F08A3C; }
.wear-item:disabled { opacity: .55; cursor: default; }
.wear-thumb {
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: #F3D2AE;   /* 部品が見やすいように、肌っぽい色の丸の上に出す */
  font-size: 18px;
}
.wear-thumb img { width: 34px; height: auto; }
.btn-wide { width: 100%; }
.btn-danger { color: #C0392B; width: 100%; margin-top: 6px; }

/* ---- 実績・設定のパネル ---- */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(74, 46, 22, .35);
}
.sheet[hidden] { display: none; }
.sheet-box {
  width: 100%;
  max-width: 400px;
  max-height: 85%;
  overflow: auto;
  background: #FFF9EF;
  border-radius: 22px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.sheet-box h2 { margin: 0; font-size: 20px; text-align: center; }
/* パネルの中身も、部品どうしの間をあける（以前は中身がくっついて、ボタンが文字にかぶって見えた） */
#sheet-body { display: flex; flex-direction: column; gap: 10px; }
#sheet-body > * { flex-shrink: 0; margin-top: 0; margin-bottom: 0; }
#sheet-body > h3 { margin-top: 8px; }
.rec { width: 100%; border-collapse: collapse; font-size: 15px; }
.rec th, .rec td { padding: 8px 4px; border-bottom: 1px solid rgba(74, 46, 22, .12); }
.rec th { text-align: left; font-weight: 400; }
.rec td { text-align: right; font-weight: 700; white-space: nowrap; }
.note.notice { font-size: 15px; line-height: 1.8; opacity: 1; }
#notice-ok { width: 100%; }
.note { margin: 4px 0; font-size: 14px; line-height: 1.6; opacity: .8; }

/* ---- お知らせ ---- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 20px);
  z-index: 20;
  transform: translate(-50%, 10px);
  background: #fff;
  border-radius: 22px;
  padding: 10px 18px;
  font-size: 15px;
  font-weight: 700;
  white-space: pre-line;
  text-align: center;
  width: max-content;
  max-width: 90vw;
  line-height: 1.5;
  box-shadow: 0 4px 14px rgba(74, 46, 22, .2);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* メニュー画面ではボタンのぶん、タヌくんを少し小さく */
.mode-home #tanu-area { width: min(80vw, 44vh * 0.8, 400px); }

#stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ---- タヌくん ---- */
#tanu-area {
  position: relative;
  /* タヌくんの上では、指を動かしてもブラウザにスクロールさせない
     （スクロールと判断されるとタッチが取り消され、さわったことにならないため） */
  touch-action: none;
  width: min(90vw, 56vh * 0.8, 460px);
  aspect-ratio: 4 / 5;
}
.ground {
  position: absolute;
  left: 12%; right: 12%; bottom: -1%;
  height: 7%;
  border-radius: 50%;
  background: rgba(74, 46, 22, .18);
}
#tanu-move, #tanu-melt, #tanu-body, #tanu-breath {
  position: absolute;
  inset: 0;
  transform-origin: 50% 96%;   /* 足もとを軸にして伸び縮み */
}
#tanu-breath { animation: breath 3.2s ease-in-out infinite; }
@keyframes breath {
  0%, 100% { transform: scale(1, 1); }
  50%      { transform: scale(1.015, .985); }
}
#tanu-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

/* ---- おなかだけ揺らす重ね絵 ----
   位置と大きさは config.js の bellyJiggle から app.js が --bx などに入れます */
#belly-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  transform-origin: var(--bx, 37%) var(--by, 46%);
  -webkit-mask-image: radial-gradient(ellipse var(--brx, 30%) var(--bry, 19%) at var(--bx, 37%) var(--by, 46%), #000 70%, transparent 100%);
          mask-image: radial-gradient(ellipse var(--brx, 30%) var(--bry, 19%) at var(--bx, 37%) var(--by, 46%), #000 70%, transparent 100%);
}
/* ---- きせかえパーツ（位置と大きさは config.js の parts から app.js が入れます） ---- */
#parts-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
#parts-layer img {
  position: absolute;
  transform: translate(-50%, -50%);
}
#parts-layer img.full {
  left: 0; top: 0;
  width: 100%;
  height: 100%;
  transform: none;
  object-fit: contain;
}
#belly-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  visibility: hidden;
}

/* ---- 「ぽん！」「ぽこ！」の文字 ---- */
.pop-word {
  position: absolute;
  z-index: 3;
  transform: translate(-50%, -50%);
  font-size: clamp(20px, 6vw, 28px);
  font-weight: 900;
  color: #fff;
  -webkit-text-stroke: 1px #C8641E;
  text-shadow: 0 2px 0 #C8641E, 0 0 6px rgba(200, 100, 30, .5);
  pointer-events: none;
  white-space: nowrap;
}

#belly-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* ---- 怒りの絵がないあいだの代用（config.js の angryTint） ---- */
#tanu-img { transition: filter .25s; }
.tint-angry #tanu-img {
  filter: sepia(.3) saturate(1.7) hue-rotate(-18deg);
}
.tint-angry #tanu-breath::after {
  content: "💢";
  position: absolute;
  left: 62%; top: 1%;
  font-size: clamp(30px, 10vw, 48px);
  animation: pop .35s cubic-bezier(.3, 1.6, .5, 1);
}
@keyframes pop { from { transform: scale(0); } to { transform: scale(1); } }

/* ---- タップ範囲 ---- */
#zones { position: absolute; inset: 0; }
.zone {
  position: absolute;
  border: 0;
  padding: 0;
  margin: 0;
  background: transparent;
  cursor: pointer;
}
.show-zones .zone {
  outline: 2px dashed rgba(229, 50, 45, .7);
  background: rgba(229, 50, 45, .08);
}
.show-zones .zone::after {
  content: attr(data-label);
  position: absolute;
  left: 4px; top: 2px;
  font-size: 12px;
  color: #E5322D;
}

/* ---- ふきだし ---- */
.bubble {
  position: relative;
  white-space: pre-line;   /* セリフの中の改行（\n）をそのまま表示 */
  min-height: 3.2em;
  max-width: min(84vw, 380px);
  margin-bottom: 10px;
  padding: 12px 20px;
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 4px 14px rgba(74, 46, 22, .15);
  font-size: clamp(17px, 4.8vw, 22px);
  font-weight: 700;
  line-height: 1.4;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: translateY(6px) scale(.9);
  transition: opacity .2s, transform .2s;
}
.bubble::after {
  content: "";
  position: absolute;
  bottom: -10px; left: 50%;
  margin-left: -10px;
  border: 10px solid transparent;
  border-bottom: 0;
  border-top-color: #fff;
}
.bubble.on {
  opacity: 1;
  transform: none;
  transition: opacity .12s, transform .25s cubic-bezier(.3, 1.6, .5, 1);
}

/* ---- 思い出（特別イラスト）：全画面で絵と台詞 ---- */
.event { position: fixed; inset: 0; z-index: 40; background: #000; opacity: 0; transition: opacity .4s; cursor: pointer; }
.event[hidden] { display: none; }
.event.on { opacity: 1; }
.ev-pic { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
/* 絵は全体が見えるように（スマホは絵より縦長なので、あいた所は同じ絵をぼかして埋める） */
.ev-img { position: relative; width: 100%; height: 100%; object-fit: contain; object-position: 50% 35%;
  animation: ev-in 1.2s ease-out; }
.ev-bg { position: absolute; inset: -40px; width: calc(100% + 80px); height: calc(100% + 80px); object-fit: cover;
  filter: blur(22px) brightness(.65); }
.ev-pic.stand .ev-bg { display: none; }
.ev-pic.stand .ev-img { width: auto; height: 66%; max-width: 92%; object-fit: contain; margin-bottom: 22%; }
@keyframes ev-in { from { transform: scale(1.06); filter: brightness(1.4); } to { transform: none; filter: none; } }
.ev-title { position: absolute; top: calc(env(safe-area-inset-top) + 16px); left: 50%; transform: translateX(-50%);
  background: rgba(255, 255, 255, .85); color: #C8641E; font-weight: 800; font-size: 15px;
  padding: 6px 16px; border-radius: 999px; white-space: nowrap; }
.ev-skip { position: absolute; top: calc(env(safe-area-inset-top) + 12px); right: 12px; width: 36px; height: 36px;
  border: 0; border-radius: 50%; background: rgba(0, 0, 0, .35); color: #fff; font-size: 20px; cursor: pointer; }
/* 思い出が始まる前の合図 */
.ev-intro { position: absolute; inset: 0; z-index: 2; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; text-align: center; padding: 24px;
  background: radial-gradient(circle at 50% 42%, #FFE3EE 0%, #FFC2D6 45%, #F59AB8 100%); transition: opacity .45s; }
.ev-intro[hidden] { display: none; }
.ev-intro.out { opacity: 0; }
.ev-bigheart { font-size: 110px; line-height: 1; animation: bigheart 1.1s cubic-bezier(.3, 1.6, .5, 1) both, beat 1.2s ease-in-out 1.1s infinite; }
@keyframes bigheart { from { transform: scale(0) rotate(-20deg); } to { transform: scale(1); } }
@keyframes beat { 50% { transform: scale(1.12); } }
.ev-i1 { margin: 6px 0 0; font-size: 24px; font-weight: 900; color: #fff; -webkit-text-stroke: 6px #E0457C; paint-order: stroke fill;
  animation: fadeup .6s .5s both; }
.ev-i2 { margin: 0; font-size: 17px; font-weight: 800; color: #8A2E52; animation: fadeup .6s .9s both; }
.ev-i3 { margin: 18px 0 0; font-size: 13px; color: #8A2E52; opacity: .7; animation: fadeup .5s 1.4s both, blink 1.4s 2.2s infinite; }
@keyframes fadeup { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
/* 合図の間は、絵と台詞の枠をかくしておく */
.event.intro .ev-box, .event.intro .ev-title { visibility: hidden; }
.ev-box { position: absolute; left: 12px; right: 12px; bottom: calc(env(safe-area-inset-bottom) + 16px);
  min-height: 112px; padding: 26px 18px 18px; border-radius: 18px;
  background: rgba(255, 249, 239, .93); border: 2px solid #F0C9A0; box-shadow: 0 6px 20px rgba(0, 0, 0, .3); }
.ev-name { position: absolute; top: -14px; left: 16px; background: #F08A3C; color: #fff; font-weight: 800;
  font-size: 14px; padding: 4px 14px; border-radius: 999px; }
.ev-text { margin: 0; font-size: 18px; font-weight: 700; line-height: 1.6; min-height: 1.6em; }
.event.sys .ev-name { display: none; }
.event.sys .ev-text { text-align: center; color: #C8641E; }
.ev-next { position: absolute; right: 16px; bottom: 10px; color: #F08A3C; font-size: 14px; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }
/* 思い出アルバム */
.album { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.mem { display: flex; flex-direction: column; gap: 4px; padding: 0; border: 0; background: none; font: inherit;
  color: inherit; cursor: pointer; text-align: center; }
.mem-pic { display: flex; align-items: center; justify-content: center; aspect-ratio: 2 / 3; overflow: hidden;
  border-radius: 12px; background: #fff; box-shadow: 0 2px 0 rgba(74, 46, 22, .15); }
.mem-pic img { width: 100%; height: 100%; object-fit: cover; }
.mem-pic.stand img { width: 90%; height: auto; object-fit: contain; }
.mem.locked .mem-pic { background: #EADFCF; color: #B9A88F; font-size: 34px; font-weight: 900; }
.mem-t { font-size: 11px; font-weight: 700; line-height: 1.3; word-break: break-all; }
.mem.locked .mem-t { opacity: .6; font-weight: 400; }

/* ---- なでなでゲージ（本編の遊ぶ画面だけ） ---- */
.gauge { display: none; gap: 4px; margin-top: 14px; }
body.mode-play:not(.demo) .gauge { display: flex; }
.gauge svg { width: 18px; height: 18px; fill: #CDBFA8; opacity: .55; transition: fill .2s, opacity .2s; }
.gauge svg.on { fill: #6FA544; opacity: 1; animation: pop .35s cubic-bezier(.3, 1.6, .5, 1); }
.gauge.full svg { animation: leaf-shine .9s ease-in-out; }
@keyframes leaf-shine { 50% { transform: translateY(-3px) scale(1.15); } }

/* ---- なでなでレポート ---- */
.rep-pic { position: relative; width: 55%; max-width: 220px; margin: 0 auto; aspect-ratio: 4 / 5; }
.rep-pic .res-img { width: 100%; max-width: none; }
.rep-pic img:not(.res-img) { position: absolute; transform: translate(-50%, -50%); }
.rep-pic img.full { left: 0; top: 0; width: 100%; height: 100%; transform: none; object-fit: contain; }
.rep-day { margin: 0; text-align: center; font-size: 15px; opacity: .75; }
.rep { width: 100%; border-collapse: collapse; font-size: 15px; }
.rep th { text-align: left; font-weight: 700; padding: 5px 4px; white-space: nowrap; width: 4.5em; }
.rep td { padding: 5px 4px; }
.rep .bar { letter-spacing: -2px; font-size: 14px; }
.rep .num { text-align: right; font-weight: 700; white-space: nowrap; width: 3em; }
.rep tr.secret th, .rep tr.secret .num { color: #8A6FB0; }

/* 本編では、さわる場所の案内は出さない（どこが反応するかは、自分で探してもらう）。お試し版だけ表示 */
body:not(.demo) .hint { display: none; }
.hint {
  margin: 22px 0 0;
  font-size: 14px;
  opacity: .55;
}

@media (prefers-reduced-motion: reduce) {
  #tanu-breath { animation: none; }
}
