* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    overflow: hidden;
    background: #000;
    color: #fff;
}

#renderCanvas {
    width: 100vw;
    height: 100vh;
    display: block;
    touch-action: none;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(10px);
}

.loading-content {
    text-align: center;
    padding: 2rem;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top: 3px solid #fff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.progress-bar {
    width: 200px;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    margin: 1rem auto;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #2196F3);
    width: 0%;
    transition: width 0.3s ease;
}

/* Start AR Button */
.start-ar-button {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 1rem 2rem;
    font-size: 1.2rem;
    font-weight: 600;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    z-index: 100;
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.4);
    transition: all 0.3s ease;
}

.start-ar-button:hover {
    transform: translate(-50%, -50%) scale(1.05);
    box-shadow: 0 15px 40px rgba(102, 126, 234, 0.6);
}

/* Error Message */
.error-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(244, 67, 54, 0.95);
    padding: 2rem;
    border-radius: 12px;
    max-width: 400px;
    text-align: center;
    z-index: 1001;
    backdrop-filter: blur(10px);
}

.error-content h3 {
    margin-bottom: 1rem;
    color: #fff;
}

.error-content p {
    margin-bottom: 1.5rem;
    color: rgba(255, 255, 255, 0.9);
}

.retry-button {
    padding: 0.8rem 1.5rem;
    background: #fff;
    color: #f44336;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s ease;
}

.retry-button:hover {
    background: #f5f5f5;
}

/* Settings Panel */
.settings-panel {
    position: fixed;
    top: 0;
    right: -300px;
    width: 300px;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
    z-index: 100;
    transition: right 0.3s ease;
    padding: 2rem 1rem;
}

.settings-panel.active {
    right: 0;
}

.settings-content h3 {
    margin-bottom: 1.5rem;
    color: #fff;
}

.settings-button {
    display: block;
    width: 100%;
    padding: 1rem;
    margin-bottom: 0.5rem;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.settings-button:hover {
    background: rgba(255, 255, 255, 0.2);
}

.close-button {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
}

.settings-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    background: rgba(0, 0, 0, 0.7);
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 1.2rem;
    cursor: pointer;
    z-index: 99;
    backdrop-filter: blur(10px);
}

/* Surface Indicator */
.surface-indicator {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 50;
    pointer-events: none;
}

.reticle {
    width: 60px;
    height: 60px;
    border: 3px solid #4CAF50;
    border-radius: 50%;
    margin: 0 auto 1rem;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.6; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.1); }
}

.surface-indicator .hint {
    background: rgba(0, 0, 0, 0.8);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.9rem;
    backdrop-filter: blur(10px);
}

/* Fallback Viewer */
.fallback-viewer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    z-index: 1;
}

#fallbackCanvas {
    width: 100%;
    height: 100%;
}

.fallback-controls {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 1rem;
}

.fallback-button {
    padding: 0.8rem 1.5rem;
    background: rgba(255, 255, 255, 0.9);
    color: #000;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
}

/* Responsive Design */
@media (max-width: 768px) {
    .loading-content {
        padding: 1rem;
    }
    
    .progress-bar {
        width: 150px;
    }
    
    .settings-panel {
        width: 250px;
    }
    
    .error-message {
        margin: 1rem;
        max-width: calc(100% - 2rem);
    }
}

/* Landscape adjustments */
@media (orientation: landscape) and (max-height: 500px) {
    .loading-overlay {
        padding: 1rem;
    }
    
    .loading-content h2 {
        font-size: 1.2rem;
    }
    
    .settings-panel {
        padding: 1rem;
    }
}
