* { box-sizing: border-box; }
html, body { height: 100%; overflow-x: hidden; }
body {
  margin: 0;
  background: radial-gradient(120% 80% at 50% 0%, #1b1c22 0%, #0a0a0d 60%);
  background-attachment: fixed;
  color: #f2f2f2;
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  -webkit-font-smoothing: antialiased;
  word-break: keep-all;
  overflow-x: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; }

.stage {
  min-height: 100dvh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px 0;
  animation: fade .5s ease both;
}
.stage[hidden] { display: none; }
.stage.out { animation: fadeout .35s ease both; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } }
@keyframes fadeout { to { opacity: 0; transform: translateY(-8px); } }

/* 앱 이름: 낱말마다 크기와 등장이 다르다 */
h1 {
  margin: 0; width: min(88vw, 420px); display: flex; flex-wrap: wrap; align-items: baseline;
  font-weight: 900; letter-spacing: -0.05em; line-height: 1.02; --u: min(1vw, 4.8px);
}
.w { display: block; flex: 0 0 100%; opacity: 0; animation-fill-mode: both; animation-timing-function: cubic-bezier(.2, .9, .2, 1); }
.w i { display: inline-block; font-style: normal; white-space: pre; }

.w1 { flex: none; font-size: calc(var(--u) * 13); color: #ffd3dc; animation: slide .45s .15s both; }
.w2 { flex: none; margin-left: .3em; font-size: calc(var(--u) * 7); font-weight: 600; color: #8c8c94; animation: pop .3s .6s both; }
.w3 { margin-top: .25em; font-size: calc(var(--u) * 15); opacity: 1; }
.w3 i { opacity: 0; transform-origin: 50% 0; animation: droop .7s both cubic-bezier(.3, 1.6, .5, 1); animation-delay: calc(.95s + var(--n) * 60ms); }
.w5 { font-size: calc(var(--u) * 19); color: #ff3b30; transform-origin: 0 60%; animation: slam .38s 1.8s both cubic-bezier(.2, 2.2, .4, 1), rage .07s 2.18s 8 alternate; }
.w6 { margin-top: .2em; font-size: calc(var(--u) * 16); opacity: 1; }
.w6 i {
  opacity: 0; animation: star .5s both cubic-bezier(.2, 2, .4, 1); animation-delay: calc(2.55s + var(--n) * 80ms);
  background: linear-gradient(100deg, #ffe27a, #ff8ad1, #7ad7ff, #a6ff9e); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.w7 { font-size: calc(var(--u) * 26); color: #ffb35c; animation: rise .7s 3.05s both; }
.w8 { margin-top: .08em; font-size: calc(var(--u) * 21); opacity: 1; color: #fff; }
.w8 i { opacity: 0; animation: stretch .6s both cubic-bezier(.2, 1.5, .4, 1); animation-delay: calc(3.6s + var(--n) * 55ms); }

@keyframes slide { from { opacity: 0; transform: translateX(-60vw) skewX(-25deg); } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: scale(0); } 70% { transform: scale(1.5); } to { opacity: 1; } }
@keyframes droop { from { opacity: 0; transform: translateY(-90px) rotate(0); } 55% { opacity: 1; transform: translateY(12px) rotate(calc((var(--n) - 2) * 5deg)); } to { opacity: 1; transform: translateY(calc(var(--n) * 2.2px)) rotate(calc((var(--n) - 2) * 2.5deg)); } }
@keyframes frost { from { opacity: 0; filter: blur(14px); transform: scale(1.6); } to { opacity: 1; filter: blur(0); } }
@keyframes shiver { from { transform: translateX(-2.5px) rotate(-1.5deg); } to { transform: translateX(2.5px) rotate(1.5deg); } }
@keyframes slam { from { opacity: 0; transform: scale(5) rotate(-8deg); } to { opacity: 1; transform: scale(1) rotate(-2deg); } }
@keyframes rage { from { transform: translate(-4px, 2px) rotate(-3deg); } to { transform: translate(4px, -2px) rotate(-1deg); } }
@keyframes star { from { opacity: 0; transform: translateY(40px) scale(.2) rotate(40deg); } to { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(70px); filter: blur(12px); letter-spacing: .3em; } to { opacity: 1; } }
@keyframes stretch { from { opacity: 0; transform: scaleY(3.2) translateY(30%); } to { opacity: 1; } }

.q { margin: 0 24px 14px; text-align: center; line-height: 1.35; font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.yes { width: 150px; padding: 14px 0; border: 0; border-radius: 999px; background: #f2f2f2; color: #0a0a0d; font-size: 18px; font-weight: 700; }
.yes:disabled { opacity: .4; }
.err { margin: 0 32px 22px; min-height: 1em; font-size: 14px; color: #bbb; text-align: center; }

.place { margin: 0 0 6px; font-size: 14px; color: #8c8c94; }
.msg { margin: 0 24px 16px; color: #999; font-size: 13px; text-align: center; }

/* 카드 한 줄을 살짝 겹쳐 포개 놓는다. 가운데 한 장이 크게, 양옆 카드가 걸쳐 보인다. 폰 화면 기준. */
.cards {
  list-style: none; padding: 0; position: relative;
  width: min(68vw, 290px, calc((100dvh - 250px) * 5 / 7)); aspect-ratio: 5 / 7;
  margin: 26px auto 34px; touch-action: pan-y; user-select: none; -webkit-user-select: none;
}
.cards:empty { display: none; }

.slot {
  position: absolute; inset: 0; perspective: 900px;
  transform: translate3d(calc(var(--p, 0) * 56% + var(--dx, 0px)), calc(var(--a, 0) * 12px), 0) rotate(calc(var(--p, 0) * 4deg)) scale(calc(1 - var(--a, 0) * .1));
  transition: transform .5s cubic-bezier(.2, .9, .25, 1), opacity .3s, filter .3s;
  filter: brightness(.62);
}
.slot[data-pos="0"] { filter: none; }
.slot:not([data-pos="0"]):not([data-pos="1"]):not([data-pos="-1"]):not([data-pos="2"]):not([data-pos="-2"]) { opacity: 0; pointer-events: none; }
.cards.drag .slot { transition: none; }

.card {
  display: flex; flex-direction: column; width: 100%; height: 100%; padding: 20px 18px 16px;
  border: 7px solid #fff; border-radius: 20px; background: var(--c); color: #fff; text-decoration: none;
  box-shadow: 0 14px 30px rgba(0, 0, 0, .45);
  -webkit-tap-highlight-color: transparent; -webkit-user-drag: none;
  animation: .8s cubic-bezier(.2, 1.2, .3, 1) backwards; animation-delay: calc(var(--a, 0) * 110ms);
}
.card.ink { color: #1a1a1a; }

/* 등장: 카드마다 다르게 들어온다 */
.e1 { animation-name: drop; }
.e2 { animation-name: spin; }
.e3 { animation-name: door; }
.e4 { animation-name: stamp; animation-timing-function: cubic-bezier(.2, 1.6, .4, 1); }
.e5 { animation-name: toss; }
.e6 { animation-name: hang; transform-origin: 50% 0; }
@keyframes drop { from { transform: translateY(-120vh) rotate(-16deg); } 60% { transform: translateY(18px) rotate(3deg); } }
@keyframes spin { from { transform: scale(.1) rotate(-300deg); opacity: 0; } }
@keyframes door { from { transform: rotateY(-110deg) translateX(-40%); opacity: 0; } }
@keyframes stamp { from { transform: scale(3); opacity: 0; } }
@keyframes toss { from { transform: translate(70vw, 80vh) rotate(60deg); } }
@keyframes hang { from { transform: rotateX(-100deg); opacity: 0; } 55% { transform: rotateX(22deg); } 78% { transform: rotateX(-10deg); } }

/* 다시 뽑을 때 */
.cards.leave .slot { transition: transform .4s cubic-bezier(.6, 0, .9, .4), opacity .4s; transform: translate3d(calc(var(--p, 0) * 120%), 110vh, 0) rotate(calc(var(--p, 0) * 20deg)); opacity: 0; }

.type { font-size: 12px; font-weight: 700; opacity: .8; }
.name { margin-top: 6px; font-size: 24px; font-weight: 900; letter-spacing: -0.04em; line-height: 1.18; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.art img { height: 100%; max-height: 150px; min-height: 0; aspect-ratio: 1; object-fit: contain; filter: drop-shadow(0 10px 10px rgba(0, 0, 0, .28)); -webkit-user-drag: none; }
.art { flex: 1; min-height: 56px; display: flex; align-items: center; justify-content: center; font-size: clamp(56px, 20vw, 84px); line-height: 1; }
.menu { list-style: none; margin: 0; padding: 0; min-height: 0; font-size: 17px; font-weight: 800; letter-spacing: -0.03em; line-height: 1.35; }
.menu li { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.meta { margin-top: 12px; padding-top: 10px; border-top: 2px solid currentColor; font-size: 11px; font-weight: 600; letter-spacing: -0.02em; opacity: .85; }

/* 가운데로 온 카드는 그림과 메뉴가 한 번 더 움직인다 */
.slot[data-pos="0"] .art { animation: bounce .6s cubic-bezier(.2, 1.8, .4, 1) .12s backwards; }
.slot[data-pos="0"] .menu li { animation: line .4s cubic-bezier(.2, .9, .2, 1) backwards; animation-delay: calc(.2s + var(--n) * 70ms); }
@keyframes bounce { from { transform: scale(.3) rotate(-30deg); } }
@keyframes line { from { transform: translateX(-24px); opacity: 0; } }

.scale { display: flex; align-items: center; gap: 12px; font-size: 11px; color: #8c8c94; }
.scale[hidden] { display: none; }
.dots { display: flex; gap: 7px; }
.dots[hidden] { display: none; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: rgba(255,255,255,.22); transition: background .3s, width .3s; }
.dots i.on { width: 18px; border-radius: 3px; background: #f2f2f2; }
.reroll { margin-top: 18px; padding: 8px 16px; border: 0; border-radius: 999px; background: rgba(255,255,255,.1); font-size: 13px; color: #cfcfd4; }
.reroll[hidden] { display: none; }
.note { margin: 22px 24px 0; max-width: 420px; font-size: 11px; color: #6c6c74; text-align: center; }

@media (prefers-reduced-motion: reduce) {
  .card, .art, .menu li, .stage { animation: none !important; }
  .w, .w i { animation: none !important; opacity: 1 !important; }
}
