/* ============================================
   CSS: Dark Theme with Glassmorphism UI
   ============================================ */

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

body {
    font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
    background: linear-gradient(135deg, #0a0a0f 0%, #1a1a2e 50%, #16213e 100%);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

/* Main 3D canvas container */
#container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* Webcam preview (small corner overlay) */
#webcam-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 240px;
    height: 180px;
    border-radius: 16px;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.2);
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    z-index: 100;
}

#webcam {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
    /* Mirror for intuitive control */
}

/* Status panel (top-left) */
#status-panel {
    position: fixed;
    top: 20px;
    left: 20px;
    padding: 16px 24px;
    background: rgba(20, 20, 40, 0.8);
    backdrop-filter: blur(20px);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 14px;
    z-index: 100;
    min-width: 200px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

#status-panel h3 {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 12px;
}

.status-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.status-row:last-child {
    border-bottom: none;
}

.status-label {
    color: rgba(255, 255, 255, 0.6);
}

.status-value {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.status-value.active {
    color: #00ff88;
    text-shadow: 0 0 10px rgba(0, 255, 136, 0.5);
}

.status-value.inactive {
    color: #ff6b6b;
}

/* Instructions panel (top-right) */
#instructions-panel {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 16px 24px;
    background: rgba(20, 20, 40, 0.8);
    backdrop-filter: blur(20px);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 13px;
    z-index: 100;
    max-width: 280px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

#instructions-panel h3 {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 12px;
}

#instructions-panel ul {
    list-style: none;
    line-height: 1.8;
}

#instructions-panel li {
    padding-left: 20px;
    position: relative;
    color: rgba(255, 255, 255, 0.8);
}

#instructions-panel li::before {
    content: '→';
    position: absolute;
    left: 0;
    color: #00d4ff;
}

/* Voxel count display (bottom-left) */
#voxel-count {
    position: fixed;
    bottom: 20px;
    left: 20px;
    padding: 12px 20px;
    background: rgba(20, 20, 40, 0.8);
    backdrop-filter: blur(20px);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    z-index: 100;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

#voxel-count span {
    color: #00d4ff;
    font-size: 24px;
    margin-right: 8px;
}

/* Loading overlay */
#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #0a0a0f 0%, #1a1a2e 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    transition: opacity 0.5s ease;
}

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

.loader {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top-color: #00d4ff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

#loading-text {
    margin-top: 24px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 16px;
    letter-spacing: 1px;
}

/* Pinch indicator animation */
.pinch-active {
    animation: pulse 0.3s ease;
}

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

    50% {
        transform: scale(1.1);
    }

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

/* Toolbar for Colors & Gravity */
#toolbar {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(20, 20, 40, 0.9);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    padding: 12px 24px;
    display: flex;
    gap: 24px;
    align-items: center;
    z-index: 9999;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.tool-group {
    display: flex;
    gap: 8px;
    align-items: center;
}

.divider {
    width: 1px;
    height: 30px;
    background: rgba(255, 255, 255, 0.1);
}

.color-swatch {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.color-swatch:hover {
    transform: scale(1.1);
}

.color-swatch.active {
    transform: scale(1.15);
    border-color: white;
    box-shadow: 0 0 15px currentColor;
}

/* Toggle Switch */
.toggle-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    color: rgba(255, 255, 255, 0.8);
    font-size: 14px;
    font-weight: 500;
}

.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.1);
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: #00d4ff;
}

input:checked+.slider:before {
    transform: translateX(20px);
}

/* Icon Button */
.icon-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ff6b6b;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 18px;
}

.icon-btn:hover {
    background: rgba(255, 107, 107, 0.2);
    border-color: #ff6b6b;
    transform: scale(1.1);
}

.icon-btn.confirming {
    background: #ff6b6b;
    color: white;
    border-color: white;
    animation: pulse 1s infinite;
}

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

    50% {
        transform: scale(1.1);
    }

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