:root{
  --ink:#efe9e2; --box:rgba(14,12,11,.86); --accent:#c9a36a; --accent-2:#8fb0c9;
  --radius:12px; --pad:clamp(14px,3vw,22px);
}
*{box-sizing:border-box;margin:0}
html,body{height:100%}
body{
  background:#0a0908; color:var(--ink); overflow:hidden;
  font-family:"Pretendard","Apple SD Gothic Neo","Malgun Gothic",system-ui,sans-serif;
  -webkit-tap-highlight-color:transparent;
  display:flex; align-items:center; justify-content:center;
}
/* 기준 화면비는 16:9 (가로). 1차작과 다르다 — 이 작품은 패널 그림이 주인공이라
   세로로 자르면 구도가 죽는다. 폰은 가로로 돌려도 되고 세로에서는 위아래 여백이 생긴다. */
#stage{
  position:relative; overflow:hidden; margin:0 auto;
  width:min(100vw, calc(100dvh * 16 / 9));
  height:min(100dvh, calc(100vw * 9 / 16));
  box-shadow:0 0 60px rgba(0,0,0,.7);
  /* 세로 폰에서는 무대가 화면 높이(dvh)보다 훨씬 낮은 16:9 띠가 된다.
     안의 글자 크기를 vh 로 재면 그 실제 높이를 넘어가 위쪽이 잘린다(겪었음).
     컨테이너 쿼리로 무대 자신의 높이(cqh)를 기준 삼는다. */
  container-type: size;
}
/* 화면이 무대보다 넓으면 여백이 '잘린 화면'이 아니라 틀로 보이게 한다.
   vw 는 여기 말고 무대 안에서는 절대 쓰지 않는다 — 무대 폭과 창 폭이 다르기 때문에
   안에서 vw 를 쓰면 무대 밖으로 삐져나가 overflow:hidden 에 잘린다(1차작에서 겪음). */
@media (min-aspect-ratio: 16/9){
  body{background:radial-gradient(85% 60% at 50% 0%, #17140f 0%, #070605 72%)}
  #stage{border-radius:18px; border:1px solid rgba(255,255,255,.08)}
}

#bg,#sprite{position:absolute; user-select:none; -webkit-user-drag:none;
  pointer-events:none; transition:opacity .5s ease}
#bg{inset:0; width:100%; height:100%; object-fit:cover; filter:brightness(.7) saturate(.92)}
#sprite{bottom:0; left:50%; transform:translateX(-50%); height:min(82%, 82cqh);
  max-width:52%; object-fit:contain; object-position:bottom;
  filter:drop-shadow(0 8px 30px rgba(0,0,0,.7))}
.hidden{display:none !important}

#hud{position:absolute; top:calc(10px + env(safe-area-inset-top)); right:12px; z-index:5}
#sound-toggle{background:rgba(0,0,0,.4); border:0; color:var(--ink); font-size:15px;
  padding:6px 12px; border-radius:999px; cursor:pointer; backdrop-filter:blur(6px)}
#sound-toggle.off{opacity:.4}

#panels{position:absolute; left:var(--pad); right:var(--pad);
  bottom:calc(var(--pad) + env(safe-area-inset-bottom));
  display:flex; flex-direction:column; gap:10px; max-height:72cqh}

/* narr — 쉰둘의 목소리. 기억 안의 말과 반드시 구분되어 보여야 한다.
   대사창이 아니라 화면 가운데에 얹히고, 글꼴도 색도 다르다. */
#narr{position:absolute; inset:0; z-index:4; display:flex; align-items:center;
  justify-content:center; padding:8% 12%; pointer-events:none;
  background:linear-gradient(180deg, rgba(8,7,6,.55), rgba(8,7,6,.78));
  font-family:"Nanum Myeongjo","Batang",serif; font-style:italic;
  font-size:clamp(17px,2.7cqh,26px); line-height:2; letter-spacing:.01em;
  color:#d9cfc2; text-align:center; word-break:keep-all; white-space:pre-wrap}

#box{position:relative; background:var(--box); border:1px solid rgba(255,255,255,.1);
  border-radius:var(--radius); padding:22px 22px 24px; min-height:20cqh;
  cursor:pointer; backdrop-filter:blur(10px)}
#speaker{position:absolute; top:-13px; left:18px; background:var(--accent); color:#17120c;
  font-weight:700; font-size:13px; padding:4px 13px; border-radius:999px}
#text{font-size:clamp(15px,2.1cqh,19px); line-height:1.9; white-space:pre-wrap;
  word-break:keep-all}
#cursor{position:absolute; right:16px; bottom:8px; color:var(--accent);
  animation:blink 1.1s infinite}
@keyframes blink{50%{opacity:.15}}

.panel-tag{font-size:12px; font-weight:700; letter-spacing:.04em;
  color:rgba(255,255,255,.5); margin-bottom:8px}
#choicebox,#scorebox{background:var(--box); border:1px solid rgba(255,255,255,.1);
  border-radius:var(--radius); padding:18px 20px 20px; backdrop-filter:blur(10px)}
#choice-text,#score-text{font-size:clamp(14px,2cqh,18px); line-height:1.8;
  margin-bottom:12px; word-break:keep-all; white-space:pre-wrap}
#choices{display:grid; gap:8px}
button{font:inherit; cursor:pointer; border:0; border-radius:10px; padding:12px 15px;
  background:rgba(255,255,255,.08); color:var(--ink); text-align:left; transition:.15s}
button:hover{background:rgba(201,163,106,.26)}
button:active{transform:scale(.985)}
button:disabled{opacity:.45; cursor:default}
/* 대화상자보다 밝게 띄워서 '읽는 것'이 아니라 '누르는 것'으로 보이게 한다. */
#choices button{background:rgba(201,163,106,.10); border:1px solid rgba(201,163,106,.3);
  display:flex; gap:10px; align-items:flex-start; line-height:1.55; word-break:keep-all}
#choices .num{flex:none; width:22px; height:22px; border-radius:7px; margin-top:1px;
  display:grid; place-items:center; font-size:12px; font-weight:800;
  background:var(--accent); color:#17120c}

/* 악보 — 유일한 판매 지점. 상점처럼 보이면 안 된다. */
#score-card{display:flex; gap:14px; align-items:center; flex-wrap:wrap;
  background:rgba(255,255,255,.05); border:1px solid rgba(255,255,255,.12);
  border-radius:10px; padding:12px 14px}
#score-preview{flex:1 1 200px; min-height:56px; border-radius:6px;
  background:rgba(255,255,255,.9); display:grid; place-items:center;
  color:#6b6259; font-size:12px; overflow:hidden}
#score-preview img,#score-preview svg{width:100%; height:auto; display:block}
#score-meta{flex:1 1 140px; display:flex; flex-direction:column; gap:3px}
#score-meta strong{font-size:15px}
#score-meta span{font-size:12px; color:rgba(255,255,255,.55)}
#score-actions{flex:0 0 auto; display:flex; gap:8px; flex-wrap:wrap}
#score-actions button{background:var(--accent); color:#17120c; font-weight:700;
  text-align:center; padding:11px 18px}
#score-actions button.own{background:rgba(255,255,255,.1); color:var(--ink)}
.ghost{background:none; color:rgba(255,255,255,.5); padding:8px 0; font-size:13px}

#title-screen,#ending{position:absolute; inset:0; z-index:7; display:flex;
  flex-direction:column; align-items:center; justify-content:center; gap:12px;
  text-align:center; padding:24px;
  background:radial-gradient(120% 90% at 50% 15%, #241d16 0%, #0a0908 70%)}
#title-screen h1{font-family:"Nanum Myeongjo","Batang",serif;
  font-size:clamp(20px,5.4cqh,44px); line-height:1.4; font-weight:700}
#title-screen h1 em{color:var(--accent); font-style:normal}
.sub{color:rgba(255,255,255,.5); font-size:14px; margin-bottom:6px}
.foot{color:rgba(255,255,255,.35); font-size:12px; margin-top:4px}
#track-list{display:grid; grid-template-columns:repeat(auto-fill, minmax(160px,1fr));
  gap:8px; width:100%; max-width:640px; max-height:46cqh; overflow-y:auto; padding:4px}
#track-list button{background:rgba(255,255,255,.07);
  border:1px solid rgba(255,255,255,.14); font-weight:600; font-size:13px;
  padding:11px 13px; line-height:1.45; display:flex; gap:9px; align-items:baseline}
#track-list button:hover{background:rgba(201,163,106,.22); border-color:var(--accent)}
#track-list .no{color:var(--accent); font-weight:800; font-size:11px; flex:0 0 auto}

#ending{background:rgba(10,9,8,.94)}
#ending .ending-no{color:var(--accent); font-size:12px; letter-spacing:.1em}
#ending h2{font-family:"Nanum Myeongjo","Batang",serif; font-size:clamp(19px,3.4cqh,30px);
  line-height:1.5}
#ending-line{color:rgba(255,255,255,.66); font-size:clamp(13px,2cqh,16px); line-height:1.9;
  max-width:26em; word-break:keep-all}
.ending-actions{display:flex; gap:10px; flex-wrap:wrap; justify-content:center;
  margin-top:8px}
.ending-actions button{background:var(--accent); color:#17120c; font-weight:700;
  padding:12px 26px; border-radius:999px; text-align:center}
.ending-actions .ghost-btn{background:rgba(255,255,255,.1); color:var(--ink)}

#toast{position:absolute; top:12%; left:50%; transform:translateX(-50%); z-index:8;
  background:rgba(20,17,14,.94); border:1px solid rgba(255,255,255,.18);
  padding:10px 18px; border-radius:999px; font-size:14px; white-space:nowrap;
  backdrop-filter:blur(8px)}
