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

:root {
    --bg-base: #020617; /* Deep slate */
    --primary: #0ea5e9; /* Cyan / Blue */
    --primary-glow: rgba(14, 165, 233, 0.4);
    --secondary: #22c55e; /* Green */
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --glass-bg: rgba(15, 23, 42, 0.6);
    --glass-border: rgba(255, 255, 255, 0.08);
}

body {
    background-color: var(--bg-base);
    color: var(--text-main);
    font-family: 'Inter', sans-serif;
    overflow: hidden;
    width: 100vw;
    height: 100vh;
}

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

/* Typography Overrides */
h1, h2, h3, .logo-text, .nav-btn {
    font-family: 'Outfit', sans-serif;
}

/* Glassmorphic Navbar */
.glass-nav {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 80px;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 40px;
    background: linear-gradient(180deg, rgba(2,6,23,0.9) 0%, rgba(2,6,23,0) 100%);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--glass-border);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 24px;
    font-weight: 800;
    letter-spacing: 0.5px;
    text-shadow: 0 0 15px var(--primary-glow);
}

.logo-icon {
    font-size: 28px;
    animation: float 3s ease-in-out infinite;
}

nav {
    display: flex;
    gap: 20px;
}

.nav-btn {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid transparent;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-btn:hover {
    color: var(--text-main);
    border-color: var(--glass-border);
    background: var(--glass-bg);
}

.nav-btn.active {
    color: var(--primary);
    background: rgba(14, 165, 233, 0.1);
    border-color: rgba(14, 165, 233, 0.3);
    box-shadow: 0 0 20px var(--primary-glow);
}

/* Diagram Modal Window */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(2, 6, 23, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 1;
    transition: opacity 0.4s ease;
}

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

.glass-panel-large {
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 24px;
    padding: 40px;
    width: 80%;
    max-width: 900px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 40px 80px rgba(0, 0, 0, 0.7), inset 0 0 0 1px rgba(255, 255, 255, 0.1);
    position: relative;
    transform: scale(1) translateY(0);
    transition: transform 0.4s cubic-bezier(0.19, 1, 0.22, 1);
}

.modal-overlay.hidden .glass-panel-large {
    transform: scale(0.95) translateY(20px);
}

#close-modal-btn {
    position: absolute;
    top: 24px;
    right: 24px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text-main);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 24px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 2;
}

#close-modal-btn:hover {
    background: rgba(239, 68, 68, 0.8);
    border-color: rgba(239, 68, 68, 1);
    transform: rotate(90deg);
}

.modal-header {
    margin-bottom: 25px;
    text-align: center;
}

#modal-title {
    font-family: 'Outfit', sans-serif;
    font-size: 38px;
    font-weight: 800;
    margin-top: 15px;
    background: linear-gradient(135deg, #ffffff 0%, #38bdf8 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.modal-body {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.diagram-container {
    width: 100%;
    height: 400px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 16px;
    border: 1px solid var(--glass-border);
    overflow: hidden;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: inset 0 0 30px rgba(0,0,0,0.6);
}

.diagram-container canvas {
    width: 100% !important;
    height: 100% !important;
    outline: none;
}

#modal-diagram {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.diagram-container:hover #modal-diagram {
    transform: scale(1.02);
}

.modal-text {
    font-size: 18px;
    line-height: 1.6;
    color: var(--text-muted);
    text-align: center;
    padding: 0 20px;
}

/* Interactive Info Panel */
.glass-panel {
    position: absolute;
    top: 100px;
    right: 40px;
    width: 360px;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 30px;
    z-index: 20;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5), inset 0 0 0 1px rgba(255, 255, 255, 0.05);
    transition: all 0.5s cubic-bezier(0.19, 1, 0.22, 1);
    transform: translateY(0);
    opacity: 1;
}

.glass-panel.hidden {
    transform: translateX(120%) scale(0.95);
    opacity: 0;
    pointer-events: none;
}

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

.badge {
    background: rgba(34, 197, 94, 0.15);
    color: var(--secondary);
    border: 1px solid rgba(34, 197, 94, 0.3);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

#close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 28px;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
}

#close-btn:hover {
    color: #fff;
}

#fact-title {
    font-size: 28px;
    font-weight: 800;
    margin-bottom: 12px;
    line-height: 1.2;
    background: linear-gradient(135deg, #fff 0%, #cbd5e1 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

#fact-desc {
    font-size: 15px;
    line-height: 1.6;
    color: var(--text-muted);
    margin-bottom: 30px;
}

/* Progress Tracking */
.progress-container {
    background: rgba(0, 0, 0, 0.2);
    padding: 15px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

#fact-counter {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 8px;
    font-weight: 500;
}

.progress-bar-bg {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    border-radius: 3px;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 10px var(--primary-glow);
}

/* Bottom Hint Overlay */
#hint-text {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    z-index: 10;
    background: var(--glass-bg);
    padding: 12px 24px;
    border-radius: 30px;
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(8px);
    pointer-events: none;
    animation: pulse 2s infinite;
}

#hint-text p {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.4;
}

#hint-text strong {
    color: var(--text-main);
}

/* Loader Base */
.loader-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--bg-base);
    z-index: 999;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 20px;
    transition: opacity 1s ease;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(14, 165, 233, 0.2);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    box-shadow: 0 0 20px var(--primary-glow);
}

/* Keyframes */
@keyframes spin { 
    to { transform: rotate(360deg); } 
}
@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}
@keyframes pulse {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 1; }
}

/* Micro-animations and responsive */
@media (max-width: 768px) {
    .glass-nav { padding: 0 20px; height: 70px; }
    .logo-text { font-size: 20px; }
    .nav-btn { font-size: 13px; padding: 8px 12px; }
    .glass-panel { top: 90px; right: 20px; left: 20px; width: auto; }
}
