* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background: #000;
    color: #fff;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

.container {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.vr-view {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: row;
}

/* Portrait single-view: hide the second eye and let the first fill width */
.vr-view.single-view .eye-view {
    width: 100%;
}
.vr-view.single-view .eye-view:nth-child(2) {
    display: none;
}

.eye-view {
    position: relative;
    width: 50%;
    height: 100%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center; /* center the square canvas without stretching */
}

.left-eye, .right-eye {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    overflow: hidden;
    background: #333;
}

.video-feed {
    width: 100%;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    aspect-ratio: 1 / 1; /* force square aspect without distortion */
    object-fit: contain; /* no cropping by CSS, shader handles crop */
}

/* Reduce stretching rules for canvas; rely on .video-feed above */
canvas {
    display: block;
}

.controls {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    display: flex;
    gap: 10px;
}

.zoom-controls {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.btn {
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid #fff;
    color: #fff;
    cursor: pointer;
    border-radius: 5px;
    font-size: 14px;
    transition: all 0.3s ease;
}

.zoom-btn {
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid #fff;
    color: #fff;
    cursor: pointer;
    border-radius: 5px;
    font-size: 18px;
    font-weight: bold;
    transition: all 0.3s ease;
    min-width: 40px;
}

.btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.zoom-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.sharpness-indicator {
    background: rgba(0, 0, 0, 0.7);
    color: #4CAF50;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 12px;
    font-weight: bold;
    text-align: center;
    margin-top: 5px;
    min-width: 80px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.error {
    color: #f44336;
    background: rgba(244, 67, 54, 0.1);
    border: 1px solid #f44336;
    padding: 10px;
    border-radius: 5px;
    margin: 10px 0;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 200;
}

.loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 18px;
    color: #4CAF50;
    z-index: 200;
}

.spinner {
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top: 3px solid #4CAF50;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
    margin: 0 auto 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.hidden {
    display: none;
}

/* Fullscreen styles - default state */
.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 9999;
}

/* Mobile Safari fullscreen support */
@media screen and (max-width: 768px) {
    .fullscreen {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        z-index: 9999;
    }
    
    /* Hide iOS Safari UI elements */
    .fullscreen .controls {
        top: 10px;
    }
    
    .fullscreen .zoom-controls {
        top: 10px;
        right: 10px;
    }
}

/* Cardboard-specific adjustments */
@media (max-width: 768px) {
    .left-eye, .right-eye {
        width: 100%;
        height: 100%;
    }
}

@media (orientation: landscape) and (max-height: 500px) {
    .controls {
        top: 10px;
    }
    
    .zoom-controls {
        top: 10px;
        right: 10px;
    }
}

/* Auto-hide controls after 3 seconds */
.controls, .zoom-controls {
    transition: opacity 0.5s ease;
}

.controls.hidden, .zoom-controls.hidden {
    opacity: 0;
    pointer-events: none;
}
