:root {
  --ink: #0b0d1a;
  --panel: rgba(12, 15, 32, 0.82);
  --line: rgba(255, 255, 255, 0.18);
  --text: #f1efe8;
  --dim: #aab0c6;
  --warm: #ffd27a;
  --danger: #ff7a6b;
  --cool: #9fc7ee;
  font-family: "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #05060d; color: var(--text); overflow: hidden; }
/* 게임 화면은 글자를 고르거나 두 번 눌러 키우는 곳이 아니다. 길게 눌러도 선택 메뉴가 뜨지 않게 한다. */
html { touch-action: manipulation; overscroll-behavior: none; -webkit-text-size-adjust: 100%; }
/* 화면이 확대된 동안에는 잠금을 푼다. 두 손가락으로 오므려서 돌아올 수 있어야 한다. */
html.zoomed, html.zoomed * { touch-action: auto !important; }
body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
/* 키보드 안내와 터치 안내. 손가락이 닿은 적이 있는 화면에서는 터치 쪽만 보인다. */
.only-touch { display: none !important; }
html.touch .only-touch { display: revert !important; }
html.touch .only-keys, html.touch kbd { display: none !important; }
#stage { position: fixed; inset: 0; width: 100%; height: 100%; display: block; image-rendering: pixelated; touch-action: none; }
[hidden] { display: none !important; }

#hud, #tour-hud { position: fixed; inset: 0; pointer-events: none; }
.tour-room { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); padding: 6px 18px; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; font-size: 20px; font-weight: 800; color: var(--warm); }
.tour-room:empty { display: none; }
.hud-top { position: absolute; top: 12px; left: 12px; display: flex; gap: 12px; align-items: center; }
.clock { font-size: 28px; font-weight: 800; letter-spacing: 2px; padding: 6px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; font-variant-numeric: tabular-nums; }
.gauge-box { width: 240px; padding: 6px 10px 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; }
.gauge-label { display: flex; justify-content: space-between; font-size: 13px; color: var(--dim); margin-bottom: 4px; }
.gauge-label #stage-label.light { color: var(--warm); }
.gauge { position: relative; height: 12px; background: #1a1e36; border-radius: 3px; overflow: hidden; }
.gauge-fill { height: 100%; width: 0; background: #7fd18b; transition: width 0.1s linear; }
.gauge-fill.warn { background: var(--warm); }
.gauge-fill.danger { background: var(--danger); }
.gauge-mark { position: absolute; left: 60%; top: 0; bottom: 0; width: 2px; background: rgba(255, 255, 255, 0.45); }
.sneak { padding: 6px 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; font-size: 13px; color: var(--cool); opacity: 0.35; }
.sneak.on { opacity: 1; }

.checklist { position: absolute; top: 12px; right: 12px; margin: 0; padding: 10px 14px; list-style: none; width: 290px; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; font-size: 13px; line-height: 1.6; }
.checklist li { color: var(--dim); }
.checklist li::before { content: "□ "; }
.checklist li.done { color: #7fd18b; text-decoration: line-through; }
.checklist li.done::before { content: "■ "; }
.checklist li.current { color: var(--text); font-weight: 700; }
.checklist li.current::before { content: "▶ "; color: var(--warm); }

.carry { position: absolute; top: 12px; right: 320px; display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; max-width: 220px; }
.carry span { padding: 4px 8px; background: var(--panel); border: 1px solid var(--warm); border-radius: 12px; font-size: 12px; color: var(--warm); }

.toast { position: absolute; left: 50%; top: 22%; transform: translateX(-50%); padding: 10px 18px; background: var(--panel); border: 1px solid var(--warm); border-radius: 6px; font-size: 16px; text-align: center; }

.prompt { position: absolute; left: 50%; bottom: 120px; transform: translateX(-50%); padding: 8px 16px; background: var(--panel); border: 1px solid var(--warm); border-radius: 20px; font-size: 16px; font-weight: 700; }
.prompt.disabled { border-color: var(--line); color: var(--dim); }
.prompt kbd, .screen kbd { display: inline-block; padding: 1px 6px; margin-right: 6px; background: #20253f; border: 1px solid var(--line); border-radius: 4px; font-size: 12px; font-family: inherit; }

.bars { position: absolute; left: 50%; bottom: 64px; transform: translateX(-50%); width: min(420px, 80vw); text-align: center; }
.bar-label { font-size: 14px; margin-bottom: 4px; text-shadow: 0 1px 3px #000; }
.bar { position: relative; height: 18px; background: #1a1e36; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.bar-zone { position: absolute; top: 0; bottom: 0; background: rgba(127, 209, 139, 0.65); }
.bar-marker { position: absolute; top: -2px; bottom: -2px; width: 4px; margin-left: -2px; background: var(--text); }
.bar-fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--warm); width: 0; }
.bars.hold .bar-zone, .bars.hold .bar-marker { display: none; }
.bars.timing .bar-fill { display: none; }
.bars.flash-ok .bar { border-color: #7fd18b; }
.bars.flash-miss .bar { border-color: var(--danger); }

.keys { position: absolute; left: 12px; bottom: 10px; font-size: 12px; color: var(--dim); text-shadow: 0 1px 3px #000; }

.loading { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; margin: 0; color: var(--dim); font-size: 18px; }
.loading.failed { flex-direction: column; gap: 14px; padding: 24px; text-align: center; color: var(--text); }
.loading small { max-width: 34em; font-size: 13px; color: var(--dim); overflow-wrap: anywhere; }
.loading .tap { font: inherit; font-size: 16px; padding: 12px 20px; color: var(--text); }
.screen { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; text-align: center; padding: 24px; background: rgba(5, 6, 13, 0.72); overflow-y: auto; touch-action: pan-y; }
/* 가운데에 모으되, 화면보다 길면 위에서부터 보이고 밀어서 내려 본다. */
.screen > :first-child { margin-top: auto; }
.screen > :last-child { margin-bottom: auto; }
.screen h1 { margin: 0 0 6px; font-size: clamp(30px, 6vw, 56px); letter-spacing: 2px; color: var(--warm); text-shadow: 0 3px 0 #5c3d12; }
.screen h2 { margin: 0 0 12px; font-size: 28px; }
.screen p { margin: 4px 0; font-size: 16px; line-height: 1.6; }
.screen .tag { display: inline-block; margin-top: 10px; padding: 3px 12px; border: 1px solid var(--warm); border-radius: 14px; font-size: 14px; color: var(--warm); }
.screen .credit { color: var(--dim); font-size: 14px; }
.screen .contact { font-size: 12px; }
.screen .contact a { color: inherit; }
.screen .hint { margin-top: 28px; color: var(--dim); font-size: 14px; animation: blink 1.4s infinite; }
@keyframes blink { 50% { opacity: 0.35; } }

.menu { list-style: none; margin: 16px 0 0; padding: 0; width: min(560px, 92vw); }
.menu li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px; margin-bottom: 8px; text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; }
.menu li, .card, .tap { cursor: pointer; }
.menu li.selected { border-color: var(--warm); background: rgba(60, 46, 16, 0.75); }
.menu .name { font-weight: 800; font-size: 18px; }
.menu .blurb { color: var(--dim); font-size: 13px; }
.menu .stars { color: var(--warm); white-space: nowrap; font-size: 15px; }
.menu .stars small { display: block; color: var(--dim); font-size: 11px; text-align: right; }

/* 준비 중인 급습: 고를 수 없는 줄이라 작고 흐리게, 여러 칸으로 늘어놓는다. */
.soon-title { margin: 14px 0 6px; font-size: 14px; font-weight: 800; color: var(--dim); letter-spacing: 1px; }
.soon-title small { font-weight: 400; }
.soon { list-style: none; margin: 0; padding: 0; width: min(920px, 94vw); display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 5px; }
.soon li { padding: 4px 8px; font-size: 12px; color: var(--dim); text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border: 1px dashed var(--line); border-radius: 4px; opacity: 0.8; }
.soon li::before { content: attr(data-kind); margin-right: 6px; padding: 0 4px; font-size: 10px; color: var(--kind); border: 1px solid var(--kind); border-radius: 3px; opacity: 0.8; }
.kind-asleep { --kind: var(--warm); }
.kind-away { --kind: var(--cool); }
.kind-visit { --kind: #9fe0a8; }
.soon-title span { color: var(--kind); }
.screen .soon + .hint { margin-top: 14px; }

.brief { width: min(560px, 92vw); text-align: left; margin-top: 8px; }
.brief p { padding-left: 14px; text-indent: -14px; }
.brief p::before { content: "• "; color: var(--warm); }

.result-stars { font-size: 40px; letter-spacing: 6px; color: var(--warm); margin: 6px 0; }
.result-stars .off { color: #3a3f5c; }
.result.fail h2 { color: var(--danger); }
.result.success h2 { color: #7fd18b; }
.result .line { font-size: 20px; margin: 12px 0; max-width: 560px; }
.result .stats { color: var(--dim); font-size: 14px; }

.title-menu { width: min(300px, 80vw); }
.title-menu li { justify-content: center; }

.screen.pause { background: none; padding-bottom: 20px; }
.screen.pause > :last-child { margin-bottom: 0; }
.screen .panel { padding: 10px 24px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
.screen .panel h2 { font-size: 20px; margin-bottom: 4px; }

/* 인물 선택: 가로로 늘어선 카드. 도트 그림은 흐려지지 않게 키운다. */
.cards { list-style: none; display: flex; gap: 14px; margin: 16px 0 0; padding: 0; justify-content: center; flex-wrap: wrap; }
.card { width: min(190px, 28vw); padding: 16px 12px; text-align: center; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; }
.card.selected { border-color: var(--warm); background: rgba(60, 46, 16, 0.75); transform: translateY(-6px); }
.card img { width: 96px; max-width: 100%; height: auto; aspect-ratio: 96 / 184; image-rendering: pixelated; }
.card .name { font-weight: 800; font-size: 20px; margin-top: 6px; }
.card .blurb { color: var(--dim); font-size: 13px; margin-top: 4px; word-break: keep-all; }
.who { color: var(--warm); font-weight: 700; margin: 0; }
/* 원작 회차 바로가기: 브리핑보다 눈에 띄지 않게 작고 흐리게. */
/* 제목 화면의 바로가기 줄: 원작 채널 하나와 출연자 인스타그램. */
.links { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 10px; width: min(640px, 94vw); }
.links a { padding: 5px 12px; font-size: 13px; color: var(--dim); text-decoration: none; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; }
.links a.channel { color: var(--warm); border-color: var(--warm); }
.links a:hover, .links a:focus-visible { color: var(--warm); border-color: var(--warm); outline: none; }

/* 눌러서 고르는 버튼 줄. 키보드에서는 키 이름이 붙은 안내로, 터치 화면에서는 버튼으로 보인다. */
.taps { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 18px; }
.tap { padding: 7px 14px; font-size: 14px; color: var(--dim); background: var(--panel); border: 1px solid var(--line); border-radius: 18px; }
.tap:hover { color: var(--warm); border-color: var(--warm); }
.screen .panel .taps { margin-top: 8px; }
html.touch .tap { padding: 12px 20px; font-size: 16px; color: var(--text); }
html.touch .links a { padding: 9px 14px; }
html.touch .screen .hint { margin-top: 14px; }

/* 터치 조작. 빈 곳에 손가락을 대면 그 자리에 조이스틱이 생기고, 버튼은 오른손 엄지 쪽에 모은다. */
#touch { position: fixed; inset: 0; touch-action: none; }
html:not(.touch) #touch { display: none; }
#touch-zone { position: absolute; inset: 0; }
#stick { position: absolute; width: 112px; height: 112px; margin: -56px 0 0 -56px; border: 2px solid rgba(255, 255, 255, 0.35); border-radius: 50%; background: rgba(12, 15, 32, 0.35); pointer-events: none; }
/* 안쪽 원은 살금살금의 경계다. 손잡이가 이 안에 있으면 살금살금이다. */
#stick::before { content: ""; position: absolute; inset: 21px; border: 1px dashed rgba(159, 199, 238, 0.6); border-radius: 50%; }
#stick-knob { position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; margin: -23px 0 0 -23px; border-radius: 50%; background: rgba(255, 210, 122, 0.85); }
#stick.sneak #stick-knob { background: rgba(159, 199, 238, 0.9); }
.tbtn { position: absolute; display: flex; align-items: center; justify-content: center; font-weight: 800; color: var(--text); background: rgba(12, 15, 32, 0.6); border: 2px solid rgba(255, 255, 255, 0.4); border-radius: 50%; touch-action: none; }
.tbtn.action { right: 20px; bottom: 28px; width: 88px; height: 88px; font-size: 18px; border-color: var(--warm); color: var(--warm); }
.tbtn.sneak { right: 122px; bottom: 22px; width: 60px; height: 60px; font-size: 14px; color: var(--cool); }
.tbtn.map { right: 34px; bottom: 130px; width: 56px; height: 56px; font-size: 14px; }
.tbtn.back { right: 12px; top: 58px; height: 34px; padding: 0 14px; border-radius: 17px; border-width: 1px; font-size: 13px; font-weight: 700; color: var(--dim); }
.tbtn.on { background: rgba(60, 46, 16, 0.9); }
/* 할 수 있는 행동이 있으면 행동 버튼이 빛난다. 안내 줄은 눌러도 되고, 앞에 붙는 '행동' 표시가 버튼과 같은 색이다. */
html:has(#hud:not([hidden]) > #prompt:not([hidden], .disabled), #tour-hud:not([hidden]) > #tour-prompt:not([hidden], .disabled)) .tbtn.action { background: rgba(60, 46, 16, 0.9); box-shadow: 0 0 16px var(--warm); }
html.touch .prompt:not(.disabled), html.touch .bars { pointer-events: auto; touch-action: none; }
.prompt b { margin-right: 7px; padding: 1px 8px; border: 1px solid var(--warm); border-radius: 10px; color: var(--warm); font-size: 12px; }
.tbtn.sneak.on { background: rgba(28, 52, 82, 0.95); border-color: var(--cool); }
/* 살금 버튼이 켜진 것을 보여 주므로 위쪽 표시는 뺀다. */
html.touch .sneak:not(.tbtn) { display: none; }
/* 세워 든 폰에서는 안내와 막대가 버튼에 가리지 않게 위로 올린다. */
@media (orientation: portrait) {
  html.touch .prompt, html.touch .bars { bottom: 210px; }
}

/* 폰 크기 화면. 위쪽 표시를 줄이고, 할 일은 지금 할 것 한 줄만 보인다. */
@media (max-width: 760px), (max-height: 520px) {
  .hud-top { top: 8px; left: 8px; gap: 6px; }
  .clock { font-size: 20px; padding: 4px 8px; letter-spacing: 1px; }
  .gauge-box { width: 150px; padding: 4px 8px 6px; }
  .gauge-label { font-size: 12px; margin-bottom: 3px; }
  .gauge { height: 9px; }
  .checklist { top: 8px; right: 8px; width: auto; max-width: 44vw; padding: 6px 10px; }
  .checklist li { display: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .checklist li.current { display: block; }
  .carry { top: 58px; right: 100px; max-width: 50vw; }
  .tour-room { top: 8px; font-size: 16px; padding: 4px 14px; }
  .toast { width: max-content; max-width: 88vw; font-size: 14px; padding: 8px 14px; }
  .prompt { font-size: 14px; white-space: nowrap; }
  .screen { padding: 16px 12px; }
  .screen h2 { font-size: 22px; margin-bottom: 8px; }
  .screen p { font-size: 14px; }
  .menu { margin-top: 10px; }
  .menu li { padding: 10px 12px; margin-bottom: 6px; }
  .menu .name { font-size: 16px; }
  .cards { gap: 8px; margin-top: 10px; }
  .card { width: min(190px, 30vw); padding: 10px 6px; }
  .card .name { font-size: 16px; }
  .card .blurb { font-size: 12px; }
  .result .line { font-size: 17px; }
  .result-stars { font-size: 32px; }
}
/* 세워 든 폰. 할 일 줄을 시계 아래 왼쪽으로 내린다. */
@media (max-width: 760px) and (orientation: portrait) {
  .checklist { top: 58px; left: 8px; right: auto; max-width: calc(100vw - 110px); }
  .carry { top: 98px; left: 8px; right: auto; justify-content: flex-start; max-width: 80vw; }
}
/* 눕혀 든 폰. 세로가 좁으니 제목과 그림을 줄인다. */
@media (max-height: 520px) {
  .screen h1 { font-size: 30px; margin-bottom: 2px; }
  .screen .tag { margin-top: 4px; }
  .links { margin-top: 6px; }
  .title-menu { display: flex; gap: 8px; width: min(520px, 92vw); }
  .title-menu li { flex: 1; }
  .card img { width: 60px; }
  .toast { top: 16%; }
}
