/* シロの推理決闘 ― 見た目
   色: 深海の紺・青緑 ＋ 灯の琥珀色。文字の箱は「紺のすりガラス＋琥珀の細い縁」
   スマホの縦を一番に。パソコンはまん中に縦長の画面（最大幅 560px） */

:root {
  --navy-0: #040b18;
  --navy-1: #081428;
  --navy-2: #0e2140;
  --navy-3: #16325a;
  --teal: #3cc8cc;
  --teal-2: #2a97a6;
  --teal-dim: #1b5f6e;
  --amber: #ffb84d;
  --amber-hi: #ffd894;
  --amber-deep: #d9861c;
  --ink: #eaf4ff;
  --ink-dim: #a5bad2;
  --ink-faint: #6f87a6;
  --glass: rgba(10, 26, 52, 0.80);
  --glass-strong: rgba(8, 20, 42, 0.92);
  --rim: rgba(255, 184, 77, 0.62);
  --rim-soft: rgba(255, 184, 77, 0.28);
  --danger: #ff7a6b;
  --ok: #7fe3c4;
  --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: dark;
}

* { 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(60, 200, 204, 0.10), transparent 70%),
    radial-gradient(ellipse 80% 60% at 50% 110%, rgba(255, 184, 77, 0.06), transparent 70%),
    linear-gradient(180deg, #071226 0%, #040b18 60%, #02060f 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(160, 230, 255, 0.35); background: rgba(160, 230, 255, 0.06);
  animation: rise 14s linear infinite;
}

/* ───────── 画面のわく ───────── */
#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(255, 184, 77, 0.12), 0 0 60px rgba(0, 0, 0, 0.6);
}

/* 上の帯 */
#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(8, 20, 42, 0.98), rgba(10, 26, 52, 0.9));
  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(--amber); 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: #3a2a18; transition: fill .3s; }
.lamp .flame { fill: #ffcf73; opacity: 0; transition: opacity .3s; }
.lamp .metal { fill: #8f7350; }
.lamp.on .glass { fill: #ffb84d; }
.lamp.on .flame { opacity: 1; }
.lamp.on svg { filter: drop-shadow(0 0 5px rgba(255, 184, 77, 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(200, 210, 230, 0.55); 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(14, 33, 64, 0.8);
  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: #000; }
#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(64, 170, 220, 0.20), transparent 70%),
    linear-gradient(180deg, #06142a 0%, #0a1d3a 55%, #071226 72%, #040c1a 100%);
}
.bg-hall .pillar { position: absolute; top: 0; bottom: 22%; width: 11%; background: linear-gradient(90deg, #07152b, #0f2547 45%, #091a33); box-shadow: 0 0 18px rgba(0, 0, 0, 0.5); }
.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 #1f3d63; box-shadow: 0 0 0 6px #0b1c36, 0 0 40px rgba(60, 180, 230, 0.35), inset 0 0 50px rgba(0, 20, 50, 0.7);
  overflow: hidden;
  background: linear-gradient(180deg, #2a8fc0 0%, #18649a 35%, #0d3d6e 70%, #082a52 100%);
}
.bg-hall .window::before {   /* ゆれる青い光（やわらかい光のまだら） */
  content: ""; position: absolute; inset: -30%;
  background:
    radial-gradient(ellipse 16% 7% at 28% 30%, rgba(190, 245, 255, 0.26), transparent 70%),
    radial-gradient(ellipse 20% 8% at 66% 46%, rgba(190, 245, 255, 0.20), transparent 70%),
    radial-gradient(ellipse 13% 6% at 42% 68%, rgba(190, 245, 255, 0.18), transparent 70%),
    radial-gradient(ellipse 22% 7% at 78% 22%, rgba(190, 245, 255, 0.16), transparent 70%),
    radial-gradient(ellipse 18% 6% at 20% 58%, rgba(190, 245, 255, 0.14), 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;
  background:
    radial-gradient(ellipse 50% 30% at 50% 28%, rgba(220, 245, 255, 0.85), rgba(150, 220, 255, 0.35) 60%, transparent 72%),
    repeating-linear-gradient(90deg, transparent 0 18%, rgba(170, 230, 255, 0.35) 18% 22%) 50% 100% / 70% 55% no-repeat;
  filter: blur(.4px) drop-shadow(0 0 8px rgba(160, 230, 255, 0.6));
  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(4, 18, 40, 0.55);
  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(10, 30, 60, 0.7) 49.4% 50.6%, transparent 50.6%),
    linear-gradient(180deg, transparent 58%, rgba(10, 30, 60, 0.55) 58% 59.2%, transparent 59.2%),
    linear-gradient(105deg, transparent 20%, rgba(200, 245, 255, 0.10) 28%, transparent 36%),
    linear-gradient(75deg, transparent 58%, rgba(200, 245, 255, 0.07) 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%, #3b6b88, transparent 70%); opacity: .8; }
.bg-hall .floor {
  position: absolute; left: 0; right: 0; bottom: 0; height: 24%;
  background: linear-gradient(180deg, #0b1f3c 0%, #071429 100%);
  border-top: 1px solid rgba(120, 200, 240, 0.25);
}
.bg-hall .floor::before { content: ""; position: absolute; inset: 0; background: radial-gradient(ellipse 40% 60% at 50% 0%, rgba(80, 180, 230, 0.22), transparent 70%); }
.bg-hall .sway { position: absolute; inset: 0; background: radial-gradient(ellipse 50% 35% at 50% 30%, rgba(90, 200, 255, 0.10), 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(200, 245, 255, 0.55); background: rgba(200, 245, 255, 0.10);
  animation: rise 8s linear infinite; opacity: 0;
}
.bg-hall .lampglow { position: absolute; bottom: 20%; width: 16%; height: 22%; background: radial-gradient(ellipse at 50% 60%, rgba(255, 184, 77, 0.22), 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, 190, 110, 0.20), transparent 70%),
    linear-gradient(180deg, #2a2234 0%, #3a2c36 50%, #2a1f28 74%, #1a1420 100%);
}
.bg-office .wall-line { position: absolute; left: 0; right: 0; top: 62%; height: 6px; background: #4a3540; box-shadow: 0 2px 0 #2a1e26; }
.bg-office .floor { position: absolute; left: 0; right: 0; bottom: 0; height: 26%; background: repeating-linear-gradient(90deg, #3a2a26 0 46px, #33241f 46px 48px), linear-gradient(#3a2a26, #2a1e1c); }
.bg-office .window { position: absolute; left: 8%; top: 10%; width: 30%; height: 38%; border: 4px solid #5a4250; border-radius: 6px; background: linear-gradient(180deg, #123a66, #0d2a4c); box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.5); }
.bg-office .window::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent 48%, #5a4250 48% 52%, transparent 52%), linear-gradient(180deg, transparent 48%, #5a4250 48% 52%, transparent 52%); }
.bg-office .fridge { position: absolute; right: 8%; bottom: 22%; width: 18%; height: 36%; background: linear-gradient(90deg, #cfd8e4, #e8eef6 60%, #b8c4d4); border-radius: 6px; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5); }
.bg-office .fridge::before { content: ""; position: absolute; left: 0; right: 0; top: 34%; height: 2px; background: #8e9bb0; }
.bg-office .fridge::after { content: ""; position: absolute; left: 22%; top: 42%; width: 22%; height: 14%; background: #ff9fc8; transform: rotate(-6deg); box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.bg-office .lamp { position: absolute; right: 30%; top: 8%; width: 14%; height: 10%; background: radial-gradient(ellipse at 50% 100%, rgba(255, 200, 120, 0.55), transparent 70%); }
.bg-office .shelf { position: absolute; left: 44%; top: 18%; width: 22%; height: 40%; background: repeating-linear-gradient(180deg, #3e2c2a 0 30%, #5a3e34 30% 33%); border: 3px solid #5a3e34; opacity: .85; }

.bg-black { background: #000; }

/* キャラ */
#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(.55) saturate(.75); }
.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(0, 0, 0, 0.55), 0 0 0 4px rgba(8, 20, 42, 0.55);
  background: var(--card, #dce8fd);
  transition: transform .2s ease;
}
.chara.talk { z-index: 2; }
.chara.talk .frame { transform: translateY(-6px) scale(1.06); box-shadow: 0 10px 26px rgba(0, 0, 0, 0.6), 0 0 0 4px rgba(8, 20, 42, 0.55), 0 0 18px rgba(255, 184, 77, 0.35); }
.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(--amber-hi); 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(6, 16, 34, 0.95); 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(--amber); letter-spacing: .1em; }
#board ol { margin: 0; padding-left: 1.4em; }
#board li { color: var(--ink-dim); }
#board li b { color: var(--amber-hi); font-weight: 700; }

/* フィールドのキャンバス */
#field-cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; z-index: 4; background: #050a14; 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(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 216, 148, 0.18);
  cursor: pointer;
}
#nameplate {
  position: absolute; left: 12px; top: -15px; min-width: 84px; padding: 4px 14px;
  border-radius: 8px; background: linear-gradient(180deg, #13294d, #0c1c38); 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(0, 0, 0, 0.4);
}
#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: #cfe2f5; font-style: normal; }
#text.low { color: #b9d4ff; letter-spacing: .04em; }
#text.testi { color: var(--amber-hi); }
#text.sys { color: var(--ok); }
#text.question { color: var(--ink); }
#text .qno { display: block; font-size: 13px; color: var(--amber); letter-spacing: .1em; margin-bottom: 2px; }
#next-mark {
  position: absolute; right: 14px; bottom: 8px; color: var(--amber); 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(--amber); 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, #15305a, #0e2142);
  font-size: 16px; font-weight: 700; letter-spacing: .04em; color: var(--ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 2px 6px rgba(0, 0, 0, 0.35);
  display: flex; align-items: center; justify-content: center; gap: 6px; text-align: center; line-height: 1.25;
}
.btn:active { transform: translateY(1px); filter: brightness(1.15); }
.btn[disabled] { opacity: .4; cursor: default; }
.btn.amber { background: linear-gradient(180deg, #ffc76b, #e79a2c); color: #2a1604; border-color: #ffe0a6; }
.btn.teal { background: linear-gradient(180deg, #2fa9b3, #1d7683); border-color: #7fe3e6; }
.btn.ghost { background: rgba(14, 33, 64, 0.55); }
.btn.small { min-height: 44px; font-size: 15px; }
.btn .ico { font-size: 18px; }
.btn.wide { width: 100%; }
.btn.sel { outline: 2px solid var(--amber); background: linear-gradient(180deg, #4a3712, #2e2108); }
.btn.right-ans { background: linear-gradient(180deg, #2a8f78, #1b6a58); border-color: var(--ok); }
.btn.right-ans[disabled], .btn.wrong-ans[disabled] { opacity: 1; }
.btn.wrong-ans { background: linear-gradient(180deg, #8f3a35, #6a2420); 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(--amber-hi); font-size: 18px; }
.nav .count .done { display: inline-block; margin-left: 8px; padding: 1px 7px; border-radius: 6px; background: var(--teal-dim); color: #d8fbff; 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, #0a1830, #050d1c); -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(--amber-hi); 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(4, 11, 24, 0.15), rgba(4, 11, 24, 0.55) 55%, rgba(4, 11, 24, 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); margin-bottom: 10px; }
.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: #fff4dc; text-shadow: 0 0 18px rgba(255, 184, 77, 0.65), 0 0 2px #ffb84d, 0 3px 0 #6a3a08;
}
.logo h1 small { display: block; font-size: .42em; letter-spacing: .5em; color: var(--amber-hi); margin-top: 6px; }
.logo .tentative { margin-top: 10px; font-size: 13px; color: var(--ink-faint); 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, #12284c, #0b1a34); cursor: pointer;
  min-height: 84px;
}
.filecard .no { font-size: 13px; color: var(--amber); 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, #0d1d38 0 12px, #0b1830 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); }
.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(255, 184, 77, 0.12); font-size: 16px; line-height: 1.55; white-space: pre-wrap; }
.log-item .who { display: block; font-size: 13px; font-weight: 700; color: var(--nc, var(--amber)); }
.log-item.narr { color: #bcd2ea; }

/* 証拠ファイル */
.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, #2a4f86, #183463); border-color: var(--rim); color: var(--amber-hi); }
.detail { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border-radius: 12px; background: rgba(4, 12, 26, 0.6); 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%, #1d3c6a, #0b1a34); 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(--amber-hi); }
.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, #13294d, #0c1c38); 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); box-shadow: 0 0 0 2px rgba(255, 184, 77, 0.45); background: linear-gradient(180deg, #2a3f63, #182b4c); }
.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(--amber-hi); }

/* メニュー・確かめ */
.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: #fff4dc; letter-spacing: .3em; margin: 12px 0 4px; text-shadow: 0 0 14px rgba(255, 184, 77, 0.6); }
.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(--amber-hi); 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(4, 12, 26, 0.5); text-align: left; }
.result .credit h3 { margin: 0 0 8px; font-size: 14px; color: var(--amber); 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(2, 5, 12, 0.95); }
.lose h2 { font-family: var(--font-title); font-size: 26px; letter-spacing: .2em; color: #c9d6ea; 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(2, 6, 14, 0.55); 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, #06142a 0%, #0f2e57 35%, #1b6f86 70%, #0a1d3a 100%);
  border-top: 3px solid var(--amber); border-bottom: 3px solid var(--amber);
  box-shadow: 0 0 40px rgba(60, 200, 204, 0.4);
  overflow: hidden;
}
#cutin .band::before { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.07) 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: #dce8fd;
}
#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(34px, 10vw, 50px); letter-spacing: .06em; white-space: nowrap;
  color: #fff6e2; -webkit-text-stroke: 1.5px #6a3a08; text-shadow: 0 0 16px rgba(255, 184, 77, 0.9), 3px 3px 0 #3a1f04;
}
#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(0, 2, 8, 0.8); }
#cutin.tsume .band {
  background: linear-gradient(90deg, #010308 0%, #050d1c 40%, #0a1730 72%, #010308 100%);
  border-color: #b8781e; box-shadow: 0 0 36px rgba(0, 0, 0, 0.85);
}
#cutin.tsume .band::before { opacity: .35; animation-duration: 1.4s; }
#cutin.tsume .face { border-color: #b8781e; }
#cutin.tsume .face img { filter: brightness(.8) contrast(1.08) saturate(.85); }
#cutin.tsume .words {
  font-size: clamp(46px, 13.5vw, 68px); letter-spacing: .14em; color: #ffe8bf;
  -webkit-text-stroke: 1px #2a1604; text-shadow: 0 0 24px rgba(255, 184, 77, 0.5), 0 2px 0 #000;
}
#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(6, 18, 38, 0.95) 15%, rgba(6, 18, 38, 0.95) 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: #fff4dc; text-shadow: 0 0 14px rgba(255, 184, 77, 0.7); }
#banner .b .small { margin-top: 6px; font-size: 15px; color: var(--amber-hi); letter-spacing: .1em; }

/* 題の札 */
.titlecard { background: #000; justify-content: center; align-items: center; text-align: center; cursor: pointer; }
.titlecard .no { font-size: 15px; letter-spacing: .5em; color: var(--amber); }
.titlecard .ttl { margin: 14px 0; font-family: var(--font-title); font-size: clamp(30px, 9vw, 40px); color: #fff4dc; letter-spacing: .12em; text-shadow: 0 0 16px rgba(255, 184, 77, 0.5); 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(2, 6, 14, 0.6); cursor: pointer; }
.gain .card {
  width: min(340px, 88%); padding: 18px 18px 16px; border-radius: 16px; text-align: center;
  background: linear-gradient(180deg, #13294d, #0a1a34); border: 1px solid var(--rim);
  box-shadow: 0 0 30px rgba(255, 184, 77, 0.25); animation: pop .35s cubic-bezier(.2, 1.4, .4, 1) 1;
}
.gain .card .head { font-size: 14px; color: var(--amber); 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(--amber-hi); }
.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, 184, 77, 0); } 50% { box-shadow: 0 0 22px rgba(255, 184, 77, 0.55); } }
@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(--amber-hi);
  background: #06101f; border: 1px solid var(--amber); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  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); outline-offset: 2px;
  box-shadow: 0 0 0 1px #2a1604, 0 0 16px rgba(255, 184, 77, 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; }
