:root {
    /* Pastel Theme */
    --primary: #d4a5e0;
    --primary-light: #f3e5f5;
    --secondary: #90caf9;
    --background: #fdfbf7;
    --glass-bg: rgba(255, 255, 255, 0.4);
    --glass-border: rgba(255, 255, 255, 0.6);
    --text: #4a4a4a;
    --text-muted: #8e8e8e;

    /* Emotion Colors (Softened) */
    --happy: #81c784;
    --sad: #64b5f6;
    --angry: #e57373;
    --surprise: #ffb74d;
    --neutral: #9e9e9e;
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--background);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden; /* Stop scrolling as it's a fullscreen app now */
}

/* Rich Aesthetics: Animated gradient background */
.background-animation {
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at center, rgba(212, 165, 224, 0.4) 0%, transparent 50%),
                radial-gradient(circle at bottom right, rgba(144, 202, 249, 0.4) 0%, transparent 50%),
                radial-gradient(circle at top left, rgba(255, 183, 77, 0.2) 0%, transparent 50%);
    animation: bg-pulse 15s infinite alternate ease-in-out;
    z-index: -2;
}

#particleCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 10; /* Put behind the UI but above background */
}

/* Fidget Orb */
.fidget-orb-container {
    position: fixed;
    bottom: 30px;
    right: 200px; /* Moved slightly more left so it doesn't overlap stats */
    width: 100px;
    height: 100px;
    z-index: 50;
    cursor: grab;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.fidget-orb-container:active {
    cursor: grabbing;
    transform: scale(0.9);
}

.orb-core {
    width: 40px;
    height: 40px;
    background: radial-gradient(circle at 30% 30%, #fff, var(--primary));
    border-radius: 50%;
    box-shadow: 0 0 20px var(--primary), inset 0 0 10px rgba(0, 0, 0, 0.5);
    z-index: 5;
    transition: background 0.5s ease, box-shadow 0.5s ease;
}

.orb-ring {
    position: absolute;
    border-radius: 50%;
    border: 2px solid transparent;
    pointer-events: none;
}

.ring-1 {
    width: 60px;
    height: 60px;
    border-top: 2px solid var(--secondary);
    border-bottom: 2px solid var(--secondary);
    animation: spin 3s linear infinite;
}

.ring-2 {
    width: 80px;
    height: 80px;
    border-left: 2px solid var(--primary-light);
    border-right: 2px solid var(--primary-light);
    animation: spin-reverse 5s linear infinite;
}

.ring-3 {
    width: 100px;
    height: 100px;
    border-top: 1px dashed var(--happy);
    border-bottom: 1px dashed var(--happy);
    animation: spin 7s linear infinite;
}

.orb-pulse {
    animation: intense-pulse 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

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

@keyframes spin-reverse {
    100% {
        transform: rotate(-360deg);
    }
}

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

    50% {
        transform: scale(1.4);
    }

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

@keyframes bg-pulse {
    0% {
        transform: scale(1) rotate(0deg);
    }

    100% {
        transform: scale(1.1) rotate(3deg);
    }
}

.container {
    position: relative;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    z-index: 1;
}

/* Header (Top Left Branding) */
.header {
    position: absolute;
    top: 2rem;
    left: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05); /* Softer shadow */
}

.logo {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text);
    /* Subtle gradient for text */
    background: linear-gradient(45deg, #a888c3, #90caf9);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Quote/Advice Area (Top Right) */
.quote-area {
    position: absolute;
    top: 2rem;
    right: 3rem; /* Leave some space before the edge */
    width: 250px;
    z-index: 10;
}

.quote-box {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1.2rem;
}

.quote-icon {
    font-size: 1.2rem;
    color: var(--primary);
    opacity: 0.7;
}

#emotionQuote {
    font-size: 0.9rem;
    font-style: italic;
    color: var(--text);
    line-height: 1.4;
    transition: opacity 0.3s ease;
}


/* Central Minimal Reactive Face */
.central-face-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3rem;
    z-index: 5;
}

.reactive-face {
    width: 320px;
    height: 180px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    /* Add constant minimal idle motion */
    animation: idle-float 4s ease-in-out infinite;
}

@keyframes idle-float {
    0%, 100% { transform: translateY(0px) scale(1); }
    50% { transform: translateY(-8px) scale(1.02); }
}

.eyes {
    display: flex;
    justify-content: space-between;
    width: 100%;
    padding: 0 10px; /* narrowed padding to allow bigger eyes */
    z-index: 2; /* Ensure eyes stay above decorations */
}

/* Base eye */
.eye {
    width: 80px; /* Made eyes significantly wider */
    height: 110px; /* Made eyes taller */
    background-color: var(--text);
    border-radius: 50px;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform-origin: center;
}

/* Add blink class to be triggered via JS */
.eye.blink {
    animation: blink-anim 0.2s ease-in-out;
}

@keyframes blink-anim {
    0%, 100% { transform: scaleY(1); }
    50% { transform: scaleY(0.1); }
}

.mouth {
    width: 90px;
    height: 30px;
    background-color: var(--text);
    border-radius: 20px;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    margin-bottom: -10px;
    z-index: 2;
}

/* --- Base Emotion Decorations --- */
.decorations {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

/* Tears */
.tear {
    position: absolute;
    width: 25px;
    height: 35px;
    background: var(--sad);
    border-radius: 0 50% 50% 50%;
    transform: rotate(45deg);
    opacity: 0;
    transition: opacity 0.5s;
}
.left-tear { top: 70px; left: 15px; }
.right-tear { top: 70px; right: 15px; }

/* Fumes */
.fume {
    position: absolute;
    width: 40px;
    height: 40px;
    background: var(--angry);
    border-radius: 50%;
    opacity: 0;
    filter: blur(8px);
    transition: opacity 0.5s;
}
.left-fume { top: -20px; left: -20px; }
.right-fume { top: -20px; right: -20px; }

/* Sweat */
.sweat {
    position: absolute;
    top: -10px;
    right: 30px;
    width: 20px;
    height: 30px;
    background: var(--surprise);
    border-radius: 0 50% 50% 50%;
    transform: rotate(45deg);
    opacity: 0;
    transition: opacity 0.5s;
}

/* --- Face Emotion States (More Dynamic) --- */

/* Happy Face */
.face-happy .eye {
    height: 70px;
    border-radius: 50px 50px 20px 20px;
    transform: translateY(20px);
}
.face-happy .mouth {
    width: 140px;
    height: 45px;
    border-radius: 10px 10px 70px 70px;
    transform: translateY(-20px);
    background-color: var(--happy);
}

/* Sad Face */
.face-sad .eye {
    height: 90px;
    transform: translateY(20px) rotate(-20deg);
}
.face-sad .right-eye {
    transform: translateY(20px) rotate(20deg);
}
.face-sad .mouth {
    width: 100px;
    height: 30px;
    border-radius: 70px 70px 15px 15px;
    transform: translateY(20px);
    background-color: var(--sad);
}
/* Show Tears */
.face-sad .tear { 
    opacity: 0.8; 
    animation: flow 2s ease-in infinite;
}

@keyframes flow {
    0% { transform: translateY(0) rotate(45deg) scale(1); opacity: 0; }
    20% { opacity: 0.8; transform: translateY(10px) rotate(45deg) scale(1.1); }
    100% { transform: translateY(50px) rotate(45deg) scale(0.5); opacity: 0; }
}

/* Angry Face */
.face-angry .eye {
    height: 80px;
    border-radius: 15px 15px 50px 50px;
    transform: translateY(15px) rotate(25deg);
}
.face-angry .right-eye {
    transform: translateY(15px) rotate(-25deg);
}
.face-angry .mouth {
    width: 120px;
    height: 20px;
    border-radius: 15px;
    transform: translateY(0px) rotate(-5deg); /* slight sneer */
    background-color: var(--angry);
    animation: shake 0.5s infinite;
}
/* Show Fumes */
.face-angry .fume {
    opacity: 0.6;
    animation: rise 3s ease-out infinite;
}

@keyframes shake {
    0%, 100% { transform: translateY(0px) rotate(-5deg); }
    50% { transform: translateY(2px) rotate(-3deg); }
}

@keyframes rise {
    0% { transform: translateY(0) scale(1); opacity: 0.6; }
    50% { opacity: 0.3; }
    100% { transform: translateY(-40px) scale(2); opacity: 0; }
}

/* Surprise Face */
.face-surprise .eye {
    height: 120px;
    width: 90px;
    border-radius: 50%;
    transform: translateY(-15px);
}
.face-surprise .mouth {
    width: 60px;
    height: 80px;
    border-radius: 50%;
    transform: translateY(15px);
    background-color: var(--surprise);
}
/* Show Sweat */
.face-surprise .sweat {
    opacity: 0.9;
    animation: drop 1.5s ease-in infinite;
}

@keyframes drop {
    0% { transform: translateY(0) rotate(45deg); opacity: 0; }
    30% { transform: translateY(5px) rotate(45deg); opacity: 0.9; }
    100% { transform: translateY(30px) rotate(45deg); opacity: 0; }
}

/* Neutral Face (Default) uses base .eye and .mouth classes */


/* Emotion Labels Text below face */
.emotion-label-container {
    text-align: center;
    background: var(--glass-bg);
    padding: 1rem 2rem;
    border-radius: 30px;
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

.emotion-label-container h3 {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text);
    margin-bottom: 0.2rem;
    letter-spacing: 1px;
}

.emotion-label-container p {
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 600;
}


/* Camera Area */
.camera-area {
    position: absolute;
    bottom: 2rem;
    left: 2rem;
    width: 320px;
    z-index: 10;
}

/* Slide-out Stats Panel Wrapper */
.stats-area-wrapper {
    position: absolute;
    top: 50%;
    right: 0;
    transform: translateY(-50%) translateX(calc(100% - 40px)); /* Hide panel mostly */
    display: flex;
    align-items: center;
    z-index: 20;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.stats-area-wrapper:hover,
.stats-area-wrapper:focus-within {
    transform: translateY(-50%) translateX(0); /* Reveal all on hover */
}

/* Stats Hover Trigger / Handle */
.stats-trigger {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-right: none;
    border-radius: 16px 0 0 16px;
    padding: 1.5rem 0.6rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    backdrop-filter: blur(16px);
    box-shadow: -4px 4px 15px rgba(0, 0, 0, 0.05);
    cursor: pointer;
    color: var(--primary);
    font-weight: 800;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    transform: rotate(180deg); /* Text reads from bottom to top */
    transition: background 0.3s;
}

.stats-trigger:hover {
    background: var(--glass-border);
}

/* Layout for Emotion Stats */
.stats-area {
    width: 280px;
    /* remove transform since parent wrapper handles position now */
}

/* Layout for Manual Triggers */
.manual-triggers-area {
    position: absolute;
    bottom: 2rem;
    right: 320px; /* offset slightly from stats */
    z-index: 10;
}

/* Reusable Glass Panel component */
.glass-panel {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 1.5rem;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08); /* softer shadow */
    transition: transform 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.glass-panel:hover {
    transform: translateY(-3px);
    border-color: rgba(255, 255, 255, 0.15);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.panel-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary);
}

.badge {
    background: rgba(255, 255, 255, 0.4);
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-muted);
}

/* Video Container within Camera Area */
.video-container {
    position: relative;
    width: 100%;
    aspect-ratio: 16/9;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.05);
}

.video-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: var(--text-muted);
    gap: 0.5rem;
}

.video-placeholder i {
    font-size: 2rem;
    color: rgba(0, 0, 0, 0.1);
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-5px); }
    100% { transform: translateY(0px); }
}

.video-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.scanner-line {
    position: absolute;
    width: 100%;
    height: 2px;
    background: var(--secondary);
    box-shadow: 0 0 10px var(--secondary), 0 0 20px var(--secondary);
    top: 0;
    left: 0;
    opacity: 0.6;
    animation: scan 3s linear infinite;
    display: none;
}

@keyframes scan {
    0% { top: 0; }
    50% { top: 100%; }
    100% { top: 0; }
}

/* Controls overlay over video area for compactness */
.controls-overlay {
    margin-top: 1rem;
    display: flex;
    justify-content: center;
    gap: 0.5rem;
}

/* Emotion Section */
.current-emotion {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.8rem;
    padding: 2rem 1rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 20px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.03);
}

.emotion-icon {
    font-size: 4.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 110px;
    height: 110px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.05), transparent);
    box-shadow: inset 0 0 20px rgba(255, 255, 255, 0.05), 0 8px 16px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--happy);
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.emotion-icon.pop {
    animation: pop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

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

    50% {
        transform: scale(1.15);
    }

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

.current-emotion h3 {
    font-size: 1.6rem;
    letter-spacing: 1px;
    font-weight: 800;
}

.current-emotion p {
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 600;
}

#emotionConfidence {
    color: var(--text);
}

/* Emotion Progress Bars */
.emotion-stats {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.stat-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
}

.stat-row span {
    width: 65px;
}

.progress-bar {
    flex: 1;
    height: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    overflow: hidden;
    position: relative;
}

.progress {
    height: 100%;
    border-radius: 8px;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dynamic Emotion Classes */
.fill-happy {
    background-color: var(--happy);
    box-shadow: 0 0 10px var(--happy);
}

.fill-sad {
    background-color: var(--sad);
    box-shadow: 0 0 10px var(--sad);
}

.fill-angry {
    background-color: var(--angry);
    box-shadow: 0 0 10px var(--angry);
}

.fill-surprise {
    background-color: var(--surprise);
    box-shadow: 0 0 10px var(--surprise);
}

.fill-neutral {
    background-color: var(--neutral);
    box-shadow: 0 0 10px var(--neutral);
}

/* Interactive Controls Section */
.control-groups {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.control-group h3 {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.button-row {
    display: flex;
    gap: 0.8rem;
    flex-wrap: wrap;
}

.btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text);
    padding: 0.8rem 1.2rem;
    border-radius: 12px;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.btn.active {
    background: rgba(14, 165, 233, 0.2);
    border-color: var(--secondary);
    box-shadow: 0 0 15px rgba(14, 165, 233, 0.3);
}

.btn-label {
    margin: 0;
    cursor: pointer;
}

.btn-emo {
    flex: 1;
    min-width: 90px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text);
    padding: 0.6rem;
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.btn-emo:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.05);
}