body {
    font-family: sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 0;
    padding: 1em;
    background-color: #f0f0f0;
    color: #333; /* Ensure text is visible */
}

h1 {
    margin-top: 0;
    text-align: center;
    color: #111; /* Darker heading */
}

button {
    padding: 10px 18px; /* Slightly more padding */
    font-size: 1em;
    cursor: pointer;
    margin-top: 15px; /* Increased margin */
    border: none;
    border-radius: 5px;
    background-color: #007bff; /* Blue background */
    color: white;
    transition: background-color 0.2s ease;
}

button:hover:not(:disabled) {
    background-color: #0056b3; /* Darker blue on hover */
}

button:disabled {
    background-color: #cccccc; /* Grey out when disabled */
    cursor: not-allowed;
}


.video-container {
    position: relative;
    width: 90%;
    max-width: 640px; /* Limit max width */
    margin: 1em auto;
    border: 2px solid #aaa; /* Slightly thicker border */
    background-color: #222; /* Dark background while loading/inactive */
    border-radius: 5px; /* Rounded corners */
    overflow: hidden; /* Keep contents within rounded corners */
}

/* Make video fill container width, maintaining aspect ratio */
video {
    display: block; /* Remove extra space below */
    width: 100%;
    height: auto;
    background-color: #000; /* Black background for video area */
    /* Default transform (for rear camera) */
    transform: scaleX(1);
}

/* Overlay canvas exactly on top of the video */
canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* Default transform (matches video) */
    transform: scaleX(1);
}

#status {
    margin-top: 1em;
    font-weight: bold;
    color: #555; /* Slightly muted status text */
    text-align: center;
    min-height: 1.2em; /* Reserve space for status text */
}

/* Responsive adjustments */
@media (max-width: 600px) {
    body {
        padding: 0.5em;
    }
    h1 {
        font-size: 1.5em;
    }
    .video-container {
        width: 100%; /* Use full width on smaller screens */
        margin: 0.5em auto;
    }
    button {
        width: 80%; /* Make buttons wider */
        max-width: 300px;
        padding: 12px;
    }
}