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

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

#map {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #1a1a2e;
}

#controls {
    position: absolute;
    top: 10px;
    left: 60px;
    z-index: 1000;
    display: flex;
    gap: 15px;
    align-items: center;
}

#world-selector {
    background: rgba(30, 30, 46, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 8px 12px;
    border-radius: 6px;
    color: #cdd6f4;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

#world-selector label {
    margin-right: 8px;
    font-size: 14px;
}

#world-select {
    background: rgba(49, 50, 68, 0.9);
    color: #cdd6f4;
    border: 1px solid #45475a;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 14px;
    cursor: pointer;
}

#world-select:hover {
    border-color: #89b4fa;
}

#coordinates {
    background: rgba(30, 30, 46, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 8px 12px;
    border-radius: 6px;
    color: #cdd6f4;
    font-size: 14px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

#layer-toggles {
    display: flex;
    gap: 8px;
}

.layer-btn {
    background: rgba(30, 30, 46, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid #45475a;
    border-radius: 6px;
    color: #cdd6f4;
    padding: 5px;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.layer-btn:hover {
    background: rgba(49, 50, 68, 0.9);
    border-color: #89b4fa;
}

.layer-btn.inactive {
    background: rgba(24, 24, 37, 0.85);
    color: #45475a;
    border-color: #313244;
}

.layer-btn.inactive svg {
    opacity: 0.5;
}

#connection-status {
    position: absolute;
    bottom: 10px;
    left: 10px;
    z-index: 1000;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

#connection-status.connected {
    background: rgba(166, 227, 161, 0.9);
    color: #1e1e2e;
}

#connection-status.disconnected {
    background: rgba(243, 139, 168, 0.9);
    color: #1e1e2e;
}

#connection-status.connecting {
    background: rgba(249, 226, 175, 0.9);
    color: #1e1e2e;
}

.player-marker {
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Нерухомий контейнер */
.player-marker-inner {
    position: relative;
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Обертається навколо центру разом з трикутником */
.player-direction {
    position: absolute;
    width: 52px;
    height: 52px;
    transform-origin: center center;
    pointer-events: none;
}

/* Трикутник у верхній точці контейнера — як стрілка напрямку */
.player-direction-arrow {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 12px solid rgba(255, 255, 255, 0.95);
    filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.8));
}

/* Аватарка — більша, по центру, нерухома */
.player-head {
    position: absolute;
    width: 32px;
    height: 32px;
    image-rendering: pixelated;
    object-fit: cover;
    filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.85));
    pointer-events: none;
    border-radius: 3px;
}


.player-tooltip {
    background: rgba(30, 30, 46, 0.95);
    border: 1px solid #45475a;
    border-radius: 4px;
    padding: 4px 8px;
    color: #cdd6f4;
    font-size: 12px;
    white-space: nowrap;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

.leaflet-container {
    background: #1a1a2e;
}

.leaflet-control-zoom {
    border: none !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3) !important;
}

.leaflet-control-zoom a {
    background: rgba(30, 30, 46, 0.95) !important;
    color: #cdd6f4 !important;
    border: none !important;
}

.leaflet-control-zoom a:hover {
    background: rgba(49, 50, 68, 0.95) !important;
}

.leaflet-control-attribution {
    background: rgba(30, 30, 46, 0.8) !important;
    color: #6c7086 !important;
    font-size: 10px !important;
}

.leaflet-control-attribution a {
    color: #89b4fa !important;
}

/* Side Panels */
#panels-container {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: calc(100vh - 20px);
}

.side-panel {
    background: rgba(30, 30, 46, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    width: 260px;
    display: flex;
    flex-direction: column;
    flex-shrink: 1;
    overflow: hidden;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    border-bottom: 1px solid #45475a;
    color: #cdd6f4;
    font-size: 14px;
    font-weight: 500;
}

.panel-toggle {
    background: #313244;
    border: 1px solid #45475a;
    border-radius: 4px;
    color: #cdd6f4;
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
}

.panel-toggle:hover {
    background: #45475a;
}

.panel-content {
    overflow-y: auto;
    max-height: 400px;
}

.panel-content.collapsed {
    display: none;
}

.item-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.item-list li {
    padding: 8px 12px;
    color: #cdd6f4;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid #313244;
    transition: background 0.15s;
}

.item-list li:last-child {
    border-bottom: none;
}

.item-list li:hover {
    background: #313244;
}

.item-list li .player-avatar {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    image-rendering: pixelated;
    object-fit: cover;
}

.item-list li .marker-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

.item-list li .item-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.item-list li .item-coords {
    font-size: 11px;
    color: #6c7086;
    white-space: nowrap;
}

.list-empty {
    padding: 12px;
    color: #6c7086;
    font-size: 13px;
    text-align: center;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    #controls {
        left: 50px;
        right: 10px;
        flex-wrap: wrap;
        gap: 6px;
        top: 10px;
    }

    #world-selector, #coordinates {
        padding: 6px 10px;
        font-size: 12px;
    }
    
    .layer-btn {
        padding: 4px;
    }
    
    .layer-btn svg {
        width: 14px;
        height: 14px;
    }
    
    #world-select {
        padding: 2px 6px;
        font-size: 12px;
    }

    #panels-container {
        top: auto;
        bottom: 50px;
        left: 10px;
        right: 10px;
        flex-direction: column-reverse;
        max-height: 80vh;
    }

    .side-panel {
        max-width: none;
        width: 100%;
        box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.3);
    }

    .panel-content {
        max-height: 40vh; /* Allow it to be scrollable but leave map area */
    }
    
    #connection-status {
        bottom: 10px;
        left: 10px;
        font-size: 11px;
        padding: 4px 8px;
    }
}
