:root {
    --bg-dark: #0b0f19;
    --card-bg: rgba(22, 29, 45, 0.7);
    --card-border: rgba(255, 255, 255, 0.1);
    --accent-gold: #ffd700;
    --accent-gold-glow: rgba(255, 215, 0, 0.4);
    --accent-cyan: #00f2fe;
    --accent-purple: #7928ca;
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-dark);
    background-image: 
        radial-gradient(at 10% 10%, rgba(121, 40, 202, 0.15) 0px, transparent 50%),
        radial-gradient(at 90% 90%, rgba(0, 242, 254, 0.15) 0px, transparent 50%);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
}

.brand {
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: #fff;
    box-shadow: 0 0 20px rgba(0, 242, 254, 0.3);
}

.brand h1 {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.subtitle {
    font-size: 13px;
    color: var(--text-muted);
}

.header-badges {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Futuristic Camera Toggle Switch */
.camera-switch-wrapper {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.camera-switch-wrapper input[type="checkbox"] {
    display: none;
}

.camera-switch {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 14px 6px 8px;
    background: rgba(15, 23, 42, 0.75);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 30px;
    backdrop-filter: blur(12px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.camera-switch-wrapper:hover .camera-switch {
    border-color: rgba(255, 255, 255, 0.3);
    box-shadow: 0 0 15px rgba(0, 242, 254, 0.25);
}

.switch-track {
    position: relative;
    width: 48px;
    height: 26px;
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid rgba(239, 68, 68, 0.5);
    border-radius: 20px;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.switch-handle {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: linear-gradient(135deg, #f87171, #ef4444);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 10px;
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.6);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.switch-label {
    font-size: 13px;
    font-weight: 700;
    font-family: 'Space Grotesk', sans-serif;
    color: #f87171;
    transition: color 0.3s ease;
}

/* Checked / Kamera ON State */
.camera-switch-wrapper input[type="checkbox"]:checked + .camera-switch .switch-track {
    background: rgba(16, 185, 129, 0.2);
    border-color: rgba(16, 185, 129, 0.5);
}

.camera-switch-wrapper input[type="checkbox"]:checked + .camera-switch .switch-handle {
    transform: translateX(22px);
    background: linear-gradient(135deg, #34d399, #10b981);
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.8);
}

.camera-switch-wrapper input[type="checkbox"]:checked + .camera-switch .switch-label {
    color: #34d399;
}

.badge {
    padding: 8px 14px;
    border-radius: 30px;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.badge-fps {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #38bdf8;
}

.badge-status {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #34d399;
}

.badge-status.active {
    background: rgba(16, 185, 129, 0.2);
}

.badge-camera-flip {
    background: rgba(121, 40, 202, 0.25);
    border: 1px solid rgba(121, 40, 202, 0.5);
    color: #c084fc;
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
    font-family: 'Outfit', sans-serif;
}

.badge-camera-flip:hover {
    background: rgba(121, 40, 202, 0.45);
    color: #e9d5ff;
    box-shadow: 0 0 12px rgba(121, 40, 202, 0.4);
}

/* Main Layout */
.main-content {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 20px;
}

@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
    }
}

/* Viewport Container */
.viewport-container {
    background: #000;
    border-radius: var(--radius-lg);
    border: 1px solid var(--card-border);
    overflow: hidden;
    position: relative;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 16 / 9;
}

.canvas-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
}

canvas {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* HUD Overlay */
.hud-overlay {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    pointer-events: none;
}

.hud-top {
    top: 20px;
}

.hud-bottom {
    bottom: 20px;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 10px 24px;
    border-radius: 40px;
    display: flex;
    align-items: center;
    gap: 20px;
}

.hud-btn {
    pointer-events: auto;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #fff;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    font-family: 'Outfit', sans-serif;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.hud-btn:hover {
    background: rgba(0, 242, 254, 0.25);
    border-color: var(--accent-cyan);
    color: var(--accent-cyan);
    box-shadow: 0 0 12px rgba(0, 242, 254, 0.4);
}

/* Fullscreen mode styles */
.viewport-container:fullscreen {
    width: 100vw !important;
    height: 100vh !important;
    aspect-ratio: auto !important;
    border-radius: 0 !important;
    border: none !important;
}

.viewport-container:-webkit-full-screen {
    width: 100vw !important;
    height: 100vh !important;
    aspect-ratio: auto !important;
    border-radius: 0 !important;
    border: none !important;
}

.viewport-container:fullscreen .hud-top {
    top: 30px;
}

.viewport-container:fullscreen .hud-bottom {
    bottom: 35px;
    padding: 12px 30px;
}

.status-pill {
    padding: 12px 28px;
    border-radius: 40px;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 15px;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 12px;
    backdrop-filter: blur(12px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}

.pulse-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: currentColor;
    box-shadow: 0 0 10px currentColor;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.4); opacity: 0.6; }
}

.mode-normal {
    background: rgba(30, 41, 59, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #e2e8f0;
}

.mode-gold {
    background: rgba(255, 215, 0, 0.2);
    border: 2px solid var(--accent-gold);
    color: var(--accent-gold);
    box-shadow: 0 0 25px var(--accent-gold-glow);
}

.mode-gray {
    background: rgba(148, 163, 184, 0.25);
    border: 2px solid #cbd5e1;
    color: #f1f5f9;
}

.mode-blur {
    background: rgba(249, 115, 22, 0.25);
    border: 2px solid #fb923c;
    color: #fdba74;
}

.mode-mosaic {
    background: rgba(239, 68, 68, 0.25);
    border: 2px solid #f87171;
    color: #fca5a5;
    box-shadow: 0 0 25px rgba(239, 68, 68, 0.4);
}

.mode-love {
    background: rgba(244, 63, 94, 0.25);
    border: 2px solid #f43f5e;
    color: #fda4af;
    box-shadow: 0 0 25px rgba(244, 63, 94, 0.5);
}

.mode-thermal {
    background: rgba(6, 182, 212, 0.25);
    border: 2px solid #06b6d4;
    color: #67e8f9;
    box-shadow: 0 0 25px rgba(6, 182, 212, 0.5);
}

.mode-disco {
    background: linear-gradient(135deg, rgba(236, 72, 153, 0.35), rgba(168, 85, 247, 0.35), rgba(59, 130, 246, 0.35));
    border: 2px solid #a855f7;
    color: #f472b6;
    box-shadow: 0 0 30px rgba(168, 85, 247, 0.7);
    animation: discoBorder 0.4s infinite alternate ease-in-out;
}

@keyframes discoBorder {
    0% { border-color: #ec4899; box-shadow: 0 0 30px rgba(236, 72, 153, 0.8); }
    50% { border-color: #a855f7; box-shadow: 0 0 35px rgba(168, 85, 247, 0.9); }
    100% { border-color: #3b82f6; box-shadow: 0 0 30px rgba(59, 130, 246, 0.8); }
}

.hand-stat {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.stat-label {
    color: var(--text-muted);
}

.stat-value {
    font-weight: 700;
    color: #38bdf8;
    font-family: 'Space Grotesk', sans-serif;
}

.stat-divider {
    width: 1px;
    height: 16px;
    background: rgba(255, 255, 255, 0.2);
}

/* Sidebar & Cards */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    padding: 20px;
}

.card h2 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #f3f4f6;
}

/* Gesture List */
.gesture-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.gesture-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
}

.gesture-item.active {
    transform: translateX(6px);
}

/* Custom Active Colors for Gesture List Cards when Filter is Used */
.gesture-item.active-gray {
    background: rgba(148, 163, 184, 0.15);
    border-color: #cbd5e1;
    box-shadow: 0 0 15px rgba(203, 213, 225, 0.3);
}

.gesture-item.active-blur {
    background: rgba(249, 115, 22, 0.18);
    border-color: #fb923c;
    box-shadow: 0 0 18px rgba(251, 146, 60, 0.4);
}

.gesture-item.active-mosaic {
    background: rgba(239, 68, 68, 0.18);
    border-color: #f87171;
    box-shadow: 0 0 18px rgba(248, 113, 113, 0.4);
}

.gesture-item.active-love {
    background: rgba(244, 63, 94, 0.22);
    border-color: #f43f5e;
    box-shadow: 0 0 22px rgba(244, 63, 94, 0.5);
}

.gesture-item.active-thermal {
    background: rgba(6, 182, 212, 0.22);
    border-color: #06b6d4;
    box-shadow: 0 0 22px rgba(6, 182, 212, 0.5);
}

.gesture-item.active-disco {
    background: linear-gradient(135deg, rgba(236, 72, 153, 0.25), rgba(168, 85, 247, 0.25));
    border-color: #c084fc;
    box-shadow: 0 0 25px rgba(192, 132, 252, 0.6);
}

/* Camera Viewport Border Glow when Filter is Active */
.viewport-container {
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.viewport-container.glow-gray {
    border-color: rgba(203, 213, 225, 0.6);
    box-shadow: 0 0 30px rgba(203, 213, 225, 0.3);
}

.viewport-container.glow-blur {
    border-color: rgba(251, 146, 60, 0.75);
    box-shadow: 0 0 35px rgba(251, 146, 60, 0.35);
}

.viewport-container.glow-mosaic {
    border-color: rgba(248, 113, 113, 0.85);
    box-shadow: 0 0 35px rgba(239, 68, 68, 0.4);
}

.viewport-container.glow-love {
    border-color: rgba(244, 63, 94, 0.9);
    box-shadow: 0 0 45px rgba(244, 63, 94, 0.5);
}

.viewport-container.glow-thermal {
    border-color: rgba(6, 182, 212, 0.9);
    box-shadow: 0 0 45px rgba(6, 182, 212, 0.5);
}

.viewport-container.glow-disco {
    border-color: #c084fc;
    box-shadow: 0 0 50px rgba(192, 132, 252, 0.6);
    animation: discoGlow 0.5s infinite alternate ease-in-out;
}

@keyframes discoGlow {
    0% { border-color: #f472b6; box-shadow: 0 0 40px rgba(244, 114, 182, 0.6); }
    50% { border-color: #c084fc; box-shadow: 0 0 55px rgba(192, 132, 252, 0.7); }
    100% { border-color: #38bdf8; box-shadow: 0 0 40px rgba(56, 189, 248, 0.6); }
}

.gesture-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.gold-glow { background: rgba(255, 215, 0, 0.15); color: var(--accent-gold); }
.gray-glow { background: rgba(148, 163, 184, 0.15); color: #cbd5e1; }
.blur-glow { background: rgba(249, 115, 22, 0.15); color: #fb923c; }
.mosaic-glow { background: rgba(239, 68, 68, 0.15); color: #f87171; }
.love-glow { background: rgba(244, 63, 94, 0.18); color: #fb7185; }
.thermal-glow { background: rgba(6, 182, 212, 0.18); color: #22d3ee; }
.disco-glow { background: rgba(168, 85, 247, 0.2); color: #c084fc; }

.gesture-info h3 {
    font-size: 14px;
    font-weight: 600;
}

.gesture-info p {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

.tag-gold { background: rgba(255, 215, 0, 0.2); color: var(--accent-gold); }
.tag-gray { background: rgba(148, 163, 184, 0.2); color: #e2e8f0; }
.tag-blur { background: rgba(249, 115, 22, 0.2); color: #fdba74; }
.tag-mosaic { background: rgba(239, 68, 68, 0.2); color: #fca5a5; }
.tag-love { background: rgba(244, 63, 94, 0.2); color: #fda4af; }
.tag-thermal { background: rgba(6, 182, 212, 0.2); color: #67e8f9; }
.tag-disco { background: linear-gradient(135deg, rgba(236, 72, 153, 0.3), rgba(168, 85, 247, 0.3)); color: #f472b6; }

/* Control Group & Inputs */
.control-group {
    margin-top: 16px;
}

.control-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 13px;
}

.slider-value {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    color: var(--accent-cyan);
}

.custom-slider {
    width: 100%;
    accent-color: var(--accent-cyan);
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.toggle-group {
    margin-top: 14px;
}

.toggle-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    font-size: 13px;
}

.toggle-label input {
    display: none;
}

.toggle-switch {
    width: 44px;
    height: 24px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    position: relative;
    transition: background 0.3s;
}

.toggle-switch::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    background: #fff;
    border-radius: 50%;
    top: 3px;
    left: 3px;
    transition: transform 0.3s;
}

.toggle-label input:checked + .toggle-switch {
    background: var(--accent-cyan);
}

.toggle-label input:checked + .toggle-switch::after {
    transform: translateX(20px);
}

/* ==========================================================================
   Comprehensive Responsive Media Queries
   ========================================================================== */

/* Laptop / Medium Desktops (Max 1200px) */
@media (max-width: 1200px) {
    .app-container {
        padding: 16px;
    }
    .main-content {
        grid-template-columns: 1fr 320px;
        gap: 16px;
    }
}

/* Tablet Layout (Max 992px) */
@media (max-width: 992px) {
    .main-content {
        grid-template-columns: 1fr;
    }
    .sidebar {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 16px;
    }
}

/* Mobile Devices (Max 768px) */
@media (max-width: 768px) {
    .app-container {
        padding: 10px;
        gap: 12px;
    }

    .viewport-container {
        width: 100%;
        max-height: 70vh;
        border-radius: var(--radius-md);
    }

    /* Stack header branding & controls */
    .app-header {
        flex-direction: column;
        align-items: stretch;
        gap: 14px;
        padding: 14px 16px;
    }

    .brand {
        justify-content: flex-start;
    }

    .brand h1 {
        font-size: 18px;
    }

    .header-badges {
        justify-content: space-between;
        width: 100%;
        flex-wrap: wrap;
    }

    .sidebar {
        grid-template-columns: 1fr;
    }

    /* HUD Adjustments on Mobile */
    .hud-top {
        top: 10px;
        width: 90%;
    }

    .status-pill {
        padding: 8px 16px;
        font-size: 12px;
        width: 100%;
        justify-content: center;
    }

    .hud-bottom {
        bottom: 10px;
        padding: 8px 14px;
        gap: 10px;
        width: 92%;
        justify-content: space-between;
    }

    .hand-stat {
        font-size: 11px;
    }

    .stat-value {
        font-size: 12px;
    }

    .hud-btn {
        padding: 4px 10px;
        font-size: 11px;
    }

    #fullscreen-btn-text {
        display: none; /* Show icon only on small mobile HUD */
    }
}

/* Ultra Small Screens (Max 480px) */
@media (max-width: 480px) {
    .logo-icon {
        width: 38px;
        height: 38px;
        font-size: 18px;
    }

    .brand h1 {
        font-size: 16px;
    }

    .subtitle {
        font-size: 11px;
    }

    .camera-switch {
        padding: 4px 10px 4px 6px;
    }

    .switch-track {
        width: 40px;
        height: 22px;
    }

    .switch-handle {
        width: 16px;
        height: 16px;
    }

    .camera-switch-wrapper input[type="checkbox"]:checked + .camera-switch .switch-handle {
        transform: translateX(18px);
    }

    .badge {
        padding: 6px 10px;
        font-size: 11px;
    }

    .viewport-container {
        border-radius: var(--radius-md);
    }

    .gesture-item {
        padding: 10px;
    }

    .gesture-icon {
        width: 36px;
        height: 36px;
        font-size: 15px;
    }
}
