:root {
    /* Google Terminal Theme */
    --bg-color: #202124;
    /* Google Dark Mode Background */
    --text-color: #e8eaed;
    --sub-color: #9aa0a6;
    --accent-color: #4285F4;
    /* Google Blue */
    --prompt-user: #0F9D58;
    /* Google Green */
    --prompt-path: #F4B400;
    /* Google Yellow */
    --cmd-color: #e8eaed;
    /* White/Grey */
    --link-color: #8ab4f8;
    /* Link Blue */
    --error-color: #ea4335;
    /* Google Red */

    /* Google Brand Colors for Header */
    --c-blue: #4285F4;
    --c-red: #DB4437;
    --c-yellow: #F4B400;
    --c-green: #0F9D58;

    /* Config */
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    --font-size: 16px;
    --line-height: 1.5;
    --terminal-padding: 20px;
}

/* --- THEMES --- */

/* Hacker Theme (Matrix Green) */
body.theme-hacker {
    --bg-color: #0d0208;
    --text-color: #00ff41;
    --sub-color: #008F11;
    --accent-color: #00ff41;
    --prompt-user: #00db00;
    --prompt-path: #008F11;
    --cmd-color: #00ff41;
    --link-color: #00ff41;
    --error-color: #ff0000;

    --c-blue: #003b00;
    --c-red: #008F11;
    --c-yellow: #00ff41;
    --c-green: #00db00;
}

/* Retro Theme (Amber/Phosphor) */
body.theme-retro {
    --bg-color: #1a1002;
    /* Very dark amber/brown */
    --text-color: #ffb000;
    --sub-color: #cc8800;
    --accent-color: #ffb000;
    --prompt-user: #ffcc00;
    --prompt-path: #cc8800;
    --cmd-color: #ffb000;
    --link-color: #ffd700;
    --error-color: #ff3300;

    --c-blue: #995500;
    --c-red: #cc6600;
    --c-yellow: #ffb000;
    --c-green: #ffcc00;
}

/* ... existing styles ... */

/* Prompt Line */
.prompt-line {
    display: flex;
    flex-wrap: wrap;
    margin-top: 5px;
    align-items: center;
    position: relative;
}

.prompt-text {
    white-space: pre;
    margin-right: 0;
}

.user {
    color: var(--prompt-user);
    font-weight: bold;
}

.host {
    color: var(--prompt-user);
}

.path {
    color: var(--prompt-path);
    font-weight: bold;
}

/* The visible command text */
#cmd-display {
    color: var(--cmd-color);
    white-space: pre-wrap;
    word-break: break-all;
    min-height: 24px;
    display: inline-block;
}

/* The mobile top bar is handled outside #terminal */
#mobile-top-bar {
    display: none;
    height: 45px;
    /* Slightly taller for better touch targets/visibility */
    background: #202124;
    /* Solid background matches terminal */
    align-items: center;
    padding: 0 15px;
    border-bottom: 2px solid var(--accent-color);
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1001;
    /* Above CRT effects (z-index: 10) */
}


#mobile-top-bar .dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 6px;
}

#mobile-top-bar .red {
    background: #ff5f56;
}

#mobile-top-bar .yellow {
    background: #ffbd2e;
}

#mobile-top-bar .green {
    background: #27c93f;
}

#mobile-top-bar .top-bar-title {
    margin-left: 15px;
    font-size: 12px;
    color: var(--sub-color);
    font-family: var(--font-mono);
}


/* Hidden Input (keeps focus/events) */
#cmd-input {
    position: absolute;
    opacity: 0;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
    cursor: text;
}

/* Custom Block Cursor */
.cursor-block {
    display: inline-block;
    width: 10px;
    height: 1.2em;
    background-color: var(--accent-color);
    /* Blue Cursor */
    animation: blink 1s step-end infinite;
    vertical-align: text-bottom;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-mono);
    font-size: var(--font-size);
    line-height: var(--line-height);
    overflow: hidden;
    /* Prevent body scroll, handle in #terminal */
    height: 100vh;
    width: 100vw;
}

/* CRT Effects */
body::before {
    content: " ";
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%,
            rgba(0, 0, 0, 0.25) 50%);
    background-size: 100% 4px;
    /* Scanlines */
    z-index: 2000;
    pointer-events: none;
}

body::after {
    content: " ";
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: radial-gradient(circle,
            rgba(0, 0, 0, 0) 60%,
            rgba(0, 0, 0, 0.4) 100%);
    /* Vignette */
    z-index: 2000;
    pointer-events: none;
}

/* Terminal Container */
#terminal {
    width: 100%;
    height: 100%;
    padding: var(--terminal-padding);
    overflow-y: auto;
    /* Scroll inside here */
    overflow-x: hidden;
    position: relative;
    z-index: 1;
    /* Below CRT effects */
    text-shadow: 0 0 2px rgba(255, 255, 255, 0.1);
}

/* Scrollbar styling */
#terminal::-webkit-scrollbar {
    width: 8px;
}

#terminal::-webkit-scrollbar-track {
    background: var(--bg-color);
}

#terminal::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 4px;
}

/* Typographic Elements */
a {
    color: var(--link-color);
    text-decoration: none;
    border-bottom: 1px dotted var(--sub-color);
}

a:hover {
    background: var(--sub-color);
    color: var(--bg-color);
}

.hidden {
    display: none;
}

.dim {
    color: var(--sub-color);
}

.accent {
    color: var(--accent-color);
    font-weight: bold;
}

/* Prompt Line */
.prompt-line {
    display: flex;
    flex-wrap: wrap;
    margin-top: 5px;
    align-items: center;
    /* Align input with text */
    min-height: 24px;
    /* Ensure height for blocks */
}

.prompt-text {
    white-space: pre;
    /* Ensure spaces are preserved */
    margin-right: 8px;
}

.user {
    color: var(--prompt-user);
    font-weight: bold;
}

.host {
    color: var(--prompt-user);
}

.path {
    color: var(--prompt-path);
    font-weight: bold;
}

.branch {
    color: var(--sub-color);
}

/* Input Handling */
#cmd-input {
    background: transparent;
    border: none;
    color: var(--cmd-color);
    font-family: inherit;
    font-size: inherit;
    flex-grow: 1;
    outline: none;
    caret-color: transparent;
    /* Custom block cursor */
    padding: 0;
    margin: 0;
}

/* Custom Block Cursor */
.cursor-block {
    display: inline-block;
    width: 10px;
    height: 1.2em;
    background-color: var(--cmd-color);
    animation: blink 1s step-end infinite;
    vertical-align: text-bottom;
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

/* Output Layouts */
.ls-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 10px;
    margin: 10px 0;
}

.file-item a {
    margin-left: 10px;
    color: var(--text-color);
}

.file-item span {
    font-family: monospace;
}

.dir {
    color: var(--prompt-path);
}

.exe {
    color: var(--accent-color);
}

.clickable {
    cursor: pointer;
}

.clickable:hover {
    text-decoration: underline;
}

/* ASCII Art Header */
.ascii-art {
    color: var(--accent-color);
    font-weight: bold;
    font-size: 10px;
    /* Adjust for responsiveness */
    line-height: 10px;
    margin-bottom: 20px;
    white-space: pre;
    overflow-x: hidden;
}

/* Color Utilities */
.c-blue {
    color: var(--c-blue);
}

.c-red {
    color: var(--c-red);
}

.c-yellow {
    color: var(--c-yellow);
}

.c-green {
    color: var(--c-green);
}



@media (min-width: 800px) {
    .ascii-art {
        font-size: 14px;
        line-height: 14px;
    }
}

/* Easter Eggs */
/* Matrix Mode */
body.matrix-mode {
    --bg-color: #000000;
    --text-color: #00FF00;
    --sub-color: #008F11;
    --accent-color: #00FF41;
    --prompt-user: #00FF00;
    --prompt-path: #008F11;
    --cmd-color: #00FF41;
    --link-color: #00FF00;
    --error-color: #FF0000;

    /* Override Header Colors to Matrix Green */
    --c-blue: #00FF00;
    --c-red: #00FF00;
    --c-yellow: #00FF41;
    /* Slight variation for texture */
    --c-green: #008F11;
}

body.matrix-mode::before {
    background: linear-gradient(rgba(0, 50, 0, 0) 50%, rgba(0, 255, 0, 0.1) 50%);
    background-size: 100% 4px;
}

/* King Kong Shake */
@keyframes shake {
    0% {
        transform: translate(1px, 1px) rotate(0deg);
    }

    10% {
        transform: translate(-1px, -2px) rotate(-1deg);
    }

    20% {
        transform: translate(-3px, 0px) rotate(1deg);
    }

    30% {
        transform: translate(3px, 2px) rotate(0deg);
    }

    40% {
        transform: translate(1px, -1px) rotate(1deg);
    }

    50% {
        transform: translate(-1px, 2px) rotate(-1deg);
    }

    60% {
        transform: translate(-3px, 1px) rotate(0deg);
    }

    70% {
        transform: translate(3px, 1px) rotate(-1deg);
    }

    80% {
        transform: translate(-1px, -1px) rotate(1deg);
    }

    90% {
        transform: translate(1px, 2px) rotate(0deg);
    }

    100% {
        transform: translate(1px, -2px) rotate(-1deg);
    }
}

.shake {
    animation: shake 0.5s;
    animation-iteration-count: infinite;
}

/* Mobile Controls */
#mobile-controls {
    display: flex;
    justify-content: space-between;
    width: 100%;
    max-width: 600px;
    /* Match canvas width */
    margin-top: 10px;
    margin-bottom: 20px;
}

#mobile-controls button {
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid var(--accent-color);
    color: var(--accent-color);
    font-family: var(--font-mono);
    font-size: 20px;
    padding: 15px 30px;
    border-radius: 8px;
    cursor: pointer;
    touch-action: manipulation;
    box-shadow: 0 0 10px rgba(66, 133, 244, 0.3);
    /* Soft blue glow */
    transition: all 0.1s ease;
}

#mobile-controls button:active {
    background: var(--accent-color);
    color: var(--bg-color);
    box-shadow: 0 0 20px var(--accent-color);
    transform: scale(0.95);
}

#mobile-controls.hidden {
    display: none;
}

/* Mobile Responsive Adjustments */
@media (max-width: 600px) {
    :root {
        --terminal-padding: 15px;
        --font-size: 14px;
    }

    #mobile-top-bar {
        display: none;
    }

    #terminal {
        margin-top: 0;
        height: 100vh;
        padding-top: 15px;
    }

    .ascii-art {
        display: block;
        font-size: 6px;
        line-height: 6px;
        width: 100%;
        overflow-x: hidden;
    }

    #game-canvas {
        width: 100% !important;
        height: auto !important;
    }

    #mobile-controls button {
        padding: 10px 15px;
        font-size: 16px;
    }

    /* Stack items if needed */
    .ls-grid {
        grid-template-columns: 1fr;
    }
}