:root { --ink: #eef3f6; --muted: #9fb0bb; --red: #ff3b30; --green: #35d07f; --panel: rgba(8, 12, 15, .82); --line: rgba(255,255,255,.14); font-family: "Noto Sans JP", "Hiragino Sans", "Yu Gothic UI", system-ui, sans-serif; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #05080a; color: var(--ink); overflow: hidden; }
.game { position: relative; width: 100vw; height: 100vh; overflow: hidden; }

/* 場面 */
.scene { position: absolute; inset: 0; }
.scene svg { width: 100%; height: 100%; display: block; }
.scene.cut svg { animation: cut .28s ease-out; }
@keyframes cut { from { opacity: 0; transform: scale(1.04); filter: brightness(1.6);} to { opacity: 1; transform: none; filter: none;} }
.scene .alarm { animation: alarm 1.6s ease-in-out infinite; }
@keyframes alarm { 0%,100% { opacity: .15;} 50% { opacity: .8;} }
.scene .caret { animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0;} }
.game.danger .scene .alarm { animation-duration: .6s; }
.game.shake { animation: shake .4s; }
.ed-btn { display: block; width: 100%; min-height: 48px; margin: 0; padding: 12px 20px 13px; border: 0; border-radius: 14px; background: linear-gradient(180deg, #ffd56b, #e8a93c); color: #1a1204; font: 800 17px/1 "Noto Sans JP", system-ui, sans-serif; letter-spacing: .06em; cursor: pointer; box-shadow: 0 6px 24px rgba(0, 0, 0, .45), 0 0 0 1px rgba(255, 213, 107, .5); animation: edIn .5s ease-out both; }
.ed-btn:hover { filter: brightness(1.07); } .ed-btn:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
@keyframes edIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.ed-btn[hidden] { display: none; }
@keyframes shake { 0%,100% { transform: none;} 25% { transform: translate(-6px, 3px);} 50% { transform: translate(5px, -4px);} 75% { transform: translate(-3px, 2px);} }

/* 上部 */
.top { position: absolute; top: 16px; left: 20px; display: flex; gap: 14px; align-items: center; z-index: 3; }
.timer { font: 800 44px/1 ui-monospace, "Cascadia Mono", Consolas, monospace; letter-spacing: .04em; color: #ffd9d6; background: rgba(40, 6, 4, .85); border: 2px solid #6e1d17; border-radius: 12px; padding: 10px 16px; text-shadow: 0 0 14px rgba(255,59,48,.7); min-width: 168px; text-align: center; }
.game.danger .timer { color: #fff; background: #a3160d; animation: pulse .6s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 10px rgba(255,59,48,0);} 0%,100% { box-shadow: 0 0 0 0 rgba(255,59,48,.6);} }
.inventory { display: flex; gap: 8px; flex-wrap: wrap; }
.item { background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-size: 13px; animation: pop .4s ease-out; }
.item.fact { border-color: rgba(143,211,255,.5); color: #cfeaff; }
@keyframes pop { from { transform: scale(.6); opacity: 0;} to { transform: none; opacity: 1;} }

/* HUD */
.hud { position: absolute; top: 16px; right: 20px; width: 300px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; z-index: 3; backdrop-filter: blur(6px); }
.hud-title { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; }
.hud-heard { font-size: 13px; margin: 6px 0 8px; color: #fff; min-height: 1.4em; }
.bar { display: grid; grid-template-columns: 1fr 44px; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); margin-top: 4px; }
.bar.win { color: #fff; }
.bar .track { grid-column: 1 / -1; height: 5px; border-radius: 3px; background: rgba(255,255,255,.12); overflow: hidden; }
.bar .track i { display: block; height: 100%; width: 0; background: #8fd3ff; transition: width .25s ease; }
.bar.win .track i { background: var(--green); }
.bar .pct { text-align: right; font-variant-numeric: tabular-nums; }

/* 下部 */
.bottom { position: absolute; left: 0; right: 0; bottom: 0; padding: 0 20px 18px; z-index: 3; display: flex; flex-direction: column; gap: 8px; background: linear-gradient(transparent, rgba(0,0,0,.75) 40%); padding-top: 60px; }
.said { align-self: flex-end; max-width: 70%; font-size: 14px; color: #d7f5e5; background: rgba(18, 60, 40, .85); border: 1px solid rgba(53,208,127,.5); border-radius: 14px 14px 4px 14px; padding: 6px 12px; min-height: 0; opacity: 0; transition: opacity .2s; }
.said.show { opacity: 1; }
.said.interim { color: var(--muted); border-style: dashed; background: rgba(10,14,17,.7); }
.message { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px 18px; font-size: 18px; line-height: 1.8; min-height: 84px; backdrop-filter: blur(6px); }
.message.none { color: var(--muted); }
.message.err { border-color: rgba(255,59,48,.6); }
.message.good { border-color: rgba(53,208,127,.7); }
.input { display: flex; gap: 8px; }
.input input { flex: 1; background: rgba(8,12,15,.85); border: 1px solid var(--line); color: var(--ink); border-radius: 12px; padding: 11px 14px; font: inherit; font-size: 15px; }
.input input:focus { outline: 2px solid rgba(143,211,255,.5); }
.mic, .send { border: 1px solid var(--line); background: rgba(8,12,15,.85); color: var(--ink); border-radius: 12px; padding: 0 16px; font: inherit; cursor: pointer; }
.mic { touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.mic.on { background: #0e3b24; border-color: var(--green); box-shadow: 0 0 0 0 rgba(53,208,127,.6); animation: micpulse 1.4s infinite; }
@keyframes micpulse { 50% { box-shadow: 0 0 0 9px rgba(53,208,127,0);} }

/* オーバーレイ */
.overlay { position: absolute; inset: 0; z-index: 10; display: grid; place-items: center; background: rgba(3, 5, 7, .86); backdrop-filter: blur(4px); }
.overlay[hidden] { display: none; }
.panel { width: min(640px, 92vw); background: #0d1418; border: 1px solid var(--line); border-radius: 20px; padding: 28px 30px; }
.eyebrow { font-size: 12px; letter-spacing: .2em; color: var(--red); font-weight: 700; }
h1 { margin: 6px 0 10px; font-size: 32px; }
.panel p { margin: 0 0 12px; line-height: 1.8; color: #d5dee4; }
.howto { margin: 0 0 18px; padding-left: 18px; color: var(--muted); font-size: 14px; line-height: 1.8; }
.start { width: 100%; border: 0; border-radius: 12px; padding: 14px; font: inherit; font-weight: 700; font-size: 16px; cursor: pointer; background: var(--red); color: #fff; margin-top: 6px; }
.start.ghost { background: transparent; border: 1px solid var(--line); color: var(--ink); font-weight: 400; }
.badge { margin-top: 12px; font-size: 12px; color: var(--muted); }
.stats { display: flex; gap: 10px; flex-wrap: wrap; margin: 10px 0 14px; }
.stat { background: rgba(255,255,255,.06); border-radius: 10px; padding: 8px 12px; font-size: 13px; color: var(--muted); }
.stat b { display: block; font-size: 20px; color: #fff; }

@media (max-width: 820px) { .hud { width: 220px; } .timer { font-size: 30px; min-width: 120px; } .message { font-size: 15px; } }

/* 手がかり・入手通知・エンディング */
.clues { position: absolute; left: 18px; top: 86px; z-index: 4; width: 270px; max-height: 46vh; overflow: auto; background: rgba(8,12,15,.72); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; backdrop-filter: blur(4px); }
.clues[hidden] { display: none !important; }
.clues-title { font-size: 11px; letter-spacing: .12em; color: var(--muted); display: flex; justify-content: space-between; margin-bottom: 6px; }
.clues-title span { color: #ffd56b; }
.clue { font-size: 12.5px; line-height: 1.45; padding: 5px 0 5px 10px; border-left: 3px solid rgba(143,211,255,.6); margin: 4px 0; color: #d6e6ef; animation: pop .4s ease-out; }
.clue.truth { border-left-color: #ffd56b; color: #fff1c9; }
.gainpop { position: absolute; left: 50%; top: 22%; transform: translate(-50%, -8px); z-index: 6; display: grid; gap: 8px; opacity: 0; pointer-events: none; transition: opacity .35s, transform .35s; }
.gainpop.show { opacity: 1; transform: translate(-50%, 0); }
.gainpop-row { background: rgba(8,12,15,.9); border: 1px solid rgba(143,211,255,.6); border-radius: 12px; padding: 10px 18px; font-size: 17px; font-weight: 700; color: #fff; text-align: center; box-shadow: 0 8px 30px rgba(0,0,0,.5); }
.gainpop-row small { display: block; font-size: 11px; letter-spacing: .14em; font-weight: 600; color: #8fd3ff; margin-bottom: 2px; }
.gainpop-row.item-row { border-color: rgba(125,255,182,.7); } .gainpop-row.item-row small { color: #7dffb6; }
.gainpop-row.truth-row { border-color: #ffd56b; } .gainpop-row.truth-row small { color: #ffd56b; }
.message.reveal { color: #fff1c9; }
h1.end-true { color: #ffd56b; } h1.end-good { color: #7dffb6; } h1.end-special { color: #c9b6ff; } h1.end-bad { color: #ff6b5e; }
.ends { margin: 0 0 14px; } .ends-title { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.end-chip { display: inline-block; font-size: 12px; padding: 4px 10px; margin: 0 6px 6px 0; border-radius: 999px; border: 1px dashed var(--line); color: var(--muted); }
.end-chip.seen { border-style: solid; color: #fff; } .end-chip.seen.true { border-color: #ffd56b; color: #ffd56b; } .end-chip.seen.special { border-color: #c9b6ff; } .end-chip.seen.good { border-color: #7dffb6; } .end-chip.seen.bad { border-color: #ff6b5e; }
@media (max-width: 900px) { .clues { width: 200px; } }

.free-tag { margin-top: 6px; font-size: 11.5px; color: #c9b6ff; border-top: 1px dashed rgba(201,182,255,.4); padding-top: 6px; }

/* 探せる場所 */
.scene .alarm { pointer-events: none; }
.scene .hot { fill: transparent; cursor: help; }
.scene .hot:hover { fill: rgba(255, 255, 255, .07); stroke: rgba(255, 255, 255, .5); stroke-width: 2; stroke-dasharray: 6 5; }
.tip { position: absolute; z-index: 7; transform: translate(-50%, -100%); background: rgba(8, 12, 15, .94); border: 1px solid rgba(255, 213, 107, .8); color: #fff1c9; font-size: 13px; font-weight: 700; padding: 5px 11px; border-radius: 999px; white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity .12s; }
.tip.show { opacity: 1; }
.top, .bottom { pointer-events: none; } .top > *, .bottom > * { pointer-events: auto; }
[hidden] { display: none !important; }

/* エンディング一覧 */
.ends-title b { color: #ffd56b; margin-left: 6px; }
.ends-kinds { display: flex; gap: 6px; margin: 0 0 7px; }
.ends-kind { flex: 1; text-align: center; font-size: 10.5px; letter-spacing: .04em; color: var(--muted); padding: 4px 2px; border: 1px solid rgba(255, 255, 255, .12); border-radius: 8px; }
.ends-kind b { font-size: 12.5px; margin-left: 3px; color: #cfd8de; font-variant-numeric: tabular-nums; }
.ends-kind.full.true { border-color: rgba(255, 213, 107, .7); } .ends-kind.full.true b { color: #ffd56b; }
.ends-kind.full.normal { border-color: rgba(143, 211, 255, .6); } .ends-kind.full.normal b { color: #8fd3ff; }
.ends-kind.full.bad { border-color: rgba(255, 107, 94, .7); } .ends-kind.full.bad b { color: #ff6b5e; }
.end-list { list-style: none; margin: 0 0 14px; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.end-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12.5px; padding: 7px 10px; border-radius: 9px; border: 1px dashed var(--line); color: var(--muted); }
.end-row.seen { border-style: solid; color: #fff; background: rgba(255, 255, 255, .04); }
.end-row.seen.true { border-color: #ffd56b; } .end-row.seen.good { border-color: rgba(125, 255, 182, .7); } .end-row.seen.normal { border-color: rgba(143, 211, 255, .6); } .end-row.seen.special { border-color: rgba(201, 182, 255, .7); } .end-row.seen.bad { border-color: rgba(255, 107, 94, .7); }
.counters { display: flex; gap: 8px; width: 100%; margin: 14px 0 2px; }
.counters .c { flex: 1; text-align: center; padding: 9px 4px 8px; border: 1px solid rgba(255, 255, 255, .14); border-radius: 12px; background: rgba(255, 255, 255, .03); }
.counters .c b { display: block; font-size: 21px; font-weight: 800; color: #ffd56b; font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.counters .c span { font-size: 10.5px; color: var(--muted); }
@media (max-width: 560px) { .counters .c b { font-size: 18px; } .counters .c span { font-size: 9.5px; } }
.end-row.now { box-shadow: 0 0 0 2px rgba(255, 213, 107, .35); }
.end-clear { flex: none; font-size: 10.5px; font-weight: 800; letter-spacing: .08em; color: #0d1418; background: #7dffb6; border-radius: 999px; padding: 2px 8px; }
.panel { max-height: 94vh; max-height: 94dvh; overflow: auto; }

/* スマホ・縦長: 場面を16:9で上に置き、その下に判定・手がかり・文章・入力を積む */
@media (max-width: 700px), (orientation: portrait) and (max-width: 1000px) {
  html, body { overflow: hidden; }
  .game { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow-y: auto; }
  .scene { position: relative; inset: auto; width: 100%; aspect-ratio: 16 / 9; flex: none; overflow: hidden; }
  .top { top: 6px; left: 6px; right: 6px; gap: 6px; align-items: flex-start; }
  .timer { font-size: 18px; min-width: 0; padding: 4px 8px; border-width: 1px; border-radius: 8px; }
  .inventory { gap: 4px; } .item { font-size: 10.5px; padding: 2px 7px; }
  .hud { position: static; width: auto; margin: 8px 10px 0; padding: 8px 10px; order: 2; backdrop-filter: none; }
  .hud .bar:not(.win) { display: none; } .hud-heard { margin: 3px 0 2px; font-size: 12px; }
  .clues { position: static; width: auto; margin: 8px 10px 0; max-height: 18vh; order: 3; }
  .bottom { position: static; order: 4; margin-top: auto; padding: 8px 10px calc(10px + env(safe-area-inset-bottom)); background: none; }
  .said { font-size: 12px; max-width: 90%; }
  .message { font-size: 14.5px; line-height: 1.65; min-height: 76px; padding: 10px 12px; }
  .input input { font-size: 16px; padding: 10px 12px; min-width: 0; } .mic, .send { padding: 0 12px; }
  .gainpop { top: 14vw; width: 86vw; } .gainpop-row { font-size: 14px; padding: 8px 12px; }
  .panel { padding: 18px 16px; border-radius: 16px; } h1 { font-size: 23px; } .panel p { font-size: 14px; } .howto { font-size: 13px; margin-bottom: 12px; }
  .end-list { grid-template-columns: 1fr; } .stat b { font-size: 16px; } .stats { gap: 6px; }
}
@media (max-width: 700px), (orientation: portrait) and (max-width: 1000px) {
  .panel { display: flex; flex-direction: column; }
  .overlay.title .panel .start { order: 3; } .overlay.title .panel #ovHow { order: 5; margin-top: 14px; } .overlay.title .panel #ovEnds { order: 6; } .overlay.title .panel .badge { order: 7; }
  .end-row { padding: 5px 10px; font-size: 12px; } .end-list { gap: 4px; }
}

/* 300 から減るタイマー・所持アイテム・中央の入手表示・文中ヒント */
.top { align-items: flex-start; }
.timer { min-width: 132px; font-size: 52px; position: relative; padding-bottom: 18px; }
.timer::after { content: 'SEC'; position: absolute; left: 0; right: 0; bottom: 4px; font: 700 10px/1 ui-monospace, monospace; letter-spacing: .3em; color: #ff8d85; text-shadow: none; }
.inventory { align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 7px 10px; max-width: min(52vw, 620px); backdrop-filter: blur(6px); }
.inv-title { font-size: 11px; letter-spacing: .1em; color: var(--muted); margin-right: 2px; }
.item { background: rgba(255,255,255,.07); display: inline-flex; align-items: center; gap: 5px; }
.item i { font-style: normal; } .item.none { color: var(--muted); background: none; border-style: dashed; animation: none; }
.clues { top: 118px; }
.gainpop { top: 50%; width: min(760px, 88vw); transform: translate(-50%, -46%) scale(.92); }
.gainpop.show { transform: translate(-50%, -50%) scale(1); }
.gainpop-row { position: relative; padding: 20px 26px 22px; border-width: 2px; border-radius: 18px; background: rgba(6, 10, 13, .95); box-shadow: 0 0 0 100vmax rgba(0,0,0,.16), 0 18px 60px rgba(0,0,0,.7); }
.gainpop-row + .gainpop-row { box-shadow: 0 18px 60px rgba(0,0,0,.7); }
.gainpop-row small { font-size: 14px; margin-bottom: 6px; } .gainpop-row b { display: block; font-size: 32px; line-height: 1.35; }
.gainpop-icon { display: block; font-size: 46px; line-height: 1.1; margin-bottom: 4px; }
.message .hint { color: #ffd84a; font-weight: 700; }
@media (max-width: 700px), (orientation: portrait) and (max-width: 1000px) {
  .timer { font-size: 22px; min-width: 0; padding: 4px 8px 12px; } .timer::after { font-size: 7px; bottom: 2px; }
  .inventory { padding: 3px 6px; max-width: none; border-radius: 8px; } .inv-title { font-size: 9px; }
  .gainpop { width: 90vw; } .gainpop-row { padding: 12px 14px 14px; } .gainpop-row b { font-size: 19px; } .gainpop-row small { font-size: 11px; } .gainpop-icon { font-size: 30px; }
}

/* タイトル画面（300脱出） */
.logo { display: none; }
.overlay.title { background: radial-gradient(ellipse at 50% 30%, #1a0707 0%, #050608 62%); backdrop-filter: none; overflow: hidden; }
.overlay.title::before { content: ''; position: absolute; inset: 0; background: repeating-linear-gradient(0deg, rgba(255,255,255,.035) 0 1px, transparent 1px 4px); pointer-events: none; }
.overlay.title::after { content: ''; position: absolute; inset: 0; box-shadow: inset 0 0 180px 40px rgba(255, 40, 30, .16); animation: alarm 2.4s ease-in-out infinite; pointer-events: none; }
.title-fx { display: none; }
.overlay.title .title-fx { display: block; position: absolute; inset: 0; pointer-events: none; }
.fx-count { position: absolute; right: -2vw; bottom: -9vh; font: 800 46vh/1 ui-monospace, "Cascadia Mono", Consolas, monospace; color: rgba(255, 59, 48, .07); letter-spacing: -.04em; }
.overlay.title .panel { position: relative; width: min(820px, 94vw); background: transparent; border: 0; text-align: center; padding: 10px 24px 18px; }
.overlay.title .logo { display: block; width: clamp(240px, 46vw, 420px); height: auto; margin: 0 auto 2px; animation: logoin .9s ease-out both; }
@keyframes logoin { from { opacity: 0; transform: scale(1.06); filter: blur(6px) brightness(2);} to { opacity: 1; transform: none; } }
.overlay.title h1 { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.overlay.title .eyebrow { letter-spacing: .28em; margin-bottom: 10px; }
.overlay.title .panel p { max-width: 640px; margin: 0 auto 14px; font-size: 15px; }
.lead { display: block; font-size: 22px; font-weight: 800; color: #fff; letter-spacing: .12em; margin-bottom: 6px; }
.red { color: #ff5a4f; font-family: ui-monospace, Consolas, monospace; font-size: 1.15em; }
.overlay.title .start { width: min(420px, 100%); margin: 6px auto 0; display: block; }
.overlay.title .start:not(.ghost) { box-shadow: 0 0 0 0 rgba(255,59,48,.6); animation: pulse 1.8s infinite; font-size: 17px; }
.overlay.title .howto { text-align: left; max-width: 600px; margin: 16px auto 12px; font-size: 13px; line-height: 1.7; }
.overlay.title .ends { max-width: 640px; margin: 0 auto; text-align: left; }
.overlay.title .badge { text-align: center; }
@media (max-width: 700px), (orientation: portrait) and (max-width: 1000px) {
  .overlay.title .panel { padding: 6px 14px 14px; } .lead { font-size: 18px; } .overlay.title .logo { width: 96%; }
  .fx-count { font-size: 30vh; bottom: -4vh; }
}

/* ボタンは説明のすぐ下（一覧より上）に置く */
.panel { display: flex; flex-direction: column; }
.overlay.title .panel .start { order: 3; } .overlay.title .panel #ovHow { order: 5; margin-top: 14px; } .overlay.title .panel #ovEnds { order: 6; } .overlay.title .panel .badge { order: 7; }
.overlay.title .panel { max-height: 100vh; max-height: 100dvh; }
.overlay.title .start { flex: none; }

h1.end-normal { color: #8fd3ff; }

.panel .hint { color: #ffd84a; font-weight: 700; }

/* 所持アイテムは押せる（もう一度見る） */
button.item { font: inherit; font-size: 13px; color: var(--ink); cursor: pointer; border: 1px solid var(--line); }
button.item:hover, button.item.sel { border-color: #ffd56b; background: rgba(255, 213, 107, .14); }
.message.info { border-color: rgba(255, 213, 107, .7); }
@media (max-width: 700px), (orientation: portrait) and (max-width: 1000px) { button.item { font-size: 10.5px; } }

.gainpop-row.awake-row { border-color: #ff5a4f; background: rgba(40, 6, 4, .96); } .gainpop-row.awake-row small { color: #ff8d85; } .gainpop-row.awake-row b { font-size: 44px; color: #fff; text-shadow: 0 0 18px rgba(255, 59, 48, .8); }
@media (max-width: 700px), (orientation: portrait) and (max-width: 1000px) { .gainpop-row.awake-row b { font-size: 26px; } }

/* TRUE END のお祝い */
.confetti { position: absolute; inset: 0; z-index: 20; pointer-events: none; overflow: hidden; display: none; }
.confetti.go { display: block; }
.confetti i { position: absolute; bottom: 0; border-radius: 2px; opacity: 0; animation: pop-confetti 3.2s cubic-bezier(.12, .7, .3, 1) var(--d) forwards; }
@keyframes pop-confetti { 0% { transform: translate(0, 0) rotate(0); opacity: 1; } 55% { opacity: 1; } 100% { transform: translate(var(--x), calc(var(--y) + 120vh)) rotate(var(--r)); opacity: 0; } }
.confetti i:nth-child(3n) { animation-name: pop-confetti-hi; }
@keyframes pop-confetti-hi { 0% { transform: translate(0, 0) rotate(0); opacity: 1; } 30% { transform: translate(calc(var(--x) * .7), var(--y)) rotate(calc(var(--r) * .5)); opacity: 1; } 100% { transform: translate(var(--x), 30vh) rotate(var(--r)); opacity: 0; } }
.congrats { position: absolute; left: 50%; top: 9%; transform: translateX(-50%) scale(.4); white-space: nowrap; font-size: clamp(26px, 5vw, 58px); font-weight: 900; color: #ffd56b; text-shadow: 0 0 24px rgba(255, 213, 107, .7), 0 4px 0 #7a4a00; opacity: 0; animation: congrats 6.5s ease-out forwards; }
@keyframes congrats { 0% { opacity: 0; transform: translateX(-50%) scale(.4); } 8% { opacity: 1; transform: translateX(-50%) scale(1.15); } 14% { transform: translateX(-50%) scale(1); } 85% { opacity: 1; } 100% { opacity: 0; transform: translateX(-50%) scale(1); } }

.eyebrow.congrats-line { font-size: clamp(22px, 3.4vw, 36px); letter-spacing: .06em; color: #ffd56b; text-shadow: 0 0 22px rgba(255, 213, 107, .6); text-align: center; margin-bottom: 6px; animation: congrats-in .7s cubic-bezier(.2, 1.6, .4, 1) both; }
@keyframes congrats-in { from { transform: scale(.4); opacity: 0; } to { transform: none; opacity: 1; } }

.confetti i { animation: none !important; opacity: 0; }

.overlay.title .lead { font-size: 20px; line-height: 1.55; letter-spacing: .06em; margin-bottom: 10px; }
@media (max-width: 700px), (orientation: portrait) and (max-width: 1000px) { .overlay.title .lead { font-size: 16px; } }

/* 全エンド達成: ボタンと表彰状 */
.sp-only { display: none; }
.perfect-btn { order: 4; background: linear-gradient(135deg, #ffe08a, #d9a520) !important; color: #2a1c00 !important; font-weight: 900; letter-spacing: .06em; box-shadow: 0 0 0 0 rgba(255, 213, 107, .7); animation: goldpulse 1.8s infinite; }
.overlay.title .panel .perfect-btn { order: 3; }
/* 結果画面でも、クレジット（©初芝賢）は一番下。ボタンの上に来ないように */
.overlay:not(.title) .panel .badge { order: 9; }
@keyframes goldpulse { 50% { box-shadow: 0 0 0 12px rgba(255, 213, 107, 0); } }
.cert-wrap { position: absolute; inset: 0; z-index: 30; display: grid; place-items: center; align-content: center; gap: 12px; background: rgba(0, 0, 0, .9); padding: 12px; overflow: auto; }
.cert { width: min(720px, 96vw); background: radial-gradient(ellipse at 50% 0%, #2a1208 0%, #0b0d10 62%); border: 2px solid #d9a520; border-radius: 10px; padding: 8px; box-shadow: 0 0 60px rgba(217, 165, 32, .35); }
.cert-inner { border: 1px solid rgba(255, 224, 138, .55); border-radius: 6px; padding: 22px 28px 18px; text-align: center; position: relative; }
.cert-logo { width: min(300px, 62%); height: auto; display: block; margin: 0 auto; }
.cert-sub { font-size: 12px; letter-spacing: .3em; color: #ff8d85; margin-top: 2px; }
.cert-title { margin: 10px 0 2px; font: 900 clamp(34px, 7.6vw, 64px)/1.05 "Arial Black", "Noto Sans JP", sans-serif; letter-spacing: .06em; background: linear-gradient(180deg, #fff6cf 0%, #ffd56b 45%, #b8860b 100%); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 2px 0 rgba(0, 0, 0, .6)) drop-shadow(0 0 18px rgba(255, 213, 107, .45)); }
.cert-kicker { font-size: 15px; letter-spacing: .6em; color: #ffe08a; margin-bottom: 10px; }
.cert-body { margin: 0 auto 12px; font-size: clamp(13.5px, 2.3vw, 17px); line-height: 2; color: #eef3f6; }
.cert-body b { color: #ffd56b; font-size: 1.15em; }
.cert-rank { margin: 0 auto clamp(6px, 1.4vh, 16px); font: 700 clamp(14px, 2.1vw, 24px)/1.5 "Yu Mincho", "Hiragino Mincho ProN", "Noto Serif JP", serif; color: #fbf3df; letter-spacing: .04em; }
.cert-rank b { color: #ffd56b; font-size: 1.6em; margin: 0 .12em; font-variant-numeric: tabular-nums; }
.cert-ends { display: flex; flex-wrap: wrap; gap: 5px 8px; justify-content: center; margin-bottom: 14px; }
.cert-ends span { font-size: 11.5px; color: #c8f7dc; border: 1px solid rgba(125, 255, 182, .45); border-radius: 999px; padding: 2px 9px; }
.cert-foot { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.cert-date { font-size: 13px; color: #9fb0bb; }
.cert-sign { text-align: right; } .cert-sign small { display: block; font-size: 11px; color: #9fb0bb; letter-spacing: .1em; }
.cert-sign span { font: 700 clamp(24px, 4.6vw, 34px)/1.2 "Yu Mincho", "Hiragino Mincho ProN", "Noto Serif JP", serif; color: #fff; border-bottom: 1px solid rgba(255, 224, 138, .7); padding: 0 4px 2px; }
.cert-tag { margin-top: 10px; font-size: 13px; font-weight: 700; color: #8fd3ff; }
.cert-close { border: 1px solid var(--line); background: rgba(8, 12, 15, .9); color: var(--ink); border-radius: 10px; padding: 9px 26px; font: inherit; cursor: pointer; }
@media (max-width: 700px), (orientation: portrait) and (max-width: 1000px) {
  .sp-only { display: inline; }
  .cert-inner { padding: 16px 12px 14px; } .cert-kicker { letter-spacing: .4em; }
}

.cert-sign span { font-size: clamp(16px, 2.8vw, 21px); }
.cert-ends span { font-size: 13px; letter-spacing: .12em; padding: 3px 14px; }

/* Jev の判定パネルは出さない（?debug=1 のときだけ） */
.hud { display: none; }
body.debug .hud { display: block; top: 64px; }

/* BACK: いつでも部屋全体に戻れる */
.back-btn { position: absolute; top: 16px; right: 20px; z-index: 5; font: 800 15px/1 ui-monospace, "Cascadia Mono", Consolas, monospace; letter-spacing: .12em; color: #fff; background: rgba(8, 12, 15, .85); border: 1px solid rgba(255, 255, 255, .35); border-radius: 10px; padding: 12px 16px; cursor: pointer; backdrop-filter: blur(6px); }
.back-btn:hover { border-color: #ffd56b; color: #ffd56b; }

/* 表彰状は画面いっぱい。後ろは一切見せない */
.cert-wrap { position: fixed; background: #000; padding: 0; gap: 0; align-content: stretch; }
.cert { width: 100vw; min-height: 100vh; min-height: 100dvh; border-radius: 0; border-width: 0; padding: clamp(10px, 2vw, 22px); display: grid; box-shadow: none; background: radial-gradient(ellipse at 50% 0%, #2a1208 0%, #07090b 60%); }
.cert-inner { border: 2px solid #d9a520; outline: 1px solid rgba(255, 224, 138, .5); outline-offset: -8px; border-radius: 10px; display: flex; flex-direction: column; justify-content: center; padding: clamp(18px, 4vh, 48px) clamp(16px, 5vw, 80px); }
.cert-logo { width: min(340px, 58%); }
.cert-title { font-size: clamp(38px, 9vw, 96px); }
.cert-body { font-size: clamp(14px, 2.2vw, 22px); }
.cert-foot { margin-top: clamp(8px, 3vh, 30px); }
.cert-close { position: fixed; right: 14px; top: 12px; z-index: 31; padding: 7px 14px; font-size: 12px; opacity: .55; }
.cert-close:hover { opacity: 1; }

/* スマホ・縦長: 上に数字と所持アイテム → 画像 → すぐ下に文章と入力 → 手がかり。画像には何も被せない */
@media (max-width: 700px), (orientation: portrait) and (max-width: 1000px) {
  .top { position: static; order: 0; flex: none; padding: 6px 84px 6px 8px; align-items: center; min-height: 44px; }
  .scene { order: 1; aspect-ratio: 8 / 5; }
  .bottom { order: 2; margin-top: 0; padding: 6px 8px 8px; gap: 6px; }
  .clues { order: 3; margin: 0 8px 8px; max-height: none; }
  .said { align-self: flex-start; }
  .message { min-height: 0; }
  .back-btn { top: 7px; right: 8px; padding: 9px 11px; font-size: 12px; }
  .inventory { background: none; border: 0; padding: 0; backdrop-filter: none; }
  .gainpop { top: calc(44px + 31vw); transform: translate(-50%, -46%) scale(.92); }
  .gainpop.show { transform: translate(-50%, -50%) scale(1); }
  body.debug .hud { order: 4; position: static; margin: 0 8px 8px; }
}

/* ===== 表彰状 v2: 金の額縁・月桂樹・メダル。文字は大きく、明朝で ===== */
.cert { position: relative; overflow: hidden; background: radial-gradient(ellipse at 50% 38%, #3a1a08 0%, #140a05 46%, #050506 100%); padding: clamp(10px, 1.8vw, 22px); }
.cert-rays { position: absolute; inset: -40%; background: repeating-conic-gradient(from 0deg at 50% 46%, rgba(255, 213, 107, .07) 0deg 6deg, transparent 6deg 12deg); animation: cert-spin 90s linear infinite; pointer-events: none; }
@keyframes cert-spin { to { transform: rotate(360deg); } }
.cert-inner { position: relative; border: 3px solid transparent; border-radius: 6px; outline: 0; background: linear-gradient(#0b0706e6, #0b0706e6) padding-box, linear-gradient(135deg, #fff2b8, #e8b93c 40%, #8a5f0a 70%, #ffe08a) border-box; box-shadow: inset 0 0 0 6px #0b0706, inset 0 0 0 7px rgba(255, 224, 138, .55), 0 0 80px rgba(232, 185, 60, .25); padding: clamp(26px, 5vh, 56px) clamp(22px, 7vw, 120px) clamp(18px, 3vh, 34px); gap: 0; }
.cert-corner { position: absolute; width: clamp(54px, 9vw, 120px); height: clamp(54px, 9vw, 120px); pointer-events: none; }
.cert-corner svg { width: 100%; height: 100%; display: block; }
.cert-corner.tl { left: 10px; top: 10px; } .cert-corner.tr { right: 10px; top: 10px; transform: scaleX(-1); }
.cert-corner.bl { left: 10px; bottom: 10px; transform: scaleY(-1); } .cert-corner.br { right: 10px; bottom: 10px; transform: scale(-1, -1); }
.cert-logo { width: min(300px, 46%); filter: drop-shadow(0 0 18px rgba(255, 60, 40, .35)); }
.cert-sub { font-size: clamp(11px, 1.3vw, 15px); letter-spacing: .34em; }
.cert-kicker { display: flex; align-items: center; justify-content: center; gap: 18px; margin: clamp(8px, 2vh, 20px) 0 0; font: 700 clamp(20px, 3vw, 38px)/1.2 "Yu Mincho", "Hiragino Mincho ProN", "Noto Serif JP", serif; letter-spacing: .7em; text-indent: .7em; color: #ffe08a; }
.cert-kicker i { flex: 0 1 clamp(40px, 12vw, 180px); height: 1px; background: linear-gradient(90deg, transparent, #e8b93c); } .cert-kicker i:last-child { transform: scaleX(-1); }
.cert-titlebox { display: flex; align-items: center; justify-content: center; gap: clamp(6px, 1.6vw, 24px); margin: clamp(2px, 1vh, 10px) 0 clamp(8px, 2vh, 20px); }
.cert-laurel { height: clamp(70px, 13vw, 170px); width: auto; flex: none; filter: drop-shadow(0 0 8px rgba(232, 185, 60, .5)); } .cert-laurel.flip { transform: scaleX(-1); }
.cert-title { margin: 0; font-size: clamp(40px, 9.4vw, 118px); line-height: 1; letter-spacing: .04em; } .cert-br { display: none; }
.cert-body { font: 600 clamp(17px, 2.7vw, 32px)/2.05 "Yu Mincho", "Hiragino Mincho ProN", "Noto Serif JP", serif; margin: 0 auto clamp(8px, 2vh, 22px); color: #fbf3df; }
.cert-body b { font-size: 1.22em; color: #ffd56b; text-shadow: 0 0 18px rgba(255, 213, 107, .45); padding: 0 .08em; background: linear-gradient(transparent 72%, rgba(232, 185, 60, .28) 72%); }
.cert-foot { display: grid; grid-template-columns: 1fr auto 1fr; align-items: end; margin-top: 0; }
.cert-date { text-align: left; font: 500 clamp(13px, 1.6vw, 18px)/1.4 "Yu Mincho", "Hiragino Mincho ProN", serif; color: #d9c9a0; }
.cert-seal { width: clamp(84px, 11vw, 136px); justify-self: center; filter: drop-shadow(0 6px 14px rgba(0, 0, 0, .6)); transform: rotate(-8deg); } .cert-seal svg { width: 100%; display: block; }
.cert-sign { justify-self: end; } .cert-sign small { font-size: clamp(10px, 1.1vw, 13px); color: #d9c9a0; }
.cert-sign span { font-size: clamp(17px, 2.4vw, 26px); border-bottom-color: rgba(232, 185, 60, .8); }
.cert-tag { margin-top: clamp(6px, 1.4vh, 14px); font-size: clamp(13px, 1.5vw, 17px); color: #ffe08a; letter-spacing: .1em; }
@media (max-width: 700px), (orientation: portrait) and (max-width: 1000px) {
  .cert-inner { padding: 34px 18px 20px; }
  .cert-br { display: inline; } .cert-title { font-size: clamp(44px, 15vw, 84px); line-height: 1.02; }
  .cert-laurel { height: clamp(96px, 30vw, 170px); }
  .cert-body { font-size: clamp(16px, 4.4vw, 22px); line-height: 2; }
  .cert-kicker { letter-spacing: .5em; text-indent: .5em; }
}

/* 表彰状 v2 の寸法: 必ず1画面に収める（幅と高さの小さいほうに合わせる） */
.cert { place-items: center; }
.cert-inner { width: 100%; max-width: 1180px; min-height: calc(100dvh - 2 * clamp(10px, 1.8vw, 22px)); margin: 0 auto; padding: clamp(18px, 4vh, 44px) clamp(18px, 6vw, 96px) clamp(14px, 2.4vh, 28px); justify-content: space-evenly; }
.cert-logo { width: auto; height: min(11vh, 9vw); }
.cert-kicker { font-size: min(3vw, 4.6vh); margin-top: min(1.4vh, 12px); }
.cert-title { font-size: min(8.2vw, 13.5vh); white-space: nowrap; } .cert-title span { display: inline-block; }
.cert-laurel { height: min(12vw, 20vh); }
.cert-titlebox { margin: 0; }
.cert-body { font-size: min(2.5vw, 3.7vh); line-height: 1.95; margin: 0 auto; } .cert-body span { display: block; }
.cert-seal { width: min(10vw, 15vh); }
@media (max-width: 700px), (orientation: portrait) and (max-width: 1000px) {
  .cert-inner { padding: 30px 14px 16px; }
  .cert-logo { height: auto; width: 46%; }
  .cert-kicker { font-size: 5.4vw; }
  .cert-title { font-size: 11vw; white-space: normal; line-height: 1.04; } .cert-title span { display: block; }
  .cert-laurel { height: 24vw; }
  .cert-body { font-size: 3.9vw; line-height: 2.1; }
  .cert-body b { font-size: 1.3em; }
  .cert-seal { width: 22vw; }
  .cert-foot { grid-template-columns: 1fr auto 1fr; gap: 4px; } .cert-date { font-size: 11px; } .cert-sign span { font-size: 16px; }
}

/* END 画面: アイテム／手がかりの見直し */
.review-wrap { position: absolute; inset: 0; z-index: 25; display: grid; place-items: center; background: rgba(0, 0, 0, .82); padding: 14px; }
.review { width: min(760px, 100%); max-height: 92vh; max-height: 92dvh; display: flex; flex-direction: column; background: #0d1418; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.review-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.review-head h2 { margin: 0; font-size: 18px; }
.review-close { border: 1px solid var(--line); background: transparent; color: var(--ink); border-radius: 9px; padding: 7px 14px; font: inherit; cursor: pointer; }
.review-body { overflow: auto; padding: 6px 18px 18px; }
.review-body h3 { margin: 16px 0 8px; font-size: 13px; letter-spacing: .12em; color: var(--muted); } .review-body h3 small { color: #ffd56b; margin-left: 6px; }
.rv-items, .rv-clues { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.rv-items li { background: rgba(255, 255, 255, .05); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; }
.rv-name { font-weight: 800; font-size: 16px; } .rv-name i { font-style: normal; margin-right: 6px; }
.rv-items p { margin: 4px 0 0; font-size: 14.5px; line-height: 1.8; color: #d5dee4; }
.rv-clues li { font-size: 14.5px; line-height: 1.6; padding: 7px 0 7px 12px; border-left: 3px solid rgba(143, 211, 255, .6); color: #d6e6ef; }
.rv-clues li.truth { border-left-color: #ffd56b; color: #fff1c9; }
.rv-empty { margin: 0; color: var(--muted); font-size: 14px; }
.review .hint { color: #ffd84a; font-weight: 700; }

.scene .hot.go { cursor: pointer; }

/* 自由脱出: 時間制限なし。警報の赤い明滅もやめる */
.scene .alarm { display: none; }
.overlay.title::after { animation: none; box-shadow: inset 0 0 200px 40px rgba(255, 190, 80, .10); }
.overlay.title { background: radial-gradient(ellipse at 50% 28%, #1c140a 0%, #050608 62%); }
.overlay.title .start:not(.ghost) { background: #e8a93c; color: #1a1204; box-shadow: 0 0 0 0 rgba(232, 169, 60, .6); animation: goldpulse 1.8s infinite; }
.eyebrow { color: #e8a93c; } .cert-sub { color: #e8c98a; }
.start { background: #e8a93c; color: #1a1204; }
.cert-logo { filter: drop-shadow(0 0 18px rgba(232, 169, 60, .35)); }
.overlay.title .logo { filter: drop-shadow(0 0 26px rgba(232, 169, 60, .3)); }

.overlay.title .logo { width: min(470px, 78%); margin-bottom: 0; }

.scene .key { cursor: pointer; } .scene .key:hover rect { filter: brightness(1.2); } .scene .key:active rect { filter: brightness(.8); }

/* タイトル画面は、中のパネルではなく画面全体をスクロールさせる（パネルの右端にスクロールバーが浮かないように） */
.overlay.title { overflow-x: hidden; overflow-y: auto; align-items: start; }
.overlay.title .panel { max-height: none; overflow: visible; margin: auto; }
.overlay.title::before, .overlay.title::after, .overlay.title .title-fx { position: fixed; }

/* 手がかり欄: PC では場面のホットスポット（ドアなど）を隠してしまうので、クリックは場面に通し、見出しでたためるようにする */
.clues { pointer-events: none; }
.clues-title { width: 100%; pointer-events: auto; cursor: pointer; background: none; border: 0; color: var(--muted); font: inherit; font-size: 11px; letter-spacing: .12em; padding: 0; display: flex; align-items: center; gap: 8px; }
.clues-title .ct-label { flex: 1; text-align: left; }
.clues-title i { font-style: normal; color: var(--muted); }
.clues-title:hover { color: var(--ink); }
.clues.closed { width: auto; max-height: none; overflow: visible; }
@media (max-width: 700px), (orientation: portrait) and (max-width: 1000px) { .clues { pointer-events: auto; } }

/* 右上のボタン群（トップへ・ヒント・BACK） */
.topright { position: absolute; top: 16px; right: 20px; z-index: 5; display: flex; gap: 8px; align-items: center; }
.topright .back-btn { position: static; }
.back-btn.ghost { color: var(--muted); }
.back-btn.hint { color: #ffd56b; border-color: rgba(255,213,107,.45); }
.back-btn[hidden] { display: none; }
@media (max-width: 700px), (orientation: portrait) and (max-width: 1000px) { .topright { top: 7px; right: 8px; gap: 5px; } }
/* ヒントの一覧 */
.hint-row { border: 1px solid var(--line); border-radius: 12px; margin: 10px 0; overflow: hidden; }
.hint-head { width: 100%; display: flex; align-items: center; gap: 10px; padding: 11px 14px; background: rgba(255,255,255,.04); border: 0; color: var(--ink); font: inherit; font-size: 14px; text-align: left; cursor: pointer; }
.hint-head:hover { background: rgba(255,255,255,.08); }
.hint-head b { flex: 1; font-weight: 700; }
.hint-head .hs { font-size: 11px; color: var(--muted); letter-spacing: .08em; }
.hint-head .done { color: #7dffb6; }
.hint-steps { padding: 4px 14px 12px; }
.hint-step { font-size: 13.5px; line-height: 1.7; color: #d6e6ef; padding: 8px 0 8px 12px; border-left: 3px solid rgba(143,211,255,.5); margin: 6px 0; }
.hint-step.s3 { border-left-color: #ffd56b; color: #fff1c9; }
.hint-more { border: 1px solid var(--line); background: transparent; color: #ffd56b; border-radius: 9px; padding: 7px 14px; font: inherit; font-size: 13px; cursor: pointer; margin-top: 4px; }
.hint-more:hover { border-color: #ffd56b; }
.hint-note { font-size: 12px; color: var(--muted); margin: 0 0 6px; }
