:root {
    --primary-color: #00f3ff;
    --secondary-color: #ff0055;
    --bg-color: #050510;
    --ui-bg: rgba(0, 20, 40, 0.8);
    --text-color: #e0e0ff;
    --font-main: 'Rajdhani', sans-serif;
    --font-display: 'Orbitron', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-main);
    overflow: hidden;
    width: 100vw;
    height: 100vh;
}

#game-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

#game-ui {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 20px;
}

/* HUD Top */
#hud-top {
    display: flex;
    gap: 20px;
    width: 100%;
    max-width: 400px;
}

.stat-group {
    flex: 1;
}

.controls-top-right {
    display: flex;
    gap: 10px;
    align-items: center;
}

.icon-btn {
    background: transparent;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    width: 40px;
    height: 40px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s ease;
    pointer-events: auto;
}

.icon-btn:hover {
    background: rgba(0, 243, 255, 0.2);
    box-shadow: 0 0 10px var(--primary-color);
}

.label {
    font-size: 0.8rem;
    color: var(--primary-color);
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.bar-container {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--primary-color);
    position: relative;
    overflow: hidden;
}

.bar {
    height: 100%;
    width: 100%;
    background: var(--primary-color);
    box-shadow: 0 0 10px var(--primary-color);
    transition: width 0.2s ease-out;
}

#entropy-bar {
    background: var(--secondary-color);
    box-shadow: 0 0 10px var(--secondary-color);
}

/* HUD Dash */
#hud-dash {
    position: absolute;
    top: 80px;
    left: 20px;
    width: 200px;
}

.dash-indicators {
    display: flex;
    align-items: center;
    gap: 10px;
}

.dash-light {
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: #333;
    border: 1px solid #555;
    box-shadow: 0 0 5px rgba(0,0,0,0.5);
    transition: all 0.2s;
}

.dash-light.ready {
    background: var(--primary-color);
    box-shadow: 0 0 10px var(--primary-color);
    border-color: #fff;
}

#dash-bar-container {
    flex: 1;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid #555;
}

#dash-bar {
    height: 100%;
    width: 0%;
    background: var(--primary-color);
    transition: width 0.1s linear;
}

/* HUD Resources */
#hud-resources {
    position: absolute;
    bottom: 20px;
    left: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    font-family: var(--font-display);
}

.resource-display {
    font-size: 1.5rem;
    color: #fff;
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
    background: var(--ui-bg);
    padding: 5px 15px;
    border-left: 3px solid var(--primary-color);
}

/* HUD Buildings */
#hud-buildings {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 20px;
}

.build-option {
    background: var(--ui-bg);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 10px 20px;
    color: #888;
    font-family: var(--font-display);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 100px;
}

.build-option .key {
    font-size: 0.7rem;
    margin-bottom: 5px;
    border: 1px solid #555;
    padding: 2px 6px;
    border-radius: 3px;
}

.build-option .cost {
    font-size: 0.8rem;
    color: var(--secondary-color);
    margin-top: 5px;
}

.build-option.active {
    border-color: var(--primary-color);
    color: #fff;
    box-shadow: 0 0 15px rgba(0, 243, 255, 0.3);
    transform: translateY(-5px);
}

.build-option.active .key {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* HUD Evolution */
#hud-evolution {
    position: absolute;
    bottom: 20px;
    right: 20px;
    text-align: right;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

#evo-progress {
    width: 150px;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    margin: 5px 0;
    border: 1px solid var(--primary-color);
}

#evo-fill {
    height: 100%;
    width: 0%;
    background: var(--primary-color);
    box-shadow: 0 0 8px var(--primary-color);
    transition: width 0.5s ease;
}

#tier-display {
    font-family: var(--font-display);
    font-size: 1.2rem;
    color: var(--primary-color);
}

/* Screens */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(5, 5, 16, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    pointer-events: auto;
    backdrop-filter: blur(5px);
    transition: opacity 0.5s ease;
    z-index: 100;
}

#scanlines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        to bottom,
        rgba(255,255,255,0),
        rgba(255,255,255,0) 50%,
        rgba(0,0,0,0.2) 50%,
        rgba(0,0,0,0.2)
    );
    background-size: 100% 4px;
    pointer-events: none;
    z-index: 5;
    opacity: 0.6;
    animation: scanlineScroll 0.2s linear infinite;
}

@keyframes scanlineScroll {
    0% { background-position: 0 0; }
    100% { background-position: 0 4px; }
}

/* High Entropy / Glitch Effects */
body.critical-entropy #game-canvas {
    animation: rgbSplit 0.2s infinite;
}

body.critical-entropy #game-ui {
    text-shadow: 2px 0 #f00, -2px 0 #0ff;
}

@keyframes rgbSplit {
    0% { transform: translate(0); filter: drop-shadow(2px 0 rgba(255,0,0,0.5)) drop-shadow(-2px 0 rgba(0,255,255,0.5)); }
    25% { transform: translate(-2px, 2px); filter: drop-shadow(-2px 0 rgba(255,0,0,0.5)) drop-shadow(2px 0 rgba(0,255,255,0.5)); }
    50% { transform: translate(2px, -2px); filter: drop-shadow(2px 0 rgba(255,0,0,0.5)) drop-shadow(-2px 0 rgba(0,255,255,0.5)); }
    75% { transform: translate(-2px, -2px); filter: drop-shadow(-2px 0 rgba(255,0,0,0.5)) drop-shadow(2px 0 rgba(0,255,255,0.5)); }
    100% { transform: translate(0); filter: drop-shadow(2px 0 rgba(255,0,0,0.5)) drop-shadow(-2px 0 rgba(0,255,255,0.5)); }
}

#vignette {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(0,0,0,0) 60%, rgba(0,0,0,0.8) 100%);
    pointer-events: none;
    z-index: 6;
    transition: all 0.5s ease;
}

#vignette.in-void {
    background: radial-gradient(circle, rgba(0,0,0,0) 20%, rgba(255, 0, 85, 0.5) 100%);
    animation: voidPulse 1s infinite alternate;
}

@keyframes voidPulse {
    0% { transform: scale(1); }
    100% { transform: scale(1.05); }
}

.hidden {
    opacity: 0;
    pointer-events: none;
    display: none;
}

.active {
    opacity: 1;
    display: flex;
}

h1.glitch {
    font-family: var(--font-display);
    font-size: 4rem;
    color: #fff;
    text-transform: uppercase;
    position: relative;
    text-shadow: 2px 2px var(--secondary-color), -2px -2px var(--primary-color);
    animation: glitch 1s infinite alternate;
}

.subtitle {
    font-size: 1.5rem;
    color: var(--primary-color);
    margin-bottom: 20px;
    letter-spacing: 5px;
}

.cyber-btn {
    background: transparent;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
    padding: 15px 40px;
    font-family: var(--font-display);
    font-size: 1.2rem;
    cursor: pointer;
    margin-top: 30px;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 2px;
    box-shadow: 0 0 10px rgba(0, 243, 255, 0.2);
    animation: btnPulse 2s infinite;
}

.cyber-btn:hover {
    background: var(--primary-color);
    color: #000;
    box-shadow: 0 0 20px rgba(0, 243, 255, 0.8);
    animation: none;
}

@keyframes btnPulse {
    0% { box-shadow: 0 0 10px rgba(0, 243, 255, 0.2); }
    50% { box-shadow: 0 0 20px rgba(0, 243, 255, 0.5), inset 0 0 10px rgba(0, 243, 255, 0.1); }
    100% { box-shadow: 0 0 10px rgba(0, 243, 255, 0.2); }
}

.high-score-label {
    font-family: var(--font-display);
    font-size: 1.5rem;
    color: var(--secondary-color);
    margin: 10px 0;
    text-shadow: 0 0 5px var(--secondary-color);
    letter-spacing: 2px;
}

.instructions {
    margin-top: 30px;
    text-align: center;
    color: #888;
    line-height: 1.6;
}

/* Mobile Controls */
#mobile-controls {
    display: none;
    position: absolute;
    bottom: 30px;
    right: 20px;
    gap: 20px;
    pointer-events: auto;
}

.mobile-action-btn {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: rgba(0, 243, 255, 0.1);
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
    font-family: var(--font-display);
    font-weight: bold;
    font-size: 0.9rem;
    backdrop-filter: blur(4px);
    touch-action: manipulation;
}

.mobile-action-btn:active {
    background: var(--primary-color);
    color: #000;
}

/* Animations */
@keyframes glitch {
    0% { transform: translate(0) }
    20% { transform: translate(-2px, 2px) }
    40% { transform: translate(-2px, -2px) }
    60% { transform: translate(2px, 2px) }
    80% { transform: translate(2px, -2px) }
    100% { transform: translate(0) }
}

@media (max-width: 768px) {
    #mobile-controls {
        display: flex;
    }
    
    .instructions {
        font-size: 0.8rem;
    }
    
    h1.glitch {
        font-size: 2.5rem;
    }

    /* Reposition HUD for Mobile */
    #hud-resources {
        bottom: auto;
        top: 80px;
        left: 20px;
        flex-direction: row;
    }

    #hud-evolution {
        bottom: auto;
        top: 20px;
        right: 20px;
        align-items: flex-end;
    }

    #hud-buildings {
        bottom: 120px; /* Move up to clear thumbs */
        width: 100%;
        justify-content: center;
        gap: 10px;
    }

    .build-option {
        min-width: 70px;
        padding: 5px 10px;
        font-size: 0.8rem;
    }

    #hud-dash {
        top: 130px;
    }
    
    #hud-top {
        max-width: 60%; /* Make room for evolution on right */
    }
}
