/* ===== MAP PAGE STYLES ===== */

/* ---- Layout ---- */
.map-app {
    position: fixed;
    top: 64px;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg-dark);
    overflow: hidden;
}

/* ---- Top Bar ---- */
.map-topbar {
    flex-shrink: 0;
    background: rgba(18, 24, 33, 0.95);
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    z-index: 20;
}
.map-topbar-inner {
    display: grid;
    grid-template-columns: 320px 1fr auto 310px;
    align-items: center;
    height: 52px;
}
/* Atlas Trigger */
.map-atlas-trigger {
    grid-column: 2;
    justify-self: start;
    margin-left: 16px;
    width: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    background: rgba(31, 182, 201, 0.1);
    border: 1px solid rgba(31, 182, 201, 0.2);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: 'Outfit', sans-serif;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}
.map-atlas-trigger:hover {
    background: rgba(31, 182, 201, 0.15);
    border-color: rgba(31, 182, 201, 0.4);
    box-shadow: 0 0 20px rgba(31, 182, 201, 0.1);
}
.map-atlas-trigger svg {
    color: var(--primary);
    flex-shrink: 0;
}
.map-atlas-current-name {
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    color: #fff;
    background: var(--primary);
    padding: 3px 10px;
    border-radius: 6px;
    margin-left: auto;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 5px rgba(31, 182, 201, 0.4);
    white-space: nowrap;
}

/* Atlas Modal */
.map-atlas-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 14, 20, 0.85);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
.map-atlas-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.map-atlas-modal {
    width: 100%;
    max-width: 1100px;
    max-height: 85vh;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.5), 0 0 50px rgba(31, 182, 201, 0.1);
    display: flex;
    flex-direction: column;
    transform: scale(0.95) translateY(20px);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
.map-atlas-overlay.active .map-atlas-modal {
    transform: scale(1) translateY(0);
}

.map-atlas-header {
    padding: 24px 32px;
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 32px;
}
.map-atlas-title {
    font-family: 'Outfit', sans-serif;
    font-size: 22px;
    font-weight: 800;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}
.map-atlas-title svg { color: var(--primary); }

.map-atlas-search-wrap {
    flex: 1;
    position: relative;
}
.map-atlas-search-wrap svg {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}
.map-atlas-search-wrap input {
    width: 100%;
    background: rgba(15, 21, 32, 0.6);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px 12px 12px 42px;
    color: var(--text-primary);
    font-size: 15px;
    font-family: 'Inter', sans-serif;
    outline: none;
    transition: all var(--transition-base);
}
.map-atlas-search-wrap input:focus {
    border-color: var(--primary);
    background: rgba(31, 182, 201, 0.05);
    box-shadow: 0 0 15px rgba(31, 182, 201, 0.1);
}

.map-atlas-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    transition: color 0.2s;
    flex-shrink: 0;
}
.map-atlas-close:hover { color: var(--text-primary); }

.map-atlas-grid {
    flex: 1;
    overflow-y: auto;
    padding: 32px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
    scrollbar-width: thin;
}

/* Atlas Card */
.atlas-card {
    background: rgba(15, 21, 32, 0.4);
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    animation: atlasCardIn 0.4s ease both;
    display: flex;
    flex-direction: column;
}
@keyframes atlasCardIn {
    0% { opacity: 0; transform: translateY(15px) scale(0.97); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}
.atlas-card:hover {
    transform: translateY(-5px);
    border-color: var(--primary);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.4), 0 0 20px rgba(31, 182, 201, 0.2);
}
.atlas-card.active {
    border-color: var(--primary);
    box-shadow: 0 0 25px rgba(31, 182, 201, 0.4);
}

.atlas-card-img-wrap {
    width: 100%;
    aspect-ratio: 16/9;
    background: #000;
    position: relative;
    overflow: hidden;
}
.atlas-card-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.75;
    transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.4s;
    display: block;
}
.atlas-card:hover .atlas-card-img {
    transform: scale(1.1);
    opacity: 1;
}
.atlas-card.active .atlas-card-img {
    opacity: 1;
}

/* Name label overlay ON thumbnail */
.atlas-card-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 24px 14px 12px 14px;
    background: linear-gradient(transparent, rgba(10, 14, 20, 0.95));
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 8px;
    z-index: 2;
    pointer-events: none;
}
.atlas-card-name {
    font-family: 'Outfit', sans-serif;
    font-size: 16px;
    font-weight: 800;
    color: #ffffff;
    letter-spacing: 0.5px;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.9);
}
.atlas-card-status {
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #fff;
    background: var(--primary);
    padding: 3px 8px;
    border-radius: 4px;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.5);
}


/* Search */
.map-search-wrap {
    grid-column: 3;
    justify-self: end;
    width: 400px;
    margin-right: 16px;
    position: relative;
}

.map-edit-btn {
    grid-column: 4;
    justify-self: end;
    margin-right: 20px;
}
.map-search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
    z-index: 2;
}
.map-search-input {
    width: 100%;
    padding: 10px 16px 10px 42px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: all 0.2s;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
    backdrop-filter: blur(8px);
}
.map-search-input:focus {
    border-color: var(--primary);
    background: rgba(31, 182, 201, 0.08);
    box-shadow: 0 0 0 3px rgba(31, 182, 201, 0.15), inset 0 2px 4px rgba(0,0,0,0.2);
}
.map-search-input::placeholder {
    color: var(--text-muted);
}

/* Predictive Search Dropdown */
.map-search-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: rgba(18, 24, 33, 0.95);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 15px rgba(31, 182, 201, 0.1);
    max-height: 400px;
    overflow-y: auto;
    z-index: 100;
    display: none;
    scrollbar-width: thin;
}
.map-search-dropdown.active {
    display: block;
    animation: dropdownIn 0.2s ease;
}
@keyframes dropdownIn {
    0% { opacity: 0; transform: translateY(-5px); }
    100% { opacity: 1; transform: translateY(0); }
}

.map-search-empty {
    padding: 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    font-style: italic;
}

.map-search-result-item {
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    transition: background 0.2s;
}
.map-search-result-item:last-child {
    border-bottom: none;
}
.map-search-result-item:hover {
    background: rgba(31, 182, 201, 0.1);
}

.map-search-result-img {
    width: 48px;
    height: 32px;
    border-radius: 4px;
    object-fit: cover;
    background: #000;
    border: 1px solid rgba(255, 255, 255, 0.1);
}
.map-search-result-item[data-type="lugh"] .map-search-result-img {
    background: transparent;
    object-fit: contain;
    border: none;
}

.map-search-result-content {
    flex: 1;
    overflow: hidden;
}
.map-search-result-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.map-search-result-subtitle {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}
.map-search-result-subtitle .highlight {
    color: var(--primary);
    font-weight: 600;
}

/* ---- Main Content Area ---- */
.map-content {
    flex: 1;
    display: flex;
    overflow: hidden;
    position: relative;
}

/* ---- Left Sidebar ---- */
.map-sidebar {
    width: 320px;
    flex-shrink: 0;
    background: rgba(18, 24, 33, 0.92);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 15;
    transition: width var(--transition-base);
    overflow: visible; /* Prevents swallowing the absolutely positioned toggle button */
}
.map-sidebar.collapsed {
    width: 0;
    border-right: none;
}
.map-sidebar.collapsed .map-sidebar-content { opacity: 0; pointer-events: none; visibility: hidden; }
.map-sidebar.collapsed .map-sidebar-toggle svg { transform: rotate(180deg); }

.map-sidebar-toggle {
    position: absolute;
    top: 12px;
    right: -16px;
    width: 32px;
    height: 32px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    cursor: pointer;
    z-index: 25;
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-sm);
}
.map-sidebar-toggle:hover {
    color: var(--primary);
    border-color: var(--primary);
}
.map-sidebar-toggle svg {
    transition: transform var(--transition-base);
}

.map-sidebar-content {
    padding: 16px;
    overflow-y: auto;
    flex: 1;
    transition: opacity var(--transition-fast);
}

.map-sidebar-section {
    margin-bottom: 24px;
}
.map-sidebar-title {
    font-family: 'Outfit', sans-serif;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: #cbd5e1;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Layer toggles */
.map-layers-list {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-auto-rows: 1fr;
    gap: 6px;
    padding-right: 4px;
    margin-bottom: 10px;
}
.map-layers-list .map-layer-toggle {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-bottom: 0;
    padding: 8px 4px;
    min-height: 64px;
    background: rgba(11, 15, 20, 0.5);
    border: 1px solid rgba(31, 182, 201, 0.15);
    border-radius: var(--radius-sm);
    font-size: 10px;
    line-height: 1.2;
    text-align: center;
    transition: all var(--transition-fast);
    cursor: pointer;
}
/* Active State (ON) */
.map-layers-list .map-layer-toggle:has(input:checked) {
    background: rgba(31, 182, 201, 0.12);
    border-color: rgba(31, 182, 201, 0.4);
}

/* Hover State (Works for both ON and OFF) */
.map-layers-list .map-layer-toggle:hover {
    background: rgba(245, 154, 46, 0.1) !important;
    border-color: var(--accent) !important;
}

/* Suppress hover immediately after unchecking until mouse leaves */
.map-layers-list .map-layer-toggle.is-unchecking:hover {
    background: rgba(11, 15, 20, 0.5) !important;
    border-color: rgba(31, 182, 201, 0.15) !important;
}
.map-layer-toggle input { display: none; }
.map-layer-icon {
    width: 22px;
    height: 22px;
    object-fit: contain;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.5));
    transition: opacity var(--transition-fast), filter var(--transition-fast);
}
.map-layer-toggle input:not(:checked) ~ .map-layer-icon {
    opacity: 0.2;
    filter: grayscale(1);
}
.map-layer-toggle input:not(:checked) ~ span {
    opacity: 0.5;
}
.map-layers-list::-webkit-scrollbar { width: 4px; }
.map-layers-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

/* Filters */
.map-filter-group {
    margin-bottom: 10px;
}
.map-filter-label {
    font-size: 12px;
    color: #94a3b8;
    font-weight: 700;
    display: block;
    margin-bottom: 6px;
}
/* Custom Select */
.map-custom-select {
    position: relative;
    width: 100%;
}
.map-select-trigger {
    width: 100%;
    padding: 6px 10px;
    background: rgba(15, 21, 32, 0.9);
    border: 1px solid rgba(31, 182, 201, 0.35);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: all var(--transition-fast);
}
.map-select-trigger:hover,
.map-custom-select.active .map-select-trigger {
    border-color: var(--accent);
    background: rgba(15, 21, 32, 1);
    box-shadow: 0 0 10px rgba(245, 154, 46, 0.1);
}
.map-select-current {
    display: flex;
    align-items: center;
    gap: 8px;
}
.map-select-current img {
    width: 18px;
    height: 18px;
    object-fit: contain;
}
.map-select-arrow {
    color: #64748b;
}
.map-select-dropdown {
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    width: 100%;
    min-width: 240px;
    background: rgba(15, 21, 32, 0.98);
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 8px;
    z-index: 100;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    display: none;
}
.map-select-dropdown.active {
    display: block;
}

.map-rarity-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.map-rarity-item {
    padding: 8px 12px;
    font-size: 13px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}
.map-rarity-item:hover {
    background: rgba(255,255,255,0.05);
}
.map-rarity-item.selected {
    background: rgba(31, 182, 201, 0.15);
    border-left: 2px solid var(--accent);
}

.map-element-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-auto-rows: 1fr;
    gap: 6px;
}
.map-element-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60px;
    padding: 6px 4px;
    background: rgba(255,255,255,0.02);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-align: center;
}
.map-element-btn:hover {
    background: rgba(31, 182, 201, 0.1);
    border-color: rgba(31, 182, 201, 0.3);
}
.map-element-btn.selected {
    background: rgba(31, 182, 201, 0.2);
    border-color: var(--accent);
}
.map-element-btn img {
    width: 22px;
    height: 22px;
    margin-bottom: 4px;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.5));
}
.map-element-btn span {
    font-size: 10px;
    color: var(--text-secondary);
}
.map-element-btn.selected span {
    color: var(--text-primary);
}
.map-filter-select {
    width: 100%;
    padding: 8px 10px;
    background: rgba(15, 21, 32, 0.9);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
    cursor: pointer;
    transition: all var(--transition-fast);
}
.map-filter-select:hover {
    border-color: var(--primary);
}
.map-filter-select option { 
    background: #0B0F14; 
    color: var(--text-primary);
}
.map-filter-select option[value="1"] { color: #94a3b8; }
.map-filter-select option[value="2"] { color: #10b981; }
.map-filter-select option[value="3"] { color: #3b82f6; }
.map-filter-select option[value="4"] { color: #a855f7; }
.map-filter-select option[value="5"] { color: #f59e0b; }

.map-element-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-auto-rows: 1fr;
    gap: 6px;
    margin-bottom: 8px;
}
.map-element-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 56px;
    padding: 6px 4px;
    background: rgba(11, 15, 20, 0.5);
    border: 1px solid rgba(31, 182, 201, 0.25);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-align: center;
}
.map-element-btn:hover {
    background: rgba(31, 182, 201, 0.1);
    border-color: var(--accent);
}
.map-element-btn.selected {
    background: rgba(31, 182, 201, 0.2);
    border-color: var(--accent);
}
.map-element-btn img {
    width: 20px;
    height: 20px;
    margin-bottom: 4px;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.5));
}
.map-element-btn span {
    font-size: 9px;
    color: var(--text-secondary);
}
.map-element-btn.selected span {
    color: var(--text-primary);
}

.map-filter-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.map-filter-input {
    width: 100%;
    padding: 8px 10px;
    background: rgba(15, 21, 32, 0.9);
    border: 1px solid rgba(31, 182, 201, 0.35);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
    transition: all var(--transition-fast);
}
.map-filter-input:hover,
.map-filter-input:focus {
    border-color: var(--accent);
    background: rgba(15, 21, 32, 1);
    box-shadow: 0 0 10px rgba(245, 154, 46, 0.1);
}
.map-reset-btn {
    width: 100%;
    padding: 7px 12px;
    margin-top: 8px;
    background: rgba(31, 182, 201, 0.08);
    border: 1px solid rgba(31, 182, 201, 0.15);
    border-radius: var(--radius-sm);
    color: var(--primary);
    font-size: 12px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    transition: all var(--transition-fast);
}
.map-reset-btn:hover {
    background: rgba(31, 182, 201, 0.15);
    border-color: rgba(31, 182, 201, 0.3);
}

/* ---- Map Viewport ---- */
.map-viewport {
    flex: 1;
    position: relative;
    overflow: hidden;
    cursor: grab;
    background:
        radial-gradient(circle at 30% 40%, rgba(31, 182, 201, 0.03) 0%, transparent 50%),
        radial-gradient(circle at 70% 60%, rgba(245, 154, 46, 0.02) 0%, transparent 50%),
        #080c12;
    /* Subtle grid pattern */
    background-size: 100% 100%, 100% 100%, 40px 40px;
}
.map-viewport:active { cursor: grabbing; }

.map-canvas {
    position: absolute;
    top: 0;
    left: 0;
    transform-origin: 0 0;
    transition: none;
    will-change: transform;
}
.map-canvas.animating {
    transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.map-image {
    display: block;
    max-width: none;
    image-rendering: auto;
    user-select: none;
    -webkit-user-drag: none;
    pointer-events: none;
}

.map-markers {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    --marker-inv-scale: 1;
}

/* ---- Map Markers ---- */
.map-marker {
    position: absolute;
    transform: translate(-50%, -50%) scale(var(--marker-inv-scale));
    pointer-events: auto;
    cursor: pointer;
    z-index: 5;
    transition: filter 0.15s ease;
}
.map-marker:hover {
    z-index: 10;
    filter: brightness(1.2);
}
.map-marker-icon {
    display: block;
    max-width: 36px;
    max-height: 36px;
    width: auto;
    height: auto;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.6));
}
.map-marker:hover .map-marker-icon {
    filter: drop-shadow(0 3px 10px rgba(31, 182, 201, 0.5));
}
.map-marker-tooltip {
    display: none;
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(11, 15, 20, 0.93);
    border: 1px solid rgba(31, 182, 201, 0.2);
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    color: var(--text-primary);
    white-space: nowrap;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}
.map-marker:hover .map-marker-tooltip {
    display: block;
}

/* Zoom controls */
.map-zoom-controls {
    position: absolute;
    bottom: 20px;
    left: 20px;
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(18, 24, 33, 0.92);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 4px;
    z-index: 10;
}
.map-zoom-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}
.map-zoom-btn:hover {
    color: var(--primary);
    background: rgba(31, 182, 201, 0.1);
}
.map-zoom-level {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    min-width: 40px;
    text-align: center;
    font-family: 'Inter', sans-serif;
}

/* Island badge */
.map-island-badge {
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(18, 24, 33, 0.88);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 8px 20px;
    z-index: 10;
    pointer-events: none;
    animation: mapBadgeIn 0.4s ease;
}
.map-island-badge-name {
    font-family: 'Outfit', sans-serif;
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 0.5px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

@keyframes mapBadgeIn {
    from { opacity: 0; transform: translateX(-50%) translateY(-8px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ---- Right Panel ---- */
.map-panel {
    width: 310px;
    flex-shrink: 0;
    background: rgba(18, 24, 33, 0.95);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border-left: 1px solid var(--border);
    overflow-y: auto;
    z-index: 15;
}
.map-panel-content {
    padding: 20px;
}

/* Island Info */
.map-panel-island-header {
    margin-bottom: 20px;
}
.map-panel-island-name {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 12px;
}
.map-panel-island-levels {
    font-size: 14px;
    font-weight: 500;
    color: var(--accent);
    background: rgba(31, 182, 201, 0.1);
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid rgba(31, 182, 201, 0.2);
}
.map-panel-island-tag {
    display: none;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--primary);
    background: rgba(31, 182, 201, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    margin-top: 4px;
}
.map-panel-island-tag.visible { display: inline-block; }
.map-panel-island-desc {
    display: none;
}
.map-panel-island-name {
    font-family: 'Outfit', sans-serif;
    font-size: 20px;
    font-weight: 800;
    color: var(--text-primary);
}
.map-panel-island-tag {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 8px;
    background: rgba(245, 154, 46, 0.15);
    color: var(--accent);
    border-radius: 20px;
    display: none;
}
.map-panel-island-tag.visible { display: inline-block; }
.map-panel-island-desc {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

/* Section headers */
.map-panel-section {
    margin-bottom: 20px;
}
.map-panel-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.map-panel-section-title {
    font-family: 'Outfit', sans-serif;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}
.map-panel-count {
    font-size: 11px;
    font-weight: 700;
    color: var(--primary);
    background: rgba(31, 182, 201, 0.1);
    padding: 2px 8px;
    border-radius: 20px;
}
.map-panel-empty {
    font-size: 12px;
    color: var(--text-muted);
    font-style: italic;
    padding: 8px 0;
}

/* Creature cards */
.map-panel-creature-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: calc(100vh - 420px);
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 4px;
}
.map-creature-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    background: rgba(15, 21, 32, 0.6);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
}
.map-creature-card:hover {
    background: rgba(31, 182, 201, 0.06);
    border-color: rgba(31, 182, 201, 0.2);
    transform: translateX(2px);
}
.map-creature-card:hover .map-creature-card-name {
    color: var(--primary);
}
.map-creature-img-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}
.map-creature-img-num {
    font-size: 10px;
    font-weight: 800;
    color: var(--text-muted);
    font-family: 'Inter', sans-serif;
    line-height: 1;
}
.map-creature-card-img {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    background: rgba(31, 182, 201, 0.04);
    border: 1px solid rgba(31, 182, 201, 0.15);
    object-fit: contain;
    image-rendering: pixelated;
    padding: 2px;
}
.map-creature-card-info {
    flex: 1;
    min-width: 0;
}
.map-creature-card-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
}
.map-creature-card-name {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    transition: color var(--transition-fast);
    white-space: nowrap;
}
.map-creature-card-elements {
    display: flex;
    gap: 3px;
    align-items: center;
}
.map-creature-card-elements img {
    width: 14px;
    height: 14px;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.5));
}
.map-creature-card-rarity {
    font-size: 10px;
    font-weight: 700;
    margin-left: auto; /* Aligns to the right */
    flex-shrink: 0;
    letter-spacing: 1px;
}
.map-creature-card-loot-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.map-loot-icon-only {
    position: relative;
    width: 28px;
    height: 28px;
    background: rgba(15, 21, 32, 0.8);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: help;
    transition: all var(--transition-fast);
}
.map-loot-icon-only:hover {
    background: rgba(245, 154, 46, 0.1);
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(245, 154, 46, 0.15);
}
.map-loot-icon-only img {
    width: 20px;
    height: 20px;
    object-fit: contain;
}
.map-loot-rarity-badge {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 8px;
    font-weight: 800;
    color: #fff;
    border: 1px solid rgba(0, 0, 0, 0.5);
    z-index: 2;
}
.rarity-1 { background: #94A3B8; }
.rarity-2 { background: #10B981; }
.rarity-3 { background: #3B82F6; }
.rarity-4 { background: #A855F7; }
.rarity-5 { background: #F59E0B; }

/* Creature tags */
.map-creature-card-tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-right: 6px;
    margin-bottom: 6px;
    font-family: 'Inter', sans-serif;
}
.map-creature-card-tag.aggressive {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
}
.map-creature-card-tag.high-chance {
    background: rgba(31, 182, 201, 0.15);
    color: var(--primary);
    border: 1px solid rgba(31, 182, 201, 0.3);
}

/* ===== EDIT MODE ===== */
.map-edit-btn {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    color: var(--accent);
    background: rgba(245, 154, 46, 0.1);
    border: 1px solid rgba(245, 154, 46, 0.25);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}
.map-edit-btn:hover {
    background: rgba(245, 154, 46, 0.2);
    border-color: rgba(245, 154, 46, 0.4);
}
.map-edit-btn.active {
    color: #fff;
    background: var(--accent);
    border-color: var(--accent);
}
.map-edit-header { margin-bottom: 12px; }
.map-edit-badge {
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 1.5px;
    padding: 3px 10px;
    background: rgba(245, 154, 46, 0.15);
    color: var(--accent);
    border: 1px solid rgba(245, 154, 46, 0.3);
    border-radius: 20px;
}
.map-edit-hint {
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}
.map-edit-palette {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
}
.map-edit-palette-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 4px;
    background: rgba(15, 21, 32, 0.6);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    min-width: 0;
}
.map-edit-palette-item:hover {
    background: rgba(31, 182, 201, 0.08);
    border-color: rgba(31, 182, 201, 0.2);
}
.map-edit-palette-item.selected {
    background: rgba(245, 154, 46, 0.12);
    border-color: var(--accent);
    box-shadow: 0 0 8px rgba(245, 154, 46, 0.2);
}
.map-edit-palette-item img {
    width: 28px;
    height: 28px;
    object-fit: contain;
}
.map-edit-palette-item span {
    font-size: 9px;
    font-weight: 600;
    color: var(--text-muted);
    text-align: center;
    line-height: 1.2;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 100%;
}
.map-edit-palette-lughs {
    grid-template-columns: repeat(3, 1fr);
    max-height: 300px;
    overflow-y: auto;
}
.map-edit-lugh-diamond {
    width: 44px;
    height: 44px;
    background: transparent;
    overflow: visible;
}
.map-edit-lugh-diamond img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    image-rendering: pixelated;
}
.map-edit-search {
    width: 100%;
    padding: 6px 10px;
    background: rgba(15, 21, 32, 0.9);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 11px;
    font-family: 'Inter', sans-serif;
    outline: none;
    margin-bottom: 8px;
}
.map-edit-search:focus { border-color: var(--primary); }
.map-edit-search::placeholder { color: var(--text-muted); }

.map-edit-lugh-config {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
    background: rgba(15, 21, 32, 0.6);
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}
.map-edit-lugh-config label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
}
.map-edit-lvl-input {
    width: 40px;
    background: rgba(11, 15, 20, 0.8);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 11px;
    padding: 2px 4px;
    text-align: center;
    outline: none;
}
.map-edit-lvl-input:focus { border-color: var(--primary); }
.map-edit-lugh-config span {
    color: var(--text-muted);
    font-size: 10px;
}
.map-edit-actions {
    display: flex;
    gap: 8px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    margin-top: 16px;
}
.map-edit-save {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 12px;
    background: var(--primary);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    font-family: 'Inter', sans-serif;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}
.map-edit-save:hover { background: var(--primary-dim); }
.map-edit-cancel {
    padding: 8px 12px;
    background: rgba(239, 68, 68, 0.1);
    color: #EF4444;
    font-size: 12px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: var(--radius-sm);
    cursor: pointer;
}
.map-edit-cancel:hover { background: rgba(239, 68, 68, 0.2); }

/* Lugh diamond markers on map */
.map-marker-lugh {
    position: absolute;
    transform: translate(-50%, -50%) scale(var(--marker-inv-scale));
    pointer-events: auto;
    cursor: pointer;
    z-index: 5;
}
.map-marker-lugh:hover { z-index: 10; }
.map-marker-lugh-diamond {
    width: 44px;
    height: 44px;
    background: transparent;
    overflow: visible;
}
.map-marker-lugh:hover .map-marker-lugh-diamond {
    filter: drop-shadow(0 3px 10px rgba(31, 182, 201, 0.5));
}
.map-marker-lugh:not(.is-boss) .map-marker-lugh-diamond {
    filter: 
        drop-shadow(1px 0 0 #ffffff) 
        drop-shadow(-1px 0 0 #ffffff) 
        drop-shadow(0 1px 0 #ffffff) 
        drop-shadow(0 -1px 0 #ffffff);
}
.map-marker-lugh:not(.is-boss):hover .map-marker-lugh-diamond {
    filter: 
        drop-shadow(1px 0 0 #ffffff) 
        drop-shadow(-1px 0 0 #ffffff) 
        drop-shadow(0 1px 0 #ffffff) 
        drop-shadow(0 -1px 0 #ffffff)
        drop-shadow(0 3px 6px rgba(31, 182, 201, 0.8));
}
.map-marker-lugh-diamond img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    image-rendering: pixelated;
}
.map-marker-labels {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    margin-bottom: 4px;
    pointer-events: none;
    z-index: 2;
}
.map-marker-lugh-boss-name {
    color: #FF6B6B; /* A vivid, slightly pastel red so it doesn't get entirely swallowed by the darker red glow */
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-family: 'Inter', sans-serif;
    white-space: nowrap;
    text-shadow: 
        0 0 4px #DC2626, 
        0 0 10px #DC2626, 
        0 0 16px #DC2626, 
        0 0 24px #991B1B, 
        0 2px 4px rgba(0,0,0,0.9);
}
.map-marker-lugh-level {
    background: #0B0F14;
    border: 1px solid rgba(31, 182, 201, 0.6);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    font-family: 'Inter', sans-serif;
    padding: 1px 6px;
    border-radius: 10px;
    white-space: nowrap;
    box-shadow: 0 2px 4px rgba(0,0,0,0.5);
}
.map-marker.edit-selected,
.map-marker-lugh.edit-selected {
    outline: 2px solid var(--accent);
    outline-offset: 4px;
    border-radius: 50%;
}

/* Boss Marker Styling */
.map-marker-lugh.is-boss {
    z-index: 25;
}
.map-marker-lugh.is-boss .map-marker-lugh-diamond {
    /* Thinner 4-directional 1px stroke */
    filter: 
        drop-shadow(1px 0 0 #ef4444) 
        drop-shadow(-1px 0 0 #ef4444) 
        drop-shadow(0 1px 0 #ef4444) 
        drop-shadow(0 -1px 0 #ef4444);
    transform: scale(1.4);
}
.map-marker-lugh.is-boss:hover .map-marker-lugh-diamond {
    filter: 
        drop-shadow(1px 0 0 #ef4444) 
        drop-shadow(-1px 0 0 #ef4444) 
        drop-shadow(0 1px 0 #ef4444) 
        drop-shadow(0 -1px 0 #ef4444)
        drop-shadow(0 0 8px rgba(239, 68, 68, 0.9));
}
.map-marker-lugh.is-boss .map-marker-lugh-level {
    background: #EF4444;
    border-color: #7f1d1d;
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.6);
}

/* Aggressive Marker */
.map-marker-lugh.is-aggressive .map-marker-lugh-diamond {
    filter: 
        drop-shadow(0 0 4px #ef4444) 
        drop-shadow(0 0 8px #ef4444) 
        drop-shadow(0 0 12px #991b1b);
}
.map-marker-lugh.is-aggressive:hover .map-marker-lugh-diamond {
    filter: 
        drop-shadow(0 0 6px #ef4444) 
        drop-shadow(0 0 12px #ef4444) 
        drop-shadow(0 0 18px #991b1b)
        drop-shadow(0 3px 10px rgba(239, 68, 68, 0.5));
}
.map-edit-cursor-preview {
    position: fixed;
    pointer-events: none;
    z-index: 999;
    opacity: 0.6;
    transform: translate(-50%, -50%);
}
.map-edit-cursor-preview img {
    width: 36px;
    height: auto;
}
.map-viewport.edit-mode { cursor: crosshair; }
