:root {
    --phosphor-main: #33ff00;
    --phosphor-dim: #1a8000;
    --bg-color: #051005;
    --scanline-color: rgba(0, 0, 0, 0.5);
    --glitch-color: #0ff;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
}

body {
    background-color: #000;
    color: var(--phosphor-main);
    font-family: 'VT323', monospace;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    text-shadow: 0 0 5px var(--phosphor-dim), 0 0 10px var(--phosphor-main);
}

/* CRT Effects */
.crt-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.6) 100%),
        linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%),
        linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
    background-size: 100% 2px, 3px 100%;
    pointer-events: none;
    z-index: 100;
}

.scanline {
    width: 100%;
    height: 10px;
    background: rgba(51, 255, 0, 0.1);
    position: fixed;
    z-index: 101;
    top: 0;
    left: 0;
    animation: scanline 6s linear infinite;
    pointer-events: none;
}

@keyframes scanline {
    0% {
        top: -10%;
    }

    100% {
        top: 110%;
    }
}

#terminal {
    width: 90%;
    height: 90%;
    border: 2px solid var(--phosphor-dim);
    padding: 2rem;
    position: relative;
    box-shadow: 0 0 20px var(--phosphor-dim) inset;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.screen {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: absolute;
    top: 0;
    left: 0;
}

.hidden {
    display: none !important;
}

/* Typography & Animations */
h1 {
    font-size: 4rem;
    letter-spacing: 0.5rem;
    margin-bottom: 2rem;
    text-transform: uppercase;
}

p {
    font-size: 1.5rem;
    font-family: 'Share Tech Mono', monospace;
}

.blink {
    animation: blink 1s step-end infinite;
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

/* Intro & Oscilloscope */
#intro-screen {
    background: #000;
    z-index: 50;
}

#oscilloscope {
    width: 100%;
    height: 100%;
}

.overlay-text {
    position: absolute;
    bottom: 20%;
    font-size: 1.5rem;
    letter-spacing: 0.2rem;
}

/* Noise Overlay */
#noise-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 200;
    opacity: 0;
    background-image: url('data:image/svg+xml;utf8,%3Csvg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg"%3E%3Cfilter id="noiseFilter"%3E%3CfeTurbulence type="fractalNoise" baseFrequency="0.65" numOctaves="3" stitchTiles="stitch"/%3E%3C/filter%3E%3Crect width="100%25" height="100%25" filter="url(%23noiseFilter)" opacity="1"/%3E%3C/svg%3E');
}

.noise-active {
    opacity: 0.5 !important;
    animation: noise-anim 0.2s steps(4) infinite;
}

@keyframes noise-anim {
    0% {
        transform: translate(0, 0)
    }

    10% {
        transform: translate(-5%, -5%)
    }

    20% {
        transform: translate(-10%, 5%)
    }

    30% {
        transform: translate(5%, -10%)
    }

    40% {
        transform: translate(-5%, 15%)
    }

    50% {
        transform: translate(-10%, 5%)
    }

    60% {
        transform: translate(15%, 0)
    }

    70% {
        transform: translate(0, 10%)
    }
}

/* Drawing Screen */
.shuffling-text {
    font-size: 2rem;
    margin-bottom: 2rem;
}

.card-cycle {
    font-size: 3rem;
    font-weight: bold;
    min-height: 4rem;
}

/* Result Screen */
#result-screen {
    z-index: 2000;
    /* Ensure on top for clicking */
    cursor: pointer;
    background: rgba(0, 0, 0, 0.85);
    /* Slightly darker backing */
}

.card-display {
    border: 2px solid var(--phosphor-main);
    padding: 2rem;
    max-width: 600px;
    background: rgba(0, 20, 0, 0.8);
    box-shadow: 10px 10px 0 var(--phosphor-dim);
    pointer-events: none;
    /* Let clicks pass through to screen container if needed, or just let them bubble */
}

#card-name {
    font-size: 3rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--phosphor-dim);
    padding-bottom: 0.5rem;
}

#card-visual {
    font-size: 5rem;
    /* Placeholder for visual */
    margin: 2rem 0;
}

.small-text {
    font-size: 1rem;
    margin-top: 2rem;
    opacity: 0.8;
}

/* Glitch Effects */
.glitch-active {
    animation: glitch-anim 0.2s infinite;
}

.glitch-text {
    position: relative;
}

.glitch-text::before,
.glitch-text::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
}

.glitch-text::before {
    left: 2px;
    text-shadow: -1px 0 red;
    clip: rect(24px, 550px, 90px, 0);
    animation: glitch-anim-2 3s infinite linear alternate-reverse;
}

.glitch-text::after {
    left: -2px;
    text-shadow: -1px 0 blue;
    clip: rect(85px, 550px, 140px, 0);
    animation: glitch-anim-2 2s infinite linear alternate-reverse;
}

@keyframes glitch-anim {
    0% {
        transform: translate(0)
    }

    20% {
        transform: translate(-5px, 5px)
    }

    40% {
        transform: translate(-5px, -5px)
    }

    60% {
        transform: translate(5px, 5px)
    }

    80% {
        transform: translate(5px, -5px)
    }

    100% {
        transform: translate(0)
    }
}

@keyframes glitch-anim-2 {
    0% {
        clip: rect(65px, 9999px, 119px, 0);
    }

    20% {
        clip: rect(28px, 9999px, 15px, 0);
    }

    40% {
        clip: rect(45px, 9999px, 86px, 0);
    }

    60% {
        clip: rect(12px, 9999px, 145px, 0);
    }

    80% {
        clip: rect(98px, 9999px, 5px, 0);
    }

    100% {
        clip: rect(34px, 9999px, 62px, 0);
    }
}

#card-visual img {
    max-height: 350px;
    width: auto;
    display: block;
    margin: 0 auto;
    box-shadow: 0 0 15px var(--phosphor-dim);
}

/* Responsive */
@media (max-width: 768px) {
    h1 {
        font-size: 2.5rem;
    }

    #terminal {
        width: 100%;
        height: 100%;
        border: none;
    }

    .card-display {
        width: 100%;
    }

    #card-visual img {
        max-height: 200px;
        width: auto;
    }
}

/* Interrogation Screen */
#interrogation-screen {
    z-index: 60;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 2rem;
}

#user-input {
    background: transparent;
    border: none;
    border-bottom: 2px solid var(--phosphor-main);
    color: var(--phosphor-main);
    font-family: 'VT323', monospace;
    font-size: 2rem;
    width: 80%;
    text-align: center;
    outline: none;
    text-transform: uppercase;
    caret-color: var(--phosphor-main);
}

/* Possessed Effects */
.invert-effect {
    filter: invert(1) hue-rotate(180deg);
}

.shake-effect {
    animation: shake 0.5s cubic-bezier(.36, .07, .19, .97) both;
    transform: translate3d(0, 0, 0);
}

@keyframes shake {

    10%,
    90% {
        transform: translate3d(-2px, 0, 0);
    }

    20%,
    80% {
        transform: translate3d(4px, 0, 0);
    }

    30%,
    50%,
    70% {
        transform: translate3d(-8px, 0, 0);
    }

    40%,
    60% {
        transform: translate3d(8px, 0, 0);
    }
}

.subliminal-text {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 10rem;
    color: red;
    z-index: 9999;
    opacity: 0.9;
    pointer-events: none;
    font-weight: bold;
    text-shadow: 0 0 20px red, 0 0 40px darkred;
    mix-blend-mode: difference;
    white-space: nowrap;
}

/* Slot Machine Layout */
.slots-container {
    display: flex;
    justify-content: center;
    gap: 2rem;
    width: 100%;
    max-width: 1000px;
}

@keyframes fadeIn {
    to {
        opacity: 1;
    }
}

.card-slot {
    width: 200px;
    height: 350px;
    border: 2px solid var(--phosphor-dim);
    box-shadow: 0 0 10px var(--phosphor-dim) inset;
    display: flex;
    justify-content: center;
    align-items: center;
}

.card-slot img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* Horizontal Result Layout Update */
.result-card-minimal {
    border: 2px solid var(--phosphor-main);
    padding: 0.5rem;
    background: rgba(0, 20, 0, 0.8);
    box-shadow: 0 0 10px var(--phosphor-dim);
    width: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    opacity: 0;
    animation: fadeIn 0.5s forwards;
    flex-shrink: 1;
    margin: 0 10px;
}

.result-card-minimal h2 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid var(--phosphor-dim);
    width: 100%;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.result-card-minimal img {
    max-height: 200px;
    width: auto;
    max-width: 100%;
    box-shadow: 0 0 5px var(--phosphor-dim);
}

/* Ensure container doesn't wrap and centers content */
.results-container {
    display: flex;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    justify-content: center;
    align-items: center;
    width: 100%;
    max-width: 1200px;
    overflow-x: auto;
    padding-bottom: 1rem;
    gap: 1rem;
}

/* Prophecy Text Container */
#prophecy-container {
    margin-top: 2rem;
    max-width: 800px;
    padding: 1rem;
    border: 1px dashed var(--phosphor-dim);
    background: rgba(0, 0, 0, 0.5);
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 90%;
}

#prophecy-text {
    font-size: 1.2rem;
    text-align: center;
    line-height: 1.6;
    color: #fff;
    text-shadow: 0 0 5px var(--phosphor-main);
}

/* Mobile Adjustments for Horizontal constraint */
@media (max-width: 768px) {
    .slots-container {
        gap: 0.5rem;
        width: 100%;
    }

    .card-slot {
        width: 30%;
        height: auto;
        aspect-ratio: 2/3.5;
    }

    .results-container {
        justify-content: center;
        width: 100%;
        gap: 0.2rem;
    }

    .result-card-minimal {
        width: 32%;
        min-width: 0;
        padding: 0.2rem;
        margin: 0;
    }

    .result-card-minimal h2 {
        font-size: 0.6rem;
    }

    .result-card-minimal img {
        max-height: 100px;
    }

    #prophecy-text {
        font-size: 0.9rem;
    }

    #prophecy-container {
        margin-top: 1rem;
        padding: 0.5rem;
    }
}