:root {
    --bg-color: #050505;
    --acc-green: #00ff41;
    --acc-red: #ff3333;
    --acc-yellow: #ffb800;
    --text-color: #e0e0e0;
    --font-main: 'Share Tech Mono', monospace;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-main);
    overflow: hidden;
    width: 100vw;
    height: 100vh;
}

#glcanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    display: block;
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none;
    /* Let clicks pass to canvas if needed */
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: rgba(5, 5, 5, 0.9);
    /* Solid dark background */
    transition: opacity 0.5s ease;
    pointer-events: auto;
}

.screen.hidden {
    opacity: 0;
    pointer-events: none;
}

.screen.active {
    opacity: 1;
}

/* Glitch Title */
.glitch-text {
    font-size: 4rem;
    font-weight: bold;
    color: var(--acc-red);
    text-shadow: 2px 2px 0px #0ff, -2px -2px 0px #f0f;
    position: relative;
    margin-bottom: 10px;
    letter-spacing: 2px;
}

.glitch-text::before,
.glitch-text::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent;
}

.glitch-text::before {
    left: 2px;
    text-shadow: -2px 0 red;
    clip: rect(24px, 550px, 90px, 0);
    animation: glitch-anim 3s infinite linear alternate-reverse;
}

.glitch-text::after {
    left: -2px;
    text-shadow: -2px 0 blue;
    clip: rect(85px, 550px, 140px, 0);
    animation: glitch-anim 2.5s infinite linear alternate-reverse;
}

@keyframes glitch-anim {
    0% {
        clip: rect(31px, 9999px, 94px, 0);
    }

    20% {
        clip: rect(62px, 9999px, 42px, 0);
    }

    40% {
        clip: rect(10px, 9999px, 50px, 0);
    }

    60% {
        clip: rect(89px, 9999px, 33px, 0);
    }

    80% {
        clip: rect(45px, 9999px, 98px, 0);
    }

    100% {
        clip: rect(23px, 9999px, 12px, 0);
    }
}

.subtitle {
    font-size: 1.2rem;
    color: var(--text-color);
    margin-bottom: 40px;
    opacity: 0.8;
}

.critical-text {
    font-size: 5rem;
    color: var(--acc-red);
    text-shadow: 0 0 20px rgba(255, 51, 51, 0.8);
    margin-bottom: 10px;
}

.instructions {
    background: rgba(255, 255, 255, 0.05);
    border-left: 4px solid var(--acc-yellow);
    padding: 20px;
    margin-bottom: 40px;
    font-size: 1.1rem;
    line-height: 1.8;
}

.instructions .key {
    background: #222;
    padding: 2px 8px;
    border: 1px solid #555;
    border-radius: 4px;
    color: var(--acc-yellow);
    font-weight: bold;
}

.warning {
    margin-top: 20px;
    font-size: 0.9rem;
    color: var(--acc-red);
    opacity: 0.7;
}

button {
    background: transparent;
    border: 2px solid var(--acc-green);
    color: var(--acc-green);
    font-family: var(--font-main);
    font-size: 1.5rem;
    padding: 15px 40px;
    cursor: pointer;
    transition: all 0.3s;
    text-transform: uppercase;
    letter-spacing: 2px;
    border-radius: 2px;
}

button:hover {
    background: var(--acc-green);
    color: #000;
    box-shadow: 0 0 20px rgba(0, 255, 65, 0.4);
}

#btn-start {
    border-color: var(--acc-green);
    color: var(--acc-green);
}

#btn-restart {
    border-color: var(--acc-red);
    color: var(--acc-red);
}

#btn-restart:hover {
    background: var(--acc-red);
    color: #000;
    box-shadow: 0 0 20px rgba(255, 51, 51, 0.4);
}

/* HUD Styling */
#game-hud {
    background: transparent;
    pointer-events: none;
    justify-content: space-between;
}

.hud-top {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: space-between;
    padding: 20px 40px;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.8) 0%, rgba(0, 0, 0, 0) 100%);
}

.stat-box {
    display: flex;
    flex-direction: column;
}

.stat-box .label {
    font-size: 0.8rem;
    color: #888;
    margin-bottom: 5px;
    letter-spacing: 1px;
}

.stat-box .value {
    font-size: 2rem;
    font-weight: bold;
    text-shadow: 0 0 10px currentColor;
}

.value.positive {
    color: var(--acc-green);
}

.value.negative {
    color: var(--acc-red);
    color: var(--acc-red);
}

/* Added for dynamic changing */
#val-portfolio {
    font-size: 2.5rem;
}

.warning-box {
    width: 300px;
}

.progress-bar-container {
    width: 100%;
    height: 12px;
    background: #222;
    border: 1px solid #444;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--acc-green);
    transition: width 0.1s linear, background-color 0.3s;
    box-shadow: 0 0 10px currentColor;
}

.hud-bottom {
    position: absolute;
    bottom: 20px;
    left: 20px;
}

.terminal-log {
    font-size: 0.9rem;
    color: var(--acc-green);
    opacity: 0.6;
}

#crosshair {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 24px;
    color: rgba(255, 255, 255, 0.3);
    font-weight: lighter;
}

.result-stats {
    margin-bottom: 30px;
    font-size: 1.5rem;
    color: #fff;
    text-align: center;
}

.result-stats span {
    color: var(--acc-yellow);
    font-weight: bold;
}

/* --- Mobile Responsiveness --- */
@media (max-width: 768px),
(orientation: portrait) {
    .glitch-text {
        font-size: 2.5rem;
    }

    .subtitle {
        font-size: 0.9rem;
        margin-bottom: 20px;
        text-align: center;
        padding: 0 10px;
    }

    .instructions {
        font-size: 0.9rem;
        padding: 15px;
        margin-bottom: 20px;
        width: 90%;
    }

    button {
        font-size: 1.2rem;
        padding: 12px 20px;
    }

    .hud-top {
        padding: 10px;
        flex-wrap: wrap;
    }

    .stat-box .value,
    #val-portfolio {
        font-size: 1.5rem;
    }

    .stat-box .label {
        font-size: 0.6rem;
    }

    .warning-box {
        width: 100%;
        margin-top: 10px;
        order: 3;
        /* Push progress bar to next line */
    }

    .hud-bottom {
        bottom: 10px;
        left: 10px;
    }

    .terminal-log {
        font-size: 0.8rem;
    }
}