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

body {
    background: #000011;
    font-family: 'Inter', 'Segoe UI', 'Arial', sans-serif;
    overflow: hidden;
    color: #ffffff;
    cursor: crosshair;
}

#scene-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1;
    background: transparent;
}

.ui-panel {
    position: fixed;
    background: rgba(8, 8, 25, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(100, 200, 255, 0.3);
    border-radius: 12px;
    padding: 16px;
    z-index: 10;
    color: #ffffff;
    font-size: 13px;
    box-shadow: 0 8px 32px rgba(0, 50, 100, 0.4), 
                inset 0 1px 0 rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
}

.ui-panel:hover {
    border-color: rgba(120, 220, 255, 0.5);
    box-shadow: 0 12px 40px rgba(0, 80, 150, 0.6);
}

/* Reality Sync Monitor */
#reality-monitor {
    top: 20px;
    left: 20px;
    min-width: 200px;
}

#reality-monitor h3 {
    margin-bottom: 8px;
    color: #66ccff;
    font-size: 16px;
    font-weight: 600;
    text-shadow: 0 0 10px rgba(102, 204, 255, 0.5);
}

#sync-status {
    margin-bottom: 12px;
    font-size: 14px;
    color: #aaddff;
    animation: syncPulse 2s ease-in-out infinite;
}

@keyframes syncPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 12px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #00aaff 0%, #66ccff 50%, #99ddff 100%);
    width: 60%;
    transition: width 0.3s ease;
    border-radius: 4px;
    box-shadow: 0 0 12px rgba(0, 170, 255, 0.6);
}

.feed-metrics {
    margin-bottom: 10px;
}

.metric {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    font-size: 12px;
}

#color-indicator {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: #ff0000;
}

.camera-status {
    font-size: 11px;
    color: #88ff88;
    margin-bottom: 8px;
}

#brightness-histogram {
    width: 100%;
    height: 30px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

/* AR Controls Panel */
#ar-controls-panel {
    top: 20px;
    right: 20px;
    min-width: 300px;
    max-width: 350px;
}

#ar-controls-toggle {
    background: linear-gradient(135deg, #0066cc 0%, #0088ff 50%, #00aaff 100%);
    border: none;
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
    font-weight: 600;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
}

#ar-controls-toggle:hover {
    background: linear-gradient(135deg, #0077dd 0%, #0099ff 50%, #00bbff 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(0, 136, 255, 0.4);
}

#ar-controls-content {
    margin-top: 12px;
    opacity: 1;
    max-height: 800px;
    transition: all 0.4s ease;
    overflow: hidden;
}

#ar-controls-content.collapsed {
    opacity: 0;
    max-height: 0;
    margin-top: 0;
}

.control-section {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid rgba(100, 200, 255, 0.2);
}

.control-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.control-section h4 {
    color: #66ccff;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Camera Controls */
.camera-controls {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.control-btn {
    background: rgba(0, 100, 200, 0.6);
    border: 1px solid rgba(100, 200, 255, 0.4);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 11px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 4px;
}

.control-btn:hover:not(:disabled) {
    background: rgba(0, 120, 240, 0.8);
    border-color: rgba(120, 220, 255, 0.6);
}

.control-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#resolution-select {
    background: rgba(0, 50, 100, 0.8);
    border: 1px solid rgba(100, 200, 255, 0.4);
    color: white;
    padding: 6px 8px;
    border-radius: 4px;
    font-size: 11px;
}

.camera-preview {
    margin-top: 8px;
    border: 1px solid rgba(100, 200, 255, 0.3);
    border-radius: 6px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.5);
}

.camera-preview.hidden {
    display: none;
}

#preview-canvas {
    display: block;
    width: 100%;
    height: auto;
}

/* Reality Mapping Presets */
.mapping-presets {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.mapping-btn {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: 2px solid rgba(100, 200, 255, 0.3);
    background: rgba(0, 50, 100, 0.6);
    color: white;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mapping-btn:hover {
    border-color: rgba(150, 220, 255, 0.6);
    background: rgba(0, 80, 160, 0.8);
    transform: scale(1.05);
}

.mapping-btn.active {
    border-color: #00aaff;
    background: rgba(0, 170, 255, 0.3);
    box-shadow: 0 0 15px rgba(0, 170, 255, 0.5);
}

/* Sliders */
.sliders {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.slider-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.slider-group label {
    font-size: 12px;
    color: #ccddff;
    font-weight: 500;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.slider-group input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.1);
    outline: none;
    -webkit-appearance: none;
}

.slider-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: linear-gradient(45deg, #00aaff, #66ccff);
    cursor: pointer;
    box-shadow: 0 0 8px rgba(0, 170, 255, 0.5);
    transition: all 0.2s ease;
}

.slider-group input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 0 12px rgba(0, 170, 255, 0.8);
}

/* Feed Metrics Panel */
#feed-metrics-panel {
    bottom: 20px;
    right: 20px;
    min-width: 220px;
}

#feed-metrics-panel h4 {
    color: #66ccff;
    font-size: 14px;
    margin-bottom: 12px;
    text-align: center;
}

.metrics-display {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

#brightness-graph {
    width: 200px;
    height: 60px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
    border: 1px solid rgba(100, 200, 255, 0.2);
}

.color-palette {
    display: flex;
    gap: 4px;
    justify-content: center;
}

.color-sample {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    transition: transform 0.2s ease;
}

.color-sample:hover {
    transform: scale(1.1);
}

.motion-indicator {
    position: relative;
    width: 60px;
    height: 60px;
}

#motion-arrows {
    position: relative;
    width: 100%;
    height: 100%;
}

.arrow {
    position: absolute;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    opacity: 0.3;
    transition: opacity 0.2s ease;
    color: #66ccff;
}

.arrow.up { top: 0; left: 50%; transform: translateX(-50%); }
.arrow.down { bottom: 0; left: 50%; transform: translateX(-50%); }
.arrow.left { left: 0; top: 50%; transform: translateY(-50%); }
.arrow.right { right: 0; top: 50%; transform: translateY(-50%); }

.analysis-status {
    font-size: 11px;
    color: #88ff88;
    text-align: center;
}

/* AR Instructions Panel */
#ar-instructions {
    bottom: 20px;
    left: 20px;
    min-width: 260px;
}

#ar-instructions h3 {
    margin-bottom: 8px;
    color: #66ccff;
    font-size: 18px;
    font-weight: 600;
    text-shadow: 0 0 12px rgba(102, 204, 255, 0.6);
}

#ar-instructions p {
    color: rgba(255, 255, 255, 0.8);
    font-size: 12px;
    line-height: 1.4;
    margin-bottom: 4px;
}

#camera-feed-status {
    color: #88ff88;
    font-weight: bold;
    animation: feedPulse 1.5s ease-in-out infinite;
}

@keyframes feedPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; transform: scale(0.98); }
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .ui-panel {
        font-size: 11px;
        padding: 12px;
        backdrop-filter: blur(15px);
    }
    
    #ar-controls-panel {
        min-width: 260px;
        max-width: 300px;
    }
    
    #reality-monitor {
        min-width: 180px;
    }
    
    #feed-metrics-panel {
        min-width: 180px;
    }
    
    #ar-instructions {
        min-width: 220px;
    }
    
    .mapping-presets {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }
    
    .mapping-btn {
        width: 35px;
        height: 35px;
        font-size: 14px;
    }
    
    .camera-controls {
        flex-direction: column;
        gap: 6px;
    }
    
    .control-btn {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .ui-panel {
        font-size: 10px;
        padding: 10px;
        margin: 5px;
    }
    
    #reality-monitor {
        top: 10px;
        left: 10px;
        right: 10px;
        min-width: auto;
        width: calc(100vw - 20px);
    }
    
    #ar-controls-panel {
        top: 120px;
        left: 10px;
        right: 10px;
        min-width: auto;
        max-width: none;
        width: calc(100vw - 20px);
    }
    
    #feed-metrics-panel {
        bottom: 120px;
        left: 10px;
        right: 10px;
        min-width: auto;
        width: calc(100vw - 20px);
    }
    
    #ar-instructions {
        bottom: 10px;
        left: 10px;
        right: 10px;
        min-width: auto;
        width: calc(100vw - 20px);
    }
}

/* Fullscreen adjustments */
body:fullscreen .ui-panel {
    opacity: 0.8;
    transition: opacity 0.3s ease;
}

body:fullscreen .ui-panel:hover {
    opacity: 1;
}

/* AR-specific animations */
@keyframes realitySync {
    0% { 
        box-shadow: 0 0 10px rgba(0, 170, 255, 0.3);
        border-color: rgba(100, 200, 255, 0.3);
    }
    50% { 
        box-shadow: 0 0 20px rgba(0, 170, 255, 0.6);
        border-color: rgba(150, 220, 255, 0.6);
    }
    100% { 
        box-shadow: 0 0 10px rgba(0, 170, 255, 0.3);
        border-color: rgba(100, 200, 255, 0.3);
    }
}

.ui-panel {
    animation: realitySync 4s ease-in-out infinite;
}

/* Loading states */
.loading {
    position: relative;
    overflow: hidden;
}

.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, 
        transparent, 
        rgba(0, 170, 255, 0.2), 
        transparent);
    animation: scanEffect 2s ease-in-out infinite;
}

@keyframes scanEffect {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* Enhanced hover effects for AR elements */
.mapping-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 6px;
    background: linear-gradient(45deg, 
        rgba(0, 170, 255, 0.1) 0%, 
        rgba(100, 220, 255, 0.1) 50%, 
        rgba(0, 170, 255, 0.1) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mapping-btn:hover::before {
    opacity: 1;
}

.control-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 4px;
    background: linear-gradient(90deg, 
        transparent, 
        rgba(0, 170, 255, 0.1), 
        transparent);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.control-btn:hover::before {
    opacity: 1;
}