#footer {
    padding: 0 10px;
    background-color: #000;
    color: white;
    flex-shrink: 0;
    position: relative;
    display: grid;
    grid-template-columns: 35% 30% 35%;
    align-items: center;
    height: 40px;
}

.footer-column {
    display: flex;
    align-items: center;
    height: 100%; /* Ensure full height for positioning */
    position: relative; /* This is the anchor for the divider line */
    min-width: 0; /* critical: allow grid items to shrink below min-content */
}
.footer-column:nth-child(2) {
    justify-content: center;
}
.footer-column:nth-child(3) {
    justify-content: flex-end;
}

#gameStatusHUD {
    font-size: 13px;
    color: #cfeccf;
    padding-left: 10px;
    margin-left: 8px;
    border-left: 1px solid rgba(255,255,255,0.04);
    align-self: center;
}

/* --- Horizontal Line Above Footer --- */
#footer::before {
    content: '';
    position: absolute;
    top: -3px;
    left: 0;
    width: 100%;
    height: 3px;
    animation: pulse-glow 5s ease-in-out infinite;
    z-index: 5;
}

/* --- Vertical Divider Lines --- */
/* This rule attaches a glowing line to the right side of the first and second columns */
.footer-column:nth-child(1)::after,
.footer-column:nth-child(2)::after {
    content: '';
    position: absolute;
    top: 0;
    right: -1.5px; /* Centers the 2px line on the column boundary */
    height: 100%;
    width: 3px;
    animation: pulse-glow 5s ease-in-out infinite;
    z-index: 5;
}


#header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 10px;
    background-color: #000;
    color: white;
    position: relative;
    border: none;
    height: 40px;
}

/* --- Horizontal Line Below Header --- */
#header::after {
    content: '';
    position: absolute;
    bottom: -3px;
    left: 0;
    width: 100%;
    height: 3px;
    animation: pulse-glow 5s ease-in-out infinite;
    z-index: 5;
}


/* Defines the three columns */
.header-left {
    width: 20%;
    display: flex;
    justify-content: center;
}
.header-center {
    flex-grow: 1;
    text-align: center;
}
.header-right {
    width: 20%;
    display: flex;
    justify-content: flex-end;
}

/* Style for the logo */
#gameLogo {
    height: 35px;
    width: auto;
}

.clock-display {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #eaffea;
    padding: 2px 12px;
    margin-right: 6px;
    border-radius: 16px;
    background: rgba(20, 40, 20, 0.25);
    border: 1px solid rgba(144, 238, 144, 0.18);
    box-shadow: 0 0 8px rgba(144,238,144,0.12) inset;
    font-family: 'Roboto Mono', monospace;
    letter-spacing: 0.5px;
    font-weight: 600;
    width: 200px;
    white-space: nowrap;
    justify-content: center;
}
.clock-display::before {
    content: '🕒';
    filter: drop-shadow(0 0 2px rgba(144,238,144,0.35));
}

.weather-widget {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 2px 10px;
    border-radius: 16px;
    background: rgba(20, 40, 20, 0.25);
    border: 1px solid rgba(144, 238, 144, 0.18);
    box-shadow: 0 0 8px rgba(144,238,144,0.12) inset;
    margin-left: 6px;
    /* Keep capsule from growing/shrinking as content changes */
    width: 200px;
    white-space: nowrap;
    font-family: 'Roboto Mono', monospace;
}
.weather-widget .weather-icon { filter: drop-shadow(0 0 2px rgba(144,238,144,0.35)); }
.weather-widget .weather-label { color: #eaffea; font-weight: 600; flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.weather-widget .weather-temp { color: #bfe6bf; flex: 0 0 auto; min-width: 5ch; text-align: right; }

/* Morale pill (mobile/compact only; shown when discovered) */
.morale-widget {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 2px 10px;
    border-radius: 16px;
    background: rgba(20, 40, 20, 0.25);
    border: 1px solid rgba(144, 238, 144, 0.18);
    box-shadow: 0 0 8px rgba(144,238,144,0.12) inset;
    margin: 0 6px;
    width: 160px;
    white-space: nowrap;
    font-family: 'Roboto Mono', monospace;
    justify-content: center;
}

.morale-widget .morale-label { color: #eaffea; font-weight: 600; }
.morale-widget .morale-value { color: #bfe6bf; font-weight: 700; }
.morale-widget .morale-icon { filter: drop-shadow(0 0 2px rgba(144,238,144,0.35)); }

/* --- Header Link and Options Popup styles --- */
.header-title {
    flex-grow: 1;
}

.header-links {
    display: flex;
    gap: 15px;
}

/* Mobile header menu button (injected by ui/header.js) */
.header-menu-btn {
    display: none;
}

/* Default: keep the overflow/menu button hidden.
   (Needs stronger specificity because .header-link sets display:flex.) */
#header .header-menu-btn {
    display: none;
}

/* Mobile-only footer speed control (injected by ui/footer.js) */
.mobile-speed-btn {
    display: none;
}

/* Desktop: use the single speed toggle button, not 4 discrete speed buttons. */
html:not(.is-compact) .footer-controls .speed-buttons {
    display: none;
}

html:not(.is-compact) .footer-controls .mobile-speed-btn {
    display: inline-flex;
}

/* Desktop: hide the redundant footer version button (version is shown in the header). */
html:not(.is-compact) #footer #changelogBtn {
    display: none;
}

.header-link {
    height: 30px;
    padding: 0 25px;
    background-image: url('../../assets/images/PNG/Button03.png');
    background-size: 100% 100%;
    background-repeat: no-repeat;
    color: white;
    text-decoration: none;
    border-radius: 5px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background-color: transparent;
}

.header-link:hover {
    background-image: url('../../assets/images/PNG/Button04.png');
}

.header-controls {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-left: 12px;
}

.footer-controls .speed-buttons {
    display: inline-flex;
    gap: 6px;
    align-items: center;
}

.header-controls .speed-buttons {
    display: inline-flex;
    gap: 6px;
    align-items: center;
}

.speed-btn {
    padding: 4px 8px;
    font-size: 13px;
    min-width: 42px;
    text-align: center;
    border-radius: 4px;
    opacity: 0.95;
    transition: transform 120ms ease, box-shadow 180ms ease, background 160ms ease, color 120ms ease;
}

.speed-btn.active {
    background: linear-gradient(180deg, rgba(34,139,34,0.22), rgba(0,100,0,0.18));
    color: #eaffea;
    border: 1px solid rgba(144,238,144,0.45);
    box-shadow: 0 8px 22px rgba(0,160,80,0.14), 0 0 10px rgba(144,238,144,0.18) inset;
    /* Keep size/position consistent when active */
    transform: none;
    font-weight: 700;
    text-shadow: 0 1px 0 rgba(0,0,0,0.45);
}

/* Apply the same active highlight to the Pause button when paused */
.footer-controls #pauseBtn.active {
    background: linear-gradient(180deg, rgba(34,139,34,0.22), rgba(0,100,0,0.18));
    color: #eaffea;
    border: 1px solid rgba(144,238,144,0.45);
    box-shadow: 0 8px 22px rgba(0,160,80,0.14), 0 0 10px rgba(144,238,144,0.18) inset;
    /* Keep size consistent when highlighted */
    transform: none;
    font-weight: 700;
    text-shadow: 0 1px 0 rgba(0,0,0,0.45);
}

/* Apply the same active highlight to the Debug button when enabled */
.footer-controls #debugBtn.active {
    background: linear-gradient(180deg, rgba(34,139,34,0.22), rgba(0,100,0,0.18));
    color: #eaffea;
    border: 1px solid rgba(144,238,144,0.45);
    box-shadow: 0 8px 22px rgba(0,160,80,0.14), 0 0 10px rgba(144,238,144,0.18) inset;
    transform: none;
    font-weight: 700;
    text-shadow: 0 1px 0 rgba(0,0,0,0.45);
}

/* Keep Pause/Resume width stable to avoid layout shift */
.footer-controls #pauseBtn { min-width: 72px; text-align: center; }

/* keep header-link look but slightly smaller for these controls */
.header-controls .header-link, .footer-controls .header-link {
    padding: 4px 10px;
    font-size: 13px;
}

.footer-controls { display: inline-flex; align-items: center; gap: 8px; }
.footer-controls .header-link { font-size: 11px; padding: 2px 8px; }
.footer-controls .speed-buttons { gap: 5px; }
.footer-controls .speed-btn { font-size: 11px; min-width: 34px; padding: 3px 6px; }

@media (max-width: 700px) {
    .header-controls { display: none; }
}

/* tweak responsiveness */
@media (max-width: 700px) {
    .header-controls { display: none; } /* hide controls on very small screens */
}

/* Phone layout (portrait) AND phone-landscape (low height): tighten header and turn
    Options/Save/Load into a dropdown.
    Target device test: iPhone 12 Pro landscape ~844x390.
    Desktop behavior remains unchanged because these rules only apply at phone-ish sizes. */
@media (max-width: 600px),
       (max-width: 900px) and (max-height: 450px),
       (hover: none) and (pointer: coarse) and (max-width: 900px) and (max-height: 600px) {
    :root {
        --footer-height: calc(25px + env(safe-area-inset-bottom));
        --edge-rail: 40px;
        --reach-pad-x: 10px;
    }

    #header {
        height: 25px;
        box-sizing: border-box;
        padding: calc(1px + env(safe-area-inset-top)) calc(var(--reach-pad-x, 10px) + env(safe-area-inset-right)) 1px calc(var(--reach-pad-x, 10px) + env(safe-area-inset-left));
        gap: 6px;
        /* Keep center truly centered even when left/right widths differ */
        display: grid;
        grid-template-columns: 1fr auto 1fr;
        align-items: center;
        /* Keep header UI (⋯ dropdown) above overlay drawers */
        z-index: 220;
    }

    .header-left {
        width: auto;
        justify-content: flex-start;
        justify-self: start;
    }

    #gameLogo {
        height: 19px;
    }

    .header-center {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        min-width: 0;
        justify-self: center;
    }

    .clock-display {
        width: auto;
        max-width: 38vw;
        font-size: 11px;
        padding: 0 8px;
        height: 18px;
        line-height: 18px;
        margin-right: 0;
        border-radius: 10px;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .clock-display::before {
        content: '';
        display: none;
    }

    .weather-widget {
        width: auto;
        max-width: 38vw;
        font-size: 11px;
        padding: 0 8px;
        height: 18px;
        line-height: 18px;
        margin-left: 0;
        overflow: hidden;
    }

    .morale-widget {
        width: auto;
        max-width: 22vw;
        font-size: 11px;
        padding: 0 8px;
        height: 18px;
        line-height: 18px;
        margin: 0;
        overflow: hidden;
        border-radius: 10px;
    }

    .morale-widget .morale-label { display: none; }

    .weather-widget .weather-temp { min-width: 0; }

    .header-right {
        width: auto;
        position: relative;
        gap: 6px;
        align-items: center;
        justify-self: end;
    }

    /* Override #header .header-menu-btn { display:none } */
    #header .header-menu-btn {
        display: inline-flex;
        min-width: 42px;
        padding: 0 12px;
        font-size: 18px;
        line-height: 1;
        height: 20px;
    }

    /* Match footer to compact header height */
    #footer {
        height: var(--footer-height, 25px);
        box-sizing: border-box;
        padding: 0 calc(var(--reach-pad-x, 10px) + env(safe-area-inset-right)) env(safe-area-inset-bottom) calc(var(--reach-pad-x, 10px) + env(safe-area-inset-left));
        /* Widen objectives (middle) column further for phone-landscape */
        grid-template-columns: 28% 44% 28%;
        /* Keep footer controls above overlay drawers (z-index 60) */
        z-index: 210;
    }

    /* Keep footer content optically centered in the shorter bar */
    .footer-column { align-items: center; }
    #footerControls { height: 100%; align-items: center; transform: translateY(-1px); }

    /* Make footer controls fit within 25px */
    .footer-controls { gap: 6px; }

    /* Replace speed button row with a single cycle button */
    .footer-controls .speed-buttons { display: none; }
    .footer-controls .mobile-speed-btn { display: inline-flex; }

    .footer-controls .header-link {
        height: 20px;
        padding: 0 8px;
        font-size: 10px;
    }

    .footer-controls .speed-btn {
        height: 20px;
        min-width: 30px;
        padding: 0 6px;
        font-size: 10px;
    }

    .footer-controls #pauseBtn { min-width: 58px; }

    /* Version button (changelog) moves into the header ⋯ menu on mobile */
    #changelogBtn { display: none; }

    /* Objectives button in the middle footer column */
    .objectives-toggle {
        height: 20px;
        font-size: 11px;
        padding: 0 10px;
        min-width: 0;
    }

    /* Hide the inline link row; show it as an anchored dropdown when open */
    .header-links {
        display: none;
        position: absolute;
        top: calc(100% + 6px);
        right: 0;
        flex-direction: column;
        gap: 8px;
        padding: 12px;
        border-radius: 12px;
        background: rgba(0, 0, 0, 0.92);
        border: 1px solid rgba(var(--glow-r), var(--glow-g), var(--glow-b), 0.28);
        box-shadow: 0 10px 26px rgba(0,0,0,0.45);
        z-index: 230;
    }

    #header .header-right.is-menu-open .header-links {
        display: flex;
    }

    /* Make dropdown items less wide than desktop buttons */
    #header .header-links .header-link {
        height: 32px;
        padding: 0 16px;
        font-size: 13px;
        justify-content: flex-start;
        min-width: 170px;
    }
}

/* --- Objectives footer panel --- */
.objectives-container {
    display: block; /* span entire middle footer column */
    position: relative;
    width: 100%;
    height: 100%;
    margin: 0; /* remove left offset so drawer can use full 30% column width */
}
.objectives-toggle {
    font-size: 14px;
    padding: 6px 16px;
    height: 34px;
    min-width: 160px;
    font-weight: 700;
}
/* Legacy objectives-drawer styles removed; now defined in objectives.css */
.objectives-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.objective-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 4px;
    color: #eaffea;
    font-family: 'Roboto Mono', monospace;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.objective-item:last-child { border-bottom: none; }
.objective-item.completed { color: #b6d9b6; opacity: 0.9; }
.objective-marker { width: 1.2em; text-align: center; color: #9fe29f; }
.objective-label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.objective-empty { color: #bfe6bf; opacity: 0.9; padding: 6px 4px; }

/* --- Objective Steps (drawer) --- */
.objective-steps {
    list-style: none;
    margin: 8px 0 0 0;
    padding: 0;
    border-top: 1px solid rgba(255,255,255,0.06);
}
.objective-step-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 2px;
    font-family: 'Roboto Mono', monospace;
    font-size: 12px;
    color: #eaffea;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}
.objective-step-item:last-child { border-bottom: none; }
.objective-step-item.done { color: #98c598; opacity: 0.85; }
.step-marker { width: 1.1em; text-align: center; color: #9fe29f; font-weight: 700; }
.objective-step-item.done .step-marker { color: #6fbf6f; }
.step-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.objective-steps-empty { margin: 8px 0 0 0; font-size: 12px; opacity: 0.85; }

@media (max-width: 700px) {
    .objectives-drawer { width: 90vw; left: 50%; transform: translateX(-50%) translateY(8px); }
}