/* =========================================================
 *  글씨체 바꾸는 곳
 *  1) 폰트 파일을 assets/fonts/ 에 넣고
 *  2) 아래 @font-face 주석을 풀어 파일명을 맞춘 뒤
 *  3) --font-hand 맨 앞을 'MyHand' 로 바꾸면 끝!
 * ========================================================= */
/* 나눔손글씨 맛있는체 (원본 TTF → 자주 쓰는 한글 2,350자 + 게임에 쓰인 글자만 남긴 woff2, 약 0.5MB) */
@font-face {
  font-family: 'MyHand';
  src: url('../assets/fonts/nanum-masitneun.woff2') format('woff2');
  size-adjust: 112%;   /* 손글씨체가 작게 보여서 살짝 키움 */
  font-display: swap;
}
:root {
  --font-hand: 'MyHand', 'Gaegu', 'Gowun Dodum', -apple-system, sans-serif;

  /* 연필 + 수채 팔레트 (기준: image/customer_rabbit.png) */
  --paper: #fffdf8;
  --paper-2: #fcf7ee;
  --ink: #3e3a3a;
  --ink-soft: #8d8582;
  --line: #e7ddd2;
  --rose: #f4bcc6;
  --rose-soft: #fde6ea;
  --sage: #c9d8b8;
  --butter: #fbe5c0;
  --butter-soft: #fef4e2;
  --choco: #6f5044;
  --pen: 1.6px;      /* 기본 선 굵기 */

  /* 삐뚤빼뚤 손그림 모서리 */
  --sk-btn: 255px 15px 225px 15px / 15px 225px 15px 255px;
  --sk-box: 10px 22px 12px 18px / 18px 10px 22px 12px;
  --sk-sm: 6px 12px 7px 10px / 10px 6px 12px 7px;
  --shadow: 1px 1.5px 0 -.3px #3e3a3a66, 0 3px 8px #6a4a3c14;
  --stroke2: 1px 1.5px 0 -.3px #3e3a3a66;   /* 연필 두 번째 선 */

  --noise: 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='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .45 0 0 0 0 .4 0 0 0 0 .35 0 0 0 .08 0'/%3E%3C/filter%3E%3Crect width='220' height='220' filter='url(%23n)'/%3E%3C/svg%3E");

  /* 수채 나무 카운터 */
  --wash-wood:
    radial-gradient(ellipse 45% 30% at 22% 30%, #fdf1dc 0, transparent 70%),
    radial-gradient(ellipse 40% 28% at 78% 62%, #f3d3ad88 0, transparent 70%),
    radial-gradient(ellipse 30% 22% at 50% 88%, #f1cfa566 0, transparent 70%),
    repeating-linear-gradient(-4deg, transparent 0 22px, #e9c99f40 22px 23px, transparent 23px 38px),
    #f8e4c6;

  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: #ddd6cc;
  color: var(--ink);
  font-family: var(--font-hand);
  font-size: 19px;
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
h1, h2, h3, .btn, .day-badge, .pay, .shop-sign { font-weight: 700; }
.ic { width: 100%; height: 100%; display: block; overflow: visible; }

#app { position: fixed; inset: 0; max-width: 520px; margin: 0 auto; }

/* 종이 + 스프링 */
.screen {
  position: absolute; inset: 0;
  display: none; flex-direction: column;
  padding-top: calc(var(--safe-t) + 16px);
  background: var(--noise), var(--paper);
}
.screen::before {
  content: ''; position: absolute; left: 0; right: 0; top: var(--safe-t); height: 14px; z-index: 5; pointer-events: none;
  background:
    radial-gradient(circle at 12px 8px, #c9c0b6 0 3px, transparent 3.6px) 0 0 / 26px 14px repeat-x,
    linear-gradient(#f5efe5, #f5efe500);
}
.screen.active { display: flex; animation: fadeIn .35s ease; }
.screen.center { align-items: center; justify-content: center; text-align: center; padding: calc(var(--safe-t) + 28px) 18px calc(24px + var(--safe-b)); gap: 14px; }
.screen.scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; justify-content: flex-start; }
.screen.center.scroll { justify-content: safe center; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.sub { color: var(--ink-soft); margin: 0; }

/* 손그림 버튼 */
.btn {
  background: var(--butter); color: var(--ink); font-size: 24px;
  padding: 8px 30px 6px; border: var(--pen) solid var(--ink);
  border-radius: var(--sk-btn); box-shadow: var(--shadow);
  transform: rotate(-1.2deg);
  transition: transform .08s, box-shadow .08s;
}
.btn:active { transform: rotate(-1.2deg) translate(1px, 2px); box-shadow: var(--stroke2); }
.btn.big { font-size: 26px; padding: 9px 36px 7px; }
.btn.ghost { background: var(--paper); transform: rotate(.8deg); }
.btn[disabled] { opacity: .45; pointer-events: none; }

/* 타이틀 */
#s-title h1 { font-size: 46px; line-height: 1.05; margin: 0; }
#s-title h1 span { background: linear-gradient(transparent 55%, #f4bcc699 55% 88%, transparent 88%); padding: 0 4px; }
.title-art { height: 220px; animation: bob 3s ease-in-out infinite; }
.title-art svg { height: 100%; overflow: visible; }
@keyframes bob { 50% { transform: translateY(-6px); } }

/* 하루 */
.day-badge {
  font-size: 54px; line-height: 1; padding: 4px 18px 0;
  background: linear-gradient(transparent 50%, #fbe5c0 50% 90%, transparent 90%);
  transform: rotate(-3deg);
}
#s-day h2 { margin: 0; font-size: 30px; }

/* 가게 */
.hud {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 6px 14px 8px; font-size: 19px; font-weight: 700;
}
.hud > span {
  min-width: 70px; text-align: center; padding: 2px 10px 0;
  background: var(--paper); border: var(--pen) solid var(--ink); border-radius: var(--sk-sm); box-shadow: var(--stroke2);
}
.shop-sign {
  background: var(--choco); color: #f7ecdc; padding: 3px 12px 1px; border-radius: var(--sk-sm);
  font-size: 15px; letter-spacing: 1px; white-space: nowrap; transform: rotate(-1.5deg);
  border: var(--pen) solid var(--ink);
}
.shop-scene {
  position: relative; flex: 1; min-height: 0; overflow: hidden; --ch: 38%;
  background:
    radial-gradient(ellipse 60% 40% at 18% 22%, #fde6ea66, transparent 70%),
    radial-gradient(ellipse 50% 35% at 85% 55%, #fbe5c055, transparent 70%),
    repeating-linear-gradient(90deg, transparent 0 34px, #f1e8dc 34px 35px, transparent 35px 70px);
}
.bubble {
  position: absolute; bottom: calc(var(--ch) + 176px); left: 16px; right: 16px;
  background: #fffdf8; border: var(--pen) solid var(--ink); border-radius: var(--sk-box); box-shadow: var(--stroke2);
  padding: 10px 16px 8px; font-size: 21px; line-height: 1.35;
  min-height: 60px; opacity: 0; transform: scale(.97); transition: .25s;
  z-index: 2;
  display: flex; align-items: center; justify-content: center; text-align: center;
}
.bubble.show { opacity: 1; transform: none; }
.bubble.long { font-size: 18px; line-height: 1.3; }
.bubble::after {
  content: ''; position: absolute; left: 50%; bottom: -11px; width: 18px; height: 18px; margin-left: -9px;
  background: #fffdf8; border-right: var(--pen) solid var(--ink); border-bottom: var(--pen) solid var(--ink);
  transform: rotate(40deg) skew(8deg);
}
.bubble p { margin: 0; white-space: pre-line; }
.customer {
  position: absolute; left: 0; right: 0; bottom: calc(var(--ch) + 22px);
  display: flex; flex-direction: column; align-items: center;
  transform: translateX(120%); transition: transform .6s cubic-bezier(.2,.9,.3,1.1);
}
.customer.in { transform: none; }
.customer.out { transform: translateX(-120%); transition-timing-function: ease-in; }
.avatar {
  width: 140px; height: 140px; display: grid; place-items: center;
  font-size: 92px; line-height: 1;
  animation: bob 2.4s ease-in-out infinite;
}
.avatar .doodle, .t-av .doodle, .g-av .doodle { width: 100%; height: 100%; overflow: visible; }
/* 직접 그린 캐릭터 이미지 (투명 배경, 테두리 없음) */
.avatar img.char-img, .t-av img.char-img, .g-av img.char-img {
  width: 100%; height: 100%; object-fit: contain; border: 0; outline: 0; border-radius: 0;
}
.avatar img.char-img { width: 118%; height: 118%; margin-top: -18%; }
.avatar img { width: 120px; height: 120px; object-fit: cover; border: 3px solid #fff; outline: 2px solid var(--ink); border-radius: var(--sk-box); }
.cust-name { margin-top: -4px; font-size: 18px; font-weight: 700; background: linear-gradient(transparent 55%, #fbe5c0 55% 90%, transparent 90%); padding: 0 4px; }
.counter {
  position: absolute; left: 0; right: 0; bottom: 0; height: var(--ch);
  border-top: var(--pen) solid var(--ink); box-shadow: 0 -1.5px 0 -.3px #3e3a3a55;
  background: var(--wash-wood);
}
.counter::before { content: ''; position: absolute; left: 0; right: 0; top: 70px; bottom: 0; background: repeating-linear-gradient(90deg, transparent 0 58px, #3e3a3a22 58px 59.5px, transparent 59.5px 64px, #3e3a3a22 64px 65.5px); }
.served {
  position: absolute; left: 50%; top: 6px; transform: translate(-50%, -30px); z-index: 2;
  opacity: 0; transition: .4s; line-height: 0;
}
.served.show { opacity: 1; transform: translate(-50%, 0); }
.result {
  position: absolute; left: 18px; right: 18px; bottom: 12px;
  background: #fffdf8; border: var(--pen) solid var(--ink); border-radius: var(--sk-box);
  padding: 6px 14px 8px; text-align: center; box-shadow: var(--shadow);
  animation: pop .4s ease; z-index: 3;
}
.stars { display: flex; justify-content: center; gap: 6px; height: 36px; }
.stars .ic { width: 36px; height: 36px; }
.pay { font-size: 22px; color: var(--choco); }
.r-hint { color: var(--ink-soft); font-size: 17px; min-height: 1em; line-height: 1.2; }
@keyframes pop { 0% { transform: scale(.85); opacity: 0; } 70% { transform: scale(1.02); } 100% { opacity: 1; } }
.shop-actions {
  padding: 10px 16px calc(14px + var(--safe-b)); display: flex; justify-content: center;
  background: var(--wash-wood);
}

/* 주방 */
.ticket {
  position: relative; display: flex; gap: 10px; align-items: center;
  margin: 6px 14px 0; padding: 8px 12px 6px; background: #fffdf8;
  border: var(--pen) solid var(--ink); border-radius: var(--sk-sm); box-shadow: var(--stroke2);
  font-size: 18px; line-height: 1.3; transform: rotate(-.6deg);
}
.ticket::before {   /* 마스킹 테이프 */
  content: ''; position: absolute; top: -9px; left: 50%; width: 70px; height: 16px; margin-left: -35px;
  background: #f4bcc6b3; transform: rotate(-3deg);
}
.ticket p { margin: 0; white-space: pre-line; }
.t-av { width: 42px; height: 42px; flex: none; font-size: 30px; display: grid; place-items: center; }
.t-av img { width: 38px; height: 38px; object-fit: cover; border-radius: var(--sk-sm); }
.scene-wrap { position: relative; flex: 1; min-height: 0; }
#scene { width: 100%; height: 100%; display: block; touch-action: none; }
.icon-btn {
  width: 44px; height: 44px; padding: 6px; background: #fffdf8;
  border: var(--pen) solid var(--ink); border-radius: var(--sk-sm); box-shadow: var(--shadow);
}
.icon-btn:active { transform: translate(1px, 2px); box-shadow: none; }
.trash { position: absolute; right: 14px; top: 12px; }
.mute { position: fixed; right: 12px; bottom: calc(12px + var(--safe-b)); z-index: 50; display: none; }
body.show-mute .mute { display: block; }
body.in-kitchen .mute, body.in-shop .mute, body.in-prologue .mute { display: none; }
.notice {
  position: absolute; left: 14px; right: 68px; top: 12px; z-index: 2;
  padding: 6px 12px 4px; font-size: 18px; line-height: 1.3; color: var(--ink);
  background: var(--butter-soft); border: 1.4px dashed var(--ink); border-radius: var(--sk-sm);
  opacity: 0; transform: translateY(-4px) rotate(-.8deg); transition: opacity .25s, transform .25s; pointer-events: none;
}
.notice.show { opacity: 1; transform: rotate(-.8deg); }
.tray {
  display: flex; gap: 8px; padding: 10px 12px; overflow-x: auto; justify-content: center;
  scrollbar-width: none;
}
.tray::-webkit-scrollbar { display: none; }
.opt {
  flex: none; width: 60px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 16px; padding: 6px 0 2px; border-radius: var(--sk-sm); background: #fffdf8;
  border: 1.4px solid var(--line); transition: transform .1s;
}
.opt:nth-child(odd) { transform: rotate(-1.5deg); }
.opt:nth-child(even) { transform: rotate(1.2deg); }
.opt.sel { border-color: var(--ink); background: var(--butter-soft); transform: translateY(-3px) rotate(-1deg); box-shadow: var(--shadow); }
.opt.locked { opacity: .3; }
.opt .sw { width: 34px; height: 34px; overflow: visible; }
.tabs {
  display: flex; gap: 6px; padding: 8px 10px calc(8px + var(--safe-b));
  background: var(--noise), var(--paper-2); border-top: var(--pen) solid var(--ink);
}
.tabs button {
  flex: 1; display: flex; flex-direction: column; align-items: center; font-size: 16px;
  padding: 3px 0 0; border-radius: var(--sk-sm); color: var(--ink-soft); border: var(--pen) solid transparent;
}
.tabs button b { width: 28px; height: 28px; display: block; }
.tabs button.on { color: var(--ink); background: #fffdf8; border-color: var(--ink); box-shadow: var(--stroke2); }
.tabs .serve {
  flex: 1.3; background: var(--rose); color: var(--ink); font-size: 23px; font-weight: 700;
  justify-content: center; border: var(--pen) solid var(--ink);
  border-radius: var(--sk-btn); box-shadow: var(--shadow); transform: rotate(-1.5deg);
}
.tabs .serve:active { transform: rotate(-1.5deg) translate(1px, 2px); box-shadow: var(--stroke2); }

/* 하루 끝 */
#s-dayend h2 { font-size: 34px; margin: 4px 0 0; }
.de-stats {
  background: #fffdf8; border: var(--pen) solid var(--ink); border-radius: var(--sk-box); box-shadow: var(--stroke2);
  padding: 8px 20px 6px; font-size: 20px; line-height: 1.45; transform: rotate(.8deg);
}
.memory {
  position: relative; background: #fffdf8; padding: 12px 12px 14px; width: min(290px, 100%);
  border: 1.5px solid var(--line); box-shadow: 0 4px 12px #0000001a; transform: rotate(-2deg);
}
.memory::before, .l-photo::before {   /* 마스킹 테이프 */
  content: ''; position: absolute; top: -10px; left: 50%; width: 80px; height: 20px; margin-left: -40px;
  background: #c9d8b8b3; transform: rotate(2deg); z-index: 1;
}
.memory .ph, .l-photo .ph {
  aspect-ratio: 4/3; display: grid; place-items: center; color: var(--ink-soft); font-size: 18px;
  border: 2px dashed var(--line);
  background: repeating-linear-gradient(45deg, transparent 0 8px, #f1e9df 8px 10px);
}
.memory img, .l-photo img { width: 100%; display: block; }
.memory h3 { margin: 10px 0 2px; font-size: 22px; }
.memory p { margin: 0; color: var(--ink-soft); font-size: 18px; line-height: 1.3; white-space: pre-line; }

/* 엔딩 */
#s-ending { padding: calc(var(--safe-t) + 30px) 16px calc(40px + var(--safe-b)); }
.envelope-wrap { margin: auto; text-align: center; }
.envelope { width: 170px; height: 135px; animation: bob 1.8s ease-in-out infinite; }
.letter {
  position: relative; background: #fffdf8; padding: 22px 18px 26px;
  border: 1.5px solid var(--line); box-shadow: 0 6px 18px #0000001a; animation: pop .5s ease;
  background-image: repeating-linear-gradient(transparent 0 33px, #e8ddd2 33px 34px);
}
.l-photo { position: relative; transform: rotate(-1.5deg); border: 8px solid #fff; box-shadow: 0 3px 10px #0000001f; }
.letter h2 { text-align: center; margin: 18px 0 6px; font-size: 32px; }
#l-body p { font-size: 21px; line-height: 34px; margin: 0; opacity: 0; transform: translateY(6px); transition: .8s; white-space: pre-line; }
#l-body p.show { opacity: 1; transform: none; }
.l-sign { text-align: right; font-size: 22px; margin: 10px 0 0; font-weight: 700; }
.gal-title { text-align: center; margin: 30px 0 8px; font-size: 24px; }
.gallery { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 2px; }
.gallery .g { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.g-av { width: 34px; height: 34px; display: grid; place-items: center; font-size: 22px; }
.total { text-align: center; color: var(--ink-soft); }
#btn-restart { display: block; margin: 18px auto 0; }

/* 효과 */
#fx { position: fixed; inset: 0; pointer-events: none; z-index: 90; overflow: hidden; }
.fx-p { position: absolute; width: 26px; height: 26px; animation: fall 1.8s ease-in forwards; }
@keyframes fall {
  from { transform: translateY(-40px) rotate(0); }
  to { transform: translateY(105vh) rotate(var(--rot, 360deg)); }
}

/* ===== 세계관 프롤로그 (컷신) ===== */
#s-prologue {
  background: var(--noise), #2b2726; color: #fbf1df;
  padding: calc(var(--safe-t) + 14px) 16px calc(18px + var(--safe-b));
  cursor: pointer;
}
#s-prologue::before { display: none; }
.pro-skip {
  position: absolute; right: 14px; top: calc(var(--safe-t) + 12px); z-index: 3;
  font-size: 15px; color: #fbf1dfaa; padding: 4px 10px; border: 1.2px solid #fbf1df55; border-radius: var(--sk-sm);
}
.pro-stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; }
.pro-panel {
  position: relative; width: min(100%, 440px, 58vh); aspect-ratio: 1;
  background: var(--paper); border: 3px solid #fbf1df; outline: 1.6px solid #00000055;
  box-shadow: 0 10px 30px #0008; transform: rotate(-1deg);
}
.pro-panel::before {   /* 테이프 */
  content: ''; position: absolute; top: -11px; left: 50%; width: 84px; height: 20px; margin-left: -42px; z-index: 2;
  background: #f4bcc6c0; transform: rotate(2deg);
}
#pro-art { width: 100%; height: 100%; display: block; overflow: hidden; }
.pro-panel.enter { animation: proEnter .55s cubic-bezier(.2, 1.2, .4, 1); }
.pro-panel.shake { animation: proShake .45s; }
@keyframes proEnter { from { opacity: 0; transform: rotate(-4deg) scale(.9) translateY(14px); } }
@keyframes proShake {
  0%, 100% { transform: rotate(-1deg); } 15% { transform: translate(-7px, 3px) rotate(-2deg); }
  30% { transform: translate(6px, -4px) rotate(0); } 45% { transform: translate(-5px, -2px) rotate(-1.5deg); }
  60% { transform: translate(4px, 3px) rotate(-.5deg); } 80% { transform: translate(-2px, 1px) rotate(-1deg); }
}
.pro-cap { position: relative; min-height: 128px; padding: 18px 6px 0; text-align: center; }
#pro-text { margin: 0; font-size: 23px; line-height: 1.4; min-height: 2.8em; white-space: pre-line; }
#pro-text.big { font-size: 38px; font-weight: 700; color: #fff; letter-spacing: 1px; }
.pro-next {
  position: absolute; right: 12px; bottom: 6px; width: 0; height: 0;
  border-left: 8px solid transparent; border-right: 8px solid transparent; border-top: 11px solid #fbf1df;
  animation: proBlink 1s ease-in-out infinite;
}
@keyframes proBlink { 50% { transform: translateY(4px); opacity: .4; } }
#pro-go { margin-top: 14px; }
/* 시작 버튼이 뜰 때는 자막 아래 빈 줄 없이 버튼을 바로 붙임 */
.pro-cap:has(#pro-go:not([hidden])) #pro-text { min-height: 0; }

/* 컷신 그림 움직임 (onN: N번째 대사부터 등장, offN: 사라짐) */
/* 움직이는 요소만 자기 중심 기준 (transform 속성 있는 위치용 g에는 적용하면 안 됨) */
#pro-art :is(.pop, .stamp, .spin, .breathe, .grow2, .twinkle, .tilt1, .rise, .bob, .floaty, .wave, .smoke, .faint, .hop) { transform-box: fill-box; transform-origin: center; }
#pro-art .on1, #pro-art .on2, #pro-art .on3 { opacity: 0; }
.a1 #pro-art .on1, .a2 #pro-art .on2, .a3 #pro-art .on3 { animation: proFade .45s ease both; }
.a1 #pro-art .off1, .a2 #pro-art .off2 { opacity: 0; transition: opacity .15s; }
@keyframes proFade { to { opacity: 1; } }
#pro-art .pop { animation: proPop .5s cubic-bezier(.2, 1.5, .4, 1) both; }
@keyframes proPop { from { transform: scale(.2); opacity: 0; } }
#pro-art .stamp { animation: proStamp .4s cubic-bezier(.3, 1.4, .5, 1) both; }
@keyframes proStamp { from { transform: scale(2.6) rotate(-40deg); opacity: 0; } to { transform: rotate(-12deg); } }
#pro-art .spin { animation: proSpin 14s linear infinite; }
@keyframes proSpin { to { transform: rotate(360deg); } }
#pro-art .breathe { animation: proBreathe 2.6s ease-in-out infinite; }
@keyframes proBreathe { 50% { transform: translateY(-5px) rotate(1deg); } }
.a2 #pro-art .grow2 { animation: proGrow .6s cubic-bezier(.2, 1.6, .4, 1) both; }
@keyframes proGrow { to { transform: scale(1.22); } }
#pro-art .twinkle { animation: proTwinkle 1.6s ease-in-out infinite; }
@keyframes proTwinkle { 50% { transform: scale(.5) rotate(45deg); opacity: .35; } }
.a1 #pro-art .tilt1 { animation: proTilt .5s cubic-bezier(.3, 1.4, .5, 1) both; }
@keyframes proTilt { to { transform: rotate(9deg) translateY(6px); } }
#pro-art .rise { animation: proRise 1.4s ease-out both; }
@keyframes proRise { from { transform: translateY(70px) scale(.6); opacity: 0; } }
#pro-art .bob { animation: proBob 2s ease-in-out infinite; }
@keyframes proBob { 50% { transform: translateY(-7px) rotate(-3deg); } }
#pro-art .floaty { animation: proBob 2.4s ease-in-out infinite; }
#pro-art .wave { animation: proWave 1.2s ease-in-out infinite; }
@keyframes proWave { 50% { transform: translateY(-4px) skewX(10deg); opacity: .5; } }
#pro-art .smoke { animation: proSmoke 2.1s ease-out infinite; }
@keyframes proSmoke { from { transform: scale(.5); opacity: .9; } to { transform: translateY(-70px) scale(1.8); opacity: 0; } }
.a2 #pro-art .faint { animation: proTilt .5s ease both; }
#pro-art .hop { animation: proHop .7s ease-in-out infinite; }
@keyframes proHop { 50% { transform: translateY(-4px); } }
/* onN 안의 등장 애니메이션은 그 대사가 나올 때 시작 */
.pro-panel:not(.a1) .on1 :is(.pop, .stamp, .rise),
.pro-panel:not(.a2) .on2 :is(.pop, .stamp, .rise),
.pro-panel:not(.a3) .on3 :is(.pop, .stamp, .rise) { animation: none; }

/* ===== 별 1개 = 사망 ===== */
.avatar.dead { filter: grayscale(1) contrast(.9); transform: rotate(-10deg) translateY(6px); animation: none; transition: .3s; }
.death-stamp {
  position: absolute; left: 50%; bottom: calc(var(--ch) + 40px); width: 170px; height: 170px; margin-left: -85px;
  z-index: 4; pointer-events: none; display: none; place-items: center;
}
.death-stamp.show { display: grid; animation: slam .45s cubic-bezier(.3, 1.5, .5, 1) both; }
.death-stamp span {
  display: grid; place-items: center; width: 150px; height: 150px; border-radius: 50%;
  border: 6px solid #d64545; outline: 2px solid #d64545; outline-offset: -14px;
  color: #d64545; font-size: 50px; font-weight: 700; letter-spacing: 4px; padding-top: 6px;
  background: #fffdf8b0; opacity: .92; transform: rotate(-14deg);
}
@keyframes slam { from { transform: scale(3) rotate(-30deg); opacity: 0; } 60% { transform: scale(.92); opacity: 1; } }
.shop-scene.shake { animation: sceneShake .45s; }
@keyframes sceneShake {
  15% { transform: translate(-8px, 4px); } 30% { transform: translate(7px, -5px); } 45% { transform: translate(-5px, -2px); }
  60% { transform: translate(4px, 3px); } 80% { transform: translate(-2px, 1px); }
}
/* 다음 손님 뒤로 지나가는 들것 */
.amb {
  position: absolute; left: 100%; bottom: calc(var(--ch) + 20px); width: 290px; z-index: 0; pointer-events: none;
  animation: ambGo 4.2s linear both;
}
@keyframes ambGo { to { transform: translateX(var(--dist, -700px)); } }
.amb-walk { position: relative; animation: ambHop .32s ease-in-out infinite; }
@keyframes ambHop { 50% { transform: translateY(-4px) rotate(-1deg); } }
.amb-svg { width: 100%; display: block; overflow: visible; }
.amb-patient {
  position: absolute; left: 21%; top: 33%; width: 25%; aspect-ratio: 1;
  transform: rotate(-80deg); filter: grayscale(1);
}
.amb-patient .doodle, .amb-patient img { width: 100%; height: 100%; object-fit: contain; }
.amb-light { animation: ambLight .4s steps(1) infinite; }
@keyframes ambLight { 50% { fill: #6a8fd6; opacity: .4; } }
.amb-ghost { animation: proBob 1.4s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }

/* ===== 가게 인테리어 ===== */
.shop-bg { position: absolute; inset: 0; pointer-events: none; }
.shop-bg .deco, .counter-deco .deco { position: absolute; display: block; overflow: visible; }
.shop-bg .storefront { left: 0; top: 0; width: 100%; height: calc(100% - var(--ch) + 4px); overflow: hidden; }
.shop-bg .lamps { position: absolute; left: 0; right: 0; top: 0; }
.shop-bg .lamp { position: relative; width: 30px; height: 66px; display: inline-block; }
.shop-bg .lamps .lamp:first-child { position: absolute; left: 30%; top: 0; }
.shop-bg .lamps .lamp:last-child { position: absolute; right: 30%; top: 0; }
.shop-bg .shelf { left: 6px; bottom: calc(var(--ch) + 30px); width: min(28%, 128px); height: auto; }
.shop-bg .menu { right: 10px; top: 0; width: min(27%, 116px); height: auto; }
/* 계산대: 윗면 + 정면 (반쯤 위에서 본 시점) */
.counter-top {
  position: absolute; left: 0; right: 0; top: 0; height: 44px;
  background: linear-gradient(#f8ecdb, #f2e2cb);
  border-bottom: var(--pen) solid var(--ink);
}
.counter-top::before { content: ''; position: absolute; inset: 0; background: repeating-linear-gradient(176deg, transparent 0 9px, #c9a2730f 9px 10px); }
.counter-top::after { content: ''; position: absolute; left: 0; right: 0; top: 100%; height: 7px; background: #e2c9a8; border-bottom: 1.2px solid #3e3a3a55; }
.counter-deco { position: absolute; left: 0; right: 0; top: 34px; height: 0; pointer-events: none; z-index: 1; }
.counter-deco .register { left: 10px; bottom: 0; width: min(24%, 100px); height: auto; }
.counter-deco .bell { right: 18px; bottom: 0; width: 52px; height: auto; }
/* 손님 상반신 */
.avatar { position: relative; }
.avatar > .doodle, .avatar > img { position: relative; z-index: 1; }
.avatar > .cust-body { position: absolute; left: 50%; top: 100px; width: 124px; height: auto; margin-left: -62px; z-index: 0; }
.customer .cust-name {
  position: absolute; top: -4px; left: auto; right: 26px; transform: rotate(5deg); white-space: nowrap; z-index: 3;
  margin: 0; padding: 3px 10px 1px; font-size: 16px; line-height: 1.3;
  background: #fffdf8; border: var(--pen) solid var(--ink); border-radius: var(--sk-sm); box-shadow: 2px 2px 0 #3e3a3a33;
}
.customer .cust-name::before { content: ''; position: absolute; left: 50%; top: -5px; width: 9px; height: 9px; margin-left: -4.5px; border-radius: 50%; background: #f4bcc6; border: 1.2px solid var(--ink); }

/* 프롤로그 5: "(일부는 아직이긴 하다.)" → 한정선·피자설기 살짝 작아짐 */
#pro-art .not-yet { transform-box: fill-box; transform-origin: center; transition: transform .7s cubic-bezier(.3, 1.5, .5, 1), opacity .7s; }
.a3 #pro-art .not-yet { transform: scale(.8); opacity: .55; }
/* 계산대 정면: 분홍 물결 띠 */
.counter::after {
  content: ''; position: absolute; left: 0; right: 0; top: 52px; height: 16px;
  background: radial-gradient(circle at 10px 0, #f4bcc6 9px, #3e3a3a 9px 10.2px, transparent 10.5px) 0 0 / 20px 16px repeat-x;
  opacity: .9;
}

/* 창문 너머 거리 (들것 · 수군수군) */
.street-fx { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.murmur {
  position: absolute; transform: translate(-50%, 0) scale(0); transform-origin: 50% 100%;
  background: #fffdf8; border: 1.2px solid var(--ink); border-radius: 10px; padding: 1px 7px 0;
  font-size: 12px; line-height: 1.4; white-space: nowrap; color: var(--ink); opacity: 0;
  animation: murmur 2.4s ease both;
}
.murmur::after { content: ''; position: absolute; left: 50%; bottom: -4px; width: 6px; height: 6px; margin-left: -3px; background: #fffdf8; border-right: 1.2px solid var(--ink); border-bottom: 1.2px solid var(--ink); transform: rotate(45deg); }
@keyframes murmur {
  0% { opacity: 0; transform: translate(-50%, 0) scale(.3); }
  12%, 80% { opacity: 1; transform: translate(-50%, -4px) scale(1); }
  40% { transform: translate(-48%, -6px) scale(1); } 60% { transform: translate(-52%, -4px) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -12px) scale(.9); }
}

/* 상반신까지 그려진 손님 그림 (예: 나) — 아랫부분은 계산대 뒤로 */
.avatar > img.char-img.full { position: absolute; left: 50%; top: 2px; width: 190px; height: 190px; margin: 0 0 0 -95px; }

/* 엔딩 컷신: 번쩍 */
.pro-flash { position: absolute; inset: 0; background: #fffbe8; opacity: 0; pointer-events: none; z-index: 4; }
.pro-flash.go { animation: proFlash .9s ease-out both; }
@keyframes proFlash { 0% { opacity: 0; } 8% { opacity: 1; } 30% { opacity: .9; } 100% { opacity: 0; } }
#pro-art .spin2 { transform-box: view-box; transform-origin: 150px 150px; animation: proSpin 8s linear infinite; }
@keyframes proSpin { to { transform: rotate(360deg); } }
/* 편지 갤러리: 사망한 손님 도장 */
.g-av { position: relative; }
.gallery .g.dead .g-av > :not(.g-stamp) { filter: grayscale(1); opacity: .7; }
.g-stamp {
  position: absolute; left: 50%; top: 50%; width: 34px; height: 34px; margin: -17px 0 0 -17px;
  display: grid; place-items: center; border: 2px solid #d64545; border-radius: 50%;
  color: #d64545; font-size: 11px; font-weight: 700; font-style: normal; letter-spacing: 1px;
  background: #fffdf8b0; transform: rotate(-14deg);
}

/* 엔딩 3: 외침 말풍선 (법정 게임 오마주) */
#pro-art .objection { transform-box: fill-box; transform-origin: center; }
.a1 #pro-art .objection { animation: objSlam .5s cubic-bezier(.2, 1.7, .4, 1) both, objShake .5s .45s both; }
@keyframes objSlam { from { transform: scale(2.6) rotate(-12deg); opacity: 0; } 50% { opacity: 1; } to { transform: none; } }
@keyframes objShake { 20% { transform: translate(-5px, 3px); } 40% { transform: translate(4px, -3px); } 60% { transform: translate(-3px, -1px); } 80% { transform: translate(2px, 2px); } }
.a1 #pro-art .speed { animation: objSpeed .25s steps(2) infinite; }
@keyframes objSpeed { 50% { opacity: .55; } }
/* 엔딩 4: 두 손이 상자를 들어 올림 */
.a1 #pro-art .lift { animation: proLift .6s cubic-bezier(.25, 1.3, .5, 1) both; }
@keyframes proLift { from { transform: translateY(70px); } }

/* 엔딩 4: 상자를 눌러 편지 열기 */
#pro-art .tapme { transform-box: fill-box; transform-origin: 50% 100%; animation: tapWiggle 1.6s ease-in-out infinite; }
@keyframes tapWiggle { 0%, 70%, 100% { transform: none; } 76% { transform: rotate(-3deg) scale(1.03); } 82% { transform: rotate(3deg) scale(1.03); } 88% { transform: rotate(-2deg); } 94% { transform: rotate(1deg); } }
#pro-art .tapme.open { animation: tapOpen .6s cubic-bezier(.3, 1.4, .5, 1) both; }
@keyframes tapOpen { 40% { transform: scale(1.15) translateY(-10px); } to { transform: scale(1.6) translateY(-30px); opacity: 0; } }

/* 포장부터 하고 초코를 묻히면 뜨는 물음표 */
.qpop {
  position: absolute; left: 50%; top: 18%; z-index: 5; pointer-events: none;
  font-size: 64px; font-weight: 700; color: var(--ink); line-height: 1;
  text-shadow: 3px 3px 0 #fffdf8, -2px -2px 0 #fffdf8, 2px -2px 0 #fffdf8, -2px 2px 0 #fffdf8;
  animation: qpop 1.2s cubic-bezier(.3, 1.6, .5, 1) both;
}
@keyframes qpop {
  0% { transform: translate(-50%, 10px) scale(.2) rotate(-20deg); opacity: 0; }
  25% { transform: translate(-50%, 0) scale(1.15) rotate(8deg); opacity: 1; }
  40%, 75% { transform: translate(-50%, 0) scale(1) rotate(-4deg); opacity: 1; }
  100% { transform: translate(-50%, -16px) scale(1); opacity: 0; }
}

/* 전설 장면: '완판' 도장이 효과음 박자(0.56s + 0.45s 간격)에 맞춰 쾅 */
#pro-art :is(.thump, .inkpuff) { transform-box: fill-box; transform-origin: center; }
.a1 #pro-art .thump { animation: proThump .28s ease-out both; }
@keyframes proThump { 0% { transform: none; } 35% { transform: scale(.94) translateY(3px); } 100% { transform: none; } }
#pro-art .inkpuff { opacity: 0; }
.a1 #pro-art .inkpuff { animation: proPuff .45s ease-out both; }
@keyframes proPuff { 0% { opacity: .9; transform: scale(.7); } 100% { opacity: 0; transform: scale(1.7); } }

/* 편지 맨 아래: 카카오톡 공유 */
.btn.kakao { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 22px auto 0; background: #fee500; color: #3a1d1d; border-color: #3a1d1d; }
.share-msg { text-align: center; font-size: 14px; color: #8a817c; margin: 8px 0 0; word-break: break-all; }

/* 편지: 진짜 택배 배송 조회 */
.real-parcel { margin: 22px 8px 4px; padding: 14px 12px; border: 1.5px dashed #c9b79c; border-radius: 10px; background: #fbf3e6; text-align: center; }
.real-parcel p { margin: 0 0 10px; line-height: 1.6; }
.real-parcel .btn { display: inline-block; text-decoration: none; color: inherit; }

/* 편지 문단 사이 한 줄 띄우기 (줄노트 간격 34px 유지) */
#l-body p + p { margin-top: 34px; }

/* 마지막 상자: 한동안 안 누르면 '클릭!' 힌트 말풍선 */
#pro-art .taphint { opacity: 0; transform-box: fill-box; transform-origin: 0% 100%; }
.a1 #pro-art .taphint { animation: hintIn .35s 3s cubic-bezier(.3, 1.6, .5, 1) both, hintBob 1.1s 3.4s ease-in-out infinite; }
#pro-art .tapme.open ~ .taphint { display: none; }
@keyframes hintIn { from { opacity: 0; transform: scale(.3); } to { opacity: 1; transform: none; } }
@keyframes hintBob { 50% { transform: translateY(-4px) rotate(-3deg); } }

/* 프롤로그 전 헤드폰 안내 */
#s-audio { background: var(--noise), #2b2726; color: #fbf1df; }
#s-audio .headphone { width: 110px; height: 110px; animation: hpBob 1.6s ease-in-out infinite; }
#s-audio .audio-msg { margin: 0; font-size: 22px; line-height: 1.5; animation: proFadeIn .8s ease both; }
#s-audio .headphone g { stroke: #fffdf8; }
@keyframes hpBob { 50% { transform: translateY(-6px) rotate(-4deg); } }
@keyframes proFadeIn { from { opacity: 0; transform: translateY(6px); } }

/* 처음 로딩 화면 */
#s-loading .load-pep { width: 260px; height: 46px; animation: loadBob 1.4s ease-in-out infinite; }
@keyframes loadBob { 50% { transform: translateY(-4px) rotate(-2deg); } }
#s-loading .load-msg { margin: 0; font-size: 22px; color: #8a817c; }
#load-fill { transition: x .2s, width .2s; }

/* 아이폰 성능: 안 움직이는 그림(연필 효과)은 한 번 그려서 레이어로 재사용 */
.shop-bg, .counter-deco, .title-art, #pro-art { will-change: transform; transform: translateZ(0); }
.avatar, .cust-body { will-change: transform; }

canvas.storefront { position: absolute; }

/* 줄바꿈: 한글은 단어 단위로만 끊고(한 글자만 다음 줄로 가지 않게), 짧은 문구는 줄 길이를 고르게 */
body { word-break: keep-all; overflow-wrap: break-word; }
h1, h2, h3, .btn, .bubble p, #pro-text, .real-parcel p, .total, .load-msg, .audio-msg, .share-msg, .l-sign, .gal-title, .result, .toast, #notice { text-wrap: balance; }
#l-body p { text-wrap: pretty; }
.real-parcel #btn-track { white-space: nowrap; font-size: 18px; padding-left: 14px; padding-right: 14px; }
