/* client/style.css */

/* === Global & Base Styles === */
body, html {
    margin: 0;
    padding: 0;
    overflow: hidden;
    font-family: sans-serif;
    background-color: #333;
    color: #eee;
}

#game-container {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 0;
}
#game-canvas { display: block; width: 100%; height: 100%; }

/* === General UI Panel Styling === */
.ui-panel {
    position: absolute;
    background-color: rgba(0, 0, 0, 0.65);
    border: 1px solid #444;
    border-radius: 6px;
    padding: 10px;
    box-sizing: border-box;
    color: #eee;
    z-index: 10;
    pointer-events: auto;
    font-size: 14px; /* Base font size for DESKTOP */
}
.ui-panel h3, .ui-panel h4 { margin-top: 0; margin-bottom: 10px; font-size: 1.0em; color: #ddd; border-bottom: 1px solid #555; padding-bottom: 5px; }
.ui-panel p, .ui-panel div, .ui-panel label, .ui-panel span, .ui-panel li { font-size: 0.9em; line-height: 1.4; }

/* === Specific Panel Positioning (BASE / DESKTOP) === */

/* --- Top Left Info Panel --- */
#top-left-info {
    top: 10px;
    left: 10px;
    /* --- Reinstate Desktop Width Constraints --- */
    width: auto; /* Allow content to determine width */
    min-width: 180px; /* Minimum */
    max-width: 250px; /* Maximum */
    /* --- End Width Constraints --- */
    padding-top: 40px; /* Keep space for button */
    position: relative;
}
#top-left-info p { margin: 4px 0; }
#top-left-info span { font-weight: bold; color: #ffc107; }
.message { margin-top: 8px; padding-top: 8px; border-top: 1px dashed #555; color: #ffcc00; font-weight: bold; min-height: 1.2em; font-size: 0.85em; }
.message.info { color: #ffcc00; }
.message.success { color: #4CAF50; }
.message.warning { color: #ff9800; }
.message.error { color: #f44336; }

/* --- Top Right Leaderboard --- */
#top-right-leaderboard {
    top: 10px;
    right: 10px;
    /* --- Reinstate Desktop Width Constraints --- */
    width: auto;
    min-width: 200px;
    max-width: 280px;
    /* --- End Width Constraints --- */
    background-color: rgba(0, 0, 0, 0.5);
}
#top-right-leaderboard h4 { font-size: 0.9em; text-align: center; border: none; padding-bottom: 0; margin-bottom: 5px; }
#top-right-leaderboard ul { list-style: none; padding: 0; margin: 0; max-height: 200px; overflow-y: auto; font-size: 0.85em; }
#top-right-leaderboard li { padding: 3px 5px; border-bottom: 1px dotted #444; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#top-right-leaderboard li:last-child { border-bottom: none; }

/* --- Bottom Left Status Panel --- */
#bottom-left-status {
    bottom: 10px;
    left: 10px;
    /* --- Reinstate Desktop Width Constraints --- */
    width: 220px; /* Fixed width for desktop */
    /* --- End Width Constraints --- */
}
#bottom-left-status .status-bar-container { margin-bottom: 10px; position: relative; }
#bottom-left-status label { display: block; margin-bottom: 2px; font-size: 0.85em; color: #ccc; }
.bar-outer { background-color: #555; border-radius: 3px; height: 15px; width: 100%; overflow: hidden; border: 1px solid #333; }
.bar-inner { height: 100%; border-radius: 2px; transition: width 0.2s ease-in-out; }
.carbon { background: linear-gradient(to right, #4CAF50, #8BC34A); }
.hydraulic { background: linear-gradient(to right, #2196F3, #03A9F4); }
#bottom-left-status span#carbon-value,
#bottom-left-status span#hydraulic-value { position: absolute; right: 5px; top: 18px; font-size: 0.75em; line-height: 15px; color: #ccc; text-shadow: 1px 1px 1px #000; }
#bottom-left-status p { margin: 8px 0 0 0; clear: both; font-weight: bold; }
#bottom-left-status p span#seed-counter { color: #ffc107; }

/* --- Bottom Right Control Panel --- */
#control-panel-right {
    bottom: 10px;
    right: 10px;
    /* --- Reinstate Desktop Width Constraints --- */
    width: 220px; /* Fixed width for desktop */
    /* --- End Width Constraints --- */
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding: 15px 12px;
}
.control-row { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; gap: 2px 8px; align-items: center; width: 100%; }
.control-row label { grid-column: 1 / 2; grid-row: 1 / 2; white-space: nowrap; color: #ccc; font-size: 0.85em; justify-self: start; }
.control-row input[type="range"] { grid-column: 1 / 3; grid-row: 2 / 3; width: 100%; cursor: pointer; margin-top: 2px; -webkit-appearance: none; appearance: none; height: 8px; background: #555; outline: none; border-radius: 4px; }
.control-row input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 16px; height: 16px; background: #ccc; cursor: pointer; border-radius: 50%; }
.control-row input[type="range"]::-moz-range-thumb { width: 16px; height: 16px; background: #ccc; cursor: pointer; border-radius: 50%; border: none; }
.control-row span { grid-column: 2 / 3; grid-row: 1 / 2; font-size: 0.85em; font-weight: bold; color: #ccc; text-align: right; white-space: nowrap; justify-self: end; }

/* === Back Button Styling (BASE / DESKTOP) === */
.back-button {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 20;
    box-sizing: border-box;
    /* --- Reinstate Desktop Width --- */
    width: 200px; /* Match default leaderboard min-width */
    /* --- End Desktop Width --- */
    padding: 6px 12px;
    font-size: 0.9em;
    background-color: rgba(80, 80, 80, 0.7);
    color: #eee;
    border: 1px solid #666;
    border-radius: 4px;
    cursor: pointer;
    pointer-events: auto;
    transition: background-color 0.2s;
    text-align: center;
    text-decoration: none;
    font-family: sans-serif;
}
.back-button:hover { background-color: rgba(110, 110, 110, 0.8); border-color: #888; }

/* === General Interactive Element Styling (Unchanged) === */
button { pointer-events: auto; }
input[type="range"], input[type="color"], input[type="number"] { pointer-events: auto; }
input[type="color"] { min-width: 40px; height: 25px; border: 1px solid #555; cursor: pointer; padding: 0; vertical-align: middle; background-color: #444; border-radius: 3px; }

/* === Game Over Modal Styling (Unchanged) === */
.modal { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); background-color: rgba(40, 40, 40, 0.9); padding: 30px; border: 1px solid #666; border-radius: 10px; z-index: 100; min-width: 300px; max-width: 90%; text-align: center; pointer-events: auto; color: #eee; box-shadow: 0 5px 15px rgba(0,0,0,0.5); }
.modal.hidden { display: none; }
.modal h2 { margin-top: 0; color: #eee; margin-bottom: 15px; }
.modal p { color: #eee; margin: 10px 0; line-height: 1.4; }
.modal p span { font-weight: bold; color: #ffc107; }
#game-over-reason { font-style: italic; color: #ffdddd; margin-bottom: 20px !important; }
.modal button { padding: 10px 20px; margin-top: 20px; cursor: pointer; background-color: #556b2f; border: none; color: #eee; border-radius: 5px; font-size: 1em; transition: background-color 0.2s; }
.modal button:hover { background-color: #6b8e23; }
#admin-close-modal { background-color: #8b4513; }
#admin-close-modal:hover { background-color: #a0522d; }


/* === Responsive Design (Keep Mobile overrides as they were) === */

/* Target screens smaller than 768px */
@media (max-width: 768px) {
    .ui-panel {
        padding: 10px;
        font-size: 14px;
        min-width: 0; /* Override desktop min-width */
        max-width: none; /* Override desktop max-width */
    }

    #top-left-info {
        top: 8px;
        left: 8px;
        width: auto; /* Let content + padding dictate width up to max */
        max-width: 180px; /* Mobile max-width */
        padding-top: 40px;
    }
    #top-right-leaderboard {
        top: 8px;
        right: 8px;
        width: auto;
        min-width: 0; /* Override desktop min-width */
        max-width: 170px; /* Mobile max-width */
        max-height: 160px;
    }
    #bottom-left-status {
        bottom: 8px;
        left: 8px;
        width: 190px; /* Specific width for this breakpoint */
    }
    #control-panel-right {
        bottom: 8px;
        right: 8px;
        width: 190px; /* Specific width for this breakpoint */
        padding: 12px 10px;
        gap: 10px;
    }
    .control-row label { font-size: 0.9em; }
    .control-row span { font-size: 0.9em; }
    .control-row input[type="range"] { height: 10px; }
    .control-row input[type="range"]::-webkit-slider-thumb { width: 18px; height: 18px; }
    .control-row input[type="range"]::-moz-range-thumb { width: 18px; height: 18px; }

    .back-button {
        top: 8px;
        left: 8px;
        width: 170px; /* Match leaderboard mobile width */
        padding: 6px 10px;
        font-size: 0.9em;
    }

    .ui-panel p, .ui-panel div, .ui-panel label, .ui-panel span, .ui-panel li { font-size: 0.9em; line-height: 1.35; }
    #top-right-leaderboard ul { font-size: 0.85em; }
    #top-right-leaderboard li { padding: 3px 5px; }
    #bottom-left-status label { font-size: 0.9em; }
    .bar-outer { height: 16px; }
    #bottom-left-status span#carbon-value,
    #bottom-left-status span#hydraulic-value { font-size: 0.8em; top: 18px; line-height: 16px; }

    .modal { padding: 25px; min-width: 300px; }
    .modal h2 { font-size: 1.3em; }
    .modal p { font-size: 1em; }
    .modal button { font-size: 1em; padding: 10px 18px;}
}

/* Target even smaller screens */
@media (max-width: 480px) {
    .ui-panel {
        font-size: 13px;
        border-radius: 5px;
        padding: 8px;
    }

    #top-left-info {
        max-width: 155px;
        padding-top: 38px;
    }
    #top-right-leaderboard {
        max-width: 145px;
        max-height: 140px;
    }
    #bottom-left-status { width: 165px; }
    #control-panel-right { width: 165px; gap: 8px; }
    .bar-outer { height: 14px; }
    #bottom-left-status span#carbon-value,
    #bottom-left-status span#hydraulic-value { line-height: 14px; top: 17px; font-size: 0.75em; }

    .back-button {
        top: 8px;
        left: 8px;
        width: 145px; /* Match leaderboard width */
        padding: 5px 8px;
        font-size: 0.9em;
    }

    .ui-panel p, .ui-panel div, .ui-panel label, .ui-panel span, .ui-panel li { font-size: 0.9em; line-height: 1.3; }
    #top-right-leaderboard li { padding: 2px 4px; }
    .control-row label { font-size: 0.85em; }
    .control-row span { font-size: 0.85em; }
    .control-row input[type="range"] { height: 12px; }
    .control-row input[type="range"]::-webkit-slider-thumb { width: 20px; height: 20px; }
    .control-row input[type="range"]::-moz-range-thumb { width: 20px; height: 20px; }
}