/* ── 「다섯 시의 저택」 ─────────────────────────────────────
   색: 썩은 남보라 · 곰팡이 녹색 · 촛불 호박색. 걷는 장면(.walk)은 다른 게임도 쓸 수 있게 테마 밖에 둔다. */
body.theme-fiveoclock {
  --navy: #141222;
  --navy-deep: #08070f;
  --navy-mid: #1e1b30;
  --navy-light: #3b3552;
  --teal: #7fa39a;
  --teal-light: #b9d6cc;
  --amber: #e9b45c;
  --amber-dark: #b8873d;
  --cream: #ece6da;
  --cream-dim: #a9a2b4;
  --line: rgba(185, 214, 204, 0.18);
  --modal-top: #1e1b30;
  --font-title: "Gowun Batang", "Noto Serif KR", serif;
  background: radial-gradient(ellipse 90% 520px at 50% 0, rgba(127, 163, 154, 0.1), transparent), #08070f;
}
body.theme-fiveoclock.playing { background: #040309; }
body.theme-fiveoclock .modal-box { background: linear-gradient(180deg, #1e1b30, #0d0b17); border: 1px solid rgba(185, 214, 204, 0.3); }
.game-art.ga-fiveoclock { background: url("/img/poster-fiveoclock.svg") center 40% / cover no-repeat, #08070f; }

/* ── 걷는 장면 ── */
.walk { position: absolute; inset: 0; z-index: 1; overflow: hidden; }
.walk-canvas { width: 100%; height: 100%; display: block; image-rendering: auto; }
/* 쫓길 때: 가장자리가 붉게 맥박 친다 */
.walk::after { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0; box-shadow: inset 0 0 120px 30px rgba(150, 10, 20, 0.75); transition: opacity 0.4s; }
.walk.chased::after { opacity: 1; animation: walk-pulse 0.42s ease-in-out infinite alternate; }
@keyframes walk-pulse { from { box-shadow: inset 0 0 90px 20px rgba(150, 10, 20, 0.55); } to { box-shadow: inset 0 0 150px 46px rgba(170, 10, 24, 0.85); } }
/* 잡혔다: 가장자리부터 까매진다 */
.walk.caught::before { content: ""; position: absolute; inset: 0; z-index: 3; background: radial-gradient(ellipse at 50% 46%, transparent 0, #000 0); animation: walk-caught 1.5s ease-in forwards; }
@keyframes walk-caught { 0% { background: radial-gradient(ellipse at 50% 46%, transparent 40%, rgba(0, 0, 0, 0.9) 70%); } 60% { background: radial-gradient(ellipse at 50% 46%, transparent 0%, #000 25%); } 100% { background: #000; } }

/* 숨어 있을 때: 옷장 문틈으로 보는 것처럼 */
.walk-hidden { position: absolute; inset: 0; z-index: 2; pointer-events: none; background: linear-gradient(90deg, rgba(4, 3, 8, 0.96) 0 42%, transparent 46% 54%, rgba(4, 3, 8, 0.96) 58%); display: flex; align-items: flex-end; justify-content: center; }
.walk-hidden p { margin: 0 0 6%; padding: 6px 14px; border-radius: 999px; background: rgba(0, 0, 0, 0.6); color: var(--cream-dim); font-size: 0.85em; animation: walk-breath 1.6s ease-in-out infinite; }
@keyframes walk-breath { 50% { opacity: 0.55; } }

.walk kbd, .walk-help kbd { display: inline-block; min-width: 1.6em; padding: 1px 6px; margin: 0 2px; border-radius: 5px; border: 1px solid rgba(255, 231, 168, 0.55); border-bottom-width: 3px; background: rgba(20, 18, 34, 0.9); color: #ffe7a8; font: 700 0.85em "Noto Sans KR", sans-serif; text-align: center; }

/* 크게 뜨는 외침 (「들켰다! 숨어!」) */
.walk-shout { position: absolute; left: 50%; top: 32%; z-index: 4; transform: translateX(-50%); font: 2.4em var(--font-title); color: #f6e8d0; text-shadow: 0 0 18px #000, 0 0 4px #000; opacity: 0; pointer-events: none; white-space: nowrap; }
.walk-shout.show { animation: walk-shout 1.6s ease-out forwards; }
.walk-shout.danger { color: #ff6b6b; }
.walk-shout.quiet { color: var(--cream-dim); font-size: 1.4em; }
@keyframes walk-shout { 0% { opacity: 0; transform: translateX(-50%) scale(1.4); } 12% { opacity: 1; transform: translateX(-50%) scale(1); } 70% { opacity: 1; } 100% { opacity: 0; } }

/* 처음 조작법 */
.walk-tutor { position: absolute; left: 50%; top: 13%; z-index: 4; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 18px; border-radius: 12px; background: rgba(8, 7, 15, 0.86); border: 1px solid rgba(255, 231, 168, 0.4); color: var(--cream); font-size: 1em; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.6); animation: walk-tutor-in 0.4s ease-out; pointer-events: none; }
.walk-tutor small { color: var(--amber); font-size: 0.75em; letter-spacing: 0.05em; }
@keyframes walk-tutor-in { from { opacity: 0; transform: translate(-50%, 10px); } }
.walk-help-btn { position: absolute; right: 10px; bottom: 10px; z-index: 4; width: 30px; height: 30px; border-radius: 50%; border: 1px solid rgba(255, 231, 168, 0.5); background: rgba(8, 7, 15, 0.8); color: #ffe7a8; font-weight: 700; cursor: pointer; }
.walk-help { position: absolute; inset: 12% 22%; z-index: 6; padding: 18px 24px; border-radius: 14px; background: rgba(12, 10, 22, 0.96); border: 1px solid rgba(255, 231, 168, 0.4); color: var(--cream); overflow: auto; }
.walk-help h3 { margin: 0 0 10px; font-family: var(--font-title); color: var(--amber); }
.walk-help dl { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0 0 12px; align-items: center; }
.walk-help dd { margin: 0; color: var(--cream-dim); }
.walk-help p { color: var(--cream-dim); font-size: 0.9em; }

/* 깜짝 그림 */
.stage-scare { position: absolute; inset: 0; z-index: 7; pointer-events: none; opacity: 0; background: #000; }
.stage-scare img { width: 100%; height: 100%; object-fit: cover; }
.stage-scare.show { animation: scare 0.75s steps(1, end) forwards; }
@keyframes scare { 0% { opacity: 1; } 8% { opacity: 0.2; } 12% { opacity: 1; } 85% { opacity: 1; } 100% { opacity: 0; } }
.stage.flicker::before { content: ""; position: absolute; inset: 0; z-index: 2; background: #000; pointer-events: none; animation: flicker 1.4s steps(1, end) forwards; }
@keyframes flicker { 0% { opacity: 0.45; } 10% { opacity: 0; } 18% { opacity: 0.5; } 24% { opacity: 0.05; } 40% { opacity: 0.5; } 52% { opacity: 0; } 70% { opacity: 0.3; } 78%, 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .walk.chased::after { animation: none; }
  .stage.flicker::before { animation: none; }
}

/* 걷는 장면에서는 아래의 오브젝트 단추 줄을 쓰지 않는다 */
body.walking .stage-chips { display: none !important; }

/* 퍼즐: 찢어진 사진 맞추기 (jigsaw) */
.jz { display: flex; flex-direction: column; align-items: center; gap: 12px; touch-action: none; user-select: none; }
.jz-board { display: grid; gap: 0; padding: 6px; border-radius: 6px; background: #241f2e; box-shadow: inset 0 0 0 2px rgba(255, 231, 168, 0.25); }
.jz-slot { position: relative; background: rgba(255, 255, 255, 0.04); outline: 1px dashed rgba(255, 231, 168, 0.25); outline-offset: -1px; }
.jz-tray { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; min-height: 90px; width: 100%; padding: 10px; border-radius: 10px; background: rgba(0, 0, 0, 0.25); }
.jz-piece { position: relative; cursor: grab; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.55); transition: transform 0.18s ease; background-repeat: no-repeat; }
.jz-tray .jz-piece { transform-origin: center; }
.jz-piece.dragging { z-index: 20; cursor: grabbing; transition: none; box-shadow: 0 10px 24px rgba(0, 0, 0, 0.7); }
.jz-piece:focus-visible { outline: 2px solid var(--amber); }
.jz-status { margin: 0; color: var(--cream-dim); font-size: 0.9rem; }
.walk-tutor.away { opacity: 0; }

/* 술래가 세는 숫자 · 미끄러짐 · 마지막 이펙트 */
.walk-count { position: absolute; left: 50%; top: 40%; z-index: 4; transform: translate(-50%, -50%); font: 3.2em var(--font-title); color: rgba(236, 230, 218, 0.85); text-shadow: 0 0 20px #000, 0 0 6px #000; pointer-events: none; }
.walk.slip { animation: fo-shake 0.45s; }
.walk.shake { animation: fo-shake 0.6s; }
.walk-fx { position: absolute; inset: 0; z-index: 5; width: 100%; height: 100%; pointer-events: none; }
@keyframes fo-shake { 20% { transform: translate(-7px, 2px); } 40% { transform: translate(6px, -3px); } 60% { transform: translate(-4px, 1px); } 80% { transform: translate(2px, 0); } }

/* 맵 위 퍼즐의 카드 (왼쪽 위) */
.walk-card { position: absolute; left: 10px; top: 10px; z-index: 6; width: min(34%, 340px); max-height: 70%; overflow: auto; padding: 10px 12px; border-radius: 10px; background: rgba(10, 9, 18, 0.88); border: 1px solid rgba(255, 231, 168, 0.35); color: var(--cream); font-size: 0.82em; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.6); }
.walk-card-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; margin-bottom: 4px; }
.walk-card-head small { color: var(--teal-light); font-weight: 700; width: 100%; }
.walk-card-head strong { font-family: var(--font-title); font-size: 1.15em; color: var(--amber); }
.walk-card-worth { margin-left: auto; color: #7ee0a8; font-weight: 700; }
.walk-card-prompt { margin: 4px 0 8px; color: var(--cream-dim); }
.walk-card-prompt p { margin: 0 0 4px; }
.walk-card-msg { margin: 0 0 6px; color: #ff9a8a; font-weight: 700; }
.walk-card-hint { margin: 0 0 6px; padding: 6px 8px; border-radius: 6px; background: rgba(233, 180, 92, 0.12); }
.walk-card-hint small { color: var(--amber); font-weight: 700; }
.walk-card .btn { width: 100%; }

/* 퍼즐 3 톱니 (gearmark) */
.gm { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.gm-board { width: 100%; max-width: 520px; background: #1a1612; border-radius: 12px; }
.gm-body { fill: #6a5232; stroke: #b8873d; stroke-width: 2; }
.gm-gear.big .gm-body { fill: #5a4428; }
.gm-hub { fill: #3b2a18; }
.gm-axle { fill: #b8873d; }
.gm-mark { fill: #e0443c; stroke: #fff2; }
.gm-label { fill: #e9d9b0; font: 700 15px "Noto Sans KR", sans-serif; text-anchor: middle; }
.gm-top { stroke: #e9b45c; stroke-width: 3; marker-end: none; }
.gm-controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; }
.gm-input { width: 90px; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line); background: #0d0b17; color: var(--cream); font-size: 1rem; }

/* 퍼즐 5 전등 다섯 (stairlamps) */
.sl-board { width: 100%; max-width: 640px; border-radius: 12px; }
.sl-bg { fill: #0d0b14; }
.sl-wall { fill: #2a1418; }
.sl-floor { fill: #1c1410; }
.sl-pool { fill: #e9b45c; opacity: 0; transition: opacity .2s; }
.sl-pool.on { opacity: .18; }
.sl-lamp { cursor: pointer; outline: none; }
.sl-hit { fill: transparent; }
.sl-glow { fill: #ffd27a; opacity: .35; }
.sl-shade { fill: #5a4a3a; }
.sl-lamp.on .sl-shade { fill: #f2cf86; }
.sl-stem { fill: #8c6a3a; }
.sl-switch { fill: #3b2a20; stroke: #8c6a3a; stroke-width: 2; }
.sl-knob { fill: #e8dcc0; transition: y .15s; }
.sl-lamp:focus-visible .sl-switch, .sl-lamp:hover .sl-switch { stroke: #ffe7a8; }
.sl-num { fill: #cfc4b0; font: 700 14px "Noto Sans KR", sans-serif; text-anchor: middle; }
.sl-step { fill: #3a2a20; stroke: #1a120c; stroke-width: 1; }
.sl-ghost { transition: transform .35s ease-out; }
.sl-dress, .sl-hair { fill: #050407; }

/* 퍼즐 4 그림일기 (diary) */
.dy-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.dy-page { position: relative; display: flex; flex-direction: column; gap: 4px; padding: 6px; border-radius: 8px; border: 2px solid #c8bca0; background: #f4eedd; color: #3a2a1a; cursor: pointer; text-align: left; font-family: "Gowun Batang", serif; }
.dy-page.on { border-color: var(--amber); box-shadow: 0 0 0 3px rgba(233, 180, 92, .45); transform: translateY(-3px); }
.dy-no { position: absolute; top: 4px; left: 6px; background: #3a2a1a; color: #f4eedd; border-radius: 50%; width: 20px; height: 20px; font: 700 12px/20px "Noto Sans KR", sans-serif; text-align: center; }
.dy-pic { width: 100%; height: auto; border-radius: 4px; }
.dy-text { font-size: .82rem; line-height: 1.35; }

/* 퍼즐 6 아무도 없는 틈 (freeslot) */
.fs { outline: none; }
.fs-board { width: 100%; touch-action: none; }
.fs-bg { fill: #0d0b17; }
.fs-cell { fill: #2a2638; stroke: #3b3552; cursor: pointer; }
.fs-cell.study { fill: #7a3a3a; }
.fs-cell.hall { fill: #6a5a2a; }
.fs-tick { fill: #b9b4c0; font: 11px "Noto Sans KR", sans-serif; }
.fs-tick.end { text-anchor: end; }
.fs-me { fill: rgba(127, 224, 168, .35); stroke: #7ee0a8; stroke-width: 2; cursor: grab; }
.fs-me-label { fill: #d8ffe8; font: 700 11px "Noto Sans KR", sans-serif; text-anchor: middle; pointer-events: none; }

/* 퍼즐 8 숨은 문 (doorcount) */
.dc-board { width: 100%; }
.dc-bg { fill: #0d0b17; }
.dc-floor { fill: none; stroke: #5a5270; stroke-width: 2; stroke-dasharray: 6 4; }
.dc-floor-label { fill: #a9a2b4; font: 700 12px "Noto Sans KR", sans-serif; }
.dc-room { cursor: pointer; outline: none; }
.dc-room rect { fill: #2a2436; stroke: #8c7aa8; stroke-width: 2; }
.dc-room text { fill: #ece6da; font: 700 12px "Noto Sans KR", sans-serif; text-anchor: middle; pointer-events: none; }
.dc-room.on rect { fill: #5a3a20; stroke: var(--amber); stroke-width: 3; }
.dc-room:focus-visible rect { stroke: #ffe7a8; }
.dc-door { fill: #c8873d; }
