body {
    margin: 0;
    padding: 0;
    background-color: #050505;
    color: #fff;
    font-family: 'Rajdhani', sans-serif;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    user-select: none;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* LANDING SCREEN */
#landing-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #050505;
    z-index: 2000;
    display: flex;
    flex-direction: column;
}

#landing-header {
    height: 20%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: linear-gradient(to bottom, #111, transparent);
    z-index: 10;
}

.neon-title {
    font-size: 48px;
    margin: 0;
    line-height: 1;
    text-align: center;
    color: #00ffcc;
    text-shadow: 
        0 0 5px #00ffcc,
        0 0 10px #00ffcc,
        0 0 20px #00ffcc,
        0 0 40px #009977;
    font-family: monospace; /* Or a custom font if available */
    letter-spacing: 4px;
}

.subtitle {
    font-size: 14px;
    color: #ff0055;
    letter-spacing: 8px;
    margin-top: 10px;
    text-shadow: 0 0 10px #ff0055;
}

#landing-visual {
    height: 50%; /* Upper part of the 80% */
    display: flex;
    justify-content: center;
    align-items: center;
    perspective: 1000px;
    overflow: hidden;
}

/* 3D Cube Animation */
.cube-container {
    width: 100px;
    height: 100px;
    transform-style: preserve-3d;
    animation: rotateCube 10s infinite linear;
}

.cube {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
}

.face {
    position: absolute;
    width: 100px;
    height: 100px;
    border: 2px solid #00ffcc;
    background: rgba(0, 255, 204, 0.1);
    box-shadow: 0 0 15px rgba(0, 255, 204, 0.2) inset, 0 0 5px rgba(0, 255, 204, 0.3); /* Added outer shadow, limited spread */
    display: flex;
    justify-content: center;
    align-items: center;
    backface-visibility: hidden; /* Added to improve performance and rendering */
}

.face.front  { transform: translateZ(50px); }
.face.back   { transform: rotateY(180deg) translateZ(50px); }
.face.right  { transform: rotateY(90deg) translateZ(50px); }
.face.left   { transform: rotateY(-90deg) translateZ(50px); }
.face.top    { transform: rotateX(90deg) translateZ(50px); }
.face.bottom { transform: rotateX(-90deg) translateZ(50px); }

@keyframes rotateCube {
    0% { transform: rotateX(0deg) rotateY(0deg); }
    100% { transform: rotateX(360deg) rotateY(360deg); }
}

#landing-nav {
    height: 30%; /* Lower part of the 80% */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 20px;
    padding-bottom: 20px;
}

.cyber-btn {
    background: transparent;
    border: 2px solid #555;
    color: #fff;
    padding: 12px 20px; /* Reduced vertical, comfortable horizontal */
    font-size: 18px;
    font-family: 'Rajdhani', sans-serif;
    text-transform: uppercase;
    letter-spacing: 2px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: all 0.3s;
    width: auto; /* Allow auto width based on content */
    min-width: 180px; /* Ensure a consistent minimum size */
    max-width: 300px;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    clip-path: polygon(15px 0, 100% 0, 100% calc(100% - 15px), calc(100% - 15px) 100%, 0 100%, 0 15px);
    box-sizing: border-box;
}

.cyber-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: 0.5s;
}

.cyber-btn:hover::before,
.cyber-btn.clicked::before {
    left: 100%;
}

.cyber-btn:hover,
.cyber-btn.clicked {
    background: rgba(255, 255, 255, 0.1);
    border-color: #fff;
    text-shadow: 0 0 8px #fff;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.3);
}

.cyber-btn.main-action {
    border-color: #00ffcc;
    color: #00ffcc;
    font-size: 24px;
    font-weight: bold;
    box-shadow: 0 0 10px rgba(0, 255, 204, 0.2);
}

.cyber-btn.main-action:hover,
.cyber-btn.main-action.clicked {
    background: rgba(0, 255, 204, 0.1);
    box-shadow: 0 0 20px rgba(0, 255, 204, 0.6);
    text-shadow: 0 0 10px #00ffcc;
}


/* Generic Overlay Screen (Used for Landing Settings) */
.overlay-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    display: flex; 
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 3000; /* Above landing screen */
    background: #050505;
    padding: 20px;
    box-sizing: border-box;
    
    /* Transition Logic */
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
    transform: scale(1.1);
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
}

.overlay-screen.active {
    opacity: 1;
    pointer-events: auto;
    visibility: visible;
    transform: scale(1);
}

.settings-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    margin-bottom: 40px;
    width: 100%;
}

.settings-content p {
    color: #aaa;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 2px;
}
/* Layout Container */
#main-container {
    display: flex;
    flex-direction: column;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    background: #333;
    overflow: hidden;
}

/* Game Field (Top ~90%) */
#game-field {
    position: relative;
    background: #111;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    flex: 9; /* Take 9 parts of space */
    min-height: 0; /* Important for flex items to shrink */
}

canvas#gameCanvas {
    display: block;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    margin: auto; /* Ensure centering */
}

/* Sidebar / Thumb Zone (Bottom ~10%) */
.cyber-panel {
    background: #0a0a0a;
    width: 100%;
    flex: 1; /* Take 1 part of space */
    min-height: 60px; /* Minimum usable height */
    z-index: 10;
    overflow: hidden;
    border-top: 2px solid #00ffcc;
    box-shadow: 0 -2px 10px rgba(0, 255, 204, 0.2);
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    padding: 0 5px;
    box-sizing: border-box;
    /* Ensure it handles full width content */
    gap: 0; 
}

/* Control Groups (The buttons we will hide) */
.control-group {
    display: flex;
    gap: 5px;
    align-items: center;
    /* This transition makes them slide out smoothly */
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s;
    overflow: hidden; /* Important for hiding */
}

/* Default State: Buttons visible */
.control-group.left { width: 15%; justify-content: flex-start; }
.control-group.right { flex: 1; justify-content: flex-end; } /* Right group takes all available space */

/* The Middle Content (Upgrade Panel) */
#sidebar-content { 
    width: 0; /* Collapsed when inactive */
    opacity: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    /* Smoothly grow to full width */
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s;
    overflow: hidden; /* Prevent content bleeding */
}

/* --- MISSING PART: Contextual Mode Classes --- */

/* When upgrade is active, hide the side buttons */
.cyber-panel.context-active .control-group {
    width: 0 !important;
    flex: 0 !important; /* Force collapse */
    opacity: 0;
    pointer-events: none;
    margin: 0;
    padding: 0;
}

/* When upgrade is active, expand the middle content to full width */
.cyber-panel.context-active #sidebar-content {
    width: 100% !important;
    opacity: 1;
}

/* Icon Buttons (Cog, Pause) */
.icon-btn {
    background: transparent;
    border: 1px solid #444;
    color: #00ffcc;
    width: 35px;
    height: 35px;
    border-radius: 4px;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    text-shadow: 0 0 5px #00ffcc;
}

.icon-btn:hover {
    border-color: #00ffcc;
    background: rgba(0, 255, 204, 0.1);
    box-shadow: 0 0 8px rgba(0, 255, 204, 0.4);
}

/* Action Buttons (Start, Overclock) */
.action-btn {
    background: #111;
    border: 1px solid #444;
    color: #fff;
    font-family: 'Rajdhani', sans-serif;
    font-weight: bold;
    cursor: pointer;
    text-transform: uppercase;
    transition: all 0.2s;
    clip-path: polygon(5px 0, 100% 0, 100% calc(100% - 5px), calc(100% - 5px) 100%, 0 100%, 0 5px);
}

.action-btn.small {
    font-size: 9px;
    padding: 2px 4px;
    width: 50px;
    height: 30px;
    border-color: #ffaa00;
    color: #ffaa00;
}

.action-btn.main {
    font-size: 14px;
    padding: 5px 10px;
    height: 40px;
    min-width: 60px;
    border-color: #00ff00;
    color: #00ff00;
    background: rgba(0, 255, 0, 0.05);
    text-shadow: 0 0 5px #00ff00;
}

.action-btn.main:hover {
    background: rgba(0, 255, 0, 0.2);
    box-shadow: 0 0 10px rgba(0, 255, 0, 0.4);
}

/* Upgrade Panel Compact Layout */
/* HORIZONTAL DASHBOARD OVERHAUL */
#upgrade-panel {
    display: flex;
    flex-direction: row; /* Horizontal Flow */
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: 100%;
    padding: 0 5px;
    gap: 10px;
    box-sizing: border-box;
    font-family: 'Rajdhani', sans-serif;
}

/* Sections */
.panel-section {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* 1. Info Section */
.panel-section.info {
    align-items: flex-start;
    min-width: 70px;
    border-right: 1px solid #333;
    padding-right: 8px;
}
#upg-header { font-size: 14px; font-weight: bold; color: #00ffcc; white-space: nowrap; }
.level-badge { font-size: 11px; color: #666; font-weight: bold; }

/* 2. Stats Section */
.panel-section.stats-group {
    flex-direction: row; /* Stats side by side */
    align-items: center;
    flex: 1; /* Take available width */
    justify-content: center;
    gap: 10px;
}

.stat-unit {
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: 45%; /* Split width */
}

.stat-label { font-size: 10px; color: #aaa; display: flex; justify-content: space-between; }
.val-highlight { color: #fff; font-weight: bold; }

.stat-controls { display: flex; align-items: center; gap: 5px; }

/* Compact Pip Bar */
.pip-bar {
    display: flex;
    gap: 2px;
    flex: 1;
    height: 12px; /* Thinner */
}
.pip {
    flex: 1;
    background: #222;
    border: 1px solid #444;
    transform: skewX(-20deg);
}
.pip.active { background: #00ffcc; border-color: #00ffcc; box-shadow: 0 0 5px #00ffcc; }

.vert-divider { width: 1px; height: 30px; background: #333; }

/* Compact Buttons */
.mini-upg-btn {
    width: 35px;
    height: 24px; /* Reduced height to fit sidebar */
    background: #111;
    border: 1px solid #444;
    color: #fff;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    line-height: 0.9;
}
.mini-upg-btn:hover { border-color: #fff; background: #222; }
.cost-text { font-size: 9px; color: #ffd700; }

/* 3. Actions Section */
.panel-section.actions {
    align-items: flex-end;
    gap: 4px;
    min-width: 90px;
    border-left: 1px solid #333;
    padding-left: 8px;
}

/* Compact Cyber Buttons */
.cyber-btn.compact {
    font-size: 10px;
    padding: 0 8px;
    height: 22px; /* Very short */
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.cyber-btn.compact .cost-text { margin-left: 5px; }

/* Top UI Overlay */
#top-ui-container {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%; /* Dynamically updated in main.js */
    height: auto;
    pointer-events: none;
    display: flex;
    justify-content: space-between;
    padding: 15px;
    box-sizing: border-box;
    z-index: 20;
}

#top-left-group, #top-right-group {
    display: flex;
    gap: 20px;
}

.stat-box {
    background: transparent;
    padding: 0;
    font-size: 14px;
    font-weight: bold;
    color: #fff;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 6px;
    text-shadow: 0 0 5px rgba(0, 255, 204, 0.6);
    font-family: 'Orbitron', sans-serif;
    letter-spacing: 1px;
}


/* Game Over Overlay & Shop (Used for Talent Screen too) */
#game-over-overlay, #pause-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start; /* Align top so we can space out content */
    z-index: 9999;
    background: #050505; /* Solid background */
    padding-top: 20px;
    padding-bottom: 20px;
    box-sizing: border-box;

    /* Transition Logic */
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
    transform: translateY(-20px);
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
}

#game-over-overlay.active, #pause-overlay.active {
    opacity: 1;
    pointer-events: auto;
    visibility: visible;
    transform: translateY(0);
}

#game-over-overlay h1, #pause-overlay h1 {
    font-size: 36px;
    color: #ff0055;
    text-shadow: 0 0 20px #ff0055;
    margin-bottom: 20px;
    margin-top: 0;
    flex-shrink: 0; /* Prevent shrinking */
}

#pause-overlay {
    background: rgba(0, 0, 0, 0.8); /* Keep pause transparent-ish */
    backdrop-filter: blur(8px);
    justify-content: center; /* Keep pause centered */
}

#shop-section {
    background: transparent; /* Seamless */
    border: none;
    padding: 0 20px;
    width: 100%;
    max-width: 600px;
    flex-grow: 1; /* Take remaining space */
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    overflow-y: auto; /* Scrollable content */
    margin-bottom: 20px;
}

.shop-title { font-size: 24px; color: #ffd700; text-transform: uppercase; letter-spacing: 2px; border-bottom: 1px solid #333; padding-bottom: 5px; width: 100%; text-align: center; font-weight: bold; }
.tech-points { font-size: 16px; color: #fff; margin-bottom: 5px; }
.ascension-info { font-size: 12px; color: #aaa; }

/* TALENT TREE STYLES */
.talent-tree {
    display: flex;
    flex-direction: column;
    gap: 30px;
    position: relative;
    padding: 10px;
}

.talent-tier {
    display: flex;
    justify-content: center;
    gap: 20px;
    position: relative;
    z-index: 2;
}

.talent-tier-label {
    position: absolute;
    left: -80px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 10px;
    color: #555;
    text-transform: uppercase;
    width: 70px;
    text-align: right;
}

.talent-node {
    background: #222;
    border: 2px solid #444;
    width: 60px;
    height: 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    transition: all 0.2s;
    border-radius: 4px;
    z-index: 2;
}

.talent-node:hover { border-color: #fff; z-index: 3; }
.talent-node.locked { opacity: 0.3; cursor: not-allowed; filter: grayscale(1); }
.talent-node.maxed { border-color: #ffd700; background: #332b00; }

.talent-icon { font-size: 18px; margin-bottom: 2px; }
.talent-ranks { font-size: 10px; color: #aaa; background: rgba(0,0,0,0.5); padding: 1px 4px; border-radius: 2px; }
.talent-node.maxed .talent-ranks { color: #ffd700; }

/* SVG Container for connection lines */
#tree-connections {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

/* Tooltip */
.talent-node:hover::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 110%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.95);
    border: 1px solid #555;
    color: #fff;
    padding: 8px;
    border-radius: 4px;
    font-size: 11px;
    width: 180px;
    text-align: center;
    z-index: 100;
    pointer-events: none;
    white-space: pre-line;
}

.req-text { color: #ff5555; font-size: 12px; margin-top: 5px; }

#game-over-overlay > div { /* For the buttons on game over screen */
    display: flex;
    gap: 10px;
}

#pause-overlay > div { /* For the buttons on pause screen */
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
}

#restart-btn, #resume-btn, #quit-run-btn {
    /* Styles now handled by .cyber-btn class */
}

#ascend-btn {
    display: none;
    margin-top: 10px;
    padding: 10px 20px;
    font-size: 14px;
    background: transparent;
    color: #ffd700;
    border: 2px solid #ffd700;
    cursor: pointer;
    font-family: inherit;
    text-transform: uppercase;
    font-weight: bold;
    border-radius: 4px;
    transition: all 0.2s;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.2);
    animation: pulse-gold 2s infinite;
}

@keyframes pulse-gold {
    0% { box-shadow: 0 0 15px rgba(255, 215, 0, 0.2); }
    50% { box-shadow: 0 0 30px rgba(255, 215, 0, 0.5); }
    100% { box-shadow: 0 0 15px rgba(255, 215, 0, 0.2); }
}



#tutorial-overlay {
    position: fixed;
    top: 0;
    height: 100vh;
    height: 100dvh;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(4px);
}

#tutorial-box {
    background: #111;
    border: 2px solid #00ffcc;
    padding: 30px;
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 0 30px rgba(0, 255, 204, 0.4);
    max-width: 400px;
    cursor: pointer;
    animation: float 2s ease-in-out infinite;
}

#tutorial-box h2 {
    color: #00ffcc;
    margin-top: 0;
    text-transform: uppercase;
    letter-spacing: 2px;
}

#tutorial-box p {
    color: #eee;
    font-size: 16px;
    line-height: 1.5;
}

.key-hint {
    color: #ffd700;
    font-weight: bold;
}

.click-hint {
    margin-top: 20px;
    font-size: 12px;
    color: #888;
    font-style: italic;
}

@keyframes float {
    0% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
    100% { transform: translateY(0); }
}

#placement-overlay {
    position: absolute;
    display: none;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 5px;
    z-index: 100;
    pointer-events: auto;
    transform: translate(-50%, 20px); /* Center Horizontally, Push Down */
    filter: drop-shadow(0 0 10px rgba(0,0,0,0.8));
}

#placement-overlay .hud-btn {
    transform: none; /* Remove skew for placement buttons */
    width: 50px;
    height: 50px;
    /* Match Start button's clipped corners */
    clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
    border-width: 2px;
    border-style: solid;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: all 0.2s;
}

#placement-overlay .hud-btn .btn-content {
    transform: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

#placement-overlay .hud-btn.primary {
    background: rgba(0, 255, 204, 0.15);
    border-color: #00ffcc;
    color: #00ffcc;
    width: 60px; /* Slightly wider primary button */
}

#placement-overlay .hud-btn.secondary {
    background: rgba(255, 170, 0, 0.15);
    border-color: #ffaa00;
    color: #ffaa00;
}

#placement-overlay .hud-btn:hover {
    filter: brightness(1.2);
    transform: scale(1.05);
}

.hud-btn {
    border: none;
    color: #fff;
    cursor: pointer;
    width: 60px;
    height: 40px;
    transform: skewX(-20deg);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hud-btn .btn-content { transform: skewX(20deg); display: flex; } /* Unskew content */

.hud-btn.secondary {
    background: rgba(255, 170, 0, 0.2);
    border: 1px solid #ffaa00;
    color: #ffaa00;
}
.hud-btn.secondary:hover { background: rgba(255, 170, 0, 0.5); width: 65px; }

.hud-btn.primary {
    background: rgba(0, 255, 204, 0.2);
    border: 1px solid #00ffcc;
    color: #00ffcc;
    width: 80px;
}
.hud-btn.primary:hover { background: rgba(0, 255, 204, 0.5); transform: skewX(-20deg) scale(1.05); }

/* Sleek Boss Notification */
#boss-warning-overlay {
    position: fixed;
    top: 15%; /* Higher up so it doesn't block the view */
    left: -100%;
    width: 100%;
    height: 60px; /* Fixed, slim height */
    
    /* Cyberpunk Gradient: Transparent -> Black/Red -> Transparent */
    background: linear-gradient(90deg, 
        rgba(0,0,0,0) 0%, 
        rgba(20, 0, 5, 0.9) 20%, 
        rgba(20, 0, 5, 0.9) 80%, 
        rgba(0,0,0,0) 100%
    );
    
    /* Thin neon lines top and bottom */
    border-top: 1px solid rgba(255, 0, 85, 0.5);
    border-bottom: 1px solid rgba(255, 0, 85, 0.5);
    
    z-index: 5000;
    display: flex;
    align-items: center;
    justify-content: center;
    
    transition: left 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
    backdrop-filter: blur(4px);
    pointer-events: none; /* Let clicks pass through */
    visibility: hidden;
}

#boss-warning-overlay.active {
    left: 0;
    visibility: visible;
}

.boss-name {
    font-size: 32px; /* Much smaller than 48px */
    color: #fff;
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    letter-spacing: 4px;
    text-transform: uppercase;
    
    /* Clean Neon Glow */
    text-shadow: 
        0 0 5px rgba(255, 0, 85, 0.8),
        0 0 10px rgba(255, 0, 85, 0.4);
}

/* Target the first stat box (Money) */
#top-left-group .stat-box:nth-child(1) {
    color: #ffd700; /* Gold Icon */
}

/* Target the second stat box (HP) */
#top-left-group .stat-box:nth-child(2) {
    color: #ff0055; /* Neon Red Icon */
}

/* Ensure the numbers themselves stick to white */
.stat-box span {
    color: #fff;
    margin-left: 2px;
}