/* ぽてむしの推理決闘 ― 見た目
   色: あたたかいクリーム ＋ ポテチの黄色 ＋ 黄緑。文字の箱は「クリームの箱＋黄色の細い縁」
   明るい画面。文字は濃い茶色で読みやすく。黄色のボタンの文字も濃い茶色
   スマホの縦を一番に。パソコンはまん中に縦長の画面（最大幅 560px）
   ※ 変数の名前（--navy-0 / --teal / --amber など）は前のまま。中の色だけ変えた */

:root {
  --navy-0: #fff4e0;
  --navy-1: #fff8ec;
  --navy-2: #ffefd2;
  --navy-3: #ffe6b8;
  --teal: #9ccc4a;
  --teal-2: #84b83a;
  --teal-dim: #6f9a2e;
  --amber: #ffd24a;
  --amber-hi: #ffe58a;
  --amber-deep: #d9a300;
  --ink: #5a4636;
  --ink-dim: #8a7664;
  --ink-faint: #b3a08f;
  --ink-accent: #9a6a00;   /* 明るい箱の上の「目立たせる文字」（黄色だと読めないので、こげ茶寄りの黄色） */
  --glass: rgba(255, 252, 246, 0.92);
  --glass-strong: rgba(255, 250, 240, 0.97);
  --rim: rgba(217, 163, 0, 0.55);
  --rim-soft: rgba(217, 163, 0, 0.28);
  --danger: #e0703a;
  --ok: #6f9a2e;
  --font: "BIZ UDPGothic", "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  --font-title: "Hiragino Mincho ProN", "Yu Mincho", "BIZ UDPMincho", "YuMincho", 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(--navy-0);
  background-image:
    radial-gradient(ellipse 70% 50% at 50% 0%, rgba(156, 204, 74, 0.12), transparent 70%),
    radial-gradient(ellipse 80% 60% at 50% 110%, rgba(255, 210, 74, 0.16), transparent 70%),
    linear-gradient(180deg, #fff8ec 0%, #fff4e0 60%, #ffecd0 100%);
  color: var(--ink);
  font-family: var(--font);
  overflow: hidden;
  -webkit-user-select: none; user-select: none;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}
button { font-family: inherit; color: inherit; }

/* パソコンの左右に広がる背景の飾り（今は見えないようにしてある） */
#outer-bubbles { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
#outer-bubbles i {
  position: absolute; bottom: -20px; width: 8px; height: 8px; border-radius: 50%;
  border: 1px solid rgba(217, 163, 0, 0.2); background: rgba(255, 210, 74, 0.06);
  animation: rise 14s linear infinite; visibility: hidden;
}

/* ───────── 画面のわく ───────── */
#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(--navy-1);
  box-shadow: 0 0 0 1px rgba(217, 163, 0, 0.18), 0 0 60px rgba(90, 70, 54, 0.18);
}

/* 上の帯 */
#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, rgba(255, 252, 246, 0.98), rgba(255, 246, 228, 0.94));
  border-bottom: 1px solid var(--rim-soft);
}
#tb-title {
  flex: 1 1 auto; min-width: 0;
  font-size: 14px; line-height: 1.3; color: var(--ink);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
#tb-title .kind { color: var(--ink-accent); font-weight: 700; margin-right: 4px; }
#lamps { flex: 0 0 auto; display: flex; gap: 2px; align-items: flex-end; }
#lamps[hidden] { display: none; }
.lamp { width: 19px; height: 30px; position: relative; }
.lamp svg { width: 100%; height: 100%; display: block; overflow: visible; }
.lamp .glass { fill: #ead9bd; transition: fill .3s; }
.lamp .flame { fill: #fff3b0; opacity: 0; transition: opacity .3s; }
.lamp .metal { fill: #b08850; }
.lamp.on .glass { fill: #ffd24a; }
.lamp.on .flame { opacity: 1; }
.lamp.on svg { filter: drop-shadow(0 0 5px rgba(255, 190, 40, 0.85)); }
.lamp.losing svg { animation: flicker .9s steps(1) 1; }
.lamp .smoke {
  position: absolute; left: 50%; top: -4px; width: 10px; height: 10px; margin-left: -5px; border-radius: 50%;
  background: rgba(160, 140, 120, 0.5); filter: blur(2px); opacity: 0; pointer-events: none;
}
.lamp.smoking .smoke { animation: smoke 1s ease-out 1; }

.ibtn {
  flex: 0 0 auto; width: 44px; height: 44px; border-radius: 12px;
  border: 1px solid var(--rim-soft); background: rgba(255, 252, 246, 0.9);
  font-size: 20px; line-height: 1; cursor: pointer; display: grid; place-items: center;
}
.ibtn:active { transform: translateY(1px); }

/* ───────── 舞台 ───────── */
#stage { position: relative; flex: 1 1 auto; min-height: 200px; overflow: hidden; background: #f3e6cc; }
#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; }

/* 広い部屋（画像が無い時の代わり）: あたたかい色の部屋・奥に大きな窓・ゆれるやわらかい日の光 */
.bg-hall {
  background:
    radial-gradient(ellipse 60% 40% at 50% 34%, rgba(255, 240, 190, 0.45), transparent 70%),
    linear-gradient(180deg, #fdf0d8 0%, #f6e2c0 55%, #ecd3a8 72%, #e2c497 100%);
}
.bg-hall .pillar { position: absolute; top: 0; bottom: 22%; width: 11%; background: linear-gradient(90deg, #ead6b4, #f3e4c8 45%, #e2cba5); box-shadow: 0 0 18px rgba(90, 70, 54, 0.15); }
.bg-hall .pillar.l { left: 0; } .bg-hall .pillar.r { right: 0; }
.bg-hall .window {
  position: absolute; left: 15%; right: 15%; top: 6%; bottom: 26%;
  border-radius: 999px 999px 10px 10px / 46% 46% 10px 10px;
  border: 3px solid #c9a77a; box-shadow: 0 0 0 6px #ecd8b6, 0 0 40px rgba(255, 230, 160, 0.5), inset 0 0 40px rgba(255, 255, 255, 0.45);
  overflow: hidden;
  background: linear-gradient(180deg, #cdeefb 0%, #e3f5fd 45%, #f4f9ec 75%, #fff4d6 100%);
}
.bg-hall .window::before {   /* ゆれる日の光（やわらかい光のまだら） */
  content: ""; position: absolute; inset: -30%;
  background:
    radial-gradient(ellipse 16% 7% at 28% 30%, rgba(255, 255, 255, 0.45), transparent 70%),
    radial-gradient(ellipse 20% 8% at 66% 46%, rgba(255, 255, 255, 0.38), transparent 70%),
    radial-gradient(ellipse 13% 6% at 42% 68%, rgba(255, 255, 255, 0.32), transparent 70%),
    radial-gradient(ellipse 22% 7% at 78% 22%, rgba(255, 255, 255, 0.28), transparent 70%),
    radial-gradient(ellipse 18% 6% at 20% 58%, rgba(255, 255, 255, 0.24), transparent 70%);
  filter: blur(5px);
  animation: caustic 8s ease-in-out infinite alternate;
}
.bg-hall .jelly {   /* 前の飾りの名残り（今は出さない） */
  position: absolute; width: 13%; aspect-ratio: 1 / 1.6; opacity: .55; display: none;
  background: radial-gradient(ellipse 50% 30% at 50% 28%, rgba(255, 255, 255, 0.85), transparent 72%);
  animation: drift 13s ease-in-out infinite alternate;
}
.bg-hall .jelly.j2 { width: 9%; left: 64%; top: 52%; animation-duration: 17s; animation-delay: -6s; opacity: .4; }
.bg-hall .jelly.j1 { left: 22%; top: 18%; }
.bg-hall .fish {   /* 前の飾りの名残り（今は出さない） */
  position: absolute; width: 7%; height: 2.2%; border-radius: 50%; background: rgba(90, 70, 54, 0.3); display: none;
  animation: swim 22s linear infinite;
}
.bg-hall .fish::after { content: ""; position: absolute; right: -35%; top: 10%; width: 45%; height: 80%; background: inherit; clip-path: polygon(0 50%, 100% 0, 100% 100%); }
.bg-hall .fish.f2 { top: 40%; animation-duration: 28s; animation-delay: -9s; transform: scale(.7); }
.bg-hall .fish.f1 { top: 63%; }
.bg-hall .fish.f3 { top: 28%; animation-duration: 34s; animation-delay: -20s; }
.bg-hall .window::after {    /* 窓の格子と光の筋 */
  content: ""; position: absolute; inset: 0;
  background:
    linear-gradient(90deg, transparent 49.4%, rgba(160, 120, 80, 0.6) 49.4% 50.6%, transparent 50.6%),
    linear-gradient(180deg, transparent 58%, rgba(160, 120, 80, 0.5) 58% 59.2%, transparent 59.2%),
    linear-gradient(105deg, transparent 20%, rgba(255, 255, 255, 0.25) 28%, transparent 36%),
    linear-gradient(75deg, transparent 58%, rgba(255, 255, 255, 0.18) 64%, transparent 70%);
}
.bg-hall .sand { position: absolute; left: 0; right: 0; bottom: 0; height: 16%; background: radial-gradient(ellipse 60% 100% at 50% 100%, #e8c48a, transparent 70%); opacity: .6; }
.bg-hall .floor {
  position: absolute; left: 0; right: 0; bottom: 0; height: 24%;
  background: linear-gradient(180deg, #e2c497 0%, #cfa874 100%);
  border-top: 1px solid rgba(160, 120, 80, 0.35);
}
.bg-hall .floor::before { content: ""; position: absolute; inset: 0; background: radial-gradient(ellipse 40% 60% at 50% 0%, rgba(255, 240, 200, 0.4), transparent 70%); }
.bg-hall .sway { position: absolute; inset: 0; background: radial-gradient(ellipse 50% 35% at 50% 30%, rgba(255, 240, 190, 0.18), transparent 70%); animation: sway 7s ease-in-out infinite alternate; }
.bubble {   /* 前の飾りの名残り（見えないようにしてある） */
  position: absolute; bottom: 20%; width: 7px; height: 7px; border-radius: 50%;
  border: 1px solid rgba(217, 163, 0, 0.3); background: rgba(255, 210, 74, 0.08);
  animation: rise 8s linear infinite; opacity: 0; visibility: hidden;
}
.bg-hall .lampglow { position: absolute; bottom: 20%; width: 16%; height: 22%; background: radial-gradient(ellipse at 50% 60%, rgba(255, 210, 74, 0.25), transparent 70%); }
.bg-hall .lampglow.l { left: 3%; } .bg-hall .lampglow.r { right: 3%; }

/* 小さい部屋（画像が無い時の代わり）: あたたかい色の部屋 */
.bg-office {
  background:
    radial-gradient(ellipse 45% 35% at 80% 30%, rgba(255, 230, 150, 0.35), transparent 70%),
    linear-gradient(180deg, #fbeedd 0%, #f5e3cb 50%, #ead2b2 74%, #dcc09a 100%);
}
.bg-office .wall-line { position: absolute; left: 0; right: 0; top: 62%; height: 6px; background: #d9bf98; box-shadow: 0 2px 0 #c9a97f; }
.bg-office .floor { position: absolute; left: 0; right: 0; bottom: 0; height: 26%; background: repeating-linear-gradient(90deg, #d9b98a 0 46px, #cfae7e 46px 48px), linear-gradient(#d9b98a, #c9a676); }
.bg-office .window { position: absolute; left: 8%; top: 10%; width: 30%; height: 38%; border: 4px solid #c9a77a; border-radius: 6px; background: linear-gradient(180deg, #cdeefb, #eaf7fd); box-shadow: inset 0 0 20px rgba(255, 255, 255, 0.5); }
.bg-office .window::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent 48%, #c9a77a 48% 52%, transparent 52%), linear-gradient(180deg, transparent 48%, #c9a77a 48% 52%, transparent 52%); }
.bg-office .fridge { position: absolute; right: 8%; bottom: 22%; width: 18%; height: 36%; background: linear-gradient(90deg, #ece6da, #fbf8f2 60%, #ddd5c6); border-radius: 6px; box-shadow: 0 4px 12px rgba(90, 70, 54, 0.25); }
.bg-office .fridge::before { content: ""; position: absolute; left: 0; right: 0; top: 34%; height: 2px; background: #bfb3a0; }
.bg-office .fridge::after { content: ""; position: absolute; left: 22%; top: 42%; width: 22%; height: 14%; background: #9ccc4a; transform: rotate(-6deg); box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.bg-office .lamp { position: absolute; right: 30%; top: 8%; width: 14%; height: 10%; background: radial-gradient(ellipse at 50% 100%, rgba(255, 220, 130, 0.6), transparent 70%); }
.bg-office .shelf { position: absolute; left: 44%; top: 18%; width: 22%; height: 40%; background: repeating-linear-gradient(180deg, #e6cfa8 0 30%, #b08458 30% 33%); border: 3px solid #b08458; opacity: .85; }

/* まっくらの場面（明かりが消えた時）: こげ茶の暗がり */
.bg-black { background: #1e1812; }

/* キャラ */
#chars { position: absolute; inset: 0; pointer-events: none; }
.chara {
  position: absolute; bottom: 4%;
  transform: translateX(-50%);
  transition: left .35s ease, width .35s ease, filter .25s ease, opacity .3s ease;
  filter: brightness(1);
}
.chara.enter { opacity: 0; }
.chara.dim { filter: brightness(.72) saturate(.7); }
.chara.dim2 { filter: brightness(.82); }
.chara .frame {
  position: relative; width: 100%; aspect-ratio: 560 / 595; border-radius: 16px; overflow: hidden;
  border: 1.5px solid var(--rim); box-shadow: 0 6px 22px rgba(90, 70, 54, 0.28), 0 0 0 4px rgba(255, 252, 246, 0.75);
  background: var(--card, #fff8ec);
  transition: transform .2s ease;
}
.chara.talk { z-index: 2; }
.chara.talk .frame { transform: translateY(-6px) scale(1.06); box-shadow: 0 10px 26px rgba(90, 70, 54, 0.32), 0 0 0 4px rgba(255, 252, 246, 0.8), 0 0 18px rgba(255, 210, 74, 0.6); }
.chara .frame img { position: absolute; inset: 0; width: 100%; height: 100%; display: block; -webkit-user-drag: none; }
.chara.k-card .frame img { object-fit: cover; object-position: 50% 0%; }
.chara.k-chibi .frame img { object-fit: contain; transform: scale(1.1) translateY(-1%); }
.chara.k-stand .frame { aspect-ratio: 1 / 1.6; border: 0; border-radius: 0; background: transparent; box-shadow: none; overflow: visible; }
.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 16px; border-radius: 999px; background: var(--glass-strong); border: 1px solid var(--rim);
  color: var(--ink-accent); font-weight: 700; font-size: 16px; opacity: 0; transition: opacity .25s, transform .25s;
  pointer-events: none; z-index: 60; white-space: nowrap;
}
#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: 12px; background: rgba(255, 252, 246, 0.96); border: 1px solid var(--rim-soft);
  font-size: 15px; line-height: 1.45;
}
#board[hidden] { display: none; }
#board h3 { margin: 0 0 4px; font-size: 13px; color: var(--ink-accent); letter-spacing: .1em; }
#board ol { margin: 0; padding-left: 1.4em; }
#board li { color: var(--ink-dim); }
#board li b { color: var(--ink-accent); font-weight: 700; }

/* フィールドのキャンバス */
#field-cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; z-index: 4; background: #f3e6cc; touch-action: none; }
#field-cv[hidden] { display: none; }

/* ───────── 文字の箱 ───────── */
#textbox {
  position: relative; flex: 0 0 auto;
  height: 172px; margin: 0 8px; margin-top: -26px; z-index: 10;
  padding: 26px 16px 12px;
  border-radius: 14px;
  background: var(--glass);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border: 1px solid var(--rim);
  box-shadow: 0 -4px 24px rgba(90, 70, 54, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.7);
  cursor: pointer;
}
#nameplate {   /* 名前の札はこげ茶。名前の色（cast.js の color）は明るい色だと読みやすい */
  position: absolute; left: 12px; top: -15px; min-width: 84px; padding: 4px 14px;
  border-radius: 8px; background: linear-gradient(180deg, #6b5442, #5a4636); border: 1px solid var(--rim);
  font-weight: 700; font-size: 16px; letter-spacing: .06em; color: var(--nc, var(--amber-hi));
  box-shadow: 0 2px 8px rgba(90, 70, 54, 0.3);
}
#nameplate[hidden] { display: none; }
#text {
  height: 100%; overflow-y: auto; overscroll-behavior: contain;
  font-size: var(--text-size); line-height: 1.62; white-space: pre-wrap; word-break: break-word;
  scrollbar-width: none;
}
#text::-webkit-scrollbar { display: none; }
#text.narr { color: #6b5848; font-style: normal; }
#text.low { color: #6a5a80; letter-spacing: .04em; }
#text.testi { color: var(--ink-accent); }
#text.sys { color: var(--ok); }
#text.question { color: var(--ink); }
#text .qno { display: block; font-size: 13px; color: var(--ink-accent); letter-spacing: .1em; margin-bottom: 2px; }
#next-mark {
  position: absolute; right: 14px; bottom: 8px; color: var(--amber-deep); font-size: 14px; 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(--ink-accent); letter-spacing: .1em; }

/* ───────── ボタンの段 ───────── */
#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; }
.grid4 { display: grid; grid-template-columns: repeat(2, 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(--rim-soft); background: linear-gradient(180deg, #fffdf8, #fff1d8);
  font-size: 16px; font-weight: 700; letter-spacing: .04em; color: var(--ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8), 0 2px 6px rgba(90, 70, 54, 0.18);
  display: flex; align-items: center; justify-content: center; gap: 6px; text-align: center; line-height: 1.25;
}
.btn:active { transform: translateY(1px); filter: brightness(0.96); }
.btn[disabled] { opacity: .4; cursor: default; }
.btn.amber { background: linear-gradient(180deg, #ffe58a, #ffd24a); color: #4a3626; border-color: #d9a300; }
.btn.teal { background: linear-gradient(180deg, #b8de78, #9ccc4a); color: #34480f; border-color: #6f9a2e; }
.btn.ghost { background: rgba(255, 252, 246, 0.6); }
.btn.small { min-height: 44px; font-size: 15px; }
.btn .ico { font-size: 18px; }
.btn.wide { width: 100%; }
.btn.sel { outline: 2px solid var(--amber-deep); background: linear-gradient(180deg, #fff3c0, #ffe58a); }
.btn.right-ans { background: linear-gradient(180deg, #dcefb8, #c3e28c); border-color: var(--ok); }
.btn.right-ans[disabled], .btn.wrong-ans[disabled] { opacity: 1; }
.btn.wrong-ans { background: linear-gradient(180deg, #fbd9c6, #f4bea0); border-color: var(--danger); }
.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(--ink-accent); font-size: 18px; }
.nav .count .done { display: inline-block; margin-left: 8px; padding: 1px 7px; border-radius: 6px; background: var(--teal-dim); color: #fff; font-size: 13px; }
.choices { display: flex; flex-direction: column; gap: 8px; }

/* フィールドの十字ボタン */
.dpad { display: grid; grid-template-columns: repeat(3, 52px); grid-template-rows: repeat(2, 48px); gap: 6px; }
.dpad .btn { min-height: 48px; padding: 0; font-size: 20px; }
.fieldrow { display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.fieldrow .look { flex: 1 1 auto; min-height: 102px; font-size: 18px; }

/* ───────── 重ねる画面 ───────── */
.layer {
  position: absolute; inset: 0; z-index: 80;
  display: flex; flex-direction: column;
  background: var(--glass-strong);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  animation: fadein .15s ease 1;
}
.layer.solid { background: linear-gradient(180deg, #fff8ec, #ffefd2); -webkit-backdrop-filter: none; backdrop-filter: none; }
.layer.clear { background: transparent; -webkit-backdrop-filter: none; backdrop-filter: none; }
.layer header { display: flex; align-items: center; gap: 8px; padding: 10px 10px 8px 16px; border-bottom: 1px solid var(--rim-soft); }
.layer header h2 { flex: 1; margin: 0; font-size: 18px; letter-spacing: .1em; color: var(--ink-accent); font-family: var(--font-title); }
.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(--rim-soft); }
.layer footer .btn { flex: 1; }

/* タイトル */
.title-screen { background: transparent; -webkit-backdrop-filter: none; backdrop-filter: none; 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, 244, 224, 0.1), rgba(255, 244, 224, 0.5) 55%, rgba(255, 244, 224, 0.92)); }
.logo { position: absolute; left: 0; right: 0; top: 13%; text-align: center; padding: 0 16px; }
.logo .kicker { font-size: 13px; letter-spacing: .4em; color: var(--teal-dim); font-weight: 700; margin-bottom: 10px; text-shadow: 0 0 6px rgba(255, 255, 255, 0.95); }
.logo h1 {
  margin: 0; font-family: var(--font-title); font-weight: 700; font-size: clamp(38px, 11vw, 54px); letter-spacing: .08em; line-height: 1.15;
  color: #5a4636; text-shadow: 0 0 14px rgba(255, 255, 255, 0.95), 0 0 4px rgba(255, 255, 255, 0.95), 0 3px 0 #ffd24a;
}
.logo h1 small { display: block; font-size: .42em; letter-spacing: .5em; color: var(--ink-accent); margin-top: 6px; }
.logo .tentative { margin-top: 10px; font-size: 13px; color: var(--ink-dim); letter-spacing: .1em; }
.title-menu { position: relative; display: flex; flex-direction: column; gap: 10px; padding: 0 28px; padding-bottom: max(28px, env(safe-area-inset-bottom)); }
.title-menu .btn { min-height: 54px; font-size: 18px; }
.tap-start { position: relative; text-align: center; padding-bottom: max(80px, env(safe-area-inset-bottom)); }
.tap-start .btn { margin: 0 auto; width: min(320px, 86%); min-height: 60px; font-size: 18px; animation: glow 2.2s ease-in-out infinite; }
.tap-start p { color: var(--ink-faint); font-size: 13px; margin: 14px 0 0; }

/* 事件ファイル */
.files { display: flex; flex-direction: column; gap: 12px; }
.filecard {
  position: relative; display: block; width: 100%; text-align: left; padding: 14px 16px; border-radius: 14px;
  border: 1px solid var(--rim-soft); background: linear-gradient(135deg, #fffcf6, #fff0d4); cursor: pointer;
  min-height: 84px;
}
.filecard .no { font-size: 13px; color: var(--ink-accent); letter-spacing: .15em; }
.filecard .ttl { font-size: 20px; font-weight: 700; margin-top: 2px; font-family: var(--font-title); }
.filecard .sub { font-size: 14px; color: var(--ink-dim); margin-top: 4px; }
.filecard .stamp { position: absolute; right: 12px; top: 12px; font-size: 12px; padding: 2px 8px; border-radius: 6px; border: 1px solid var(--ok); color: var(--ok); }
.filecard.soon, .filecard.secret { cursor: default; opacity: .6; background: repeating-linear-gradient(135deg, #f6ead4 0 12px, #f0e2c8 12px 24px); }
.filecard.secret .ttl { letter-spacing: .3em; }

/* 設定 */
.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(--amber-deep); }
.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.seg .btn { min-height: 44px; font-size: 15px; padding: 4px; }

/* ログ */
.log-item { padding: 8px 0; border-bottom: 1px solid rgba(217, 163, 0, 0.18); font-size: 16px; line-height: 1.55; white-space: pre-wrap; }
.log-item .who { display: block; font-size: 13px; font-weight: 700; color: var(--ink-accent); border-left: 4px solid var(--nc, var(--amber)); padding-left: 6px; }
.log-item.narr { color: #8a7664; }

/* 証拠ファイル */
.tabs { display: flex; gap: 6px; padding: 8px 12px 0; }
.tabs .btn { flex: 1; min-height: 44px; border-radius: 10px 10px 0 0; }
.tabs .btn.on { background: linear-gradient(180deg, #ffe58a, #ffd24a); border-color: var(--amber-deep); color: var(--ink); }
.detail { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border-radius: 12px; background: rgba(255, 244, 224, 0.7); border: 1px solid var(--rim-soft); margin-bottom: 12px; min-height: 110px; }
.detail .big { flex: 0 0 auto; width: 76px; height: 76px; border-radius: 12px; display: grid; place-items: center; font-size: 46px; background: radial-gradient(circle at 50% 40%, #fff8e6, #ffe6b8); border: 1px solid var(--rim-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(--ink-accent); }
.detail .info p { margin: 0; font-size: 15px; line-height: 1.6; 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(--rim-soft);
  background: linear-gradient(180deg, #fffcf6, #fff1d6); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
}
.item .ic { font-size: 32px; line-height: 1; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 10px; overflow: hidden; }
.item .ic img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 0; }
.item .nm { font-size: 13px; line-height: 1.3; text-align: center; color: var(--ink); }
.item.on { border-color: var(--amber-deep); box-shadow: 0 0 0 2px rgba(255, 210, 74, 0.6); background: linear-gradient(180deg, #fff3c0, #ffe58a); }
.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; }
.clash-list { display: flex; flex-direction: column; gap: 8px; }
.clash-list .btn { justify-content: flex-start; text-align: left; font-weight: 400; font-size: 16px; min-height: 56px; padding: 8px 12px; }
.clash-list .btn .n { flex: 0 0 auto; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--navy-3); font-size: 13px; font-weight: 700; color: var(--ink-accent); }

/* メニュー・確かめ */
.menu-list { display: flex; flex-direction: column; gap: 10px; }
.dialog { margin: auto 20px; padding: 20px; border-radius: 16px; background: var(--glass-strong); border: 1px solid var(--rim); }
.dialog p { margin: 0 0 16px; font-size: 16px; line-height: 1.6; }
.dialog .row .btn { flex: 1; }

/* 結果 */
.result { text-align: center; }
.result h2 { font-family: var(--font-title); font-size: 30px; color: var(--ink); letter-spacing: .3em; margin: 12px 0 4px; text-shadow: 0 2px 0 rgba(255, 210, 74, 0.9); }
.result .ep { color: var(--ink-dim); font-size: 15px; margin-bottom: 18px; }
.result .stat { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--rim-soft); font-size: 16px; }
.result .stat .v { color: var(--ink-accent); font-weight: 700; }
.result .lampsrow { display: inline-flex; gap: 3px; vertical-align: middle; }
.result .credit { margin-top: 20px; padding: 14px; border-radius: 12px; border: 1px solid var(--rim-soft); background: rgba(255, 240, 200, 0.5); text-align: left; }
.result .credit h3 { margin: 0 0 8px; font-size: 14px; color: var(--ink-accent); letter-spacing: .2em; }
.result .credit p { margin: 0 0 10px; font-size: 15px; line-height: 1.6; }
.result .credit .btn { width: 100%; text-decoration: none; }

/* 負け */
.lose { justify-content: center; text-align: center; background: rgba(255, 244, 224, 0.96); }
.lose h2 { font-family: var(--font-title); font-size: 26px; letter-spacing: .2em; color: #8a7664; margin: 0 0 10px; }
.lose p { color: var(--ink-dim); margin: 0 0 26px; font-size: 15px; }
.lose .lampsrow { display: flex; gap: 4px; justify-content: center; margin-bottom: 18px; }
.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(90, 70, 54, 0.35); animation: fadein .12s ease 1; }
#cutin .band {
  position: absolute; left: -10%; right: -10%; top: 50%; height: 168px; margin-top: -96px;
  transform: rotate(-7deg);
  background: linear-gradient(90deg, #ffe58a 0%, #ffd24a 35%, #b8de78 70%, #ffe58a 100%);
  border-top: 3px solid var(--amber-deep); border-bottom: 3px solid var(--amber-deep);
  box-shadow: 0 0 40px rgba(255, 210, 74, 0.5);
  overflow: hidden;
}
#cutin .band::before { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.35) 0 2px, transparent 2px 26px); animation: speed .35s linear infinite; }
#cutin .face {
  position: absolute; left: 12%; top: -24px; width: 190px; height: 216px;
  transform: rotate(7deg); border-radius: 14px; overflow: hidden; border: 2px solid var(--amber-hi);
  background: #fff8ec;
}
#cutin .face img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 12%; }
#cutin .words {
  position: absolute; right: 9%; top: 50%; transform: translateY(-50%) rotate(7deg);
  font-family: var(--font-title); font-weight: 900; font-size: clamp(28px, 8.6vw, 46px); letter-spacing: .04em; white-space: pre; text-align: center; line-height: 1.12;
  color: #fffdf6; -webkit-text-stroke: 1.5px #5a4636; text-shadow: 0 0 16px rgba(255, 255, 255, 0.7), 3px 3px 0 #5a4636;
}
#cutin.go .band { animation: bandin .9s cubic-bezier(.2, .9, .2, 1) 1 both; }
#cutin.go .words { animation: wordsin .9s ease 1 both; }

/* 最後の決め手「世界がおかしいのだ」: 低く静かに（帯の色を落とす・文字を大きく・間を長く） */
#cutin.tsume .dark { background: rgba(42, 30, 20, 0.72); }
#cutin.tsume .band {
  background: linear-gradient(90deg, #2a1e14 0%, #4a3828 40%, #5a4636 72%, #2a1e14 100%);
  border-color: #d9a300; box-shadow: 0 0 36px rgba(42, 30, 20, 0.6);
}
#cutin.tsume .band::before { opacity: .35; animation-duration: 1.4s; }
#cutin.tsume .face { border-color: #d9a300; }
#cutin.tsume .face img { filter: brightness(.8) contrast(1.08) saturate(.85); }
#cutin.tsume .words {
  font-size: clamp(28px, 8.6vw, 50px); letter-spacing: .04em; color: #ffe58a;
  -webkit-text-stroke: 1px #2a1e14; text-shadow: 0 0 24px rgba(255, 210, 74, 0.5), 0 2px 0 #1e1610;
}
#cutin.tsume.go .band { animation: bandin-slow 1.7s cubic-bezier(.16, .84, .3, 1) 1 both; }
#cutin.tsume.go .words { animation: wordsin-slow 1.7s ease 1 both; }
@keyframes bandin-slow { 0% { transform: rotate(-7deg) translateX(-110%); } 20% { transform: rotate(-7deg) translateX(0); } 90% { transform: rotate(-7deg) translateX(0); opacity: 1; } 100% { transform: rotate(-7deg) translateX(0); opacity: 0; } }
@keyframes wordsin-slow { 0% { opacity: 0; transform: translateY(-50%) rotate(7deg) scale(1.12); } 24% { opacity: 1; transform: translateY(-50%) rotate(7deg) scale(1); } 90% { opacity: 1; } 100% { opacity: 0; } }

/* 大きな帯（推理決闘 開始／決着／証言） */
#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(255, 252, 246, 0.96) 15%, rgba(255, 252, 246, 0.96) 85%, transparent);
  border-top: 1px solid var(--rim); border-bottom: 1px solid var(--rim);
  animation: bannerin 1.4s ease 1 both;
}
#banner .b .big { font-family: var(--font-title); font-size: clamp(30px, 9vw, 42px); font-weight: 700; letter-spacing: .3em; color: var(--ink); text-shadow: 0 2px 0 rgba(255, 210, 74, 0.9); }
#banner .b .small { margin-top: 6px; font-size: 15px; color: var(--ink-accent); letter-spacing: .1em; }

/* 題の札 */
.titlecard { background: #fff4e0; justify-content: center; align-items: center; text-align: center; cursor: pointer; }
.titlecard .no { font-size: 15px; letter-spacing: .5em; color: var(--ink-accent); }
.titlecard .ttl { margin: 14px 0; font-family: var(--font-title); font-size: clamp(30px, 9vw, 40px); color: var(--ink); letter-spacing: .12em; text-shadow: 0 2px 0 rgba(255, 210, 74, 0.8); padding: 0 16px; }
.titlecard .sub { font-size: 14px; color: var(--ink-dim); letter-spacing: .3em; }
.titlecard .line { width: 60%; height: 1px; margin: 0 auto; background: linear-gradient(90deg, transparent, var(--amber), transparent); }

/* 証拠を手に入れた */
.gain { justify-content: center; align-items: center; background: rgba(90, 70, 54, 0.35); cursor: pointer; }
.gain .card {
  width: min(340px, 88%); padding: 18px 18px 16px; border-radius: 16px; text-align: center;
  background: linear-gradient(180deg, #fffcf6, #fff1d6); border: 1px solid var(--rim);
  box-shadow: 0 0 30px rgba(255, 210, 74, 0.45); animation: pop .35s cubic-bezier(.2, 1.4, .4, 1) 1;
}
.gain .card .head { font-size: 14px; color: var(--ink-accent); letter-spacing: .2em; }
.gain .card .ic { font-size: 64px; line-height: 1.2; margin: 10px 0 4px; }
.gain .card .ic img { width: 96px; height: 96px; object-fit: cover; border-radius: 12px; }
.gain .card h3 { margin: 0 0 8px; font-size: 20px; color: var(--ink-accent); }
.gain .card p { margin: 0; font-size: 15px; line-height: 1.6; color: var(--ink); text-align: left; white-space: pre-wrap; }
.gain .card .tapnote { margin-top: 12px; font-size: 12px; color: var(--ink-faint); }

/* ───────── 動き ───────── */
@keyframes rise { 0% { transform: translateY(0) translateX(0); opacity: 0; } 10% { opacity: .9; } 50% { transform: translateY(-45vh) translateX(6px); } 100% { transform: translateY(-90vh) translateX(-4px); opacity: 0; } }
@keyframes caustic { 0% { transform: translate(0, 0) rotate(0deg) scale(1); } 100% { transform: translate(7%, -5%) rotate(6deg) scale(1.1); } }
@keyframes drift { 0% { transform: translate(0, 0); } 50% { transform: translate(8%, -12%); } 100% { transform: translate(-6%, -22%); } }
@keyframes swim { 0% { left: 105%; } 100% { left: -15%; } }
@keyframes sway { 0% { transform: translateX(-6%); opacity: .7; } 100% { transform: translateX(6%); opacity: 1; } }
@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: .95; } 100% { opacity: 0; } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(3px); } }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { transform: scale(.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes glow { 0%, 100% { box-shadow: 0 0 0 rgba(255, 210, 74, 0); } 50% { box-shadow: 0 0 22px rgba(255, 190, 40, 0.65); } }
@keyframes speed { from { transform: translateX(0); } to { transform: translateX(-26px); } }
@keyframes bandin { 0% { transform: rotate(-7deg) translateX(-110%); } 22% { transform: rotate(-7deg) translateX(0); } 80% { transform: rotate(-7deg) translateX(0); } 100% { transform: rotate(-7deg) translateX(110%); } }
@keyframes wordsin { 0% { opacity: 0; transform: translateY(-50%) rotate(7deg) scale(1.8); } 25% { opacity: 1; transform: translateY(-50%) rotate(7deg) scale(1); } 80% { 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 flicker { 0% { opacity: 1; } 15% { opacity: .2; } 30% { opacity: 1; } 45% { opacity: .1; } 60% { opacity: .8; } 75% { opacity: 0; } 100% { opacity: 1; } }
@keyframes smoke { 0% { opacity: .8; transform: translateY(0) scale(.6); } 100% { opacity: 0; transform: translateY(-18px) scale(1.6); } }

@media (prefers-reduced-motion: reduce) {
  .bg-hall .window::before, .bg-hall .sway, .bubble, #outer-bubbles i, .bg-hall .jelly, .bg-hall .fish { animation: none !important; }
}

/* パソコン（広い画面）: 文字の箱とボタンを少しゆったり */
@media (min-width: 561px) {
  #textbox { height: 180px; }
}
/* 背の低い画面 */
@media (max-height: 700px) {
  #textbox { height: 150px; }
  :root { --btn-h: 48px; }
}

/* ───────── コントローラー（パッドがつながっている時だけ出す） ───────── */
.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 var(--font); letter-spacing: 0; color: var(--ink);
  background: #ffe58a; border: 1px solid var(--amber-deep); box-shadow: 0 1px 3px rgba(90, 70, 54, 0.35);
  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(--amber-deep); outline-offset: 2px;
  box-shadow: 0 0 0 1px #5a4636, 0 0 16px rgba(255, 190, 40, 0.75) !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; }
