/* Christmas Tree 2025 - v39 */
:root {
    --primary-red: #DC3545;
    --primary-green: #198754;
    --gold: #FFD700;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    height: 100%;
    height: 100dvh;
}

body {
    font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
    overflow-x: hidden;
    color: #fff;
}

/* 시간대별 배경 */
body.morning { background: linear-gradient(180deg, #87CEEB 0%, #E0F4FF 100%); }
body.afternoon { background: linear-gradient(180deg, #4A90D9 0%, #87CEEB 100%); }
body.sunset { background: linear-gradient(180deg, #FF6B6B 0%, #FFE66D 100%); }
body.evening { background: linear-gradient(180deg, #2C3E50 0%, #4A6FA5 100%); }
body.night { background: linear-gradient(180deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%); }
body { background: linear-gradient(180deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%); }

/* 메인 컨테이너 */
.main-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    max-width: 100%;
    margin: 0 auto;
    padding: 0 8px;
    padding-bottom: env(safe-area-inset-bottom);
}

/* 눈 효과 */
.snowflakes {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 1000;
    overflow: hidden;
}
.snowflake {
    position: absolute;
    top: -20px;
    color: rgba(255,255,255,0.5);
    font-size: 0.7rem;
    animation: snowfall linear infinite;
}
.snowflake:nth-child(1) { left: 5%; animation-duration: 12s; }
.snowflake:nth-child(2) { left: 15%; animation-duration: 14s; animation-delay: 1s; }
.snowflake:nth-child(3) { left: 25%; animation-duration: 10s; animation-delay: 2s; }
.snowflake:nth-child(4) { left: 35%; animation-duration: 16s; animation-delay: 0.5s; }
.snowflake:nth-child(5) { left: 45%; animation-duration: 11s; animation-delay: 3s; }
.snowflake:nth-child(6) { left: 55%; animation-duration: 13s; animation-delay: 1.5s; }
.snowflake:nth-child(7) { left: 65%; animation-duration: 15s; animation-delay: 2.5s; }
.snowflake:nth-child(8) { left: 75%; animation-duration: 12s; animation-delay: 4s; }
.snowflake:nth-child(9) { left: 85%; animation-duration: 17s; }
.snowflake:nth-child(10) { left: 95%; animation-duration: 9s; animation-delay: 2s; }

@keyframes snowfall {
    0% { transform: translateY(-20px) rotate(0deg); opacity: 1; }
    100% { transform: translateY(100vh) rotate(360deg); opacity: 0.2; }
}

/* 헤더 - 컴팩트 */
header { 
    text-align: center; 
    padding: 8px 0 4px;
    flex-shrink: 0;
}
header .small { font-size: 0.65rem; }
header .text-white-50 { color: rgba(255,255,255,0.8) !important; }

.display-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--gold);
    text-shadow: 0 2px 10px rgba(255,215,0,0.5);
    margin: 2px 0;
}

/* 헤더 액션 영역 - 통계 + 버튼 */
.header-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

.stats-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    background: rgba(255,255,255,0.15);
    backdrop-filter: blur(10px);
    border-radius: 50px;
    font-size: 0.68rem;
    border: 1px solid rgba(255,255,255,0.2);
}

.btn-message-header {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 18px;
    background: linear-gradient(135deg, #ff6b6b 0%, #e74c3c 50%, #c0392b 100%);
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 50px;
    color: #fff;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(231,76,60,0.5), 0 0 20px rgba(255,107,107,0.3);
    animation: btnPulse 2s ease-in-out infinite;
}

@keyframes btnPulse {
    0%, 100% { 
        transform: scale(1);
        box-shadow: 0 4px 15px rgba(231,76,60,0.5), 0 0 20px rgba(255,107,107,0.3);
    }
    50% { 
        transform: scale(1.05);
        box-shadow: 0 6px 20px rgba(231,76,60,0.6), 0 0 30px rgba(255,107,107,0.5);
    }
}

.btn-message-header:hover, .btn-message-header:active {
    transform: scale(1.08);
    box-shadow: 0 6px 25px rgba(231,76,60,0.7), 0 0 35px rgba(255,107,107,0.6);
    animation: none;
}

/* 가이드 텍스트 - 헤더 아래 */
.guide-text-header {
    font-size: 0.68rem;
    margin-top: 4px;
    margin-bottom: 0;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
    font-weight: 500;
}

/* 공지 - 컴팩트 */
.notice-card {
    background: linear-gradient(135deg, rgba(220, 53, 69, 0.95) 0%, rgba(180, 40, 55, 0.95) 100%);
    border-radius: 10px;
    padding: 6px 10px;
    margin: 0 0 6px;
    border: 1px solid rgba(255,255,255,0.1);
    flex-shrink: 0;
}
.notice-card .small { font-size: 0.68rem; line-height: 1.3; }

/* 트리 섹션 - 5개 트리 */
.tree-section {
    display: flex;
    flex-direction: row;
    align-items: flex-end;
    justify-content: center;
    flex: 1;
    gap: 0;
    position: relative;
    overflow: visible;
    width: 100%;
    max-width: 100vw;
}

/* 사이드 트리 - 4개 (좌2, 우2) */
.side-tree {
    position: absolute;
    width: 80px;
    height: 180px;
    z-index: 3;
    bottom: 15px;
}

/* 가까운 사이드 트리 (메인 트리 바로 옆) */
.side-tree-left {
    left: 15%;
    z-index: 4;
    transform: scale(0.9);
}

.side-tree-right {
    right: 15%;
    z-index: 4;
    transform: scale(0.9);
}

/* 먼 사이드 트리 (화면 가장자리) - 더 작고 멀리 */
.side-tree-far-left {
    left: 0;
    z-index: 2;
    opacity: 0.75;
    transform: scale(0.7);
}

.side-tree-far-right {
    right: 0;
    z-index: 2;
    opacity: 0.75;
    transform: scale(0.7);
}

.side-tree-star {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1.4rem;
    z-index: 20;
    animation: starPulse 2s ease-in-out infinite;
    filter: drop-shadow(0 0 8px rgba(255,215,0,0.8));
}

.side-tree-svg {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 4px 10px rgba(0,0,0,0.3));
}

.side-ornaments {
    position: absolute;
    top: 10px;
    left: 0;
    width: 100%;
    height: calc(100% - 35px);
    pointer-events: none;
    z-index: 16;
}

.side-ornaments .ornament {
    pointer-events: auto;
}

.side-ornaments .ornament-img {
    width: 22px;
    height: 22px;
}

.side-ornaments .ornament-label {
    font-size: 5px;
    max-width: 38px;
    padding: 1px 2px;
}

/* 먼 트리 장식 - 더 작게 */
.side-tree-far-left .side-ornaments .ornament-img,
.side-tree-far-right .side-ornaments .ornament-img {
    width: 18px;
    height: 18px;
}

.side-tree-far-left .side-ornaments .ornament-label,
.side-tree-far-right .side-ornaments .ornament-label {
    font-size: 4px;
    max-width: 30px;
}

/* 트리 래퍼 - 버튼이 헤더로 이동해서 더 크게 */
.tree-wrapper {
    position: relative;
    width: 100%;
    max-width: 100%;
    height: calc(100vh - 240px);
    min-height: 300px;
    max-height: 520px;
    flex-shrink: 0;
    margin-bottom: -10px;
}

/* 별 - 트리 꼭대기 */
.tree-star {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    font-size: 2.2rem;
    z-index: 20;
    animation: starPulse 2s ease-in-out infinite;
    filter: drop-shadow(0 0 12px rgba(255,215,0,0.9));
}

@keyframes starPulse {
    0%, 100% { transform: translateX(-50%) scale(1); }
    50% { transform: translateX(-50%) scale(1.15); filter: drop-shadow(0 0 18px rgba(255,215,0,1)); }
}

/* 트리 SVG */
.tree-svg {
    position: absolute;
    top: 28px;
    left: 50%;
    transform: translateX(-50%);
    width: 95%;
    height: calc(100% - 30px);
    filter: drop-shadow(0 6px 15px rgba(0,0,0,0.4));
}

/* 트리 조명 */
.tree-lights {
    position: absolute;
    top: 28px;
    left: 50%;
    transform: translateX(-50%);
    width: 95%;
    height: calc(100% - 70px);
    pointer-events: none;
    z-index: 10;
}

.light {
    position: absolute;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    animation: lightGlow 1.5s ease-in-out infinite;
}
.light.red { background: #ff4444; box-shadow: 0 0 5px 2px #ff4444; }
.light.gold { background: #ffd700; box-shadow: 0 0 5px 2px #ffd700; }
.light.blue { background: #00bfff; box-shadow: 0 0 5px 2px #00bfff; }
.light.green { background: #00ff7f; box-shadow: 0 0 5px 2px #00ff7f; }
.light.white { background: #fff; box-shadow: 0 0 5px 2px #fff; }

@keyframes lightGlow {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.3; transform: scale(0.6); }
}
.light:nth-child(odd) { animation-delay: 0.5s; }
.light:nth-child(3n) { animation-delay: 1s; }

/* 장식 컨테이너 */
.ornaments {
    position: absolute;
    top: 28px;
    left: 50%;
    transform: translateX(-50%);
    width: 95%;
    height: calc(100% - 70px);
    pointer-events: none;
    z-index: 15;
}

.ornament {
    position: absolute;
    cursor: pointer;
    pointer-events: auto;
    transition: transform 0.2s ease;
    z-index: 15;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.ornament:hover, .ornament:active {
    transform: translate(-50%, -50%) scale(1.2) !important;
    z-index: 30;
}

.ornament-img {
    width: 24px;
    height: 24px;
    object-fit: contain;
    filter: drop-shadow(0 2px 3px rgba(0,0,0,0.5));
}

.ornament-label {
    font-size: 7px;
    background: rgba(0,0,0,0.85);
    color: #fff;
    padding: 1px 4px;
    border-radius: 3px;
    white-space: nowrap;
    max-width: 55px;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 1px;
    text-align: center;
    font-weight: 500;
}



/* 푸터 */
footer {
    text-align: center;
    padding: 4px 0 10px;
    flex-shrink: 0;
}

/* 카카오 버튼 */
.btn-kakao {
    background: #FEE500 !important;
    color: #3C1E1E !important;
    border: none !important;
    font-weight: 600;
    font-size: 0.75rem;
}
.btn-kakao:hover {
    background: #E6CF00 !important;
    color: #3C1E1E !important;
}

/* 푸터 텍스트 - 가독성 개선 */
.footer-text {
    font-size: 0.68rem;
    margin: 0;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
    font-weight: 500;
}
.footer-text a {
    color: var(--gold);
    text-decoration: none;
    font-weight: 600;
}
.footer-text a:hover {
    text-decoration: underline;
}

/* 시간대별 텍스트 색상 최적화 */
body.morning .guide-text-header,
body.morning .footer-text,
body.afternoon .guide-text-header,
body.afternoon .footer-text {
    color: #1a1a2e;
    text-shadow: 0 1px 2px rgba(255,255,255,0.5);
}
body.morning .footer-text a,
body.afternoon .footer-text a {
    color: #c0392b;
}

body.sunset .guide-text-header,
body.sunset .footer-text {
    color: #2c1810;
    text-shadow: 0 1px 2px rgba(255,255,255,0.3);
}
body.sunset .footer-text a {
    color: #8B0000;
}

/* 모달 - 카카오톡 브라우저 호환 (완전 중앙 정렬) */
.modal {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
}

.modal.fade:not(.show) {
    display: none !important;
}

.modal-dialog {
    margin: 0 auto !important;
    max-width: calc(100vw - 32px) !important;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100%;
    padding: 16px;
}

.modal-dialog-centered {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-height: 100vh !important;
    min-height: 100dvh !important;
    margin: 0 auto !important;
}

.modal-sm {
    max-width: 320px !important;
}

.christmas-modal {
    background: #fff !important;
    border-radius: 16px !important;
    border: none !important;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3) !important;
    color: #333 !important;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    position: relative;
}

.christmas-modal .modal-header {
    border-bottom: none !important;
    padding: 10px 12px 0 !important;
}

.christmas-modal .modal-body {
    padding: 12px 16px 16px !important;
    overflow-x: hidden;
}

.christmas-modal .btn-close { 
    opacity: 0.5; 
    padding: 8px;
}
.christmas-modal .btn-close:hover { opacity: 1; }

.form-step { display: none; }
.form-step.active { display: block; }

/* 장식 선택 그리드 - 카카오톡 브라우저 호환 */
.ornament-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
    margin: 10px 0;
    padding: 0;
    width: 100%;
    box-sizing: border-box;
}

.ornament-pick {
    width: 100%;
    aspect-ratio: 1;
    min-width: 0;
    min-height: 0;
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

.ornament-pick img {
    width: 100%;
    height: 100%;
    max-width: 100%;
    object-fit: contain;
    display: block;
}

.ornament-pick:hover,
.ornament-pick:active {
    border-color: var(--primary-green);
    background: #e8f5e9;
}

.ornament-pick.selected {
    border-color: var(--primary-green);
    background: #e8f5e9;
    box-shadow: 0 0 0 2px rgba(25, 135, 84, 0.25);
}

/* 작은 화면에서 그리드 조정 */
@media (max-width: 320px) {
    .ornament-grid {
        gap: 4px;
    }
    .ornament-pick {
        border-radius: 6px;
        padding: 3px;
        border-width: 1.5px;
    }
}

.preview-card {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 10px;
    padding: 10px;
}

.preview-ornament {
    width: 26px;
    height: 26px;
    object-fit: contain;
}

.message-box {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 12px;
    font-size: 0.9rem;
    line-height: 1.5;
    color: #333;
}

.christmas-modal .form-control {
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 9px 12px;
    font-size: 0.88rem;
}

.christmas-modal .form-control:focus {
    border-color: var(--primary-green);
    box-shadow: 0 0 0 3px rgba(25, 135, 84, 0.15);
}

.christmas-modal .form-label {
    color: #495057;
    font-weight: 500;
    margin-bottom: 4px;
    font-size: 0.82rem;
}

.christmas-modal .alert-success {
    background: #d1e7dd;
    border: 1px solid #badbcc;
    color: #0f5132;
}

/* 반응형 - 모바일 큰 화면 */
@media (min-height: 700px) {
    header { padding: 12px 0 6px; }
    .display-title { font-size: 1.25rem; }
    .tree-star { font-size: 2.5rem; }
    .tree-wrapper { 
        height: calc(100vh - 220px);
        max-height: 560px;
    }
    .ornament-img { width: 26px; height: 26px; }
    .ornament-label { font-size: 7px; max-width: 58px; }
    .btn-message-header { padding: 6px 16px; font-size: 0.75rem; }
    .side-tree { height: 240px; width: 100px; bottom: 25px; }
    .side-tree-left { left: 12%; transform: scale(0.85); }
    .side-tree-right { right: 12%; transform: scale(0.85); }
    .side-tree-far-left { left: -5px; transform: scale(0.65); }
    .side-tree-far-right { right: -5px; transform: scale(0.65); }
    .side-tree-star { font-size: 1.4rem; }
    .side-ornaments .ornament-img { width: 20px; height: 20px; }
    .side-ornaments .ornament-label { font-size: 5px; max-width: 40px; }
}

@media (min-height: 800px) {
    .tree-wrapper { 
        height: calc(100vh - 230px);
        max-height: 600px;
    }
    .tree-star { font-size: 2.8rem; }
    .ornament-img { width: 28px; height: 28px; }
    .ornament-label { font-size: 8px; max-width: 60px; }
    .side-tree { height: 280px; width: 110px; bottom: 30px; }
    .side-tree-left { left: 10%; transform: scale(0.85); }
    .side-tree-right { right: 10%; transform: scale(0.85); }
    .side-tree-far-left { left: -8px; transform: scale(0.6); }
    .side-tree-far-right { right: -8px; transform: scale(0.6); }
    .side-ornaments .ornament-img { width: 22px; height: 22px; }
    .side-ornaments .ornament-label { font-size: 5px; max-width: 42px; }
}

/* PC 화면 - 고정 크기로 정렬 유지 */
@media (min-width: 768px) {
    .main-container { 
        max-width: 700px;
        justify-content: center;
    }
    .display-title { font-size: 1.5rem; }
    .header-actions { gap: 12px; }
    .btn-message-header { padding: 7px 18px; font-size: 0.8rem; }
    .tree-wrapper { 
        height: 620px;
        max-width: 480px;
    }
    .tree-star { font-size: 3rem; }
    .tree-svg {
        width: 90%;
        height: calc(100% - 35px);
    }
    .tree-lights,
    .ornaments {
        width: 90%;
        height: calc(100% - 75px);
    }
    .ornament-img { width: 32px; height: 32px; }
    .ornament-label { font-size: 9px; max-width: 70px; }
    .side-tree { height: 320px; width: 120px; bottom: 40px; }
    .side-tree-left { left: 5%; transform: scale(0.8); }
    .side-tree-right { right: 5%; transform: scale(0.8); }
    .side-tree-far-left { left: -15px; transform: scale(0.55); }
    .side-tree-far-right { right: -15px; transform: scale(0.55); }
    .side-tree-star { font-size: 1.5rem; }
    .side-ornaments .ornament-img { width: 24px; height: 24px; }
    .side-ornaments .ornament-label { font-size: 6px; max-width: 48px; }
}

/* 더 큰 PC 화면 */
@media (min-width: 1024px) {
    .main-container { max-width: 900px; }
    .tree-wrapper { 
        height: 680px;
        max-width: 520px;
    }
    .tree-star { font-size: 3.5rem; top: -5px; }
    .ornament-img { width: 36px; height: 36px; }
    .ornament-label { font-size: 9px; max-width: 75px; }
    .side-tree { height: 360px; width: 140px; bottom: 45px; }
    .side-tree-left { left: 8%; transform: scale(0.85); }
    .side-tree-right { right: 8%; transform: scale(0.85); }
    .side-tree-far-left { left: -10px; transform: scale(0.6); }
    .side-tree-far-right { right: -10px; transform: scale(0.6); }
    .side-tree-star { font-size: 1.6rem; }
    .side-ornaments .ornament-img { width: 26px; height: 26px; }
    .side-ornaments .ornament-label { font-size: 7px; max-width: 50px; }
}
