/* 레이아웃: 키네틱 팝 배경 위 '카드 보상' 화면. 상단 캐릭터+말풍선 / 가운데 카드 3장(덱에서 뽑혀 뒤집힘) / 하단 덱·건너뛰기 */
:root {
  --cream: #F6E2A6;
  --paper: #FFF8E4;
  --black: #15121F;
  --brick: #A8322A;
  --hat: #2B1F55;
  --hat-2: #362770;
  --mint: #3BEFD9;
  --signal: #2BF5A6;
  --upgrade: #1E9E57;
  --magenta: #D63FF2;
  --blonde: #FCE38A;
  --energy: #FFB84A;
  --onair: #E8283A;
  --card-yt: #F26A55;
  --card-chzzk: #44D9C8;
  --hazard: #FFD60A;
  --f-pop: "Bagel Fat One", "IBM Plex Sans KR", system-ui, sans-serif;
  --f-body: "IBM Plex Sans KR", system-ui, -apple-system, "Malgun Gothic", sans-serif;
  color-scheme: light;
}
html, body { height: 100%; }
/* keep-all: 한글이 '골라/요'처럼 단어 중간에서 줄바꿈되지 않게 띄어쓰기 단위로만 끊는다 */
body { margin: 0; background: var(--cream); color: var(--black); font-family: var(--f-body); overflow-x: hidden; word-break: keep-all; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--hat); outline-offset: 4px; border-radius: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.table { position: relative; min-height: 100%; box-sizing: border-box; padding: max(16px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: center; gap: 14px; overflow: hidden; }

/* 흐르는 타이포 */
.marquee { position: absolute; left: 0; width: 100%; overflow: hidden; pointer-events: none; user-select: none; font-family: var(--f-pop); font-size: clamp(84px, 14vw, 180px); line-height: 1.05; white-space: nowrap; }
.marquee .track { display: inline-flex; animation: slide 38s linear infinite; }
.marquee span { padding-right: .35em; }
.m1 { top: 64px; color: transparent; -webkit-text-stroke: 2px rgba(168, 50, 42, .45); }
.m2 { bottom: 0; color: rgba(168, 50, 42, .1); }
.m2 .track { animation-direction: reverse; animation-duration: 46s; }
@keyframes slide { to { transform: translateX(-50%); } }

/* 상단: 워드마크 + 방송 상태 */
.top { position: relative; z-index: 4; width: min(980px, 100%); display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.wordmark { margin: 0; font: 26px/1 var(--f-pop); letter-spacing: .02em; }
.live-pill { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border: 3px solid var(--black); border-radius: 999px; background: #fff; box-shadow: 3px 3px 0 var(--black); font-weight: 700; font-size: 13px; text-decoration: none; white-space: nowrap; }
.live-pill .dot { width: 9px; height: 9px; border-radius: 50%; background: #A7A2B5; }
body.live .live-pill .dot { background: var(--onair); animation: blink 1s steps(2, start) infinite; }

/* 끌어서 옮길 수 있는 스티커. 기본 자리는 리본 제목 양옆이고, 드래그하면 그 자리 기준으로 left/top만큼 옮겨진다 */
.tag { position: relative; z-index: 3; padding: 7px 12px; border: 3px solid var(--black); border-radius: 10px; font: 700 14px/1 var(--f-body); box-shadow: 4px 4px 0 var(--black); cursor: grab; touch-action: none; user-select: none; white-space: nowrap; }
.tag:active { cursor: grabbing; }
.countdown { display: grid; justify-items: center; gap: 5px; }
.countdown small { font-size: 11px; font-weight: 700; color: var(--brick); }
.countdown span { font-size: 15px; font-variant-numeric: tabular-nums; white-space: nowrap; }
body.live .countdown span { color: var(--onair); }
.mail { display: inline-flex; align-items: center; gap: 8px; }
.mail small { padding: 3px 7px; border: 2px solid var(--black); border-radius: 6px; background: #fff; font-size: 11px; }

/* 캐릭터 + 말풍선 */
/* AI-NOTE: 말풍선 길이가 바뀌어도 캐릭터 원이 움직이지 않도록, 원은 고정 폭 열에 두고 말풍선 열 너비와 최소 높이(3줄)를 고정한다 */
.stage { position: relative; z-index: 3; display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 26px; width: min(540px, 100%); margin-top: 8px; }
.sticker { --tx: 0px; --ty: 0px; --rot: -5deg; position: relative; flex: none; width: clamp(118px, 15vw, 164px); aspect-ratio: 1; padding: 0; border: 4px solid var(--black); border-radius: 50%; background: var(--mint); overflow: hidden; cursor: pointer; box-shadow: 0 0 0 7px #fff, 0 0 0 10px var(--black), 9px 10px 0 10px var(--black); transform: translate(var(--tx), var(--ty)) rotate(var(--rot)); transition: transform .35s cubic-bezier(.2, .9, .3, 1.3); }
.sticker img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.sticker.boing { animation: boing .5s ease-out; }
.bubble { position: relative; display: flex; align-items: center; margin: 0; padding: 12px 16px; border: 3px solid var(--black); border-radius: 18px; background: #fff; box-shadow: 5px 5px 0 var(--black); font-weight: 700; font-size: 15.5px; line-height: 1.45; min-height: calc(1.45em * 3); overflow-wrap: anywhere; }
.bubble::before { content: ""; position: absolute; left: -14px; top: 50%; width: 18px; height: 18px; background: #fff; border-left: 3px solid var(--black); border-bottom: 3px solid var(--black); transform: translateY(-50%) rotate(45deg); }

/* 보상 리본 + 양옆 스티커 */
/* AI-NOTE: 가운데 열(auto)은 리본 폭, 양옆 열(1fr)은 같은 폭이라 리본이 항상 화면 가운데에 오고 스티커는 리본 끝에 붙는다.
   폭이 좁아 양옆에 다 들어가지 않는 구간(아래 max-width: 880px 미디어 쿼리)부터는 리본 아래 한 줄로 내린다 */
.ribbon-row { position: relative; z-index: 4; width: min(980px, 100%); display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 22px; }
.ribbon-row .mail { justify-self: end; background: var(--blonde); transform: rotate(-5deg); }
.ribbon-row .countdown { justify-self: start; background: #fff; transform: rotate(5deg); }
.ribbon-wrap { position: relative; z-index: 3; filter: drop-shadow(4px 4px 0 var(--black)); }
.ribbon { margin: 0; padding: 9px 46px 10px; background: var(--brick); color: var(--paper); font: 22px/1 var(--f-pop); letter-spacing: .02em; clip-path: polygon(0 0, 100% 0, calc(100% - 18px) 50%, 100% 100%, 0 100%, 18px 50%); }

/* 카드 */
.hand { position: relative; z-index: 5; display: flex; justify-content: center; gap: clamp(14px, 2.6vw, 34px); padding: 26px 0 8px; perspective: 1500px; }
.card { --mx: 50%; --my: 50%; --o: 0; --rx: 0deg; --ry: 0deg; --fan-rot: 0deg; --fan-y: 0px; position: relative; flex: none; display: block; width: clamp(196px, 21vw, 238px); aspect-ratio: 63 / 88; text-decoration: none; color: var(--black); transform: translateY(var(--fan-y)) rotate(var(--fan-rot)); transition: transform .28s cubic-bezier(.2, .8, .2, 1.1); outline: none; -webkit-tap-highlight-color: transparent; }
/* 스크립트가 켜져 있으면 덱에서 뽑기 전까지 카드를 숨긴다 (처음 그려질 때 제자리에 있다가 튀는 것 방지) */
.js .card:not(.in-hand) { visibility: hidden; }
.card:hover, .card:focus-visible { z-index: 2; transform: translateY(-26px) scale(1.07); }
.hand:has(.card:hover) .card:not(:hover) { filter: saturate(.75) brightness(.96); }
.tilt { position: absolute; inset: 0; transform-style: preserve-3d; transform: rotateX(var(--rx)) rotateY(var(--ry)); transition: transform .5s cubic-bezier(.2, .8, .2, 1); }
.card.active .tilt { transition: transform .06s linear; }
.flip { position: absolute; inset: 0; transform-style: preserve-3d; transform: rotateY(180deg); transition: transform .6s cubic-bezier(.3, 1.3, .5, 1); }
.card.revealed .flip { transform: rotateY(0deg); }
.face { position: absolute; inset: 0; box-sizing: border-box; border: 4px solid var(--black); border-radius: 16px; overflow: hidden; backface-visibility: hidden; -webkit-backface-visibility: hidden; box-shadow: 6px 7px 0 var(--black); }
.card:focus-visible .face { box-shadow: 6px 7px 0 var(--black), 0 0 0 5px var(--hat); }

.back { transform: rotateY(180deg); display: grid; place-items: center; background: repeating-linear-gradient(45deg, var(--hat) 0 14px, var(--hat-2) 14px 28px); }
.back::before { content: ""; position: absolute; left: 0; right: 0; top: 58%; height: 16px; background: var(--mint); box-shadow: 0 16px 0 var(--magenta); }
.back-mark { position: relative; padding: 10px 14px; border: 3px solid var(--blonde); border-radius: 12px; color: var(--blonde); background: var(--hat); font: 24px/1 var(--f-pop); transform: rotate(-8deg); }

.front { display: flex; flex-direction: column; gap: 7px; padding: 9px 9px 10px; background: var(--body); }
.cost { position: absolute; z-index: 2; top: 6px; left: 6px; width: 40px; height: 40px; display: grid; place-items: center; border: 3px solid var(--black); border-radius: 50%; background: var(--energy); font: 22px/1 var(--f-pop); box-shadow: 2px 2px 0 var(--black); }
.banner { margin: 3px 2px 0 30px; padding: 5px 6px 4px; border: 3px solid var(--black); border-radius: 9px; background: var(--paper); text-align: center; font: 19px/1.15 var(--f-pop); }
/* AI-NOTE: 그림 창은 가로가 약간 더 넓다. contain으로 넣으면 양옆 여백과 이미지 가장자리(캐릭터가 잘린 면)가 세로 검은 선처럼 보여서 cover로 꽉 채운다.
   대신 위아래가 조금(약 15%) 잘리므로, 얼굴과 머리 장식(모자, 고양이 귀, 헬멧 윗부분)이 다 들어오게 카드마다 --art-pos의 세로 위치를 맞춘다 */
.art { position: relative; flex: 1; min-height: 0; overflow: hidden; border: 3px solid var(--black); background: var(--art-bg); }
.art img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: var(--art-pos, 50% 50%); }
.ctag { align-self: center; margin-top: -19px; position: relative; z-index: 1; padding: 2px 12px; border: 2.5px solid var(--black); border-radius: 999px; background: #fff; font-weight: 700; font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.desc { flex: none; min-height: 2.6em; display: grid; place-items: center; margin: 0; padding: 7px 9px; border: 3px solid var(--black); border-radius: 10px; background: rgba(255, 248, 228, .92); text-align: center; font-size: 12.8px; line-height: 1.5; font-weight: 500; overflow-wrap: anywhere; }
.desc em { font-style: normal; font-weight: 700; color: var(--brick); }
.desc > span { font-size: 15px; font-weight: 700; }
.desc small { display: block; margin-top: 5px; font-size: 11.5px; font-weight: 500; line-height: 1.4; color: rgba(21, 18, 31, .72); }

/* 반짝이 (패턴 변수는 holo-patterns.css) */
.holo { position: absolute; inset: 0; pointer-events: none; mix-blend-mode: color-dodge; opacity: calc(var(--o) * .42); transition: opacity .35s; }
/* 유튜브: 삼각 프리즘. 위쪽 삼각형과 아래쪽 삼각형에 서로 반대로 흐르는 무지개를 따로 입혀 면마다 다른 색으로 번쩍이게 한다.
   마스크는 자식까지 잘라내므로 두 번째 층은 .holo의 자식이 아니라 .front::after에 둔다 */
.k-yt .holo { opacity: calc(var(--o) * .65); background: linear-gradient(120deg, #ff5ec8, #ffd35e 20%, #6effa8 40%, #5ecbff 60%, #a37bff 80%, #ff5ec8); background-size: 260% 260%; background-position: var(--mx) var(--my); -webkit-mask-image: var(--prism-up); mask-image: var(--prism-up); -webkit-mask-size: var(--prism-tile); mask-size: var(--prism-tile); }
.k-yt .front::after { content: ""; position: absolute; inset: 0; pointer-events: none; mix-blend-mode: color-dodge; opacity: calc(var(--o) * .65); transition: opacity .35s; background: linear-gradient(-60deg, #5ecbff, #a37bff 20%, #ff5ec8 40%, #ffd35e 60%, #6effa8 80%, #5ecbff); background-size: 260% 260%; background-position: calc(100% - var(--mx)) calc(100% - var(--my)); -webkit-mask-image: var(--prism-down); mask-image: var(--prism-down); -webkit-mask-size: var(--prism-tile); mask-size: var(--prism-tile); }
/* 치지직: 별 글리터. 큰 별과 작은 별이 반대 방향으로 움직여 깊이감을 주고, 기울이는 동안 반짝임이 깜빡인다 */
.k-chzzk .holo { opacity: calc(var(--o) * .95); background-image: var(--stars-big), var(--stars-small), linear-gradient(125deg, rgba(255, 94, 200, .3), rgba(94, 203, 255, .3) 50%, rgba(110, 255, 168, .3)); background-size: var(--stars-big-tile), var(--stars-small-tile), 250% 250%; background-position: calc(var(--mx) * .35) calc(var(--my) * .35), calc(var(--mx) * -.7) calc(var(--my) * -.7), var(--mx) var(--my); }
.card.active.k-chzzk .holo { animation: twinkle 1.1s ease-in-out infinite; }
/* 헬다이버즈 2: 대각선 무지개 (경고 사선 줄무늬와 같은 방향) */
.k-hd2 .holo { background: repeating-linear-gradient(115deg, #ff6ad5 0%, #c774e8 6%, #ad8cff 12%, #8795e8 18%, #94d0ff 24%, #7dffb3 30%, #fdff8f 36%, #ff6ad5 42%); background-size: 400% 400%; background-position: var(--mx) var(--my); }
.glare { position: absolute; inset: 0; pointer-events: none; mix-blend-mode: soft-light; opacity: var(--o); background: radial-gradient(farthest-corner circle at var(--mx) var(--my), rgba(255, 255, 255, .95) 6%, rgba(255, 255, 255, .25) 30%, rgba(0, 0, 0, .35) 95%); transition: opacity .35s; }

/* 카드별 색과 그림 창 모양. 모양은 의미 없이 세 장이 서로 달라 보이게 하려는 장식 */
.k-yt { --body: var(--card-yt); --art-bg: #151213; --art-pos: 50% 0%; }
.k-yt .art { border-radius: 10px 10px 40% 40% / 10px 10px 16% 16%; }
.k-chzzk { --body: var(--card-chzzk); --art-bg: #100E0F; --art-pos: 50% 15%; }
.k-chzzk .art { border-radius: 26px; }
.k-hd2 { --body: var(--hazard); --art-bg: #050505; --art-pos: 50% 55%; }
.k-hd2 .art { border-radius: 6px; }
.stamp { position: absolute; right: 6px; bottom: 8px; padding: 3px 8px; border: 3px solid var(--brick); border-radius: 6px; background: rgba(255, 248, 228, .92); color: var(--brick); font: 13px/1.1 var(--f-pop); transform: rotate(-10deg); }
/* 방송 중이면 치지직 카드가 강화 카드('치지직+')가 된다 */
.card.is-live .front { box-shadow: 6px 7px 0 var(--black), 0 0 0 4px var(--signal), 0 0 30px 8px rgba(43, 245, 166, .75); }
.card.is-live .banner { color: var(--upgrade); }
.card.is-live .ctag { background: #CFFFE5; color: var(--upgrade); }
.card.shake { animation: shake .42s ease-in-out; }

/* 하단 */
.tray { position: relative; z-index: 4; width: min(980px, 100%); display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-top: 4px; }
.deck { display: grid; justify-items: center; gap: 8px; padding: 0; border: 0; background: none; cursor: pointer; font-weight: 700; font-size: 13px; }
.deck .stack { position: relative; width: 64px; height: 86px; transition: transform .2s; }
.deck .stack i { position: absolute; inset: 0; border: 3px solid var(--black); border-radius: 10px; background: repeating-linear-gradient(45deg, var(--hat) 0 8px, var(--hat-2) 8px 16px); }
.deck .stack i:nth-child(1) { transform: translate(6px, 6px) rotate(4deg); }
.deck .stack i:nth-child(2) { transform: translate(3px, 3px) rotate(2deg); }
.deck .count { position: absolute; right: -12px; bottom: -10px; width: 30px; height: 30px; display: grid; place-items: center; border: 3px solid var(--black); border-radius: 50%; background: #fff; font: 15px/1 var(--f-pop); }
.deck:hover .stack { transform: translateY(-3px) rotate(-3deg); }
.hint { margin: 0 0 6px; font-size: 13px; font-weight: 500; text-align: center; color: rgba(21, 18, 31, .7); }
.skip { padding: 11px 20px; border: 3px solid var(--black); border-radius: 14px; background: #fff; box-shadow: 5px 5px 0 var(--black); font: 18px/1 var(--f-pop); cursor: pointer; transition: transform .12s, box-shadow .12s; }
.skip:hover { transform: translate(-2px, -2px); box-shadow: 7px 7px 0 var(--black); }
.skip:active { transform: translate(3px, 3px); box-shadow: 2px 2px 0 var(--black); }
.toast { position: fixed; z-index: 60; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 22px); transform: translateX(-50%); padding: 11px 16px; border: 3px solid var(--black); border-radius: 12px; background: #fff; box-shadow: 4px 4px 0 var(--black); font-weight: 700; font-size: 14px; }
.toast[hidden] { display: none; }

/* 헬다이버즈 2 카드를 냈을 때: 화면을 위에서부터 덮는 강하 연출 */
.drop-overlay { position: fixed; inset: 0; z-index: 100; display: grid; grid-template-rows: auto 1fr auto; background: #0a0b0d; color: var(--hazard); animation: drop-cover .28s ease-out both; }
.drop-overlay[hidden] { display: none; }
.drop-band { height: 22px; background: repeating-linear-gradient(-45deg, var(--hazard) 0 14px, #0d0d0d 14px 28px); background-size: 39.6px 22px; animation: drop-stripes .45s linear infinite; }
.drop-text { margin: 0; align-self: center; text-align: center; font: 400 clamp(34px, 7vw, 64px)/1.1 var(--f-pop); letter-spacing: .02em; }
.drop-text span { display: block; margin-top: 12px; font: 700 14px/1 var(--f-body); letter-spacing: .14em; color: #e9eaec; }
@keyframes drop-cover { from { clip-path: inset(0 0 100% 0); } }
@keyframes drop-stripes { to { background-position: 39.6px 0; } }

@keyframes boing { 30% { transform: translate(var(--tx), var(--ty)) rotate(8deg) scale(1.08); } 60% { transform: translate(var(--tx), var(--ty)) rotate(-9deg) scale(.96); } }
@keyframes shake { 20%, 60% { transform: translateX(-9px) rotate(-2deg); } 40%, 80% { transform: translateX(9px) rotate(2deg); } }
@keyframes blink { to { visibility: hidden; } }
@keyframes twinkle { 50% { filter: brightness(1.7) saturate(1.3); } }

/* 리본 양옆에 스티커가 다 들어가지 않는 폭: 리본을 첫 줄, 스티커 두 장을 그 아래 한 줄(모자라면 두 줄)로 */
@media (max-width: 880px) {
  .ribbon-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px 14px; }
  .ribbon-row .ribbon-wrap { order: -1; flex-basis: 100%; display: flex; justify-content: center; }
  .ribbon-row .mail { transform: rotate(-3deg); }
  .ribbon-row .countdown { transform: rotate(3deg); }
}

/* AI-NOTE: 이 720px 기준은 public/js/config.js 의 NARROW_QUERY 와 같아야 한다 (카드 부채꼴 배치를 끄는 기준) */
@media (max-width: 720px) {
  /* 폰 폭에서 스티커 두 장이 한 줄에 들어가도록 글자를 줄이고 '복사' 표시는 뺀다 (눌러서 복사는 그대로 됨) */
  .tag { padding: 6px 10px; font-size: 12px; }
  .mail small { display: none; }
  .countdown span { font-size: 12.5px; }
  .countdown small { font-size: 10px; }
  .stage { gap: 20px; }
  .bubble { font-size: 14.5px; padding: 10px 13px; }
  .ribbon { font-size: 19px; padding-inline: 38px; }
  .hand { justify-content: flex-start; width: 100vw; margin-inline: -16px; padding: 30px 19vw 14px; box-sizing: border-box; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
  .card { width: 62vw; max-width: 250px; scroll-snap-align: center; }
  .card:hover { transform: none; }
  .hint { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
