:root {
    --bg-color: #0f172a;
    --panel-bg: rgba(30, 41, 59, 0.7);
    --panel-border: rgba(255, 255, 255, 0.1);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent: #3b82f6;
    --accent-hover: #60a5fa;
    --res-color: #00c2ff;
    --enl-color: #03dc03;
    --neu-color: #ffce00;
    --mac-color: #eb2222;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    background-image: 
        radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 0%, rgba(16, 185, 129, 0.1) 0px, transparent 50%);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.glass-header {
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--panel-border);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 1000;
    flex-shrink: 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    font-size: 1.5rem;
}

h1 {
    font-size: 1.25rem;
    font-weight: 600;
    background: linear-gradient(to right, #60a5fa, #34d399);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

nav {
    display: flex;
    gap: 1rem;
    background: rgba(0, 0, 0, 0.2);
    padding: 0.25rem;
    border-radius: 0.5rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

nav button {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

nav button:hover {
    color: var(--text-primary);
}

nav button.active {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.dot {
    width: 8px;
    height: 8px;
    background-color: #10b981;
    border-radius: 50%;
}

.pulse {
    box-shadow: 0 0 0 rgba(16, 185, 129, 0.4);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
    70% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

main {
    flex: 1;
    min-height: 0;
    position: relative;
    overflow: hidden;
}

.view {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.view.active {
    opacity: 1;
    pointer-events: auto;
    z-index: 10;
}

/* Map View */
#map {
    width: 100%;
    height: 100%;
    background-color: #0f172a;
}

.glass-panel {
    background: var(--panel-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--panel-border);
    border-radius: 1rem;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
}

.map-overlay {
    position: absolute;
    bottom: 2rem;
    left: 2rem;
    z-index: 1000;
    padding: 1.25rem;
    min-width: 300px;
}

.map-overlay h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.75rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 0.5rem;
}

.stat-item.res .value { color: var(--res-color); }
.stat-item.enl .value { color: var(--enl-color); }
.stat-item.neu .value { color: var(--neu-color); }

.stat-item .label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-bottom: 0.25rem;
}

.stat-item .value {
    font-size: 1.5rem;
    font-weight: 700;
}

/* COMM View */
.comm-container {
    margin: 1rem auto;
    max-width: 800px;
    height: calc(100% - 2rem);
    display: flex;
    flex-direction: column;
}

.comm-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--panel-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.comm-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.btn-icon {
    background: transparent;
    border: 1px solid var(--panel-border);
    color: var(--text-primary);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: rotate(15deg);
}

.comm-list {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.comm-list::-webkit-scrollbar {
    width: 8px;
}

.comm-list::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.1);
}

.comm-list::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 4px;
}

.comm-item {
    padding: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    transition: background 0.2s;
}

.comm-item:hover {
    background: rgba(255, 255, 255, 0.02);
}

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

.comm-meta {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: space-between;
}

.comm-player {
    font-weight: 600;
}

.comm-player-clickable {
    cursor: pointer;
    text-decoration: underline;
    text-decoration-style: dotted;
}

.comm-player-clickable:hover {
    text-decoration-style: solid;
}

.player-RESISTANCE { color: var(--res-color); }
.player-ENLIGHTENED { color: var(--enl-color); }
.player-MAC { color: var(--mac-color); }

.team-res { color: var(--res-color); }
.team-enl { color: var(--enl-color); }
.team-mac { color: var(--mac-color); }
.team-neu { color: var(--neu-color); }

.comm-message {
    font-size: 0.9rem;
    line-height: 1.5;
}

.comm-portal {
    color: var(--accent-hover);
    cursor: pointer;
    text-decoration: underline;
    text-decoration-style: dotted;
}

.loading {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
}

/* Leaflet Dark Theme Overrides */
.leaflet-container {
    background: #0f172a;
}
.leaflet-bar a {
    background-color: var(--panel-bg) !important;
    color: var(--text-primary) !important;
    border-color: var(--panel-border) !important;
}
.leaflet-bar a:hover {
    background-color: rgba(255, 255, 255, 0.1) !important;
}
.leaflet-popup-content-wrapper, .leaflet-popup-tip {
    background: var(--panel-bg) !important;
    color: var(--text-primary) !important;
    backdrop-filter: blur(12px);
    border: 1px solid var(--panel-border);
}
.leaflet-popup-content h4 {
    margin: 0 0 0.5rem 0;
    color: var(--text-primary);
}
.leaflet-popup-content p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Portal Search Layout */
.search-layout {
    display: flex;
    gap: 2rem;
    padding: 2rem;
    height: 100%;
    overflow: hidden;
}

.search-sidebar {
    width: 380px;
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    height: 100%;
}

.search-box {
    position: relative;
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.search-box input {
    flex: 1;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--panel-border);
    border-radius: 0.5rem;
    color: var(--text-primary);
    padding: 0.75rem 1rem;
    font-family: inherit;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}

.search-box input:focus {
    border-color: var(--accent);
}

.search-box button {
    background: var(--accent);
    border: none;
    color: white;
    padding: 0.75rem 1.25rem;
    border-radius: 0.5rem;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.2s;
}

.search-box button:hover {
    background: var(--accent-hover);
}

.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid var(--panel-border);
    border-radius: 0.5rem;
    margin-top: 0.25rem;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1001;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    backdrop-filter: blur(10px);
}

.autocomplete-dropdown.hidden {
    display: none;
}

.autocomplete-item {
    padding: 0.5rem 1rem;
    cursor: pointer;
    font-size: 0.9rem;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-primary);
}

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

.autocomplete-item:hover, .autocomplete-item.selected {
    background: rgba(255, 255, 255, 0.1);
}

.search-results-container {
    flex: 1;
    overflow-y: auto;
}

.search-results-container::-webkit-scrollbar {
    width: 6px;
}

.search-results-container::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}

.search-results-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.search-results {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.search-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: 0.75rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.03);
    cursor: pointer;
    transition: all 0.2s ease;
}

.search-item:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

.search-item.active {
    background: rgba(59, 130, 246, 0.15);
    border-color: var(--accent);
}

.search-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    gap: 0.5rem;
}

.search-item-name {
    font-weight: 600;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.search-item-level {
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.15rem 0.4rem;
    border-radius: 0.25rem;
    background: rgba(255, 255, 255, 0.1);
    white-space: nowrap;
}

.search-item-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.faction-RESISTANCE { color: var(--res-color); font-weight: 600; }
.faction-ENLIGHTENED { color: var(--enl-color); font-weight: 600; }
.faction-MAC { color: var(--mac-color); font-weight: 600; }
.faction-ENLIGHTENED { color: var(--enl-color); font-weight: 600; }
.faction-NEUTRAL { color: var(--text-secondary); }

.placeholder-text, .detail-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-secondary);
    text-align: center;
    padding: 2rem;
}

.detail-placeholder h3 {
    font-size: 1.25rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

/* Detail Panel */
.detail-panel {
    flex: 1;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow-y: auto;
    max-width: 900px;
    margin: 0 auto;
}

.detail-panel::-webkit-scrollbar {
    width: 8px;
}

.detail-panel::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}

.detail-panel::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--panel-border);
    padding-bottom: 1.5rem;
    gap: 1.5rem;
}

.detail-title-area h2 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    background: linear-gradient(to right, #ffffff, #94a3b8);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.detail-subtitle {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.badge {
    font-weight: 700;
    font-size: 0.8rem;
    padding: 0.2rem 0.5rem;
    border-radius: 0.25rem;
    color: white;
}

.badge.L1 { background: #fe0303; }
.badge.L2 { background: #ff5504; }
.badge.L3 { background: #ffaa02; }
.badge.L4 { background: #e0e002; color: black; }
.badge.L5 { background: #96ea02; color: black; }
.badge.L6 { background: #02e602; color: black; }
.badge.L7 { background: #02e6a9; color: black; }
.badge.L8 { background: #028fff; }

.detail-links {
    display: flex;
    gap: 0.75rem;
    flex-shrink: 0;
}

.btn-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--panel-border);
    color: var(--text-primary);
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn-link:hover {
    background: rgba(255, 255, 255, 0.10);
    border-color: var(--text-secondary);
}

.detail-info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.info-card {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 0.75rem;
    padding: 1.25rem;
    border: 1px solid rgba(255, 255, 255, 0.02);
}

.info-card.full-width {
    grid-column: span 2;
}

.info-card h4 {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-bottom: 0.5rem;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.info-card p {
    font-size: 1rem;
    font-weight: 500;
    word-break: break-all;
}

.info-card .owner-name {
    font-weight: 600;
}

/* History Timeline */
.history-timeline-section {
    margin-top: 1rem;
}

.history-timeline-section h3 {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
    color: var(--text-primary);
}

.timeline {
    position: relative;
    padding-left: 1.75rem;
    border-left: 2px solid var(--panel-border);
    margin-left: 0.5rem;
}

.timeline-item {
    position: relative;
    margin-bottom: 1.75rem;
}

.timeline-item:last-child {
    margin-bottom: 0;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: calc(-1.75rem - 7px);
    top: 5px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--bg-color);
    border: 2.5px solid var(--accent);
    z-index: 2;
    transition: all 0.2s ease;
}

.timeline-item.faction-RESISTANCE::before { border-color: var(--res-color); }
.timeline-item.faction-ENLIGHTENED::before { border-color: var(--enl-color); }
.timeline-item.faction-MAC::before { border-color: var(--mac-color); }
.timeline-item.faction-NEUTRAL::before { border-color: var(--text-secondary); }

.timeline-meta {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 0.35rem;
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.timeline-tag {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.1rem 0.35rem;
    border-radius: 0.25rem;
    text-transform: uppercase;
}

.timeline-tag.type-history {
    background: rgba(59, 130, 246, 0.15);
    color: var(--accent-hover);
}

.timeline-tag.type-comm {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
}

.timeline-content {
    font-size: 0.925rem;
    line-height: 1.5;
    background: rgba(255, 255, 255, 0.02);
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    border: 1px solid rgba(255, 255, 255, 0.02);
}

.timeline-content .player-name {
    font-weight: 600;
}

/* ==========================================
   Active Players Map Sidebar & Markers Styling
   ========================================== */

/* Active Players Map Sidebar */
.map-sidebar {
    position: absolute;
    top: 2rem;
    right: 2rem;
    z-index: 1000;
    width: 320px;
    height: calc(100% - 4rem);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: var(--panel-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--panel-border);
    border-radius: 1rem;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
    overflow: visible;
}

.map-sidebar.collapsed {
    transform: translateX(calc(100% + 2rem));
}

.toggle-sidebar-btn {
    position: absolute;
    left: -48px;
    top: 1.5rem;
    width: 48px;
    height: 48px;
    border-radius: 1rem 0 0 1rem;
    background: var(--panel-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--panel-border);
    border-right: none;
    cursor: pointer;
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    box-shadow: -5px 5px 15px rgba(0, 0, 0, 0.3);
    transition: background-color 0.2s;
    outline: none;
}

.toggle-sidebar-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.toggle-sidebar-btn .toggle-icon {
    font-size: 0.75rem;
    transition: transform 0.3s ease;
}

.map-sidebar.collapsed .toggle-sidebar-btn .toggle-icon {
    transform: rotate(180deg);
}

.toggle-sidebar-btn .badge {
    font-size: 0.7rem;
    padding: 0.1rem 0.3rem;
    border-radius: 0.5rem;
    background: var(--accent);
    color: white;
    font-weight: 700;
}

.sidebar-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.sidebar-header {
    padding: 1.25rem;
    border-bottom: 1px solid var(--panel-border);
}

.sidebar-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.sidebar-list {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.sidebar-list::-webkit-scrollbar {
    width: 6px;
}

.sidebar-list::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}

.sidebar-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.10);
    border-radius: 3px;
}

.no-players {
    text-align: center;
    color: var(--text-secondary);
    padding: 2rem;
    font-size: 0.9rem;
}

.player-item {
    padding: 0.85rem;
    border-radius: 0.75rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.02);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.player-item:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

.player-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.player-item-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.player-item-time {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.player-item-msg {
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Active Player Radar Markers on Leaflet Map */
.player-marker {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid #ffffff;
    box-shadow: 0 0 8px rgba(0,0,0,0.5);
}

.player-marker::after {
    content: '';
    position: absolute;
    top: -6px;
    left: -6px;
    right: -6px;
    bottom: -6px;
    border-radius: 50%;
    animation: pulse-radar 1.5s infinite ease-out;
    opacity: 0;
}

.player-marker-res {
    background-color: var(--res-color);
}

.player-marker-res::after {
    border: 2px solid var(--res-color);
}

.player-marker-enl {
    background-color: var(--enl-color);
}

.player-marker-enl::after {
    border: 2px solid var(--enl-color);
}

.player-marker-neu {
    background-color: #94a3b8;
}

.player-marker-neu::after {
    border: 2px solid #94a3b8;
}

.player-marker-mac {
    background-color: var(--mac-color);
}

.player-marker-mac::after {
    border: 2px solid var(--mac-color);
}

@keyframes pulse-radar {
    0% {
        transform: scale(0.6);
        opacity: 0.8;
    }
    100% {
        transform: scale(2.4);
        opacity: 0;
    }
}

/* Tooltip Styling */
.player-tooltip {
    background: rgba(15, 23, 42, 0.95) !important;
    border: 1px solid var(--panel-border) !important;
    color: var(--text-primary) !important;
    border-radius: 0.375rem !important;
    padding: 0.25rem 0.5rem !important;
    font-family: inherit !important;
    font-size: 0.8rem !important;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3) !important;
}

.player-tooltip::before {
    border-top-color: rgba(15, 23, 42, 0.95) !important;
}

/* Popup Styling */
.player-popup {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.25rem;
}

.player-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--panel-border);
    padding-bottom: 0.25rem;
    gap: 1rem;
}

.player-popup-name {
    font-weight: 700;
    font-size: 0.95rem;
}

.player-popup-msg {
    font-size: 0.85rem;
    color: var(--text-primary);
    line-height: 1.4;
    word-break: break-word;
}

.player-popup-time {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-align: right;
}

/* ==========================================
   Cybernetic Portal Sizing, Layout, and Glow
   ========================================== */

.search-item-thumbnail {
    width: 60px;
    height: 60px;
    border-radius: 0.5rem;
    overflow: hidden;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.05);
    position: relative;
}

.search-item-thumbnail.fallback {
    border: 1px dashed rgba(255, 255, 255, 0.15);
}

.search-item-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.search-item:hover .search-item-thumbnail img {
    transform: scale(1.1);
}

.search-item-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.search-item-address {
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 0.15rem;
}

.search-item-address.unknown {
    color: rgba(255, 255, 255, 0.25);
    font-style: italic;
}

/* Details Panel Banner Card styling */
.portal-image-card {
    width: 100%;
    height: 350px;
    border-radius: 1rem;
    overflow: hidden;
    position: relative;
    margin-bottom: 1.5rem;
    border: 1px solid var(--panel-border);
    background: rgba(0, 0, 0, 0.4);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

.portal-image-card.fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 50% 50%, rgba(30, 41, 59, 0.6) 0%, rgba(15, 23, 42, 0.9) 100%);
    border: 1px dashed rgba(255, 255, 255, 0.1);
}

.portal-image-card .portal-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background-color: rgba(0,0,0,0.5);
    transition: transform 0.5s ease;
}

.portal-image-card:hover .portal-image {
    transform: scale(1.05);
}

.portal-image-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to bottom, rgba(15, 23, 42, 0) 60%, rgba(15, 23, 42, 0.8) 100%);
    pointer-events: none;
}

.portal-fallback-bg {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
    background-size: 20px 20px;
    background-position: center;
    pointer-events: none;
    z-index: 1;
}

/* Faction Glow and Color Definitions */
.resistance, .faction-resistance {
    --faction-color: var(--res-color);
    --faction-glow-color: rgba(0, 194, 255, 0.4);
}
.enlightened, .faction-enlightened {
    --faction-color: var(--enl-color);
    --faction-glow-color: rgba(3, 220, 3, 0.4);
}
.neutral, .faction-neutral {
    --faction-color: #94a3b8;
    --faction-glow-color: rgba(148, 163, 184, 0.15);
}

/* Animations for Fallbacks */
.cyber-portal-svg {
    width: 120px;
    height: 120px;
    z-index: 2;
    filter: drop-shadow(0 0 8px var(--faction-glow-color));
    animation: portal-spin 20s linear infinite;
}

.cyber-portal-svg-thumb {
    width: 100%;
    height: 100%;
    padding: 10%;
    filter: drop-shadow(0 0 3px var(--faction-glow-color));
    animation: portal-spin-reverse 15s linear infinite;
}

@keyframes portal-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes portal-spin-reverse {
    from { transform: rotate(360deg); }
    to { transform: rotate(0deg); }
}

/* Make player names look and feel like clickable links to search their profile */
.player-popup-name,
.player-item-name,
.player-name {
    cursor: pointer;
    text-decoration: underline;
    text-decoration-style: dotted;
    transition: text-decoration-color 0.2s ease;
}

.player-popup-name:hover,
.player-item-name:hover,
.player-name:hover {
    text-decoration-style: solid;
}

/* ==========================================
   Mobile Responsive Adjustments
   ========================================== */
@media (max-width: 768px) {
    .glass-header {
        flex-direction: column;
        padding: 0.75rem 1rem;
        gap: 0.75rem;
    }
    
    .status-indicator {
        display: none; /* Hide status indicator to save space on very small screens, or we can keep it */
    }

    nav {
        flex-wrap: wrap;
        justify-content: center;
        width: 100%;
    }

    nav button {
        padding: 0.5rem 0.5rem;
        font-size: 0.85rem;
        flex: 1;
        text-align: center;
        min-width: 80px;
    }

    .search-layout {
        flex-direction: column;
        padding: 1rem;
        gap: 1rem;
        height: 100%;
        overflow-y: auto; /* Let the entire layout scroll vertically on mobile */
    }

    .search-sidebar {
        width: 100%;
        height: auto;
        min-height: 250px;
        max-height: 40vh; /* Take up to 40% of the screen for results */
        flex: none;
    }

    .detail-panel {
        width: 100%;
        height: auto;
        flex: none;
        padding: 1.5rem 1rem;
    }
    
    .detail-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .detail-info-grid {
        grid-template-columns: 1fr; /* 1 column on mobile */
    }

    .info-card.full-width {
        grid-column: span 1;
    }

    /* Active Players Map Sidebar */
    .map-sidebar {
        width: calc(100% - 3rem);
        right: 1.5rem;
        top: 1.5rem;
        height: calc(100% - 3rem);
    }
}

