/* Main Wrapper */
#zhai-fortune-wrapper {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    transition: opacity 0.5s ease;
}

#zhai-fortune-wrapper.initial-hidden {
    opacity: 0 !important;
    pointer-events: none;
}

/* --- Level 1: FAB & CSS Steamer --- */
#zhai-steamer-fab {
    width: 120px;
    height: 120px;
    cursor: pointer;
    position: relative;
    transition: transform 0.2s ease;
    animation: steamer-idle-bob 3s ease-in-out infinite;
}

@keyframes steamer-idle-bob {

    0%,
    100% {
        transform: translateY(0) rotate(0deg);
    }

    50% {
        transform: translateY(-5px) rotate(2deg);
    }
}

#zhai-steamer-fab:hover {
    transform: scale(1.05);
    /* Adjusted scale since it's already big */
    animation-play-state: paused;
}

.steamer-icon {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
}

/* Bamboo color variables */
:root {
    --bamboo-light: #e6cfa3;
    --bamboo-dark: #cfaa76;
    --bamboo-shadow: #8d6e63;
}

.basket-lid {
    width: 100px;
    height: 40px;
    background: var(--bamboo-light);
    border-radius: 50px 50px 10px 10px;
    border: 4px solid var(--bamboo-dark);
    position: relative;
    z-index: 2;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

/* Knob on lid */
.basket-lid::after {
    content: '';
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 12px;
    background: var(--bamboo-dark);
    border-radius: 8px;
}

.basket-body {
    width: 92px;
    height: 40px;
    background: var(--bamboo-dark);
    border-radius: 10px 10px 30px 30px;
    border: 4px solid var(--bamboo-shadow);
    margin-top: -4px;
    /* Overlap slightly */
    z-index: 1;
}

/* Steam Animation */
.steam {
    position: absolute;
    background: rgba(255, 255, 255, 0.8);
    width: 16px;
    height: 40px;
    border-radius: 20px;
    opacity: 0;
    top: -40px;
    filter: blur(4px);
}

.steam-1 {
    left: 20%;
    animation: rise 2s infinite ease-out;
    animation-delay: 0s;
}

.steam-2 {
    left: 50%;
    animation: rise 2s infinite ease-out;
    animation-delay: 0.6s;
    transform: translateX(-50%);
}

.steam-3 {
    right: 20%;
    animation: rise 2s infinite ease-out;
    animation-delay: 1.2s;
}

@keyframes rise {
    0% {
        transform: translateY(0) scaleX(1);
        opacity: 0;
    }

    50% {
        opacity: 0.6;
    }

    100% {
        transform: translateY(-60px) scaleX(1.5);
        opacity: 0;
    }
}

/* Shake Animation (for Loading) */
@keyframes steamer-shake {
    0% {
        transform: rotate(0deg);
    }

    25% {
        transform: rotate(5deg);
    }

    50% {
        transform: rotate(0deg);
    }

    75% {
        transform: rotate(-5deg);
    }

    100% {
        transform: rotate(0deg);
    }
}

#zhai-fortune-loading .steamer-shake {
    animation: steamer-shake 0.5s infinite;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 0 auto 1rem;
}

/* --- Level 2 & 3: Dialog (Centered) --- */
#zhai-fortune-dialog {
    position: fixed;
    /* Changed from absolute */
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90vw;
    /* Mobile: 90% */
    max-width: 90vw;
    font-size: 14px;
    /* Mobile Content Base */
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
    padding: 25px;
    opacity: 1;
    visibility: visible;
    z-index: 10000;
    /* Higher than FAB */
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 1px solid rgba(255, 255, 255, 0.6);
}

#zhai-fortune-dialog.hidden {
    opacity: 0;
    visibility: hidden;
    transform: translate(-50%, -40%) scale(0.95);
    /* Adjusted hidden state for center */
    pointer-events: none;
}

/* Backdrop */
#zhai-fortune-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    /* Between FAB and Dialog */
    opacity: 1;
    visibility: visible;
    transition: opacity 0.3s ease;
}

#zhai-fortune-backdrop.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.dialog-content {
    position: relative;
    text-align: center;
}

.close-btn {
    position: absolute;
    top: -10px;
    right: -10px;
    background: #eee;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    line-height: 24px;
    font-size: 16px;
    color: #666;
}

#zhai-flavor-menu h3 {
    margin: 0 0 15px;
    font-size: 16px;
    color: #333;
}

.flavor-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.flavor-btn {
    background: #fdf2d0;
    /* wrapper color */
    border: 1px solid #e6cfa3;
    padding: 8px 12px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    color: #5d4037;
    transition: all 0.2s;
}

.flavor-btn:hover {
    background: #ffecb3;
    transform: translateY(-2px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Result Styles */
#zhai-fortune-result h3 {
    margin: 0 0 10px;
    font-size: 18px;
    /* Mobile Title */
    color: #d84315;
}

#fortune-content {
    font-size: 14px;
    /* Mobile Content */
    line-height: 1.6;
    color: #555;
    margin-bottom: 15px;
}

.hidden {
    display: none !important;
}

/* Image Support */
.fortune-image-container {
    margin-bottom: 15px;
    text-align: center;
    width: 100%;
}

.fortune-featured-image {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    display: inline-block;
    max-height: 250px;
    /* Prevent overly tall images */
    object-fit: cover;
}

/* --- Desktop Styles (min-width: 768px) --- */
@media (min-width: 768px) {
    #zhai-fortune-dialog {
        width: 60vw;
        /* Desktop: 60% */
        max-width: 1000px;
        /* Optional cap to prevent becoming too massive on huge screens? Or stick to 60vw as requested. Let's stick to 60vw but maybe cap reasonable for ultra-wide */
    }

    #zhai-fortune-result h3 {
        font-size: 26px;
        /* Desktop Title */
        margin-bottom: 20px;
    }

    #fortune-content {
        font-size: 20px;
        /* Desktop Content */
        line-height: 1.8;
    }

    .fortune-image-container .fortune-featured-image {
        max-height: 400px;
        /* Allow larger images on desktop */
    }
}