html, body {
    height: 100%;
}

body {
    margin: 0;
    background: #111;
    font-family: Arial, sans-serif;
    overflow: hidden;
}

.map-shell {
    --tile-size: 125px;
    position: relative;
    width: 100vw;
    height: 100vh;
}

.map-viewport {
    width: 100%;
    height: 100%;
    overflow: auto;
    cursor: grab;
    touch-action: none;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.map-viewport::-webkit-scrollbar {
    width: 0;
    height: 0;
    display: none;
}

.map-viewport.dragging {
    cursor: grabbing;
}

.map-viewport.placing {
    cursor: crosshair;
}

.marker-list {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 10;
    margin: 0;
    padding: 8px 10px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 8px;
    width: fit-content;
    max-height: calc(100vh - 40px);
    overflow-x: hidden;
    overflow-y: auto;
    user-select: none;
    pointer-events: auto;
    z-index: 2000;
}

.legend-section + .legend-section {
    margin-top: 10px;
}

.legend-title {
    display: block;
    margin: 0 0 6px;
    padding: 0;
    border: 0;
    background: transparent;
    color: #d7d7d7;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    text-align: left;
}

.legend-title::before {
    content: "▾";
    display: inline-block;
    width: 12px;
    margin-right: 4px;
}

.legend-section.is-collapsed .legend-title {
    margin-bottom: 0;
}

.legend-section.is-collapsed .legend-title::before {
    content: "▸";
}

.legend-section.is-collapsed .legend-items {
    display: none;
}

.legend-title::before {
    content: "v";
}

.legend-section.is-collapsed .legend-title::before {
    content: ">";
}

.legend-items {
    margin: 0;
    padding: 0;
    list-style: none;
}

.marker-item {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 24px;
    line-height: 24px;
    color: #fff;
}

.marker-item.active {
    color: #ffd36b;
}

.marker-item.is-hidden {
    color: #8f8f8f;
}

.marker-item + .marker-item {
    margin-top: 6px;
}

.marker-item img {
    display: block;
    height: 24px;
    width: auto;
    user-select: none;
    -webkit-user-drag: none;
}

.marker-add {
    display: none;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 4px;
    background: #2f7d32;
    color: #fff;
    font: inherit;
    line-height: 1;
    cursor: pointer;
}

.map-shell.admin-mode.max-zoom .marker-add {
    display: inline-flex;
}

.marker-add.is-active {
    background: #d28700;
}

.marker-label {
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    line-height: 24px;
    cursor: pointer;
}

.marker-item.is-hidden .marker-label {
    text-decoration: line-through;
}

.grid {
    display: grid;
    grid-template-columns: repeat(var(--grid-columns), var(--tile-size));
    grid-template-rows: repeat(var(--grid-rows), var(--tile-size));
    gap: 0;
}

.tile {
    position: relative;
    width: var(--tile-size);
    height: var(--tile-size);
    overflow: visible;
}

.tile-base {
    width: 100%;
    height: 100%;
    display: block;
    user-select: none;
    -webkit-user-drag: none;
    pointer-events: none;
}

.tile-marker {
    position: absolute;
    left: calc(var(--tile-size) * var(--marker-x) / 250);
    top: calc(var(--tile-size) * var(--marker-y) / 250);
    width: 32px;
    height: auto;
    object-fit: contain;
    pointer-events: none;
    user-select: none;
    -webkit-user-drag: none;
    transform: translate(-50%, -50%);
    z-index: 1000;
}

.map-shell.admin-mode .tile-marker {
    pointer-events: auto;
    cursor: pointer;
}

.tile-marker.is-selected {
    filter: drop-shadow(0 0 0 2px #ffcc33) drop-shadow(0 0 6px rgba(255, 204, 51, 0.7));
}

.tile-marker.is-hidden {
    display: none;
}
