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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    overflow: hidden;
    background: #0a0a12;
}

#viewer-canvas {
    display: block;
    width: 100vw;
    height: 100vh;
}

/* Loading Overlay */
#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('../BackgroundHSeamless.jpg');
    background-size: auto 100vh;
    background-repeat: repeat-x;
    background-position: center;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.loading-container {
    text-align: center;
    color: #fff;
    padding: 3rem;
    max-width: 500px;
    background: rgba(20, 20, 35, 0.8);
    border-radius: 16px;
    border: 1px solid rgba(147, 51, 234, 0.3);
    backdrop-filter: blur(20px);
}

.loading-container h2 {
    margin-bottom: 2rem;
    font-size: 1.75rem;
    font-weight: 600;
    background: linear-gradient(135deg, #d946ef 0%, #9333ea 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(147, 51, 234, 0.2);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 1.5rem;
    border: none;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #d946ef 0%, #9333ea 50%, #06b6d4 100%);
    background-size: 200% 100%;
    animation: shimmer 2s linear infinite;
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 4px;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

#loading-status {
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.7);
    font-weight: 400;
    margin-bottom: 0.5rem;
}

.loading-detail {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.5);
    font-weight: 300;
    font-family: 'Courier New', monospace;
    min-height: 1.2rem;
}

/* Stage Indicators */
.stage-indicators {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 2rem;
    gap: 0;
}

.stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    position: relative;
}

.stage-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: rgba(147, 51, 234, 0.3);
    border: 2px solid rgba(147, 51, 234, 0.5);
    transition: all 0.3s ease;
    position: relative;
}

.stage.active .stage-dot {
    background: linear-gradient(135deg, #d946ef 0%, #9333ea 100%);
    border-color: #d946ef;
    box-shadow: 0 0 12px rgba(217, 70, 239, 0.6);
    animation: pulse 1.5s ease-in-out infinite;
}

.stage.completed .stage-dot {
    background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%);
    border-color: #06b6d4;
    box-shadow: 0 0 8px rgba(6, 182, 212, 0.4);
}

.stage.completed .stage-dot::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 10px;
    font-weight: bold;
}

.stage-label {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.5);
    font-weight: 400;
    transition: color 0.3s ease;
}

.stage.active .stage-label {
    color: rgba(217, 70, 239, 0.9);
    font-weight: 500;
}

.stage.completed .stage-label {
    color: rgba(6, 182, 212, 0.8);
}

.stage-connector {
    width: 32px;
    height: 2px;
    background: rgba(147, 51, 234, 0.3);
    transition: background 0.3s ease;
}

.stage-connector.completed {
    background: linear-gradient(90deg, #06b6d4 0%, #0891b2 100%);
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 12px rgba(217, 70, 239, 0.6);
    }
    50% {
        transform: scale(1.1);
        box-shadow: 0 0 20px rgba(217, 70, 239, 0.8);
    }
}

/* UI Overlay */
#ui-overlay {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Audio Panel - Top Right Positioning (next to fullscreen) */
#audio-panel {
    position: fixed !important;
    top: 20px !important;
    right: 80px !important;
    left: auto !important;
    bottom: auto !important;
    min-width: 60px;
    width: auto;
    padding: 0;
    background: transparent;
    border: none;
    box-shadow: none;
    backdrop-filter: none;
}

#audio-panel h3 {
    display: none;
}

#audio-toggle {
    margin-bottom: 0;
    width: 50px;
    height: 50px;
    min-width: unset;
    padding: 0;
    font-size: 1.2rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Debug Panel - Collapsible */
#debug-panel {
    max-height: 600px;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

#debug-panel.collapsed {
    max-height: 50px;
}

#debug-panel.collapsed > *:not(h3):not(#debug-toggle) {
    display: none;
}

#debug-panel h3 {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 30px;
}

#debug-panel h3::after {
    content: '▼';
    position: absolute;
    right: 0;
    transition: transform 0.3s ease;
}

#debug-panel.collapsed h3::after {
    transform: rotate(-90deg);
}

/* Controls Panel - Collapsible (same pattern as debug panel) */
#controls-panel {
    max-height: 600px;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

#controls-panel.collapsed {
    max-height: 50px;
}

#controls-panel.collapsed > *:not(h3) {
    display: none;
}

#controls-panel h3 {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 30px;
    margin: 0 0 12px 0;
}

#controls-panel h3::after {
    content: '▼';
    position: absolute;
    right: 0;
    transition: transform 0.3s ease;
}

#controls-panel.collapsed h3::after {
    transform: rotate(-90deg);
}

/* Controls Collapse Button */
#controls-collapse-btn {
    transition: all 0.3s ease;
}

#controls-collapse-btn:hover {
    background: rgba(138, 43, 226, 0.2);
    border-color: rgba(138, 43, 226, 1);
    box-shadow: 0 0 30px rgba(138, 43, 226, 0.6);
}

/* Fullscreen Panel - Top Right Positioning (matches audio panel design) */
#fullscreen-panel {
    position: fixed !important;
    top: 20px !important;
    right: 20px !important;
    left: auto !important;
    bottom: auto !important;
    min-width: 60px;
    width: auto;
    padding: 0;
    background: transparent;
    border: none;
    box-shadow: none;
    backdrop-filter: none;
}

#fullscreen-panel h3 {
    display: none;
}

#fullscreen-toggle {
    margin-bottom: 0;
    width: 50px;
    height: 50px;
    min-width: unset;
    padding: 0;
    font-size: 1.2rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Controls Panel - Dynamic Sections */
.control-section {
    margin: 5px 0;
}

.control-section.hidden {
    display: none;
}

.control-panel {
    background: rgba(10, 10, 20, 0.98);
    padding: 18px 24px;
    border-radius: 12px;
    backdrop-filter: blur(20px);
    border: 1px solid rgba(147, 51, 234, 0.5);
    min-width: 280px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.7), 0 0 40px rgba(147, 51, 234, 0.15);
}

.control-panel h3 {
    color: #fff;
    margin-bottom: 14px;
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 1.0;
}

.btn {
    background: transparent;
    color: #fff;
    border: 2px solid #d946ef;
    padding: 12px 24px;
    border-radius: 50px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.2s ease;
    width: 100%;
    margin-bottom: 8px;
    box-shadow:
        0 0 10px rgba(217, 70, 239, 0.5),
        0 0 20px rgba(217, 70, 239, 0.3),
        inset 0 0 10px rgba(217, 70, 239, 0.1);
}

.btn:hover {
    transform: translateY(-1px);
    border-color: #e879f9;
    box-shadow:
        0 0 15px rgba(217, 70, 239, 0.7),
        0 0 30px rgba(217, 70, 239, 0.5),
        0 0 45px rgba(217, 70, 239, 0.3),
        inset 0 0 15px rgba(217, 70, 239, 0.2);
}

.btn:active {
    transform: translateY(0);
    box-shadow:
        0 0 8px rgba(217, 70, 239, 0.6),
        0 0 15px rgba(217, 70, 239, 0.4),
        inset 0 0 10px rgba(217, 70, 239, 0.15);
}

.volume-control {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
}

.volume-control label {
    color: #fff;
    font-size: 0.9rem;
}

#volume-slider {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: rgba(147, 51, 234, 0.2);
    outline: none;
    -webkit-appearance: none;
}

#volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: linear-gradient(135deg, #d946ef 0%, #9333ea 100%);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(217, 70, 239, 0.4);
    transition: transform 0.2s ease;
}

#volume-slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

#volume-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: linear-gradient(135deg, #d946ef 0%, #9333ea 100%);
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 6px rgba(217, 70, 239, 0.4);
}

#volume-value {
    color: #d946ef;
    font-size: 0.9rem;
    min-width: 45px;
    font-weight: 600;
}

.help-text {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.85rem;
    margin-top: 10px;
    line-height: 1.5;
}

#locomotion-mode {
    font-weight: 700;
    color: #d946ef;
    text-shadow: 0 0 10px rgba(217, 70, 239, 0.3);
}

/* Input Fields */
.input-field {
    width: 100%;
    padding: 10px 14px;
    background: rgba(30, 30, 45, 0.8);
    border: 1px solid rgba(147, 51, 234, 0.3);
    border-radius: 6px;
    color: #fff;
    font-size: 0.9rem;
    font-family: inherit;
    outline: none;
    transition: all 0.2s ease;
}

.input-field:focus {
    border-color: rgba(217, 70, 239, 0.6);
    background: rgba(30, 30, 45, 0.95);
    box-shadow: 0 0 0 3px rgba(217, 70, 239, 0.1);
}

.input-field::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

select.input-field {
    cursor: pointer;
}

select.input-field option {
    background: #1a1a2e;
    color: #fff;
}

/* VR Button Container */
#vr-button-container {
    margin-top: 10px;
}

/* Error Overlay */
#error-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 10, 18, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    backdrop-filter: blur(8px);
}

.error-container {
    background: rgba(20, 20, 35, 0.95);
    padding: 2.5rem;
    border-radius: 16px;
    max-width: 500px;
    text-align: center;
    border: 2px solid rgba(239, 68, 68, 0.5);
    box-shadow: 0 8px 32px rgba(239, 68, 68, 0.2);
}

.error-container h2 {
    color: #ef4444;
    margin-bottom: 1.25rem;
    font-weight: 600;
    font-size: 1.5rem;
}

.error-container p {
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 2rem;
    line-height: 1.6;
    font-size: 0.95rem;
    white-space: pre-line;
    text-align: left;
    max-height: 400px;
    overflow-y: auto;
}

/* Responsive Design */
@media (max-width: 768px) {
    #ui-overlay {
        top: 10px;
        left: 10px;
        right: 10px;
    }

    .control-panel {
        min-width: auto;
    }
}

/* Hide VR-only elements on PC */
.vr-only {
    display: none;
}

/* Show VR-only elements when VR is available */
body.vr-available .vr-only {
    display: block;
}

/* Hide UI when in VR */
body.vr-mode #ui-overlay {
    display: none;
}
