/* リンゴ探偵と消えた手紙 ― 見た目
   色: 雲海の白・空の水色（#8ccbec）・りんごの赤（#d8342c）・木のベンチの茶（#8a5a36）・紙のクリーム（#f6efe1）。やさしい昼の色
   字は游ゴシック（外から読みこまない）。文の窓はクリームの紙に赤い細線。区切りの飾りは、りんごと肉球
   スマホの縦を一番に。パソコンはまん中に縦長の画面（最大幅 560px） */

:root {
  --sky: #8ccbec;
  --sky-hi: #c6e6f6;
  --sky-pale: #eaf6fc;
  --sky-ink: #2f7fb8;
  --cloud: #ffffff;
  --apple: #d8342c;
  --apple-hi: #ef5a4c;
  --apple-dk: #a8221c;
  --apple-soft: rgba(216, 52, 44, 0.55);
  --apple-faint: rgba(216, 52, 44, 0.22);
  --wood: #8a5a36;
  --wood-dk: #5e3b22;
  --wood-soft: rgba(138, 90, 54, 0.35);
  --leaf: #5aa05a;
  --paper: #f6efe1;
  --paper-2: #efe3cb;
  --ink: #3a2a20;
  --ink-dim: #6f5a48;
  --ink-faint: #a08c78;
  --ok: #4f9a63;
  --font: "Yu Gothic", "YuGothic", "Hiragino Maru Gothic ProN", "Hiragino Sans", "Noto Sans JP", "Meiryo", sans-serif;
  --text-size: clamp(17px, 4.5vw, 19px);
  --btn-h: 52px;
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--sky);
  background-image: radial-gradient(ellipse 80% 40% at 50% 100%, #ffffff 0%, rgba(255, 255, 255, 0) 70%), linear-gradient(180deg, #8ccbec, #dff1fa);
  color: var(--ink);
  font-family: var(--font);
  font-weight: 500;
  overflow: hidden;
  -webkit-user-select: none; user-select: none;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}
button { font-family: inherit; color: inherit; }

/* ───────── 画面のわく ───────── */
#app {
  position: relative; z-index: 1;
  width: 100%; max-width: 560px; margin: 0 auto;
  height: 100vh; height: 100dvh;
  display: flex; flex-direction: column;
  overflow: hidden;
  background: var(--paper);
  box-shadow: 0 0 0 1px var(--wood-soft), 0 0 60px rgba(47, 127, 184, 0.25);
}

/* 上の帯 */
#topbar {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 8px;
  min-height: 52px; padding: 4px 6px 4px 12px;
  padding-top: max(4px, env(safe-area-inset-top));
  background: linear-gradient(180deg, #ffffff, var(--sky-pale));
  border-bottom: 2px solid var(--apple-faint);
  position: relative; z-index: 20;
}
#tb-title {
  flex: 1 1 auto; min-width: 0;
  font-size: 14px; line-height: 1.35; color: var(--ink);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  letter-spacing: .04em;
}
#tb-title .kind { color: var(--apple); margin-right: 6px; letter-spacing: .12em; font-weight: 700; }
#lamps { flex: 0 0 auto; display: flex; gap: 1px; align-items: center; }
#lamps[hidden] { display: none; }

.ibtn {
  flex: 0 0 auto; width: 44px; height: 44px; border-radius: 10px;
  border: 1px solid var(--wood-soft); background: var(--paper); color: var(--wood-dk);
  font-size: 20px; line-height: 1; cursor: pointer; display: grid; place-items: center;
}
.ibtn:active { transform: translateY(1px); }

/* ───────── りんご・肉球・封筒（命・飾り・演出で共通） ───────── */
.ap { position: relative; width: 28px; height: 28px; }
.ap svg { width: 100%; height: 100%; display: block; overflow: visible; }
.ap .body { fill: var(--apple); stroke: var(--apple-dk); stroke-width: 1.4; }
.ap .leaf { fill: var(--leaf); stroke: #3f7a3f; stroke-width: 1; }
.ap .stem { stroke: var(--wood-dk); stroke-width: 2; fill: none; stroke-linecap: round; }
.ap .hi { stroke: #ffffff; stroke-width: 2.2; fill: none; stroke-linecap: round; opacity: .75; }
.pw { position: relative; width: 22px; height: 22px; }
.pw svg { width: 100%; height: 100%; display: block; fill: var(--wood); opacity: .85; }
.ev { position: relative; width: 64px; height: 44px; }
.ev svg { width: 100%; height: 100%; display: block; overflow: visible; }
.ev .paper { fill: #fffaf0; stroke: var(--wood); stroke-width: 1.6; }
.ev .flap { fill: none; stroke: var(--wood); stroke-width: 1.6; stroke-linejoin: round; }
.ev .fold { fill: none; stroke: var(--wood-soft); stroke-width: 1.2; }
.ev .seal { fill: var(--apple); stroke: var(--apple-dk); stroke-width: 1; }

.life { width: 26px; height: 26px; display: inline-block; position: relative; }
.life .ap { width: 24px; height: 24px; opacity: .2; filter: grayscale(1); }
.life.on .ap { opacity: 1; filter: none; animation: sway 3.4s ease-in-out infinite; transform-origin: 50% 90%; }
.life:nth-child(2) .ap { animation-delay: -.7s; } .life:nth-child(3) .ap { animation-delay: -1.5s; }
.life:nth-child(4) .ap { animation-delay: -2.2s; } .life:nth-child(5) .ap { animation-delay: -2.9s; }
.life.rollaway .ap { animation: rollaway 1s cubic-bezier(.4, 0, .9, .6) forwards; }

/* ───────── 舞台 ───────── */
#stage { position: relative; flex: 1 1 auto; min-height: 200px; overflow: hidden; background: var(--sky-pale); }
#stage.quake { animation: quake .45s linear 1; }
.bg-layer { position: absolute; inset: 0; opacity: 0; transition: opacity .45s ease; overflow: hidden; }
.bg-layer.show { opacity: 1; }
.bg-layer.img { background-size: cover; background-position: center; }
.snow { position: absolute; inset: 0; pointer-events: none; }
.snow i { position: absolute; top: -10px; border-radius: 50%; background: #ffffff; animation: snowfall 9s linear infinite; }

/* 人物 */
#chars { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
.chara {
  position: absolute; bottom: 4%;
  transform: translateX(-50%);
  transition: left .35s ease, width .35s ease, filter .25s ease, opacity .3s ease;
}
.chara.enter { opacity: 0; }
.chara.dim { filter: brightness(.82) saturate(.8); }
.chara.dim2 { filter: brightness(.92); }
.chara .frame {
  position: relative; width: 100%; aspect-ratio: 520 / 560; border-radius: 14px; overflow: hidden;
  border: 2px solid #ffffff;
  box-shadow: 0 8px 22px rgba(58, 42, 32, 0.28), 0 0 0 1px var(--wood-soft);
  background: var(--card, #f6efe1);
  background: radial-gradient(ellipse 72% 62% at 50% 42%, #ffffff 0%, var(--card, #f6efe1) 62%, color-mix(in srgb, var(--card, #f6efe1) 80%, #c6e6f6) 100%);
  transition: transform .2s ease;
}
.chara.talk { z-index: 2; }
.chara.talk .frame { transform: translateY(-6px) scale(1.04); box-shadow: 0 10px 26px rgba(58, 42, 32, 0.32), 0 0 0 2px var(--apple-soft), 0 0 20px rgba(216, 52, 44, 0.25); }
.chara .frame img { position: absolute; inset: 0; width: 100%; height: 100%; display: block; -webkit-user-drag: none; object-fit: contain; object-position: 50% 100%; }
.chara.k-stand .frame { aspect-ratio: 480 / 1120; border: 0; border-radius: 0; background: transparent; box-shadow: none; overflow: visible; }
.chara.k-stand.talk .frame { transform: none; box-shadow: none; }
.chara.k-stand .frame img { object-fit: contain; object-position: 50% 100%; }
.chara .shake-box { width: 100%; }
.chara.shake .shake-box { animation: shake .5s linear 1; }
.chara.jump .shake-box { animation: jump .5s ease-out 1; }

/* 光（見破った時は、あたたかい白） */
#fx-flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; z-index: 30; }
#fx-flash.on { animation: flash .5s ease-out 1; }

/* 舞台の上の札 */
#toast {
  position: absolute; left: 50%; top: 64px; transform: translateX(-50%) translateY(-8px);
  padding: 8px 18px; border-radius: 20px; background: rgba(255, 250, 240, 0.97); border: 1px solid var(--apple);
  color: var(--apple-dk); font-size: 16px; font-weight: 700; letter-spacing: .08em; opacity: 0; transition: opacity .25s, transform .25s;
  pointer-events: none; z-index: 60; white-space: nowrap; box-shadow: 0 3px 10px rgba(58, 42, 32, 0.18);
}
#toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 推理の糸の板 */
#board {
  position: absolute; left: 10px; right: 10px; top: 10px; z-index: 5;
  padding: 10px 12px; border-radius: 10px; background: rgba(255, 250, 240, 0.96); border: 1px solid var(--apple-soft);
  font-size: 15px; line-height: 1.5; box-shadow: 0 4px 14px rgba(58, 42, 32, 0.15);
}
#board[hidden] { display: none; }
#board h3 { margin: 0 0 4px; font-size: 13px; color: var(--apple); letter-spacing: .2em; font-weight: 700; }
#board ol { margin: 0; padding-left: 1.4em; }
#board li { color: var(--ink-dim); }
#board li b { color: var(--apple-dk); font-weight: 700; }

/* ヒント役（モモコ）。舞台の左下からのぞく。手帳の印つき */
#sabi {
  position: absolute; left: 10px; bottom: 36px; width: 92px; height: 99px; z-index: 6;
  border-radius: 12px; overflow: hidden; border: 2px solid var(--apple); background: var(--paper);
  transform: translateY(140%); opacity: 0; transition: transform .35s cubic-bezier(.2, 1.2, .4, 1), opacity .25s;
  pointer-events: none; box-shadow: 0 4px 12px rgba(58, 42, 32, 0.25);
}
#sabi.on { transform: none; opacity: 1; }
#sabi img { width: 100%; height: 100%; object-fit: cover; display: block; }
#sabi .note { position: absolute; right: 3px; bottom: 3px; width: 40px; height: 30px; animation: flip 1.1s ease-in-out infinite; }
#sabi .note svg { width: 100%; height: 100%; display: block; }
#sabi .note rect { fill: #fffaf0; stroke: var(--wood); stroke-width: 1.4; }
#sabi .note path { stroke: var(--apple); stroke-width: 1.2; }

/* ───────── 聞き込み（一枚絵と調べる所） ───────── */
#scene { position: absolute; inset: 0; z-index: 2; overflow: hidden; background: var(--sky-pale); touch-action: none; }
#scene[hidden] { display: none; }
#scene .pic { position: absolute; left: 0; top: 0; will-change: transform; }
#scene .pic.smooth { transition: transform .35s ease; }
#scene .pic-bg { position: absolute; inset: 0; background-size: cover; background-position: center; }
#scene .spots { position: absolute; inset: 0; }
.spot { position: absolute; padding: 0; margin: 0; border: 0; background: transparent; cursor: pointer; border-radius: 8px; transition: background .2s, box-shadow .2s; }
.spot .glint {
  position: absolute; left: 50%; top: 50%; width: 20px; height: 20px; margin: -10px 0 0 -10px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 1) 0%, rgba(255, 214, 120, 0.85) 40%, rgba(255, 214, 120, 0) 72%);
  animation: glint 2.6s ease-in-out infinite; pointer-events: none;
}
.spot:nth-child(2n) .glint { animation-delay: -1.1s; } .spot:nth-child(3n) .glint { animation-delay: -1.9s; }
.spot.seen .glint { display: none; }
.spot .mark {
  display: none; position: absolute; right: 3px; top: 3px; font-size: 11px; line-height: 1; padding: 3px 4px; border-radius: 4px;
  background: rgba(255, 250, 240, 0.92); color: var(--ink-dim); border: 1px solid var(--wood-soft); pointer-events: none;
}
.spot.seen .mark { display: block; }
.spot .tag {
  display: none; position: absolute; left: 50%; bottom: calc(100% + 6px); transform: translateX(-50%); white-space: nowrap;
  font-size: 13px; padding: 3px 9px; border-radius: 12px; background: rgba(255, 250, 240, 0.96); border: 1px solid var(--apple); color: var(--ink); pointer-events: none;
}
.spot:hover .tag, .spot.kbsel .tag { display: block; }
.spot:hover, .spot.kbsel { background: rgba(255, 255, 255, 0.18); box-shadow: inset 0 0 0 2px rgba(216, 52, 44, 0.85), 0 0 0 1px rgba(255, 255, 255, 0.8); }
.spot.hinted { animation: hintpulse 1.3s ease-in-out infinite; }
.spot.hinted .glint { width: 32px; height: 32px; margin: -16px 0 0 -16px; }
#scene.busy .spot { opacity: 0; pointer-events: none; }
#scene.busy .spot.hinted { opacity: 1; }
#scene.busy .spot.hinted .tag { display: block; }
#scene .pan {
  position: absolute; top: 10px; width: 44px; height: 44px; z-index: 3; cursor: pointer;
  border-radius: 10px; background: rgba(255, 250, 240, 0.85); border: 1px solid var(--wood-soft); color: var(--wood-dk); font-size: 16px;
}
#scene .pan.l { left: 6px; } #scene .pan.r { right: 6px; }
#scene .pan[hidden], #scene.busy .pan { display: none; }

/* ───────── 文の窓（クリームの紙に、赤い細線） ───────── */
#textbox {
  position: relative; flex: 0 0 auto;
  height: 172px; margin: 0 8px; margin-top: -26px; z-index: 10;
  padding: 26px 18px 12px;
  border-radius: 10px;
  background: rgba(253, 248, 236, 0.97);
  border: 1px solid var(--apple-soft);
  box-shadow: 0 -4px 18px rgba(58, 42, 32, 0.16), inset 0 0 0 4px #fdf8ec, inset 0 0 0 5px var(--apple-faint);
  cursor: pointer;
}
#nameplate {
  position: absolute; left: 12px; top: -15px; min-width: 96px; padding: 4px 16px;
  border-radius: 14px; background: #ffffff; border: 1px solid var(--nc, var(--apple));
  font-weight: 700; font-size: 16px; letter-spacing: .14em; color: var(--nc, var(--ink));
  box-shadow: 0 2px 8px rgba(58, 42, 32, 0.18);
}
#nameplate[hidden] { display: none; }
#text {
  height: 100%; overflow-y: auto; overscroll-behavior: contain;
  font-size: var(--text-size); line-height: 1.7; white-space: pre-wrap; word-break: break-word; letter-spacing: .03em;
  scrollbar-width: none; color: var(--ink);
}
#text::-webkit-scrollbar { display: none; }
#text.narr { color: var(--ink-dim); }
#text.low { color: #5b3d6e; letter-spacing: .07em; }
#text.testi { color: var(--apple-dk); font-weight: 700; }
#text.sys { color: var(--sky-ink); }
#text.question { color: var(--ink); }
#text .qno { display: block; font-size: 13px; color: var(--apple); letter-spacing: .14em; margin-bottom: 2px; font-weight: 700; }
#next-mark { position: absolute; right: 14px; bottom: 8px; color: var(--apple); font-size: 13px; opacity: 0; }
#textbox.waiting #next-mark { opacity: 1; animation: bob 1s ease-in-out infinite; }
#textbox .testi-mark { position: absolute; right: 12px; top: 6px; font-size: 12px; color: var(--apple); letter-spacing: .2em; font-weight: 700; }

/* ───────── ボタンの段 ───────── */
#controls {
  flex: 0 0 auto; padding: 10px 8px; padding-bottom: max(10px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 8px; min-height: 64px;
}
.row { display: flex; gap: 8px; align-items: stretch; }
.row > .btn { flex: 1; }
.grid4 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
@media (min-width: 540px) { .grid4 { grid-template-columns: repeat(4, 1fr); } }
.btn {
  min-height: var(--btn-h); padding: 6px 10px; border-radius: 12px; cursor: pointer;
  border: 1px solid var(--wood-soft); background: linear-gradient(180deg, #ffffff, #f3e9d6);
  font-size: 16px; font-weight: 700; letter-spacing: .1em; color: var(--ink);
  box-shadow: inset 0 -2px 0 rgba(138, 90, 54, 0.15), 0 2px 6px rgba(58, 42, 32, 0.12);
  display: flex; align-items: center; justify-content: center; gap: 6px; text-align: center; line-height: 1.3;
  text-decoration: none;
}
.btn:active { transform: translateY(1px); filter: brightness(.97); }
.btn[disabled] { opacity: .42; cursor: default; }
.btn.blue { background: linear-gradient(180deg, #ef5a4c, #d8342c); border-color: var(--apple-dk); color: #fff; text-shadow: 0 1px 0 rgba(120, 20, 10, 0.4); }
.btn.deep { background: linear-gradient(180deg, #a87448, #8a5a36); border-color: var(--wood-dk); color: #fff; }
.btn.ghost { background: rgba(255, 250, 240, 0.9); }
.btn.small { min-height: 44px; font-size: 15px; letter-spacing: .06em; }
.btn.wide { width: 100%; }
.btn.sel { outline: 2px solid var(--apple); outline-offset: -2px; background: linear-gradient(180deg, #fff3ee, #fbe0d8); }
.btn.right-ans { background: linear-gradient(180deg, #6fbf7f, #4f9a63); border-color: #3c7a4c; color: #fff; }
.btn.right-ans[disabled], .btn.wrong-ans[disabled] { opacity: 1; }
.btn.wrong-ans { background: linear-gradient(180deg, #e9d6d0, #d9bdb5); border-color: var(--apple-dk); color: var(--apple-dk); }
.btn.ready { animation: readyglow 1.8s ease-in-out infinite; }
.btn em.new { font-style: normal; font-size: 10px; line-height: 1; padding: 3px 5px; border-radius: 3px; background: var(--apple); color: #fff; letter-spacing: .05em; }
.btn.seenitem { color: var(--ink-dim); }
.btn.seenitem::after { content: "済"; font-size: 11px; padding: 2px 4px; border: 1px solid var(--wood-soft); border-radius: 3px; color: var(--ink-faint); }
.btn.kbsel, .kbsel.btn { outline: 2px solid var(--apple); outline-offset: 2px; box-shadow: 0 0 12px rgba(216, 52, 44, 0.35); }
.nav { display: flex; gap: 8px; align-items: center; }
.nav .btn { flex: 0 0 auto; width: 60px; }
.nav .count { flex: 1 1 auto; text-align: center; font-size: 15px; color: var(--ink-dim); }
.nav .count b { color: var(--apple); font-size: 18px; }
.nav .count .done { display: inline-block; margin-left: 8px; padding: 1px 7px; border-radius: 4px; border: 1px solid var(--sky-ink); color: var(--sky-ink); font-size: 12px; }
.nav .hintbtn { font-size: 18px; }
.choices { display: flex; flex-direction: column; gap: 8px; }
.invlist { max-height: 36vh; overflow-y: auto; }
.invlist .btn { justify-content: space-between; padding: 6px 14px; flex: 0 0 auto; }
.talkrow .btn { padding: 4px 4px; }

/* ───────── 重ねる画面 ───────── */
.layer {
  position: absolute; inset: 0; z-index: 80;
  display: flex; flex-direction: column;
  background: rgba(246, 239, 225, 0.97);
  animation: fadein .15s ease 1;
}
.layer.solid { background: linear-gradient(180deg, #ffffff, var(--paper)); }
.layer header { display: flex; align-items: center; gap: 8px; padding: 10px 10px 8px 16px; border-bottom: 2px solid var(--apple-faint); }
.layer header h2 { flex: 1; margin: 0; font-size: 18px; letter-spacing: .2em; color: var(--apple-dk); font-weight: 700; }
.layer .body { flex: 1 1 auto; overflow-y: auto; padding: 14px 16px; overscroll-behavior: contain; }
.layer footer { padding: 10px 12px; padding-bottom: max(10px, env(safe-area-inset-bottom)); display: flex; gap: 8px; border-top: 1px solid var(--wood-soft); }
.layer footer .btn { flex: 1; }

/* タイトル（タイトルの絵の上に、横書きの題字） */
.title-screen { background: var(--sky); justify-content: flex-end; }
.title-screen .bgwrap { position: absolute; inset: 0; z-index: -1; }
.title-screen .shade { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0) 45%, rgba(253, 248, 236, 0.75) 72%, rgba(253, 248, 236, 0.96) 100%); }
.logo {
  position: absolute; left: 50%; top: 6%; transform: translateX(-50%);
  width: min(88%, 420px); text-align: center;
  padding: 16px 14px 14px; border-radius: 16px;
  background: rgba(253, 248, 236, 0.9); border: 1px solid var(--apple-soft);
  box-shadow: 0 6px 20px rgba(58, 42, 32, 0.18), inset 0 0 0 4px rgba(253, 248, 236, 0.9), inset 0 0 0 5px var(--apple-faint);
}
.logo h1 {
  margin: 0; font-weight: 800; line-height: 1.18; color: var(--apple-dk); letter-spacing: .08em;
  text-shadow: 0 2px 0 #ffffff;
}
.logo h1 .l1 { display: block; font-size: clamp(26px, 8vw, 36px); }
.logo h1 .l2 { display: block; font-size: clamp(32px, 10vw, 46px); color: var(--wood-dk); }
.logo .orn { margin: 8px 0 4px; }
.logo .kicker { font-size: clamp(13px, 3.6vw, 15px); letter-spacing: .3em; color: var(--ink-dim); }
.orn { display: flex; align-items: center; justify-content: center; gap: 8px; }
.orn > i { display: block; width: 64px; height: 1px; background: linear-gradient(90deg, transparent, var(--apple)); }
.orn > i:last-child { background: linear-gradient(90deg, var(--apple), transparent); }
.ap.mark { width: 30px; height: 30px; }
.pw.mark { width: 24px; height: 24px; }
.ap.small { width: 24px; height: 24px; }
.pw.small { width: 18px; height: 18px; }
.title-menu { position: relative; display: flex; flex-direction: column; gap: 10px; padding: 0 30px; padding-bottom: max(18px, env(safe-area-inset-bottom)); }
.title-menu .btn { min-height: 52px; font-size: 18px; letter-spacing: .24em; }
.credit-line { margin: 6px 0 0; text-align: center; font-size: 12px; letter-spacing: .1em; color: var(--ink-dim); }
.credit-line a { color: var(--apple-dk); text-decoration: underline; text-underline-offset: 3px; }
.credit-line a:focus-visible { outline: 2px solid var(--apple); outline-offset: 2px; }
.tap-start { position: relative; text-align: center; padding-bottom: max(40px, env(safe-area-inset-bottom)); }
.tap-start .btn { margin: 0 auto; width: min(320px, 86%); min-height: 58px; font-size: 17px; letter-spacing: .14em; animation: glow 2.4s ease-in-out infinite; }
.tap-start p { color: var(--ink-dim); font-size: 13px; margin: 12px 0 0; }

/* 事件の記録・章をえらぶ */
.files { display: flex; flex-direction: column; gap: 12px; }
.chap-ep { margin: 0 0 4px; text-align: center; color: var(--apple-dk); letter-spacing: .3em; font-size: 15px; font-weight: 700; }
.filecard {
  position: relative; display: block; width: 100%; text-align: left; padding: 14px 16px; border-radius: 12px;
  border: 1px solid var(--wood-soft); background: linear-gradient(135deg, #ffffff, #f6ecda); cursor: pointer; color: var(--ink);
  min-height: 76px; box-shadow: 0 2px 6px rgba(58, 42, 32, 0.1);
}
.filecard .no { font-size: 13px; color: var(--apple); letter-spacing: .24em; font-weight: 700; }
.filecard .ttl { font-size: 20px; font-weight: 700; margin-top: 4px; letter-spacing: .1em; }
.filecard .sub { font-size: 14px; color: var(--ink-dim); margin-top: 4px; }
.filecard .stamp { position: absolute; right: 12px; top: 12px; font-size: 13px; padding: 2px 8px; border-radius: 4px; border: 1px solid var(--apple); color: var(--apple); }
.filecard.soon, .filecard.secret { cursor: default; opacity: .55; background: repeating-linear-gradient(135deg, #f6efe1 0 12px, #efe3cb 12px 24px); }

/* 設定 */
.setting { margin-bottom: 22px; }
.setting label { display: block; font-size: 15px; color: var(--ink-dim); margin-bottom: 8px; }
.setting input[type=range] { width: 100%; height: 36px; accent-color: var(--apple); }
.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.seg.three { grid-template-columns: repeat(3, 1fr); }
.seg .btn { min-height: 44px; font-size: 15px; padding: 4px; }

/* ログ */
.log-item { padding: 8px 0; border-bottom: 1px dashed var(--wood-soft); font-size: 16px; line-height: 1.65; white-space: pre-wrap; }
.log-item .who { display: block; font-size: 13px; font-weight: 700; color: var(--nc, var(--apple)); border-left: 3px solid var(--nc, var(--apple)); padding-left: 6px; letter-spacing: .1em; }
.log-item.narr { color: var(--ink-dim); }

/* 手帳 */
.tabs { display: flex; gap: 6px; padding: 8px 12px 0; }
.tabs .btn { flex: 1; min-height: 44px; border-radius: 12px 12px 0 0; }
.tabs .btn.on { background: linear-gradient(180deg, #ef5a4c, #d8342c); border-color: var(--apple-dk); color: #fff; }
.detail { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border-radius: 12px; background: #ffffff; border: 1px solid var(--wood-soft); margin-bottom: 12px; min-height: 110px; }
.detail .big { flex: 0 0 auto; width: 76px; height: 76px; border-radius: 10px; display: grid; place-items: center; font-size: 44px; background: radial-gradient(circle at 50% 40%, #ffffff, var(--paper-2)); border: 1px solid var(--wood-soft); overflow: hidden; }
.detail .big img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 0; }
.detail .info { flex: 1; min-width: 0; }
.detail .info h3 { margin: 0 0 4px; font-size: 18px; color: var(--apple-dk); letter-spacing: .06em; }
.detail .info p { margin: 0; font-size: 15px; line-height: 1.7; color: var(--ink); white-space: pre-wrap; }
.items { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.item {
  min-height: 92px; padding: 8px 4px; border-radius: 12px; cursor: pointer; border: 1px solid var(--wood-soft); color: var(--ink);
  background: linear-gradient(180deg, #ffffff, #f6ecda); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
}
.item .ic { font-size: 30px; line-height: 1; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 8px; overflow: hidden; }
.item .ic img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 0; }
.item .nm { font-size: 13px; line-height: 1.35; text-align: center; }
.item.on { border-color: var(--apple); box-shadow: 0 0 0 2px rgba(216, 52, 44, 0.4); background: linear-gradient(180deg, #fff6f2, #fbe3da); }
.empty { color: var(--ink-faint); font-size: 15px; text-align: center; padding: 24px 0; }

/* 重ねる（証言の一覧から2行） */
.clash-hint { font-size: 14px; color: var(--ink-dim); margin: 0 0 10px; letter-spacing: .06em; }
.clash-list { display: flex; flex-direction: column; gap: 8px; }
.clash-list .btn { justify-content: flex-start; text-align: left; font-weight: 500; font-size: 16px; min-height: 56px; padding: 8px 12px; letter-spacing: .03em; }
.clash-list .btn .n { flex: 0 0 auto; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--apple-soft); font-size: 13px; color: var(--apple); }

/* メニュー・確かめ */
.menu-list { display: flex; flex-direction: column; gap: 10px; }
.dialog { margin: auto 20px; padding: 20px; border-radius: 14px; background: #fffaf0; border: 1px solid var(--apple-soft); box-shadow: 0 8px 24px rgba(58, 42, 32, 0.2); }
.dialog p { margin: 0 0 16px; font-size: 16px; line-height: 1.7; white-space: pre-wrap; }
.dialog .row .btn { flex: 1; }

/* 結果 */
.result { text-align: center; }
.result .orn { margin-top: 8px; }
.result h2 { font-size: 30px; color: var(--apple-dk); letter-spacing: .4em; margin: 10px 0 4px; font-weight: 800; padding-left: .4em; }
.result .ep { color: var(--ink-dim); font-size: 15px; margin-bottom: 18px; letter-spacing: .1em; }
.result .stat { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-bottom: 1px dashed var(--wood-soft); font-size: 16px; }
.result .stat .v { color: var(--apple-dk); font-weight: 700; display: inline-flex; align-items: center; gap: 6px; }
.lampsrow { display: inline-flex; gap: 2px; vertical-align: middle; }
.result .credit { margin-top: 20px; padding: 14px; border-radius: 12px; border: 1px solid var(--wood-soft); background: #ffffff; text-align: left; }
.result .credit h3 { margin: 0 0 8px; font-size: 14px; color: var(--apple); letter-spacing: .3em; }
.result .credit p { margin: 0 0 8px; font-size: 15px; line-height: 1.6; }
.result .credit .btn { width: 100%; margin-bottom: 10px; }

/* 今日は、ここまで */
.lose { justify-content: center; text-align: center; background: rgba(253, 244, 228, 0.98); }
.lose h2 { font-size: clamp(20px, 5.8vw, 26px); letter-spacing: .12em; color: var(--wood-dk); margin: 0 0 12px; font-weight: 700; }
.lose p { color: var(--ink-dim); margin: 0 0 28px; font-size: 15px; letter-spacing: .08em; }
.lose .lampsrow { display: flex; gap: 4px; justify-content: center; margin-bottom: 20px; }
.lose .btns { display: flex; flex-direction: column; gap: 10px; padding: 0 28px; }

/* ───────── カットイン（リンゴだけ） ───────── */
#cutin { position: absolute; inset: 0; z-index: 90; pointer-events: none; overflow: hidden; }
#cutin[hidden] { display: none; }
#cutin .dark { position: absolute; inset: 0; background: rgba(58, 42, 32, 0.32); animation: fadein .12s ease 1; }
#cutin .band {
  position: absolute; left: -8%; right: -8%; top: 48%; height: 150px; margin-top: -75px;
  transform: rotate(-4deg);
  background: linear-gradient(90deg, #fdf8ec 0%, #ffffff 45%, #fbefe0 100%);
  overflow: hidden; box-shadow: 0 6px 20px rgba(58, 42, 32, 0.25);
}
#cutin .gl { position: absolute; left: 0; right: 0; height: 2px; background: linear-gradient(90deg, transparent, var(--apple) 15%, var(--apple-hi) 50%, var(--apple) 85%, transparent); }
#cutin .gl.t { top: 6px; } #cutin .gl.b { bottom: 6px; }
#cutin .face {
  position: absolute; left: 11%; top: 50%; width: 124px; height: 124px; margin-top: -62px; border-radius: 50%; overflow: hidden;
  background: radial-gradient(circle at 50% 42%, #ffffff 0%, #f6efe1 55%, #c6e6f6 100%); border: 2px solid var(--apple); transform: rotate(4deg);
}
#cutin .face img { position: absolute; left: -18%; top: -14%; width: 136%; height: auto; }
#cutin .words {
  position: absolute; left: 40%; right: 4%; top: 50%; transform: translateY(-50%) rotate(4deg);
  font-weight: 800; font-size: clamp(22px, 6.4vw, 34px); letter-spacing: .08em; white-space: pre; line-height: 1.3;
  color: var(--apple-dk); text-shadow: 0 2px 0 #ffffff;
}
#cutin.go .band { animation: bandin 1.05s cubic-bezier(.2, .9, .2, 1) 1 both; }
#cutin.go .words { animation: wordsin 1.05s ease 1 both; }
#cutin.tou .band { height: 120px; margin-top: -60px; background: linear-gradient(90deg, #eaf6fc, #ffffff 60%, #eaf6fc); }
#cutin.tou .words { font-size: clamp(20px, 5.8vw, 30px); color: var(--wood-dk); }
#cutin.tou .face { width: 100px; height: 100px; margin-top: -50px; }

/* 封筒とりんごが横切る ／ 最後の決め手（封筒がベンチに届く） */
#bfly { position: absolute; inset: 0; z-index: 88; pointer-events: none; overflow: hidden; }
#bfly[hidden] { display: none; }
#bfly .lane { position: absolute; left: 0; top: 0; width: 100%; height: 100%; }
#bfly.cross.go .lane { animation: laneX 1.5s cubic-bezier(.35, .1, .25, 1) both; }
#bfly .bob { position: absolute; left: 50%; top: 50%; }
#bfly.cross.go .bob { animation: bobY .5s ease-in-out infinite alternate; }
#bfly .ev.big { position: absolute; width: 132px; height: 91px; left: -66px; top: -45px; transform: rotate(-12deg); filter: drop-shadow(0 6px 10px rgba(58, 42, 32, 0.3)); }
#bfly .ap.rider { position: absolute; width: 54px; height: 54px; left: 30px; top: -78px; animation: spin 1.5s linear infinite; }
#bfly .glow { position: absolute; left: -130px; top: -130px; width: 260px; height: 260px; border-radius: 50%; background: radial-gradient(circle, rgba(255, 244, 214, 0.75) 0%, rgba(255, 220, 170, 0.25) 45%, rgba(255, 220, 170, 0) 70%); }
#bfly .dot { position: absolute; left: -11px; top: -11px; width: 22px; height: 22px; display: block; }
#bfly .dot .pw { width: 22px; height: 22px; }
#bfly .sweep { position: absolute; inset: -20%; background: linear-gradient(110deg, transparent 38%, rgba(255, 255, 255, 0.5) 50%, transparent 62%); }
#bfly.cross.go .sweep { animation: sweep 1.5s ease both; }

#bfly.final .dim { position: absolute; inset: 0; background: rgba(58, 42, 32, 0); }
#bfly.final.go .dim { animation: dimIn 1.6s ease forwards; }
#bfly .fcard {
  position: absolute; left: 50%; top: 32%; width: min(300px, 78%); padding: 18px 16px 14px; transform: translate(-50%, -50%);
  border-radius: 14px; text-align: center; background: #fffaf0; border: 1px solid var(--apple);
  box-shadow: inset 0 0 0 4px #fffaf0, inset 0 0 0 5px var(--apple-faint);
  opacity: 0;
}
#bfly.final.go .fcard { animation: fadeUp .8s ease .15s forwards; }
#bfly .fic { font-size: 52px; line-height: 1.2; }
#bfly .fic img { width: 90px; height: 90px; object-fit: cover; border-radius: 8px; }
#bfly .fname { margin-top: 6px; color: var(--ink); font-size: 17px; letter-spacing: .1em; font-weight: 700; }
#bfly .flines p { margin: 0 0 6px; font-size: 15px; line-height: 1.55; color: var(--apple-dk); text-align: left; }
#bfly .fbench { position: absolute; left: 50%; top: 56%; width: 200px; height: 90px; margin-left: -100px; opacity: 0; }
#bfly.final.go .fbench { animation: fadein .6s ease .3s forwards; }
#bfly .fseat svg { width: 200px; height: 90px; display: block; fill: #9a6a3f; }
#bfly .fseat .leg { fill: #6e4526; }
#bfly .perch { position: absolute; left: 100px; top: 44px; width: 0; height: 0; }
#bfly.final.go .perch .lane { animation: land 1.8s cubic-bezier(.2, .7, .2, 1) .4s both; width: 0; height: 0; }
#bfly .perch .glow { left: -60px; top: -60px; width: 120px; height: 120px; }
#bfly .ev.perched { position: absolute; width: 64px; height: 44px; left: -32px; top: -42px; }
#bfly .fwords {
  position: absolute; left: 0; right: 0; top: 76%; text-align: center; white-space: pre;
  font-weight: 800; font-size: clamp(24px, 7vw, 36px); letter-spacing: .12em; line-height: 1.35; color: #fffaf0;
  text-shadow: 0 0 14px rgba(216, 52, 44, 0.6), 0 2px 0 #5e3b22; opacity: 0;
}
#bfly.final.go .fwords { animation: fadein .9s ease 1.1s forwards; }
#bfly.final.out { animation: fadeout .6s ease forwards; }

/* 大きな帯（ベンチの推理 はじまり／証言） */
#banner { position: absolute; inset: 0; z-index: 85; display: grid; place-items: center; pointer-events: none; }
#banner[hidden] { display: none; }
#banner .b {
  width: 100%; padding: 18px 10px; text-align: center;
  background: linear-gradient(90deg, transparent, rgba(253, 248, 236, 0.97) 15%, rgba(253, 248, 236, 0.97) 85%, transparent);
  animation: bannerin 1.4s ease 1 both;
}
#banner .bl { display: block; height: 2px; margin: 0 auto; width: 70%; background: linear-gradient(90deg, transparent, var(--apple), transparent); }
#banner .b .big { font-size: clamp(26px, 8vw, 38px); font-weight: 800; letter-spacing: .3em; color: var(--apple-dk); margin: 12px 0 4px; padding-left: .3em; }
#banner .b .small { margin-bottom: 12px; font-size: 15px; color: var(--wood-dk); letter-spacing: .12em; padding: 0 10px; }

/* 題の札（章のはじまり） */
.titlecard { background: radial-gradient(ellipse 80% 60% at 50% 45%, #ffffff, #dff1fa); justify-content: center; align-items: center; text-align: center; cursor: pointer; }
.titlecard .no { font-size: 15px; letter-spacing: .6em; color: var(--apple); padding-left: .6em; margin-bottom: 14px; font-weight: 700; }
.titlecard .ttl { margin: 16px 0; font-size: clamp(26px, 7.6vw, 36px); color: var(--wood-dk); letter-spacing: .14em; padding: 0 16px; font-weight: 800; }
.titlecard .sub { font-size: 14px; color: var(--ink-dim); letter-spacing: .3em; margin-top: 14px; }
.titlecard .line { width: 60%; height: 1px; margin: 0 auto; background: linear-gradient(90deg, transparent, var(--apple), transparent); }
.titlecard .orn { margin-top: 22px; }

/* 証拠を手に入れた（手帳に書きとめた） */
.gain { justify-content: center; align-items: center; background: rgba(58, 42, 32, 0.28); cursor: pointer; }
.gain .card {
  width: min(340px, 88%); padding: 18px 18px 16px; border-radius: 14px; text-align: center;
  background: #fffaf0; border: 1px solid var(--apple);
  box-shadow: 0 8px 26px rgba(58, 42, 32, 0.25), inset 0 0 0 4px #fffaf0, inset 0 0 0 5px var(--apple-faint); animation: pop .35s cubic-bezier(.2, 1.3, .4, 1) 1;
}
.gain .card .head { font-size: 14px; color: var(--apple); letter-spacing: .3em; font-weight: 700; }
.gain .card .ic { font-size: 60px; line-height: 1.2; margin: 10px 0 4px; }
.gain .card .ic img { width: 96px; height: 96px; object-fit: cover; border-radius: 8px; }
.gain .card h3 { margin: 0 0 8px; font-size: 20px; color: var(--ink); letter-spacing: .08em; }
.gain .card p { margin: 0; font-size: 15px; line-height: 1.7; color: var(--ink-dim); text-align: left; white-space: pre-wrap; }
.gain .card .tapnote { margin-top: 12px; font-size: 12px; color: var(--ink-faint); }

/* ───────── 動き ───────── */
@keyframes snowfall { 0% { transform: translate(0, -10px); } 50% { transform: translate(14px, 50vh); } 100% { transform: translate(-6px, 102vh); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 15% { transform: translateX(-9px); } 30% { transform: translateX(8px); } 45% { transform: translateX(-6px); } 60% { transform: translateX(5px); } 75% { transform: translateX(-3px); } 90% { transform: translateX(2px); } }
@keyframes jump { 0%, 100% { transform: translateY(0); } 35% { transform: translateY(-18px); } 60% { transform: translateY(0); } 78% { transform: translateY(-6px); } }
@keyframes quake { 0%, 100% { transform: translate(0, 0); } 12% { transform: translate(-7px, 3px); } 25% { transform: translate(6px, -4px); } 38% { transform: translate(-5px, -2px); } 52% { transform: translate(5px, 3px); } 66% { transform: translate(-3px, 2px); } 82% { transform: translate(2px, -1px); } }
@keyframes flash { 0% { opacity: .9; } 100% { opacity: 0; } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(3px); } }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeout { from { opacity: 1; } to { opacity: 0; } }
@keyframes fadeUp { from { opacity: 0; transform: translate(-50%, -44%); } to { opacity: 1; transform: translate(-50%, -50%); } }
@keyframes pop { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes glow { 0%, 100% { box-shadow: 0 0 0 rgba(216, 52, 44, 0); } 50% { box-shadow: 0 0 20px rgba(216, 52, 44, 0.5); } }
@keyframes readyglow { 0%, 100% { box-shadow: 0 0 0 rgba(216, 52, 44, 0); } 50% { box-shadow: 0 0 16px rgba(216, 52, 44, 0.7); } }
@keyframes bandin { 0% { transform: rotate(-4deg) translateX(-110%); } 22% { transform: rotate(-4deg) translateX(0); } 82% { transform: rotate(-4deg) translateX(0); opacity: 1; } 100% { transform: rotate(-4deg) translateX(30%); opacity: 0; } }
@keyframes wordsin { 0% { opacity: 0; letter-spacing: .4em; } 30% { opacity: 1; letter-spacing: .08em; } 82% { opacity: 1; } 100% { opacity: 0; } }
@keyframes bannerin { 0% { opacity: 0; transform: scaleY(.2); } 15% { opacity: 1; transform: scaleY(1); } 82% { opacity: 1; } 100% { opacity: 0; } }
@keyframes sway { 0%, 80%, 100% { transform: rotate(0); } 86% { transform: rotate(-8deg); } 92% { transform: rotate(6deg); } 96% { transform: rotate(-3deg); } }
@keyframes rollaway { 0% { transform: none; opacity: 1; } 30% { transform: translate(10px, -10px) rotate(120deg); opacity: 1; } 100% { transform: translate(60px, 30px) rotate(540deg) scale(.7); opacity: 0; } }
@keyframes spin { from { transform: rotate(0); } to { transform: rotate(360deg); } }
@keyframes flip { 0%, 100% { transform: rotateY(0); } 50% { transform: rotateY(60deg); } }
@keyframes laneX { 0% { transform: translate(-64%, 28%); } 100% { transform: translate(64%, -30%); } }
@keyframes bobY { from { transform: translateY(-12px); } to { transform: translateY(12px); } }
@keyframes sweep { from { transform: translateX(-60%); } to { transform: translateX(60%); } }
@keyframes dimIn { to { background: rgba(58, 42, 32, 0.72); } }
@keyframes land { 0% { transform: translate(-160px, -260px) rotate(-24deg); opacity: 0; } 15% { opacity: 1; } 55% { transform: translate(30px, -60px) rotate(10deg); } 80% { transform: translate(-8px, -10px) rotate(-4deg); } 100% { transform: translate(0, 0) rotate(0deg); opacity: 1; } }
@keyframes glint { 0%, 100% { opacity: .45; transform: scale(.8); } 50% { opacity: 1; transform: scale(1.15); } }
@keyframes hintpulse { 0%, 100% { box-shadow: inset 0 0 0 1px rgba(216, 52, 44, 0.5), 0 0 0 0 rgba(216, 52, 44, 0); } 50% { box-shadow: inset 0 0 0 3px rgba(216, 52, 44, 0.95), 0 0 18px 2px rgba(255, 214, 120, 0.8); } }

@media (prefers-reduced-motion: reduce) {
  .snow i, .life .ap, .spot .glint, #sabi .note, #bfly .ap.rider { animation: none !important; }
}

/* パソコン（広い画面） */
@media (min-width: 561px) {
  #textbox { height: 180px; }
}
/* 背の低い画面 */
@media (max-height: 700px) {
  #textbox { height: 150px; }
  :root { --btn-h: 46px; }
}

/* ───────── コントローラー（パッドがつながっている時だけ出す） ───────── */
.only-pad { display: none; }
html[data-pad="1"] .only-pad { display: inline; }
html[data-pad="1"] p.only-pad, html[data-pad="1"] div.only-pad { display: block; }
html[data-pad="1"] .no-pad { display: none; }
.btn, .ibtn { position: relative; }
html[data-pad="1"] [data-padkey]::before, html[data-pad="1"] [data-esc]::before {
  content: attr(data-padkey); position: absolute; top: -8px; left: -6px; z-index: 3;
  min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; box-sizing: border-box;
  display: grid; place-items: center;
  font: 700 11px/1 sans-serif; letter-spacing: 0; color: #ffffff;
  background: var(--apple); border: 1px solid var(--apple-dk); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  pointer-events: none;
}
html[data-pad="1"] [data-esc]:not([data-padkey])::before { content: 'B'; }
html[data-pad="1"] .ibtn[data-padkey="START"]::before { top: auto; bottom: -7px; left: 50%; transform: translateX(-50%); font-size: 9px; }
html[data-pad="1"] .padfocus {
  outline: 3px solid var(--apple); outline-offset: 2px;
  box-shadow: 0 0 0 1px #ffffff, 0 0 14px rgba(216, 52, 44, 0.5) !important;
}
html[data-pad="1"] input[type=range].padfocus { outline-offset: 4px; border-radius: 8px; }
html[data-pad="1"] #textbox.waiting #next-mark::before { content: 'Ⓐ 進む  '; font-size: 13px; }
html[data-pad="1"] .tap-start .btn::after { content: '（Ⓐ）'; font-size: 14px; }
