/* Lazy Loader Styles */
#loader-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #0a1a0f; /* Deep jungle green */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.5s ease-out, visibility 0.5s;
}

#loader-wrapper.fade-out {
    opacity: 0;
    visibility: hidden;
}

#loader {
    position: relative;
    width: 120px;
    height: 120px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.spinner {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 8px solid rgba(138, 226, 52, 0.1);
    border-top: 8px solid #8ae234; /* Vibrant moss green */
    border-radius: 50%;
    animation: spin 1.5s linear infinite;
}

.pig-emoji {
    font-size: 50px;
    animation: bounce 2s ease-in-out infinite;
}

#loader-text {
    margin-top: 20px;
    color: #8ae234;
    font-family: 'Luckiest Guy', cursive;
    font-size: 24px;
    letter-spacing: 2px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    text-align: center;
    padding: 0 20px;
    max-width: 80%;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes bounce {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-10px) scale(1.1); }
}

body {
    margin: 0;
    padding: 10px 0; /* Minimal vertical padding */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: #0a1a0f; /* Deep jungle green */
    overflow: hidden;
    touch-action: none; /* Prevent browser handling of touch gestures */
    user-select: none; /* Prevent text selection */
    -webkit-user-select: none;
}

#game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    background: transparent; /* Remove container background */
    padding: 0; /* Remove padding */
    border: none; /* Remove outer border */
    box-shadow: none; /* Remove shadow */
    max-width: 100vw;
    max-height: 100vh;
}

#fortress-header {
    width: 100%;
    display: flex;
    justify-content: center;
    overflow: hidden;
    border-radius: 10px;
    border: 4px solid #2d5a27; /* Dark forest green */
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
}

#fortress-image {
    max-width: 400px;
    height: auto;
    display: block;
}

#ui-container {
    font-size: 22px; /* Slightly smaller font */
    font-weight: bold;
    color: #d3f9d8; /* Minty white */
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

#back-to-arcade {
    position: fixed;
    bottom: 20px;
    left: 20px;
    color: #d3f9d8;
    text-decoration: none;
    font-size: 1rem;
    opacity: 0.7;
    z-index: 100;
    font-family: Arial, sans-serif;
    transition: opacity 0.2s;
}

#back-to-arcade:hover {
    opacity: 1;
}

#game-title {
    position: absolute;
    top: 22%; /* Slightly higher to accommodate the new size */
    left: 0;
    width: 100%;
    text-align: center;
    font-size: 52px;
    font-family: 'Luckiest Guy', cursive;
    color: #8ae234; /* Vibrant moss green */
    
    /* Complex multi-layered text shadow for depth and glow */
    text-shadow: 
        3px 3px 0px #0a1a0f,
        -1px -1px 0px #0a1a0f,  
        1px -1px 0px #0a1a0f,
        -1px 1px 0px #0a1a0f,
        1px 1px 0px #0a1a0f,
        0px 0px 15px rgba(138, 226, 52, 0.6);
    
    z-index: 5;
    white-space: nowrap;
    letter-spacing: 2px;
    
    /* Animation for a subtle "breathing" jungle effect */
    animation: titleGlow 3s ease-in-out infinite;
    pointer-events: none; /* Ensure it doesn't block clicks */
}

@keyframes titleGlow {
    0%, 100% {
        transform: scale(1);
        text-shadow: 
            3px 3px 0px #0a1a0f,
            0px 0px 15px rgba(138, 226, 52, 0.6);
    }
    50% {
        transform: scale(1.05);
        text-shadow: 
            3px 3px 0px #0a1a0f,
            0px 0px 25px rgba(138, 226, 52, 0.9);
    }
}

#score-float {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: rgba(10, 26, 15, 0.8);
    color: #d3f9d8;
    padding: 10px 20px;
    border-radius: 30px;
    font-size: 20px;
    font-weight: bold;
    z-index: 100;
    pointer-events: none;
    font-family: Arial, sans-serif;
    border: 1px solid #2d5a27;
}

#game-wrapper {
    position: relative;
    background-color: transparent;
    overflow: hidden;
    /* This makes the container itself responsive while keeping the aspect ratio */
    height: 100vh;
    width: auto;
    aspect-ratio: 9 / 16; /* Matches the vertical portrait image */
    display: flex;
    justify-content: center;
    align-items: center;
    max-width: 100vw;
}

#fortress-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain; /* Changed to contain to stop left/right cutting */
    z-index: 1;
}

#gameCanvas { 
   display: block; 
   position: absolute; 
   top: 35%; 
   left: 50%; 
   transform: translateX(-50%); 
   z-index: 2; 
   background-color: transparent; 
   width: 55%; 
   height: 30%; 
   image-rendering: pixelated; 
   border-radius: 2%; 
 }

#overlay {
    position: absolute;
    top: 35%; 
    left: 50%; 
    transform: translateX(-50%); 
    width: 55%; 
    height: 30%; 
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: rgba(10, 26, 15, 0.9); /* Deep jungle overlay */
    z-index: 10;
    border-radius: 2%; /* Matches canvas */
}

#overlay.hidden {
    display: none;
}

#start-screen, #pause-screen, #game-over-screen {
    text-align: center;
    background: #1e3a1e; /* Dark mossy green */
    padding: 15px; /* Reduced padding for smaller area */
    border-radius: 10px;
    border: 3px solid #4e9a06; /* Leaf green border */
    box-shadow: 0 0 20px rgba(0,0,0,0.7);
    width: 80%; /* Ensure it fits inside the new smaller overlay */
}

#start-screen h1, #pause-screen h1, #game-over-screen h1 {
    color: #8ae234; /* Vibrant green */
    font-size: 24px; /* Scaled down font size */
    margin-bottom: 10px;
    text-shadow: 1px 1px #0a1a0f;
}

#start-screen p, #game-over-screen p {
    color: #d3f9d8;
    margin-bottom: 15px;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 5px;
}

.inline-ghost {
    height: 1.4em;
    vertical-align: middle;
    filter: drop-shadow(0 0 5px rgba(255, 0, 0, 0.5));
}

#game-over-title {
    color: #ff5252 !important; /* Brighter red for game over */
}

button {
    background-color: #4e9a06; /* Leaf green */
    color: #d3f9d8;
    border: none;
    padding: 8px 16px; /* Scaled down padding */
    font-size: 16px; /* Scaled down font size */
    font-weight: bold;
    cursor: pointer;
    border-radius: 5px;
    transition: transform 0.2s, background-color 0.2s;
    box-shadow: 0 3px #1b3022;
}

button:hover {
    background-color: #6dbf1a;
    transform: scale(1.05);
}

button:active {
    transform: translateY(2px);
    box-shadow: 0 2px #1b3022;
}

.hidden {
    display: none !important;
}

#instructions {
    font-size: 14px;
    color: #a5d6a7;
    margin-top: 5px;
    opacity: 0.8;
}
