/* 해피 할로윈: Arc:ade 모바일 디자인 시스템의 회색 단계를 밤 배경으로 뒤집었다.
   색은 Fluent 3D 이모지만. 굵기 최대 700, 숫자는 tabular-nums. 바닥 표면 그림자 없음. */
:root {
  --ink: #ffffff;
  --title: #f9fafb;
  --body: #d1d5dc;
  --muted: #99a1af;
  --tertiary: #6a7282;
  --line: #364153;
  --surface: #1e2939;
  --panel: #182230;
  --bg: #101828;
  --error: #ffb4b4;
  --radius: 16px;
  --ease: cubic-bezier(0.42, 0, 0.58, 1);
  --snap: cubic-bezier(0.22, 1, 0.36, 1);
  --font: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); min-height: 100%; }
html, body { overflow-x: hidden; }
body {
  margin: 0; min-height: 100dvh; font-family: var(--font); font-size: 16px; line-height: 1.5; color: var(--body); background: var(--bg);
  word-break: keep-all; overflow-wrap: anywhere; letter-spacing: -0.02em; -webkit-font-smoothing: antialiased;
}
b, strong { font-weight: 700; color: var(--ink); }
button, input, textarea { font: inherit; color: inherit; }
a { color: var(--ink); }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }

.topbar { position: fixed; top: 0; left: 0; right: 0; z-index: 20; }
.topbar-in { height: 56px; display: flex; align-items: center; justify-content: center; }
.brand { font-size: 12px; font-weight: 700; letter-spacing: 0.24em; color: var(--ink); text-decoration: none; min-height: 44px; min-width: 44px; display: inline-flex; align-items: center; justify-content: center; padding: 0 12px; }
.wrap { max-width: 500px; margin: 0 auto; padding: 64px 16px 36px; }
#view { min-height: 60dvh; }
footer { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; margin-top: 32px; font-size: 13px; }
footer a { color: var(--muted); text-decoration: none; min-height: 44px; display: inline-flex; align-items: center; }

h1 { font-size: 26px; line-height: 1.25; font-weight: 700; margin: 8px 0; letter-spacing: -0.035em; color: var(--title); }
h2 { font-size: 22px; line-height: 1.3; font-weight: 700; margin: 4px 0 8px; letter-spacing: -0.03em; color: var(--title); }
p { margin: 0 0 12px; }
.lead { font-size: 16px; }
.small { font-size: 13px; line-height: 1.6; color: var(--muted); letter-spacing: -0.01em; }
.center { text-align: center; }
.stack > * + * { margin-top: 12px; }
.num { font-variant-numeric: tabular-nums; }

.card { background: var(--surface); border-radius: var(--radius); padding: 20px 18px; margin: 16px 0; }
.panel { background: var(--panel); border-radius: var(--radius); padding: 16px; margin: 12px 0; }

.btn {
  display: flex; align-items: center; justify-content: center; width: 100%; min-height: 52px; padding: 14px 20px;
  border: 0; border-radius: 14px; background: var(--ink); color: var(--bg); font-size: 17px; font-weight: 700; cursor: pointer;
  transition: transform 0.12s var(--snap), opacity 0.12s;
}
.btn:active { transform: scale(0.98); }
.btn[disabled] { opacity: 0.5; cursor: default; }
.btn.ghost { background: var(--surface); color: var(--ink); }

/* 밤하늘 떠다니는 이모지 */
.sky { position: relative; height: 220px; margin: 8px 0 4px; }
.sky img { position: absolute; width: 120px; height: 120px; left: 50%; top: 50%; margin: -60px 0 0 -60px; animation: bob 3.2s var(--ease) infinite; }
.sky img.ghost { width: 64px; height: 64px; margin: -92px 0 0 40px; animation: drift 5s var(--ease) infinite; opacity: 0.95; }
.sky img.candy { width: 40px; height: 40px; margin: 20px 0 0 -112px; animation: drift 4.2s var(--ease) infinite reverse; }
.sky img.skull { width: 34px; height: 34px; margin: 48px 0 0 88px; animation: bob 4.6s var(--ease) infinite; opacity: 0.8; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
@keyframes drift { 0%, 100% { transform: translate(0, 0) rotate(-4deg); } 50% { transform: translate(8px, -14px) rotate(4deg); } }

/* 바구니 흔들기 (2.5초) */
.sky img.shake { animation: shake 2.5s var(--snap) forwards; }
@keyframes shake {
  0% { transform: rotate(0) scale(1); }
  10% { transform: rotate(-12deg) scale(1.02); }
  20% { transform: rotate(12deg) scale(1.04); }
  30% { transform: rotate(-14deg) scale(1.06); }
  40% { transform: rotate(14deg) scale(1.08); }
  50% { transform: rotate(-10deg) scale(1.1); }
  60% { transform: rotate(10deg) scale(1.12); }
  70% { transform: rotate(-6deg) scale(1.16); }
  80% { transform: rotate(6deg) scale(1.2); }
  90% { transform: rotate(0) scale(1.28); }
  100% { transform: rotate(0) scale(0.2); opacity: 0; }
}

/* 결과 카드 */
.reveal { text-align: center; animation: pop 0.6s var(--snap) both; }
.reveal img.prize-img { width: 160px; height: 160px; animation: bob 3s var(--ease) infinite; }
.reveal img.prize-img.photo { border-radius: 24px; object-fit: cover; animation: none; }
.reveal .prize-name { font-size: 26px; font-weight: 700; color: var(--title); letter-spacing: -0.03em; margin: 6px 0 4px; }
.reveal.special .prize-name { font-size: 30px; }
@keyframes pop { 0% { transform: scale(0.6); opacity: 0; } 60% { transform: scale(1.05); opacity: 1; } 100% { transform: scale(1); } }

.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 10; }
.confetti i { position: absolute; top: -20px; width: 8px; height: 14px; border-radius: 2px; animation: fall 2.6s linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(540deg); opacity: 0.6; } }

.tag { display: inline-block; background: var(--line); color: var(--ink); border-radius: 999px; padding: 4px 12px; font-size: 13px; font-weight: 700; }
.err { color: var(--error); font-size: 14px; }
@media (prefers-reduced-motion: reduce) { .sky img, .reveal img, .reveal, .confetti i { animation: none !important; } }

/* 로고: 그라데이션 원본을 흰색으로 */
.brand { gap: 7px; }
.symbol { height: 22px; width: 22px; display: block; }
.logo { height: 22px; width: auto; display: block; filter: brightness(0) invert(1); }
.logo.sm { height: 14px; margin: 0 auto; opacity: 0.8; }
.from { margin-top: 18px; font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 6px; align-items: center; }

/* 탭 미니게임 */
.game { text-align: center; }
.tap-zone { position: relative; height: 240px; display: flex; align-items: center; justify-content: center; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
.tap-target { background: none; border: 0; padding: 0; width: 180px; height: 180px; cursor: pointer; border-radius: 50%; }
.tap-target img { width: 100%; height: 100%; display: block; animation: bob 3.2s var(--ease) infinite; }
.tap-target.bump img { animation: bump 0.18s var(--snap); }
@keyframes bump { 0% { transform: scale(1); } 50% { transform: scale(1.14) rotate(-4deg); } 100% { transform: scale(1); } }
.fly { position: absolute; width: 32px; height: 32px; left: 50%; top: 50%; margin: -16px 0 0 -16px; pointer-events: none; animation: fly 0.8s var(--ease) forwards; }
@keyframes fly { 0% { transform: translate(0, 0) scale(0.6); opacity: 1; } 100% { transform: translate(var(--dx), var(--dy)) scale(1) rotate(var(--rot)); opacity: 0; } }
.ring { width: 96px; height: 96px; margin: 0 auto 8px; position: relative; }
.ring svg { transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 8; }
.ring .bg { stroke: var(--line); }
.ring .fg { stroke: var(--ink); stroke-linecap: round; transition: stroke-dashoffset 0.12s linear; }
.ring b { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 22px; font-variant-numeric: tabular-nums; }
.timer { font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.bar { height: 6px; background: var(--line); border-radius: 999px; overflow: hidden; margin: 10px 0; }
.bar i { display: block; height: 100%; background: var(--ink); border-radius: 999px; transition: width 0.1s linear; }
@media (prefers-reduced-motion: reduce) { .tap-target img, .fly, .tap-target.bump img { animation: none !important; } .fly { display: none; } }

.logo.md { height: 22px; }
.hero-from { margin: 0 0 4px; }
.next-card { padding-top: 80px; }

/* 미션 공통: 시간 바, 카운트다운, 마지막 1초 흔들림 */
.tbar-wrap { height: 10px; background: var(--line); border-radius: 999px; overflow: hidden; margin: 8px 0 6px; }
.tbar-wrap i { display: block; height: 100%; background: var(--ink); border-radius: 999px; transition: width 0.05s linear, background 0.2s; }
.tbar-wrap i.danger { background: #ff5a5a; }
.tnum { font-size: 40px; font-weight: 700; color: var(--title); font-variant-numeric: tabular-nums; line-height: 1.1; margin-bottom: 4px; }
.tnum.pulse { color: #ff5a5a; animation: pulse 0.5s var(--ease) infinite; }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.18); } }
.game.quake { animation: quake 0.12s linear infinite; }
@keyframes quake { 0% { transform: translate(0, 0); } 25% { transform: translate(2px, -1px); } 50% { transform: translate(-2px, 1px); } 75% { transform: translate(1px, 2px); } 100% { transform: translate(0, 0); } }

/* 유령 잡기 */
.arena { position: relative; height: 300px; background: var(--surface); border-radius: var(--radius); overflow: hidden; touch-action: manipulation; }
.ghost-btn { position: absolute; width: 72px; height: 72px; background: none; border: 0; padding: 0; cursor: pointer; animation: ghostIn 0.2s var(--snap) both; }
.ghost-btn img { width: 100%; height: 100%; display: block; }
.ghost-btn.hit { animation: ghostOut 0.2s var(--snap) forwards; }
@keyframes ghostIn { from { transform: scale(0.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes ghostOut { to { transform: scale(1.5); opacity: 0; } }
.ghost-count { font-size: 18px; font-weight: 700; color: var(--title); font-variant-numeric: tabular-nums; margin-bottom: 8px; }

/* 지금 열기 */
.tap-target.dim img { filter: brightness(0.35) saturate(0.4); transition: filter 0.1s; }
.tap-target.flash img { animation: flash 0.25s var(--snap) 3; }
@keyframes flash { 0%, 100% { filter: brightness(1); transform: scale(1); } 50% { filter: brightness(1.8); transform: scale(1.12); } }
.now { position: absolute; left: 50%; top: 10px; transform: translateX(-50%); font-size: 28px; font-weight: 700; color: #ffd166; pointer-events: none; animation: pop 0.3s var(--snap) both; }
@media (prefers-reduced-motion: reduce) { .game.quake { animation: none !important; } }

/* 오늘의 바구니 */
.strip-wrap { margin: 4px 0 12px; }
.strip-title { margin: 0 0 8px; font-weight: 700; color: var(--muted); }
.strip { display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 4px 16px 10px; margin: 0 -16px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.strip::-webkit-scrollbar { display: none; }
.strip .pcard { flex: 0 0 150px; scroll-snap-align: start; }
.strip .pcard.gold { flex-basis: 170px; }
.pcard { background: var(--surface); border-radius: 16px; padding: 8px; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--body); animation: drift-card 3s var(--ease) infinite; position: relative; overflow: hidden; }
.pcard:nth-child(2) { animation-delay: -1s; } .pcard:nth-child(3) { animation-delay: -2s; } .pcard:nth-child(4) { animation-delay: -1.5s; }
@keyframes drift-card { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
.pcard .pimg { width: 100%; aspect-ratio: 1; border-radius: 12px; display: flex; align-items: center; justify-content: center; overflow: hidden; background: var(--panel); }
.pcard .pimg img { width: 60%; height: 60%; object-fit: contain; }
.pcard.photo .pimg img { width: 100%; height: 100%; object-fit: cover; }
.pcard.gold { background: #1f1a12; }
.pcard.gold::after { content: ''; position: absolute; top: -40%; left: -60%; width: 40%; height: 180%; background: linear-gradient(100deg, transparent 0%, rgba(255, 230, 160, 0.28) 50%, transparent 100%); transform: rotate(12deg); animation: shimmer 4s linear infinite; }
@keyframes shimmer { 0% { left: -60%; } 30% { left: 130%; } 100% { left: 130%; } }
.pcard.white.photo .pimg { background: #fff; }
.tally { margin: 0 0 10px; }
.tally b { color: #ffd166; }

/* 결과 카드 사진 틀 */
.prize-tile { width: 180px; height: 180px; margin: 0 auto; border-radius: 24px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.prize-tile .prize-img { width: 160px; height: 160px; }
.prize-tile.white { background: #fff; }
.prize-tile.white .prize-img.photo { width: 100%; height: 100%; }
.prize-tile.gold { background: #1f1a12; }
.prize-tile.gold .prize-img.photo { width: 100%; height: 100%; object-fit: cover; }
@media (prefers-reduced-motion: reduce) { .pcard, .pcard.gold::after { animation: none !important; } }

/* 초대, 토스트, 폼 */
.btn-ico { width: 22px; height: 22px; margin-right: 6px; }
.invite h3 { margin: 0; }
.invite-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.invite-left { display: flex; gap: 2px; }
.invite-left .chip { width: 26px; height: 26px; transition: opacity .3s, filter .3s; }
.invite-left .chip.used { opacity: .25; filter: grayscale(1); }
.invite-n { margin-left: 6px; font-size: 13px; font-weight: 500; opacity: .7; }
.btn.sm { min-height: 40px; font-size: 13px; }
.toast { position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: 14px; font-weight: 700; z-index: 30; animation: pop 0.25s var(--snap) both; }
label.small { display: block; }
label.small input[type=text], label.small input[type=tel] { width: 100%; margin-top: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px; color: var(--ink); min-height: 48px; font-size: 16px; }
label.check { display: flex; gap: 8px; align-items: flex-start; }
label.check input { width: 20px; height: 20px; margin-top: 2px; flex: none; }
.wrap-notop { padding-top: 28px; }

/* 하단 고정 바 */
.actbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; display: flex; gap: 8px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: rgba(16, 24, 40, 0.78); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line); }
.actbar .btn { margin: 0; max-width: 500px; margin: 0 auto; }
.actbar .btn + .btn { margin-left: 0; }
body.has-bar .wrap { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
.wrap { padding-top: 64px; }
footer { margin-top: 24px; }
.reveal .prize-name { margin: 8px 0 4px; }
.invite-head h2 { font-size: 20px; }
.hero-from { display: none; }
.countdown { font-size: 15px; margin: 0 0 8px; } .countdown b { color: #ffd166; }
#turnstile:empty { display: none; }

/* 인스타 연동 조건 모달: 닫기 없음 */
.gate { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; background: rgba(6, 10, 20, 0.72); backdrop-filter: blur(6px); padding: 16px; }
.gate-card { width: 100%; max-width: 420px; background: var(--surface); border-radius: 24px; padding: 28px 20px 20px; text-align: center; display: flex; flex-direction: column; gap: 10px; animation: gateUp .35s var(--snap); }
.gate-card h2 { margin: 4px 0 0; font-size: 21px; color: var(--title); }
.gate-card .small { margin: 0 0 8px; }
.gate-card .btn { text-decoration: none; display: flex; align-items: center; justify-content: center; }
.gate-ico { width: 64px; height: 64px; margin: 0 auto; }
body.gated { overflow: hidden; }
body.gated .actbar { visibility: hidden; }
@media (min-width: 560px) { .gate { align-items: center; } }
@keyframes gateUp { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .gate-card { animation: none; } }

/* 오늘의 바구니 띠: 저절로 옆으로 흐른다. 누르고 있으면 멈춘다 */
.strip { overflow: hidden; scroll-snap-type: none; padding: 4px 0 10px; margin: 0 -16px; }
.strip-track { display: flex; gap: 10px; width: max-content; animation: stripFlow 18s linear infinite; }
.strip-dup { display: flex; gap: 10px; }
.strip-track .pcard { flex: 0 0 150px; }
.strip-track .pcard.gold { flex-basis: 170px; }
.strip:active .strip-track, .strip:hover .strip-track { animation-play-state: paused; }
@keyframes stripFlow { from { transform: translateX(0); } to { transform: translateX(calc(-50% - 5px)); } }
@media (prefers-reduced-motion: reduce) { .strip { overflow-x: auto; } .strip-track { animation: none; } .strip-dup { display: none; } }

/* 사탕 뽕뽕: 아래에서 위로 */
.candy-rain { position: fixed; inset: 0; pointer-events: none; z-index: 1; overflow: hidden; }
.candy-rain img { position: absolute; bottom: -48px; opacity: 0; animation: rise linear forwards; filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.35)); }
@keyframes rise {
  0% { transform: translate(0, 0) rotate(0deg) scale(0.6); opacity: 0; }
  8% { opacity: 0.95; transform: translate(0, -8vh) rotate(0deg) scale(1.05); }
  50% { transform: translate(var(--wob), -55vh) rotate(var(--spin)) scale(1); opacity: 0.9; }
  100% { transform: translate(calc(var(--wob) * -1), -112vh) rotate(calc(var(--spin) * 2)) scale(0.8); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) { .candy-rain { display: none; } }

/* 시작 카운트다운 */
.intro { padding-top: 40px; }
.cd-num { font-size: 96px; font-weight: 700; color: var(--title); line-height: 1; min-height: 110px; margin-top: 24px; font-variant-numeric: tabular-nums; letter-spacing: -0.04em; }
.cd-num.pop { animation: cdpop 0.8s var(--snap) both; }
.cd-num.go { color: #ffd166; font-size: 72px; }
@keyframes cdpop { 0% { transform: scale(0.5); opacity: 0; } 30% { transform: scale(1.15); opacity: 1; } 100% { transform: scale(1); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .cd-num.pop { animation: none !important; } }

/* 카카오톡 선물하기 표시 */
.kakao-pill { display: inline-flex; align-items: center; gap: 5px; background: #FEE500; color: #191919; font-weight: 700; font-size: 13px; line-height: 1; padding: 5px 9px 5px 7px; border-radius: 999px; vertical-align: middle; white-space: nowrap; }
