body,
html {
    margin: 0;
    padding: 0;
    width: 100%;
    min-height: 100%;
    overflow-x: hidden;
    font-family: 'Roboto', sans-serif;
    background-color: #1a1a1a;
    color: #e0e0e0;
}

#map-viewport {
    width: 100%;
    height: var(--map-view-height, clamp(620px, 80vh, 900px));
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    cursor: grab;
    background-color: #0f0f0f;
}

#map-viewport:active {
    cursor: grabbing;
}

#map-container {
    position: absolute;
    transform-origin: 0 0;
    width: 1536px;
    height: 1536px;
    /* Transformation will be handled by JS */
}

#map-image {
    display: block;
    width: 1536px;
    /* Native size of the image */
    height: 1536px;
    pointer-events: none;
    user-select: none;
}

/* Controls remain below the map, in normal document flow. */
#ui-container {
    position: static;
    box-sizing: border-box;
    margin-top: 12px;
    background: rgba(20, 20, 20, 0.9);
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    width: 100%;
    border: 1px solid #333;
}

h1 {
    margin: 0;
    font-size: 1.1rem;
    color: #ffcc00;
    /* DayZ-ish Yellow */
    text-transform: uppercase;
    letter-spacing: 1px;
}

.controls {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

button {
    background: #333;
    color: white;
    border: 1px solid #555;
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.2s;
}

button:hover {
    background: #444;
}

#search-input {
    background: #222;
    border: 1px solid #444;
    color: white;
    padding: 8px;
    border-radius: 4px;
}

#search-results {
    max-height: 150px;
    overflow-y: auto;
    background: #222;
    border: 1px solid #333;
    display: none;
    /* Hidden by default */
}

.result-item {
    padding: 8px;
    cursor: pointer;
    border-bottom: 1px solid #333;
}

.result-item:hover {
    background: #333;
}

/* Legend */
.legend {
    margin-top: 15px;
    padding-top: 10px;
    border-top: 1px solid #444;
}

.legend-item {
    display: flex;
    align-items: center;
    margin-bottom: 5px;
    font-size: 0.9rem;
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 10px;
    display: inline-block;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
}

.dot.yellow {
    background-color: #ffd700;
    box-shadow: 0 0 8px #ffd700;
}

.dot.green {
    background-color: #00ff00;
    box-shadow: 0 0 8px #00ff00;
}

.dot.blue {
    background-color: #00bfff;
    box-shadow: 0 0 8px #00bfff;
}

.dot.purple {
    background-color: #9932cc;
    box-shadow: 0 0 8px #9932cc;
}

.dot.red {
    background-color: #ff4500;
    box-shadow: 0 0 8px #ff4500;
}

#coords-display {
    margin-top: 10px;
    font-family: monospace;
    font-size: 0.9rem;
    color: #888;
}

/* Markers */
.marker {
    position: absolute;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    /* Centering */
    border: 2px solid white;
    cursor: pointer;
    transition: transform 0.2s;
    z-index: 10;
}

.marker:hover {
    transform: translate(-50%, -50%) scale(1.5);
    z-index: 100;
}

.marker-popup {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    white-space: nowrap;
    pointer-events: none;
    display: none;
    z-index: 101;
}

.marker:hover .marker-popup {
    display: block;
}

/* Auth & User UI */
#auth-section {
    margin-bottom: 10px;
}

#login-btn {
    background: #171a21;
    /* Steam color */
    color: #c7d5e0;
    width: 100%;
    font-weight: bold;
}

#login-btn:hover {
    background: #2a475e;
}

.user-marker {
    border: 2px solid #00ffcc;
    /* Cyan for user bases */
    background-color: rgba(0, 255, 204, 0.3);
}

/* Modal */
.modal {
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: #222;
    padding: 20px;
    border: 1px solid #444;
    border-radius: 8px;
    width: 300px;
    color: white;
}

.modal-content input,
.modal-content textarea {
    width: 100%;
    margin-bottom: 10px;
    padding: 8px;
    background: #333;
    border: 1px solid #555;
    color: white;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover {
    color: white;
}

/* Labels */
.marker-label {
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    text-shadow: 1px 1px 2px black;
    white-space: nowrap;
    pointer-events: none;
    font-size: 0.8rem;
    color: white;
}

/* City Markers */
.city-marker {
    position: absolute;
    background: black;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
    border: 1px solid white;
    transform: translate(-50%, -50%);
    z-index: 20;
    /* Below hover items but above map */
    cursor: pointer;
}

.city-marker::before {
    content: '📍';
    /* Simple pin icon */
}

.city-marker.safezone {
    border-color: #00ff00;
    color: #00ff00;
    box-shadow: 0 0 5px #00ff00;
}

#server-map-status { font-size: 12px; line-height: 1.5; max-width: 290px; color: #ccc; }
#server-map-filters label { display: flex; align-items: center; gap: 6px; font-size: 12px; margin: 8px 0; }
#server-marker-list { display: flex; flex-direction: column; gap: 4px; max-height: 170px; overflow: auto; }
.server-filter-actions { display: flex; gap: 5px; margin-bottom: 8px; }
.server-radius { position: absolute; left: 0; top: 0; pointer-events: none; }
.server-icon { display: block; width: 24px; height: 24px; mask-size: contain; mask-position: center; mask-repeat: no-repeat; -webkit-mask-size: contain; -webkit-mask-position: center; -webkit-mask-repeat: no-repeat; }
.missing-server-icon { display: block; width: 24px; height: 24px; border: 1px dashed #ddd; text-align: center; font-weight: bold; color: #ddd; }
.marker-highlight { outline: 3px solid #fff; outline-offset: 5px; z-index: 50; }
[hidden] { display: none !important; }

#map-tiles { position:absolute; inset:0; overflow:hidden; background:#25332b; }
.native-tile { position:absolute; display:block; pointer-events:none; user-select:none; }
.native-tile-level { position:absolute; left:0; top:0; transform-origin:0 0; }
#city-labels { position:absolute; inset:0; pointer-events:none; z-index:15; }
#markers-layer { position:absolute; inset:0; z-index:20; pointer-events:none; }
#markers-layer .marker { pointer-events:auto; }
.locality-label { position:absolute; color:#fff; font-size:13px; font-weight:700; white-space:nowrap; text-shadow:0 1px 3px #000,1px 0 3px #000; transform:translate(-50%,-50%) scale(var(--marker-inverse-scale,1)); transform-origin:center; }
.marker { transform:translate(-50%,-50%) scale(var(--marker-inverse-scale,1)); transition:none; }
.marker:hover { transform:translate(-50%,-50%) scale(var(--marker-inverse-scale,1)) scale(1.15); }
.zoom-controls { display:flex; gap:8px; align-items:center; margin:8px 0; }
.zoom-controls button { width:38px; margin:0; font-size:20px; }
#zoom-level { font-size:12px; }
.map-attribution { position:static; font-size:11px; }
.map-attribution a { color:#ddd; }

#ocean-display-cleanup {
    position:absolute; z-index:10; overflow:hidden; pointer-events:none;
    mask-image:linear-gradient(to right,transparent,#000 10%,#000 90%,transparent),linear-gradient(to bottom,transparent,#000 1.5%,#000 98.5%,transparent);
    mask-composite:intersect;
}
.ocean-native-level { position:absolute; left:0; top:0; transform-origin:0 0; }
.ocean-native-level img { position:absolute; width:256px; height:256px; pointer-events:none; }

.panel-heading { display:flex; align-items:center; flex-wrap:wrap; gap:10px; margin-bottom:12px; }
.panel-heading h1 { margin-right:auto; }
.panel-heading .zoom-controls { margin:0; }
.panel-search { flex:1; min-width:0; }
#search-input { box-sizing:border-box; width:100%; }
#search-results { position:static; margin-top:4px; }
.server-filter-actions { margin:0; flex-shrink:0; }
#server-map-status { max-width:none; margin:8px 0; font-size:12px; }
.panel-filters { display:flex; align-items:center; flex-wrap:wrap; gap:12px; font-size:12px; }
#server-map-filters { display:flex; flex-wrap:wrap; gap:8px 18px; }
#server-map-filters label { margin:0; }
#ui-container details { margin-top:12px; font-size:12px; }
#ui-container summary { cursor:pointer; margin-bottom:8px; }
#server-marker-list { display:grid; grid-template-columns:repeat(auto-fit,minmax(180px,1fr)); max-height:86px; gap:6px; }
#server-marker-list button { font-size:12px; text-align:left; }
.panel-footer { display:flex; justify-content:space-between; align-items:center; gap:12px; flex-wrap:wrap; border-top:1px solid #333; margin-top:12px; padding-top:10px; }
#coords-display { margin:0; font-size:12px; }
@media (max-width:640px) {
    #map-viewport { height:var(--map-view-height, clamp(420px, 70vh, 680px)); }
    #ui-container { padding:12px; }
    .panel-heading { align-items:stretch; }
    .panel-heading h1 { width:100%; font-size:1rem; }
    .panel-heading #auth-section, .panel-heading #toggle-map-btn { flex:1 1 100%; }
    #auth-section button { width:100%; }
    .controls { flex-direction:column; align-items:stretch; }
    .server-filter-actions button { flex:1; }
    .panel-filters { align-items:flex-start; }
    #server-map-filters { gap:8px 14px; }
    #server-marker-list { grid-template-columns:repeat(2,minmax(0,1fr)); max-height:108px; }
    #server-marker-list button { overflow-wrap:anywhere; }
}
