/* ── 최후의 세레나데 — 기본 스타일 (모바일 세로 기준) ───────────── */

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  background: #050308;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", sans-serif;
  color: #f2ede6;
}

#frame {
  height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: stretch;
}

#stage {
  position: relative;
  width: min(100vw, 56dvh);   /* 데스크톱에서는 세로폰 비율로 중앙 정렬 */
  max-width: 520px;
  height: 100dvh;
  overflow: hidden;
  background: #000;
  cursor: pointer;
}

/* ── 배경 ── */
#bg-layer .bg {
  position: absolute; inset: 0;
  opacity: 0;
  transition: opacity 1.1s ease;
  background-size: cover;
  background-position: center;
}
#bg-layer .bg.visible { opacity: 1; }

/* ── 캐릭터 ── */
#char-layer {
  position: absolute; inset: 0;
  pointer-events: none;
}
.char {
  position: absolute;
  bottom: 24dvh;
  width: 34%;
  opacity: 0;
  transition: opacity .7s ease, transform .7s ease;
  transform: translateY(12px);
  filter: drop-shadow(0 6px 18px rgba(0,0,0,.45));
}
.char.visible { opacity: 1; transform: translateY(0); animation: charFloat 5s ease-in-out infinite; }
.char.pos-left  { left: 6%; }
.char.pos-right { right: 6%; }
.char.pos-center { left: 50%; margin-left: -17%; }
.char svg { width: 100%; height: auto; display: block; }
@keyframes charFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

/* ── 효과 ── */
#fx-heat {
  position: absolute; inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 2s ease;
  background:
    radial-gradient(ellipse at 50% 100%, rgba(255,110,40,.22), transparent 55%),
    radial-gradient(ellipse at 50% 0%, rgba(255,170,60,.10), transparent 50%);
  mix-blend-mode: screen;
}
#fx-heat.on { opacity: 1; animation: heatPulse 4.5s ease-in-out infinite; }
@keyframes heatPulse {
  0%, 100% { opacity: .55; }
  50% { opacity: 1; }
}
#fx-flash {
  position: absolute; inset: 0;
  pointer-events: none;
  background: #fff;
  opacity: 0;
}
#fx-flash.go { animation: flashAnim .5s ease-out; }
@keyframes flashAnim { 0% { opacity: .9; } 100% { opacity: 0; } }
@keyframes shakeAnim {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(7px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(3px); }
}
#stage.shake { animation: shakeAnim .45s ease; }

/* ── 대사창 ── */
#dialog {
  position: absolute;
  left: 3.5%; right: 3.5%;
  bottom: max(env(safe-area-inset-bottom), 14px);
  min-height: 21dvh;
  padding: 16px 18px 26px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(14,8,16,.78), rgba(10,6,12,.9));
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,.09);
  opacity: 0;
  transition: opacity .4s ease;
}
#dialog.visible { opacity: 1; }
#name-plate {
  display: none;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: .04em;
  margin-bottom: 8px;
}
#name-plate.visible { display: block; }
#text-box {
  font-size: 16.5px;
  line-height: 1.75;
  letter-spacing: .01em;
  word-break: keep-all;
  min-height: 3.4em;
}
#text-box.narration { color: #cfc6bd; font-size: 15.5px; }
#next-hint {
  position: absolute;
  right: 18px; bottom: 10px;
  font-size: 11px;
  color: rgba(255,255,255,.65);
  opacity: 0;
}
#next-hint.visible { opacity: 1; animation: hintBlink 1.2s ease-in-out infinite; }
@keyframes hintBlink {
  0%, 100% { transform: translateY(0); opacity: .9; }
  50% { transform: translateY(3px); opacity: .35; }
}

/* ── 선택지 ── */
#choice-layer {
  position: absolute; inset: 0;
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 14px;
  padding: 0 8%;
  background: rgba(5,3,8,.45);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
#choice-layer.visible { display: flex; }
.choice-btn {
  width: 100%;
  padding: 15px 18px;
  font-size: 15.5px;
  font-family: inherit;
  color: #f6f1e8;
  word-break: keep-all;
  background: linear-gradient(180deg, rgba(50,32,48,.92), rgba(30,18,32,.92));
  border: 1px solid rgba(255,180,110,.35);
  border-radius: 14px;
  cursor: pointer;
  transition: transform .15s ease, border-color .15s ease;
}
.choice-btn:active { transform: scale(.97); border-color: rgba(255,200,140,.8); }

/* ── 영상 ── */
#video-layer {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  display: none;
  background: #000;
}
#video-layer.visible { display: block; }
#video-placeholder {
  position: absolute; inset: 0;
  display: none;
  justify-content: center;
  align-items: center;
  background: radial-gradient(circle at 50% 45%, #1c1026, #070409 75%);
}
#video-placeholder.visible { display: flex; }
.vp-card { text-align: center; padding: 0 10%; }
.vp-icon {
  width: 64px; height: 64px;
  margin: 0 auto 18px;
  border: 2px solid rgba(255,255,255,.45);
  border-radius: 50%;
  display: flex; justify-content: center; align-items: center;
  font-size: 20px; color: rgba(255,255,255,.8);
}
.vp-caption { font-size: 17px; font-weight: 600; margin-bottom: 10px; }
.vp-note { font-size: 12.5px; color: rgba(255,255,255,.5); }

/* ── 타이틀 카드 (챕터 제목 연출) ── */
#title-card {
  position: absolute; inset: 0;
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 16px;
  text-align: center;
  background: rgba(4,2,6,.88);
  opacity: 0;
  transition: opacity 1.4s ease;
}
#title-card.visible { display: flex; }
#title-card.shown { opacity: 1; }
.tc-main {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: .12em;
  line-height: 1.5;
  background: linear-gradient(180deg, #ffe8c8, #f5a95c);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.tc-sub { font-size: 13.5px; color: #b8aca2; letter-spacing: .08em; }

/* ── 엔드 카드 ── */
#end-card {
  position: absolute; inset: 0;
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 30px;
  background: rgba(4,2,6,.92);
  text-align: center;
  padding: 0 10%;
}
#end-card.visible { display: flex; }
.ec-text { font-size: 16px; line-height: 2; color: #ded5ca; word-break: keep-all; }
#ec-home {
  padding: 13px 34px;
  font-size: 15px;
  font-family: inherit;
  color: #ffe6c4;
  background: transparent;
  border: 1px solid rgba(255,200,140,.55);
  border-radius: 999px;
  cursor: pointer;
}
#ec-home:active { background: rgba(255,200,140,.12); }

/* ── 타이틀 화면 ── */
#title-screen {
  position: absolute; inset: 0;
  display: none;
  z-index: 20;
}
#title-screen.visible { display: block; }
.ts-sky {
  position: absolute; inset: 0;
  background:
    radial-gradient(circle at 50% 66%, rgba(255,205,130,.85), rgba(255,132,72,.4) 26%, transparent 48%),
    linear-gradient(180deg, #170f2e 0%, #4b1f44 30%, #a33a48 55%, #e07a45 74%, #f4b063 84%, #241521 84.5%, #120a12 100%);
  animation: skyBreath 9s ease-in-out infinite;
}
@keyframes skyBreath {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.12); }
}
.ts-body {
  position: absolute; inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding-bottom: 6dvh;
}
.ts-sub {
  font-size: 13px;
  letter-spacing: .3em;
  color: rgba(255,240,220,.85);
  margin-bottom: 14px;
  text-shadow: 0 1px 8px rgba(0,0,0,.5);
}
.ts-title {
  font-size: 52px;
  font-weight: 900;
  line-height: 1.28;
  letter-spacing: .1em;
  text-align: center;
  color: #fff6e8;
  text-shadow: 0 2px 24px rgba(60,10,20,.65);
  margin-bottom: 7dvh;
}
.ts-buttons { display: flex; flex-direction: column; gap: 13px; width: 62%; max-width: 260px; }
.ts-buttons button {
  padding: 14px 0;
  font-size: 15.5px;
  font-family: inherit;
  font-weight: 600;
  color: #fff2df;
  background: rgba(20,10,18,.5);
  border: 1px solid rgba(255,225,180,.5);
  border-radius: 999px;
  cursor: pointer;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.ts-buttons button:active { background: rgba(255,220,170,.18); }
.ts-buttons button:disabled { opacity: .35; cursor: default; }
.ts-credit {
  position: absolute;
  bottom: max(env(safe-area-inset-bottom), 18px);
  font-size: 11px;
  letter-spacing: .22em;
  color: rgba(255,255,255,.55);
}
