/* escape.css — 部屋ページとハブ共通（レトロ調・モバイル縦優先） */
:root {
  --bg: #0f0d0c; --panel: #1c1815; --panel2: #26201b; --line: #4a3d31; --ink: #efe3cc; --mute: #b5a58a;
  --accent: #e0b25a; --accent-ink: #1c1206; --danger: #c8564a; --ok: #8fcf7a;
  --font: "DotGothic16", "Hiragino Kaku Gothic ProN", "Noto Sans JP", system-ui, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); line-height: 1.7; }
a { color: var(--accent); }
.wrap { max-width: 520px; margin: 0 auto; padding: 0 16px 48px; }
.page-h1 { font-size: 18px; margin: 12px 0 8px; font-weight: normal; letter-spacing: .04em; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---- ゲーム ---- */
.esc { max-width: min(480px, calc((100svh - 400px) * 0.8)); min-width: min(100%, 300px); margin: 0 auto; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
.esc-top { display: flex; align-items: center; gap: 6px; padding: 6px 0; }
.esc-title { flex: 1; min-width: 0; font-size: 13px; color: var(--mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.esc-btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; min-width: 44px; padding: 0 14px; border: 2px solid var(--line); background: var(--panel2); color: var(--ink); font: inherit; font-size: 15px; border-radius: 4px; text-decoration: none; cursor: pointer; box-shadow: inset 0 -3px 0 rgba(0,0,0,.35); }
.esc-btn:active { transform: translateY(1px); box-shadow: none; }
.esc-btn.primary { background: var(--accent); border-color: #f3d38f; color: var(--accent-ink); }
.esc-btn.danger { background: var(--danger); border-color: #e8877c; color: #fff; }
.esc-btn.wide { display: flex; width: 100%; margin-top: 10px; }
.esc-hub { font-size: 14px; padding: 0 10px; }

.esc-stage { position: relative; width: 100%; aspect-ratio: 4 / 5; background: #000; border: 2px solid var(--line); border-radius: 4px; overflow: hidden; touch-action: manipulation; cursor: pointer; }
.esc-canvas { display: block; width: 100%; height: 100%; image-rendering: pixelated; image-rendering: crisp-edges; }
.esc-hots { position: absolute; inset: 0; pointer-events: none; }
.esc-hot { position: absolute; background: transparent; border: 0; padding: 0; pointer-events: none; opacity: 0; }
.esc-hot:focus-visible { opacity: 1; outline: 3px dashed var(--accent); outline-offset: -3px; }
.esc-nav { min-width: 56px; min-height: 48px; border: 2px solid var(--line); background: var(--panel2); color: var(--ink); font: inherit; font-size: 18px; border-radius: 4px; cursor: pointer; box-shadow: inset 0 -3px 0 rgba(0,0,0,.35); }
.esc-nav:active { transform: translateY(1px); box-shadow: none; }
/* ◀ もどる ▶ は絵の外の1列。出ないボタンも場所は取っておく（並びが動かない） */
.esc-navrow { display: grid; grid-template-columns: 72px 1fr 72px; gap: 8px; margin-top: 6px; }
.esc-navrow .esc-nav[hidden] { display: block; visibility: hidden; }
.esc-nav-b { font-size: 15px; }
/* 書き起こしの帯（絵の真下・高さ固定）。何もないときはいま見ている場所の名前 */
.esc-cap { height: 5.2em; margin-top: 6px; padding: 4px 10px; background: #0e0c0a; border: 2px solid #3a3026; border-radius: 4px; font-size: 14px; line-height: 1.4; text-align: center; overflow: hidden; display: flex; flex-direction: column; justify-content: center; }
.esc-cap .esc-panel-box { background: none; border: 0; padding: 0; font-size: 15px; }
.esc-cap.name { color: var(--mute); font-size: 13px; }
.esc-cap-name::before { content: "― "; } .esc-cap-name::after { content: " ―"; }
.esc-cap-name:empty::before, .esc-cap-name:empty::after { content: ""; }
/* ◀▶ は下の角（壁ビューの下端はたいてい床で、調べる物と重ならない。親指も届きやすい）。もどる はズームにしか出ないので同じ段でぶつからない */

.esc-fade { position: absolute; inset: 0; background: #000; opacity: 0; pointer-events: none; transition: opacity .18s steps(4); }
.esc-fade.on { opacity: 1; transition: none; }
.esc-panel { position: absolute; left: 8px; right: 8px; top: 8px; pointer-events: none; }
.esc-panel[hidden] { display: none; }
.esc-panel.bottom { top: auto; bottom: 64px; }
.esc-panel-box { background: rgba(14,12,10,.86); border: 2px solid #c9b48f; padding: 8px 12px; border-radius: 3px; font-size: 16px; line-height: 1.5; text-align: center; }
.esc-panel-title { font-size: 12px; color: var(--mute); }
.esc-panel-line { letter-spacing: .06em; }
.esc-chip { font-weight: bold; }

.esc-msg { height: 5.9em; overflow-y: auto; margin: 8px 0; padding: 8px 12px; background: var(--panel); border: 2px solid var(--line); border-radius: 4px; font-size: 15px; white-space: pre-line; }
.esc-items { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.esc-slot { aspect-ratio: 1; min-height: 48px; border: 2px solid var(--line); background: var(--panel2); border-radius: 4px; padding: 2px; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.esc-slot img { width: 100%; height: 100%; image-rendering: pixelated; }
.esc-slot.empty { background: #15120f; cursor: default; }
.esc-slot.sel { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset; background: #3a2e1e; }

.esc-modal { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.66); display: flex; align-items: flex-end; justify-content: center; padding: 12px; }
.esc-modal[hidden] { display: none; }
.esc-sheet { width: 100%; max-width: 440px; max-height: 92svh; overflow: auto; background: var(--panel); border: 2px solid #c9b48f; border-radius: 6px; padding: 16px; box-shadow: 0 0 0 4px #000; }
.esc-h { font-size: 18px; font-weight: normal; margin: 0 0 8px; color: var(--accent); }
.esc-small { font-size: 13px; color: var(--mute); margin: 6px 0; }
.esc-row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; flex-wrap: wrap; }
.esc-bigicon { display: block; margin: 6px auto; image-rendering: pixelated; background: #120f0c; border: 2px solid var(--line); }

.esc-dials { display: flex; justify-content: center; gap: 10px; margin: 12px 0; flex-wrap: wrap; }
.esc-dial { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.esc-dial.tap { background: none; border: 0; padding: 0; cursor: pointer; font: inherit; color: inherit; }
.esc-key { min-width: 52px; min-height: 44px; border: 2px solid var(--line); background: var(--panel2); color: var(--ink); font: inherit; font-size: 18px; border-radius: 4px; cursor: pointer; }
.esc-dialface { width: 56px; height: 64px; display: flex; align-items: center; justify-content: center; font-size: 30px; background: #0f1a12; color: var(--ok); border: 2px solid #000; box-shadow: inset 0 0 0 2px #2c3a2e; border-radius: 3px; }
.esc-dialface.sw { font-size: 16px; background: #2a2a2e; color: #999; }
.esc-dialface.sw.on { background: var(--ok); color: #102010; }
.esc-dialface.sl { background: linear-gradient(to top, var(--accent) calc(var(--lv) * 100%), #2a2a2e 0); color: #fff; font-size: 20px; }
.esc-seq { display: flex; justify-content: center; gap: 8px; margin: 12px 0; }
.esc-seqcell { width: 44px; height: 48px; display: flex; align-items: center; justify-content: center; font-size: 26px; background: #0f1a12; color: var(--ok); border-radius: 3px; }
.esc-dpad { display: grid; grid-template-columns: repeat(3, 60px); grid-template-rows: repeat(3, 52px); gap: 6px; justify-content: center; }
.esc-dpad .k-up { grid-area: 1 / 2; } .esc-dpad .k-left { grid-area: 2 / 1; } .esc-dpad .k-right { grid-area: 2 / 3; } .esc-dpad .k-down { grid-area: 3 / 2; }
.esc-lock.ng { animation: escShake .3s steps(4); }
.esc-lockmsg { min-height: 1.5em; margin: 4px 0 0; text-align: center; font-size: 14px; color: #f0a090; }
/* 外れたときの一言が出てもキーが動かないよう、2行ぶんの場所を先に取っておく（2026-11 第3バッチ検品） */
.esc-lockmsg { min-height: 2.8em; line-height: 1.4; display: flex; align-items: center; justify-content: center; }
.esc-dials.many { gap: 6px; flex-wrap: nowrap; }
.esc-dials.many .esc-dialface { width: 44px; font-size: 14px; }
.esc-slot img { background: radial-gradient(circle, #3a332b 0%, #26201b 70%); }
.esc-btn:disabled { opacity: .55; cursor: default; }
@keyframes escShake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

.esc-hint { background: var(--panel2); border-left: 4px solid var(--accent); padding: 8px 12px; margin: 8px 0; border-radius: 3px; }
.esc-hint p { margin: 4px 0 0; }
.esc-hint.ans { border-left-color: var(--danger); }

.esc-clear { text-align: center; }
.esc-clear-kicker { letter-spacing: .4em; color: var(--mute); margin: 0; font-size: 12px; }
.esc-rank { font-size: 88px; line-height: 1; color: var(--accent); text-shadow: 4px 4px 0 #000; margin: 8px 0; }
.esc-stats { display: grid; grid-template-columns: auto auto; gap: 2px 16px; justify-content: center; margin: 8px 0 4px; }
.esc-stats dt { color: var(--mute); text-align: right; } .esc-stats dd { margin: 0; text-align: left; }

@media (prefers-reduced-motion: reduce) { .esc-fade { transition: none; } .esc-lock.ng { animation: none; } }

/* ---- 説明文（部屋ページ下） ---- */
.about { margin-top: 28px; border-top: 2px solid var(--line); padding-top: 12px; font-size: 15px; }
.about h2 { font-size: 16px; font-weight: normal; color: var(--accent); margin: 18px 0 6px; }
.about dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 0; }
.about dt { color: var(--mute); }
.about dd { margin: 0; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; padding: 0; margin: 8px 0; list-style: none; }
.tags li { border: 1px solid var(--line); padding: 0 8px; border-radius: 3px; font-size: 13px; }
.foot { margin-top: 32px; font-size: 13px; color: var(--mute); }

/* ---- ハブ ---- */
.hub-lead { color: var(--mute); font-size: 15px; }
.cards { list-style: none; padding: 0; margin: 16px 0; display: grid; gap: 14px; }
.card { background: var(--panel); border: 2px solid var(--line); border-radius: 6px; overflow: hidden; }
.card a { display: block; color: inherit; text-decoration: none; }
.card img { display: block; width: 100%; height: auto; aspect-ratio: 1200 / 630; image-rendering: pixelated; background: #000; }
.card-body { padding: 10px 14px 14px; }
.card-title { font-size: 17px; margin: 0 0 4px; color: var(--ink); font-weight: normal; }
.card-meta { font-size: 13px; color: var(--mute); display: flex; gap: 12px; flex-wrap: wrap; }
.badge { display: inline-block; font-size: 12px; padding: 0 8px; border-radius: 3px; background: var(--ok); color: #102010; margin-left: 6px; }
.badge.todo { background: var(--panel2); color: var(--mute); border: 1px solid var(--line); }

/* 数字・文字のキー（下の列から直接入れる） */
.esc-keys { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin: 8px 0 0; }
.esc-keys.alpha { grid-template-columns: repeat(7, 1fr); }
.esc-kbtn { min-height: 44px; border: 2px solid var(--line); background: var(--panel2); color: var(--ink); font: inherit; font-size: 18px; border-radius: 4px; cursor: pointer; padding: 0; }
.esc-kbtn:active { background: #3a2e1e; }
.esc-dial.act .esc-dialface { box-shadow: inset 0 0 0 2px #2c3a2e, 0 0 0 3px var(--accent); }
.esc-dialface { cursor: pointer; }
.esc-top .esc-title { flex: 1; }
/* 一覧 */
.badge[hidden] { display: none; }
.badge { white-space: nowrap; }

/* ---- 2026-11 3回目の検品後：小さい画面（375x667）でも持ち物欄まで1画面に ---- */
.page-h1 { font-size: 15px; margin: 6px 0 2px; }
.esc-top { padding: 2px 0 4px; }
.esc-top .esc-btn { min-height: 40px; font-size: 14px; }
.esc-navrow { grid-template-columns: 84px 1fr 84px; align-items: center; margin-top: 4px; }
.esc-navrow .esc-nav[hidden] { display: none; }
.esc-navcell .esc-nav { width: 100%; min-height: 42px; }
.esc-where { font-size: 12px; color: var(--mute); text-align: center; line-height: 1.3; max-height: 2.6em; overflow: hidden; }
.esc-msg { height: calc(4.5em + 16px); font-size: 14px; line-height: 1.5; padding: 6px 10px; margin: 4px 0; }
.esc-msg.more::after { content: "▼"; position: sticky; bottom: 0; float: right; color: var(--accent); font-size: 12px; background: var(--panel); padding-left: 4px; }
.esc-msgcap { margin-top: 4px; padding-top: 4px; border-top: 1px dashed var(--line); color: #f3e2b8; }
.esc-msgcap .esc-panel-box { background: none; border: 0; padding: 0; font-size: 14px; text-align: left; line-height: 1.45; }
.esc-msgcap .esc-panel-title { font-size: 11px; }
.esc-inspect { font: inherit; font-size: 13px; color: var(--accent); background: none; border: 1px solid var(--line); border-radius: 3px; padding: 0 8px; min-height: 28px; cursor: pointer; }
.esc-items { gap: 5px; }
.esc-slot { min-height: 44px; }
/* 錠：5けたでも1列、キーと閉じるまで1画面に */
.esc-sheet { padding: 12px; }
.esc-lock .esc-h { margin-bottom: 2px; }
.esc-lock .esc-small { margin: 2px 0; }
.esc-dials { margin: 8px 0; }
.esc-dial { gap: 4px; }
.esc-dial .esc-key { min-height: 36px; min-width: 48px; }
.esc-dials.many .esc-dialface { width: 46px; height: 52px; font-size: 24px; }
.esc-dials.many .esc-key { min-width: 46px; }
.esc-keys { gap: 5px; margin-top: 6px; }
.esc-kbtn { min-height: 40px; font-size: 18px; }
.esc-lock .esc-row { margin-top: 8px; }
/* 錠の文字は O と 0 が見分けやすい字形で */
.esc-dialface, .esc-kbtn { font-family: "Verdana", "Trebuchet MS", "Arial", sans-serif; font-weight: bold; }
.esc-dialface.sw, .esc-dialface.sl { font-family: var(--font); font-weight: normal; }
.esc-dials.many .esc-dialface.sw { font-size: 13px; }

/* 色ボタンは色名も出す（色の見分けにくい人向け） */
.esc-dialface.col { color: #fff; font-size: 18px; text-shadow: 1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000; font-family: var(--font); }

/* もどる は真ん中（◀▶と同じ場所に出さない）。壁ビューでは場所の名前、ズームでは もどる */
.esc-navmid { display: flex; align-items: center; justify-content: center; min-height: 42px; }
.esc-navmid .esc-nav-b { width: 100%; min-height: 42px; }
.esc-navmid .esc-nav-b:not([hidden]) + .esc-where { display: none; }
.esc-msg > .esc-msgcap:first-child { margin-top: 0; padding-top: 0; border-top: 0; }

/* ---- 2026-11 第3バッチ：とても小さい画面（320x568 など高さ600px以下）でも持ち物欄まで1画面に ----
   ふだんは .esc の最小幅 300px が絵の縮小を止めていたので、低い画面でだけ外して fit() に絵の大きさを任せる */
@media (max-height: 600px) {
  .esc { min-width: min(100%, 236px); }
  .esc-navrow { grid-template-columns: 64px 1fr 64px; }
  .esc-slot { min-height: 0; }
  .esc-top .esc-btn { padding: 0 8px; font-size: 13px; white-space: nowrap; }
  /* 外れの一言の場所を取ったぶん、文字錠のキーを少し低くして1画面に収める */
  .esc-kbtn { min-height: 36px; }
  .esc-dial .esc-key { min-height: 32px; }
}

/* 決定ボタンは「少し待つ（3）」のあいだも幅を変えない（閉じるが動かない・2026-11 第3バッチ検品2回目） */
.esc-lock [data-confirm] { flex: 0 0 8.2em; width: 8.2em; white-space: nowrap; padding: 0 6px; }
