@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=Roboto:wght@400;700&display=swap');

body {
    margin: 0;
    padding: 0;
    background-color: #111;
    overflow: hidden;
    font-family: 'Roboto', sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    color: white;
    touch-action: none;
    /* Prevent zoom/scroll on mobile */
    user-select: none;
    /* Prevent text selection */
    -webkit-user-select: none;
}

#game-container {
    position: relative;
    width: 100%;
    height: 100%;
    /* Remove strict aspect ratio constraint for broader mobile support, handled by JS scale */
    max-width: 650px;
    max-height: 100%;
    background: #000;
    overflow: hidden;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.8);
    touch-action: none;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
    image-rendering: pixelated;
    /* Keep pixel art crisp */
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    /* Let clicks pass through to canvas by default */
}

/* Screens */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 10;
}

.screen.active {
    opacity: 1;
    pointer-events: auto;
}

.hidden {
    display: none !important;
}

/* Typography */
h1.game-title {
    font-family: 'Press Start 2P', cursive;
    color: #ff9800;
    text-shadow: 4px 4px 0 #8b0000;
    font-size: 2rem;
    line-height: 1.5;
    animation: float 2s ease-in-out infinite;
    margin-bottom: 20px;
}

.subtitle {
    font-size: 1rem;
    color: #fff;
    text-shadow: none;
}

.instruction {
    font-size: 1rem;
    color: #ccc;
    margin-bottom: 30px;
    animation: pulse 1.5s infinite;
}

.game-over-title {
    font-family: 'Press Start 2P', cursive;
    color: #ff3333;
    font-size: 2.5rem;
    margin-bottom: 10px;
}

#score,
#final-score,
#high-score {
    font-family: 'Press Start 2P', cursive;
    color: #fff;
}

#score {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 1.5rem;
    text-shadow: 2px 2px 0 #000;
    pointer-events: none;
}

/* Narrative Subtitles */
#story-subtitle {
    position: absolute;
    top: 15%;
    /* Moved higher up */
    left: 50%;
    transform: translateX(-50%);
    color: #ffd700;
    font-family: 'Courier New', Courier, monospace;
    font-size: 16px;
    /* Smaller font */
    text-align: center;
    text-shadow: 2px 2px 0 #000;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.5s;
    width: 90%;
    /* Ensure centering works well */
    z-index: 20;
}

/* Buttons */
.btn {
    background: linear-gradient(180deg, #ff9800, #f57c00);
    border: none;
    border-radius: 8px;
    padding: 20px 40px;
    /* Larger touch target */
    color: white;
    font-family: 'Press Start 2P', cursive;
    font-size: 1.2rem;
    /* Larger text */
    cursor: pointer;
    box-shadow: 0 6px 0 #b35900;
    transition: transform 0.1s, box-shadow 0.1s;
    text-transform: uppercase;
    margin: 15px;
    touch-action: manipulation;
}

.btn:active {
    transform: translateY(4px);
    box-shadow: 0 0 0 #b35900;
}

.btn.secondary {
    background: linear-gradient(180deg, #2196f3, #1976d2);
    box-shadow: 0 4px 0 #0d47a1;
}

.btn.secondary:active {
    box-shadow: 0 0 0 #0d47a1;
}

.viral-hook {
    margin-top: 15px;
    color: #ffd700;
    font-weight: bold;
    color: #ffd700;
    font-weight: bold;
    font-size: 0.9rem;
}

.bonus-hint {
    color: #00ffff;
    font-size: 0.8rem;
    margin-bottom: 15px;
    animation: pulse 2s infinite;
}

/* Animations */
@keyframes pulse {
    0% {
        opacity: 0.6;
        transform: scale(0.95);
    }

    50% {
        opacity: 1;
        transform: scale(1.05);
    }

    100% {
        opacity: 0.6;
        transform: scale(0.95);
    }
}

@keyframes float {
    0% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-10px);
    }

    100% {
        transform: translateY(0px);
    }
}

@keyframes shake {
    0% {
        transform: translate(1px, 1px) rotate(0deg);
    }

    10% {
        transform: translate(-1px, -2px) rotate(-1deg);
    }

    20% {
        transform: translate(-3px, 0px) rotate(1deg);
    }

    30% {
        transform: translate(3px, 2px) rotate(0deg);
    }

    40% {
        transform: translate(1px, -1px) rotate(1deg);
    }

    50% {
        transform: translate(-1px, 2px) rotate(-1deg);
    }

    60% {
        transform: translate(-3px, 1px) rotate(0deg);
    }

    70% {
        transform: translate(3px, 1px) rotate(-1deg);
    }

    80% {
        transform: translate(-1px, -1px) rotate(1deg);
    }

    90% {
        transform: translate(1px, 2px) rotate(0deg);
    }

    100% {
        transform: translate(1px, -2px) rotate(-1deg);
    }
}

.shake {
    animation: shake 0.5s;
    animation-iteration-count: 1;
}