/* ============================================================
   LOBBY
   ============================================================ */

.setup-screen {
    position: relative;

    min-height: 100dvh;

    display: flex;
    align-items: center;
    justify-content: center;

    padding:
        max(70px, env(safe-area-inset-top))
        18px
        max(25px, env(safe-area-inset-bottom));

      background: none;

    overflow: hidden;
}

.setup-container {
    position: relative;

    z-index: 2;

    width: min(94%, 620px);

    text-align: center;
}


/* ============================================================
   HEADER
   ============================================================ */

.lobby-header {
    position: absolute;

    z-index: 5;

    top:
        max(
            14px,
            env(safe-area-inset-top)
        );

    left: 18px;
    right: 18px;

    display: flex;
    align-items: center;
    justify-content: space-between;
}

.mini-logo {
    font-size: 18px;

    font-weight: 900;

    letter-spacing: 2px;
}

.mini-logo span,
.game-logo span {
    color: #f59e0b;
}

.menu-button {
    width: 45px;
    height: 45px;

     display: flex; /*## Dùng Flexbox để căn icon */
    align-items: center; /*## Căn giữa theo chiều dọc */
    justify-content: center; /*## Căn giữa theo chiều ngang */

    padding: 0; /*## Xóa padding mặc định của button */

    border:
        1px solid #334155;

    border-radius: 12px;

    background:
        rgba(15,23,42,0.9);

    color: white;

    font-size: 21px;
    line-height: 1; /*## Tránh ký tự ☰ bị lệch do line-height */

    cursor: pointer;
}


/* ============================================================
   LOGO
   ============================================================ */

.game-logo {
    font-size:
        clamp(40px, 9vw, 64px);

    font-weight: 900;

    letter-spacing: 2px;
}

.game-subtitle {
    margin-top: 3px;
    margin-bottom: 25px;

    color: #94a3b8;

    font-size: 10px;

    letter-spacing: 4px;
}


/* ============================================================
   SELECTOR
   ============================================================ */
.selector-arrow:disabled {
    opacity: 0.35;
    cursor: default;
    pointer-events: none;
}

.selector-section {
    margin-bottom: 14px;
}

.selector-label {
    min-height: 18px;
    margin-bottom: 7px;

    color: #cbd5e1;

    font-size: 12px;
    font-weight: 800;
    line-height: 1.3;

    letter-spacing: 0.6px;

    white-space: normal;
    overflow-wrap: break-word;
}

.selector {
    height: 60px;

    display: grid;

    grid-template-columns:
        55px
        1fr
        55px;

    align-items: center;

    border:
        1px solid #334155;

    border-radius: 13px;

    background:
        rgba(17,24,39,0.92);

    overflow: hidden;
}

.selector-arrow {
    height: 100%;

    border: none;

    background: transparent;

    color: #cbd5e1;

    font-size: 18px;

    cursor: pointer;
}

.selector-arrow:hover {
    background: rgba(255,255,255,0.06);
    color: #ffffff;
}

.selector-viewport {
    position: relative;

    height: 100%;

    overflow: hidden;
}

.selector-value {
    position: absolute;

    inset: 0;

    display: flex;
    align-items: center;
    justify-content: center;

    padding: 0 8px;

    font-size:
        clamp(14px,4vw,18px);

    font-weight: 900;
    line-height: 1.2;
    text-align: center;

    white-space: nowrap;
}

.level-value,
.sub-mode-value {
    color: #fbbf24;
}


/* ============================================================
   SLIDE
   ============================================================ */

.slide-out-left {
    animation:
        slideOutLeft
        0.22s
        forwards;
}

.slide-in-right {
    animation:
        slideInRight
        0.22s
        forwards;
}

.slide-out-right {
    animation:
        slideOutRight
        0.22s
        forwards;
}

.slide-in-left {
    animation:
        slideInLeft
        0.22s
        forwards;
}

@keyframes slideOutLeft {
    to {
        transform:
            translateX(-100%);

        opacity: 0;
    }
}

@keyframes slideInRight {
    from {
        transform:
            translateX(100%);

        opacity: 0;
    }

    to {
        transform:
            translateX(0);

        opacity: 1;
    }
}

@keyframes slideOutRight {
    to {
        transform:
            translateX(100%);

        opacity: 0;
    }
}

@keyframes slideInLeft {
    from {
        transform:
            translateX(-100%);

        opacity: 0;
    }

    to {
        transform:
            translateX(0);

        opacity: 1;
    }
}


/* ============================================================
   MOBILE
   ============================================================ */

@media (max-width: 480px) {

    .selector {
        height: 56px;

        grid-template-columns:
            45px
            1fr
            45px;
    }

    .selector-section {
        margin-bottom: 9px;
    }

    .game-subtitle {
        margin-bottom: 18px;
    }
}
/* =========================================
   LOBBY HEADER
========================================= */

.lobby-header {
    position: absolute;

    top: max(
        16px,
        env(safe-area-inset-top)
    );

    left: 20px;
    right: 20px;

    z-index: 50;

    display: flex;
    align-items: center;
    justify-content: space-between;

    pointer-events: none;
}


/* Cho các control nhận click */
.lobby-header button,
.lobby-header select,
.home-actions {
    pointer-events: auto;
}

.home-user-menu {
    pointer-events: auto;
}


/* =========================================
   TOP ACTION GROUP
========================================= */

.home-actions {
    position: relative;
    margin-left: auto;

    display: flex;
    align-items: center;

    gap: 8px;
}


/* =========================================
   COMMON BUTTON
========================================= */

.top-action-btn,
.top-language,
.top-user-btn {
    height: 42px;

    border:
        1px solid
        rgba(255,255,255,.22);

    background:
        rgba(8, 13, 23, .72);

    color: #fff;

    backdrop-filter:
        blur(10px);

    box-shadow:
        0 4px 14px
        rgba(0,0,0,.25);
}


/* =========================================
   MENU
========================================= */

.top-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;

    gap: 7px;

    padding: 0 14px;

    border-radius: 12px;

    font-weight: 700;

    cursor: pointer;

    transition:
        background .15s ease,
        transform .1s ease;
}


.top-action-btn:hover {
    background:
        rgba(25,35,55,.9);
}


.top-action-btn:active {
    transform: scale(.96);
}


/* Menu chỉ cần icon */
.menu-button {
    width: 42px;

    padding: 0;

    font-size: 18px;
}


/* =========================================
   LANGUAGE
========================================= */

.top-language {
    display: flex;
    align-items: center;

    gap: 7px;

    padding:
        0 8px
        0 12px;

    border-radius: 12px;
}


.top-language-icon {
    font-size: 14px;
}


.top-language-select {
    height: 100%;

    min-width: 82px;

    border: 0;
    outline: 0;

    background: transparent;

    color: #fff;

    font-size: 13px;
    font-weight: 700;

    cursor: pointer;
}


.top-language-select option {
    color: #111;
}


/* =========================================
   LOGIN
========================================= */

.login-button {
    min-width: 92px;
}


/* =========================================
   LOGGED USER
========================================= */

.top-user-btn {
    display: flex;
    align-items: center;

    gap: 8px;

    max-width: 150px;

    padding:
        4px 12px
        4px 5px;

    border-radius: 22px;

    cursor: pointer;
}


.top-user-avatar {
    width: 32px;
    height: 32px;

    border-radius: 50%;

    object-fit: cover;
}


#homeUserName {
    overflow: hidden;

    text-overflow: ellipsis;
    white-space: nowrap;

    font-size: 13px;
    font-weight: 700;
}


/* =========================================
   MOBILE
========================================= */

@media (max-width: 600px) {

    .lobby-header {
        top: max(
            10px,
            env(safe-area-inset-top)
        );

        left: 10px;
        right: 10px;
    }


    .home-actions {
        gap: 5px;
    }


    .menu-button {
        width: 38px;
    }


    .top-action-btn,
    .top-language,
    .top-user-btn {
        height: 38px;
    }


    .top-language {
        padding:
            0 5px
            0 8px;
    }


    .top-language-select {
        min-width: 65px;
        max-width: 80px;

        font-size: 12px;
    }


    .login-button {
        min-width: auto;

        padding:
            0 10px;
    }


    .mini-logo {
        display: none;
    }

}
/* =========================================
   LOBBY BACKGROUND OVERLAY
========================================= */

.setup-screen {
    position: relative;
}

.lobby-overlay {
    position: absolute;
    inset: 0;

    width: 100%;
    height: 100%;

    background:
        linear-gradient(
            to bottom,
            rgba(3, 8, 18, 0.50) 0%,
            rgba(3, 8, 18, 0.55) 50%,
            rgba(3, 8, 18, 0.65) 100%
        );

    z-index: 1;

    pointer-events: none;
}
/* UI nằm trên overlay nhưng KHÔNG đổi position */
.lobby-header {
    z-index: 50;
}

.setup-container {
    position: relative;
    z-index: 2;
}


/* ==========================================
   SOLO / MODE CONFIG HEADER
========================================== */

#configScreen .game-logo {
    margin-top: 4px;
    text-align: center;
}

#configScreen .game-subtitle {
    margin-bottom: 18px;
    text-align: center;
}

#configScreen .solo-settings {
    margin-top: 0;
}

@media (max-width: 600px) {

    #configScreen .game-logo {
        margin-top: 0;
    }

    #configScreen .game-subtitle {
        margin-bottom: 14px;
    }
}


/* ============================================================
   BATLINGO - CONFIG SCREEN LAYOUT FIX

   Prevent vertical jumping when switching
   Survival <-> Practice
============================================================ */

/* Apply only when Configuration is open */

#setupScreen:has(#configScreen:not(.hidden)) {

    display: flex;

    flex-direction: column;

    align-items: center;

    /* Important: do not vertically center content */
    justify-content: flex-start;

    min-height: 100dvh;
    height: auto;

    overflow-x: clip;
    overflow-y: visible;

    padding-top:
        max(85px, env(safe-area-inset-top));

    padding-bottom:
        max(30px, env(safe-area-inset-bottom));
}

/* Configuration container */

#configScreen {

    position: relative;

    box-sizing: border-box;

    width: min(100%, 560px);
    max-width: 560px;
    min-width: 0;

    height: auto;
    min-height: 0;
    max-height: none;

    margin: 0 auto;

    transform: none;
}

/* Prevent children from expanding width */

#configScreen .solo-settings,
#configScreen .practice-options {

    width: 100%;
    max-width: 100%;

    min-width: 0;

    box-sizing: border-box;
}

/* Mobile */

@media (max-width: 600px) {

    #setupScreen:has(#configScreen:not(.hidden)) {

        padding-top:
            max(72px, env(safe-area-inset-top));

        padding-left: 12px;
        padding-right: 12px;
    }

    #configScreen {
        width: 100%;
        max-width: 100%;
    }
}

/* ==========================================
   BATLINGO LOBBY - FIX BACKGROUND ZOOM
========================================== */

/* Background follows viewport, not content height */
#setupScreen {
    position: relative;
    isolation: isolate;
    background: transparent;
}

/* Fixed background layer */
#setupScreen::before {
    content: "";
    position: fixed;
    inset: 0;

    z-index: -1;

    background-image:
        url("../assets/images/backgrounds/lobby-bg-desktop.webp");

    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;

    pointer-events: none;
}

/* Keep the overlay fixed as well */
#setupScreen .lobby-overlay {
    position: fixed;
    inset: 0;

    width: 100%;
    height: 100dvh;

    pointer-events: none;
}

/* Configuration content may grow vertically */
#setupScreen:has(#configScreen:not(.hidden)) {
    min-height: 100dvh;
    height: auto;

    overflow-x: clip;
    overflow-y: visible;
}
