html, body {
    margin: 0;
    padding: 0;
    font-family: sans-serif;
    background: #000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    overflow: none;
}

header {
    position: absolute;
    top: 0;
    left: 16px;
    width: 300px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #fff;
}

h1 {
    padding-left: 8px;
    cursor: default;
    flex-grow: 1;
    color: #fff;
}

.video-container {
    position: fixed;
    inset: 0;
    background: transparent;
    margin: 0 auto;
    overflow: hidden;
}

video {
    display: none;
    width: 640px;
    height: 480px;
    object-fit: cover;
}

canvas {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 640px;
    height: 480px;
    background: transparent;
    touch-action: none;
}

footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    padding: 16px;
}

footer button {
    background: none;
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
}

.spacer {
    flex-grow: 1;
}

.start-button {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 18px 26px;
    background: rgb(23, 202, 50);
    border: double 4px #fff;
    color: #fff;
    font-size: 30px;
    border-radius: 8px;
    cursor: pointer;
    white-space: nowrap;
}

.generate-button {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 1;
    width: 48px;
    height: 48px;
    background-color: transparent;
    border: dashed 1px rgb(137, 18, 152);
    color: #fff;
    border-radius: 8px;
    cursor: pointer;
}

.generate-button.active {
    background: rgb(170, 11, 172);
    animation: glow 2.5s infinite;
}

.record-button {
    position: absolute;
    width: 72px;
    height: 72px;
    bottom: 85px;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 16px;
    background: #f00;
    border: double 4px #fff;
    color: #fff;
    border-radius: 50%;
    cursor: pointer;
}

.record-button.active {
    background: #d00;
    animation: glow 2.5s infinite;
}

.record-button.active.video::before {
    content: "Recording Video...";
    font-size: 16px;
    white-space: nowrap;
    position: absolute;
    top: -40px;
    left: 50%;
    transform: translateX(-50%);
    animation: fade 2.5s infinite;
}

@keyframes fade {
    0% {
        opacity: 0.9;
    }

    50% {
        opacity: 0.1;
    }

    100% {
        opacity: 0.9;
    }
}

@keyframes glow {
    0% {
        box-shadow: 0 0 10px 0 #f00;
    }

    50% {
        box-shadow: 0 0 20px 10px #f00;
    }

    100% {
        box-shadow: 0 0 10px 0 #f00;
    }
}

.camera-button,
.video-button {
    position: relative;
    padding: 4px 8px;
}

.camera-button.active,
.video-button.active {
    color: #000;
}

.camera-button.active::before,
.video-button.active::before {
    content: "";
    position: absolute;
    z-index: -1;
    top: -4px;
    left: 2px;
    width: 100%;
    height: 100%;
    background-color: white;
    border-radius: 50%;
}

.camera-button::after {
    content: "";
    position: absolute;
    z-index: -1;
    top: -4px;
    left: 2px;
    width: 200%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.486);
    border-radius: 18px;
}

.next-button,
.prev-button {
    width: 80px;
    height: 50px;
    margin: 0 20px;
}

.avatar-button img,
.lens-button img {
    height: 50px;
    border-radius: 50%;
}

.instructions {
    position: absolute;
    top: 100px;
    left: 50%;
    width: 100%;
    max-width: 420px;
    transform: translate(-50%, 0);
    padding: 16px;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    font-size: 20px;
    line-height: 1.5;
    text-align: left;
    cursor: default;
}

.selection-container {
    position: fixed;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    bottom: 60px;
}

.selection-container.top {
    top: 0;
    bottom: auto;
    flex-direction: column-reverse;
}

.selection-container.left {
    left: 0;
    right: auto;
    top: 0;
    flex-direction: row;
}

.selection-container.right {
    right: 0;
    left: auto;
    top: 0;
    flex-direction: row;
}

.selection-container.left,
.selection-container.right {
    top: 60px;
}

/* Toggle Button (Selection) */
.selection {
    position: absolute;
    bottom: 0;
    z-index: 1;
    background-color: rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(10px);
    font-size: 2rem;
    padding: 0.4em 0.6em;
    border-radius: 999px;
    cursor: pointer;
    border: none;
    transition: transform 0.3s ease;
    outline: none;
    height: 75px;
    width: 75px;
}

.selection:focus {
    box-shadow: 0 0 0 3px rgba(100, 150, 255, 0.5);
}

.selection-container.left .selection {
    right: auto;
    left: 16px;
}

.selection-container.right .selection {
    left: auto;
    right: 16px;
}

.selection-container.left .selection,
.selection-container.right .selection {
    top: 50%;
    transform: translateY(-50%);
}

.selection-container.top .selection {
    top: 0;
    bottom: auto;
    transform: translateY(0);
}

.selection-container.bottom .selection {
    bottom: 0;
    top: auto;
    transform: translateY(0);
}

/* Dock */
.dock {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(12px);
    border: 2px solid rgba(255, 255, 255, 0.5);
    padding: 10px;
    width: 300px;
    /* Hidden by default with scaleY(0) */
    transform: scale(0);
    transform-origin: bottom center;
    transition: transform 0.3s ease;
    overflow: hidden;
    overflow-x: auto;
}

/* If the container is at the top, change transform origin. */
.selection-container.top .dock {
    transform-origin: top center;
}

.selection-container.left .dock {
    transform-origin: center right;
}

.selection-container.right .dock {
    transform-origin: center left;
}

.selection-container.left .dock,
.selection-container.right .dock {
    transform-origin: center left;
    flex-direction: column;
    width: auto;
    height: calc(100vh - 120px);
}

/* Show the dock */
.dock.open {
    transform: scale(1);
}

.selection-container.left .dock.open,
.selection-container.right .dock.open {
    overflow-y: auto;
    overflow-x: none;
}

.selection-container.top .dock.open,
.selection-container.bottom .dock.open {
    overflow-x: auto;
}

/* Hide the dock items when dock is open */
.selection-container:has(.dock.open) .selection {
    width: 0;
    height: 0;
    padding: 0;
}

.selection-container.lenses .selection::after {
    content: "🕶️";
}

.selection-container.avatars .selection::after {
    content: "👤";
}

.selection-container:has(.dock.open) .selection::after,
.selection-container:has(.selected) .selection::after {
    content: "";
}

/* Dock Items */
.dock-item {
    background: transparent;
    border: none;
    font-size: 2rem;
    margin: 0 10px;
    cursor: pointer;
    transition: transform 0.2s ease;
    outline: none;
}

.dock-item:hover,
.dock-item:focus {
    transform: scale(1.4);
}

.dock-item:focus {
    box-shadow: 0 0 0 3px rgba(100, 150, 255, 0.5);
    border-radius: 50%;
}

.selection-container img {
    height: 50px;
    border-radius: 50%;
}

.dock-item.selected {
    box-shadow: 0 0 0 3px rgba(100, 150, 255, 0.5);
    border-radius: 50%;
}