:root {
    --phosphor-green: #33ff33;
    --amber: #ffbf00;
    --danger-red: #ff4444;
    --ui-cyan: #00ffcc;
    --bg-color: #050505;
    --terminal-dim: rgba(51, 255, 51, 0.2);
}

/* --- Base Layout --- */
body {
    background-color: var(--bg-color);
    color: var(--phosphor-green);
    font-family: 'VT323', monospace;
    font-size: 1.4rem;
    margin: 0;
    padding: 2rem;
    overflow-x: hidden;
    text-shadow: 0 0 5px rgba(51, 255, 51, 0.7);
    line-height: 1.2;
}

/* --- Retro CRT Effects --- */
.scanlines {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: linear-gradient(
        to bottom,
        rgba(255, 255, 255, 0),
        rgba(255, 255, 255, 0) 50%,
        rgba(0, 0, 0, 0.25) 50%,
        rgba(0, 0, 0, 0.25)
    );
    background-size: 100% 4px;
    pointer-events: none;
    z-index: 100;
}

.vignette {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: radial-gradient(circle, transparent 60%, rgba(0,0,0,0.8) 150%);
    pointer-events: none;
    z-index: 101;
}

/* --- Navigation & Links --- */
a {
    color: var(--phosphor-green);
    text-decoration: none;
    transition: all 0.2s ease;
}

a:hover {
    background: var(--phosphor-green);
    color: var(--bg-color);
    box-shadow: 0 0 10px var(--phosphor-green);
}

.nav-btn {
    display: inline-block;
    padding: 5px 15px;
    border: 1px solid var(--phosphor-green);
    margin: 10px 5px;
}

.nav-btn.disabled {
    color: #444;
    border-color: #444;
    text-shadow: none;
    cursor: not-allowed;
}

/* --- Starmap Hex Grid --- */
#sector-map {
    display: grid;
    /* Adjust grid template columns based on your JS c size */
    padding: 50px;
    background: #000;
}

.hex {
    position: relative;
    box-sizing: border-box;
    width: 64px; 
    height: 74px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    cursor: pointer;
    border: 1px solid rgba(51, 255, 51, 0.1); /* Faint grid */
    transition: transform 0.1s;
}

.hex:hover {
    transform: scale(1.1);
    z-index: 10;
    background: rgba(51, 255, 51, 0.1);
}

/* System Presentation States */
.hex.system-present {
    box-shadow: inset 0 0 5px var(--terminal-dim);
    border: 1px solid var(--phosphor-green);
}

.hex.zone-amber {
    border: 1px solid var(--amber);
    box-shadow: inset 0 0 8px rgba(255, 191, 0, 0.3);
    color: var(--amber);
}

.hex.zone-red {
    border: 1px solid var(--danger-red);
    box-shadow: inset 0 0 8px rgba(255, 68, 68, 0.4);
    color: var(--danger-red);
}

/* Hex Internal Labels */
.planet-name { font-weight: bold; font-size: 0.8rem; text-transform: uppercase; }
.planet-pos { font-size: 0.6rem; opacity: 0.7; }
.tech-level { font-size: 0.65rem; color: var(--ui-cyan); }

/* --- System Detail Page Classes --- */
.main-world-highlight {
    border: 2px solid var(--phosphor-green);
    padding: 15px;
    margin: 20px 0;
    background: rgba(51, 255, 51, 0.05);
    box-shadow: inset 0 0 15px var(--terminal-dim);
}

.main-world-badge {
    background-color: var(--phosphor-green);
    color: var(--bg-color);
    padding: 2px 8px;
    font-size: 0.9rem;
    font-weight: bold;
}

/* --- Components --- */
#system-list {
    list-style: none;
    padding: 0;
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid var(--terminal-dim);
}

#system-list li {
    padding: 5px 10px;
    border-bottom: 1px solid var(--terminal-dim);
}

.terminal-coord {
    color: var(--amber);
    font-size: 0.9em;
}

/* Custom Scrollbar for Terminal look */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-color); }
::-webkit-scrollbar-thumb { 
    background: var(--terminal-dim); 
    border: 1px solid var(--phosphor-green);
}

/* --- Animations --- */
.cursor {
    display: inline-block;
    width: 10px;
    height: 1.2rem;
    background-color: var(--phosphor-green);
    animation: blink 1s step-end infinite;
}

@keyframes blink { 50% { opacity: 0; } }


/* Subsector Boundary Lines */
.subsector-boundary-right {
    border-right: 2px solid rgba(255, 255, 255, 0.3) !important;
}

.subsector-boundary-bottom {
    border-bottom: 2px solid rgba(255, 255, 255, 0.3) !important;
}

/* Styling the Subsector Text */
.subsector-label {
    font-size: 0.6rem;
    text-transform: uppercase;
    color: #888;
    margin-bottom: 2px;
    height: 10px; /* Prevents layout jump if name is missing */
    overflow: hidden;
    white-space: nowrap;
}

/* Ensure the cell content is centered and fits */
/* The main container within the hex */
.cell-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    /* Reset any inherited gap */
    gap: 0px; 
}

/* Global reset for all text inside the hex */

/* Faction (Subsector) Label - Top */
.faction-name {
    font-size: 0.5rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 1px; /* Tiny nudge for the faction title */
}

/* Main Planet Name */
.planet-name {
    font-size: 0.75rem;
    font-weight: bold;
    color: #fff;
    margin-bottom: -1px; /* Slight overlap to keep it tight */
}

/* Update your existing cell-content child styles */
.cell-content div {
    margin: 0;
    padding: 0;
    line-height: 0.9; /* Even tighter to accommodate the new line */
    width: 100%;
    text-align: center;
}

/* Specific styling for the UWP string */
.uwp {
    font-family: 'Courier New', monospace; /* Monospaced looks more "sci-fi" */
    font-size: 0.35rem;
    font-weight: bold;
    letter-spacing: -0.5px; /* Slight squeeze for width */
    color: #eee;
    margin: 1px 0; /* Tiny bit of breathing room */
}

/* Shrink coordinates slightly more to save space */
.planet-pos {
    font-size: 0.55rem;
    color: #888;
}

/* Tech Level - Bottom */
.tech-level {
    font-size: 0.55rem;
    color: #00ffcc;
    margin-top: 1px;
}


/* Base styling for all factions */
.faction-name {
    font-size: 0.3rem;
    font-weight: bold;
    letter-spacing: 1px;
    margin-bottom: 3px;
    opacity: 0.8;
}


.faction-another-name {
    background-color: rgba(0, 100, 0, 0.2); /* Dark Green tint */
    border: 1px solid rgba(0, 255, 0, 0.5);
}

/* Systems with no faction */
.faction-unaligned {
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.system-present {
    box-shadow: inset 0 0 15px rgba(255, 255, 255, 0.1);
    transition: transform 0.2s, box-shadow 0.2s;
}

img.planetary-map {
    max-width: 100%;
    height: auto;
    border: 1px solid #39FF14;
    margin: 20px 0;
    image-rendering: pixelated; /* Keeps that digital terminal look crisp */
}

#orbitCanvas {
    background-color: black;
    border-top: 2px solid #39FF14;
    border-bottom: 2px solid #39FF14;
    display: block;
    margin: 30px auto;
    max-width: 100%;
    filter: blur(0.5px); /* Mimics a slight phosphor bleed */
}


/* CSS Snippet for the CRT look */
.terminal-frame {
    background: black;
    color: #39FF14;
    font-family: 'Monospace', 'Courier New', Courier;
    border: 2px solid #39FF14;
    padding: 20px;
    box-shadow: inset 0 0 10px #0a3a05;
}

input, select {
    background: #051505;
    color: #39FF14;
    border: 1px solid #39FF14;
    margin-bottom: 15px;
}

.terminal-btn:hover {
    background: #39FF14;
    color: black;
    cursor: crosshair;
}

