/* ============================================================
   SHADOWSKINGS — MAP OVERLAY
   WORKING MAP FOUNDATION / 8 BUTTON VERSION
   DESKTOP + IPHONE + ANDROID
============================================================ */


/* ============================================================
   ROOT
   IMPORTANT:
   THIS MATCHES THE KNOWN-WORKING MAP FOUNDATION
============================================================ */

#map-overlay-root {
    position: fixed;

    inset: 0;

    width: 100vw;
    height: 100dvh;

    pointer-events: none;

    z-index: 9000;

    font-family:
        "Cinzel",
        "Trajan Pro",
        serif;

    color: #e5d9ff;
}


/* ============================================================
   OVERLAY VEIL
============================================================ */

#map-overlay-root .overlay-veil {
    position: fixed;

    inset: 0;

    background:
        radial-gradient(
            circle at top,
            rgba(40,20,80,0.9),
            rgba(5,5,15,0.95)
        );

    backdrop-filter:
        blur(4px);

    -webkit-backdrop-filter:
        blur(4px);

    display: flex;

    justify-content: center;
    align-items: center;

    opacity: 0;

    pointer-events: none;

    transition:
        opacity 0.25s ease-in-out;

    z-index: 9001;
}


#map-overlay-root .overlay-veil.active {
    opacity: 1;

    pointer-events: all;
}


/* ============================================================
   MAP OVERLAY ROOT
   IMPORTANT:
   KEEP RELATIVE — THIS IS FROM THE WORKING BACKUP
============================================================ */

#mapOverlay {
    position: relative;

    width: 100%;
    height: 100%;

    pointer-events: none;
}


/* ============================================================
   MAP CANVAS
   IMPORTANT:
   THIS IS THE KNOWN-WORKING CANVAS STRUCTURE
============================================================ */

#mapOverlay #map-canvas {
    position: absolute;

    inset: 0;

    width: 100%;
    height: 100%;

    display: block;

    image-rendering: pixelated;

    pointer-events: auto;

    z-index: 1;
}


/* ============================================================
   LEGEND PANEL
============================================================ */

#mapOverlay #mapLegendPanel {
    position: absolute;

    top: 18px;
    left: 18px;

    min-width: 260px;
    max-width: 320px;

    background:
        radial-gradient(
            circle at top left,
            rgba(40,20,80,0.95),
            rgba(10,5,25,0.98)
        );

    border:
        1px solid #7b4bff;

    border-radius:
        10px;

    padding:
        12px 14px;

    box-shadow:
        0 0 18px
        rgba(123,75,255,0.6);

    font-size:
        12px;

    line-height:
        1.35;

    pointer-events:
        auto;

    z-index:
        5;

    transition:
        height 0.25s ease,
        padding 0.25s ease,
        opacity 0.25s ease;

    cursor:
        pointer;
}


/* ============================================================
   LEGEND HEADER
============================================================ */

#mapOverlay #mapLegendPanel h2 {
    margin:
        0 0 6px 0;

    font-size:
        14px;

    letter-spacing:
        0.08em;

    text-transform:
        uppercase;

    color:
        #f3e8ff;

    text-shadow:
        0 0 6px
        #7b4bff;

    border-bottom:
        1px solid
        rgba(180,150,255,0.4);

    padding-bottom:
        4px;
}


/* ============================================================
   LEGEND ITEMS
============================================================ */

#mapOverlay #mapLegendPanel .legendItem {
    display:
        flex;

    align-items:
        center;

    gap:
        6px;

    margin:
        2px 0;
}


#mapOverlay #mapLegendPanel .legendColor {
    width:
        12px;

    height:
        12px;

    border-radius:
        3px;
}


/* ============================================================
   LEGEND COLLAPSED
============================================================ */

#mapOverlay #mapLegendPanel.collapsed {
    height:
        32px;

    overflow:
        hidden;

    padding:
        6px 10px;

    opacity:
        0.85;
}


#mapOverlay #mapLegendPanel.collapsed h2 {
    margin-bottom:
        0;

    border-bottom:
        none;

    padding-bottom:
        0;
}


/* ============================================================
   CLOCK DISPLAY
============================================================ */

#mapOverlay #mapClockDisplay {
    position:
        absolute;

    top:
        14px;

    left:
        50%;

    transform:
        translateX(-50%);

    padding:
        6px 14px;

    background:
        linear-gradient(
            to right,
            rgba(20,10,40,0.95),
            rgba(40,20,80,0.98),
            rgba(20,10,40,0.95)
        );

    border-radius:
        999px;

    border:
        1px solid #8f6bff;

    font-size:
        12px;

    letter-spacing:
        0.08em;

    text-transform:
        uppercase;

    color:
        #f5ecff;

    text-shadow:
        0 0 6px
        #8f6bff;

    box-shadow:
        0 0 16px
        rgba(143,107,255,0.7);

    pointer-events:
        auto;

    z-index:
        6;
}


/* ============================================================
   ACTION BAR — DESKTOP
   8 BUTTON VERSION
============================================================ */

#mapOverlay .map-action-bar,
#mapOverlay #mapActionBar {
    position:
        absolute;

    left:
        50%;

    bottom:
        18px;

    transform:
        translateX(-50%);

    width:
        min(
            calc(100vw - 80px),
            980px
        );

    min-width:
        700px;

    max-width:
        980px;

    box-sizing:
        border-box;

    padding:
        10px 14px;

    background:
        radial-gradient(
            circle at bottom,
            rgba(20,10,40,0.95),
            rgba(5,3,12,0.98)
        );

    border-radius:
        12px;

    border:
        1px solid #7b4bff;

    box-shadow:
        0 0 22px
            rgba(123,75,255,0.7),
        0 0 6px
            rgba(0,0,0,0.9);

    pointer-events:
        auto;

    z-index:
        7;
}


/* ============================================================
   ACTION BAR INNER
============================================================ */

#mapOverlay .mapActionBar-inner {
    display:
        flex;

    flex-direction:
        row;

    align-items:
        center;

    justify-content:
        space-between;

    width:
        100%;

    gap:
        16px;
}


/* ============================================================
   PLAYER INFO
============================================================ */

#mapOverlay .playerInfoBlock {
    display:
        flex;

    flex-direction:
        column;

    gap:
        2px;

    flex:
        0 0 auto;

    min-width:
        110px;

    font-size:
        11px;

    color:
        #e5d9ff;

    text-shadow:
        0 0 4px
        #7b4bff;
}


#mapOverlay .playerInfoLine {
    display:
        flex;

    align-items:
        center;

    gap:
        4px;

    white-space:
        nowrap;
}


#mapOverlay .playerInfoLine .label {
    color:
        #c8b7f5;
}


/* ============================================================
   BUTTON CONTAINER — DESKTOP
   8 BUTTONS IN ONE ROW
============================================================ */

#mapOverlay .actionButtons {
    display:
        grid;

    grid-template-columns:
        repeat(
            8,
            minmax(0, 1fr)
        );

    gap:
        7px;

    flex:
        1 1 auto;

    min-width:
        0;
}


/* ============================================================
   BUTTONS
============================================================ */

#mapOverlay .actionButton {
    display:
        flex;

    justify-content:
        center;

    align-items:
        center;

    width:
        100%;

    min-width:
        0;

    min-height:
        38px;

    box-sizing:
        border-box;

    background:
        linear-gradient(
            to bottom,
            #3b2375,
            #241347
        );

    border:
        1px solid #a98bff;

    border-radius:
        6px;

    padding:
        6px 7px;

    font-size:
        9px;

    font-family:
        inherit;

    font-weight:
        700;

    text-transform:
        uppercase;

    letter-spacing:
        0.045em;

    color:
        #f3e8ff;

    cursor:
        pointer;

    box-shadow:
        0 0 10px
        rgba(169,139,255,0.7);

    transition:
        transform 0.1s ease,
        box-shadow 0.1s ease,
        background 0.1s ease;

    white-space:
        nowrap;

    text-align:
        center;

    touch-action:
        manipulation;
}


#mapOverlay .actionButton:hover {
    transform:
        translateY(-1px);

    background:
        linear-gradient(
            to bottom,
            #50329a,
            #30185d
        );

    box-shadow:
        0 0 14px
        rgba(169,139,255,0.9);
}


#mapOverlay .actionButton:active {
    transform:
        translateY(1px);
}


/* ============================================================
   TABLET / SMALL DESKTOP
============================================================ */

@media
(max-width: 1100px)
and
(min-width: 901px) {

    #mapOverlay .map-action-bar,
    #mapOverlay #mapActionBar {
        width:
            calc(100vw - 40px);

        min-width:
            0;

        max-width:
            none;
    }


    #mapOverlay .playerInfoBlock {
        min-width:
            90px;

        font-size:
            10px;
    }


    #mapOverlay .actionButtons {
        gap:
            5px;
    }


    #mapOverlay .actionButton {
        padding:
            6px 4px;

        font-size:
            8px;
    }
}


/* ============================================================
   MOBILE — IPHONE / ANDROID
   8 BUTTONS = 4 TOP + 4 BOTTOM
============================================================ */

@media (max-width: 900px) {


    /* --------------------------------------------------------
       ROOT
    -------------------------------------------------------- */

    #map-overlay-root {
        width:
            100vw;

        height:
            100vh;

        height:
            100dvh;
    }


    /* --------------------------------------------------------
       MAP OVERLAY
    -------------------------------------------------------- */

    #mapOverlay {
        width:
            100%;

        height:
            100%;
    }


    /* --------------------------------------------------------
       MAP CANVAS
       PRESERVED FROM WORKING BACKUP
    -------------------------------------------------------- */

    #mapOverlay #map-canvas {
        width:
            100vw;

        height:
            100vh;

        height:
            100dvh;

        display:
            block;
    }


    /* --------------------------------------------------------
       ACTION BAR
    -------------------------------------------------------- */

    #mapOverlay .map-action-bar,
    #mapOverlay #mapActionBar {
        position:
            fixed;

        left:
            0;

        right:
            0;

        bottom:
            0;

        width:
            100%;

        min-width:
            0;

        max-width:
            none;

        transform:
            none;

        border-radius:
            12px 12px 0 0;

        padding:
            10px
            16px
            calc(
                env(
                    safe-area-inset-bottom,
                    0px
                )
                +
                40px
            );

        box-sizing:
            border-box;

        overflow-x:
            hidden;

        overflow-y:
            auto;

        max-height:
            60vh;

        pointer-events:
            auto;

        z-index:
            999999;

        background:
            radial-gradient(
                circle at bottom,
                rgba(20,10,40,0.98),
                rgba(5,3,12,0.99)
            );

        border:
            1px solid #7b4bff;

        box-shadow:
            0 0 22px
                rgba(123,75,255,0.7),
            0 0 6px
                rgba(0,0,0,0.9);
    }


    /* --------------------------------------------------------
       INNER BAR
    -------------------------------------------------------- */

    #mapOverlay .mapActionBar-inner {
        display:
            flex;

        flex-direction:
            column;

        align-items:
            stretch;

        justify-content:
            flex-start;

        width:
            100%;

        gap:
            10px;
    }


    /* --------------------------------------------------------
       PLAYER INFO
    -------------------------------------------------------- */

    #mapOverlay .playerInfoBlock {
        display:
            flex;

        flex-direction:
            row;

        justify-content:
            center;

        align-items:
            center;

        flex-wrap:
            wrap;

        width:
            100%;

        min-width:
            0;

        gap:
            3px 12px;

        text-align:
            center;

        font-size:
            10px;

        line-height:
            1.3;
    }


    /* --------------------------------------------------------
       BUTTON GRID

       8 BUTTONS:

       [ 1 ] [ 2 ] [ 3 ] [ 4 ]
       [ 5 ] [ 6 ] [ 7 ] [ 8 ]

    -------------------------------------------------------- */

    #mapOverlay .actionButtons {
        display:
            grid;

        grid-template-columns:
            repeat(
                4,
                minmax(0, 1fr)
            );

        gap:
            8px;

        width:
            100%;

        overflow:
            visible;

        box-sizing:
            border-box;
    }


    /* --------------------------------------------------------
       MOBILE BUTTONS
    -------------------------------------------------------- */

    #mapOverlay .actionButton {
        display:
            flex;

        justify-content:
            center;

        align-items:
            center;

        width:
            100%;

        min-width:
            0;

        min-height:
            40px;

        padding:
            7px 5px;

        box-sizing:
            border-box;

        text-align:
            center;

        white-space:
            normal;

        word-break:
            normal;

        overflow-wrap:
            anywhere;

        font-size:
            9px;

        line-height:
            1.15;

        background:
            linear-gradient(
                to bottom,
                #3b2375,
                #241347
            );

        border:
            1px solid #a98bff;

        border-radius:
            6px;

        color:
            #f3e8ff;

        box-shadow:
            0 0 10px
            rgba(169,139,255,0.7);

        cursor:
            pointer;
    }


    /* --------------------------------------------------------
       LEGEND
    -------------------------------------------------------- */

    #mapOverlay #mapLegendPanel {
        top:
            10px;

        left:
            10px;

        min-width:
            0;

        width:
            auto;

        max-width:
            calc(100vw - 20px);

        font-size:
            11px;
    }


    /* --------------------------------------------------------
       CLOCK
    -------------------------------------------------------- */

    #mapOverlay #mapClockDisplay {
        top:
            8px;

        font-size:
            11px;

        max-width:
            90vw;

        box-sizing:
            border-box;

        white-space:
            nowrap;

        overflow:
            hidden;

        text-overflow:
            ellipsis;
    }
}


/* ============================================================
   VERY SMALL PHONES
============================================================ */

@media (max-width: 430px) {

    #mapOverlay .map-action-bar,
    #mapOverlay #mapActionBar {
        padding-left:
            8px;

        padding-right:
            8px;

        padding-top:
            8px;

        padding-bottom:
            calc(
                env(
                    safe-area-inset-bottom,
                    0px
                )
                +
                30px
            );
    }


    #mapOverlay .mapActionBar-inner {
        gap:
            7px;
    }


    #mapOverlay .actionButtons {
        gap:
            5px;
    }


    #mapOverlay .actionButton {
        min-height:
            36px;

        padding:
            6px 3px;

        font-size:
            8px;

        letter-spacing:
            0.02em;
    }


    #mapOverlay .playerInfoBlock {
        font-size:
            9px;
    }


    #mapOverlay #mapClockDisplay {
        font-size:
            9px;

        max-width:
            70vw;
    }
}


/* ============================================================
   LANDSCAPE PHONE
============================================================ */

@media
(max-width: 900px)
and
(orientation: landscape)
and
(max-height: 520px) {

    #mapOverlay .map-action-bar,
    #mapOverlay #mapActionBar {
        padding-bottom:
            calc(
                env(
                    safe-area-inset-bottom,
                    0px
                )
                +
                10px
            );

        max-height:
            75vh;
    }


    #mapOverlay .playerInfoBlock {
        display:
            none;
    }


    #mapOverlay .actionButton {
        min-height:
            32px;
    }


    #mapOverlay #mapLegendPanel {
        max-height:
            45vh;

        overflow-y:
            auto;
    }
}


/* ============================================================
   REDUCED MOTION
============================================================ */

@media (prefers-reduced-motion: reduce) {

    #map-overlay-root *,
    #map-overlay-root *::before,
    #map-overlay-root *::after {
        transition-duration:
            0.001ms !important;

        animation-duration:
            0.001ms !important;

        animation-iteration-count:
            1 !important;
    }
}