/* style.css */
:root {
    --color-bg: #00000a;
    --color-neon-cyan: #00ffff;
    --color-neon-green: #39ff14;
    --color-neon-red: #ff073a;
}

body {
    background-color: var(--color-bg);
    color: var(--color-neon-green);
    font-family: 'Consolas', monospace;
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 30px;
    min-height: 100vh;
    background-image: repeating-linear-gradient(0deg, var(--color-bg) 0, #000000 1px, #00000a 2px);
}

/* 1. INITIAL STATE: Hide the game elements until 'START DEFENSE' is clicked */
#game-container, #control-panel {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s;
}

/* 2. ACTIVE STATE: Show the game elements */
body.game-active #game-container, body.game-active #control-panel {
    opacity: 1;
    pointer-events: auto;
}

/* 3. WELCOME MODAL STYLING */
#welcome-modal {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 600px;
    padding: 30px;
    background-color: rgba(0, 0, 15, 0.95);
    border: 3px solid var(--color-neon-cyan);
    box-shadow: 0 0 20px var(--color-neon-cyan), 0 0 40px rgba(0, 255, 255, 0.3);
    border-radius: 8px;
    text-align: center;
    z-index: 100;
}

#welcome-modal h3 {
    color: var(--color-neon-green);
    text-shadow: 0 0 5px var(--color-neon-green);
    font-size: 1.8em;
    margin-bottom: 20px;
}

#start-defense-button {
    padding: 15px 30px;
    font-size: 1.2em;
    font-weight: bold;
    margin-top: 20px;
    background-color: var(--color-neon-green);
    color: var(--color-bg);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    box-shadow: 0 0 10px var(--color-neon-green);
    transition: background-color 0.2s;
}

#start-defense-button:hover {
    background-color: #5eff4d;
}

/* 4. RATIONALE PAUSE MODAL STYLING */
#rationale-modal {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 700px;
    max-height: 500px;
    padding: 30px;
    background-color: rgba(0, 0, 0, 0.95);
    border: 3px solid var(--color-neon-red); 
    box-shadow: 0 0 20px var(--color-neon-red);
    color: var(--color-neon-cyan);
    z-index: 101; 
    overflow-y: auto;
}

#rationale-modal h2 {
    color: var(--color-neon-red);
    text-shadow: 0 0 5px var(--color-neon-red);
    text-align: center;
    border-bottom: 1px solid var(--color-neon-red);
    padding-bottom: 10px;
}

#rationale-content {
    font-size: 0.95em;
    text-align: left;
    white-space: pre-wrap;
    padding: 10px 0;
    line-height: 1.5;
}

#close-rationale-button {
    margin-top: 20px;
    padding: 10px 20px;
    background-color: var(--color-neon-red);
    color: var(--color-bg);
    border: none;
    cursor: pointer;
    font-weight: bold;
    box-shadow: 0 0 10px var(--color-neon-red);
}

/* 5. IN-GAME THREAT INSTRUCTION POPUP STYLING */
#instruction-popup {
    position: absolute;
    width: 300px;
    padding: 15px;
    background-color: rgba(0, 0, 0, 0.9);
    border: 2px solid var(--color-neon-cyan);
    box-shadow: 0 0 10px var(--color-neon-cyan);
    color: white;
    z-index: 102; 
    pointer-events: auto; 
    text-align: left;
    font-size: 0.9em;
}

#instruction-popup h4 {
    color: var(--color-neon-green);
    text-shadow: 0 0 3px var(--color-neon-green);
    margin-top: 0;
    margin-bottom: 10px;
    border-bottom: 1px dashed var(--color-neon-cyan);
    padding-bottom: 5px;
}

#instruction-popup .instruction-defense {
    font-weight: bold;
    color: var(--color-neon-cyan);
    margin-top: 10px;
}

#resume-instruction-button {
    width: 100%;
    margin-top: 15px;
    padding: 10px;
    background-color: var(--color-neon-cyan);
    color: var(--color-bg);
    border: none;
    cursor: pointer;
    font-weight: bold;
}

/* 6. NODE HOVER POPUP STYLING (Used on buttons) */
#node-hover-popup {
    position: absolute;
    width: 250px;
    padding: 10px;
    background-color: rgba(0, 0, 0, 0.95);
    border: 1px solid var(--color-neon-green); 
    box-shadow: 0 0 8px var(--color-neon-green);
    color: var(--color-neon-cyan);
    z-index: 90; /* CRITICAL: Must be above control panel (usually z-index 1 or 2) */
    pointer-events: none; 
    text-align: left;
    font-size: 0.85em;
}

#node-hover-popup h5 {
    color: var(--color-neon-green);
    margin: 0 0 5px 0;
    font-size: 1.1em;
}

#node-hover-popup #hover-rationale {
    font-style: italic;
    margin: 5px 0 0 0;
    font-size: 0.9em;
}

/* 7. WAVE COMPLETE MODAL STYLING */
#wave-complete-modal {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 400px;
    padding: 30px;
    background-color: rgba(0, 0, 0, 0.95);
    border: 3px solid var(--color-neon-green); 
    box-shadow: 0 0 15px var(--color-neon-green);
    color: var(--color-neon-cyan);
    text-align: center;
    z-index: 105; 
}

#wave-complete-modal h2 {
    color: var(--color-neon-green);
    text-shadow: 0 0 5px var(--color-neon-green);
    margin-bottom: 10px;
}

#close-wave-complete-button {
    margin-top: 15px;
    padding: 10px 20px;
    background-color: var(--color-neon-green);
    color: var(--color-bg);
    border: none;
    cursor: pointer;
    font-weight: bold;
}


/* 8. GAME UI STYLING & BUTTON FIXES */
#game-container {
    border: 4px solid var(--color-neon-cyan);
    box-shadow: 0 0 18px var(--color-neon-cyan), 0 0 40px rgba(0, 255, 255, 0.6);
}

#control-panel {
    width: 300px;
    padding: 20px;
    background-color: rgba(0, 0, 0, 0.5); 
    border: 3px solid var(--color-neon-green);
    box-shadow: 0 0 15px var(--color-neon-green), 0 0 30px rgba(57, 255, 20, 0.4);
    border-radius: 5px;
    text-align: center;
}

/* CYBERPUNK: Status flicker */
#budget-display, #core-hp-display, #wave-display {
    text-shadow: 0 0 2px rgba(255, 255, 255, 0.5), 0 0 5px var(--color-neon-green);
    animation: flicker 1s infinite alternate;
}

@keyframes flicker {
    from { opacity: 1; }
    to { opacity: 0.8; text-shadow: 0 0 3px var(--color-neon-green); }
}

/* --- BUTTON LAYOUT FIX: Creates the two-column grid --- */
#node-placement-buttons {
    display: flex;
    flex-wrap: wrap; 
    justify-content: space-between; 
    gap: 8px; 
    margin-bottom: 15px;
}

#node-placement-buttons button {
    width: calc(50% - 4px); 
    padding: 10px 5px; 
    margin-bottom: 0; 
    
    background-color: rgba(0, 50, 50, 0.5);
    color: var(--color-neon-cyan);
    border: 1px solid var(--color-neon-cyan);
    cursor: pointer;
    font-weight: bold;
    text-align: center;
    transition: background-color 0.2s, box-shadow 0.2s;
}

/* --- START WAVE STYLING FIX: Unique look and centering --- */
#start-wave {
    width: 100%;
    margin-top: 10px;
    padding: 12px;
    background-color: var(--color-neon-red); 
    color: var(--color-bg); 
    border: 3px solid var(--color-neon-red);
    box-shadow: 0 0 10px var(--color-neon-red);
    font-size: 1.1em;
    font-weight: 900;
    display: block; 
    margin-left: auto;
    margin-right: auto;
}

#start-wave:hover {
    background-color: #ff4d6e; 
    box-shadow: 0 0 15px var(--color-neon-red);
}

/* Generic hover styles for placement and utility buttons */
#node-placement-buttons button:hover, #show-help-button:hover {
    background-color: rgba(0, 100, 100, 0.7);
    box-shadow: 0 0 8px var(--color-neon-cyan);
}

#show-help-button {
    width: 100%;
    padding: 10px;
    margin-bottom: 8px;
    margin-top: 15px;
    color: var(--color-neon-green);
    border-color: var(--color-neon-green);
    background-color: rgba(0, 50, 50, 0.5);
    cursor: pointer;
}