/* ぴよずの世界 — 見た目。色はここだけで変える */
:root {
  --ink: #3b2a14;
  --wood: #8a5a2b;
  --paper: #fff8ea;
  --paper-80: rgba(255, 248, 234, 0.86);
  --accent: #e4583f;
  --leaf: #2b7a4b;
  --font: "Hiragino Maru Gothic ProN", "BIZ UDPGothic", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #cfe4ea; }
body { font-family: var(--font); color: var(--ink); -webkit-font-smoothing: antialiased; touch-action: none; }

#world { position: fixed; inset: 0; display: block; cursor: grab; touch-action: none; }
#world:active { cursor: grabbing; }

/* ---------- 読み込み ---------- */
/* 1枚目の背景のぼかし版（数百バイト）を敷き、その上で主人公が「道」を歩いて読み込みを進める */
#loader {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
  background: #f6efdc; color: var(--ink); overflow: hidden; transition: opacity 0.9s ease 0.15s, visibility 0.9s 0.15s;
}
.loader-bg {
  position: absolute; inset: -40px; background: url("assets/bg/s1-garden-morning-tiny.webp") center / cover no-repeat;
  filter: blur(18px) saturate(1.1); opacity: 0.75; transform: scale(1.05); transition: transform 1.4s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.loader-body {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 32px 28px 28px;
  width: min(420px, calc(100vw - 32px)); background: rgba(255, 248, 234, 0.72); border-radius: 28px;
  box-shadow: 0 20px 60px rgba(80, 60, 20, 0.18); text-align: center; transition: transform 0.9s cubic-bezier(0.6, 0, 0.3, 1);
}
#loader .sub { margin: 0; font-size: 10px; letter-spacing: 0.5em; color: var(--wood); }
#loader .ttl { margin: 0; font-size: 30px; letter-spacing: 0.12em; font-weight: 700; text-shadow: 0 2px 0 #fff; }
#loader .lead { margin: 2px 0 6px; font-size: 13px; line-height: 1.8; letter-spacing: 0.06em; word-break: keep-all; overflow-wrap: anywhere; }
#loader .path { position: relative; width: min(64vw, 280px); height: 74px; margin-top: 4px; }
#walker { position: absolute; bottom: 8px; left: 0; width: 60px; transform: translateX(-50%); transition: left 0.35s ease-out; }
#walker img { display: block; width: 100%; height: auto; transform-origin: 50% 100%; animation: walker-step 0.42s ease-in-out infinite alternate; }
#loader.loaded #walker img { animation: walker-hop 1.1s ease-in-out infinite; }
@keyframes walker-step {
  from { transform: translateY(0) rotate(-5deg); }
  to { transform: translateY(-6px) rotate(5deg); }
}
@keyframes walker-hop {
  0%, 60%, 100% { transform: translateY(0) scale(1, 1); }
  70% { transform: translateY(0) scale(1.08, 0.92); }
  82% { transform: translateY(-14px) scale(0.96, 1.05); }
}
#loader .track { position: absolute; left: 0; right: 0; bottom: 4px; height: 4px; background: rgba(59, 42, 20, 0.15); border-radius: 2px; overflow: hidden; }
#bar { height: 100%; width: 0; background: var(--accent); transition: width 0.35s ease-out; }
#pct, #loaderMsg { font-family: var(--mono); font-size: 12px; margin: 0; min-height: 1em; }
#loader.loaded #pct { font-family: var(--font); letter-spacing: 0.1em; color: var(--leaf); }
#enterBtn {
  margin-top: 6px; font: inherit; font-size: 16px; font-weight: 700; letter-spacing: 0.2em; color: #fff; background: var(--accent);
  border: 0; border-radius: 999px; padding: 14px 34px; cursor: pointer; box-shadow: 0 6px 0 #b8402c, 0 10px 24px rgba(228, 88, 63, 0.35);
  animation: enter-in 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.3) both;
}
/* 出る前も場所は取っておき、出た瞬間に板の高さが変わって全体がずれないようにする */
#enterBtn[hidden] { display: block; visibility: hidden; animation: none; }
#enterBtn:hover { transform: translateY(-1px); }
#enterBtn:active { transform: translateY(4px); box-shadow: 0 2px 0 #b8402c, 0 4px 12px rgba(228, 88, 63, 0.35); }
#enterBtn:focus-visible { outline: 3px solid var(--ink); outline-offset: 4px; }
@keyframes enter-in {
  from { opacity: 0; transform: translateY(10px) scale(0.9); }
  to { opacity: 1; transform: none; }
}
/* 入場: 板が上へ抜け、背景のぼかしが寄って、後ろの村が円く開く */
#loader.done { opacity: 0; visibility: hidden; pointer-events: none; }
#loader.done .loader-body { transform: translateY(-40px) scale(0.96); }
#loader.done .loader-bg { transform: scale(1.4); }
#world { clip-path: circle(0% at 50% 62%); transition: clip-path 1.3s cubic-bezier(0.5, 0, 0.2, 1); }
body.ready #world { clip-path: circle(150% at 50% 62%); }

/* ---------- HUD ---------- */
.hud { position: fixed; z-index: 10; pointer-events: none; opacity: 0; transition: opacity 0.8s ease 0.2s; }
body.ready .hud { opacity: 1; }
.hud > * { pointer-events: auto; }

#brand { left: 20px; top: 16px; }
#brand h1 { margin: 0; font-size: 22px; letter-spacing: 0.08em; text-shadow: 0 1px 0 #fff; }
#brand p { margin: 2px 0 0; font-size: 10px; letter-spacing: 0.4em; color: var(--wood); }

#help {
  /* 右上のボタンと重ならないよう、中央より少し左に置き、狭いときは折り返す（切り詰めない） */
  left: 42%; top: 18px; transform: translateX(-50%); max-width: calc(100vw - 700px);
  font-size: 12px; letter-spacing: 0.08em; color: var(--ink); background: var(--paper-80);
  padding: 6px 14px; border-radius: 16px; text-align: center; line-height: 1.6; transition: opacity 0.6s;
}
/* 一度動かしたら操作の説明は消す（キャラの上に残らないように） */
body.moved #help { opacity: 0; pointer-events: none; }
@media (min-width: 701px) and (max-width: 1280px) {
  #help { left: 50%; top: auto; bottom: 74px; max-width: calc(100vw - 32px); }
}

#side { right: 16px; top: 16px; display: flex; gap: 8px; }
.pill {
  font: inherit; font-size: 12px; letter-spacing: 0.1em; color: var(--ink); background: var(--paper-80);
  border: 1px solid rgba(138, 90, 43, 0.4); border-radius: 999px; padding: 8px 14px; cursor: pointer;
}
.pill:hover, .pill:focus-visible { background: #fff; border-color: var(--wood); outline: none; }

#hunt {
  left: 20px; bottom: 20px; background: var(--paper-80); border-radius: 12px; padding: 8px 12px;
  font-size: 12px; letter-spacing: 0.08em; display: flex; align-items: center; gap: 8px;
}
#hunt b { font-family: var(--mono); font-size: 14px; }

#scenes { left: 50%; bottom: 18px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; }
#sceneName { font-size: 12px; letter-spacing: 0.2em; background: var(--paper-80); padding: 2px 10px; border-radius: 999px; }
#scenes nav { display: flex; gap: 6px; }
#scenes button {
  width: 32px; height: 32px; padding: 0; border: 1px solid rgba(138, 90, 43, 0.4); background: var(--paper-80);
  color: var(--ink); border-radius: 8px; font: inherit; font-size: 13px; cursor: pointer; transition: transform 0.15s;
}
#scenes button:hover { transform: translateY(-2px); }
#scenes button.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }

/* ---------- パネル ---------- */
#panelBack { position: fixed; inset: 0; z-index: 20; background: rgba(40, 30, 10, 0.35); opacity: 0; visibility: hidden; transition: 0.3s; border: 0; padding: 0; }
#panel {
  position: fixed; z-index: 21; right: 0; top: 0; bottom: 0; width: min(460px, 100vw); background: var(--paper);
  box-shadow: -10px 0 40px rgba(0, 0, 0, 0.2); transform: translateX(100%); transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  overflow-y: auto; padding: 24px 24px 40px;
}
#panel.open { transform: none; }
#panel.open ~ #panelBack, body:has(#panel.open) #panelBack { opacity: 1; visibility: visible; }
#panelClose {
  position: sticky; top: 0; float: right; width: 40px; height: 40px; border-radius: 50%; border: 1px solid rgba(138, 90, 43, 0.4);
  background: #fff; font-size: 20px; cursor: pointer; color: var(--ink);
}
.panel-eyebrow { font-size: 11px; letter-spacing: 0.4em; color: var(--wood); margin: 8px 0 4px; font-weight: 600; }
.panel-title { font-size: 24px; margin: 4px 0 12px; line-height: 1.4; word-break: keep-all; overflow-wrap: anywhere; }
#panel p { line-height: 1.9; margin: 8px 0; font-size: 15px; }
#panel .lead { font-size: 16px; font-weight: 600; }
.card { display: grid; grid-template-columns: 110px 1fr; gap: 16px; align-items: start; padding: 16px 0; border-top: 1px solid rgba(138, 90, 43, 0.2); }
.card:first-of-type { border-top: 0; }
.card-img { width: 110px; height: 130px; object-fit: contain; background: rgba(255, 255, 255, 0.6); border-radius: 12px; }
.card h3 { margin: 0 0 6px; font-size: 20px; }
.card p { margin: 0 0 6px; font-size: 14px; line-height: 1.8; }
.card-en, #panel .card-en { font-family: var(--mono); font-size: 11px; letter-spacing: 0.2em; color: var(--wood); margin: 0 0 2px; }
.card-note, #panel .card-note { font-size: 12px; color: #7a6a52; }
.status { font-size: 13px; color: #9a7b3c; font-weight: 600; }
.status.ready { color: var(--leaf); }
.points { padding-left: 1.2em; line-height: 1.9; font-size: 14px; }
.maker { font-weight: 600; }
.cta { background: rgba(228, 88, 63, 0.08); padding: 12px 14px; border-radius: 10px; }
.btn { display: inline-block; margin-top: 8px; padding: 12px 20px; background: var(--accent); color: #fff; border-radius: 999px; text-decoration: none; font-weight: 600; letter-spacing: 0.1em; }

/* 試し読み・試し見・記念カード */
.reader { margin: 12px 0 4px; }
.reader img, #trialVideo, .card-preview {
  display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; border-radius: 12px; background: #e9dfc8;
  box-shadow: 0 6px 18px rgba(60, 40, 10, 0.18);
}
.card-preview { aspect-ratio: 1200 / 630; margin: 12px 0; }
.reader img { cursor: pointer; }
.reader figcaption { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 8px; font-family: var(--mono); font-size: 13px; }
.page-btn {
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid rgba(138, 90, 43, 0.4); background: #fff;
  font-size: 22px; line-height: 1; color: var(--ink); cursor: pointer;
}
.page-btn:hover, .page-btn:focus-visible { border-color: var(--wood); outline: none; background: #fffaf0; }
.panel-sub { font-size: 14px; letter-spacing: 0.08em; margin: 18px 0 8px; color: var(--wood); }
#soundBtn[aria-pressed="false"] { color: #8a7a62; }

#toast {
  position: fixed; z-index: 15; left: 50%; bottom: 120px; transform: translate(-50%, 20px); background: var(--ink); color: var(--paper);
  padding: 12px 20px; border-radius: 999px; font-size: 14px; letter-spacing: 0.06em; opacity: 0; transition: 0.4s; pointer-events: none; max-width: calc(100vw - 32px); text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
/* 曲が変わったときに音のボタンの下へ曲名を少しだけ出す */
#nowPlaying {
  position: fixed; z-index: 14; right: 16px; top: 62px; background: rgba(255, 250, 238, 0.92); color: var(--ink);
  padding: 4px 12px; border-radius: 999px; font-size: 12px; letter-spacing: 0.06em; opacity: 0; transform: translateY(-4px); transition: 0.5s; pointer-events: none;
}
#nowPlaying.show { opacity: 1; transform: none; }

/* ---------- おたより ---------- */
.pill-mail { background: var(--accent); color: #fff; border-color: var(--accent); }
.pill-mail:hover, .pill-mail:focus-visible { background: #c9452f; color: #fff; border-color: #c9452f; }
.pill-mail.pulse { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(228, 88, 63, 0.55); } 50% { box-shadow: 0 0 0 8px rgba(228, 88, 63, 0); } }
button.btn { font: inherit; border: 0; cursor: pointer; }
.btn-sub { background: transparent; color: var(--accent); border: 1px solid var(--accent) !important; padding: 9px 16px; font-size: 14px; }
.btn-yt { background: #c4302b; }
.fb { display: grid; gap: 12px; margin-top: 12px; }
.fb-kinds { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.fb-kinds label { display: inline-flex; align-items: center; gap: 4px; padding: 6px 10px; border: 1px solid rgba(138, 90, 43, 0.35); border-radius: 999px; font-size: 14px; cursor: pointer; }
.fb-kinds label:has(input:checked) { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.fb-kinds input { accent-color: var(--accent); }
.fb-row { display: grid; gap: 4px; font-size: 14px; }
.fb textarea, .fb input[name="nickname"], .fb select {
  font: inherit; font-size: 16px; color: var(--ink); background: #fff; border: 1px solid rgba(138, 90, 43, 0.4); border-radius: 10px; padding: 8px 10px; width: 100%; box-sizing: border-box;
}
.fb textarea { resize: vertical; min-height: 110px; }
.fb-check { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; }
.fb-trap { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.fb-msg { min-height: 1.4em; color: var(--accent); font-size: 14px; margin: 0; }
.fb-thanks { font-size: 18px; font-weight: 700; color: var(--ink); padding: 24px 0; text-align: center; }
.voices { list-style: none; padding: 0; display: grid; gap: 10px; }
.voices li { background: #fff; border-radius: 12px; padding: 12px 14px; font-size: 14px; line-height: 1.7; }
.voice-kind { display: block; font-size: 12px; color: var(--accent); letter-spacing: 0.1em; }
.voice-name { display: block; text-align: right; font-size: 12px; color: #8a7a62; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- スマホ ---------- */
/* 縦持ちのスマホ: 上に「題名・ボタン・さがせ」、下に「操作の説明・場面」を分けて重ねない */
@media (max-width: 700px) {
  #brand { left: 12px; top: 12px; }
  #brand h1 { font-size: 17px; }
  #brand p { font-size: 9px; letter-spacing: 0.3em; }
  #side { top: 12px; right: 10px; gap: 6px; }
  /* おたよりは 2 段目の右端（題名・さがせと重ならない位置） */
  #mailBtn { position: absolute; right: 0; top: 40px; }
  .pill { font-size: 12px; padding: 6px 9px; letter-spacing: 0.02em; }
  /* 音のボタンは「♪」だけにして、ほかのボタンの文字を 12px に保つ（ON/OFF は色と aria-pressed で示す） */
  #soundBtn { font-size: 14px; padding: 4px 11px; }
  #soundBtn .snd-label { display: none; }
  #nowPlaying { top: 92px; right: 10px; }
  #soundBtn[aria-pressed="false"] .snd-icon { text-decoration: line-through; }
  #hunt { top: 60px; left: 12px; bottom: auto; font-size: 12px; padding: 6px 10px; }
  #help { top: auto; bottom: 66px; font-size: 10px; max-width: calc(100vw - 24px); white-space: normal; text-align: center; line-height: 1.6; letter-spacing: 0.04em; }
  #scenes { bottom: 14px; }
  #scenes button { width: 28px; height: 28px; font-size: 12px; }
  #sceneName { font-size: 12px; }
  #toast { bottom: 150px; font-size: 13px; }
}
/* 横持ちのスマホ: 高さが無いので操作の説明は出さない */
@media (max-height: 500px) {
  .loader-body { padding: 18px 24px 18px; gap: 6px; }
  #loader .ttl { font-size: 24px; }
  #loader .lead { display: none; }
  #loader .path { height: 60px; }
  #walker { width: 48px; }
  #enterBtn { padding: 11px 28px; margin-top: 2px; }
  #help { display: none; }
  #hunt { top: auto; bottom: 16px; left: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
