/* ===== BASE STYLES ===== */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background-color: #0e0c2d;
    font-family: 'VT323', monospace;
    color: #D0F0FF;
    padding: 2rem;
    text-align: center;
}

/* ===== GLITCH TITLE ===== */
.glitch-text {
    position: relative;
    color: #FF77E9;
    font-size: 2.4rem;
    text-align: center;
    text-shadow: 0 0 2px #FF77E9, 0 0 4px #FF77E9, 0 0 6px #39FF14;
    animation: glitch-flicker 2.5s infinite alternate;
}

.glitch-text::before,
.glitch-text::after {
    content: attr(data-text);
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    pointer-events: none;
    opacity: 0.7;
    clip: rect(0, 0, 0, 0);
}

.glitch-text::before {
    color: #7DF9FF;
    animation: glitchTop 2.5s infinite linear alternate-reverse;
}

.glitch-text::after {
    color: #FF5588;
    animation: glitchBottom 2.5s infinite linear alternate;
}

@keyframes glitch-flicker {
    0%, 100% {
        transform: none;
        opacity: 1;
    }
    15% {
        transform: translate(-1px, 1px);
        opacity: 0.85;
    }
    30% {
        transform: translate(1px, -1px);
        opacity: 0.8;
    }
    45% {
        transform: translate(-1px, -1px);
        opacity: 0.95;
    }
    60% {
        transform: translate(1px, 1px);
        opacity: 0.88;
    }
}

@keyframes glitchTop {
    0% {
        clip: rect(0, 9999px, 0, 0);
    }
    10% {
        clip: rect(0, 9999px, 20px, 0);
        transform: translate(2px, -2px);
    }
    40% {
        clip: rect(10px, 9999px, 30px, 0);
        transform: translate(-1px, 1px);
    }
    60%, 100% {
        clip: rect(0, 9999px, 0, 0);
        transform: none;
    }
}

@keyframes glitchBottom {
    0% {
        clip: rect(0, 9999px, 0, 0);
    }
    10% {
        clip: rect(20px, 9999px, 40px, 0);
        transform: translate(-2px, 1px);
    }
    40% {
        clip: rect(5px, 9999px, 25px, 0);
        transform: translate(1px, -1px);
    }
    60%, 100% {
        clip: rect(0, 9999px, 0, 0);
        transform: none;
    }
}

/* ===== TYPEWRITER & TEXT LINES ===== */
#typewriter-box {
    margin-top: 1.5rem;
}

.typewriter-line {
    font-size: 1.2rem;
    color: #D0F0FF;
    margin: 0.5rem auto;
    display: inline-block;
}

.typewriter-line::after {
    content: "▍";
    animation: blink 1s step-start infinite;
    margin-left: 2px;
}

@keyframes blink {
    50% {
        opacity: 0;
    }
}

/* ===== PORYGON SPRITE ===== */
.porygon-pixel {
    image-rendering: pixelated;
    width: 64px;
    height: 64px;
    display: block;
    margin: 1rem auto;
    filter: drop-shadow(0 0 3px #7DF9FF);
    animation: float 2.5s ease-in-out infinite;
}

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

/* ===== SPEECH + INPUT ===== */
.porygon-speech {
    color: #7DF9FF;
    background-color: #14122f;
    padding: 0.5rem 1rem;
    border: 1px solid #7DF9FF;
    border-radius: 8px;
    margin-top: 0.5rem;
    font-size: 1rem;
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
    box-shadow: 0 0 6px rgba(125, 249, 255, 0.4);
}

.access-input {
    background: #101a12;
    border: none;
    border-bottom: 1px solid #39FF14;
    color: #39FF14;
    font-family: 'VT323', monospace;
    font-size: 1.2rem;
    text-shadow: 0 0 4px #39FF14;
    padding: 0.3rem;
    width: 250px;
}

/* ===== CURSOR + BUTTON ===== */
.blinking-cursor {
    font-weight: bold;
    font-size: 1.2em;
    color: #7DF9FF;
    animation: blink 1s step-start infinite;
}

.login-btn {
    font-size: 1.2rem;
    background-color: #101a12;
    border: 1px solid #39FF14;
    color: #39FF14;
    padding: 0.4rem 1.6rem;
    margin-top: 1rem;
    cursor: pointer;
    transition: all 0.3s ease-in-out;
    box-shadow: 0 0 6px #39FF14;
    text-shadow: 0 0 3px #39FF14;
    letter-spacing: 0.08em;
}

.login-btn:hover {
    background-color: #1a2a18;
    box-shadow: 0 0 10px #39FF14;
}

/* ===== ERROR + UNOWN GLITCH ===== */
#error-msg {
    color: #FF5588;
    text-shadow: 0 0 3px #FF5588;
    visibility: hidden;
    margin-top: 1rem;
}

.unown-reveal {
    display: none;
    width: auto;
    max-width: 90%;
    margin: 2rem auto;
    animation: glitchFade 1s ease-in-out forwards;
    filter: drop-shadow(0 0 4px #39F);
    image-rendering: pixelated;
}

@keyframes glitchFade {
    0% {
        opacity: 1;
        transform: scale(1);
    }
    20% {
        opacity: 0.9;
        transform: scale(1.02);
    }
    40% {
        opacity: 1;
        transform: scale(0.98);
    }
    60% {
        opacity: 0.85;
        transform: scale(1.04);
    }
    100% {
        opacity: 0;
        transform: scale(1);
    }
}

/* ===== CRT MOON EFFECT ===== */
.crt-moon {
    position: relative;
    background: rgba(0, 0, 0, 0.72);
    border: 1px solid rgba(245, 242, 232, 0.30);
    box-shadow: 0 0 18px rgba(245, 242, 232, 0.22),
    inset 0 0 30px rgba(0, 0, 0, 0.92);
    overflow: hidden;
    color: #f5f2e8;
}

/* Scanlines + phosphor mask */
.crt-moon::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 2;
    background: linear-gradient(
            rgba(0, 0, 0, 0) 50%,
            rgba(0, 0, 0, 0.22) 50%
    ),
    linear-gradient(
            90deg,
            rgba(255, 170, 150, 0.055),
            rgba(255, 250, 220, 0.040),
            rgba(180, 205, 255, 0.055)
    );
    background-size: 100% 2px, 3px 100%;
    opacity: 0.62;
    mix-blend-mode: overlay;
}

/* Vignette + gentle flicker */
.crt-moon::after {
    content: "";
    position: absolute;
    inset: -2px;
    pointer-events: none;
    z-index: 3;
    background: radial-gradient(circle at center,
    rgba(0, 0, 0, 0) 45%,
    rgba(0, 0, 0, 0.36) 78%,
    rgba(0, 0, 0, 0.74) 100%
    );
    opacity: 0.42;
    animation: crtFlicker 6.5s infinite;
}

@keyframes crtFlicker {
    0%, 100% {
        filter: brightness(1) contrast(1);
    }
    50% {
        filter: brightness(1.03) contrast(1.02);
    }
}

/* Keep content above overlays */
.crt-moon > * {
    position: relative;
    z-index: 4;
}

/* Breathing resonance line */
@keyframes tide {
    0% {
        opacity: 0.45;
        text-shadow: 0 0 4px rgba(245, 242, 232, 0.12);
    }
    50% {
        opacity: 1;
        text-shadow: 0 0 12px rgba(245, 242, 232, 0.55);
    }
    100% {
        opacity: 0.45;
        text-shadow: 0 0 4px rgba(245, 242, 232, 0.12);
    }
}

.resonance {
    animation: tide 7.2s ease-in-out infinite;
}

/* ===== MOON-WASHED VARIANT ===== */
.crt-moon.lost {
    background: rgba(10, 10, 10, 0.55);
    border-color: rgba(255, 255, 255, 0.45);
    box-shadow: 0 0 22px rgba(255, 255, 255, 0.35),
    inset 0 0 26px rgba(0, 0, 0, 0.85);
    color: #ffffff;
}

/* Brighter phosphor for lost fragment */
.crt-moon.lost::before {
    opacity: 0.78;
    background: linear-gradient(
            rgba(255, 255, 255, 0.05) 50%,
            rgba(0, 0, 0, 0.18) 50%
    ),
    linear-gradient(
            90deg,
            rgba(255, 255, 255, 0.10),
            rgba(255, 255, 255, 0.05),
            rgba(255, 255, 255, 0.10)
    );
}

/* Slightly stronger bloom, slower flicker */
.crt-moon.lost::after {
    opacity: 0.55;
    animation-duration: 8s;
}

/* ===== RESPONSIVE ADJUST ===== */
@media (max-width: 480px) {
    .access-input,
    .login-btn {
        width: 80%;
        font-size: 1rem;
    }
}

/* ===== ACCESSIBILITY ===== */
@media (prefers-reduced-motion: reduce) {
    .crt-moon::after {
        animation: none !important;
    }

    .resonance {
        animation: none !important;
    }
}