/* Modern header skin aligned with the arcade lobby. */
.header {
    height: 64px;
    padding: 8px 12px !important;
    background:
        radial-gradient(circle at 78% 0%, rgba(88, 65, 152, .18), transparent 34%),
        radial-gradient(circle at 16% 100%, rgba(37, 159, 190, .13), transparent 38%),
        linear-gradient(180deg, rgba(9, 33, 44, .94), rgba(5, 24, 34, .88));
    border-bottom: 1px solid rgba(172, 224, 239, .09);
    box-shadow: 0 12px 32px rgba(0, 0, 0, .2), inset 0 -1px 0 rgba(255, 255, 255, .025);
    backdrop-filter: blur(14px);
}

@media (min-width: 933px) {
    .header-settings-dropdown .settings-desktop-item .dropdown-item {
        min-height: 46px;
    }

    .header-settings-dropdown .settings-current-language-flag {
        width: 28px;
        height: 20px;
        flex: 0 0 auto;
        border-radius: 5px;
        object-fit: cover;
        box-shadow: 0 0 0 1px rgba(255, 255, 255, .14);
    }

    .header-settings-dropdown .settings-menu-chevron {
        width: auto;
        margin: 0;
        font-size: 11px;
        color: rgba(255, 255, 255, .48);
    }
}

@media (max-width: 932px), (orientation: landscape) and (max-width: 1024px) and (max-height: 560px) {
    #openProfile img { box-shadow:none !important; }
    .header-settings-dropdown .settings-desktop-item {
        display: none !important;
    }
}

/* Profile modal aligned with the modern lobby visual language. */
#profileModal .profile-dialog {
    --bs-modal-width: 590px;
    width: min(590px, calc(100vw - 24px));
    margin-inline: auto;
}

#profileModal .profile-modal {
    padding: 26px;
    overflow: hidden;
    color: #edf9fc;
    background:
        radial-gradient(circle at 8% 0, rgba(73, 196, 226, .14), transparent 34%),
        radial-gradient(circle at 96% 10%, rgba(242, 190, 67, .1), transparent 30%),
        linear-gradient(155deg, rgba(17, 48, 61, .985), rgba(6, 25, 34, .995));
    border: 1px solid rgba(126, 211, 232, .18);
    border-radius: 26px;
    box-shadow: 0 30px 90px rgba(0, 0, 0, .58), inset 0 1px 0 rgba(255, 255, 255, .07);
}

#profileModal .profile-modal::before {
    inset: 0;
    height: auto;
    background:
        linear-gradient(90deg, rgba(85, 205, 233, .34), rgba(244, 194, 75, .2), transparent 76%) top / 100% 2px no-repeat;
    border-radius: inherit;
    filter: none;
    opacity: 1;
    -webkit-mask-image: none;
    mask-image: none;
}

#profileModal .profile-close {
    top: 16px;
    right: 16px;
    width: 38px;
    height: 38px;
    color: rgba(228, 246, 250, .78);
    background: rgba(116, 202, 223, .07);
    border: 1px solid rgba(140, 215, 233, .12);
    border-radius: 12px;
    box-shadow: none;
}

#profileModal .profile-close:hover,
#profileModal .profile-close:focus {
    color: #fff;
    background: rgba(239, 95, 105, .14);
    border-color: rgba(255, 133, 140, .24);
}

#profileModal .profile-hero {
    gap: 20px;
    min-height: 122px;
    padding: 15px 56px 15px 16px;
    background: rgba(116, 202, 223, .055);
    border: 1px solid rgba(133, 214, 234, .11);
    border-radius: 19px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .035);
}

#profileModal .profile-avatar {
    width: 94px;
    height: 94px;
    border: 2px solid rgba(151, 224, 241, .38);
    box-shadow: 0 0 0 6px rgba(63, 170, 196, .08), 0 16px 32px rgba(0, 0, 0, .3);
}

#profileModal .profile-level {
    right: -5px;
    bottom: -5px;
    min-width: 35px;
    height: 35px;
    color: #3c2600;
    background: linear-gradient(145deg, #ffe692, #eeb63d);
    border: 3px solid #0d303d;
    box-shadow: 0 5px 14px rgba(0, 0, 0, .28);
}

#profileModal .profile-name {
    font-size: 24px;
    font-weight: 950;
    letter-spacing: -.02em;
}

#profileModal .profile-id {
    color: rgba(207, 231, 237, .55);
    font-weight: 700;
}

#profileModal .profile-vip {
    padding: 6px 9px;
    color: #ffe9a9;
    background: rgba(222, 167, 48, .12);
    border: 1px solid rgba(247, 202, 94, .22);
    border-radius: 9px;
}

#profileModal .profile-rank {
    margin-top: 10px;
    padding: 7px 10px;
    border-radius: 9px;
    font-size: 13px;
    font-weight: 850;
}

#profileModal .profile-progress-panel {
    margin-top: 12px;
    padding: 14px 16px;
    background: rgba(1, 18, 25, .34);
    border: 1px solid rgba(128, 210, 230, .1);
    border-radius: 15px;
}

#profileModal .profile-progress-track {
    height: 9px;
    background: rgba(190, 226, 234, .09);
}

#profileModal .profile-progress-track .progress-bar {
    background: linear-gradient(90deg, #35c98b, #55c8e4);
    box-shadow: 0 0 14px rgba(69, 201, 218, .28);
}

#profileModal .profile-rating {
    color: #ffe084;
    background: rgba(221, 168, 48, .1);
    border: 1px solid rgba(246, 201, 92, .16);
    border-radius: 9px;
}

#profileModal .profile-main-stats {
    gap: 10px;
    margin-top: 10px;
}

#profileModal .profile-main-stat {
    min-height: 118px;
    padding: 16px 18px;
    background: rgba(89, 182, 205, .055);
    border: 1px solid rgba(125, 207, 228, .1);
    border-radius: 15px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .03);
}

#profileModal .profile-winrate-panel {
    background:
        radial-gradient(circle at 88% 8%, rgba(93, 231, 202, .17), transparent 43%),
        linear-gradient(145deg, rgba(38, 177, 157, .16), rgba(40, 134, 170, .075));
    border-color: rgba(91, 222, 198, .2);
    box-shadow: inset 0 1px 0 rgba(187, 255, 240, .07), 0 10px 24px rgba(10, 101, 91, .09);
}

#profileModal .profile-games-panel {
    background:
        radial-gradient(circle at 88% 12%, rgba(255, 215, 108, .14), transparent 42%),
        linear-gradient(145deg, rgba(213, 157, 38, .13), rgba(160, 107, 16, .055));
    border-color: rgba(241, 196, 85, .2);
    box-shadow: inset 0 1px 0 rgba(255, 237, 177, .08), 0 10px 24px rgba(130, 85, 8, .08);
}

#profileModal .profile-main-stat::after {
    opacity: .32;
}

#profileModal .profile-winrate-value {
    margin-top: 6px;
    color: #58e2bb;
    font-size: 44px;
    line-height: .95;
    text-shadow: 0 0 20px rgba(66, 216, 181, .22);
}

#profileModal .profile-games-value {
    margin-top: 7px;
    color: #ffd86f;
    font-size: 42px;
    line-height: .95;
    text-shadow: 0 0 20px rgba(239, 184, 57, .2);
}

#profileModal .profile-games-panel .profile-winrate-label {
    color: rgba(255, 226, 146, .76);
}

#profileModal .profile-winrate-track {
    height: 10px;
    margin-top: 13px;
    padding: 2px;
    background: rgba(4, 23, 29, .58);
    border: 1px solid rgba(102, 224, 199, .11);
}

#profileModal .profile-winrate-fill {
    background: linear-gradient(90deg, #36d28e, #54dfca 58%, #5bccec);
    box-shadow: 0 0 16px rgba(67, 218, 181, .34);
}

#profileModal .profile-stats {
    gap: 8px;
    margin-top: 8px;
}

#profileModal .profile-stat {
    min-height: 86px;
    padding: 10px;
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr);
    grid-template-rows: auto auto;
    column-gap: 9px;
    align-items: center;
    text-align: left;
    background: rgba(112, 197, 218, .045);
    border: 1px solid rgba(130, 211, 231, .09);
    border-radius: 14px;
}

#profileModal .profile-stat-icon {
    grid-row: 1 / 3;
    width: 34px;
    height: 34px;
    margin: 0;
}

#profileModal .profile-stat-label {
    align-self: end;
    font-size: 10px;
    font-weight: 750;
}

#profileModal .profile-stat-value {
    align-self: start;
    margin: 0;
    font-size: 19px;
    font-weight: 950;
}

#profileModal .profile-partner-block {
    margin-top: 10px;
}

@media (max-width: 620px) {
    #profileModal .profile-modal {
        padding: 16px;
        border-radius: 21px;
    }

    #profileModal .profile-hero {
        gap: 13px;
        min-height: 104px;
        padding: 12px 46px 12px 12px;
    }

    #profileModal .profile-avatar {
        width: 76px;
        height: 76px;
    }

    #profileModal .profile-name { font-size: 20px; }
    #profileModal .profile-name-row { display: block; }
    #profileModal .profile-vip { width: fit-content; margin-top: 6px; }
    #profileModal .profile-main-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    #profileModal .profile-main-stat { min-height: 88px; padding: 12px; }
    #profileModal .profile-winrate-value { font-size: 36px; }
    #profileModal .profile-games-value { font-size: 34px; }
    #profileModal .profile-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    #profileModal .profile-stat {
        min-height: 78px;
        padding: 8px 6px;
        display: block;
        text-align: center;
    }
    #profileModal .profile-stat-icon { margin: 0 auto 4px; }
    #profileModal .profile-stat-value { font-size: 17px; }
}

.header > .row { height: 100%; }

.header > .row > .col:first-child {
    display: flex;
    align-items: center;
}

.header .btn,
.header-install-link,
.header-fortune-link,
.header-landscape-lobby-back {
    min-height: 42px;
    border: 1px solid rgba(173, 222, 236, .1) !important;
    border-radius: 13px !important;
    background: linear-gradient(145deg, rgba(22, 62, 76, .78), rgba(8, 35, 47, .88)) !important;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .055), 0 8px 18px rgba(0, 0, 0, .14) !important;
    color: rgba(239, 250, 253, .92) !important;
    transition: transform .18s ease, background .18s ease, border-color .18s ease;
}

.header .btn:hover,
.header-install-link:hover,
.header-fortune-link:hover,
.header-landscape-lobby-back:hover {
    transform: none;
    border-color: rgba(173, 222, 236, .1) !important;
    background: linear-gradient(145deg, rgba(22, 62, 76, .78), rgba(8, 35, 47, .88)) !important;
}

.header .header-home-link {
    height: 42px !important;
    color: #bfefff !important;
}

.header-install-link {
    height: 42px;
    margin-left: 8px;
    padding-inline: 12px;
    gap: 8px;
    align-self: center;
    border-color: rgba(85, 200, 226, .12) !important;
    background: linear-gradient(145deg, rgba(22, 85, 104, .52), rgba(8, 39, 52, .76)) !important;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .045) !important;
    font-size: 13px;
}

.header-install-link:hover,
.header-install-link:focus {
    border-color: rgba(85, 200, 226, .12) !important;
    background: linear-gradient(145deg, rgba(22, 85, 104, .62), rgba(8, 39, 52, .82)) !important;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .07) !important;
}

.header .header-install-reward {
    height: 20px !important;
    min-height: 20px;
    padding-inline: 6px;
    border: 1px solid rgba(255, 215, 111, .16);
    border-radius: 7px;
    color: #fff0b7;
    background: linear-gradient(145deg, rgba(164, 112, 25, .86), rgba(91, 58, 12, .9));
    box-shadow: inset 0 1px 0 rgba(255, 244, 192, .1);
}

.header .btn-purple {
    border-color: rgba(183, 145, 255, .18) !important;
    background: linear-gradient(145deg, rgba(115, 75, 179, .9), rgba(70, 45, 126, .94)) !important;
}

.header .btn-purple:hover,
.header .btn-purple:focus,
.header .btn-purple:active {
    border-color: rgba(183, 145, 255, .18) !important;
    background: linear-gradient(145deg, rgba(115, 75, 179, .9), rgba(70, 45, 126, .94)) !important;
}

.header .btn-danger {
    border-color: rgba(255, 130, 145, .16) !important;
    background: linear-gradient(145deg, rgba(215, 69, 89, .94), rgba(159, 43, 66, .96)) !important;
}

.header .btn-danger:hover,
.header .btn-danger:focus,
.header .btn-danger:active {
    border-color: rgba(255, 130, 145, .16) !important;
    background: linear-gradient(145deg, rgba(215, 69, 89, .94), rgba(159, 43, 66, .96)) !important;
}

.header-fortune-link {
    width: 42px;
    height: 42px;
    display: inline-grid;
    place-items: center;
    padding: 2px;
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
}

.header-fortune-link:hover,
.header-fortune-link:focus,
.header-fortune-link:active {
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
}

.header-fortune-link .wheel-icon {
    width: 38px;
    height: 38px;
}

.header .blot-balance-animated {
    min-height: 42px;
    margin-right: 8px;
    padding-inline: 11px !important;
    border: 0;
    border-radius: 13px;
    background: transparent;
    box-shadow: none;
}

.header .blot-balance-animated strong {
    min-height: 0;
    padding: 0;
    font-size: 21px;
    font-weight: 900;
}

.header-settings-dropdown .header-mobile-menu-button {
    width: auto;
    min-width: 42px;
    padding: 5px 12px !important;
}

.header-settings-dropdown .header-mobile-menu-button {
    background: transparent !important;
    border-color: transparent !important;
    box-shadow: none !important;
}

.header-settings-dropdown .header-mobile-menu-button:hover,
.header-settings-dropdown .header-mobile-menu-button:focus {
    background: rgba(111, 193, 214, .09) !important;
    border-color: transparent !important;
    box-shadow: none !important;
}

.header .header-home-link {
    background: transparent !important;
    border-color: transparent !important;
    box-shadow: none !important;
}

.header .header-home-link:hover,
.header .header-home-link:focus {
    background: rgba(111, 193, 214, .09) !important;
    border-color: transparent !important;
    box-shadow: none !important;
}

.header-settings-dropdown {
    margin-left: 0 !important;
    margin-right: 8px !important;
}

@media (min-width: 933px) {
    .header-settings-dropdown > .dropdown-menu {
        min-width: 260px;
        padding: 8px;
        background:
            radial-gradient(circle at 100% 0, rgba(89, 207, 235, .12), transparent 42%),
            linear-gradient(155deg, rgba(20, 48, 60, .98), rgba(7, 24, 32, .99));
        border: 1px solid rgba(129, 211, 232, .17);
        border-radius: 17px;
        box-shadow: 0 20px 52px rgba(0, 0, 0, .42), inset 0 1px 0 rgba(255, 255, 255, .06);
    }

    .header-settings-dropdown > .dropdown-menu > li > .dropdown-item {
        min-height: 46px;
        padding: 9px 11px;
        color: rgba(235, 247, 250, .88);
        border: 1px solid transparent;
        border-radius: 11px;
        background: transparent;
        font-size: 14px;
        font-weight: 750;
        transition: color .16s ease, background-color .16s ease, border-color .16s ease;
    }

    .header-settings-dropdown > .dropdown-menu > li > .dropdown-item:hover,
    .header-settings-dropdown > .dropdown-menu > li > .dropdown-item:focus {
        color: #fff;
        background: rgba(91, 194, 220, .1);
        border-color: rgba(126, 211, 232, .13);
    }

    .header-settings-dropdown .form-check-label,
    .header-settings-dropdown .dropdown-item > span:first-child {
        display: inline-flex;
        align-items: center;
        gap: 12px;
    }

    .header-settings-dropdown .form-check-label > i,
    .header-settings-dropdown .dropdown-item > span:first-child > i {
        width: 20px;
        flex: 0 0 20px;
        color: #76d9ef;
        text-align: center;
    }

    .header-settings-dropdown .dropdown-divider {
        margin: 5px 8px;
        border-color: rgba(145, 215, 232, .12);
    }
}

#openProfile {
    width: auto;
    min-width: 42px;
    padding: 5px 7px 5px 10px !important;
    gap: 7px;
    white-space: nowrap;
    background: transparent !important;
    border-color: transparent !important;
    box-shadow: none !important;
}

#openProfile:hover,
#openProfile:focus {
    background: rgba(111, 193, 214, .09) !important;
    border-color: transparent !important;
    box-shadow: none !important;
}

.header .btn-purple:hover,
.header .btn-purple:focus,
.header .btn-purple:active,
.header .btn-danger:hover,
.header .btn-danger:focus,
.header .btn-danger:active {
    filter: brightness(1.12) saturate(1.04);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .16), 0 8px 18px rgba(0, 0, 0, .18) !important;
}

#openProfile > span {
    margin: 0 !important;
    max-width: 105px;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 14px;
}

#openProfile img {
    width: 31px;
    height: 31px;
    border: 1px solid rgba(159, 226, 243, .28);
    box-shadow: 0 0 0 3px rgba(50, 143, 168, .1);
}

@media (max-width: 767px) {
    .header {
        height: 56px;
        padding: 6px 8px !important;
    }

    .header .btn,
    .header-fortune-link,
    .header-landscape-lobby-back {
        min-height: 40px;
        border-radius: 12px !important;
    }

    .header-fortune-link {
        width:40px !important;
        min-width:40px !important;
        height:40px !important;
        min-height:40px !important;
        max-height:40px !important;
        padding:2px !important;
        display:inline-grid !important;
        place-items:center !important;
        align-self:center !important;
    }

    .header-fortune-link .wheel-icon {
        width:36px !important;
        height:36px !important;
        margin:0 !important;
    }

    .header .btn-purple {
        min-width: 45px;
        padding-inline: 9px !important;
    }

    .header .header-buychips-link {
        min-width: 40px;
        padding-inline: 9px !important;
    }

    .header .blot-balance-animated {
        min-height: 40px;
        padding-inline: 8px !important;
    }

    .header .blot-balance-animated strong { font-size: 19px; }

    .header-settings-dropdown .header-mobile-menu-button {
        width: 40px;
        min-width: 40px;
        padding: 5px 10px !important;
    }

    #openProfile {
        width: 40px;
        min-width: 40px;
        padding: 5px !important;
    }

    #openProfile img {
        width: 29px;
        height: 29px;
        border-radius: 9px !important;
    }
}

@media (max-width: 932px) {
    .header-landscape-lobby-back,
    .header-landscape-lobby-back:hover,
    .header-landscape-lobby-back:focus,
    .header-landscape-lobby-back:active,
    .header-landscape-lobby-back:focus-visible {
        top: 50% !important;
        transform: translate3d(0, -50%, 0) !important;
        transition: none !important;
    }

    #openProfile img {
        border-radius: 9px !important;
    }

    #openProfile {
        width: 40px !important;
        min-width: 40px !important;
        height: 40px !important;
        min-height: 40px !important;
        max-height: 40px !important;
        padding: 4px !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    #openProfile img {
        width: 30px !important;
        height: 30px !important;
    }
}

@media (max-width: 767px) and (orientation: portrait) {
    .header .header-buychips-link {
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        padding-inline: 0 !important;
    }

    .header .header-buychips-compact-icon {
        width: auto !important;
        margin: 0 !important;
        line-height: 1;
        text-align: center;
    }
}

@media (orientation: landscape) and (max-height: 600px) {
    .header {
        height: 50px;
        padding-block: 4px !important;
    }

    .header .btn,
    .header-fortune-link,
    .header-landscape-lobby-back,
    .header .blot-balance-animated {
        min-height: 38px;
    }

    .header-fortune-link {
        width:38px !important;
        min-width:38px !important;
        height:38px !important;
        min-height:38px !important;
        max-height:38px !important;
    }

    .header-fortune-link .wheel-icon {
        width:34px !important;
        height:34px !important;
    }

    #openProfile {
        width: 38px !important;
        min-width: 38px !important;
        height: 38px !important;
        min-height: 38px !important;
        max-height: 38px !important;
        padding: 4px !important;
    }

    #openProfile img {
        width: 28px !important;
        height: 28px !important;
    }

    .header-landscape-lobby-back,
    .header-landscape-lobby-back:hover,
    .header-landscape-lobby-back:focus,
    .header-landscape-lobby-back:active {
        transform: translateY(-50%) !important;
        transition: none !important;
    }
}

/* Faster shared window transitions. */
.modal.fade {
    transition: opacity .11s linear !important;
}

.modal-backdrop.fade {
    transition: opacity .1s linear !important;
}

.modal.fade .modal-dialog {
    opacity: 0;
    transform: translate3d(0, 7px, 0) scale(.99) !important;
    transition: transform .14s cubic-bezier(.2, .78, .24, 1), opacity .1s linear !important;
}

.modal.show .modal-dialog {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1) !important;
}

@media (prefers-reduced-motion: reduce) {
    .modal.fade,
    .modal-backdrop.fade,
    .modal.fade .modal-dialog {
        transition: none !important;
    }
}

/* Profile: dedicated mobile portrait layout. */
@media (max-width: 700px) and (orientation: portrait) {
    #profileModal {
        padding: 8px !important;
    }

    #profileModal .profile-dialog {
        width: 100%;
        max-width: 520px;
        min-height: 100dvh;
        margin: 0 auto;
        display: flex;
        align-items: flex-end;
    }

    #profileModal .profile-modal {
        max-height: min(88dvh, 760px);
        padding: 14px;
        overflow-x: hidden;
        overflow-y: auto;
        border-radius: 22px 22px 12px 12px;
        scrollbar-width: thin;
    }

    #profileModal.fade .profile-dialog {
        opacity: 0;
        transform: translate3d(0, 34px, 0) scale(.995) !important;
    }

    #profileModal.show .profile-dialog {
        opacity: 1;
        transform: translate3d(0, 0, 0) scale(1) !important;
    }

    #profileModal .profile-close {
        position: sticky;
        top: 0;
        float: right;
        width: 34px;
        height: 34px;
        margin: 0 0 -34px auto;
        z-index: 5;
    }

    #profileModal .profile-hero {
        clear: both;
        min-height: 96px;
        gap: 12px;
        padding: 11px 42px 11px 11px;
        border-radius: 16px;
    }

    #profileModal .profile-avatar {
        width: 70px;
        height: 70px;
    }

    #profileModal .profile-level {
        min-width: 29px;
        height: 29px;
        padding-inline: 5px;
        font-size: 12px;
    }

    #profileModal .profile-name { font-size: 19px; }
    #profileModal .profile-id { margin-top: 2px; }
    #profileModal .profile-rank { margin-top: 7px; padding: 6px 8px; }
    #profileModal .profile-progress-panel { margin-top: 8px; padding: 11px 12px; }
    #profileModal .profile-progress-head { margin-bottom: 7px; }
    #profileModal .profile-progress-meta { margin-top: 6px; font-size: 10px; }

    #profileModal .profile-main-stats {
        gap: 7px;
        margin-top: 7px;
    }

    #profileModal .profile-main-stat {
        min-height: 91px;
        padding: 11px;
        border-radius: 13px;
    }

    #profileModal .profile-winrate-value { font-size: 34px; }
    #profileModal .profile-games-value { font-size: 32px; }
    #profileModal .profile-winrate-track { height: 8px; margin-top: 9px; }

    #profileModal .profile-stats {
        gap: 6px;
        margin-top: 7px;
    }

    #profileModal .profile-stat {
        min-height: 70px;
        padding: 7px 4px;
        border-radius: 12px;
    }

    #profileModal .profile-stat-icon {
        width: 29px;
        height: 29px;
        margin-bottom: 3px;
    }

    #profileModal .profile-stat-label { font-size: 9px; }
    #profileModal .profile-stat-value { font-size: 16px; }
}

/* Profile: dedicated low-height mobile landscape layout. */
@media (orientation: landscape) and (max-height: 600px) and (max-width: 1024px) {
    #profileModal {
        padding: 4px 0 4px 4px !important;
        overflow-x: hidden !important;
        overflow-y: hidden !important;
    }

    #profileModal .profile-dialog {
        --bs-modal-width: 450px;
        width: min(450px, calc(100vw - 8px));
        max-width: none;
        min-height: calc(100dvh - 8px);
        margin: 4px 0 4px auto !important;
        display: flex;
        align-items: stretch;
    }

    #profileModal .profile-modal {
        width: 100%;
        height: auto;
        min-height: 0;
        max-height: calc(100dvh - 8px);
        padding: 9px 10px;
        display: block;
        overflow-x: hidden;
        overflow-y: hidden;
        border-radius: 17px 0 0 17px;
    }

    #profileModal.fade .profile-dialog {
        opacity: 0;
        transform: translate3d(38px, 0, 0) scale(.995) !important;
    }

    #profileModal.show .profile-dialog {
        opacity: 1;
        transform: translate3d(0, 0, 0) scale(1) !important;
    }

    #profileModal .profile-close {
        top: 9px;
        right: 8px;
        width: 29px;
        height: 29px;
    }

    #profileModal .profile-hero {
        min-height: 72px;
        gap: 10px;
        padding: 6px 36px 6px 8px;
        border-radius: 12px;
    }

    #profileModal .profile-avatar {
        width: 56px;
        height: 56px;
    }

    #profileModal .profile-level {
        min-width: 24px;
        height: 24px;
        padding-inline: 4px;
        font-size: 11px;
    }

    #profileModal .profile-name { font-size: 17px; }
    #profileModal .profile-id { margin-top: 2px; }
    #profileModal .profile-rank { margin-top: 3px; padding: 3px 6px; font-size: 9px; }
    #profileModal .profile-vip { padding: 4px 6px; font-size: 9px; }

    #profileModal .profile-progress-panel {
        min-height: 58px;
        margin-top: 4px;
        padding: 6px 8px;
        border-radius: 11px;
    }

    #profileModal .profile-progress-head { margin-bottom: 4px; }
    #profileModal .profile-progress-meta { margin-top: 3px; font-size: 8px; }

    #profileModal .profile-main-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 5px;
        margin-top: 4px;
    }

    #profileModal .profile-main-stat {
        min-height: 69px;
        padding: 7px 8px;
        border-radius: 11px;
    }

    #profileModal .profile-winrate-label { font-size: 10px; }
    #profileModal .profile-winrate-value { margin-top: 3px; font-size: 26px; }
    #profileModal .profile-games-value { margin-top: 3px; font-size: 25px; }
    #profileModal .profile-winrate-track { height: 6px; margin-top: 4px; padding: 1px; }

    #profileModal .profile-stats {
        gap: 5px;
        margin-top: 4px;
    }

    #profileModal .profile-stat {
        min-height: 57px;
        padding: 4px 3px;
        display: block;
        text-align: center;
        border-radius: 12px;
    }

    #profileModal .profile-stat-icon {
        width: 22px;
        height: 22px;
        margin: 0 auto 1px;
    }

    #profileModal .profile-stat-label { font-size: 8px; }
    #profileModal .profile-stat-value { margin-top: 0; font-size: 14px; }
    #profileModal .profile-partner-block { margin-top: 4px; }
}

@media (max-width:700px) and (orientation:portrait) {
    #openProfile { width:40px !important; min-width:40px !important; height:40px !important; min-height:40px !important; padding:0 !important; }
    #openProfile img { width:40px !important; height:40px !important; border-radius:11px !important; box-shadow:none !important; }
}

@media (orientation:landscape) and (max-width:1024px) and (max-height:600px) {
    #openProfile { width:38px !important; min-width:38px !important; height:38px !important; min-height:38px !important; padding:0 !important; }
    #openProfile img { width:38px !important; height:38px !important; border-radius:10px !important; box-shadow:none !important; }
}

/* Full-width portrait sheet across the complete mobile breakpoint. */
@media (max-width: 932px) and (orientation: portrait) {
    #profileModal {
        padding-inline: 0 !important;
    }

    #profileModal .profile-dialog {
        width: 100vw !important;
        max-width: 100vw !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    #profileModal .profile-modal {
        width: 100vw !important;
        max-width: 100vw !important;
        border-radius: 22px 22px 0 0;
    }
}

/* Compact icon-only mobile settings rail. */
@media (max-width: 932px), (orientation: landscape) and (max-width: 1024px) and (max-height: 600px) {
    .header-settings-dropdown {
        --mobile-header-menu-width: 62px;
    }

    .header-settings-dropdown > .dropdown-menu {
        position: fixed !important;
        inset: 58px auto auto 8px !important;
        top: 58px !important;
        right: auto !important;
        bottom: auto !important;
        left: 8px !important;
        z-index: 1100;
        width: 62px !important;
        min-width: 62px !important;
        max-height: calc(100dvh - 68px);
        padding: 0 !important;
        display: none !important;
        grid-template-columns: none !important;
        flex-direction: column;
        gap: 5px !important;
        overflow: visible;
        background: transparent !important;
        border: 0 !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        transform: none !important;
        transform-origin: top right;
    }

    .header-settings-dropdown > .dropdown-menu.show {
        display: flex !important;
        animation: none !important;
    }

    .header-settings-dropdown .mobile-game-menu-head,
    .header-settings-dropdown .settings-mobile-divider,
    .header-settings-dropdown .settings-fullscreen-divider,
    .header-settings-dropdown .dropdown-divider {
        display: none !important;
    }

    .header-settings-dropdown > .dropdown-menu > li {
        position: relative;
        width: 50px;
        min-width: 50px;
        margin: 0 !important;
        display: block;
        grid-column: auto !important;
    }

    .header-settings-dropdown > .dropdown-menu.show > li {
        animation: mobileMenuIconDrop .2s cubic-bezier(.18, .86, .28, 1.12) both;
    }

    .header-settings-dropdown > .dropdown-menu.show > li:nth-child(2) { animation-delay: 0s; }
    .header-settings-dropdown > .dropdown-menu.show > li:nth-child(4) { animation-delay: .045s; }
    .header-settings-dropdown > .dropdown-menu.show > li:nth-child(7) { animation-delay: .09s; }
    .header-settings-dropdown > .dropdown-menu.show > li:nth-child(9) { animation-delay: .135s; }
    .header-settings-dropdown > .dropdown-menu.show > li:nth-child(11) { animation-delay: .18s; }
    .header-settings-dropdown > .dropdown-menu.show > li:nth-child(13) { animation-delay: .225s; }

    .header-settings-dropdown .settings-orientation-item .dropdown-item > i {
        color: #8adcf0 !important;
        transition: transform .2s ease, color .14s ease;
    }

    .header-settings-dropdown .settings-orientation-item .dropdown-item:hover > i,
    .header-settings-dropdown .settings-orientation-item .dropdown-item:focus > i {
        color: #fff !important;
        transform: rotate(90deg);
    }

    .header-settings-dropdown > .dropdown-menu > li > .dropdown-item {
        width: 50px !important;
        min-width: 50px !important;
        min-height: 48px !important;
        height: 48px;
        padding: 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        color: #dff6fb !important;
        background: rgba(115, 203, 224, .055) !important;
        border: 1px solid rgba(135, 214, 233, .1) !important;
        border-radius: 13px !important;
        box-shadow: none !important;
        transition: transform .14s ease, color .14s ease, background-color .14s ease, border-color .14s ease !important;
    }

    .header-settings-dropdown > .dropdown-menu > li > .dropdown-item:hover,
    .header-settings-dropdown > .dropdown-menu > li > .dropdown-item:focus {
        color: #fff !important;
        background: rgba(81, 194, 222, .15) !important;
        border-color: rgba(130, 220, 241, .22) !important;
        transform: translateY(-1px);
    }

    .header-settings-dropdown .dropdown-item > i,
    .header-settings-dropdown .dropdown-item > span > i,
    .header-settings-dropdown .form-check-label > i {
        width: auto !important;
        margin: 0 !important;
        color: #77dbef !important;
        font-size: 20px !important;
        text-align: center;
    }

    .header-settings-dropdown .dropdown-item > span:first-child:not(.settings-language-current),
    .header-settings-dropdown .form-check-label {
        width: auto !important;
        display: flex !important;
        align-items: center;
        justify-content: center;
        gap: 0 !important;
        font-size: 0 !important;
    }

    .header-settings-dropdown .form-check-label > span,
    .header-settings-dropdown .dropdown-item > span:first-child:not(.settings-language-current):not(:has(i)),
    .header-settings-dropdown .settings-language-current,
    .header-settings-dropdown .form-switch {
        display: none !important;
    }

    .header-settings-dropdown li:has(.form-check-input:checked) > .dropdown-item {
        color: #fff !important;
        background: rgba(49, 199, 154, .14) !important;
        border-color: rgba(82, 225, 180, .24) !important;
    }

    .header-settings-dropdown li:has(.form-check-input:checked) .form-check-label > i {
        color: #69e2b6 !important;
    }

    .header-settings-dropdown #logout .dropdown-item {
        color: #ffaaa5 !important;
        background: rgba(233, 78, 86, .07) !important;
        border-color: rgba(241, 105, 112, .12) !important;
    }

    .header-settings-dropdown #logout .dropdown-item > i {
        color: #ff8d89 !important;
    }

    .header-settings-dropdown .settings-language-menu {
        position: relative;
        order: 0 !important;
    }

    .header-settings-dropdown #settingsLanguageToggle {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    .header-settings-dropdown #settingsLanguageToggle > .fa-earth-americas {
        display: block !important;
        width: auto !important;
        margin: 0 !important;
        color: #77dbef !important;
        font-size: 20px !important;
    }

    .header-settings-dropdown .settings-language-list {
        position: absolute !important;
        top: 0 !important;
        right: calc(100% + 9px) !important;
        left: auto !important;
        width: 148px !important;
        margin: 0 !important;
        padding: 6px !important;
        display: none !important;
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 5px !important;
        background: linear-gradient(155deg, rgba(17, 50, 63, .99), rgba(5, 23, 31, .995)) !important;
        border: 1px solid rgba(127, 212, 233, .18) !important;
        border-radius: 14px !important;
        box-shadow: 0 18px 42px rgba(0, 0, 0, .42) !important;
        transform-origin: right center;
    }

    .header-settings-dropdown .settings-language-list.settings-language-list-open {
        display: none !important;
        animation: none !important;
    }

    .header-settings-dropdown .settings-language-list .dropdown-item {
        width: 42px !important;
        min-width: 42px !important;
        height: 42px !important;
        min-height: 42px !important;
        padding: 5px !important;
        justify-content: center !important;
        font-size: 0 !important;
        border-radius: 10px !important;
    }

    .header-settings-dropdown .settings-language-list .dropdown-item span {
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 0;
    }

    .header-settings-dropdown .settings-language-list .dropdown-item img {
        width: 28px;
        height: 28px;
        margin: 0 !important;
        border-radius: 50%;
        object-fit: cover;
    }
}

@media (orientation: landscape) and (max-width: 1024px) and (max-height: 600px) {
    .header-settings-dropdown > .dropdown-menu {
        inset: 52px auto auto 8px !important;
        top: 52px !important;
        left: 8px !important;
        max-height: calc(100dvh - 56px);
        overflow-y: auto;
        scrollbar-width: none;
    }

    .header-settings-dropdown > .dropdown-menu::-webkit-scrollbar {
        display: none;
    }

    .header-settings-dropdown > .dropdown-menu > li,
    .header-settings-dropdown > .dropdown-menu > li > .dropdown-item {
        width: clamp(38px, 11dvh, 48px) !important;
        min-width: clamp(38px, 11dvh, 48px) !important;
    }

    .header-settings-dropdown > .dropdown-menu > li > .dropdown-item {
        height: clamp(36px, 10.5dvh, 46px);
        min-height: clamp(36px, 10.5dvh, 46px) !important;
    }
}

@keyframes mobileMenuIconDrop {
    from { opacity: 0; transform: translate3d(0, -16px, 0) scale(.82); }
    to { opacity: 1; transform: translate3d(0, 0, 0) scale(1); }
}

@keyframes mobileLanguageFlyout {
    from { opacity: 0; transform: translate3d(8px, 0, 0) scale(.96); }
    to { opacity: 1; transform: translate3d(0, 0, 0) scale(1); }
}

.language-picker-modal .modal-dialog {
    width: min(92vw, 390px);
    margin-inline: auto;
}

.language-picker-modal .modal-content {
    color: #eafaff;
    background: linear-gradient(160deg, rgba(18, 55, 68, .99), rgba(5, 24, 32, .995));
    border: 1px solid rgba(125, 216, 237, .2);
    border-radius: 22px;
    box-shadow: 0 28px 70px rgba(0, 0, 0, .5);
}

.language-picker-modal .modal-header { border-bottom-color: rgba(135, 215, 234, .12); }
.language-picker-list { display: grid; gap: 10px; }
.language-picker-option {
    width: 100%; min-height: 58px; padding: 9px 14px; display: grid;
    grid-template-columns: 38px 1fr 20px; align-items: center; gap: 12px;
    color: #eafaff; text-align: left; background: rgba(112, 205, 227, .06);
    border: 1px solid rgba(130, 215, 235, .11); border-radius: 15px;
}
.language-picker-option img { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; }
.language-picker-option i { opacity: 0; color: #62e0b1; }
.language-picker-option.active { background: rgba(62, 205, 159, .13); border-color: rgba(82, 225, 180, .27); }
.language-picker-option.active i { opacity: 1; }

/* Final fluid profile sizing: both axes follow the available viewport. */
@media (max-width: 700px) and (orientation: portrait) {
    #profileModal {
        padding: 0 !important;
    }

    #profileModal .profile-dialog {
        width: 100vw;
        max-width: none;
        margin-inline: 0;
    }

    #profileModal .profile-modal {
        width: 100%;
        height: auto;
        max-height: calc(100dvh - 12px);
        padding: clamp(10px, 3.3vw, 16px);
        display: block;
        border-radius: 22px 22px 0 0;
    }

    #profileModal .profile-close {
        position: absolute;
        top: clamp(10px, 2.5vw, 14px);
        right: clamp(10px, 2.5vw, 14px);
        float: none;
        margin: 0;
    }

    #profileModal .profile-hero {
        width: 100%;
        min-height: clamp(92px, 25vw, 112px);
        gap: clamp(9px, 3vw, 15px);
        padding: clamp(8px, 2.8vw, 13px) clamp(40px, 12vw, 52px) clamp(8px, 2.8vw, 13px) clamp(8px, 2.8vw, 13px);
    }

    #profileModal .profile-avatar {
        width: clamp(58px, 19vw, 82px);
        height: clamp(58px, 19vw, 82px);
    }

    #profileModal .profile-name { font-size: clamp(17px, 5vw, 22px); }
    #profileModal .profile-rank { font-size: clamp(9px, 2.7vw, 12px); }

    #profileModal .profile-progress-panel {
        width: 100%;
        min-height: 0;
        margin-top: clamp(7px, 2vw, 10px);
        padding: clamp(8px, 2.6vw, 12px);
    }

    #profileModal .profile-main-stats {
        width: 100%;
        min-height: 0;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: clamp(5px, 2vw, 9px);
        margin-top: clamp(7px, 2vw, 10px);
    }

    #profileModal .profile-main-stat {
        min-width: 0;
        min-height: clamp(92px, 25vw, 108px);
        height: auto;
        padding: clamp(8px, 2.8vw, 13px);
    }

    #profileModal .profile-winrate-value { font-size: clamp(28px, 9vw, 40px); }
    #profileModal .profile-games-value { font-size: clamp(27px, 8.5vw, 38px); }

    #profileModal .profile-stats {
        width: 100%;
        min-height: 0;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: clamp(4px, 1.8vw, 8px);
        margin-top: clamp(7px, 2vw, 10px);
    }

    #profileModal .profile-stat {
        min-width: 0;
        min-height: clamp(68px, 19vw, 82px);
        height: auto;
        padding: clamp(5px, 2vw, 9px);
    }
}

@media (orientation: landscape) and (max-height: 600px) and (max-width: 1024px) {
    #profileModal {
        padding: 0 !important;
    }

    #profileModal .profile-dialog {
        width: clamp(370px, 48vw, 470px);
        height: 100dvh;
        min-height: 100dvh;
        margin: 0 0 0 auto !important;
    }

    #profileModal .profile-modal {
        width: 100%;
        height: 100%;
        max-height: 100dvh;
        padding: clamp(10px, 2.8dvh, 14px) clamp(8px, 1.5vw, 13px);
        box-sizing: border-box;
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows:
            minmax(0, 1.15fr)
            minmax(0, .84fr)
            minmax(0, 1fr)
            minmax(0, .74fr);
        gap: clamp(6px, 2dvh, 10px);
        overflow: hidden;
    }

    #profileModal .profile-hero {
        width: 100%;
        height: 100%;
        min-height: 0;
        gap: clamp(12px, 2vw, 17px);
        padding: clamp(5px, 1.5dvh, 9px) clamp(34px, 5vw, 44px) clamp(5px, 1.5dvh, 9px) clamp(7px, 1.2vw, 11px);
        overflow: hidden;
    }

    #profileModal .profile-avatar {
        width: clamp(46px, 13dvh, 66px);
        height: clamp(46px, 13dvh, 66px);
    }

    #profileModal .profile-name { font-size: clamp(15px, 4.3dvh, 20px); }
    #profileModal .profile-rank { font-size: clamp(8px, 2.3dvh, 11px); }

    #profileModal .profile-progress-panel {
        width: 100%;
        height: 100%;
        min-height: 0;
        margin: 0;
        padding: clamp(5px, 1.5dvh, 9px) clamp(7px, 1.2vw, 11px);
        overflow: hidden;
    }

    #profileModal .profile-main-stats {
        width: 100%;
        height: 100%;
        min-height: 0;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: clamp(8px, 1.5vw, 12px);
        margin: 0;
    }

    #profileModal .profile-main-stat {
        min-width: 0;
        min-height: 0;
        height: 100%;
        padding: clamp(5px, 1.6dvh, 9px) clamp(6px, 1vw, 10px);
    }

    #profileModal .profile-winrate-value { font-size: clamp(22px, 7dvh, 32px); }
    #profileModal .profile-games-value { font-size: clamp(21px, 6.7dvh, 31px); }
    #profileModal .profile-winrate-track { margin-top: clamp(2px, 1dvh, 5px); }

    #profileModal .profile-stats {
        width: 100%;
        height: 100%;
        min-height: 0;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: clamp(7px, 1.2vw, 10px);
        margin: 0;
        align-items: stretch;
        overflow: hidden;
    }

    #profileModal .profile-stat {
        min-width: 0;
        min-height: 0;
        height: 100%;
        padding: clamp(3px, 1dvh, 6px);
        box-sizing: border-box;
        display: grid;
        grid-template-rows: auto auto auto;
        align-content: center;
        justify-items: center;
        overflow: hidden;
    }

    #profileModal .profile-stat-icon {
        width: clamp(19px, 6dvh, 26px);
        height: clamp(19px, 6dvh, 26px);
        margin: 0 0 clamp(1px, .5dvh, 3px);
    }

    #profileModal .profile-stat-label {
        line-height: 1;
    }

    #profileModal .profile-stat-value {
        margin-top: clamp(1px, .4dvh, 2px);
        line-height: 1;
    }

    #profileModal .profile-main,
    #profileModal .profile-name-row,
    #profileModal .profile-main-stat {
        min-width: 0;
        min-height: 0;
        overflow: hidden;
    }

    #profileModal .profile-name,
    #profileModal .profile-id,
    #profileModal .profile-rank span,
    #profileModal .profile-winrate-label {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}
