/* Reset và Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: "Roboto", sans-serif;
}

body {
    /* Updated font stack with Vietnamese fonts first */
    background: linear-gradient(135deg, #87CEEB 0%, #98FB98 50%, #F0E68C 100%);
    min-height: 100vh;
    overflow-x: hidden;
    user-select: none;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Game Container */
.game-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header Styles */
.game-header {
    text-align: center;
    margin-bottom: 30px;
    background: rgba(255, 255, 255, 0.9);
    padding: 20px;
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
}

.game-header h1 {
    /* Updated font family with Vietnamese fonts */
    font-size: 2.5rem;
    font-weight: 600;
    color: #2E8B57;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
    animation: bounce 2s infinite ease-in-out;
    letter-spacing: 0.5px;
}

.game-header p {
    font-size: 1.2rem;
    color: #228B22;
    font-weight: 600;
    letter-spacing: 0.3px;
}

/* Game Area */
.game-area {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex: 1;
    gap: 40px;
    margin-bottom: 30px;
}

/* Bean Container - Drop Zone (Transparent, no brown border) */
.bean-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 500px;
    background: transparent; /* Remove brown background */
    border: 4px dashed transparent; /* Make border transparent initially */
    border-radius: 20px;
    transition: all 0.3s ease;
    position: relative;
}

.bean-container.drag-over {
    background: rgba(144, 238, 144, 0.3);
    border-color: #32CD32;
    transform: scale(1.02);
    box-shadow: 0 0 30px rgba(50, 205, 50, 0.5);
}

/* Remove Soil background - larger transparent container for Lottie animation */
.soil {
    width: 400px; /* Increased from 300px */
    height: 400px; /* Increased from 300px */
    background: transparent; /* Remove soil background */
    border-radius: 20px;
    position: relative;
    box-shadow: none; /* Remove soil shadow */
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Lottie Animation Container - Much larger for better visibility */
.lottie-container {
    position: relative;
    width: 400px; /* Increased from 300px */
    height: 400px; /* Increased from 300px */
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Bean seed overlay - static image displayed on top of animation initially */
.bean-seed-overlay {
    position: absolute;
    top: 80%; /* Moved down from 70% */
    left: 50%;
    transform: translate(-50%, -50%);
    width: 30px; /* Reduced from 60px (half size) */
    height: 37px; /* Reduced from 75px (half size) */
    z-index: 20; /* Higher than animation to display on top */
    transition: opacity 0.8s ease-out;
    pointer-events: none;
}

/* Hide the bean seed overlay when animation starts */
.bean-seed-overlay.hidden {
    opacity: 0;
    visibility: hidden;
}

/* Seed body - attractive styling */
.bean-seed-overlay .seed-body {
    width: 100%;
    height: 100%;
    background: linear-gradient(145deg, #8B4513 0%, #D2691E 30%, #CD853F 60%, #8B4513 100%);
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
    position: relative;
    box-shadow: inset 2px 2px 4px rgba(255, 255, 255, 0.3),
    inset -2px -2px 4px rgba(0, 0, 0, 0.3),
    0 4px 8px rgba(0, 0, 0, 0.2);

    /* Add a subtle glow effect */
    filter: drop-shadow(0 0 8px rgba(139, 69, 19, 0.3));
}

/* Add a crack line in the middle to make it look more realistic */
.bean-seed-overlay .seed-body::before {
    content: '';
    position: absolute;
    top: 15%;
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    height: 70%;
    background: linear-gradient(to bottom, transparent 0%, rgba(0, 0, 0, 0.4) 20%, rgba(0, 0, 0, 0.6) 50%, rgba(0, 0, 0, 0.4) 80%, transparent 100%);
    border-radius: 1px;
}

/* Add highlight to make it look 3D */
.bean-seed-overlay .seed-body::after {
    content: '';
    position: absolute;
    top: 20%;
    left: 25%;
    width: 15px;
    height: 20px;
    background: radial-gradient(ellipse at center, rgba(255, 255, 255, 0.4) 0%, transparent 70%);
    border-radius: 50%;
    transform: rotate(-15deg);
}

/* Animation for when the seed is "pulsing" with life */
.bean-seed-overlay.pulse .seed-body {
    animation: seedPulse 2s ease-in-out infinite;
}

@keyframes seedPulse {
    0%, 100% {
        transform: scale(1);
        filter: drop-shadow(0 0 8px rgba(139, 69, 19, 0.3));
    }
    50% {
        transform: scale(1.05);
        filter: drop-shadow(0 0 12px rgba(139, 69, 19, 0.5));
    }
}

/* Lottie animation will be positioned to fill the larger container */
.lottie-container > svg,
.lottie-container > canvas,
#beanAnimation > svg,
#beanAnimation > canvas,
#beanAnimation {
    width: 100% !important;
    height: 100% !important;
    max-width: 400px !important; /* Increased from 300px */
    max-height: 400px !important; /* Increased from 300px */
    min-width: 400px !important;
    min-height: 400px !important;
}

/* Elements Container */
.elements-container {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    max-width: 400px;
}

/* Draggable Elements */
.element {
    background: rgba(255, 255, 255, 0.95);
    border: 3px solid #4CAF50; /* Same green border for all elements */
    border-radius: 20px;
    padding: 20px;
    text-align: center;
    cursor: grab;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
}

.element:hover {
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
    border-color: #45a049; /* Same hover color for all */
}

.element:active,
.element.dragging {
    cursor: grabbing;
    transform: rotate(5deg) scale(1.1);
    z-index: 1000;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.element-icon {
    font-size: 3rem;
    margin-bottom: 10px;
    animation: bounce 2s infinite ease-in-out;
}

.element-label {
    font-size: 1rem;
    font-weight: 600;
    color: #2E8B57;
    /* Ensure Vietnamese text displays properly */
}

/* Remove wrong elements special styling - they now look the same */

/* Used elements styling */
.element.used {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* Disappearing animation for correctly dropped elements */
.element.disappearing {
    opacity: 0;
    transform: scale(0.8) translateY(-20px);
    transition: all 0.5s ease-out;
    pointer-events: none;
    cursor: default;
}

/* Animation for element being absorbed into bean */
@keyframes absorbToBeanAnimation {
    0% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.7;
        transform: scale(0.9) translateY(-10px);
    }
    100% {
        opacity: 0;
        transform: scale(0.6) translateY(-30px);
    }
}

.element.absorbing {
    animation: absorbToBeanAnimation 0.8s ease-out forwards;
    pointer-events: none;
}

.element.used:hover {
    transform: none !important;
}

/* Progress Container */
.progress-container {
    display: flex;
    align-items: center;
    gap: 15px;
    background: rgba(255, 255, 255, 0.9);
    padding: 15px 25px;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

.progress-label {
    font-weight: 600;
    color: #2E8B57;
    font-size: 1.1rem;
    /* Vietnamese font support */
}

.progress-bar {
    flex: 1;
    height: 20px;
    background: #F0F0F0;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #32CD32, #228B22);
    width: 0%;
    transition: width 0.5s ease;
    border-radius: 10px;
}

.progress-text {
    font-weight: bold;
    color: #2E8B57;
    font-size: 1.1rem;
    /* Vietnamese font support */
}

/* Success Message */
/* Success Message - Updated to be less intrusive */
.success-message {
    position: fixed;
    bottom: 20px; /* Position from bottom */
    right: 20px; /* Position from right */
    width: auto; /* Auto width based on content */
    height: auto; /* Auto height based on content */
    background: transparent; /* No background overlay */
    display: flex;
    justify-content: flex-end; /* Align content to the right */
    align-items: flex-end; /* Align content to the bottom */
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.5s cubic-bezier(0.25, 1, 0.5, 1); /* Smoother transition */
    pointer-events: none; /* Allow clicking through when hidden */
}

.success-message.show {
    opacity: 1;
    visibility: visible;
    pointer-events: auto; /* Allow interaction when shown */
}

.success-content {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    padding: 25px; /* Reduced padding */
    border-radius: 20px; /* Slightly smaller radius */
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2); /* Softer shadow */
    animation: successPop 0.5s ease-out;
    border: 3px solid #FF6347; /* Slightly thinner border */
    max-width: 320px; /* Limit max width */
}

.success-content h2 {
    /* Updated font family with Vietnamese fonts */
    font-size: 2rem; /* Smaller font size */
    font-weight: 600;
    color: #fff;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    margin-bottom: 15px;
    animation: bounce 1s infinite ease-in-out;
    letter-spacing: 0.5px;
}

.success-content p {
    font-size: 1.1rem; /* Smaller font size */
    color: #fff;
    font-weight: 600;
    margin-bottom: 20px; /* Reduced margin */
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
    /* Vietnamese font support */
}

.restart-btn {
    background: linear-gradient(135deg, #32CD32, #228B22);
    color: white;
    border: none;
    padding: 12px 25px; /* Smaller padding */
    font-size: 1rem; /* Smaller font size */
    font-weight: 600;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    /* Vietnamese font support */
}

.restart-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
    background: linear-gradient(135deg, #228B22, #006400);
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Animations */
@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
    60% {
        transform: translateY(-5px);
    }
}

@keyframes pulse {
    0% {
        transform: translate(-50%, -50%) scale(1);
    }
    50% {
        transform: translate(-50%, -50%) scale(1.05);
    }
    100% {
        transform: translate(-50%, -50%) scale(1);
    }
}

@keyframes successPop {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Music Control */
.music-control {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
}

.music-btn {
    background: linear-gradient(135deg, #FF6B6B, #FF8E8E);
    border: none;
    border-radius: 50px;
    padding: 10px 20px;
    color: white;
    /* Vietnamese font support */
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.3);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.music-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 107, 107, 0.4);
}

.music-btn.playing {
    background: linear-gradient(135deg, #4ECDC4, #44A08D);
    box-shadow: 0 4px 15px rgba(78, 205, 196, 0.3);
}

.music-btn.playing:hover {
    box-shadow: 0 6px 20px rgba(78, 205, 196, 0.4);
}

.music-icon {
    font-size: 1.2rem;
    animation: musicPulse 2s infinite ease-in-out;
}

.music-btn.playing .music-icon {
    animation: musicDance 1s infinite ease-in-out;
}

@keyframes musicPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

@keyframes musicDance {
    0%, 100% {
        transform: scale(1) rotate(0deg);
    }
    25% {
        transform: scale(1.1) rotate(-5deg);
    }
    75% {
        transform: scale(1.1) rotate(5deg);
    }
}

/* Responsive Design Updates */
@media (max-width: 768px) {
    .game-area {
        flex-direction: column;
        gap: 30px;
    }

    /* Adjust soil container for mobile */
    .soil {
        width: 350px; /* Slightly smaller on tablet */
        height: 350px;
    }

    /* Adjust Lottie animation for mobile */
    .lottie-container > svg,
    .lottie-container > canvas,
    #beanAnimation > svg,
    #beanAnimation > canvas,
    #beanAnimation {
        max-width: 350px !important;
        max-height: 350px !important;
        min-width: 350px !important;
        min-height: 350px !important;
    }

    .elements-container {
        grid-template-columns: repeat(4, 1fr);
        max-width: 100%;
        gap: 10px;
    }

    .game-header h1 {
        font-size: 2rem;
    }

    .element {
        padding: 12px;
    }

    .element-icon {
        font-size: 2.2rem;
    }

    .success-content {
        margin: 20px;
        padding: 30px;
    }

    .success-content h2 {
        font-size: 2rem;
    }

    .music-control {
        top: 10px;
        right: 10px;
    }

    .music-btn {
        padding: 8px 16px;
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    /* Adjust soil container for small mobile */
    .soil {
        width: 280px; /* Smaller for phone */
        height: 280px;
    }

    /* Adjust Lottie animation for small mobile */
    .lottie-container > svg,
    .lottie-container > canvas,
    #beanAnimation > svg,
    #beanAnimation > canvas,
    #beanAnimation {
        max-width: 280px !important;
        max-height: 280px !important;
        min-width: 280px !important;
        min-height: 280px !important;
    }

    .elements-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .game-header h1 {
        font-size: 1.5rem;
    }

    .element {
        padding: 8px;
    }

    .element-icon {
        font-size: 1.8rem;
    }

    .music-btn {
        padding: 6px 12px;
        font-size: 0.8rem;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .element:hover {
        transform: none;
    }

    .element:active {
        transform: scale(1.05);
    }
}

/* Canvas animation styling - clean and simple */
#beanAnimation {
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    background: transparent !important;
    border-radius: 20px; /* Match the soil container */
}