/* 크레용 그림책 콜라주. 색 · 글자 · 간격은 이 :root 토큰만 쓴다 (hud-ux §6). */
:root {
  --paper: #FBF4E6;          /* 바탕 종이 */
  --paper-2: #F3E4C8;        /* 접힌 면, 책등 */
  --card: #FFFDF8;           /* 오려 붙인 카드 */
  --ink: #3A2C26;            /* 본문: paper 위 대비 12.9:1 */
  --ink-soft: #6B5A50;       /* 보조: paper 위 대비 6.2:1 */
  --tomato: #C23E25;         /* 흰 글자 5.2:1, card 위 5.2:1, paper 위 4.8:1 (모두 4.5 이상) */
  --tomato-deep: #A3341F;
  --sun: #F2B93D;
  --sky: #3E86C6;
  --leaf: #4E9A52;
  --plum: #8A57A6;
  --pink: #EE82A8;
  --shadow: rgba(58, 44, 38, .9);
  --shade: rgba(58, 44, 38, .12);

  --font-display: "Jua", "Gowun Dodum", system-ui, sans-serif;
  --font-body: "Gowun Dodum", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  --fs-hero: clamp(2rem, 4.2vw, 3.4rem);
  --fs-h2: clamp(1.5rem, 2.6vw, 2.1rem);
  --fs-story: clamp(1.25rem, 2vw, 1.7rem);
  --fs-body: 1.05rem;
  --fs-small: .92rem;

  --r: 18px;
  --gap: clamp(12px, 2vw, 24px);
  --tap: 52px;               /* 터치 최소 48dp 이상 */
  --pop: 4px 5px 0 var(--shadow);
  --ease-pop: cubic-bezier(.34, 1.56, .64, 1);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  color: var(--ink);
  font: var(--fs-body)/1.6 var(--font-body);
  background-color: var(--paper);
  /* 종이 결: 잔 노이즈 + 아주 옅은 줄 */
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 .35 0 0 0 0 .27 0 0 0 0 .2 0 0 0 .07 0'/%3E%3C/filter%3E%3Crect width='220' height='220' filter='url(%23n)'/%3E%3C/svg%3E"),
    radial-gradient(ellipse at 20% 0%, #fffaf0 0%, transparent 60%);
  background-attachment: fixed;
  overflow-x: hidden;
}
button, input { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }

/* ---------- 상단 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 10px max(16px, env(safe-area-inset-left));
}
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  min-height: 44px; padding: 0 6px; border: 0; background: none; cursor: pointer;
  font: 1.35rem var(--font-display); letter-spacing: .5px;
}
.brand-mark {
  width: 14px; height: 34px; border-radius: 4px 4px 2px 2px; background: var(--tomato);
  transform: rotate(24deg); box-shadow: 2px 2px 0 var(--shadow); position: relative;
}
.brand-mark::after { content: ""; position: absolute; left: 3px; top: -7px; border: 4px solid transparent; border-bottom: 7px solid var(--sun); }
.badge {
  font: .95rem var(--font-display); padding: 4px 12px; border-radius: 99px;
  background: var(--sun); box-shadow: 2px 2px 0 var(--shadow); transform: rotate(-3deg);
}
.icon-btn {
  margin-left: auto; min-height: 44px; min-width: 44px; padding: 0 14px;
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  border: 2px solid var(--ink); border-radius: 99px; background: var(--card);
}
.icon-btn[aria-pressed="false"] { opacity: .55; }
.icon-btn[aria-pressed="false"] span:first-child { filter: grayscale(1); }

/* ---------- 화면 전환 ---------- */
#app { min-height: calc(100dvh - 64px); display: grid; }
.screen { display: none; padding: var(--gap) max(16px, var(--gap)) calc(var(--gap) * 1.5); }
.screen.on { display: grid; animation: screen-in .45s var(--ease-pop) both; }
@keyframes screen-in { from { opacity: 0; transform: translateY(14px) scale(.985); } }

/* ---------- 공통 카드 · 버튼 (오려 붙인 종이) ---------- */
.btn {
  position: relative; isolation: isolate;
  min-height: var(--tap); padding: 0 22px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 1.2rem var(--font-display); letter-spacing: .3px;
  border: 0; border-radius: 14px; background: var(--card); cursor: pointer;
  box-shadow: var(--pop);
  transition: transform .15s var(--ease-pop), box-shadow .15s;
}
.btn::before { /* 손으로 그린 테두리 */
  content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit;
  border: 2.5px solid var(--ink); filter: url(#rough);
}
.btn:hover:not(:disabled) { transform: translate(-1px, -2px) rotate(-.6deg); box-shadow: 6px 8px 0 var(--shadow); }
.btn:active:not(:disabled) { transform: translate(3px, 4px); box-shadow: 1px 1px 0 var(--shadow); }
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: 2px 2px 0 var(--shade); }
.btn[aria-disabled="true"] { opacity: .5; box-shadow: 2px 2px 0 var(--shade); }
.btn:focus-visible, .link-btn:focus-visible, .choice:focus-visible, .tool:focus-visible, .icon-btn:focus-visible, .brand:focus-visible {
  outline: 3px dashed var(--sky); outline-offset: 4px;
}
.btn-primary { background: var(--tomato); color: #fff; }
.btn-primary::before { border-color: var(--ink); }
.btn-big { min-height: 64px; padding: 0 30px; font-size: 1.45rem; }
.link-btn {
  min-height: 44px; padding: 0 6px; border: 0; background: none; cursor: pointer;
  color: var(--ink-soft); text-decoration: underline wavy var(--sun) 2px; text-underline-offset: 6px;
}
.hint { color: var(--ink-soft); margin: 0; }
h1, h2 { font-family: var(--font-display); font-weight: 400; margin: 0; line-height: 1.25; }
h2 { font-size: var(--fs-h2); }

/* ---------- 표지 ---------- */
.title-card {
  place-self: center; text-align: center; max-width: 640px;
  display: grid; justify-items: center; gap: 18px; padding: 24px 8px;
}
.title-card h1 { font-size: var(--fs-hero); }
.title-card h1 em {
  font-style: normal; color: var(--tomato);
  background: linear-gradient(transparent 62%, rgba(242, 185, 61, .55) 62% 92%, transparent 92%);
}
.lead { font-size: 1.2rem; color: var(--ink-soft); margin: 0; }
.crayon-row { display: flex; gap: 10px; margin-bottom: 4px; }
.crayon-row i {
  width: 18px; height: 70px; border-radius: 5px 5px 3px 3px; position: relative;
  box-shadow: 2px 3px 0 var(--shadow); animation: crayon-bob 2.8s ease-in-out infinite;
}
.crayon-row i::after { content: ""; position: absolute; left: 2px; top: -12px; border: 7px solid transparent; border-bottom: 12px solid currentColor; }
.crayon-row i:nth-child(1) { background: var(--tomato); color: var(--tomato); transform: rotate(-8deg); }
.crayon-row i:nth-child(2) { background: var(--sun); color: var(--sun); animation-delay: -.5s; }
.crayon-row i:nth-child(3) { background: var(--leaf); color: var(--leaf); transform: rotate(6deg); animation-delay: -1s; }
.crayon-row i:nth-child(4) { background: var(--sky); color: var(--sky); animation-delay: -1.5s; }
.crayon-row i:nth-child(5) { background: var(--plum); color: var(--plum); transform: rotate(-5deg); animation-delay: -2s; }
@keyframes crayon-bob { 50% { translate: 0 -8px; } }

/* ---------- 그리기 ---------- */
.draw-screen {
  grid-template-columns: minmax(200px, 300px) auto minmax(84px, 120px);
  grid-template-areas: "side sheet tools" "side actions actions";
  justify-content: center; align-items: start; gap: var(--gap);
}
.draw-side { grid-area: side; display: grid; gap: 12px; align-content: start; padding-top: 8px; }
.step { margin: 0; font: 1rem var(--font-display); color: var(--tomato); }
.name-field { display: grid; gap: 6px; font-size: var(--fs-small); color: var(--ink-soft); margin-top: 8px; }
.name-field input {
  min-height: var(--tap); padding: 0 14px; font: 1.25rem var(--font-display); color: var(--ink);
  border: 2.5px solid var(--ink); border-radius: 12px; background: var(--card);
}
.name-field input:focus { outline: 3px dashed var(--sky); outline-offset: 3px; }
.ghost { display: grid; gap: 6px; justify-items: start; margin-top: 8px; color: var(--ink-soft); font-size: var(--fs-small); }
.ghost img { width: 120px; height: 120px; object-fit: contain; background: var(--card); border-radius: 12px; box-shadow: var(--pop); padding: 6px; transform: rotate(-3deg); }

.sheet {
  grid-area: sheet; position: relative;
  width: min(72dvh, 58vw, 620px); aspect-ratio: 1;
  background: #fff; border-radius: 6px; padding: 0;
  box-shadow: 0 1px 0 var(--shade), 6px 8px 0 var(--shade), 0 18px 40px -18px rgba(58, 44, 38, .45);
  transform: rotate(-.6deg);
}
.sheet canvas { width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; border-radius: 6px; }
.sheet.transparent { background-color: #fff; background-image: conic-gradient(#f4efe6 25%, transparent 0 50%, #f4efe6 0 75%, transparent 0); background-size: 32px 32px; }
.tape { position: absolute; top: -14px; width: 96px; height: 30px; background: rgba(242, 185, 61, .55); box-shadow: 0 1px 2px var(--shade); }
.tape-l { left: 18px; transform: rotate(-8deg); }
.tape-r { right: 18px; transform: rotate(7deg); }

.toolbox { grid-area: tools; display: grid; gap: 10px; justify-items: center; align-content: start; }
.crayons { display: grid; grid-template-columns: repeat(2, 48px); gap: 10px; }
.tool {
  width: 48px; height: var(--tap); border: 0; cursor: pointer; border-radius: 10px;
  display: grid; place-items: center; background: var(--card); box-shadow: 2px 3px 0 var(--shadow);
  transition: transform .15s var(--ease-pop);
}
.tool.crayon { background: var(--c); position: relative; border-radius: 8px 8px 12px 12px; }
.tool.crayon::after { /* 크레용 끝 */
  content: ""; position: absolute; top: -9px; left: 50%; translate: -50% 0;
  border: 9px solid transparent; border-bottom: 10px solid var(--c); border-top: 0;
}
.tool[aria-pressed="true"] { transform: translateY(-6px) rotate(-6deg); outline: 3px solid var(--ink); outline-offset: 2px; }
.tool-row { display: flex; gap: 10px; }
.tool .dot { border-radius: 50%; background: var(--ink); }

.draw-actions { grid-area: actions; display: flex; gap: 12px; justify-content: flex-end; flex-wrap: wrap; }

/* 가이드 그리기 */
.chip-label { margin: 6px 0 0; font: 1rem var(--font-display); color: var(--ink-soft); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 44px; padding: 0 16px; border-radius: 99px; border: 2px solid var(--ink); background: var(--card); font: 1.05rem var(--font-display); cursor: pointer; transition: transform .15s var(--ease-pop); }
.chip:hover { transform: translateY(-2px) rotate(-1deg); }
.chip[aria-pressed="true"] { background: var(--sun); box-shadow: 2px 3px 0 var(--shadow); transform: rotate(-2deg); }
.chip:focus-visible { outline: 3px dashed var(--sky); outline-offset: 3px; }
.guide { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 8px; }
.guide li { display: flex; gap: 10px; align-items: center; padding: 8px 12px; border-radius: 12px; color: var(--ink-soft); transition: background .3s, transform .3s var(--ease-pop); }
.guide li .ico { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; background: var(--card); box-shadow: 1px 2px 0 var(--shade); flex: none; }
.guide li.now { background: var(--card); color: var(--ink); box-shadow: 3px 4px 0 var(--shadow); transform: rotate(-.6deg) scale(1.02); font-family: var(--font-display); }
.guide li.now .ico { background: var(--sun); animation: wiggle 2s ease-in-out infinite; }
.guide li.done { text-decoration: line-through wavy var(--leaf) 1.5px; opacity: .7; }
.guide-ghost { position: absolute; inset: 18%; border: 4px dashed rgba(62, 134, 198, .35); border-radius: 50%; display: grid; place-items: center; pointer-events: none; animation: ghost-breathe 2.6s ease-in-out infinite; }
.guide-ghost span { font: 1.1rem var(--font-display); color: rgba(62, 134, 198, .85); background: rgba(255, 255, 255, .85); padding: 4px 12px; border-radius: 99px; }
@keyframes ghost-breathe { 50% { transform: scale(1.04); border-color: rgba(62, 134, 198, .55); } }

/* ---------- 깨어나는 중 · 변신 ---------- */
.wake-screen { grid-template-columns: minmax(260px, 440px) minmax(300px, 500px); gap: calc(var(--gap) * 2); align-items: center; justify-content: center; }
.wake-stage { position: relative; justify-self: center; width: min(42vw, 420px); aspect-ratio: 1; display: grid; place-items: center; }
.wake-char { max-width: 78%; max-height: 78%; object-fit: contain; animation: wake-hop 1.1s ease-in-out infinite; filter: drop-shadow(3px 4px 0 rgba(58, 44, 38, .18)); }
.wake-stage.listening .wake-char { animation: wake-hop 1.6s ease-in-out infinite; }
.wake-stage.magic .wake-char { animation: magic-spin .65s ease-in both; }
.wake-stage.transformed .wake-char { animation: wake-pop .8s var(--ease-pop) both, hero-sway 3.2s ease-in-out .8s infinite; max-width: 92%; max-height: 92%; }
@keyframes magic-spin { to { transform: rotate(540deg) scale(.1); opacity: 0; filter: brightness(3); } }
.burst { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.burst i { position: absolute; width: 16px; height: 16px; background: var(--sun); clip-path: polygon(50% 0, 61% 39%, 100% 50%, 61% 61%, 50% 100%, 39% 61%, 0 50%, 39% 39%); opacity: 0; }
.wake-stage.magic .burst i { animation: burst .9s ease-out .5s both; }
.burst i:nth-child(1) { --a: 0deg; } .burst i:nth-child(2) { --a: 45deg; background: var(--pink); } .burst i:nth-child(3) { --a: 90deg; background: var(--sky); } .burst i:nth-child(4) { --a: 135deg; }
.burst i:nth-child(5) { --a: 180deg; background: var(--leaf); } .burst i:nth-child(6) { --a: 225deg; } .burst i:nth-child(7) { --a: 270deg; background: var(--plum); } .burst i:nth-child(8) { --a: 315deg; background: var(--pink); }
@keyframes burst { 0% { opacity: 1; transform: rotate(var(--a)) translateY(0) scale(.5); } 100% { opacity: 0; transform: rotate(var(--a)) translateY(-180px) scale(1.6) rotate(180deg); } }
.before-after { position: absolute; left: -2%; bottom: -4%; margin: 0; width: 34%; padding: 8px 8px 6px; background: #fff; border-radius: 6px; box-shadow: 4px 5px 0 var(--shade); transform: rotate(-6deg); animation: card-deal .6s var(--ease-pop) both; display: grid; gap: 4px; }
.before-after img { width: 100%; aspect-ratio: 1; object-fit: contain; }
.before-after figcaption { font: .85rem var(--font-display); text-align: center; color: var(--ink-soft); }
.wake-text h2 small { display: block; margin-top: 6px; font: 1rem var(--font-body); color: var(--ink-soft); }
.floor-shadow { position: absolute; bottom: 9%; width: 46%; height: 22px; border-radius: 50%; background: var(--shade); animation: shadow-pulse 1.1s ease-in-out infinite; }
@keyframes wake-hop { 0%, 100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-16px) rotate(2deg); } }
@keyframes shadow-pulse { 50% { transform: scaleX(.8); opacity: .6; } }
@keyframes wake-pop { 0% { transform: scale(.85); } 60% { transform: scale(1.08) rotate(-3deg); } }
.sparkles i {
  position: absolute; width: 22px; height: 22px; background: var(--sun);
  clip-path: polygon(50% 0, 61% 39%, 100% 50%, 61% 61%, 50% 100%, 39% 61%, 0 50%, 39% 39%);
  animation: twinkle 1.8s ease-in-out infinite;
}
.sparkles i:nth-child(1) { top: 8%; left: 14%; }
.sparkles i:nth-child(2) { top: 18%; right: 10%; animation-delay: -.4s; background: var(--pink); }
.sparkles i:nth-child(3) { bottom: 26%; left: 4%; animation-delay: -.8s; background: var(--sky); }
.sparkles i:nth-child(4) { bottom: 14%; right: 14%; animation-delay: -1.2s; }
.sparkles i:nth-child(5) { top: 2%; left: 52%; animation-delay: -.6s; background: var(--leaf); width: 14px; height: 14px; }
.sparkles i:nth-child(6) { top: 46%; right: 0; animation-delay: -1.5s; background: var(--plum); width: 14px; height: 14px; }
@keyframes twinkle { 0%, 100% { transform: scale(.4) rotate(0); opacity: .3; } 50% { transform: scale(1) rotate(45deg); opacity: 1; } }

.wake-text { display: grid; gap: 14px; justify-items: start; }
.trait-cards { list-style: none; margin: 4px 0; padding: 0; display: grid; gap: 12px; width: 100%; }
.trait {
  position: relative; isolation: isolate; padding: 12px 16px 12px 58px;
  background: var(--card); border-radius: 14px; box-shadow: 3px 4px 0 var(--shadow);
  animation: card-deal .55s var(--ease-pop) both; animation-delay: calc(var(--i) * .45s);
}
.trait:nth-child(odd) { rotate: -.8deg; } .trait:nth-child(even) { rotate: .7deg; }
.trait::before { content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit; border: 2px solid var(--ink); filter: url(#rough); }
.trait .num {
  position: absolute; left: 12px; top: 50%; translate: 0 -50%;
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  font: 1.1rem var(--font-display); color: #fff; background: var(--c, var(--sky));
}
.trait .look { font: 1.2rem var(--font-display); }
.trait .power { color: var(--ink-soft); }
.trait .power::before { content: "→ "; color: var(--tomato); font-weight: 700; }
@keyframes card-deal { from { opacity: 0; transform: translateX(40px) rotate(6deg) scale(.9); } }

/* ---------- 장면: 펼친 책 ---------- */
.scene-screen { place-items: center; position: relative; }
.book {
  width: min(1180px, 100%); display: grid; grid-template-columns: 1.08fr 1fr;
  background: var(--paper-2); padding: 12px; border-radius: 22px;
  box-shadow: 0 2px 0 var(--shade), 8px 12px 0 var(--shade), 0 30px 60px -30px rgba(58, 44, 38, .5);
}
.page { position: relative; background: var(--card); min-height: min(70dvh, 620px); }
.page-left { border-radius: 14px 4px 4px 14px; overflow: hidden; }
.page-right {
  border-radius: 4px 14px 14px 4px; padding: clamp(18px, 3vw, 40px);
  display: flex; flex-direction: column; gap: 14px;
  background-image: linear-gradient(90deg, rgba(58, 44, 38, .1), transparent 7%);
}
.page-left::after { content: ""; position: absolute; inset: 0 0 0 auto; width: 9%; background: linear-gradient(270deg, rgba(58, 44, 38, .14), transparent); pointer-events: none; }
.page-no { position: absolute; left: 16px; bottom: 12px; font: .95rem var(--font-display); color: var(--ink-soft); background: var(--card); padding: 2px 10px; border-radius: 99px; }
.chapter { margin: 0; font: 1rem var(--font-display); color: var(--tomato); }
.story-text { font-size: var(--fs-story); line-height: 1.75; min-height: 6.5em; }
.story-text span { display: block; animation: line-in .6s ease both; animation-delay: calc(var(--i) * .55s); }
@keyframes line-in { from { opacity: 0; transform: translateY(8px); filter: blur(2px); } }
.replay { align-self: flex-start; }
.page-right.turning { animation: page-turn .5s ease both; transform-origin: left center; }
@keyframes page-turn { 0% { transform: perspective(1400px) rotateY(0); } 45% { transform: perspective(1400px) rotateY(-12deg); opacity: .4; } 100% { transform: none; } }

.choices { margin-top: auto; display: grid; gap: 12px; }
.choice {
  position: relative; isolation: isolate; text-align: left; cursor: pointer;
  min-height: 60px; padding: 12px 18px 12px 64px; border: 0; border-radius: 16px;
  background: var(--card); font: 1.2rem var(--font-display); box-shadow: 3px 4px 0 var(--shadow);
  transition: transform .15s var(--ease-pop), box-shadow .15s;
  animation: card-deal .5s var(--ease-pop) both; animation-delay: calc(1s + var(--i) * .15s);
}
.choice::before { content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit; border: 2.5px solid var(--ink); filter: url(#rough); }
/* 선택지 성향 꼬리표 (D-019) */
.choice .tone { display: inline-block; margin-right: 8px; padding: 1px 9px; border-radius: 99px; font-size: .85rem; vertical-align: 2px; border: 1.5px solid var(--ink); }
.t-brave { background: #FFD9C7; } .t-kind { background: #FFDCEB; } .t-silly { background: #DDF0C9; }
.tone-badge { display: inline-block; margin: 0 0 8px !important; padding: 4px 14px; border-radius: 99px; background: var(--sun); color: var(--ink); font: 1.1rem var(--font-display); transform: rotate(-3deg); box-shadow: 2px 3px 0 rgba(0, 0, 0, .25); }
.spread .said { margin-top: 8px; font: 1.1rem var(--font-display); color: var(--plum); }
.choice .key {
  position: absolute; left: 14px; top: 50%; translate: 0 -50%; width: 36px; height: 36px;
  display: grid; place-items: center; border-radius: 50%; background: var(--sun); font-size: 1.05rem;
}
.choice:hover:not(:disabled) { transform: translate(-2px, -2px) rotate(-.5deg); box-shadow: 6px 7px 0 var(--shadow); }
.choice:disabled { cursor: default; opacity: .5; }
.choice.picked { opacity: 1; background: #FFF3C9; }
.choice.picked::after { content: "선택!"; position: absolute; right: 14px; top: -12px; font-size: .95rem; padding: 2px 10px; background: var(--tomato); color: #fff; border-radius: 6px; transform: rotate(6deg); }
.choice.draw { background: linear-gradient(100deg, #FFF0F4, #FFF8E2 60%, #EAF4FF); }
.choice.draw .key { background: var(--pink); }
.choice.draw .sub { display: block; font: var(--fs-small) var(--font-body); color: var(--ink-soft); }
.choice.draw:not(:disabled) { animation: card-deal .5s var(--ease-pop) both, wiggle 2.4s ease-in-out 2s infinite; animation-delay: calc(1s + var(--i) * .15s), 2s; }
@keyframes wiggle { 0%, 88%, 100% { rotate: 0; } 91% { rotate: -1.6deg; } 94% { rotate: 1.4deg; } 97% { rotate: -.6deg; } }
.choice.end { background: var(--tomato); color: #fff; }
.choice.end .key { background: var(--card); }
/* 다음 장 대기: 흐름 밖에 겹쳐 띄운다. 선택지 · 글을 밀어내지 않고, 고른 선택지는 그대로 강조된 채 기다린다. */
.writing { position: absolute; z-index: 3; top: clamp(12px, 2.2vw, 26px); right: clamp(12px, 2.2vw, 26px);
  display: flex; align-items: center; gap: 8px; padding: 6px 14px 6px 10px; border-radius: 99px;
  background: var(--card); box-shadow: 2px 3px 0 var(--shade), 0 0 0 1.5px rgba(58, 44, 38, .12);
  font: 1rem var(--font-display); color: var(--ink-soft); animation: writing-in .35s var(--ease-pop) both; pointer-events: none; }
.writing[hidden] { display: none; }
/* 첫 장면처럼 페이지가 비어 있을 때는 가운데에 */
.page-right:has(#storyText:empty) .writing { top: 42%; right: auto; left: 50%; translate: -50% 0; font-size: 1.15rem; padding: 10px 18px; }
@keyframes writing-in { from { opacity: 0; transform: translateY(-6px) scale(.92); } }
.pencil { display: inline-block; animation: scribble .5s ease-in-out infinite alternate; }
@keyframes scribble { from { transform: translateX(-4px) rotate(-12deg); } to { transform: translateX(6px) rotate(8deg); } }
.dots::after { content: ""; animation: dots 1.2s steps(4) infinite; }
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }

/* ---------- 무대: 층으로 쌓은 공간 (D-017) ----------
   --px, --py: -1..1. stage.js 가 손가락 · 마우스 위치나 스스로 흔들리는 값으로 채운다. 층마다 다른 깊이로 움직인다. */
.stage { position: absolute; inset: 0; overflow: hidden; background: #fff; --px: 0; --py: 0; }
.stage .tilt { position: absolute; inset: 0; animation: paper-sway 9s ease-in-out infinite; transform-origin: 50% 60%; }
@keyframes paper-sway { 0%, 100% { transform: scale(1.02); } 50% { transform: rotate(.5deg) scale(1.02); } }
.layer { position: absolute; inset: 0; }
.l-bg { inset: -5%; transform: translate(calc(var(--px) * -10px), calc(var(--py) * -6px)); }
.bg-img { position: absolute; inset: 0; background: linear-gradient(#DDEFFF, #FFF8E8 66%, #E7F2D9 66%) center / cover no-repeat; animation: ken 26s ease-in-out infinite alternate; }
.bg-img.next { opacity: 0; transition: opacity .9s ease; }
.bg-img.next.show { opacity: 1; }
@keyframes ken { from { transform: scale(1.02) translate(-1%, 0); } to { transform: scale(1.1) translate(1.5%, -1%); } }
.l-mid { transform: translate(calc(var(--px) * 12px), calc(var(--py) * 7px)); }
.l-fx { pointer-events: none; transform: translate(calc(var(--px) * 22px), calc(var(--py) * 12px)); }

/* 카메라 구도 (D-021): 주인공이 넓은 세상 속에 작게 녹아들 때(wide)와 감정이 크게 보일 때(close)를 오간다.
   크기 · 위치 · 배경 확대 · 배경 흐림이 1.4초에 걸쳐 바뀌어 카메라가 움직이는 것처럼 보인다. */
.l-bg { scale: var(--zoom, 1.04); filter: blur(var(--blur, 0)); transition: scale 1.4s ease, filter 1.4s ease; }
.stage[data-shot="wide"] { --zoom: 1; --hero-h: 30%; --hero-b: 10%; --extra-w: 15%; }
.stage[data-shot="medium"] { --zoom: 1.06; --hero-h: 56%; --hero-b: 5%; --extra-w: 22%; }
.stage[data-shot="close"] { --zoom: 1.22; --blur: 1.4px; --hero-h: 84%; --hero-b: -12%; --extra-w: 26%; }
.stage .hero { height: var(--hero-h, 56%); bottom: var(--hero-b, 5%); transition: left 1s var(--ease-pop), height 1.4s ease, bottom 1.4s ease; }
.stage .extra { width: var(--extra-w, 22%); transition: width 1.4s ease; }
/* 멀리 있는 주인공은 풍경 색에 조금 섞인다(대기 원근) */
.stage[data-shot="wide"] .hero img { filter: saturate(.92) brightness(1.02) drop-shadow(1px 2px 0 rgba(58, 44, 38, .1)); }
.stage[data-shot="wide"] .hero .shadow { opacity: .6; }
.stage[data-shot="close"] .hero .shadow { opacity: 0; } /* 클로즈업은 발이 화면 밖 */
.stage[data-shot="close"] .hero .bubble { bottom: 70%; }

/* 하이라이트: 장면 전체 일러스트. 천천히 다가가고 빛이 한 번 지나간다 */
.l-spot { inset: -4%; opacity: 0; transition: opacity 1.1s ease; overflow: hidden; }
.l-spot img { width: 100%; height: 100%; object-fit: cover; transform: translate(calc(var(--px) * -8px), calc(var(--py) * -5px)); }
.l-spot.show { opacity: 1; }
.l-spot.show img { animation: spot-zoom 16s ease-out both; }
@keyframes spot-zoom { from { scale: 1.02; } to { scale: 1.14; } }
.l-spot .sweep { position: absolute; inset: 0; background: linear-gradient(105deg, transparent 35%, rgba(255, 250, 225, .55) 50%, transparent 65%); transform: translateX(-120%); }
.l-spot.show .sweep { animation: sweep 2.6s ease .6s 1; }
@keyframes sweep { to { transform: translateX(120%); } }
.stage.spotlight .l-mid { opacity: 0; transition: opacity .8s; }

/* 주인공 */
.hero { position: absolute; bottom: 5%; height: 56%; aspect-ratio: 1; translate: -50% 0; transition: left 1s var(--ease-pop); }
.hero.pos-left { left: 30%; } .hero.pos-center { left: 50%; } .hero.pos-right { left: 70%; }
/* 그림자는 위치 지정 요소라 그대로 두면 캐릭터 그림 '위에' 그려졌다 → 캐릭터를 위 층(z-index 1)으로, 그림자는 발밑 뒤로. */
.hero .shadow { position: absolute; z-index: 0; left: 16%; right: 16%; bottom: -2.5%; height: 9%; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(58, 44, 38, .26), rgba(58, 44, 38, .1) 62%, transparent);
  animation: shadow-breathe 3.2s ease-in-out infinite; transform-origin: 50% 50%; }
.hero .sway { position: relative; z-index: 1; }
.hero:has(.m-jump) .shadow { animation: shadow-jump 1.1s var(--ease-pop) 2; }
.hero:has(.m-bounce) .shadow { animation: shadow-jump 1s ease-in-out 3; }
.hero:has(.m-float) .shadow { animation: shadow-jump 3s ease-in-out 2; }
@keyframes shadow-jump { 45% { transform: scale(.55); opacity: .45; } }
.hero .sway { width: 100%; height: 100%; transform-origin: 50% 95%; animation: hero-sway 3.2s ease-in-out infinite; }
.hero .move { width: 100%; height: 100%; transform-origin: 50% 100%; }
.hero img { width: 100%; height: 100%; object-fit: contain; object-position: bottom; filter: drop-shadow(2px 4px 0 rgba(58, 44, 38, .12)); }
@keyframes hero-sway { 0%, 100% { transform: rotate(-2.5deg) scaleY(1); } 50% { transform: rotate(2.5deg) scaleY(1.03); } }
@keyframes shadow-breathe { 50% { transform: scaleX(.88); opacity: .75; } }
.hero.poof .move { animation: poof .7s var(--ease-pop) both; }
@keyframes poof { 0% { transform: scale(.3) rotate(-25deg); opacity: 0; filter: brightness(2.2); } 60% { transform: scale(1.12) rotate(4deg); opacity: 1; } 100% { transform: none; filter: none; } }

.m-bounce { animation: m-bounce 1s ease-in-out 3; }
.m-jump { animation: m-jump 1.1s var(--ease-pop) 2; }
.m-wobble { animation: m-wobble 1.2s ease-in-out 2; }
.m-shake { animation: m-shake .5s ease-in-out 3; }
.m-grow { animation: m-grow 1.6s var(--ease-pop) 1 both; }
.m-walk { animation: m-walk 2.4s ease-in-out 1; }
.m-spin { animation: m-spin 1.4s var(--ease-pop) 1; }
.m-float { animation: m-float 3s ease-in-out 2; }
@keyframes m-bounce { 50% { transform: translateY(-9%) scaleY(1.04); } }
@keyframes m-jump { 0%, 100% { transform: none; } 15% { transform: scaleY(.85) scaleX(1.1); } 45% { transform: translateY(-28%) rotate(-6deg); } 75% { transform: translateY(0) scaleY(.92); } }
@keyframes m-wobble { 25% { transform: rotate(-7deg); } 75% { transform: rotate(7deg); } }
@keyframes m-shake { 20%, 60% { transform: translateX(-4%); } 40%, 80% { transform: translateX(4%); } }
@keyframes m-grow { 50% { transform: scale(1.18); } 100% { transform: scale(1.06); } }
@keyframes m-walk { 0% { transform: translateX(-30%); } 15%, 45%, 75% { transform: translateX(-15%) translateY(-4%) rotate(3deg); } 30%, 60% { transform: translateX(0) rotate(-3deg); } 100% { transform: translateX(0); } }
@keyframes m-spin { 0% { transform: rotate(0); } 70% { transform: rotate(370deg) scale(1.08); } 100% { transform: rotate(360deg); } }
@keyframes m-float { 50% { transform: translateY(-14%) rotate(3deg); } }

/* 아이가 그려 준 소품 */
.prop-sprite { position: absolute; bottom: 3%; height: 48%; z-index: 2; aspect-ratio: 1; object-fit: contain; object-position: bottom; filter: drop-shadow(2px 4px 0 rgba(58, 44, 38, .12)); animation: prop-sway 4s ease-in-out infinite; transform-origin: 50% 100%; }
.prop-sprite.side-left { left: 4%; } .prop-sprite.side-right { right: 4%; }
.prop-sprite.pop { animation: prop-in .9s var(--ease-pop) both, prop-sway 4s ease-in-out .9s infinite; }
@keyframes prop-in { 0% { opacity: 0; transform: translateY(-60%) rotate(-25deg) scale(.4); } 70% { opacity: 1; } }
@keyframes prop-sway { 50% { transform: rotate(1.5deg); } }

/* 이야기에 새로 나온 친구 · 물건 */
.extra { position: absolute; width: 24%; aspect-ratio: 1; animation: extra-in .8s var(--ease-pop) both; }
.extra img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(2px 4px 0 rgba(58, 44, 38, .1)); }
.slot-sky-right { right: 6%; top: 8%; } .slot-sky-left { left: 6%; top: 10%; }
.slot-ground-right { right: 3%; bottom: 6%; width: 22%; } .slot-ground-left { left: 3%; bottom: 6%; width: 22%; }
@keyframes extra-in { from { opacity: 0; transform: scale(.2) rotate(-30deg); } }
.e-float img { animation: e-float 4s ease-in-out infinite; }
.e-flutter img { animation: e-flutter 2.6s ease-in-out infinite; }
.e-bounce img { animation: e-bounce 1.4s ease-in-out infinite; transform-origin: 50% 100%; }
.e-spin img { animation: e-spin 6s linear infinite; }
.e-sway img { animation: e-sway 3.4s ease-in-out infinite; transform-origin: 50% 100%; }
@keyframes e-float { 50% { transform: translateY(-12%) rotate(4deg); } }
@keyframes e-flutter { 0%, 100% { transform: translate(0, 0) rotate(-6deg); } 25% { transform: translate(-14%, -10%) rotate(4deg) scaleX(.92); } 50% { transform: translate(-4%, -18%) rotate(-3deg); } 75% { transform: translate(8%, -6%) rotate(6deg) scaleX(.94); } }
@keyframes e-bounce { 0%, 100% { transform: none; } 40% { transform: translateY(-18%) scaleY(1.05); } 55% { transform: scaleY(.9) scaleX(1.06); } }
@keyframes e-spin { to { transform: rotate(360deg); } }
@keyframes e-sway { 50% { transform: rotate(6deg); } }

/* 효과 입자 */
.fx { position: absolute; left: var(--x); top: var(--y); animation-delay: var(--d); animation-duration: var(--t); animation-iteration-count: infinite; scale: var(--s); }
.fx-sparkle, .fx-star { width: 18px; height: 18px; background: #FFE27A; clip-path: polygon(50% 0, 61% 39%, 100% 50%, 61% 61%, 50% 100%, 39% 61%, 0 50%, 39% 39%); animation-name: twinkle; filter: drop-shadow(0 0 4px #fff7c2); }
.fx-star { width: 26px; height: 26px; background: #FFF3B0; }
.fx-petal { top: -6%; width: 14px; height: 10px; border-radius: 80% 0 80% 0; background: #F7A8C4; animation-name: fall-sway; animation-timing-function: linear; }
.fx-leaf { top: -6%; width: 16px; height: 10px; border-radius: 0 80% 0 80%; background: #8CC56B; animation-name: fall-sway; animation-timing-function: linear; }
.fx-snow { top: -4%; width: 8px; height: 8px; border-radius: 50%; background: #fff; box-shadow: 0 0 4px rgba(120, 160, 200, .6); animation-name: fall; animation-timing-function: linear; }
.fx-bubble { top: 104%; width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .9); background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, .9) 0 18%, rgba(170, 220, 255, .25) 20%); animation-name: rise; animation-timing-function: ease-in; }
.fx-heart { top: 104%; width: 16px; height: 16px; background: #F26B8A; transform: rotate(45deg); animation-name: rise; }
.fx-heart::before, .fx-heart::after { content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%; background: inherit; }
.fx-heart::before { left: -8px; } .fx-heart::after { top: -8px; }
.fx-wind { width: 80px; height: 3px; border-radius: 3px; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .9), transparent); animation-name: wind; animation-timing-function: ease-in-out; }
.fx-rain { top: -6%; width: 2px; height: 18px; background: rgba(110, 160, 220, .7); animation-name: fall; animation-timing-function: linear; animation-duration: calc(var(--t) / 5); }
.l-light { pointer-events: none; }
.fx-glow { position: absolute; inset: 0; background: radial-gradient(circle at 70% 25%, rgba(255, 236, 170, .55), transparent 55%); animation-name: glow; animation-duration: 5s; }
@keyframes twinkle { 0%, 100% { transform: scale(.2) rotate(0); opacity: 0; } 50% { transform: scale(1) rotate(90deg); opacity: 1; } }
@keyframes fall { to { transform: translateY(115vh); } }
@keyframes fall-sway { 0% { transform: translate(0, 0) rotate(var(--r)); } 50% { transform: translate(40px, 55vh) rotate(calc(var(--r) + 180deg)); } 100% { transform: translate(-20px, 115vh) rotate(calc(var(--r) + 360deg)); } }
@keyframes rise { 0% { transform: translateY(0); opacity: 0; } 15% { opacity: 1; } 100% { transform: translate(20px, -115vh); opacity: .2; } }
@keyframes wind { 0% { transform: translateX(-160px); opacity: 0; } 30%, 70% { opacity: 1; } 100% { transform: translateX(260px); opacity: 0; } }
@keyframes glow { 50% { opacity: .5; } }

/* 말풍선 */
.hero .bubble { position: absolute; left: 50%; bottom: 96%; translate: -50% 0; z-index: 3; max-width: min(240%, 300px); width: max-content;
  padding: 8px 14px; border-radius: 18px; background: var(--card); color: var(--ink); font: clamp(.95rem, 1.6vw, 1.15rem) var(--font-display);
  box-shadow: 3px 4px 0 var(--shadow); opacity: 0; pointer-events: none; text-align: center; line-height: 1.35; }
.hero .bubble::after { content: ""; position: absolute; left: 50%; top: 100%; translate: -50% -2px; border: 10px solid transparent; border-top-color: var(--card); }
.hero .bubble:empty { display: none; }
.hero .bubble.pop { animation: bubble-pop 6s var(--ease-pop) 1.2s both; }
.hero.pos-left .bubble { left: 70%; } .hero.pos-right .bubble { left: 30%; }
@keyframes bubble-pop { 0% { opacity: 0; transform: scale(.4) translateY(14px); } 8% { opacity: 1; transform: scale(1.06); } 12% { transform: none; } 85% { opacity: 1; } 100% { opacity: 0; transform: translateY(-6px); } }

/* 의성어 */
/* 크레용으로 쓴 손글씨가 종이 스티커처럼 붙는다: 글자마다 크레용 색, 얇은 흰 테두리, 손그림 떨림(#rough).
   자리는 주인공 머리 옆(말풍선과 겹치지 않는 쪽), 한 자씩 통통 나왔다가 살랑 흔들리고 사라진다. */
.sfx { position: absolute; z-index: 4; left: var(--sfx-x, 66%); top: var(--sfx-y, 20%); display: flex; gap: .02em; pointer-events: none;
  font: clamp(1.2rem, 2.4vw, 1.9rem) var(--font-display); line-height: 1; rotate: -7deg; transition: left 1s ease, top 1.4s ease; }
.stage[data-pos="left"] { --sfx-x: 47%; } .stage[data-pos="center"] { --sfx-x: 66%; } .stage[data-pos="right"] { --sfx-x: 20%; }
.stage[data-shot="wide"] { --sfx-y: 46%; } .stage[data-shot="medium"] { --sfx-y: 20%; } .stage[data-shot="close"] { --sfx-y: 9%; }
.stage.spotlight { --sfx-x: 7%; --sfx-y: 8%; }
.sfx span { display: inline-block; color: var(--c); opacity: 0; rotate: var(--r);
  -webkit-text-stroke: 4px #FFFDF8; paint-order: stroke fill; filter: url(#rough) drop-shadow(1px 2px 0 rgba(58, 44, 38, .2)); }
.sfx span.sp { width: .3em; }
.sfx.pop span { animation: sfx-in .5s var(--ease-pop) calc(.7s + var(--i) * .09s) both, sfx-bob 1.4s ease-in-out calc(1.25s + var(--i) * .09s) 2 alternate, sfx-out .7s ease calc(3.8s + var(--i) * .05s) forwards; }
@keyframes sfx-in { from { opacity: 0; transform: translateY(10px) scale(.3); } to { opacity: 1; transform: none; } }
@keyframes sfx-bob { to { translate: 0 -4px; } }
@keyframes sfx-out { to { opacity: 0; transform: translateY(-8px); } }

.painting { position: absolute; right: 12px; top: 12px; padding: 4px 12px; border-radius: 99px; background: rgba(255, 253, 248, .92); font: .95rem var(--font-display); box-shadow: 2px 3px 0 var(--shade); }
.painting span { display: inline-block; animation: scribble .5s ease-in-out infinite alternate; }

/* 책 속 정지 화면 */
.stage.still *, .stage.still .tilt { animation: none !important; transition: none !important; }
.stage.still .l-spot.show img { scale: 1.04; }

/* 소품 그리기 */
.prop-dialog { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 16px; background: rgba(58, 44, 38, .35); backdrop-filter: blur(3px); animation: screen-in .35s ease both; }
.prop-card {
  width: min(760px, 100%); max-height: 100%; overflow: auto;
  display: grid; grid-template-columns: auto 1fr; grid-template-areas: "title title" "hint hint" "sheet tools" "actions actions";
  gap: 14px; padding: 22px; background: var(--paper); border-radius: 22px; box-shadow: 8px 10px 0 var(--shadow);
}
.prop-card h2 { grid-area: title; } .prop-card .hint { grid-area: hint; margin: 0; }
.sheet-small { width: min(56dvh, 60vw, 460px); }
.prop-card .draw-actions { grid-area: actions; }

/* ---------- 책 ---------- */
.book-screen { justify-items: center; gap: var(--gap); }
.book-actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.keepsake { width: min(980px, 100%); display: grid; gap: calc(var(--gap) * 1.5); }
.cover {
  position: relative; display: grid; grid-template-columns: 1fr 1fr; align-items: center; gap: var(--gap);
  padding: clamp(18px, 3vw, 36px); border-radius: 10px 22px 22px 10px;
  background: var(--tomato); color: #fff; box-shadow: inset 14px 0 0 rgba(0, 0, 0, .12), 8px 10px 0 var(--shadow);
}
.cover h1 { font-size: var(--fs-hero); }
.cover p { margin: 6px 0 0; opacity: .95; }
.cover .frame { aspect-ratio: 4 / 3; position: relative; border-radius: 10px; overflow: hidden; background: #fff; border: 6px solid var(--card); transform: rotate(2deg); box-shadow: 4px 6px 0 rgba(0, 0, 0, .25); }
.spread { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); align-items: center; background: var(--card); border-radius: 16px; padding: clamp(14px, 2.4vw, 28px); box-shadow: 6px 8px 0 var(--shade); }
.spread:nth-child(even) .frame { order: 2; }
.spread .frame { aspect-ratio: 4 / 3; position: relative; border-radius: 10px; overflow: hidden; box-shadow: 0 0 0 2px var(--ink); }
.spread .text { font-size: 1.2rem; line-height: 1.75; }
.spread .n { font: 1rem var(--font-display); color: var(--tomato); }
.spread .picked-path { margin-top: 10px; font-size: var(--fs-small); color: var(--ink-soft); }
.spread .picked-path::before { content: "고른 길 ▸ "; color: var(--leaf); font-weight: 700; }
.originals { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--gap); background: var(--card); border-radius: 16px; padding: 20px; box-shadow: 6px 8px 0 var(--shade); }
.originals h2 { grid-column: 1 / -1; font-size: 1.4rem; }
.originals figure { margin: 0; display: grid; gap: 6px; justify-items: center; color: var(--ink-soft); font-size: var(--fs-small); }
.originals img { width: 100%; aspect-ratio: 1; object-fit: contain; background: #fff; border-radius: 8px; box-shadow: 0 0 0 2px var(--paper-2); }

/* ---------- 표지: 물감 · 도서관 ---------- */
.budget-line { margin: -4px 0 0; color: var(--ink-soft); font-size: .98rem; min-height: 1.6em; }
.budget-line .paints { letter-spacing: 2px; }
.budget-line.empty { padding: 10px 16px; border-radius: 14px; background: var(--card); color: var(--ink); box-shadow: 3px 4px 0 var(--shade); }
.title-links { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: center; }

/* ---------- 도서관 ---------- */
.library-screen { justify-items: center; align-content: start; gap: var(--gap); }
.lib-head { text-align: center; display: grid; gap: 6px; }
.lib-grid { width: min(1180px, 100%); display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: calc(var(--gap) * 1.2); }
.lib-card { position: relative; display: grid; gap: 6px; padding: 10px 10px 14px; border: 0; border-radius: 6px 14px 14px 6px; background: var(--card); text-align: left; cursor: pointer;
  box-shadow: inset 8px 0 0 var(--tomato), 5px 6px 0 var(--shade); transition: transform .2s var(--ease-pop), box-shadow .2s; animation: card-deal .5s var(--ease-pop) both; animation-delay: calc(var(--i) * .06s); }
.lib-card:nth-child(3n+2) { box-shadow: inset 8px 0 0 var(--sky), 5px 6px 0 var(--shade); }
.lib-card:nth-child(3n) { box-shadow: inset 8px 0 0 var(--leaf), 5px 6px 0 var(--shade); }
.lib-card:hover { transform: translateY(-4px) rotate(-1deg); }
.lib-card:focus-visible { outline: 3px dashed var(--sky); outline-offset: 4px; }
.lib-card.opening { opacity: .6; }
.lib-card img { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; border-radius: 4px; margin-left: 6px; width: calc(100% - 6px); }
.lib-title { font: 1.15rem var(--font-display); margin-left: 8px; }
.lib-badge { justify-self: start; margin-left: 8px; padding: 1px 10px; border-radius: 99px; background: var(--sun); font-size: .85rem; }
.lib-date { margin-left: 8px; font-size: .82rem; color: var(--ink-soft); }
.lib-empty { padding: 40px 0; }

/* 올리기 확인 */
.share-card { width: min(520px, 100%); display: grid; gap: 14px; padding: 24px; background: var(--paper); border-radius: 22px; box-shadow: 8px 10px 0 var(--shadow); }
.share-card p { margin: 0; }
.guardian { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 14px; border-radius: 12px; background: var(--card); font: 1.1rem var(--font-display); cursor: pointer; }
.guardian input { width: 24px; height: 24px; accent-color: var(--tomato); }

/* ---------- 토스트 ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; translate: -50% 0; z-index: 40; max-width: min(560px, calc(100% - 32px));
  padding: 12px 18px; border-radius: 14px; background: var(--ink); color: var(--paper); box-shadow: 4px 5px 0 var(--sun);
  animation: screen-in .35s var(--ease-pop) both;
}

/* ---------- 좁은 화면 ---------- */
@media (max-width: 900px) {
  .draw-screen { grid-template-columns: 1fr; grid-template-areas: "side" "sheet" "tools" "actions"; justify-items: center; }
  .draw-side { text-align: center; justify-items: center; }
  .sheet { width: min(92vw, 62dvh); }
  .toolbox { display: flex; flex-wrap: wrap; justify-content: center; }
  .crayons { grid-template-columns: repeat(8, 44px); gap: 8px; }
  .crayons .tool { width: 44px; }
  .draw-actions { justify-content: center; }
  .wake-screen { grid-template-columns: 1fr; justify-items: center; }
  .wake-stage { width: min(70vw, 320px); }
  .book { grid-template-columns: 1fr; }
  .page-left { min-height: 44dvh; border-radius: 14px 14px 4px 4px; }
  .page-right { min-height: auto; border-radius: 4px 4px 14px 14px; background-image: none; }
  .cover, .spread { grid-template-columns: 1fr; }
  .spread:nth-child(even) .frame { order: 0; }
  .prop-card { grid-template-columns: 1fr; grid-template-areas: "title" "hint" "sheet" "tools" "actions"; justify-items: center; }
  .sheet-small { width: min(84vw, 50dvh); }
  .icon-label { display: none; }
}
@media (max-width: 520px) { .crayons { grid-template-columns: repeat(4, 44px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  /* 사라지는 애니메이션으로 끝나는 것(말풍선 · 의성어)은 끝 상태가 투명이라, 동작을 줄이면 아예 안 보였다 → 그냥 보여 준다 */
  .hero .bubble.pop, .sfx.pop span { animation: none !important; opacity: 1; }
}

/* ---------- 인쇄: 책만 ---------- */
@media print {
  @page { size: A4 landscape; margin: 12mm; }
  body { background: #fff; }
  .topbar, .no-print, .toast { display: none !important; }
  .screen { display: none !important; } .book-screen.on { display: block !important; padding: 0; }
  .cover, .spread, .originals { break-inside: avoid; break-after: page; box-shadow: none; }
  * { animation: none !important; }
  .cover { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
