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

body {
    font-family: "Arial", sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #2c3e50, #3498db);
    color: white;
    padding: 20px;
    text-align: center;
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
}

header p {
    font-size: 1.2em;
    opacity: 0.9;
}

.lab-setup {
    padding: 30px;
    background: #f8f9fa;
    min-height: 500px;
    position: relative;
}

/* Chemical bottles styling */
.chemicals-shelf {
    display: flex;
    justify-content: space-around;
    margin-bottom: 40px;
    padding: 20px;
    background: #e9ecef;
    border-radius: 10px;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.1);
}

.bottle-container {
    position: relative;
    width: 100px;
    height: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.bottle-container:hover {
    transform: translateY(-5px);
}

.bottle-svg {
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.label {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: white;
    padding: 5px 8px;
    border: 1px solid #333;
    border-radius: 3px;
    font-size: 12px;
    font-weight: bold;
    z-index: 2;
}

.liquid {
    position: absolute;
    bottom: 15px; /* Adjust to fit inside the bottle SVG */
    width: 70%; /* Adjust to fit inside the bottle SVG */
    height: 60%;
    border-radius: 0 0 5px 5px;
    transition: all 0.3s ease;
    z-index: 0;
}

.bacl2-liquid {
    background: linear-gradient(to bottom, #fff 70%, #e3f2fd 100%);
    /* Subtle glassy highlight for solution realism */
    position: absolute;
    bottom: 15px;
    width: 70%;
    height: 60%;
    border-radius: 0 0 5px 5px;
    box-shadow: 0 2px 8px rgba(30, 136, 229, 0.08) inset;
    transition: all 0.3s ease;
    z-index: 0;
    overflow: visible;
}
.bacl2-liquid::before {
    content: "";
    position: absolute;
    left: 0;
    top: -7px;
    width: 100%;
    height: 14px;
    background: radial-gradient(
        ellipse at center,
        rgba(227, 242, 253, 0.7) 60%,
        transparent 100%
    );
    border-radius: 50%;
    pointer-events: none;
    z-index: 1;
    opacity: 0.7;
}

.na2so4-liquid {
    background: linear-gradient(to bottom, #fff 70%, #e0e0e0 100%);
    /* Optional: subtle sparkle effect for crystalline look */
    background-blend-mode: lighten;
    /* You can add a repeating pattern or SVG for more realism if desired */
}

.hcl-liquid {
    background: linear-gradient(to bottom, #fff, #e0f7fa 90%);
    position: absolute;
    bottom: 15px;
    width: 70%;
    height: 60%;
    border-radius: 0 0 5px 5px;
    transition: all 0.3s ease;
    z-index: 0;
    overflow: visible;
}
.hcl-liquid::before {
    content: "";
    position: absolute;
    left: 0;
    top: -8px;
    width: 100%;
    height: 16px;
    background: radial-gradient(
        ellipse at center,
        rgba(0, 180, 255, 0.18) 70%,
        rgba(255, 255, 255, 0.7) 100%
    );
    border-radius: 50%;
    pointer-events: none;
    z-index: 3;
    opacity: 0.8;
}

/* Dropper styling */
.dropper-svg {
    position: absolute;
    top: -30px; /* Position above the bottle */
    width: 50px;
    height: 100px;
    cursor: grab;
    z-index: 10;
}

.dropper-svg:active {
    cursor: grabbing;
}

/* Equipment area */
.equipment-area {
    display: flex;
    justify-content: space-around;
    align-items: flex-end;
    height: 300px;
    background: #e9e9e9;
}

/* Test tube styling */
.test-tube-container {
    position: relative;
    width: 60px;
    height: 250px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
}

.test-tube-svg {
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.test-tube-svg:hover {
    transform: scale(1.05);
}

.solution {
    position: absolute;
    bottom: 15px; /* Adjust to fit inside the test tube SVG */
    width: 70%; /* Adjust to fit inside the test tube SVG */
    height: 0;
    border-radius: 0 0 18px 18px;
    transition: all 0.8s cubic-bezier(0.4, 0.2, 0.2, 1);
    z-index: 0;
}

/* Chemically realistic: cloudy solution overlay */
.cloudy {
    position: relative;
}
.cloudy::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.55);
    border-radius: 0 0 18px 18px;
    pointer-events: none;
    z-index: 2;
    opacity: 1;
    transition: opacity 2.2s;
}
.solution:not(.cloudy)::after {
    opacity: 0;
    transition: opacity 2.2s;
}

.precipitate {
    position: absolute;
    bottom: 15px; /* Adjust to fit inside the test tube SVG */
    left: 20%;
    width: 60%; /* Narrower for a more conical, realistic look */
    height: 0;
    background: radial-gradient(ellipse at 50% 70%, #fff 70%, #e0e0e0 100%);
    border-radius: 0 0 18px 18px / 0 0 24px 24px;
    opacity: 0;
    transition:
        height 2.2s cubic-bezier(0.4, 0.2, 0.2, 1),
        opacity 2.2s;
    z-index: 2;
    overflow: visible;
}
.precipitate::after {
    content: "";
    position: absolute;
    left: 0;
    top: -8px;
    width: 100%;
    height: 16px;
    background: radial-gradient(
        ellipse at 50% 100%,
        rgba(200, 200, 200, 0.15) 60%,
        transparent 100%
    );
    border-radius: 50%;
    pointer-events: none;
    z-index: 1;
}

/* Chemically realistic: precipitate settling effect */
.settling {
    /* No longer needed for smooth effect, but kept for compatibility */
}

.test-tube-rack {
    width: 80px;
    height: 20px;
    background: #8d6e63;
    border-radius: 5px;
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 0;
}

/* Beaker styling */
.beaker-container {
    position: relative;
    width: 150px;
    height: 180px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
}

.beaker-svg {
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.beaker-solution {
    position: absolute;
    bottom: 6px; /* Lowered for a tighter fit with the beaker SVG bottom */
    width: 70%; /* Adjust to fit inside the beaker SVG */
    left: 20%;
    height: 0;
    background: none;
    border-radius: 0 0 100% 100% / 0 0 100% 100%; /* Flatter bottom */
    box-shadow: none;
    transition: all 0.8s cubic-bezier(0.4, 0.2, 0.2, 1);
    z-index: 1;
    overflow: visible;
}

/* When beaker-solution is filled, add a class .filled dynamically in JS */
.beaker-solution.filled {
    background: radial-gradient(ellipse at 50% 100%, #b3e5fc 60%, #0277bd 100%);
    box-shadow: 0 4px 12px rgba(2, 119, 189, 0.15) inset;
}
.beaker-solution::after {
    display: none;
}
.beaker-solution.filled::after {
    display: block;
    content: "";
    position: absolute;
    left: 0;
    bottom: 6px;
    width: 100%;
    height: 32px;
    background: radial-gradient(
        ellipse at 50% 0%,
        rgba(2, 119, 189, 0.18) 60%,
        transparent 100%
    );
    border-radius: 0 0 100% 100% / 0 0 100% 100%;
    z-index: 2;
    pointer-events: none;
}

/* Optional: Meniscus effect for beaker solution */
.beaker-meniscus {
    position: absolute;
    left: 10%;
    /* The bottom value should be dynamically set to match the top of the solution.
       For static demo, place it just above the solution's bottom. */
    bottom: calc(15px + var(--solution-height, 40%));
    width: 80%;
    height: 10px;
    background: radial-gradient(
        ellipse at center,
        rgba(255, 255, 255, 0.5) 60%,
        transparent 100%
    );
    border-radius: 50%;
    pointer-events: none;
    z-index: 1;
}

/* Instructions and observations */
.instructions,
.observations {
    padding: 20px;
    margin: 20px;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.instructions h3,
.observations h3 {
    color: #2c3e50;
    margin-bottom: 15px;
    font-size: 1.3em;
}

.instructions ol {
    padding-left: 20px;
}

.instructions li {
    margin: 10px 0;
    padding: 8px;
    border-radius: 5px;
    transition: all 0.3s ease;
}

.instructions li.active {
    background: #e3f2fd;
    border-left: 4px solid #2196f3;
    font-weight: bold;
}

.instructions li.completed {
    background: #e8f5e8;
    border-left: 4px solid #4caf50;
    text-decoration: line-through;
    opacity: 0.7;
}

#observation-text {
    padding: 15px;
    background: #f8f9fa;
    border-left: 4px solid #17a2b8;
    font-style: italic;
}

/* Zoom modal */
.zoom-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
}

.zoom-content {
    background-color: #fefefe;
    margin: 5% auto;
    padding: 20px;
    border-radius: 10px;
    width: 80%;
    max-width: 500px;
    text-align: center;
    position: relative;
    background: #d9d9d9;
}

.close-zoom {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    position: absolute;
    top: 10px;
    right: 20px;
}

.close-zoom:hover {
    color: #000;
}

.zoomed-test-tube {
    width: 150px;
    height: 400px;
    margin: 20px auto;
    position: relative;
}

.zoomed-test-tube-svg {
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.zoomed-solution {
    position: absolute;
    bottom: 5px;
    left: 80%;
    width: 40%;
    height: 0;
    background: radial-gradient(
        ellipse at 50% 70%,
        rgba(255, 255, 255, 0.7) 60%,
        rgba(200, 230, 255, 0.3) 100%
    );
    border-radius: 0 0 0 0;
    opacity: 0.25;
    transition: all 0.8s cubic-bezier(0.4, 0.2, 0.2, 1);
    z-index: 2;
    overflow: visible;
}

.zoomed-precipitate {
    position: absolute;
    bottom: 5px; /* Adjust to fit inside the zoomed test tube SVG */
    left: 80%;
    width: 40%; /* Even narrower and more right-shifted for best alignment */
    height: 0;
    background: radial-gradient(ellipse at 50% 70%, #fff 70%, #e0e0e0 100%);
    border-radius: 0 0 26px 26px / 0 0 36px 36px;
    transition: all 0.8s cubic-bezier(0.4, 0.2, 0.2, 1);
    z-index: 2;
    overflow: visible;
}
.zoomed-precipitate::after {
    content: "";
    position: absolute;
    left: 0;
    top: -10px;
    width: 100%;
    height: 20px;
    background: radial-gradient(
        ellipse at 50% 100%,
        rgba(200, 200, 200, 0.15) 60%,
        transparent 100%
    );
    border-radius: 50%;
    pointer-events: none;
    z-index: 1;
}

/* Drag and drop effects */
.dragging {
    opacity: 0.7;
    transform: scale(1.1);
    z-index: 100;
    filter: drop-shadow(0 0 8px #2196f3);
    transition:
        filter 0.2s,
        transform 0.2s;
}

.drop-zone {
    border: 3px dashed #2196f3;
    background: rgba(33, 150, 243, 0.1);
}

.active-drop-zone {
    box-shadow: 0 0 16px 4px #2196f3;
    border: 2px dashed #2196f3;
    background: rgba(33, 150, 243, 0.08);
    transition:
        box-shadow 0.3s,
        background 0.3s;
}

/* Animations */
@keyframes bubble {
    0% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
    80% {
        opacity: 0.7;
    }
    100% {
        transform: translateY(-30px) translateX(var(--bubble-x, 0px)) scale(0.7);
        opacity: 0;
    }
}

.bubble {
    position: absolute;
    width: 8px;
    height: 8px;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 50%;
    animation: bubble 2s linear forwards;
    pointer-events: none;
    will-change: transform, opacity;
    z-index: 3;
    opacity: 0.7;
    transition: opacity 0.2s;
}

/* Reset button styles */
.reset-btn {
    background: #e53935;
    color: #fff;
    border: none;
    border-radius: 5px;
    padding: 10px 20px;
    font-size: 1em;
    margin: 10px 0;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(229, 57, 53, 0.15);
    transition: background 0.2s;
}
.reset-btn:hover {
    background: #b71c1c;
}

/* Responsive design */
@media (max-width: 768px) {
    .chemicals-shelf {
        flex-direction: column;
        align-items: center;
        gap: 20px;
    }

    .equipment-area {
        flex-direction: column;
        align-items: center;
        gap: 30px;
        height: auto;
    }

    .container {
        margin: 10px;
    }

    header h1 {
        font-size: 2em;
    }
}
