/* Parallax Galaxy Map — Dark theme with golden accents */
:root {
    --bg-deep: #06060e;
    --bg-panel: rgba(10, 10, 20, 0.92);
    --bg-panel-border: rgba(180, 155, 80, 0.3);
    --gold: #c8a850;
    --gold-bright: #e8cc70;
    --gold-dim: #8a7030;
    --text-primary: #d4d0c8;
    --text-secondary: #8a8678;
    --text-bright: #f0ece0;
    --accent-blue: #4a7fa5;
    --star-glow: rgba(255, 240, 200, 0.15);
    --font-display: 'Orbitron', monospace;
    --font-body: 'Exo 2', sans-serif;
}

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

html {
    /* Prevent browser zoom on Ctrl+scroll / pinch */
    touch-action: pan-x pan-y;
}

body {
    background: var(--bg-deep);
    color: var(--text-primary);
    font-family: var(--font-body);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

#map {
    width: 100%; height: 100%;
    background: var(--bg-deep);
    z-index: 1;
    touch-action: none;
}

/* Loading screen */
#loading-screen {
    position: fixed; inset: 0; z-index: 9999;
    background: var(--bg-deep);
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    transition: opacity 0.8s ease;
}
#loading-screen.fade-out { opacity: 0; pointer-events: none; }
.loading-logo { width: 120px; margin-bottom: 30px; filter: drop-shadow(0 0 20px rgba(200, 168, 80, 0.4)); }
.loading-text {
    font-family: var(--font-display); font-size: 14px;
    color: var(--gold); letter-spacing: 4px; margin-bottom: 20px;
}
.loading-bar {
    width: 200px; height: 2px;
    background: rgba(200, 168, 80, 0.2); border-radius: 1px;
}
.loading-fill {
    height: 100%; width: 0; background: var(--gold);
    border-radius: 1px; transition: width 0.3s ease;
}

/* Header bar */
#header-bar {
    position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
    height: 48px; display: flex; align-items: center;
    padding: 0 20px; gap: 12px;
    background: linear-gradient(180deg, rgba(10, 10, 20, 0.95) 0%, rgba(10, 10, 20, 0.7) 80%, transparent 100%);
    pointer-events: none;
}
#header-bar > * { pointer-events: auto; }
.header-logo { height: 28px; filter: drop-shadow(0 0 8px rgba(200, 168, 80, 0.3)); }
.header-title {
    font-family: var(--font-display); font-weight: 900;
    font-size: 18px; color: var(--gold); letter-spacing: 6px;
}
.header-subtitle {
    font-family: var(--font-display); font-size: 10px;
    color: var(--text-secondary); letter-spacing: 3px; margin-top: 2px;
}
.header-credit {
    margin-left: auto; font-family: var(--font-display);
    font-size: 9px; color: var(--gold-dim); letter-spacing: 2px;
}

/* Toggle button */
.header-toggle {
    font-family: var(--font-display); font-size: 9px;
    color: var(--text-secondary); letter-spacing: 1px;
    background: rgba(200, 168, 80, 0.08);
    border: 1px solid rgba(200, 168, 80, 0.2);
    border-radius: 3px; padding: 5px 12px;
    cursor: pointer; transition: all 0.2s;
    margin-left: 16px;
}
.header-toggle:hover {
    color: var(--gold); border-color: rgba(200, 168, 80, 0.5);
    background: rgba(200, 168, 80, 0.12);
}
.header-toggle.active {
    color: var(--gold-bright); border-color: var(--gold);
    background: rgba(200, 168, 80, 0.18);
}

/* Info panel */
.panel {
    position: fixed; top: 60px; right: 16px; z-index: 1001;
    width: 360px; max-height: calc(100vh - 80px);
    background: var(--bg-panel);
    border: 1px solid var(--bg-panel-border);
    border-radius: 4px; overflow-y: auto;
    padding: 20px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(200, 168, 80, 0.1);
    backdrop-filter: blur(10px);
}
.panel.hidden { display: none; }
.panel-close {
    position: absolute; top: 8px; right: 12px;
    background: none; border: none; color: var(--text-secondary);
    font-size: 22px; cursor: pointer; line-height: 1;
}
.panel-close:hover { color: var(--gold); }
.panel h2 {
    font-family: var(--font-display); font-size: 16px;
    color: var(--gold); letter-spacing: 2px; margin-bottom: 12px;
}
.panel h3 {
    font-family: var(--font-display); font-size: 11px;
    color: var(--gold-dim); letter-spacing: 1px;
    margin: 14px 0 6px; text-transform: uppercase;
}
.panel .stat-row {
    display: flex; justify-content: space-between;
    padding: 4px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    font-size: 13px;
}
.panel .stat-label { color: var(--text-secondary); }
.panel .stat-value { color: var(--text-bright); font-weight: 600; }
.panel .faction-name { color: var(--gold-bright); }
.panel .sector-colour {
    display: inline-block; width: 10px; height: 10px;
    border-radius: 2px; margin-right: 6px; vertical-align: middle;
}

/* Terrain grid */
.terrain-grid {
    display: inline-grid; gap: 0;
    margin: 10px 0; border: 1px solid rgba(200, 168, 80, 0.2);
    border-radius: 2px; overflow: hidden;
}
.terrain-cell {
    width: 14px; height: 14px;
    position: relative;
}
.terrain-cell.city-marker::after {
    content: ''; position: absolute; inset: 3px;
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: 1px;
}

/* Breadcrumb */
#breadcrumb {
    position: fixed; bottom: 16px; left: 16px; z-index: 1000;
    font-family: var(--font-display); font-size: 11px;
    letter-spacing: 1px; color: var(--text-secondary);
    background: var(--bg-panel); padding: 8px 16px;
    border: 1px solid var(--bg-panel-border); border-radius: 3px;
}
#breadcrumb.hidden { display: none; }
.bc-link { color: var(--gold); cursor: pointer; }
.bc-link:hover { color: var(--gold-bright); }
.bc-item::before { content: ' / '; color: var(--text-secondary); }
.bc-item.hidden { display: none; }

/* Coordinates display */
#coords-display {
    position: fixed; bottom: 16px; right: 16px; z-index: 1000;
    font-family: var(--font-display); font-size: 10px;
    color: var(--text-secondary); letter-spacing: 1px;
}

/* Leaflet overrides */
.leaflet-container { background: var(--bg-deep) !important; }
.leaflet-control-zoom { display: none; }
.leaflet-interactive:focus { outline: none; }

.star-tooltip {
    background: var(--bg-panel) !important;
    border: 1px solid var(--bg-panel-border) !important;
    color: var(--text-primary) !important;
    font-family: var(--font-body) !important;
    font-size: 12px !important;
    padding: 4px 10px !important;
    border-radius: 3px !important;
    box-shadow: 0 2px 10px rgba(0,0,0,0.5) !important;
}
.star-tooltip::before { border: none !important; }
.leaflet-tooltip-top::before { border: none !important; }
.leaflet-tooltip-bottom::before { border: none !important; }

.sector-label {
    background: none !important; border: none !important;
    box-shadow: none !important;
    font-family: var(--font-display) !important;
    font-size: 8px !important;
    color: rgba(200, 168, 80, 0.35) !important;
    letter-spacing: 2px !important;
    text-transform: uppercase !important;
    white-space: nowrap !important;
    text-shadow: 0 0 10px rgba(200, 168, 80, 0.15) !important;
}

/* Planet markers in system view */
.planet-marker {
    border-radius: 50%;
    border: 1px solid rgba(200, 168, 80, 0.4);
    box-shadow: 0 0 8px rgba(200, 168, 80, 0.2);
    cursor: pointer;
    transition: box-shadow 0.2s;
}
.planet-marker:hover {
    box-shadow: 0 0 16px rgba(200, 168, 80, 0.5);
    border-color: var(--gold);
}

/* Planet/star images in system view */
.planet-img {
    border-radius: 50%;
    width: 100%; height: 100%;
    object-fit: cover;
    pointer-events: none;
}

/* System grid view (game-style) */
.grid-sun {
    border-radius: 50%;
    box-shadow: 0 0 16px rgba(255, 220, 100, 0.5), 0 0 40px rgba(255, 200, 60, 0.2);
}
.grid-entity-label {
    font-family: var(--font-body);
    font-size: 9px;
    color: var(--text-secondary);
    text-align: center;
    white-space: nowrap;
    pointer-events: none;
}

/* Mobile: panel becomes a bottom sheet */
@media (max-width: 768px) {
    .panel {
        top: auto; right: 0; bottom: 0; left: 0;
        width: 100%; max-height: 45vh;
        border-radius: 12px 12px 0 0;
        border-bottom: none;
    }
    .panel-close {
        top: 10px; right: 16px; font-size: 26px;
    }
    #header-bar {
        height: 40px; padding: 0 12px; gap: 8px;
    }
    .header-title { font-size: 14px; letter-spacing: 4px; }
    .header-subtitle { display: none; }
    .header-toggle { font-size: 8px; padding: 4px 8px; margin-left: 8px; }
    #breadcrumb { bottom: auto; top: 44px; left: 8px; font-size: 9px; padding: 5px 10px; }
    #coords-display { bottom: 8px; right: 8px; font-size: 9px; }
}
