/* ============== 포춘쿠키 페이지 ============== */

.fortune-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: #1a1a2e;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.fortune-back-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    border-radius: 50%;
    transition: background 0.2s;
}

.fortune-back-btn:active { background: rgba(255,255,255,0.1); }

.fortune-page-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
}

/* 메인 컨테이너 - 신비로운 밤하늘 */
.fortune-container {
    min-height: calc(100vh - 240px);
    display: flex;
    flex-direction: column;
    align-items: center;
    background: linear-gradient(180deg, #1a1a2e 0%, #16213e 40%, #0f3460 100%);
    padding: 0 20px 40px;
    position: relative;
    overflow: hidden;
}

.fortune-container::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-image:
        radial-gradient(2px 2px at 20px 30px, rgba(255,255,255,0.5), transparent),
        radial-gradient(2px 2px at 40px 70px, rgba(255,255,255,0.3), transparent),
        radial-gradient(1px 1px at 90px 40px, rgba(255,255,255,0.5), transparent),
        radial-gradient(1px 1px at 130px 80px, rgba(255,255,255,0.4), transparent),
        radial-gradient(2px 2px at 160px 30px, rgba(255,255,255,0.5), transparent),
        radial-gradient(1px 1px at 200px 60px, rgba(255,255,255,0.3), transparent),
        radial-gradient(2px 2px at 250px 20px, rgba(255,255,255,0.4), transparent),
        radial-gradient(1px 1px at 300px 50px, rgba(255,255,255,0.5), transparent),
        radial-gradient(2px 2px at 350px 70px, rgba(255,255,255,0.3), transparent),
        radial-gradient(1px 1px at 400px 30px, rgba(255,255,255,0.5), transparent),
        radial-gradient(2px 2px at 60px 120px, rgba(255,255,255,0.3), transparent),
        radial-gradient(1px 1px at 140px 150px, rgba(255,255,255,0.5), transparent),
        radial-gradient(2px 2px at 220px 130px, rgba(255,255,255,0.4), transparent),
        radial-gradient(1px 1px at 80px 200px, rgba(255,255,255,0.5), transparent),
        radial-gradient(2px 2px at 280px 190px, rgba(255,255,255,0.3), transparent),
        radial-gradient(1px 1px at 450px 100px, rgba(255,255,255,0.4), transparent);
    pointer-events: none;
    animation: twinkle 4s ease-in-out infinite alternate;
}

@keyframes twinkle {
    0% { opacity: 0.6; }
    100% { opacity: 1; }
}

/* 오늘 날짜 */
.fortune-date {
    margin-top: 24px;
    padding: 6px 18px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 20px;
    color: rgba(255,255,255,0.6);
    font-size: 0.8rem;
    font-weight: 500;
    z-index: 1;
    letter-spacing: 1px;
}

/* ============== 쿠키 씬 ============== */

.cookie-scene {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding-top: 50px;
    position: relative;
    z-index: 1;
}

.cookie-glow {
    position: absolute;
    top: 40px;
    width: 250px; height: 250px;
    background: radial-gradient(circle, rgba(240,192,96,0.25) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
}

.cookie-wrapper {
    position: relative;
    width: 160px; height: 160px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.cookie-whole {
    width: 100%; height: 100%;
    animation: cookieFloat 3s ease-in-out infinite;
    transition: transform 0.3s ease;
}
.cookie-whole:active { transform: scale(0.93); }

.cookie-svg {
    width: 100%; height: 100%;
    filter: drop-shadow(0 8px 24px rgba(0,0,0,0.35));
}

@keyframes cookieFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-12px); }
}

.cookie-whole.wobble { animation: cookieWobble 0.6s ease-in-out; }

@keyframes cookieWobble {
    0% { transform: rotate(0deg) scale(1); }
    15% { transform: rotate(-12deg) scale(1.05); }
    30% { transform: rotate(10deg) scale(1.05); }
    45% { transform: rotate(-8deg) scale(1.02); }
    60% { transform: rotate(6deg) scale(1.02); }
    75% { transform: rotate(-3deg) scale(1); }
    100% { transform: rotate(0deg) scale(1); }
}

.cookie-split {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
}

.cookie-half {
    position: absolute;
    top: 0; width: 50%; height: 100%;
}
.cookie-half svg {
    width: 100%; height: 100%;
    filter: drop-shadow(0 6px 15px rgba(0,0,0,0.3));
}
.cookie-left { left: 0; transform-origin: right center; }
.cookie-right { right: 0; transform-origin: left center; }

.cookie-left.crack { animation: crackLeft 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards; }
.cookie-right.crack { animation: crackRight 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards; }

@keyframes crackLeft {
    0% { transform: translateX(0) rotate(0deg); opacity: 1; }
    100% { transform: translateX(-60px) rotate(-25deg) translateY(40px); opacity: 0.4; }
}
@keyframes crackRight {
    0% { transform: translateX(0) rotate(0deg); opacity: 1; }
    100% { transform: translateX(60px) rotate(25deg) translateY(40px); opacity: 0.4; }
}

/* 종이 쪽지 */
.fortune-paper {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%) scale(0);
    width: 200px;
    background: #fffef5;
    border-radius: 4px;
    padding: 16px 14px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    opacity: 0;
    z-index: 5;
}
.fortune-paper.reveal { animation: paperReveal 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) forwards; }

@keyframes paperReveal {
    0% { transform: translate(-50%, -30%) scale(0) rotate(-5deg); opacity: 0; }
    50% { opacity: 1; }
    100% { transform: translate(-50%, -60%) scale(1) rotate(0deg); opacity: 1; }
}

.fortune-message {
    font-size: 0.85rem;
    font-weight: 600;
    color: #5a3e1b;
    line-height: 1.6;
    font-style: italic;
    margin: 0;
    text-align: center;
}

/* 파티클 */
.particles-container {
    position: absolute;
    top: 100px; left: 50%;
    transform: translateX(-50%);
    width: 200px; height: 200px;
    pointer-events: none;
    z-index: 10;
}

.crumb {
    position: absolute;
    width: var(--size, 6px); height: var(--size, 6px);
    background: var(--color, #e8a830);
    border-radius: 2px;
    opacity: 0;
}
.crumb.burst {
    animation: crumbFall var(--duration, 1s) cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
    animation-delay: var(--delay, 0s);
}
@keyframes crumbFall {
    0% { transform: translate(0, 0) rotate(0deg) scale(1); opacity: 1; }
    100% { transform: translate(var(--tx, 30px), var(--ty, 80px)) rotate(var(--rot, 180deg)) scale(0.3); opacity: 0; }
}

/* 안내 텍스트 */
.cookie-hint {
    margin-top: 40px;
    font-size: 0.9rem;
    color: rgba(255,255,255,0.7);
    text-align: center;
    animation: hintPulse 2s ease-in-out infinite;
}
.cookie-hint.hidden { animation: hintFade 0.4s ease forwards; }

@keyframes hintPulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}
@keyframes hintFade { to { opacity: 0; transform: translateY(10px); } }


/* ============== 결과 영역 ============== */

.fortune-result {
    width: 100%;
    max-width: 400px;
    padding-top: 24px;
    z-index: 1;
    animation: resultFadeIn 0.6s ease forwards;
}
@keyframes resultFadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* 운세 등급 카드 */
.fortune-grade-card {
    text-align: center;
    padding: 28px 20px;
    margin-bottom: 14px;
    background: radial-gradient(ellipse at center, rgba(255,215,0,0.08) 0%, transparent 70%);
    border: 1px solid rgba(255,215,0,0.15);
    border-radius: 20px;
}

.grade-stamp {
    font-size: 3rem;
    font-weight: 900;
    line-height: 1.2;
    margin-bottom: 8px;
    background: linear-gradient(135deg, #ffd700, #ffaa00, #ffd700);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 2px 8px rgba(255,215,0,0.4));
}

.grade-desc {
    font-size: 0.85rem;
    color: rgba(255,255,255,0.6);
    margin: 0;
    line-height: 1.5;
}

/* 총운 카드 */
.fortune-main-card {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 14px;
}

.card-label {
    font-size: 0.7rem;
    font-weight: 700;
    color: rgba(255,215,0,0.8);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 10px;
}

.main-fortune-text {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
    color: rgba(255,255,255,0.9);
    line-height: 1.8;
    word-break: keep-all;
}

/* 카테고리별 운세 */
.fortune-categories {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 14px;
}

.fortune-cat-item {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 14px;
    padding: 14px;
}

.cat-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
}

.cat-icon { font-size: 1rem; }

.cat-name {
    font-size: 0.75rem;
    font-weight: 700;
    color: rgba(255,255,255,0.8);
}

.cat-stars {
    margin-bottom: 8px;
    font-size: 0.85rem;
    letter-spacing: 2px;
    color: #ffd700;
}

.cat-text {
    margin: 0;
    font-size: 0.73rem;
    color: rgba(255,255,255,0.55);
    line-height: 1.5;
    word-break: keep-all;
}

/* 럭키 아이템 */
.lucky-items-card {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 16px;
    padding: 18px 16px;
    margin-bottom: 14px;
}

.lucky-items-row {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 12px;
}

.lucky-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.lucky-icon { font-size: 1.2rem; }

.lucky-label {
    font-size: 0.6rem;
    color: rgba(255,255,255,0.4);
    font-weight: 500;
}

.lucky-value {
    font-size: 0.9rem;
    font-weight: 700;
    color: rgba(255,215,0,0.9);
}

.lucky-divider {
    width: 1px;
    height: 40px;
    background: rgba(255,255,255,0.1);
}

/* 한줄 조언 */
.fortune-advice-card {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: linear-gradient(135deg, rgba(102,126,234,0.15), rgba(118,75,162,0.15));
    border: 1px solid rgba(102,126,234,0.2);
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 20px;
}

.advice-icon { font-size: 1.3rem; flex-shrink: 0; margin-top: 2px; }

.advice-text {
    margin: 0;
    font-size: 0.85rem;
    font-weight: 600;
    color: rgba(255,255,255,0.85);
    line-height: 1.6;
}

/* 하단 버튼 */
.result-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.share-btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 14px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s;
}
.share-btn:active { transform: scale(0.97); }

.home-btn {
    display: block;
    text-align: center;
    padding: 12px;
    color: rgba(255,255,255,0.5);
    text-decoration: none;
    font-size: 0.85rem;
}

.fortune-note {
    text-align: center;
    margin-top: 16px;
    font-size: 0.75rem;
    color: rgba(255,255,255,0.35);
    padding-bottom: 20px;
}

/* 이미 열었을 때 */
.cookie-scene.already-opened {
    padding-top: 20px;
}
.cookie-scene.already-opened .cookie-wrapper {
    height: 80px; width: 140px;
}
.cookie-scene.already-opened .cookie-glow {
    width: 150px; height: 150px; top: 10px;
}
.cookie-scene.already-opened .cookie-hint { display: none; }
