/**
 * BattlePals Mobile Styles
 * Hamburger navigation + global mobile-friendly overrides
 */

/* ===== HAMBURGER MENU BUTTON ===== */
.nav-hamburger {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 44px;
    height: 44px;
    cursor: pointer;
    z-index: 1001;
    background: linear-gradient(145deg, rgba(139, 69, 19, 0.95), rgba(160, 82, 45, 0.9));
    border: 2px solid rgba(218, 165, 32, 0.6);
    border-radius: 10px;
    padding: 8px;
    gap: 5px;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.nav-hamburger span {
    display: block;
    width: 22px;
    height: 2px;
    background: #E0E0E0;
    border-radius: 2px;
    transition: all 0.3s ease;
}

/* Hamburger -> X animation */
.nav-hamburger.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}
.nav-hamburger.active span:nth-child(2) {
    opacity: 0;
}
.nav-hamburger.active span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}

/* ===== MOBILE NAV LAYOUT (<=1024px) ===== */
@media (max-width: 1024px) {
    .nav-hamburger {
        display: flex;
    }

    .nav-container {
        flex-direction: row !important;
        flex-wrap: wrap;
        justify-content: space-between;
        align-items: center;
        padding: 8px 12px !important;
        gap: 0 !important;
    }

    /* Hide nav sections by default on mobile */
    .nav-primary,
    .nav-secondary {
        display: none !important;
        width: 100%;
        flex-direction: column !important;
        gap: 6px !important;
        padding-top: 10px;
    }

    /* Show when menu is open */
    .nav-menu-open .nav-primary,
    .nav-menu-open .nav-secondary {
        display: flex !important;
    }

    .nav-menu-open .nav-secondary {
        border-top: 1px solid rgba(218, 165, 32, 0.3);
        padding-top: 8px;
        margin-top: 4px;
    }

    /* Nav items fill width on mobile */
    .nav-item {
        width: 100%;
    }

    .nav-scroll-bg {
        width: 100% !important;
        min-width: unset !important;
        height: 44px !important;
        border-radius: 10px !important;
        padding: 8px 16px !important;
        justify-content: flex-start !important;
    }

    .nav-text {
        max-width: none !important;
        font-size: 14px !important;
        text-align: left !important;
    }

    .nav-link {
        justify-content: flex-start !important;
    }

    /* Dropdowns appear inline below the item on mobile */
    .nav-dropdown {
        position: static !important;
        width: 100% !important;
        transform: none !important;
        display: none;
        border-radius: 0 0 10px 10px !important;
        margin-top: -2px;
        border-top: none !important;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease;
    }

    .nav-item.nav-mobile-active .nav-dropdown {
        display: block;
        max-height: 500px;
    }

    /* Override hover-based dropdowns on touch - use tap instead */
    .nav-item:hover .nav-dropdown {
        display: none;
    }
    .nav-item.nav-mobile-active:hover .nav-dropdown,
    .nav-item.nav-mobile-active .nav-dropdown {
        display: block;
    }

    .nav-dropdown-item {
        padding: 14px 20px !important;
        font-size: 15px !important;
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    .nav-dropdown-note {
        padding: 2px 20px 6px 20px;
        font-size: 11px;
    }

    /* Logo adjusts on mobile */
    .nav-logo {
        order: -1;
    }
    .nav-logo img {
        height: 40px;
    }

    /* Disable hover transform effects on touch */
    .nav-item:hover .nav-scroll-bg {
        transform: none !important;
        filter: none !important;
    }
}

/* ===== LANDSCAPE MOBILE NAV — show inline, no hamburger ===== */
@media (max-width: 1024px) and (orientation: landscape) {
    /* Hide hamburger */
    .nav-hamburger {
        display: none !important;
    }

    /* Restore inline nav row */
    .nav-container {
        flex-wrap: nowrap !important;
        padding: 4px 8px !important;
        gap: 6px !important;
    }

    .nav-primary,
    .nav-secondary {
        display: flex !important;
        flex-direction: row !important;
        width: auto !important;
        gap: 4px !important;
        padding-top: 0 !important;
    }

    .nav-secondary {
        border-top: none !important;
        margin-top: 0 !important;
    }

    .nav-item {
        width: auto !important;
    }

    /* Compact scroll buttons */
    .nav-scroll-bg {
        height: 32px !important;
        min-width: 60px !important;
        padding: 4px 10px !important;
        border-radius: 8px !important;
    }

    .nav-text {
        font-size: 11px !important;
    }

    /* Restore hover dropdowns (not tap) */
    .nav-item:hover .nav-dropdown {
        display: block !important;
    }

    .nav-dropdown {
        position: absolute !important;
        top: 100% !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        width: 180px !important;
        max-height: none !important;
        overflow: visible !important;
        border-radius: 8px !important;
        margin-top: 0 !important;
        z-index: 1000;
    }

    .nav-dropdown-item {
        padding: 8px 12px !important;
        min-height: 32px;
        font-size: 12px !important;
    }

    .nav-dropdown-note {
        font-size: 9px;
        padding: 1px 12px 3px 12px;
    }

    /* Re-enable hover effects */
    .nav-item:hover .nav-scroll-bg {
        transform: translateY(-2px) scale(1.03) !important;
        filter: brightness(1.1) !important;
    }
}

/* ===== SMALL MOBILE (<=480px) ===== */
@media (max-width: 480px) {
    .nav-container {
        padding: 6px 8px !important;
    }

    .nav-text {
        font-size: 13px !important;
    }

    .nav-scroll-bg {
        height: 42px !important;
        padding: 6px 12px !important;
    }
}

/* ===== GLOBAL MOBILE OVERRIDES ===== */

/* Prevent horizontal overflow */
@media (max-width: 1024px) {
    /* Catch-all: no element wider than viewport */
    *, *::before, *::after {
        max-width: 100vw;
        box-sizing: border-box;
    }

    /* Tables scroll horizontally */
    table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        max-width: 100%;
    }

    /* Images don't overflow */
    img {
        max-width: 100%;
        height: auto;
    }

    /* Inputs zoom prevention (iOS) */
    input, select, textarea {
        font-size: 16px;
    }

    /* Better tap targets */
    a, button, [role="button"], .clickable {
        min-height: 44px;
        min-width: 44px;
    }

    /* Inline links don't need min-height */
    p a, span a, li a, td a,
    .nav-dropdown-item,
    .nav-dropdown-note {
        min-height: unset;
        min-width: unset;
    }

    /* Guild menu responsive — full page scroll, no inner scrollbars */
    .guild-menu {
        flex-direction: column !important;
        height: auto !important;
        width: 100% !important;
        box-sizing: border-box !important;
        overflow: visible !important;
    }

    .guild-menu-left,
    .guild-menu-center,
    .guild-menu-right {
        width: 100% !important;
        max-width: 100% !important;
        min-height: auto !important;
        max-height: none !important;
        overflow: visible !important;
        box-sizing: border-box !important;
    }

    .guild-menu-left {
        order: 1;
    }

    .guild-menu-center {
        order: 2;
    }

    .guild-menu-right {
        order: 3;
    }

    /* Footer inside exp bar, right side */
    footer {
        position: fixed !important;
        bottom: 0 !important;
        right: 8px !important;
        left: auto !important;
        padding: 0 !important;
        margin: 0 !important;
        font-size: 9px !important;
        text-align: right !important;
        z-index: 51 !important;
        height: 35px !important;
        line-height: 35px !important;
        color: #888 !important;
    }

    footer p {
        margin: 0 !important;
        padding: 0 !important;
        line-height: 35px !important;
    }

    /* Keep exp bar fixed at bottom on mobile */
    .exp-bar-cont {
        position: fixed !important;
        bottom: 0 !important;
        height: 35px !important;
        width: 100% !important;
        display: block !important;
        font-size: 11px !important;
        z-index: 50;
    }

    .exp-bar {
        width: 80% !important;
    }

    /* === FULL PAGE SCROLL === */
    /* Remove fixed heights so entire page scrolls as one document */
    html, body {
        height: auto !important;
        overflow-x: clip !important;
        overflow-y: visible !important;
        position: static !important;
        -webkit-text-size-adjust: 100%;
    }

    wrapper {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        height: auto !important;
        min-height: auto !important;
        max-height: none !important;
        overflow: visible !important;
        padding-left: 8px !important;
        padding-right: 8px !important;
        padding-bottom: 50px !important; /* Space for fixed exp bar */
    }

    .home-menu {
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
    }

    .menu1, .menu2, .menu3 {
        width: 100% !important;
        height: auto !important;
        overflow: visible !important;
    }

    /* Common container patterns */
    .container, .content-wrapper, .page-wrapper,
    .main-content, .content-area {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        padding-left: 8px;
        padding-right: 8px;
    }

    /* Battle pages: no padding on wrapper, battlefield needs edge-to-edge */
    body:has(.battlefield) wrapper {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
}

/* ===== PORTRAIT MOBILE BONUS STYLES ===== */
@media (max-width: 1024px) and (orientation: portrait) {
    /* Stack flex rows vertically */
    .flex-row-portrait {
        flex-direction: column;
    }

    /* Full-width buttons */
    .btn, .button, [type="submit"], [type="button"] {
        width: 100%;
        text-align: center;
    }

    /* Modals and popups full-width */
    .modal, .popup, .dialog {
        width: 95vw !important;
        max-width: 95vw !important;
        left: 2.5vw !important;
        transform: none !important;
    }
}

/* ===== TABLET (1025px - 1200px) ===== */
@media (min-width: 1025px) and (max-width: 1200px) {
    .guild-menu-left,
    .guild-menu-right {
        width: 25% !important;
    }

    .guild-menu-center {
        width: 50% !important;
    }
}

/* ===== INVENTORY PAGE ===== */
/* Full page scroll for inventory on all mobile orientations */
@media (max-width: 1024px) {
    /* Override base body:has(.inventory-menu) fixed sizing */
    body:has(.inventory-menu) {
        overflow-x: clip !important;
        overflow-y: visible !important;
        height: auto !important;
        position: static !important;
    }

    body:has(.inventory-menu) wrapper {
        overflow: visible !important;
        height: auto !important;
        max-height: none !important;
        display: block !important;
    }

    body:has(.inventory-menu) .home-menu {
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
        display: block !important;
    }

    /* Column layout: filter on top, side-by-side content below */
    .inventory-menu {
        display: flex !important;
        flex-direction: column !important;
        height: auto !important;
        gap: 8px !important;
        padding: 8px !important;
        overflow: visible !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    /* Filter spans full width above the side-by-side content */
    .inventory-menu > form,
    .inventory-menu > div:has(form) {
        width: 100% !important;
        max-width: 100% !important;
        flex-shrink: 0 !important;
        box-sizing: border-box !important;
    }

    .inv-filter-form {
        box-sizing: border-box !important;
        max-width: 100% !important;
        overflow: hidden !important;
    }

    .inv-filter-row {
        flex-wrap: wrap !important;
        max-width: 100% !important;
    }

    .inv-filter-grid {
        max-width: 100% !important;
        overflow: hidden !important;
    }

    /* .inventory-main-content wraps items + armory side by side */
    .inventory-main-content {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        align-items: flex-start !important;
        gap: 8px !important;
        width: 100% !important;
        overflow: visible !important;
    }

    /* Items grid - show everything, no inner scroll */
    .inventory-container {
        flex: 1 1 0% !important;
        min-width: 0 !important;
        height: auto !important;
        min-height: auto !important;
        max-height: none !important;
        overflow: visible !important;
        overflow-y: visible !important;
        display: grid !important;
        grid-template-columns: repeat(auto-fill, minmax(65px, 1fr)) !important;
        gap: 8px !important;
        padding: 10px !important;
        grid-column: unset !important;
        grid-row: unset !important;
    }

    .inventory-container::-webkit-scrollbar {
        display: none !important;
    }

    /* Armory sticky on the right while scrolling items */
    .inventory-armory {
        position: sticky !important;
        top: 70px !important; /* Below nav bar */
        flex: 0 0 200px !important;
        width: 200px !important;
        height: auto !important;
        max-height: calc(100vh - 120px) !important;
        overflow-y: auto !important;
        padding: 30px 10px 10px 10px !important;
        align-self: flex-start !important;
        grid-column: unset !important;
        grid-row: unset !important;
    }

    .armor_cont {
        max-width: 100% !important;
        justify-content: center;
        gap: 6px !important;
    }

    .inventory-armory .slottedArmor,
    .inventory-armory .helm, .inventory-armory .shoulder,
    .inventory-armory .chest, .inventory-armory .neck,
    .inventory-armory .pants, .inventory-armory .feet,
    .inventory-armory .ring, .inventory-armory .gloves,
    .inventory-armory .weapon, .inventory-armory .offhand,
    .inventory-armory .bracer, .inventory-armory .belt {
        width: 50px !important;
        height: 50px !important;
        min-width: 50px !important;
    }

    .inventory-item {
        width: 100% !important;
        height: auto !important;
        min-height: 80px !important;
        padding: 6px !important;
        overflow: hidden !important;
        box-sizing: border-box !important;
    }

    .inv-icon-name {
        width: 100% !important;
        height: auto !important;
        overflow: hidden !important;
        min-width: 0 !important;
    }

    .inv-name {
        display: block !important;
        font-size: 9px !important;
        line-height: 1.2 !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
        width: 100% !important;
        min-width: 0 !important;
        margin-top: 3px !important;
    }

    .inv-icon {
        width: 40px !important;
        height: 40px !important;
    }

    .inventory-container {
        grid-template-columns: repeat(auto-fill, minmax(85px, 1fr)) !important;
    }
}

/* Portrait: stack inventory to single column */
@media (max-width: 1024px) and (orientation: portrait) {
    .inventory-menu {
        flex-direction: column !important;
    }

    /* Filter form full width */
    .inventory-menu > form,
    .inventory-menu > div:has(form) {
        order: 1;
        width: 100%;
    }

    .inv-filter-form {
        padding: 8px;
    }

    .inv-filter-row {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .inv-filter-search {
        width: 100% !important;
    }

    .inv-filter-grid {
        justify-content: center;
    }

    .inv-filter-select {
        width: 100%;
    }

    /* Main content stacks vertically in portrait */
    .inventory-main-content {
        display: flex !important;
        flex-direction: column !important;
        order: 2;
        flex-shrink: 0 !important;
    }

    /* Armory full-width below items in portrait */
    .inventory-armory {
        position: static !important;
        flex: none !important;
        width: 100% !important;
        max-height: none !important;
    }
}

@media (max-width: 480px) {
    .inventory-container {
        grid-template-columns: repeat(auto-fill, minmax(75px, 1fr)) !important;
    }

    .inventory-item {
        min-height: 70px !important;
    }

    .inv-icon {
        width: 34px !important;
        height: 34px !important;
    }

    .inv-name {
        font-size: 8px !important;
    }

    .slottedArmor {
        width: 60px !important;
        height: 60px !important;
    }
}

/* ===== LOGIN / REGISTER PAGES ===== */
@media (max-width: 1024px) {
    .modern-login-container {
        flex-direction: column !important;
        padding: 10px !important;
        gap: 15px !important;
    }

    .login-card, .register-card {
        width: 100% !important;
        max-width: 100% !important;
    }

    .login-features {
        width: 100% !important;
    }

    .input-group input,
    .input-group select {
        width: 100% !important;
        font-size: 16px !important;
    }
}

/* ===== AUCTION HOUSE ===== */
@media (max-width: 1024px) {
    /* Allow auction page to scroll */
    body:has(.auction) {
        overflow: auto !important;
        height: auto !important;
    }

    body:has(.auction) wrapper {
        overflow: visible !important;
        height: auto !important;
    }

    body:has(.auction) .home-menu {
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
    }

    .auction {
        height: auto !important;
        max-height: none !important;
    }

    .ah-tabs-bar {
        flex-wrap: wrap;
        height: auto !important;
    }

    .ah-tab {
        flex: 1 1 auto;
        min-width: 80px;
        padding: 10px 12px !important;
        font-size: 13px !important;
    }

    /* Stack top bar filters vertically */
    .ah-top-bar {
        flex-direction: column !important;
        padding: 8px !important;
    }

    .ah-top-list {
        width: 100% !important;
        margin: 4px 0;
    }

    .ah-top-list select,
    .ah-top-list input {
        width: 100% !important;
    }

    .ah-range {
        width: 45% !important;
    }

    /* Stack sidebar and content vertically */
    .ah-cont {
        flex-direction: column !important;
        height: auto !important;
    }

    .ah-left {
        width: 100% !important;
        height: auto !important;
        flex-direction: row !important;
        flex-wrap: wrap;
        gap: 4px;
        padding: 8px !important;
    }

    .ah-categories {
        flex: 1 1 auto;
        min-width: 60px;
        padding: 6px 8px !important;
        font-size: 12px !important;
        text-align: center;
    }

    .ah-right {
        width: 100% !important;
        height: auto !important;
        min-height: 300px;
    }

    /* Listing items scroll */
    .ah-list {
        max-height: 50vh;
        overflow-y: auto !important;
    }

    /* Auction list items stack info */
    .ah-list-item {
        flex-wrap: wrap;
        gap: 4px;
        padding: 8px !important;
    }

    .ah-right-bar {
        font-size: 11px !important;
    }

    .ah-right-top-bar {
        display: none !important;
    }

    .ah-right-rarity {
        width: 100% !important;
    }

    .ah-right-lvl,
    .ah-right-time-left,
    .ah-right-seller,
    .ah-right-current-bid {
        width: auto !important;
        flex: 1 1 auto;
    }

    /* Bottom bar */
    .ah-bottom-bar {
        flex-direction: column !important;
        gap: 8px;
        padding: 8px !important;
    }

    .ah-bid-input {
        width: 100% !important;
    }

    /* Sell form */
    .ah-sell-form-row {
        flex-direction: column !important;
        gap: 8px;
    }

    .ah-form-group {
        width: 100% !important;
    }

    /* Sell inventory grid */
    .ah-sell-inv {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)) !important;
    }
}

/* ===== BANK PAGE ===== */
@media (max-width: 1024px) {
    .bank-container {
        padding: 10px !important;
        margin: 5px !important;
    }

    .bank-main-content {
        grid-template-columns: 1fr !important;
    }

    .bank-content-header {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }
}

/* ===== MERCHANT PAGE ===== */
@media (max-width: 1024px) {
    .merchant-container, .trader-container, .trainer-container {
        width: 95% !important;
        max-width: 100% !important;
        padding: 10px !important;
        margin: 10px auto !important;
    }

    .merchant-grid, .shop-grid {
        grid-template-columns: 1fr !important;
    }

    .merchant-item, .shop-item {
        width: 100% !important;
    }
}

/* ===== QUEST / ACHIEVEMENT PAGES ===== */
@media (max-width: 1024px) {
    .quest-container, .achievement-container {
        width: 95% !important;
        padding: 10px !important;
    }

    .quest-list, .achievement-list {
        grid-template-columns: 1fr !important;
    }

    .quest-card, .achievement-card {
        width: 100% !important;
    }

    .quest-header, .achievement-header {
        flex-direction: column;
        gap: 8px;
    }
}

/* ===== BATTLE SETUP PAGE ===== */
@media (max-width: 1024px) {
    .battle-setup-container {
        width: 95% !important;
        padding: 10px !important;
    }

    .battle-type-grid {
        grid-template-columns: 1fr !important;
    }

    .battle-type-card {
        width: 100% !important;
    }

    .difficulty-selector {
        flex-direction: column;
        gap: 8px;
    }

    .difficulty-btn {
        width: 100%;
    }
}

/* ===== MAIL PAGE ===== */
@media (max-width: 1024px) {
    .mail-container {
        flex-direction: column !important;
    }

    .mail-sidebar, .mail-content {
        width: 100% !important;
    }

    .mail-list {
        max-height: 200px;
        overflow-y: auto;
    }
}

/* ===== TRADING PAGE ===== */
@media (max-width: 1024px) {
    .trade-container {
        flex-direction: column !important;
    }

    .trade-panel {
        width: 100% !important;
    }

    .trade-grid {
        grid-template-columns: repeat(auto-fill, minmax(55px, 1fr)) !important;
    }
}

/* ===== PROFESSIONS PAGE ===== */
@media (max-width: 1024px) {
    .profession-container {
        width: 95% !important;
        padding: 10px !important;
    }

    .recipe-grid {
        grid-template-columns: 1fr !important;
    }
}

/* ===== CHARACTER SHEET ENHANCEMENTS ===== */
@media (max-width: 1024px) {
    .character-container {
        width: 98% !important;
        padding: 10px !important;
        margin: 10px auto !important;
    }

    .character-header {
        flex-direction: column !important;
        gap: 15px;
        text-align: center;
    }

    .character-quick-nav {
        justify-content: center;
    }

    .stats-row {
        grid-template-columns: 1fr !important;
    }

    .resistance-grid {
        flex-direction: column;
    }

    .resistance-item {
        min-width: auto !important;
    }

    .equipment-grid {
        justify-content: center;
    }
}

/* ===== SOCIAL WIDGET MOBILE ===== */
@media (max-width: 1024px) {
    .social-widget {
        width: 280px !important;
        min-width: 0 !important;
        max-width: 85vw !important;
        bottom: 40px !important;
        right: 5px !important;
        max-height: 60vh !important;
        box-sizing: border-box !important;
    }

    .social-widget.minimized {
        width: auto !important;
    }

    .social-widget-content {
        max-height: 50vh !important;
        overflow-y: auto !important;
    }
}

/* ===== GLOBAL CHAT WIDGET MOBILE ===== */
@media (max-width: 1024px) {
    .global-chat-widget {
        width: 280px !important;
        min-width: 0 !important;
        max-width: 85vw !important;
        max-height: 50vh !important;
        box-sizing: border-box !important;
    }

    .global-chat-messages {
        max-height: 30vh !important;
    }

    .chat-tab {
        padding: 6px 8px !important;
    }

    .tab-name {
        font-size: 10px !important;
    }
}

/* Landscape: shorter widgets to leave room for gameplay */
@media (max-height: 500px) and (orientation: landscape) {
    .social-widget {
        max-height: 45vh !important;
        bottom: 35px !important;
    }

    .social-widget-content {
        max-height: 35vh !important;
    }

    .global-chat-widget {
        max-height: 40vh !important;
        width: 250px !important;
    }

    .global-chat-messages {
        max-height: 25vh !important;
    }
}

/* ===== 2D BATTLE CANVAS MOBILE ===== */
@media (max-width: 1024px) {
    /* Canvas container: fill viewport properly */
    .battle-canvas-container {
        width: 100vw !important;
        height: 100vh !important;
        overflow: hidden !important;
    }

    /* Don't apply global wrapper/body overrides to 2D canvas page */
    body:has(.battle-canvas-container) {
        overflow: hidden !important;
        height: 100vh !important;
    }

    body:has(.battle-canvas-container) wrapper {
        padding: 0 !important;
        height: 100vh !important;
        overflow: hidden !important;
    }

    .player-hud {
        min-width: 160px !important;
        max-width: 180px !important;
        padding: 6px !important;
        font-size: 10px !important;
        top: 6px !important;
        left: 6px !important;
    }

    .player-name {
        font-size: 11px !important;
    }

    .health-bar, .mana-bar {
        height: 14px !important;
    }

    .bar-text {
        font-size: 8px !important;
    }

    .stat-line {
        font-size: 9px !important;
    }

    /* Action bars compact on mobile */
    .ability-slot {
        width: 40px !important;
        height: 40px !important;
    }

    .ability-icon {
        width: 32px !important;
        height: 32px !important;
    }

    .action-bar {
        gap: 3px !important;
        padding: 6px !important;
        border-radius: 10px !important;
    }

    .ability-hotkey {
        font-size: 7px !important;
    }

    /* Battle log compact */
    .battle-log-widget {
        max-width: 250px !important;
        max-height: 150px !important;
        font-size: 10px !important;
    }

    /* NPC HUD compact */
    .npc-hud {
        max-width: 180px !important;
        font-size: 10px !important;
    }

    /* Target info panel */
    .target-info {
        max-width: 180px !important;
        font-size: 10px !important;
    }

    /* Party frames compact */
    .party-frames {
        max-width: 140px !important;
        font-size: 9px !important;
    }

    .party-frames .party-member {
        padding: 3px !important;
    }
}

@media (max-width: 480px) {
    .player-hud {
        min-width: 140px !important;
        max-width: 160px !important;
        padding: 4px !important;
    }

    .ability-slot {
        width: 36px !important;
        height: 36px !important;
    }

    .ability-icon {
        width: 28px !important;
        height: 28px !important;
    }
}

/* Landscape mobile - optimize for gameplay */
@media (max-height: 500px) and (orientation: landscape) {
    .player-hud {
        min-width: 150px !important;
        max-width: 170px !important;
        padding: 4px !important;
        font-size: 9px !important;
    }

    .health-bar, .mana-bar {
        height: 12px !important;
    }

    .stats-panel {
        display: none !important;
    }

    /* In landscape, tuck action bars closer to bottom edge */
    .action-bar.position-bottom-center,
    .action-bar.position-bottom-left,
    .action-bar.position-bottom-right {
        bottom: 8px !important;
    }

    /* Ability slots slightly smaller in tight landscape */
    .ability-slot {
        width: 38px !important;
        height: 38px !important;
    }

    .ability-icon {
        width: 30px !important;
        height: 30px !important;
    }
}

/* ===== 1D BATTLE MOBILE ===== */
@media (max-width: 1024px) {
    /* Battlefield: stack sidebar + main vertically */
    .battlefield {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        height: auto !important;
        min-height: auto !important;
        font-size: 0.85em !important;
    }

    /* Left menu: collapse to a horizontal battle-feed strip */
    .left-menu {
        display: block !important;
        width: 100% !important;
        height: auto !important;
        min-height: auto !important;
        min-width: 0 !important;
        max-height: 120px !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        order: 2 !important;
        border-top: 1px solid rgba(255, 183, 0, 0.3) !important;
    }

    .battle-feed {
        max-height: 100px !important;
        overflow-y: auto !important;
        font-size: 0.85em !important;
        padding: 4px !important;
        margin: 2px !important;
    }

    .feed-msg {
        padding: 3px !important;
        margin: 2px 0 !important;
        font-size: 0.85em !important;
    }

    /* Main battle area: full width */
    .battle {
        display: block !important;
        width: 100% !important;
        height: auto !important;
        min-height: auto !important;
        overflow: visible !important;
        order: 1 !important;
    }

    /* Player card compact */
    .yourCharacterContainer {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        gap: 6px !important;
        padding: 6px !important;
        margin: 4px !important;
        min-width: 0 !important;
        width: auto !important;
        bottom: auto !important;
    }

    .player-card {
        flex: 1 1 45% !important;
        width: auto !important;
        min-width: 0 !important;
        font-size: 0.9em !important;
    }

    .your-stats {
        display: flex !important;
        flex: 1 1 45% !important;
        width: auto !important;
        height: auto !important;
        max-height: none !important;
        flex-wrap: wrap !important;
        gap: 2px 8px !important;
        font-size: 0.85em !important;
        align-content: flex-start !important;
    }

    .your-stats > span {
        display: inline-block !important;
        padding: 1px 4px !important;
        width: auto !important;
        white-space: nowrap !important;
    }

    .your-player-name {
        font-size: 1em !important;
    }

    .your-health-bg, .your-mana-bg {
        height: 16px !important;
    }

    /* Creature containers: fill width, remove max-height */
    .creatureContainers {
        flex-direction: row !important;
        flex-wrap: wrap !important;
        justify-content: center !important;
        gap: 8px !important;
        padding: 4px !important;
        width: 100% !important;
    }

    .creatureContainer {
        flex: 1 1 calc(50% - 12px) !important;
        min-width: 140px !important;
        max-width: none !important;
        max-height: none !important;
        margin: 0 !important;
        padding: 10px 8px !important;
        font-size: 0.9em !important;
        box-sizing: border-box !important;
    }

    .creatureContainer h1 {
        font-size: 1em !important;
        margin-bottom: 4px !important;
    }

    .boss-stats h2 {
        font-size: 0.9em !important;
    }

    /* Group battle frames compact */
    #group-battle-frames {
        padding: 4px !important;
        font-size: 10px !important;
    }

    /* Hub toggle + nav bar */
    .hub-toggle {
        bottom: auto !important;
        top: 50px !important;
        right: 4px !important;
        width: 80px !important;
        font-size: 11px !important;
        z-index: 200 !important;
    }

    /* Action bar within battle — adjust position for mobile */
    #actionbar .ability-slot {
        width: 40px !important;
        height: 40px !important;
    }

    #actionbar .ability-icon {
        width: 32px !important;
        height: 32px !important;
    }

    #actionbar .action-bar {
        gap: 3px !important;
        padding: 6px !important;
        flex-wrap: wrap !important;
        justify-content: center !important;
    }

    #actionbar .ability-hotkey {
        font-size: 7px !important;
    }

    /* Bottom-positioned action bars: raise above exp bar */
    #actionbar .action-bar.position-bottom-center,
    #actionbar .action-bar.position-bottom-left,
    #actionbar .action-bar.position-bottom-right {
        bottom: 45px !important;
    }

    /* Battle area generic */
    .battle-area {
        flex-direction: column !important;
        gap: 10px;
    }

    .player-side, .enemy-side {
        width: 100% !important;
    }

    .battle-log {
        max-height: 200px;
        overflow-y: auto;
    }

    /* Raid-specific layouts */
    .raid-gui {
        position: static !important;
        width: 100% !important;
        max-height: none !important;
        height: auto !important;
    }

    .boss-gui {
        position: relative !important;
        width: 100% !important;
        height: auto !important;
    }

    .boss-section {
        position: relative !important;
        width: 100% !important;
        left: auto !important;
    }

    .raid-group-raid-gui {
        max-width: 80px !important;
        min-width: 60px !important;
        min-height: 35px !important;
        height: 35px !important;
    }
}

/* 1D Battle Landscape — more compact, side-by-side player+enemies */
@media (max-width: 1024px) and (orientation: landscape) {
    .left-menu {
        max-height: 80px !important;
    }

    .battle-feed {
        max-height: 65px !important;
    }

    .yourCharacterContainer {
        flex-direction: row !important;
        flex-wrap: nowrap !important;
    }

    .player-card {
        flex: 0 0 auto !important;
        max-width: 250px !important;
    }

    .your-stats {
        flex: 1 1 auto !important;
    }

    .creatureContainer {
        flex: 1 1 calc(33% - 12px) !important;
        min-width: 120px !important;
        padding: 8px 6px !important;
    }

    /* Raise action bars above the shorter landscape exp bar */
    #actionbar .action-bar.position-bottom-center,
    #actionbar .action-bar.position-bottom-left,
    #actionbar .action-bar.position-bottom-right {
        bottom: 38px !important;
    }
}

/* 1D Battle Portrait — single-column enemies, compact player card */
@media (max-width: 1024px) and (orientation: portrait) {
    .yourCharacterContainer {
        flex-direction: column !important;
    }

    .player-card, .your-stats {
        flex: none !important;
        width: 100% !important;
    }

    .creatureContainer {
        flex: 1 1 100% !important;
        max-width: 100% !important;
    }
}

/* ===== PVP PAGES MOBILE ===== */
@media (max-width: 1024px) {
    .pvp-container {
        width: 100% !important;
        max-width: 100% !important;
        padding: 10px !important;
        box-sizing: border-box !important;
    }

    .pvp-header {
        text-align: center !important;
        padding: 10px !important;
    }

    .pvp-header h1 {
        font-size: 1.4em !important;
    }

    .battle-selection {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    .battle-type-card {
        width: 100% !important;
        padding: 14px !important;
        box-sizing: border-box !important;
    }

    /* Private match section */
    .private-match-form {
        padding: 10px !important;
    }

    .private-match-form input,
    .private-match-form select {
        width: 100% !important;
        box-sizing: border-box !important;
    }

    /* PvP 1D battle container */
    .pvp-1d-container {
        padding: 10px !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }
}

@media (max-width: 1024px) and (orientation: landscape) {
    .battle-selection {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* ===== BATTLE GROUP WIDGET MOBILE ===== */
@media (max-width: 1024px) {
    .battle-group-widget {
        max-width: 250px !important;
        min-width: 0 !important;
        font-size: 11px !important;
        box-sizing: border-box !important;
    }

    .battle-group-widget.compact {
        width: 200px !important;
    }

    .party-frame {
        padding: 4px !important;
    }

    .party-frame .health-bar {
        height: 12px !important;
    }

    /* Vote notification — prevent overflow */
    .vote-notification {
        min-width: 0 !important;
        max-width: 90vw !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
        box-sizing: border-box !important;
    }

    /* Don't push canvas for widget on mobile */
    .battleCanvas {
        margin-right: 0 !important;
        margin-top: 0 !important;
    }
}

/* ===== TOOLTIPS MOBILE ===== */
@media (max-width: 1024px) {
    .item-tooltip, .inv-tooltip {
        max-width: 85vw !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        right: auto !important;
        position: fixed !important;
        top: auto !important;
        bottom: 80px !important;
        z-index: 99999 !important;
    }
}

/* ===== MOBILE UTILITY CLASSES ===== */
@media (max-width: 1024px) {
    .mobile-stack {
        flex-direction: column !important;
    }

    .mobile-full {
        width: 100% !important;
        max-width: 100% !important;
    }

    .mobile-hide {
        display: none !important;
    }

    .mobile-show {
        display: block !important;
    }

    .mobile-center {
        text-align: center !important;
        justify-content: center !important;
        align-items: center !important;
    }

    .mobile-p-sm {
        padding: 8px !important;
    }

    .mobile-text-sm {
        font-size: 13px !important;
    }

    .mobile-gap-sm {
        gap: 8px !important;
    }

    .mobile-scroll-x {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
    }
}

/* ============================================
   PHASE 2 — PAGE-SPECIFIC MOBILE OVERRIDES
   ============================================ */

/* ===== HUB PAGE ===== */
@media (max-width: 1024px) {
    .hub-container {
        width: 100% !important;
        margin: 8px auto !important;
        padding: 12px !important;
        border-radius: 10px !important;
        box-sizing: border-box !important;
    }

    .hub-global-modifiers {
        margin-bottom: 12px !important;
    }

    .hub-modifiers-header {
        padding: 10px 14px !important;
    }

    .hub-modifiers-header h3 {
        font-size: 16px !important;
    }

    .hub-modifiers-content {
        padding: 10px !important;
        gap: 8px !important;
    }

    .hub-main-content {
        flex-direction: column !important;
        gap: 12px !important;
        min-height: auto !important;
    }

    .hub-character-panel {
        flex: none !important;
        width: 100% !important;
        padding: 12px !important;
    }

    .hub-activity-panel {
        flex: none !important;
        width: 100% !important;
        padding: 12px !important;
        min-height: auto !important;
    }

    .hub-side-panel {
        width: 100% !important;
        flex-direction: column !important;
        gap: 12px !important;
        overflow-x: visible !important;
    }

    .hub-panel-section {
        min-width: auto !important;
        width: 100% !important;
    }

    .hub-character-info h2 {
        font-size: 18px !important;
    }

    .hub-character-info h4 {
        font-size: 14px !important;
    }

    /* Stats grid — single column on mobile */
    .hub-character-panel .stats-grid {
        grid-template-columns: 1fr !important;
        gap: 6px !important;
    }

    .stat-item {
        padding: 6px 10px !important;
        font-size: 13px !important;
    }

    /* Battle feed compact */
    .hub-battle-feed {
        max-height: none !important;
        overflow: visible !important;
    }

    .hub-battle-item {
        padding: 8px !important;
        margin-bottom: 6px !important;
        font-size: 13px !important;
    }

    .hub-battle-item .details {
        font-size: 11px !important;
    }

    /* Hub widgets */
    .hub-widgets-section {
        padding: 8px 0 !important;
    }

    .hub-widgets-row {
        flex-direction: column !important;
        gap: 10px !important;
    }

    .hub-widget-container {
        width: 100% !important;
    }

    /* Admin/debug section compact */
    .hub-admin-section {
        font-size: 12px !important;
    }

    .hub-admin-btn {
        padding: 8px 12px !important;
        font-size: 12px !important;
    }

    /* Hub logout/actions */
    .hub-logout-actions {
        flex-wrap: wrap !important;
        gap: 6px !important;
    }

    .hub-logout-actions a,
    .hub-logout-actions button {
        font-size: 12px !important;
        padding: 6px 10px !important;
    }

    /* Weapon section */
    .hub-weapon-section {
        padding: 8px !important;
    }

    .weapon-display {
        flex-direction: column !important;
        gap: 8px !important;
    }
}

/* Hub landscape — 2-column stats, side-by-side panels where possible */
@media (max-width: 1024px) and (orientation: landscape) {
    .hub-main-content {
        flex-direction: row !important;
        flex-wrap: wrap !important;
        gap: 8px !important;
    }

    .hub-character-panel {
        flex: 1 1 45% !important;
        min-width: 280px !important;
    }

    .hub-activity-panel {
        flex: 1 1 45% !important;
        min-width: 280px !important;
    }

    .hub-side-panel {
        flex: 1 1 100% !important;
        flex-direction: row !important;
        gap: 8px !important;
    }

    .hub-panel-section {
        flex: 1 !important;
    }

    .hub-character-panel .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* ===== CHARACTER SHEET PAGE ===== */
@media (max-width: 1024px) {
    .character-container {
        width: 100% !important;
        padding: 10px !important;
        margin: 8px auto !important;
        box-sizing: border-box !important;
    }

    .character-header {
        flex-direction: column !important;
        gap: 10px !important;
        text-align: center !important;
    }

    .character-quick-nav {
        justify-content: center !important;
        gap: 6px !important;
        flex-wrap: wrap !important;
    }

    .character-quick-nav a,
    .character-quick-nav button {
        font-size: 11px !important;
        padding: 6px 10px !important;
    }

    .stats-row {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }

    .stats-section {
        padding: 10px !important;
    }

    .resistance-grid {
        flex-direction: column !important;
        gap: 8px !important;
    }

    .resistance-item {
        min-width: auto !important;
        width: 100% !important;
    }

    .equipment-grid {
        justify-content: center !important;
        gap: 8px !important;
    }

    .equipment-card {
        width: 100% !important;
        max-width: 100% !important;
    }
}

/* Character sheet landscape — 2-col stats */
@media (max-width: 1024px) and (orientation: landscape) {
    .stats-row {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .resistance-grid {
        flex-direction: row !important;
        flex-wrap: wrap !important;
    }

    .resistance-item {
        flex: 1 1 calc(50% - 8px) !important;
    }
}

/* ===== BATTLE SETUP PAGE ===== */
@media (max-width: 1024px) {
    .setup-container {
        width: 100% !important;
        padding: 12px !important;
        margin: 8px auto !important;
        box-sizing: border-box !important;
    }

    .setup-header {
        margin-bottom: 20px !important;
        padding-bottom: 10px !important;
    }

    .setup-header h1 {
        font-size: 1.6em !important;
    }

    .setup-subtitle {
        font-size: 1em !important;
    }

    .setup-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
        margin-top: 15px !important;
    }

    .setup-card {
        padding: 15px !important;
    }

    .setup-card-header {
        margin-bottom: 10px !important;
        padding-bottom: 8px !important;
    }

    .difficulty-selector {
        flex-direction: column !important;
        gap: 6px !important;
    }

    .difficulty-btn {
        width: 100% !important;
    }
}

/* Battle setup landscape — 2-col cards */
@media (max-width: 1024px) and (orientation: landscape) {
    .setup-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .setup-card {
        padding: 12px !important;
    }

    .difficulty-selector {
        flex-direction: row !important;
    }

    .difficulty-btn {
        width: auto !important;
        flex: 1 !important;
    }
}

/* ===== SETTINGS PAGE ===== */
@media (max-width: 1024px) {
    .settings-manager {
        max-width: 100% !important;
        padding: 10px !important;
        box-sizing: border-box !important;
    }

    .settings-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    .settings-card {
        padding: 15px !important;
    }

    .character-info {
        padding: 8px 12px !important;
        font-size: 14px !important;
    }
}

/* ===== GROUP / SOCIAL PAGE ===== */
@media (max-width: 1024px) {
    .group-discovery-container {
        max-width: 100% !important;
        margin: 8px !important;
        padding: 12px !important;
        box-sizing: border-box !important;
    }

    .enhanced-actions {
        flex-wrap: wrap !important;
        gap: 8px !important;
    }

    .enhanced-actions button,
    .enhanced-actions a {
        flex: 1 1 calc(50% - 8px) !important;
        min-width: 120px !important;
        font-size: 12px !important;
        padding: 10px 12px !important;
    }

    .social-features {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }

    .group-container {
        padding: 10px !important;
    }
}

/* ===== GUILD PAGE ===== */
@media (max-width: 1024px) {
    .guild-discovery-container {
        max-width: 100% !important;
        margin: 8px !important;
        padding: 12px !important;
        box-sizing: border-box !important;
    }

    /* Guild list cards — single column */
    .guild-list {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    .guild-card {
        padding: 12px !important;
        box-sizing: border-box !important;
    }

    .guild-header {
        flex-wrap: wrap !important;
        gap: 8px !important;
    }

    .guild-header h3 {
        font-size: 1.1em !important;
    }

    .guild-stats {
        gap: 6px !important;
    }

    .guild-search-filters {
        padding: 12px !important;
    }

    .search-bar {
        flex-direction: column !important;
        gap: 8px !important;
    }

    .search-bar input,
    .search-bar select {
        width: 100% !important;
    }

    /* Guild tabs compact */
    .guild-main-tabs {
        flex-wrap: wrap !important;
    }

    .guild-tab {
        padding: 10px 14px !important;
        font-size: 13px !important;
        flex: 1 1 auto !important;
        min-width: 80px !important;
        text-align: center !important;
    }

    /* Guild actions bar */
    .guild-actions-bar {
        flex-wrap: wrap !important;
        gap: 8px !important;
    }

    .guild-actions-bar button,
    .guild-actions-bar .btn {
        padding: 8px 14px !important;
        font-size: 13px !important;
    }

    /* Guild chat container — static position, auto height */
    .guild-chat-container {
        position: static !important;
        width: 100% !important;
        min-height: 200px !important;
        max-height: 300px !important;
        height: auto !important;
    }
}

/* ===== QUEST / ACHIEVEMENT PAGES (enhanced) ===== */
@media (max-width: 1024px) and (orientation: landscape) {
    .quest-list, .achievement-list {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* ===== TRAINER / MERCHANT (enhanced) ===== */
@media (max-width: 1024px) and (orientation: landscape) {
    .merchant-grid, .shop-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* ===== ABILITIES PAGE ===== */
@media (max-width: 1024px) {
    .ability-manager {
        width: 100% !important;
        max-width: 100% !important;
        padding: 10px !important;
        box-sizing: border-box !important;
    }

    .template-section,
    .action-bars-section,
    .available-abilities-section,
    .instructions {
        padding: 12px !important;
        box-sizing: border-box !important;
        max-width: 100% !important;
        overflow: hidden !important;
    }

    .template-controls {
        flex-direction: column !important;
        gap: 8px !important;
    }

    .template-controls select {
        min-width: 0 !important;
        width: 100% !important;
    }

    .template-controls button {
        width: 100% !important;
    }

    /* Action bar slots scroll horizontally if needed */
    .action-bar-slots {
        flex-wrap: wrap !important;
        gap: 4px !important;
        justify-content: center !important;
    }

    .action-slot {
        width: 42px !important;
        height: 42px !important;
    }

    .action-slot .ability-icon {
        width: 30px !important;
        height: 30px !important;
    }

    /* Abilities grid — single column */
    .abilities-grid {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }

    .draggable-ability {
        padding: 10px !important;
        min-width: 0 !important;
    }

    .ability-header {
        gap: 8px !important;
    }

    .ability-name {
        font-size: 14px !important;
    }

    .ability-details {
        font-size: 12px !important;
    }

    .action-bar-header {
        flex-wrap: wrap !important;
        gap: 6px !important;
        font-size: 13px !important;
    }
}

/* Abilities landscape — 2-col grid */
@media (max-width: 1024px) and (orientation: landscape) {
    .abilities-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .template-controls {
        flex-direction: row !important;
        flex-wrap: wrap !important;
    }

    .template-controls select {
        width: auto !important;
        min-width: 150px !important;
        flex: 1 !important;
    }

    .template-controls button {
        width: auto !important;
    }
}

/* ===== ABILITIES INDEX PAGE (spellbook + consumables) ===== */
@media (max-width: 1024px) {
    /* Force all ability-manager children to respect container width */
    .ability-manager,
    .ability-manager *,
    .book-panels,
    .book-panels * {
        box-sizing: border-box !important;
        max-width: 100% !important;
    }

    .ability-manager {
        width: 100% !important;
        padding: 10px !important;
        overflow: hidden !important;
    }

    /* Two-panel grid → single column so consumables show */
    .book-panels {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }

    /* Panels: remove fixed max-height, let content flow */
    .book-panels .panel {
        max-height: none !important;
        overflow: visible !important;
        width: 100% !important;
    }

    .book-panels .panel-grid {
        overflow: visible !important;
        max-height: none !important;
    }

    .panel-header {
        padding: 8px 12px !important;
    }

    .panel-search {
        width: 100px !important;
    }

    .panel-filters {
        gap: 4px !important;
        padding: 6px 8px !important;
    }

    /* Action bar slots */
    .ab-slots {
        gap: 4px !important;
    }

    .ab-slot {
        width: 44px !important;
        height: 44px !important;
    }

    .ab-slot .slot-icon {
        width: 30px !important;
        height: 30px !important;
    }
}

/* Abilities index landscape — keep 2-col panels */
@media (max-width: 1024px) and (orientation: landscape) {
    .book-panels {
        grid-template-columns: 1fr 1fr !important;
    }

    /* Limit panel height in landscape so both fit on screen */
    .book-panels .panel {
        max-height: calc(100vh - 180px) !important;
        overflow: hidden !important;
    }

    .book-panels .panel-grid {
        overflow-y: auto !important;
        max-height: calc(100vh - 280px) !important;
    }
}

/* ===== DONATIONS PAGE ===== */
@media (max-width: 1024px) {
    .donations-container {
        max-width: 100% !important;
        padding: 10px !important;
        box-sizing: border-box !important;
    }

    .modifiers-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    .info-sections {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    /* Live donations sidebar → full width banner */
    .live-donations {
        position: static !important;
        width: 100% !important;
        max-height: 200px !important;
        margin-bottom: 12px !important;
    }
}

@media (max-width: 1024px) and (orientation: landscape) {
    .modifiers-grid,
    .info-sections {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* ===== SUPPORT PAGE ===== */
@media (max-width: 1024px) {
    .support-container {
        max-width: 100% !important;
        padding: 10px !important;
        box-sizing: border-box !important;
    }

    /* Sidebar + content → single column */
    .support-container .main-content,
    .support-page .main-content {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    .support-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* Issue detail modal → single column */
    .issue-detail-modal {
        grid-template-columns: 1fr !important;
    }

    /* Modal sizing */
    .support-container .modal-content,
    .support-page .modal-content {
        width: 95vw !important;
        max-width: 95vw !important;
    }
}

/* ===== MAIL PAGE (enhanced) ===== */
@media (max-width: 1024px) {
    .mail-container {
        max-width: 100% !important;
        padding: 10px !important;
        box-sizing: border-box !important;
    }

    /* Mail items → simplified layout */
    .mail-item {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 6px !important;
        padding: 8px !important;
    }

    .mail-sender {
        min-width: 0 !important;
        flex: 1 1 auto !important;
    }

    .mail-subject {
        width: 100% !important;
        order: 10;
    }

    .mail-date,
    .mail-actions {
        font-size: 11px !important;
    }

    /* Compose modal */
    .compose-modal .modal-content,
    .item-modal .modal-content {
        width: 95vw !important;
        max-width: 95vw !important;
        padding: 12px !important;
    }

    .compose-modal textarea,
    .compose-modal input {
        width: 100% !important;
        box-sizing: border-box !important;
    }
}

/* ===== BANK PAGE (enhanced) ===== */
@media (max-width: 1024px) {
    .bank-container {
        max-width: 100% !important;
        padding: 10px !important;
        box-sizing: border-box !important;
    }

    .bank-main-content {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    .bank-items-grid,
    .inventory-items-grid {
        grid-template-columns: repeat(auto-fill, minmax(65px, 1fr)) !important;
        max-height: none !important;
        overflow: visible !important;
    }

    .item-slot {
        width: auto !important;
        height: auto !important;
        min-width: 60px !important;
        min-height: 60px !important;
    }

    .bank-container .modal-content {
        width: 95vw !important;
        max-width: 95vw !important;
    }
}

/* ===== TRADING PAGE (enhanced) ===== */
@media (max-width: 1024px) {
    .trading-container {
        width: 100% !important;
        max-width: 100% !important;
        padding: 10px !important;
        box-sizing: border-box !important;
    }

    /* Trading interface → stacked */
    .trading-interface {
        grid-template-columns: 1fr !important;
        min-height: auto !important;
        gap: 12px !important;
    }

    .invitations-container {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    .friends-list {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }

    /* Item slots responsive grid */
    .item-slots {
        grid-template-columns: repeat(auto-fill, minmax(60px, 1fr)) !important;
        gap: 6px !important;
        min-height: auto !important;
    }

    .trading-modal-content {
        width: 95vw !important;
        max-width: 95vw !important;
    }
}

@media (max-width: 1024px) and (orientation: landscape) {
    .trading-interface {
        grid-template-columns: 1fr 1fr !important;
    }

    .invitations-container {
        grid-template-columns: 1fr 1fr !important;
    }

    .friends-list {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* ===== CHANGELOG PAGE ===== */
@media (max-width: 1024px) {
    .changelog-container {
        max-width: 100% !important;
        padding: 10px !important;
        box-sizing: border-box !important;
    }

    .changelog-entry {
        padding: 12px !important;
    }
}

/* ===== GLOBAL MODALS ===== */
@media (max-width: 1024px) {
    .modal-overlay .modal-content,
    .modal-content {
        width: 95vw !important;
        max-width: 95vw !important;
        max-height: 85vh !important;
        overflow-y: auto !important;
        box-sizing: border-box !important;
    }
}

/* ===== LANDING PAGE ===== */
@media (max-width: 1024px) {
    .single-viewport-landing {
        flex-direction: column !important;
        height: auto !important;
        min-height: 100vh !important;
        overflow: visible !important;
    }

    .landing-left,
    .landing-right {
        flex: none !important;
        width: 100% !important;
        padding: 15px !important;
        border-left: none !important;
    }

    .landing-right {
        border-top: 2px solid #8B4513 !important;
    }

    .hero-content {
        max-width: 100% !important;
        padding: 20px 15px !important;
    }

    .hero-header h1 {
        font-size: 1.5em !important;
    }

    .hero-actions {
        flex-direction: column !important;
        align-items: center !important;
        gap: 12px !important;
    }

    .hero-button {
        min-width: 180px !important;
        width: 100% !important;
        max-width: 280px !important;
    }

    .features-overview {
        max-width: 100% !important;
    }

    .features-overview h2 {
        font-size: 1.6em !important;
    }

    .feature-item {
        padding: 10px !important;
    }
}

@media (max-width: 1024px) and (orientation: landscape) {
    .single-viewport-landing {
        flex-direction: row !important;
    }

    .landing-left,
    .landing-right {
        flex: 1 !important;
        width: 50% !important;
    }

    .landing-right {
        border-top: none !important;
        border-left: 2px solid #8B4513 !important;
    }

    .hero-actions {
        flex-direction: row !important;
        flex-wrap: wrap !important;
    }

    .hero-button {
        width: auto !important;
    }
}

/* ===== BATTLE WIN PAGE ===== */
@media (max-width: 1024px) {
    .won {
        width: 100% !important;
        min-width: 0 !important;
        padding: 8px !important;
        box-sizing: border-box !important;
    }

    .win-table {
        display: flex !important;
        flex-direction: column !important;
        gap: 10px !important;
    }

    .win-table-div {
        display: block !important;
        width: 100% !important;
        height: auto !important;
        max-height: none !important;
        padding: 10px !important;
        box-sizing: border-box !important;
    }

    .win-feed {
        max-height: 200px !important;
        overflow-y: auto !important;
    }

    .win-feed-item {
        font-size: 0.9em !important;
    }
}

@media (max-width: 1024px) and (orientation: landscape) {
    .win-table {
        flex-direction: row !important;
        flex-wrap: wrap !important;
    }

    .win-table-div {
        flex: 1 1 calc(33% - 10px) !important;
        min-width: 200px !important;
        max-height: 50vh !important;
        overflow-y: auto !important;
    }
}

/* ===== MAIL APP (enhanced) ===== */
@media (max-width: 1024px) {
    .mail-container {
        display: flex !important;
        flex-direction: column !important;
        max-width: 100% !important;
        padding: 8px !important;
        box-sizing: border-box !important;
        gap: 10px !important;
    }

    .mail-sidebar {
        width: 100% !important;
        flex: none !important;
        border-right: none !important;
        border-bottom: 1px solid rgba(255, 183, 0, 0.3) !important;
        padding-bottom: 8px !important;
    }

    .mail-filters {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 4px !important;
    }

    .filter-item {
        flex: 1 1 auto !important;
    }

    .filter-btn {
        width: 100% !important;
        padding: 8px !important;
        font-size: 12px !important;
        text-align: center !important;
    }

    .mail-content {
        width: 100% !important;
        flex: 1 !important;
    }

    .mail-list {
        max-height: none !important;
        overflow: visible !important;
    }

    .content-header {
        flex-wrap: wrap !important;
        gap: 8px !important;
    }

    .mail-actions {
        width: 100% !important;
        display: flex !important;
        gap: 6px !important;
    }

    .action-btn {
        flex: 1 !important;
        font-size: 12px !important;
        padding: 8px !important;
    }

    .compose-btn {
        width: 100% !important;
    }

    /* Mail modal */
    .mail-modal .modal-content {
        width: 95vw !important;
        max-width: 95vw !important;
        max-height: 85vh !important;
        overflow-y: auto !important;
        padding: 12px !important;
    }
}

/* ===== GROUP/GUILD BROWSE PAGES ===== */
@media (max-width: 1024px) {
    .group-discovery-container,
    .guild-discovery-container {
        max-width: 100% !important;
        margin: 8px !important;
        padding: 10px !important;
        box-sizing: border-box !important;
    }

    .group-list,
    .guild-list {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }

    .group-card,
    .guild-card {
        width: 100% !important;
        box-sizing: border-box !important;
        padding: 12px !important;
    }

    .group-header,
    .guild-header {
        flex-wrap: wrap !important;
        gap: 6px !important;
    }

    .group-actions,
    .guild-actions {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 6px !important;
    }

    .group-actions button,
    .guild-actions button {
        flex: 1 1 auto !important;
        min-width: 100px !important;
    }

    /* Filters */
    .filters {
        display: flex !important;
        flex-direction: column !important;
        gap: 8px !important;
    }

    .filters input,
    .filters select {
        width: 100% !important;
    }
}

@media (max-width: 1024px) and (orientation: landscape) {
    .group-list,
    .guild-list {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* ===== CHARACTER CREATION PAGE ===== */
@media (max-width: 1024px) {
    .class-menu {
        width: 100% !important;
        min-width: 0 !important;
        height: auto !important;
        padding: 10px !important;
        box-sizing: border-box !important;
        overflow: visible !important;
    }

    .selectClass, .selectedClass {
        padding: 10px 0 !important;
    }

    .classDiv {
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
        margin-bottom: 15px !important;
        box-sizing: border-box !important;
    }

    .classDiv .classImg {
        width: 120px !important;
        max-width: 50% !important;
        height: auto !important;
    }

    .classDiv span, .classDiv p {
        max-width: 100% !important;
        width: 100% !important;
    }

    .selectedClass form input[type='text'] {
        width: 80% !important;
        max-width: 300px !important;
    }
}

@media (max-width: 1024px) and (orientation: landscape) {
    .classDiv {
        display: inline-block !important;
        width: 30% !important;
        vertical-align: top !important;
    }

    .classDiv .classImg {
        width: 100px !important;
    }
}

/* ===== CHARACTER RESET / STAT ALLOCATION PAGE ===== */
@media (max-width: 1024px) {
    .menu2-character-sheet {
        width: 100% !important;
        min-width: 0 !important;
        height: auto !important;
        overflow: visible !important;
        box-sizing: border-box !important;
    }

    .stat-reset {
        text-align: center !important;
    }

    .icon-split {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        flex-wrap: wrap !important;
        gap: 6px !important;
        margin: 8px 0 !important;
    }

    .icon-cont {
        display: inline-flex !important;
        align-items: center !important;
    }

    .character-sheet-icon {
        width: 40px !important;
        height: 40px !important;
    }

    .reset-stats-form {
        padding: 10px !important;
    }
}

/* ===== PROFESSIONS PAGE ===== */
@media (max-width: 1024px) {
    .professions-container {
        width: 100% !important;
        max-width: 100% !important;
        padding: 10px !important;
        box-sizing: border-box !important;
    }

    .professions-container .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)) !important;
    }

    .character-professions-grid,
    .professions-grid {
        grid-template-columns: 1fr !important;
    }

    .profession-categories {
        grid-template-columns: 1fr !important;
    }

    .category-card {
        flex-direction: column !important;
        text-align: center !important;
    }

    .profession-actions {
        flex-direction: column !important;
        gap: 8px !important;
    }

    .profession-actions button {
        width: 100% !important;
    }
}

@media (max-width: 1024px) and (orientation: landscape) {
    .character-professions-grid,
    .professions-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .profession-categories {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* ===== QUESTS PAGE ===== */
@media (max-width: 1024px) {
    .quest-container {
        width: 100% !important;
        max-width: 100% !important;
        padding: 10px !important;
        box-sizing: border-box !important;
    }

    .quest-title {
        flex-direction: column !important;
        gap: 10px !important;
        text-align: center !important;
    }

    .quest-stats {
        grid-template-columns: 1fr !important;
    }

    .quest-nav {
        flex-direction: column !important;
    }

    .quest-content .content-header {
        flex-direction: column !important;
        gap: 10px !important;
        align-items: stretch !important;
    }

    .filter-controls {
        width: 100% !important;
        flex-wrap: wrap !important;
    }

    .seasonal-content-grid,
    .achievement-grid,
    .events-grid {
        grid-template-columns: 1fr !important;
    }

    .quest-rewards-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)) !important;
    }
}

@media (max-width: 1024px) and (orientation: landscape) {
    .quest-nav {
        flex-direction: row !important;
        flex-wrap: wrap !important;
    }

    .seasonal-content-grid,
    .achievement-grid,
    .events-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .quest-stats {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* ===== CHARACTER DELETE PAGE ===== */
@media (max-width: 1024px) {
    .delete-character-container {
        max-width: 100% !important;
        padding: 15px !important;
        margin: 10px !important;
        box-sizing: border-box !important;
    }

    .delete-character-container .form-group {
        margin-bottom: 15px !important;
    }

    .delete-character-container input,
    .delete-character-container textarea,
    .delete-character-container select {
        width: 100% !important;
        box-sizing: border-box !important;
    }
}

/* ===== LOGIN CHARACTER SELECT ===== */
@media (max-width: 1024px) {
    .character-selection-card {
        width: 95% !important;
        max-width: 95vw !important;
        padding: 15px !important;
        box-sizing: border-box !important;
    }

    .character-card {
        padding: 12px !important;
    }
}

/* ===== 2FA PAGE ===== */
@media (max-width: 1024px) {
    .twofa-container {
        width: 95% !important;
        max-width: 95vw !important;
        padding: 15px !important;
        box-sizing: border-box !important;
    }

    .twofa-card {
        max-width: 100% !important;
        padding: 15px !important;
    }
}

/* ===== LOOTBOX / BATTLE RESULTS ===== */
@media (max-width: 1024px) {
    .lootbox-container {
        padding: 10px !important;
        box-sizing: border-box !important;
    }

    .loot-grid {
        grid-template-columns: repeat(auto-fill, minmax(60px, 1fr)) !important;
    }
}

/* ===== WORLD BOSS BATTLE ===== */
@media (max-width: 1024px) {
    /* Prevent global scroll overrides from breaking fullscreen canvas */
    body:has(#gameContainer) {
        overflow: hidden !important;
        height: 100vh !important;
    }

    body:has(#gameContainer) wrapper {
        padding: 0 !important;
        height: 100vh !important;
        overflow: hidden !important;
    }

    #gameContainer {
        width: 100vw !important;
        height: 100vh !important;
    }

    /* Compact boss HUD */
    .boss-hud {
        min-width: 0 !important;
        max-width: 250px !important;
        font-size: 11px !important;
        padding: 8px !important;
    }

    /* Compact player HUD */
    .player-hud {
        min-width: 150px !important;
        max-width: 180px !important;
        font-size: 10px !important;
        padding: 6px !important;
    }

    /* Party list compact */
    .party-list {
        max-width: 160px !important;
        max-height: 300px !important;
        font-size: 9px !important;
    }

    /* Action bar ability slots */
    .ability-slot {
        width: 40px !important;
        height: 40px !important;
    }

    .ability-icon {
        width: 32px !important;
        height: 32px !important;
    }
}

@media (max-height: 500px) and (orientation: landscape) {
    .boss-hud {
        max-width: 200px !important;
        font-size: 10px !important;
    }

    .player-hud {
        min-width: 140px !important;
        max-width: 160px !important;
        font-size: 9px !important;
    }

    .ability-slot {
        width: 36px !important;
        height: 36px !important;
    }
}

/* ===== ACHIEVEMENT SYSTEM (component CSS gap-fill) ===== */
@media (max-width: 1024px) {
    .achievements-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    .achievement-stats {
        flex-wrap: wrap !important;
        gap: 10px !important;
    }

    .achievement-stats .stat-card {
        min-width: 0 !important;
        flex: 1 1 45% !important;
    }

    .achievement-nav {
        flex-wrap: wrap !important;
        gap: 6px !important;
        padding: 10px !important;
    }

    .achievement-nav .nav-tab {
        min-width: 0 !important;
        flex: 1 1 auto !important;
        padding: 8px 12px !important;
        font-size: 0.85rem !important;
    }

    .tier-summary {
        gap: 8px !important;
        padding: 10px !important;
    }

    .tier-badge {
        min-width: 0 !important;
        padding: 10px 16px !important;
        font-size: 1.1rem !important;
        flex: 1 1 auto !important;
    }
}

@media (max-width: 1024px) and (orientation: landscape) {
    .achievements-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* ===== CONSUMABLE BAR (battle pages) ===== */
@media (max-width: 1024px) {
    .consumable-bag-panel {
        width: 280px !important;
        max-width: 85vw !important;
        max-height: 350px !important;
        right: 4px !important;
        bottom: 55px !important;
    }

    .consumable-bar {
        bottom: 4px !important;
        right: 4px !important;
        gap: 2px !important;
        padding: 3px 4px !important;
    }

    .consumable-slot {
        width: 36px !important;
        height: 36px !important;
    }

    .consumable-bag-btn {
        width: 32px !important;
        height: 32px !important;
    }
}

@media (max-width: 1024px) and (orientation: portrait) {
    .consumable-bag-panel {
        width: calc(100vw - 16px) !important;
        max-width: none !important;
        left: 8px !important;
        right: 8px !important;
    }
}

/* ===== BANK NAV TABS (gap-fill) ===== */
@media (max-width: 1024px) {
    .bank-nav-tabs {
        flex-wrap: wrap !important;
    }

    .bank-tab {
        padding: 10px 16px !important;
        font-size: 14px !important;
        flex: 1 1 auto !important;
        min-width: 0 !important;
        text-align: center !important;
    }

    .bank-management {
        flex-wrap: wrap !important;
        gap: 8px !important;
        padding: 12px !important;
    }
}

/* ===== AOE TARGETING PANEL (battle pages) ===== */
@media (max-width: 1024px) {
    .aoe-targeting-panel {
        width: auto !important;
        max-width: calc(100vw - 20px) !important;
        right: 10px !important;
        left: 10px !important;
        top: 10px !important;
    }
}

/* ===== GLOBAL LANDSCAPE SPACING ===== */
@media (max-width: 1024px) and (orientation: landscape) {
    wrapper {
        padding-bottom: 40px !important;
    }

    .exp-bar-cont {
        height: 30px !important;
    }

    footer {
        height: 30px !important;
        line-height: 30px !important;
    }

    footer p {
        line-height: 30px !important;
    }
}
