/* Test-only responsive shell. Remove this link to restore the previous layout. */

.mobile-game-header {
    display: none;
}

#view-character {
    min-width: 0;
}

/* Keep responsive display overrides from exposing the paperdoll on other views. */
#view-character.hidden {
    display: none !important;
}

#view-character > * {
    min-width: 0;
}

@media (min-width: 901px) and (max-width: 1700px) {
    .sidebar {
        width: clamp(190px, 14vw, 220px);
        padding: 12px 8px;
    }

    .sidebar .btn {
        font-size: 0.94em;
        padding: 8px 6px;
    }

    .content {
        min-width: 0;
        padding: 12px;
    }

    #view-character {
        display: grid !important;
        grid-template-columns: minmax(220px, 0.72fr) minmax(350px, 1.35fr) minmax(290px, 0.92fr);
        gap: 10px !important;
        width: 100% !important;
        height: clamp(620px, calc(100dvh - 335px), 840px) !important;
        padding: 0 !important;
        overflow: hidden !important;
        transform: none !important;
    }

    #view-character > div:nth-child(1),
    #view-character > div:nth-child(2),
    #view-character > div:nth-child(3),
    #view-character > div:nth-child(3) > .glass-panel {
        width: auto !important;
        min-width: 0 !important;
        height: 100% !important;
        flex: none !important;
    }

    #view-character > div:nth-child(1) {
        overflow-y: auto !important;
        scrollbar-width: thin;
    }

    #view-character .paper-slot {
        min-width: 48px;
        min-height: 48px;
    }

    #view-character #inventory-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
        gap: clamp(5px, 0.65vw, 10px) !important;
        padding: 6px !important;
        min-width: 0;
    }

    #view-character > div:nth-child(3) > .glass-panel > div:first-child {
        gap: 8px;
        flex-wrap: wrap;
    }

    #view-character > div:nth-child(3) > .glass-panel {
        padding: 10px !important;
    }
}

@media (min-width: 901px) and (max-width: 1180px) {
    #view-character {
        grid-template-columns: minmax(340px, 1fr) minmax(290px, 0.82fr);
        grid-template-rows: minmax(620px, auto) auto;
        height: auto !important;
        min-height: 0;
        overflow: visible !important;
    }

    #view-character > div:nth-child(2) {
        grid-column: 1;
        grid-row: 1;
        height: min(76vw, 760px) !important;
    }

    #view-character > div:nth-child(3) {
        grid-column: 2;
        grid-row: 1;
        height: min(76vw, 760px) !important;
    }

    #view-character > div:nth-child(1) {
        grid-column: 1 / -1;
        grid-row: 2;
        display: grid !important;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        height: auto !important;
        overflow: visible !important;
    }
}

@media (max-width: 900px) {
    html,
    body {
        width: 100%;
        min-height: 100%;
        overflow-x: hidden;
    }

    #game-ui {
        min-height: 100dvh;
        height: auto !important;
        overflow: visible !important;
    }

    .game-header.game-header-custom {
        display: none !important;
    }

    .mobile-game-header {
        position: sticky;
        top: 0;
        z-index: 12000;
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 8px 10px;
        padding: max(8px, env(safe-area-inset-top)) 10px 8px;
        background: linear-gradient(180deg, #160b0b 0%, #080707 100%);
        border-bottom: 1px solid #5e2929;
        box-shadow: 0 4px 18px rgba(0, 0, 0, 0.78);
    }

    .mobile-hud-player {
        display: flex;
        align-items: center;
        min-width: 0;
        gap: 8px;
    }

    .mobile-hud-player img {
        width: 42px;
        height: 42px;
        flex: 0 0 42px;
        object-fit: cover;
        object-position: top center;
        border: 1px solid #86622a;
        background: #050505;
    }

    .mobile-hud-identity {
        min-width: 0;
        display: flex;
        flex-direction: column;
        line-height: 1.25;
    }

    .mobile-hud-identity strong {
        overflow: hidden;
        color: #f4dfaf;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: 0.95rem;
    }

    .mobile-hud-identity span {
        color: #9b9185;
        font-size: 0.7rem;
    }

    .mobile-hud-vitals {
        display: grid;
        gap: 4px;
        min-width: 116px;
    }

    .mobile-hud-vital {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
        min-height: 18px;
        padding: 1px 6px;
        border: 1px solid #302323;
        background: #070606;
        font: 700 0.66rem/1.2 monospace;
    }

    .mobile-hud-vital span {
        font-family: 'Cairo', sans-serif;
    }

    .mobile-hud-hp span,
    .mobile-hud-hp b { color: #ef7770; }
    .mobile-hud-energy span,
    .mobile-hud-energy b { color: #75b9e7; }

    .mobile-hud-resources {
        display: flex;
        gap: 6px;
        min-width: 0;
    }

    .mobile-hud-resources button {
        display: flex;
        flex: 1 1 0;
        align-items: center;
        justify-content: space-between;
        min-width: 0;
        padding: 4px 7px;
        color: #c7bca8;
        border: 1px solid #3d3120;
        background: #0b0907;
        font-size: 0.67rem;
    }

    .mobile-hud-resources b {
        color: #e8ca75;
        direction: ltr;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .mobile-quick-nav {
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        grid-column: 1 / -1;
        gap: 5px;
    }

    .mobile-quick-nav button {
        min-width: 0;
        min-height: 34px;
        padding: 5px 3px;
        color: #eee5d8;
        border: 1px solid #57352e;
        background: #120d0c;
        font-weight: 800;
        font-size: 0.72rem;
    }

    .gh-ticker {
        position: relative;
        min-width: 0;
        padding: 4px 8px;
    }

    .main-layout {
        display: block;
        min-height: 0;
        overflow: visible;
    }

    .sidebar {
        position: fixed;
        top: 0;
        right: 0;
        z-index: 30000;
        width: min(84vw, 320px);
        height: 100dvh;
        max-height: 100dvh;
        padding: max(12px, env(safe-area-inset-top)) 10px max(16px, env(safe-area-inset-bottom));
        transform: translateX(105%);
        transition: transform 180ms ease;
        box-shadow: -12px 0 36px rgba(0, 0, 0, 0.85);
    }

    .sidebar.mobile-sidebar-open {
        transform: translateX(0);
    }

    .mobile-sidebar-backdrop {
        position: fixed;
        inset: 0;
        z-index: 29999;
        display: none;
        border: 0;
        background: rgba(0, 0, 0, 0.72);
    }

    .mobile-sidebar-backdrop.is-open {
        display: block;
    }

    .content {
        width: 100%;
        min-width: 0;
        padding: 8px;
        overflow: visible;
        box-sizing: border-box;
    }

    #view-character {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) !important;
        gap: 10px !important;
        width: 100% !important;
        height: auto !important;
        min-height: 0;
        padding: 0 0 max(18px, env(safe-area-inset-bottom)) !important;
        overflow: visible !important;
        transform: none !important;
    }

    #view-character > div:nth-child(2) {
        grid-row: 1;
        width: 100% !important;
        height: min(104vw, 680px) !important;
        min-height: 420px;
        flex: none !important;
    }

    #view-character > div:nth-child(3) {
        grid-row: 2;
        width: 100% !important;
        min-width: 0 !important;
        height: auto !important;
        overflow: visible !important;
        flex: none !important;
    }

    #view-character > div:nth-child(3) > .glass-panel {
        height: auto !important;
        min-height: 0;
        padding: 9px !important;
        overflow: visible !important;
    }

    #view-character > div:nth-child(3) > .glass-panel > div:first-child {
        align-items: stretch !important;
        gap: 7px;
        flex-direction: column;
    }

    #view-character > div:nth-child(3) > .glass-panel > div:first-child > div {
        flex-wrap: wrap;
    }

    #view-character #inventory-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
        gap: 6px !important;
        padding: 4px !important;
        overflow: visible !important;
    }

    #view-character > div:nth-child(1) {
        grid-row: 3;
        width: 100% !important;
        height: auto !important;
        overflow: visible !important;
        flex: none !important;
    }

    #view-character .paper-slot {
        min-width: 46px;
        min-height: 46px;
    }

    #view-character .item-card:hover {
        transform: none;
    }

    #game-global-tooltip,
    #global-tooltip,
    .equip-tooltip {
        max-width: calc(100vw - 20px) !important;
        white-space: normal !important;
        overflow-wrap: anywhere;
    }

    .game-modal,
    .modal-content,
    .glass-panel {
        max-width: 100%;
        box-sizing: border-box;
    }
}

@media (max-width: 420px) {
    .mobile-game-header {
        gap: 6px;
        padding-inline: 7px;
    }

    .mobile-hud-vitals {
        min-width: 104px;
    }

    .mobile-hud-resources button span {
        font-size: 0.62rem;
    }

    #view-character .character-paperdoll-column {
        min-height: 380px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .sidebar {
        transition: none;
    }
}
