:root {
    --primary-color: #6200ee;
    --secondary-color: #03dac6;
    --background-color: #121212;
    --surface-color: #1e1e1e;
    --on-surface-color: #ffffff;
    --error-color: #cf6679;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--background-color);
    color: var(--on-surface-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    overflow-x: hidden;
}

header {
    width: 100%;
    padding: 2rem 1rem;
    text-align: center;
}

header h1 {
    font-size: 3rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 800px;
    padding: 0 1rem;
}

.video-container {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    background-color: #000;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

#output-canvas {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transform: scaleX(-1); /* Mirror camera */
}

#loading-overlay, #start-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background-color: rgba(0,0,0,0.8);
    z-index: 10;
}

#start-btn {
    background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
    padding: 1rem 2rem;
    font-size: 1.5rem;
    font-weight: bold;
    border-radius: 50px;
    cursor: pointer;
    margin-bottom: 1rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    transition: transform 0.2s;
}

#start-btn:hover {
    transform: scale(1.05);
}

#start-overlay p {
    color: #aaa;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255,255,255,0.1);
    border-top: 5px solid var(--secondary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.controls {
    width: 100%;
    padding: 2rem 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    white-space: nowrap;
}

select {
    background-color: var(--surface-color);
    color: var(--on-surface-color);
    border: 1px solid #444;
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    font-size: 0.9rem;
    cursor: pointer;
}

select:focus {
    outline: none;
    border-color: var(--secondary-color);
}

.status {
    font-size: 0.9rem;
    color: #aaa;
}

#error-message {
    background-color: var(--error-color);
    color: white;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    width: 100%;
    text-align: center;
}

.hidden {
    display: none !important;
}

/* Toggle Switch Styling */
.switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 34px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #555;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
}

input:checked + .slider {
    background-color: var(--primary-color);
}

input:checked + .slider:before {
    transform: translateX(26px);
}

.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

@media (max-width: 600px) {
    header h1 {
        font-size: 2rem;
    }
}
