:root {
    --primary-color: #007aff;
    --bg-color: #f5f5f7;
    --text-color: #1d1d1f;
    --card-bg: #ffffff;
}

* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #000;
    color: #fff;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

.container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

header {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    padding: 16px;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
    background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
}

h1 {
    display: none;
}

.controls {
    display: flex;
    gap: 6px;
    justify-content: center;
    flex-wrap: wrap;
    align-items: center;
}

.cam-switch {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,0.2);
    color: #fff;
    font-size: 1.2rem;
    cursor: pointer;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 8px;
}

.mode-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 20px;
    background-color: rgba(255,255,255,0.2);
    color: #fff;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.mode-btn:hover {
    background-color: rgba(255,255,255,0.3);
}

.mode-btn.active {
    background-color: var(--primary-color);
    color: white;
}

main {
    flex: 1;
    position: relative;
    width: 100%;
    height: 100%;
}

.video-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #000;
    overflow: hidden;
}

video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
    /* Mirror effect */
}

canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* transform: scaleX(-1); Canvas drawing usually needs to be mirrored manually or via context */
}

.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    z-index: 10;
    transition: opacity 0.3s;
}

.loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
    margin-bottom: 10px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

#webcamButton {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 5;
    display: none;
    /* Hidden by default, shown if cam not auto-started */
}

.blend-shapes {
    display: none; /* Hide for fullscreen mode */
}

.blend-shapes-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
}

.blend-shapes-item {
    display: flex;
    flex-direction: column;
    font-size: 0.8rem;
}

.blend-shapes-label {
    margin-bottom: 4px;
}

.blend-shapes-value {
    background: #e0e0e0;
    height: 4px;
    border-radius: 2px;
    overflow: hidden;
}

.blend-shapes-bar {
    background: var(--primary-color);
    height: 100%;
    width: 0;
}

/* Responsive adjustments */
@media (max-width: 600px) {
    header {
        padding: 12px;
    }

    h1 {
        font-size: 1.2rem;
        margin-bottom: 8px;
    }

    .mode-btn {
        padding: 6px 12px;
        font-size: 0.8rem;
    }
}