.hidden {
    display: none !important;
}

/* Ensure native `hidden` stays non-rendered even if author CSS sets `display`. */
[hidden] {
    display: none !important;
}

.game-section:not(.hidden) {
    z-index: 2; /* Add this line */
}

.game-section {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
	color: white;
}

#gameArea {
  width: 60%;
  height: 100%;
  background-color: #34495e;
  overflow: hidden;
  position: relative;
  transition: width 0.3s ease;
}

#gameArea.expanded-left {
  width: 80%;
}

#gameArea.expanded-right {
  width: 80%;
}

#gameArea.expanded-both {
  width: 100%;
}

#gameArea::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5); 
  pointer-events: none; 
  z-index: -1; 
}

/* Phone-landscape: let the center game area fill remaining space.
     The right info panel becomes an overlay drawer, so the desktop width % rules would waste space. */
@media (max-width: 600px),
       (max-width: 900px) and (max-height: 450px),
       (hover: none) and (pointer: coarse) and (max-width: 900px) and (max-height: 600px) {
    /* Keep the section/background full-bleed, but inset the *content panel*
       so it doesn't sit under the collapsed drawer tabs.
       (Classes are applied to <html> by ui/panelCollapse.js.) */
    #mainContainer {
        --content-edge-inset: 3px;
    }

    /* When a side is collapsed, use a symmetric inset so the content stays centered. */
    html.left-panel-collapsed #mainContainer {
        --content-edge-inset: 43px; /* 40px rail + 3px gap */
    }

    html.right-panel-collapsed #mainContainer {
        --content-edge-inset: 43px; /* 40px rail + 3px gap */
    }

    #gameArea,
    #gameArea.expanded-left,
    #gameArea.expanded-right,
    #gameArea.expanded-both {
        width: auto;
        flex: 1 1 auto;
        transition: none;
        padding-left: 0;
        padding-right: 0;
        box-sizing: border-box;
    }

    /* Ensure absolutely-positioned sections remain full-bleed in compact mode. */
    .game-section {
        left: 0;
        right: 0;
        width: 100%;
    }

    /* Center the section's main panel and keep it clear of collapsed rails. */
    .game-section .content-panel {
        width: auto;
        align-self: stretch;
        min-width: 0;
        margin-left: var(--content-edge-inset, 8px);
        margin-right: var(--content-edge-inset, 8px);
    }
}

/* Same compact behavior when ui/compactMode.js sets html.is-compact (covers wider phone-landscape viewports). */
html.is-compact #mainContainer {
    --content-edge-inset: 3px;
}

html.is-compact.left-panel-collapsed #mainContainer {
    --content-edge-inset: 43px; /* 40px rail + 3px gap */
}

html.is-compact.right-panel-collapsed #mainContainer {
    --content-edge-inset: 43px; /* 40px rail + 3px gap */
}

html.is-compact #gameArea,
html.is-compact #gameArea.expanded-left,
html.is-compact #gameArea.expanded-right,
html.is-compact #gameArea.expanded-both {
    width: auto;
    flex: 1 1 auto;
    transition: none;
    padding-left: 0;
    padding-right: 0;
    box-sizing: border-box;
}

html.is-compact .game-section {
    left: 0;
    right: 0;
    width: 100%;
}

html.is-compact .game-section .content-panel {
    width: auto;
    align-self: stretch;
    min-width: 0;
    margin-left: var(--content-edge-inset, 8px);
    margin-right: var(--content-edge-inset, 8px);
}

/* Shared content panel (centralized) */
.content-panel {
    /* very dark, near-opaque panel for maximum readability over art */
    position: relative;
    background-color: rgba(6, 6, 6, 0.89);
    border: 1px solid rgba(var(--glow-r), var(--glow-g), var(--glow-b), 0.56);
    border-radius: 6px;
    width: 100%;
    height: 100%;
    padding: 25px;
    box-sizing: border-box;
    overflow-y: auto;
    scrollbar-gutter: stable;

    /* elevation / glow */
    box-shadow: 0 10px 34px rgba(0,0,0,0.75), 0 0 28px rgba(var(--glow-r), var(--glow-g), var(--glow-b), 0.16);
}

/* Phone-landscape: reduce padding to maximize usable space */
@media (max-width: 600px),
       (max-width: 900px) and (max-height: 450px),
       (hover: none) and (pointer: coarse) and (max-width: 900px) and (max-height: 600px) {
    .content-panel {
        padding: 6px;
    }
}

html.is-compact .content-panel {
    padding: 6px;
}

/* progress bar used by image-button */
.action-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.25);
    z-index: 1;
    transition: width 0.1s linear;
}

/* ===================================================================
   IMAGE BUTTON - Shared button component for actions and buildings
   =================================================================== */

/* Base style for all image-based buttons */
.image-button {
    /* --- Sizing and Layout --- */
    width: 180px;
    height: 55px;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 0 10px;

    /* --- Background Image --- */
    background-image: url('../../assets/images/PNG/Button03.png');
    background-size: 100% 100%;
    background-color: transparent;

    /* --- Text and Font --- */
    color: #EAEAEA;
    font-size: 14px;
    font-weight: bold;
    text-shadow: 1px 1px 2px #000;

    /* --- General --- */
    border: none;
    cursor: pointer;
    transition: transform 0.15s ease;
}

/* Allow the combat badge to sit slightly outside the button */
.image-button.action-has-combat {
    overflow: visible;
}

/* Allow the unknown badge to sit slightly outside the button */
.image-button.action-has-unknown {
    overflow: visible;
}

.image-button:hover {
    background-image: url('../../assets/images/PNG/Button04.png');
    color: #FFF;
    transform: scale(1.05);
}

/* Special element for the building count */
.building-count {
    font-size: 14px;
    background-color: transparent;
    padding: 0;
    border-radius: 0;
    color: #90EE90;
}

/* ensure button label sits above progress bar */
.image-button .building-name {
    position: relative;
    z-index: 4;
}

/* "New" badge for newly unlocked actions/buildings (and hint badges that reuse the same visual) */
.image-button .action-new-badge,
.image-button .action-hint-badge {
    position: absolute;
    top: 8px;
    right: 10px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 14px;
    font-weight: 900;
    line-height: 1;
    color: #111;
    background: #ffd84a;
    box-shadow:
        0 0 6px rgba(255, 216, 74, 0.85),
        0 0 10px rgba(255, 216, 74, 0.45);
    z-index: 3;
    pointer-events: none;
}

/* Combat badge for actions that will start an encounter */
.image-button.action-has-combat .action-combat-badge {
    position: absolute;
    top: -14px;
    left: 50%;
    transform: translateX(-50%);
    width: 22px;
    height: 22px;
    display: grid;
    place-items: center;
    color: rgba(255, 85, 85, 0.98);
    background: rgba(8, 8, 8, 0.72);
    border: 1px solid rgba(255, 85, 85, 0.78);
    border-radius: 999px;
    text-shadow: 0 1px 2px rgba(0,0,0,0.75);
    box-shadow:
        0 2px 10px rgba(0,0,0,0.55),
        0 0 10px rgba(255, 85, 85, 0.22);
    z-index: 3;
    pointer-events: none;
}

.image-button.action-has-combat .action-combat-badge svg {
    width: 16px;
    height: 16px;
    display: block;
}

/* Unknown-outcome badge for exploration/search actions */
.image-button.action-has-unknown .action-unknown-badge {
    position: absolute;
    top: -14px;
    left: 50%;
    transform: translateX(-50%);
    width: 22px;
    height: 22px;
    display: grid;
    place-items: center;
    color: rgba(255, 216, 74, 0.98);
    background: rgba(8, 8, 8, 0.72);
    border: 1px solid rgba(255, 216, 74, 0.78);
    border-radius: 999px;
    text-shadow: 0 1px 2px rgba(0,0,0,0.75);
    box-shadow:
        0 2px 10px rgba(0,0,0,0.55),
        0 0 10px rgba(255, 216, 74, 0.22);
    z-index: 3;
    pointer-events: none;
}

.image-button.action-has-unknown .action-unknown-badge svg {
    width: 18px;
    height: 18px;
    display: block;
}

/* hidden "Abort?" text behavior shared by sections */
.image-button .cancel-text {
    display: none;
    position: relative;
    z-index: 2;
    color: #E74C3C;
    font-weight: bold;
}
.image-button.confirm-cancel .building-name { display: none; }
.image-button.confirm-cancel .cancel-text { display: inline; }

/* Click animation for image buttons */
@keyframes button-click-bounce {
    0% { transform: scale(1); }
    50% { transform: scale(0.9); }
    100% { transform: scale(1); }
}

.is-clicking {
    animation: button-click-bounce 0.2s ease;
}

/* small utility to indicate a visually-blocked action */
.content-panel::-webkit-scrollbar { width: 12px; }
.content-panel::-webkit-scrollbar-track { background: #0b0b0b; }
.content-panel::-webkit-scrollbar-thumb {
    background-color: rgba(136,136,136,0.9);
    border-radius: 6px;
    border: 3px solid #0b0b0b;
}
.content-panel::-webkit-scrollbar-thumb:hover { background-color: #666; }

/* small utility to indicate a visually-blocked action */
.image-button.blocked-action {
    filter: grayscale(55%);
    opacity: 0.68;
    cursor: not-allowed;
}

.image-button.blocked-action:hover {
    background-image: url('../../assets/images/PNG/Button03.png');
    color: #EAEAEA;
    transform: none;
}

.image-button.blocked-action .building-name {
    color: #ffd84a;
    text-shadow: none;
}

/* Unaffordable button state - applies to all sections */
.image-button.unaffordable {
    filter: grayscale(60%);
    opacity: 0.7;
    cursor: not-allowed;
}

/* Building buttons: avoid filter on the whole button (it blurs text on some browsers). */
.image-button.unaffordable[data-building] {
    filter: none;
}

/* Make the text color red for unaffordable items */
.image-button.unaffordable .building-name {
    color: #E74C3C;
    text-shadow: none;
}

.image-button.unaffordable .building-count {
    color: #E74C3C;
    text-shadow: none;
}

/* Storage full (reward would be wasted) */
.image-button.capacity-blocked {
    filter: grayscale(55%);
    opacity: 0.68;
    cursor: not-allowed;
}

.image-button.capacity-blocked:hover {
    background-image: url('../../assets/images/PNG/Button03.png');
    color: #EAEAEA;
    transform: none;
}

.image-button.capacity-blocked .building-name {
    color: #ffd84a;
    text-shadow: none;
}

/* Shared custom scrollbar for content-panel */