body {
    margin: 0;
    padding: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #025FF4;
    font-family: sans-serif;
    overflow: hidden;
}

/* Background Canvas */
.background-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 0;
}

.container {
    position: relative;
    z-index: 2;
    /* Aspect ratio 4:3 is standard for webcams, adjust if needed */
    width: 640px; 
    height: 480px;
    /* Overflow visible to allow countdown to hang outside */
    overflow: visible;
}

.video-frame {
    width: 100%;
    height: 100%;
    position: relative;
    background-color: #000;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.input_video {
    display: block; /* Make sure it takes up space */
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* Mirror the video so it feels natural like a mirror */
    transform: scaleX(-1); 
}

.output_canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    /* Ensure canvas sits behind the video but above background */
    z-index: 1;
    /* Mirror canvas so drawings match the mirrored video */
    transform: scaleX(-1);
    pointer-events: none;
}

/* Side Panel Wrapper */
.side-panel {
    position: absolute;
    right: 100%; /* Anchor to the left edge of the container */
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 20px; /* Gap between button and countdown */
    margin-right: 20px; /* Gap between panel and video */
    z-index: 10;
}

/* Money Panel */
.money-panel {
    position: absolute;
    bottom: 100%; /* Position above the container */
    left: 0;
    width: 100%; /* Match container width */
    height: 80px;
    background-color: #0062FF;
    color: white;
    border: 4px solid #FFFFFF;
    box-sizing: border-box;
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    font-size: 32px;
    font-weight: 700;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 12px;
    margin-bottom: 20px; /* Gap between money panel and video */
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    z-index: 10;
}

/* Open Cam Button */
.open-cam-btn {
    width: 220px;
    height: 80px;
    background-color: #FFFFFF;
    border: 4px solid #0062FF;
    border-radius: 12px;
    color: #0062FF;
    font-size: 32px;
    font-weight: 700;
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    transition: transform 0.1s;
}

.open-cam-btn:active {
    transform: scale(0.98);
}

/* Countdown Panel */
.countdown-panel {
    width: 220px;
    height: 220px;
    background-color: #0062FF;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.countdown-label {
    font-size: 18px;
    font-weight: 300;
    margin-bottom: 5px;
    opacity: 0.9;
}

.countdown-display {
    font-size: 56px;
    font-weight: 700;
    margin: 5px 0;
    font-variant-numeric: tabular-nums; /* Monospaced numbers */
}

.countdown-instruction {
    font-size: 20px;
    font-weight: 400;
    margin-top: 5px;
    line-height: 1.3;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.5); /* Semi-transparent dimming */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999; /* Highest layer */
    opacity: 1;
    transition: opacity 0.3s ease;
}

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

.modal-content {
    background-color: white;
    width: 80vw;
    max-width: 1200px;
    padding: 40px;
    border-radius: 16px;
    position: relative;
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
    text-align: center;
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    font-size: 24px;
    color: #333;
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #999;
    line-height: 1;
}

.modal-close:hover {
    color: #333;
}
