@import url('https://fonts.googleapis.com/css2?family=Fredoka+One&display=swap');

:root {
    --primary-color: #6a0572; /* Deep Purple */
    --secondary-color: #fca311; /* Bright Orange */
    --accent-color: #e0f2f7; /* Light Blue */
    --background-light: #fdf6e3; /* Light Yellow-Cream */
    --text-color: #333;
    --button-bg: #8ac926; /* Lime Green */
    --button-hover-bg: #6a9b1c;
}

body {
    font-family: 'Fredoka One', cursive;
    margin: 0;
    padding: 20px;
    background-color: var(--background-light);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    box-sizing: border-box;
}

.game-container {
    background-color: white;
    border-radius: 20px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
    padding: 30px;
    display: grid;
    grid-template-areas:
        "header header"
        "professor experiment"
        "ingredients ingredients";
    grid-template-columns: 1fr 2fr;
    gap: 30px;
    max-width: 1200px;
    width: 100%;
    box-sizing: border-box;
    position: relative;
    overflow: hidden;
}

h1 {
    grid-area: header;
    text-align: center;
    color: var(--primary-color);
    font-size: 3.5em;
    margin-bottom: 20px;
    text-shadow: 2px 2px var(--secondary-color);
}

.professor-area {
    grid-area: professor;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    padding: 20px;
}

#professor-bubbles {
    width: 180px;
    height: auto;
    animation: bounce 2s infinite ease-in-out;
}

.speech-bubble {
    background-color: var(--accent-color);
    border: 3px solid var(--primary-color);
    border-radius: 20px;
    padding: 15px 20px;
    margin-top: 20px;
    font-size: 1.2em;
    text-align: center;
    position: relative;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease-in-out;
}

.speech-bubble::before {
    content: '';
    position: absolute;
    width: 0;
    height: 0;
    border-left: 20px solid transparent;
    border-right: 20px solid transparent;
    border-top: 20px solid var(--accent-color);
    bottom: -20px;
    left: 50%;
    transform: translateX(-50%);
}
.speech-bubble::after { /* Border for the pointer */
    content: '';
    position: absolute;
    width: 0;
    height: 0;
    border-left: 24px solid transparent;
    border-right: 24px solid transparent;
    border-top: 24px solid var(--primary-color);
    bottom: -24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: -1;
}

.experiment-area {
    grid-area: experiment;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    background-color: var(--background-light);
    border-radius: 15px;
    padding: 20px;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.05);
}

.beaker-container {
    position: relative;
    width: 250px;
    height: 250px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 10px;
}

#beaker {
    width: 100%;
    height: 100%;
    object-fit: contain;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 5;
}

.beaker-contents-display {
    position: absolute;
    width: 60%; 
    height: 60%; 
    top: 20%; 
    left: 20%; 
    background-color: rgba(255, 255, 255, 0.3); 
    border-radius: 40% 40% 10% 10% / 10% 10% 80% 80%; 
    overflow: hidden;
    z-index: 6; 
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-end; 
    padding: 5px;
    gap: 5px;
    pointer-events: none; 
    transition: background-color 0.3s ease;
}

.beaker-ingredient-icon {
    width: 50px; 
    height: 50px;
    object-fit: contain;
    filter: drop-shadow(1px 1px 2px rgba(0,0,0,0.3));
    animation: ingredient-pop-in 0.3s ease-out;
}

.reaction-animation-area {
    position: absolute;
    width: 60%; 
    height: 60%;
    top: 20%;
    left: 20%;
    border-radius: 40% 40% 10% 10% / 10% 10% 80% 80%;
    overflow: hidden;
    z-index: 10; 
    pointer-events: none;
}

/* Animations for reactions */
@keyframes fizz {
    0% { transform: translateY(0); opacity: 1; }
    100% { transform: translateY(-100px) scale(1.5); opacity: 0; }
}

.fizz-bubble {
    position: absolute;
    background-color: rgba(255, 255, 255, 0.7);
    border-radius: 50%;
    opacity: 0;
    animation: fizz 1.5s forwards ease-out;
}

@keyframes swirl {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
.swirl-color {
    position: absolute;
    width: 150%;
    height: 150%;
    border-radius: 50%;
    animation: swirl 4s infinite linear;
    opacity: 0.8;
}

@keyframes separate-float {
    0% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
    100% { transform: translateY(0); }
}
.oil-drop {
    position: absolute;
    background-color: yellow;
    border-radius: 50%;
    animation: separate-float 2s infinite ease-in-out;
    opacity: 0.9;
}
.water-layer {
    position: absolute;
    width: 100%;
    height: 50%;
    bottom: 0;
    left: 0;
    background-color: lightblue;
}

@keyframes bubble-pop {
    0% { transform: scale(0); opacity: 0; }
    50% { transform: scale(1); opacity: 1; }
    100% { transform: scale(1.2); opacity: 0; }
}
.foam-bubble {
    position: absolute;
    background-color: rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    animation: bubble-pop 1s forwards ease-out;
}


.mix-button {
    background-color: var(--button-bg);
    color: white;
    border: none;
    border-radius: 15px;
    padding: 15px 30px;
    font-size: 1.8em;
    font-family: 'Fredoka One', cursive;
    cursor: pointer;
    box-shadow: 0 5px 0 var(--button-hover-bg);
    transition: all 0.1s ease;
    outline: none;
}

.mix-button:hover {
    background-color: var(--button-hover-bg);
    transform: translateY(2px);
    box-shadow: 0 3px 0 var(--button-hover-bg);
}

.mix-button:active {
    transform: translateY(5px);
    box-shadow: 0 0 0 var(--button-hover-bg);
}

.ingredients-tray {
    grid-area: ingredients;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 25px;
    background-color: var(--accent-color);
    border-radius: 15px;
    padding: 20px;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.05);
}

.ingredient-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: grab;
    background-color: white;
    border-radius: 15px;
    padding: 10px;
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.1);
    transition: transform 0.1s ease;
    width: 120px; 
    text-align: center;
}

.ingredient-item img {
    width: 80px;
    height: 80px;
    object-fit: contain;
    margin-bottom: 5px;
}

.ingredient-item span {
    font-size: 1.1em;
    color: var(--primary-color);
}

.ingredient-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.15);
}

.ingredient-item.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

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

@keyframes ingredient-pop-in {
    0% { transform: scale(0.5); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}


/* Responsive Design */
@media (max-width: 900px) {
    .game-container {
        grid-template-areas:
            "header"
            "professor"
            "experiment"
            "ingredients";
        grid-template-columns: 1fr;
        padding: 20px;
    }

    h1 {
        font-size: 2.5em;
    }

    .professor-area {
        flex-direction: row;
        gap: 15px;
        padding: 0;
    }

    #professor-bubbles {
        width: 120px;
    }

    .speech-bubble {
        flex-grow: 1;
        font-size: 1em;
        margin-top: 0;
        min-height: 60px;
    }
    .speech-bubble::before {
        border-top: 15px solid var(--accent-color);
        bottom: auto;
        top: 50%;
        left: -15px;
        transform: translateY(-50%) rotate(-90deg);
    }
    .speech-bubble::after {
        border-top: 19px solid var(--primary-color);
        bottom: auto;
        top: 50%;
        left: -19px;
        transform: translateY(-50%) rotate(-90deg);
    }


    .experiment-area {
        padding: 15px;
    }

    .beaker-container {
        width: 200px;
        height: 200px;
    }

    .mix-button {
        padding: 12px 25px;
        font-size: 1.5em;
    }

    .ingredients-tray {
        padding: 15px;
        gap: 15px;
    }

    .ingredient-item {
        width: 100px;
        padding: 8px;
    }

    .ingredient-item img {
        width: 60px;
        height: 60px;
    }

    .ingredient-item span {
        font-size: 0.9em;
    }
}

@media (max-width: 600px) {
    body {
        padding: 10px;
    }
    .game-container {
        padding: 15px;
        gap: 20px;
    }
    h1 {
        font-size: 2em;
        margin-bottom: 15px;
    }
    .professor-area {
        flex-direction: column;
        gap: 10px;
    }
    .speech-bubble {
        width: 90%;
        margin-top: 15px;
        min-height: auto;
    }
    .speech-bubble::before {
        border-top: 15px solid var(--accent-color);
        bottom: -15px;
        top: auto;
        left: 50%;
        transform: translateX(-50%);
    }
    .speech-bubble::after {
        border-top: 19px solid var(--primary-color);
        bottom: -19px;
        top: auto;
        left: 50%;
        transform: translateX(-50%);
    }

    .beaker-container {
        width: 180px;
        height: 180px;
    }
    .ingredients-tray {
        justify-content: space-around;
    }
    .ingredient-item {
        width: 80px;
    }
    .ingredient-item img {
        width: 50px;
        height: 50px;
    }
    .ingredient-item span {
        font-size: 0.8em;
    }
}