/* =========================================================
   세로 모바일 웹앱
   - 폰: 화면 전체 사용 / PC: 가운데에 폰 비율 창
   - 무대(#stage)가 컨테이너 → cqw(가로 1%), cqh(세로 1%)는 무대 기준
   ========================================================= */
:root {
  --accent: #ff8a3d;            /* 포인트 컬러 (오렌지) — 여기만 바꾸면 전체 변경 */
  --accent-rgb: 255, 138, 61;
  --on-accent: #1f0e03;         /* 포인트 컬러 위 글자색 */
  --ink: #f2f5f8;
  --mute: rgba(242, 245, 248, .6);
  --line: rgba(255, 255, 255, .18);
  --glass: rgba(14, 12, 16, .72);
  --sans: 'Pretendard Variable', Pretendard, -apple-system, system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
html.x-app { --safe-t: 0px; }   /* X 앱 안 브라우저: 상단바 여백 없음 */

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #000; overflow: hidden; overscroll-behavior: none; }
/* 문서 자체는 절대 스크롤되지 않게 고정 (인앱 브라우저 하단 바가 스크롤 변화로 다시 올라오는 것 줄이기) */
html, body { position: fixed; inset: 0; width: 100%; }
body {
  display: grid; place-items: center;
  height: 100dvh;
  color: var(--ink);
  font-family: var(--sans);
  -webkit-user-select: none; user-select: none;
  touch-action: manipulation;
  word-break: keep-all;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }

#stage {
  position: relative;
  width: 100vw; height: 100dvh;
  container-type: size;
  overflow: hidden;
  background: #070608;
  /* 클립 영상 위치: 위쪽에서 16% 지점, 가로 꽉 차게 16:9 */
  --vt: max(calc(56px + var(--safe-t)), 9cqh);   /* 영상 위쪽 여백 (인앱 브라우저에서 위가 비어 보이지 않게 줄임) */
  --vh: calc(100cqw * 9 / 16);
  --vb: calc(var(--vt) + var(--vh));
}
/* PC: 가운데에 폰 비율 창 */
@media (min-width: 600px) {
  body {
    background:
      radial-gradient(ellipse 50% 60% at 30% 30%, rgba(var(--accent-rgb), .14), transparent 70%),
      radial-gradient(ellipse 50% 60% at 75% 80%, rgba(255, 90, 140, .1), transparent 70%),
      #050406;
  }
  #stage {
    width: auto; height: min(100dvh - 40px, 920px); aspect-ratio: 9 / 19.5;
    border-radius: 28px; box-shadow: 0 0 0 1px rgba(255,255,255,.08), 0 30px 80px rgba(0,0,0,.6);
  }
}

/* ---------- 영상 / 플레이스홀더 ---------- */
#video, #ph { position: absolute; left: 0; top: 0; width: 100%; height: 100%; }
#video { object-fit: cover; background: #000; transition: filter .6s; }
#ph { overflow: hidden; }
#ph .ph-bg {
  position: absolute; inset: -6%;
  background:
    radial-gradient(ellipse 60% 50% at 50% 45%, var(--ph-c1, #2a3c4f) 0%, transparent 70%),
    linear-gradient(180deg, var(--ph-c2, #0c1620), #050608);
  animation: drift 14s ease-in-out infinite alternate;
}
#ph .ph-label {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  text-align: center; font: 500 12px/1.7 var(--mono); color: rgba(255,255,255,.3);
  border: 1px dashed rgba(255,255,255,.18); border-radius: 8px; padding: 10px 16px; white-space: nowrap;
}
#ph .ph-label b { display: block; font-size: 15px; color: rgba(255,255,255,.45); }
html:not(.dev) #ph .ph-label { display: none; }
@keyframes drift { from { transform: scale(1); } to { transform: scale(1.06) translate(-1%, -1%); } }

/* 클립: 영상은 위쪽 16:9 칸, 뒤는 같은 영상 흐림 */
#clip-bg { position: absolute; inset: -10%; width: 120%; height: 120%; display: none; filter: blur(28px) brightness(.42) saturate(1.2); }
#stage[data-type="clip"] #clip-bg { display: block; }
#stage[data-type="clip"] #video,
#stage[data-type="clip"] #ph { top: var(--vt); height: var(--vh); }
#stage[data-type="clip"] #video { object-fit: contain; background: transparent; box-shadow: 0 10px 40px rgba(0,0,0,.5); }
#stage.slowmo #video { filter: brightness(.75) saturate(.9); }
#stage.slowmo #ph .ph-bg { animation-duration: 40s; filter: brightness(.7); }

/* ---------- HUD (상단) ---------- */
.hud { position: absolute; z-index: 5; pointer-events: none; transition: opacity .4s; }
#logo {
  top: calc(18px + var(--safe-t)); left: 18px;
  display: flex; align-items: center; gap: 7px;
  font: 800 14px/1 var(--sans); color: rgba(255,255,255,.9); letter-spacing: -.01em;
}
#logo::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #ff4d5e; box-shadow: 0 0 8px #ff4d5e; animation: rec 1.6s ease-in-out infinite; }
@keyframes rec { 50% { opacity: .25; } }
#chapter {
  top: calc(42px + var(--safe-t)); left: 18px;
  display: flex; align-items: center; gap: 8px; font: 600 13px/1 var(--sans); color: var(--ink);
}
#chapter .no { font: 700 11px/1 var(--mono); color: var(--on-accent); background: var(--accent); padding: 4px 6px; border-radius: 4px; }
#chapter.flash { animation: fadeIn .6s both; }
#tools { top: calc(12px + var(--safe-t)); right: 12px; display: flex; gap: 6px; pointer-events: auto; z-index: 8; }
#tools button {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(0,0,0,.35); border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); opacity: .7;
}
#tools svg { width: 17px; height: 17px; fill: none; stroke: var(--ink); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#tools #btn-mute svg path:first-child { fill: var(--ink); }
#tools #btn-mute .x { display: none; }
#tools #btn-mute.off .x { display: inline; }
#tools #btn-mute.off .wave { display: none; }
/* 장면별로 HUD 숨김 */
#stage:not([data-type="clip"]) #logo,
#stage:not([data-type="clip"]) #chapter,
#stage[data-type="ending"] #tools,
#stage[data-type="route"] #tools,
#stage[data-type="narration"] #tools,
#stage.phone-mode .hud { opacity: 0; pointer-events: none; }
#stage.phone-mode #tools { display: none; }

/* ---------- 자막 ---------- */
#sub {
  position: absolute; z-index: 6; left: 20px; right: 20px; top: calc(var(--vb) + 22px);
  text-align: center; pointer-events: none;
  font: 700 17px/1.5 var(--sans); color: #fff;
  -webkit-text-stroke: .12em rgba(0,0,0,.8); paint-order: stroke fill;
  text-shadow: 0 0 .4em rgba(0,0,0,.6);
  transition: opacity .2s;
}
#sub:empty { opacity: 0; }
/* 속마음: 노란 글씨 + 글자 주변만 어둡게 */
#sub.think {
  color: #ffe14d;
  -webkit-text-stroke: .1em rgba(0,0,0,.75);
  text-shadow: 0 0 .3em rgba(0,0,0,.9), 0 0 .8em rgba(0,0,0,.65), 0 .08em .2em rgba(0,0,0,.8);
  animation: thinkIn .4s ease both;
}
@keyframes thinkIn { from { opacity: 0; transform: translateY(.3em); filter: blur(4px); } }
/* 영상통화·문자 화면에서는 폰 버튼을 피해 가운데 아래쪽 */
#stage.phone-mode #sub { top: auto; bottom: 34cqh; }

/* ---------- 선택지: 아래쪽에 세로로 (엄지 닿는 곳) ---------- */
#choices {
  position: absolute; z-index: 7; left: 16px; right: 16px; bottom: calc(22px + var(--safe-b));
  display: flex; flex-direction: column; gap: 9px;
}
#choices:empty { display: none; }
.opt {
  position: relative; width: 100%;
  display: flex; align-items: center; gap: 10px; text-align: left;
  min-height: 52px; padding: 12px 18px;
  font: 600 16px/1.35 var(--sans); color: var(--ink);
  background: var(--glass);
  -webkit-backdrop-filter: blur(14px) saturate(1.3); backdrop-filter: blur(14px) saturate(1.3);
  border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 6px 20px rgba(0,0,0,.35);
  opacity: 0; transform: translateY(10px);
  animation: optIn .45s cubic-bezier(.2,.8,.2,1) forwards;
  animation-delay: calc(var(--i) * 60ms + 80ms);
  transition: background .18s, border-color .18s, transform .18s, opacity .3s, color .18s;
}
.opt .txt { flex: 1; }
.opt .arrow { flex: none; color: var(--mute); font: 500 18px/1 var(--mono); }
.opt:active { transform: scale(.98); background: rgba(40, 30, 26, .85); }
@media (hover: hover) { .opt:hover { border-color: rgba(var(--accent-rgb), .8); } }
@keyframes optIn { to { opacity: 1; transform: none; } }
/* 이미 골랐던 선택지: 끝의 › 자리에 ✿ (장식) */
.opt.seen .arrow { color: rgba(var(--accent-rgb), .8); font: 700 14px/1 var(--sans); letter-spacing: -.08em; }

#choices.decided .opt { pointer-events: none; }
/* 고른 뒤에도 버튼은 그 자리 그대로 (다른 버튼만 살짝 흐리게) → 바로 다음 화면으로 */
#choices.decided .opt:not(.picked) { opacity: .45 !important; }
#choices.decided .opt.picked { background: var(--accent); border-color: var(--accent); color: var(--on-accent); box-shadow: 0 0 24px rgba(var(--accent-rgb), .45); }
#choices.decided .opt.picked .arrow { color: var(--on-accent); }

.c-head { display: flex; flex-direction: column; gap: 6px; margin-bottom: 4px; font: 700 16px/1.4 var(--sans); color: #fff; animation: fadeIn .4s both; }
.c-head span { font: 700 10px/1 var(--mono); color: var(--accent); letter-spacing: .16em; }
.c-timer { display: flex; align-items: center; gap: 10px; font: 700 11px/1 var(--mono); color: var(--accent); animation: fadeIn .4s .3s both; transition: opacity .3s; }
.c-timer i { flex: 1; height: 3px; border-radius: 3px; background: rgba(255,255,255,.15); overflow: hidden; position: relative; }
.c-timer i::after { content: ""; position: absolute; inset: 0; background: var(--accent); transform-origin: left; transform: scaleX(var(--p, 1)); }
.c-timer.hurry { color: #ff5d6c; }
.c-timer.hurry i::after { background: #ff5d6c; }
#choices.decided .c-timer { opacity: 0; }

/* ---------- 클립 탭 → 일시정지 / 진행 바 ---------- */
#tapzone { position: absolute; inset: 0; z-index: 4; display: none; cursor: pointer; }
#stage[data-type="clip"] #tapzone, #stage.ctl #tapzone { display: block; }
#pause-ind {
  position: absolute; z-index: 6; left: 50%; top: calc(var(--vt) + var(--vh) / 2); transform: translate(-50%, -50%) scale(.9);
  display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none;
  opacity: 0; transition: opacity .25s, transform .25s;
  font: 600 12px/1 var(--sans); color: rgba(255,255,255,.9); text-shadow: 0 1px 4px rgba(0,0,0,.8);
}
#pause-ind svg { width: 54px; height: 54px; padding: 15px; border-radius: 50%; background: rgba(0,0,0,.5); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); color: #fff; }
#pause-ind.on { opacity: 1; transform: translate(-50%, -50%); }

#scrub {
  position: absolute; z-index: 6; left: 0; right: 0; top: calc(var(--vb) - 12px); height: 26px;
  display: none; align-items: center; cursor: pointer; touch-action: none;
  opacity: 0; pointer-events: none; transition: opacity .25s;
}
#stage[data-type="clip"] #scrub:not([hidden]), #stage.ctl #scrub:not([hidden]) { display: flex; }
#scrub.active { opacity: 1; pointer-events: auto; }
#scrub .sb-track { position: relative; flex: 1; height: 4px; margin: 0 14px; background: rgba(255,255,255,.25); border-radius: 4px; }
#scrub .sb-fill { position: absolute; left: 0; top: 0; bottom: 0; width: calc(var(--f, 0) * 100%); background: var(--accent); border-radius: 4px; }
#scrub .sb-fill::after { content: ""; position: absolute; right: -7px; top: 50%; width: 14px; height: 14px; border-radius: 50%; background: #fff; transform: translateY(-50%); box-shadow: 0 0 6px rgba(0,0,0,.5); }
#scrub .sb-time { position: absolute; right: 14px; top: -16px; font: 600 11px/1 var(--mono); color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.9); }

/* ---------- 내레이션 ---------- */
#narr {
  position: absolute; inset: 0; z-index: 8; cursor: pointer; overflow: hidden;
  background:
    radial-gradient(circle, rgba(255,255,255,.06) 1px, transparent 1.2px) 0 0 / 22px 22px,
    radial-gradient(ellipse 80% 45% at 15% 15%, rgba(var(--accent-rgb), .22), transparent 70%),
    radial-gradient(ellipse 75% 45% at 90% 90%, rgba(255, 90, 140, .16), transparent 70%),
    linear-gradient(180deg, #0d0a0c, #050405);
}
#narr::before {
  content: ""; position: absolute; inset: -20%; pointer-events: none;
  background: radial-gradient(ellipse 45% 30% at 50% 50%, rgba(var(--accent-rgb), .10), transparent 70%);
  animation: drift 16s ease-in-out infinite alternate;
}
#narr .lines {
  position: absolute; left: 28px; right: 28px; top: 46%; transform: translateY(-50%);
  display: flex; flex-direction: column; gap: .45em;
}
#narr .line { font: 600 21px/1.55 var(--sans); color: var(--ink); letter-spacing: -.01em; transition: color .5s; }
#narr .line.past { color: rgba(242,245,248,.38); }
#narr .line.typing::after { content: ""; display: inline-block; width: .5em; height: 1.05em; margin-left: .12em; vertical-align: -.15em; background: var(--accent); animation: caret .9s steps(1) infinite; }
@keyframes caret { 50% { opacity: 0; } }
#narr .nsub { position: absolute; left: 24px; right: 24px; bottom: calc(110px + var(--safe-b)); text-align: center; font: 600 14px/1.45 var(--sans); color: var(--mute); animation: fadeIn .6s ease both; }
#narr .n-cta {
  position: absolute; left: 50%; bottom: calc(48px + var(--safe-b)); transform: translate(-50%, 10px);
  display: flex; align-items: center; gap: 10px; padding: 12px 20px 12px 16px; border-radius: 99em; white-space: nowrap;
  font: 700 15px/1 var(--sans); color: #fff;
  background: rgba(var(--accent-rgb), .14); border: 1px solid rgba(var(--accent-rgb), .6);
  opacity: 0; pointer-events: none; transition: opacity .4s, transform .4s;
}
#narr .n-cta.show { opacity: 1; transform: translate(-50%, 0); }
#narr .n-cta .ring { position: relative; width: 13px; height: 13px; border-radius: 50%; background: var(--accent); }
#narr .n-cta .ring::after { content: ""; position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--accent); animation: tapRing 1.4s ease-out infinite; }
@keyframes tapRing { from { transform: scale(1); opacity: .9; } to { transform: scale(2.6); opacity: 0; } }
@keyframes blink { 50% { opacity: .25; } }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ---------- 버튼(공용) ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; padding: 0 22px;
  font: 700 16px/1 var(--sans); color: var(--on-accent); background: var(--accent);
  border-radius: 99em; box-shadow: 0 0 24px rgba(var(--accent-rgb), .35);
  transition: filter .18s, transform .18s;
}
.btn svg { width: 18px; height: 18px; }
.btn:active { transform: scale(.97); }
.btn.ghost { color: var(--ink); background: rgba(255,255,255,.06); border: 1px solid var(--line); box-shadow: none; }

/* ---------- 타이틀 ---------- */
#title {
  position: absolute; inset: 0; z-index: 9;
  display: flex; flex-direction: column; justify-content: flex-start;
  padding: calc(9cqh + var(--safe-t)) 24px calc(30px + var(--safe-b));
  background:
    radial-gradient(circle, rgba(255,255,255,.05) 1px, transparent 1.2px) 0 0 / 22px 22px,
    radial-gradient(ellipse 90% 40% at 50% 22%, rgba(var(--accent-rgb), .24), transparent 70%),
    radial-gradient(ellipse 80% 40% at 10% 95%, rgba(255, 90, 140, .14), transparent 70%),
    linear-gradient(180deg, #0c0a10, #040405);
}
#title[hidden] { display: none; }
#title .confetti { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2; }
#title .t-right { position: relative; z-index: 1; order: -1; margin-bottom: 26px; }
#title .t-left { position: relative; z-index: 1; flex: 1; display: flex; flex-direction: column; gap: 10px; }
#title .t-media {
  display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 16px;
  border: 1px solid rgba(var(--accent-rgb), .35);
  box-shadow: 0 0 0 4px rgba(var(--accent-rgb), .06), 0 16px 40px rgba(0,0,0,.6), 0 0 50px rgba(var(--accent-rgb), .15);
  opacity: 0; transition: opacity .8s;
}
#title .t-media.ready { opacity: 1; }
#title .t-right .ph-label { aspect-ratio: 16 / 9; display: grid; place-items: center; border: 1px dashed rgba(255,255,255,.16); border-radius: 16px; font: 500 12px var(--mono); color: rgba(255,255,255,.3); }
#title .t-kicker { font: 800 15px/1 var(--sans); color: var(--accent); animation: slideUp .6s ease both; }
#title .t-logo { margin: 0; font: 900 46px/1.02 var(--sans); letter-spacing: -.04em; color: #fff; animation: slideUp .7s .1s cubic-bezier(.2,.8,.2,1) both; }
#title .t-tag { font: 500 15px/1.5 var(--sans); color: var(--mute); animation: fadeIn 1s .5s both; }
#title .t-menu { display: flex; flex-direction: column; gap: 10px; margin-top: auto; padding-top: 24px; animation: fadeIn .8s .8s both; }
#title .t-menu .btn { width: 100%; }
#title .t-count { align-self: center; margin-top: 4px; font: 600 11px var(--mono); color: var(--mute); letter-spacing: .06em; }

/* ---------- 엔딩 ---------- */
#ending { position: absolute; inset: 0; z-index: 8; }
#stage[data-type="ending"] .ph-label { display: none; }
#ending .end-card {
  position: absolute; inset: 0; padding: calc(28px + var(--safe-t)) 22px calc(28px + var(--safe-b));
  display: flex; flex-direction: column; justify-content: center; gap: 34px;
  background:
    radial-gradient(ellipse 80% 40% at 50% 30%, rgba(var(--accent-rgb), .12), transparent 70%),
    rgba(6, 5, 8, .82);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  animation: fadeIn 1s ease both;
}
#ending .end-main { display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; transition: transform .6s cubic-bezier(.2,.8,.2,1); }
#ending h1 { margin: 0; display: flex; align-items: center; gap: 12px; font: 800 24px/1.3 var(--sans); letter-spacing: -.02em; color: #fff; animation: slideUp .7s .2s both; }
#ending h1 i { flex: none; width: 28px; height: 1px; background: linear-gradient(90deg, transparent, var(--accent)); }
#ending h1 i:last-child { transform: scaleX(-1); }
#ending .end-desc { margin: 0; font: 500 15px/1.7 var(--sans); color: rgba(242,245,248,.82); animation: fadeIn .8s .6s both; }
#ending .end-actions { display: flex; flex-direction: column; gap: 12px; animation: fadeIn .8s 1s both; transition: opacity .4s; }
#ending .voice-pill {
  display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 58px; padding: 0 18px 0 8px;
  border-radius: 99em; font: 700 16px/1 var(--sans); color: #fff;
  background: linear-gradient(90deg, rgba(var(--accent-rgb), .08), rgba(var(--accent-rgb), .2), rgba(var(--accent-rgb), .08));
  border: 1px solid rgba(var(--accent-rgb), .55);
}
#ending .vp-av, #ending .vc-av { flex: none; display: grid; place-items: center; border-radius: 50%; overflow: hidden; background: linear-gradient(135deg, var(--accent), #e8622a); color: var(--on-accent); font-weight: 800; }
#ending .vp-av { width: 42px; height: 42px; font-size: 16px; }
#ending .vp-av img, #ending .vc-av img { width: 100%; height: 100%; object-fit: cover; }
#ending .vp-ic { width: 20px; color: var(--accent); display: grid; }
#ending .end-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
#ending .end-btns .btn { padding: 0 12px; font-size: 15px; }

/* 듣기 모드: 위에 제목, 가운데 프로필 + 말풍선, 아래 그만 듣기 */
#ending .voice-panel {
  position: absolute; left: 20px; right: 20px; top: 50%; transform: translateY(-40%);
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  opacity: 0; pointer-events: none; transition: opacity .5s .2s, transform .7s cubic-bezier(.2,.8,.2,1);
}
#ending .vc-person { display: flex; flex-direction: column; align-items: center; gap: 8px; font: 700 13px/1 var(--sans); color: var(--mute); }
#ending .vc-av { width: 92px; height: 92px; font-size: 32px; box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .7), 0 0 30px rgba(var(--accent-rgb), .25); }
#ending .playing .vc-av { animation: talk 1.1s ease-in-out infinite; }
@keyframes talk { 50% { box-shadow: 0 0 0 4px rgba(var(--accent-rgb), .9), 0 0 40px rgba(var(--accent-rgb), .45); } }
#ending .vc-bubble {
  position: relative; width: 100%; padding: 14px 16px 16px; border-radius: 20px;
  background: rgba(30, 24, 22, .94); border: 1px solid rgba(var(--accent-rgb), .35); box-shadow: 0 10px 30px rgba(0,0,0,.4);
}
#ending .vc-bubble::before {   /* 말풍선 꼬리 → 위쪽 프로필 */
  content: ""; position: absolute; left: 50%; top: -9px; width: 16px; height: 16px; margin-left: -8px;
  background: inherit; border-left: inherit; border-top: inherit; transform: rotate(45deg); border-radius: 3px 0 0 0;
}
#ending .vc-player { display: flex; align-items: center; gap: 12px; }
#ending .vc-btn { flex: none; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); font-size: 40px; }
#ending .vc-btn i { margin-left: .08em; border-left: .28em solid var(--on-accent); border-top: .17em solid transparent; border-bottom: .17em solid transparent; }
#ending .playing .vc-btn i { margin: 0; width: .26em; height: .3em; border: 0; border-left: .08em solid var(--on-accent); border-right: .08em solid var(--on-accent); }
#ending .wave { flex: 1; height: 34px; display: flex; align-items: center; gap: 2px; }
#ending .wave i { flex: 1; height: calc(var(--h) * 100%); min-height: 3px; border-radius: 99em; background: rgba(255,255,255,.28); transition: background .15s, transform .15s; }
#ending .wave i.played { background: var(--accent); }
#ending .wave i.hot { transform: scaleY(1.25); background: #ffd2b0; }
#ending .vc-dur { flex: none; font: 600 12px/1 var(--mono); color: var(--mute); min-width: 3em; text-align: right; }
#ending .vc-sub { min-height: 1.4em; margin-top: 12px; padding-top: 12px; border-top: 1px solid rgba(255,255,255,.08); font: 600 17px/1.5 var(--sans); color: #fff; text-align: center; }
#ending .vc-sub:empty { display: none; }
#ending .vc-sub.in { animation: slideUp .45s ease both; }
#ending .vc-stop {
  position: absolute; left: 50%; bottom: calc(40px + var(--safe-b)); transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px; padding: 12px 18px; font: 700 16px/1 var(--sans); color: #fff;
  opacity: 0; pointer-events: none; transition: opacity .4s .3s;
}
#ending .vc-stop b { color: var(--accent); font-size: 1.4em; }
#ending .listening .end-main { position: absolute; left: 22px; right: 22px; top: calc(40px + var(--safe-t)); transform: scale(.88); }
#ending .listening .end-actions { opacity: 0; pointer-events: none; animation: none; }
#ending .listening .voice-panel { opacity: 1; pointer-events: auto; transform: translateY(-50%); }
#ending .listening .vc-stop { opacity: 1; pointer-events: auto; }

/* ---------- 스토리 루트 (위→아래로 갈라지는 지도) ---------- */
#route {
  position: absolute; inset: 0; z-index: 9; display: flex; flex-direction: column;
  background:
    radial-gradient(circle, rgba(255,255,255,.05) 1px, transparent 1.2px) 0 0 / 22px 22px,
    radial-gradient(ellipse 80% 50% at 50% 30%, rgba(var(--accent-rgb), .18), transparent 70%),
    radial-gradient(ellipse 70% 45% at 10% 95%, rgba(255, 90, 140, .12), transparent 70%),
    linear-gradient(180deg, #0b0a10, #040406);
  animation: fadeIn .4s both;
}
#route[hidden] { display: none; }
.r-top { flex: none; display: flex; justify-content: space-between; align-items: flex-end; padding: calc(20px + var(--safe-t)) 20px 10px; }
.r-kicker { font: 700 10px/1 var(--mono); color: var(--accent); letter-spacing: .18em; }
.r-top h2 { margin: 6px 0 0; font: 900 22px/1 var(--sans); letter-spacing: -.03em; color: #fff; }
.r-stats { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; font: 600 12px/1 var(--sans); color: var(--mute); }
.r-stats b { color: #fff; font-family: var(--mono); margin-left: 4px; }
.r-map { position: relative; flex: 1; min-height: 0; overflow: hidden; touch-action: none; }
.r-canvas { position: absolute; left: 0; top: 0; }
.r-canvas.anim { transition: transform .35s cubic-bezier(.2,.8,.2,1); }
.r-canvas svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.r-canvas path { fill: none; stroke: rgba(255,255,255,.2); stroke-width: .35; stroke-dasharray: 1.2 1; }
.r-canvas path.on { stroke: var(--accent); stroke-width: .5; stroke-dasharray: none; }
.r-chip {
  position: absolute; transform: translate(-50%, -50%); max-width: var(--mw, 36cqw); text-align: center;
  padding: 5px 9px; border-radius: 99em; font: 600 11px/1.25 var(--sans);
  color: rgba(255,255,255,.5); background: #0b0a10; border: 1px solid rgba(255,255,255,.14);
}
.r-chip.on { color: #fff; border-color: rgba(var(--accent-rgb), .7); background: #1a1009; }
.r-node { position: absolute; transform: translate(-50%, -50%); }
.r-node.card { width: 36cqw; display: flex; flex-direction: column; align-items: stretch; gap: 6px; text-align: center; }
.r-thumb { position: relative; display: grid; place-items: center; aspect-ratio: 16 / 9; border-radius: 10px; overflow: hidden; background: #16161c center / cover no-repeat; border: 1px solid rgba(255,255,255,.14); }
.r-node.reached .r-thumb { border-color: rgba(var(--accent-rgb), .7); box-shadow: 0 0 16px rgba(var(--accent-rgb), .2); }
.r-node.locked .r-thumb { filter: grayscale(1) brightness(.35) blur(2px); }
.r-play { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: rgba(0,0,0,.55); border: 1px solid rgba(255,255,255,.6); font-size: 30px; }
.r-play::after { content: ""; margin-left: .08em; border-left: .3em solid #fff; border-top: .19em solid transparent; border-bottom: .19em solid transparent; }
.r-lock { font: 800 16px/1 var(--mono); color: rgba(255,255,255,.5); font-style: normal; }
.r-label { align-self: center; max-width: 100%; padding: 5px 10px; border-radius: 99em; font: 700 11px/1.25 var(--sans); color: #fff; background: rgba(20,20,26,.9); border: 1px solid rgba(255,255,255,.14); }
.r-node.reached .r-label { border-color: rgba(var(--accent-rgb), .55); }
.r-node.locked .r-label { color: rgba(255,255,255,.35); }
.r-label em { font: 700 .8em var(--mono); font-style: normal; color: var(--accent); margin-right: 5px; letter-spacing: .08em; }
.r-node.small { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.r-node.small i { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font: 700 13px/1 var(--mono); font-style: normal; color: rgba(255,255,255,.35); background: #121218; border: 1px dashed rgba(255,255,255,.22); }
.r-node.small.reached i { color: var(--accent); border: 1px solid rgba(var(--accent-rgb), .6); }
.r-node.small span { font: 600 10px/1 var(--sans); color: var(--mute); white-space: nowrap; }
.r-pan {
  position: absolute; z-index: 3; display: none; place-items: center; width: 36px; height: 36px; border-radius: 50%;
  font: 700 20px/1 var(--sans); color: #fff; padding-bottom: 2px;
  background: rgba(20,16,14,.85); border: 1px solid rgba(var(--accent-rgb), .55); box-shadow: 0 4px 14px rgba(0,0,0,.5);
}
.r-pan.l { left: 8px; top: 50%; transform: translateY(-50%); }
.r-pan.r { right: 8px; top: 50%; transform: translateY(-50%); }
.r-pan.u { top: 6px; right: 8px; transform: rotate(90deg); }
.r-pan.d { bottom: 6px; right: 8px; transform: rotate(90deg); }
.r-pan { opacity: .85; }
.r-chip.merge { z-index: 1; transform: translate(-50%, -50%) rotate(-90deg); white-space: nowrap; max-width: none; }
.r-map.can-l .r-pan.l, .r-map.can-r .r-pan.r, .r-map.can-u .r-pan.u, .r-map.can-d .r-pan.d { display: grid; }
.r-bottom { flex: none; display: flex; flex-direction: column; gap: 12px; padding: 10px 20px calc(20px + var(--safe-b)); }
.r-progress { display: flex; align-items: center; gap: 10px; font: 600 12px/1 var(--sans); color: var(--mute); }
.r-progress b { color: var(--accent); font-family: var(--mono); }
.r-progress i { flex: 1; height: 3px; border-radius: 3px; background: rgba(255,255,255,.12); overflow: hidden; }
.r-progress s { display: block; height: 100%; background: var(--accent); }
.r-hint { font: 500 12px/1.4 var(--sans); color: rgba(255,255,255,.45); }
.rt-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---------- 기타 ---------- */
#tap-play {
  position: absolute; z-index: 20; left: 50%; top: 50%; transform: translate(-50%,-50%);
  padding: 14px 24px; border-radius: 99em; font: 700 16px var(--sans);
  background: rgba(0,0,0,.7); border: 1px solid var(--accent); color: var(--accent);
}
#fade { position: absolute; inset: 0; z-index: 30; background: #000; opacity: 0; pointer-events: none; transition: opacity .3s ease; }
#fade.on { opacity: 1; }
#fade.loading::after {
  content: ""; position: absolute; left: 50%; top: 50%; margin: -12px 0 0 -12px; width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid rgba(var(--accent-rgb), .25); border-top-color: var(--accent); animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.toast {
  position: absolute; z-index: 40; left: 50%; bottom: calc(90px + var(--safe-b)); transform: translateX(-50%);
  padding: 12px 18px; border-radius: 99em; font: 600 14px/1 var(--sans); white-space: nowrap;
  background: rgba(20,22,28,.94); border: 1px solid var(--line); color: var(--ink);
  animation: toastIn 2.4s ease both;
}
@keyframes toastIn { 0% { opacity: 0; transform: translate(-50%, 8px); } 10%, 85% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; } }

/* 개발용 패널 (?dev) */
#dev {
  position: fixed; z-index: 200; left: 8px; bottom: 8px;
  display: flex; gap: 6px; align-items: center;
  font: 12px/1 system-ui, sans-serif; color: #ccc;
  background: rgba(20,20,20,.85); border: 1px solid #444; border-radius: 6px; padding: 6px 8px;
}
#dev select, #dev button { font: inherit; color: #eee; background: #333; border: 1px solid #555; border-radius: 4px; padding: 3px 6px; max-width: 200px; }
#dev code { color: #9c9; max-width: 120px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

/* 캡처용(?shot): 애니메이션 즉시 완료 */
.noanim *, .noanim *::before, .noanim *::after { animation-duration: 0s !important; animation-delay: 0s !important; transition: none !important; }
/* 내레이션 위로 선택 버튼 */
#stage[data-type="narration"] #choices { z-index: 9; bottom: calc(40px + var(--safe-b)); }

/* 대사 없는 구간의 안내 자막: 은은하게 숨쉬듯 */
#sub.idle { color: rgba(255, 225, 77, .85); animation: idlePulse 2.6s ease-in-out infinite; }
@keyframes idlePulse { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }

/* 엔딩 상단: The End 타이포 + ENDING n/N */
/* The End + 제목·설명은 한 묶음, 버튼은 아래로 떨어뜨림 */
#ending .end-card { justify-content: center; gap: 0; padding-bottom: calc(40px + var(--safe-b)); }
#ending .end-head { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 26px; animation: slideUp .7s both; }
#ending .end-logo { width: min(72%, 300px); filter: invert(1) drop-shadow(0 6px 20px rgba(var(--accent-rgb), .25)); }
#ending .end-count { font: 700 12px/1 var(--mono); letter-spacing: .22em; color: var(--accent); padding: 7px 12px; border: 1px solid rgba(var(--accent-rgb), .5); border-radius: 99em; }
#ending .end-actions { margin-top: 64px; }
#ending .listening .end-head { visibility: hidden; }

/* 선택지 위 고정 문구 (노란 자막 스타일) */
.c-head.sub-style { align-self: center; text-align: center; margin-bottom: 6px; font: 700 17px/1.5 var(--sans); color: #ffe14d;
  -webkit-text-stroke: .1em rgba(0,0,0,.75); paint-order: stroke fill; text-shadow: 0 0 .3em rgba(0,0,0,.9), 0 0 .8em rgba(0,0,0,.65); }

/* 두 줄 자막: 내 말(흰색) + 아래 줄 속마음(노란색) */
#sub .l { display: block; }
#sub .l.think { color: #ffe14d; -webkit-text-stroke: .1em rgba(0,0,0,.75);
  text-shadow: 0 0 .3em rgba(0,0,0,.9), 0 0 .8em rgba(0,0,0,.65), 0 .08em .2em rgba(0,0,0,.8); animation: thinkIn .4s ease both; }

/* 연타 이벤트 */
.mash { position: absolute; inset: 0; z-index: 12; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px;
  background: rgba(0,0,0,.35); animation: mashIn .2s ease both; touch-action: manipulation; }
.mash-btn { width: min(62vw, 250px); aspect-ratio: 1; border-radius: 50%; border: 0; cursor: pointer;
  background: radial-gradient(circle at 50% 35%, #ff6b4a, #e0262a); color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  box-shadow: 0 0 0 8px rgba(255,80,60,.25), 0 0 60px rgba(255,60,40,.6); animation: mashPulse .5s ease-in-out infinite alternate; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; }
.mash-btn b { font: 800 19px/1.3 var(--sans); padding: 0 18px; word-break: keep-all; }
.mash-n { font: 700 15px/1 var(--mono); opacity: .9; }
.mash-btn.hit { animation: mashHit .12s ease; }
.mash-bar { width: min(70vw, 280px); height: 8px; border-radius: 9px; background: rgba(255,255,255,.2); overflow: hidden; }
.mash-bar s { display: block; height: 100%; background: #ffe14d; transform-origin: left; }
.mash.win .mash-btn { background: radial-gradient(circle at 50% 35%, #ffb35a, #ff8a3d); animation: none; }
.mash.lose { opacity: .6; }
@keyframes mashIn { from { opacity: 0; } }
@keyframes mashPulse { to { transform: scale(1.04); } }
@keyframes mashHit { 50% { transform: scale(.92); } }

/* 굿/배드 엔딩 그림 + 효과 */
#ending .end-art { width: min(64%, 260px); max-height: 30cqh; object-fit: contain; }
#ending .end-art.good { filter: drop-shadow(0 0 18px rgba(255,150,80,.45)); }
#ending .end-art.bad { width: min(46%, 190px); filter: drop-shadow(0 10px 24px rgba(0,0,0,.6)) saturate(.9); animation: badWobble 3.2s ease-in-out infinite; }
@keyframes badWobble { 50% { transform: rotate(-3deg) translateY(2px); } }
#ending .end-kind { font: 800 12px/1 var(--mono); letter-spacing: .26em; }
#ending .end-kind.good { color: #ffd84d; }
#ending .end-kind.bad { color: #8fb4ff; }
#ending .end-fx { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 3; overflow: hidden; }
#ending .end-fx i { position: absolute; top: -10%; font-size: calc(26px * var(--s)); font-style: normal; opacity: .85;
  animation: tearFall var(--d) linear var(--w) infinite; }
@keyframes tearFall { from { transform: translateY(0) rotate(-8deg); } to { transform: translateY(125cqh) rotate(8deg); } }
#ending .listening ~ .end-fx, #ending:has(.listening) .end-fx { opacity: .35; }
#ending .end-fx { z-index: 3; }
#ending .end-fx i { opacity: .7; }
#ending .end-fx i.drop { font-size: calc(17px * var(--s)); opacity: .55; }

/* 세로 영상: 화면 가득 */
#stage.clip-full[data-type="clip"] #video { top: 0; height: 100%; object-fit: cover; box-shadow: none; }
#stage.clip-full[data-type="clip"] #clip-bg { display: none; }
#stage.clip-full #sub { top: auto; bottom: calc(15% + var(--safe-b)); }

/* 영상 위 선택지: 흐림(backdrop-filter) 대신 반투명 배경 → 영상 재생이 버벅이지 않게 */
#stage[data-type="clip"] .opt { -webkit-backdrop-filter: none; backdrop-filter: none; background: rgba(20, 16, 18, .78); }
#clip-bg { transition: opacity .8s; will-change: auto; }
/* 연타 버튼: 60% 크기, 게임 주황 톤 */
.mash-btn { width: min(37vw, 150px); gap: 6px;
  background: radial-gradient(circle at 50% 35%, #ffb066, #ff8a3d 60%, #f06a28);
  box-shadow: 0 0 0 6px rgba(var(--accent-rgb), .22), 0 0 36px rgba(var(--accent-rgb), .5); color: #2a1406; }
.mash-btn b { font: 800 13px/1.3 var(--sans); padding: 0 12px; }
.mash-n { font: 700 12px/1 var(--mono); }
.mash-bar { width: min(44vw, 170px); height: 6px; }
.mash.win .mash-btn { background: radial-gradient(circle at 50% 35%, #ffe08a, #ffc23d); }
/* 루트: 되돌아가는 길 칸 */
.r-node.small.back span { white-space: normal; text-align: center; max-width: 20cqw; line-height: 1.25; }
.r-node.small.back i { font-size: 16px; }
.r-chip.tree { transform: translate(-50%, -100%); }

/* 화면 가득 영상(세로 클립·영상통화): 일시정지 표시는 화면 가운데, 진행 바는 화면 아래 */
#stage.clip-full #pause-ind, #stage[data-type="call"] #pause-ind { top: 50%; }
#stage.clip-full #scrub { top: auto; bottom: calc(26px + var(--safe-b)); }
#stage[data-type="call"] #scrub { top: auto; bottom: calc(var(--safe-b) + 14px); right: calc(27cqw + 18px); }
#stage[data-type="call"] #tapzone { z-index: 5; }
/* 엔딩 그림 자리를 미리 잡아둠 → 그림이 늦게 떠도 화면이 출렁이지 않게 */
#ending .end-art { height: auto; }
#ending .end-art.good { aspect-ratio: 722 / 477; }
#ending .end-art.bad { aspect-ratio: 600 / 590; }

/* ── 10초 미션 (혼자 준비한다) ── */
.mission { position: absolute; inset: 0; z-index: 12; overflow: hidden; touch-action: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none;
  background: radial-gradient(120% 80% at 50% 45%, #3a2416 0%, #1a0e08 55%, #080403 100%); animation: mashIn .25s ease both; }
.mission img { pointer-events: none; -webkit-user-drag: none; }
.ms-top { position: absolute; top: calc(58px + var(--safe-t)); left: 50%; transform: translateX(-50%); width: min(78cqw, 320px);
  display: flex; flex-direction: column; align-items: center; gap: 8px; }
.ms-steps { display: flex; gap: 8px; }
.ms-steps i { width: 30px; height: 6px; border-radius: 9px; background: rgba(255,255,255,.18); transition: background .3s; }
.ms-steps i.on { background: #ffb34d; } .ms-steps i.done { background: #8fe388; }
.ms-time b { font: 800 44px/1 var(--mono); color: #fff; letter-spacing: -.02em; font-variant-numeric: tabular-nums; text-shadow: 0 2px 18px rgba(255,150,60,.45); }
.ms-bar { width: 100%; height: 8px; border-radius: 9px; background: rgba(255,255,255,.15); overflow: hidden; }
.ms-bar s { display: block; height: 100%; background: linear-gradient(90deg, #ff8a3d, #ffd84d); transform-origin: left; }
.mission.hurry .ms-time b { color: #ff5a4a; animation: msHurry .5s ease-in-out infinite alternate; }
.mission.hurry .ms-bar s { background: #ff5a4a; }
@keyframes msHurry { to { transform: scale(1.08); } }
.ms-title { position: absolute; top: calc(160px + var(--safe-t)); left: 0; right: 0; text-align: center; font: 800 20px/1.3 var(--sans); color: #fff;
  padding: 0 20px; word-break: keep-all; text-shadow: 0 2px 10px rgba(0,0,0,.6); }
.ms-play { position: absolute; left: 0; width: 100cqw; height: 120cqw; top: max(calc(196px + var(--safe-t)), calc(52cqh - 56cqw)); cursor: pointer; touch-action: none; }
.ms-play > * { position: absolute; transition: opacity .35s ease; }
.ms-box { left: 12cqw; top: 22cqw; width: 44cqw; filter: drop-shadow(0 12px 22px rgba(0,0,0,.55)); }
.ms-stick { left: 75.5cqw; top: 53.5cqw; width: 5cqw; height: 54.5cqw; rotate: -28deg; transform-origin: 50% 100%; z-index: 3;
  transition: left .45s ease, top .45s ease, rotate .45s ease, opacity .35s; }
.ms-stick img { position: absolute; transition: opacity .25s, transform .35s cubic-bezier(.3,1.6,.5,1); }
.ms-stick .off { inset: 0; width: 100%; height: 100%; filter: drop-shadow(0 6px 10px rgba(0,0,0,.5)); }
.ms-stick .on { width: 42cqw; left: -18.6cqw; bottom: 0; opacity: 0; transform: scale(.6); transform-origin: 50% 30%; }
.mission.lit .ms-stick .off { opacity: 0; }
.mission.lit .ms-stick .on { opacity: 1; transform: none; animation: msFlicker .18s ease-in-out infinite alternate .4s; }
@keyframes msFlicker { to { transform: scale(1.03) rotate(1deg); } }
.ms-sparks { left: 51cqw; top: 64cqw; width: 0; height: 0; z-index: 4; }
.ms-sparks i { position: absolute; width: 5px; height: 5px; border-radius: 50%; background: #ffd84d; box-shadow: 0 0 8px #ff8a3d; animation: msSpark .42s ease-out forwards; }
@keyframes msSpark { to { transform: translate(var(--x), var(--y)); opacity: 0; } }
.ms-heat { left: 14cqw; top: 92cqw; width: 40cqw; height: 9px; border-radius: 9px; background: rgba(255,255,255,.15); overflow: hidden; }
.ms-heat s { display: block; height: 100%; background: linear-gradient(90deg, #ff8a3d, #ffe14d); transform-origin: left; transform: scaleX(0); transition: transform .08s; }
.ms-candle { left: 6cqw; top: 2cqw; width: 88cqw; border-radius: 18px; opacity: 0; box-shadow: 0 14px 40px rgba(0,0,0,.6); }
.ms-target { left: 51.7cqw; top: 20.2cqw; width: 15cqw; height: 15cqw; transform: translate(-50%, -50%); opacity: 0; z-index: 2; }
.ms-target svg { width: 100%; height: 100%; rotate: -90deg; overflow: visible; }
.ms-target circle { fill: none; stroke: rgba(255,255,255,.55); stroke-width: 2.4; stroke-dasharray: 4 4; }
.ms-target circle.p { stroke: #ffb34d; stroke-width: 4; stroke-linecap: round; transition: stroke-dashoffset .1s linear; }
.ms-box, .ms-heat, .ms-sparks { opacity: 0; }
.mission[data-step="1"] .ms-box, .mission[data-step="1"] .ms-heat, .mission[data-step="1"] .ms-sparks { opacity: 1; }
.mission[data-step="2"] .ms-candle.off { opacity: 1; }
.mission[data-step="2"] .ms-target { opacity: 1; animation: msPulse 1s ease-in-out infinite alternate; }
.mission[data-step="2"] .ms-stick { left: 72cqw; top: 63.5cqw; rotate: 0deg; }
.mission.near .ms-target { animation: none; filter: drop-shadow(0 0 10px #ffb34d); }
.mission.candle-lit .ms-candle.on { opacity: 1; }
.mission.candle-lit .ms-stick, .mission.candle-lit .ms-target { opacity: 0; }
.mission[data-step="3"] .ms-stick { opacity: 0; }
@keyframes msPulse { to { transform: translate(-50%, -50%) scale(1.12); } }
@keyframes msPull { 0%, 100% { transform: translateY(-6px); } 50% { transform: translateY(10px); } }
.ms-cta { position: absolute; left: 50%; bottom: calc(34px + var(--safe-b)); transform: translateX(-50%); white-space: nowrap; pointer-events: none;
  font: 600 15px/1 var(--sans); color: #fff; background: rgba(0,0,0,.45); border: 1px solid rgba(255,255,255,.2); padding: 12px 18px; border-radius: 99px; }
.ms-cta:empty { display: none; }
.ms-cta b { color: #ffd84d; }
.ms-cta.in { animation: msCta 1.6s ease-in-out infinite; }
@keyframes msCta { 0%, 100% { opacity: .75; } 50% { opacity: 1; } }
.ms-dark { position: absolute; inset: 0; background: #000; opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 5; }
.ms-flash { position: absolute; left: 0; right: 0; top: 46%; text-align: center; font: 900 46px/1 var(--sans); color: #ffd84d; opacity: 0; pointer-events: none; z-index: 6;
  text-shadow: 0 4px 24px rgba(0,0,0,.7); }
.ms-flash.show { animation: msFlash .9s ease both; }
.ms-flash.good.show, .ms-flash.bad.show { animation: msFlashStay .5s cubic-bezier(.3,1.6,.5,1) both; }
.ms-flash.bad { color: #ff5a4a; }
@keyframes msFlash { 0% { opacity: 0; transform: scale(.6); } 25% { opacity: 1; transform: scale(1.05); } 70% { opacity: 1; transform: none; } 100% { opacity: 0; transform: scale(1.1); } }
@keyframes msFlashStay { from { opacity: 0; transform: scale(.5); } to { opacity: 1; transform: none; } }
.mission.fail .ms-play { animation: msShake .4s ease; filter: grayscale(.6) brightness(.7); }
@keyframes msShake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }

/* ── 폴라로이드 엔딩 ── */
.pola-intro { position: absolute; inset: 0; z-index: 4; cursor: pointer; transition: opacity .45s; display: grid; place-items: center; }
.pola-intro.leave { opacity: 0; }
.pi-flash { position: absolute; inset: 0; background: #fff; opacity: 0; animation: piFlash .6s ease-out both; }
@keyframes piFlash { 0% { opacity: .85; } 100% { opacity: 0; } }
.pi-photo { position: relative; width: min(82cqw, 360px); rotate: -2deg; filter: drop-shadow(0 16px 30px rgba(0,0,0,.55));
  animation: piIn .45s cubic-bezier(.2,1.2,.4,1) both; }
.pi-photo img { display: block; width: 100%; }
/* 찍힌 직후 프레임 안은 어둡게(살짝 흐림) → 1.5초 동안 서서히 밝아지며 사진이 드러남 */
.pi-dev { position: absolute; left: 6.7%; top: 8.36%; width: 71.2%; height: 84.36%; background: url(../media/images/alone/pola_blur.jpg) center / 100% 100%; opacity: .96;
  animation: piDev 1.5s cubic-bezier(.3,.1,.4,1) .15s forwards; }
@keyframes piIn { from { opacity: 0; transform: translateY(16px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes piDev { from { opacity: .96; } to { opacity: 0; } }
.pola-intro.skip .pi-dev { animation: none; opacity: 0; transition: opacity .3s; }
.pola-intro.flying .pi-flash { display: none; }
.pola-intro.flying .pi-dev { animation: none; opacity: 0; }
.pola-intro.flying .pi-photo { animation: none; }
/* 사진이 날아가 앉는 동안: 그림 자리는 움직이지 않게(위로 올라오는 효과 없이), 나머지는 서서히 */
#ending .pola-fly .end-head { animation: none; }
#ending .pola-fly .end-head > :not(.end-art) { animation: endFade .6s .35s both; }
@keyframes endFade { from { opacity: 0; } to { opacity: 1; } }
#ending .end-art.polaroid { width: min(66%, 270px); aspect-ratio: 860 / 710; rotate: -3deg; filter: drop-shadow(0 12px 24px rgba(0,0,0,.55)); }

/* ── 영상 위 문자 알림 + 긴급상황 답장 (원빈) ── */
.cnoti { position: absolute; inset: 0; z-index: 13; pointer-events: none; }
.cnoti .cn { position: absolute; left: 10px; right: 10px; top: calc(var(--safe-t) + 10px); z-index: 3; display: flex; gap: 11px; align-items: center;
  padding: 11px 13px; border-radius: 20px; color: #fff; background: rgba(40, 40, 46, .86); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  box-shadow: 0 8px 30px rgba(0,0,0,.45); opacity: 0; transform: translateY(-120%); transition: transform .45s cubic-bezier(.2,1.1,.4,1), opacity .3s; }
.cnoti .cn.in { opacity: 1; transform: none; }
.cnoti .cn.old { z-index: 2; transform: translateY(9px) scale(.94); opacity: .55; }
.cnoti .cn p { margin: 2px 0 0; font: 400 15px/1.35 -apple-system, var(--sans); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cnoti .cn.hot { pointer-events: auto; cursor: pointer; box-shadow: 0 0 0 3px #ff4b3e, 0 0 40px rgba(255,75,62,.6); animation: urHot .6s ease-in-out infinite alternate; }
@keyframes urHot { to { box-shadow: 0 0 0 5px #ff4b3e, 0 0 60px rgba(255,75,62,.85); } }
.ur-ov { position: absolute; inset: 0; z-index: 1; background: rgba(0,0,0,.72); display: grid; place-items: center; pointer-events: auto; animation: mashIn .25s ease both; }
.ur-box { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 0 26px; text-align: center; }
.ur-tag { font: 900 15px/1 var(--sans); letter-spacing: .08em; color: #fff; background: #ff3b30; padding: 9px 16px; border-radius: 99px; animation: urBlink .45s steps(2) infinite; }
@keyframes urBlink { 50% { background: #b3150c; } }
.ur-box p { margin: 0; font: 800 22px/1.35 var(--sans); color: #fff; word-break: keep-all; }
.ur-box small { font: 500 14px/1 var(--sans); color: rgba(255,255,255,.7); }
.ur-bar, .ur-time { width: min(70cqw, 280px); height: 8px; border-radius: 9px; background: rgba(255,255,255,.18); overflow: hidden; }
.ur-bar s, .ur-time s { display: block; height: 100%; background: #ff4b3e; transform-origin: left; }
#stage.urgent .cnoti .cn.old { opacity: 0; }
.cnoti.late .ur-ov { background: rgba(0,0,0,.85); }
/* 답장 화면: 문서 위에 고정 (키보드 올라오면 보이는 영역에 맞춤) */
.ur-sheet { position: fixed; left: 0; right: 0; top: 0; height: 100%; z-index: 50; display: flex; flex-direction: column; background: #000; color: #fff;
  font-family: -apple-system, var(--sans); opacity: 0; pointer-events: none; transform: translateY(14px); transition: opacity .18s, transform .18s; }
.ur-sheet.open { opacity: 1; pointer-events: auto; transform: none; }
.ur-sheet .ur-time { width: auto; margin: calc(var(--safe-t) + 8px) 14px 0; height: 5px; }
.ur-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid rgba(255,255,255,.1); }
.ur-head .back svg { width: 24px; height: 24px; color: #0a84ff; }
.ur-head .m-av { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-size: 15px; background: linear-gradient(#9aa0ab, #6b707a); }
.ur-head b { font: 600 16px/1 -apple-system, var(--sans); }
.ur-body { flex: 1; min-height: 0; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; gap: 4px; padding: 10px 12px; }
.ur-b { display: flex; }
.ur-b span { max-width: 75%; padding: 8px 13px; border-radius: 18px; font: 400 16px/1.3 -apple-system, var(--sans); background: #26252a; }
.ur-b.me { justify-content: flex-end; }
.ur-b.me span { background: #0a84ff; }
.ur-b.pop { animation: mashIn .25s ease both; }
.ur-input { display: flex; align-items: center; gap: 8px; padding: 8px 10px calc(8px + var(--safe-b)); margin: 0; }
.ur-input .plus { width: 32px; height: 32px; border-radius: 50%; background: #26252a; display: grid; place-items: center; flex: none; }
.ur-input .plus svg { width: 18px; height: 18px; color: #aaa; }
.ur-input .field { flex: 1; display: flex; align-items: center; border: 1px solid rgba(255,255,255,.22); border-radius: 20px; padding: 3px 3px 3px 14px; }
.ur-input input { flex: 1; min-width: 0; background: none; border: 0; outline: 0; color: #fff; font: 400 16px/1.4 -apple-system, var(--sans); padding: 5px 0; }
.ur-input input::placeholder { color: rgba(255,255,255,.4); }
.ur-input .send { flex: none; width: 30px; height: 30px; border-radius: 50%; border: 0; padding: 0; display: grid; place-items: center; background: #0a84ff; opacity: .35; transition: opacity .15s; }
.ur-input .send svg { width: 17px; height: 17px; color: #fff; }
.ur-sheet.typed .send { opacity: 1; }
.ur-sheet.wrong .field { animation: msShake .35s ease; border-color: #ff4b3e; }
.ur-sheet.late::after { content: '시간 초과…'; position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,.8); font: 800 26px/1 var(--sans); color: #fff; }
/* 키보드가 내려가는 동안 답장 화면 아래로 뒤 화면이 비치지 않게 검정으로 채움 */
.ur-sheet { box-shadow: 0 0 0 100vmax #000; }
.ur-sheet:not(.open) { box-shadow: none; }

/* 미션 수정: 3단계 스위치 사진 화면 가득 / 2단계 성냥 들면 대각선 / 불 끄면 확실히 어둡게 */
.ms-sw { position: absolute; inset: 0; opacity: 0; transition: opacity .3s; pointer-events: none; }
.ms-sw img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ms-sw .down { opacity: 0; }
.ms-sw::after { content: ''; position: absolute; inset: 0; background: linear-gradient(rgba(0,0,0,.6), rgba(0,0,0,0) 32%, rgba(0,0,0,0) 78%, rgba(0,0,0,.55)); }
.mission[data-step="3"] .ms-sw { opacity: 1; }
.mission[data-step="3"] .ms-play { pointer-events: none; opacity: 0; transition: opacity .25s; }
.mission.off .ms-sw .up { opacity: 0; }
.mission.off .ms-sw .down { opacity: 1; }
.ms-pull { position: absolute; font: 900 40px/1 var(--sans); color: #fff; font-style: normal; opacity: 0; z-index: 3; pointer-events: none;
  text-shadow: 0 0 6px #000, 0 0 16px rgba(255,140,40,.95); translate: 0 var(--dy, 0); }
/* 3단계 화살표 안내는 뺌 (.ms-pull 안 보임) */
.mission.off .ms-pull { opacity: 0; animation: none; }
.mission[data-step="2"] .ms-stick { transform-origin: 50% -4.5cqw; }
.mission.held .ms-stick { rotate: -50deg; }
.mission.off .ms-dark { opacity: .82; transition: opacity .12s; }
.mission.dark .ms-dark { opacity: .82; }
.ur-b.typing span { display: flex; gap: 4px; padding: 12px 14px; }
.ur-b.typing i { width: 7px; height: 7px; border-radius: 50%; background: rgba(255,255,255,.45); animation: urDot 1s infinite; }
.ur-b.typing i:nth-child(2) { animation-delay: .15s; } .ur-b.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes urDot { 0%, 60%, 100% { opacity: .35; } 30% { opacity: 1; } }
.ur-sheet.sent .ur-time { visibility: hidden; }
/* 원빈 답장 입력: 타자연습식 (진짜 입력 글자는 숨기고 위에 색으로 그림) */
.ur-input .field { position: relative; }
.ur-ghost { position: absolute; left: 14px; right: 40px; top: 50%; transform: translateY(-50%); pointer-events: none; white-space: pre; overflow: hidden;
  font: 400 16px/1.4 -apple-system, var(--sans); }
.ur-ghost i { font-style: normal; }
.ur-ghost .g { color: rgba(255,255,255,.35); }
.ur-ghost .t { color: #fff; }
.ur-ghost .x { color: #ff4b3e; background: rgba(255,75,62,.18); border-radius: 3px; }
.ur-input input { color: transparent; -webkit-text-fill-color: transparent; caret-color: #0a84ff; position: relative; }
.ur-sheet.sent .ur-ghost { visibility: hidden; }
.c-timer.quick { animation: none; font-size: 13px; color: #ff5d6c; margin-bottom: 4px; }
.c-timer.quick i { height: 8px; border-radius: 8px; }
.c-timer.quick i::after { background: #ff5d6c; }
#choices.timeout .opt { opacity: .35; }
.ur-body { position: relative; overflow: hidden; touch-action: none; }
.ur-in { position: absolute; left: 12px; right: 12px; bottom: 10px; display: flex; flex-direction: column; gap: 4px; }
.ur-b span img { display: block; max-width: 160px; border-radius: 12px; }
/* 엔딩에서 '다시 하기'로 온 경우 그 엔딩 위치 강조 */
.r-node.card.focus { outline: 3px solid var(--accent); outline-offset: 4px; animation: rFocus 1.2s ease-in-out 3; }
@keyframes rFocus { 50% { outline-offset: 9px; outline-color: rgba(var(--accent-rgb), .4); } }
.r-node.card.ending { cursor: default; }
/* 루트 글씨·칸: 화면 폭에 비례 (좁은 폰에서도 390px 기준 배치 그대로 → 겹침 없음). 넓은 화면에선 기존 크기 유지 */
.r-chip { font-size: min(11px, 2.82cqw); padding: min(5px, 1.28cqw) min(9px, 2.3cqw); }
.r-label { font-size: min(11px, 2.82cqw); padding: min(5px, 1.28cqw) min(10px, 2.56cqw); }
.r-node.card { gap: min(6px, 1.54cqw); }
.r-node.small { gap: min(5px, 1.28cqw); }
.r-node.small i { width: min(40px, 10.25cqw); height: min(40px, 10.25cqw); font-size: min(13px, 3.33cqw); }
.r-node.small span { font-size: min(10px, 2.56cqw); }
.r-play { width: min(30px, 7.7cqw); height: min(30px, 7.7cqw); font-size: min(30px, 7.7cqw); }
/* 초에 불 붙이기: 진행 원(채워지는 링)은 빼고 점선 원만 */
.ms-target circle.p { display: none; }
/* 가로형 루트 미리보기 (?route=h) */
.r-chip.h.tree { transform: translate(-100%, -50%); }
.r-chip.h.mid { transform: translate(-50%, -50%); z-index: 1; }
.r-chip.h.mid { transform: translate(0, -50%); }
/* 남겨진 한마디 ↔ 엔딩 화면 전환: 덜컥거림 없이 살짝 사라졌다 나타남 */
#ending .settled .end-head, #ending .settled .end-actions, #ending .settled h1, #ending .settled .end-desc, #ending .settled .end-art { animation: none; }
#ending .end-head, #ending .end-main, #ending .end-actions, #ending .voice-panel, #ending .vc-stop { transition: opacity .28s ease, transform .5s cubic-bezier(.2,.8,.2,1); }
#ending .end-card.swap .end-head, #ending .end-card.swap .end-main, #ending .end-card.swap .end-actions,
#ending .end-card.swap .voice-panel, #ending .end-card.swap .vc-stop { opacity: 0 !important; transition: opacity .18s ease !important; }
#ending .listening .end-head { opacity: 0; }
#ending .listening .end-main { transition: opacity .28s ease; }

/* 제작자 크레딧: 메인 · 스토리 루트 · 엔딩 화면 오른쪽 위 */
.credit { position: absolute; z-index: 9; right: 16px; top: calc(16px + var(--safe-t)); font: 600 10.5px/1 var(--mono); letter-spacing: .05em; color: rgba(255,255,255,.4); pointer-events: none; white-space: nowrap; }
#route .credit { top: calc(11px + var(--safe-t)); right: 20px; }   /* 엔딩/선택지 숫자 위로 살짝 띄움 */

/* 언어 선택 (메인 화면 작은 밑줄 글씨 → 팝업) */
#title .t-langlink { align-self: center; margin-bottom: 2px; padding: 4px 8px; background: none; border: 0; font: 500 12px/1.2 var(--sans); color: rgba(255,255,255,.55); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.lang-modal { position: fixed; inset: 0; z-index: 9999; display: grid; place-items: center; padding: 24px; background: rgba(0,0,0,.6); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); animation: fadeIn .2s ease both; }
.lang-modal .lm-box { position: relative; width: min(100%, 340px); padding: 22px 16px 16px; border-radius: 20px; background: #17120f; border: 1px solid rgba(255,255,255,.1); box-shadow: 0 20px 60px rgba(0,0,0,.6); display: flex; flex-direction: column; gap: 8px; }
.lang-modal .lm-head { margin: 0 36px 6px 4px; font: 700 14px/1.6 var(--sans); color: rgba(255,255,255,.8); }
.lang-modal .lm-opt { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; padding: 12px 14px; border-radius: 12px; background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.08); color: #fff; text-align: left; cursor: pointer; }
.lang-modal .lm-opt b { font: 700 15px/1.2 var(--sans); }
.lang-modal .lm-opt small { font: 500 11px/1.4 var(--sans); color: rgba(255,255,255,.45); }
.lang-modal .lm-opt.on { border-color: var(--accent); background: rgba(var(--accent-rgb), .12); }
.lang-modal .lm-ko { align-items: center; padding: 9px; background: none; border-color: transparent; }
.lang-modal .lm-ko b { font-size: 13px; font-weight: 600; color: rgba(255,255,255,.6); }
.lang-modal .lm-ko.on b { color: var(--accent); }
.lang-modal .lm-x { position: absolute; top: 10px; right: 10px; width: 30px; height: 30px; border-radius: 50%; background: rgba(255,255,255,.08); border: 0; color: rgba(255,255,255,.7); font-size: 13px; cursor: pointer; }
/* 일본어·중국어: keep-all 이면 줄바꿈이 안 돼서 화면 밖으로 넘침 */
html[data-lang="ja"] body *, html[data-lang="zh"] body * { word-break: normal !important; line-break: strict; }
