* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
/*     background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); */
    background: linear-gradient(135deg, #41245e 0%, #2d3a61 100%);
    min-height: 100vh;
    overflow-x: auto;
    background-attachment: fixed;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

.header {
    text-align: center;
    margin-bottom: 30px;
}

.title {
    color: white;
    font-size: 2.5rem;
    font-weight: 600;
    margin-bottom: 10px;
    text-shadow: 0 2px 10px rgba(0,0,0,0.3);
    background: linear-gradient(135deg, #ffffff, #e0e7ff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: rgba(255,255,255,0.8);
    font-size: 1.1rem;
    font-weight: 300;
}

.controls {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.controls:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
}

.control-group {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    justify-content: center;
    align-items: center;
    margin-bottom: 25px;
}

.control-group:last-child {
    margin-bottom: 0;
}

.input-group {
    display: flex;
    gap: 12px;
    align-items: center;
}

.traversal-controls {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.label {
    color: rgba(255, 255, 255, 0.9);
    font-weight: 500;
    margin-right: 10px;
}

input {
    padding: 14px 18px;
    border: none;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    color: white;
    font-size: 16px;
    width: 90px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.3);
    transition: all 0.3s ease;
    font-weight: 500;
}

input:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

input::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

.btn {
    padding: 14px 24px;
    border: none;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    color: white;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.3);
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
}

.btn:hover::before {
    left: 100%;
}

.btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
}

.btn:active {
    transform: translateY(0);
}

.btn.primary {
    background: linear-gradient(135deg, #667eea, #764ba2);
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.btn.primary:hover {
    background: linear-gradient(135deg, #5a6fd8, #6a42a0);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

.btn.traversal {
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.btn.traversal:hover {
    background: linear-gradient(135deg, #ff5252, #e55100);
}

.info-panel {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(15px);
    border-radius: 20px;
    padding: 20px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    margin-top: 10px;
}

.stats {
    display: flex;
    justify-content: space-around;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 15px;
}

.stat-item {
    text-align: center;
}

.stat-label {
    display: block;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.9rem;
    margin-bottom: 5px;
}

.stat-value {
    display: block;
    color: white;
    font-size: 1.4rem;
    font-weight: 600;
    text-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

.traversal-result {
    text-align: center;
    padding-top: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.result-label {
    color: rgba(255, 255, 255, 0.8);
    font-weight: 500;
    margin-right: 10px;
}

.result-value {
    color: #ffd700;
    font-weight: 600;
    font-family: 'Courier New', monospace;
    text-shadow: 0 2px 10px rgba(255, 215, 0, 0.3);
}

.visualization-container {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 20px;
    margin-bottom: 30px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    overflow: auto;
    min-height: 400px;
    display: flex;
    justify-content: center;
    align-items: center;
}

#treeSvg {
    max-width: 100%;
    height: auto;
    min-height: 400px;
}

.tree-node {
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}

.tree-node:hover {
    transform: scale(1.1);
}

.tree-node.highlight {
    filter: url(#glow);
    animation: pulse 1s infinite;
}

.tree-node.inserting {
    animation: insertBounce 0.6s ease-out;
}

.tree-node.deleting {
    animation: deleteSlide 0.6s ease-in forwards;
}

.tree-edge {
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0.7;
}

.tree-edge.highlight {
    stroke-width: 3;
    opacity: 1;
    filter: drop-shadow(0 0 5px rgba(255, 215, 0, 0.8));
}

.instructions {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 25px;
    color: rgba(255, 255, 255, 0.9);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.instructions h3 {
    margin-bottom: 15px;
    color: white;
    font-size: 1.3rem;
}

.instructions ul {
    list-style: none;
    padding-left: 0;
}

.instructions li {
    margin-bottom: 10px;
    padding-left: 20px;
    position: relative;
}

.instructions li::before {
    content: '→';
    position: absolute;
    left: 0;
    color: #ffd700;
    font-weight: bold;
}

.instructions strong {
    color: #ffd700;
}

/* Animations */
@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

@keyframes insertBounce {
    0% { transform: scale(0) rotate(180deg); opacity: 0; }
    50% { transform: scale(1.3) rotate(90deg); opacity: 0.8; }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

@keyframes deleteSlide {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.5; }
    100% { transform: scale(0); opacity: 0; }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.5s ease-out;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    .title {
        font-size: 2rem;
    }
    
    .control-group {
        flex-direction: column;
        gap: 10px;
    }
    
    .input-group {
        width: 100%;
        justify-content: center;
    }
    
    .traversal-controls {
        justify-content: center;
    }
    
    .stats {
        flex-direction: column;
        gap: 10px;
    }
    
    #treeSvg {
        width: 100%;
        height: 300px;
    }
}

@media (max-width: 480px) {
    .btn {
        padding: 12px 18px;
        font-size: 13px;
    }
    
    input {
        width: 70px;
        padding: 12px 14px;
    }

}
