:root {
    --bg-color: #050a12;
    --sidebar-bg: rgba(10, 25, 47, 0.7);
    --accent-color: #64ffda;
    --text-primary: #e6f1ff;
    --text-secondary: #8892b0;
    --glass-border: rgba(100, 255, 218, 0.2);
    --font-main: 'Inter', sans-serif;
    --font-heading: 'Outfit', sans-serif;
}

body,
html {
    margin: 0;
    padding: 0;
    height: 100%;
    width: 100%;
    overflow: hidden;
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-main);
}

/* Glassmorphism Utility */
.glass-morphism {
    background: var(--sidebar-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.8);
    border-radius: 12px;
}

/* Intro Overlay */
#intro-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    background: radial-gradient(circle at center, #0a192f 0%, #020c1b 100%);
}

#intro-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

#intro-content {
    position: relative;
    z-index: 10;
    text-align: center;
}

#intro-content h1 {
    font-family: var(--font-heading);
    font-size: 5rem;
    font-weight: 700;
    margin: 0;
    letter-spacing: 12px;
    color: var(--text-primary);
    text-shadow: 0 0 20px rgba(100, 255, 218, 0.5);
}

#intro-content p {
    font-size: 1.2rem;
    color: var(--accent-color);
    letter-spacing: 4px;
    margin-top: 10px;
    text-transform: uppercase;
}

#start-btn {
    margin-top: 40px;
    padding: 15px 40px;
    background: transparent;
    border: 1px solid var(--accent-color);
    color: var(--accent-color);
    font-family: var(--font-heading);
    font-size: 1.1rem;
    letter-spacing: 2px;
    cursor: pointer;
    transition: all 0.3s ease;
    border-radius: 4px;
    text-transform: uppercase;
}

#start-btn:hover {
    background: rgba(100, 255, 218, 0.1);
    box-shadow: 0 0 20px rgba(100, 255, 218, 0.3);
    transform: translateY(-2px);
}

/* App Container */
#app-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: none;
    /* Hidden by default */
    opacity: 0;
    transition: opacity 1s ease;
}

.mobile-only {
    display: none;
}

.mobile-only {
    display: none;
}

/* Sidebar */
#sidebar {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 320px;
    height: calc(100% - 40px);
    z-index: 100;
    padding: 24px;
    display: flex;
    flex-direction: column;
    pointer-events: auto;
}

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

.status-indicator {
    width: 10px;
    height: 10px;
    background: var(--accent-color);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--accent-color);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        opacity: 0.4;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.4;
    }
}

.sidebar-header h2 {
    font-family: var(--font-heading);
    font-size: 1.2rem;
    color: var(--text-primary);
    margin: 0;
}

#filter-section {
    margin-bottom: 25px;
}

#node-search {
    width: 100%;
    padding: 10px 15px;
    margin-bottom: 12px;
    font-size: 0.85rem;
    color: var(--text-primary);
    box-sizing: border-box;
    outline: none;
}

#node-search::placeholder {
    color: var(--text-secondary);
}

#sector-filters {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.sector-chip {
    padding: 6px 12px;
    font-size: 0.65rem;
    font-weight: 700;
    border-radius: 20px;
    background: rgba(100, 255, 218, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    letter-spacing: 1px;
}

.sector-chip:hover {
    background: rgba(100, 255, 218, 0.1);
    color: var(--text-primary);
}

.sector-chip.active {
    background: var(--accent-color);
    color: var(--bg-color);
    border-color: var(--accent-color);
    box-shadow: 0 0 10px rgba(100, 255, 218, 0.3);
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 30px;
}

.stat-item {
    display: flex;
    flex-direction: column;
}

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

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-color);
    font-family: var(--font-heading);
}

.loader {
    font-size: 0.7rem;
    color: var(--accent-color);
    letter-spacing: 2px;
    padding: 20px 0;
    text-align: center;
    border-top: 1px solid var(--glass-border);
    animation: blink 1.5s infinite;
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.3;
    }
}

#node-list-container {
    flex: 1;
    overflow-y: auto;
    margin-right: -10px;
    padding-right: 10px;
}

#node-list-container h3 {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 15px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.node-item {
    padding: 12px;
    border-radius: 8px;
    background: rgba(100, 255, 218, 0.05);
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-left: 2px solid transparent;
}

.node-item:hover {
    background: rgba(100, 255, 218, 0.1);
    border-left-color: var(--accent-color);
}

.node-item-title {
    font-size: 0.85rem;
    font-weight: 600;
}

/* Map */
#map-container {
    flex: 1;
    height: 100%;
}

#map {
    width: 100%;
    height: 100%;
}

/* Custom Mapbox Marker */
.custom-marker {
    width: 24px;
    height: 24px;
    cursor: pointer;
}

.marker-pin {
    width: 12px;
    height: 12px;
    background: var(--accent-color);
    border-radius: 50%;
    margin: 6px auto;
    box-shadow: 0 0 10px var(--accent-color);
}

.marker-pulse {
    position: absolute;
    width: 24px;
    height: 24px;
    border: 2px solid var(--accent-color);
    border-radius: 50%;
    animation: marker-pulse 2s infinite;
    top: 0;
    left: 0;
    pointer-events: none;
}

@keyframes marker-pulse {
    0% {
        transform: scale(0.5);
        opacity: 1;
    }

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

/* Viewer */
#viewer-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    background: black;
}

#panorama {
    width: 100%;
    height: 100%;
}

#viewer-overlay-top {
    position: absolute;
    top: 30px;
    left: 30px;
    right: 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 1001;
    pointer-events: none;
}

#close-viewer {
    pointer-events: auto;
    background: var(--sidebar-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    padding: 10px 20px;
    border-radius: 30px;
    font-family: var(--font-heading);
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s ease;
    letter-spacing: 1px;
}

#close-viewer:hover {
    background: var(--accent-color);
    color: var(--bg-color);
}

#viewer-meta-panel {
    display: flex;
    align-items: center;
    padding: 10px 20px;
    pointer-events: auto;
}

.meta-item {
    display: flex;
    flex-direction: column;
}

.meta-label {
    font-size: 0.6rem;
    color: var(--text-secondary);
    letter-spacing: 1px;
}

.meta-value {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--accent-color);
}

.meta-divider {
    width: 1px;
    height: 20px;
    background: var(--glass-border);
    margin: 0 20px;
}

#nav-controls {
    position: absolute;
    top: 50%;
    left: 30px;
    right: 30px;
    transform: translateY(-50%);
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 1001;
    pointer-events: none;
}

.nav-btn {
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    cursor: pointer;
    pointer-events: auto;
    transition: all 0.3s ease;
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    background: var(--sidebar-bg);
}

.nav-btn:hover {
    background: var(--accent-color);
    color: var(--bg-color);
    transform: scale(1.1);
}

.nav-label {
    font-family: var(--font-heading);
    font-size: 0.7rem;
    letter-spacing: 4px;
    color: var(--text-secondary);
    opacity: 0.5;
}

#minimap-container {
    position: absolute;
    bottom: 30px;
    left: 30px;
    width: 180px;
    height: 180px;
    z-index: 1001;
    overflow: hidden;
    padding: 0;
    border: 2px solid var(--glass-border);
}

#minimap-map {
    width: 100%;
    height: 100%;
    border-radius: 50%;
}

#fov-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-left: 25px solid transparent;
    border-right: 25px solid transparent;
    border-bottom: 50px solid rgba(100, 255, 218, 0.4);
    transform: translate(-50%, -100%) rotate(0deg);
    transform-origin: bottom center;
    pointer-events: none;
    z-index: 1002;
}

/* Neighbor Markers on Minimap */
.mini-marker {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: 1px solid white;
}

.mini-marker.current {
    background: var(--accent-color);
    box-shadow: 0 0 5px var(--accent-color);
    width: 10px;
    height: 10px;
}

.mini-marker.neighbor {
    background: #ff64da;
    /* Distinct color for neighbors */
    opacity: 0.8;
}

#viewer-controls {
    position: absolute;
    bottom: 30px;
    right: 30px;
    padding: 15px 25px;
    display: flex;
    align-items: center;
    gap: 20px;
    z-index: 1001;
}

#viewer-title {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 1.1rem;
    letter-spacing: 1px;
}

.control-buttons button {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.2s;
}

.control-buttons button:hover {
    color: var(--accent-color);
}

.hidden {
    display: none !important;
}

/* Custom Hotspot Arroy (Floor Arrow) */
.pnlm-controls-container,
.pnlm-control-box,
.pnlm-zoom-controls,
.pnlm-fullscreen-control {
    display: none !important;
}

.pnlm-hotspot-base {
    cursor: pointer;
}

.floor-arrow {
    width: 60px;
    height: 60px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364ffda' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 13l5-5 5 5M7 17l5-5 5 5'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    transition: transform 0.3s ease;
    filter: drop-shadow(0 0 5px rgba(100, 255, 218, 0.5));
}

.floor-arrow:hover {
    transform: scale(1.2) translateY(-5px);
}

/* --- Robust Mobile & Tablet Refinement --- */
@media (max-width: 768px) {
    .mobile-only {
        display: block !important;
    }

    /* Intro Scaling */
    #intro-content h1 {
        font-size: clamp(2.5rem, 12vw, 4.5rem);
        letter-spacing: 4px;
    }

    /* Sidebar as Robust Bottom Sheet */
    #sidebar {
        width: 100% !important;
        left: 0 !important;
        top: auto !important;
        bottom: 0 !important;
        height: 65vh !important;
        border-radius: 24px 24px 0 0 !important;
        margin: 0 !important;
        transform: translateY(calc(65vh - 70px)) !important;
        /* Peak just enough to see header */
        transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1) !important;
        padding: 24px !important;
        box-sizing: border-box !important;
        border-bottom: none !important;
    }

    #sidebar.open {
        transform: translateY(0) !important;
        box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.9) !important;
    }

    #sidebar-toggle {
        position: absolute;
        top: 15px;
        right: 20px;
        background: rgba(100, 255, 218, 0.1);
        border: 1px solid var(--glass-border);
        border-radius: 8px;
        color: var(--accent-color);
        padding: 8px;
        cursor: pointer;
        z-index: 101;
    }

    /* Sidebar Content adjustments */
    #filter-section {
        margin-top: 10px;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }

    /* Viewer Layout Adjustments */
    #viewer-overlay-top {
        top: 15px;
        left: 15px;
        right: 15px;
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    #viewer-meta-panel {
        width: 100%;
        display: flex;
        justify-content: space-between;
        padding: 8px 15px;
    }

    #nav-controls {
        left: 10px;
        right: 10px;
        width: auto;
    }

    .nav-btn {
        width: 48px;
        height: 48px;
        background: rgba(10, 25, 47, 0.9);
    }

    .nav-label {
        display: none;
    }

    #minimap-container {
        width: 120px;
        height: 120px;
        bottom: 85px;
        left: 15px;
        border-radius: 50%;
    }

    #fov-indicator {
        border-bottom-width: 35px;
        border-left-width: 18px;
        border-right-width: 18px;
    }

    #viewer-controls {
        bottom: 85px;
        right: 15px;
        padding: 8px 15px;
    }

    #viewer-title {
        font-size: 0.85rem;
    }
}

/* Fix for very small devices */
@media (max-width: 380px) {
    #viewer-meta-panel .meta-divider {
        margin: 0 10px;
    }
}