/*
 * Eggy Pool mobile-friendly foundation.
 *
 * Phone-only runtime classes are applied by mobile.js.
 * Desktop/tablet presentation is untouched.
 */


/* ============================================================
   ORIENTATION / FULLSCREEN GATE
   ============================================================ */

.epPoolMobileGate
{
    position: fixed;
    inset: 0;
    z-index: 2147483000;

    display: grid;
    place-items: center;

    width: 100vw;
    height: 100dvh;

    padding:
        max(18px, env(safe-area-inset-top))
        max(18px, env(safe-area-inset-right))
        max(18px, env(safe-area-inset-bottom))
        max(18px, env(safe-area-inset-left));

    box-sizing: border-box;

    background:
        radial-gradient(
            circle at 50% 35%,
            rgba(57, 185, 120, .12),
            transparent 38%
        ),
        #090c0e;

    color: #f4f4f4;
}

.epPoolMobileGate[hidden]
{
    display: none !important;
}

.epPoolMobileGate__card
{
    width: min(360px, 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.epPoolMobileGate__device
{
    position: relative;

    width: 66px;
    height: 108px;

    margin-bottom: 20px;

    border: 4px solid rgba(255, 255, 255, .82);
    border-radius: 12px;

    transform: rotate(90deg);

    opacity: .92;
}

.epPoolMobileGate__device:before
{
    content: "";

    position: absolute;
    left: 50%;
    bottom: 5px;

    width: 7px;
    height: 7px;

    border-radius: 50%;

    background: rgba(255, 255, 255, .74);

    transform: translateX(-50%);
}

.epPoolMobileGate__device span
{
    position: absolute;
    inset: 8px 6px 17px;

    border-radius: 5px;

    background:
        linear-gradient(
            145deg,
            rgba(57, 185, 120, .22),
            rgba(255, 255, 255, .035)
        );
}

.epPoolMobileGate__title
{
    color: #fff;

    font-size: 23px;
    line-height: 1.1;
    font-weight: 850;
}

.epPoolMobileGate__text
{
    max-width: 310px;

    margin-top: 8px;

    color: rgba(255, 255, 255, .64);

    font-size: 13px;
    line-height: 1.45;
}

.epPoolMobileGate__button
{
    min-width: 210px;
    min-height: 44px;

    margin-top: 18px;
    padding: 10px 20px;

    border: 1px solid rgba(57, 185, 120, .72);
    border-radius: 9px;

    background: #39b978;
    color: #07100b;

    font: inherit;
    font-size: 13px;
    font-weight: 850;

    cursor: pointer;
}


/* ============================================================
   GAMEPLAY
   ============================================================ */

body.epPoolMobilePhone.epPoolMobileMode-room
{
    overscroll-behavior: none;
}

#eggyPoolRoom.epPoolMobileGameReady
{
    position: fixed !important;
    inset: 0 !important;

    z-index: 2147482000 !important;

    width: 100vw !important;
    height: 100dvh !important;

    margin: 0 !important;
    padding: 0 !important;

    overflow: hidden !important;

    background: #080b0d !important;

    box-sizing: border-box;
}

#eggyPoolRoom.epPoolMobileGameReady
.epPoolMatchBeta__scoreboard,

#eggyPoolRoom.epPoolMobileGameReady
.epPoolMatchBeta__gameHeader,

#eggyPoolRoom.epPoolMobileGameReady
.epPoolMatchBeta__remaining,

#eggyPoolRoom.epPoolMobileGameReady
.epPoolMatchBeta__shotPanel,

#eggyPoolRoom.epPoolMobileGameReady
.epPoolMatchBeta__workspace > aside
{
    display: none !important;
}

#eggyPoolRoom.epPoolMobileGameReady
.epPoolMatchBeta__workspace
{
    display: block !important;

    width: 100% !important;
    height: 100% !important;

    margin: 0 !important;
    padding: 0 !important;

    overflow: hidden !important;
}

#eggyPoolRoom.epPoolMobileGameReady
.epPoolMatchBeta__workspace > .block
{
    margin: 0 !important;
}

#eggyPoolRoom.epPoolMobileGameReady
.epPoolMatchBeta__game
{
    width: 100% !important;
    height: 100% !important;

    margin: 0 !important;
    padding: 0 !important;
}

#eggyPoolRoom.epPoolMobileGameReady
.epPoolMatchBeta__game > .block-container
{
    width: 100% !important;
    height: 100% !important;

    margin: 0 !important;
    padding: 0 !important;

    display: grid !important;
    grid-template-rows:
        32px
        minmax(0, 1fr) !important;

    border: 0 !important;
    border-radius: 0 !important;

    overflow: hidden !important;

    background: #080b0d !important;
}


/* ============================================================
   COMPACT PLAYER / POTTED BALL HUD
   ============================================================ */

.epPoolMobileHud
{
    min-width: 0;
    height: 32px;

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

    border-bottom:
        1px solid rgba(255, 255, 255, .11);

    background:
        rgba(8, 11, 13, .97);

    overflow: hidden;
}

.epPoolMobileHud__player
{
    position: relative;

    min-width: 0;

    display: flex;
    align-items: center;
    gap: 7px;

    padding: 4px 9px;

    box-sizing: border-box;

    overflow: hidden;
}

.epPoolMobileHud__player + .epPoolMobileHud__player
{
    border-left:
        1px solid rgba(255, 255, 255, .09);
}

.epPoolMobileHud__player.is-turn
{
    background:
        rgba(57, 185, 120, .075);
}

.epPoolMobileHud__player.is-turn:after
{
    content: "";

    position: absolute;
    left: 8px;
    right: 8px;
    bottom: 0;

    height: 2px;

    border-radius: 2px;

    background: #39b978;
}

.epPoolMobileHud__name
{
    flex: 0 1 auto;

    min-width: 48px;
    max-width: 42%;

    overflow: hidden;

    color: rgba(255, 255, 255, .94);

    font-size: 11px;
    line-height: 1;
    font-weight: 800;

    text-overflow: ellipsis;
    white-space: nowrap;
}

.epPoolMobileHud__balls
{
    min-width: 0;

    display: flex;
    flex: 1 1 auto;
    align-items: center;
    gap: 2px;

    overflow: hidden;
}

.epPoolMobileHud__player[data-seat="2"]
{
    flex-direction: row-reverse;
}

.epPoolMobileHud__player[data-seat="2"]
.epPoolMobileHud__balls
{
    justify-content: flex-end;
}

.epPoolMobileHud__ball.epPoolMatchBeta__ballChip
{
    width: 15px !important;
    height: 15px !important;

    flex: 0 0 15px !important;

    border-width: 1px !important;

    font-size: 5.5px !important;
    line-height: 15px !important;

    box-shadow:
        inset 0 1px 1px rgba(255, 255, 255, .35),
        0 1px 1px rgba(0, 0, 0, .28) !important;
}

.epPoolMobileHud__open,
.epPoolMobileHud__empty
{
    color: rgba(255, 255, 255, .42);

    font-size: 8px;
    line-height: 1;
    font-weight: 700;
}


/* ============================================================
   TABLE MAXIMISATION
   ============================================================ */

#eggyPoolRoom.epPoolMobileGameReady
.epPoolMatchBeta__tableStage
{
    width: 100% !important;
    max-width: none !important;
    height: 100% !important;

    margin: 0 !important;
    padding:
        2px
        max(2px, env(safe-area-inset-right))
        max(2px, env(safe-area-inset-bottom))
        max(2px, env(safe-area-inset-left))
        !important;

    display: flex !important;
    align-items: center !important;
    justify-content: center !important;

    box-sizing: border-box !important;

    overflow: hidden !important;
}

#eggyPoolRoom.epPoolMobileGameReady
.epPoolMatchBeta__tableFrame
{
    position: relative !important;

    width:
        min(
            calc(100vw - env(safe-area-inset-left) - env(safe-area-inset-right)),
            calc((100dvh - 36px - env(safe-area-inset-bottom)) * 2)
        )
        !important;

    max-width: 100% !important;

    margin: 0 auto !important;

    overflow: hidden !important;
}

#eggyPoolRoom.epPoolMobileGameReady
.epPoolMatchBeta__tableFrame canvas
{
    display: block !important;

    width: 100% !important;
    height: auto !important;

    max-width: none !important;
    max-height: calc(100dvh - 36px) !important;

    margin: 0 auto !important;

    aspect-ratio: 2 / 1 !important;

    border-radius: 5px !important;
}


/*
 * AI cue overlay occupies the same exact table surface.
 */
#eggyPoolRoom.epPoolMobileGameReady
#eggyPoolAiCueOverlay
{
    position: absolute !important;
    inset: 0 !important;

    width: 100% !important;
    height: 100% !important;

    pointer-events: none !important;
}


/* ============================================================
   REQUIRED GAME OVER / BREAK DECISION OVERLAYS
   ============================================================ */

#eggyPoolRoom.epPoolMobileGameReady
.epPoolMatchBeta__choiceOverlay,

#eggyPoolRoom.epPoolMobileGameReady
.epPoolMatchBeta__endOverlay
{
    z-index: 2147482500 !important;
}


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

@media
    (pointer: coarse)
    and (orientation: landscape)
    and (max-height: 600px)
{
    html.epPoolMobilePhone,
    body.epPoolMobilePhone
    {
        overscroll-behavior: none;
    }

    body.epPoolMobilePhone.epPoolMobileActivated
    {
        overflow: hidden;
    }
}


/* ============================================================
   MOBILE DIRECT-PRESS SHOT INPUT
   ============================================================ */

#eggyPoolRoom.epPoolMobileGameReady #eggyPoolCanvas
{
    touch-action: none !important;
    user-select: none !important;
    -webkit-user-select: none !important;
}


/*
 * EGGY_POOL_MOBILE_CONTROL_RAIL_V1
 *
 * Dedicated mobile aiming and shot power controls.
 *
 * The table itself never fires a shot on mobile.
 */

.epPoolMobileControls
{
    display: none;
}

#eggyPoolRoom.epPoolMobileGameReady
.epPoolMatchBeta__tableStage
{
    position: relative !important;
}

#eggyPoolRoom.epPoolMobileGameReady
.epPoolMobileControls
{
    position: absolute;

    left:
        max(
            5px,
            env(safe-area-inset-left)
        );

    top: 50%;

    z-index: 80;

    width: 58px;

    display: flex;
    flex-direction: column;
    align-items: center;

    gap: 7px;

    padding: 6px 4px;

    box-sizing: border-box;

    border:
        1px solid
        rgba(255, 255, 255, .12);

    border-radius: 11px;

    background:
        rgba(7, 10, 12, .82);

    box-shadow:
        0 8px 24px
        rgba(0, 0, 0, .34);

    backdrop-filter:
        blur(6px);

    transform:
        translateY(-50%);

    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

.epPoolMobileControls__aim,
.epPoolMobileControls__power
{
    width: 100%;

    display: flex;
    flex-direction: column;
    align-items: center;
}

.epPoolMobileControls__label
{
    color:
        rgba(255, 255, 255, .52);

    font-size: 7px;
    line-height: 1;
    font-weight: 900;

    letter-spacing: .12em;
}

.epPoolMobileAimWheel
{
    position: relative;

    width: 44px;
    height: 44px;

    margin-top: 5px;

    flex: 0 0 44px;

    border:
        1px solid
        rgba(255, 255, 255, .22);

    border-radius: 50%;

    background:
        radial-gradient(
            circle,
            rgba(255,255,255,.10) 0 23%,
            rgba(255,255,255,.025) 24% 53%,
            rgba(57,185,120,.10) 54% 100%
        );

    box-shadow:
        inset 0 0 0 4px
        rgba(0, 0, 0, .16);

    touch-action: none;
}

.epPoolMobileAimWheel__ring
{
    position: absolute;

    inset: 7px;

    border:
        1px dashed
        rgba(255,255,255,.20);

    border-radius: 50%;
}

.epPoolMobileAimWheel__mark
{
    position: absolute;

    left: 50%;
    top: 3px;

    width: 2px;
    height: 17px;

    border-radius: 2px;

    background: #39b978;

    box-shadow:
        0 0 6px
        rgba(57,185,120,.55);

    transform-origin:
        50% 19px;

    transform:
        translateX(-50%)
        rotate(0deg);
}

.epPoolMobileControls__fine
{
    width: 46px;

    margin-top: 4px;

    display: grid;
    grid-template-columns:
        repeat(2, 1fr);

    gap: 3px;
}

.epPoolMobileControls__fineButton
{
    min-width: 0;
    height: 22px;

    padding: 0;

    border:
        1px solid
        rgba(255,255,255,.14);

    border-radius: 5px;

    background:
        rgba(255,255,255,.06);

    color: #fff;

    font-size: 14px;
    line-height: 20px;
    font-weight: 800;

    text-align: center;

    touch-action: manipulation;
}

.epPoolMobileControls__power
{
    margin-top: 2px;

    padding-top: 6px;

    border-top:
        1px solid
        rgba(255,255,255,.10);
}

.epPoolMobilePower
{
    width: 38px;
    height: 100px;

    margin-top: 5px;

    display: flex;
    justify-content: center;

    touch-action: none;
}

.epPoolMobilePower__track
{
    position: relative;

    width: 16px;
    height: 100%;

    border:
        1px solid
        rgba(255,255,255,.18);

    border-radius: 10px;

    background:
        linear-gradient(
            to bottom,
            rgba(255,255,255,.04),
            rgba(255,255,255,.10)
        );

    overflow: visible;
}

.epPoolMobilePower__fill
{
    position: absolute;

    left: 0;
    top: 0;

    width: 100%;
    height: 0;

    border-radius: 9px;

    background:
        linear-gradient(
            to bottom,
            rgba(57,185,120,.52),
            rgba(57,185,120,.96)
        );
}

.epPoolMobilePower__knob
{
    position: absolute;

    left: 50%;
    top: 0;

    width: 30px;
    height: 13px;

    border:
        1px solid
        rgba(255,255,255,.42);

    border-radius: 7px;

    background: #39b978;

    box-shadow:
        0 2px 5px
        rgba(0,0,0,.45);

    transform:
        translate(
            -50%,
            -50%
        );
}

.epPoolMobileControls.is-power-active
.epPoolMobilePower__knob
{
    box-shadow:
        0 0 0 2px
        rgba(57,185,120,.22),
        0 3px 7px
        rgba(0,0,0,.5);
}

.epPoolMobilePower__value
{
    margin-top: 4px;

    color:
        rgba(255,255,255,.82);

    font-size: 8px;
    line-height: 1;
    font-weight: 850;
}


/*
 * Table is a dedicated coarse aim surface.
 */
#eggyPoolRoom.epPoolMobileGameReady
#eggyPoolCanvas
{
    touch-action: none !important;
}


/*
 * Extra-short phones keep the same controls,
 * just slightly smaller.
 */
@media
    (pointer: coarse)
    and (orientation: landscape)
    and (max-height: 360px)
{
    #eggyPoolRoom.epPoolMobileGameReady
    .epPoolMobileControls
    {
        width: 52px;

        gap: 5px;

        padding: 5px 3px;
    }

    .epPoolMobileAimWheel
    {
        width: 38px;
        height: 38px;

        flex-basis: 38px;
    }

    .epPoolMobileAimWheel__mark
    {
        height: 14px;

        transform-origin:
            50% 16px;
    }

    .epPoolMobilePower
    {
        height: 82px;
    }

    .epPoolMobileControls__fine
    {
        width: 40px;
    }
}


/*
 * EGGY_POOL_MOBILE_FORFEIT_END_V1
 *
 * Compact landscape utility button, in-game forfeit confirmation,
 * and shallow match-complete presentation.
 */

.epPoolMobileUtility,
.epPoolMobileForfeitConfirm
{
    display: none;
}

@media
    (pointer: coarse)
    and (orientation: landscape)
    and (max-height: 600px)
{
    /*
     * Desktop navigation actions do not belong in active mobile gameplay.
     * The actual Forfeit button has been moved into .epPoolMobileUtility.
     */
    #eggyPoolRoom.epPoolMobileGameReady
    .epPoolMatchBeta__headerActions > a
    {
        display: none !important;
    }


    /* --------------------------------------------------------
       TOP-RIGHT GAME UTILITY
       -------------------------------------------------------- */

    #eggyPoolRoom.epPoolMobileGameReady
    .epPoolMobileUtility
    {
        position: fixed;

        top:
            max(
                5px,
                env(safe-area-inset-top)
            );

        right:
            max(
                7px,
                env(safe-area-inset-right)
            );

        z-index: 150;

        display: flex;
        align-items: center;

        margin: 0;
        padding: 0;

        pointer-events: auto;
    }

    #eggyPoolRoom.epPoolMobileGameReady
    .epPoolMobileForfeitButton
    {
        width: auto !important;
        min-width: 70px !important;
        min-height: 30px !important;

        margin: 0 !important;
        padding: 4px 9px !important;

        border:
            1px solid
            rgba(239, 91, 91, .42) !important;

        border-radius: 8px !important;

        background:
            rgba(35, 11, 12, .90) !important;

        color:
            #ffb0b0 !important;

        box-shadow:
            0 4px 14px
            rgba(0, 0, 0, .30) !important;

        font-size: 9px !important;
        line-height: 18px !important;
        font-weight: 850 !important;

        text-transform: uppercase;
        letter-spacing: .045em;

        touch-action: manipulation;
    }

    #eggyPoolRoom.epPoolMobileGameReady
    .epPoolMobileForfeitButton::before
    {
        content: "⚑";

        margin-right: 5px;

        font-size: 11px;
    }

    #eggyPoolRoom.epPoolMobileGameReady
    .epPoolMobileForfeitButton:disabled
    {
        opacity: .42 !important;
    }


    /* --------------------------------------------------------
       FORFEIT CONFIRMATION
       -------------------------------------------------------- */

    #eggyPoolRoom.epPoolMobileGameReady
    .epPoolMobileForfeitConfirm:not([hidden])
    {
        position: fixed;

        inset: 0;

        z-index: 310;

        display: grid;
        place-items: center;

        padding:
            max(
                8px,
                env(safe-area-inset-top)
            )
            max(
                10px,
                env(safe-area-inset-right)
            )
            max(
                8px,
                env(safe-area-inset-bottom)
            )
            max(
                10px,
                env(safe-area-inset-left)
            );

        background:
            rgba(3, 5, 7, .72);

        backdrop-filter:
            blur(5px);
    }

    .epPoolMobileForfeitConfirm__card
    {
        width:
            min(
                560px,
                72vw
            );

        min-height: 0;

        box-sizing: border-box;

        padding: 13px 16px;

        border:
            1px solid
            rgba(255, 255, 255, .14);

        border-radius: 12px;

        background:
            rgba(13, 17, 20, .97);

        box-shadow:
            0 18px 55px
            rgba(0, 0, 0, .50);

        text-align: center;
    }

    .epPoolMobileForfeitConfirm__eyebrow
    {
        display: block;

        margin-bottom: 4px;

        color:
            #ff9292;

        font-size: 8px;
        line-height: 1;
        font-weight: 900;

        letter-spacing: .12em;
    }

    .epPoolMobileForfeitConfirm__title
    {
        display: block;

        color: #fff;

        font-size: 21px;
        line-height: 1.05;
        font-weight: 900;
    }

    .epPoolMobileForfeitConfirm__card p
    {
        margin: 6px 0 10px;

        color:
            rgba(255,255,255,.67);

        font-size: 10px;
        line-height: 1.35;
    }

    .epPoolMobileForfeitConfirm__actions
    {
        display: grid;

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

        gap: 7px;
    }

    .epPoolMobileForfeitConfirm__actions
    .button
    {
        width: 100% !important;
        min-height: 32px !important;

        margin: 0 !important;
        padding: 5px 9px !important;

        font-size: 10px !important;
        line-height: 20px !important;
    }

    .epPoolMobileForfeitConfirm__confirm
    {
        border-color:
            rgba(239,91,91,.48) !important;

        background:
            rgba(145,34,38,.92) !important;
    }


    /* --------------------------------------------------------
       MATCH COMPLETE
       -------------------------------------------------------- */

    #eggyPoolRoom.epPoolMobileGameReady
    .epPoolMatchBeta__endOverlay
    {
        padding:
            max(
                8px,
                env(safe-area-inset-top)
            )
            max(
                10px,
                env(safe-area-inset-right)
            )
            max(
                8px,
                env(safe-area-inset-bottom)
            )
            max(
                10px,
                env(safe-area-inset-left)
            ) !important;

        align-items: center !important;
        justify-content: center !important;
    }

    #eggyPoolRoom.epPoolMobileGameReady
    .epPoolMatchBeta__endCard
    {
        width:
            min(
                620px,
                76vw
            ) !important;

        max-width: 620px !important;
        min-height: 0 !important;

        margin: 0 !important;
        padding: 12px 15px !important;

        border-radius: 12px !important;

        text-align: center;
    }

    #eggyPoolRoom.epPoolMobileGameReady
    .epPoolMatchBeta__endEyebrow
    {
        margin-bottom: 3px !important;

        font-size: 8px !important;
        line-height: 1 !important;

        letter-spacing: .11em !important;
    }

    #eggyPoolRoom.epPoolMobileGameReady
    .epPoolMatchBeta__endCard
    #eggyPoolEndTitle
    {
        margin: 3px 0 0 !important;

        font-size: 23px !important;
        line-height: 1 !important;
    }

    #eggyPoolRoom.epPoolMobileGameReady
    .epPoolMatchBeta__endCard
    #eggyPoolEndText
    {
        max-width: 500px;

        margin:
            6px auto
            9px !important;

        font-size: 10px !important;
        line-height: 1.35 !important;
    }


    /* AI: Rematch / Difficulty / Pool Hall in one row */

    #eggyPoolRoom.epPoolMobileGameReady
    .epPoolAi__endActions
    {
        width: 100%;

        display: grid !important;

        grid-template-columns:
            repeat(
                3,
                minmax(0, 1fr)
            ) !important;

        gap: 6px !important;

        margin-top: 7px !important;
    }

    #eggyPoolRoom.epPoolMobileGameReady
    .epPoolAi__endActions form
    {
        display: contents !important;
    }

    #eggyPoolRoom.epPoolMobileGameReady
    .epPoolAi__endActions .button
    {
        width: 100% !important;
        min-width: 0 !important;
        min-height: 32px !important;

        margin: 0 !important;
        padding: 5px 8px !important;

        font-size: 9px !important;
        line-height: 20px !important;

        white-space: nowrap;
    }


    /* Human match currently has the single Pool Hall action. */

    #eggyPoolRoom.epPoolMobileGameReady
    .epPoolMatchBeta__endCard
    > .button
    {
        min-width: 180px;
        min-height: 32px;

        margin: 7px auto 0 !important;

        padding: 5px 12px !important;

        font-size: 10px !important;
    }
}


@media
    (pointer: coarse)
    and (orientation: landscape)
    and (max-height: 360px)
{
    #eggyPoolRoom.epPoolMobileGameReady
    .epPoolMobileForfeitButton
    {
        min-width: 62px !important;
        min-height: 27px !important;

        padding: 3px 7px !important;

        font-size: 8px !important;
    }

    .epPoolMobileForfeitConfirm__card
    {
        width:
            min(
                520px,
                76vw
            );

        padding: 10px 13px;
    }

    .epPoolMobileForfeitConfirm__title
    {
        font-size: 18px;
    }

    #eggyPoolRoom.epPoolMobileGameReady
    .epPoolMatchBeta__endCard
    {
        width:
            min(
                580px,
                80vw
            ) !important;

        padding: 9px 12px !important;
    }

    #eggyPoolRoom.epPoolMobileGameReady
    .epPoolMatchBeta__endCard
    #eggyPoolEndTitle
    {
        font-size: 20px !important;
    }
}
