.map-container {
    flex: 1;
    position: relative;
    background: #1e1e24;
}

#map {
    width: 100%;
    height: 100%;
}

/* GFlatMap popup styles (replaces maplibre-gl.css popup rules) */
.gflatmap-popup {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.4;
    will-change: transform;
}

.maplibregl-popup-content {
    position: relative;
    background: #fff;
    border-radius: 6px;
    padding: 12px;
    box-shadow: 0 3px 14px rgba(0,0,0,.35);
    max-width: 300px;
    word-wrap: break-word;
}

.maplibregl-popup-close-button {
    position: absolute;
    top: 2px;
    right: 6px;
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #666;
    z-index: 1;
    line-height: 1;
    padding: 2px 4px;
}
.maplibregl-popup-close-button:hover { color: #000; }

.maplibregl-popup-tip {
    width: 0; height: 0;
    border: 10px solid transparent;
    position: absolute;
    transform: translateX(-50%);
    pointer-events: none;
}
.gflatmap-tip-top {
    bottom: -20px;
    border-top-color: #fff;
}
.gflatmap-tip-bottom {
    top: -20px;
    border-bottom-color: #fff;
}

.marker-popup-image img {
    width: 100%;
    max-height: 160px;
    object-fit: cover;
    border-radius: 4px;
    margin-bottom: 6px;
    cursor: pointer;
}

.marker-popup-category {
    display: flex;
    align-items: center;
    gap: 6px;
}

.marker-popup-icon {
    width: 20px;
    height: 20px;
    object-fit: contain;
}

/* Player marker overlay */
.player-marker {
    pointer-events: none;
    will-change: transform;
}

.search-container {
    padding: 5px;
    border-bottom: 1px solid var(--border-color);
}

#search-input {
    width: 100%;
    padding: 6px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

.filters-container {
    flex: 1;
    overflow-y: auto;
    padding: 5px;
}

.category-group {
    margin-bottom: 15px;
}

.category-group h3 {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 10px;
    text-transform: uppercase;
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
}

.category-item {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
}

.category-item:hover {
    background-color: #f0f0f0;
}

/* ── Custom sword-tick checkbox ────────────── */
.sword-check {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    min-width: 18px;
    border: 2px solid #888;
    border-radius: 3px;
    background: transparent;
    cursor: pointer;
    position: relative;
    transition: border-color 0.2s, background 0.2s;
    margin: 0;
}
.sword-check:hover {
    border-color: var(--primary-color, #d4a853);
}
.sword-check:checked {
    background: var(--primary-color, #d4a853);
    border-color: var(--primary-color, #d4a853);
}
.sword-check:checked::after {
    content: '';
    position: absolute;
    /* Sword-like slash tick: a bold angled stroke */
    left: 3px;
    top: -2px;
    width: 5px;
    height: 11px;
    border: solid #fff;
    border-width: 0 2.5px 2.5px 0;
    transform: rotate(40deg);
}

.category-item input {
    margin-right: 10px;
}

.category-item img {
    width: 24px;
    height: 24px;
    margin-right: 10px;
    object-fit: contain;
}

.category-item span {
    font-size: 0.9rem;
}

/* Marker Popup */
.marker-popup {
    max-width: 250px;
}

.marker-popup h3 {
    margin-bottom: 5px;
    color: var(--secondary-color);
}

.marker-popup p {
    font-size: 0.9rem;
    margin-bottom: 10px;
    color: #555;
}

.marker-popup button {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 3px;
    cursor: pointer;
    width: 100%;
}

.marker-popup button:hover {
    opacity: 0.9;
}

.marker-popup img.popup-image {
    width: 100%;
    height: auto;
    margin-bottom: 10px;
    border-radius: 4px;
}

.marker {
    background-image: url('../images/icons/default.svg');
    background-size: cover;
    cursor: pointer;
}

/* Selection Mode Controls */
.map-floating-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 10;
    width: 40px;
    height: 40px;
    background: white;
    border: 2px solid rgba(0,0,0,0.2);
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: all 0.2s;
    font-size: 1.2rem;
}

.map-floating-btn:hover {
    background: #f8f8f8;
}

.map-home-btn {
    top: 20px;
    left: 20px;
    right: auto;
    text-decoration: none;
    color: #444;
    font-size: 1rem;
}
.map-home-btn:hover {
    background: #eee;
    color: #000;
}

.map-floating-btn.active {
    background: var(--primary-color, #007bff);
    color: white;
    border-color: var(--primary-color, #007bff);
}

/* ── Floating Map/Region Dropdown Selectors ── */
.floating-selectors {
    position: absolute;
    top: 00px;
    left: 75px;
    z-index: 10;
    display: flex;
    gap: 6px;
    align-items: flex-start;
}

.floating-dropdown {
    position: relative;
}

.floating-selector-btn {
    position: relative;
    display: flex;
    align-items: center;
    gap: 5px;
    width: auto;
    height: 40px;
    padding: 0 10px;
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
}

.floating-selector-btn .dd-arrow {
    font-size: 0.7rem;
    opacity: 0.7;
    transition: transform 0.2s;
}

.floating-dropdown.open .floating-selector-btn .dd-arrow {
    transform: rotate(180deg);
}

.region-icon-btn {
    padding: 0 10px;
    gap: 4px;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 160px;
    max-height: 320px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 6px;
    box-shadow: 0 4px 14px rgba(0,0,0,0.15);
    z-index: 100;
}

.floating-dropdown.open .dropdown-menu {
    display: block;
}

.dropdown-menu .dropdown-item {
    display: block;
    width: 100%;
    padding: 8px 12px;
    border: none;
    background: none;
    text-align: left;
    font-size: 0.85rem;
    cursor: pointer;
    color: #333;
    white-space: nowrap;
    transition: background 0.15s;
}

.dropdown-menu .dropdown-item:first-child {
    border-radius: 6px 6px 0 0;
}
.dropdown-menu .dropdown-item:last-child {
    border-radius: 0 0 6px 6px;
}

.dropdown-menu .dropdown-item:hover {
    background: #f0f0f0;
}

.dropdown-menu .dropdown-item.active {
    background: var(--primary-color, #007bff);
    color: white;
    font-weight: 700;
}

.selection-panel {
    position: absolute;
    top: 70px;
    right: 20px;
    z-index: 10;
    width: 250px;
    background: white;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    padding: 15px;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
}

.panel-header h3 {
    margin: 0;
    font-size: 1rem;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0 5px;
}

.panel-content .hint {
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 10px;
    font-style: italic;
}

.action-buttons {
    display: flex;
    gap: 5px;
    margin-bottom: 10px;
}

.action-btn {
    flex: 1;
    padding: 6px;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.85rem;
    color: white;
}

.action-btn.save {
    background-color: #28a745;
}

.action-btn.undo {
    background-color: #ffc107;
    color: #333;
}

.action-btn.delete {
    background-color: #dc3545;
}

.action-btn.manage {
    background-color: #17a2b8;
}

.action-btn:hover {
    opacity: 0.9;
}

.saved-list {
    max-height: 150px;
    overflow-y: auto;
    border-top: 1px solid #eee;
    margin-top: 10px;
    padding-top: 5px;
    display: none;
}

.saved-polygon-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px;
    border-bottom: 1px solid #f5f5f5;
    font-size: 0.9rem;
}

.saved-polygon-item:last-child {
    border-bottom: none;
}

.saved-polygon-item button {
    background: none;
    border: none;
    color: #dc3545;
    cursor: pointer;
    font-size: 1.1rem;
    padding: 0 5px;
}

/* Underground Floor Selector */
.floor-selector {
    position: absolute;
    right: 10px;
    bottom: 10px;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    border-radius: 6px;
    overflow: visible;
}

/* Toggle button - always visible */
.floor-selector .floor-toggle-btn {
    width: auto;
    min-width: 40px;
    height: 36px;
    border: none;
    background: rgba(30, 30, 36, 0.85);
    color: #ccc;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 0 8px;
    transition: background 0.15s, color 0.15s;
    user-select: none;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.floor-selector .floor-toggle-btn.active {
    background: var(--primary-color, #007bff);
    color: #fff;
}

.floor-selector .floor-toggle-btn.fallen-toggle:hover {
    background: rgba(50, 50, 60, 0.95);
    color: #fff;
}

.floor-selector .floor-toggle-btn.fallen-toggle.active:hover {
    background: color-mix(in srgb, var(--primary-color, #007bff) 85%, white);
    color: #fff;
}

/* Toggle indicator (pill switch) */
.fallen-toggle-indicator {
    display: inline-block;
    width: 26px;
    height: 14px;
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.25);
    position: relative;
    vertical-align: middle;
    flex-shrink: 0;
    transition: background 0.2s;
}

.fallen-toggle.active .fallen-toggle-indicator {
    background: rgba(255, 255, 255, 0.45);
}

.fallen-toggle-knob {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ccc;
    transition: left 0.2s, background 0.2s;
}

.fallen-toggle.active .fallen-toggle-knob {
    left: 14px;
    background: #fff;
}

.floor-selector .floor-toggle-btn:hover {
    background: rgba(50, 50, 60, 0.95);
    color: #fff;
}

.floor-selector .floor-toggle-btn .fa-chevron-up {
    font-size: 0.65rem;
    transition: transform 0.2s ease;
}

.floor-selector.open .floor-toggle-btn .fa-chevron-up {
    transform: rotate(180deg);
}

/* Floor list - hidden by default */
.floor-selector .floor-list {
    display: none;
    flex-direction: column-reverse;
    gap: 2px;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    margin-bottom: 2px;
}

.floor-selector.open .floor-list {
    display: flex;
}

.floor-selector .floor-btn {
    width: 40px;
    height: 36px;
    border: none;
    background: rgba(30, 30, 36, 0.85);
    color: #ccc;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
    user-select: none;
}

.floor-selector .floor-btn:hover {
    background: rgba(50, 50, 60, 0.95);
    color: #fff;
}

.floor-selector .floor-btn.active {
    background: var(--primary-color, #007bff);
    color: #fff;
}

.floor-selector .floor-btn.surface {
    font-size: 0.75rem;
}

@media (max-width: 768px) {
    .floating-selectors {
        left: 68px;
        top: 0px;
        gap: 4px;
    }
    .floating-selector-btn {
        height: 34px;
        padding: 0 7px;
        font-size: 0.78rem;
    }
    .floor-selector {
        right: 10px;
        bottom: 10px;
    }
    .floor-selector .floor-toggle-btn,
    .floor-selector .floor-btn {
        width: 34px;
        height: 30px;
        font-size: 0.75rem;
    }
    .floor-toggle-btn.fallen-toggle {
        width: auto !important;
    }
    .map-home-btn {
        font-size: 0.85rem;
        width: 34px;
        height: 34px;
    }
    .map-floating-btn {
        height: 34px;
    }
    #floating-window-button {
        display: none !important;
    }
    #btn-load-game-data {
        right: 10px !important;
        font-size: 12px;
        padding: 0 5px;
    }
    #map-dropdown-btn {
        font-size: 11px;
        max-width: 100px;
        white-space: normal;
    }
}

/* Van Su Tri Popup Styles */
.vst-popup {
    min-width: 250px;
    max-width: 320px;
}

.vst-header {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 8px;
}

.vst-title {
    font-size: 1em;
    font-weight: 600;
    color: #333;
    flex: 1;
    line-height: 1.3;
    max-width: calc(100% - 20px);
}

.vst-badge {
    font-size: 0.7em;
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
}

.vst-badge-hidden {
    background: #6c5ce7;
    color: #fff;
}

.vst-step-indicator {
    display: flex;
    gap: 6px;
    margin: 8px 0;
    justify-content: center;
}

.vst-step-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ddd;
    cursor: pointer;
    transition: all 0.2s;
}

.vst-step-dot:hover {
    transform: scale(1.3);
}

.vst-step-dot.current {
    background: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.3);
}

.vst-step-dot.completed {
    background: #28a745;
}

.vst-description {
    font-size: 0.9em;
    color: #555;
    margin: 8px 0;
    line-height: 1.5;
    word-break: break-word;
}

.vst-section {
    margin: 10px 0;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    overflow: hidden;
}

.vst-section-title {
    background: #f8f9fa;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 0.85em;
    font-weight: 500;
    color: #444;
    display: flex;
    align-items: center;
    gap: 6px;
    user-select: none;
}

.vst-section-title:hover {
    background: #e9ecef;
}

.vst-section-title::marker {
    content: '';
}

.vst-steps-list,
.vst-clues-list {
    padding: 6px;
    max-height: 200px;
    overflow-y: auto;
}

.vst-step-item,
.vst-clue-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 2px 0px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85em;
    transition: background 0.15s;
}

.vst-step-item:hover,
.vst-clue-item:hover {
    background: #f0f4ff;
}

.vst-step-item.current {
    background: #e7f1ff;
    border-left: 3px solid #007bff;
}

.vst-step-item.completed,
.vst-clue-item.completed {
    opacity: 0.7;
}

.vst-step-status,
.vst-clue-status {
    position: relative;
    flex-shrink: 0;
    width: 16px;
    text-align: center;
}

.vst-step-item.connect-prev .vst-step-status::before,
.vst-step-item.connect-next .vst-step-status::after {
    content: "";
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    background: rgb(39,121,207);
    border-radius: 999px;
}

.vst-step-item.connect-prev .vst-step-status::before {
    top: -8px;
    bottom: 50%;
}

.vst-step-item.connect-next .vst-step-status::after {
    top: 50%;
    bottom: -12px;
}

.vst-step-item.completed.connect-prev .vst-step-status::before,
.vst-step-item.completed.connect-next .vst-step-status::after {
    background: rgba(40, 167, 69, 0.45);
}

.vst-step-item.completed .vst-step-status,
.vst-clue-item.completed .vst-clue-status {
    color: #28a745;
}

.vst-step-label {
    font-weight: 500;
    white-space: nowrap;
}

.vst-step-desc {
    color: #d5d5d5;
    font-size: 0.9em;
    overflow: hidden;
    text-overflow: ellipsis;
}

.vst-clue-text {
    color: #d5d5d5;
    line-height: 1.4;
}

.vst-complete-btn {
    width: 100%;
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    background: #007bff;
    color: #fff;
    font-size: 0.9em;
    cursor: pointer;
    transition: all 0.2s;
}

.vst-complete-btn:hover {
    background: #0056b3;
}

.vst-complete-btn.completed {
    background: #28a745;
}

/* Dark theme support */
.dark-theme .vst-title {
    color: #e0e0e0;
}

.dark-theme .vst-description {
    color: #e7e7e7;
}

.dark-theme .vst-section {
    border-color: #444;
}

.dark-theme .vst-section-title {
    background: #2a2a2a;
    color: #ccc;
}

.dark-theme .vst-section-title:hover {
    background: #333;
}

.dark-theme .vst-step-item:hover,
.dark-theme .vst-clue-item:hover {
    background: #3a3a4a;
}

.dark-theme .vst-step-item.current {
    background: #1a3a5a;
}

/* ══════════════════════════════════════ */
/* Kỳ Ngộ (KyNgo) Popup — Green Grass Theme */
/* ══════════════════════════════════════ */

.kng-popup {
    min-width: 260px;
    max-width: 340px;
    border-radius: 10px;
    background: linear-gradient(135deg, #f0fdf4 0%, #ecfce5 50%, #f0fdf4 100%);
    
    box-shadow: 0 0 12px rgba(74, 222, 128, 0.25), 0 0 4px rgba(74, 222, 128, 0.15);
    padding: 10px 12px;
}

/* Override the popup container when it holds a KyNgo popup */
.maplibregl-popup-content:has(.kng-popup) {
    background: transparent;
    box-shadow: none;
    padding: 0px !important;
    max-width: 360px;
}

.kng-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(74, 222, 128, 0.3);
}

.kng-icon {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
}

.kng-title {
    font-size: 1.05em;
    font-weight: 600;
    color: #166534;
    line-height: 1.3;
    max-width: calc(100% - 25px);
}

.kng-description {
    font-size: 0.88em;
    color: #365314;
    margin: 6px 0;
    line-height: 1.5;
    word-break: break-word;
}

/* Conditions section */
.kng-conditions {
    margin: 8px 0;
    border: 1px solid rgba(74, 222, 128, 0.4);
    border-radius: 8px;
    overflow: hidden;
    background: rgba(240, 253, 244, 0.6);
}

.kng-conditions-title {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 10px;
    cursor: pointer;
    font-size: 0.85em;
    font-weight: 600;
    color: #15803d;
    background: linear-gradient(90deg, rgba(187, 247, 208, 0.5) 0%, rgba(220, 252, 231, 0.3) 100%);
    user-select: none;
    transition: background 0.15s;
}

.kng-conditions-title:hover {
    background: linear-gradient(90deg, rgba(187, 247, 208, 0.7) 0%, rgba(220, 252, 231, 0.5) 100%);
}

.kng-conditions-title svg {
    color: #22c55e;
    flex-shrink: 0;
}

.kng-conditions-title::marker {
    content: '';
}

.kng-conditions-body {
    padding: 2px 4px 2px;
}

.kng-condition-group {
    margin-bottom: 4px;
}

.kng-condition-group:last-child {
    margin-bottom: 0;
}

.kng-group-label {
    font-size: 0.78em;
    font-weight: 600;
    color: #16a34a;
    margin: 6px 0 3px;
    padding: 2px 6px;
    background: rgba(74, 222, 128, 0.12);
    border-radius: 4px;
    display: inline-block;
}

.kng-condition-line {
    display: flex;
    align-items: flex-start;
    gap: 2px;
    padding: 3px 0;
    font-size: 0.84em;
    line-height: 1.45;
    flex-wrap: wrap;
}

.kng-condition-bullet {
    color: #22c55e;
    flex-shrink: 0;
    font-size: 0.85em;
    margin-top: 1px;
}

.kng-condition-text {
    color: #1a3a0a;
    flex: 1;
}

/* Location pin button */
.kng-loc-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    padding: 0;
    margin-left: 4px;
    border: 1px solid rgba(74, 222, 128, 0.5);
    border-radius: 50%;
    background: rgba(220, 252, 231, 0.7);
    color: #16a34a;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s;
}

.kng-loc-btn:hover {
    background: #22c55e;
    color: #fff;
    border-color: #22c55e;
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.5);
    transform: scale(1.15);
}

.kng-loc-btn svg {
    width: 13px;
    height: 13px;
}

/* Complete button */
.kng-complete-btn {
    width: 100%;
    padding: 7px 12px;
    border: none;
    border-radius: 6px;
    background: #22c55e;
    color: #fff;
    font-size: 0.88em;
    cursor: pointer;
    transition: all 0.2s;
}

.kng-complete-btn:hover {
    background: #16a34a;
}

.kng-complete-btn.completed {
    background: #15803d;
}

/* ── Dark theme ── */
.dark-theme .maplibregl-popup-content:has(.kng-popup) {
    background: transparent !important;
    box-shadow: none !important;
    border: none !important;
}

.dark-theme .kng-popup {
    background: linear-gradient(135deg, #0a2618 0%, #0d3320 50%, #0a2618 100%);
    border-color: #22c55e55;
    box-shadow: 0 0 14px rgba(34, 197, 94, 0.2), 0 0 6px rgba(34, 197, 94, 0.1);
}

.dark-theme .kng-header {
    border-bottom-color: rgba(34, 197, 94, 0.25);
}

.dark-theme .kng-title {
    color: #86efac;
}

.dark-theme .kng-description {
    color: #bbf7d0;
}

.dark-theme .kng-conditions {
    border-color: rgba(34, 197, 94, 0.25);
    background: rgba(10, 38, 24, 0.6);
}

.dark-theme .kng-conditions-title {
    color: #86efac;
    background: linear-gradient(90deg, rgba(34, 197, 94, 0.15) 0%, rgba(34, 197, 94, 0.05) 100%);
}

.dark-theme .kng-conditions-title:hover {
    background: linear-gradient(90deg, rgba(34, 197, 94, 0.25) 0%, rgba(34, 197, 94, 0.1) 100%);
}

.dark-theme .kng-conditions-title svg {
    color: #4ade80;
}

.dark-theme .kng-group-label {
    color: #4ade80;
    background: rgba(34, 197, 94, 0.1);
}

.dark-theme .kng-condition-bullet {
    color: #4ade80;
}

.dark-theme .kng-condition-text {
    color: #d1fae5;
}

.dark-theme .kng-loc-btn {
    border-color: rgba(34, 197, 94, 0.35);
    background: rgba(34, 197, 94, 0.12);
    color: #4ade80;
}

.dark-theme .kng-loc-btn:hover {
    background: #22c55e;
    color: #fff;
    border-color: #22c55e;
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.5);
}

.dark-theme .kng-complete-btn {
    background: #16a34a;
}

.dark-theme .kng-complete-btn:hover {
    background: #15803d;
}

.dark-theme .kng-complete-btn.completed {
    background: #166534;
}

/* ══════════════════════════════════════ */
/* Cổ Vật (CoVat) Popup — Old / Antique Theme */
/* ══════════════════════════════════════ */

.cv-popup {
    min-width: 260px;
    max-width: 340px;
    border-radius: 8px;
    background: linear-gradient(145deg, #fdf6e3 0%, #f5e6c8 50%, #fdf6e3 100%);
    box-shadow: 0 0 12px rgba(160, 120, 60, 0.2), inset 0 0 30px rgba(201, 169, 110, 0.08);
    padding: 10px 12px;
    position: relative;
}

.cv-popup::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 8px;
    pointer-events: none;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 3px,
        rgba(139, 90, 43, 0.015) 3px,
        rgba(139, 90, 43, 0.015) 4px
    );
}

.maplibregl-popup-content:has(.cv-popup) {
    background: transparent;
    box-shadow: none;
    padding: 0px !important;
    max-width: 360px;
}

.cv-image {
    margin: -10px -12px 8px -12px;
    border-radius: 8px 8px 0 0;
    overflow: hidden;
    border-bottom: 2px solid #c9a96e;
}

.cv-image img {
    width: 100%;
    display: block;
    cursor: pointer;
    filter: sepia(0.15) contrast(1.02);
}

.cv-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    padding-bottom: 6px;
    border-bottom: 1px dashed rgba(160, 120, 60, 0.4);
}

.cv-icon {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    filter: sepia(0.3);
}

.cv-title {
    font-size: 1.05em;
    font-weight: 700;
    color: #5c3d10;
    line-height: 1.3;
    max-width: calc(100% - 25px);
    letter-spacing: 0.3px;
}

.cv-description {
    font-size: 0.88em;
    color: #6b4f26;
    margin: 6px 0;
    line-height: 1.55;
    word-break: break-word;
}

/* Requirements / History section */
.cv-requirements {
    margin: 8px 0;
    border-radius: 6px;
    overflow: hidden;
    background: rgba(253, 246, 227, 0.6);
}

.cv-description a {
    color: #92400e;
    text-decoration: underline;
    transition: color 0.15s;
}

.cv-requirements-title {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 10px;
    cursor: pointer;
    font-size: 0.85em;
    font-weight: 600;
    color: #78580e;
    background: linear-gradient(90deg, rgba(201, 169, 110, 0.3) 0%, rgba(245, 230, 200, 0.3) 100%);
    user-select: none;
    transition: background 0.15s;
}

.cv-requirements-title:hover {
    background: linear-gradient(90deg, rgba(201, 169, 110, 0.5) 0%, rgba(245, 230, 200, 0.4) 100%);
}

.cv-requirements-title svg {
    color: #92400e;
    flex-shrink: 0;
}

.cv-requirements-title::marker {
    content: '';
}

.cv-requirements-body {
    padding: 2px 4px 2px;
}

.cv-req-group {
    margin-bottom: 4px;
}

.cv-req-group:last-child {
    margin-bottom: 0;
}

.cv-group-label {
    font-size: 0.78em;
    font-weight: 600;
    color: #92400e;
    margin: 6px 0 3px;
    padding: 2px 6px;
    background: rgba(160, 120, 60, 0.12);
    border-radius: 4px;
    display: inline-block;
}

.cv-req-line {
    display: flex;
    align-items: flex-start;
    gap: 2px;
    padding: 3px 0;
    font-size: 0.84em;
    line-height: 1.45;
    flex-wrap: wrap;
}

.cv-req-bullet {
    color: #b45309;
    flex-shrink: 0;
    font-size: 0.85em;
    margin-top: 1px;
}

.cv-req-text {
    color: #5c3d10;
    flex: 1;
}

/* Location pin button */
.cv-loc-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    padding: 0;
    margin-left: 4px;
    border: 1px solid rgba(160, 120, 60, 0.5);
    border-radius: 50%;
    background: rgba(253, 246, 227, 0.8);
    color: #92400e;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s;
}

.cv-loc-btn:hover {
    background: #b45309;
    color: #fef3c7;
    border-color: #b45309;
    box-shadow: 0 0 8px rgba(180, 83, 9, 0.4);
    transform: scale(1.15);
}

.cv-loc-btn svg {
    width: 13px;
    height: 13px;
}

/* Complete button */
.cv-complete-btn {
    width: 100%;
    padding: 7px 12px;
    border: none;
    border-radius: 6px;
    background: #92400e;
    color: #fef3c7;
    font-size: 0.88em;
    cursor: pointer;
    transition: all 0.2s;
}

.cv-complete-btn:hover {
    background: #78350f;
}

.cv-complete-btn.completed {
    background: #6b4f26;
}

/* ── Dark theme ── */
.dark-theme .maplibregl-popup-content:has(.cv-popup) {
    background: transparent !important;
    box-shadow: none !important;
    border: none !important;
}

.dark-theme .cv-popup {
    background: linear-gradient(145deg, #1c1208 0%, #2a1d0e 50%, #1c1208 100%);
    border-color: #6b4f26;
    box-shadow: 0 0 14px rgba(160, 120, 60, 0.15), inset 0 0 30px rgba(107, 79, 38, 0.05);
}

.dark-theme .cv-image {
    border-bottom-color: #6b4f26;
}

.dark-theme .cv-image img {
    filter: sepia(0.25) brightness(0.9) contrast(1.05);
}

.dark-theme .cv-header {
    border-bottom-color: rgba(160, 120, 60, 0.3);
}

.dark-theme .cv-title {
    color: #fbbf24;
}

.dark-theme .cv-description {
    color: #d4a976;
}

.dark-theme .cv-requirements {
    border-color: rgba(160, 120, 60, 0.25);
    background: rgba(28, 18, 8, 0.6);
}

.dark-theme .cv-requirements-title {
    color: #fbbf24;
    background: linear-gradient(90deg, rgba(160, 120, 60, 0.15) 0%, rgba(160, 120, 60, 0.05) 100%);
}

.dark-theme .cv-requirements-title:hover {
    background: linear-gradient(90deg, rgba(160, 120, 60, 0.25) 0%, rgba(160, 120, 60, 0.1) 100%);
}

.dark-theme .cv-requirements-title svg {
    color: #f59e0b;
}

.dark-theme .cv-group-label {
    color: #f59e0b;
    background: rgba(160, 120, 60, 0.1);
}

.dark-theme .cv-req-bullet {
    color: #f59e0b;
}

.dark-theme .cv-req-text {
    color: #fde68a;
}

.dark-theme .cv-loc-btn {
    border-color: rgba(160, 120, 60, 0.35);
    background: rgba(160, 120, 60, 0.12);
    color: #f59e0b;
}

.dark-theme .cv-loc-btn:hover {
    background: #b45309;
    color: #fef3c7;
    border-color: #b45309;
    box-shadow: 0 0 8px rgba(180, 83, 9, 0.4);
}

.dark-theme .cv-complete-btn {
    background: #78350f;
}

.dark-theme .cv-complete-btn:hover {
    background: #6b4f26;
}

.dark-theme .cv-complete-btn.completed {
    background: #5c3d10;
}

/*  Proximity Hint (focus mode)  */
#proximity-hint {
    position: fixed;
    z-index: 2000;
    pointer-events: auto;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.proximity-hint-bar {
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(12, 12, 20, 0.82);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-top: 1px solid rgba(212, 168, 83, 0.35);
    padding: 5px 35px 5px 5px;
    color: #e8e4dc;
}

.proximity-hint-wide {
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    min-width: 340px;
    max-width: 520px;
    background: rgba(12, 12, 20, 0.88);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(212, 168, 83, 0.4);
    border-radius: 10px;
    padding: 10px 44px 10px 16px;
    color: #e8e4dc;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
}

.proximity-hint-close {
    position: absolute;
    top: 6px;
    right: 8px;
    background: none;
    border: none;
    color: #888;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    padding: 2px 6px;
}
.proximity-hint-close:hover { color: #fff; }

.proximity-hint-title {
    font-size: 0.88rem;
    font-weight: 600;
    line-height: 1.4;
    color: #f0e8d0;
    display: flex;
    align-items: baseline;
    gap: 5px;
    flex-wrap: wrap;
}

.proximity-hint-cat {
    font-size: 0.75rem;
    font-weight: 700;
    color: #d4a853;
    background: rgba(212, 168, 83, 0.12);
    border: 1px solid rgba(212, 168, 83, 0.3);
    border-radius: 4px;
    padding: 1px 6px;
    white-space: nowrap;
    flex-shrink: 0;
}

.proximity-hint-desc {
    margin-top: 3px;
    font-size: 0.8rem;
    color: #a09880;
    line-height: 1.5;
}

/* ── User Markers ── */

/* Context menu */
.map-context-menu {
    position: fixed;
    z-index: 1000;
    background: #1e1e2e;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    overflow: hidden;
    min-width: 160px;
}
.ctx-menu-item {
    display: block;
    width: 100%;
    padding: 10px 16px;
    background: none;
    border: none;
    color: #e0e0e0;
    text-align: left;
    cursor: pointer;
    font-size: 14px;
    white-space: nowrap;
}
.ctx-menu-item:hover {
    background: rgba(255,255,255,0.1);
}

/* User marker modal overlay */
.user-marker-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
}
.user-marker-modal {
    background: #1e1e2e;
    color: #e0e0e0;
    border-radius: 12px;
    padding: 24px 28px;
    min-width: 320px;
    max-width: 420px;
    width: 90vw;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.user-marker-modal h3 {
    margin: 0 0 16px;
    font-size: 18px;
    font-weight: 600;
}
.user-marker-modal-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.user-marker-modal-form label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 13px;
    color: #aaa;
}
.user-marker-modal-form input[type="text"],
.user-marker-modal-form input[type="number"],
.user-marker-modal-form textarea,
.user-marker-modal-form select {
    background: #2a2a3e;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 6px;
    padding: 8px 10px;
    color: #e0e0e0;
    font-size: 14px;
    outline: none;
}
.user-marker-modal-form input:focus,
.user-marker-modal-form textarea:focus,
.user-marker-modal-form select:focus {
    border-color: #4a9eff;
}
.um-category-preview {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
}
.um-category-preview img {
    width: 24px;
    height: 24px;
}
.um-share-toggle {
    flex-direction: row !important;
    align-items: center !important;
    gap: 8px !important;
    cursor: pointer;
}
.um-coords-info {
    font-size: 11px;
    color: #666;
}
.user-marker-modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 8px;
}
.um-btn {
    padding: 8px 18px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    font-weight: 500;
}
.um-btn-save {
    background: #4a9eff;
    color: #fff;
}
.um-btn-save:hover { background: #3a8eef; }
.um-btn-save:disabled { opacity: 0.5; cursor: not-allowed; }
.um-btn-cancel {
    background: #333;
    color: #ccc;
}
.um-btn-cancel:hover { background: #444; }
.um-btn-delete {
    background: #c0392b;
    color: #fff;
    margin-right: auto;
}
.um-btn-delete:hover { background: #a93226; }

/* User marker popup */
.user-marker-badge {
    font-size: 11px;
    color: #ff6b35;
    font-weight: 600;
    margin-bottom: 4px;
}
.user-marker-height {
    font-size: 12px;
    color: #999;
    margin: 4px 0;
}
.user-marker-popup-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}
.user-marker-popup {
    min-width: 200px;
}
.um-popup-btn {
    padding: 4px 12px;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 4px;
    background: #2a2a3e;
    color: #e0e0e0;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.15s, border-color 0.15s;
}
.um-popup-btn:hover { background: #b89c00; }
.um-popup-btn-delete {
    color: #e74c3c;
    border-color: rgba(231, 77, 60, 0.795);
}
.um-popup-btn-delete:hover { background: rgba(231, 77, 60, 0.418); }

/* User marker filter group */
.user-marker-group {
    padding-bottom: 8px;
    margin-bottom: 4px;
}
