/* ───────────────── 기본 ───────────────── */
:root {
  --blue: #2f5bb0;
  --blue-deep: #1f3f86;
  --navy: #1d2f5a;
  --red: #e2483b;
  --red-deep: #b9332a;
  --cream: #fff8ea;
  --paper: #fffdf6;
  --ink: #2a2a3a;
  --ink-soft: #55586a;
  --gold: #e7b44a;
  --font-cute: "Jua", "Gowun Dodum", system-ui, sans-serif;
  --font-body: "Gowun Dodum", system-ui, sans-serif;
  --font-title: "Single Day", "Jua", system-ui, sans-serif;
  --ease-pop: cubic-bezier(.34, 1.56, .64, 1);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: #f3e6c9;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 19px;
  line-height: 1.75;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 4px solid var(--gold); outline-offset: 3px; }

/* ───────────────── 버튼 ───────────────── */
.pill-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4em;
  border: 0; border-radius: 999px;
  padding: .55em 1.25em;
  font-family: var(--font-cute); font-size: 18px; line-height: 1.2;
  text-decoration: none; white-space: nowrap;
  transition: transform .2s var(--ease-pop), box-shadow .2s, background .2s;
}
.pill-btn:hover { transform: translateY(-2px); }
.pill-btn:active { transform: translateY(1px); }
.pill-btn.red  { background: var(--red);  color: #fff; box-shadow: 0 4px 0 var(--red-deep); }
.pill-btn.blue { background: var(--blue); color: #fff; box-shadow: 0 4px 0 var(--blue-deep); }
.pill-btn.line { background: #fff; color: var(--blue-deep); box-shadow: inset 0 0 0 2px var(--blue), 0 3px 0 var(--blue-deep); }
.pill-btn.big { font-size: 22px; padding: .65em 1.6em; }

/* ───────────────── 상단 바 ───────────────── */
.topbar {
  position: fixed; inset: 0 0 auto 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.icon-btn {
  width: 52px; height: 52px; border-radius: 50%;
  border: 0; background: rgba(255,255,255,.92);
  box-shadow: 0 3px 0 rgba(31,63,134,.35), 0 6px 18px rgba(0,0,0,.12);
  display: grid; place-items: center;
}
.burger { display: grid; gap: 5px; }
.burger i { display: block; width: 22px; height: 3px; border-radius: 2px; background: var(--blue-deep); }
.topbar-title {
  margin: 0; padding: 6px 20px; border-radius: 999px;
  background: var(--blue); color: #fff;
  font-family: var(--font-cute); font-size: 22px; letter-spacing: .02em;
  box-shadow: 0 3px 0 var(--blue-deep), 0 6px 18px rgba(0,0,0,.15);
  opacity: 0; transform: translateY(-8px); transition: .4s;
}
.topbar-title .sm { font-size: .72em; opacity: .85; }
.topbar-title.show { opacity: 1; transform: none; }
#topBookBtn { opacity: 0; pointer-events: none; transition: opacity .4s; }
#topBookBtn.show { opacity: 1; pointer-events: auto; }

/* ───────────────── 메뉴 ───────────────── */
.drawer {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(20, 30, 60, .35);
  animation: fadeIn .25s;
}
.drawer-panel {
  position: absolute; left: 0; top: 0; bottom: 0;
  width: min(340px, 86vw);
  background: var(--cream);
  padding: 84px 20px 24px;
  box-shadow: 8px 0 30px rgba(0,0,0,.18);
  display: flex; flex-direction: column;
  animation: slideIn .3s ease-out;
  border-right: 10px solid transparent;
  border-image: repeating-linear-gradient(-45deg, var(--red) 0 12px, var(--paper) 12px 20px, var(--blue) 20px 32px, var(--paper) 32px 40px) 10;
}
.drawer-head { font-family: var(--font-cute); font-size: 22px; color: var(--blue-deep); margin: 0 0 12px; }
.drawer ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.drawer li button {
  width: 100%; display: flex; align-items: center; gap: 14px;
  border: 0; background: transparent; border-radius: 14px;
  padding: 10px 12px; text-align: left;
  font-family: var(--font-cute); font-size: 21px; color: var(--ink);
}
.drawer li button:hover { background: #fff; }
.drawer li img { width: 44px; height: 44px; object-fit: contain; }
.drawer li img.round { border-radius: 50%; object-fit: cover; }
.drawer-out {
  margin-top: auto; border: 0; background: none; text-align: left;
  font-family: var(--font-cute); font-size: 18px; color: var(--blue-deep); padding: 12px;
}

/* ───────────────── 장면 / 무대 ───────────────── */
.scene { position: fixed; inset: 0; }
.viewport { position: absolute; inset: 0; overflow: hidden; background: #2b3a5c center / cover no-repeat; }
/* 창 비율이 16:9가 아닐 때 남는 가장자리: 미리 흐리게 만든 배경 그림으로 채움
   (실시간 blur 필터는 매 프레임 다시 계산돼 느려서 쓰지 않음) */
/* 가장자리 쪽은 살짝 어둡게(비네팅) 해서 가운데 그림이 또렷하게 보이게 */
#outside .viewport { background-image: radial-gradient(ellipse at center, transparent 35%, rgba(18, 28, 60, .38)), url("assets/bg-outside-blur.webp"); }
#inside .viewport { background-image: radial-gradient(ellipse at center, transparent 35%, rgba(18, 28, 60, .38)), url("assets/bg-inside-blur.webp"); }
.viewport::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  transition: background .7s;
}
#insideViewport.dark::before { background: rgba(8, 12, 36, .93); } /* 불 끄면 가장자리도 어둡게 */
/* 가로 화면: 그림 전체가 항상 보이도록 창 안에 '맞춤'(잘리지 않음) */
.stage {
  position: absolute; left: 50%; top: 50%;
  width: min(100vw, 177.69vh);
  height: min(100vh, 56.28vw);
  width: min(100vw, 177.69dvh);
  height: min(100dvh, 56.28vw);
  transform: translate(-50%, -50%);
  container-type: size;
  user-select: none;
  box-shadow: 0 0 60px rgba(10, 20, 50, .28);
}
.bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }

/* 장면 전환 */
.scene { transition: transform 1.1s cubic-bezier(.6,0,.3,1), opacity .5s; }
.scene.zoom-out-door { transform: scale(2.4); transform-origin: 10% 45%; }
.fade {
  position: fixed; inset: 0; z-index: 25; pointer-events: none;
  background: var(--cream); opacity: 0; transition: opacity .55s;
}
.fade.on { opacity: 1; }

/* ───────────────── 상호작용 물건 ───────────────── */
.hot {
  position: absolute; border: 0; padding: 0; background: none;
  -webkit-tap-highlight-color: transparent;
}
.hot.obj img { width: 100%; height: auto; pointer-events: none; transition: filter .2s, transform .35s var(--ease-pop); }
.hot.obj:hover img, .hot.obj:focus-visible img {
  filter:
    drop-shadow(3px 0 0 #fff) drop-shadow(-3px 0 0 #fff)
    drop-shadow(0 3px 0 #fff) drop-shadow(0 -3px 0 #fff)
    drop-shadow(0 10px 14px rgba(30, 50, 110, .35));
  transform: translateY(-4%) scale(1.04);
}
.hot.obj:focus-visible { outline: none; }

/* 말풍선 라벨 (참고 사이트의 호버 말풍선) */
.hot::after {
  content: attr(data-label);
  position: absolute; left: 50%; bottom: calc(100% + 1.1cqw);
  transform: translate(-50%, 6px) scale(.85);
  background: #fff; color: var(--blue-deep);
  font-family: var(--font-cute);
  font-size: clamp(15px, 1.25cqw, 24px);
  padding: .3em .9em; border-radius: 999px; white-space: nowrap;
  box-shadow: 0 3px 0 rgba(31,63,134,.25), 0 6px 16px rgba(0,0,0,.15);
  opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .25s var(--ease-pop);
  z-index: 5;
}
.hot::before {
  content: ""; position: absolute; left: 50%; bottom: calc(100% + 1.1cqw - 9px);
  width: 14px; height: 14px; background: #fff;
  transform: translateX(-50%) rotate(45deg); border-radius: 2px;
  opacity: 0; transition: opacity .2s; z-index: 5;
}
.hot[data-below]::after { bottom: auto; top: calc(100% + 1.1cqw); }
.hot[data-below]::before { bottom: auto; top: calc(100% + 1.1cqw - 6px); }
.hot:hover::after, .hot:focus-visible::after, .hot.peek::after { opacity: 1; transform: translate(-50%, 0) scale(1); }
.hot:hover::before, .hot:focus-visible::before, .hot.peek::before { opacity: 1; }

/* 배경 속 장소(창구·게시판·문) */
.hot.area { border-radius: 1.2cqw; transition: box-shadow .2s, background .2s; }
.hot.area:hover, .hot.area:focus-visible, .hot.area.peek {
  outline: none;
  box-shadow: 0 0 0 .3cqw #fff, 0 0 2cqw .4cqw rgba(255, 244, 200, .9);
  background: rgba(255, 255, 255, .14);
}

/* 반짝 표시: 누를 수 있다는 신호 */
.hot .sparkle {
  position: absolute; right: -4%; top: -6%;
  width: 1.6cqw; height: 1.6cqw; pointer-events: none;
  background: radial-gradient(circle, #fff 0 22%, rgba(255,240,170,.9) 23% 40%, transparent 60%);
  animation: twinkle 2.2s ease-in-out infinite;
}

/* 바깥 장면 위치 */
.door { left: 2.4%; top: 14.9%; width: 15.6%; height: 62%; }
.title-card {
  position: absolute; left: 53.5%; top: 27%;
  transform: translateX(-50%);
  width: 42%;
  text-align: center;
  padding: 2.2cqw 2cqw 1.8cqw;
  background: rgba(255, 252, 242, .9);
  border-radius: 2.2cqw;
  box-shadow: 0 .5cqw 0 rgba(31,63,134,.18), 0 1.6cqw 3cqw rgba(30,60,120,.18);
  animation: rise .9s .2s both var(--ease-pop);
}
/* 타이포그래피 타이틀 */
.logo {
  margin: 0 0 .5cqw; font-family: var(--font-title); font-weight: 400; line-height: 1;
  cursor: default; outline: none; user-select: none; -webkit-tap-highlight-color: transparent;
}
.logo-l1, .logo-l2 { display: block; white-space: nowrap; }
.logo-l1 { font-size: 3.5cqw; margin-bottom: .1em; }
.logo-l2 { font-size: 8.2cqw; letter-spacing: .02em; }
.logo .ch {
  display: inline-block;
  transform: translateY(var(--y, 0)) rotate(var(--r, 0deg));
  color: var(--navy);
  /* 얇은 글꼴을 같은 색 테두리로 두껍게 + 흰 스티커 테두리 + 그림자 */
  -webkit-text-stroke: .05em currentColor;
  text-shadow:
    .07em 0 0 #fff, -.07em 0 0 #fff, 0 .07em 0 #fff, 0 -.07em 0 #fff,
    .05em .05em 0 #fff, -.05em .05em 0 #fff, .05em -.05em 0 #fff, -.05em -.05em 0 #fff,
    0 .13em 0 rgba(31, 63, 134, .22);
  transition: transform .4s var(--ease-pop), color .25s, opacity .3s;
}
.logo-l2 .ch { color: var(--blue); }
.logo .sp { display: inline-block; width: .32em; }
/* '사과' 묶음 */
.apo { position: relative; display: inline-block; margin-inline: 0; transition: margin .4s var(--ease-pop), transform .4s var(--ease-pop); }
.apo::after { /* 밑줄 */
  content: ""; position: absolute; left: 4%; right: 4%; bottom: -.02em; height: .14em;
  background: var(--red); border-radius: 99px; opacity: .85;
  transform: scaleX(0); transform-origin: left; transition: transform .35s .1s ease-out;
}
.apo-heart {
  position: absolute; left: 50%; top: -1.35em; font-size: .7em; color: var(--red);
  -webkit-text-stroke: 0; text-shadow: none; transform: translate(-50%, .4em) scale(0); opacity: 0;
  transition: transform .45s .1s var(--ease-pop), opacity .2s .1s;
}
/* 강조 상태 (JS가 .hl을 붙임) */
.logo.hl .ch { opacity: .68; }
/* 글자를 하나씩 키우면 서로 겹치므로, '사과' 묶음 전체를 키우고 글자는 똑바로 세움 */
.apo { transform-origin: 50% 80%; }
.logo.hl .apo { transform: scale(1.42) rotate(-3deg); margin-inline: .45em .5em; }
.logo.hl .apo .ch { opacity: 1; color: var(--red); transform: none; }
.logo.hl .apo::after { transform: scaleX(1); }
.logo.hl .apo-heart { opacity: 1; transform: translate(-50%, 0) scale(1); animation: beat 1.2s .6s ease-in-out infinite; }
@keyframes beat { 0%,100% { transform: translate(-50%, 0) scale(1); } 50% { transform: translate(-50%, -.08em) scale(1.18); } }
.t-line { margin: 0 0 1.3cqw; font-size: max(17px, 1.45cqw); color: var(--ink-soft); }
.title-card .pill-btn.big { font-size: max(19px, 1.6cqw); }
.t-meta { margin: 1.1cqw 0 0; font-size: max(14px, 1cqw); color: var(--ink-soft); }

.flying { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.fly { position: absolute; width: 5.5cqw; opacity: .95; filter: drop-shadow(0 6px 8px rgba(0,0,0,.12)); }
.f1 { left: 30%; top: 30%; animation: drift1 9s ease-in-out infinite; }
.f2 { left: 74%; top: 22%; width: 4.6cqw; animation: drift2 11s ease-in-out infinite; }
.f3 { left: 28%; top: 58%; width: 4.2cqw; animation: drift1 10s -4s ease-in-out infinite reverse; }

/* 안쪽 장면 위치 (배경 1672×941 기준 %) */
.window { left: 42.4%; top: 21.2%; width: 15.2%; height: 10%; }
.board  { left: 71.6%; top: 20.6%; width: 10.6%; height: 22.6%; }
.frame  { left: 19.6%; top: 20.6%; width: 8.6%; }
.lamp   { top: -3%; width: 6.94%; transform-origin: 50% 0; }
.lamp.l1 { left: 19.26%; }
.lamp.l2 { left: 74.04%; }
.lamp:hover img { animation: swing 1.4s ease-in-out infinite; transform-origin: 50% 0; }
.plant  { left: 11.6%; top: -1%; width: 6.6%; transform-origin: 50% 0; }
.plant.sway img, .plant:hover img { animation: swing 1.8s ease-in-out; transform-origin: 50% 0; }
.mailbox { left: 60.9%; top: 59.5%; width: 15.7%; animation: breathe 3.2s ease-in-out infinite; transform-origin: 50% 100%; }
.mailbox:hover { animation: wobble .6s ease-in-out infinite; }
.letter { width: 10%; }
.letter .no {
  position: absolute; left: -.6cqw; top: -.6cqw;
  width: 2.2cqw; height: 2.2cqw; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--blue); color: #fff; font-family: var(--font-cute); font-size: 1.3cqw;
  box-shadow: 0 .2cqw 0 var(--blue-deep);
  pointer-events: none;
}
.lt1 { left: 22.5%; top: 73%; transform: rotate(-8deg); }
.lt2 { left: 32.5%; top: 81.5%; transform: rotate(5deg); }
.lt3 { left: 41%;   top: 71.5%; transform: rotate(-4deg); }
.lt4 { left: 48.6%; top: 81.5%; transform: rotate(7deg); }

/* 불 끄기 */
.night {
  position: absolute; inset: 0; pointer-events: none; z-index: 1; overflow: hidden;
  opacity: 0; visibility: hidden; transition: opacity .7s, visibility 0s .7s;
}
.lights-off .night { opacity: 1; visibility: visible; transition: opacity .7s; }
/* 손전등: 무대보다 2배 큰 어둠판 가운데에 빛 구멍. 그림을 다시 그리지 않고
   위치(transform)만 옮겨서 가볍게 움직임. 위치는 app.js의 moveLight()가 정함 */
.torch {
  position: absolute; left: 0; top: 0; width: 200%; height: 200%;
  background: radial-gradient(circle 12cqw at 50% 50%,
    rgba(10, 16, 44, 0) 0%, rgba(10, 16, 44, .08) 55%, rgba(8, 12, 36, .93) 100%);
  transform: translate(-25%, -25%);
}
.lights-off .torch { will-change: transform; } /* 불 꺼졌을 때만 별도 레이어로 */
.lights-off .glow { opacity: .3; }
.glow {
  position: absolute; width: 22cqw; height: 22cqw; margin: -11cqw 0 0 -11cqw; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 222, 150, .75), rgba(255, 200, 120, .25) 35%, transparent 68%);
}
.g1 { left: 22.7%; top: 14%; } .g2 { left: 77.5%; top: 14%; }
.g3 { left: 34.6%; top: 23%; width: 12cqw; height: 12cqw; margin: -6cqw 0 0 -6cqw; }
.g4 { left: 65.4%; top: 23%; width: 12cqw; height: 12cqw; margin: -6cqw 0 0 -6cqw; }
.lights-off .mailbox img { filter: drop-shadow(0 0 1.4cqw rgba(255, 210, 120, .8)); }

/* ───────── 밤 이벤트: 잃어버린 편지 ───────── */
/* 편지 조각: 어둠(.night) 아래에 있어서 손전등을 비춰야 보임 */
.piece {
  position: absolute; width: 4.6%; border: 0; padding: 0; background: none;
  -webkit-tap-highlight-color: transparent;
  animation: pieceBob 2.6s ease-in-out infinite;
}
.piece::after { content: ""; position: absolute; inset: -45%; } /* 누르기 쉽게 넓은 판정 */
.piece img { width: 100%; height: auto; pointer-events: none; filter: drop-shadow(0 0 .7cqw rgba(255, 236, 160, .95)); }
.piece:focus-visible { outline: 3px solid #ffe27a; outline-offset: 4px; border-radius: 6px; }
.piece.got { animation: pieceGot .5s ease-in forwards; pointer-events: none; }
.pc1 { left: 5.5%; top: 55%; --rot: -18deg; }
.pc2 { left: 87.5%; top: 34%; --rot: 14deg; animation-delay: -.6s; }
.pc3 { left: 31%; top: 49%; --rot: 8deg; animation-delay: -1.2s; }
.pc4 { left: 66.5%; top: 45%; --rot: -10deg; animation-delay: -1.8s; }
@keyframes pieceBob { 0%,100% { transform: rotate(var(--rot)) translateY(0); } 50% { transform: rotate(var(--rot)) translateY(-.5cqw); } }
@keyframes pieceGot { to { transform: rotate(0) translateY(-6cqw) scale(1.6); opacity: 0; } }

/* 유오 실루엣: 어둠 위에 그려서 항상 보임 */
.yuo-shadow {
  position: absolute; left: 44.5%; top: 37%; width: 7.2%; z-index: 3;
  border: 0; padding: 0; background: none; -webkit-tap-highlight-color: transparent;
  animation: shadowIn .9s ease-out both;
}
.yuo-shadow img {
  width: 100%; height: auto; pointer-events: none;
  filter: brightness(0) drop-shadow(0 0 .35cqw rgba(160, 190, 255, .9)) drop-shadow(0 0 1.2cqw rgba(110, 150, 255, .45));
  opacity: .92; transition: transform .3s var(--ease-pop);
}
.yuo-shadow:hover img, .yuo-shadow:focus-visible img { transform: translateY(-3%) scale(1.04); }
.yuo-shadow:focus-visible { outline: none; }
.quest-mark {
  position: absolute; left: 50%; top: -2.6cqw; transform: translateX(-50%);
  width: 2.9cqw; height: 2.9cqw; min-width: 30px; min-height: 30px;
  display: grid; place-items: center; border-radius: 50%;
  background: #ffd23f; color: var(--navy); border: 3px solid #fff;
  font-family: var(--font-cute); font-size: max(20px, 1.9cqw); line-height: 1;
  box-shadow: 0 0 0 4px rgba(255, 210, 63, .35), 0 0 1.6cqw rgba(255, 220, 90, .9);
  animation: markBounce 1.1s ease-in-out infinite;
}
.quest-mark.wait { background: #cfd8ee; box-shadow: 0 0 0 4px rgba(207, 216, 238, .3); }
@keyframes markBounce { 0%,100% { transform: translate(-50%, 0); } 50% { transform: translate(-50%, -.7cqw); } }
@keyframes shadowIn { from { opacity: 0; transform: translateY(1.5cqw); } }

/* 조각을 다 모으면 우체통이 어둠 위로 빛남 */
.quest-ready .mailbox { z-index: 2; }
.quest-ready .mailbox img { filter: drop-shadow(0 0 1.6cqw rgba(255, 220, 120, 1)) drop-shadow(0 0 .4cqw #fff) !important; }

/* 진행 표시 (화면 위 가운데) */
.quest-hud {
  position: fixed; left: 50%; top: 72px; z-index: 31; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px; white-space: nowrap;
  padding: 7px 16px; border-radius: 999px;
  background: rgba(20, 30, 70, .88); color: #fff; font-family: var(--font-cute); font-size: 17px;
  box-shadow: 0 6px 18px rgba(0,0,0,.3); animation: fadeIn .4s;
}
.qh-dots { display: flex; gap: 5px; }
.qh-dots i { width: 13px; height: 13px; border-radius: 3px; background: rgba(255,255,255,.22); transform: rotate(45deg); transition: background .3s, transform .3s var(--ease-pop); }
.qh-dots i.on { background: #ffd23f; transform: rotate(45deg) scale(1.2); }

/* 유오의 말 (화면 아래) */
.quest-talk {
  position: fixed; left: 50%; bottom: 18px; z-index: 36; transform: translateX(-50%);
  width: min(560px, calc(100vw - 32px));
  display: flex; gap: 14px; align-items: flex-start;
  padding: 14px 16px; border-radius: 20px;
  background: var(--paper); border: 3px solid var(--blue);
  box-shadow: 0 12px 34px rgba(0,0,0,.35); animation: pop .35s var(--ease-pop);
}
.qt-face { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; border: 3px solid #ffd23f; flex: none; }
.qt-body { flex: 1; min-width: 0; }
.qt-name { margin: 0; font-family: var(--font-cute); color: var(--blue); font-size: 16px; line-height: 1.3; }
.qt-text { margin: 2px 0 0; font-size: 18px; line-height: 1.55; color: var(--ink); word-break: keep-all; }
.qt-btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.qt-btns:empty { display: none; }
.qt-btns .pill-btn { font-size: 17px; padding: .45em 1.1em; }

/* 엔딩 */
.quest-modal { background: rgba(10, 16, 44, .82); }
.qe-card {
  position: relative; width: min(560px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow: auto;
  padding: 28px 24px 22px; text-align: center; border-radius: 24px;
  background: var(--paper); box-shadow: 0 20px 60px rgba(0,0,0,.4); animation: pop .4s var(--ease-pop);
}
.qe-letter { position: relative; width: 62%; aspect-ratio: 720 / 536; margin: 6px auto 4px; }
.qe-p { position: absolute; height: auto; transition: transform .8s var(--ease-pop); }
/* letter-plain.webp 안에서 각 조각의 자리 (make_pieces.py 결과) */
.qe-p1 { left: 0;      top: 8.21%; width: 53.19%; }
.qe-p2 { left: 49.72%; top: 0;     width: 46.81%; }
.qe-p3 { left: 2.92%;  top: 50%;   width: 48.89%; }
.qe-p4 { left: 49.72%; top: 50.37%; width: 50.28%; }
.qe-letter.scatter .qe-p1 { transform: translate(-30%, -25%) rotate(-14deg); }
.qe-letter.scatter .qe-p2 { transform: translate(30%, -30%) rotate(12deg); }
.qe-letter.scatter .qe-p3 { transform: translate(-28%, 30%) rotate(10deg); }
.qe-letter.scatter .qe-p4 { transform: translate(32%, 26%) rotate(-12deg); }
.qe-stamp {
  position: absolute; right: -10%; bottom: 2%; width: 40%; opacity: 0;
  transform: scale(2.4) rotate(-20deg);
}
.qe-letter.stamped .qe-stamp { animation: stampIn .45s cubic-bezier(.5, 0, .7, 1.4) forwards; }
@keyframes stampIn { 70% { opacity: 1; transform: scale(.92) rotate(-12deg); } 100% { opacity: 1; transform: scale(1) rotate(-12deg); } }
.qe-title { margin: 22px 0 4px; font-family: var(--font-cute); color: var(--navy); font-size: 26px; line-height: 1.3; word-break: keep-all; }
.qe-thanks { display: flex; align-items: center; gap: 12px; margin-top: 10px; text-align: left; opacity: 0; transform: translateY(16px); transition: opacity .5s, transform .5s var(--ease-pop); }
.qe-thanks.show { opacity: 1; transform: none; }
.qe-thanks img { width: 26%; flex: none; }
.qe-bubble { position: relative; flex: 1; background: #fff4cf; border-radius: 16px; padding: 12px 16px; }
.qe-bubble::before { content: ""; position: absolute; left: -9px; top: 40%; width: 18px; height: 18px; background: #fff4cf; transform: rotate(45deg); border-radius: 3px; }
.qe-bubble p { position: relative; margin: 0; font-size: 17px; line-height: 1.6; word-break: keep-all; }
.qe-bubble .qt-name { font-size: 15px; }
.qe-btns { display: flex; justify-content: center; gap: 10px; margin-top: 18px; opacity: 0; transition: opacity .4s .2s; }
.qe-thanks.show + .qe-btns { opacity: 1; }
@media (max-width: 760px) {
  .quest-hud { top: 66px; font-size: 15px; padding: 6px 12px; }
  .qh-label { display: none; }
  .quest-talk { bottom: 12px; padding: 12px; }
  .qt-face { width: 50px; height: 50px; }
  .qt-text { font-size: 17px; }
  .qe-letter { width: 76%; }
}

.scroll-hint { display: none; }

/* ───────────────── 실내 → 아래로 스크롤 ───────────────── */
#inside { overflow-y: auto; overflow-x: hidden; scroll-behavior: smooth; }
#inside > .viewport { position: relative; height: 100vh; height: 100dvh; }
.to-games { /* 편지·우체통을 가리지 않게 오른쪽 아래 빈 바닥에 */
  position: absolute; right: 84px; bottom: 14px; z-index: 6;
  display: flex; flex-direction: column; align-items: center; gap: 0;
  border: 0; background: none; color: #fff;
  font-family: var(--font-cute); font-size: 18px;
  text-shadow: 0 2px 6px rgba(20, 40, 90, .55);
}
.to-games span { background: rgba(29, 47, 90, .82); padding: 5px 16px; border-radius: 999px; text-shadow: none; }
.to-games b { font-size: 22px; color: var(--blue-deep); text-shadow: 0 0 6px #fff; animation: bob 1.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(6px); } }

.games {
  position: relative;
  background:
    linear-gradient(#fff8ea, #f6e9cf);
  padding: 74px 16px 40px;
}
.games::before { /* 우체국 벽 아래 파란 판넬 + 나무 테 */
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 34px;
  background:
    linear-gradient(#b9814a 0 8px, #8f5d2f 8px 10px, transparent 10px),
    repeating-linear-gradient(90deg, #3d68b8 0 180px, #3460ad 180px 184px);
  box-shadow: 0 6px 14px rgba(30, 60, 120, .18);
}
.games-inner { max-width: 1120px; margin: 0 auto; }
.games .kicker { text-align: center; }
.games h2 {
  margin: 4px 0 6px; text-align: center;
  font-family: var(--font-cute); font-weight: 400; color: var(--navy);
  font-size: clamp(32px, 4.4vw, 50px); line-height: 1.2;
}
.games-lead { text-align: center; margin: 0 0 34px; color: var(--ink-soft); }
.game-arts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 30px; max-width: 1040px; margin: 0 auto; }
.game-art {
  position: relative; border-radius: 26px; overflow: hidden;
  box-shadow: 0 6px 0 rgba(31, 63, 134, .12), 0 18px 40px rgba(60, 50, 20, .16);
}
/* 일러스트는 고정, 그림 속 버튼(.hs)만 반응 */
.game-art img { width: 100%; height: auto; }
/* 그림 속 버튼 위에 겹친 진짜 버튼 */
.game-art .hs { position: absolute; border: 0; padding: 0; background: transparent; border-radius: 999px; transition: transform .15s, box-shadow .15s; }
.game-art .hs:hover, .game-art .hs:focus-visible { outline: none; transform: scale(1.05); box-shadow: 0 0 0 4px rgba(255,255,255,.95), 0 0 26px rgba(255,230,140,.95); }
.sort-start { left: 58.8%; top: 48%;   width: 38.8%; height: 11.1%; }
.sort-how   { left: 65.5%; top: 60.6%; width: 29.6%; height: 7.2%; }
.rain-start { left: 25.2%; top: 82.8%; width: 39.5%; height: 11.4%; }
.rain-how   { left: 71%;   top: 85.4%; width: 27%;   height: 6.6%; }
.game-card {
  background: var(--paper); border-radius: 26px; overflow: hidden;
  box-shadow: 0 6px 0 rgba(31, 63, 134, .12), 0 18px 40px rgba(60, 50, 20, .14);
  display: flex; flex-direction: column;
  transition: transform .3s var(--ease-pop), box-shadow .3s;
}
.game-card:hover { transform: translateY(-6px) rotate(-.4deg); box-shadow: 0 6px 0 rgba(31,63,134,.14), 0 26px 50px rgba(60,50,20,.2); }
.game-thumb { display: block; border: 0; padding: 0; background: #eee; aspect-ratio: 5 / 4; overflow: hidden; }
.game-thumb img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 30%; transition: transform .5s ease; }
.game-card:hover .game-thumb img { transform: scale(1.04); }
.game-txt { padding: 22px 26px 26px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.game-no { margin: 0; font-family: var(--font-cute); color: var(--red); font-size: 17px; }
.game-txt h3 { margin: 0; font-family: var(--font-cute); font-weight: 400; color: var(--navy); font-size: 32px; line-height: 1.2; }
.game-txt p { margin: 0; }
.tags { list-style: none; margin: 4px 0 8px; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.tags li { background: #eaf0fd; color: var(--blue-deep); font-family: var(--font-cute); font-size: 15px; padding: 3px 12px; border-radius: 999px; }
.game-txt .pill-btn { margin-top: auto; align-self: flex-start; }
.site-foot { margin-top: 48px; text-align: center; color: var(--ink-soft); font-size: 16px; }
.site-foot p { margin: 2px 0; }
.site-foot a { color: var(--red-deep); }
.back-up { margin-top: 14px; border: 0; background: none; font-family: var(--font-cute); font-size: 18px; color: var(--blue-deep); }

/* 게임 화면 */
.game-layer { position: fixed; inset: 0; z-index: 70; background: #fff8ea; animation: fadeIn .3s; }
.game-layer iframe { width: 100%; height: 100%; border: 0; display: block; }

/* ───────────────── 공통 UI ───────────────── */
.help-badge {
  position: fixed; right: 16px; bottom: 16px; z-index: 30;
  width: 52px; height: 52px; border-radius: 50%; border: 0;
  background: #fff; color: var(--blue-deep);
  font-family: var(--font-cute); font-size: 26px;
  box-shadow: 0 3px 0 rgba(31,63,134,.35), 0 6px 18px rgba(0,0,0,.15);
  opacity: 0; pointer-events: none; transition: opacity .4s;
}
.help-badge.show { opacity: 1; pointer-events: auto; }
.toast {
  position: fixed; left: 50%; bottom: 90px; z-index: 60;
  transform: translate(-50%, 20px);
  max-width: calc(100vw - 32px);
  background: var(--navy); color: #fff;
  font-family: var(--font-cute); font-size: 19px; text-align: center;
  word-break: keep-all;
  padding: 12px 22px; border-radius: 18px;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
  opacity: 0; pointer-events: none; transition: .3s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ───────────────── 굿즈 팝업 ───────────────── */
.goods-pop {
  position: fixed; left: 16px; top: 76px; z-index: 35; /* 상단 바 위, 메뉴·창 아래 */
  width: 300px; max-width: calc(100vw - 32px);
  padding: 18px 18px 0; text-align: center;
  background: var(--paper); border-radius: 20px;
  border: 3px solid transparent;
  background-image: linear-gradient(var(--paper), var(--paper)),
    repeating-linear-gradient(135deg, var(--red) 0 10px, #fff 10px 16px, var(--blue) 16px 26px, #fff 26px 32px);
  background-origin: border-box; background-clip: padding-box, border-box;
  box-shadow: 0 14px 36px rgba(20, 30, 70, .28);
  animation: gpIn .55s var(--ease-pop) both;
}
.goods-pop.out { animation: gpOut .25s ease-in forwards; }
@keyframes gpIn { from { opacity: 0; transform: translate(-30px, -10px) scale(.9); } }
@keyframes gpOut { to { opacity: 0; transform: translate(-20px, -6px) scale(.95); } }
.gp-x { position: absolute; right: 8px; top: 6px; width: 34px; height: 34px; border: 0; background: none; font-size: 26px; line-height: 1; color: var(--ink-soft); border-radius: 50%; }
.gp-x:hover { background: #f1ead8; }
.gp-kicker { margin: 0; font-family: var(--font-cute); color: var(--red); font-size: 15px; }
.gp-title { margin: 0 0 8px; font-family: var(--font-cute); color: var(--navy); font-size: 26px; line-height: 1.2; }
.gp-items { display: flex; justify-content: center; align-items: flex-end; gap: 8px; height: 76px; margin-bottom: 8px; }
.gp-items img { height: 100%; width: auto; object-fit: contain; filter: drop-shadow(0 4px 6px rgba(0,0,0,.15)); }
.gp-items img:nth-child(1) { height: 64px; transform: rotate(-8deg); }
.gp-items img:nth-child(3) { height: 60px; transform: rotate(8deg); }
.gp-text { margin: 0 0 12px; font-size: 15px; line-height: 1.55; color: var(--ink-soft); word-break: keep-all; }
.gp-go { width: 100%; font-size: 18px; }
.gp-foot { display: flex; margin: 14px -18px 0; border-top: 1px solid #ece3cc; }
.gp-foot button { flex: 1; border: 0; background: none; padding: 11px 6px; font-size: 14px; color: var(--ink-soft); }
.gp-foot button + button { border-left: 1px solid #ece3cc; }
.gp-foot button:hover { color: var(--navy); background: #faf4e4; }
.gp-foot button:first-child { border-bottom-left-radius: 17px; }
.gp-foot button:last-child { border-bottom-right-radius: 17px; }
@media (max-width: 760px) {
  .goods-pop { top: 70px; width: 270px; padding-top: 14px; }
  .gp-items { height: 58px; } .gp-items img:nth-child(1) { height: 50px; } .gp-items img:nth-child(3) { height: 46px; }
  .gp-title { font-size: 23px; }
}

/* ───────────────── 모달 공통 ───────────────── */
.modal {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  padding: 72px 16px 24px;
  background: rgba(22, 32, 70, .66); /* 뒤 흐림(blur) 대신 조금 더 어둡게: 책 넘김이 버벅이지 않게 */
  overflow-y: auto;
  animation: fadeIn .25s;
}
.close {
  position: absolute; right: 14px; top: 12px; z-index: 3;
  width: 46px; height: 46px; border-radius: 50%; border: 0;
  background: #fff; color: var(--blue-deep);
  font-size: 30px; line-height: 1;
  box-shadow: 0 3px 0 rgba(31,63,134,.3);
}
.modal > .close { position: fixed; right: 16px; top: 14px; }

.paper {
  position: relative;
  width: min(760px, 100%);
  background: var(--paper);
  border-radius: 22px;
  padding: 36px clamp(20px, 5vw, 52px) 34px;
  box-shadow: 0 24px 60px rgba(10, 20, 60, .35);
  animation: pop .45s var(--ease-pop);
}
.paper.wide { width: min(1040px, 100%); }
.paper .close { right: 16px; top: 16px; box-shadow: inset 0 0 0 2px #dfe5f3, 0 3px 0 rgba(31,63,134,.2); }
.airmail { border: 12px solid transparent; border-image: repeating-linear-gradient(-45deg, var(--red) 0 14px, var(--paper) 14px 22px, var(--blue) 22px 36px, var(--paper) 36px 44px) 12; border-radius: 0; }
.kicker { margin: 0; font-family: var(--font-cute); color: var(--red); font-size: 18px; }
.paper h2 { margin: 0 0 18px; font-family: var(--font-cute); font-weight: 400; font-size: clamp(30px, 4vw, 42px); color: var(--navy); line-height: 1.2; }

/* 줄거리 */
.letter-tabs { display: flex; gap: 10px; margin: 0 56px 18px 0; flex-wrap: wrap; }
.letter-tabs button {
  position: relative; width: 74px; height: 60px; padding: 6px; border: 0; border-radius: 14px;
  background: #f4efe2; transition: transform .2s var(--ease-pop), background .2s;
}
.letter-tabs button img { width: 100%; height: 100%; object-fit: contain; }
.letter-tabs button span {
  position: absolute; left: -4px; top: -4px; width: 24px; height: 24px; border-radius: 50%;
  background: #b9c3db; color: #fff; font-family: var(--font-cute); font-size: 14px; line-height: 24px;
}
.letter-tabs button[aria-selected="true"] { background: #fff; box-shadow: 0 0 0 3px var(--blue); transform: translateY(-3px); }
.letter-tabs button[aria-selected="true"] span { background: var(--blue); }
.story-body img { width: 100%; border-radius: 14px; box-shadow: 0 6px 18px rgba(0,0,0,.12); margin-bottom: 18px; aspect-ratio: 3308 / 1969; object-fit: cover; background: #eee; }
.story-body p { margin: 0; font-size: 20px; line-height: 1.9; }
.story-nav { display: flex; justify-content: space-between; gap: 10px; margin-top: 24px; flex-wrap: wrap; }
.story-nav .pill-btn[disabled] { opacity: .35; pointer-events: none; }

/* 등장인물: 우표 카드 */
.stamps { display: grid; grid-template-columns: repeat(2, 1fr); gap: 22px; }
.chip { display: inline-block; vertical-align: middle; font-size: 15px; padding: 2px 10px; border-radius: 999px; background: #eaf0fd; color: var(--blue-deep); }
.pc-guide { margin: -8px 0 16px; color: var(--ink-soft); font-size: 17px; }
.pc-guide b { display: inline-block; margin-left: 6px; padding: 0 10px; border-radius: 999px; background: #eaf0fd; color: var(--blue-deep); font-family: var(--font-cute); font-weight: 400; }
.pc-done {
  display: flex; align-items: center; gap: 10px; margin: -8px 0 16px; padding: 6px 14px 6px 6px;
  width: fit-content; border-radius: 999px; background: #fde9e4;
  font-family: var(--font-cute); color: var(--red-deep); font-size: 18px; animation: pop .4s var(--ease-pop);
}
.pc-done img { width: 44px; height: 44px; object-fit: contain; transform: rotate(-12deg); }

/* 카드: 앞(우표)·뒤(한마디) 두 면을 같은 칸에 겹쳐 두고 Y축으로 뒤집음 */
.pcard { position: relative; perspective: 1200px; cursor: pointer; -webkit-tap-highlight-color: transparent; }

/* 완성 도장: 보리 카드 위쪽 여백에 손이 내려와 '접수'를 찍고 올라감 → 잉크 자국만 남음 */
.seal { position: absolute; right: 96px; bottom: calc(100% - 28px); width: 130px; height: 94px; z-index: 5; pointer-events: none; }
.seal-ink { display: block; width: 100%; height: 100%; opacity: 0; transform: rotate(-12deg); mix-blend-mode: multiply; }
/* 손 그림의 도장 면(그림의 왼쪽 26%, 위 68% 지점)이 잉크 자국 한가운데에 오도록 배치 */
.seal-hand { position: absolute; width: 200px; left: 13px; top: -67px; opacity: 0; transform-origin: 26% 68%; }
.seal.go .seal-hand { animation: handStamp 1.4s ease-in-out forwards; }
.seal.go .seal-ink { animation: inkIn .22s .56s ease-out forwards; }
.seal.done .seal-ink { opacity: .9; }
@keyframes handStamp {
  0%   { opacity: 0; transform: translate(40px, -80px) rotate(14deg) scale(1.15); }
  22%  { opacity: 1; transform: translate(12px, -46px) rotate(6deg) scale(1.1); }
  40%  { transform: translate(0, 0) rotate(0) scale(1); }
  46%  { transform: translate(0, 2px) scale(1.03, .96); }
  60%  { opacity: 1; transform: translate(0, -4px) rotate(-2deg); }
  100% { opacity: 0; transform: translate(50px, -110px) rotate(16deg) scale(1.05); }
}
@keyframes inkIn { from { opacity: 0; transform: rotate(-12deg) scale(1.18); } to { opacity: .9; transform: rotate(-12deg) scale(1); } }
.pcard.thud { animation: thud .32s ease-out; }
@keyframes thud { 30% { transform: translateY(4px) scale(.99); } }
.pc-flip {
  display: grid; position: relative; transform-style: preserve-3d;
  transition: transform .6s var(--ease-pop);
}
.pcard.on .pc-flip { transform: rotateY(180deg); }
.pc-face {
  grid-area: 1 / 1; position: relative; padding: 24px;
  -webkit-backface-visibility: hidden; backface-visibility: hidden;
  /* 우표 톱니: 가장자리에 종이색 구멍 */
  background: radial-gradient(circle, var(--paper) 5px, #fff 5.5px) -8px -8px / 16px 16px;
  box-shadow: 0 4px 10px rgba(0,0,0,.1);
}
.pc-face::before { content: ""; position: absolute; inset: 8px; background: #fff; border-radius: 2px; }
.pc-face > * { position: relative; }
.pc-front { display: grid; grid-template-columns: 150px 1fr; gap: 18px; align-items: center; }
.pc-back { transform: rotateY(180deg); }
.pc-back::before { background: #fffaf0 repeating-linear-gradient(#fffaf0 0 33px, #efe3c8 33px 34px); } /* 편지지 줄 */
.pcard:not(.on):hover .pc-front { transform: translateY(-3px) rotate(-.6deg); }
.pc-front { transition: transform .25s var(--ease-pop); }

.pc-head { aspect-ratio: 1; display: grid; place-items: center; border-radius: 12px; background: #e8eefb; box-shadow: inset 0 0 0 3px #fff, 0 0 0 2px #d6dcec; }
.pc-head.red { background: #fde3dc; }
.pc-head img { width: 84%; height: 84%; object-fit: contain; transform-origin: 50% 85%; filter: drop-shadow(0 4px 4px rgba(0,0,0,.12)); }
.pcard h3 { margin: 2px 0 2px; font-family: var(--font-cute); font-weight: 400; font-size: 28px; color: var(--navy); }
.pcard .one { margin: 0 0 10px; font-family: var(--font-cute); color: var(--red-deep); font-size: 19px; line-height: 1.45; word-break: keep-all; }
.pc-btn {
  border: 0; border-radius: 999px; padding: 4px 14px; background: #eaf0fd; color: var(--blue-deep);
  font-family: var(--font-cute); font-size: 16px; transition: background .2s;
}
.pc-btn:hover, .pc-btn:focus-visible { background: #d7e2fb; outline: none; box-shadow: 0 0 0 3px var(--blue); }
.pc-label { margin: 0; font-family: var(--font-cute); color: var(--red); font-size: 15px; }
.pc-quote {
  margin: 4px 72px 12px 0; font-family: var(--font-title); color: var(--navy);
  font-size: 30px; line-height: 1.3; word-break: keep-all;
}
.pcard.on .pc-quote { animation: quoteIn .5s .35s var(--ease-pop) both; }
@keyframes quoteIn { from { opacity: 0; transform: translateY(8px) scale(.94); } }
.pc-back ul { margin: 0 0 10px; padding-left: 1.1em; font-size: 17px; line-height: 1.7; color: var(--ink-soft); word-break: keep-all; }
.pc-mini { position: absolute; right: 20px; top: 18px; width: 64px; transform: rotate(8deg); }
.pc-back .pc-btn { float: right; }

/* 캐릭터마다 다른 움직임 (마우스를 올리거나 카드를 뒤집을 때) */
.pcard[data-char="yuo"]:hover .pc-head img, .pcard[data-char="yuo"].on .pc-mini { animation: hopHop .7s ease-in-out infinite; }
.pcard[data-char="bori"]:hover .pc-head img, .pcard[data-char="bori"].on .pc-mini { animation: shyTilt 1.6s ease-in-out infinite; }
.pcard[data-char="chief"]:hover .pc-head img, .pcard[data-char="chief"].on .pc-mini { animation: nodHat 1.4s ease-in-out infinite; }
.pcard[data-char="mailbox"]:hover .pc-head img, .pcard[data-char="mailbox"].on .pc-mini { animation: chomp .5s ease-in-out infinite; }
@keyframes hopHop { 0%,100% { transform: translateY(0); } 30% { transform: translateY(-12%) rotate(-4deg); } 55% { transform: translateY(0) scale(1.04, .96); } 75% { transform: translateY(-6%) rotate(3deg); } }
@keyframes shyTilt { 0%,100% { transform: rotate(0); } 30% { transform: rotate(-8deg) translateX(-3%); } 60% { transform: rotate(5deg); } }
@keyframes nodHat { 0%,100% { transform: rotate(0); } 40% { transform: rotate(-7deg) translateY(4%); } 60% { transform: rotate(-7deg) translateY(4%); } }
@keyframes chomp { 0%,100% { transform: scale(1, 1); } 40% { transform: scale(1.08, .88); } 70% { transform: scale(.95, 1.06); } }

/* 작가의 말: 액자 */
.paper.framed {
  border: 18px solid #c98b4f;
  border-radius: 10px;
  box-shadow: inset 0 0 0 4px #e7b680, 0 0 0 4px #9b6534, 0 24px 60px rgba(10,20,60,.35);
  background: #fffaf0;
}
blockquote {
  margin: 0 0 26px; padding: 22px 48px 22px 26px;
  font-family: var(--font-cute); font-size: clamp(23px, 3vw, 30px); line-height: 1.55; color: var(--navy);
  word-break: keep-all;
  background: #fde9e4; border-radius: 16px; position: relative;
}
blockquote::before { content: "♥"; position: absolute; right: 18px; top: 10px; color: var(--red); font-size: 22px; }
.author-row { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.author-row > div { background: #f6f1e3; border-radius: 14px; padding: 16px 20px; }
.author-row p { margin: 0; }
.label { font-family: var(--font-cute); color: var(--red); font-size: 16px; }
.name { font-family: var(--font-cute); font-size: 30px; color: var(--navy); }

/* 책 정보: 게시판 */
.paper.notice { background: #fffdf6; border-top: 14px solid var(--blue); }
.info-grid { display: grid; grid-template-columns: 220px 1fr; gap: 26px; align-items: start; }
.cover { width: 100%; border-radius: 6px 12px 12px 6px; box-shadow: -6px 0 0 #e9dfc9, 0 14px 30px rgba(0,0,0,.22); transform: rotate(-2deg); }
dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 8px 18px; }
dt { font-family: var(--font-cute); color: var(--blue); font-size: 17px; padding-top: 2px; }
dd { margin: 0; font-size: 19px; }
dd a { color: var(--red-deep); font-weight: 700; }
.send { margin-top: 26px; width: 100%; }

/* ───────────────── 책 펼쳐보기 ───────────────── */
.book-modal { background: radial-gradient(ellipse at 50% 45%, rgba(48, 74, 140, .75), rgba(14, 22, 52, .92)); }
.book-wrap { display: flex; align-items: center; gap: 14px; width: 100%; justify-content: center; }
.book-holder { perspective: 2600px; }
.book {
  --w: min(calc(100vw - 150px), calc((100dvh - 210px) * 1.68), 1200px);
  position: relative;
  width: var(--w);
  aspect-ratio: 3308 / 1969;
  transition: transform .7s cubic-bezier(.5,0,.3,1);
  animation: bookIn .7s var(--ease-pop);
}
.book.closed-front { transform: translateX(-25%); }
.book.closed-back  { transform: translateX(25%); }
.half, .face {
  position: absolute; top: 0; width: 50%; height: 100%;
  background-color: #fff; background-repeat: no-repeat;
}
.half.left  { left: 0;   border-radius: 6px 0 0 6px; }
.half.right { left: 50%; border-radius: 0 6px 6px 0; }
.half.empty { background: none !important; box-shadow: none !important; }
.half.empty::after { display: none; }
.half:not(.empty) {
  box-shadow: 0 30px 50px -10px rgba(0, 0, 0, .55);
}
/* 책 두께(쌓인 종이) */
.half.left:not(.empty)  { box-shadow: -3px 3px 0 #f1ece0, -6px 6px 0 #e3dccb, 0 30px 50px -10px rgba(0,0,0,.55); }
.half.right:not(.empty) { box-shadow: 3px 3px 0 #f1ece0, 6px 6px 0 #e3dccb, 0 30px 50px -10px rgba(0,0,0,.55); }
.half.cover-page.right { border-radius: 4px 10px 10px 4px; box-shadow: 4px 4px 0 #e9e2d0, 8px 8px 0 #d5ccb6, 0 30px 50px -10px rgba(0,0,0,.6); }
.half.cover-page.left  { border-radius: 10px 4px 4px 10px; box-shadow: -4px 4px 0 #e9e2d0, -8px 8px 0 #d5ccb6, 0 30px 50px -10px rgba(0,0,0,.6); }
/* 가운데 접힘 그림자 */
.half::after, .face::after { content: ""; position: absolute; inset: 0; pointer-events: none; border-radius: inherit; }
.half.left:not(.cover-page)::after  { background: linear-gradient(to left, rgba(0,0,0,.22), rgba(0,0,0,.06) 6%, transparent 14%), linear-gradient(to right, rgba(255,255,255,.08), transparent 4%); }
.half.right:not(.cover-page)::after { background: linear-gradient(to right, rgba(0,0,0,.22), rgba(0,0,0,.06) 6%, transparent 14%); }
.half.cover-page.right::after { background: linear-gradient(to right, rgba(0,0,0,.18), rgba(255,255,255,.12) 2%, transparent 5%); }
.half.cover-page.left::after  { background: linear-gradient(to left, rgba(0,0,0,.18), rgba(255,255,255,.12) 2%, transparent 5%); }

.leaf {
  position: absolute; top: 0; width: 50%; height: 100%;
  transform-style: preserve-3d; display: none; z-index: 4;
}
.leaf .face { left: 0; width: 100%; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.leaf .back { transform: rotateY(180deg); }
.leaf.fwd  { display: block; left: 50%; transform-origin: 0 50%; animation: flipFwd .75s cubic-bezier(.45,.05,.35,1) forwards; }
.leaf.bwd  { display: block; left: 0;   transform-origin: 100% 50%; animation: flipBwd .75s cubic-bezier(.45,.05,.35,1) forwards; }
.leaf.fwd .front::after, .leaf.bwd .back::after { background: linear-gradient(to right, rgba(0,0,0,.2), transparent 14%); }
.leaf.fwd .back::after, .leaf.bwd .front::after { background: linear-gradient(to left, rgba(0,0,0,.2), transparent 14%); }

.nav {
  flex: none; width: 56px; height: 56px; border-radius: 50%; border: 0;
  background: rgba(255,255,255,.95); color: var(--blue-deep); font-size: 20px;
  box-shadow: 0 4px 0 rgba(0,0,0,.25);
  transition: transform .2s var(--ease-pop), opacity .2s;
}
.nav:hover { transform: scale(1.08); }
.nav[disabled] { opacity: .25; pointer-events: none; }
.book-foot { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-top: 22px; color: #fff; min-height: 104px; }
.counter { margin: 0; font-family: var(--font-cute); font-size: 22px; letter-spacing: .06em; }
.progress { width: min(320px, 70vw); height: 6px; border-radius: 3px; background: rgba(255,255,255,.25); overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--gold); border-radius: 3px; transition: width .5s; }
.book-modal { grid-template-rows: 1fr auto; align-content: center; }

/* AR 영상 */
.ar-modal { z-index: 55; background: rgba(10, 16, 40, .8); }
.ar-box { position: relative; background: #fff; padding: 12px; border-radius: 18px; box-shadow: 0 20px 60px rgba(0,0,0,.4); animation: pop .4s var(--ease-pop); }
.ar-box video { display: block; max-width: min(88vw, 960px); max-height: calc(100dvh - 150px); border-radius: 10px; background: #000; }
.ar-tag { position: absolute; left: 22px; top: 22px; z-index: 2; background: #3fb34f; color: #fff; font-family: var(--font-cute); padding: 2px 12px; border-radius: 8px; }

/* ───────────────── 애니메이션 ───────────────── */
@keyframes fadeIn { from { opacity: 0; } }
@keyframes slideIn { from { transform: translateX(-100%); } }
@keyframes pop { from { opacity: 0; transform: translateY(24px) scale(.94); } }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 30px); } }
@keyframes bookIn { from { opacity: 0; transform: translateY(40px) rotateX(18deg) scale(.9); } }
@keyframes flipFwd { from { transform: rotateY(0); } to { transform: rotateY(-180deg); } }
@keyframes flipBwd { from { transform: rotateY(0); } to { transform: rotateY(180deg); } }
@keyframes swing { 0%,100% { transform: rotate(0); } 25% { transform: rotate(5deg); } 75% { transform: rotate(-5deg); } }
@keyframes breathe { 0%,100% { transform: scale(1, 1); } 50% { transform: scale(1.025, .975); } }
@keyframes wobble { 0%,100% { transform: rotate(0); } 25% { transform: rotate(-3deg); } 75% { transform: rotate(3deg); } }
@keyframes twinkle { 0%,100% { opacity: .2; transform: scale(.6); } 50% { opacity: 1; transform: scale(1.1); } }
@keyframes drift1 { 0%,100% { transform: translate(0,0) rotate(-8deg); } 50% { transform: translate(3cqw,-2cqw) rotate(6deg); } }
@keyframes drift2 { 0%,100% { transform: translate(0,0) rotate(10deg); } 50% { transform: translate(-3cqw,1.5cqw) rotate(-4deg); } }
@keyframes spit { 0% { transform: none; } 30% { transform: rotate(-6deg) scale(1.08,.92); } 60% { transform: rotate(4deg) scale(.96,1.05); } 100% { transform: none; } }
.mailbox.spit { animation: spit .6s ease-in-out; }

/* 창·게임이 열려 있는 동안 뒤 장면의 반복 애니메이션 멈춤 (app.js setBusy) */
body.busy .scene *, body.busy .scene *::before, body.busy .scene *::after { animation-play-state: paused !important; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ───────────────── 작은 화면 ───────────────── */
@media (max-aspect-ratio: 1/1) {
  /* 세로 화면: 장면을 옆으로 밀어서 둘러봄 */
  .viewport { overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .viewport::-webkit-scrollbar { display: none; }
  .stage { left: 0; top: 0; transform: none; height: 100dvh; width: calc(100dvh * 1.7769); box-shadow: none; }
  .viewport::before { display: none; } /* 세로 화면은 그림이 꽉 차므로 흐린 가장자리 불필요 */
  .scroll-hint {
    display: block; position: fixed; left: 50%; bottom: 84px; z-index: 20; transform: translateX(-50%);
    margin: 0; padding: 6px 16px; border-radius: 999px; white-space: nowrap;
    background: rgba(29, 47, 90, .85); color: #fff; font-family: var(--font-cute); font-size: 16px;
    animation: fadeIn .4s, hintOut .6s 5s forwards;
  }
  #outside .viewport { overflow: hidden; }
  .to-games { position: fixed; right: 72px; bottom: 12px; }
  #inside.scrolled .to-games { opacity: 0; pointer-events: none; }
  .title-card { left: 50%; top: 24%; width: min(calc(100vw - 32px), 520px); padding: 26px 20px 22px; border-radius: 22px; }
  .logo-l1 { font-size: 30px; }
  .logo-l2 { font-size: 74px; }
  .t-line { font-size: 17px; margin-bottom: 18px; }
  .title-card .pill-btn.big { font-size: 20px; }
  .t-meta { font-size: 14px; margin-top: 14px; }
  .fly { width: 64px; } .f2 { width: 54px; } .f3 { width: 50px; }
  .book-modal .close { top: 14px; }
}
@keyframes hintOut { to { opacity: 0; visibility: hidden; } }
@media (max-width: 760px) {
  body { font-size: 18px; }
  .topbar-title { font-size: 18px; padding: 5px 14px; }
  .topbar-title .sm { display: none; }
  #topBookBtn { font-size: 15px; padding: .5em .9em; }
  .stamps, .game-arts { grid-template-columns: 1fr; }
  .pc-front { grid-template-columns: 104px 1fr; gap: 14px; }
  .pc-face { padding: 20px; }
  .pc-quote { font-size: 25px; margin-right: 60px; }
  .pc-mini { width: 52px; right: 16px; }
  .seal { right: 70px; width: 112px; height: 81px; } /* 오른쪽 위 작은 얼굴과 겹치지 않게 */
  .seal-hand { width: 172px; left: 11px; top: -58px; }
  .author-row, .info-grid { grid-template-columns: 1fr; }
  .info-grid .cover { width: 60%; margin: 0 auto; }
  .book { --w: min(calc(100vw - 24px), calc((100dvh - 230px) * 1.68)); }
  .book-wrap { flex-wrap: wrap; }
  .nav { position: fixed; bottom: 22px; z-index: 3; }
  .nav.prev { left: 16px; } .nav.next { right: 16px; }
  .icon-btn, .help-badge { width: 46px; height: 46px; }
}
