/* Import futuristic fonts */
@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;600;700;900&family=Rajdhani:wght@300;400;500;600;700&family=Share+Tech+Mono&display=swap');

/* ==================== RESET & BASE ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-cyan: #00ffcc;
    --primary-pink: #ff006e;
    --primary-blue: #0066ff;
    --dark-bg: #0a0e17;
    --darker-bg: #050810;
    --text-white: #ffffff;
    --text-gray: rgba(255, 255, 255, 0.6);
    --glow-cyan: rgba(0, 255, 204, 0.6);
    --glow-pink: rgba(255, 0, 110, 0.6);
}

body {
    font-family: 'Rajdhani', sans-serif;
    background: radial-gradient(ellipse at bottom, #1b2735 0%, #090a0f 100%);
    overflow: hidden;
    color: var(--text-white);
    position: relative;
    height: 100vh;
    width: 100vw;
}

/* ==================== ANIMATED BACKGROUND ==================== */
.stars {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.star {
    position: absolute;
    width: 2px;
    height: 2px;
    background: white;
    border-radius: 50%;
    box-shadow: 0 0 3px rgba(255, 255, 255, 0.8);
    animation: twinkle 3s infinite ease-in-out;
}

@keyframes twinkle {
    0%, 100% { 
        opacity: 0.2;
        transform: scale(1);
    }
    50% { 
        opacity: 1;
        transform: scale(1.2);
    }
}

/* Scanline effect */
.scanline {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        to bottom,
        transparent 0px,
        rgba(0, 255, 200, 0.03) 1px,
        transparent 2px,
        transparent 4px
    );
    pointer-events: none;
    z-index: 999;
    animation: scan 12s linear infinite;
}

@keyframes scan {
    0% { transform: translateY(0); }
    100% { transform: translateY(100%); }
}

/* Grid overlay */
.grid-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        linear-gradient(rgba(0, 255, 204, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 255, 204, 0.03) 1px, transparent 1px);
    background-size: 50px 50px;
    pointer-events: none;
    z-index: 1;
}

/* ==================== LOADING SCREEN ==================== */
#loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--darker-bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    transition: opacity 0.8s ease, visibility 0.8s ease;
}

#loading.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.loader {
    width: 100px;
    height: 100px;
    border: 4px solid rgba(0, 255, 204, 0.1);
    border-top: 4px solid var(--primary-cyan);
    border-right: 4px solid var(--primary-pink);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 30px;
    box-shadow: 
        0 0 20px var(--glow-cyan),
        inset 0 0 20px rgba(0, 255, 204, 0.1);
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-text {
    font-family: 'Orbitron', sans-serif;
    color: var(--primary-cyan);
    font-size: 24px;
    letter-spacing: 6px;
    text-transform: uppercase;
    margin-bottom: 10px;
    text-shadow: 0 0 20px var(--glow-cyan);
    animation: pulse 2s infinite;
}

.loading-subtext {
    font-family: 'Share Tech Mono', monospace;
    color: var(--text-gray);
    font-size: 12px;
    letter-spacing: 2px;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ==================== HEADER ==================== */
#header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    padding: 25px 50px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 100;
    background: linear-gradient(180deg, rgba(10, 14, 23, 0.9) 0%, transparent 100%);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(0, 255, 204, 0.1);
}

#title {
    display: flex;
    align-items: baseline;
    gap: 10px;
    font-family: 'Orbitron', sans-serif;
}

.title-prefix {
    color: var(--primary-pink);
    font-size: 28px;
    font-weight: 900;
    text-shadow: 0 0 20px var(--glow-pink);
}

.title-main {
    font-size: 36px;
    font-weight: 900;
    color: var(--primary-cyan);
    letter-spacing: 8px;
    text-transform: uppercase;
    text-shadow: 
        0 0 10px var(--glow-cyan),
        0 0 20px var(--glow-cyan),
        0 0 30px var(--glow-cyan);
}

.title-sub {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-gray);
    letter-spacing: 4px;
    text-transform: uppercase;
}

#stats {
    display: flex;
    gap: 20px;
}

.stat-box {
    background: linear-gradient(135deg, rgba(0, 255, 204, 0.08) 0%, rgba(0, 100, 255, 0.08) 100%);
    border: 1px solid rgba(0, 255, 204, 0.3);
    padding: 12px 24px;
    border-radius: 4px;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.stat-box::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(0, 255, 204, 0.2), transparent);
    transition: left 0.5s;
}

.stat-box:hover::before {
    left: 100%;
}

.stat-box:hover {
    border-color: var(--primary-cyan);
    box-shadow: 0 0 20px var(--glow-cyan);
    transform: translateY(-2px);
}

.stat-label {
    font-size: 10px;
    color: var(--primary-cyan);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 5px;
    font-weight: 600;
}

.stat-value {
    font-size: 20px;
    color: var(--text-white);
    font-weight: 700;
    font-family: 'Orbitron', sans-serif;
    letter-spacing: 2px;
}

/* ==================== 3D CONTAINER ==================== */
#container {
    width: 100vw;
    height: 100vh;
    position: relative;
    cursor: grab;
    z-index: 10;
}

#container:active {
    cursor: grabbing;
}

#container canvas {
    display: block;
}

/* ==================== HOVER INDICATOR ==================== */
.hover-indicator {
    position: fixed;
    width: 40px;
    height: 40px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 500;
    transform: translate(-50%, -50%);
}

.hover-indicator.active {
    opacity: 1;
}

.indicator-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    border: 2px solid var(--primary-cyan);
    border-radius: 50%;
    box-shadow: 
        0 0 20px var(--glow-cyan),
        inset 0 0 20px rgba(0, 255, 204, 0.2);
    animation: indicatorPulse 1.5s infinite;
}

.indicator-dot {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 8px;
    background: var(--primary-cyan);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--glow-cyan);
}

@keyframes indicatorPulse {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.3);
        opacity: 0.6;
    }
}

/* ==================== INFO PANEL ==================== */
#info-panel {
    position: fixed;
    top: 50%;
    right: -500px;
    transform: translateY(-50%);
    width: 450px;
    max-height: 85vh;
    background: rgba(10, 15, 30, 0.95);
    border: 2px solid var(--primary-cyan);
    backdrop-filter: blur(20px);
    transition: right 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 200;
    box-shadow: 
        -15px 0 50px rgba(0, 255, 204, 0.4),
        inset 0 0 30px rgba(0, 255, 204, 0.05);
    overflow: hidden;
}

#info-panel.active {
    right: 30px;
}

/* Corner decorations */
#info-panel::before,
#info-panel::after {
    content: '';
    position: absolute;
    width: 25px;
    height: 25px;
    border: 2px solid var(--primary-pink);
    z-index: 10;
}

#info-panel::before {
    top: -2px;
    left: -2px;
    border-right: none;
    border-bottom: none;
    animation: cornerGlow 2s infinite alternate;
}

#info-panel::after {
    bottom: -2px;
    right: -2px;
    border-left: none;
    border-top: none;
    animation: cornerGlow 2s infinite alternate 1s;
}

@keyframes cornerGlow {
    0% { 
        opacity: 0.5;
        filter: drop-shadow(0 0 5px var(--primary-pink));
    }
    100% { 
        opacity: 1;
        filter: drop-shadow(0 0 15px var(--primary-pink));
    }
}

/* Panel Header */
.panel-header {
    background: linear-gradient(135deg, rgba(0, 255, 204, 0.15) 0%, rgba(255, 0, 110, 0.15) 100%);
    padding: 30px;
    border-bottom: 2px solid var(--primary-cyan);
    position: relative;
    text-align: center;
}

.panel-header::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--primary-pink);
    animation: headerLine 1s ease-out forwards;
}

@keyframes headerLine {
    to { width: 100%; }
}

.country-flag {
    font-size: 48px;
    margin-bottom: 15px;
    filter: drop-shadow(0 0 10px var(--glow-cyan));
}

#country-name {
    font-family: 'Orbitron', sans-serif;
    font-size: 28px;
    font-weight: 700;
    color: var(--text-white);
    text-transform: uppercase;
    letter-spacing: 4px;
    margin-bottom: 8px;
    text-shadow: 0 0 15px var(--glow-cyan);
}

#country-code {
    font-family: 'Share Tech Mono', monospace;
    font-size: 11px;
    color: var(--primary-cyan);
    letter-spacing: 3px;
    font-weight: 400;
}

.close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 45px;
    height: 45px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 0, 110, 0.15);
    border: 2px solid var(--primary-pink);
    transition: all 0.3s ease;
    z-index: 20;
}

.close-btn:hover {
    background: rgba(255, 0, 110, 0.3);
    transform: rotate(90deg);
    box-shadow: 0 0 25px var(--glow-pink);
}

.close-icon {
    font-size: 32px;
    color: var(--primary-cyan);
    font-family: 'Orbitron', sans-serif;
    font-weight: 300;
    transition: color 0.3s;
}

.close-btn:hover .close-icon {
    color: var(--primary-pink);
}

/* Panel Content */
.panel-content {
    padding: 25px;
    max-height: calc(85vh - 180px);
    overflow-y: auto;
    overflow-x: hidden;
}

.panel-content::-webkit-scrollbar {
    width: 8px;
}

.panel-content::-webkit-scrollbar-track {
    background: rgba(0, 255, 204, 0.05);
}

.panel-content::-webkit-scrollbar-thumb {
    background: var(--primary-cyan);
    border-radius: 4px;
    box-shadow: 0 0 10px var(--glow-cyan);
}

.panel-content::-webkit-scrollbar-thumb:hover {
    background: var(--primary-pink);
}

/* Data Sections */
.data-section {
    margin-bottom: 25px;
}

.section-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 14px;
    color: var(--primary-cyan);
    text-transform: uppercase;
    letter-spacing: 3px;
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(0, 255, 204, 0.3);
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
}

.section-icon {
    font-size: 18px;
    filter: drop-shadow(0 0 5px var(--glow-cyan));
}

.info-grid {
    display: grid;
    gap: 12px;
}

.info-item {
    position: relative;
    padding: 16px 18px;
    background: linear-gradient(135deg, rgba(0, 255, 204, 0.05) 0%, rgba(0, 100, 255, 0.05) 100%);
    border-left: 3px solid var(--primary-cyan);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    overflow: hidden;
}

.info-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(0, 255, 204, 0.15), transparent);
    transition: left 0.6s;
}

.info-item:hover::before {
    left: 100%;
}

.info-item:hover {
    background: linear-gradient(135deg, rgba(0, 255, 204, 0.12) 0%, rgba(0, 100, 255, 0.12) 100%);
    border-left-color: var(--primary-pink);
    transform: translateX(8px);
    box-shadow: 
        0 5px 15px rgba(0, 255, 204, 0.2),
        inset 0 0 20px rgba(0, 255, 204, 0.05);
}

.info-label {
    font-size: 11px;
    color: var(--primary-cyan);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 8px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

.label-icon {
    color: var(--primary-pink);
    font-size: 12px;
}

.info-value {
    font-size: 18px;
    color: var(--text-white);
    font-weight: 600;
    letter-spacing: 0.5px;
    line-height: 1.4;
}

/* ==================== INSTRUCTIONS ==================== */
#instructions {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    z-index: 100;
    background: rgba(10, 14, 23, 0.8);
    padding: 18px 45px;
    border: 1px solid rgba(0, 255, 204, 0.3);
    border-radius: 4px;
    backdrop-filter: blur(15px);
    box-shadow: 0 5px 30px rgba(0, 255, 204, 0.2);
}

.instruction-line {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 8px;
}

.instruction-icon {
    font-size: 18px;
    color: var(--primary-cyan);
    animation: rotate 4s linear infinite;
}

@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.instruction-text {
    font-family: 'Orbitron', sans-serif;
    font-size: 14px;
    color: var(--primary-cyan);
    text-transform: uppercase;
    letter-spacing: 3px;
    font-weight: 600;
    text-shadow: 0 0 10px var(--glow-cyan);
}

.instruction-subtext {
    font-size: 12px;
    color: var(--text-gray);
    letter-spacing: 1px;
}

/* ==================== LEGEND ==================== */
#legend {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: rgba(10, 15, 30, 0.9);
    border: 1px solid rgba(0, 255, 204, 0.3);
    padding: 18px 22px;
    border-radius: 4px;
    backdrop-filter: blur(15px);
    z-index: 100;
    box-shadow: 0 5px 30px rgba(0, 255, 204, 0.2);
}

.legend-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(0, 255, 204, 0.2);
}

.legend-icon {
    font-size: 16px;
    color: var(--primary-cyan);
}

.legend-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 12px;
    color: var(--primary-cyan);
    text-transform: uppercase;
    letter-spacing: 2px;
    font-weight: 600;
}

.legend-items {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.legend-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    font-size: 11px;
}

.legend-key {
    font-family: 'Share Tech Mono', monospace;
    color: var(--primary-pink);
    background: rgba(255, 0, 110, 0.1);
    padding: 4px 10px;
    border: 1px solid var(--primary-pink);
    border-radius: 2px;
    font-size: 10px;
    letter-spacing: 1px;
}

.legend-description {
    color: var(--text-gray);
    letter-spacing: 0.5px;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 1400px) {
    #info-panel {
        width: 400px;
    }
}

@media (max-width: 1200px) {
    #info-panel {
        width: 380px;
    }
    
    #legend {
        display: none;
    }
}

@media (max-width: 768px) {
    #header {
        padding: 20px;
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }

    .title-main {
        font-size: 24px;
        letter-spacing: 4px;
    }

    .title-sub {
        font-size: 14px;
    }

    #stats {
        width: 100%;
        justify-content: space-between;
        gap: 10px;
    }

    .stat-box {
        padding: 10px 15px;
        flex: 1;
    }

    .stat-value {
        font-size: 16px;
    }

    #info-panel {
        width: calc(100% - 30px);
        right: -100%;
        max-height: 70vh;
    }

    #info-panel.active {
        right: 15px;
    }

    #instructions {
        bottom: 15px;
        padding: 12px 25px;
        font-size: 10px;
    }

    .instruction-text {
        font-size: 11px;
    }

    .instruction-subtext {
        font-size: 10px;
    }
}

@media (max-width: 480px) {
    .title-prefix {
        font-size: 20px;
    }

    .title-main {
        font-size: 20px;
    }

    #info-panel {
        max-height: 60vh;
    }

    .country-flag {
        font-size: 36px;
    }

    #country-name {
        font-size: 20px;
    }
}