/* 보석 맞추기 — 보석 동굴 */

/* ── 공통 틀(퍼즐 6종이 같이 쓰는 모양): 제목 화면 · PLAY 단추 · HUD 알약 · 결과 별 · 손가락 안내 ──
   게임마다 바꾸는 색: --k-a(로고 위) --k-b(로고 아래) --k-edge(로고 테두리) --k-glow(빛) */
.k-title { position: absolute; inset: 0; z-index: 10; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 18px 16px; text-align: center; overflow: hidden; }
.k-title[hidden] { display: none; }
.k-title > * { position: relative; z-index: 2; }
.k-title .k-bg { position: absolute; inset: 0; z-index: 0; pointer-events: none; }
.k-bot { width: 86px; height: 86px; filter: drop-shadow(0 10px 14px rgba(0, 0, 0, 0.35)); animation: k-bob 2.4s ease-in-out infinite; }
@keyframes k-bob { 50% { transform: translateY(-9px) rotate(-3deg); } }
.k-logo { position: relative; margin: 0; font-family: 'Black Han Sans', var(--title); font-weight: 400; font-size: clamp(42px, 8.4vw, 82px); line-height: 1; letter-spacing: -0.01em; white-space: nowrap; }
.k-logo span { position: relative; display: inline-block; background: linear-gradient(180deg, #fff 8%, var(--k-a, #ffe27a) 46%, var(--k-b, #ff9a3c) 100%); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; color: transparent; }
.k-logo::before { content: attr(data-t); position: absolute; inset: 0; z-index: -1; -webkit-text-stroke: 12px var(--k-edge, #3a1d6e); color: var(--k-edge, #3a1d6e); text-shadow: 0 8px 0 var(--k-edge, #3a1d6e), 0 16px 26px rgba(0, 0, 0, 0.45); }
.k-logo small { display: block; font-size: 0.34em; margin-top: 6px; }
.k-sub { margin: -4px 0 2px; max-width: 420px; font-size: 15px; line-height: 1.45; color: rgba(255, 255, 255, 0.86); text-shadow: 0 2px 4px rgba(0, 0, 0, 0.4); }
@media (max-width: 420px) { .k-logo { font-size: clamp(36px, 11vw, 54px); } .k-bot { width: 70px; height: 70px; } }

/* 크고 도톰한 입체 단추 (모든 게임 같은 금빛) */
.k-play { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 12px; min-width: 230px; padding: 15px 44px 17px; border: 0; border-radius: 24px; cursor: pointer; overflow: hidden;
  font-family: 'Black Han Sans', var(--title); font-size: 32px; line-height: 1; color: #fff; letter-spacing: 0.02em; text-shadow: 0 3px 0 rgba(150, 60, 0, 0.55);
  background: linear-gradient(180deg, #ffe066 0%, #ffb21e 52%, #ff8a00 100%);
  box-shadow: 0 8px 0 #c25e00, 0 14px 26px rgba(0, 0, 0, 0.38), inset 0 3px 0 rgba(255, 255, 255, 0.65), inset 0 -4px 0 rgba(200, 80, 0, 0.35);
  animation: k-breathe 1.8s ease-in-out infinite; transition: transform 0.08s, box-shadow 0.08s; }
.k-play::before { content: ''; position: absolute; left: 10px; right: 10px; top: 5px; height: 42%; border-radius: 18px 18px 40% 40%; background: linear-gradient(rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0)); pointer-events: none; }
.k-play::after { content: ''; position: absolute; top: -20%; bottom: -20%; width: 34%; left: -50%; background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.75), transparent); transform: skewX(-18deg); animation: k-shine 2.8s ease-in-out infinite; pointer-events: none; }
.k-play svg { width: 0.9em; height: 0.9em; fill: #fff; filter: drop-shadow(0 3px 0 rgba(150, 60, 0, 0.55)); }
.k-play:hover { filter: brightness(1.06); }
.k-play:active { transform: translateY(6px) scale(0.98); box-shadow: 0 2px 0 #c25e00, 0 6px 12px rgba(0, 0, 0, 0.3), inset 0 3px 0 rgba(255, 255, 255, 0.65); animation: none; }
.k-play.small { min-width: 0; font-size: 24px; padding: 12px 26px 14px; border-radius: 18px; }
.k-play.wide { width: 100%; }
@keyframes k-breathe { 50% { transform: scale(1.045); } }
@keyframes k-shine { 0%, 55% { left: -50%; } 100% { left: 130%; } }

.k-ghost[hidden], .k-play[hidden], .k-best[hidden], .k-link[hidden] { display: none; }
/* 작은 보조 단추 · 고르기 칩 */
.k-ghost { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 18px; border-radius: 16px; border: 2px solid rgba(255, 255, 255, 0.28); background: rgba(255, 255, 255, 0.1); color: #fff; font-family: var(--title); font-size: 17px; cursor: pointer; text-decoration: none; backdrop-filter: blur(4px); box-shadow: 0 4px 0 rgba(0, 0, 0, 0.25); }
.k-ghost:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25); }
.k-link { display: inline-block; margin-top: 2px; font-size: 14px; color: rgba(255, 255, 255, 0.72); text-decoration: underline; text-underline-offset: 3px; }

/* HUD 알약: 아이콘 + 숫자 */
.k-pill { position: relative; display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px 0 4px; border-radius: 999px; background: linear-gradient(180deg, rgba(20, 16, 50, 0.72), rgba(20, 16, 50, 0.55)); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.14), 0 4px 10px rgba(0, 0, 0, 0.25); color: #fff; }
.k-pill i { flex: none; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: linear-gradient(180deg, var(--ic1, #ffd75e), var(--ic2, #ff9d1c)); box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.55), inset 0 -3px 0 rgba(0, 0, 0, 0.2); }
.k-pill i svg { width: 19px; height: 19px; fill: #fff; filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.3)); }
.k-pill b { font-family: 'Black Han Sans', var(--title); font-weight: 400; font-size: 22px; line-height: 1; min-width: 1.2em; text-align: center; letter-spacing: 0.01em; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.35); }
.k-pill small { font-size: 11px; opacity: 0.7; margin-left: -2px; }
.k-pill.k-hot b { color: #ffd75e; }
.k-pop { animation: k-pop 0.36s cubic-bezier(.3, 1.8, .5, 1); }
@keyframes k-pop { 0% { transform: scale(1); } 35% { transform: scale(1.32) translateY(-2px); } 100% { transform: scale(1); } }
.k-best { display: inline-flex; align-items: center; gap: 8px; padding: 7px 16px 7px 8px; border-radius: 999px; background: rgba(0, 0, 0, 0.28); box-shadow: inset 0 0 0 2px rgba(255, 215, 94, 0.45); color: #ffe7a0; font-family: var(--title); font-size: 17px; }
.k-best i { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: linear-gradient(#ffe27a, #ffa41c); }
.k-best i svg { width: 17px; height: 17px; fill: #fff; }
.k-best b { font-family: 'Black Han Sans', var(--title); font-weight: 400; font-size: 21px; color: #fff; }

/* 결과 화면 카드 */
.k-res { position: absolute; inset: 0; z-index: 12; display: grid; place-items: center; padding: 16px; background: radial-gradient(ellipse at 50% 40%, rgba(40, 30, 90, 0.55), rgba(10, 8, 30, 0.86)); backdrop-filter: blur(3px); }
.k-res[hidden] { display: none; }
.k-card { position: relative; width: min(380px, 100%); max-height: 100%; overflow: auto; padding: 16px 22px 20px; border-radius: 28px; text-align: center; color: #fff;
  background: linear-gradient(180deg, var(--k-card1, #3b2f86) 0%, var(--k-card2, #231a5c) 100%); box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.16), inset 0 3px 0 rgba(255, 255, 255, 0.25), 0 26px 60px rgba(0, 0, 0, 0.5);
  animation: k-card-in 0.45s cubic-bezier(.2, 1.4, .4, 1) both; }
@keyframes k-card-in { from { transform: translateY(40px) scale(0.85); opacity: 0; } }
.k-card h2 { margin: 0 0 2px; font-family: 'Black Han Sans', var(--title); font-weight: 400; font-size: 34px; line-height: 1.1; color: #fff; text-shadow: 0 3px 0 rgba(0, 0, 0, 0.35); }
.k-card p { margin: 0 0 10px; color: rgba(255, 255, 255, 0.78); font-size: 15px; }
.k-stars { display: flex; justify-content: center; align-items: flex-end; gap: 2px; margin: 0 0 4px; }
.k-stars span { width: 62px; height: 62px; display: block; }
.k-stars span:nth-child(2) { width: 82px; height: 82px; margin-bottom: 12px; }
.k-stars svg { width: 100%; height: 100%; overflow: visible; }
.k-stars .bg { fill: #1a1446; stroke: rgba(255, 255, 255, 0.25); stroke-width: 1.4; }
.k-stars .fg { fill: url(#k-gold); stroke: #b86a00; stroke-width: 1.4; transform-origin: 12px 12px; transform: scale(0); }
.k-stars .on .fg { animation: k-stamp 0.42s cubic-bezier(.3, 1.9, .5, 1) forwards; }
@keyframes k-stamp { 0% { transform: scale(2.4) rotate(-30deg); opacity: 0; } 60% { opacity: 1; } 100% { transform: scale(1) rotate(0); opacity: 1; } }
.k-score { display: block; margin: 4px 0 2px; font-family: 'Black Han Sans', var(--title); font-weight: 400; font-size: 56px; line-height: 1.05; background: linear-gradient(#fff, #ffe48a); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; filter: drop-shadow(0 4px 0 rgba(0, 0, 0, 0.35)); }
.k-rows { display: grid; gap: 6px; margin: 8px 0 12px; }
.k-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 14px; border-radius: 14px; background: rgba(0, 0, 0, 0.22); font-size: 15px; }
.k-row b { font-family: 'Black Han Sans', var(--title); font-weight: 400; font-size: 20px; }
.k-next { margin: 0 0 12px; padding: 8px 12px; border-radius: 14px; background: rgba(255, 215, 94, 0.14); box-shadow: inset 0 0 0 1.5px rgba(255, 215, 94, 0.4); color: #ffe7a0; font-size: 14px; }
.k-next:empty { display: none; }
.k-ribbon { position: relative; display: inline-block; margin: 2px 0 8px; padding: 6px 26px; font-family: 'Black Han Sans', var(--title); font-size: 20px; color: #fff; background: linear-gradient(#ff5d8f, #e0245e); box-shadow: 0 4px 0 #9c1240; border-radius: 6px; transform: rotate(-3deg); animation: k-ribbon 0.6s 0.3s cubic-bezier(.3, 1.8, .5, 1) both; }
.k-ribbon[hidden] { display: none; }
@keyframes k-ribbon { from { transform: rotate(-3deg) scale(0); } }
.k-card .k-play { margin-top: 4px; }
.k-card .k-link { margin-top: 12px; }

/* 손가락 안내 */
.k-hand { position: absolute; left: 0; top: 0; z-index: 9; width: 58px; height: 58px; pointer-events: none; filter: drop-shadow(0 6px 6px rgba(0, 0, 0, 0.4)); }
.k-hand svg { width: 100%; height: 100%; transform-origin: 30% 8%; }
.k-hand.press svg { transform: scale(0.85); }
.k-tap { position: absolute; z-index: 8; width: 54px; height: 54px; margin: -27px 0 0 -27px; border-radius: 50%; border: 4px solid #fff; pointer-events: none; animation: k-tap 0.6s ease-out forwards; }
@keyframes k-tap { from { transform: scale(0.3); opacity: 0.9; } to { transform: scale(1.4); opacity: 0; } }
.k-tipbox { position: absolute; left: 50%; z-index: 9; transform: translateX(-50%); padding: 8px 16px; border-radius: 14px; background: rgba(15, 10, 40, 0.82); color: #fff; font-family: var(--title); font-size: 17px; white-space: nowrap; pointer-events: none; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35); animation: k-tip-in 0.4s ease-out both; }
@keyframes k-tip-in { from { opacity: 0; transform: translate(-50%, 8px); } }

/* 콤보 글자 */
.sb-float.k-combo { font-family: 'Black Han Sans', var(--title); -webkit-text-stroke: 7px rgba(40, 10, 70, 0.92); letter-spacing: 0.02em; }
@media (prefers-reduced-motion: reduce) { .k-play, .k-bot { animation: none; } }

.stage.m3 { --k-a: #ffe9a8; --k-b: #ff7ad9; --k-edge: #2a0f5c; --k-card1: #4a2a8f; --k-card2: #22114f;
  padding: 12px; background: radial-gradient(70% 55% at 50% 0%, #6b3fc8 0%, rgba(80, 40, 160, 0) 70%), radial-gradient(60% 40% at 50% 100%, rgba(30, 180, 200, 0.35), transparent 70%), linear-gradient(180deg, #2b1b6e 0%, #1a1248 60%, #120c33 100%); }
/* 천장에서 내려오는 빛줄기 */
.m3-rays, .m3-trays { position: absolute; left: 50%; top: -10%; width: 140%; height: 120%; transform: translateX(-50%); pointer-events: none;
  background: conic-gradient(from 180deg at 50% 0%, transparent 0 150deg, rgba(255, 220, 255, 0.10) 156deg, transparent 162deg, rgba(200, 240, 255, 0.08) 172deg, transparent 178deg, rgba(255, 230, 180, 0.10) 186deg, transparent 194deg, rgba(220, 200, 255, 0.08) 204deg, transparent 210deg 360deg);
  animation: m3-sway 9s ease-in-out infinite alternate; transform-origin: 50% 0; }
@keyframes m3-sway { from { transform: translateX(-50%) rotate(-4deg); } to { transform: translateX(-50%) rotate(4deg); } }
.stage.m3::after { content: ''; position: absolute; inset: 0; pointer-events: none; opacity: 0.7;
  background: radial-gradient(circle at 12% 30%, #fff 0 1.2px, transparent 2px), radial-gradient(circle at 80% 20%, #fff 0 1px, transparent 2px), radial-gradient(circle at 66% 70%, #ffe9a8 0 1.4px, transparent 2.4px), radial-gradient(circle at 30% 80%, #c9f6ff 0 1.2px, transparent 2px);
  background-size: 210px 230px, 260px 190px, 300px 280px, 240px 260px; animation: m3-twinkle 3s ease-in-out infinite alternate; }
@keyframes m3-twinkle { from { opacity: 0.35; } to { opacity: 0.8; } }

.m3-wrap { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.m3-wrap.side { flex-direction: row; gap: 22px; }
.m3-side { width: var(--size); display: flex; flex-direction: column; gap: 8px; }
.m3-wrap.side .m3-side { width: 196px; gap: 14px; }

.m3-hud { display: flex; gap: 8px; }
.m3-hud .k-pill { flex: 1; min-width: 0; }
.m3-hud .k-pill b { flex: 1; text-align: left; white-space: nowrap; overflow: hidden; }
.m3-hud .h-moves b { color: #7ff0cf; }
.m3-hud .h-moves.low { box-shadow: inset 0 0 0 2px rgba(255, 107, 90, 0.8), 0 0 16px rgba(255, 107, 90, 0.5); animation: m3-beat 0.9s ease-in-out infinite; }
.m3-hud .h-moves.low i { --ic1: #ffb0a6; --ic2: #ff4d3a; }
.m3-hud .h-moves.low b { color: #ff9c8f; }
.m3-wrap.side .m3-hud { flex-direction: column; }
.m3-wrap.side .m3-hud .k-pill { height: 50px; }
.m3-wrap.side .m3-hud .k-pill b { font-size: 28px; }
@keyframes m3-beat { 50% { transform: scale(1.06); } }

/* 별 사다리 */
.m3-goal { position: relative; height: 30px; margin: 2px 16px 0 8px; }
.m3-bar { position: absolute; left: 0; right: 0; top: 10px; height: 10px; border-radius: 99px; background: rgba(0, 0, 0, 0.35); box-shadow: inset 0 2px 3px rgba(0, 0, 0, 0.4), 0 0 0 1.5px rgba(255, 255, 255, 0.12); overflow: hidden; }
.m3-fill { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, #7b6cff, #3ee0b5 45%, #ffd23f); box-shadow: 0 0 10px rgba(255, 210, 63, 0.5), inset 0 2px 0 rgba(255, 255, 255, 0.45); transition: width 0.35s ease-out; }
.m3-star { position: absolute; top: -1px; transform: translateX(-50%); font-size: 26px; line-height: 30px; color: #3a2f6e; -webkit-text-stroke: 1.5px rgba(255, 255, 255, 0.25); transition: color 0.2s; }
.m3-star.on { color: #ffd23f; -webkit-text-stroke: 1.5px #b86a00; text-shadow: 0 0 12px rgba(255, 210, 63, 0.9); animation: m3-starpop 0.5s cubic-bezier(.3, 1.8, .5, 1); }
@keyframes m3-starpop { 40% { transform: translateX(-50%) scale(1.8) rotate(-14deg); } }

.m3-tip { margin: 0; font-size: 13px; color: #b9b0e6; text-align: center; line-height: 1.4; }
.m3-wrap.side .m3-tip { text-align: left; }

.m3-board { position: relative; border-radius: calc(var(--size) * 0.04); touch-action: none;
  box-shadow: 0 0 0 3px #c9a64a, 0 0 0 6px #6b4a12, 0 0 0 8px rgba(255, 220, 140, 0.35), 0 22px 50px rgba(0, 0, 0, 0.55), 0 0 60px rgba(160, 100, 255, 0.35); }
.m3-cv { display: block; touch-action: none; cursor: pointer; }

/* 제목 화면 */
.m3 .ov-start { background: radial-gradient(60% 50% at 50% 38%, rgba(180, 120, 255, 0.45), transparent 70%), linear-gradient(180deg, #2b1b6e 0%, #1a1248 60%, #120c33 100%); }
.m3-fl { position: absolute; width: calc(76px * var(--s)); height: calc(76px * var(--s)); opacity: 0.85; filter: drop-shadow(0 10px 14px rgba(0, 0, 0, 0.4)); animation: m3-fl 5.5s ease-in-out infinite; }
@keyframes m3-fl { 0%, 100% { transform: translateY(0) rotate(-10deg); } 50% { transform: translateY(-18px) rotate(10deg); } }
.m3-gems { display: block; width: 300px; max-width: 90%; height: auto; filter: drop-shadow(0 8px 12px rgba(0, 0, 0, 0.35)); animation: k-bob 2.6s ease-in-out infinite; }
.m3 .k-logo { --k-a: #ffe9a8; --k-b: #ff7ad9; }
.m3-specials { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 14px; max-width: 520px; }
.m3-specials span { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px 4px 4px; border-radius: 999px; background: rgba(0, 0, 0, 0.28); box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.12); font-size: 13.5px; color: #e6defe; }
.m3-sp { width: 32px; height: 32px; }
@media (max-width: 500px) { .m3-fl { opacity: 0.4; } }
@media (max-height: 600px) { .m3-specials, .m3 .ov-start .k-sub { display: none; } }
@media (max-height: 560px) { .m3-tip { display: none; } }
@media (max-height: 500px) { .m3-gems { display: none; } }
