body {
    margin: 0;
    padding: 0;
    background-color: #000;
    color: #fff;
    font-family: 'Helvetica Neue', Arial, sans-serif;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100vh;
}

#container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start; /* Start from top to reduce gap */
    padding-top: 10px;
}

h1 {
    position: relative; 
    font-size: 2.5rem;
    font-weight: 100;
    letter-spacing: 0.2em;
    z-index: 10;
    margin: 5px 0 0 0;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
    pointer-events: none;
}

.subtitle {
    position: relative;
    font-size: 1.0rem;
    font-weight: 300;
    letter-spacing: 0.1em;
    z-index: 10;
    color: #ccc;
    margin-bottom: 2px;
}

.sub-subtitle {
    position: relative;
    font-size: 1.0rem; /* Match subtitle size */
    font-weight: 300;
    letter-spacing: 0.1em;
    z-index: 10;
    color: #ccc;
    margin-bottom: 10px;
    font-style: italic;
}

#wait-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2rem;
    font-weight: 100;
    letter-spacing: 0.2em;
    color: #fff;
    z-index: 20; /* Above canvas, below controls if needed, but above everything else */
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
    pointer-events: none;
    animation: pulse 1.5s infinite ease-in-out;
}

@keyframes pulse {
    0% { opacity: 0.5; }
    50% { opacity: 1; }
    100% { opacity: 0.5; }
}

#canvas-wrapper {
    position: relative;
    width: 640px;
    height: 640px;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #000;
}

#input_video {
    position: absolute;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
    display: block !important;
}

#output_canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
}

#controls {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    background: rgba(0, 0, 0, 0.7);
    padding: 10px 20px;
    border-radius: 15px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    backdrop-filter: blur(8px);
    width: 90%;
    max-width: 500px;
}

.control-group {
    width: 100%;
    display: flex;
    flex-direction: row; /* Horizontal layout */
    align-items: center;
    justify-content: space-between;
    gap: 15px;
}

#controls label {
    font-size: 0.9rem;
    font-weight: 300;
    white-space: nowrap;
    min-width: 110px; /* Fixed width for labels to align sliders */
    display: flex;
    justify-content: space-between;
}

input[type=range] {
    flex-grow: 1;
    cursor: pointer;
    margin: 0;
}

.button-row {
    display: flex;
    flex-direction: row;
    width: 100%;
    gap: 10px;
    margin-top: 5px;
}

button {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 8px 5px; /* Narrower padding */
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.85rem; /* Slightly smaller font */
    font-family: inherit;
    transition: background 0.3s;
    flex: 1; /* Equal width */
    white-space: nowrap;
}

button:hover {
    background: rgba(255, 255, 255, 0.2);
}

button.active {
    background: rgba(0, 255, 0, 0.3);
    border-color: rgba(0, 255, 0, 0.6);
    color: #fff;
}

#error-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 0, 0, 0.8);
    padding: 20px;
    border-radius: 10px;
    z-index: 100;
    font-size: 1.5rem;
}

#loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 20;
    font-size: 1.5rem;
    background: rgba(0,0,0,0.7);
    padding: 20px;
    border-radius: 10px;
}

/* Mobile adjustments */
@media (max-width: 600px) {
    h1 {
        font-size: 2rem;
    }
    input[type=range] {
        width: 200px;
    }
}