body {
    font-family: 'Arial', sans-serif;
    margin: 0;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: #f0f2f5;
}

.container {
    max-width: 800px;
    width: 100%;
    text-align: center;
}

h1 {
    color: #1a73e8;
    margin-bottom: 30px;
}

h2 {
    color: #1a73e8;
    margin: 20px 0;
}

.video-container {
    position: relative;
    width: 100%;
    max-width: 640px;
    margin: 0 auto 20px;
    transform: scaleX(-1);
}

#videoElement {
    width: 100%;
    background-color: #000;
    border-radius: 8px;
    transform: none !important; /* ensure video itself stays unflipped */
}

#recordVideo {
    width: 100%;
    background-color: #000;
    border-radius: 8px;
    transform: none !important;
}

#outputCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 8px;
}

.controls {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 20px;
}

.spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 60px;
    height: 60px;
    margin: -30px 0 0 -30px; /* center */
    border: 6px solid #ccc;
    border-top-color: #1a73e8;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 10;
}

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

.hidden {
    display: none !important;
}

button {
    padding: 10px 20px;
    font-size: 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    background-color: #1a73e8;
    color: white;
    transition: background-color 0.3s;
}

button:hover {
    background-color: #1557b0;
}

button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

.mask-selection {
    margin-top: 20px;
    padding: 20px;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.mask-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.mask-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    padding: 10px;
    border-radius: 8px;
    transition: background-color 0.3s;
}

.mask-option:hover {
    background-color: #f0f2f5;
}

.mask-option img {
    width: 80px;
    height: 80px;
    object-fit: contain;
    margin-bottom: 10px;
}

.mask-option span {
    font-size: 14px;
    color: #333;
}

#videoElement {
    transform: scaleX(-1);
}

video#processedVideo {
    margin-top: 1rem;
    border: 1px solid #ccc;
    max-width: 100%;
}