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

:root {
    --primary: #6366f1;
    --secondary: #a855f7;
    --accent: #06b6d4;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --dark: #0a0a0f;
    --dark-secondary: #12121a;
    --light: #f8fafc;
    --text-primary: rgba(255, 255, 255, 0.95);
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-muted: rgba(255, 255, 255, 0.5);
    --glass-bg: rgba(10, 10, 15, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--dark);
    color: var(--light);
    overflow: hidden;
    cursor: grab;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body:active {
    cursor: grabbing;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at center, transparent 0%, var(--dark) 100%);
    pointer-events: none;
    z-index: 2;
}

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

#ui-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 20px;
}

#ui-overlay > * {
    pointer-events: auto;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: var(--glass-bg);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-radius: var(--radius-xl);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    animation: slideDown 0.8s ease forwards;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.logo-icon {
    font-size: 1.6rem;
    animation: rotate 8s linear infinite;
}

@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.logo-text {
    font-size: 1.3rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--light), var(--accent));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}

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

.nav-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border: none;
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    font-family: inherit;
    transition: all var(--transition-normal);
    border: 1px solid transparent;
}

.nav-icon {
    font-size: 1.1rem;
}

.nav-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.15);
}

.nav-btn.active {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
}

.header-actions {
    display: flex;
    gap: 8px;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-normal);
    border: 1px solid transparent;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-color: rgba(255, 255, 255, 0.15);
}

.world-info {
    position: absolute;
    bottom: 100px;
    left: 20px;
    max-width: 420px;
    opacity: 0;
    transform: translateY(30px);
    animation: slideUp 0.8s ease forwards;
    animation-delay: 0.5s;
}

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

.world-badge {
    display: inline-block;
    padding: 6px 14px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
    margin-bottom: 12px;
    letter-spacing: 0.5px;
}

.world-info h1 {
    font-size: 3.2rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--light) 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    line-height: 1.1;
    margin-bottom: 12px;
    letter-spacing: -1px;
}

.world-info p {
    font-size: 1.1rem;
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 16px;
}

.world-stats {
    display: flex;
    gap: 20px;
}

.world-stat {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.world-stat-icon {
    font-size: 1rem;
}

.controls-hint {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 14px 28px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 30px;
    border: 1px solid var(--glass-border);
    font-size: 0.85rem;
    color: var(--text-muted);
    opacity: 0;
    animation: fadeIn 1s ease forwards;
    animation-delay: 1s;
}

@keyframes fadeIn {
    to { opacity: 1; }
}

.hint-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.hint-icon {
    font-size: 1rem;
}

.separator {
    color: rgba(255, 255, 255, 0.15);
}

.stats {
    position: absolute;
    bottom: 30px;
    right: 20px;
    display: flex;
    gap: 12px;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    padding: 12px 16px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: var(--radius-md);
    border: 1px solid var(--glass-border);
    min-width: 80px;
}

.stat-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
}

.stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 500;
}

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

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

.loader-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 40px;
}

.loader {
    position: relative;
    width: 100px;
    height: 100px;
}

.loader-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 3px solid transparent;
    border-radius: 50%;
}

.loader-ring:nth-child(1) {
    border-top-color: var(--primary);
    animation: spin 1.5s linear infinite;
}

.loader-ring:nth-child(2) {
    border-right-color: var(--secondary);
    animation: spin 2s linear infinite reverse;
    width: 70px;
    height: 70px;
    top: 15px;
    left: 15px;
}

.loader-ring:nth-child(3) {
    border-bottom-color: var(--accent);
    animation: spin 1s linear infinite;
    width: 40px;
    height: 40px;
    top: 30px;
    left: 30px;
}

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

.loading-content {
    text-align: center;
}

.loading-title {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--light), var(--accent));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 12px;
}

.loading-text {
    font-size: 0.95rem;
    color: var(--text-muted);
    letter-spacing: 1px;
    margin-bottom: 20px;
}

.loading-bar {
    width: 200px;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
    margin: 0 auto;
}

.loading-progress {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    border-radius: 2px;
    width: 0%;
    transition: width 0.3s ease;
    animation: loadingProgress 2s ease forwards;
}

@keyframes loadingProgress {
    0% { width: 0%; }
    50% { width: 70%; }
    100% { width: 100%; }
}

#portal-modal,
#about-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 1;
    transition: opacity var(--transition-normal);
    backdrop-filter: blur(8px);
}

#portal-modal.hidden,
#about-modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background: linear-gradient(145deg, rgba(20, 20, 30, 0.98), rgba(30, 30, 45, 0.98));
    padding: 48px;
    border-radius: var(--radius-xl);
    max-width: 500px;
    width: 90%;
    text-align: center;
    position: relative;
    border: 1px solid var(--glass-border);
    box-shadow: 0 25px 80px -12px rgba(0, 0, 0, 0.6);
    animation: modalIn 0.4s ease;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.close-btn {
    position: absolute;
    top: 20px;
    right: 24px;
    background: rgba(255, 255, 255, 0.05);
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    transform: rotate(90deg);
}

.modal-icon {
    font-size: 3rem;
    margin-bottom: 20px;
    animation: float 3s ease-in-out infinite;
}

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

.modal-content h2 {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 16px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.modal-content p {
    color: var(--text-secondary);
    line-height: 1.7;
    font-size: 1rem;
}

.modal-divider {
    width: 60px;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    margin: 24px auto;
    border-radius: 2px;
}

.modal-particles {
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.modal-particle {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    animation: particleFloat 2s ease-in-out infinite;
}

.modal-particle:nth-child(odd) {
    background: var(--primary);
}

.modal-particle:nth-child(even) {
    background: var(--accent);
    animation-delay: 0.5s;
}

@keyframes particleFloat {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-15px) scale(1.2); }
}

.about-content {
    max-width: 560px;
    text-align: left;
}

.about-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.about-icon {
    font-size: 2rem;
}

.about-header h2 {
    margin-bottom: 0;
    background: linear-gradient(135deg, var(--light), var(--accent));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.about-subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 0;
}

.about-divider {
    width: 100%;
    height: 1px;
    background: var(--glass-border);
    margin: 24px 0;
}

.about-section {
    margin-bottom: 24px;
}

.about-section h3 {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--accent);
    margin-bottom: 12px;
}

.about-section p {
    font-size: 0.95rem;
    line-height: 1.7;
}

.tech-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tech-tag {
    padding: 6px 12px;
    background: rgba(99, 102, 241, 0.15);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 20px;
    font-size: 0.8rem;
    color: var(--primary);
    font-weight: 500;
}

.feature-list {
    list-style: none;
    padding: 0;
}

.feature-list li {
    padding: 8px 0;
    padding-left: 24px;
    position: relative;
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.feature-list li::before {
    content: '✦';
    position: absolute;
    left: 0;
    color: var(--accent);
}

.about-footer {
    padding-top: 20px;
    border-top: 1px solid var(--glass-border);
    text-align: center;
}

.about-footer p {
    color: var(--text-muted);
    font-size: 0.85rem;
}

@media (max-width: 900px) {
    header {
        flex-direction: column;
        gap: 16px;
        padding: 16px;
    }

    nav {
        flex-wrap: wrap;
        justify-content: center;
    }

    .nav-label {
        display: none;
    }

    .nav-btn {
        padding: 10px 14px;
    }

    .nav-icon {
        font-size: 1.3rem;
    }

    .header-actions {
        display: none;
    }

    .world-info {
        left: 16px;
        right: 16px;
        bottom: 120px;
    }

    .world-info h1 {
        font-size: 2.2rem;
    }

    .controls-hint {
        flex-wrap: wrap;
        justify-content: center;
        gap: 12px;
        padding: 12px 20px;
        font-size: 0.75rem;
    }

    .stats {
        bottom: 100px;
    }

    .modal-content {
        padding: 32px;
        margin: 16px;
    }
}

@media (max-width: 480px) {
    .world-info h1 {
        font-size: 1.8rem;
    }

    .world-info p {
        font-size: 0.95rem;
    }

    .world-stats {
        flex-direction: column;
        gap: 8px;
    }

    .controls-hint {
        display: none;
    }

    .stats {
        left: 16px;
        right: 16px;
        justify-content: space-between;
    }

    .stat {
        flex: 1;
    }
}
