:root {
  /* 카드 비율(가로:세로) — 화면 방향과 무관하게 항상 고정 */
  --ratio: 5 / 7;
  --gap: 0.6vw;
  --card-w: min(9.2vw, 64px); /* 하단 더미 크기 기준 */
  --radius: clamp(4px, 1.3vw, 8px);
  --felt: #9a7be0;        /* 귀여운 보라(밝은 쪽) */
  --felt-dark: #4a3a7a;   /* 귀여운 보라(어두운 쪽) */
  --red: #d11e1e;
  --black: #1a1a1a;
}

/* 픽셀 폰트 — 숫자/라틴 글자에만 적용(한글은 unicode-range 밖이라 자동 fallback) */
@font-face {
  font-family: 'PixelFont';
  src: url('pressstart.woff2') format('woff2');
  font-display: swap;
  unicode-range: U+0020-007E;
}
/* 카드 랭크 전용 번들 폰트(Roboto Black) — 웹/안드/iOS 모두 동일 렌더 보장 */
@font-face {
  font-family: 'RankFont';
  src: url('rank.woff2') format('woff2');
  font-weight: 900;
  font-display: swap;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--felt-dark);
  font-family: 'PixelFont', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans KR", sans-serif;
  color: #fff;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

body {
  display: flex;
  flex-direction: column;
  /* 노을→하늘 그라데이션(위는 어둡게 → 상단 메뉴 글씨 대비 유지). 픽셀 궁전 풍경은 JS가 아래에 깔음 */
  background: linear-gradient(180deg, #2e2550 0%, #4a3a82 20%, #7e9ad8 56%, #cfe0d0 80%, #aedd8a 100%);
  image-rendering: pixelated;
  /* 안전영역 대응 — 하단도 inset 확보(Android 15 edge-to-edge: 내비바 뒤로 안 깔리게). 비-edge-to-edge/에뮬은 0이라 무변화 */
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* ---------- 상단바 ---------- */
#topbar, #bottombar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
}
#topbar {
  justify-content: space-between;
  /* 실시간 변하는 하늘 위에서도 글씨가 보이게 옅은 패널 */
  background: linear-gradient(180deg, rgba(38,26,58,0.55), rgba(38,26,58,0));
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}
/* 점수(좌) · 시각(중앙) · 이동(우) 을 가로로 고르게 펼침, 설정은 최우측 */
#topbar .stats { flex: 1 1 auto; justify-content: space-between; }
#topbar .icon-btn { margin-left: 10px; }

/* 메뉴 아래 줄: 완성 세트(좌) + 스톡 더미(우) */
#stockbar {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: calc(var(--real-card-w, 44px) * 7 / 5 + 4px);
  padding: 2px 10px 0;
  gap: 8px;
}

/* 파운데이션: 완성한 세트 8칸 (게임판 카드와 같은 크기, 겹치지 않게 나란히 → 춤 모션 다 보이게) */
.foundations { display: flex; align-items: center; flex-wrap: nowrap; gap: 1px; }
.found-slot {
  position: relative;
  flex: 0 0 auto;
  width: var(--real-card-w, 44px);
  aspect-ratio: var(--ratio);
  border-radius: var(--radius);
  border: 1px dashed rgba(255,255,255,0.22);
}
.found-slot.filled {
  background: #fff;
  border: 1px solid rgba(0,0,0,0.35);
  box-shadow: -1px 1px 3px rgba(0,0,0,0.45);
  overflow: hidden;
}
.found-king {
  position: absolute;
  inset: 2px;
  width: calc(100% - 4px);
  height: calc(100% - 4px);
  object-fit: contain;
  image-rendering: pixelated;
  transform-origin: 50% 92%;
}
.found-suit {
  position: absolute;
  top: 1px; left: 2px;
  font-size: clamp(8px, 2.6vw, 11px);
  font-weight: 800;
  line-height: 1;
}
.found-suit.red { color: var(--red); }
.found-suit.black { color: var(--black); }
/* K 댄스 — 여러 종류(서로 다른 동작 + 다른 길이), 출 때마다 무작위로 골라 재생 */
.found-king.d-sway   { animation: dSway 1.1s ease-in-out; }
.found-king.d-jump   { animation: dJump 0.9s ease-out; }
.found-king.d-spin   { animation: dSpin 1.0s ease-in-out; }
.found-king.d-shake  { animation: dShake 0.7s ease-in-out; }
.found-king.d-wobble { animation: dWobble 1.4s ease-in-out; }
.found-king.d-pop    { animation: dPop 0.85s cubic-bezier(.2,.8,.3,1.4); }
.found-king.d-tilt   { animation: dTilt 1.2s ease-in-out; }
.found-king.d-flip   { animation: dFlip 0.9s ease-in-out; }
@keyframes dTilt {
  0%,100% { transform: rotate(0deg) translateY(0); }
  30% { transform: rotate(-22deg) translateY(-6%); }
  55% { transform: rotate(-22deg) translateY(-6%); }
  80% { transform: rotate(18deg) translateY(-4%); }
}
@keyframes dFlip {
  0%,100% { transform: scaleX(1) rotate(0deg); }
  35% { transform: scaleX(-1) rotate(6deg); }
  70% { transform: scaleX(1) rotate(-6deg); }
}
@keyframes dSway {
  0%,100% { transform: rotate(0deg); }
  25% { transform: rotate(-15deg) translateY(-8%); }
  50% { transform: rotate(0deg); }
  75% { transform: rotate(15deg) translateY(-8%); }
}
@keyframes dJump {
  0%,100% { transform: translateY(0) scaleY(1); }
  15% { transform: translateY(2%) scaleY(0.85); }
  45% { transform: translateY(-40%) scaleY(1.12); }
  70% { transform: translateY(0) scaleY(0.92); }
  85% { transform: translateY(-15%) scaleY(1.04); }
}
@keyframes dSpin {
  0% { transform: rotate(0deg) scale(1); }
  50% { transform: rotate(180deg) scale(1.1); }
  100% { transform: rotate(360deg) scale(1); }
}
@keyframes dShake {
  0%,100% { transform: translateX(0) rotate(0deg); }
  20% { transform: translateX(-18%) rotate(-6deg); }
  40% { transform: translateX(18%) rotate(6deg); }
  60% { transform: translateX(-12%) rotate(-4deg); }
  80% { transform: translateX(12%) rotate(4deg); }
}
@keyframes dWobble {
  0%,100% { transform: rotate(0deg); }
  20% { transform: rotate(-10deg); }
  40% { transform: rotate(8deg); }
  60% { transform: rotate(-6deg); }
  80% { transform: rotate(4deg); }
}
@keyframes dPop {
  0% { transform: scale(1); }
  35% { transform: scale(1.3, 0.8); }
  60% { transform: scale(0.9, 1.15) translateY(-12%); }
  100% { transform: scale(1, 1) translateY(0); }
}

.icon-btn {
  background: rgba(0,0,0,0.28);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 10px;
  padding: 6px 10px;
  font-size: clamp(16px, 4.6vw, 20px);
  line-height: 1;
  cursor: pointer;
}
.icon-btn:active { transform: scale(0.94); background: rgba(0,0,0,0.45); }

.stats { display: flex; gap: clamp(8px, 4vw, 22px); }
.stat { display: flex; flex-direction: column; align-items: center; line-height: 1.1; }
.stat .label { font-size: 10px; opacity: 0.7; }
.stat span:last-child { font-size: clamp(14px, 4vw, 18px); font-weight: 700; }
/* 공유 이미지 미리보기 폴백 오버레이 */
#shotOverlay { position: fixed; inset: 0; z-index: 400; background: rgba(0,0,0,0.82); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 20px; }
#shotOverlay .shot-img { max-width: 90%; max-height: 64%; border-radius: 10px; box-shadow: 0 10px 36px rgba(0,0,0,0.6); -webkit-touch-callout: default; }
#shotOverlay .shot-hint { color: #fff; font-size: 15px; text-align: center; }
#shotOverlay .diff { width: auto; min-width: 160px; }
/* 콤보칸(점수 옆) — 콤보 쌓이면 강조, 갱신 시 통통 */
.combo-stat #combo { color: #b8b0cc; transition: color .2s; }
.combo-stat.on #combo { color: #ffe24d; text-shadow: 0 0 8px #ff9e3a; }
.combo-stat.on .label { color: #ffd45e; opacity: 0.95; }
#combo { display: inline-block; transform-origin: center; }
#combo.combo-bump { animation: comboBump 0.4s cubic-bezier(.2,1.6,.4,1); }
@keyframes comboBump { 0% { transform: scale(1); } 35% { transform: scale(1.5); } 100% { transform: scale(1); } }
#score { display: inline-block; transform-origin: center; }
#score.score-bump { animation: scoreBump 0.42s cubic-bezier(.2,1.6,.4,1); }
@keyframes scoreBump {
  0% { transform: scale(1); color: #fff; }
  35% { transform: scale(1.45); color: #ffe24d; text-shadow: 0 0 10px #ff9e3a; }
  100% { transform: scale(1); color: #fff; }
}

/* ---------- 게임판 ---------- */
#board {
  flex: 1 1 auto;
  position: relative;
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: var(--gap);
  padding: 8px var(--gap) 0;
  align-content: start;
  min-height: 0;
  touch-action: none; /* 드래그 중 브라우저 스크롤/당겨서 새로고침 방지 */
}

/* 드래그 중 따라다니는 카드 묶음 */
.card-ghost {
  position: fixed;
  z-index: 100;
  pointer-events: none;
  transform: rotate(2deg);
  filter: drop-shadow(0 8px 10px rgba(0,0,0,0.55));
}
.card-ghost .card { transition: none; }

.column {
  position: relative;
  border-radius: var(--radius);
  /* 실제 높이는 JS가 카드 수에 맞춰 지정 */
}
.column.empty-target::before {
  content: "";
  position: absolute;
  inset: 0;
  border: 1.5px dashed rgba(255,255,255,0.25);
  border-radius: var(--radius);
}
.column.drop-ok::after {
  content: "";
  position: absolute;
  inset: -3px;
  border: 2px solid #ffe169;
  border-radius: calc(var(--radius) + 3px);
  pointer-events: none;
}
/* 자동 힌트: 목적지 열 / 출발 카드 강조 */
.column.hint-dst::after {
  content: "";
  position: absolute;
  inset: -3px;
  border: 2px dashed #7fffb0;
  border-radius: calc(var(--radius) + 3px);
  pointer-events: none;
  animation: pulse 0.8s ease-in-out infinite;
}
.card.hint-src { animation: pulse 0.8s ease-in-out infinite; box-shadow: 0 0 0 2px #7fffb0, 0 2px 6px rgba(0,0,0,0.5); }
.card.hint-dst-card { animation: pulse 0.8s ease-in-out infinite; box-shadow: 0 0 0 3px #45d0ff, 0 2px 6px rgba(0,0,0,0.5); z-index: 40; }
@keyframes pulse { 0%,100% { filter: brightness(1); } 50% { filter: brightness(1.35); } }

/* 콤보 ×N 숫자 팝업 — tier(콤보 길이)가 클수록 크고 화려 */
.combo-tag {
  position: fixed; transform: translate(-50%, -50%);
  font-family: 'RankFont', 'PixelFont', sans-serif; font-weight: 900;
  font-size: calc(14px + var(--tier, 1) * 4px);
  color: #ffe24d;
  -webkit-text-stroke: 2px #c0392b;
  text-shadow: 0 0 calc(5px + var(--tier, 1) * 3px) #ff9e3a, 0 2px 0 #b03048, 0 0 calc(8px + var(--tier, 1) * 4px) #ffd64a;
  pointer-events: none; z-index: 250; white-space: nowrap;
  animation: comboPop 1.15s cubic-bezier(.2, 1.7, .35, 1) forwards;
}
@keyframes comboPop {
  0%   { transform: translate(-50%, -50%) scale(.2) rotate(-14deg); opacity: 0; }
  22%  { transform: translate(-50%, -55%) scale(1.3) rotate(7deg);  opacity: 1; }
  50%  { transform: translate(-50%, -78%) scale(1) rotate(-3deg);   opacity: 1; }
  100% { transform: translate(-50%, -165%) scale(.92) rotate(2deg); opacity: 0; }
}

/* ---------- 카드 ---------- */
.card {
  position: absolute;
  left: 0;
  width: 100%;
  aspect-ratio: var(--ratio);   /* 높이는 폭에 비례 → 비율 항상 고정 */
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,0.4);
  border: 1px solid rgba(0,0,0,0.22);   /* 겹쳤을 때 카드 경계 구분 */
  transition: top 0.16s ease, transform 0.1s ease, box-shadow 0.1s ease, filter 0.2s ease;
  will-change: top, transform;
  container-type: inline-size; /* cqw = 카드 폭의 1% */
}
.card .face {
  position: absolute;
  inset: 0;
  font-weight: 800;
}
/* 좌상단 인덱스 — 카드가 겹쳐도 보이는 부분(최대한 크게) */
.card .corner {
  position: absolute;
  top: 2%;        /* 위 여백 최소 */
  left: 8%;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 0.7;
}
/* 숫자·알파벳 — 레퍼런스처럼 '깔끔한 굵은 폰트'로 큼직하게(픽셀폰트는 여백 커서 작아보임).
   크기는 카드 폭 기준 calc(=cqw 미지원 대비 안전). */
.card .corner .r {
  font-family: 'RankFont', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-weight: 900;
  /* 크기 제약(앱 실측 역산): 위여백 ≥2% + Q꼬리가 빡빡한 팬(0.36)·무늬에 안 닿는 최대치 = 0.48배(cap높이 ~25%) */
  font-size: calc(var(--real-card-w, 46px) * 0.48);
  line-height: 1; letter-spacing: -0.02em;
  margin-top: -0.14em; /* 가장 키 큰 글자 잉크 top을 카드 높이의 2%에 맞춤(실측) */
}
/* '10'은 두 글자지만 '같은 높이'로 — 폰트크기는 동일하게 두고 가로만 압축해 폭만 줄임 */
.card .corner .r.r-ten { display: inline-block; letter-spacing: -0.12em; transform: scaleX(0.82); transform-origin: left center; }
/* 가운데 큰 무늬 — 카드 빈 공간을 채움(아래쪽 보이는 카드에 표시) */
.card .big {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 92cqw;
  line-height: 1;
  opacity: 0.92;
}
/* 그림(무늬/캐릭터)은 카드 아래쪽 영역에만 → 좌상단 숫자/글자와 겹치지 않음 */
.card .big.art { inset: 46% 8% 7% 8%; opacity: 1; }
/* 진짜 픽셀아트: 비트맵을 흐림 없이 블록 그대로 확대 */
.card .big.art .pix {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
.card.red { color: var(--red); }
.card.black { color: var(--black); }
.card.joker-card { color: #8b5cf6; } /* 조커(와일드) — 보라 ★ */
/* 알려줄 카드 없을 때 우상단 스톡 더미 강조(통통) */
.stock.stock-attn { animation: stockPulse 0.65s ease-in-out 3; }
@keyframes stockPulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.14); filter: drop-shadow(0 0 8px rgba(127,255,176,0.9)); } }

/* ---------- 캐릭터 idle 모션: 가끔씩 짧게, 캐릭터마다 다르게 ---------- */
.card.facecard .pix { transform-origin: 50% 100%; }
.card .back-art { transform-origin: 50% 50%; }
/* J — 장난꾸러기 소년: 깡총 두 번 뛰며 까딱 */
.card.c-j .pix { animation: jackHop 5s ease-in-out infinite; }
@keyframes jackHop {
  0%, 78%, 100% { transform: translateY(0) rotate(0deg); }
  84% { transform: translateY(-13%) rotate(-6deg); }
  89% { transform: translateY(0) rotate(0deg); }
  93% { transform: translateY(-7%) rotate(5deg); }
  97% { transform: translateY(0) rotate(0deg); }
}
/* Q — 우아한 공주: 드레스 자락처럼 좌우로 살랑 */
.card.c-q .pix { animation: queenSway 6.5s ease-in-out infinite; }
@keyframes queenSway {
  0%, 76%, 100% { transform: rotate(0deg); }
  84% { transform: rotate(6deg) translateY(1%); }
  92% { transform: rotate(-6deg) translateY(1%); }
  100% { transform: rotate(0deg); }
}
/* K — 근엄한 왕: 느릿하게 위엄 있는 끄덕 + 가슴 으쓱 */
.card.c-k .pix { animation: kingNod 8s ease-in-out infinite; }
@keyframes kingNod {
  0%, 80%, 100% { transform: scale(1) translateY(0) rotate(0deg); }
  87% { transform: scale(1.06) translateY(-3%) rotate(0deg); }
  94% { transform: scale(1) translateY(3%) rotate(1.5deg); }
}
/* 거미(뒷면) — 다리 꼼지락 + 폴짝 (가려지지 않은 맨 아래 카드에서만) */
.card .back-art.live { animation: spiderWiggle 4.5s ease-in-out infinite; }
@keyframes spiderWiggle {
  0%, 72%, 100% { transform: translateY(0) rotate(0deg); }
  78% { transform: rotate(-5deg); }
  83% { transform: rotate(5deg); }
  88% { transform: translateY(-10%) rotate(-3deg); }
  94% { transform: translateY(0) rotate(2deg); }
}
@media (prefers-reduced-motion: reduce) {
  .card.c-j .pix, .card.c-q .pix, .card.c-k .pix, .card .back-art.live { animation: none; }
}

.card.down {
  background: repeating-linear-gradient(45deg, #4a3b8a 0 6px, #5d4ab0 6px 12px);
  border: 1px solid rgba(255,255,255,0.25);
}
.card.down .face { display: none; }
/* 카드 뒷면 거미 픽셀아트 — 가운데 */
.card .back-art {
  position: absolute;
  inset: 0;
  margin: auto;            /* transform 안 쓰고 정중앙 정렬(흔들림 애니와 충돌 방지) */
  width: 60%;
  height: 60%;
  object-fit: contain;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  pointer-events: none;
}

.card.movable { cursor: pointer; }
/* 배분 직후, 못 옮기는 맨 위 카드는 살짝 회색 */
.card.dim { filter: brightness(0.78) saturate(0.8); }

/* 갈 곳 없는 카드 탭 → 짧게 도리도리(고개 젓기) */
.card.shake { animation: noShake 0.24s ease-in-out; z-index: 56; }
@keyframes noShake {
  0%, 100% { transform: translateX(0) rotate(0deg); }
  30% { transform: translateX(-12%) rotate(-4deg); }
  65% { transform: translateX(9%) rotate(3deg); }
}

/* 착지 임팩트: 쫙! 스쿼시 바운스 */
.card.land { animation: landSquash 0.3s cubic-bezier(.2,.8,.3,1); z-index: 50; }
@keyframes landSquash {
  0% { transform: scale(1.16, 0.82); }   /* 닿는 순간 납작 */
  45% { transform: scale(0.95, 1.07); }  /* 튕겨 늘어남 */
  75% { transform: scale(1.03, 0.98); }
  100% { transform: scale(1, 1); }
}
/* 연속 런 카스케이드: 카드 팝(아래로 갈수록 --pop-s 커짐) */
.card.pop { animation: cardPop 0.42s cubic-bezier(.2,.9,.3,1.5); z-index: 58; }
@keyframes cardPop {
  0% { transform: scale(1); }
  38% { transform: scale(var(--pop-s, 1.3)); filter: brightness(1.5); }
  100% { transform: scale(1); filter: brightness(1); }
}
/* 픽셀 파편 — 고정 3px 사각(네모 안 커짐), 이동+페이드만(중력 아치) */
.px-spark {
  position: fixed;
  width: 3px; height: 3px;
  border-radius: 0;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 97;
  image-rendering: pixelated;
  animation: pxBurst var(--dur, 0.9s) cubic-bezier(.15,.7,.5,1) forwards;
}
@keyframes pxBurst {
  0%   { transform: translate(-50%, -50%); opacity: 1; }
  60%  { transform: translate(calc(-50% + var(--mx, 0px)), calc(-50% + var(--my, 0px))); opacity: 1; }
  100% { transform: translate(calc(-50% + var(--dx, 0px)), calc(-50% + var(--dy, 0px))); opacity: 0; }
}
/* 중앙 픽셀 팝 — 고정 4px +모양(섬광 대신) */
.px-pop {
  position: fixed;
  width: 4px; height: 4px;
  border-radius: 0;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 98;
  image-rendering: pixelated;
  animation: pxPopFade 0.28s steps(3) forwards;
}
@keyframes pxPopFade { 0% { opacity: 1; } 100% { opacity: 0; } }
/* 세트 완성마다 차오르는 에너지 글로우(터질 듯 말 듯) */
.charge-glow {
  position: fixed;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,231,105,0.55), rgba(255,143,176,0.25) 55%, transparent 72%);
  transform: translate(-50%, -50%) scale(0.4);
  opacity: 0.85;
  pointer-events: none;
  z-index: 100;
  animation: chargeGlow 0.72s ease-out forwards;
}
@keyframes chargeGlow {
  to { transform: translate(-50%, -50%) scale(var(--cg, 5)); opacity: 0; }
}

/* 마지막 카드 화면 번쩍 */
.screen-flash {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 50% 50%, rgba(255,231,105,0.22), rgba(255,143,176,0.12) 55%, transparent 75%);
  opacity: 0;
  pointer-events: none;
  z-index: 105;
  animation: screenFlash 0.32s ease-out forwards;
}
@keyframes screenFlash { 0% { opacity: 1; } 100% { opacity: 0; } }

/* 귀여운 픽셀 해님 — 동(우)에서 떠서 서(좌)로 지는 궤도. 궤도=위치, #sun=표정/모션 */
#sunOrbit {
  position: fixed;
  top: 0; left: 0;
  width: 17vmin; height: 17vmin;
  z-index: 1;             /* 하늘(배경) 앞, 풍경(#scene,z:2) 뒤 → 집 뒤에서 뜸 */
  pointer-events: none;
  animation: sunArc 60s linear infinite;
}
/* 떠다니는 구름 레이어 — 하늘(배경) 앞, 카드/풍경 뒤. 느리게 흐름 */
#skyclouds { position: fixed; left: 0; top: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; overflow: hidden; }
.skycloud { position: absolute; image-rendering: pixelated; filter: drop-shadow(0 2px 2px rgba(120,140,180,0.25)); }
/* 픽셀 궁전 풍경(별도 레이어): 해/달 앞, UI 뒤 */
#scene {
  position: fixed;
  left: 0; bottom: 104px;
  width: 100%;
  image-rendering: pixelated;
  z-index: 2;
  pointer-events: none;
}
@keyframes sunArc {
  0%   { transform: translate(86vw, 66vh); opacity: 0; }   /* 동쪽 지평선에서 떠오름 */
  7%   { opacity: 1; }
  28%  { transform: translate(64vw, 22vh); }
  50%  { transform: translate(42vw, 5vh); }                /* 정오(가장 높이) */
  72%  { transform: translate(20vw, 22vh); }
  93%  { opacity: 1; }
  100% { transform: translate(2vw, 66vh); opacity: 0; }    /* 서쪽으로 짐 */
}
#sun {
  width: 100%; height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.25));
  transform-origin: 50% 50%;
}
/* 해님이 UI 뒤(빈 영역)에 보이도록 주요 바들을 위 레이어로 */
#topbar, #stockbar, #board, #bottombar { position: relative; z-index: 5; } /* 풍경·해달 앞 */
#sun.s-bounce { animation: sunBounce 0.9s ease-in-out; }
#sun.s-spin   { animation: sunSpin 1.0s ease-in-out; }
#sun.s-wobble { animation: sunWobble 1.0s ease-in-out; }
#sun.s-jump   { animation: sunJump 0.8s ease-out; }
#sun.s-pop    { animation: sunPop 0.7s cubic-bezier(.2,.8,.3,1.45); }
#sun.s-sparkle { animation: sunSparkle 0.85s ease-in-out; }
@keyframes sunSparkle {
  0%,100% { filter: drop-shadow(0 2px 4px rgba(0,0,0,0.25)) brightness(1); transform: scale(1); }
  40% { filter: drop-shadow(0 0 12px rgba(255,243,160,0.95)) brightness(1.55); transform: scale(1.12); }
}
/* 반짝이 별 */
.sparkle {
  position: fixed;
  width: 9px; height: 9px;
  background: #fff7c0;
  clip-path: polygon(50% 0, 60% 40%, 100% 50%, 60% 60%, 50% 100%, 40% 60%, 0 50%, 40% 40%);
  transform: translate(-50%, -50%) scale(0);
  pointer-events: none;
  z-index: 4;
  animation: sparkleTwinkle 0.7s ease-out forwards;
}
@keyframes sparkleTwinkle {
  0% { transform: translate(-50%,-50%) scale(0) rotate(0deg); opacity: 0; }
  45% { transform: translate(-50%,-50%) scale(1.2) rotate(45deg); opacity: 1; }
  100% { transform: translate(-50%,-50%) scale(0.2) rotate(90deg); opacity: 0; }
}
@keyframes sunBounce { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-22%); } }
@keyframes sunSpin { 0% { transform: rotate(0); } 100% { transform: rotate(360deg); } }
@keyframes sunWobble { 0%,100% { transform: rotate(0); } 25% { transform: rotate(-15deg); } 75% { transform: rotate(15deg); } }
@keyframes sunJump { 0%,100% { transform: translateY(0) scaleY(1); } 30% { transform: translateY(-30%) scaleY(1.1); } 60% { transform: translateY(0) scaleY(0.9); } 80% { transform: translateY(-12%); } }
@keyframes sunPop { 0% { transform: scale(1); } 40% { transform: scale(1.25); } 100% { transform: scale(1); } }

/* 승리 축하 공연 무대 */
.win-stage {
  position: fixed;
  inset: 0;
  z-index: 108;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}
.win-spot {
  position: absolute;
  left: 50%; top: 50%;
  width: 80vw; height: 80vw;
  max-width: 520px; max-height: 520px;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(255,231,105,0.30), rgba(255,143,176,0.12) 45%, transparent 68%);
  animation: winSpot 1.6s ease-in-out infinite;
}
@keyframes winSpot { 0%,100% { opacity: 0.6; } 50% { opacity: 1; } }
.win-char {
  position: relative;
  width: 42vw; max-width: 230px;
  aspect-ratio: 1;
  object-fit: contain;
  image-rendering: pixelated;
  filter: drop-shadow(0 8px 16px rgba(0,0,0,0.45));
  transform-origin: 50% 90%;
  animation: winDance 0.62s ease-in-out infinite;
}
.win-buddy {
  position: absolute;
  width: 20vw; max-width: 110px;
  aspect-ratio: 1;
  object-fit: contain;
  image-rendering: pixelated;
  bottom: 14%;
  filter: drop-shadow(0 6px 12px rgba(0,0,0,0.4));
  transform-origin: 50% 90%;
  animation: winHop 0.5s ease-in-out infinite;
}
/* 랜덤 위치 댄서(인라인 left/top 사용) — 크기 약간 작게, 다양한 박자 */
.win-buddy.rnd { bottom: auto; right: auto; width: 15vw; max-width: 84px; animation-duration: .46s; animation-delay: calc(var(--d, 0) * 1ms); }
.win-buddy.rnd:nth-child(3n) { animation-duration: .54s; }
.win-buddy.rnd:nth-child(2n) { animation-duration: .5s; }
.win-buddy.d1 { left: 4%;  bottom: 20%; animation-delay: 0s; }
.win-buddy.d2 { right: 4%; bottom: 20%; animation-delay: .12s; animation-duration: .46s; }
.win-buddy.d3 { left: 20%; bottom: 6%;  animation-delay: .25s; animation-duration: .54s; }
.win-buddy.d4 { right: 20%; bottom: 6%; animation-delay: .37s; animation-duration: .5s; }
@keyframes winDance {
  0%,100% { transform: translateY(0) rotate(-7deg) scale(1); }
  25% { transform: translateY(-9%) rotate(0deg) scale(1.06); }
  50% { transform: translateY(0) rotate(7deg) scale(1); }
  75% { transform: translateY(-9%) rotate(0deg) scale(1.06); }
}
@keyframes winHop {
  0%,100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-22%) rotate(6deg); }
}
/* 팝업 안 랜덤 위치 캐릭터(가장자리) */
.win-dialog { position: relative; }
.win-pop {
  position: absolute; width: 12%; max-width: 50px; aspect-ratio: 1;
  object-fit: contain; image-rendering: pixelated; pointer-events: none; z-index: 3;
  filter: drop-shadow(0 3px 5px rgba(0,0,0,0.35));
  animation: winPopHop 0.5s ease-in-out infinite;
}
@keyframes winPopHop {
  0%,100% { transform: translate(-50%, -50%) rotate(-6deg); }
  50% { transform: translate(-50%, -64%) rotate(6deg); }
}
/* 승리/패배 캐릭터 고유 대사 말풍선 */
.win-bubble {
  position: absolute; transform: translate(-50%, 0); /* 캐릭터 아래에 매달림(꼬리는 위) */
  background: #fff; color: #6a533a; border: 2px solid #ffd592;
  border-radius: 11px; padding: 2px 7px; font-size: 11px; font-weight: 700;
  white-space: nowrap; max-width: 40vw; overflow: hidden; text-overflow: ellipsis;
  z-index: 6; pointer-events: none; box-shadow: 0 2px 6px rgba(0,0,0,0.18);
  animation: winBubblePop 0.45s ease-out both;
}
.win-bubble::after { /* 위를 가리키는 꼬리 */
  content: ""; position: absolute; left: 50%; bottom: 100%; transform: translateX(-50%);
  border: 5px solid transparent; border-bottom-color: #fff;
}
@keyframes winBubblePop {
  from { opacity: 0; transform: translate(-50%, 8px) scale(0.6); }
  to   { opacity: 1; transform: translate(-50%, 0) scale(1); }
}
/* 픽셀 폭죽(제목 양옆) */
.win-fw { width: 15%; max-width: 56px; image-rendering: pixelated; pointer-events: none; z-index: 4; animation: fwTwinkle 1.1s ease-in-out infinite; }
@keyframes fwTwinkle { 0%,100% { transform: scale(0.85) rotate(0deg); opacity: 0.8; } 50% { transform: scale(1.12) rotate(22deg); opacity: 1; } }
.win-stage.bow .win-char { animation: winBow 0.8s ease-out forwards; }
@keyframes winBow {
  0% { transform: translateY(0) rotate(0); }
  40% { transform: translateY(8%) rotate(0) scaleY(0.9); }
  100% { transform: translateY(0) rotate(0) scale(1.1); }
}

/* 첫 배분 — 카드 착지 반짝 별 */
.deal-spark {
  position: fixed;
  width: 3px; height: 3px;
  margin: -1.5px 0 0 -1.5px;
  border-radius: 0;
  image-rendering: pixelated;
  pointer-events: none;
  z-index: 70;
  animation: dealSpark 0.36s steps(3) forwards;
}
@keyframes dealSpark { 0% { opacity: 0; } 30% { opacity: 1; } 100% { opacity: 0; } }

/* 축하 컨페티 — 아래에서 위로 솟구쳤다가 다시 아래로 흩날림 */
.confetti {
  position: fixed;
  width: 8px; height: 12px;
  border-radius: 2px;
  pointer-events: none;
  z-index: 110;
  animation: confettiPop 2.8s cubic-bezier(.25,.7,.5,1) forwards;
}
@keyframes confettiPop {
  0%   { opacity: 1; transform: translate(0, 0) rotate(0deg); }
  35%  { opacity: 1; transform: translate(calc(var(--cx, 0px) * 0.5), var(--up, -60vh)) rotate(calc(var(--rot, 360deg) * 0.5)); }
  100% { opacity: 0; transform: translate(var(--cx, 0px), 16vh) rotate(var(--rot, 360deg)); }
}

/* 충격 파동 링 */
.impact-ripple {
  position: fixed;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.9);
  transform: translate(-50%, -50%) scale(0.3);
  opacity: 0.9;
  pointer-events: none;
  z-index: 95;
  animation: ripple 0.44s ease-out forwards;
}
@keyframes ripple {
  to { transform: translate(-50%, -50%) scale(5); opacity: 0; }
}

/* 완성된 한 벌이 좌상단으로 모여 사라지는 클론 */
.card.fly-complete {
  position: fixed;
  z-index: 120;
  pointer-events: none;
  transition: transform 0.55s cubic-bezier(.4,.1,.2,1), opacity 0.55s ease;
  box-shadow: 0 6px 14px rgba(0,0,0,0.5);
}
.card.complete-fly {
  transition: top 0.35s ease, left 0.35s ease, opacity 0.35s ease;
  opacity: 0;
}

/* ---------- 스톡(우측 상단): 남은 배분을 가로로 겹친 카드 뒷면으로 표시 ---------- */
.right { display: flex; align-items: center; gap: 8px; }
.stock {
  position: relative;
  flex: 0 0 auto;
  cursor: pointer;
}
.stock.empty {
  width: var(--real-card-w, 44px);
  aspect-ratio: var(--ratio);
  height: auto;
  border: 1.5px dashed rgba(255,255,255,0.3);
  border-radius: var(--radius);
  cursor: default;
}
.stock:active:not(.empty) { transform: scale(0.95); }
.mini-back {
  position: absolute;
  top: 0;
  width: var(--real-card-w, 44px);
  aspect-ratio: var(--ratio);
  border-radius: var(--radius);
  background: repeating-linear-gradient(45deg, #4a3b8a 0 6px, #5d4ab0 6px 12px);
  border: 1px solid rgba(255,255,255,0.4);
  box-shadow: 1px 0 2px rgba(0,0,0,0.45);
  overflow: hidden;
}
.mini-back .mini-spider {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 60%;
  height: 60%;
  object-fit: contain;
  image-rendering: pixelated;
}

/* ---------- 하단 액션 메뉴 ---------- */
#bottombar {
  flex-direction: column;
  gap: 4px;
  padding-bottom: 4px; /* 광고가 바로 아래에 붙으므로 safe-area 중복 제거(빈공간 방지) */
  /* 메뉴 뒤 흐린 네모 패널 제거(투명) — 배경은 메뉴 위에서만 보임 */
  background: transparent;
  /* 항상 표시 */
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}
#bottombar.show { transform: translateY(0); opacity: 1; pointer-events: auto; }
/* 힌트/조커 설명글은 absolute로 띄워 #bottombar 높이에 영향 주지 않음 → 배경 위치 안 흔들림 */
.hint {
  position: absolute; left: 10px; right: 10px; bottom: 100%; margin-bottom: 3px;
  font-size: clamp(11px, 3.2vw, 14px); opacity: 0.9; text-align: center;
  text-transform: uppercase; pointer-events: none;
  text-shadow: 0 1px 3px rgba(0,0,0,0.55);
}
.actions { display: flex; justify-content: space-around; align-items: stretch; gap: 8px; width: 100%; max-width: 460px; }
.act {
  position: relative;
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: rgba(0,0,0,0.28);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 12px;
  padding: 8px 4px;
  cursor: pointer;
}
.act:active { transform: scale(0.95); background: rgba(0,0,0,0.45); }
.act:disabled { opacity: 0.38; }
.act .ico { font-size: clamp(18px, 5.4vw, 24px); line-height: 1; display: flex; align-items: center; justify-content: center; }
.act .lbl { font-size: clamp(10px, 3vw, 13px); font-weight: 600; text-transform: uppercase; }
.ico-img { width: clamp(22px, 6.4vw, 28px); height: clamp(22px, 6.4vw, 28px); object-fit: contain; image-rendering: pixelated; }
#settingsBtn .ico-img { width: clamp(20px, 5.6vw, 24px); height: clamp(20px, 5.6vw, 24px); }
.gift-ico { width: 1.15em; height: 1.15em; object-fit: contain; image-rendering: pixelated; vertical-align: -0.18em; }
.coin-ico { width: 1.25em; height: 1.25em; object-fit: contain; image-rendering: pixelated; vertical-align: -0.2em; }
#comboLabel .coin-ico { width: 17px; height: 17px; display: block; } /* 좌상단 포인트 코인 */
.wp-total .coin-ico { width: 1.05em; height: 1.05em; vertical-align: -0.1em; }
.dialog.gacha h1 .gift-ico { width: 1em; height: 1em; }
.act .badge {
  position: absolute;
  top: 2px;
  right: 6px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: #e8483f;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}
.act.armed { box-shadow: 0 0 0 2px #ffe169; background: rgba(255,225,105,0.18); }

/* ---------- 오버레이/다이얼로그 ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
  backdrop-filter: blur(3px);
}
.overlay.show { display: flex; }
.dialog {
  background: #143d22;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 18px;
  padding: 26px 22px;
  width: min(86vw, 360px);
  text-align: center;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
  max-height: 90vh;
  overflow-y: auto;
}
.dialog h1 { margin: 0 0 4px; font-size: clamp(22px, 6vw, 30px); }
.dialog .sub { margin: 0 0 18px; opacity: 0.8; font-size: 14px; }
.diff {
  display: block;
  width: 100%;
  margin: 8px 0 0;
  padding: 14px;
  border: none;
  border-radius: 12px;
  background: #1f6e3a;
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
}
.diff:active { transform: scale(0.97); background: #28854a; }
.diff.again { background: #c9a227; color: #1a1a1a; }

/* 승리 팝업 — 배경 안 어둡게/안 흐리게, 댕청미 가득한 귀여운 창 */
#winOverlay.win { background: transparent; backdrop-filter: none; z-index: 120; pointer-events: none; }
#winOverlay.win .win-dialog { pointer-events: auto; }
.win-dialog {
  background: linear-gradient(165deg, #fffdf4 0%, #fff2dc 60%, #ffe9c8 100%);
  border: 3px solid #ffd592;
  box-shadow: 0 16px 52px rgba(150,110,40,0.4);
  color: #6a5436;
  animation: winPop .5s cubic-bezier(.18,1.55,.4,1) both;
  overflow: visible; /* 가장자리 캐릭터가 팝업 테두리에 안 잘리고 앞으로 보이게(.dialog의 overflow-y:auto 덮어씀) */
}
@keyframes winPop { 0% { transform: scale(.4); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
/* 팝업 속 랜덤 캐릭터 무리(이모지 대신) */
.win-troupe, .over-troupe { display: flex; justify-content: center; align-items: flex-end; gap: 6px; min-height: 60px; margin-bottom: 6px; }
.troupe-char { width: 46px; height: 58px; object-fit: contain; object-position: bottom; image-rendering: pixelated; transform-origin: 50% 100%; filter: drop-shadow(0 3px 3px rgba(0,0,0,0.3)); }
.troupe-dance { animation: troupeDance 0.6s ease-in-out infinite; }
@keyframes troupeDance { 0%,100% { transform: translateY(0) rotate(-9deg) scale(1); } 50% { transform: translateY(-22%) rotate(9deg) scale(1.05); } }
.troupe-droop { animation: troupeDroop 1.8s ease-in-out infinite; filter: grayscale(0.3) brightness(0.96) drop-shadow(0 3px 3px rgba(0,0,0,0.3)); }
@keyframes troupeDroop { 0%,100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(4px) rotate(3deg); } }
.win-dialog h1 { color: #f0913c; text-shadow: 0 2px 0 #fff; font-size: clamp(26px, 7.5vw, 38px); }
.win-sub { margin: 4px 0 16px; font-size: 14px; color: #a9865c; font-weight: 600; }
.win-stats { display: flex; justify-content: center; gap: 8px; margin: 0 0 18px; }
.win-stats .ws {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: rgba(255,255,255,0.78);
  border: 2px solid #ffe1ad;
  border-radius: 14px;
  padding: 8px 10px; min-width: 62px;
}
.win-stats .ws span { font-size: 11px; color: #b59169; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; }
.win-stats .ws b { font-size: clamp(16px, 5vw, 22px); color: #ee8a2f; }
.win-dialog .diff.again { background: #ffb259; color: #fff; }
.win-dialog .diff.again:active { background: #f59f3c; }
.win-dialog .diff.ghost { background: rgba(240,145,60,0.16); color: #d8801f; }

/* 게임오버 — 귀엽게 풀죽은 캐릭터 */
.dialog.over { position: relative; }
.over-face { position: relative; width: 88px; height: 88px; margin: 0 auto 6px; }
.over-face img {
  width: 100%; height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
  filter: grayscale(0.35) brightness(0.95);
  animation: overBob 1.6s ease-in-out infinite;
  transform-origin: 50% 80%;
}
.over-tear {
  position: absolute;
  left: 62%; top: 46%;
  font-size: 16px;
  animation: overTear 1.8s ease-in infinite;
}
@keyframes overBob {
  0%,100% { transform: translateY(0) rotate(-4deg); }
  50% { transform: translateY(4px) rotate(4deg); }
}
@keyframes overTear {
  0% { opacity: 0; transform: translateY(-2px) scale(0.7); }
  30% { opacity: 1; }
  100% { opacity: 0; transform: translateY(16px) scale(1); }
}
.diff.ghost { background: rgba(255,255,255,0.12); }

/* 설정 패널 */
/* 설정도 컬렉션처럼 전체 페이지(팝업 아님) + 좌상단 뒤로가기 */
.dialog.settings {
  position: fixed; inset: 0; width: 100%; height: 100%;
  max-width: none; max-height: none; margin: 0; border: none; border-radius: 0; box-shadow: none;
  background: linear-gradient(180deg, #2e2550 0%, #4a3a82 32%, #7e9ad8 100%);
  display: flex; flex-direction: column; align-items: stretch;
  padding: max(56px, calc(env(safe-area-inset-top) + 44px)) 18px 24px;
  overflow-y: auto; text-align: left;
}
.dialog.settings > * { width: 100%; max-width: 420px; margin-left: auto; margin-right: auto; }
.dialog.settings h1 { text-align: center; margin-bottom: 18px; color: #fff; text-shadow: 2px 2px 0 #2a2230; }
.dialog.settings .row-label, .dialog.settings .toggle-row span, .dialog.settings .diff-note { font-family: 'Jua', sans-serif; }
.row { margin: 14px 0 6px; }
.row-label { font-size: 13px; opacity: 0.8; font-weight: 600; }
.seg {
  display: flex;
  gap: 6px;
}
.seg-btn {
  flex: 1 1 0;
  padding: 10px 4px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(0,0,0,0.25);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.seg-btn.on { background: #1f6e3a; border-color: #2fae5f; }
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 2px;
  font-size: 15px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.toggle-row input { width: 20px; height: 20px; accent-color: #2fae5f; }
/* 언어 드롭다운(많은 언어 수용) */
.lang-select {
  width: 100%; padding: 11px 12px; border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.18); background: rgba(0,0,0,0.35);
  color: #fff; font-size: 15px; font-weight: 600; -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 14 14'><path d='M3 5l4 4 4-4' fill='none' stroke='white' stroke-width='2'/></svg>");
  background-repeat: no-repeat; background-position: right 12px center;
}
.lang-select option { color: #000; }
/* ===== 콜렉션: 전체화면 픽셀아트 페이지 ===== */
.dialog.gacha {
  position: fixed; inset: 0; width: 100%; height: 100%;
  max-width: none; max-height: none; margin: 0; border: none; border-radius: 0; box-shadow: none;
  background: linear-gradient(180deg, #2e2550 0%, #4a3a82 32%, #7e9ad8 100%);
  display: flex; flex-direction: column; align-items: center;
  padding: max(18px, env(safe-area-inset-top)) 14px 20px;
  overflow-y: auto; text-align: center;
  font-family: 'PixelFont', 'Jua', -apple-system, monospace; image-rendering: pixelated;
}
/* 한글은 귀여운 Jua, 영문/숫자는 픽셀폰트 — 도감 글씨 귀엽게 */
.dialog.gacha h1, .gacha-cat-h, .gacha-cell span, .gacha-points, .gacha-got { font-family: 'Jua', 'PixelFont', sans-serif; }
.gacha-cat-h { font-size: 17px; }
.gacha-cell span { font-size: 13px; letter-spacing: 0.3px; }
.gacha-back { position: absolute; top: max(14px, env(safe-area-inset-top)); left: 12px; width: 44px; height: 44px; padding: 0; display: flex; align-items: center; justify-content: center; font-size: 30px; line-height: 1; font-weight: 800; color: #fff; background: rgba(0,0,0,0.28); border: 3px solid #2a2230; border-radius: 6px; cursor: pointer; z-index: 2; font-family: inherit; }
.gacha-back:active { transform: translateY(1px); }
.dialog.gacha h1 { color: #fff; text-shadow: 2px 2px 0 #2a2230; letter-spacing: 1px; margin: 2px 0 6px; }
.gacha-points { font-size: 16px; margin: 2px 0 12px; color: #fff; }
.gacha-points b { color: #ffe24d; font-size: 20px; }
.dialog.gacha #gachaDraw, .dialog.gacha #gachaClose { width: 100%; max-width: 360px; border-radius: 4px; border: 3px solid #2a2230; font-family: inherit; }
#gachaDraw:disabled { opacity: 0.5; }
.gacha-result { min-height: 0; margin: 6px 0; color: #fff; }
.gacha-result:not(:empty) { min-height: 72px; margin: 10px 0; }
.gacha-win-img { width: 60px; height: 60px; image-rendering: pixelated; object-fit: contain; display: block; margin: 0 auto 4px; animation: gachaWinPop .5s cubic-bezier(.2,1.7,.4,1); }
@keyframes gachaWinPop { 0% { transform: scale(.2); } 100% { transform: scale(1); } }
.gacha-grid { display: flex; flex-direction: column; align-items: center; gap: 4px; margin: 12px 0 16px; width: 100%; }
.gacha-cat { width: 100%; max-width: 380px; margin: 2px 0 10px; }
.gacha-cat-h { font-size: 14px; color: #ffe24d; text-align: left; margin: 8px 2px 8px; letter-spacing: 1px; text-shadow: 2px 2px 0 #2a2230; }
.gacha-cat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.gacha-q { width: 48px; height: 48px; display: flex; align-items: center; justify-content: center; font-size: 30px; font-weight: 700; color: rgba(255,255,255,0.5); }
.gacha-cell { background: rgba(0,0,0,0.3); border: 3px solid #2a2230; border-radius: 4px; padding: 10px 4px; min-height: 86px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; }
.gacha-cell img { width: 48px; height: 48px; image-rendering: pixelated; object-fit: contain; }
.gacha-cell span { font-size: 12px; color: #fff; }
.gacha-cell.owned { border-color: #ffe24d; background: rgba(255,226,77,0.18); }
.gacha-cell.locked img { filter: brightness(0) opacity(0.4); } /* 미보유 = 실루엣 */
.gacha-cell.locked span { opacity: 0.6; }
/* 카드세트 등장 on/off 토글(보유 캐릭터 셀, 탭으로 전환) */
.gacha-cell.owned { position: relative; cursor: pointer; }
.set-toggle { font-size: 10px; font-weight: 700; color: #2a2230; background: #ffe24d; border-radius: 999px; padding: 1px 7px; margin-top: 1px; }
.gacha-cell.set-off { border-color: #6a6470; background: rgba(0,0,0,0.3); }
.gacha-cell.set-off img { filter: grayscale(0.85) opacity(0.55); }
.gacha-cell.set-off span { opacity: 0.5; }
.gacha-cell.set-off .set-toggle { background: #6a6470; color: #fff; }
.gacha-pop { animation: gachaBigPop .6s cubic-bezier(.2,1.8,.4,1) !important; }
@keyframes gachaBigPop { 0% { transform: scale(.3) rotate(-14deg); } 55% { transform: scale(1.35) rotate(8deg); } 100% { transform: scale(1) rotate(0); } }
.gacha-got { font-size: 18px; font-weight: 800; color: #ffe24d; margin-top: 4px; text-shadow: 2px 2px 0 #2a2230; animation: gachaGot .5s ease-out; }
@keyframes gachaGot { from { opacity: 0; transform: translateY(8px) scale(.8); } to { opacity: 1; transform: translateY(0) scale(1); } }
/* 승리 팝업 포인트 + 난이도 설명 */
.win-points { font-size: 15px; font-weight: 800; color: #f0913c; margin: -6px 0 12px; }
/* 포인트 단계별 연출(쿵쿵쿵 → 쿠웅) */
.win-points.revealing { display: flex; flex-direction: column; align-items: center; gap: 6px; min-height: 96px; }
.wp-rows { display: flex; flex-direction: column; gap: 5px; width: min(252px, 76vw); }
.wp-row { display: flex; align-items: center; gap: 8px; padding: 5px 13px;
  background: rgba(255,255,255,0.74); border: 2px solid #ffe1ad; border-radius: 12px;
  opacity: 0; transform: translateY(8px) scale(.8); transform-origin: 50% 50%; }
.wp-row.show { opacity: 1; transform: none; }
.wp-row .wp-ico { font-size: 16px; line-height: 1; }
.wp-row .wp-lbl { font-size: 13px; color: #b07b3a; font-weight: 800; flex: 1; text-align: left; }
.wp-row .wp-val { font-size: 18px; font-weight: 900; color: #ee8a2f; }
.wp-row.wp-pump { animation: wpPump .42s cubic-bezier(.18,1.7,.4,1); }
@keyframes wpPump { 0% { transform: scale(1.5); } 58% { transform: scale(.93); } 100% { transform: scale(1); } }
.wp-total { display: flex; align-items: center; justify-content: center; gap: 4px; margin-top: 4px;
  opacity: 0; transform: scale(.6); transition: opacity .18s ease, transform .18s ease; }
.wp-total.show { opacity: 1; transform: none; }
.wp-total .wp-total-num { font-size: clamp(32px, 11vw, 50px); font-weight: 900; color: #ff7a1a;
  line-height: 1; text-shadow: 0 2px 0 #fff, 0 0 16px rgba(255,150,40,0.55); }
.wp-total .wp-total-suffix { font-size: 16px; font-weight: 800; color: #f0913c; }
.wp-total .gift-ico { width: 1.35em; height: 1.35em; vertical-align: -0.28em; }
.wp-total.wp-boom { animation: wpBoom .62s cubic-bezier(.2,1.8,.35,1); }
@keyframes wpBoom { 0% { transform: scale(2.05); filter: brightness(1.9); } 44% { transform: scale(.86); } 70% { transform: scale(1.12); } 100% { transform: scale(1); filter: none; } }
.win-dialog.shake { animation: winShake .62s cubic-bezier(.36,.07,.19,.97); }
@keyframes winShake {
  0%,100% { transform: translate(0,0) rotate(0); }
  10% { transform: translate(-8px,4px) rotate(-1.5deg); }
  22% { transform: translate(9px,-5px) rotate(1.5deg); }
  36% { transform: translate(-7px,5px) rotate(-1deg); }
  52% { transform: translate(7px,-4px) rotate(1deg); }
  68% { transform: translate(-5px,3px) rotate(-.6deg); }
  84% { transform: translate(4px,-2px) rotate(.4deg); }
}
.wp-flash { position: fixed; inset: 0; z-index: 99; pointer-events: none;
  background: radial-gradient(circle at 50% 45%, rgba(255,240,200,0.85), rgba(255,220,150,0) 62%);
  animation: wpFlash .42s ease-out forwards; }
@keyframes wpFlash { 0% { opacity: 0; } 18% { opacity: 1; } 100% { opacity: 0; } }
.wp-spark { position: fixed; width: 8px; height: 8px; border-radius: 50%; z-index: 100; pointer-events: none;
  animation: wpSpark .55s ease-out forwards; }
@keyframes wpSpark { 0% { transform: translate(0,0) scale(1); opacity: 1; } 100% { transform: translate(var(--dx), var(--dy)) scale(.2); opacity: 0; } }
.diff-note { font-size: 12px; opacity: 0.78; margin: 7px 2px 0; line-height: 1.45; }

/* 게임방법(튜토리얼) */
.dialog.how { position: relative; }
.how-emoji { font-size: 64px; line-height: 1; margin: 6px 0 8px; }
.how-body { font-size: 15px; line-height: 1.5; opacity: 0.92; min-height: 4.2em; margin: 6px 0 12px; }
.how-dots { display: flex; gap: 6px; justify-content: center; margin-bottom: 12px; }
.how-dots .dot { width: 7px; height: 7px; border-radius: 50%; background: rgba(255,255,255,0.3); }
.how-dots .dot.on { background: #2fae5f; }
.how-nav { display: flex; gap: 8px; }
.how-nav .diff { margin-top: 0; }
.how-close {
  position: absolute;
  top: 10px;
  right: 12px;
  background: none;
  border: none;
  color: #fff;
  font-size: 18px;
  opacity: 0.7;
  cursor: pointer;
}

@media (orientation: landscape) {
  :root { --card-w: min(7vw, 70px); }
}

/* ===== 개발자 갓 모드 ===== */
.god-fab {
  position: fixed; left: 10px; bottom: 132px;   /* 항상 보이는 하단 메뉴 위로 */
  width: 44px; height: 44px; border-radius: 50%;
  border: none; background: rgba(40,30,60,0.82); color: #fff;
  font-size: 21px; line-height: 1; z-index: 140;
  display: flex; align-items: center; justify-content: center;   /* 기본 항상 표시 */
  box-shadow: 0 4px 14px rgba(0,0,0,0.4); cursor: pointer;
}
.god-fab:active { transform: scale(0.92); }
/* 갓모드 = 전체 페이지(팝업 아님) */
.god-panel {
  position: fixed; inset: 0; width: 100%; height: 100%; z-index: 141;
  padding: max(54px, calc(env(safe-area-inset-top) + 44px)) 16px 28px;
  background: linear-gradient(180deg, #1c1628, #2a2240);
  border: none; border-radius: 0; box-shadow: none;
  display: none; flex-direction: column; gap: 8px;
  overflow-y: auto;
}
.god-panel.show { display: flex; }
.god-panel > * { width: 100%; max-width: 440px; margin-left: auto; margin-right: auto; }
.god-title { color: #ffd27a; font-weight: 800; font-size: 15px; text-align: center; margin: 6px auto 2px; }
.god-panel button {
  border: none; border-radius: 9px; padding: 12px 12px;
  background: #34406a; color: #fff; font-size: 14px; font-weight: 700;
  text-align: left; cursor: pointer;
}
.god-panel button:active { transform: scale(0.97); }
.god-panel .god-close { background: rgba(255,255,255,0.12); text-align: center; }
.god-toast {
  position: fixed; left: 50%; top: 18%; transform: translateX(-50%);
  background: rgba(20,16,30,0.92); color: #ffe08a;
  padding: 10px 18px; border-radius: 999px; font-weight: 800; font-size: 14px;
  z-index: 200; pointer-events: none; animation: godToast 1.4s ease forwards;
}
@keyframes godToast {
  0% { opacity: 0; transform: translate(-50%, 8px); }
  15%,75% { opacity: 1; transform: translate(-50%, 0); }
  100% { opacity: 0; transform: translate(-50%, -6px); }
}

/* ===== 마을(풍경 속에서 사는 캐릭터들) ===== */
#village {
  position: fixed;
  z-index: 3;               /* 풍경(z2) 앞, UI(z5) 뒤 */
  pointer-events: none;
  overflow: visible;
}
.villager {
  position: absolute;
  bottom: 0;
  /* 배경(씬)과 같은 픽셀 크기: 씬 픽셀=100vw/128, 캐릭터 아트 11px → 11*100vw/128 ≈ 8.6vw */
  width: 8.6vw;
  aspect-ratio: 11 / 14;
  transform-origin: 50% 100%;
  /* 탭은 문서 레벨 히트테스트(setupVillageTap)로 처리 → 드래그 방해 안 함 */
}
.villager.cat { width: 8.6vw; aspect-ratio: 11 / 11; }
/* 파운데이션(가챠 자리) → 마을 점프 클론 (보드 위로 보이게 최상위) */
.villager-fly {
  position: fixed;
  z-index: 130;
  pointer-events: none;
  object-fit: contain;
  image-rendering: pixelated;
  transform-origin: 50% 50%;
  filter: drop-shadow(0 4px 4px rgba(0,0,0,0.4));
}
/* 그 자리에서 살짝 떴다가(ease-out) 바닥으로 가속해 떨어짐(ease-in) */
.villager-fly.hop { animation: villagerHop .8s both; }
@keyframes villagerHop {
  0%   { transform: translate(0,0) scale(1); animation-timing-function: ease-out; }
  32%  { transform: translate(calc(var(--dx) * 0.34), -46px) scale(calc((1 + var(--s)) / 2)); animation-timing-function: ease-in; }
  100% { transform: translate(var(--dx), var(--dy)) scale(var(--s)); }
}
.vflip { width: 100%; height: 100%; transform-origin: 50% 100%; } /* 좌우반전 전용(말풍선 글자는 밖이라 안 뒤집힘) */
.villager .vsprite {
  width: 100%; height: 100%;
  object-fit: contain;
  object-position: bottom;
  image-rendering: pixelated;
  filter: drop-shadow(0 2px 2px rgba(0,0,0,0.35));
  transform-origin: 50% 100%;
}
/* 걷기 — 통통 발걸음 (좌우반전은 바깥 .villager의 scaleX, 모션은 안쪽 .vsprite transform → 충돌 없음) */
.villager.walking .vsprite { animation: vBob 0.34s ease-in-out infinite; }
@keyframes vBob {
  0%,100% { transform: translateY(0); }
  50% { transform: translateY(-10%); }
}
/* 같이/혼자 춤 */
/* 잡혀서 신나게 대롱대롱 흔들림(좋아함) */
.villager.grabbed { filter: drop-shadow(0 8px 6px rgba(0,0,0,0.35)); }
.villager.grabbed .vsprite { animation: vGrab 0.3s ease-in-out infinite; }
@keyframes vGrab { 0%,100% { transform: rotate(-12deg); } 50% { transform: rotate(12deg); } }
.villager.dancing .vsprite { animation: vDance 0.5s ease-in-out infinite; }
/* 조커 저글링 — 몸은 살짝 흔들, 머리 위 공 3개가 번갈아 오르내림 */
.villager.juggling .vsprite { animation: vJuggle 0.55s ease-in-out infinite; }
@keyframes vJuggle { 0%,100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-6%) rotate(4deg); } }
.vjuggle { position: absolute; left: 50%; bottom: 90%; width: 70%; height: 45%; transform: translateX(-50%); pointer-events: none; z-index: 3; }
/* 공 픽셀 = 조커/씬 픽셀과 동일 크기: 공 5px × (100vw/128) = 3.9vw */
.jball { position: absolute; left: 50%; top: 60%; width: 3.9vw; aspect-ratio: 1; margin-left: -1.95vw; image-rendering: pixelated; filter: drop-shadow(0 1px 1px rgba(0,0,0,0.3)); animation: jbob 0.55s ease-in-out infinite; }
.jb0 { --jx: -120%; }
.jb1 { --jx: 0%; animation-delay: -0.18s; }
.jb2 { --jx: 120%; animation-delay: -0.37s; }
@keyframes jbob { 0%,100% { transform: translate(var(--jx), 20%); } 50% { transform: translate(var(--jx), -120%); } }
@keyframes vDance {
  0%,100% { transform: rotate(-10deg) translateY(0); }
  25% { transform: rotate(0deg) translateY(-14%); }
  50% { transform: rotate(10deg) translateY(0); }
  75% { transform: rotate(0deg) translateY(-14%); }
}
/* 잠 — 살짝 기울여 쿨쿨 */
/* 누워서 잠 — 깬 상태와 크기 비슷하게(긴 축이 가로가 되며 커 보이던 것 보정) */
/* 잠 — 크기 그대로(회전/스케일 없음). 눈감김 스프라이트 + Zzz로만 표현 */
.villager.sleeping .vsprite { transform: none; filter: drop-shadow(0 2px 2px rgba(0,0,0,0.35)) brightness(0.97); }
/* 성문으로 쏙 들어감/나옴 */
/* 성문 안으로 들어감 — 떠오르지 않고 제자리에서 작아지며(문 안으로) 사라짐 */
.villager.toGate { animation: villagerToGate 1.1s ease-in forwards; }
@keyframes villagerToGate {
  0%   { transform: translate(0, 0) scale(1); opacity: 1; }
  55%  { transform: translate(0, 4%) scale(0.7); opacity: 1; }     /* 문으로 다가가 살짝 작아짐 */
  100% { transform: translate(0, 8%) scale(0.34); opacity: 0; }    /* 문 안으로 쏙 사라짐 */
}
/* 말풍선 */
.vbubble {
  position: absolute;
  left: 50%; bottom: 102%;
  transform: translateX(-50%) scale(0);
  background: #fff; color: #5a3a5a;
  font-size: 10px; font-weight: 800; white-space: nowrap;
  padding: 3px 7px; border-radius: 9px;
  border: 1.5px solid #ffb3d9;
  box-shadow: 0 2px 5px rgba(0,0,0,0.25);
  transform-origin: 50% 120%;
  opacity: 0;
  transition: transform .2s cubic-bezier(.2,1.4,.4,1), opacity .2s;
}
.vbubble::after {
  content: ""; position: absolute; left: 50%; top: 100%;
  transform: translateX(-50%);
  border: 4px solid transparent; border-top-color: #fff;
}
.vbubble.show { transform: translateX(-50%) scale(1); opacity: 1; }
/* 잠잘 때 Zzz (픽셀아트) */
.vzzz {
  position: absolute;
  left: 82%; bottom: 68%;
  display: flex; align-items: flex-end; gap: 1px;
  opacity: 0; pointer-events: none;
}
.vzzz .zpix { image-rendering: pixelated; display: block; }
.vzzz .z0 { width: 5px; }
.vzzz .z1 { width: 7px; }
.vzzz .z2 { width: 9px; }
.vzzz.show { opacity: 1; animation: vZzz 1.8s ease-in-out infinite; }
/* 고양이가 캣타워 발판에 가로로 누워 잠(식빵 포즈) */
/* 자는 고양이(식빵) — 깬 고양이와 얼굴 크기 비슷하게(평소보다 커지던 것 보정) */
/* 자는 고양이도 평소와 같은 크기(식빵 안 씀) */
.villager.cat.catsleep { width: 8.6vw; aspect-ratio: 11 / 11; }
/* 강아지는 살짝 작게(다른 캐릭터보다 아담) */
.villager.vdog { width: 6.8vw; }
/* 낙하산(위로 던지면 타고 내려옴) */
.villager .vchute { position: absolute; left: 50%; bottom: 92%; width: 135%; transform: translateX(-50%); image-rendering: pixelated; pointer-events: none; z-index: 2; }
/* 공룡 불뿜기 — 머리(오른쪽) 앞으로 확 커지며 길게 뻗었다 사라짐(크고 화려) */
.villager .vflame { position: absolute; left: 84%; top: 4%; width: 78%; height: 78%; image-rendering: pixelated; pointer-events: none; transform-origin: left center; animation: vFlame 1.3s cubic-bezier(.2,.7,.3,1) forwards; z-index: 3; filter: drop-shadow(0 0 6px rgba(255,140,40,0.8)); }
@keyframes vFlame { 0% { transform: scaleX(.2) scaleY(.6); opacity: 0; } 18% { transform: scaleX(1.5) scaleY(1.12); opacity: 1; } 55% { transform: scaleX(1.85) scaleY(1); opacity: 1; } 100% { transform: scaleX(2.2) scaleY(.8); opacity: 0; } }
.villager .vflame.f-b { top: 16%; width: 62%; height: 62%; animation-duration: 1.15s; }
.villager .vflame.f-c { top: -6%; width: 56%; height: 56%; animation-duration: 1.0s; }
/* 어지러움 별(빙글빙글 돌리다 놓으면) */
.villager .vdizzy { position: absolute; left: 50%; bottom: 86%; width: 75%; transform: translateX(-50%); image-rendering: pixelated; pointer-events: none; animation: dizzySpin 0.9s linear infinite; }
@keyframes dizzySpin { to { transform: translateX(-50%) rotate(360deg); } }
.villager.dizzy .vflip { transform: rotate(74deg); transform-origin: 50% 80%; animation: dizzyWobble 0.7s ease-in-out infinite; }
@keyframes dizzyWobble { 0%, 100% { transform: rotate(68deg); } 50% { transform: rotate(82deg); } }
/* 포옹/부딪힘 하트(가운데 뿅 떠오름) */
.fxheart { position: fixed; width: 26px; image-rendering: pixelated; pointer-events: none; z-index: 136; animation: fxHeart 1.6s ease-out forwards; }
@keyframes fxHeart {
  0% { opacity: 0; transform: translate(-50%, -20%) scale(0.4); }
  22% { opacity: 1; transform: translate(-50%, -60%) scale(1.2); }
  100% { opacity: 0; transform: translate(-50%, -180%) scale(0.95); }
}
/* 포옹 중 살짝 통통 */
.villager.hugging .vsprite { animation: hugBob 0.5s ease-in-out infinite alternate; }
@keyframes hugBob { from { transform: translateY(0) scale(1, 1); } to { transform: translateY(-2px) scale(1.06, 0.94); } }
@keyframes vZzz {
  0% { opacity: 0; transform: translate(0, 4px) scale(0.7); }
  40% { opacity: 1; }
  100% { opacity: 0; transform: translate(8px, -10px) scale(1.1); }
}

/* 갓 모드 진입 버튼 (DEV 전용 — 사용자 배포 시 JS에서 미생성) */
.god-entry {
  position: fixed;
  left: 6px; bottom: 6px;
  z-index: 142;
  background: rgba(40,30,60,0.7);
  color: #ffd27a;
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 11px; font-weight: 800;
  cursor: pointer;
}
.god-entry:active { transform: scale(0.94); background: rgba(40,30,60,0.9); }

/* ===== 가챠 — 좌상단 캐릭터 슬롯머신 공개 ===== */
.found-slot.gacha-active { overflow: visible; z-index: 8; }
.found-king.gacha-spin { animation: gachaSpin .12s linear infinite; }
@keyframes gachaSpin {
  0%,100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-9%) scale(1.07); }
}
.found-king.gacha-win { animation: gachaWin .6s cubic-bezier(.2,1.7,.4,1); }
@keyframes gachaWin {
  0% { transform: scale(.5); }
  55% { transform: scale(1.5); filter: drop-shadow(0 0 10px rgba(255,210,120,0.95)) brightness(1.3); }
  100% { transform: scale(1); }
}
.gacha-badge {
  position: fixed;
  transform: translate(-50%, 0);
  z-index: 135;
  background: #fff;
  color: #e08a1e;
  font-size: 13px; font-weight: 900; white-space: nowrap;
  padding: 4px 12px; border-radius: 999px;
  border: 2px solid #ffd592;
  box-shadow: 0 4px 12px rgba(150,110,40,0.4);
  pointer-events: none;
  animation: gachaBadge 1.5s ease forwards;
}
@keyframes gachaBadge {
  0% { opacity: 0; transform: translate(-50%, 8px) scale(.5); }
  18% { opacity: 1; transform: translate(-50%, 0) scale(1.12); }
  30% { transform: translate(-50%, 0) scale(1); }
  78% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -10px) scale(1); }
}

/* 갓 모드 캐릭터 소환 버튼 그리드 */
.god-spawn { display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px; }
.god-spawn button { text-align: center; padding: 8px 0; font-size: 13px; }
.god-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }

/* 구글 광고 자리(메뉴 바로 아래) — 항상 비워둠. 배너 로드되면 실제 높이로 맞춰짐(ads.js). 메뉴는 이 위에 뜸 */
#adspace {
  flex: 0 0 60px;
  height: 60px;            /* 적응형 배너 안전 기본값 — 로드 전에도 메뉴가 안 가리게 확보 */
  width: 100%;
  position: relative;
  z-index: 5;
  overflow: hidden;
}

/* 자동완성 버튼 — 엔드게임에 메뉴 위로 떠오름(강제 자동 X, 눌러서 실행) */
.auto-btn {
  position: absolute; left: 50%; bottom: 100%; margin-bottom: 16px; /* 메뉴(#bottombar) 바로 위 — 겹침 없음 */
  transform: translateX(-50%) translateY(16px);
  z-index: 30;
  background: #ffb259; color: #fff; border: 2px solid #fff;
  border-radius: 999px; padding: 10px 22px;
  font-size: clamp(13px, 4vw, 16px); font-weight: 800;
  box-shadow: 0 5px 16px rgba(0,0,0,0.4);
  opacity: 0; pointer-events: none; cursor: pointer;
  transition: opacity .25s ease, transform .25s cubic-bezier(.2,1.4,.4,1);
}
.auto-btn.show { opacity: 1; pointer-events: auto; transform: translateX(-50%) translateY(0); animation: autoPulse 1.4s ease-in-out infinite; }
@keyframes autoPulse { 0%,100% { box-shadow: 0 5px 16px rgba(255,178,89,0.5); } 50% { box-shadow: 0 5px 22px rgba(255,178,89,0.95); } }
.auto-btn:active { transform: translateX(-50%) scale(0.95); }

/* ===== 가로모드(가로가 길고 세로가 짧은 폰) — 크롬 압축 + 카드를 높이 기준으로 ===== */
@media (orientation: landscape) and (max-height: 560px) {
  #topbar { padding: 1px 10px; }
  .stat .label { font-size: 8px; }
  .stat span:last-child { font-size: 13px; }
  .icon-btn { width: clamp(28px, 7vh, 38px); height: clamp(28px, 7vh, 38px); font-size: clamp(14px, 4.4vh, 18px); }
  #stockbar { min-height: calc(var(--real-card-w, 34px) * 7 / 5); padding: 1px 8px 0; }
  /* 카드를 세로(vh) 기준으로 작게 → 10열이 가운데 모이고 각 열이 메뉴 직전까지 펼쳐짐 */
  #board { grid-template-columns: repeat(10, minmax(0, 12.5vh)); justify-content: center; padding-top: 3px; }
  /* 하단 메뉴 컴팩트 */
  #bottombar { padding: 2px 10px; }
  .act { padding: 3px 10px; }
  .act .ico { font-size: clamp(14px, 4vh, 18px); }
  .act .lbl { font-size: clamp(8px, 2.4vh, 11px); }
  #adspace { flex: 0 0 34px; height: 34px; } /* 가로에선 배너 공간도 슬림하게 */
}
