@import url('https://fonts.googleapis.com/css2?family=VT323&family=Share+Tech+Mono&display=swap');

:root {
    --term-green: #33ff00;
    --term-green-dim: #1a8000;
    --term-bg: #0a0e0a;
    /* Very dark green/black */
    --scanline-color: rgba(18, 16, 16, 0.5);
    --glitch-color: #ff00ff;
}

body {
    background-color: #000;
    color: var(--term-green);
    font-family: 'Share Tech Mono', monospace;
    overflow: hidden;
    /* Prevent scrolling for app-like feel */
    height: 100vh;
    width: 100vw;
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 20px;
    box-sizing: border-box;
}

/* TYPOGRAPHY OVERRIDES */
h1,
h2,
h3,
.retro-font {
    font-family: 'VT323', monospace;
    text-transform: uppercase;
}

/* BACKGROUND LAYER */
.bg-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    opacity: 0.3;
    /* Dim for readability */
    transition: background-image 1s ease-in-out;
    z-index: 0;
    filter: brightness(0.6) contrast(1.2);
}

/* MATRIX ANIMATION CANVAS */
#matrix-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    /* Above bg-layer, below crt-container */
    display: none;
    /* Hidden by default */
}

/* CRT EFFECT LAYER */
.crt-container {
    position: relative;
    width: 100%;
    height: calc(100% - 100px);
    max-width: 600px;
    /* Mobile-first limit */
    /* Removed background-color to let image show through */
    border: 1px solid var(--term-green-dim);
    box-shadow: 0 0 20px rgba(51, 255, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 10;
    opacity: 0.8;
    margin: 0 auto;
    padding-bottom: 0;
}

/* SCANLINES */
.crt-overlay {
    position: absolute;
    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: 50;
}

/* FLICKER ANIMATION */
@keyframes flicker {
    0% {
        opacity: 0.97;
    }

    5% {
        opacity: 0.95;
    }

    10% {
        opacity: 0.9;
    }

    15% {
        opacity: 0.95;
    }

    20% {
        opacity: 0.99;
    }

    100% {
        opacity: 0.95;
    }
}

.screen-flicker {
    animation: flicker 0.15s infinite;
}

/* TEXT GLOW */
.glow-text {
    text-shadow: 0 0 5px var(--term-green), 0 0 10px var(--term-green-dim);
}

/* UTILS */
.btn-retro {
    border: 2px solid var(--term-green);
    background: transparent;
    color: var(--term-green);
    padding: 0.5rem 1rem;
    cursor: pointer;
    transition: all 0.1s;
    text-transform: uppercase;
    font-family: 'VT323', monospace;
    font-size: 1.5rem;
    line-height: 1;
}

.btn-retro:active {
    background: var(--term-green);
    color: black;
}

.btn-retro:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    border-color: var(--term-green-dim);
}

/* Keypad Grid */
.keypad-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}

.keypad-grid.hex {
    grid-template-columns: repeat(4, 1fr);
}

.text-retro-yellow {
    color: #ccff00;
}

/* NEW INTRO SCREEN */
#intro-cover {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-image: url('assets/img/Back.png');
    background-size: cover;
    background-position: center;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: transform 0.8s cubic-bezier(0.77, 0, 0.175, 1);
}

#intro-cover.slide-up {
    transform: translateY(-100%);
}

.intro-content {
    background: rgba(0, 0, 0, 0.7);
    padding: 2rem;
    border: 2px solid var(--term-green);
    text-align: center;
    backdrop-filter: blur(5px);
}

/* MISSION MODAL */
#mission-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-image: url('assets/img/Genius.png');
    background-size: cover;
    background-position: center;
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    transform: translateY(-100%);
    transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

#mission-popup.active {
    transform: translateY(0);
}

.mission-content {
    background: rgba(0, 0, 0, 0.85);
    max-width: 500px;
    width: 90%;
    padding: 2rem;
    border: 2px solid var(--term-green);
    box-shadow: 0 0 30px var(--term-green-dim);
    font-family: 'Share Tech Mono', monospace;
    line-height: 1.6;
}

.mission-text {
    max-height: 60vh;
    overflow-y: auto;
    margin-bottom: 1.5rem;
    white-space: pre-wrap;
}

/* SEVER FAIL SCREEN */
#sever-fail-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-image: url('assets/img/Serve Con.png');
    background-size: cover;
    background-position: center;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transform: translateY(-100%);
    transition: transform 1s cubic-bezier(0.16, 1, 0.3, 1);
}

#sever-fail-screen.active {
    transform: translateY(0);
}

.sever-content {
    background: rgba(0, 0, 0, 0.7);
    padding: 2rem;
    border: 2px solid #ff0000;
    text-align: center;
    color: #ff0000;
    font-family: 'Share Tech Mono', monospace;
    box-shadow: 0 0 20px rgba(255, 0, 0, 0.5);
}

.btn-sever {
    background: transparent;
    border: 1px solid #ff0000;
    color: #ff0000;
    padding: 4px 12px;
    font-size: 10px;
    cursor: pointer;
    transition: all 0.3s;
    opacity: 0.5;
    pointer-events: none;
    text-transform: uppercase;
}

.btn-sever.active {
    opacity: 1;
    pointer-events: auto;
    box-shadow: 0 0 10px #ff0000;
    background: rgba(255, 0, 0, 0.1);
}

.btn-sever:hover {
    background: #ff0000;
    color: white;
}

/* SCROLLBAR CUSTOMIZATION */
.custom-scrollbar::-webkit-scrollbar {
    width: 10px;
}

.custom-scrollbar::-webkit-scrollbar-track {
    background: #000;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background: #33ff00;
    border: 1px solid #000;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: #1a8000;
}

/* FADE OUT ANIMATION */
.fade-out {
    animation: fadeOut 1s forwards;
    pointer-events: none;
}

@keyframes fadeOut {
    to {
        opacity: 0;
    }
}
