:root {
    --bg-dark: #0a0a0f;
    --bg-light: #1a1a2e;
    --text-primary: #ffffff;
    --text-secondary: #a0a0b0;
    --accent-genesis: #FFD700;
    --accent-generative: #00FF7F;
    --glass-bg: rgba(20, 20, 35, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
}

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

body,
html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: radial-gradient(circle at center, var(--bg-light), var(--bg-dark));
    color: var(--text-primary);
}

#visualizer-container {
    position: relative;
    width: 100%;
    height: 100%;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* Glassmorphism Panels */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

/* Sidebar */
#sidebar {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 280px;
    z-index: 10;
}

#sidebar h1 {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 20px;
    letter-spacing: 0.5px;
}

.stats-group {
    margin-bottom: 24px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.9rem;
}

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

.stat-item .value {
    font-weight: 500;
    font-feature-settings: "tnum";
}

.legend h3 {
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.legend-item {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    font-size: 0.85rem;
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 10px;
}

.dot.genesis {
    background-color: var(--accent-genesis);
    box-shadow: 0 0 8px var(--accent-genesis);
}

.dot.generative {
    background-color: var(--accent-generative);
    box-shadow: 0 0 5px var(--accent-generative);
}

.dot.year-ring {
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: transparent;
}

/* External Links in Sidebar */
.external-links {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.link-item {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 0.8rem;
    transition: color 0.2s, transform 0.2s;
}

.link-item:hover {
    color: var(--text-primary);
    transform: translateX(4px);
}

.link-item img {
    width: 18px;
    height: 18px;
    object-fit: contain;
    filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.2));
}

/* Controls */
#controls {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: flex;
    gap: 10px;
    padding: 10px;
    z-index: 10;
}

#controls button {
    width: 40px;
    height: 40px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.2rem;
    transition: background 0.2s;
}

#controls button:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Detail Panel */
#detail-panel {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 250px;
    z-index: 11;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s;
}

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

#btn-close-detail {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
}

#detail-id {
    font-size: 1.1rem;
    margin-bottom: 15px;
    padding-right: 20px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.detail-row span:first-child {
    color: var(--text-secondary);
}

/* Mobile Responsiveness */
@media (max-width: 600px) {
    #mobile-header {
        display: flex !important; /* Override hidden */
        justify-content: space-between;
        align-items: center;
        position: absolute;
        top: 20px;
        left: 20px;
        right: 20px;
        z-index: 20;
        padding: 15px 20px;
    }

    #mobile-header h1 {
        font-size: 1.2rem;
        font-weight: 600;
        margin: 0;
    }

    #btn-mobile-toggle {
        background: none;
        border: none;
        color: var(--text-primary);
        font-size: 1.2rem;
        cursor: pointer;
        transition: transform 0.3s ease;
    }

    #btn-mobile-toggle.rotated {
        transform: rotate(180deg);
    }

    /* Hide Sidebar Main Title on Mobile as it's in the header now */
    #sidebar h1 {
        display: none;
    }

    #sidebar {
        width: calc(100% - 40px);
        top: 80px; /* Below header */
        left: 20px;
        max-height: 0;
        overflow: hidden;
        padding-top: 0;
        padding-bottom: 0;
        border: none; /* Hide border when collapsed */
        opacity: 0;
        transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        pointer-events: none;
    }

    #sidebar.sidebar-open {
        max-height: 500px; /* Arbitrary large height */
        padding: 20px;
        border: 1px solid var(--glass-border);
        opacity: 1;
        pointer-events: auto;
    }

    #detail-panel {
        width: calc(100% - 40px);
        top: 80px; /* Below header */
        right: 20px;
        left: 20px; /* Center it effectively */
    }
}

/* Loading Screen Styles */
#loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: opacity 1s ease-out, visibility 1s;
}

#loading-screen.fade-out {
    opacity: 0;
    visibility: hidden;
}

.loading-content {
    text-align: center;
    width: 80%;
    max-width: 600px;
}

.animate-title {
    font-size: 3rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    background: linear-gradient(45deg, #fff, var(--accent-genesis), var(--accent-generative));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: titleShift 3s ease-in-out infinite alternate;
}

@keyframes titleShift {
    from {
        background-position: 0% 50%;
        filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.2));
    }

    to {
        background-position: 100% 50%;
        filter: drop-shadow(0 0 15px var(--accent-generative));
    }
}

.animate-subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
    letter-spacing: 2px;
    opacity: 0;
    animation: fadeIn 1s ease-out forwards 0.5s;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.progress-container {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    margin-bottom: 1rem;
    overflow: hidden;
}

#progress-bar {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--accent-genesis), var(--accent-generative));
    transition: width 0.3s ease-out;
    box-shadow: 0 0 10px var(--accent-generative);
}

#loading-status {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-family: monospace;
}

/* Icon Contraction Overlay */
#icon-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1001;
    pointer-events: none;
}

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

#contracting-icon {
    width: 80vh;
    height: 80vh;
    object-fit: contain;
    opacity: 0;
}

.animate-contract {
    animation: contractAndFade 1.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes contractAndFade {
    0% {
        transform: scale(1.5);
        opacity: 0;
        filter: blur(10px);
    }

    20% {
        transform: scale(1);
        opacity: 1;
        filter: blur(0);
    }

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