@font-face {
    font-family: 'Amazon Ember';
    src: url('/fonts/AmazonEmber_Rg.ttf');
    font-weight: 400
}

@font-face {
    font-family: 'Amazon Ember';
    src: url('/fonts/AmazonEmber_Bd.ttf');
    font-weight: 700
}

@font-face {
    font-family: 'Amazon Ember';
    src: url('/fonts/AmazonEmber_Lt.ttf');
    font-weight: 300
}

@font-face {
    font-family: 'Cinzel Decorative';
    src: url('/fonts/CinzelDecorative-Regular.ttf');
    font-weight: 400
}

@font-face {
    font-family: 'Cinzel Decorative';
    src: url('/fonts/CinzelDecorative-Bold.ttf');
    font-weight: 700
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0
}

html,
body {
    height: 100%;
    font-family: 'Amazon Ember', system-ui, sans-serif;
    background: #12121200;
    color: #d0d0d0
}

#app {
    display: flex;
    height: 100vh;
}

/* Sidebar — snapped left */
#sidebar {
    width: 260px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: #1a1a1a;
    border-right: 1px solid #333;
    overflow: hidden;
    transition: width 0.2s ease;
    position: relative;
}
#sidebar.collapsed {
    width: 0 !important;
    min-width: 0 !important;
    overflow: hidden;
}

#sidebar h1 {
    padding: 12px 16px;
    font-family: 'Cinzel Decorative', serif;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: #c0c0c0;
    border-bottom: 1px solid #333
}

#search-box {
    padding: 8px;
    border-bottom: 1px solid #333
}

#search-box input {
    width: 100%;
    padding: 6px 28px 6px 8px;
    background: #222;
    border: 1px solid #444;
    color: #d0d0d0;
    font-size: 0.85rem;
    font-family: 'Amazon Ember', sans-serif
}

#search-box input::placeholder {
    color: #666
}

#search-box input:focus {
    outline: none;
    border-color: #888
}

#map-search-clear {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    font-size: 0.8rem;
    line-height: 1;
    padding: 2px 4px;
    display: none
}

#map-search-clear:hover {
    color: #c0c0c0
}

#map-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px 0
}

.map-group-header {
    padding: 6px 16px 2px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #888
}

.map-entry {
    padding: 5px 16px;
    cursor: pointer;
    font-size: 0.82rem;
    border-left: 3px solid transparent;
    transition: background 0.1s;
    display: flex;
    align-items: center;
    gap: 6px
}

.map-entry:hover {
    background: #2a2a2a
}

.map-entry.active {
    background: #2a2a2a;
    border-left-color: #c0c0c0;
    color: #fff
}

.map-entry .img-dot,
.map-subentry .img-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0
}

.map-entry .img-dot.has-img,
.map-subentry .img-dot.has-img {
    background: #5a5
}

.map-entry .img-dot.no-img,
.map-subentry .img-dot.no-img {
    background: #555
}

.map-entry .expand-arrow {
    font-size: 0.6rem;
    color: #888;
    flex-shrink: 0;
    transition: transform 0.15s;
    width: 10px;
    text-align: center
}

.map-entry.expanded .expand-arrow {
    transform: rotate(90deg)
}

.map-sublist {
    display: none
}

.map-sublist.open {
    display: block
}

.map-subentry {
    padding: 4px 16px 4px 30px;
    cursor: pointer;
    font-size: 0.78rem;
    color: #aaa;
    border-left: 3px solid transparent;
    transition: background 0.1s;
    display: flex;
    align-items: center;
    gap: 6px
}

.map-subentry:hover {
    background: #2a2a2a;
    color: #e0e0e0
}

.map-subentry.active {
    background: #2a2a2a;
    border-left-color: #c0c0c0;
    color: #fff
}

/* Layers panel */
#layers-panel {
    padding: 10px 16px;
    border-top: 1px solid #333;
    font-size: 0.82rem
}

#layers-panel h3 {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #888;
    margin-bottom: 6px
}

#layers-panel .layer-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 8px
}

.layer-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 2px 0;
    cursor: pointer
}

.layer-toggle input {
    cursor: pointer;
    accent-color: #c0c0c0
}

/* Map container — flex child, fills remaining space */
#map-container {
    flex: 1;
    position: relative;
    overflow: hidden
}

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

#map-title {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 500;
    background: rgba(18, 18, 18, 0.9);
    padding: 4px 14px;
    font-family: 'Cinzel Decorative', serif;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: #c0c0c0;
    pointer-events: none;
    border: 1px solid #444
}

#floor-selector {
    position: absolute;
    top: 42px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 500;
    display: flex;
    gap: 4px
}

#floor-selector button {
    background: rgba(18, 18, 18, 0.9);
    color: #b0b0b0;
    border: 1px solid #444;
    padding: 2px 10px;
    font-size: 0.75rem;
    cursor: pointer
}

#floor-selector button.active {
    background: #333;
    color: #fff;
    border-color: #888
}

#tile-layer-selector {
    position: absolute;
    top: 72px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 500;
    display: flex;
    gap: 4px
}

#tile-layer-selector button {
    background: rgba(18, 18, 18, 0.9);
    color: #b0b0b0;
    border: 1px solid #444;
    padding: 2px 10px;
    font-size: 0.75rem;
    cursor: pointer
}

#tile-layer-selector button.active {
    background: #333;
    color: #fff;
    border-color: #888
}

#coord-display {
    position: absolute;
    bottom: 8px;
    left: 8px;
    z-index: 500;
    background: rgba(18, 18, 18, 0.9);
    padding: 4px 10px;
    font-size: 0.9rem;
    font-family: monospace;
    font-weight: 600;
    color: #d0d0d0;
    pointer-events: none;
    min-width: 280px;
    text-align: left;
    border: 1px solid #444
}

/* Pd pieces */
.pd-label {
    color: #ffcc44;
    font-size: 10px;
    font-family: monospace;
    font-weight: 600;
    white-space: nowrap;
    pointer-events: none
}

.pd-label-btn {
    pointer-events: auto;
    cursor: zoom-in;
    text-decoration: underline dotted
}

.pd-label-btn:hover {
    color: #ffe88a
}

.stage-label {
    color: rgba(200, 200, 200, 0.75);
    font-size: 2rem;
    font-family: 'Cinzel Decorative', serif;
    font-weight: 800;
    text-align: center;
    pointer-events: none;
    white-space: nowrap;
    text-shadow: 0 0 8px rgba(0, 0, 0, 1), 0 0 4px rgba(0, 0, 0, 1);
    letter-spacing: 0.06em
}

.grid-label {
    color: rgba(255, 255, 255, 0.5);
    font-size: 10px;
    font-family: monospace;
    font-weight: 600;
    text-align: center;
    pointer-events: none;
    white-space: nowrap;
    text-shadow: 0 0 3px rgba(0, 0, 0, 0.9)
}

/* Icons */
.ddon-icon {
    height: 32px;
    width: 32px;
    background-image: url("resources/MapIcons.webp");
    background-size: 256px
}

.ddon-icon-door {
    background-position: -191px 0
}

.ddon-icon-dungeon {
    background-position: -111px -29px
}

.enemy-marker {
    filter: drop-shadow(0 0 2px #000) drop-shadow(0 0 1px #000)
}

.key-bearer-spawn {
    filter: drop-shadow(0 0 3px #c8a000) drop-shadow(0 0 2px #000)
}

/* Group chips */
.group-chip {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 7px 2px 5px;
    border: 1.5px solid currentColor;
    background: rgba(18, 18, 18, 0.9);
    font-family: 'Amazon Ember', sans-serif;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    text-shadow: 0 0 4px rgba(0, 0, 0, 0.9);
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.7);
    transition: background 0.1s
}

.group-chip:hover {
    background: rgba(40, 40, 40, 0.95)
}

.chip-count {
    font-size: 9px;
    opacity: 0.75;
    font-weight: 500
}

.chip-arrow {
    font-size: 8px;
    transition: transform 0.15s;
    display: inline-block;
    opacity: 0.8
}

.chip-arrow.open {
    transform: rotate(90deg)
}

.group-chip.chip-open {
    opacity: 0.75
}

.leaflet-control-reset-view {
    font-size: 18px;
    line-height: 26px !important;
    font-weight: normal
}

/* Sidebar toggle — always visible */
#sidebar-toggle {
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 1010;
    width: 30px;
    height: 30px;
    background: rgba(18, 18, 18, 0.92);
    border: 1px solid #444;
    color: #c0c0c0;
    font-size: 16px;
    line-height: 28px;
    text-align: center;
    cursor: pointer;
    display: none
}

#sidebar.collapsed~#sidebar-toggle {
    display: block
}

#sidebar-toggle:hover {
    background: #333
}

#sidebar-resize-handle {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 5px;
    cursor: ew-resize;
    z-index: 10
}

#sidebar-resize-handle:hover {
    background: rgba(200, 200, 200, 0.15)
}

#map-list::-webkit-scrollbar {
    width: 6px
}

#map-list::-webkit-scrollbar-track {
    background: transparent
}

#map-list::-webkit-scrollbar-thumb {
    background: #333
}

.gather-node-icon {
    filter: drop-shadow(0 0 1px #000) drop-shadow(0 0 1px #000)
}

/* Spot search panel */
#spot-panel-toggle {
    position: absolute;
    right: 10px;
    top: 10px;
    z-index: 1010;
    background: #1a1a1a;
    border: 1px solid #444;
    color: #b0b0b0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.9rem
}

#spot-panel-toggle:hover {
    background: #333
}

#spot-panel {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 265px;
    background: #1a1a1a;
    border-left: 1px solid #333;
    z-index: 1050;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.2s ease;
    overflow: hidden;
    color: #d0d0d0
}

#spot-panel.open {
    transform: translateX(0)
}

#spot-panel.resizing {
    transition: none
}

#spot-resize-handle {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 5px;
    cursor: ew-resize;
    z-index: 10
}

#spot-resize-handle:hover {
    background: rgba(200, 200, 200, 0.15)
}

#spot-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 10px;
    background: #222;
    border-bottom: 1px solid #333;
    font-size: 0.73rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #999;
    flex-shrink: 0
}

#spot-panel-close {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    font-size: 0.9rem;
    line-height: 1;
    padding: 2px 4px
}

#spot-panel-close:hover {
    color: #c0c0c0
}

#spot-search-wrap {
    position: relative;
    margin: 7px 8px 4px;
    flex-shrink: 0
}

#spot-search-input {
    padding: 5px 24px 5px 8px;
    background: #222;
    border: 1px solid #444;
    color: #d0d0d0;
    font-size: 0.82rem;
    width: 100%;
    outline: none
}

#spot-search-input:focus {
    border-color: #888
}

#spot-search-clear {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    font-size: 0.8rem;
    line-height: 1;
    padding: 2px 4px;
    display: none
}

#spot-search-clear:hover {
    color: #c0c0c0
}

#spot-filter-tabs {
    display: flex;
    gap: 4px;
    padding: 0 8px 6px;
    flex-shrink: 0
}

.spot-tab {
    flex: 1;
    padding: 3px 0;
    background: #222;
    border: 1px solid #444;
    color: #888;
    font-size: 0.72rem;
    cursor: pointer
}

.spot-tab.active {
    background: #333;
    color: #d0d0d0;
    border-color: #888
}

.spot-tab:hover:not(.active) {
    background: #2a2a2a;
    color: #b0b0b0
}

#spot-scope-row {
    display: flex;
    border-bottom: 1px solid #2a2a2a;
    flex-shrink: 0
}

.spot-scope {
    flex: 1;
    padding: 4px 0;
    background: none;
    border: none;
    color: #666;
    font-size: 0.72rem;
    cursor: pointer;
    border-bottom: 2px solid transparent
}

.spot-scope.active {
    color: #b0b0b0;
    border-bottom-color: #b0b0b0
}

.spot-scope:hover:not(.active) {
    color: #999
}

#spot-results {
    flex: 1;
    overflow-y: auto;
    padding: 0 4px 4px
}

#spot-results::-webkit-scrollbar {
    width: 5px
}

#spot-results::-webkit-scrollbar-track {
    background: transparent
}

#spot-results::-webkit-scrollbar-thumb {
    background: #333
}

.spot-empty {
    padding: 10px 8px;
    color: #666;
    font-size: 0.78rem;
    text-align: center
}

.spot-summary {
    padding: 4px 8px 2px;
    color: #666;
    font-size: 0.7rem;
    border-bottom: 1px solid #2a2a2a
}

.spot-result-row {
    position: relative;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 8px;
    cursor: pointer;
    font-size: 0.78rem;
    border-bottom: 1px solid #2a2a2a
}

.spot-result-row:hover {
    background: #2a2a2a
}

.spot-result-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #d0d0d0
}

.spot-result-count {
    color: #777;
    font-size: 0.7rem;
    flex-shrink: 0
}

.spot-nav-btn {
    background: #222;
    border: 1px solid #444;
    color: #888;
    padding: 1px 5px;
    cursor: pointer;
    font-size: 0.68rem;
    line-height: 1.4
}

.spot-nav-btn:hover {
    background: #333;
    color: #d0d0d0
}

.spot-preview {
    display: none;
    position: absolute;
    right: calc(100% + 4px);
    top: 0;
    background: #2a2a2a;
    border: 1px solid #444;
    padding: 6px 10px;
    font-size: 0.74rem;
    line-height: 1.6;
    white-space: nowrap;
    z-index: 1200;
    pointer-events: none;
    box-shadow: -2px 2px 8px rgba(0, 0, 0, 0.6);
    color: #b0b0b0
}

.spot-result-row:hover .spot-preview {
    display: block
}

.spot-preview b {
    color: #e0e0e0
}

.spot-stage-sub {
    font-size: 0.68rem;
    color: #888;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-top: 1px
}

.spot-hl-outer {
    background: none !important;
    border: none !important
}

.spot-hl {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 3px solid #ffe600;
    box-shadow: 0 0 0 3px rgba(255, 230, 0, 0.25), 0 0 12px 5px rgba(255, 200, 0, 0.55);
    animation: spot-pulse 0.85s ease-in-out infinite;
    pointer-events: none
}

.group-chip.spot-hl-chip {
    animation: spot-pulse-chip 0.85s ease-in-out infinite
}

@keyframes spot-pulse-chip {

    0%,
    100% {
        box-shadow: 0 0 4px rgba(0, 0, 0, 0.7), 0 0 0 2px rgba(255, 230, 0, 0.5), 0 0 12px 5px rgba(255, 200, 0, 0.7)
    }

    50% {
        box-shadow: 0 0 4px rgba(0, 0, 0, 0.7), 0 0 0 4px rgba(255, 230, 0, 0.15), 0 0 18px 8px rgba(255, 200, 0, 0.25)
    }
}

@keyframes spot-pulse {

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

    50% {
        transform: scale(1.6);
        opacity: 0.35
    }
}

/* Override Leaflet control styling */
.leaflet-control-zoom a {
    background: #1a1a1a !important;
    color: #c0c0c0 !important;
    border: 1px solid #444 !important
}

.leaflet-control-zoom a:hover {
    background: #333 !important
}

.leaflet-control-attribution {
    background: rgba(18, 18, 18, 0.7) !important;
    color: #666 !important;
    font-size: 10px !important
}

/* Hide edit-mode and data-source UI */
#settings-modal,
#named-param-modal,
#dt-picker-modal,
#dt-editor-modal,
#edit-panel,
#named-stats-panel,
#stage-groups-panel,
#src-errors {
    display: none !important
}

/* Dark popups — all content light text on dark bg */
.leaflet-popup-content-wrapper {
    background: #1a1a1a !important;
    color: #c0c0c0 !important;
    border: 1px solid #444 !important;
    border-radius: 0 !important;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.6) !important
}

.leaflet-popup-content-wrapper .leaflet-popup-content {
    color: #c0c0c0 !important
}

.leaflet-popup-content-wrapper .leaflet-popup-content * {
    color: #d0d0d0
}

.leaflet-popup-content-wrapper .leaflet-popup-content a {
    color: #8cb4ff
}

.leaflet-popup-content-wrapper .leaflet-popup-content a:visited {
    color: #b89bff
}

.leaflet-popup-tip {
    background: #1a1a1a !important;
    border: 1px solid #444 !important
}

.leaflet-popup-close-button {
    color: #888 !important
}

.leaflet-popup-close-button:hover {
    color: #c0c0c0 !important
}

/* Dark tooltips */
.leaflet-tooltip {
    background: #1a1a1a !important;
    color: #c0c0c0 !important;
    border: 1px solid #444 !important;
    border-radius: 0 !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5) !important
}

.leaflet-tooltip-top::before {
    border-top-color: #1a1a1a !important
}

.leaflet-tooltip-bottom::before {
    border-bottom-color: #1a1a1a !important
}