#infoPanel {
    position: relative;
    width: 20%;
    background-color: black;
    height: 100%;
    padding: 10px;
    box-sizing: border-box;
    display: flex;
    transition: width 0.3s ease, transform 0.3s ease;
    overflow: visible;
}

#infoPanel.collapsed {
    width: 40px;
    overflow: visible;
    padding: 0;
}

#infoPanel.collapsed::before {
    content: 'Resources';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(90deg);
    transform-origin: center;
    color: rgba(var(--glow-r), var(--glow-g), var(--glow-b), 0.97);
    font-size: 21px; /* slightly larger */
    font-weight: 800;
    letter-spacing: 1.5px; /* slightly more spacing */
    word-spacing: 2px;
    white-space: nowrap;
    pointer-events: none;
    z-index: 120;
    text-shadow:
        0 0 2px rgba(0,0,0,0.9),
        0 0 6px rgba(var(--glow-r), var(--glow-g), var(--glow-b), 0.60),
        0 0 12px rgba(var(--glow-r), var(--glow-g), var(--glow-b), 0.35);
}

#infoPanel.collapsed #infoPanelContent {
    opacity: 0;
    pointer-events: none;
}

/* Phone-landscape: treat the info panel as an overlay drawer so it doesn't steal width.
   (Desktop/tablet layout remains unchanged.) */
@media (max-width: 600px),
       (max-width: 900px) and (max-height: 450px),
       (hover: none) and (pointer: coarse) and (max-width: 900px) and (max-height: 600px) {
    #infoPanel {
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        height: auto;
        width: min(280px, 78vw);
        z-index: 60;
        padding: 8px;
        background-color: rgba(0, 0, 0, 0.68);
        backdrop-filter: blur(2px);
        -webkit-backdrop-filter: blur(2px);
        box-shadow: -10px 0 28px rgba(0,0,0,0.65);
    }

    #infoPanel.collapsed {
        width: 40px;
        padding: 0;
    }

    /* Replace the big rotated "Resources" label with just the chevron tab in compact mode */
    #infoPanel.collapsed::before {
        content: none;
        display: none;
    }

    /* When the right panel is collapsed in compact mode, show a small vitals rail
       (mirrors the left-side mobile menu icon sizing and positioning). */
    #infoPanel .info-vitals-icons {
        display: none;
    }

    #infoPanel.collapsed .info-vitals-icons {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: flex-start;
        gap: 6px;
        padding: 8px 4px;
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        overflow: hidden;
        z-index: 130;
        pointer-events: auto;
    }

    #infoPanel.collapsed .info-vital-orb {
        width: 30px;
        height: 30px;
        border-radius: 999px;
        border: 1px solid rgba(var(--glow-r), var(--glow-g), var(--glow-b), 0.22);
        position: relative;
        overflow: hidden;
        display: grid;
        place-items: center;
        box-sizing: border-box;
        box-shadow:
            0 0 10px rgba(0,0,0,0.65),
            0 0 10px rgba(var(--glow-r), var(--glow-g), var(--glow-b), 0.08) inset;

        /* Diablo-like orb: dark base + highlight; actual fill is rendered by ::before */
        --fill: 50%;
        --orb-r: 255;
        --orb-g: 255;
        --orb-b: 255;
        background:
            radial-gradient(circle at 30% 28%, rgba(255,255,255,0.16), rgba(255,255,255,0.0) 60%),
            radial-gradient(circle at 50% 55%, rgba(0,0,0,0.55), rgba(0,0,0,0.86) 70%);

        cursor: pointer;
        pointer-events: auto;
    }

    /* Filled portion (only the bottom part should be tinted). */
    #infoPanel.collapsed .info-vital-orb::before {
        content: '';
        position: absolute;
        left: 0;
        right: 0;
        bottom: 0;
        height: var(--fill);
        background:
            radial-gradient(circle at 35% 25%, rgba(255,255,255,0.10), rgba(255,255,255,0.0) 62%),
            linear-gradient(to top,
                rgba(var(--orb-r), var(--orb-g), var(--orb-b), 0.96) 0%,
                rgba(var(--orb-r), var(--orb-g), var(--orb-b), 0.78) 100%);
        filter: saturate(1.05);
        pointer-events: none;
        z-index: 1;
        transition: height 140ms linear;
    }

    #infoPanel.collapsed .info-vital-orb::after {
        content: '';
        position: absolute;
        inset: 2px;
        border-radius: 999px;
        box-shadow: 0 0 0 1px rgba(255,255,255,0.06) inset;
        pointer-events: none;
        z-index: 3;
    }

    #infoPanel.collapsed .info-vital-orb[data-vital="health"] { --orb-r: 231; --orb-g: 76;  --orb-b: 60; }
    #infoPanel.collapsed .info-vital-orb[data-vital="stamina"] { --orb-r: 255; --orb-g: 215; --orb-b: 0; }
    #infoPanel.collapsed .info-vital-orb[data-vital="water"] { --orb-r: 52;  --orb-g: 152; --orb-b: 219; }
    #infoPanel.collapsed .info-vital-orb[data-vital="food"] { --orb-r: 240; --orb-g: 240; --orb-b: 240; }

    #infoPanel.collapsed .info-vital-orb .orb-text {
        position: relative;
        z-index: 4;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 0;
        font-variant-numeric: tabular-nums;
        text-shadow:
            0 1px 2px rgba(0,0,0,0.92),
            0 0 6px rgba(0,0,0,0.65);
    }

    #infoPanel.collapsed .info-vital-orb .orb-current {
        font-size: 11px;
        font-weight: 900;
        line-height: 1;
        letter-spacing: -0.2px;
        color: rgba(0,0,0,0.92);
        text-shadow:
            0 1px 0 rgba(255,255,255,0.28),
            0 0 6px rgba(255,255,255,0.18),
            0 0 10px rgba(0,0,0,0.55);
    }
}

/* Forced compact mode (html.is-compact) should behave like the phone-landscape media rules,
   even on devices whose landscape width exceeds the legacy max-width cutoffs (e.g., ~915px). */
html.is-compact #infoPanel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    height: auto;
    width: min(280px, 78vw);
    z-index: 60;
    padding: 8px;
    background-color: rgba(0, 0, 0, 0.68);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    box-shadow: -10px 0 28px rgba(0,0,0,0.65);
}

html.is-compact #infoPanel.collapsed {
    width: 40px;
    padding: 0;
}

html.is-compact #infoPanel.collapsed::before {
    content: none;
    display: none;
}

html.is-compact #infoPanel .info-vitals-icons {
    display: none;
}

html.is-compact #infoPanel.collapsed .info-vitals-icons {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 6px;
    padding: 8px 4px;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
    z-index: 130;
    pointer-events: auto;
}

html.is-compact #infoPanel.collapsed .info-vital-orb {
    border-radius: 999px;
    border: 1px solid rgba(var(--glow-r), var(--glow-g), var(--glow-b), 0.22);
    position: relative;
    overflow: hidden;
    display: grid;
    place-items: center;
    box-sizing: border-box;
    box-shadow:
        0 0 10px rgba(0,0,0,0.65),
        0 0 10px rgba(var(--glow-r), var(--glow-g), var(--glow-b), 0.08) inset;

    /* Diablo-like orb: dark base + highlight; actual fill is rendered by ::before */
    --fill: 50%;
    --orb-r: 255;
    --orb-g: 255;
    --orb-b: 255;
    background:
        radial-gradient(circle at 30% 28%, rgba(255,255,255,0.16), rgba(255,255,255,0.0) 60%),
        radial-gradient(circle at 50% 55%, rgba(0,0,0,0.55), rgba(0,0,0,0.86) 70%);

    cursor: pointer;
    pointer-events: auto;
    width: 30px;
    height: 30px;
}

/* Filled portion (only the bottom part should be tinted). */
html.is-compact #infoPanel.collapsed .info-vital-orb::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: var(--fill);
    background:
        radial-gradient(circle at 35% 25%, rgba(255,255,255,0.10), rgba(255,255,255,0.0) 62%),
        linear-gradient(to top,
            rgba(var(--orb-r), var(--orb-g), var(--orb-b), 0.96) 0%,
            rgba(var(--orb-r), var(--orb-g), var(--orb-b), 0.78) 100%);
    filter: saturate(1.05);
    pointer-events: none;
    z-index: 1;
    transition: height 140ms linear;
}

html.is-compact #infoPanel.collapsed .info-vital-orb::after {
    content: '';
    position: absolute;
    inset: 2px;
    border-radius: 999px;
    box-shadow: 0 0 0 1px rgba(255,255,255,0.06) inset;
    pointer-events: none;
    z-index: 3;
}

html.is-compact #infoPanel.collapsed .info-vital-orb[data-vital="health"] { --orb-r: 231; --orb-g: 76;  --orb-b: 60; }
html.is-compact #infoPanel.collapsed .info-vital-orb[data-vital="stamina"] { --orb-r: 255; --orb-g: 215; --orb-b: 0; }
html.is-compact #infoPanel.collapsed .info-vital-orb[data-vital="water"] { --orb-r: 52;  --orb-g: 152; --orb-b: 219; }
html.is-compact #infoPanel.collapsed .info-vital-orb[data-vital="food"] { --orb-r: 240; --orb-g: 240; --orb-b: 240; }

html.is-compact #infoPanel.collapsed .info-vital-orb .orb-text {
    position: relative;
    z-index: 4;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0;
    font-variant-numeric: tabular-nums;
    text-shadow:
        0 1px 2px rgba(0,0,0,0.92),
        0 0 6px rgba(0,0,0,0.65);
}

html.is-compact #infoPanel.collapsed .info-vital-orb .orb-current {
    font-size: 11px;
    font-weight: 900;
    line-height: 1;
    letter-spacing: -0.2px;
    color: rgba(0,0,0,0.92);
    text-shadow:
        0 1px 0 rgba(255,255,255,0.28),
        0 0 6px rgba(255,255,255,0.18),
        0 0 10px rgba(0,0,0,0.55);
}

#infoPanelContent {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.info-section {
    width: 100%;
    height: 100%;
    overflow-y: auto;
    scrollbar-width: none;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.info-category {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.info-category-header {
    margin-top: 10px;
    /* Align category header text with the left edge of resource bars/rows */
    padding: 4px 0 2px 0;
    color: rgba(var(--glow-r), var(--glow-g), var(--glow-b), 0.85);
    font-size: 14px;
    font-weight: 800;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    text-shadow:
        0 0 2px rgba(0,0,0,0.85),
        0 0 8px rgba(var(--glow-r), var(--glow-g), var(--glow-b), 0.25);
}

.info-category:first-child .info-category-header {
    margin-top: 0;
}

.info-category-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.info-section::-webkit-scrollbar {
    display: none;
}

.info-row {
    position: relative;
    display: grid;
    grid-template-columns: 6fr 7fr 5fr;
    align-items: center;
    /* MODIFIED: Reduced vertical padding */
    padding: 4px 10px;
    color: #EAEAEA;
    gap: 10px;
    background-color: #111;
    border-radius: 4px;
    overflow: hidden;
    transition: background-color 0.2s ease;
    flex-shrink: 0;
    /* MODIFIED: Reduced the fixed height */
    height: 26px;
}

.info-row.non-producible {
    /* Keep columns consistent across all resources.
       Some "non-producible" resources can still gain production from jobs/buildings
       and should keep the generation column aligned. */
    grid-template-columns: 6fr 7fr 5fr;
}

.info-row:hover {
    background-color: #2a2a2a;
    cursor: help;
}

.resource-progress-bar {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0%;
    background-color: rgba(var(--glow-r), var(--glow-g), var(--glow-b), 0.2);
    z-index: 1;
    transition: width 0.2s ease-out;
}

/* Ensure text over the Stamina bar is readable */
.info-row[data-resource="Stamina"] {
    color: rgba(255, 215, 0, 0.9);
}

.info-row[data-resource="Stamina"] .resource-progress-bar {
    background-color: rgba(255, 215, 0, 0.18);
}

/* Health should read as a red vital */
.info-row[data-resource="Health"] {
    color: rgba(231, 76, 60, 0.95);
}

.info-row[data-resource="Health"] .resource-progress-bar {
    background-color: rgba(231, 76, 60, 0.20);
}

/* Morale row: always full bar; color tint varies by level */
.info-row.morale .resource-progress-bar {
    width: 100% !important;
    transition: none;
}
.info-row.morale.morale-high .resource-progress-bar { background-color: rgba(80, 200, 120, 0.25); }
.info-row.morale.morale-mid  .resource-progress-bar { background-color: rgba(255, 200, 0, 0.22); }
.info-row.morale.morale-low  .resource-progress-bar { background-color: rgba(231, 76, 60, 0.22); }
.info-row.morale span, .info-row.morale p { color: #EAEAEA; }

.infocolumn1, .infocolumn2, .infocolumn3 {
    display: flex;
    align-items: center;
    height: 100%;
    z-index: 2;
    min-width: 0;
}

.infocolumn1 { justify-content: flex-start; }
.infocolumn2, .infocolumn3 { justify-content: flex-end; }

.info-row {
    position: relative;
}

.info-row .infocolumn1 {
    display: inline-flex;
    align-items: center;
    gap: 8px; /* space between icon and text */
}

.info-row span,
.info-row p {
    margin: 0;
    font-size: 11px;
    white-space: nowrap;
    font-weight: 600; /* unify with Survivors weight */
}

.infocolumn1 span {
    font-weight: bold;
    overflow: hidden;
    text-overflow: ellipsis;
}

.info-row .zero-amount {
    color: #E74C3C;
    font-weight: bold;
}

.info-row .negative-rate {
    color: #E74C3C;
    font-weight: 600; /* unify with other values */
}

.info-row.insight-resource {
    color: #FFD700;
}

/* Morale layout: place the % value on the far right */
.info-row.morale .infocolumn2 {
    /* Move the morale value cell into the third grid column (right side) */
    grid-column: 3;
    justify-content: flex-end;
}
.info-row.morale .infocolumn3 {
    /* Hide the unused third cell so it doesn't occupy space */
    display: none;
}

/* Ensure ordering: Morale first, Survivors directly after */
.info-row.morale { order: -2; }
.info-row.survivors { order: -1; }

/* Survivors: hide the progress bar and the generation column; keep value right-aligned */
/* Survivors row: keep standard 3-column grid, move value to right column */
.info-row.survivors {
    grid-template-columns: 6fr 7fr 5fr; /* match default */
    grid-template-rows: initial;
    height: 26px;
    padding: 4px 10px;
    gap: 10px;
}
.info-row.survivors .infocolumn1 { grid-column: 1; justify-content: flex-start; }
.info-row.survivors .infocolumn2 { grid-column: 3; justify-content: flex-end; }
.info-row.survivors .infocolumn3 { display: none; }

/* Survivors progress bar: always full */
.info-row.survivors .resource-progress-bar { width: 100% !important; }

/* Survivors value styling */
.info-row.survivors [data-value-type="storage"] {
    font-size: 12px;
    font-weight: 600;
    color: #e6ffe6;
}

/* Debuff icon inside resource row: symbol only */
.info-row .debuff-icon {
    display: none; /* shown when .active is added */
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    min-width: 18px;
    border-radius: 50%;
    margin-right: 6px;
    color: #111;
    background: #ffd84a;
    font-size: 14px;
    font-weight: 900;
    line-height: 1;
    box-shadow:
        0 0 6px rgba(255, 216, 74, 0.85),
        0 0 10px rgba(255, 216, 74, 0.45);
    pointer-events: auto;   /* ensure it receives mouse events */
    position: relative; 
    z-index: 999; 
}

/* show when active */
.info-row .debuff-icon.active {
    display: inline-flex !important;
}

.info-row .debuff-icon .debuff-badge {
    pointer-events: none;
}

/* Visually indicate actions blocked until the nearby sound has been investigated */
.blocked-investigate-sound {
    opacity: 0.55;
    filter: grayscale(30%);
    cursor: not-allowed;
}

/* keep cancel-text and tooltip behavior functional even when visually blocked */
.blocked-investigate-sound .cancel-text { opacity: 0.6; }