html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #000;
    font-family: Verdana, Arial, sans-serif;
}

#map {
    position: absolute;
    inset: 0;
    background: #000;
}

#map img,
.leaflet-tile {
    image-rendering: optimizeSpeed;
    image-rendering: -moz-crisp-edges;
    image-rendering: -o-crisp-edges;
    -ms-interpolation-mode: nearest-neighbor;
    image-rendering: pixelated;
}

#panelToggle {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 1200;
    width: 38px;
    height: 38px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 6px;
    background: #1a1a2b;
    color: #e9e4ff;
    font-size: 18px;
    cursor: pointer;
}

#panelToggle:hover { background: #241b3d; border-color: #7c3aed; }

#sidePanel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 300px;
    z-index: 1100;
    overflow-y: auto;
    background: rgba(19, 19, 31, 0.97);
    border-left: 1px solid rgba(255, 255, 255, 0.12);
    color: #d6d2e8;
    padding: 12px;
    box-sizing: border-box;
    display: none;
}

#sidePanel.open {
    display: flex;
    flex-direction: column;
}

#housesSection {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 200px;
    margin-bottom: 0;
}

#housesSection .chosen-container { flex-shrink: 0; }

#sidePanel::-webkit-scrollbar { width: 8px; }
#sidePanel::-webkit-scrollbar-track { background: #13131f; }
#sidePanel::-webkit-scrollbar-thumb { background: #2a2a38; border-radius: 4px; }
#sidePanel::-webkit-scrollbar-thumb:hover { background: #7c3aed; }

.panel-section { margin-bottom: 18px; }

.panel-title {
    font-size: 15px;
    font-weight: bold;
    color: #e9e4ff;
    margin-bottom: 4px;
    padding-right: 44px;
}

.panel-legend {
    font-size: 12px;
    font-weight: bold;
    color: #a78bfa;
    margin-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.10);
    padding-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.toggle-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    font-weight: bold;
    color: #d6d2e8;
    cursor: pointer;
    user-select: none;
}

.toggle-switch {
    width: 34px;
    height: 18px;
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.12);
    position: relative;
    transition: background 0.12s;
    flex-shrink: 0;
}

.toggle-switch::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 4px;
    width: 12px;
    height: 12px;
    border-radius: 6px;
    background: #ffffff;
    transition: left 0.12s;
}

.toggle-switch.on { background: #7c3aed; }

.toggle-switch.on::after { left: 18px; }

.panel-btn {
    margin-top: 8px;
    padding: 6px 16px;
    border: none;
    border-radius: 5px;
    background: #7c3aed;
    color: #ffffff;
    font-weight: bold;
    cursor: pointer;
    font-size: 12px;
}

.panel-btn:hover { background: #8b5cf6; }

#monsterSearchResults, #houseList { margin-top: 10px; }

#monsterSearchResults {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.03);
    padding: 8px;
}

#monsterSearchResults:empty { display: none; }

#monsterSearchResults::-webkit-scrollbar { width: 8px; }
#monsterSearchResults::-webkit-scrollbar-track { background: #13131f; }
#monsterSearchResults::-webkit-scrollbar-thumb { background: #2a2a38; border-radius: 4px; }
#monsterSearchResults::-webkit-scrollbar-thumb:hover { background: #7c3aed; }

#houseList {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-auto-rows: min-content;
    align-content: start;
    gap: 4px;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.03);
    padding: 8px;
}

#houseList .result-info { grid-column: 1 / -1; margin-bottom: 0; }

#houseList .result-btn {
    margin-bottom: 0;
    padding: 4px 7px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 10px;
}

#houseList::-webkit-scrollbar { width: 8px; }
#houseList::-webkit-scrollbar-track { background: #13131f; }
#houseList::-webkit-scrollbar-thumb { background: #2a2a38; border-radius: 4px; }
#houseList::-webkit-scrollbar-thumb:hover { background: #7c3aed; }

#sidePanel .result-info {
    font-size: 11px;
    color: rgba(214, 210, 232, 0.55);
    margin-bottom: 6px;
}

#sidePanel .result-btn {
    display: block;
    width: 100%;
    text-align: left;
    margin-bottom: 4px;
    padding: 5px 9px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 5px;
    background: #1a1a26;
    color: #d6d2e8;
    cursor: pointer;
    font-size: 11px;
}

#sidePanel .result-btn:hover { background: #241b3d; border-color: #7c3aed; }

#sidePanel .result-btn.active { background: #241b3d; border-color: #a78bfa; color: #e9e4ff; }

#sidePanel select { width: 100%; }

.chosen-container { width: 100% !important; font-size: 12px; }
.chosen-container .chosen-choices,
.chosen-container .chosen-single {
    background: #1a1a26 !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    border-radius: 5px !important;
    color: #d6d2e8 !important;
    background-image: none !important;
    box-shadow: none !important;
}
.chosen-container-active .chosen-choices,
.chosen-container-active .chosen-single {
    border-color: #7c3aed !important;
}
.chosen-container .chosen-drop {
    background: #1a1a26 !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    border-top: none !important;
    color: #d6d2e8 !important;
}
.chosen-container .chosen-results li { color: #d6d2e8; }
.chosen-container .chosen-results li.highlighted { background: #7c3aed !important; color: #ffffff !important; }
.chosen-container .chosen-search input[type="text"] {
    background: #13131f !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    color: #d6d2e8 !important;
}
.chosen-container-multi .chosen-choices li.search-choice {
    background: #241b3d !important;
    border: 1px solid #7c3aed !important;
    border-radius: 4px !important;
    color: #e9e4ff !important;
    background-image: none !important;
}
.chosen-container-multi .chosen-choices li.search-field input[type="text"] { color: rgba(214, 210, 232, 0.5) !important; }

.map-side-controls {
    background: #1d1a14;
    border: 1px solid #6b5b3e !important;
    border-radius: 4px;
}

.map-side-controls .control-btn {
    display: block;
    width: 34px;
    height: 30px;
    border: none;
    border-bottom: 1px solid #4a4030;
    background: transparent;
    color: #e6d9b8;
    font-size: 13px;
    cursor: pointer;
}

.map-side-controls .control-btn:last-child { border-bottom: none; }
.map-side-controls .control-btn:hover { background: #2b261c; }
.map-side-controls .control-btn:disabled { color: #5a5244; cursor: default; }

.map-side-controls .floor-indicator {
    width: 34px;
    height: 26px;
    line-height: 26px;
    text-align: center;
    color: #f4d150;
    font-weight: bold;
    font-size: 13px;
    border-bottom: 1px solid #4a4030;
}

.leaflet-bar a, .leaflet-bar a:hover {
    background-color: #1d1a14;
    color: #e6d9b8;
    border-bottom-color: #4a4030;
}
.leaflet-bar a:hover { background-color: #2b261c; }

.leaflet-bottom.leaflet-left {
    display: flex;
    flex-direction: row;
    align-items: flex-end;
}

.map-attribution {
    background: rgba(29, 26, 20, 0.85);
    border: 1px solid #4a4030;
    border-radius: 4px;
    color: #b8ab8a;
    font-size: 11px;
    padding: 5px 9px;
    white-space: nowrap;
}

.map-attribution a {
    color: #f4d150;
    text-decoration: none;
    font-weight: bold;
}

.map-attribution a:hover { text-decoration: underline; }

.map-position-info {
    background: rgba(29, 26, 20, 0.92);
    border: 1px solid #6b5b3e !important;
    border-radius: 4px;
    color: #e6d9b8;
    font-size: 11px;
    padding: 5px 9px;
    min-width: 130px;
}

.town-label {
    background: transparent;
    border: none;
}

.town-label span {
    color: #fff;
    font-weight: bold;
    white-space: nowrap;
    text-shadow: -1px 0 #000, 0 1px #000, 1px 0 #000, 0 -1px #000;
}

.creature-name-tooltip {
    background: rgba(20, 18, 13, 0.94);
    border: 1px solid #6b5b3e;
    border-radius: 4px;
    color: #f4d150;
    font-size: 12px;
    font-weight: bold;
    padding: 3px 8px;
    white-space: nowrap;
}

.creature-name-label {
    background: transparent;
    border: none;
    color: #ffffff;
    font-weight: bold;
    text-align: center;
    white-space: nowrap;
    pointer-events: none;
    text-shadow: -1px 0 #000, 0 1px #000, 1px 0 #000, 0 -1px #000, 0 0 3px #000;
}

.creature-name-label.npc-name { color: #569cd6; }

.creature-count-badge {
    background: transparent;
    border: none;
    color: #ff1a1a;
    font-size: 13px;
    font-weight: 900;
    text-align: center;
    text-shadow: -1px 0 #000, 0 1px #000, 1px 0 #000, 0 -1px #000, 0 0 4px #000;
}

.creature-sprite-icon { image-rendering: pixelated; }

.map-copy-toast {
    position: absolute;
    left: 50%;
    bottom: 26px;
    transform: translateX(-50%);
    z-index: 1500;
    background: rgba(20, 18, 13, 0.95);
    border: 1px solid #f4d150;
    border-radius: 4px;
    color: #f4d150;
    font-size: 13px;
    padding: 8px 18px;
    opacity: 0;
    transition: opacity 0.25s;
    pointer-events: none;
}

.map-copy-toast.visible { opacity: 1; }
