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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    min-height: 100vh;
    color: #fff;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

h1 {
    text-align: center;
    margin-bottom: 20px;
    font-size: 2.5rem;
    background: linear-gradient(90deg, #00d9ff, #00ff88);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.main-content {
    display: flex;
    gap: 20px;
}

.controls {
    width: 300px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 15px;
    padding: 20px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.control-group {
    margin-bottom: 20px;
}

.control-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #00d9ff;
}

select, input, button {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
}

select, input {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

select option {
    background: #1a1a2e;
}

button {
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease; 
    margin-bottom: 10px;
}

.btn-primary {
    background: linear-gradient(135deg, #00d9ff, #00ff88);
    color: #1a1a2e;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(0, 217, 255, 0.4);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
}

.btn-danger {
    background: linear-gradient(135deg, #ff4757, #ff6b81);
    color: #fff;
}

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(255, 71, 87, 0.4);
}

.canvas-container {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 15px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
}

#graphCanvas {
    width: 100%;
    height: 600px;
    cursor: crosshair;
}

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-top: 15px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
}

.legend-color {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.info-panel {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    padding: 15px;
    margin-top: 15px;
}

.info-panel h3 {
    color: #00ff88;
    margin-bottom: 10px;
    font-size: 14px;
}

.info-panel p {
    font-size: 12px;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.8);
}

.stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 15px;
}

.stat-box {
    background: rgba(0, 0, 0, 0.3);
    padding: 15px;
    border-radius: 10px;
    text-align: center;
}

.stat-value {
    font-size: 24px;
    font-weight: bold;
    color: #00d9ff;
}

.stat-label {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.6);
    margin-top: 5px;
}

.traversal-order {
    margin-top: 15px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    padding: 15px;
    max-height: 150px;
    overflow-y: auto;
}

.traversal-order h3 {
    color: #00ff88;
    margin-bottom: 10px;
    font-size: 14px;
}

.order-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.order-item {
    background: rgba(0, 217, 255, 0.2);
    padding: 5px 12px;
    border-radius: 15px;
    font-size: 12px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

.mode-indicator {
    background: rgba(0, 217, 255, 0.2);
    padding: 10px;
    border-radius: 8px;
    text-align: center;
    margin-bottom: 15px;
    font-size: 13px;
}

.instructions {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.6);
    margin-top: 10px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    line-height: 1.8;
}

.speed-value {
    text-align: center;
    margin-top: 5px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
}

input[type="range"] {
    -webkit-appearance: none;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    padding: 0;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    background: linear-gradient(135deg, #00d9ff, #00ff88);
    border-radius: 50%;
    cursor: pointer;
}

.weight-input-container {
    position: absolute;
    background: #1a1a2e;
    padding: 15px;
    border-radius: 10px;
    border: 1px solid #00d9ff;
    z-index: 100;
    display: none;
}

.weight-input-container input {
    width: 80px;
    margin-right: 10px;
}

.weight-input-container button {
    width: auto;
    padding: 8px 15px;
}