.world-section {
    position: relative;
    display: flex;
    flex-direction: column !important;    /* Stack header on top of the content row */
    justify-content: center;   /* Centers everything vertically */
    align-items: center;       /* Centers everything horizontally */
    padding: 30px;
    width: 100%;
    min-height: 100vh;   /* Centers them perfectly vertically */
    
    background:

        radial-gradient(
            circle at top,
            #f8eed7 0%,
            #e8d4af 100vh
        );

    z-index: 3 !important;
    box-shadow: 0 -20px 40px rgba(76, 59, 31, 0.4);
    
}


.world-section::before {
    content: '';
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    
    background-image: url('/static/images/layout/paper_texture.jpg');
    background-repeat: repeat;
    background-size: auto; 
    
    /* Blends the texture cleanly *into the background gradient only* */
    mix-blend-mode: multiply; 
    opacity: 0.3; 
    pointer-events: none; 
    
    /* LOWER STACK LAYER: 
       By dropping this to 1, we can easily pull the text/art above it */
    z-index: 1; 
}

.flex-row-wrapper {
    display: flex;
    flex-direction: row;
    justify-content: center;   /* Centers the map and panel together */
    align-items: stretch;       /* Keeps them aligned nicely on their horizontal axis */
    width: auto;
    max-width: 100vw;        
    gap: 40px !important;       /* Lifts above paper texture */
    position: relative;
}

/* --- HEADER AREA --- */
.lore-header {
    text-align: center;
    margin-bottom: 20px;
    max-width: 700px;
}

.lore-title {
    font-size: 2.4rem;
    color: var(--dark);
    letter-spacing: 2px;
    margin: 0 0 15px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

.lore-deco {
    color: var(--light); /* Elegant light-gold accent diamonds */
    font-size: 1.5rem;
}


.map-container {
    position: relative;
    width: 35vw !important;  
    aspect-ratio: 169.33333 / 224.36667 !important; 
    max-width: 500px;          
    display: block;            /* Swapped from flex to block to prevent layout squishing */
    margin: 0 auto;
    justify-content: center;   
    z-index: 5 !important;
    overflow: hidden; /* Keeps scaled active overlays from clipping */
}


.base-map,
.region-overlay,
.hitbox-layer {

    position: absolute;
    display: block;
    inset: 0;
    width: 100% !important;
    height: 100% !important;
    
    /* CRITICAL FIX: Forces the overlay raster sheets and base map 
       to utilize the exact same scaling algorithm inside the aspect-ratio box */
    object-fit: contain !important; 
    
    /* Centers the assets inside the aspect ratio box model space */
    object-position: center center !important;
}

.base-map {

    filter: sepia(60%) brightness(80%);
    border-radius: 24px;
    z-index: 1;
}

.region-overlay {

    opacity: 0;
    z-index: 2;
    pointer-events: none;
    /* Smooth opacity filter transitions */
    transition: opacity 0.4s ease, transform 0.4s ease, filter 0.4s ease;
}

.region-overlay.active {
    

    opacity: 1;
    transform: scale(1.01);
    /* FIXED: We dropped transform: scale(1.01) because scaling a raster graphic 
       independently of the SVG matrix on mobile breaks pixel alignment targets.
       The neon drop shadow will give you that awesome highlight pop on its own! */
    filter: drop-shadow(0 0 20px rgba(255,210,120,0.7));
}

.hitbox-layer {

    z-index: 3; /* Floats perfectly on the very top of the asset stack */
}

.hitbox {

    fill: transparent;
    stroke: transparent;
    cursor: pointer;
    transition: fill 0.3s ease;
}

.hitbox:hover {
    fill: rgba(255,255,255,0.08);
}


.info-panel {
    width: 500px;
    margin-left: 40px;         /* Creates a nice gap between the map and the text */
    height: 78vh;
    padding-left: 38px;
    padding-right: 38px;
    position: relative;
}

.info-panel h2{
    margin-top: 4vh;
    justify-self: center;
    color: var(--light);
}

.info-panel p{
    color: var(--dark);
}

.info-panel::before {

    content: "";

    position: absolute;

    inset: 0;

    background:
        url("/static/images/layout/frame.png")
        center center
        no-repeat;

    background-size:
        100%
        100%;


    transform-origin:
        center;

    pointer-events: none;

    z-index: 5;

    mix-blend-mode: overlay;
}

.info-panel > * {

    position: relative;

    z-index: 10;
}

.region-image {

    width: 100%;

    height: 25vh;

    object-fit: cover;

    border-radius: 12px;

    margin: 1% 1%;

    border:
        2px solid rgba(140,90,40,0.4);
}

.hidden {

    display: none;
}

.region-icons {

    display: flex;

    flex-direction: column;

    gap: 10px;

    margin-top: 2vh;

    

}

.region-icon {

    display: flex;

    align-items: flex-start;

    gap: 14px;
}

.region-icon img {

    width: 30px;
    height: 30px;

    opacity: 0.85;
    
    filter: brightness(80%);
}

.region-icon h4 {

    margin: 0;

    font-size: 0.85rem;
    font-weight: bold;
    text-transform: uppercase;

    letter-spacing: 1px;

    color: var(--light);
}

.region-icon p {

    margin: 4px 0 0;

    line-height: 1.2;
}

/* THE MASTER CONTROL: Shrink this wrapper to scale the entire button */
.custom-game-btn.lore-btn {
   position: relative;
    
    /* CHANGE THIS: inline-block doesn't accept auto margins, block does! */
    display: block ; 
    
    width: 180px !important;         
    height: auto !important;         
    
    /* THE FIX: Auto handles left/right spacing, 25px keeps your top gap */
    margin: 12px auto 0 auto;
    
    cursor: pointer;
    text-decoration: none;

    transition: transform 0.15s cubic-bezier(0.25, 1, 0.5, 1), filter 0.15s ease;
    filter: drop-shadow(0px 6px 10px  rgba(95, 32, 7, 0.35));
}

/* THE BACKGROUND IMAGE: Forces the custom asset to fit the new smaller box */
.custom-game-btn.lore-btn .btn-bg-asset {
    width: 100% !important;
    height: auto !important;
    display: block;
}

/* THE CONTENT OVERLAY: Centers the text and icon inside the smaller button */
.custom-game-btn.lore-btn .btn-content-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%); /* Keeps text perfectly dead-center over the background asset */
    
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;                          /* Space between the ✦ star icon and text */
    width: 100%;
    white-space: nowrap;               /* Prevents the text from breaking into two lines */
}

/* FINE-TUNE TEXT & ICON SIZES FOR THE NEW BUTTON FOOTPRINT */
.custom-game-btn.lore-btn .btn-text-label {
    font-size: 0.75rem !important;     
}

.custom-game-btn.lore-btn .btn-icon-marker {
    font-size: 0.8rem !important;       
}

.custom-game-btn.lore-btn:hover {
     /* Slightly lifts the button up on the Y axis and pushes scale slightly */
    transform: translateY(-2px) scale(1.02);
    
    /* Enhances the drop shadow downwards as it lifts to simulate a 3D gap,
       and slightly brightens the whole button image graphic */
    filter: drop-shadow(0px 12px 18px  rgba(95, 32, 7, 0.45)) brightness(1.1);
}

.custom-game-btn.lore-btn:active {
     /* Provides physical compression clicking feedback */
    transform: translateY(-1px) scale(0.98);
    filter: drop-shadow(0px 3px 6px  rgba(95, 32, 7, 0.4)) brightness(0.95);
}

/* Hide the button initially until a map region is clicked */
.custom-game-btn.lore-btn.hidden-btn {
    display: none; /* Prevents ghost clicks while hidden */
}

@media screen and (max-width: 768px) {

    
    .flex-row-wrapper {
        flex-direction: column !important;
        align-items: center !important;
        gap: 25px !important;
    }

    .map-container {
        width: 90vw !important; /* The aspect-ratio property handles the height automatically now! */
        order: 2;
    }

    .info-panel {
        width: 90vw !important;
        height: auto;
        order: 1;
        margin: 0;
        padding-bottom: 2vh;
    }


    .region-image {

        height: 10vh;

    }

    .lore-header{
        margin-bottom: 0;
    }

    /* ==========================================================================
       2. LORE MAP LAYOUT: STACK SYSTEM (Panel top, Map bottom)
       ========================================================================== */
    .world-section {
        display: flex !important;
        flex-direction: column !important; /* Stacks panel and map vertically */
        justify-content: flex-start !important;
        padding: 20px 10px !important;
        gap: 10px;
    }

    /* THE MAP CONTAINER: Scales to fill the width of the phone display */
    .map-container {
        width: 95vw !important; /* Uses almost full screen width on mobile */
        max-width: 100%;
        margin: 0 auto !important;
        aspect-ratio: 2000 / 2650 !important; /* Preserves your exact ratio */
        order: 2; /* Puts the map underneath the initial text instructions */
    }
    /* ==========================================================================
       3. CUSTOM GRAPHIC BUTTON RESIZING
       ========================================================================== */

    /* THE INFO PANEL TEXT OVERRIDES */
    .info-panel h2 {
        font-size: 1.1rem !important; /* Crisp, readable title on phone screens */
    }

    .info-panel h4 {
        font-size: 0.6rem !important; /* Crisp, readable title on phone screens */
    }

    .info-panel p {
        font-size: 13px !important;    /* Small but legible print size for descriptions */
    }

    /* THE CUSTOM ACTION BUTTON IN THE PANEL */
    .custom-game-btn.lore-btn {
        padding: 8px 16px !important;  /* Slims down the button box padding */
        margin-top: 0px;
    }

    .custom-game-btn.lore-btn .btn-text-label {
        font-size: 0.7rem !important;  /* Prevents text from wrapping into two broken lines */
        letter-spacing: 0.5px;
    }
}