* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    overflow: hidden;
    background-color: #050510;
    /* Deep mystical dark blue/black */
    color: white;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

#canvas-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1;
}

/* --- UI Layer (Top Right) --- */
#ui-layer {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    pointer-events: none;
    /* Let clicks pass through empty space */
}

#ui-layer * {
    pointer-events: auto;
    /* Re-enable clicks for buttons/panels */
}

#ui-toggle {
    background: rgba(0, 10, 30, 0.6);
    color: #00c6ff;
    border: 1px solid rgba(0, 198, 255, 0.4);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 20px;
    cursor: pointer;
    backdrop-filter: blur(5px);
    transition: all 0.3s ease;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#ui-toggle:hover {
    background: rgba(0, 198, 255, 0.2);
    transform: scale(1.1);
}

#ui-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: flex-end;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

#ui-panel.hidden {
    opacity: 0;
    transform: translateY(-20px);
    pointer-events: none;
}

/* --- Controls Panel --- */
#controls {
    text-align: center;
    background: rgba(0, 10, 30, 0.6);
    padding: 15px;
    border-radius: 12px;
    border: 1px solid rgba(100, 200, 255, 0.2);
    backdrop-filter: blur(10px);
    width: 280px;
    /* Compact width */
}

#toggle-camera {
    background: linear-gradient(135deg, #00c6ff, #0072ff);
    color: white;
    border: none;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: bold;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 0 15px rgba(0, 198, 255, 0.4);
    margin-bottom: 10px;
    width: 100%;
    text-transform: uppercase;
    letter-spacing: 1px;
}

#toggle-camera:hover {
    transform: scale(1.02);
    box-shadow: 0 0 20px rgba(0, 198, 255, 0.6);
}

#status {
    font-size: 13px;
    margin-bottom: 8px;
}

#help {
    font-size: 11px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 8px;
    color: rgba(255, 255, 255, 0.7);
}

/* --- Debug Console --- */
#debug-console {
    background: rgba(0, 0, 0, 0.85);
    border: 1px solid #00ff88;
    color: #00ff88;
    padding: 12px;
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    font-size: 11px;
    width: 280px;
    box-shadow: 0 0 10px rgba(0, 255, 136, 0.2);
}

#debug-console h3 {
    margin-bottom: 10px;
    border-bottom: 1px solid #00ff88;
    padding-bottom: 5px;
    text-align: center;
}

.debug-item {
    margin: 5px 0;
    display: flex;
    justify-content: space-between;
}

/* --- Modal --- */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: #0a1020;
    border: 1px solid #00c6ff;
    padding: 20px;
    border-radius: 10px;
    width: 300px;
    text-align: left;
    box-shadow: 0 0 20px rgba(0, 198, 255, 0.3);
}

.modal-content h3 {
    color: #00c6ff;
    margin-bottom: 15px;
    text-align: center;
}

.input-group {
    margin-bottom: 15px;
}

.input-group label {
    display: block;
    margin-bottom: 5px;
    font-size: 12px;
    color: #8899aa;
}

.input-group input {
    width: 100%;
    padding: 8px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid #334455;
    color: white;
    border-radius: 4px;
}

.input-group input:focus {
    outline: none;
    border-color: #00c6ff;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

.modal-actions button {
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    border: none;
    font-weight: bold;
}

#btn-cancel-gesture {
    background: #334455;
    color: white;
}

#btn-save-gesture {
    background: #00c6ff;
    color: #000;
}

.secondary-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ddd;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 12px;
    width: 100%;
    margin-bottom: 10px;
    transition: all 0.2s;
}

/* --- Recording Overlay --- */
#recording-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    pointer-events: none;
}

#recording-overlay.hidden {
    display: none;
}

#countdown {
    font-size: 150px;
    font-weight: bold;
    color: #00ff88;
    text-shadow: 0 0 40px rgba(0, 255, 136, 0.8);
    animation: pulse 1s infinite;
}

#recording-status {
    font-size: 40px;
    color: #ff3333;
    text-transform: uppercase;
    font-weight: bold;
    margin-top: 20px;
    text-shadow: 0 0 20px rgba(255, 51, 51, 0.8);
    animation: blink 0.5s infinite;
}

#recording-status.hidden {
    display: none;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes blink {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.3;
    }

    100% {
        opacity: 1;
    }
}