body {
    font-family: Arial, sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: #f8f9fa;
    margin: 0;
    padding: 0; 
}

/* Header & Navigation */
header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 20px;
    border-bottom: 1px solid #ddd;
    background-color: #fff;
    box-sizing: border-box;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.header-left, .header-center, .header-right {
    display: flex;
    flex: 1;
    align-items: center;
}

.header-left { justify-content: flex-start; }
.header-center { justify-content: center; }
.header-right { justify-content: flex-end; }

#logo {
    height: 60px;
    width: auto;
    display: block;
}

header h1 { margin: 0; color: #333; font-size: 2rem; text-align: center; }

.top-nav { display: flex; gap: 15px; }
.top-nav button {
    background: none;
    border: none;
    font-size: 16px;
    font-weight: bold;
    color: #555;
    cursor: pointer;
    transition: color 0.2s;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px;
}
.top-nav button:hover { color: #000; }

/* Main Area */
main { display: flex; flex-direction: column; align-items: center; width: 100%; padding: 0 20px; box-sizing: border-box; }

/* Carousel Styling - Updated for Mobile */
.carousel-container { 
    display: flex; 
    align-items: center; 
    justify-content: center;
    gap: 10px; 
    margin-bottom: 20px; 
    width: 100%;
    max-width: 500px;
}

.image-wrapper { 
    position: relative; 
    width: 100%; 
    max-width: 400px; 
    aspect-ratio: 4 / 3; /* Keeps the photo box proportional on small screens */
    background-color: #e9ecef; 
    border-radius: 8px; 
    overflow: hidden; 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    box-shadow: 0 4px 6px rgba(0,0,0,0.1); 
}

#current-squirrel-img { max-width: 100%; max-height: 100%; object-fit: contain; }
#image-counter { position: absolute; bottom: 10px; right: 10px; background: rgba(0, 0, 0, 0.6); color: white; padding: 4px 8px; border-radius: 4px; font-size: 14px; }
.carousel-btn { background: #ccc; border: none; font-size: 24px; cursor: pointer; padding: 10px; border-radius: 4px; transition: background 0.2s; }
.carousel-btn:hover { background: #bbb; }

/* Input Section & Autocomplete - Updated for Mobile */
#input-section { margin-bottom: 20px; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px; width: 100%; }
.autocomplete-container { position: relative; display: inline-block; width: 100%; max-width: 250px; }
#guess-input { padding: 10px; font-size: 16px; width: 100%; box-sizing: border-box; border: 1px solid #ccc; border-radius: 4px; }
.autocomplete-items { position: absolute; border: 1px solid #ccc; border-top: none; z-index: 99; top: 100%; left: 0; right: 0; margin: 0; padding: 0; list-style-type: none; background-color: #fff; max-height: 200px; overflow-y: auto; border-radius: 0 0 4px 4px; box-shadow: 0 4px 6px rgba(0,0,0,0.1); }
.autocomplete-items li { padding: 10px; cursor: pointer; border-bottom: 1px solid #eee; font-size: 14px; text-align: left; }
.autocomplete-items li:hover { background-color: #f1f1f1; }
#submit-guess { padding: 10px 20px; font-size: 16px; background-color: #3b82f6; color: white; border: none; border-radius: 4px; cursor: pointer; font-weight: bold; white-space: nowrap; }
#submit-guess:hover { background-color: #2563eb; }
#guess-tracker { font-weight: bold; color: #555; margin-left: 10px; }

/* Guess Grid - Updated for tight mobile fitting */
#guess-grid { width: 100%; max-width: 800px; }
.grid-header, .guess-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; text-align: center; }
.grid-header div { font-weight: bold; font-size: 14px; padding-bottom: 5px; border-bottom: 2px solid #ccc; margin-bottom: 10px; }
.guess-wrapper { margin-bottom: 10px; }
.guess-species-label { font-weight: bold; font-size: 15px; color: #333; margin-bottom: 5px; text-align: left; padding-left: 5px; }

.guess-row div { 
    background-color: #fff; 
    border: 1px solid #d3d6da; 
    padding: 8px 4px; 
    font-size: 14px; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    min-height: 40px; 
    line-height: 1.2;
    overflow-wrap: break-word; /* Allows long words like "Marmot/Prairie Dog" to wrap */
}

/* Wordle Colors */
.correct { background-color: #6aaa64 !important; color: white; border-color: #6aaa64 !important; }
.incorrect { background-color: #787c7e !important; color: white; border-color: #787c7e !important; }

/* Hint System */
#hint-container { position: fixed; bottom: 20px; right: 20px; background: #fff; padding: 15px; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.15); border: 2px solid #4CAF50; z-index: 100; }
#hint-prompt span { font-weight: bold; margin-right: 10px; }
#hint-prompt button { margin-left: 5px; padding: 5px 10px; border: none; border-radius: 4px; cursor: pointer; font-weight: bold; color: white; }
#hint-yes { background-color: #4CAF50; }
#hint-yes:hover { background-color: #45a049; }
#hint-no { background-color: #ef4444; }
#hint-no:hover { background-color: #dc2626; }
#hint-text { font-weight: bold; color: #333; margin-top: 5px; }

/* Modals General Formatting */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.6); display: flex; justify-content: center; align-items: center; z-index: 200; padding: 10px; box-sizing: border-box; }
.modal-content { position: relative; background: white; padding: 40px 20px; border-radius: 8px; text-align: center; box-shadow: 0 4px 15px rgba(0,0,0,0.2); max-width: 450px; width: 100%; box-sizing: border-box; max-height: 90vh; overflow-y: auto; }
.modal-content h2 { margin-top: 0; font-size: 24px; }
.close-modal-btn { position: absolute; top: 10px; right: 15px; background: none; border: none; font-size: 24px; cursor: pointer; color: #777; }
.close-modal-btn:hover { color: #000; }

/* Stats & Game Over Specific Styling */
#modal-icon { font-size: 60px; margin-bottom: 10px; }
.text-green { color: #4CAF50 !important; }
.text-red { color: #ef4444 !important; }
.modal-buttons { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; margin: 20px 0; }

#copy-results-btn { background-color: #6366f1; color: white; padding: 10px 20px; border: none; border-radius: 4px; cursor: pointer; font-size: 16px; font-weight: bold; }
#copy-results-btn:hover { background-color: #4f46e5; }
#close-modal-main-btn { background-color: #ef4444; color: white; padding: 10px 20px; border: none; border-radius: 4px; cursor: pointer; font-size: 16px; font-weight: bold; }
#close-modal-main-btn:hover { background-color: #dc2626; }

.stats-container { margin-top: 10px; }
.stats-grid { display: flex; justify-content: space-around; flex-wrap: wrap; gap: 10px; }
.stat-box { display: flex; flex-direction: column; align-items: center; min-width: 60px; }
.stat-box span { font-size: 24px; font-weight: bold; color: #333; }
.stat-box label { font-size: 12px; color: #777; margin-top: 5px; }

/* Info Specific Styling */
.info-list { text-align: left; margin: 20px 0; padding-left: 20px; line-height: 1.6; font-size: 15px; }
.info-color { padding: 2px 6px; border-radius: 3px; font-weight: bold; }

.hidden { display: none !important; }

/* ========================================= */
/* MOBILE RESPONSIVE FIXES (Screens < 600px) */
/* ========================================= */
@media (max-width: 600px) {
    header { padding: 10px; }
    
    #logo { height: 45px; }
    
    header h1 { font-size: 1.5rem; }
    
    .top-nav { gap: 5px; }
    .top-nav button { font-size: 14px; padding: 4px; }

    main { padding: 0 10px; }

    /* Carousel Buttons Shrink */
    .carousel-btn { font-size: 18px; padding: 8px; }

    /* Input Stacks Nicely */
    .autocomplete-container { max-width: 100%; }
    #submit-guess { width: 100%; max-width: 250px; }
    #guess-tracker { width: 100%; text-align: center; margin-left: 0; margin-top: 5px; }

    /* Grid Shrinks to fit 5 columns on narrow screens */
    .grid-header div { font-size: 11px; padding-bottom: 2px; }
    .guess-row div { font-size: 10px; padding: 4px 2px; min-height: 35px; }
    .guess-species-label { font-size: 13px; }

    /* Hint Banner becomes full-width at bottom instead of corner box */
    #hint-container { 
        bottom: 10px; 
        right: 10px; 
        left: 10px; 
        text-align: center; 
        padding: 10px; 
    }
    
    #hint-prompt {
        display: flex;
        flex-direction: column;
        gap: 10px;
        align-items: center;
    }
    #hint-prompt span { margin-right: 0; }
    #hint-prompt button { width: 100px; padding: 8px; margin: 0; }

    /* Modals adjust */
    .modal-content { padding: 30px 15px; }
    #copy-results-btn, #close-modal-main-btn { width: 100%; }
}