body {
    font-family: 'Barlow Condensed', sans-serif;
    background-color: #f0f0f0;
    display: flex;
    justify-content: center;
    align-items: flex-start; /* Align to top allows scrolling */
    min-height: 100vh;
    margin: 0;
    /* Adjusted padding for better mobile spacing */
    padding: 10px 0;
    font-weight: 400;
}

.game-container {
    background-color: #fff;
    /* Adjusted padding */
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    width: 90%;
    max-width: 750px;
    text-align: center;
}

.logo-banner {
    display: block;
    margin: 0 auto 10px auto;
    max-width: 100%;
    height: auto;
}

.subtitle {
    font-size: 1.1em;
    color: #444;
    margin-bottom: 25px; /* Slightly reduced default margin */
    font-style: bold;
    font-weight: 400;
    line-height: 1.3;
}

/* H1 Styling Removed */

.info-bar {
    display: flex;
    justify-content: space-between;
    font-size: 1.1em;
    margin-top: 0;
    margin-bottom: 15px; /* Reduced margin */
    padding: 10px;
    background-color: #e9e9e9;
    border-radius: 4px;
    font-weight: 700;
}

.main-content {
    display: flex;
    gap: 30px;
    margin-bottom: 20px;
}

.game-area {
    flex: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 0; /* Prevents flex items from overflowing */
}

.history-area {
    flex: 1;
    border-left: 1px solid #ccc;
    padding-left: 20px;
    max-height: 400px; /* Limit height on desktop */
    overflow-y: auto;
    text-align: left;
    min-width: 0; /* Prevents flex items from overflowing */
}

.history-area h2 {
    margin-top: 0;
    font-size: 1.2em;
    color: #444;
    text-align: center;
    margin-bottom: 10px;
    font-weight: 700;
}

#history-list {
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 1em;
    color: #333;
}

#history-list li {
    margin-bottom: 5px;
    padding: 3px 5px;
    border-radius: 3px;
    background-color: #f8f8f8;
    white-space: pre;
    word-break: break-all; /* Prevent long words causing overflow */
}

.feedback {
    font-size: 1.2em;
    font-weight: 700;
    min-height: 1.5em; /* Keep min-height */
    margin-bottom: 15px;
    word-wrap: break-word; /* Ensure feedback wraps */
}

.guess-section {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    width: 100%;
    max-width: 400px; /* Limit width of this section */
}

#guess-input {
    padding: 10px;
    font-size: 1.1em;
    border: 1px solid #ccc;
    border-radius: 4px;
    margin-right: 10px;
    flex-grow: 1; /* Allow input to grow */
    min-width: 100px; /* Ensure minimum width */
    font-family: inherit;
    /* Removed max-width to allow flex-grow */
}

#submit-guess,
.new-game-btn { /* Applies base styles to all new game buttons */
    padding: 10px 15px; /* Adjusted padding */
    font-size: 1.1em;
    cursor: pointer;
    border: none;
    border-radius: 4px;
    background-color: #5c8ded;
    color: white;
    transition: background-color 0.2s ease;
    font-family: inherit;
    font-weight: 700;
    flex-shrink: 0; /* Prevent button from shrinking too much */
}

#submit-guess:hover,
.new-game-btn:hover {
    background-color: #4a76c8;
}

#submit-guess:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

.alphabet-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 5px;
    margin-bottom: 20px;
    max-width: 350px;
    width: 100%; /* Take available width up to max-width */
}

.alphabet-button {
    font-family: inherit;
    font-weight: 700;
    border: 1px solid #aaa;
    border-radius: 4px;
    padding: 0;
    margin: 2px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    font-size: 1.1em;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    transition: background-color 0.2s ease, color 0.2s ease;
    text-transform: uppercase;
    flex-shrink: 0; /* Prevent shrinking */
    flex-grow: 0; /* Prevent growing */
}

.letter-unknown {
    background-color: lightgrey;
    color: black;
}

.letter-yes {
    background-color: #6aaa64;
    color: white;
    border-color: #6aaa64;
}

.letter-no {
    background-color: #787c7e;
    color: white;
    border-color: #787c7e;
}

#new-game-button-main {
    margin-top: 15px;
    /* This button is visible by default (desktop) */
}

/* Hide Mobile button by default */
#new-game-button-mobile {
    display: none; /* Hidden on desktop */
    /* We will style width/margins in the media query */
}

.instructions {
    font-size: 0.9em;
    color: #666;
    margin-top: 25px;
    margin-bottom: 5px;
    line-height: 1.4;
    border-top: 1px solid #eee;
    padding-top: 15px;
    text-align: center;
}

/* --- Win Overlay --- */
.hidden {
    display: none !important;
}

.win-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 15px; /* Add padding for smaller screens */
    box-sizing: border-box;
}

.win-message {
    background-color: #b5e8a0;
    padding: 20px 25px; /* Reduced padding */
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    color: #333;
    width: 90%; /* Limit width */
    max-width: 400px; /* Set max width */
}

.win-message h2 { font-weight: 700; margin-top: 0; color: #2a5c2a; font-size: 1.4em; } /* Adjusted size */
.win-message p { font-weight: 400; font-size: 1em; margin: 8px 0; } /* Adjusted size */
.win-message .new-game-btn { font-weight: 700; margin-top: 15px; background-color: #4CAF50; padding: 10px 18px; }
.win-message .new-game-btn:hover { background-color: #45a049; }


/* === START: Media Queries for Mobile Optimization === */

/* Target devices narrower than 768px (typical tablet portrait / large phone landscape) */
@media (max-width: 767px) {
    body {
        padding: 10px 0; /* Ensure consistent padding */
        align-items: flex-start; /* Keep alignment */
    }

    .game-container {
        width: 95%; /* Use slightly more screen width */
        padding: 15px; /* Adjust padding */
        max-width: none; /* Remove max-width limit */
    }

    .main-content {
        flex-direction: column; /* Stack game area and history area */
        gap: 20px; /* Adjust gap for vertical stacking */
        margin-bottom: 0; /* Remove bottom margin as button comes after */
    }

    .history-area {
        flex: none; /* Remove flex sizing */
        width: 100%; /* Take full width */
        border-left: none; /* Remove the side border */
        padding-left: 0; /* Remove side padding */
        border-top: 1px solid #ccc; /* Add a top border for separation */
        padding-top: 15px; /* Add space above the list */
        margin-top: 10px; /* Add margin above the history section */
        max-height: 250px; /* Reduce height for stacked layout */
    }

    .info-bar {
        font-size: 1em; /* Slightly smaller font for info */
        padding: 8px;
        flex-wrap: wrap; /* Allow items to wrap if needed */
        justify-content: space-around; /* Better spacing if wrapped */
        gap: 5px;
    }

    .subtitle {
        font-size: 1em;
        margin-bottom: 20px;
    }

    .feedback {
        font-size: 1.1em;
    }

    .guess-section {
        max-width: none; /* Allow section to use available width */
    }

    .instructions {
        font-size: 0.85em;
    }

    .win-message {
        padding: 15px 20px;
    }
     .win-message h2 { font-size: 1.3em; }
     .win-message p { font-size: 0.95em; }

    /* Hide the DESKTOP button */
    #new-game-button-main {
        display: none;
    }

    /* Show and style the MOBILE button */
    #new-game-button-mobile {
        display: block; /* Make it visible */
        width: 90%; /* Adjust width as desired */
        max-width: 300px; /* Optional max width */
        margin: 25px auto 0 auto; /* Center it and add space above */
    }
}

/* Target devices narrower than 480px (typical phone portrait) */
@media (max-width: 479px) {
    body {
        font-size: 15px; /* Adjust base font size slightly for small screens */
    }
    .game-container {
        padding: 10px;
    }

    .logo-banner {
        margin-bottom: 5px; /* Reduce space below banner */
    }

    .subtitle {
        font-size: 0.95em;
        margin-bottom: 15px;
    }

    .info-bar {
         /* Already wraps, should be okay */
    }

    .feedback {
        font-size: 1em;
        min-height: 1.2em; /* Adjust min-height */
        margin-bottom: 10px;
    }

    .guess-section {
        flex-direction: column; /* Stack input and button vertically */
        align-items: stretch; /* Make input/button take full width */
        gap: 10px;
    }

    #guess-input {
        margin-right: 0; /* No margin needed when stacked */
        width: 100%; /* Take full width */
        box-sizing: border-box; /* Include padding in width calculation */
        font-size: 1em; /* Adjust size */
    }

    /* Style Submit and Win buttons on smallest screens */
    #submit-guess,
    .win-message .new-game-btn {
        width: 100%; /* Make buttons full width */
        box-sizing: border-box;
        font-size: 1em; /* Adjust size */
        padding: 12px 15px; /* Slightly larger padding for tapping */
    }

    .alphabet-container {
        gap: 3px; /* Reduce gap slightly */
        margin-bottom: 15px;
    }

    .alphabet-button {
        width: 28px; /* Slightly smaller buttons */
        height: 28px;
        font-size: 1em;
        margin: 1px; /* Reduce margin */
    }

    .history-area {
         max-height: 200px; /* Further reduce history height */
    }

    #history-list li {
        font-size: 0.9em; /* Slightly smaller history text */
    }

    .instructions {
        font-size: 0.8em;
        margin-top: 15px;
        padding-top: 10px;
    }

    .win-message {
        padding: 10px 15px;
    }
    .win-message h2 { font-size: 1.2em; }
    .win-message p { font-size: 0.9em; }
    .win-message .new-game-btn { /* Styles already applied above */
         margin-top: 10px;
    }

     /* Ensure the mobile button gets the full-width treatment */
    #new-game-button-mobile {
        width: 100%;
        max-width: none;
        box-sizing: border-box;
        padding: 12px 15px; /* Match submit button padding */
        margin: 20px auto 0 auto; /* Center it and add space above */
        font-size: 1em; /* Match other buttons */
    }

    /* Make sure the desktop one remains hidden */
    #new-game-button-main {
        display: none;
    }
}

/* === END: Media Queries for Mobile Optimization === */
