html, body { overscroll-behavior: none; }

:root {
    --topbar-height: 78px;
    --topbar-height-editor: 0px;
    --neon-cyan: #8af7ff;
    --neon-blue: #6f7bff;
    --panel-dark: rgba(6, 14, 31, 0.9);
    --panel-glow: rgba(87, 196, 255, 0.28);
    --cyan-soft: #87e9ff;
    --cyan-strong: #9cf7ff;
    --bg-main: #070b17;
    --bg-panel: #0d1425;
    --border-soft: rgba(255, 255, 255, 0.08);
    --text-soft: #cfd6e4;
    --text-strong: #ffffff;
    --map-stroke: rgba(0, 0, 0, 0.95);
}

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

body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -2;
    background:
        linear-gradient(180deg, rgba(7, 9, 14, 0.82) 0%, rgba(8, 10, 16, 0.72) 100%),
        url('/assets/img/branding/site-bg.jpg') center center / cover no-repeat;
    background-attachment: fixed;
}

body::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background: radial-gradient(circle at center, rgba(255,255,255,0.03) 0%, rgba(0,0,0,0.24) 60%, rgba(0,0,0,0.44) 100%);
}

.site-watermark {
    position: fixed;
    right: clamp(10px, 2vw, 28px);
    bottom: max(10px, env(safe-area-inset-bottom));
    z-index: 18;
    width: clamp(132px, 15vw, 272px);
    opacity: 0.6;
    pointer-events: none;
    user-select: none;
}

.site-watermark img {
    display: block;
    width: 100%;
    height: auto;
    object-fit: contain;
    filter: drop-shadow(0 10px 26px rgba(0, 0, 0, 0.4)) drop-shadow(0 0 18px rgba(80, 220, 255, 0.16));
}

#topbar {
    position: relative;
    height: var(--topbar-height);
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: start;
    gap: 16px;
    padding: 10px 18px 8px;
    background:
        radial-gradient(circle at 18% -20%, rgba(138, 247, 255, 0.12) 0%, rgba(138, 247, 255, 0) 34%),
        radial-gradient(circle at 82% -45%, rgba(111, 123, 255, 0.10) 0%, rgba(111, 123, 255, 0) 36%),
        linear-gradient(180deg, rgba(4, 11, 24, 0.98) 0%, rgba(5, 12, 24, 0.94) 100%);
    border-bottom: 1px solid rgba(140, 238, 255, 0.18);
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.42), inset 0 -1px 0 rgba(255,255,255,0.03), 0 0 42px rgba(111, 123, 255, 0.08);
    backdrop-filter: blur(20px);
}

#topbar::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 1px;
    background: linear-gradient(90deg, transparent 0%, rgba(103, 223, 255, 0.6) 50%, transparent 100%);
    pointer-events: none;
}

.topbar-left, .topbar-center, .topbar-right {
    justify-content: flex-end;
    gap: 10px;
    align-self: start;
    min-width: 220px;
}

.topbar-left {
    gap: 12px;
    flex-wrap: nowrap;
    min-width: 0;
}

#lastUpdateBtn {
    min-width: 148px;
}

.topbar-center {
    justify-content: center;
    align-self: center;
}

.topbar-right {
    justify-content: flex-end;
    gap: 10px;
    align-self: start;
    min-width: 220px;
}

.topbar-nav {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 4px;
    border: 1px solid rgba(112, 199, 255, 0.18);
    border-radius: 18px;
    background: linear-gradient(180deg, rgba(7, 17, 34, 0.86) 0%, rgba(5, 12, 24, 0.72) 100%);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.04), 0 14px 34px rgba(0,0,0,0.28), 0 0 26px rgba(77,184,255,0.08);
    backdrop-filter: blur(18px);
}

.topbar-tab, .topbar-link, .topbar-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 0 18px;
    border-radius: 14px;
    border: 1px solid rgba(120, 205, 255, 0.14);
    background: linear-gradient(180deg, rgba(15, 30, 55, 0.84) 0%, rgba(8, 18, 35, 0.84) 100%);
    color: #e8f8ff;
    font-weight: 700;
    letter-spacing: 0.02em;
    transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease, background .16s ease, color .16s ease;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.04), 0 8px 18px rgba(0,0,0,0.18);
    backdrop-filter: blur(12px);
}

.topbar-tab:hover, .topbar-link:hover, .topbar-btn:hover {
    transform: translateY(-1px);
    border-color: rgba(146, 225, 255, 0.34);
    background: linear-gradient(180deg, rgba(19, 38, 67, 0.94) 0%, rgba(10, 22, 40, 0.92) 100%);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.06), 0 12px 26px rgba(0, 0, 0, 0.24), 0 0 22px rgba(84, 213, 255, 0.12);
}

.topbar-tab.is-active {
    color: #041019;
    border-color: rgba(185, 240, 255, 0.74);
    background: linear-gradient(180deg, rgba(207, 244, 255, 0.98) 0%, rgba(116, 214, 255, 0.94) 100%);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.4), 0 10px 26px rgba(0, 0, 0, 0.18), 0 0 30px rgba(107, 214, 255, 0.2);
}

.topbar-link {
    min-width: 230px;
    justify-content: center;
    text-align: center;
    color: #dffaff;
    font-weight: 700;
    background: linear-gradient(180deg, rgba(13, 29, 53, 0.9) 0%, rgba(8, 18, 34, 0.82) 100%);
}

.topbar-btn {
    font-weight: 800;
}

.topbar-status-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #5dffb4;
    box-shadow: 0 0 0 4px rgba(93, 255, 180, 0.08), 0 0 18px rgba(93, 255, 180, 0.45);
}

.topbar-status-label {
    color: rgba(216, 244, 255, 0.84);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.16em;
}

.history-indicator {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 0 16px;
    border-radius: 14px;
    color: rgba(225, 247, 255, 0.94);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    background: linear-gradient(180deg, rgba(18, 34, 56, 0.74) 0%, rgba(10, 18, 34, 0.68) 100%);
    border: 1px solid rgba(123, 225, 255, 0.14);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.04), 0 0 20px rgba(106,222,255,0.06);
    backdrop-filter: blur(14px);
}

.topbar-panels {
    position: fixed;
    top: calc(var(--topbar-height) + 10px);
    left: 18px;
    right: 18px;
    z-index: 40;
    pointer-events: none;
}

.topbar-panels.has-open-panel {
    pointer-events: auto;
}

.topbar-panel {
    max-width: 460px;
}

.topbar-panel-card {
    padding: 18px 20px;
    border-radius: 22px;
    border: 1px solid rgba(111, 230, 255, 0.18);
    background: linear-gradient(180deg, rgba(7, 16, 31, 0.78) 0%, rgba(8, 16, 34, 0.64) 100%);
    box-shadow: 0 24px 60px rgba(0,0,0,0.34), 0 0 40px rgba(72, 196, 255, 0.12);
    backdrop-filter: blur(20px);
}

.topbar-panel-kicker {
    color: var(--cyan-strong);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.topbar-panel-title {
    color: #ffffff;
    font-size: 26px;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 10px;
}

.topbar-panel-card p {
    margin: 0;
    color: rgba(220, 234, 245, 0.82);
    line-height: 1.55;
}

.hidden { display: none !important; }

body.editor-mode {
    --topbar-height: var(--topbar-height-editor);
}

body.editor-mode .site-watermark {
    opacity: 0.18;
    width: clamp(110px, 12vw, 190px);
}

body.editor-mode #mapPage {
    height: 100%;
}

body.editor-mode #mapFrame {
    width: calc(100vw - 12px);
    height: calc(100vh - 12px);
    border-radius: 18px;
}

#mapPage {
    width: 100%;
    height: calc(100% - var(--topbar-height));
    background:
        radial-gradient(circle at center, rgba(41, 61, 102, 0.18) 0%, rgba(11, 16, 32, 0.08) 55%),
        linear-gradient(180deg, rgba(11, 16, 32, 0.46) 0%, rgba(8, 12, 24, 0.6) 100%);
}

#mapViewport {
    position: relative;
    touch-action: none;
    overscroll-behavior: none;
    width: 100%;
    height: 100%;
    overflow: hidden;
    user-select: none;
}

#mapFrame {
    position: absolute;
    touch-action: none;
    overscroll-behavior: none;
    left: 50%;
    top: 50%;
    width: calc(100vw - 24px);
    height: calc(100vh - var(--topbar-height) - 24px);
    max-width: 1800px;
    max-height: 1400px;
    transform: translate(-50%, -50%);
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.16);
    border-radius: 16px;
    box-shadow:
        0 18px 50px rgba(0, 0, 0, 0.42),
        inset 0 0 0 1px rgba(255,255,255,0.04);
    background: #0f172a;
}

#mapFrame::before {
    content: "";
    position: absolute;
    inset: 8px;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 10px;
    pointer-events: none;
    z-index: 20;
}

.map-controls {
    position: absolute;
    right: 12px;
    top: 12px;
    z-index: 25;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.map-control-btn {
    width: 34px;
    height: 34px;
    border: 1px solid rgba(255,255,255,0.14);
    border-radius: 12px;
    background: linear-gradient(180deg, rgba(13, 24, 43, 0.86) 0%, rgba(9, 17, 31, 0.86) 100%);
    color: #fff;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.04), 0 10px 22px rgba(0,0,0,0.24);
    backdrop-filter: blur(12px);
    transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}

.map-control-btn:hover {
    background: linear-gradient(180deg, rgba(21, 38, 67, 0.94) 0%, rgba(10, 22, 40, 0.92) 100%);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.05), 0 14px 28px rgba(0,0,0,0.28), 0 0 18px rgba(84, 213, 255, 0.12);
    transform: translateY(-1px);
}

.map-control-reset {
    font-size: 20px;
}

#world {
    position: absolute;
    touch-action: none;
    left: 0;
    top: 0;
    width: 1566px;
    height: 2048px;
    transform-origin: 0 0;
    background: transparent;
}

#tilesLayer, #logosLayer, #mapSvg {
    position: absolute;
    left: 0;
    top: 0;
}

#tilesLayer, #logosLayer {
    width: 1566px;
    height: 2048px;
}

#tilesLayer {
    z-index: 1;
    overflow: hidden;
    background: #0f172a;
}

.map-tile {
    position: absolute;
    display: block;
    object-fit: cover;
    user-select: none;
    -webkit-user-drag: none;
    pointer-events: none;
}

#mapSvg {
    z-index: 2;
    width: 1566px;
    height: 2048px;
    display: block;
}

#logosLayer {
    z-index: 3;
    pointer-events: none;
}

.regiao {
    touch-action: manipulation;
    fill: rgba(190,190,190,0.35);
    stroke: var(--map-stroke);
    stroke-width: 3;
    stroke-linejoin: round;
    stroke-linecap: round;
    vector-effect: non-scaling-stroke;
    cursor: pointer;
    transition: fill 0.15s ease;
}

#labels { pointer-events: none; }

.node-label {
    fill: #ffffff;
    font-size: 36px;
    font-weight: bold;
    text-anchor: middle;
    dominant-baseline: middle;
    pointer-events: none;
    paint-order: stroke;
    stroke: rgba(0, 0, 0, 0.45);
    stroke-width: 4px;
}

.map-logo {
    touch-action: manipulation;
    position: absolute;
    transform: translate(-50%, -50%);
    pointer-events: auto;
    cursor: pointer;
}

.map-logo img {
    pointer-events: none;
    width: 28px;
    height: 28px;
    object-fit: contain;
    display: block;
    filter: drop-shadow(0 0 4px rgba(0, 0, 0, 0.6));
}

.map-tooltip {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 9999;
    padding: 8px 10px;
    border-radius: 8px;
    background: rgba(12, 16, 28, 0.94);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    font-size: 13px;
    line-height: 1.2;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.12s ease, transform 0.12s ease;
}

.map-tooltip.visible {
    opacity: 1;
    transform: translateY(0);
}


#mapFrame {
    cursor: grab;
}

#mapFrame.is-dragging {
    cursor: grabbing;
}


#mapFrame {
    cursor: grab;
    touch-action: none;
}

#mapFrame.is-dragging {
    cursor: grabbing;
}

@media (max-width: 900px) {
    :root {
        --mobile-top-gap: 12px;
        --future-sidebar-space: 12px;
    }

    #mapViewport {
        padding: 0;
    }

    #mapFrame {
        left: 50%;
        top: calc(50% + 2px);
        width: calc(100vw - var(--future-sidebar-space));
        height: calc(100vh - var(--topbar-height) - var(--mobile-top-gap));
        max-height: none;
        transform: translate(-50%, -50%);
        border-radius: 0;
        border-left: 0;
        border-right: 0;
        border-bottom: 0;
        box-shadow: none;
    }

    .map-logo {
        touch-action: manipulation;
        z-index: 5;
        display: block;
    }

    .map-logo img {
        width: 100%;
        height: 100%;
        min-width: 0;
        min-height: 0;
        display: block;
    }
}


@media (max-width: 520px) {
    .map-logo img {
        filter: drop-shadow(0 0 3px rgba(0, 0, 0, 0.55));
    }
}

@media (max-width: 768px) {
    .site-watermark {
        right: max(8px, env(safe-area-inset-right));
        bottom: max(8px, env(safe-area-inset-bottom));
        width: clamp(64px, 18vw, 112px);
        opacity: 0.18;
    }
}


@media (max-width: 980px) {
    #topbar {
    position: relative;
    height: var(--topbar-height);
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: start;
    gap: 16px;
    padding: 10px 18px 8px;
    background:
        radial-gradient(circle at 18% -20%, rgba(138, 247, 255, 0.12) 0%, rgba(138, 247, 255, 0) 34%),
        radial-gradient(circle at 82% -45%, rgba(111, 123, 255, 0.10) 0%, rgba(111, 123, 255, 0) 36%),
        linear-gradient(180deg, rgba(4, 11, 24, 0.98) 0%, rgba(5, 12, 24, 0.94) 100%);
    border-bottom: 1px solid rgba(140, 238, 255, 0.18);
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.42), inset 0 -1px 0 rgba(255,255,255,0.03), 0 0 42px rgba(111, 123, 255, 0.08);
    backdrop-filter: blur(20px);
}


.topbar-status-dot,
.topbar-status-label { display: none !important; }

@media (max-width: 980px) {
    #topbar { grid-template-columns: 1fr; height: auto; min-height: var(--topbar-height); align-items: stretch; gap: 10px; padding: 10px 12px 12px; }
    .topbar-left, .topbar-center, .topbar-right { width: 100%; justify-content: center; }
    .topbar-left { flex-wrap: wrap; }
    .topbar-right { justify-content: flex-end; min-width: 0; }
    .topbar-nav {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 4px;
    border: 1px solid rgba(112, 199, 255, 0.18);
    border-radius: 18px;
    background: linear-gradient(180deg, rgba(7, 17, 34, 0.86) 0%, rgba(5, 12, 24, 0.72) 100%);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.04), 0 14px 34px rgba(0,0,0,0.28), 0 0 26px rgba(77,184,255,0.08);
    backdrop-filter: blur(18px);
}
