/* =========================================================
 *  글씨체 바꾸는 곳
 *  1) 폰트 파일을 assets/fonts/ 에 넣고
 *  2) 아래 @font-face 주석을 풀어 파일명을 맞춘 뒤
 *  3) --font-hand 맨 앞을 'MyHand' 로 바꾸면 끝!
 * ========================================================= */
/*
@font-face {
  font-family: 'MyHand';
  src: url('../assets/fonts/myhand.woff2') format('woff2'),
       url('../assets/fonts/myhand.ttf') format('truetype');
  font-display: swap;
}
*/

:root {
  --font-hand: 'Gaegu', 'Gowun Dodum', -apple-system, sans-serif;

  /* 스케치북 · 색연필 팔레트 */
  --paper: #fbf8f1;
  --paper-2: #f5f0e6;
  --ink: #4b4542;
  --ink-soft: #8a817c;
  --line: #d8cfc5;
  --rose: #e3a9b2;
  --rose-soft: #f6e1e3;
  --sage: #b5c6a5;
  --butter: #efdca6;
  --butter-soft: #f7edcf;
  --choco: #6a4a3c;

  /* 삐뚤빼뚤 손그림 모서리 */
  --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: 3px 4px 0 #4b454226;

  --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");

  --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, #b9b0a6 0 3.2px, transparent 3.8px) 0 0 / 26px 14px repeat-x,
    linear-gradient(#efe8dd, #efe8dd00);
}
.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: 2.5px 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(2px, 3px); box-shadow: 1px 1px 0 #4b454226; }
.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%, #e3a9b280 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%, #efdca6 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: 2px solid var(--ink); border-radius: var(--sk-sm);
}
.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: 2px solid var(--ink);
}
.shop-scene {
  position: relative; flex: 1; min-height: 0; overflow: hidden;
  background: repeating-linear-gradient(90deg, transparent 0 34px, #e9dfd2 34px 36px, transparent 36px 70px);
}
.bubble {
  position: absolute; bottom: calc(34% + 200px); left: 16px; right: 16px;
  background: #fffdf8; border: 2.2px solid var(--ink); border-radius: var(--sk-box);
  padding: 10px 16px 8px; font-size: 21px; line-height: 1.35;
  min-height: 60px; opacity: 0; transform: scale(.97); transition: .25s;
  z-index: 2;
}
.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: 2.2px solid var(--ink); border-bottom: 2.2px 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(34% + 18px);
  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 { 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%, #efdca6aa 55% 90%, transparent 90%); padding: 0 4px; }
.counter {
  position: absolute; left: 0; right: 0; bottom: 0; height: 34%;
  border-top: 2.5px solid var(--ink);
  background: repeating-linear-gradient(-58deg, transparent 0 5px, #e2cdb1 5px 7px), #efe0cb;
}
.counter::before { content: ''; position: absolute; left: 0; right: 0; top: 10px; border-top: 2px solid #4b454240; }
.served {
  position: absolute; left: 50%; top: 18px; transform: translate(-50%, -30px);
  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: 2.2px 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: repeating-linear-gradient(-58deg, transparent 0 5px, #e2cdb1 5px 7px), #efe0cb;
}

/* 주방 */
.ticket {
  position: relative; display: flex; gap: 10px; align-items: center;
  margin: 6px 14px 0; padding: 8px 12px 6px; background: #fffdf8;
  border: 2px solid var(--ink); border-radius: var(--sk-sm);
  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: #e3a9b2a6; 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: 2px solid var(--ink); border-radius: var(--sk-sm); box-shadow: 2px 3px 0 #4b454226;
}
.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 { 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: 2px 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: 2px 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: 2px 3px 0 #4b454226; }
.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: 2.5px 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: 2px solid transparent;
}
.tabs button b { width: 28px; height: 28px; display: block; }
.tabs button.on { color: var(--ink); background: #fffdf8; border-color: var(--ink); }
.tabs .serve {
  flex: 1.3; background: var(--rose); color: var(--ink); font-size: 23px; font-weight: 700;
  justify-content: center; border: 2.5px solid var(--ink);
  border-radius: var(--sk-btn); box-shadow: var(--shadow); transform: rotate(-1.5deg);
}
.tabs .serve:active { transform: rotate(-1.5deg) translate(2px, 3px); box-shadow: none; }

/* 하루 끝 */
#s-dayend h2 { font-size: 34px; margin: 4px 0 0; }
.de-stats {
  background: #fffdf8; border: 2px solid var(--ink); border-radius: var(--sk-box);
  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: #b5c6a5b3; 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)); }
}
