/* 무대 — 벽·바닥·냉장고·문·영수증·플래시
 * 크기 단위: 냉장고 안에서는 1em = 문 너비의 1% (문 100em × 190em)
 * 색은 한 가지 룩으로 고정(크림핑크 + 빨강 하나). 어두운 테마는 일부러 두지 않음.
 */
:root {
  --wall: #F9DAD6;
  --wall-low: #F3C7C6;
  --floor: #EDB3B8;
  --fridge: #FCE7E0;
  --fridge-shade: #EFC8C3;
  --fridge-edge: #D8A3A3;
  --red: #D7263D;
  --red-deep: #A3142A;
  --leaf: #5F8D3B;
  --ink: #2A1B1D;
  --ink-soft: #6B5558;
  --paper: #FFFDF8;
  --amber: #FF8A1F;
  --f-ui: "Nanum Gothic Coding", "D2Coding", "Apple SD Gothic Neo", "Malgun Gothic", monospace;
  --f-pen: "Nanum Pen Script", "Gaegu", "Apple SD Gothic Neo", "Malgun Gothic", cursive;
  --f-marker: "Gaegu", "Nanum Pen Script", "Apple SD Gothic Neo", "Malgun Gothic", cursive;
  --f-pencil: "Gamja Flower", "Gaegu", "Apple SD Gothic Neo", "Malgun Gothic", cursive;
}

html, body { height: 100%; margin: 0; }
body {
  background: var(--wall); color: var(--ink);
  font-family: var(--f-ui); font-size: 15px; line-height: 1.5;
  -webkit-text-size-adjust: 100%; overscroll-behavior: none;
  word-break: keep-all; overflow-wrap: break-word;      /* 한글은 낱말 단위로 줄바꿈(「보 / 세요」처럼 꺾이지 않게) */
}
[hidden] { display: none !important; }
*, *::before, *::after { box-sizing: border-box; }

.app {
  position: relative; height: 100%; overflow: hidden;
  display: flex; flex-direction: column;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.stage { position: relative; flex: 1 1 auto; min-height: 0; overflow: hidden; }

/* 벽과 바닥 — 바닥 선 높이는 scene.js가 --floor-y로 맞춤 */
.wall {
  position: absolute; inset: 0;
  background:
    linear-gradient(to bottom,
      var(--wall) 0, var(--wall-low) calc(var(--floor-y, 80%) - 1px),
      #DFA0A8 var(--floor-y, 80%), var(--floor) calc(var(--floor-y, 80%) + 3px), #F2C2C4 100%);
}

/* 냉장고 */
.fridge {
  position: absolute; left: 0; top: 0; z-index: 1;
  width: 104em; height: 204em;
  font-size: calc(var(--u, 3.4) * 1px);
  transform: translate3d(calc(var(--fx, 0) * 1px), calc(var(--fy, 0) * 1px), 0);
}
/* 직광 플래시가 벽에 만드는 딱딱한 그림자 */
.fridge__cast {
  position: absolute; left: 4em; top: 3em; width: 104em; height: 195em;
  border-radius: 7.5em 7.5em 4em 4em;
  background: rgba(150, 62, 78, .3); filter: blur(.5em);
}
.fridge__body {
  position: absolute; left: 0; top: 0; width: 104em; height: 194em;
  border-radius: 7.5em 7.5em 4em 4em;
  background: linear-gradient(100deg, #F6D5CF, var(--fridge-shade) 60%, #E4B5B2);
  box-shadow: inset 0 0 0 .35em rgba(255, 255, 255, .35);
  perspective: 300em; perspective-origin: 50% 45%;
}
.fridge__feet {
  position: absolute; left: 9em; right: 9em; top: 194em; height: 3.4em;
  background:
    linear-gradient(#5A3A3F, #3A2428) left / 9em 100% no-repeat,
    linear-gradient(#5A3A3F, #3A2428) right / 9em 100% no-repeat;
}
.fridge__feet::after { /* 바닥에 닿는 그림자 */
  content: ""; position: absolute; left: -12em; right: -16em; top: 2.2em; height: 4em;
  background: radial-gradient(ellipse at 50% 30%, rgba(120, 40, 60, .38), rgba(120, 40, 60, 0) 70%);
}

/* 문 */
.door {
  position: absolute; left: 2em; top: 2em; width: 100em; height: 190em;
  transform-origin: 0 50%; transform: rotateY(0deg);
  transform-style: preserve-3d;
  transition: transform .95s cubic-bezier(.55, .02, .2, 1);
}
.app[data-door="open"] .door { transform: rotateY(-104deg); }
.door__front, .door__back {
  position: absolute; inset: 0; border-radius: 6em 6em 3em 3em;
  -webkit-backface-visibility: hidden; backface-visibility: hidden;
}
.door__front {
  background:
    linear-gradient(96deg, rgba(255, 255, 255, 0) 16%, rgba(255, 255, 255, .5) 24%, rgba(255, 255, 255, 0) 33%),
    linear-gradient(to bottom, #FFF1EB, var(--fridge) 30%, #F7D8D2 100%);
  background-size: cover;
  box-shadow:
    inset 0 0 0 .3em rgba(255, 255, 255, .55),
    inset -1.2em -1.6em 3em rgba(196, 120, 124, .28),
    .5em .6em 0 rgba(160, 80, 90, .22);
}
.door__back {
  transform: rotateY(180deg);
  background:
    repeating-linear-gradient(to bottom, rgba(196, 130, 130, 0) 0 38em, rgba(196, 130, 130, .45) 38em 39em),
    linear-gradient(#FFF6EE, #F3D9D0);
  box-shadow: inset 0 0 0 3em #F8E3DB, inset 0 0 0 3.4em rgba(190, 120, 120, .35);
}
.door__badge {
  position: absolute; left: 0; right: 0; top: 1.15em; text-align: center;
  font: 700 4.4em/1 "Arial Black", "Helvetica Neue", Arial, sans-serif; letter-spacing: .34em;
  text-indent: .34em; color: rgba(176, 98, 104, .6);
  text-shadow: 0 .06em 0 rgba(255, 255, 255, .8);
}

/* 손잡이 — 누르는 곳은 44px 넘게 넓히고, 보이는 막대는 가늘게 */
.handle {
  position: absolute; right: 1em; top: 66em; width: 15em; height: 58em;
  padding: 0; border: 0; background: none; cursor: pointer; z-index: 6;
  font-size: inherit; /* 버튼은 글자 크기를 물려받지 않아서, 안 적으면 em이 4배로 커져 화면 밖으로 나간다 */
  -webkit-appearance: none; appearance: none;
}
.handle__bar {
  position: absolute; right: 4em; top: 4em; width: 4.4em; bottom: 4em; border-radius: 2.2em;
  background: linear-gradient(90deg, #8E7B7E, #F7F1F0 34%, #BFAFB1 58%, #6F5C60);
  box-shadow: 1.1em 1.3em 0 rgba(150, 70, 84, .34), inset 0 0 0 .2em rgba(255, 255, 255, .4);
  transition: transform .12s ease-out;
}
.handle::after { /* 손잡이에 걸린 가격표 「열기」 */
  content: "열기"; position: absolute; right: .5em; top: 11.6em; white-space: nowrap; /* em은 이 딱지의 글자 크기 기준 */
  padding: .25em .5em; font: 700 3em/1.3 var(--f-ui); color: var(--paper);
  background: var(--red); border-radius: .3em; transform: rotate(-6deg);
  box-shadow: .12em .16em 0 rgba(120, 30, 46, .35);
}
.handle:active .handle__bar { transform: translateX(-.5em); }
.handle:focus-visible { outline: 3px solid var(--red); outline-offset: 2px; border-radius: 8px; }

/* 영수증 — 발매일은 이 물건이 말한다 */
.receipt {
  position: absolute; left: 8em; top: 15em; width: 34em; z-index: 5;
  padding: 5em 2.4em 3em; transform: rotate(-2.5deg);
  background: var(--paper); color: #2B2224;
  font-family: var(--f-ui); display: flex; flex-direction: column; gap: .7em;
  box-shadow: .5em .7em 0 rgba(150, 70, 84, .3);
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 1.2em), 95% 100%, 90% calc(100% - 1.2em), 85% 100%, 80% calc(100% - 1.2em), 75% 100%, 70% calc(100% - 1.2em), 65% 100%, 60% calc(100% - 1.2em), 55% 100%, 50% calc(100% - 1.2em), 45% 100%, 40% calc(100% - 1.2em), 35% 100%, 30% calc(100% - 1.2em), 25% 100%, 20% calc(100% - 1.2em), 15% 100%, 10% calc(100% - 1.2em), 5% 100%, 0 calc(100% - 1.2em));
}
.receipt__magnet {
  position: absolute; left: 50%; top: -1.6em; width: 7em; height: 8.2em; margin-left: -3.5em;
  background: var(--berry-1) center / contain no-repeat;
}
.receipt__shop { font-size: 4.6em; line-height: 1; text-align: center; letter-spacing: .12em; margin-top: .5em; }
.receipt__rule { border-top: .25em dashed #6E6064; }
.receipt__row { display: flex; justify-content: space-between; font-size: 2.5em; line-height: 1.25; }
.receipt__row em { font-style: normal; }
.receipt__date { font-size: 4.5em; line-height: 1.05; text-align: center; color: var(--red); letter-spacing: -.02em; }
.receipt__time { font-size: 3.4em; line-height: 1; text-align: center; font-weight: 700; }

/* 문 열릴 때만: 플래시 한 번 + 깨지는 화면(scene.js가 그림) */
.mosh {
  position: absolute; left: 0; top: 0; z-index: 5; opacity: 0; pointer-events: none;
  image-rendering: pixelated; image-rendering: crisp-edges;
}
.light { /* 플래시 핫스팟 + 모서리 어두움. 섞기 모드 없이 알파만(가볍게) */
  position: absolute; inset: 0; z-index: 6; pointer-events: none;
  background:
    radial-gradient(ellipse 62% 44% at 50% 36%, rgba(255, 255, 255, .26), rgba(255, 255, 255, 0) 62%),
    radial-gradient(ellipse 120% 100% at 50% 44%, rgba(70, 12, 28, 0) 56%, rgba(70, 12, 28, .26) 100%);
}
.grain { position: absolute; inset: 0; z-index: 7; pointer-events: none; opacity: .55; }
.flash { position: absolute; inset: 0; z-index: 8; pointer-events: none; background: #fff; opacity: 0; }
.flash.is-on { animation: flash .46s ease-out 1; }
@keyframes flash { 0% { opacity: 0; } 10% { opacity: .92; } 26% { opacity: .5; } 100% { opacity: 0; } }

/* 굴러떨어지는 딸기 */
.spill { position: absolute; left: -8em; right: -8em; top: 189.4em; height: 9em; z-index: 4; pointer-events: none; }
.berry { position: absolute; width: 7em; height: 8.2em; background: var(--berry-1) center / contain no-repeat; }
.berry--2 { background-image: var(--berry-2); }
.berry--3 { background-image: var(--berry-3); }
.berry--4 { background-image: var(--berry-4); }
.berry--5 { background-image: var(--berry-5); }
.spill .berry { left: 0; bottom: 0; opacity: 0; transform: translate3d(var(--ex), 0, 0) rotate(var(--er)); }
.spill.is-rest .berry { opacity: 1; }
.spill.is-fall .berry { opacity: 1; animation: fall var(--dur, 1s) var(--delay, .5s) both; }
@keyframes fall {
  0% { opacity: 0; transform: translate3d(var(--sx), var(--sy), 0) rotate(0deg); animation-timing-function: cubic-bezier(.5, 0, 1, .6); }
  8% { opacity: 1; }
  56% { transform: translate3d(var(--mx), 0, 0) rotate(calc(var(--er) * .6)); animation-timing-function: cubic-bezier(0, .5, .5, 1); }
  70% { transform: translate3d(calc(var(--mx) * .6 + var(--ex) * .4), -2.6em, 0) rotate(calc(var(--er) * .8)); animation-timing-function: cubic-bezier(.5, 0, 1, .6); }
  84% { transform: translate3d(calc(var(--mx) * .25 + var(--ex) * .75), 0, 0) rotate(calc(var(--er) * .95)); animation-timing-function: cubic-bezier(0, .5, .5, 1); }
  92% { transform: translate3d(calc(var(--mx) * .1 + var(--ex) * .9), -.7em, 0) rotate(var(--er)); animation-timing-function: cubic-bezier(.5, 0, 1, .6); }
  100% { opacity: 1; transform: translate3d(var(--ex), 0, 0) rotate(var(--er)); }
}

@media (prefers-reduced-motion: reduce) {
  .door { transition: none; }
  .flash.is-on { animation: none; }
  .spill.is-fall .berry { animation: none; }
  .handle__bar { transition: none; }
}
