:root {
    --bg-color: #050505;
    --text-color: #ffffff;
    --primary-color: #00d4ff;
    --secondary-color: #7000ff;
    --accent-color: #ff00c8;
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --font-main: 'Outfit', sans-serif;
    --font-ui: 'Inter', sans-serif;
}

/* Theme: Neon */
.theme-neon {
    --primary-color: #00ff9f;
    --secondary-color: #00b8ff;
    --accent-color: #ff00ff;
}

/* Theme: Nature */
.theme-nature {
    --primary-color: #a8e063;
    --secondary-color: #56ab2f;
    --accent-color: #48c6ef;
}

/* Theme: Futuristic */
.theme-futuristic {
    --primary-color: #fbff00;
    --secondary-color: #ff5e00;
    --accent-color: #00f2ff;
}

/* Theme: Dream */
.theme-dream {
    --primary-color: #fceabb;
    --secondary-color: #f8b500;
    --accent-color: #ff9a9e;
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-main);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

#app {
    position: relative;
    width: 100%;
    height: 100%;
}

#main-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.ui-overlay {
    position: relative;
    z-index: 10;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 2rem;
    pointer-events: none;
}

.ui-overlay * {
    pointer-events: auto;
}

/* Glassmorphism Utility */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 1.5rem;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.gradient-text {
    background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.stats {
    display: flex;
    gap: 1.5rem;
}

.stat-item {
    background: var(--glass-bg);
    padding: 0.5rem 1.2rem;
    border-radius: 12px;
    border-left: 3px solid var(--primary-color);
    display: flex;
    flex-direction: column;
}

.stat-item .label {
    font-family: var(--font-ui);
    font-size: 0.7rem;
    font-weight: 600;
    opacity: 0.6;
    letter-spacing: 1px;
}

.stat-item .value {
    font-size: 1.2rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

/* Detection Panel */
.detection-panel {
    align-self: flex-start;
    margin-top: 2rem;
}

.current-emotion .label {
    font-size: 0.8rem;
    opacity: 0.7;
    letter-spacing: 2px;
}

.current-emotion h1 {
    font-size: 4rem;
    font-weight: 900;
    text-transform: uppercase;
    line-height: 1;
    margin-top: 0.5rem;
    filter: drop-shadow(0 0 10px var(--primary-color));
    transition: all 0.3s ease;
}

#emotion-meter-container {
    width: 200px;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    margin-top: 1rem;
    overflow: hidden;
}

.meter-fill {
    height: 100%;
    width: 0%;
    background: var(--primary-color);
    transition: width 0.2s ease, background 0.5s ease;
    box-shadow: 0 0 10px var(--primary-color);
}

/* Challenge Card */
.challenge-panel {
    position: absolute;
    top: 50%;
    right: 2rem;
    transform: translateY(-50%);
    width: 300px;
}

.challenge-card {
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 1.5rem;
    border-right: 4px solid var(--accent-color);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.badge {
    background: var(--accent-color);
    color: black;
    font-size: 0.6rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    display: inline-block;
    margin-bottom: 0.5rem;
}

#challenge-desc {
    font-size: 1.1rem;
    font-weight: 600;
}

/* Footer & Controls */
.footer {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.theme-selector {
    display: flex;
    gap: 0.8rem;
    background: var(--glass-bg);
    padding: 0.6rem;
    border-radius: 20px;
    backdrop-filter: blur(10px);
}

.theme-btn {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    border: none;
    background: rgba(255, 255, 255, 0.05);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.theme-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

.theme-btn.active {
    background: var(--primary-color);
    color: black;
    box-shadow: 0 0 15px var(--primary-color);
}

.primary-btn {
    background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
    border: none;
    color: white;
    padding: 1rem 2rem;
    border-radius: 50px;
    font-family: var(--font-main);
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    cursor: pointer;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    transition: all 0.3s ease;
}

.primary-btn.secondary {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
}

.primary-btn.secondary:hover {
    background: var(--glass-bg);
    border-color: var(--accent-color);
}

.primary-btn.hidden {
    display: none;
}

.primary-btn:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 15px 40px rgba(0,0,0,0.4);
}

.primary-btn:active {
    transform: translateY(0);
}

/* Loading Screen */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    transition: opacity 0.8s ease, visibility 0.8s ease;
}

.loading-overlay.hidden {
    opacity: 0;
    visibility: hidden;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    margin: 0 auto 2rem;
    animation: spin 1s linear infinite;
}

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

.loader-content h2 { margin-bottom: 0.5rem; letter-spacing: 1px; }
.loader-content p { opacity: 0.5; font-size: 0.9rem; }

/* Responsive adjustments */
@media (max-width: 768px) {
    .current-emotion h1 { font-size: 2.5rem; }
    .challenge-panel { position: static; transform: none; width: 100%; margin: 1rem 0; }
    .footer { flex-direction: column; align-items: center; gap: 1.5rem; }
}

.back-to-dashboard-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 99999;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: rgba(15, 15, 25, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 30px;
    color: #fff;
    text-decoration: none;
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
    cursor: pointer;
}
.back-to-dashboard-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
    box-shadow: 0 4px 25px rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}
.back-to-dashboard-btn svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    stroke-width: 2.5;
    fill: none;
}
