/* 상점 (MGW-DEV-024 S3). 다솜 DSN-002 참고 구현(20_디자인\DSN-002\anim\shop.css)을 그대로 옮기고
   글꼴만 공용 변수로, 상태 셋(불러오는 중·상점 꺼짐·판매 멈춤)을 더했다.
   MGW-DEV-028(DSN-003 7.1): 머리 48·누르는 칸 44, 머리 아래 한 줄(세로 화면), 줄 머리 = 원소 칸 + 게임 이름(폭 44),
   칸 아래 "1000 left", 자세히 시트 행동 줄 80(버튼 아래 글자 20) · 번호 패 위 "Your No.". 예전 수집 목록·구매 이력은 My items(items.css)로.
   - 시작 페이지 위에 겹치는 한 화면(스크롤 0). My items 시트(items.js)도 같은 틀(.sp)과 자세히 시트(.sd)를 쓴다.
   - 격자: 게임 줄 3(2048·Snake·Planets) × 등급 칸 3(Common·Rare·Epic).
   - 아이콘 크기 --ic 하나로 화면 6종을 맞춘다(DSN-002 3.4 식에서 줄 머리 44·머리 48·머리 아래 줄만큼 뺌). */
.sp {
  --ink: #1d2540; --muted: #5f6987; --line: #d9deea; --bg: #f3f5fa;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  /* 아이콘 한 변: 폭 기준 (W − 140)/3, 높이 기준 (H − 88 − 머리 아래 줄 − 안전 영역)/3 − 36, 48~120 */
  --lead: 0px;
  --ic: clamp(48px, min((100vw - 140px) / 3, (100dvh - 88px - var(--lead) - var(--safe-t) - var(--safe-b)) / 3 - 36px), 120px);
  --big: 128px;
  position: fixed; inset: 0; z-index: 50;
  display: grid; grid-template-rows: 48px auto minmax(0, 1fr);
  padding: var(--safe-t) env(safe-area-inset-right, 0px) var(--safe-b) env(safe-area-inset-left, 0px);
  background: var(--bg); color: var(--ink);
  font-family: var(--cf-font);
  overflow: hidden;
}
.sp[hidden] { display: none; }
/* MGW-DEV-030: 게임 페이지에도 같은 시트를 싣는다. 시작 페이지(home.css * border-box)와 같은 상자 계산 */
.sp, .sp *, .sp *::before, .sp *::after { box-sizing: border-box; }
.sp-head { display: flex; align-items: center; justify-content: space-between; width: min(100vw - 24px, 980px); margin: 0 auto; }
.sp-head > span { display: inline-flex; align-items: center; min-width: 44px; justify-content: flex-end; }
.sp-btn {
  display: inline-flex; align-items: center; justify-content: center; position: relative;
  width: 44px; height: 44px; padding: 0; border: 0; border-radius: 12px;
  background: none; color: #000; cursor: pointer;
}
.sp-btn svg { width: 20px; height: 20px; }
.sp-btn:hover { background: rgba(29, 37, 64, 0.07); }
.sp-btn:focus-visible, .sp-card:focus-visible, .sd-act:focus-visible { outline: 3px solid #000; outline-offset: 2px; }
.sp-score { display: inline-flex; align-items: center; gap: 6px; font-size: 16px; font-weight: 800; font-variant-numeric: tabular-nums; }
.sp-score svg { width: 18px; height: 18px; }
.sp-body { min-height: 0; display: flex; align-items: center; justify-content: center; padding: 12px; }
/* 머리 아래 한 줄: 세로 화면만(가로는 높이가 모자람) */
.sp-lead { display: none; margin: 0; height: 20px; text-align: center; font-size: 13px; font-weight: 700; line-height: 20px; color: var(--muted); }
@media (orientation: portrait) { .sp[data-mode="shop"] { --lead: 20px; } .sp[data-mode="shop"] .sp-lead { display: block; } }

/* 격자 */
.sp-grid {
  display: grid; gap: 8px; align-items: center; justify-items: center;
  grid-template-columns: 44px repeat(3, calc(var(--ic) + 16px));
  grid-auto-rows: calc(var(--ic) + 36px);
}
.sp-rh { width: 44px; display: flex; flex-direction: column; align-items: center; gap: 3px; }
.sp-rh svg { display: block; width: 28px; height: 28px; }
.sp-rh-t { max-width: 44px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; font-weight: 800; line-height: 14px; color: var(--muted); }
.sp-card {
  position: relative; width: 100%; height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  padding: 8px 8px 6px; border: 0; border-radius: 16px;
  background: #fff; box-shadow: 0 4px 14px rgba(29, 37, 64, 0.08);
  color: inherit; font: inherit; cursor: pointer;
}
.sp-art { display: block; width: var(--ic); height: var(--ic); }
.sp-n { font-size: 12px; line-height: 16px; height: 16px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.sp-card.is-out .sp-art { filter: grayscale(1); opacity: 0.38; }          /* 다 팔림: 0/한정 */
.sp-card.is-wait .sp-art { filter: grayscale(1); opacity: 0.6; }          /* 남은 것이 모두 남의 예약 중: 잠시 회색, 숫자는 그대로 */
.sp-own {                                                                  /* 이미 가짐: 오른쪽 위 작은 ✓ */
  position: absolute; top: 4px; right: 4px; width: 18px; height: 18px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; background: #000; color: #fff;
}
.sp-own svg { width: 12px; height: 12px; stroke-width: 3; }
.sp-own.pop { animation: sp-pop 140ms ease-out both; }
@keyframes sp-pop { from { transform: scale(0); } 70% { transform: scale(1.2); } to { transform: scale(1); } }

/* 응답 전 빈 테 */
.sp-slot { display: block; width: var(--ic); height: var(--ic); border: 2px solid var(--line); border-radius: calc(var(--ic) * 0.22); }
.sp-slot.gone { border-style: dashed; }
.sp-card.is-empty { background: transparent; box-shadow: none; cursor: default; }

/* 응답 전·실패(빈 테만, 흐림) · 상점 꺼짐(빈 테 + 머리 가운데 멈춤 표시). MGW-DEV-024 */
.sp[data-state="wait"] .sp-grid, .sp[data-state="off"] .sp-grid { opacity: 0.45; }
.sp-pause { display: none; color: var(--muted); }
.sp-pause svg { width: 20px; height: 20px; }
.sp[data-state="off"] .sp-pause, .sp[data-state="paused"] .sp-pause { display: inline-flex; }

/* 자세히 시트: 세로 화면 = 아래에서 올라오는 시트, 넓은 화면 = 가운데 카드, 낮은 가로 화면 = 가로 두 칸 */
.sd { position: absolute; inset: 0; z-index: 3; display: flex; align-items: flex-end; justify-content: center; }
.sd[hidden] { display: none; }
.sd-back { position: absolute; inset: 0; background: rgba(29, 37, 64, 0.38); }
.sd-card {
  position: relative; width: min(360px, 100vw - 16px); max-height: calc(100dvh - 16px);
  margin-bottom: calc(8px + var(--safe-b)); padding: 40px 20px 20px; border-radius: 22px;
  display: grid; justify-items: center; align-content: center; gap: 10px;
  background: #fff; box-shadow: 0 10px 30px rgba(29, 37, 64, 0.25);
}
.sd-x { position: absolute; top: 4px; right: 4px; }
.sd-art { display: block; width: var(--big); height: var(--big); }
.sd-info { display: grid; justify-items: center; gap: 10px; }
.sd-n { font-size: 13px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.sd-meta { display: flex; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px 0 7px; border-radius: 16px;
  background: var(--bg); font-size: 15px; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap;
}
.chip svg { width: 18px; height: 18px; flex: none; }
.chip small { font-size: 11px; font-weight: 700; color: var(--muted); margin-left: -3px; }
.chip.short { color: #9aa3b8; }                      /* 내 잔량이 모자람: 회색 */
.chip.short svg { opacity: 0.45; }
.chip.score svg { width: 16px; height: 16px; }
.sd-bal { display: inline-flex; align-items: center; gap: 5px; height: 16px; font-size: 12px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.sd-bal svg { width: 16px; height: 16px; }
.sd-bal[hidden] { display: inline-flex; visibility: hidden; }  /* 자리는 남긴다(레이아웃 이동 0) */
.sd-row { display: flex; align-items: flex-start; justify-content: center; gap: 12px; height: 80px; }
/* 번호 패 위 "Your No."(확인·가짐 때만 보임, 자리는 늘 남김) · 행동 버튼 아래 글자(Buy / Tap again to buy / Not enough) */
/* 높이 80 = 버튼 위 8 + 버튼 52 + 글자 20. 번호 패 가운데(12 + 2 + 20 = 34)를 버튼 가운데(8 + 26)에 맞춘다 */
.sd-pillw, .sd-actw { display: flex; flex-direction: column; align-items: center; }
.sd-pillw { gap: 2px; }
.sd-actw { padding-top: 8px; }
.sd-yn { height: 12px; font-size: 10px; font-weight: 700; line-height: 12px; color: var(--muted); visibility: hidden; }
.sd-yn.on { visibility: visible; }
.sd-lb { height: 20px; font-size: 13px; font-weight: 800; line-height: 20px; white-space: nowrap; color: var(--ink); }
.sd-lb.go { color: #2a52c0; }

/* 번호 패: 받을 번호(점선) → 내 번호(채움). 화면에는 숫자만 */
.pill {
  min-width: 56px; height: 40px; padding: 0 12px; border: 2px dashed #000; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; color: #000; background: #fff;
}
.pill.off { visibility: hidden; }
.pill.mine { border-style: solid; background: #000; color: #fff; }

/* 행동 버튼 52: 사기(장바구니) → 확인(✓, 3초 고리) / 모자람·잠시 뒤·판매 멈춤 = 흐림 / 로그인 안 함 = 사람 */
.sd-act {
  position: relative; flex: none; width: 52px; height: 52px; padding: 0; border: 0; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center; background: #000; color: #fff; cursor: pointer;
}
.sd-act svg.ic { width: 26px; height: 26px; }
.sd-act[aria-disabled="true"] { background: var(--line); color: #8a93ab; cursor: default; }
.sd-act.busy { opacity: 0.6; pointer-events: none; }
.sd-act.signin { width: auto; height: 44px; margin: 4px 0; padding: 0 16px; border-radius: 22px; background: #fff; color: #000; box-shadow: inset 0 0 0 2px #000; font: inherit; font-size: 15px; font-weight: 800; white-space: nowrap; }
.sd-act.gone { display: none; }                         /* 이미 가짐·다 팔림: 버튼 없음(줄 높이 60 은 그대로) */
.sd-act .ring { position: absolute; inset: -6px; width: 64px; height: 64px; transform: rotate(-90deg); pointer-events: none; }
.sd-act .ring circle { fill: none; stroke: #000; stroke-width: 2.5; stroke-dasharray: 188.5; stroke-dashoffset: 0; }
.sd-act.confirm .ring circle { animation: sd-ring 3000ms linear forwards; }
@keyframes sd-ring { to { stroke-dashoffset: 188.5; } }
.sd-act.nope { animation: sd-nope 240ms ease-in-out; }
@keyframes sd-nope { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

/* 구매 성공: 날아가는 그림, 수집 아이콘 튐, 반짝임 */
.sp-fly { position: absolute; left: 0; top: 0; z-index: 9; pointer-events: none; transform-origin: 0 0; will-change: transform, opacity; }
.sp-btn.bump { animation: sp-bump 120ms ease-out; }
@keyframes sp-bump { 50% { transform: scale(1.18); } }
.sp-spark { position: absolute; z-index: 9; width: 6px; height: 6px; margin: -3px 0 0 -3px; border-radius: 50%; background: #f5b041; pointer-events: none; }

/* 넓은 화면: 가운데 카드 */
@media (min-width: 700px) and (min-height: 600px) {
  .sd { align-items: center; }
  .sd-card { margin-bottom: 0; }
}
/* 낮은 가로 화면(667×375 등): 그림 왼쪽, 정보 오른쪽 */
@media (orientation: landscape) and (max-height: 480px) {
  .sd { align-items: center; }
  .sd-card { --big: min(128px, 100dvh - 120px); width: min(460px, 100vw - 24px); margin-bottom: 0; padding: 20px 44px 20px 20px; grid-template-columns: auto auto; gap: 20px; }
  .sd-info { gap: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  .sd-act.confirm .ring circle { animation: none; }
  .sp-own.pop, .sp-btn.bump, .sd-act.nope { animation: none; }
}
