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

body {
    font-family: 'Inter', 'Roboto', sans-serif;
    background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
    color: #ffffff;
    overflow-x: hidden;
}

.header {
    text-align: center;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.8);
    border-bottom: 2px solid #00aaff;
}

.header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(45deg, #00aaff, #ff6600);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header p {
    font-size: 1.1rem;
    color: #cccccc;
}

.main-container {
    display: grid;
    grid-template-columns: 250px 1fr 250px;
    height: calc(100vh - 200px);
    gap: 1rem;
    padding: 1rem;
}

.info-panel, .controls-panel {
    background: rgba(0, 0, 0, 0.7);
    border-radius: 10px;
    padding: 1rem;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    overflow-y: auto;
}

#scene-container {
    background: #1a1a1a;
    border-radius: 10px;
    border: 2px solid #333;
    overflow: hidden;
    position: relative;
}

.section {
    margin-bottom: 1.5rem;
}

.section h3 {
    color: #00aaff;
    margin-bottom: 0.8rem;
    font-size: 1.1rem;
    border-bottom: 1px solid #333;
    padding-bottom: 0.3rem;
}

.component-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.component-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    padding: 0.8rem;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.component-btn:hover {
    background: rgba(0, 170, 255, 0.2);
    border-color: #00aaff;
    transform: translateY(-1px);
}

.color-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.ball-color { background: #333333; }
.roller-color { background: #00aaff; }
.sensor-color { background: #ff6600; }
.housing-color { background: #666666; }

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    margin-bottom: 0.8rem;
}

.control-group label {
    font-size: 0.9rem;
    color: #cccccc;
}

.control-group input[type="range"] {
    width: 100%;
    height: 6px;
    background: #333;
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
}

.control-group input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 18px;
    height: 18px;
    background: #00aaff;
    border-radius: 50%;
    cursor: pointer;
}

.control-group span {
    font-size: 0.8rem;
    color: #00aaff;
    text-align: center;
}

.view-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.view-btn, #auto-rotate, #cross-section {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    padding: 0.6rem;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.85rem;
}

.view-btn:hover, #auto-rotate:hover, #cross-section:hover {
    background: rgba(255, 102, 0, 0.2);
    border-color: #ff6600;
}

.cursor-display {
    background: rgba(0, 0, 0, 0.5);
    border-radius: 8px;
    padding: 1rem;
    position: relative;
}

.coordinate-display {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1rem;
    font-family: monospace;
    font-size: 0.9rem;
}

.coordinate-display span {
    color: #00aaff;
}

.virtual-cursor {
    width: 200px;
    height: 200px;
    background: rgba(0, 170, 255, 0.1);
    border: 1px solid #00aaff;
    border-radius: 4px;
    position: relative;
    margin: 0 auto;
}

.virtual-cursor::after {
    content: '';
    position: absolute;
    width: 8px;
    height: 8px;
    background: #00aaff;
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: all 0.2s ease;
}

.fun-facts p {
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
    padding: 0.5rem;
    background: rgba(255, 102, 0, 0.1);
    border-radius: 4px;
    border-left: 3px solid #ff6600;
}

#explanation-text {
    background: rgba(0, 170, 255, 0.1);
    padding: 1rem;
    border-radius: 6px;
    border-left: 4px solid #00aaff;
}

#explanation-text h4 {
    color: #00aaff;
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

#explanation-text p {
    font-size: 0.9rem;
    line-height: 1.4;
    color: #e0e0e0;
}

.bottom-controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.5);
}

.bottom-controls button {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    padding: 0.8rem 1.5rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.bottom-controls button:hover {
    background: rgba(0, 170, 255, 0.2);
    border-color: #00aaff;
    transform: translateY(-2px);
}

.footer {
    text-align: center;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.8);
    border-top: 1px solid #333;
    font-size: 0.9rem;
    color: #888;
}

.footer a {
    color: #00aaff;
    text-decoration: none;
}

.footer a:hover {
    color: #ff6600;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .main-container {
        grid-template-columns: 200px 1fr 200px;
    }
    
    .info-panel, .controls-panel {
        font-size: 0.85rem;
    }
}

@media (max-width: 900px) {
    .main-container {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr auto;
        height: auto;
    }
    
    #scene-container {
        height: 400px;
        order: 1;
    }
    
    .info-panel {
        order: 2;
    }
    
    .controls-panel {
        order: 3;
    }
    
    .header h1 {
        font-size: 1.8rem;
    }
}

@media (max-width: 600px) {
    .main-container {
        padding: 0.5rem;
        gap: 0.5rem;
    }
    
    .view-buttons {
        grid-template-columns: 1fr;
    }
    
    .bottom-controls {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .bottom-controls button {
        padding: 0.6rem 1rem;
        font-size: 0.8rem;
    }
}

/* Loading and transitions */
canvas {
    transition: opacity 0.5s ease;
}

.component-btn.active {
    background: rgba(0, 170, 255, 0.3);
    border-color: #00aaff;
}

/* Scrollbar styling */
.info-panel::-webkit-scrollbar,
.controls-panel::-webkit-scrollbar {
    width: 6px;
}

.info-panel::-webkit-scrollbar-track,
.controls-panel::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

.info-panel::-webkit-scrollbar-thumb,
.controls-panel::-webkit-scrollbar-thumb {
    background: rgba(0, 170, 255, 0.5);
    border-radius: 3px;
}

.info-panel::-webkit-scrollbar-thumb:hover,
.controls-panel::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 170, 255, 0.7);
}