/**
 * Solid Conquer — mobile / responsive fixes (v7)
 * MUST load last (after divaous / ranking / page CSS) so these rules win.
 */

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    overflow-x: hidden;
}

img,
video,
svg {
    max-width: 100%;
    height: auto;
}

/* max-width only — never height:auto on iframes (breaks reCAPTCHA box). */
iframe {
    max-width: 100%;
}

/* Champion info is a <span> — force proper column layout everywhere */
body.home .ashunt-champion-info {
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    justify-content: center !important;
    gap: 2px !important;
    min-width: 0 !important;
    overflow: hidden !important;
}

body.home .ashunt-champion-portrait {
    margin-left: 0 !important;
}

body.home .ashunt-champion-score {
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-end !important;
    justify-content: center !important;
    min-width: 0 !important;
}

/* Desktop/tablet-wide only: force Bootstrap-hidden Register/Logout visible */
@media (min-width: 992px) {
    .ashunt-auth-actions .ashunt-auth-btn.d-none.d-sm-inline-flex {
        display: inline-flex !important;
    }
}

button,
.ashunt-login-submit,
.ashunt-register-submit,
.ashunt-dash-btn,
.ashunt-auth-btn,
.ashunt-fortress-tab,
a.ashunt-dash-link,
.ashunt-rk-tab {
    touch-action: manipulation;
}

/* ========== TABLET / PHONE ========== */
@media (max-width: 991.98px) {
    .container-xxl,
    .app-container.container-xxl {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

    /* ----- Header topbar: [menu] [logo] ...... [flag] [login] ----- */
    /* Keep header above hero (hero uses negative margin and was covering logo/buttons) */
    #kt_app_header.ashunt-header-v2,
    .ashunt-header-v2.app-header {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        z-index: 100 !important;
        height: 60px !important;
        min-height: 60px !important;
        max-height: 60px !important;
        overflow: visible !important;
        background: linear-gradient(180deg, #0d0e11, #020305) !important;
    }

    .ashunt-header-v2 .ashunt-topbar,
    .ashunt-header-v2 .app-header-primary.h-50px {
        height: 60px !important;
        min-height: 60px !important;
        max-height: 60px !important;
        overflow: visible !important;
        background: linear-gradient(180deg, #0d0e11, #020305) !important;
    }

    /* Drawer must sit above the fixed topbar when open */
    .ashunt-header-v2 .ashunt-mainbar.app-header-mobile-drawer,
    .app-header-mobile-drawer.ashunt-mainbar {
        z-index: 110 !important;
    }

    .ashunt-header-v2 .ashunt-topbar-inner {
        display: flex !important;
        height: 60px !important;
        min-height: 60px !important;
        max-height: 60px !important;
        align-items: center !important;
        justify-content: space-between !important;
        gap: 8px !important;
        padding-top: 0 !important;
        padding-bottom: 0 !important;
        padding-left: 10px !important;
        padding-right: 10px !important;
    }

    .ashunt-header-v2 .ashunt-socials {
        display: flex !important;
        align-items: center !important;
        gap: 8px !important;
        margin-right: 0 !important;
        min-width: 0;
        flex: 1 1 auto;
    }

    .ashunt-mobile-brand {
        display: inline-flex !important;
        align-items: center !important;
        justify-content: flex-start !important;
        max-width: min(168px, 46vw);
        height: 48px !important;
        margin: 0 !important;
        padding: 0 !important;
        text-decoration: none !important;
        overflow: visible !important;
        flex: 0 1 auto;
    }

    .ashunt-mobile-brand-img {
        display: block !important;
        width: auto !important;
        height: 48px !important;
        max-width: 100% !important;
        max-height: 48px !important;
        object-fit: contain !important;
        /* PNG has a solid black canvas — knock it out on the dark header */
        mix-blend-mode: lighten;
    }

    .ashunt-topbar-actions {
        display: flex !important;
        align-items: center !important;
        gap: 6px !important;
        flex: 0 0 auto;
        justify-content: flex-end;
        min-width: 0;
        height: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    .ashunt-auth-actions,
    .ashunt-auth-actions.py-3 {
        display: flex !important;
        align-items: center !important;
        flex-wrap: nowrap !important;
        gap: 5px !important;
        max-width: none;
        height: auto !important;
        padding-top: 0 !important;
        padding-bottom: 0 !important;
        margin: 0 !important;
    }

    .ashunt-auth-actions > div {
        display: flex !important;
        align-items: center !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* One primary CTA on phones — Register lives in the drawer menu */
    .ashunt-auth-actions .ashunt-auth-btn-register,
    .ashunt-auth-actions .ashunt-auth-btn.d-none.d-sm-inline-flex {
        display: none !important;
    }

    .ashunt-auth-btn,
    .ashunt-auth-btn-login {
        min-height: 34px !important;
        height: 34px !important;
        padding: 0 12px !important;
        font-size: 0.72rem !important;
        letter-spacing: 0.03em !important;
        line-height: 1 !important;
        white-space: nowrap;
        flex: 0 0 auto;
        box-sizing: border-box !important;
        overflow: hidden !important;
    }

    .ashunt-mobile-toggle,
    .ashunt-tool-button,
    .ashunt-header-v2 .btn.ashunt-tool-button {
        width: 36px !important;
        height: 36px !important;
        min-width: 36px !important;
        min-height: 36px !important;
        flex: 0 0 36px;
        padding: 0 !important;
        margin: 0 !important;
    }

    .ashunt-mobile-toggle i {
        color: #efc657 !important;
    }

    .ashunt-language-flag,
    .ashunt-header-v2 .ashunt-language-flag.h-30px {
        width: 18px !important;
        height: 18px !important;
    }

    /* Drawer nav */
    .ashunt-header-v2 .ashunt-nav-link {
        min-height: 48px !important;
    }

    .ashunt-section-heading h2 {
        font-size: clamp(1.3rem, 5.5vw, 1.8rem) !important;
        line-height: 1.2 !important;
    }

    /* Server status */
    body.home .ashunt-server-grid-six {
        grid-template-columns: 1fr 1fr !important;
        gap: 10px !important;
    }

    body.home .ashunt-fortress-tabs {
        display: grid !important;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    body.home .ashunt-fortress-tab {
        width: 100%;
        min-height: 44px;
        justify-content: center;
        font-size: 0.78rem !important;
    }

    body.home .ashunt-fortress-stats {
        grid-template-columns: 1fr !important;
    }

    /* Hall of Fame rows — clean 3-col + score under info
       (overrides divaous 4-col mobile rules) */
    body.home .ashunt-champion-list {
        padding: 10px 8px !important;
    }

    body.home .ashunt-champion-row,
    body.home .ashunt-champion-row.is-gold,
    body.home .ashunt-champion-row.is-silver,
    body.home .ashunt-champion-row.is-bronze,
    body.home .ashunt-champion-row.is-standard {
        display: grid !important;
        grid-template-columns: 42px 46px minmax(0, 1fr) !important;
        grid-template-rows: auto auto !important;
        grid-template-areas: none !important;
        column-gap: 8px !important;
        row-gap: 2px !important;
        align-items: center !important;
        min-height: 0 !important;
        height: auto !important;
        padding: 10px 10px !important;
        overflow: hidden !important;
        transform: none !important;
    }

    body.home .ashunt-champion-energy,
    body.home .ashunt-champion-spark {
        display: none !important;
    }

    body.home .ashunt-champion-medal {
        grid-column: 1 !important;
        grid-row: 1 / span 2 !important;
        position: relative !important;
        width: 40px !important;
        height: 40px !important;
        margin: 0 !important;
        justify-self: center !important;
        align-self: center !important;
    }

    body.home .ashunt-champion-portrait,
    body.home .ashunt-champion-guild-portrait {
        grid-column: 2 !important;
        grid-row: 1 / span 2 !important;
        position: relative !important;
        width: 46px !important;
        height: 46px !important;
        margin: 0 !important;
        justify-self: center !important;
        align-self: center !important;
    }

    body.home .ashunt-champion-info {
        grid-column: 3 !important;
        grid-row: 1 !important;
        position: relative !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        justify-content: center !important;
        gap: 1px !important;
        width: 100% !important;
        min-width: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    body.home .ashunt-champion-score {
        grid-column: 3 !important;
        grid-row: 2 !important;
        position: relative !important;
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        align-items: baseline !important;
        justify-content: flex-start !important;
        gap: 6px !important;
        min-width: 0 !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        text-align: left !important;
    }

    body.home .ashunt-champion-name {
        font-size: 0.9rem !important;
        line-height: 1.2 !important;
        max-width: 100% !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }

    body.home .ashunt-champion-level,
    body.home .ashunt-champion-class {
        font-size: 0.72rem !important;
        margin-top: 0 !important;
        line-height: 1.25 !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        max-width: 100% !important;
    }

    body.home .ashunt-champion-score strong {
        font-size: 0.92rem !important;
        line-height: 1.2 !important;
    }

    body.home .ashunt-champion-score small {
        display: inline-block !important;
        font-size: 0.62rem !important;
        opacity: 0.8;
    }

    body.home .ashunt-hof-view-all,
    body.home .ashunt-champion-view-all {
        min-height: 44px;
        font-size: 0.74rem !important;
        padding: 10px 12px !important;
        justify-content: center;
    }

    body.home .ashunt-hof-card-header {
        padding: 14px 12px !important;
    }

    body.home .ashunt-hof-card-header h3 {
        font-size: 1.05rem !important;
    }

    /* Social */
    .ashunt-social-box {
        min-height: 400px !important;
    }

    .ashunt-social-box__frame,
    .ashunt-social-box__fallback {
        min-height: 320px !important;
    }

    /* Footer */
    .ashunt-footer-bottom {
        flex-direction: column !important;
        align-items: center !important;
        text-align: center !important;
        gap: 12px !important;
    }

    .ashunt-footer-server-time {
        text-align: center;
    }

    /* Forms */
    .ashunt-login-page,
    .ashunt-register-page {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

    .ashunt-login-control input,
    .ashunt-register-control input {
        font-size: 16px !important;
    }

    .ashunt-login-submit,
    .ashunt-register-submit {
        width: 100%;
        min-height: 48px;
    }

    .ashunt-recaptcha-field {
        margin: 14px 0 20px !important;
        min-height: 78px !important;
        overflow: visible !important;
        align-items: center !important;
        text-align: center !important;
    }

    .ashunt-recaptcha-wrap,
    .ashunt-recaptcha-wrap .g-recaptcha {
        overflow: visible !important;
    }

    .ashunt-recaptcha-wrap iframe,
    .ashunt-recaptcha-field iframe,
    .g-recaptcha iframe {
        max-width: none !important;
        width: 304px !important;
        height: 78px !important;
    }

    /* Dashboard */
    .ashunt-dash-wrap {
        width: min(100% - 20px, 1120px) !important;
    }

    .ashunt-dash-top-actions {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 8px !important;
    }

    .ashunt-dash-btn {
        flex: 1 1 calc(50% - 8px);
        min-width: 140px;
        min-height: 44px;
        justify-content: center;
    }

    .ashunt-dash-links {
        grid-template-columns: 1fr !important;
    }

    /* Ranking */
    .ashunt-rk-page {
        width: calc(100% - 16px) !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    .ashunt-rk-tabs,
    .public-rank-tabs {
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        gap: 8px !important;
        justify-content: flex-start !important;
        padding: 0 2px 8px !important;
        scrollbar-width: thin;
    }

    .ashunt-rk-tab,
    .public-rank-tab {
        flex: 0 0 auto !important;
        min-height: 40px !important;
        white-space: nowrap !important;
    }

    .ashunt-rk-panel-head {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 6px !important;
        padding: 16px !important;
    }

    .public-rank-toolbar {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 10px !important;
        padding: 12px !important;
    }

    .public-rank-search,
    .public-rank-per-page,
    .public-rank-toolbar__submit {
        width: 100% !important;
    }

    .public-rank-toolbar__submit {
        min-height: 46px !important;
        justify-content: center !important;
    }

    .ashunt-rk-tabs::-webkit-scrollbar,
    .ashunt-rk-table-wrap::-webkit-scrollbar {
        height: 4px;
    }

    .ashunt-rk-tabs::-webkit-scrollbar-thumb,
    .ashunt-rk-table-wrap::-webkit-scrollbar-thumb {
        background: rgba(220, 167, 47, 0.45);
        border-radius: 999px;
    }

    .ashunt-rk-table-wrap,
    .public-rank-table-wrap,
    .table-responsive {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        max-width: 100%;
    }

    .ashunt-rk-table {
        min-width: 0 !important;
        width: 100% !important;
    }

    /* Players: keep # / Character / Score — drop Guild + Class on phones */
    .ashunt-rk-table--players th:nth-child(3),
    .ashunt-rk-table--players td:nth-child(3),
    .ashunt-rk-table--players th:nth-child(4),
    .ashunt-rk-table--players td:nth-child(4) {
        display: none !important;
    }

    /* Guilds: keep # / Guild / Fund — drop Leader on phones */
    .ashunt-rk-table--guilds th:nth-child(3),
    .ashunt-rk-table--guilds td:nth-child(3) {
        display: none !important;
    }

    .ashunt-rk-table th:nth-child(1),
    .ashunt-rk-table td:nth-child(1) {
        width: 48px !important;
        padding-left: 10px !important;
        padding-right: 6px !important;
    }

    .ashunt-rk-table .ashunt-rk-value {
        white-space: nowrap !important;
        font-size: 0.86rem !important;
    }
}

/* ========== SMALL PHONES ========== */
@media (max-width: 575.98px) {
    body.home .ashunt-server-grid-six {
        grid-template-columns: 1fr !important;
    }

    body.home .ashunt-fortress-tabs {
        grid-template-columns: 1fr;
    }

    .ashunt-auth-btn-login {
        padding: 0 10px !important;
        font-size: 0.7rem !important;
    }

    body.home .ashunt-champion-row {
        grid-template-columns: 36px 42px minmax(0, 1fr) !important;
        padding: 9px !important;
        column-gap: 7px !important;
    }

    body.home .ashunt-champion-medal {
        width: 34px !important;
        height: 34px !important;
    }

    body.home .ashunt-champion-portrait,
    body.home .ashunt-champion-guild-portrait {
        width: 42px !important;
        height: 42px !important;
    }

    body.home .ashunt-champion-name {
        font-size: 0.84rem !important;
    }

    body.home .ashunt-champion-level,
    body.home .ashunt-champion-class {
        font-size: 0.68rem !important;
    }

    .ashunt-dash-btn {
        flex: 1 1 100%;
    }

    .ashunt-armory-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    }

    .ashunt-rk-table th,
    .ashunt-rk-table td {
        padding: 10px 8px !important;
        font-size: 0.82rem !important;
    }

    .ashunt-rk-tab {
        padding: 0 12px !important;
        font-size: 0.78rem !important;
    }

    .ashunt-rk-avatar {
        width: 34px !important;
        height: 34px !important;
    }

    .ashunt-social-box {
        min-height: 360px !important;
    }

    .ashunt-social-box__frame,
    .ashunt-social-box__fallback {
        min-height: 280px !important;
    }
}

@media (max-width: 400px) {
    .ashunt-mobile-brand {
        max-width: min(132px, 40vw);
        height: 42px !important;
    }

    .ashunt-mobile-brand-img {
        height: 42px !important;
        max-height: 42px !important;
    }

    .ashunt-auth-btn-login {
        font-size: 0.7rem !important;
        padding: 0 12px !important;
    }
}

@supports (padding: max(0px)) {
    .ashunt-header-v2 .ashunt-topbar-inner {
        padding-left: max(10px, env(safe-area-inset-left)) !important;
        padding-right: max(10px, env(safe-area-inset-right)) !important;
    }

    .ashunt-footer {
        padding-bottom: max(16px, env(safe-area-inset-bottom));
    }
}
