body {
    font-family: 'Inter', sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 25px;
    
    background: radial-gradient(circle at 10% 20%, #1a202c 0%, #171c26 50%, #13171f 100%);
    color: #e2e8f0;
    min-height: 100vh;
    transition: background 0.7s ease-in-out;
    overflow-x: hidden;
}

h1 {
    color: #e2e8f0;
    margin-bottom: 35px;
    font-size: 3.2em; 
    font-weight: 800;
    text-shadow: 3px 3px 6px rgba(0,0,0,0.4); 
    letter-spacing: 1.5px; 
    animation: fadeInDown 1s ease-out; 
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.controls {
    margin-bottom: 40px;
    display: flex;
    flex-wrap: wrap;
    gap: 25px; 
    align-items: center;
    padding: 30px; 
    background-color: #2d3748;
    border-radius: 25px; 
   
    box-shadow: 0 15px 45px rgba(0, 0, 0, 0.5), 0 0 0 5px rgba(45, 55, 72, 0.2);
    justify-content: center;
    max-width: 90%;
    transition: all 0.4s ease;
}

input[type="number"] {
    padding: 15px 22px; 
    border: 1px solid #4a5568;
    border-radius: 15px; 
    font-size: 19px; 
    width: 160px;
    transition: all 0.3s ease;
    box-shadow: inset 0 3px 7px rgba(0,0,0,0.3); 
    background-color: #2d3748;
    color: #e2e8f0;
}

input[type="number"]:focus {
    outline: none;
    border-color: #00bcd4;
    
    box-shadow: 0 0 0 6px rgba(0, 188, 212, 0.6), inset 0 3px 7px rgba(0,0,0,0.3);
}

select {
    padding: 15px 22px;
    border: 1px solid #4a5568;
    border-radius: 15px;
    font-size: 19px;
    background-color: #2d3748;
    color: #e2e8f0;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: inset 0 3px 7px rgba(0,0,0,0.3);
    appearance: none;
    background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%20viewBox%3D%220%200%20292.4%20292.4%22%3E%3Cpath%20fill%3D%22%23e2e8f0%22%20d%3D%22M287%2C197.93l-131.7-131.7c-4.7-4.7-12.3-4.7-17%2C0L5.4%2C197.93c-4.7%2C4.7-4.7%2C12.3%2C0%2C17l11.3%2C11.3c4.7%2C4.7%2C12.3%2C4.7%2C17%2C0l103.1-103.1l103.1%2C103.1c4.7%2C4.7%2C12.3%2C4.7%2C17%2C0l11.3-11.3C291.7%2C210.23%2C291.7%2C202.63%2C287%2C197.93z%22%2F%3E%3C%2Fsvg%3E');
    background-repeat: no-repeat;
    background-position: right 18px center; 
    background-size: 14px; 
    padding-right: 45px; 
}

select:hover {
    border-color: #00bcd4;
}

select:focus {
    outline: none;
    border-color: #00bcd4;
    box-shadow: 0 0 0 6px rgba(0, 188, 212, 0.6), inset 0 3px 7px rgba(0,0,0,0.3);
}

button {
    padding: 15px 30px; 
    color: #1a202c;
    border: none;
    border-radius: 15px; 
    cursor: pointer;
    font-size: 19px; 
    font-weight: bold;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1); 
    position: relative;
    overflow: hidden;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.45); 
    background-image: linear-gradient(135deg, #00bcd4 0%, #00a8c0 100%); 
}

button:hover {
    transform: translateY(-7px); 
    box-shadow: 0 20px 35px rgba(0, 0, 0, 0.6), 0 0 15px rgba(0, 188, 212, 0.5); 
    background-image: linear-gradient(135deg, #00a8c0 0%, #00bcd4 100%); /
}

button:active {
    transform: translateY(-2px) scale(1.02); 
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.3);
}

#deleteBtn {
    background-image: linear-gradient(135deg, #ef4444 0%, #dc2626 100%); 
    color: white;
}

#deleteBtn:hover {
    box-shadow: 0 20px 35px rgba(0, 0, 0, 0.6), 0 0 15px rgba(239, 68, 68, 0.5);
    background-image: linear-gradient(135deg, #dc2626 0%, #ef4444 100%);
}

#searchBtn {
    background-image: linear-gradient(135deg, #00bcd4 0%, #00a8c0 100%); 
    color: #1a202c;
}

#searchBtn:hover {
    box-shadow: 0 20px 35px rgba(0, 0, 0, 0.6), 0 0 15px rgba(0, 188, 212, 0.5);
    background-image: linear-gradient(135deg, #00a8c0 0%, #00bcd4 100%);
}

#clearBtn, #clearLogBtn, #generateRandomBtn { 
    background-image: linear-gradient(135deg, #4a5568 0%, #2d3748 100%); 
    color: #e2e8f0;
}

#clearBtn:hover, #clearLogBtn:hover, #generateRandomBtn:hover { 
    box-shadow: 0 20px 35px rgba(0, 0, 0, 0.6), 0 0 15px rgba(74, 85, 104, 0.5);
    background-image: linear-gradient(135deg, #2d3748 0%, #4a5568 100%);
}


.slider-label {
    color: #e2e8f0;
    font-size: 1.1em;
    font-weight: 600;
    margin-right: 10px;
}

#animationSpeed {
    -webkit-appearance: none; 
    appearance: none;
    width: 180px; 
    height: 10px;
    background: #4a5568; 
    outline: none;
    opacity: 0.8;
    transition: opacity .2s ease-in-out;
    border-radius: 5px;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.3);
}

#animationSpeed:hover {
    opacity: 1;
}


#animationSpeed::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #00bcd4; /
    cursor: pointer;
    box-shadow: 0 0 8px rgba(0, 188, 212, 0.7);
    transition: background 0.3s ease, box-shadow 0.3s ease;
}

#animationSpeed::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #00bcd4;
    cursor: pointer;
    box-shadow: 0 0 8px rgba(0, 188, 212, 0.7);
    transition: background 0.3s ease, box-shadow 0.3s ease;
}

#animationSpeed::-webkit-slider-thumb:hover,
#animationSpeed::-moz-range-thumb:hover {
    background: #00a8c0;
    box-shadow: 0 0 12px rgba(0, 188, 212, 1);
}



#mainContent {
    display: flex;
    flex-direction: row; 
    gap: 30px; 
    width: 95%;
    max-width: 1800px; 
    margin-bottom: 35px;
    align-items: flex-start; 
}

#treeContainer {
    flex: 3; 
    min-width: 60%; 
    border: 1px solid #4a5568;
    min-height: 600px;
    background-color: #2d3748;
    position: relative;
    overflow: auto;
    padding-top: 90px;
    border-radius: 30px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4), 0 0 0 8px rgba(45, 55, 72, 0.3);
    transition: all 0.6s ease-in-out;
}


.node {
    position: absolute;
    width: 65px;
    height: 65px;
    background-color: #2ecc71; 
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #1a202c; 
    font-weight: bold;
    font-size: 20px;
    border: 5px solid #27ae60; 
    box-shadow: 5px 6px 25px rgba(0,0,0,0.5), inset 0 0 10px rgba(255,255,255,0.1);
    transition: all 0.7s cubic-bezier(0.68, -0.55, 0.27, 1.55), background-color 0.4s ease, border-color 0.4s ease, opacity 0.6s ease, transform 0.6s ease;
    z-index: 10;
    cursor: pointer;
    opacity: 0;
    transform: scale(0);
}

.node.spawned {
    opacity: 1;
    transform: scale(1);
}

.node:hover {
    transform: scale(1.2);
    box-shadow: 6px 7px 30px rgba(0,0,0,0.6), inset 0 0 15px rgba(255,255,255,0.2);
}

.node.highlight {
    background-color: #00bcd4;
    border-color: #00a8c0;
    transform: scale(1.3);
    box-shadow: 0 0 40px rgba(0, 188, 212, 1.2), 0 0 10px rgba(0, 188, 212, 0.8) inset;
    animation: pulse 1.8s infinite alternate;
}

@keyframes pulse {
    from {
        box-shadow: 0 0 40px rgba(0, 188, 212, 1.2), 0 0 10px rgba(0, 188, 212, 0.8) inset;
    }
    to {
        box-shadow: 0 0 60px rgba(0, 188, 212, 1.5), 0 0 15px rgba(0, 188, 212, 1) inset;
    }
}


.node.red {
    background-color: #ef4444;
    border-color: #dc2626;
    color: white; 
}

.node.black {
    background-color: #1a202c;
    color: #e2e8f0;
    border-color: #2d3748;
}


.node.temp-highlight {
    border: 7px solid #fbbf24;
    box-shadow: 0 0 30px rgba(251, 191, 36, 1.2), 0 0 10px rgba(251, 191, 36, 0.8) inset;
    transform: scale(1.2);
}


.line {
    position: absolute;
    background-color: #636b7a;
    height: 6px;
    transform-origin: 0 0;
    z-index: 5;
    transition: all 0.7s ease-in-out;
    box-shadow: 0 0 5px rgba(0,0,0,0.5);
}

/* Message Box Styling */
#messageBox {
    position: fixed;
    top: 50px;
    right: 50px;
    padding: 22px 45px;
    border-radius: 20px;
    font-weight: bold;
    color: #1a202c;
    z-index: 1000;
    box-shadow: 0 12px 30px rgba(0,0,0,0.5);
    transition: opacity 0.8s ease-in-out, transform 0.5s cubic-bezier(0.68, -0.55, 0.27, 1.55);
    opacity: 0;
    min-width: 300px;
    text-align: center;
    transform: translateY(-70px);
}

#messageBox.show {
    opacity: 1;
    transform: translateY(0);
}

#messageBox.error {
    background-color: #ef4444;
    color: white;
}

#messageBox.info {
    background-color: #00bcd4;
    color: #1a202c;
}


#explanationBox {
    flex: 1; 
    min-width: 30%; 
    background-color: #2d3748;
    border: 1px solid #4a5568;
    border-radius: 20px;
    padding: 35px; 
    min-height: 600px; 
    max-height: 600px; 
    overflow-y: auto;
    font-family: 'Segoe UI Mono', 'Consolas', monospace;
    font-size: 17px;
    color: #e2e8f0;
    box-shadow: 0 10px 28px rgba(0,0,0,0.25);
    line-height: 1.4; 
    white-space: pre-wrap;
    margin-top: 0; 
}

#explanationBox h3 {
    color: #e2e8f0;
    margin-bottom: 15px; 
    font-size: 1.6em;
    border-bottom: 3px solid #4a5568;
    padding-bottom: 10px; 
}

#explanationBox p {
    margin: 2px 0; 
    padding: 0;
}


#nodeTooltip {
    position: absolute;
    background-color: rgba(45, 55, 72, 0.95); 
    color: #e2e8f0;
    border: 1px solid #636b7a;
    border-radius: 8px;
    padding: 10px 15px;
    font-size: 0.9em;
    pointer-events: none; 
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
    z-index: 1001; 
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    line-height: 1.4;
}

::-webkit-scrollbar {
    width: 12px; 
}

::-webkit-scrollbar-track {
    background: #2d3748; 
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: #4a5568; 
    border-radius: 10px;
    border: 3px solid #2d3748; 
}

::-webkit-scrollbar-thumb:hover {
    background: #636b7a; 



@media (max-width: 1200px) { 
    #mainContent {
        flex-direction: column; 
        align-items: center;
        gap: 25px;
    }
    #treeContainer, #explanationBox {
        width: 95%; 
        max-width: none; 
        min-height: 450px; 
        max-height: 450px;
    }
    h1 {
        font-size: 2.8em;
        margin-bottom: 30px;
    }
    .controls {
        flex-direction: column;
        gap: 18px;
        width: 98%;
        padding: 25px;
    }
    input[type="number"] {
        width: 90%;
        font-size: 17px;
        padding: 14px 20px;
    }
    button, select {
        width: 95%;
        font-size: 17px;
        padding: 14px 28px;
    }
    .node {
        width: 60px;
        height: 60px;
        font-size: 18px;
    }
    .line {
        height: 5px;
    }
    #explanationBox {
        padding: 30px;
        font-size: 16px;
    }
    #messageBox {
        top: 40px;
        right: 40px;
        padding: 18px 35px;
        min-width: 250px;
    }
}

@media (max-width: 768px) {
    h1 {
        font-size: 2.2em;
        margin-bottom: 25px;
    }
    .controls {
        gap: 15px;
        padding: 20px;
    }
    input[type="number"] {
        font-size: 16px;
        padding: 12px 18px;
    }
    button, select {
        width: 95%;
        font-size: 16px;
        padding: 12px 25px;
    }
    #treeContainer, #explanationBox {
        min-height: 350px;
        max-height: 350px;
        padding-top: 60px;
    }
    .node {
        width: 55px;
        height: 55px;
        font-size: 16px;
    }
    .line {
        height: 4px;
    }
    #explanationBox {
        padding: 25px;
        font-size: 15px;
    }
    #messageBox {
        top: 30px;
        right: 30px;
        padding: 15px 30px;
        min-width: 200px;
    }
}
