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

body {
    font-family: 'Space Grotesk', sans-serif;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
}

::selection {
    background: rgba(255,255,255,0.16);
    color: #fff;
}

::-moz-selection {
    background: rgba(255,255,255,0.16);
    color: #fff;
}

#map {
    height: 100vh;
    background-color: white;
    cursor: crosshair;
}

.coordinateDisplay {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    position: fixed;
    bottom: 0;
    left: 0;
    margin: 0 0 16px 16px;
    font-size: 12px;
    z-index: 960;
    background: transparent;
    border: none;
    padding: 0;
    backdrop-filter: none;
}

.coordinateDisplay p {
    margin: 0;
    color: #f4f4f4;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    padding: 6px 10px;
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    background: rgba(30, 30, 30, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    backdrop-filter: blur(3px);
}

.coordinateDisplay p span {
    width: 6ch;
    display: inline-block;
    font-weight: 600;
    margin-left: 0.2rem;
}

#tileX,
#tileY {
    width: 2ch;
    min-width: 0;
}

#dimensionType {
    font-size: 12px;
    font-weight: 700;
    color: #f5f5f5;
    background: rgba(30, 30, 30, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    cursor: pointer;
    padding: 6px 10px;
    margin: 0;
    backdrop-filter: blur(3px);
    min-height: 34px;
    -webkit-appearance: none;
    appearance: none;
}

#dimensionType option {
    font-weight: normal;
    color: #fff;
    background: #1e1e1e;
}

#dimensionType:focus {
    outline: 1px solid rgba(255, 255, 255, 0.35);
    outline-offset: 1px;
}

.urls {
    position: fixed;
    bottom: 0;
    right: 0;
    margin: 0 16px 16px 0;
    z-index: 930;
}

img {
    vertical-align: middle;
}

.map-icon {
    border-radius: 0;
    transition: opacity 0.3s ease, filter 0.3s ease;
}

.map-icon:hover {
    opacity: 0.4;
    filter: brightness(0.9);
}

.map-icon:focus {
    opacity: 1;
    filter: none;
}

.map-icon.player-followed {
    filter: none;
    transform: scale(1.1);
    outline: 1px solid rgba(255, 255, 255, 0.95);
}

.map-icon.player-offline.player-followed {
    filter: none;
}

.context-menu {
    position: absolute;
    z-index: 1200;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 4px 0;
    background: rgba(30, 30, 30, 0.92);
    border-radius: 4px;
    min-width: 180px;
    font-size: 13px;
}

.context-menu button {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 6px 12px;
    background: none;
    border: none;
    color: #e8e8e8;
    cursor: pointer;
    text-align: left;
    width: 100%;
}

.context-menu button:hover {
    background: rgba(255, 255, 255, 0.1);
}

.ctx-label {
    color: #aaa;
    white-space: nowrap;
}

.ctx-value {
    color: #fff;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.hidden {
    display: none !important;
}

.player-offline {
    opacity: 0.6;
    filter: none;
}

.ctx-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 3px 0;
}

.ctx-hint {
    color: #666;
    font-size: 11px;
    white-space: nowrap;
}

#edgeIndicators { position: fixed; inset: 0; pointer-events: none; z-index: 1100; }

.edge-indicator {
    position: absolute;
    pointer-events: all;
    cursor: pointer;
    user-select: none;
    transition: opacity 0.15s;
}

.edge-indicator.hidden { display: none !important; }
.edge-indicator.offline { opacity: 0.85; }
.edge-indicator.offline .edge-sprite { filter: none; }
.edge-indicator:hover { opacity: 0.65; }

.edge-indicator.diff-dim .edge-sprite { filter: hue-rotate(200deg) brightness(1.2); }
.edge-indicator.offline.diff-dim .edge-sprite { filter: grayscale(1) hue-rotate(200deg); }

.edge-sprite {
    width: 16px;
    height: 16px;
    image-rendering: pixelated;
    filter: drop-shadow(0 0 3px rgba(0,0,0,0.9));
}

.edge-label {
    font-size: 10px;
    font-weight: bold;
    color: #fff;
    background: rgba(0,0,0,0.6);
    border-radius: 3px;
    padding: 1px 4px;
    white-space: nowrap;
    pointer-events: none;
    text-shadow: 0 1px 2px rgba(0,0,0,0.9);
    line-height: 1.3;
}

.player-panel {
    position: fixed;
    top: 0;
    right: 0;
    margin: 16px 16px 0 0;
    z-index: 980;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.player-panel-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    background: rgba(30, 30, 30, 0.85);
    border: none;
    border-radius: 4px;
    color: #e8e8e8;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s;
}

.player-panel-toggle:hover {
    background: rgba(50, 50, 50, 0.95);
}

#playerPanelCount {
    min-width: 4ch;
    text-align: right;
}

.player-panel-dropdown {
    margin-top: 4px;
    background: rgba(30, 30, 30, 0.92);
    border-radius: 4px;
    min-width: 160px;
    max-height: 260px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.player-panel-header {
    font-size: 11px;
    font-weight: bold;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 7px 12px 4px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.player-panel-list {
    display: flex;
    flex-direction: column;
    padding: 4px 0;
}

.player-panel-empty {
    font-size: 12px;
    color: #666;
    padding: 8px 12px;
    text-align: center;
}

.player-panel-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    cursor: pointer;
    transition: background 0.1s;
    color: #e8e8e8;
    font-size: 13px;
}

.player-panel-item:hover {
    background: rgba(255,255,255,0.08);
}

.player-panel-avatar {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    image-rendering: pixelated;
    border-radius: 0;
}

.player-panel-avatar.player-followed {
    transform: none;
}

.player-panel-avatar.player-offline {
    opacity: 0.2;
}

.player-panel-item.followed {
    background: rgba(255,255,255,0.08);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.18);
}

.player-panel-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.player-panel-following {
    font-size: 10px;
    color: #f0f0f0;
    white-space: nowrap;
    font-style: italic;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.16);
    border-radius: 999px;
    padding: 1px 6px;
}

.player-panel-dim {
    font-size: 10px;
    color: #c8c8c8;
    background: rgba(255,255,255,0.06);
    border-radius: 3px;
    padding: 1px 5px;
    white-space: nowrap;
    text-transform: capitalize;
}

/* Player popup (marker click) */
.player-popup {
    position: absolute;
    z-index: 1200;
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 4px 0;
    background: rgba(30, 30, 30, 0.92);
    border-radius: 4px;
    min-width: 160px;
    font-size: 13px;
    backdrop-filter: blur(4px);
}

.player-popup-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px 6px;
}

.player-popup-avatar {
    width: 16px;
    height: 16px;
    image-rendering: pixelated;
    flex-shrink: 0;
}

.player-popup-name {
    color: #f0f0f0;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
}

.player-popup-coords {
    padding: 5px 12px;
    color: #ccc;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.player-popup-follow-btn {
    display: block;
    width: 100%;
    padding: 6px 12px;
    background: none;
    border: none;
    color: #e8e8e8;
    cursor: pointer;
    text-align: left;
    font-size: 13px;
}

.player-popup-follow-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}