@import url('https://fonts.googleapis.com/css2?family=Exo+2:wght@400;700&family=Press+Start+2P&display=swap');

:root {
    --primary: #ff00ff;
    --secondary: #00ffff;
    --dark-overlay: rgba(0, 0, 0, 0.7);
    --dialog-bg: rgba(20, 20, 35, 0.95);
    --text-color: #fff;
    --accent: #ffd700;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
}

body {
    background-color: #000;
    color: white;
    font-family: 'Exo 2', sans-serif;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

#game-container {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

/* Backgrounds */
#background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    background-size: cover;
    background-position: center;
    transition: opacity 1s ease-in-out;
}

.bg-black-cat {
    background-image: url('bg-5ka.jpg');
}

.bg-kitchen {
    background-image: url('bg-app.jpg');
}

/* Characters */
#character {
    position: absolute;
    bottom: -50px;
    /* Slight offset to hide legs cut-off if any */
    left: 50%;
    transform: translateX(-50%);
    height: 90vh;
    width: auto;
    z-index: 5;
    pointer-events: none;
    transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    justify-content: center;
    align-items: flex-end;
}

.char-img {
    height: 100%;
    width: auto;
    filter: drop-shadow(0 0 10px rgba(0, 0, 0, 0.5));
    /* Removing background if not transparent - mix-blend can help if white bg */
    /* mix-blend-mode: multiply; Only works if bg strictly white and scene bright */
}

/* Animations */
@keyframes breathe {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.02);
    }

    100% {
        transform: scale(1);
    }
}

.char-anim {
    animation: breathe 4s infinite ease-in-out;
}

#ui-layer {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 20;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding-bottom: 20px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8) 0%, transparent 40%);
}

#dialog-box {
    background: var(--dialog-bg);
    border: 2px solid var(--secondary);
    border-radius: 15px;
    margin: 0 auto 20px;
    width: 90%;
    max-width: 1000px;
    min-height: 200px;
    padding: 25px;
    position: relative;
    box-shadow: 0 0 30px rgba(0, 255, 255, 0.2);
    backdrop-filter: blur(5px);
    display: flex;
    flex-direction: column;
}

#name-tag {
    position: absolute;
    top: -25px;
    left: 40px;
    background: linear-gradient(45deg, var(--primary), #800080);
    color: white;
    padding: 8px 30px;
    font-weight: bold;
    font-size: 18px;
    border-radius: 8px;
    border: 2px solid white;
    box-shadow: 0 0 10px var(--primary);
    transition: opacity 0.3s;
}

#name-tag:empty {
    display: none;
}

#text-content {
    font-size: 20px;
    line-height: 1.6;
    margin-top: 10px;
    margin-bottom: 20px;
    text-shadow: 1px 1px 2px black;
    height: 100px;
    /* Fixed height to prevent jumping */
}

#choices-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: auto;
}

.choice-btn {
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid var(--secondary);
    border-left: 5px solid var(--secondary);
    color: var(--text-color);
    padding: 12px 20px;
    cursor: pointer;
    font-family: 'Exo 2', sans-serif;
    font-size: 16px;
    text-align: left;
    transition: all 0.3s;
    border-radius: 4px;
}

.choice-btn:hover {
    background: var(--secondary);
    color: black;
    transform: translateX(10px);
    box-shadow: 0 0 15px var(--secondary);
}

/* Effects */
#vignette {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, transparent 60%, black 100%);
    z-index: 10;
    pointer-events: none;
}

#scanlines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(0deg,
            rgba(0, 0, 0, 0.15),
            rgba(0, 0, 0, 0.15) 1px,
            transparent 1px,
            transparent 2px);
    z-index: 12;
    pointer-events: none;
    opacity: 0.5;
}

.hidden {
    display: none !important;
}

/* Warnings */
#epilepsy-warning {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: black;
    color: red;
    z-index: 100;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 20px;
    transition: opacity 1.5s ease-in-out;
}

.fade-out-screen {
    opacity: 0 !important;
    pointer-events: none;
}

#epilepsy-warning p {
    line-height: 1.2;
    /* Tighter spacing for retro feeling, overrides global p */
    max-width: 800px;
    margin-bottom: 20px;
}

#epilepsy-warning h1 {
    font-family: 'Press Start 2P', cursive;
    margin-bottom: 20px;
    color: red;
    text-shadow: 2px 2px 0 #fff;
    line-height: 1.4;
    /* Specific for the header */
}

#start-btn {
    background: transparent;
    border: 2px solid red;
    color: red;
    padding: 20px 40px;
    font-family: 'Press Start 2P', cursive;
    font-size: 16px;
    cursor: pointer;
    margin-top: 50px;
    transition: all 0.3s;
}

#start-btn:hover {
    background: red;
    color: black;
    box-shadow: 0 0 20px red;
}

/* Text Effects */
.effect-shake {
    display: inline-block;
    animation: text-shake 0.5s infinite;
    color: #ff4444;
    /* Angry Red */
    font-weight: bold;
}

@keyframes text-shake {
    0% {
        transform: translate(0, 0);
    }

    25% {
        transform: translate(2px, 2px);
    }

    50% {
        transform: translate(-2px, -2px);
    }

    75% {
        transform: translate(2px, -2px);
    }

    100% {
        transform: translate(0, 0);
    }
}

.effect-wave {
    display: inline-block;
    animation: text-wave 2s infinite ease-in-out;
    color: #00ffff;
}

@keyframes text-wave {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-5px);
    }
}

.effect-glitch {
    display: inline-block;
    color: white;
    font-family: 'Press Start 2P', cursive;
    font-size: 0.9em;
    animation: glitch-text-shadow 2s infinite;
}

/* Remove pseudo-elements that caused the ghost text issue */
.effect-glitch::before,
.effect-glitch::after {
    display: none;
}

@keyframes glitch-text-shadow {
    0% {
        text-shadow: 2px 2px #ff00ff, -2px -2px #00ffff;
        transform: translate(0, 0);
    }

    10% {
        text-shadow: -2px 2px #ff00ff, 2px -2px #00ffff;
        transform: translate(-1px, 1px);
    }

    20% {
        text-shadow: 2px -2px #ff00ff, -2px 2px #00ffff;
        transform: translate(1px, -1px);
    }

    30% {
        text-shadow: 0 0 #ff00ff, 0 0 #00ffff;
        transform: translate(0, 0);
    }

    40% {
        text-shadow: 3px 0 #ff00ff, -3px 0 #00ffff;
        transform: translate(1px, 0);
    }

    50% {
        text-shadow: 0 0 #ff00ff, 0 0 #00ffff;
        transform: translate(0, 0);
    }

    90% {
        text-shadow: 0 0 #ff00ff, 0 0 #00ffff;
        transform: translate(0, 0);
    }

    100% {
        text-shadow: 2px 2px #ff00ff, -2px -2px #00ffff;
        transform: translate(0, 0);
    }
}

.effect-rainbow {
    /* Pure Neon Gradient - High Contrast */
    background: linear-gradient(to right,
            #ff3333, #ffb733, #ffff33, #33ff33, #33ffff, #d133ff, #ff33ff);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    font-weight: 900;
    animation: rainbow-anim 2s linear infinite;
    background-size: 200% auto;
    /* White glow to separate from dark background */
    filter: drop-shadow(0 0 1px white) drop-shadow(0 0 3px rgba(255, 255, 255, 0.3));
}

@keyframes rainbow-anim {
    to {
        background-position: 200% center;
    }
}

.effect-small {
    font-size: 0.7em;
    opacity: 0.7;
}


/* Global Typography Fixes */
p {
    line-height: 1.6;
    /* Increased for better readability */
}

/* Mobile */
@media (max-width: 768px) {
    #ui-layer {
        padding-bottom: 0;
        /* Override desktop padding */
        justify-content: flex-end;
    }

    #character {
        height: 90vh;
        /* Make character large again */
        bottom: 0;
        top: auto;
        /* Remove top anchor */
        transform: translateX(-50%);
        /* Center without scale reduction if possible, or slight scale */
        left: 50%;
        align-items: flex-end;
    }

    #dialog-box {
        width: 100%;
        margin-bottom: 0;
        /* Reset desktop margin */
        margin-left: 0;
        margin-right: 0;
        border-radius: 15px 15px 0 0;
        border-bottom: none;
        padding-bottom: 15px;
        /* Minimal padding for content */
        bottom: 0;
    }

    #text-content {
        font-size: 14px;
        /* Slightly smaller for more text fit */
        height: auto;
        min-height: 80px;
        line-height: 1.5;
    }

    .choice-btn {
        padding: 12px;
        font-size: 13px;
        line-height: 1.4;
    }
}

/* Statistics Overlay */
#stats-container {
    padding: 20px;
    background: rgba(0, 0, 0, 0.9);
    border: 2px solid var(--primary);
    border-radius: 10px;
    margin-top: 10px;
    color: white;
    font-family: 'Exo 2', sans-serif;
    animation: fadeIn 1s ease-in;
    max-height: 200px;
    overflow-y: auto;
    font-size: 14px;
    width: 90%;
    margin-left: auto;
    margin-right: auto;
}

#stats-container h3 {
    margin-bottom: 15px;
    color: var(--secondary);
    text-transform: uppercase;
    font-size: 12px;
    border-bottom: 1px solid white;
    padding-bottom: 5px;
    text-align: center;
}

.stat-item {
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.stat-label {
    width: 55%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-right: 10px;
    font-size: 12px;
}

.stat-bar-container {
    width: 40%;
    height: 12px;
    background: #333;
    border-radius: 6px;
    position: relative;
    overflow: hidden;
}

.stat-bar {
    height: 100%;
    background: var(--primary);
    transition: width 1s ease-out;
}

.stat-bar.current {
    background: var(--accent);
    box-shadow: 0 0 5px var(--accent);
}

.stat-val {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 8px;
    color: white;
    font-weight: bold;
    text-shadow: 1px 1px 0 #000;
    z-index: 2;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* UI Entrance Animations */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes popIn {
    0% {
        opacity: 0;
        transform: scale(0.8);
    }

    70% {
        transform: scale(1.05);
    }

    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Apply animations */
.choice-btn {
    animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) backwards;
    /* Stagger effect via script or simple delay logic effectively handled by typing delay often */
}

/* Stagger delays for buttons if there are multiple */
.choice-btn:nth-child(1) {
    animation-delay: 0ms;
}

.choice-btn:nth-child(2) {
    animation-delay: 100ms;
}

.choice-btn:nth-child(3) {
    animation-delay: 200ms;
}

#dialog-box {
    transition: transform 0.3s ease, opacity 0.3s ease;
}

/* Smooth Transitions */
#background,
#character {
    transition: opacity 0.5s ease-in-out, filter 0.5s ease, transform 0.5s ease;
}

.fade-out {
    opacity: 0 !important;
    filter: blur(5px) grayscale(100%);
    transform: scale(1.05);
    /* Slight zoom on exit */
}

/* UI Entrance Animations */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.anim-slide-up {
    animation: slideUp 0.5s ease-out forwards;
}

@keyframes popIn {
    0% {
        opacity: 0;
        transform: scale(0.8);
    }

    70% {
        transform: scale(1.05);
    }

    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Apply animations */
.choice-btn {
    animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) backwards;
}

/* Stagger delays for buttons if there are multiple */
.choice-btn:nth-child(1) {
    animation-delay: 0ms;
}

.choice-btn:nth-child(2) {
    animation-delay: 100ms;
}

.choice-btn:nth-child(3) {
    animation-delay: 200ms;
}

#dialog-box {
    transition: transform 0.3s ease, opacity 0.3s ease;
}

#mute-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 200;
    background: rgba(0, 0, 0, 0.7);
    border: 2px solid var(--primary);
    color: white;
    font-size: 24px;
    padding: 10px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s;
    width: 50px;
    height: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
}

#mute-btn:hover {
    background: var(--primary);
    box-shadow: 0 0 15px var(--primary);
    transform: scale(1.1);
}

.credits {
    position: absolute;
    bottom: 10px;
    width: 100%;
    text-align: center;
    font-size: 10px;
    color: rgba(255, 255, 255, 0.5);
    font-family: 'Exo 2', sans-serif;
    pointer-events: none;
}