body, html { 
    margin: 0; 
    padding: 0; 
    height: 100%; 
    font-family: Arial, sans-serif; 
    overflow: hidden; 
}

/* --- START OF CHOROPLETH COLORS (NO CHANGES NEEDED) --- */
/* This existing section already contains all the colors our new manageTools.json uses */
:root {
    --color-dark-green: #006d2c;
    --color-medium-green: #31a354;
    --color-yellow-green: #74c476;
    --color-yellow: #ffffcc; /* A light yellow for moderate yields */
    --color-orange: #fd8d3c;
    --color-reddish-orange: #f03b20;
    --color-red: #bd0026;
    --color-no-data: #e0e0e0; /* Neutral grey for states without data */
}
/* --- END OF CHOROPLETH COLORS --- */


#container { 
    display: flex; 
    height: 100vh; 
    width: 100vw; 
}

/* Landscape mode: Equal split (50/50) for map and details */
@media (orientation: landscape) {
    #map-container { 
        width: 50vw; 
        height: 100vh; 
        flex-shrink: 0; 
        position: relative;
    }
    #details { 
        width: 50vw; 
        height: 100vh; 
        padding: 20px; 
        background: #f8f8f8; 
        overflow-y: auto; 
    }
    #portrait-message { 
        display: none; 
    }
}

/* Portrait mode: Map on top, details below */
@media (orientation: portrait) {
    #container { 
        flex-direction: column; 
    }
    #map-container { 
        width: 100vw; 
        height: 60vh; 
        flex-shrink: 0; 
        position: relative;
    }
    #details { 
        width: 100vw; 
        height: 40vh; 
        padding: 15px; 
        background: #f8f8f8; 
        overflow-y: auto; 
        box-sizing: border-box; 
    }
    #portrait-message { 
        display: none; 
    }
}

/* --- START OF MODIFICATION: Game Mode Fullscreen --- */
#container.game-mode-active #map-container {
    display: none;
}

#container.game-mode-active #details {
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}
/* --- END OF MODIFICATION --- */


/* --- START OF MODIFICATION: Map Controls & State Labels --- */
.map-controls-top-right {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 1000;
    display: flex;
    gap: 10px;
}

.map-control-button {
    padding: 8px 12px;
    border: 1.5px solid rgba(0, 0, 0, 0.4); /* Darker, slightly thicker border */
    background-color: rgba(255, 255, 255, 0.9); /* Slightly transparent */
    color: #333;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    box-shadow: 0 1px 7px rgba(0,0,0,0.3); /* Stronger shadow */
    transition: all 0.15s ease;
}

.map-control-button:hover {
    background-color: #f4f4f4;
}

.map-control-button.active {
    background-color: #3388ff;
    color: white;
    border-color: #3388ff;
}

.state-label {
    color: black;
    text-align: center;
    text-shadow: 
        -1px -1px 0 #FFF,  
         1px -1px 0 #FFF,
        -1px  1px 0 #FFF,
         1px  1px 0 #FFF; /* White outline for readability */
    pointer-events: none;
    user-select: none;
    white-space: nowrap;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
}

.state-label-large b { font-size: 14px; }
.state-label-medium b { font-size: 11px; }
.state-label-small b { font-size: 9px; }
/* --- END OF MODIFICATION --- */


/* --- START OF NEW MODIFICATION: Leaflet Attribution Control Styling --- */
/* Ensure the attribution control has proper spacing and styling */
.leaflet-control-attribution {
    background: rgba(255, 255, 255, 0.8) !important;
    padding: 3px 8px !important;
    border-radius: 4px;
    margin: 0 0 5px 10px !important; /* This ensures it's not flush with the edge */
    box-shadow: 0 1px 5px rgba(0,0,0,0.2);
}
/* --- END OF NEW MODIFICATION --- */


/* --- START OF MODIFIED: #details for Loader Positioning --- */
#details {
    position: relative; /* This is crucial for the absolute positioning of the loader overlay */
}
/* --- END OF MODIFIED --- */


/* Content wrapper to ensure proper scrolling */
#details-content {
    min-height: calc(100% + 7em);
    padding-bottom: 7em;
}

/* START OF MODIFICATION: Game Button & Back Button Alignment */
#details h2 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #333;
    border-bottom: 2px solid #3388ff;
    padding-bottom: 5px;
    margin-bottom: 10px;
}

/* NEW: Style for the back button inside a heading */
.back-to-selection-btn {
    padding: 5px 12px;
    font-size: 14px;
    font-weight: 500;
    color: #3388ff;
    background-color: white;
    border: 1px solid #3388ff;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.back-to-selection-btn:hover {
    background-color: #e6f3ff;
    transform: translateY(-1px);
}

/* NEW: Style for the arrow inside the back button */
.back-arrow {
    font-size: 1.3em; /* Makes the arrow slightly larger */
    position: relative;
    top: 0px; /* Fine-tunes vertical alignment */
    margin-right: 2px;
}
/* END OF MODIFICATION */

.detail-section {
    margin-bottom: 20px;
}

.detail-section h3 {
    color: #333;
    border-bottom: 2px solid #3388ff;
    padding-bottom: 5px;
    margin-bottom: 10px;
}

/* --- START OF NEW MODIFICATION: Subheader with Button --- */
.detail-section h3.subheader-with-button {
    display: flex;
    justify-content: flex-start; /* Aligns items to the left */
    align-items: center;
    gap: 15px; /* Adds space between the title and the button */
}
/* --- END OF NEW MODIFICATION --- */


.detail-row {
    display: flex;
    margin-bottom: 5px;
}

.detail-label {
    font-weight: bold;
    min-width: 150px;
    color: #555;
}

.detail-value {
    flex: 1;
    color: #333;
}

.list-value {
    color: #333;
}

.number-value {
    color: #2c7fb8;
    font-weight: 500;
}

/* MODIFIED: This class is now used for multiple sections */
.features-section {
    margin-top: 25px;
}

.features-section h3 {
    color: #333;
    border-bottom: 2px solid #3388ff;
    padding-bottom: 5px;
    margin-bottom: 15px;
}

.feature-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
}

.feature-toggle {
    padding: 8px 16px;
    border: 2px solid #3388ff;
    background-color: white;
    color: #3388ff;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.15s ease;
    white-space: nowrap;
    user-select: none;
}

.feature-toggle:hover {
    background-color: #e6f3ff;
    transform: translateY(-1px);
}

.feature-toggle:active {
    transform: translateY(0);
}

.feature-toggle.active {
    background-color: #3388ff;
    color: white;
    box-shadow: 0 2px 8px rgba(51, 136, 255, 0.3);
}

.feature-toggle.active:hover {
    background-color: #2968cc;
}

/* --- START OF NEW: Disabled state for feature toggles --- */
.feature-toggle.disabled {
    background-color: #f0f0f0;
    border-color: #dcdcdc;
    color: #b0b0b0;
    cursor: not-allowed;
    transform: none;
}

.feature-toggle.disabled:hover {
    background-color: #f0f0f0;
    transform: none;
}
/* --- END OF NEW --- */


/* Points of Interest List Styling */
.poi-list {
    margin-top: 15px;
}

.poi-list h3 {
    color: #333;
    border-bottom: 2px solid #3388ff;
    padding-bottom: 5px;
    margin-bottom: 10px;
    font-size: 16px;
}

.poi-items {
    list-style: none;
    padding: 0;
    margin: 0;
}

.poi-items li {
    padding: 8px 12px;
    margin: 4px 0;
    background: #f0f7ff;
    border-left: 3px solid #3388ff;
    border-radius: 4px;
    font-size: 14px;
    color: #333;
}

.poi-items li:nth-child(odd) {
    background: #f8fbff;
}

.poi-no-items {
    padding: 15px;
    text-align: center;
    color: #666;
    font-style: italic;
    background: #f9f9f9;
    border-radius: 4px;
    margin-top: 10px;
}


/* --- START OF CHOROPLETH LEGEND (NO CHANGES NEEDED) --- */
.choropleth-legend {
    margin-top: 20px;
}

.choropleth-legend h3 {
    color: #333;
    border-bottom: 2px solid #3388ff;
    padding-bottom: 5px;
    margin-bottom: 10px;
}

.legend-item {
    display: flex;
    align-items: center;
    margin-bottom: 6px;
    font-size: 14px;
}

.legend-color-box {
    width: 20px;
    height: 20px;
    margin-right: 10px;
    border: 1px solid rgba(0,0,0,0.2);
}

/* Mapping color names from JSON to CSS variables */
.legend-color-box.dark_green { background-color: var(--color-dark-green); }
.legend-color-box.medium_green { background-color: var(--color-medium-green); }
.legend-color-box.yellow_green { background-color: var(--color-yellow-green); }
.legend-color-box.yellow { background-color: var(--color-yellow); }
.legend-color-box.orange { background-color: var(--color-orange); }
.legend-color-box.reddish_orange { background-color: var(--color-reddish-orange); }
.legend-color-box.red { background-color: var(--color-red); }
.legend-color-box.no_data { background-color: var(--color-no-data); }

.legend-label {
    color: #333;
}
/* --- END OF CHOROPLETH LEGEND --- */


/* Responsive adjustments for smaller screens */
@media (orientation: portrait) and (max-width: 480px) {
    #details { 
        padding: 10px; 
        font-size: 14px; 
    }
    .detail-label { 
        min-width: 120px; 
        font-size: 13px; 
    }
    #details h2, .detail-section h3 { 
        font-size: 16px; 
    }
    .detail-section { 
        margin-bottom: 15px; 
    }
    .feature-toggle { 
        padding: 6px 12px; 
        font-size: 12px; 
    }
    
    .poi-items li {
        padding: 6px 10px;
        font-size: 13px;
    }
}
/* --- START OF SIMPLIFIED HOME SCREEN STYLES --- */
/* The entire 'REFACTORED AUTH & HOME SCREEN STYLES' section has been removed. */
/* The following styles are simplified for the new, static home screen. */

.game-section {
    margin-top: 15px;
    padding: 10px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

/* This is the new style for the main "Play Game" button */
#play-game-button {
    padding: 12px 28px;
    font-size: 1.1em;
    font-weight: bold;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 220px;
    max-width: 250px;
    box-sizing: border-box;
    border: 2px solid transparent;
    background-color: #3388ff;
    color: white;
    border-color: #3388ff;
}

#play-game-button:hover {
    background-color: #2968cc;
}

.title-container {
    display: flex;
    flex-direction: column;
}

.home-prompt-subtitle {
    font-size: 0.9rem;
    font-weight: 500;
    color: #555;
    margin-left: 0;
    font-style: normal;
    margin-top: 4px;
}
/* --- END OF SIMPLIFIED HOME SCREEN STYLES --- */


/* --- START OF SIMPLIFIED GAME MODE SELECTION STYLES --- */
/* The old logic-dependent styles are removed. */

.game-mode-layout {
    display: flex;
    flex-direction: row;
    justify-content: center;
    gap: 15px;
}

.game-mode-separator {
    border: 0;
    height: 1px;
    background-color: #e0e0e0;
    margin: 25px auto;
    width: 80%;
}

.game-access-info {
    margin-top: 25px;
    text-align: center;
}

/* The grey back button style has been removed. */

/* --- END OF SIMPLIFIED GAME MODE SELECTION STYLES --- */


/* --- START OF NEW/MODIFIED: STATE COMPARISON FEATURE STYLES --- */
.comparison-selection-area {
    text-align: center;
    padding: 20px 0;
}

.comparison-prompt {
    font-size: 1.2em;
    font-weight: 500;
    color: #333;
    margin-bottom: 20px;
}

.comparison-state-display {
    font-size: 1.1em;
    margin-bottom: 15px;
    background-color: #e9ecef;
    padding: 10px 15px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.deselect-state-btn {
    font-size: 1.2em;
    font-weight: bold;
    color: #dc3545;
    cursor: pointer;
    padding: 0 5px;
}

.comparison-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    margin-top: 25px;
}

#show-comparison-btn {
    background-color: #007bff;
    border-color: #007bff;
    color: white;
    padding: 8px 18px; /* Added padding */
    font-size: 15px;   /* Added font-size */
    border-radius: 20px; /* Added border-radius */
    cursor: pointer;
}
#show-comparison-btn:hover {
    background-color: #0069d9;
}
#show-comparison-btn:disabled {
    background-color: #ced4da;
    border-color: #ced4da;
    cursor: not-allowed;
}

.comparison-table-container {
    width: 100%;
    overflow-x: auto;
    margin-top: 15px;
}

.comparison-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 500px; 
}

/* --- START OF STICKY HEADER MODIFICATION --- */
.comparison-table thead {
    position: sticky; /* Makes the header sticky */
    top: 0;           /* Sticks to the top of the scrolling container (#details) */
    z-index: 10;      /* Ensures it stays above the table body content */
}

.comparison-table th {
    background-color: #e9ecef;
    font-size: 1.1em;
}

.comparison-table th, .comparison-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid #dee2e6;
    vertical-align: top;
}

.comparison-table td:first-child {
    font-weight: bold;
    color: #495057;
    width: 1%; 
    white-space: nowrap; 
    background-color: #f8f9fa;
}
/* --- END OF STICKY HEADER MODIFICATION --- */

.comparison-table .section-header th {
    background-color: #007bff;
    color: white;
    text-align: center;
    font-size: 1.2em;
    padding: 8px;
}

.winner-cell {
    background-color: #d4edda !important; /* Light green for winner */
    font-weight: bold;
}
/* --- END OF STATE COMPARISON FEATURE STYLES --- */

/* NEW: Container for the bottom home button on the state details page */
.bottom-nav-container {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid #ddd;
    display: flex;
    justify-content: center;
    padding-bottom: 40px; /* MODIFIED: Added bottom padding */
}

.creator-contact-footer {
    text-align: center;
    margin-top: 50px;
    color: #666;
    font-size: 0.9em;
}
.creator-contact-footer hr {
    border: 0;
    height: 1px;
    background-color: #ddd;
    margin-bottom: 15px;
}
.creator-contact-footer p {
    margin: 0;
    padding: 0;
}


/* --- START OF NEW: Details Panel Loader Styles --- */
.details-loading-overlay {
    position: absolute;
    /* top is set dynamically by JavaScript */
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(248, 248, 248, 0.8); /* Translucent version of the details background */
    z-index: 100; /* High enough to cover content in #details */
    display: flex;
    justify-content: center;
    align-items: center;
    /* Add a transition for a smooth fade-in/out */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease-in-out, visibility 0.2s ease-in-out;
    pointer-events: none; /* Default to non-interactive */
}

.details-loading-overlay.visible {
    opacity: 1;
    visibility: visible;
    pointer-events: all; /* When visible, it blocks clicks */
}

.details-spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #e0e0e0; /* Lighter grey */
    border-top: 5px solid #3388ff; /* Theme blue */
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* The spin animation might be defined elsewhere, but including it here ensures it works */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
/* --- END OF NEW: Details Panel Loader Styles --- */