/* 기본 폰트 설정 */
@font-face {
    font-family: 'KyoboHandwriting';
    src: url('font/KyoboHandwriting2019.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

/* 리셋 및 기본 스타일 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    /* 기준 해상도 */
    --base-width: 640;
    --base-height: 1384;
    /* 실제 뷰포트 대비 스케일 */
    --scale: min(100vw / var(--base-width), 100vh / var(--base-height));
    /* 640px 기준 비율 계산용 */
    --vw-unit: min(100vw, 640px);
}

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, sans-serif;
}

body {
    background: #0a0a1a;
    display: flex;
    justify-content: center;
}

#app {
    width: 640px;
    max-width: 100vw;
    height: 100%;
    position: relative;
    overflow: hidden;
}

/* 페이지 기본 스타일 */
.page {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    overflow-y: auto;
    overflow-x: hidden;
}

.page.active {
    display: block;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.background {
    position: absolute;
    top: 0;
    left: 0;
    width: 640px;
    max-width: 100vw;
    height: auto;
    min-height: 100%;
    z-index: 0;
}

.bg-image {
    width: 640px;
    max-width: 100vw;
    height: auto;
    display: block;
}

/* ==================== 페이지 1: 메인 ==================== */
/* 이미지 크기 기준: 640 x 1384 - 모든 위치는 이 비율 기준 */
.page-1 {
    position: relative;
}

.page-1 .background {
    position: relative;
    width: 640px;
    max-width: 100vw;
    margin: 0 auto;
    /* 높이는 이미지 로드 후 JavaScript로 설정 */
    /* 기본 aspect-ratio로 초기 높이 설정 (640:1384) */
    aspect-ratio: 640 / 1384;
    min-height: 0;
}

.page-1 .bg-image {
    display: block;
    width: 100%;
    height: auto;
    position: relative;
    /* 이미지가 컨테이너를 채우도록 */
    object-fit: contain;
}

/* 하늘별 이미지 - 배경 이미지 상단 정렬 */
.sky-stars {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1;
    pointer-events: none;
}

.sky-stars img {
    width: 100%;
    height: auto;
    display: block;
    animation: skyStarsOpacity 3s ease-in-out infinite;
}

@keyframes skyStarsOpacity {

    0%,
    100% {
        opacity: 0.3;
    }

    50% {
        opacity: 1;
    }
}

/* 하늘별 반짝임 글로우 효과들 */
.sky-stars::before,
.sky-stars::after {
    content: '';
    position: absolute;
    pointer-events: none;
}

.sky-stars::before {
    top: 10%;
    left: 15%;
    width: calc(60 / 640 * 100%);
    max-width: 60px;
    aspect-ratio: 1;
    background: radial-gradient(circle, rgba(255, 240, 150, 0.9) 0%, rgba(255, 220, 120, 0.6) 30%, rgba(255, 200, 80, 0.3) 60%, transparent 80%);
    border-radius: 50%;
    animation: skyStarGlow1 2s ease-in-out infinite;
    filter: blur(4px);
    z-index: 2;
}

.sky-stars::after {
    top: 25%;
    right: 20%;
    width: calc(45 / 640 * 100%);
    max-width: 45px;
    aspect-ratio: 1;
    background: radial-gradient(circle, rgba(255, 230, 140, 0.85) 0%, rgba(255, 210, 110, 0.65) 30%, rgba(255, 190, 70, 0.35) 60%, transparent 80%);
    border-radius: 50%;
    animation: skyStarGlow2 2.5s ease-in-out infinite;
    animation-delay: 0.5s;
    filter: blur(3px);
    z-index: 2;
}

/* 하늘별 추가 글로우 효과들 */
.sky-star-glow-1,
.sky-star-glow-2,
.sky-star-glow-3,
.sky-star-glow-4,
.sky-star-glow-5 {
    position: absolute;
    pointer-events: none;
    border-radius: 50%;
    filter: blur(3px);
    z-index: 2;
}

.sky-star-glow-1 {
    top: 5%;
    left: 30%;
    width: calc(50 / 640 * 100%);
    max-width: 50px;
    aspect-ratio: 1;
    background: radial-gradient(circle, rgba(255, 235, 145, 0.9) 0%, rgba(255, 215, 115, 0.7) 30%, rgba(255, 195, 75, 0.4) 60%, transparent 80%);
    animation: skyStarGlow3 1.8s ease-in-out infinite;
    animation-delay: 0.3s;
}

.sky-star-glow-2 {
    top: 15%;
    right: 25%;
    width: calc(40 / 640 * 100%);
    max-width: 40px;
    aspect-ratio: 1;
    background: radial-gradient(circle, rgba(255, 225, 135, 0.88) 0%, rgba(255, 205, 105, 0.68) 30%, rgba(255, 185, 65, 0.38) 60%, transparent 80%);
    animation: skyStarGlow4 2.2s ease-in-out infinite;
    animation-delay: 0.7s;
}

.sky-star-glow-3 {
    top: 8%;
    left: 50%;
    width: calc(35 / 640 * 100%);
    max-width: 35px;
    aspect-ratio: 1;
    background: radial-gradient(circle, rgba(255, 245, 155, 0.92) 0%, rgba(255, 225, 125, 0.72) 30%, rgba(255, 205, 85, 0.42) 60%, transparent 80%);
    animation: skyStarGlow5 1.6s ease-in-out infinite;
    animation-delay: 1s;
}

.sky-star-glow-4 {
    top: 20%;
    left: 10%;
    width: calc(55 / 640 * 100%);
    max-width: 55px;
    aspect-ratio: 1;
    background: radial-gradient(circle, rgba(255, 238, 142, 0.87) 0%, rgba(255, 218, 112, 0.67) 30%, rgba(255, 198, 72, 0.37) 60%, transparent 80%);
    animation: skyStarGlow6 2.4s ease-in-out infinite;
    animation-delay: 0.4s;
}

.sky-star-glow-5 {
    top: 12%;
    right: 10%;
    width: calc(42 / 640 * 100%);
    max-width: 42px;
    aspect-ratio: 1;
    background: radial-gradient(circle, rgba(255, 232, 138, 0.86) 0%, rgba(255, 212, 108, 0.66) 30%, rgba(255, 192, 68, 0.36) 60%, transparent 80%);
    animation: skyStarGlow7 1.9s ease-in-out infinite;
    animation-delay: 0.8s;
}

@keyframes skyStarGlow1 {

    0%,
    100% {
        transform: scale(0.6);
        opacity: 0.4;
        box-shadow: 0 0 15px rgba(255, 220, 120, 0.4);
    }

    50% {
        transform: scale(1.3);
        opacity: 1;
        box-shadow: 0 0 35px rgba(255, 220, 120, 0.7);
    }
}

@keyframes skyStarGlow2 {

    0%,
    100% {
        transform: scale(0.7);
        opacity: 0.5;
        box-shadow: 0 0 18px rgba(255, 210, 110, 0.45);
    }

    50% {
        transform: scale(1.4);
        opacity: 1;
        box-shadow: 0 0 38px rgba(255, 210, 110, 0.75);
    }
}

@keyframes skyStarGlow3 {

    0%,
    100% {
        transform: scale(0.65);
        opacity: 0.45;
        box-shadow: 0 0 16px rgba(255, 215, 115, 0.42);
    }

    50% {
        transform: scale(1.35);
        opacity: 1;
        box-shadow: 0 0 36px rgba(255, 215, 115, 0.72);
    }
}

@keyframes skyStarGlow4 {

    0%,
    100% {
        transform: scale(0.7);
        opacity: 0.4;
        box-shadow: 0 0 14px rgba(255, 205, 105, 0.4);
    }

    50% {
        transform: scale(1.5);
        opacity: 1;
        box-shadow: 0 0 40px rgba(255, 205, 105, 0.8);
    }
}

@keyframes skyStarGlow5 {

    0%,
    100% {
        transform: scale(0.6);
        opacity: 0.5;
        box-shadow: 0 0 17px rgba(255, 225, 125, 0.48);
    }

    50% {
        transform: scale(1.3);
        opacity: 1;
        box-shadow: 0 0 37px rgba(255, 225, 125, 0.78);
    }
}

@keyframes skyStarGlow6 {

    0%,
    100% {
        transform: scale(0.65);
        opacity: 0.43;
        box-shadow: 0 0 19px rgba(255, 218, 112, 0.44);
    }

    50% {
        transform: scale(1.4);
        opacity: 1;
        box-shadow: 0 0 39px rgba(255, 218, 112, 0.74);
    }
}

@keyframes skyStarGlow7 {

    0%,
    100% {
        transform: scale(0.7);
        opacity: 0.46;
        box-shadow: 0 0 15px rgba(255, 212, 108, 0.43);
    }

    50% {
        transform: scale(1.35);
        opacity: 1;
        box-shadow: 0 0 38px rgba(255, 212, 108, 0.73);
    }
}

/* 은하수빛 효과 - 72,345,567,755 영역 기준 (640x1384 이미지) - bg-image 기준 */
.milkyway {
    position: absolute;
    top: calc((345 / 1384) * 100%);
    left: calc((72 / 640) * 100%);
    width: calc((567 - 72) / 640 * 100%);
    z-index: 2;
    pointer-events: none;
    opacity: 0.8;
    animation: milkywayGlow 3s ease-in-out infinite;
}

.milkyway img {
    width: 100%;
    height: auto;
}

@keyframes milkywayGlow {

    0%,
    100% {
        opacity: 0.3;
    }

    50% {
        opacity: 1;
    }
}

/* 별 반짝임 영역 - 274,394,371,494 (별의 중심) - bg-image 기준 */
.star-area {
    position: absolute;
    top: calc((394 / 1384) * 100%);
    left: calc((271 / 640) * 100%);
    width: calc((371 - 274) / 640 * 100%);
    height: calc((494 - 394) / 1384 * 100%);
    z-index: 3;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.star-glow {
    position: absolute;
    width: calc(50 / 640 * 100vw);
    max-width: 50px;
    aspect-ratio: 1;
    background: radial-gradient(circle, rgba(255, 223, 128, 0.95) 0%, rgba(255, 200, 100, 0.7) 25%, rgba(255, 180, 50, 0.3) 50%, transparent 70%);
    border-radius: 50%;
    animation: starPulse 1.5s ease-in-out infinite;
    filter: blur(3px);
}

.star-glow-2 {
    width: calc(40 / 640 * 100vw);
    max-width: 40px;
    top: -10px;
    left: 10px;
    animation: starPulse 2s ease-in-out infinite;
    animation-delay: 0.3s;
    background: radial-gradient(circle, rgba(255, 240, 150, 0.9) 0%, rgba(255, 220, 120, 0.6) 25%, rgba(255, 200, 80, 0.3) 50%, transparent 70%);
}

.star-glow-3 {
    width: calc(35 / 640 * 100vw);
    max-width: 35px;
    top: 5px;
    right: 15px;
    animation: starPulse 1.8s ease-in-out infinite;
    animation-delay: 0.6s;
    background: radial-gradient(circle, rgba(255, 230, 140, 0.85) 0%, rgba(255, 210, 110, 0.65) 25%, rgba(255, 190, 70, 0.35) 50%, transparent 70%);
}

.star-glow-4 {
    width: calc(45 / 640 * 100vw);
    max-width: 45px;
    bottom: -5px;
    left: -5px;
    animation: starPulse 2.2s ease-in-out infinite;
    animation-delay: 0.9s;
    background: radial-gradient(circle, rgba(255, 235, 145, 0.9) 0%, rgba(255, 215, 115, 0.7) 25%, rgba(255, 195, 75, 0.4) 50%, transparent 70%);
}

.star-glow-5 {
    width: calc(30 / 640 * 100vw);
    max-width: 30px;
    bottom: 10px;
    right: -10px;
    animation: starPulse 1.6s ease-in-out infinite;
    animation-delay: 1.2s;
    background: radial-gradient(circle, rgba(255, 225, 135, 0.88) 0%, rgba(255, 205, 105, 0.68) 25%, rgba(255, 185, 65, 0.38) 50%, transparent 70%);
}

@keyframes starPulse {

    0%,
    100% {
        transform: scale(0.7);
        opacity: 0.5;
        box-shadow: 0 0 20px rgba(255, 215, 0, 0.3);
    }

    50% {
        transform: scale(1.4);
        opacity: 1;
        box-shadow: 0 0 40px rgba(255, 215, 0, 0.6);
    }
}

@keyframes clickPulse {

    0%,
    100% {
        transform: translateX(-50%) scale(0.85);
        opacity: 0.6;
    }

    50% {
        transform: translateX(-50%) scale(1.15);
        opacity: 1;
    }
}

/* 메인 텍스트 영역 - 43,1140,585,1200 - bg-image 기준 */
.main-text-area {
    position: absolute;
    top: calc((1077 / 1384) * 97%);
    left: calc((43 / 640) * 100%);
    width: calc((585 - 43) / 640 * 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 5;
    animation: textBounce 2s ease-in-out infinite;
    /* 이미지 기준 위치 고정 */
    pointer-events: none;
}

.main-text-img {
    width: 100%;
    height: auto;
}

.arrow-down {
    margin-top: 8px;
    color: #ecca85;
    /* [폰트-화살표] 기본 12px */
    font-size: clamp(10px, calc(12 / 640 * 100vw), 12px);
    animation: arrowBounce 1s ease-in-out infinite;
}

@keyframes textBounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-4px);
    }
}

@keyframes arrowBounce {

    0%,
    100% {
        transform: translateY(0);
        opacity: 0.4;
    }

    50% {
        transform: translateY(4px);
        opacity: 1;
    }
}

/* 새해소원보내기 버튼 - 38,1225,602,1318 - bg-image 기준 */
.main-button-area {
    position: absolute;
    top: calc((1197 / 1384) * 100%);
    left: calc((38 / 640) * 100%);
    width: calc((602 - 38) / 640 * 100%);
    z-index: 5;
    /* 이미지 기준 위치 고정 */
}

.main-button {
    width: 100%;
    height: auto;
    cursor: pointer;
    transition: transform 0.2s ease, filter 0.2s ease;
}

.main-button:hover {
    transform: scale(1.02);
}

.main-button:active {
    transform: scale(0.98);
}

/* ==================== 페이지 2: 닉네임 입력 ==================== */
.page-2 .background {
    position: fixed;
    width: 640px;
    max-width: 100vw;
    left: 50%;
    transform: translateX(-50%);
}

.page-2 .bg-image {
    width: 640px;
    max-width: 100vw;
    height: 100vh;
    object-fit: cover;
}

.input-box-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, 100%);
    width: 85%;
    max-width: 540px;
    z-index: 10;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.input-box-container.show {
    transform: translate(-50%, -50%);
    opacity: 1;
}

.input-box-img {
    width: 100%;
    height: auto;
}

.close-btn {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 36px;
    height: 36px;
    background: rgba(30, 40, 70, 0.9);
    border: 2px solid rgba(200, 180, 140, 0.5);
    border-radius: 50%;
    color: #c8b48c;
    /* [폰트-닫기버튼] 기본 18px */
    font-size: clamp(14px, calc(18 / 640 * 100vw), 18px);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
    transition: all 0.2s ease;
}

.close-btn:hover {
    background: rgba(50, 60, 90, 0.95);
    transform: scale(1.1);
}

/* 닉네임 입력 필드 - 박스 이미지 기준 (616x616 이미지) */
/* 입력 영역: 104,234,510,311 좌표 기준 */
.nickname-input-area {
    position: absolute;
    top: calc((234 / 616) * 100%);
    left: calc((104 / 616) * 100%);
    width: calc((510 - 104) / 616 * 100%);
    height: calc((311 - 234) / 616 * 100%);
    display: flex;
    align-items: center;
    gap: 8px;
}

.nickname-input-area input {
    width: 100%;
    background: transparent;
    border: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.3);
    outline: none;
    color: #ffffff;
    font-family: 'KyoboHandwriting', serif;
    font-size: clamp(22px, 5.64vw, 32px);
    text-align: left;
    padding: 0px 4px;
}

.nickname-input-area input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.clear-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    background: rgba(100, 100, 120, 0.8);
    border: none;
    border-radius: 50%;
    color: #fff;
    /* [폰트-삭제버튼] 기본 12px */
    font-size: clamp(10px, calc(12 / 640 * 100vw), 12px);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.clear-btn.show {
    opacity: 1;
}

/* 닉네임 제출 버튼 - 박스 이미지 기준 (616x616) 77,374,540,475 */
.submit-btn-area-1 {
    position: absolute;
    top: calc((374 / 616) * 100%);
    left: calc((77 / 616) * 100%);
    width: calc((540 - 77) / 616 * 100%);
    height: calc((475 - 374) / 616 * 100%);
}

.submit-btn {
    width: 100%;
    height: 100%;
    background: transparent;
    border: none;
    cursor: pointer;
}

/* ==================== 페이지 3: 소원 입력 ==================== */
.page-3 {
    container-type: inline-size;
}

.page-3 .background {
    position: fixed;
    width: 640px;
    max-width: 100vw;
    left: 50%;
    transform: translateX(-50%);
}

.page-3 .bg-image {
    width: 640px;
    max-width: 100vw;
    height: 100vh;
    object-fit: cover;
}

.input-box-container-2 {
    position: absolute;
    top: 40px;
    left: 50%;
    transform: translateX(-50%);
    width: 640px;
    max-width: 90vw;
    z-index: 10;
    animation: slideUp 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

@keyframes slideUp {
    from {
        transform: translateX(-50%) translateY(100%);
        opacity: 0;
    }

    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

.close-btn-2 {
    top: 12px;
    right: 12px;
}

.input-box-img-2 {
    width: 100%;
    height: auto;
}

/* 소원 입력 필드 - 박스 이미지 기준 (616x1243 이미지) */
/* 두루마리 내 입력 영역 - 416,158 ~ 630,458 좌표 기준 */
.wish-input-area {
    position: absolute;
    top: calc((425 / 1243) * 100%);
    left: calc((158 / 616) * 100%);
    width: calc((465 - 158) / 616 * 100%);
    height: calc((725 - 416) / 1243 * 100%);
}

.wish-input-area textarea {
    width: 100%;
    height: 100%;
    background: transparent;
    border: none;
    outline: none;
    color: #5a4a3a;
    font-family: 'KyoboHandwriting', serif;
    font-size: clamp(2px, calc(28 / 640 * 100vw), 28px);
    line-height: 1.95;
    resize: none;
    padding: 0;
    margin-top: 0;
}

.wish-input-area textarea::placeholder {
    color: rgba(90, 74, 58, 0.4);
}

/* 소원 제출 버튼 - 박스 이미지 기준 (616x1243) 111,988,503,1096 */
.submit-btn-area-2 {
    position: absolute;
    top: calc((1013 / 1243) * 100%);
    left: calc((111 / 616) * 100%);
    width: calc((503 - 111) / 616 * 100%);
    height: calc((1096 - 988) / 1243 * 100%);
}

.submit-btn-2 {
    width: 100%;
    height: 100%;
    background: transparent;
    border: none;
    cursor: pointer;
}

/* ==================== 페이지 4: GIF 재생 ==================== */
.page-4 {
    background: #0a0a1a;
}

.gif-container {
    width: 640px;
    max-width: 100vw;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
}

.motion-gif {
    width: 640px;
    max-width: 100vw;
    height: auto;
}

/* ==================== 페이지 5: 결과 페이지 ==================== */
/* 이미지 크기 기준: 640 x 3500 (추정) - 모든 위치는 이 비율 기준 */
.page-5 {
    overflow-y: auto;
    overflow-x: hidden;
}

.page-5 .background {
    position: relative;
    width: 640px;
    max-width: min(100vw, 640px);
    margin: 0 auto;
    /* 이미지 비율 유지를 위한 컨테이너 */
}

.page-5 .bg-image {
    display: block;
    width: 100%;
    height: auto;
}

.close-btn-result {
    position: absolute;
    /* 538,197,572,232 기준 - 640x3471 이미지 */
    top: calc((100 / 3471) * 100%);
    right: calc((640 - 572) / 640 * 100%);
    z-index: 20;
    width: calc((572 - 538) / 640 * 100%);
    aspect-ratio: 1;
    background: transparent;
    border: none;
    cursor: pointer;
    color: transparent;
    font-size: 0;
    display: block;
}

/* 두루마리 결과 영역 - 57,254,589,945 기준 (640x3471) */
.scroll-result-area {
    position: absolute;
    top: calc((1585 / 3471) * 100%);
    left: calc((57 / 640) * 100%);
    width: calc((620 - 68) / 640 * 100%);
    z-index: 5;
}

.scroll-result-area canvas {
    width: 100%;
    height: auto;
    border-radius: 8px;
}

/* 저장/링크 버튼 - 저장: 91,1049,315,1128 / 링크: 328,1051,550,1127 (640x3471) */
.action-buttons {
    position: absolute;
    top: calc((2346 / 3471) * 100%);
    left: calc((91 / 640) * 100%);
    width: calc((550 - 91) / 640 * 100%);
    height: calc((1128 - 1049) / 3471 * 100%);
    display: flex;
    gap: calc(13 / 640 * 100%);
    z-index: 5;
}

.save-btn {
    /* 91,1049,315,1128 영역 - 저장하기 */
    width: calc((315 - 91) / (550 - 91) * 100%);
    height: 100%;
    background: transparent;
    border: none;
    cursor: pointer;
}

.link-btn {
    /* 328,1051,550,1127 영역 - 링크복사 */
    width: calc((550 - 328) / (550 - 91) * 100%);
    height: 100%;
    background: transparent;
    border: none;
    cursor: pointer;
}

/* 제품 갤러리 - 83,1716,559,2039 (640x3471) */
.product-gallery {
    position: absolute;
    top: calc((556 / 3471) * 100%);
    left: calc((83 / 640) * 100%);
    width: calc((559 - 83) / 640 * 100%);
    height: calc((2039 - 1716) / 3471 * 100%);
    z-index: 5;
    min-height: min(calc((2039 - 1716) / 640 * 100vw), calc((2039 - 1716) / 640 * 640px));
    display: flex;
    align-items: center;
    justify-content: center;
}

.gallery-container {
    position: relative;
    width: 100%;
    height: 100%;
    padding: clamp(14px, calc(18 / 640 * 100vw), 22px);
    border-radius: 18px;
    background: radial-gradient(circle at 50% 25%, rgba(255, 211, 144, 0.12) 0%, rgba(27, 30, 62, 0.92) 55%, rgba(10, 12, 26, 0.96) 100%);
    box-shadow:
        0 20px 38px rgba(0, 0, 0, 0.45),
        0 0 0 1.5px rgba(255, 210, 140, 0.35),
        0 0 28px rgba(255, 196, 120, 0.3);
    overflow: hidden;
}

.gallery-track {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    height: 100%;
    z-index: 1;
    display: flex;
    transition: transform 0.3s ease-in-out;
    will-change: transform;
    align-items: center;
    border-radius: 18px;
    overflow: hidden;
    /* 너비는 JavaScript에서 동적으로 설정 (아이템 개수 * 100%) */
}

.gallery-item {
    flex-shrink: 0;
    /* width는 JavaScript에서 동적으로 설정 */
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
}

.gallery-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: clamp(32px, calc(38 / 640 * 100vw), 40px);
    height: clamp(32px, calc(38 / 640 * 100vw), 40px);
    background: rgba(12, 14, 30, 0.7);
    border: 1px solid rgba(255, 206, 130, 0.4);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: all 0.2s ease;
    user-select: none;
    padding: 0;
    box-shadow:
        0 8px 14px rgba(0, 0, 0, 0.35),
        0 0 10px rgba(255, 206, 130, 0.28);
}

.gallery-btn::before {
    content: '';
    width: 0;
    height: 0;
    border-style: solid;
}

.gallery-btn-prev {
    left: clamp(6px, calc(10 / 640 * 100vw), 14px);
}

.gallery-btn-prev::before {
    border-width: 6px 9px 6px 0;
    border-color: transparent rgba(255, 230, 180, 0.9) transparent transparent;
    margin-left: -2px;
}

.gallery-btn-next {
    right: clamp(6px, calc(10 / 640 * 100vw), 14px);
}

.gallery-btn-next::before {
    border-width: 6px 0 6px 9px;
    border-color: transparent transparent transparent rgba(255, 230, 180, 0.9);
    margin-right: -2px;
}

.gallery-btn:hover {
    background: rgba(18, 22, 50, 0.85);
    transform: translateY(-50%) scale(1.05);
    box-shadow:
        0 10px 18px rgba(0, 0, 0, 0.4),
        0 0 12px rgba(255, 210, 150, 0.35);
}

.gallery-btn:active {
    transform: translateY(-50%) scale(0.95);
    box-shadow:
        0 5px 10px rgba(0, 0, 0, 0.35),
        0 0 6px rgba(255, 210, 150, 0.25);
}

.gallery-btn:disabled,
.gallery-btn.hidden {
    display: none;
}

/* 응모하기 버튼 - 128,2110,512,2213 (640x3471) */
.apply-btn-area {
    position: absolute;
    top: calc((967 / 3471) * 100%);
    left: calc((128 / 640) * 100%);
    width: calc((512 - 128) / 640 * 100%);
    height: calc((2213 - 2110) / 3471 * 100%);
    z-index: 5;
    display: flex;
    align-items: center;
}

.apply-btn {
    width: 100%;
    height: 100%;
    background: transparent;
    border: none;
    cursor: pointer;
}

/* 복사하기(해시태그) 버튼 (640x3471) */
.copy-btn-area {
    position: absolute;
    top: calc((2007 / 3470) * 136%);
    left: calc((340 / 640) * 100%);
    width: calc((226 - 124) / 640 * 100%);
    z-index: 5;
}

.copy-btn {
    width: 100%;
    height: calc(50 / 640 * 100vw);
    max-height: 50px;
    background: transparent;
    border: none;
    cursor: pointer;
}

/* 이벤트 정보 - 78,2243,461,2311 (640x3471) */
.event-info {
    position: absolute;
    top: calc((2243 / 3471) * 100%);
    left: calc((78 / 640) * 100%);
    width: calc((461 - 78) / 640 * 100%);
    z-index: 5;
    font-family: 'Pretendard', sans-serif;
    font-weight: 300;
    /* [폰트-이벤트정보] 5.5pt = 약 7.3px */
    font-size: clamp(6px, calc(24 / 640 * 100vw), 16px);
    color: rgba(255, 255, 255, 0.8);
    line-height: 1.5;
    text-align: left;
}

/* 유의사항 - 77,3150,563,3377 (640x3471) */
.notice-text {
    position: absolute;
    top: calc((3150 / 3471) * 100%);
    left: calc((77 / 640) * 100%);
    width: calc((563 - 77) / 640 * 100%);
    z-index: 5;
    font-family: 'Pretendard', sans-serif;
    font-weight: 300;
    /* [폰트-유의사항] 3.95pt = 약 5.3px */
    font-size: clamp(6px, calc(14 / 640 * 100vw), 14px);
    color: rgba(255, 255, 255, 0.6);
    line-height: 1.7;
    text-align: left;
}

/* ==================== 페이지 6: 코멘트 페이지 ==================== */
/* 이미지 크기 기준: 640 x 1384 - 모든 위치는 이 비율 기준 */
.page-6 {
    position: relative;
    container-type: inline-size;
    /* 높이는 JavaScript로 이미지 높이에 맞춰 설정 */
    min-height: 0;
}

.page-6 .background {
    position: relative;
    width: 640px;
    max-width: 100vw;
    margin: 0 auto;
    /* 높이는 이미지 로드 후 JavaScript로 설정 */
    /* 기본 aspect-ratio로 초기 높이 설정 (640:1384) */
    aspect-ratio: 640 / 1384;
    min-height: 0;
}

.page-6 .bg-image {
    display: block;
    width: 100%;
    height: auto;
    position: relative;
    object-fit: contain;
    /* 모든 absolute 요소들이 이 이미지를 기준으로 위치 */
}

.close-btn-comment {
    position: absolute;
    top: calc((197 / 1384) * 100%);
    right: calc((640 - 573) / 640 * 100%);
    z-index: 5;
    width: calc(30 / 640 * 100vw);
    height: calc(30 / 640 * 100vw);
    aspect-ratio: 1;
}

/* 소원 갯수 - 226,313,375,360 위치 (640x1384 이미지 기준) - bg-image 기준 */
.wish-count-area {
    position: absolute;
    top: calc((314 / 1384) * 100%);
    left: calc((233 / 640) * 100%);
    width: calc((375 - 233) / 640 * 100%);
    height: calc((375 - 314) / 1384 * 100%);
    z-index: 5;
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

.wish-count {
    font-family: 'Noto Serif KR', 'Batang', serif;
    font-size: clamp(2px, calc(26px / 640px * 100cqw), 26px);
    color: #f6f6f6;
    text-shadow: 0 0 24px rgb(89 66 28);
    letter-spacing: 1px;
    font-weight: bold;
}

/* 소원 목록 컨테이너 - 79,495,561,1286 위치 기준 - bg-image 기준 */
.wish-list-container {
    position: absolute;
    /* 이미지 기준 79,495,561,1286 좌표 */
    top: calc((495 / 1384) * 100%);
    left: calc((79 / 640) * 100%);
    width: calc((561 - 79) / 640 * 100%);
    max-width: 482px;
    /* 소원 목록 영역 높이 (1286 - 495) */
    height: calc((1286 - 495) / 1384 * 100%);
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 5;
    scrollbar-width: thin;
    scrollbar-color: rgba(200, 180, 140, 0.3) transparent;
}

.wish-list-container::-webkit-scrollbar {
    width: 4px;
}

.wish-list-container::-webkit-scrollbar-track {
    background: transparent;
}

.wish-list-container::-webkit-scrollbar-thumb {
    background: rgba(200, 180, 140, 0.3);
    border-radius: 2px;
}

.wish-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 10px 5px;
}

/* 소원 박스 */
.wish-box {
    background: rgba(30, 40, 70, 0.85);
    border: 1px solid rgba(200, 180, 140, 0.3);
    border-radius: 8px;
    padding: 16px 20px;
    position: relative;
}

.wish-box::before,
.wish-box::after {
    content: '✦';
    position: absolute;
    color: #FFD700;
    /* [폰트-별장식] 기본 10px */
    font-size: clamp(8px, calc(10 / 640 * 100vw), 10px);
    opacity: 0.7;
}

.wish-box::before {
    top: 12px;
    left: 12px;
}

.wish-box::after {
    bottom: 12px;
    right: 12px;
}

.wish-box-header {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 10px;
}

.wish-nickname {
    font-family: 'Pretendard', sans-serif;
    font-weight: 600;
    /* [폰트-소원닉네임] 기본 14px */
    font-size: clamp(11px, calc(14 / 640 * 100vw), 14px);
    color: #fff;
}

.wish-time {
    font-family: 'Pretendard', sans-serif;
    font-weight: 300;
    /* [폰트-소원시간] 기본 11px */
    font-size: clamp(9px, calc(11 / 640 * 100vw), 11px);
    color: rgba(255, 255, 255, 0.5);
}

.wish-content {
    font-family: 'Pretendard', sans-serif;
    font-weight: 400;
    /* [폰트-소원내용] 기본 15px */
    font-size: clamp(12px, calc(15 / 640 * 100vw), 15px);
    color: rgba(255, 255, 255, 0.9);
    line-height: 1.5;
    display: -webkit-box;
/*     -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis; */
}

/* 로딩 스피너 */
.loading-spinner {
    display: flex;
    justify-content: center;
    padding: 20px;
}

.spinner {
    width: 30px;
    height: 30px;
    border: 3px solid rgba(200, 180, 140, 0.2);
    border-top-color: #FFD700;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ==================== 토스트 메시지 ==================== */
.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: rgba(30, 40, 70, 0.95);
    border: 1px solid rgba(200, 180, 140, 0.4);
    color: #fff;
    padding: 14px 28px;
    border-radius: 30px;
    font-family: 'Pretendard', sans-serif;
    /* [폰트-토스트] 기본 14px */
    font-size: clamp(12px, calc(14 / 640 * 100vw), 14px);
    z-index: 1000;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* ==================== 반응형 ==================== */
/* 640px 기준 비율 계산 - calc() 사용 */

/* 640px 이하에서 배경/컨테이너 100vw로 확장 */
@media (max-width: 640px) {
    #app {
        width: 100vw;
    }

    .background {
        width: 100vw;
    }

    .bg-image {
        width: 100vw;
    }

    /* 입력박스 컨테이너 */
    .input-box-container {
        width: 90%;
        max-width: 90%;
    }

    .wish-box {
        padding: calc(16px * (100vw / 640)) calc(20px * (100vw / 640));
    }

    .close-btn {
        width: calc(36px * (100vw / 640));
        height: calc(36px * (100vw / 640));
    }
}

@media (max-width: 480px) {
    .product-item {
        height: 80%;
    }
}

/* 결과 페이지 스크롤 설정은 페이지 5 섹션에서 정의됨 */

/* 페이지 6 (코멘트) 스크롤 설정 */
.page-6 {
    overflow-y: auto;
    overflow-x: hidden;
}