@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
body { 
    margin: 0; 
    overflow: hidden; 
    background: #000;
    font-family: 'Courier New', Courier, monospace;
    color: #00f2ff; /* Sci-fi Cyan */
}

canvas {
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1; /* Keep game behind UI */
}

/* Container for all HUD elements */
.cockpit-overlay {
    position: absolute;
    width: 100vw;
    height: 100vh;
    z-index: 10;
    pointer-events: none; /* Allows clicking "through" the UI to the 3D scene */
    border: 20px solid #1a1a1a; /* Frame of the ship window */
    box-sizing: border-box;
}

/* Subtle dark edges to simulate being inside a cabin */
.vignette {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: radial-gradient(circle, transparent 50%, rgba(0,0,0,0.8) 100%);
}

/* Top status bar */
.hud-top {
    position: absolute;
    top: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 242, 255, 0.1);
    padding: 10px 40px;
    border: 1px solid #00f2ff;
    box-shadow: 0 0 15px rgba(0, 242, 255, 0.3);
    text-shadow: 0 0 5px #00f2ff;
    clip-path: polygon(10% 0, 90% 0, 100% 100%, 0 100%); /* Angular sci-fi shape */
}

/* Central targeting reticle */
.crosshair {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    border: 2px solid rgba(0, 242, 255, 0.5);
    border-radius: 50%;
    transform: translate(-50%, -50%);
}
.crosshair::before {
    content: '';
    position: absolute;
    top: 50%; left: -10px; width: 10px; height: 2px; background: #00f2ff;
}
.crosshair::after {
    content: '';
    position: absolute;
    top: -10px; left: 50%; width: 2px; height: 10px; background: #00f2ff;
}

/* Fake glass reflection */
.glass-glare {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(255,255,255,0.05) 0%, transparent 25%, transparent 100%);
    opacity: 0.3;
}

/* Sidebar Container */
.side-console {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    width: 250px;
    height: 80vh;
    background: rgba(0, 20, 30, 0.7);
    border-left: 2px solid #00f2ff;
    display: flex;
    flex-direction: column;
    padding: 15px;
    box-shadow: -10px 0 20px rgba(0, 242, 255, 0.1);
    pointer-events: auto; /* Make the sidebar interactive if needed */
}

.console-section {
    margin-bottom: 25px;
}

.label {
    font-size: 10px;
    letter-spacing: 2px;
    margin-bottom: 8px;
    color: rgba(0, 242, 255, 0.6);
}

/* 1. Radar/Map Style */
.radar-grid {
    width: 100%;
    aspect-ratio: 1/1;
    border: 1px solid rgba(0, 242, 255, 0.3);
    background: radial-gradient(circle, rgba(0,242,255,0.05) 0%, transparent 70%);
    position: relative;
    overflow: hidden;
}

.radar-sweep {
    position: absolute;
    width: 200%; height: 200%;
    top: -50%; left: -50%;
    background: conic-gradient(from 0deg, rgba(0,242,255,0.2) 0%, transparent 10%);
    animation: sweep 4s linear infinite;
}

/* 2. Vitals / Progress Bars */
.stat-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    font-size: 12px;
}

.bar-bg {
    flex-grow: 1;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(0, 242, 255, 0.2);
}

.bar-fill { height: 100%; transition: width 0.3s ease; }
.shield { background: #00f2ff; box-shadow: 0 0 10px #00f2ff; }
.armor { background: #ffaa00; }
.hull { background: #ff3300; }

/* 3. Enemy List */
.enemy-list {
    flex-grow: 1;
    border-top: 1px solid rgba(0, 242, 255, 0.2);
    padding-top: 10px;
    font-size: 11px;
}

.enemy-entry {
    padding: 5px;
    color: #ff3300;
    text-shadow: 0 0 5px #ff3300;
    border-bottom: 1px solid rgba(255, 51, 0, 0.2);
}

@keyframes sweep {
    to { transform: rotate(360deg); }
}

.radar-blip {
    position: absolute;
    width: 6px;
    height: 6px;
    background-color: #00f2ff;
    border-radius: 50%;
    transform: translate(-50%, -50%); /* Center the dot on the coordinate */
    box-shadow: 0 0 8px #00f2ff;
    transition: all 0.1s ease; /* Smooth movement */
}

/* Add a pulse effect to the blips */
.radar-blip::after {
    content: '';
    position: absolute;
    width: 100%; height: 100%;
    border: 1px solid inherit;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    100% { transform: scale(3); opacity: 0; }
}

#dock-btn {
    position: absolute;
    bottom: 20%;
    left: 50%;
    transform: translateX(-50%);
    padding: 15px 30px;
    background: rgba(0, 242, 255, 0.2);
    border: 2px solid #00f2ff;
    color: #00f2ff;
    font-family: 'Courier New', monospace;
    font-weight: bold;
    cursor: pointer;
    pointer-events: auto; /* IMPORTANT: This must be auto to be clickable */
    text-shadow: 0 0 5px #00f2ff;
    box-shadow: 0 0 15px rgba(0, 242, 255, 0.4);
}

#dock-btn:hover {
    background: rgba(0, 242, 255, 0.5);
    color: #fff;
}

.docking-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    background: rgba(0, 0, 0, 0.85); /* Dim the background stars */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    font-family: 'Courier New', monospace;
}

.docking-window {
    width: 400px;
    padding: 30px;
    background: #050505;
    border: 2px solid #00f2ff;
    box-shadow: 0 0 20px rgba(0, 242, 255, 0.3);
    text-align: center;
    color: #00f2ff;
}

.docking-menu {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin: 25px 0;
}

.menu-btn {
    background: transparent;
    border: 1px solid #00f2ff;
    color: #00f2ff;
    padding: 12px;
    cursor: pointer;
    font-size: 1.1rem;
    transition: all 0.2s;
}

.menu-btn:hover {
    background: #00f2ff;
    color: #000;
    box-shadow: 0 0 10px #00f2ff;
}

.exit-btn {
    margin-top: 10px;
    background: #440000;
    color: #ff3300;
    border: 1px solid #ff3300;
    padding: 10px;
    width: 100%;
    cursor: pointer;
}

.service-body {
    min-height: 200px;
    max-height: 400px;
    overflow-y: auto;
    padding: 10px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px inset var(--neon-blue);
    text-align: left;
    font-size: 0.9rem;
    line-height: 1.4;
}

/* Custom Scrollbar for that Sci-Fi feel */
.service-body::-webkit-scrollbar {
    width: 5px;
}
.service-body::-webkit-scrollbar-thumb {
    background: var(--neon-blue);
}

/* Container for the building category content */
#service-content {
    display: flex;
    flex-direction: column;
    align-items: center; /* Centers items horizontally */
    text-align: center;
    padding: 20px;
    color: #00f2ff; /* Cyberpunk Cyan */
}

/* The wrapper for multiple buttons */
.build-options {
    display: flex;
    flex-direction: column;
    gap: 12px; /* Space between buttons */
    width: 100%;
    max-width: 300px; /* Prevents buttons from being too wide */
    margin-top: 15px;
}

/* Enhanced Sci-Fi Buttons */
.btn-primary {
    background: rgba(0, 242, 255, 0.1);
    border: 1px solid #00f2ff;
    color: #00f2ff;
    padding: 12px 20px;
    font-family: 'Courier New', Courier, monospace;
    font-weight: bold;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.3s ease;
    border-radius: 4px;
    outline: none;
}

/* Hover & Active States */
.btn-primary:hover {
    background: rgba(0, 242, 255, 0.3);
    box-shadow: 0 0 15px rgba(0, 242, 255, 0.5);
    transform: translateY(-2px); /* Slight lift effect */
}

.btn-primary:active {
    transform: translateY(1px);
    box-shadow: 0 0 5px rgba(0, 242, 255, 0.8);
}

/* Tier Card Styling (for the Option 2 layout) */
.tier-card {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 10px;
    border-left: 3px solid #00f2ff;
    width: 100%;
}

#resource-tooltip {
    position: fixed;
    pointer-events: none; /* Prevents the tooltip from flickering when the mouse is over it */
    background: rgba(0, 10, 20, 0.95);
    border: 1px solid #00f2ff;
    color: #fff;
    padding: 10px;
    border-radius: 4px;
    z-index: 1000;
    font-size: 0.8rem;
    box-shadow: 0 0 15px rgba(0, 242, 255, 0.4);
    z-index: 9999; /* Make sure it's above everything else */
}

.hidden { display: none; }

.cost-item {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    margin: 3px 0;
}

.res-name { color: #00f2ff; text-transform: uppercase; font-weight: bold; }
.res-val { color: #ffd700; } /* Gold color for values */

#resource-tooltip {
    min-width: 200px;
    border-left: 4px solid #00f2ff; /* Accent bar */
}

.tooltip-title {
    font-weight: bold;
    border-bottom: 1px solid rgba(0, 242, 255, 0.2);
    margin-bottom: 8px;
    padding-bottom: 4px;
    color: #00f2ff;
}

.section-label {
    font-size: 0.65rem;
    color: #888;
    margin-bottom: 5px;
    letter-spacing: 0.5px;
}

.yield-divider {
    height: 1px;
    background: linear-gradient(90deg, rgba(0, 255, 136, 0.5), transparent);
    margin: 10px 0;
}

.yield-header {
    font-size: 0.65rem;
    color: #00ff88;
    margin-bottom: 2px;
}

.yield-val {
    color: #00ff88;
    font-size: 0.65rem;
    font-family: 'Orbitron', sans-serif; /* If you have a sci-fi font loaded */
    text-shadow: 0 0 5px rgba(0, 255, 136, 0.3);
}

/* Maintenance specific styles */
.maint-divider {
    height: 1px;
    background: linear-gradient(90deg, rgba(255, 120, 0, 0.5), transparent);
    margin: 10px 0;
}

.maint-header {
    font-size: 0.65rem;
    color: #ff7800; /* Safety Orange */
    margin-bottom: 2px;
    letter-spacing: 0.5px;
}

.maint-val {
    color: #ff7800;
    font-size: 1.1rem;
    font-weight: bold;
}

.maint-unit {
    font-size: 1.1rem;
    color: #888;
    margin-left: 4px;
}

/* Shipyard Specific Styling */
.filter-btn {
    background: #222;
    border: 1px solid #444;
    color: #888;
    padding: 5px 12px;
    cursor: pointer;
    font-family: 'Orbitron', sans-serif; /* Or your preferred sci-fi font */
}

.filter-btn.active-filter {
    background: #00ffcc;
    color: #000;
    border-color: #fff;
    box-shadow: 0 0 10px #00ffcc;
}

.ship-row {
    border-bottom: 1px solid #222;
    transition: background 0.2s;
}

.ship-row:hover {
    background: #1a1a1a;
}

/* Size Badges */
.ship-id-badge {
    display: inline-block;
    padding: 2px 6px;
    font-size: 0.7em;
    border-radius: 3px;
    margin-bottom: 4px;
    background: #333;
}

.size-s .ship-id-badge { border-left: 3px solid #00ff88; } /* Agile/Green */
.size-m .ship-id-badge { border-left: 3px solid #0088ff; } /* Reliable/Blue */
.size-l .ship-id-badge { border-left: 3px solid #ffaa00; } /* Heavy/Orange */
.size-c .ship-id-badge { border-left: 3px solid #ff0044; } /* Massive/Red */

.price-cell {
    color: #ffcc00;
    font-family: monospace;
    font-weight: bold;
}

#hud-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none; /* Let clicks pass through to the 3D scene */
}
.buy-btn, .mini-btn {
    pointer-events: auto; /* Buttons still need to be clickable */
}

.hud-bottom {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 40px;
    background: rgba(0, 20, 20, 0.7);
    padding: 10px 30px;
    border-top: 2px solid #00ffcc;
    clip-path: polygon(10% 0%, 90% 0%, 100% 100%, 0% 100%);
    pointer-events: none;
}

.weapon-group {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.group-label {
    font-size: 10px;
    color: #00ffcc;
    margin-bottom: 5px;
    letter-spacing: 1px;
}

.slot-container {
    display: flex;
    gap: 8px;
}

.weapon-slot {
    width: 40px;
    height: 40px;
    border: 1px solid #444;
    background: rgba(0, 0, 0, 0.5);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.weapon-slot.active {
    border-color: #00ffcc;
    box-shadow: inset 0 0 10px rgba(0, 255, 204, 0.3);
}

.weapon-slot .slot-icon {
    font-size: 18px;
    color: #555;
}

.weapon-slot.equipped .slot-icon {
    color: #00ffcc;
}

/* Decorative elements should never catch clicks */
.vignette, .glass-glare, .crosshair {
    pointer-events: none !important;
}

/* The container must allow clicks, but let them pass through empty space */
.cockpit-overlay {
    pointer-events: none;
}

/* The actual interactive sections must re-enable pointer events */
.side-console, .hud-bottom, #dock-btn {
    pointer-events: auto !important;
}

.weapon-slot {
    cursor: pointer;
    pointer-events: auto; /* Just to be safe */
}

.radar-blip.player-blip {
    background-color: #00ff44 !important; /* Bright green */
    box-shadow: 0 0 5px #00ff44;          /* Glowing effect */
    width: 6px;                            /* Make them slightly different size if desired */
    height: 6px;
    border-radius: 50%;
}

#player-radar-arrow {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 12px;
    height: 12px;
    background-color: #00f2ff;
    /* Create an arrow shape */
    clip-path: polygon(50% 0%, 0% 100%, 50% 80%, 100% 100%);
    z-index: 20;
    pointer-events: none;
    box-shadow: 0 0 10px #00f2ff;
    /* Ensure the rotation center is the middle of the arrow */
    transform-origin: center center;
}

.radar-blip.star-blip {
    background-color: #ffcc00 !important; /* Bright Yellow */
    box-shadow: 0 0 8px #ffcc00;           /* Star glow */
    width: 8px;                            /* Slightly larger than planets */
    height: 8px;
    z-index: 5;                            /* Ensure it sits below the player arrow */
}

#chat-window {
    position: absolute;
    bottom: 20px;
    left: 20px;
    width: 350px;
    height: 250px;
    background: rgba(0, 20, 30, 0.8);
    border: 1px solid #00f2ff;
    display: flex;
    flex-direction: column;
    font-family: 'Courier New', Courier, monospace;
    pointer-events: auto;
    box-shadow: 0 0 15px rgba(0, 242, 255, 0.2);
}

#chat-output {
    flex-grow: 1;
    overflow-y: auto;
    padding: 10px;
    color: #00f2ff;
    font-size: 13px;
    text-shadow: 0 0 5px rgba(0, 242, 255, 0.5);
}

/* Custom Scrollbar for the sci-fi look */
#chat-output::-webkit-scrollbar {
    width: 5px;
}
#chat-output::-webkit-scrollbar-thumb {
    background: #00f2ff;
}

.chat-input-area {
    display: flex;
    border-top: 1px solid #00f2ff;
    background: rgba(0, 40, 60, 0.9);
}

#chat-input {
    flex-grow: 1;
    background: transparent;
    border: none;
    padding: 10px;
    color: #fff;
    outline: none;
}

#chat-send {
    background: #00f2ff;
    color: #000;
    border: none;
    padding: 0 15px;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.2s;
}

#chat-send:hover {
    background: #fff;
}

.chat-msg.system { color: #ffcc00; font-style: italic; }
.chat-msg.player { color: #fff; }
.chat-msg.name { color: #00f2ff; font-weight: bold; margin-right: 5px; }

.chat-time {
    color: rgba(0, 242, 255, 0.4);
    font-size: 0.8em;
    margin-right: 5px;
}

.uninstall-btn {
    background: #ff4400;
    color: white;
    border: 1px solid #ff6600;
    padding: 5px 10px;
    cursor: pointer;
    font-family: 'Courier New', monospace;
    font-weight: bold;
    transition: all 0.2s;
}

.uninstall-btn:hover {
    background: #ffffff;
    color: #ff4400;
}

.build-btn {
    background: #555; /* Neutral grey to indicate it costs money */
    color: #fff;
    border: 1px solid #777;
    padding: 5px 10px;
    cursor: pointer;
    font-weight: bold;
}

.build-btn:hover {
    background: gold;
    color: black;
}

.install-btn {
    background: #00f2ff; /* Your signature cyan */
    color: #000;
    border: none;
    padding: 5px 10px;
    cursor: pointer;
    font-weight: bold;
}

/* Show the manifest window when hovering over the wrapper */
#planetary-reserve-wrap:hover .manifest-window {
    display: block !important;
}

/* Optional: Add a slight "scanline" effect to the manifest window */
.manifest-window::before {
    content: " ";
    position: absolute;
    top: 0; left: 0; bottom: 0; right: 0;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.1) 50%), 
                linear-gradient(90deg, rgba(255, 0, 0, 0.02), rgba(0, 255, 0, 0.01), rgba(0, 0, 255, 0.02));
    background-size: 100% 2px, 3px 100%;
    pointer-events: none;
}