:root {
    --bg: #000814;
    --bg-alt: #0f1419;
    --card: #0a0e18;
    --panel: rgba(10, 14, 24, 0.92);
    --border: rgba(77, 227, 255, 0.2);
    --shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
    --text: #e4ecf6;
    --muted: #7a8fa3;
    --accent: #4de3ff;
    --accent-amber: #f6c344;
    --accent-green: #7bf0c6;
    --accent-red: #ff7b7b;
    --glow: rgba(77, 227, 255, 0.5);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    font-family: 'Courier New', monospace;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    letter-spacing: 0.5px;
}

.starmap-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--bg);
    margin: 0;
    padding: 0;
}

.stars-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    background: radial-gradient(ellipse at 50% 30%, rgba(77, 227, 255, 0.08), transparent 60%);
    display: block;
}

.hyperspace-lanes {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
}

.hyperspace-lane {
    stroke: rgba(77, 227, 255, 0.2);
    stroke-width: 0.6;
    stroke-dasharray: 6 3;
    fill: none;
    animation: dashMove 16s linear infinite;
}

@keyframes dashMove {
    to { stroke-dashoffset: -60; }
}

#starmap {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
}

/* Planet Styling */
.planet {
    position: fixed;
    transform: translate(-50%, -50%);
    cursor: pointer;
    z-index: 10;
    user-select: none;
}

.planet-sphere {
    position: relative;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: transparent;
    box-shadow: 
        0 0 20px rgba(77, 227, 255, 0.6),
        0 0 40px rgba(77, 227, 255, 0.3),
        inset -2px -2px 8px rgba(0, 0, 0, 0.5),
        inset 2px 2px 8px rgba(255, 255, 255, 0.1);
    animation: planetFloat 4s ease-in-out infinite;
    transition: all 0.3s ease;
    background-size: cover;
    background-position: center;
    overflow: hidden;
}

@keyframes planetFloat {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-2px); }
}

.planet:hover .planet-sphere {
    transform: scale(1.15);
    box-shadow: 
        0 0 30px rgba(77, 227, 255, 0.8),
        0 0 60px rgba(77, 227, 255, 0.4),
        inset -2px -2px 8px rgba(0, 0, 0, 0.5),
        inset 2px 2px 8px rgba(255, 255, 255, 0.15);
}

/* Status-specific colors */
.planet.friendly .planet-sphere:not([style*="background-image"]) {
    background: radial-gradient(circle at 35% 35%, rgba(150, 255, 200, 0.9), rgba(70, 200, 150, 0.6));
    box-shadow: 
        0 0 20px rgba(123, 240, 198, 0.8),
        0 0 40px rgba(123, 240, 198, 0.4),
        inset -2px -2px 8px rgba(0, 0, 0, 0.5),
        inset 2px 2px 8px rgba(255, 255, 255, 0.1);
}

.planet.hostile .planet-sphere:not([style*="background-image"]) {
    background: radial-gradient(circle at 35% 35%, rgba(255, 150, 150, 0.9), rgba(200, 70, 70, 0.6));
    box-shadow: 
        0 0 20px rgba(255, 123, 123, 0.8),
        0 0 40px rgba(255, 123, 123, 0.4),
        inset -2px -2px 8px rgba(0, 0, 0, 0.5),
        inset 2px 2px 8px rgba(255, 255, 255, 0.1);
}

.planet.neutral .planet-sphere:not([style*="background-image"]) {
    background: radial-gradient(circle at 35% 35%, rgba(255, 220, 100, 0.9), rgba(200, 160, 50, 0.6));
    box-shadow: 
        0 0 20px rgba(246, 195, 68, 0.8),
        0 0 40px rgba(246, 195, 68, 0.4),
        inset -2px -2px 8px rgba(0, 0, 0, 0.5),
        inset 2px 2px 8px rgba(255, 255, 255, 0.1);
}

.planet.homeworld .planet-sphere:not([style*="background-image"]) {
    background: radial-gradient(circle at 35% 35%, rgba(150, 220, 255, 0.95), rgba(50, 150, 200, 0.7));
    box-shadow: 
        0 0 30px rgba(77, 227, 255, 0.9),
        0 0 60px rgba(77, 227, 255, 0.5),
        inset -2px -2px 8px rgba(0, 0, 0, 0.5),
        inset 2px 2px 8px rgba(255, 255, 255, 0.15);
    animation: pulseHomeworld 2s ease-in-out infinite, planetFloat 4s ease-in-out infinite;
}

/* If an image is applied, suppress any fallback fills */
.planet.has-image .planet-sphere {
    background: none;
}

@keyframes pulseHomeworld {
    0%, 100% { box-shadow: 0 0 20px rgba(77, 227, 255, 0.7), 0 0 40px rgba(77, 227, 255, 0.3), inset -2px -2px 8px rgba(0, 0, 0, 0.5), inset 2px 2px 8px rgba(255, 255, 255, 0.15); }
    50% { box-shadow: 0 0 25px rgba(77, 227, 255, 0.8), 0 0 50px rgba(77, 227, 255, 0.4), inset -2px -2px 8px rgba(0, 0, 0, 0.5), inset 2px 2px 8px rgba(255, 255, 255, 0.15); }
}

/* Venator Spaceship */
.planet.spaceship .planet-sphere {
    width: 60px;
    height: 40px;
    border-radius: 50% 50% 45% 45%;
    background-size: cover;
    background-position: center;
    box-shadow: 
        0 0 15px rgba(200, 200, 200, 0.6),
        0 0 30px rgba(200, 200, 200, 0.3),
        inset -2px -2px 8px rgba(0, 0, 0, 0.5),
        inset 2px 2px 8px rgba(255, 255, 255, 0.1);
    position: relative;
    transform: rotate(-30deg);
}

.planet.spaceship .planet-atmosphere {
    width: 85px;
    height: 60px;
}

.planet-atmosphere {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 70px;
    height: 70px;
    border: 1.5px solid;
    border-radius: 50%;
    opacity: 0;
    animation: atmosphereRotate 12s linear infinite;
}

.planet.friendly .planet-atmosphere {
    border-color: rgba(123, 240, 198, 0.3);
}

.planet.hostile .planet-atmosphere {
    border-color: rgba(255, 123, 123, 0.3);
}

.planet.neutral .planet-atmosphere {
    border-color: rgba(246, 195, 68, 0.3);
}

.planet.homeworld .planet-atmosphere {
    border-color: rgba(77, 227, 255, 0.5);
    opacity: 0.7;
}

@keyframes atmosphereRotate {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

.planet:hover .planet-atmosphere {
    opacity: 1;
    border-width: 2px;
}

.planet-name {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 12px;
    white-space: nowrap;
    font-size: 0.75rem;
    font-weight: bold;
    letter-spacing: 1px;
    text-transform: uppercase;
    opacity: 0;
    transition: opacity 0.2s ease;
    text-shadow: 0 0 8px rgba(0, 0, 0, 0.8);
    pointer-events: none;
}

.planet.friendly .planet-name {
    color: var(--accent-green);
    text-shadow: 0 0 8px rgba(123, 240, 198, 0.5);
}

.planet.hostile .planet-name {
    color: var(--accent-red);
    text-shadow: 0 0 8px rgba(255, 123, 123, 0.5);
}

.planet.neutral .planet-name {
    color: var(--accent-amber);
    text-shadow: 0 0 8px rgba(246, 195, 68, 0.5);
}

.planet.homeworld .planet-name {
    color: var(--accent);
    text-shadow: 0 0 8px rgba(77, 227, 255, 0.8);
}

.planet:hover .planet-name {
    opacity: 1;
}

/* Tooltip */
.tooltip {
    position: fixed;
    padding: 8px 12px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
    z-index: 1000;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.5);
    font-size: 0.8rem;
}

.tooltip.visible {
    opacity: 1;
}

.tooltip-name {
    font-weight: bold;
    letter-spacing: 1px;
    margin-bottom: 4px;
}

.tooltip-status {
    font-size: 0.75rem;
    letter-spacing: 0.5px;
}

/* Legend */
.legend {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 16px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    min-width: 180px;
}

.legend-title {
    font-size: 0.8rem;
    font-weight: bold;
    letter-spacing: 1px;
    margin-bottom: 10px;
    color: var(--accent);
    text-transform: uppercase;
}

.legend-items {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.legend-dot.friendly {
    background: var(--accent-green);
    box-shadow: 0 0 8px rgba(123, 240, 198, 0.6);
}

.legend-dot.hostile {
    background: var(--accent-red);
    box-shadow: 0 0 8px rgba(255, 123, 123, 0.6);
}

.legend-dot.neutral {
    background: var(--accent-amber);
    box-shadow: 0 0 8px rgba(246, 195, 68, 0.6);
}

.legend-dot.homeworld {
    background: var(--accent);
    box-shadow: 0 0 8px rgba(77, 227, 255, 0.8);
}

/* Responsive */
@media (max-width: 768px) {
    .legend {
        bottom: 12px;
        right: 12px;
        padding: 12px;
    }

    .planet-sphere {
        width: 40px;
        height: 40px;
    }

    .planet-atmosphere {
        width: 60px;
        height: 60px;
    }

    .planet-name {
        font-size: 0.65rem;
        margin-top: 8px;
    }
}

@media (max-width: 480px) {
    .legend {
        bottom: 8px;
        right: 8px;
        padding: 10px;
        font-size: 0.7rem;
    }

    .planet-sphere {
        width: 35px;
        height: 35px;
    }

    .planet-atmosphere {
        width: 50px;
        height: 50px;
    }

    .planet-name {
        font-size: 0.6rem;
        margin-top: 6px;
    }
}

/* ==========================================
   GMOD TRAVEL BUTTONS
   ========================================== */
.travel-btn {
    position: absolute;
    bottom: -35px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, rgba(77, 227, 255, 0.2), rgba(77, 227, 255, 0.1));
    border: 1px solid var(--accent);
    color: var(--accent);
    padding: 5px 12px;
    font-size: 0.7rem;
    font-family: 'Courier New', monospace;
    cursor: pointer;
    border-radius: 3px;
    opacity: 0;
    transition: all 0.3s ease;
    white-space: nowrap;
    z-index: 100;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.planet:hover .travel-btn {
    opacity: 1;
}

.travel-btn:hover {
    background: var(--accent);
    color: var(--bg);
    box-shadow: 0 0 15px var(--glow);
}

/* ==========================================
   RESSOURCEN PANEL
   ========================================== */
.resources-panel {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.resource-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 0.75rem;
}

.resource-bar span:first-child {
    width: 90px;
    color: var(--muted);
}

.resource-bar span:last-child {
    width: 35px;
    text-align: right;
    color: var(--text);
}

.resource-bar .bar {
    flex: 1;
    height: 6px;
    background: rgba(77, 227, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

.resource-bar .fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease;
}

.resource-bar .fill.supply {
    background: linear-gradient(90deg, var(--accent-green), #5de8a0);
}

.resource-bar .fill.research {
    background: linear-gradient(90deg, var(--accent), #3ab8d8);
}

.resource-bar .fill.material {
    background: linear-gradient(90deg, var(--accent-amber), #e8a832);
}

.danger-info {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px dashed var(--border);
    font-size: 0.7rem;
}

.danger-info span {
    padding: 2px 6px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 3px;
}

/* Status: contested */
.planet.contested .planet-sphere {
    background: linear-gradient(135deg, var(--accent-amber) 0%, #e87632 100%);
    animation: contestedPulse 1.5s ease-in-out infinite;
}

@keyframes contestedPulse {
    0%, 100% { box-shadow: 0 0 20px rgba(246, 195, 68, 0.4); }
    50% { box-shadow: 0 0 30px rgba(255, 123, 123, 0.6); }
}
