:root { --bs: var(--kit-btn-scale, 1); --ink: #2f3550; --muted: #7a809c; --accent: #8b7cf6; --pink: #ff8fb8; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body { font-family: "Pretendard", -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif; background: #eaf6ff; color: var(--ink); word-break: keep-all; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
.hidden { display: none !important; }

#stage { position: fixed; inset: 0; }
#stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.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: 20px; font-weight: 900; letter-spacing: -0.5px; color: #4b4f73; text-shadow: 0 2px 0 rgba(255, 255, 255, .8); white-space: nowrap; }
.top h1 b { color: var(--accent); }
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) + 58px) 16px calc(env(safe-area-inset-bottom) + 14px); pointer-events: none; }
#home > * { pointer-events: auto; }
.hero { text-align: center; }
.best { margin: 0 auto; display: inline-block; padding: 6px 14px; border-radius: 99px; background: rgba(255, 255, 255, .78); 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: 120px; pointer-events: none !important; }
.panel { width: 100%; max-width: 440px; margin: 0 auto; padding: 14px; border-radius: 24px; background: rgba(255, 255, 255, .9); border: 1px solid #ece8f4; box-shadow: 0 14px 40px rgba(80, 70, 140, .16); display: grid; gap: 8px; max-height: 62vh; overflow-y: auto; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.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; }
.big:active { transform: scale(.97); }
.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; }
/* 📅 오늘의 도전 단추 (2026-10-31) */
.big.daily { color: #6a4a00; background: linear-gradient(135deg, #fff1c2, #ffd36e); box-shadow: 0 6px 16px rgba(245, 165, 36, .25); display: flex; flex-direction: column; align-items: center; gap: 2px; }
.big.daily small { font-size: calc(12px * var(--bs)); font-weight: 700; opacity: .8; }
/* ⚡ 빠른 대전 (2026-11-03) */
.big.quick { color: #fff; background: linear-gradient(135deg, #5fb8ff, #8b7cf6); box-shadow: 0 6px 16px rgba(95, 140, 246, .25); display: flex; flex-direction: column; align-items: center; gap: 2px; }
.big.quick small { font-size: calc(12px * var(--bs)); font-weight: 700; opacity: .9; }
.daily-bonus b { color: #e08a00; }
.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; }
.quit, .sound { position: absolute; top: calc(env(safe-area-inset-top) + 10px); width: calc(44px * var(--bs)); height: calc(44px * var(--bs)); border-radius: 50%; border: 0; background: rgba(255, 255, 255, .85); color: #6b6f92; font-size: calc(18px * var(--bs)); font-weight: 900; box-shadow: 0 4px 12px rgba(60, 50, 110, .15); cursor: pointer; display: grid; place-items: center; padding: 0; }
.quit { left: 12px; }
.sound { left: 12px; top: calc(env(safe-area-inset-top) + 18px + 44px * var(--bs)); font-size: calc(16px * var(--bs)); }
.mus-play { top: calc(env(safe-area-inset-top) + 26px + 88px * var(--bs)); }
@media (pointer: coarse) {
  .quit, .sound { width: max(44px, calc(44px * var(--bs))); height: max(44px, calc(44px * var(--bs))); }
  .sound { top: calc(env(safe-area-inset-top) + 18px + max(44px, calc(44px * var(--bs)))); }
  .mus-play { top: calc(env(safe-area-inset-top) + 26px + 2 * max(44px, calc(44px * var(--bs)))); }
}
/* 🎵 음악 단추 (2026-10-31): 처음 화면은 계정 칩 왼쪽, 누르기 쉽게 44px (2026-11-07) */
.mus.off { opacity: .55; }
.mus-top { margin-left: auto; flex: none; width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .85); font-size: 17px; box-shadow: 0 4px 12px rgba(60, 50, 110, .15); cursor: pointer; display: grid; place-items: center; padding: 0; }
.hud { position: absolute; top: calc(env(safe-area-inset-top) + 18px); left: 50%; transform: translateX(-50%); text-align: center; color: #fff; text-shadow: 0 2px 10px rgba(60, 50, 120, .35); }
.hud b { display: block; font-size: 56px; font-weight: 900; line-height: 1; letter-spacing: -1px; }
.hud small { display: block; margin-top: 4px; font-size: 14px; font-weight: 800; -webkit-text-stroke: 4px rgba(75, 70, 140, .55); paint-order: stroke fill; text-shadow: 0 2px 10px rgba(60, 50, 120, .35), 0 1px 3px rgba(60, 50, 120, .6); } /* '층' 글자가 하늘색 위에서 안 보여서 테두리 (2026-11-07) */
.pops { position: absolute; left: 0; right: 0; top: 34%; text-align: center; }
.pop { position: absolute; left: 50%; transform: translateX(-50%); white-space: nowrap; font-weight: 900; font-size: 26px; color: #ff4f8b; -webkit-text-stroke: 5px #fff; paint-order: stroke fill; text-shadow: 0 4px 14px rgba(120, 60, 120, .3); animation: pop 0.9s ease-out forwards; }
.pop.gold { color: #f08c00; }
.pop.blue { color: #3b82f6; }
@keyframes pop { 0% { opacity: 0; transform: translate(-50%, 10px) scale(.7); } 15% { opacity: 1; transform: translate(-50%, 0) scale(1.08); } 70% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -40px) scale(1); } }
.tap-hint { position: absolute; left: 0; right: 0; bottom: calc(env(safe-area-inset-bottom) + 26px); margin: 0; text-align: center; font-size: 16px; font-weight: 800; color: #fff; text-shadow: 0 2px 8px rgba(60, 50, 120, .4); animation: blink 1.4s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .45; } }
.count { position: absolute; inset: 0; display: grid; place-items: center; font-size: 110px; font-weight: 900; color: #fff; text-shadow: 0 6px 30px rgba(139, 124, 246, .6); }
.banner { position: absolute; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 70px); transform: translateX(-50%); padding: 12px 18px; border-radius: 18px; background: rgba(255, 255, 255, .92); box-shadow: 0 10px 30px rgba(60, 50, 110, .2); text-align: center; font-weight: 800; font-size: 15px; line-height: 1.5; width: max-content; max-width: calc(100% - 32px); }
.banner b { color: #c2477a; }

/* 친구 탑 (오른쪽) */
.rivals { position: absolute; right: 8px; top: calc(env(safe-area-inset-top) + 10px); display: grid; gap: 6px; width: 86px; }
.rv { padding: 5px 6px 6px; border-radius: 14px; background: rgba(255, 255, 255, .86); box-shadow: 0 4px 12px rgba(60, 50, 110, .14); border-top: 3px solid var(--pc); text-align: center; }
.rv canvas { display: block; width: 100%; height: 54px; }
.rv b { display: block; font-size: 18px; font-weight: 900; line-height: 1.1; }
.rv small { display: block; font-size: 11px; font-weight: 800; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rv.dead { opacity: .62; filter: grayscale(.7); }
.rv.dead b::after { content: ' 끝'; font-size: 11px; color: #c2477a; }
.rv.me { outline: 2px solid var(--pc); }

/* 결과 */
.res-big { text-align: center; margin: 4px 0 10px; }
.res-big b { display: block; font-size: 54px; font-weight: 900; line-height: 1; color: var(--accent); }
.res-big small { color: var(--muted); font-weight: 800; }
.res-new { display: inline-block; margin-top: 6px; padding: 3px 10px; border-radius: 99px; background: #ffe0ea; color: #c23a5e; font-weight: 900; font-size: 13px; }
.rank { display: grid; gap: 6px; margin: 8px 0; }
.rk { display: grid; grid-template-columns: 34px 1fr auto auto; gap: 8px; align-items: center; padding: 9px 12px; border-radius: 14px; background: #faf9fd; border: 1px solid #ece8f4; border-left: 5px solid var(--pc); }
.rk.me { background: #f3f0ff; }
.rk i { font-style: normal; font-weight: 900; font-size: 18px; text-align: center; }
.rk b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rk span { font-weight: 900; }
.rk em { font-style: normal; font-size: 12px; font-weight: 800; color: #c98200; min-width: 44px; text-align: right; }
.res-actions .kit-btn { padding: calc(12px * var(--bs)) 14px; font-size: calc(15px * var(--bs)); }

.load-err { position: fixed; left: 50%; top: 40%; transform: translate(-50%, -50%); z-index: 30; padding: 16px 20px; border-radius: 18px; background: #fff; box-shadow: 0 10px 30px rgba(60, 50, 110, .2); text-align: center; font-weight: 800; line-height: 1.6; }

/* 휴대폰 가로: 단추 판을 오른쪽에 */
@media (orientation: landscape) and (max-height: 560px) {
  #home { flex-direction: row; align-items: stretch; gap: 12px; padding-top: calc(env(safe-area-inset-top) + 52px); }
  .hero { position: absolute; left: 16px; top: calc(env(safe-area-inset-top) + 54px); }
  .spacer { min-height: 0; }
  .panel { width: min(400px, 52vw); max-height: none; margin: 0; align-self: stretch; }
  .hud b { font-size: 44px; }
  .hud { top: calc(env(safe-area-inset-top) + 8px); }
  .rivals { grid-template-columns: repeat(3, 76px); width: auto; }
  .rv canvas { height: 40px; }
  .count { font-size: 80px; }
  /* 낮은 가로 화면: 혼자 쌓기 옆에 ⚡ 빠른 대전 (설명 줄은 빼고) → 방 만들기·코드로 참가까지 한 화면에 */
  .panel { grid-template-columns: 1fr 1fr; }
  .panel > * { grid-column: 1 / -1; }
  #soloBtn { grid-row: 1; grid-column: 1; }
  #quickBtn { grid-row: 1; grid-column: 2; justify-content: center; }
  .big.quick small { display: none; }
}
@media (min-width: 900px) and (min-height: 600px) {
  #home { flex-direction: row; align-items: center; padding-left: 40px; padding-right: 40px; }
  .hero { position: absolute; left: 50%; transform: translateX(-50%); top: 70px; }
  .panel { width: 420px; max-height: calc(100vh - 120px); margin: 0 0 0 auto; }
  .spacer { min-height: 0; }
  .rivals { width: 110px; right: 16px; }
  .rv canvas { height: 70px; }
}

/* 좁은 휴대폰: 손님 계정 칸(💾 가입 붙음)이 남은 너비 안에서 줄어들게 → 오른쪽이 잘리지 않음 (2026-10-31) */
@media (max-width: 480px) {
  #accountSlot { min-width: 0; flex: 0 1 auto; }
  #accountSlot .kit-chip { max-width: 100%; }
  #accountSlot .kit-chip button { white-space: nowrap; }
  #accountSlot .kc-me { min-width: 0; flex: 0 1 auto; padding: 5px 7px 5px 10px; }
  #accountSlot .kc-me b, #accountSlot .kc-me span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #accountSlot .kc-rank { flex: none; padding: 0 6px; }
  #accountSlot .kc-shop, #accountSlot .kc-save { flex: none; padding: 0 8px; }
}
@media (max-width: 380px) { .top { gap: 6px; } .top h1 { font-size: 17px; } }

/* ---------- 🎬 첫 화면 배경 (kit/title.css 위에 구름탑 하늘·구름·블록, 2026-11-10) ---------- */
#title { --lt-a: #4fb0ff; --lt-b: #8b7cf6; --lt-ink: #2f3550; --lt-muted: #5f7392; --lt-brand: #3f8fe0; --lt-sh: #5a68d6; --lt-glow: rgba(79, 150, 255, .4); --lt-bgc: #cfeaff;
  background-image: linear-gradient(180deg, #9fd3ff 0%, #cfeaff 45%, #eef8ff 100%); }
#title .lt-o { filter: drop-shadow(0 6px 10px rgba(40, 90, 150, .22)); }
#title .ct-e { font-size: 44px; }
#title .ct-cloud svg { width: 100px; height: 55px; opacity: .9; }
#title .c1 { top: 9%; left: -4%; } #title .c1 svg { width: 130px; height: 71.5px; opacity: .95; }
#title .c2 { top: 22%; right: -3%; }
#title .c3 { bottom: 12%; left: 52%; } #title .c3 svg { width: 150px; height: 82.5px; opacity: .95; }
#title .c4 { top: 4%; left: 46%; --r: 20deg; font-size: 40px; }
#title .c5 { top: 15%; left: 30%; --r: -10deg; font-size: 34px; }
#title .c6 { top: 28%; left: 7%; --r: -8deg; }
#title .c7 { top: 31%; right: 7%; --r: 10deg; }
#title .c8 { bottom: 4%; left: 6%; }
#title .c9 { bottom: 17%; right: 6%; --r: 4deg; }
#title .c10 { bottom: 17%; left: 12%; font-size: 30px; }
@media (orientation: landscape) and (max-height: 500px) {
  #title .ct-e { font-size: 32px; } #title .c4 { left: 30%; } #title .c5 { top: 30%; left: 18%; }
  #title .c6 { top: 50%; left: 4%; } #title .c7 { top: 50%; right: 4%; } #title .c8 { left: 3%; } #title .c9 { right: 4%; bottom: 8%; } #title .c3 { left: 64%; bottom: 4%; }
}
/* 세로 휴대폰: 로켓이 계정 칩 밑에 숨지 않게, 블록·별·구름이 작은 단추와 겹치지 않게 */
@media (orientation: portrait) and (max-width: 600px) {
  #title .c4 { top: 12%; left: 58%; } #title .c9 { bottom: 8%; right: 4%; } #title .c3 { bottom: 2%; left: 46%; } #title .c10 { bottom: auto; top: 40%; left: 4%; }
}
@media (orientation: portrait) and (max-height: 720px) {
  #title .c8 { bottom: 1%; left: 2%; } #title .c8 svg { width: 56px; height: 67px; }
  #title .c9 { bottom: 2%; } #title .c9 svg { width: 60px; height: 45px; } #title .c3 svg { width: 110px; height: 60.5px; }
}
@media (min-width: 900px) and (min-height: 680px) { #title .c3 { left: 68%; bottom: 8%; } }
