:root { --bs: var(--kit-btn-scale, 1); --ink: #2f3550; --muted: #7a809c; --accent: #8b7cf6; --pink: #ff8fb8; --hud: #4b4f73; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; }
body { font-family: "Pretendard Variable", "Pretendard", -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif; background: #f6f1ff; color: var(--ink); word-break: keep-all; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
body.dark { --hud: #f1efff; background: #232857; }
.hidden { display: none !important; }

#stage { position: fixed; inset: 0; }
#cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; will-change: transform; }

.top { position: fixed; top: 0; left: 0; right: 0; z-index: 20; display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: calc(env(safe-area-inset-top) + 10px) 14px 8px; pointer-events: none; }
.top > * { pointer-events: auto; }
.top h1 { margin: 0; font-size: 21px; font-weight: 900; letter-spacing: -0.5px; color: var(--hud); white-space: nowrap; }
.top h1 b { color: #ff6b8b; }
body.playing .top { display: none; }

.screen { position: fixed; inset: 0; z-index: 10; }
#home { display: flex; flex-direction: column; padding: calc(env(safe-area-inset-top) + 64px) 16px calc(env(safe-area-inset-bottom) + 14px); pointer-events: none; }
#home > * { pointer-events: auto; }
.hero { text-align: center; }
.title-art { display: grid; grid-template-columns: repeat(3, 34px); grid-template-rows: repeat(2, 34px); gap: 4px; justify-content: center; margin: 18px auto 14px; }
.title-art i { border-radius: 9px; box-shadow: inset 0 -5px 0 rgba(0, 0, 0, .12), inset 0 5px 0 rgba(255, 255, 255, .35); animation: bob 2.4s ease-in-out infinite; }
.title-art .c1 { background: #ff6b8b; } .title-art .c2 { background: #ffa94d; animation-delay: .2s; } .title-art .c3 { background: #ffd43b; animation-delay: .4s; grid-row: span 2; }
.title-art .c4 { background: #4dabf7; animation-delay: .6s; } .title-art .c5 { background: #5fd68a; animation-delay: .8s; }
@keyframes bob { 50% { transform: translateY(-5px); } }
.best { margin: 0 auto; display: inline-block; padding: 6px 14px; border-radius: 99px; background: rgba(255, 255, 255, .82); font-weight: 800; font-size: 14px; color: #c2477a; box-shadow: 0 4px 14px rgba(90, 80, 150, .1); }
.best:empty { display: none; }
.spacer { flex: 1; min-height: 20px; pointer-events: none !important; }
.panel { width: 100%; max-width: 440px; margin: 0 auto; padding: 14px; border-radius: 24px; background: rgba(255, 255, 255, .92); border: 1px solid #ece8f4; box-shadow: 0 14px 40px rgba(80, 70, 140, .16); display: grid; gap: 8px; max-height: 70vh; overflow-y: auto; }
.big { padding: calc(13px * var(--bs)) 12px; border-radius: calc(16px * var(--bs)); border: 0; font: inherit; font-weight: 900; font-size: calc(16px * var(--bs)); cursor: pointer; transition: transform .1s; line-height: 1.3; }
.big:active { transform: scale(.97); }
.big small { display: block; font-size: 12.5px; font-weight: 700; opacity: .9; }
.big.primary { color: #fff; background: linear-gradient(135deg, #ff8fb8, #8b7cf6); box-shadow: 0 8px 20px rgba(139, 124, 246, .32); font-size: calc(19px * var(--bs)); padding: calc(15px * var(--bs)) 12px; }
.big.ghost { background: #fff; color: var(--accent); border: 1.5px solid #e4def5; padding-top: calc(9px * var(--bs)); padding-bottom: calc(9px * var(--bs)); font-size: calc(14px * var(--bs)); }
.big.daily { color: #fff; background: linear-gradient(135deg, #ffb54d, #ff6b8b); box-shadow: 0 8px 20px rgba(255, 120, 110, .28); }
.howto { border-radius: 16px; background: #faf8ff; border: 1px solid #ece8f4; padding: 8px 12px; }
.howto summary { cursor: pointer; font-weight: 900; font-size: 14px; color: #5b5f86; padding: 2px 0; }
.howto ul { margin: 6px 0 2px; padding-left: 18px; font-size: 13.5px; line-height: 1.6; color: #565c7c; }
.howto li { margin: 2px 0; }
.gear { margin: 0; font-size: 12.5px; color: var(--muted); text-align: center; }
.gear b { color: #5b5f86; }

/* 게임 화면 */
#play { pointer-events: none; }
#play button { pointer-events: auto; }
.hud { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: calc(env(safe-area-inset-top) + 8px) 12px 4px; }
.round { width: calc(42px * var(--bs)); height: calc(42px * var(--bs)); flex: none; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .88); color: #6b6f92; font-size: calc(17px * var(--bs)); font-weight: 900; box-shadow: 0 4px 12px rgba(60, 50, 110, .15); cursor: pointer; display: grid; place-items: center; padding: 0; font-family: inherit; }
.round:active { transform: scale(.94); }
.score { text-align: center; color: var(--hud); min-width: 0; }
.score b { display: block; font-size: 38px; font-weight: 900; line-height: 1; letter-spacing: -1px; font-variant-numeric: tabular-nums; }
.score b.bump { animation: bump .25s ease-out; }
.score small { display: block; margin-top: 3px; font-size: 13px; font-weight: 800; opacity: .8; white-space: nowrap; }
@keyframes bump { 40% { transform: scale(1.14); } }
/* 콤보 표시 (자리는 늘 잡아 둠 → 판 크기가 안 흔들림) */
.combo { display: flex; align-items: center; justify-content: center; gap: 5px; height: 22px; margin-top: 3px; visibility: hidden; opacity: 0; transition: opacity .2s; white-space: nowrap; }
.combo.on { visibility: visible; opacity: 1; }
.score .combo b { display: inline-block; font-size: 13px; font-weight: 900; line-height: 20px; padding: 0 9px; border-radius: 99px; background: linear-gradient(90deg, #ff8a3d, #ff4f8b); color: #fff; letter-spacing: 0; }
.combo span { font-size: 11.5px; font-weight: 800; opacity: .85; overflow: hidden; text-overflow: ellipsis; }
.score .combo.ending b { animation: comboEnd 1s ease-in-out infinite; }
.combo.ending span { color: #ff4f8b; opacity: 1; }
body.dark .combo.ending span { color: #ff9cc2; }
@keyframes comboEnd { 50% { opacity: .45; transform: scale(.94); } }
.pops { position: absolute; left: 0; right: 0; top: 0; height: 0; text-align: center; }
.pop { position: absolute; left: 50%; transform: translateX(-50%); white-space: nowrap; font-weight: 900; font-size: 30px; color: #ff4f8b; -webkit-text-stroke: 6px #fff; paint-order: stroke fill; text-shadow: 0 4px 14px rgba(120, 60, 120, .25); animation: pop 1.1s ease-out forwards; pointer-events: none; }
.pop.small { font-size: 20px; color: #8b5cf6; -webkit-text-stroke: 5px #fff; }
.pop.gold { color: #f08c00; }
.pop.big2 { font-size: 36px; color: #ff6b00; }
@keyframes pop { 0% { opacity: 0; transform: translate(-50%, 12px) scale(.6); } 15% { opacity: 1; transform: translate(-50%, 0) scale(1.1); } 70% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -46px) scale(1); } }

/* 결과 창 */
.res-big { text-align: center; margin: 4px 0 6px; }
.res-big b { display: block; font-size: 46px; font-weight: 900; letter-spacing: -1px; color: #8b5cf6; line-height: 1.1; }
.res-big small { display: block; color: var(--muted); font-weight: 700; font-size: 13.5px; margin-top: 4px; }
.res-new { display: inline-block; margin-top: 8px; padding: 4px 12px; border-radius: 99px; background: linear-gradient(90deg, #ffd43b, #ff8fb8); color: #fff; font-weight: 900; font-size: 14px; }
.res-actions .kit-btn { min-height: 48px; }
.ad-slot { margin: 10px 0 0; min-height: 0; }

@media (prefers-reduced-motion: reduce) { .title-art i, .pop, .score b.bump, .score .combo.ending b { animation: none; } }
@media (max-width: 340px) { .combo span { display: none; } }
@media (max-height: 640px) { .title-art { display: none; } #home { padding-top: calc(env(safe-area-inset-top) + 54px); } .score b { font-size: 30px; } }
