@charset "utf-8";

/* =========================================================
 * 스노우볼 꾸미기
 * STEP 1 (.sg_view_deco) : sg_globe_img(스노우볼 이미지) → sg_inner(아이템·눈)
 * STEP 2 (.sg_view_wall) : 월페이퍼 선택 + 완성된 스노우볼 배치
 * STEP 3 (.sg_view_done) : 완성된 월페이퍼 확인 + 다운로드 / 공유하기
 * ========================================================= */
.snow_globe {
    background: #8fa3d4 url("/img/snow-globe/bg.jpg") center center / cover no-repeat;
}
.snow_globe .game_wrap {
    --sg-point: #798CAA;
    --sg-card: #EAF0FD;
    --sg-select: #fff;
    --sg-card-size: calc((min(100vw, 640px) - 54px) / 4);
    --sg-panel-h: calc(101px + var(--sg-card-size) * 1.4 + env(safe-area-inset-bottom));
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 640px;
    height: 100vh;
    height: 100dvh;
    margin: 0 auto;
    overflow: hidden;
    color: #fff;
    -webkit-tap-highlight-color: transparent;
}
.snow_globe *,
.snow_globe *::before,
.snow_globe *::after { box-sizing: border-box; }
.snow_globe button { font-family: inherit; }

/* ---------- 상단 ---------- */
.snow_globe .sg_head {
    flex: 0 0 auto;
    padding: clamp(12px, 4dvh, 40px) 20px 0;
    text-align: center;
    color: #fff;
}
.snow_globe .sg_nav {
    display: flex;
    justify-content: space-between;
}
.snow_globe .sg_nav_btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid #fff;
    border-radius: 50%;
    background: transparent;
    color: #fff;
    cursor: pointer;
}
.snow_globe .sg_nav_btn svg { width: 16px; aspect-ratio: 8 / 16; }
.snow_globe .sg_nav_btn.sg_prev svg { transform: translateX(-1.5px); }
.snow_globe .sg_nav_btn.sg_next svg { transform: translateX(1.5px); }
.snow_globe .sg_title {
    margin: clamp(8px, calc(8dvh - 28px), 44px) 0 0;
    text-align: center;
}
.snow_globe .sg_title span {
    color: #FFF;
    font-size: clamp(18px, 2.9dvh, 26px);
    font-weight: 500;
    line-height: 128%;
    letter-spacing: -0.07em;
    text-transform: uppercase;
}

.snow_globe .sg_desc {
    margin: clamp(6px, calc(4.4dvh - 17px), 22px) 0 0;
    text-align: center;
}
.snow_globe .sg_desc span {
    color: #FFF;
    font-size: clamp(12px, 1.6dvh, 14px);
    font-weight: 300;
    line-height: 150%;
    text-transform: uppercase;
}

.snow_globe .sg_title,
.snow_globe .sg_desc { display: grid; }
.snow_globe .sg_txt { grid-area: 1 / 1; }
.snow_globe .sg_txt[aria-hidden="true"] { visibility: hidden; }

@media (max-height: 600px) {
    .snow_globe .sg_desc { display: none; }
}

/* ---------- 단계별 화면 ---------- */
.snow_globe .sg_view {
    display: none;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
}
.snow_globe .sg_view.is_active { display: flex; }
.snow_globe .sg_view.is_leave_next { animation: sgLeaveNext .28s ease-in both; }
.snow_globe .sg_view.is_leave_prev { animation: sgLeavePrev .28s ease-in both; }
.snow_globe .sg_view.is_enter_next { animation: sgEnterNext .45s cubic-bezier(.2, .7, .3, 1) both; }
.snow_globe .sg_view.is_enter_prev { animation: sgEnterPrev .45s cubic-bezier(.2, .7, .3, 1) both; }
@keyframes sgLeaveNext { to   { opacity: 0; transform: translateX(-24px); } }
@keyframes sgLeavePrev { to   { opacity: 0; transform: translateX(24px); } }
@keyframes sgEnterNext { from { opacity: 0; transform: translateX(24px); } }
@keyframes sgEnterPrev { from { opacity: 0; transform: translateX(-24px); } }

.snow_globe .sg_view.is_enter_next .sg_panel,
.snow_globe .sg_view.is_enter_prev .sg_panel { animation: sgPanelIn .45s cubic-bezier(.2, .7, .3, 1) both; }
@keyframes sgPanelIn { from { transform: translateY(30px); } }

/* ---------- 스노우볼 ---------- */
.snow_globe .sg_stage {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 10px 0;
    container-type: size;
}
.snow_globe .sg_globe {
    position: relative;
    width: min(86cqw, calc(122cqh * 906 / 1173));
    aspect-ratio: 906 / 993;
    user-select: none;
}
.snow_globe .sg_globe.is_shake { animation: sgShake .6s ease-in-out; }

.snow_globe .sg_globe_img {
    position: absolute;
    left: 0;
    top: 0;
    z-index: 1;
    width: 100%;
    height: auto;
    pointer-events: none;
    filter: drop-shadow(0 0 30px rgba(255, 252, 233, .30)) drop-shadow(0 0 30px #FFFCE9);
}

.snow_globe .sg_inner {
    position: absolute;
    z-index: 2;
    left: 11.479%;
    top: 5.740%;
    width: 75.055%;
    aspect-ratio: 1 / 1;
    border-radius: 50%;
    overflow: hidden;
    -webkit-clip-path: circle(50% at 50% 50%);
    clip-path: circle(50% at 50% 50%);
    pointer-events: none;
}
.snow_globe .sg_items {
    position: absolute;
    inset: 0;
}

.snow_globe .sg_item {
    position: absolute;
    height: auto;
    transform: translate(-50%, -100%) scale(.6);
    transform-origin: 50% 100%;
    opacity: 0;
    visibility: hidden;
    transition: opacity .25s ease, transform .35s cubic-bezier(.34, 1.56, .64, 1), visibility 0s .35s;
}
.snow_globe .sg_item.is_on {
    transform: translate(-50%, -100%) scale(1);
    opacity: 1;
    visibility: visible;
    transition: opacity .25s ease, transform .35s cubic-bezier(.34, 1.56, .64, 1), visibility 0s;
}
.snow_globe .sg_snow {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 20;
}

/* ---------- 스노우볼 우측 버튼 ---------- */
.snow_globe .sg_ctrl {
    position: absolute;
    right: 16px;
    bottom: 14%;
    z-index: 5;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.snow_globe .sg_ctrl_btn {
    display: block;
    width: 52px;
    height: 52px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: none;
    cursor: pointer;
    transition: transform .15s, box-shadow .2s;
}
.snow_globe .sg_ctrl_btn img {
    display: block;
    width: 100%;
    height: 100%;
    pointer-events: none;
}
.snow_globe .sg_ctrl_btn:active { transform: scale(.94); }
.snow_globe .sg_ctrl_btn.is_on { box-shadow: 0 0 0 2px #fff, 0 0 12px rgba(255, 255, 255, .8); }

/* ---------- 하단 패널 ---------- */
.snow_globe .sg_panel {
    display: flex;
    flex: 0 0 var(--sg-panel-h);
    flex-direction: column;
    min-height: 0;
    border: 1px solid rgba(255, 255, 255, .9);
    border-bottom: 0;
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    border-radius: 30px 30px 0 0;
    border-top: 1px solid #FFF;
    background: rgba(255, 255, 255, 0.40);
}

/* ---------- 하단 패널 접기 / 펼치기 ---------- */
.snow_globe .sg_panel { overflow: hidden; }
.snow_globe .sg_panel_toggle {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 22px;
    padding: 6px 0 0;
    border: 0;
    background: none;
    color: var(--sg-point);
    cursor: pointer;
    touch-action: none;
}
.snow_globe .sg_panel_toggle svg { transition: transform .35s; }
.snow_globe .sg_panel.is_folded .sg_panel_toggle svg { transform: rotate(180deg); }
.snow_globe .sg_panel_body {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
    transition: opacity .25s;
}
.snow_globe .sg_panel.is_folded .sg_panel_body { opacity: 0; pointer-events: none; }

.snow_globe .sg_deco_panel { transition: flex-basis .45s cubic-bezier(.2, .7, .3, 1); }
.snow_globe .sg_deco_panel.is_folded { flex-basis: calc(34px + env(safe-area-inset-bottom)); }

.snow_globe .sg_wp_panel .sg_panel_body {
    display: grid;
    grid-template-rows: 1fr;
    transition: grid-template-rows .45s cubic-bezier(.2, .7, .3, 1), opacity .25s;
}
.snow_globe .sg_wp_panel .sg_panel_body { overflow: hidden; }
.snow_globe .sg_wp_panel .sg_wp_list {
    min-height: 0;
    transition: padding .45s cubic-bezier(.2, .7, .3, 1);
}
.snow_globe .sg_wp_panel.is_folded .sg_panel_body { grid-template-rows: 0fr; }
.snow_globe .sg_wp_panel.is_folded .sg_wp_list { padding-top: 0; padding-bottom: 0; }

/* ---------- 탭 ---------- */
.snow_globe .sg_tabs {
    display: flex;
    flex: 0 0 auto;
    justify-content: space-between;
    margin: 4px 18px 6px;
    padding: 6px;
    border-radius: 15px;
    background: #fff;
}
.snow_globe .sg_tab {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: transparent;
    cursor: pointer;
    transition: background .2s;
}

.snow_globe .sg_tab_icon {
    display: block;
    width: 46px;
    height: 32px;
    background-color: var(--sg-point);
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
    -webkit-mask-size: contain;
    mask-size: contain;
    pointer-events: none;
    transition: background-color .2s;
}
.snow_globe .sg_tab.is_active {
    background: var(--sg-point);
}
.snow_globe .sg_tab.is_active .sg_tab_icon {
    background-color: #fff;
}

/* ---------- 아이템 목록 ---------- */
.snow_globe .sg_gallery {
    display: grid;
    flex: 1 1 auto;
    grid-template-columns: repeat(4, 1fr);
    align-content: start;
    gap: 10px;
    min-height: 0;
    margin: 0;
    padding: 14px 12px calc(16px + env(safe-area-inset-bottom));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    scrollbar-width: none;
    list-style: none;
}
.snow_globe .sg_gallery::-webkit-scrollbar { display: none; }
.snow_globe .sg_card.is_hide { display: none; }
.snow_globe .sg_card_btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    aspect-ratio: 1 / 1;
    padding: 1%;
    border: 2px solid transparent;
    border-radius: 20px;
    background: var(--sg-card);
    cursor: pointer;
    transition: border-color .2s, transform .15s;
}
.snow_globe .sg_card_btn:active { transform: scale(.96); }
.snow_globe .sg_card_btn img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    pointer-events: none;
}
.snow_globe .sg_card_btn.is_on { border-color: var(--sg-select);  outline: 2px solid #637CD7; }
.snow_globe .sg_card_btn.is_on::after {
    content: "";
    position: absolute;
    top: 6px;
    right: 6px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: url("/img/snow-globe/icon_check.svg") center / contain no-repeat;
}

/* =========================================================
 * STEP 2 : 월페이퍼 배치
 * ========================================================= */
.snow_globe .sg_wp_stage {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
    align-items: center;
    justify-content: center;
    padding: 16px 0;
    container-type: size;
}

/* ---------- 미리보기 ---------- */
.snow_globe .sg_wp_frame {
    position: relative;
    height: min(100cqh, calc(62cqw * 16 / 9));
    aspect-ratio: 9 / 16;
    overflow: hidden;
    border: 2px solid #fff;
    border-radius: 22px;
    background: #c7d2e6;
    box-shadow: 0 10px 30px rgba(20, 40, 90, .25);
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}
.snow_globe .sg_wp_bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
}

/* ---------- 배치된 스노우볼 ---------- */
.snow_globe .sg_wp_globe {
    position: absolute;
    z-index: 2;
    transform: translate(-50%, -50%);
    touch-action: none;
    cursor: grab;
}
.snow_globe .sg_wp_globe.is_dragging { cursor: grabbing; }
.snow_globe .sg_wp_globe_img {
    display: block;
    width: 100%;
    height: auto;
    pointer-events: none;
    -webkit-user-drag: none;
}

/* ---------- 선택 박스 · 핸들 ---------- */
.snow_globe .sg_wp_box,
.snow_globe .sg_wp_dot,
.snow_globe .sg_wp_handle { display: none; }
.snow_globe .sg_wp_globe.is_selected .sg_wp_box,
.snow_globe .sg_wp_globe.is_selected .sg_wp_dot,
.snow_globe .sg_wp_globe.is_selected .sg_wp_handle { display: flex; }
.snow_globe .sg_wp_box {
    position: absolute;
    inset: -4px;
    border: 1px solid rgba(255, 255, 255, .95);
    box-shadow: 0 0 0 .5px rgba(0, 0, 0, .15);
    pointer-events: none;
}
.snow_globe .sg_wp_dot {
    position: absolute;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 0 0 .5px rgba(0, 0, 0, .2);
    pointer-events: none;
}
.snow_globe .sg_wp_dot_tl { left: -7.5px; top: -7.5px; }
.snow_globe .sg_wp_dot_bl { left: -7.5px; bottom: -7.5px; }
.snow_globe .sg_wp_handle {
    position: absolute;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: none;
    cursor: pointer;
    touch-action: none;
}
.snow_globe .sg_wp_handle svg {
    display: block;
    width: 100%;
    height: 100%;
    pointer-events: none;
    filter: drop-shadow(0 1px 2px rgba(0, 20, 50, .3));
}
.snow_globe .sg_wp_handle::before {
    content: "";
    position: absolute;
    inset: -5px;
}

.snow_globe .sg_wp_remove { right: -12px; top: -12px; }
.snow_globe .sg_wp_resize { right: -12px; bottom: -12px; cursor: nwse-resize; }
.snow_globe .sg_wp_hint {
    display: none;
    position: absolute;
    left: 10%;
    right: 10%;
    top: 50%;
    z-index: 1;
    margin: 0;
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(20, 36, 70, .55);
    color: #fff;
    font-size: 12px;
    line-height: 1.4;
    text-align: center;
    word-break: keep-all;
    transform: translateY(-50%);
    pointer-events: none;
}
.snow_globe .sg_wp_frame.is_empty .sg_wp_hint { display: block; }

/* ---------- 월페이퍼 목록 ---------- */
.snow_globe .sg_wp_panel {
    flex: 0 0 auto;
    padding-bottom: env(safe-area-inset-bottom);
    transition: padding-bottom .45s cubic-bezier(.2, .7, .3, 1);
}

.snow_globe .sg_wp_panel.is_folded { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }

.snow_globe .sg_wp_list {
    --wp-gap: 10px;
    display: flex;
    flex: 0 0 auto;
    gap: var(--wp-gap);
    margin: 0;
    padding: clamp(6px, 1.6dvh, 14px) 14px clamp(16px, 3.4dvh, 30px);
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    scroll-padding: 0 14px;
    scrollbar-width: none;
    list-style: none;
}
.snow_globe .sg_wp_list::-webkit-scrollbar { display: none; }
.snow_globe .sg_wp_item {
    flex: 0 0 calc((100% - var(--wp-gap) * 3) / 4);
    padding: 2px;
    scroll-snap-align: start;
}
.snow_globe .sg_wp_card {
    position: relative;
    display: block;
    width: 100%;
    aspect-ratio: 9 / 16;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 20px;
    background: #e3e8f2;
    overflow: hidden;
    cursor: pointer;
    transition: transform .15s;
}
.snow_globe .sg_wp_card:active { transform: scale(.97); }
.snow_globe .sg_wp_card img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
}
.snow_globe .sg_wp_card.is_on { border-color: var(--sg-select); outline: 2px solid #637CD7; }
.snow_globe .sg_wp_card.is_on::after {
    content: "";
    position: absolute;
    top: 6px;
    right: 6px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: url("/img/snow-globe/icon_check.svg") center / contain no-repeat;
}

/* =========================================================
 * STEP 3 : 완성 · 다운로드 / 공유하기
 * ========================================================= */

.snow_globe .sg_next { transition: opacity .3s, visibility .3s; }
.snow_globe .game_wrap[data-step="3"] .sg_next { opacity: 0; visibility: hidden; }

.snow_globe .sg_done_stage {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
    align-items: center;
    justify-content: center;
    padding: clamp(14px, 3dvh, 28px) 0 4px;
    container-type: size;
}
.snow_globe .sg_done_frame {
    height: min(100cqh, calc(70cqw * 16 / 9));
    touch-action: auto;
}
.snow_globe .sg_done_globe {
    position: absolute;
    z-index: 2;
    height: auto;
    transform: translate(-50%, -50%);
    pointer-events: none;
    filter: drop-shadow(0 6px 10px rgba(0, 20, 50, .25));
}
.snow_globe .sg_done_btns {
    display: flex;
    flex: 0 0 auto;
    gap: 8px;
    padding: clamp(14px, 3.4dvh, 30px) 20px calc(clamp(16px, 4dvh, 36px) + env(safe-area-inset-bottom));
}
.snow_globe .sg_done_btn {
    display: flex;
    flex: 1 1 0;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 50px;
    padding: 0;
    border: 0;
    border-radius: 100px;
    background: #142446;
    color: #fff;
    font-size: 16px;
    font-weight: 500;
    letter-spacing: -.02em;
    cursor: pointer;
    transition: transform .1s;
}
.snow_globe .sg_done_btn svg { flex: 0 0 auto; }
.snow_globe .sg_done_btn span {
    color: #FFF;
    font-size: 16px;
    font-weight: 500;
    line-height: 150%;
    text-transform: uppercase;
}
.snow_globe .sg_done_btn:active { transform: scale(.98); }
.snow_globe .sg_view_done.is_enter_next .sg_done_btns { animation: sgPanelIn .45s cubic-bezier(.2, .7, .3, 1) both; }

/* ---------- 애니메이션 ---------- */
@keyframes sgShake {
    0%, 100% { transform: rotate(0); }
    20% { transform: rotate(-4deg); }
    40% { transform: rotate(3deg); }
    60% { transform: rotate(-2deg); }
    80% { transform: rotate(1deg); }
}

/* ---------- 동작 줄이기 ---------- */
@media (prefers-reduced-motion: reduce) {
    .snow_globe .sg_item,
    .snow_globe .sg_item.is_on { transition: none; }
    .snow_globe .sg_view,
    .snow_globe .sg_view .sg_panel { animation: none !important; }
}

/* ---------- 하단 패널 최소 높이 ---------- */
.snow_globe .game_wrap {
    --sg-wp-thumb-h: calc(((min(100vw, 640px) - 58px) / 4 - 4px) * 16 / 9);
}
.snow_globe .sg_deco_panel:not(.is_folded) {
    min-height: calc(101px + var(--sg-card-size) * 1.1 + env(safe-area-inset-bottom));
}
.snow_globe .sg_wp_panel:not(.is_folded) {
    min-height: calc(25px + clamp(6px, 1.6dvh, 14px) + var(--sg-wp-thumb-h) * .6 + env(safe-area-inset-bottom));
}

/* ---------- 낮은 화면 (높이 700px 미만) ---------- */
@media (max-height: 699px) {
    .snow_globe .sg_stage    { flex: 1 1 320px; }
    .snow_globe .sg_wp_stage { flex: 1 1 360px; }
    .snow_globe .sg_deco_panel { flex-shrink: 100; }
    .snow_globe .sg_wp_panel   { flex-shrink: 100; }
}

/* ---------- PC ---------- */
@media screen and (min-width: 450px) {
    .snow_globe { background-image: url(/img/snow-globe/bg_pc.jpg); }
}

/* ---------- 첫 진입 애니메이션 ---------- */
.snow_globe.sg_intro_wait .logo,
.snow_globe.sg_intro_wait .sg_nav_btn,
.snow_globe.sg_intro_wait .sg_title,
.snow_globe.sg_intro_wait .sg_desc,
.snow_globe.sg_intro_wait .sg_globe,
.snow_globe.sg_intro_wait .sg_ctrl_btn,
.snow_globe.sg_intro_wait .sg_deco_panel { opacity: 0; }

.snow_globe.sg_intro .logo { animation: sgIntroFade .6s ease both; }
.snow_globe.sg_intro .sg_nav_btn { animation: sgIntroDown .6s cubic-bezier(.2, .7, .2, 1) both; }
.snow_globe.sg_intro .sg_next { animation-delay: .06s; }
.snow_globe.sg_intro .sg_title { animation: sgIntroText .7s cubic-bezier(.2, .7, .2, 1) .12s both; }
.snow_globe.sg_intro .sg_desc { animation: sgIntroText .7s cubic-bezier(.2, .7, .2, 1) .24s both; }
.snow_globe.sg_intro .sg_globe:not(.is_shake) { animation: sgIntroGlobe .9s cubic-bezier(.2, .8, .2, 1) .3s both; }
.snow_globe.sg_intro .sg_deco_panel { animation: sgIntroPanel .8s cubic-bezier(.2, .7, .2, 1) .5s both; }
.snow_globe.sg_intro .sg_ctrl_btn { animation: sgIntroPop .5s cubic-bezier(.34, 1.56, .64, 1) .85s both; }
.snow_globe.sg_intro .sg_btn_snow { animation-delay: .93s; }

@keyframes sgIntroFade  { from { opacity: 0; } }
@keyframes sgIntroDown  { from { opacity: 0; transform: translateY(-10px); } }
@keyframes sgIntroText  { from { opacity: 0; transform: translateY(10px); filter: blur(6px); } }
@keyframes sgIntroGlobe { from { opacity: 0; transform: translateY(30px) scale(.9); } }
@keyframes sgIntroPanel { from { opacity: 0; transform: translateY(100%); } }
@keyframes sgIntroPop   { from { opacity: 0; transform: scale(.5); } }