html {
    height: 100%;
    width: 100%;
}

:root {
    --nodes-bg: #050505;
    --nodes-bg-2: #0a0a0a;
    --nodes-border: rgba(255, 255, 255, 0.13);
    --nodes-border-soft: rgba(255, 255, 255, 0.07);
    --nodes-text: #e8e8e8;
    --nodes-text-dim: #8c8c8c;
    --nodes-gold: #e3b11c;
    --nodes-accent: #d4a017;
    --nodes-mono: Consolas, "Courier New", "DejaVu Sans Mono", monospace;
}

body {
    padding: 0;
    margin: 0;
    height: 100%;
    width: 100%;
    background: var(--nodes-bg);
    color: var(--nodes-text);
    font-family: var(--nodes-mono);
    font-size: 13px;
}

#page-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: row;
}

#nodes-container {
    height: 100%;
    width: 360px;
    min-width: 360px;
    transition: width 0.18s ease, min-width 0.18s ease;
    overflow: hidden;
    background: var(--nodes-bg);
    font-family: var(--nodes-mono);
}

#page-container.nodes-menu-collapsed #nodes-container {
    width: 0;
    min-width: 0;
}

#dynmap-container {
    flex-grow: 420;
    border: none;
    position: relative;
}

#dynmap {
    width: 100%;
    height: 100%;
    background: #1a1a2e;
}

.leaflet-container {
    background: #1a1a2e !important;
    font-family: var(--nodes-mono) !important;
}

.leaflet-nodes-pane {
    z-index: 500;
}

#nodes-world {
    z-index: 500;
}

.leaflet-nodes-pane > svg path {
    pointer-events: all;
}

#port-tooltip-container {
    position: fixed;
}

#port-tooltip {
    position: fixed;
    z-index: 10001;
    font-size: 1.2em;
    background-color: rgba(0, 0, 0, 0.85);
    border: 1px solid var(--nodes-border);
    padding: 6px 8px;
    min-width: 200px;
    font-family: var(--nodes-mono);
}

#port-tooltip div {
    margin: 0;
    padding: 0;
    line-height: 1.5;
}

#port-tooltip b {
    font-weight: bold;
    color: var(--nodes-gold);
}

/* ── Sidebar sections ─────────────────────────────────────────────────── */

.gv-section {
    padding: 8px 12px 10px;
    border-bottom: 1px solid var(--nodes-border-soft);
}

.gv-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--nodes-gold);
    font-size: 12px;
    font-weight: 700;
    text-transform: lowercase;
    letter-spacing: 0.04em;
    margin-bottom: 6px;
}

.gv-section-header-actions {
    display: flex;
    gap: 4px;
}

/* Collapsible section (header + body wrapped together; click header to toggle). */
.gv-collapsible {
    border-top: 1px solid var(--nodes-border-soft);
    margin-top: 4px;
}
.gv-collapsible:first-of-type { border-top: 0; }

.gv-sec-header {
    padding: 9px 12px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--nodes-gold);
    display: flex;
    align-items: center;
    gap: 6px;
}

.gv-sec-toggle {
    cursor: pointer;
    user-select: none;
}
.gv-sec-toggle:hover { background: rgba(255, 255, 255, 0.04); }

.gv-sec-chevron {
    display: inline-block;
    width: 10px;
    color: var(--nodes-text-dim);
    font-size: 10px;
    transition: transform 0.1s ease;
}

.gv-sec-meta {
    margin-left: auto;
    font-size: 10px;
    font-weight: 400;
    color: var(--nodes-text-dim);
    text-transform: none;
    letter-spacing: 0;
}

.gv-sec-body {
    padding: 2px 0 10px;
    overflow: hidden;
    transition: max-height 0.15s ease, padding 0.15s ease;
}

.gv-collapsible.collapsed .gv-sec-body {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
}

/* ── Modal overlay (nation overview, town members) ─────────────────────── */

.gv-overlay {
    position: fixed;
    inset: 0;
    z-index: 4000;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
    animation: gv-overlay-fade 0.12s ease-out;
}
@keyframes gv-overlay-fade {
    from { opacity: 0; }
    to   { opacity: 1; }
}
.gv-overlay-modal {
    width: min(560px, 92vw);
    max-height: 86vh;
    background: var(--nodes-bg, #050505);
    border: 1px solid var(--nodes-gold, #e3b11c);
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.7);
    color: var(--nodes-text, #e8e8e8);
    font-family: var(--nodes-mono, Consolas, monospace);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.gv-overlay-title {
    padding: 10px 14px;
    background: rgba(227, 177, 28, 0.12);
    border-bottom: 1px solid var(--nodes-gold, #e3b11c);
    color: var(--nodes-gold, #e3b11c);
    font-weight: 700;
    font-size: 13px;
    letter-spacing: 0.04em;
}
.gv-overlay-body {
    padding: 14px;
    overflow-y: auto;
    flex: 1;
}
.gv-overlay-section {
    color: var(--nodes-gold, #e3b11c);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-top: 1px solid rgba(255, 255, 255, 0.07);
    padding-top: 8px;
    margin-top: 6px;
    margin-bottom: 4px;
}
.gv-overlay-section:first-child {
    border-top: 0;
    padding-top: 0;
    margin-top: 0;
}

.gv-icon-btn {
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--nodes-border);
    background: rgba(255, 255, 255, 0.03);
    color: var(--nodes-text);
    cursor: pointer;
    font-family: var(--nodes-mono);
    font-size: 11px;
    border-radius: 0;
    padding: 0;
}

.gv-icon-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--nodes-gold);
}

.gv-icon-btn.active {
    background: rgba(227, 177, 28, 0.15);
    border-color: var(--nodes-gold);
    color: var(--nodes-gold);
}

/* Town list */

.gv-town-list {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 220px;
    overflow-y: auto;
}

.gv-town-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 2px 4px;
    cursor: pointer;
    font-family: var(--nodes-mono);
    font-size: 12px;
    line-height: 1.4;
}

.gv-town-item:hover {
    background: rgba(255, 255, 255, 0.06);
}

.gv-town-item.selected {
    background: rgba(227, 177, 28, 0.12);
    color: var(--nodes-gold);
}

.gv-town-swatch {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
    border: 1px solid rgba(0, 0, 0, 0.6);
}

.gv-town-nation {
    color: var(--nodes-text-dim);
}

/* Info panels (Selected Town / Selected Territory) */

.gv-info-panel dl {
    margin: 0;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 2px 10px;
    font-size: 12px;
}

.gv-info-panel dt {
    color: var(--nodes-text-dim);
    font-weight: normal;
}

.gv-info-panel dd {
    margin: 0;
    color: var(--nodes-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gv-info-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2px 10px;
    font-size: 12px;
}

.gv-info-grid-2 .gv-label {
    color: var(--nodes-text-dim);
}

.gv-empty-box {
    margin-top: 6px;
    min-height: 80px;
    border: 1px solid var(--nodes-border-soft);
    background: rgba(0, 0, 0, 0.4);
    padding: 6px 8px;
    font-size: 11px;
    color: var(--nodes-text-dim);
}

/* Help */

.gv-help {
    padding: 8px 12px 12px;
    color: var(--nodes-text-dim);
    font-size: 11px;
    line-height: 1.5;
}

.gv-help b {
    color: var(--nodes-text);
}

/* ── Floating buttons & menu toggle ───────────────────────────────────── */

.nodes-floating-button {
    position: fixed;
    z-index: 2500;
    border: 1px solid var(--nodes-border);
    background: var(--nodes-bg);
    color: var(--nodes-text);
    padding: 8px 12px;
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
    user-select: none;
    font-family: var(--nodes-mono);
    border-radius: 0;
}

.nodes-floating-button:hover {
    background: rgba(28, 28, 34, 0.97);
    color: var(--nodes-gold);
}

.nodes-menu-toggle {
    left: 352px;
    top: calc(50% - 24px);
    min-width: 28px;
    width: 28px;
    height: 48px;
    padding: 0;
    border-left: 0;
    font-size: 16px;
}

/* Floating ✓ Finish / ✕ Cancel cluster shown during an active draw. */
.gv-draw-controls {
    position: fixed;
    left: 50%;
    bottom: 22px;
    transform: translateX(-50%);
    z-index: 2600;
    display: flex;
    gap: 8px;
    animation: gv-draw-pop 0.18s ease-out;
}
@keyframes gv-draw-pop {
    from { opacity: 0; transform: translate(-50%, 8px); }
    to   { opacity: 1; transform: translate(-50%, 0); }
}
.gv-draw-controls .nodes-floating-button {
    position: static;
    font-size: 14px;
    font-weight: 700;
    padding: 10px 18px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.6);
}
.gv-draw-controls .gv-draw-finish {
    background: rgba(34, 110, 50, 0.95);
    border-color: #6fe085;
    color: #f0fff0;
    box-shadow: 0 0 0 2px rgba(106, 224, 133, 0.25), 0 6px 18px rgba(0, 0, 0, 0.6);
}
.gv-draw-controls .gv-draw-finish:hover {
    background: rgba(48, 140, 70, 1);
    color: #fff;
}
.gv-draw-controls .gv-draw-cancel {
    background: rgba(120, 30, 30, 0.9);
    border-color: #d04a4a;
    color: #ffeaea;
}
.gv-draw-controls .gv-draw-cancel:hover {
    background: rgba(160, 40, 40, 1);
    color: #fff;
}

#page-container.nodes-menu-collapsed .nodes-menu-toggle {
    left: 0;
    border-left: 1px solid var(--nodes-border);
}

@media (max-width: 900px) {
    #nodes-container {
        width: 300px;
        min-width: 300px;
    }
    .nodes-menu-toggle {
        left: 292px;
    }
}

.nodes-page-map-options-mount {
    position: fixed;
    left: 14px;
    top: 72px;
    z-index: 2501;
}

.nodes-map-options-toggle {
    position: static;
    min-width: 140px;
    text-align: left;
    font-weight: 700;
    font-family: var(--nodes-mono);
}

.nodes-map-options-panel {
    display: none;
    margin-top: 8px;
    width: 300px;
    max-height: min(70vh, 520px);
    overflow-y: auto;
    background: var(--nodes-bg-2);
    border: 1px solid var(--nodes-border);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.55);
}

.nodes-map-options-panel.open {
    display: block;
}

.nodes-page-map-options-list {
    padding: 10px 12px 12px;
}

.nodes-page-map-options-native-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 0;
}

@media (max-width: 900px) {
    .nodes-page-map-options-mount {
        left: 10px;
        top: 66px;
    }
    .nodes-map-options-panel {
        width: min(300px, calc(100vw - 20px));
    }
}

/* Scrollbars in the sidebar */

#nodes-container ::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
#nodes-container ::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
}
#nodes-container ::-webkit-scrollbar-track {
    background: transparent;
}
