/* Google Fonts Import */
@import url('https://fonts.googleapis.com/css2?family=Black+Han+Sans&family=Do+Hyeon&family=Press+Start+2P&display=swap');

html,
body {
    height: 100%;
    margin: 0;
    overflow: hidden;
    /* background-color: #050011;  Removed to show #game-bg */
    font-family: 'Do Hyeon', sans-serif;
    color: #fff;
}

/* --- CRT & Background Effects --- */
.scanlines {
    position: fixed;
    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;
    animation: scanline 0.2s linear infinite;
    pointer-events: none;
    z-index: 999;
}

.vignette {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(0, 0, 0, 0) 60%, rgba(0, 0, 0, 0.7) 100%);
    pointer-events: none;
    z-index: 998;
}

#game-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 85%;
    overflow: hidden;
    z-index: 1;
    background:
        linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%),
        linear-gradient(90deg, rgba(255, 0, 0, 0.06) 50%, rgba(0, 0, 0, 0.06) 50%),
        linear-gradient(rgba(0, 0, 0, 0.06) 50%, rgba(0, 0, 0, 0.06) 50%);
    background-size: 100% 2px, 20px 100%, 100% 20px;
}

/* --- Typography & Neon --- */
.arcade-font {
    font-family: 'Black Han Sans', sans-serif;
}

.neon-text-title {
    color: #fff;
    text-shadow: 0 0 5px #fff, 0 0 10px #fff, 0 0 20px #ff00de, 0 0 30px #ff00de;
}

.neon-text-sub {
    color: #0ff;
    text-shadow: 0 0 10px #0ff;
}

.neon-text-blue {
    color: #00ffff;
    text-shadow: 0 0 10px #00ffff;
}

.neon-text-pink {
    color: #ff00ff;
    text-shadow: 0 0 10px #ff00ff;
}

.neon-text-red {
    color: #ff003c;
    text-shadow: 0 0 20px #ff003c;
}

/* --- Screens & UI --- */
.screen-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2000;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(5px);
    overflow-y: auto;
    /* Enable scrolling for mobile */
}

/* Ensure footer is above overlays */
footer.fixed-bottom {
    z-index: 3000;
}

.stage-card {
    background-color: rgba(0, 0, 0, 0.8);
    /* Darker for better contrast */
    background-size: cover;
    background-position: center;
    border: 2px solid #00ffff;
    padding: 20px;
    width: 250px;
    height: 300px;
    /* Fixed height for consistency */
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    box-shadow: 0 0 10px #00ffff;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    /* Text at bottom */
}

/* Dark overlay for readability */
.stage-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9), rgba(0, 0, 0, 0.3));
    z-index: 1;
}

.stage-badge,
.stage-card h3,
.stage-card p {
    position: relative;
    z-index: 2;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
}

.stage-card:hover {
    transform: scale(1.05);
    border-color: #ff00de;
    box-shadow: 0 0 20px #ff00de;
}

/* Global Background Dimming */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    /* Darken bg image */
    z-index: -1;
    pointer-events: none;
}

.stage-badge {
    display: inline-block;
    align-self: center;
    background: #ff00de;
    color: #fff;
    font-size: 0.8rem;
    padding: 2px 8px;
    border-radius: 4px;
    margin-bottom: auto;
    /* Push to top */
    margin-top: 10px;
}

/* --- Gameplay Elements --- */
.word-entity {
    position: absolute;
    color: #fff;
    font-family: 'Do Hyeon', sans-serif;
    font-size: 1.5rem;
    padding: 5px 12px;
    border: 2px solid #00ffff;
    background: rgba(0, 10, 20, 0.85);
    box-shadow: 0 0 10px #00ffff, inset 0 0 5px #00ffff;
    border-radius: 8px;
    transform: translateX(-50%);
    white-space: nowrap;
}

/* Long Text Handling */
.word-entity.long-text {
    font-size: 1.3rem;
    /* Uniform size */
    padding: 8px 12px;
    border-color: #ffeb3b;
    box-shadow: 0 0 10px #ffeb3b;
    white-space: normal;
    /* Allow wrap */
    max-width: 300px;
    text-align: center;
    line-height: 1.4;
}

/* VERY Long Text (100 chars) */
.word-entity.very-long-text {
    font-size: 1.3rem;
    /* Uniform size */
    padding: 10px 15px;
    border-color: #ff003c;
    box-shadow: 0 0 15px #ff003c;
    background: rgba(0, 0, 0, 0.95);

    white-space: normal;
    word-break: keep-all;
    text-align: center;
    width: auto;
    max-width: 90%;
    line-height: 1.5;
    z-index: 5;
}

#ground-line {
    position: absolute;
    bottom: 15%;
    left: 0;
    width: 100%;
    height: 4px;
    background-color: #ff003c;
    box-shadow: 0 0 20px #ff003c;
    z-index: 2;
}

.ground-glow {
    width: 100%;
    height: 50px;
    background: linear-gradient(to top, rgba(255, 0, 60, 0.5), transparent);
    position: absolute;
    bottom: 0;
    left: 0;
    pointer-events: none;
}

/* --- UI Input --- */
#ui-layer {
    z-index: 10;
}

#score-board {
    z-index: 3000;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    background: rgba(0, 0, 0, 0.8);
    border: 2px solid #ff00de;
    box-shadow: 0 0 15px #ff00de;
    padding: 10px;
}

.input-prompt {
    font-family: 'Press Start 2P', cursive;
    color: #ff00de;
    font-size: 1.2rem;
    margin-right: 10px;
    animation: blink 1s infinite;
}

.arcade-input {
    background: transparent;
    border: none;
    color: #fff;
    font-family: 'Do Hyeon', sans-serif;
    font-size: 1.5rem;
    width: 100%;
    outline: none;
}

.arcade-input::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

/* --- Buttons --- */
.btn-arcade {
    background: #ff00de;
    border: none;
    color: #fff;
    font-family: 'Black Han Sans', sans-serif;
    font-size: 1.5rem;
    clip-path: polygon(10% 0, 100% 0, 100% 80%, 90% 100%, 0 100%, 0 20%);
    text-shadow: 2px 2px 0px #000;
}

.btn-arcade:active {
    transform: scale(0.95);
    background: #c200a8;
}

.btn-arcade-red {
    background: #ff003c;
    border: none;
    color: #fff;
    font-family: 'Black Han Sans', sans-serif;
    font-size: 1.5rem;
    clip-path: polygon(0 0, 90% 0, 100% 20%, 100% 100%, 10% 100%, 0 80%);
    box-shadow: 0 0 20px #ff003c;
}

.result-box {
    border: 4px solid #fff;
    padding: 20px 40px;
    background: rgba(0, 0, 0, 0.8);
    box-shadow: inset 0 0 20px rgba(255, 255, 255, 0.2), 0 0 20px rgba(255, 255, 255, 0.5);
}

/* --- Explosion --- */
.explosion {
    position: absolute;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    white-space: nowrap;
    animation: fadeOut 3.6s forwards;
    z-index: 20;
}

.exp-word {
    font-size: 2.5rem;
    color: #ffeb3b;
    font-family: 'Black Han Sans', sans-serif;
    text-shadow: 0 0 20px #ffeb3b;
    animation: popScale 0.2s ease-out;
}

.exp-desc {
    font-size: 1.1rem;
    color: #fff;
    margin-top: 5px;
    text-shadow: 0 0 4px #000;
}

.particle {
    position: absolute;
    width: 6px;
    height: 6px;
    background: #ffeb3b;
    border-radius: 50%;
    pointer-events: none;
}

@keyframes scanline {
    0% {
        background-position: 0 0;
    }

    100% {
        background-position: 0 4px;
    }
}

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

@keyframes popScale {
    0% {
        transform: scale(0.5);
    }

    50% {
        transform: scale(1.4);
    }

    100% {
        transform: scale(1);
    }
}

@keyframes fadeOut {
    0% {
        opacity: 1;
        margin-top: 0;
    }

    100% {
        opacity: 0;
        margin-top: -50px;
    }
}

.pulse-anim {
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 0, 222, 0.7);
    }

    70% {
        box-shadow: 0 0 0 20px rgba(255, 0, 222, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(255, 0, 222, 0);
    }
}

/* Mobile */
@media (max-width: 768px) {
    .display-2 {
        font-size: 3rem;
    }

    .display-4 {
        font-size: 2.5rem;
    }

    #ground-line {
        bottom: 120px;
    }

    .word-entity.long-text {
        font-size: 1rem;
    }

    .word-entity.very-long-text {
        font-size: 0.9rem;
        width: 95%;
        /* Use almost full width on mobile */
    }
}

@keyframes shake {
    0% {
        transform: translateX(0);
    }

    10% {
        transform: translateX(-10px) rotate(-5deg);
    }

    20% {
        transform: translateX(10px) rotate(5deg);
    }

    30% {
        transform: translateX(-10px) rotate(-5deg);
    }

    40% {
        transform: translateX(10px) rotate(5deg);
    }

    50% {
        transform: translateX(-10px) rotate(-5deg);
    }

    60% {
        transform: translateX(10px) rotate(5deg);
    }

    70% {
        transform: translateX(-10px) rotate(-5deg);
    }

    80% {
        transform: translateX(10px) rotate(5deg);
    }

    90% {
        transform: translateX(-5px) rotate(0);
    }

    100% {
        transform: translateX(0);
    }
}

.shake-anim {
    animation: shake 0.4s cubic-bezier(.36, .07, .19, .97) both;
    box-shadow: 0 0 30px #ff0000 !important;
    border-color: #ff0000 !important;
}

@keyframes flashGreen {
    0% {
        background-color: rgba(0, 255, 0, 0.5);
        box-shadow: 0 0 30px #00ff00;
        border-color: #00ff00;
    }

    100% {
        background-color: transparent;
        box-shadow: none;
        border-color: #00ffff;
    }
}

.success-anim {
    animation: flashGreen 0.2s ease-out;
}

/* Background Layer */
#game-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -10;
    background-size: cover;
    background-position: center;
    filter: blur(4px) brightness(0.7);
    /* Blur and dim */
    transition: background-image 0.5s ease-in-out;
}

#level-up-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    color: #00ffff;
    font-size: 5rem;
    z-index: 1000;
    text-shadow: 0 0 20px #00ffff, 0 0 40px #fff;
    animation: popScale 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) infinite alternate;
}