:root {
    --bg-dark: #0b0b0b;
    --ui-panel: rgba(20, 20, 20, 0.95);
    --accent: #55ff55;
    --text-color: #fff;
    --border: rgba(255, 255, 255, 0.1);
    --hover-bg: rgba(85, 255, 85, 0.2);
    --player-accent: #ffcc00;
}

body, html {
    margin: 0; padding: 0; height: 100%; width: 100%;
    background-color: var(--bg-dark);
    overflow: hidden;
    font-family: 'Segoe UI', 'Microsoft JhengHei', sans-serif;
}

#map { height: 100vh; width: 100vw; background: #000; cursor: crosshair; }

/* --- UI 面板 --- */
.control-panel {
    position: absolute; top: 20px; left: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 280px;
}

.info-box {
    background: var(--ui-panel);
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    border: 1px solid var(--border);
    backdrop-filter: blur(4px);
}

.brand-title { margin: 0; font-size: 18px; color: var(--accent); letter-spacing: 1px; }
.sub-title { font-size: 11px; opacity: 0.6; margin-top: 4px; }

/* --- SSO 登入驗證 UI --- */
.auth-section {
    margin-top: 12px;
    border-top: 1px solid var(--border);
    padding-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.login-btn {
    background: var(--player-accent);
    color: #000;
    border: none;
    border-radius: 4px;
    padding: 8px 12px;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    width: 100%;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.login-btn:hover {
    opacity: 0.9;
    transform: scale(1.02);
}

.logout-btn {
    background: rgba(255, 68, 68, 0.15);
    color: #ff4444;
    border: 1px solid rgba(255, 68, 68, 0.3);
    border-radius: 4px;
    padding: 3px 8px;
    font-size: 11px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}
.logout-btn:hover {
    background: rgba(255, 68, 68, 0.25);
    border-color: rgba(255, 68, 68, 0.5);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-info-text {
    display: flex;
    flex-direction: column;
}

.user-status-badge {
    font-size: 9px;
    color: var(--accent);
    background: rgba(85, 255, 85, 0.1);
    border: 1px solid rgba(85, 255, 85, 0.3);
    border-radius: 3px;
    padding: 1px 4px;
    width: fit-content;
    margin-top: 2px;
}

/* --- 傳送按鈕樣式 --- */
.teleport-btn {
    background: var(--accent);
    color: #000;
    border: none;
    border-radius: 4px;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    width: 100%;
    margin-top: 8px;
    transition: all 0.2s;
    box-shadow: 0 2px 6px rgba(85, 255, 85, 0.2);
}
.teleport-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(85, 255, 85, 0.4);
}
.teleport-btn:disabled {
    background: rgba(255, 255, 255, 0.1) !important;
    color: rgba(255, 255, 255, 0.3) !important;
    border: 1px solid var(--border) !important;
    cursor: not-allowed;
    box-shadow: none !important;
}

/* --- 全域動態通知視窗 --- */
.gis-notification {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: var(--ui-panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 15px 20px;
    color: white;
    z-index: 9999;
    box-shadow: 0 10px 30px rgba(0,0,0,0.8);
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 250px;
    max-width: 350px;
    animation: slideIn 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
    backdrop-filter: blur(8px);
}

.gis-notification.error {
    border-left: 4px solid #ff4444;
}

.gis-notification.success {
    border-left: 4px solid var(--accent);
}

.gis-notification.info {
    border-left: 4px solid var(--player-accent);
}

@keyframes slideIn {
    from { transform: translateX(50px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* --- 維度切換 UI --- */
.dimension-selector {
    display: flex;
    flex-direction: column;
    gap: 5px;
    background: var(--ui-panel);
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

.dimension-label {
    font-size: 11px;
    color: var(--accent);
    text-transform: uppercase;
    font-weight: bold;
    letter-spacing: 0.5px;
}

.dimension-select {
    background: #141414;
    color: #fff;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 8px;
    font-size: 13px;
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s;
}

.dimension-select:focus {
    border-color: var(--accent);
}

/* --- 搜尋系統 --- */
.search-container {
    position: relative;
    display: flex;
    flex-direction: column;
}

.search-box {
    display: flex;
    gap: 5px;
    background: var(--ui-panel);
    padding: 5px;
    border-radius: 8px;
    border: 1px solid var(--border);
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

.search-input {
    background: transparent;
    border: none;
    color: var(--accent);
    padding: 8px;
    flex-grow: 1;
    font-size: 14px;
    outline: none;
}
.search-input::placeholder { color: rgba(255,255,255,0.3); }

.search-btn {
    background: var(--accent);
    color: #000;
    border: none;
    border-radius: 4px;
    padding: 0 15px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
}
.search-btn:hover { opacity: 0.9; transform: scale(1.02); }

.results-list {
    position: absolute;
    top: 52px; left: 0; right: 0;
    background: var(--ui-panel);
    border-radius: 8px;
    border: 1px solid var(--border);
    max-height: 400px;
    overflow-y: auto;
    display: none;
    box-shadow: 0 8px 25px rgba(0,0,0,0.6);
}

.result-item {
    padding: 12px 15px;
    color: #eee;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    transition: background 0.2s;
}
.result-item:hover { background: var(--hover-bg); color: var(--accent); }
.result-item .item-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; }
.result-item .item-id { font-size: 10px; color: var(--accent); opacity: 0.8; font-family: monospace; }
.result-item .item-addr { display: block; font-size: 12px; opacity: 0.5; }

/* --- 在線玩家選單 --- */
.player-menu-container {
    position: fixed;
    left: 50px;
    bottom: 100px;
    z-index: 1300;
}

.player-menu-toggle {
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: var(--ui-panel);
    color: var(--accent);
    font-size: 10px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
}

.player-menu-toggle:hover {
    background: rgba(85, 255, 85, 0.15);
    transform: scale(1.04);
}

.player-menu-panel {
    position: absolute;
    left: 56px;
    bottom: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px;
    background: rgba(20, 20, 20, 0.95);
    border: 1px solid var(--border);
    border-radius: 999px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.6);
    min-height: 44px;
}

.player-menu-list {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
}

.player-menu-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px 4px 4px;
    border-radius: 999px;
    background: rgba(255,255,255,0.06);
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}

.player-menu-item:hover {
    background: var(--hover-bg);
}

.player-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid #fff;
    object-fit: cover;
    background: #3c3c3c;
}

.player-menu-name {
    color: #eee;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    flex-direction: column;
}

.player-menu-dim {
    font-size: 8px;
    opacity: 0.6;
    color: var(--player-accent);
}

.player-menu-empty {
    padding: 8px 12px;
    color: rgba(255,255,255,0.6);
    font-size: 12px;
    white-space: nowrap;
}

/* --- 座標顯示與當前維度 --- */
.coord-display {
    position: absolute; bottom: 30px; left: 30px;
    background: var(--ui-panel);
    color: var(--accent);
    padding: 10px 15px;
    border-radius: 6px;
    font-family: 'Consolas', monospace;
    font-size: 16px;
    z-index: 1000;
    border-left: 4px solid var(--accent);
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    pointer-events: none;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.dim-display {
    font-size: 10px;
    opacity: 0.7;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* --- 玩家定位樣式 --- */
.player-tooltip {
    background: rgba(0, 0, 0, 0.8) !important;
    border: 1px solid var(--player-accent) !important;
    color: var(--player-accent) !important;
    font-weight: bold !important;
    font-size: 12px !important;
    padding: 3px 8px !important;
    border-radius: 4px !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.8) !important;
    white-space: nowrap;
}

.player-tooltip::before {
    border-top-color: var(--player-accent) !important;
}

.player-dot {
    background: var(--player-accent); 
    width: 10px; 
    height: 10px; 
    border: 2px solid #fff; 
    border-radius: 50%;
    box-shadow: 0 0 12px var(--player-accent);
}

#loading-indicator { font-size: 11px; color: var(--accent); margin-top: 5px; display: none; }

.leaflet-tile { image-rendering: pixelated !important; }
.leaflet-popup-content-wrapper { background: var(--ui-panel); color: #fff; border: 1px solid var(--border); border-radius: 4px; }
.leaflet-popup-tip { background: var(--ui-panel); }
.leaflet-tooltip-pane { z-index: 650; }