/* Daily Pack — full-screen feed, one pack per screen. Gesture-first: no nav buttons. */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  color-scheme: dark;
  --bg: #08090c; --text: #f2f3f5; --muted: #9aa1ae; --gold: #ffd21f;
  --pack-h: min(62dvh, 600px);
  --card-h: min(62dvh, 560px);
}
html, body { height: 100%; }
body {
  background: var(--bg); color: var(--text); overflow: hidden;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  -webkit-tap-highlight-color: transparent;
}
:lang(ko) body { word-break: keep-all; }
img { -webkit-user-drag: none; user-select: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
a { color: inherit; }

/* HUD */
.hud {
  position: fixed; top: 0; left: 0; right: 0; z-index: 30;
  display: flex; justify-content: space-between; align-items: center;
  padding: max(12px, env(safe-area-inset-top)) 16px 12px; pointer-events: none;
}
.hud > * { pointer-events: auto; }
.brand { font-size: 14px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; opacity: .9; text-decoration: none; padding: 6px 0; }
.brand span { color: var(--gold); margin-left: .35em; }
.brand:hover { opacity: 1; }
.lang select {
  appearance: none; background: rgba(255,255,255,.08); color: var(--text); border: 0;
  border-radius: 999px; padding: 7px 12px; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; min-height: 32px;
}

/* Feed */
.feed {
  position: fixed; inset: 0; overflow-y: auto; scroll-snap-type: y mandatory;
  overscroll-behavior: contain; scrollbar-width: none; outline: none;
}
.feed::-webkit-scrollbar { display: none; }
.slide {
  position: relative; height: 100vh; height: 100dvh; scroll-snap-align: start; scroll-snap-stop: always;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  overflow: hidden; isolation: isolate; padding: 56px 16px 28px;
}
.slide::before {
  content: ""; position: absolute; inset: -20%; z-index: -1;
  background: radial-gradient(circle at 50% 46%, var(--glow, #333) 0%, transparent 46%);
  opacity: .55; filter: blur(30px); animation: drift 9s ease-in-out infinite alternate;
}
@keyframes drift { to { transform: translate(3%, -2%) scale(1.06); } }

.pack { background: none; border: 0; padding: 0; cursor: pointer; perspective: 900px; animation: bob 4.2s ease-in-out infinite; }
.pack:focus-visible { outline: 2px solid var(--gold); outline-offset: 8px; border-radius: 8px; }
.pack-float {
  position: relative; display: block; height: var(--pack-h);
  transform: rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)); transition: transform .18s ease-out;
}
.pack-float img { height: 100%; width: auto; display: block; filter: drop-shadow(0 26px 40px rgba(0,0,0,.6)); }
.shine {
  position: absolute; inset: 1% 3%; pointer-events: none; border-radius: 6px; mix-blend-mode: overlay;
  background: linear-gradient(105deg, transparent 38%, rgba(255,255,255,.55) 48%, rgba(255,255,255,0) 58%);
  background-size: 260% 100%; animation: sweep 3.8s ease-in-out infinite;
}
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
@keyframes sweep { 0% { background-position: 130% 0; } 55%, 100% { background-position: -40% 0; } }
.pack-name { font-size: 22px; font-weight: 800; letter-spacing: -.01em; text-align: center; }
.pack-meta { font-size: 13px; color: var(--muted); margin-top: -6px; }

.hint {
  position: fixed; left: 50%; bottom: max(22px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 25;
  background: rgba(255,255,255,.1); backdrop-filter: blur(8px); border-radius: 999px;
  padding: 8px 16px; font-size: 13px; font-weight: 600; white-space: nowrap; transition: opacity .4s;
  animation: nudge 1.8s ease-in-out infinite;
}
.hint.gone, .hint:empty { opacity: 0; pointer-events: none; }
@keyframes nudge { 0%, 100% { transform: translate(-50%, 0); } 50% { transform: translate(-50%, -6px); } }

.about-slide { height: auto; min-height: 45dvh; justify-content: flex-end; gap: 10px; color: var(--muted); font-size: 12.5px; line-height: 1.6; text-align: center; max-width: 560px; margin: 0 auto; scroll-snap-align: end; }
.about-slide::before { display: none; }
.load-fail { padding: 40vh 24px 0; text-align: center; color: var(--muted); }

/* Buttons (result only) */
.btn {
  min-height: 48px; padding: 0 20px; border-radius: 999px; border: 1px solid rgba(255,255,255,.18);
  background: rgba(255,255,255,.08); color: var(--text); font: inherit; font-size: 15px; font-weight: 800; cursor: pointer;
}
.btn.primary { background: var(--gold); color: #141414; border-color: transparent; }
.btn:disabled { opacity: .55; cursor: default; }
.btn:focus-visible, .r-cta:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }

/* Result slide */
.result-slide { gap: 8px; padding-top: 52px; }
.r-label { font-size: 12px; font-weight: 700; letter-spacing: .14em; color: var(--muted); text-align: center; }
.r-total { font-size: clamp(36px, 6dvh, 52px); font-weight: 900; line-height: 1; }
.r-best {
  position: relative; height: min(40dvh, 420px); aspect-ratio: 63 / 88; border-radius: 4.5% / 3.3%;
  transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)); transition: transform .18s ease-out;
  box-shadow: 0 20px 50px rgba(0,0,0,.6); margin: 6px 0 2px;
}
.r-best img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; display: block; }
.r-best-name { font-size: 14px; font-weight: 700; text-align: center; max-width: 92vw; }
.r-strip { list-style: none; display: flex; gap: 6px; overflow-x: auto; max-width: min(100%, 640px); padding: 4px 2px; scrollbar-width: none; }
.r-strip::-webkit-scrollbar { display: none; }
.r-strip li { flex: 0 0 auto; height: min(11dvh, 110px); aspect-ratio: 63 / 88; }
.r-strip img { width: 100%; height: 100%; object-fit: cover; border-radius: 5px; display: block; }
.r-actions { display: flex; gap: 8px; width: min(100%, 420px); margin-top: 6px; }
.r-actions .btn { flex: 1; }
.r-cta { display: flex; align-items: center; justify-content: center; width: min(100%, 420px); text-decoration: none; color: var(--gold); border-color: var(--gold); background: transparent; }
.r-next { font-size: 12.5px; color: var(--muted); }
.result-slide.enter > * { animation: rise .5s ease-out both; }
.result-slide.enter > :nth-child(2) { animation-delay: .05s; }
.result-slide.enter > :nth-child(3) { animation-delay: .1s; }
.result-slide.enter > :nth-child(n+4) { animation-delay: .18s; }
@keyframes rise { from { opacity: 0; transform: translateY(24px); } }

/* Holo shimmer on hits */
.holo {
  position: absolute; inset: 0; border-radius: inherit; pointer-events: none; opacity: 0; mix-blend-mode: color-dodge;
  background: linear-gradient(115deg, transparent 18%, rgba(255,0,170,.35) 34%, rgba(0,255,225,.35) 50%, rgba(255,235,0,.35) 66%, transparent 82%);
  background-size: 260% 260%; animation: holo 2.6s linear infinite;
}
[data-tier="ultra"] > .holo, [data-tier="illus"] > .holo, [data-tier="special"] > .holo { opacity: .55; }
@keyframes holo { from { background-position: 0% 50%; } to { background-position: 100% 50%; } }

/* Stage: tearing and the card stack */
.stage { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; background: rgba(6,7,10,.94); transition: opacity .3s; }
.stage[hidden] { display: none; }
.stage > .tear, .stage > .deck { grid-area: 1 / 1; }
.stage.done { opacity: 0; }
.stage-glow { position: absolute; inset: -20%; background: radial-gradient(circle at 50% 48%, var(--glow, #444) 0%, transparent 45%); opacity: .6; filter: blur(34px); pointer-events: none; }
.tear {
  position: relative; height: var(--pack-h); aspect-ratio: 416 / 760; touch-action: none; user-select: none; cursor: grab;
  transition: transform .45s cubic-bezier(.2,.8,.2,1); outline: none;
}
.tear.dragging { cursor: grabbing; }
.tear img { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.tear-body, .tear-top { position: absolute; inset: 0; }
.tear-body img { clip-path: inset(15% 0 0 0); filter: drop-shadow(0 26px 40px rgba(0,0,0,.6)); }
.tear-top { transform-origin: 0 15%;
  transform: translateY(calc(var(--p, 0) * -8px)) rotate(calc(var(--p, 0) * -7deg * var(--dir, 1))); }
.tear-top img { clip-path: inset(0 0 85% 0); }
.tear-line { position: absolute; left: 2%; right: 2%; top: 15%; height: 2px; border-top: 2px dashed rgba(255,255,255,.55); }
.tear-line span { position: absolute; left: 0; top: -3px; height: 4px; width: calc(var(--p, 0) * 100%); background: var(--gold); box-shadow: 0 0 14px var(--gold), 0 0 30px var(--gold); border-radius: 2px; }
.tear.torn .tear-top { transition: transform .6s cubic-bezier(.3,.6,.3,1), opacity .6s; transform: translate(35%, -140%) rotate(-28deg); opacity: 0; }
.tear.torn .tear-line { opacity: 0; transition: opacity .2s; }
.tear.torn .tear-body { animation: burst-open .65s ease-in forwards; }
@keyframes burst-open { 0% { filter: brightness(1); } 30% { filter: brightness(2.2); transform: scale(1.03); } 100% { filter: brightness(1.4); transform: translateY(60%) scale(.9); opacity: 0; } }
.stage.dealing .tear { display: none; }

.stage-hint {
  position: absolute; bottom: max(28px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  font-size: 13px; font-weight: 600; color: rgba(255,255,255,.8); white-space: nowrap; animation: nudge-x 1.6s ease-in-out infinite;
}
.stage-hint:empty { display: none; }
@keyframes nudge-x { 0%, 100% { transform: translateX(-50%); } 50% { transform: translateX(calc(-50% + 8px)); } }
.deck-count { position: absolute; top: max(56px, calc(env(safe-area-inset-top) + 44px)); left: 50%; transform: translateX(-50%); font-size: 13px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }

/* The deck shares the pack's grid cell; only its top card takes input, so taps reach the pack before dealing. */
.deck { position: relative; height: var(--card-h); aspect-ratio: 63 / 88; pointer-events: none; }
.card.top { pointer-events: auto; }
.card {
  position: absolute; inset: 0; border-radius: 4.5% / 3.3%; touch-action: none; cursor: grab;
  transform: translateY(calc(var(--depth, 0) * 9px)) scale(calc(1 - var(--depth, 0) * .035));
  transition: transform .26s cubic-bezier(.2,.8,.2,1), box-shadow .3s;
  box-shadow: 0 18px 40px rgba(0,0,0,.55);
  animation: deal .55s cubic-bezier(.2,.8,.2,1) var(--delay, 0ms) both;
}
.card img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; display: block; background: #1b1e26; }
.card.dragging { transition: none; cursor: grabbing; }
.card.gone { transition: transform .26s ease-in, opacity .26s ease-in; opacity: 0; }
.card:not(.top) { pointer-events: none; }
.card:not(.top) > .holo { opacity: 0; }
@keyframes deal { from { transform: translateY(70dvh) scale(.85); opacity: 0; } }
.rarity { display: none; position: absolute; left: 50%; top: calc(100% + 14px); transform: translateX(-50%); white-space: nowrap;
  font-size: 13px; font-weight: 800; letter-spacing: .04em; padding: 5px 12px; border-radius: 999px; background: rgba(0,0,0,.5); color: var(--gold); }
.card.top[data-tier="ultra"] .rarity, .card.top[data-tier="illus"] .rarity, .card.top[data-tier="special"] .rarity { display: block; }
.card.top[data-tier="ultra"] { box-shadow: 0 0 34px rgba(255,210,31,.6), 0 18px 40px rgba(0,0,0,.55); }
.card.top[data-tier="illus"] { box-shadow: 0 0 44px rgba(120,220,255,.7), 0 18px 40px rgba(0,0,0,.55); }
.card.top[data-tier="special"] { box-shadow: 0 0 54px rgba(255,120,220,.85), 0 0 90px rgba(80,255,220,.5), 0 18px 40px rgba(0,0,0,.55); }
.stage::after { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0;
  background: radial-gradient(circle at 50% 48%, rgba(255,255,255,.75), rgba(255,210,31,.25) 25%, transparent 55%); }
.stage.burst::after { animation: flash .8s ease-out; }
.stage.burst[data-tier="special"] .deck { animation: shake .45s ease-in-out; }
@keyframes flash { 0% { opacity: 0; transform: scale(.6); } 25% { opacity: 1; } 100% { opacity: 0; transform: scale(1.4); } }
@keyframes shake { 0%, 100% { transform: none; } 25% { transform: translateX(-7px) rotate(-1deg); } 50% { transform: translateX(7px) rotate(1deg); } 75% { transform: translateX(-4px); } }

.toast {
  position: fixed; left: 50%; bottom: 86px; transform: translate(-50%, 12px); z-index: 40; opacity: 0; pointer-events: none;
  background: rgba(20,22,29,.95); border: 1px solid rgba(255,255,255,.12); border-radius: 999px; padding: 10px 16px;
  font-size: 13.5px; font-weight: 600; transition: opacity .25s, transform .25s; max-width: 92vw; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
