body {
    margin: 0;
    font-family: sans-serif;
    /* Initial background - overridden by script */
    background-image: url('/gardenview_daycare.webp');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    color: #333;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    box-sizing: border-box;
    /* Allow overflow for content within container if needed */
    overflow-y: auto;
    transition: background-image 1s ease-in-out;
}

#loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #000;
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-size: 2em;
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.5s ease;
}

#loading-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-logo {
    max-width: 80%;
    height: auto;
    margin-bottom: 20px;
}

#main-content {
    opacity: 0;
    transition: opacity 0.5s ease;
    position: relative;
    /* Adjusted for game active state */
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 1; /* Ensure main content is above body background but below joystick */
}

#main-content.visible {
    opacity: 1;
}

#main-content.game-active {
     /* Adjust container appearance for game view */
    background-color: rgba(255, 255, 255, 0.8); 
    padding: 20px; 
}


.container {
    background-color: rgba(255, 255, 255, 0.9);
    padding: 30px;
    border-radius: 15px;
    text-align: center;
    max-width: 900px;
    width: 100%;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    transition: opacity 0.5s ease, padding 0.5s ease, background-color 0.5s ease;
    box-sizing: border-box;
}


/* Hide elements during game */
#selection-header.hidden,
#character-grid.hidden,
#play-button.hidden {
    opacity: 0;
    transition: opacity 0.5s ease;
    pointer-events: none;
}


/* Game Screen Styles */
#game-screen {
    opacity: 0;
    transition: opacity 0.5s ease;
    width: 100%;
    display: flex;
    flex-direction: column; 
    align-items: center;
    gap: 20px; 
}

#game-screen.visible {
    opacity: 1;
}

#game-screen .player-area,
#game-screen .enemies-area {
    padding: 15px;
    border-radius: 10px;
    background-color: rgba(255, 255, 255, 0.7);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    width: 100%;
    box-sizing: border-box;
    text-align: center;
}

#game-screen .player-area {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.player-char-img {
    max-width: 100px; 
    height: auto;
    border: 2px solid #4CAF50;
    border-radius: 8px;
    padding: 3px;
    background-color: #fff;
    margin-bottom: 5px;
}

.player-char-name {
    font-size: 1.1em;
    font-weight: bold;
    color: #673ab7;
}

/* Style for the container holding map and location text */
.game-info-bar {
    display: flex; /* Arrange children (map and text) in a row */
    align-items: center; /* Vertically align items */
    justify-content: center; /* Center content horizontally */
    gap: 15px; /* Space between map and text */
    margin-bottom: 15px; /* Space below the info bar */
    width: 100%; /* Take full width */
    box-sizing: border-box;
}

#game-map {
    width: 50px; /* Size of the map icon container */
    height: 50px;
    border: 2px solid #ccc; /* Optional border */
    border-radius: 8px; /* Optional rounded corners */
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: rgba(255, 255, 255, 0.8); /* Background for the map area */
    box-shadow: 0 1px 3px rgba(0,0,0,0.1); /* Subtle shadow */
}

#map-icon {
    max-width: 90%; /* Ensure icon fits within its container */
    max-height: 90%;
    height: auto;
    display: block; /* Remove extra space below image */
}

#current-location { /* Style for the new location text */
    font-size: 1.2em;
    font-weight: bold;
    color: #3f51b5; /* A nice blue */
    margin: 0; /* Remove default margin */
    text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
    flex-grow: 1; /* Allow text to take up available space */
    text-align: left; /* Align text to the left next to the icon */
}


#game-screen .enemies-area h2 {
    color: #e91e63;
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 1.5em;
}

#twisted-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(70px, 1fr)); 
    gap: 10px; 
    justify-items: center;
    max-height: 300px; 
    overflow-y: auto; 
    padding-right: 5px; 
}

.enemy-item img {
    max-width: 60px; 
    height: auto;
    border: 1px solid #ccc;
    border-radius: 5px;
    padding: 2px;
    background-color: #fff;
}


/* --- Existing Selection UI Styles --- */
#selection-header {
    display: block; 
    transition: opacity 0.5s ease;
    width: 100%;
    box-sizing: border-box;
}

header h1 {
    color: #e91e63;
    margin-top: 0;
    font-size: 2em;
}

.logo {
    max-width: 250px;
    height: auto;
    margin-bottom: 15px;
    margin-top: 20px;
}

#character-grid {
    display: grid; 
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 20px;
    justify-items: center;
    transition: opacity 0.5s ease;
    width: 100%;
    box-sizing: border-box;
}

.character-item {
    cursor: pointer;
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
    padding: 10px;
    border-radius: 10px;
    background-color: #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    box-sizing: border-box;
}

.character-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
}

.character-item.selected {
    border: 3px solid #4CAF50;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

.character-item img {
    max-width: 80px;
    height: auto;
    margin-bottom: 10px;
}

.character-item p {
    margin: 0;
    font-weight: bold;
    color: #673ab7;
    font-size: 0.9em;
    word-break: break-word;
}

#play-button {
    display: block; 
    margin: 0 auto 0;
    padding: 12px 25px;
    font-size: 1.2em;
    color: #fff;
    background-color: #4CAF50;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.1s ease, opacity 0.5s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
    position: relative;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2; 
    box-sizing: border-box;
}

#play-button:hover:not(:disabled) {
    background-color: #388E3C;
    transform: translateY(-2px) translateX(-50%);
}

#play-button:active:not(:disabled) {
    background-color: #2E7D32;
    transform: translateY(0) translateX(-50%);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

#play-button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
    box-shadow: none;
}

/* Joystick Styles (Mobile-focused) */
#joystick-container {
    position: fixed; /* Fixed position relative to viewport */
    bottom: 20px; /* 20px from the bottom */
    left: 20px; /* 20px from the left */
    width: 100px; /* Size of the touch area */
    height: 100px;
    z-index: 10; /* Above main content */
    display: flex;
    justify-content: center;
    align-items: center;
    /* Remove background color/border if it interferes with interaction */
}

#joystick-container.hidden {
    display: none; /* Hide when game screen is hidden */
}


#joystick-base {
    width: 80px; /* Size of the base visual */
    height: 80px;
    background-color: rgba(100, 100, 100, 0.5); /* Semi-transparent grey */
    border-radius: 50%; /* Make it round */
    position: absolute; /* Position relative to container */
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
}

#joystick-stick {
    width: 40px; /* Size of the stick visual */
    height: 40px;
    background-color: rgba(200, 200, 200, 0.7); /* Lighter, semi-transparent grey */
    border-radius: 50%; /* Make it round */
    position: absolute; /* Position relative to container */
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
    /* Transform is used to move the stick within the base - js will handle this */
    transform: translate(0, 0);
    transition: transform 0.1s ease; /* Smooth movement */
}


@media (max-width: 600px) {
    .container {
        padding: 15px;
    }

    #main-content.game-active {
        padding: 10px;
    }

    header h1 {
        font-size: 1.5em;
    }

    .logo {
        max-width: 200px;
        margin-top: 15px;
    }

    #character-grid {
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
        gap: 15px;
    }

    .character-item img {
        max-width: 70px;
    }

    #play-button {
        font-size: 1em;
        padding: 10px 20px;
        margin-bottom: 15px;
        top: 5px;
    }
    .loading-logo {
        max-width: 90%;
    }
    #loading-screen p {
        font-size: 1.5em;
    }

    /* Game Screen Mobile Adjustments */
    #game-screen {
        gap: 15px;
    }
    #game-screen .player-area,
    #game-screen .enemies-area {
        padding: 10px;
    }

    .player-char-img {
        max-width: 80px;
    }
     .player-char-name {
        font-size: 1em;
     }

    /* Adjust game info bar for mobile */
    .game-info-bar {
        gap: 10px; /* Smaller gap */
        margin-bottom: 10px;
    }

    #game-map {
        width: 40px; /* Smaller map icon */
        height: 40px;
    }

    #current-location { /* Adjust font size for mobile */
        font-size: 1em;
        margin: 0; /* Remove default margin */
        text-align: left;
    }


    #game-screen .enemies-area h2 {
        font-size: 1.3em;
        margin-bottom: 10px;
    }

    #twisted-gallery {
        grid-template-columns: repeat(auto-fit, minmax(50px, 1fr));
        gap: 8px;
        max-height: 250px;
    }

    .enemy-item img {
        max-width: 50px;
    }

     /* Joystick Mobile Adjustments */
    #joystick-container {
        bottom: 10px; /* Closer to the bottom on small screens */
        left: 10px; /* Closer to the left on small screens */
        width: 80px; /* Slightly smaller touch area */
        height: 80px;
    }

    #joystick-base {
        width: 60px; /* Smaller base */
        height: 60px;
    }

    #joystick-stick {
        width: 30px; /* Smaller stick */
        height: 30px;
    }
}