/* Ten arkusz jest ladowany po wszystkich podstawowych stylach interfejsu.
   Reguly responsywne musza pozostac tutaj albo na koncu arkusza komponentu,
   aby pozniej dolaczany styl bazowy nie przywracal ukladu desktopowego. */

@media (min-width: 769px) {
    .worldmap-layout {
        grid-template-columns: 500px 1fr;
    }
}

@media (max-width: 928px) {
    .label {
        display: none;
    }
}

@media (max-width: 768px) {
    .toast {
        font-size: 12px;
    }

    #ui {
        height: auto;
        min-height: 100dvh;
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: 80px 40px auto 1fr;
        align-content: start;
    }

    #left {
        height: min(510px, 66dvh);
        border-right-width: 4px;
    }

    #right {
        overflow-y: auto;
    }

    #mobileDpad {
        --mobile-dpad-button-size: clamp(34px, 10vw, 40px);
        display: grid;
        left: 12px;
        right: auto;
        bottom: 76px;
        width: auto;
        transform: none;
        grid-template-columns: repeat(3, var(--mobile-dpad-button-size));
        grid-template-rows: repeat(3, var(--mobile-dpad-button-size));
        gap: 4px;
        padding: 4px;
        background: rgba(15, 23, 42, 0.42);
        z-index: 110;
    }

    #mobileDpad .mobile-dpad-drag-handle {
        position: absolute;
        top: -24px;
        left: 50%;
        width: 42px;
        height: 22px;
        transform: translateX(-50%);
        display: grid;
        place-items: center;
        border: 1px solid rgba(148, 163, 184, 0.7);
        border-radius: 8px 8px 4px 4px;
        background: rgba(15, 23, 42, 0.88);
        color: #cbd5e1;
        font-size: 17px;
        line-height: 1;
        cursor: grab;
        touch-action: none;
        user-select: none;
    }

    #mobileDpad .mobile-dpad-drag-handle:active {
        cursor: grabbing;
    }

    #mobileDpad button {
        min-width: 0;
        min-height: 0;
        font-size: clamp(15px, 4.5vw, 18px);
    }

    #hotbar {
        --mobile-hotbar-slot-size: clamp(42px, 13vw, 48px);
        left: 4px;
        right: 4px;
        top: auto;
        bottom: 4px;
        width: auto;
        transform: none;
        display: grid;
        grid-template-columns:
            var(--mobile-hotbar-slot-size)
            var(--mobile-hotbar-slot-size)
            minmax(44px, 1fr)
            var(--mobile-hotbar-slot-size)
            var(--mobile-hotbar-slot-size);
        gap: 4px;
        cursor: default;
        pointer-events: none;
    }

    #hotbar > .item-tooltip-wrapper {
        width: var(--mobile-hotbar-slot-size);
        pointer-events: auto;
    }

    #hotbar > .item-tooltip-wrapper:nth-child(3) {
        grid-column: 4;
    }

    #hotbar > .item-tooltip-wrapper:nth-child(4) {
        grid-column: 5;
    }

    #hotbar .hotbar-slot {
        width: var(--mobile-hotbar-slot-size);
        height: var(--mobile-hotbar-slot-size);
    }

    .panel[data-panel="controls"] {
        display: none;
    }

    #left:has(#battleWindow.active) #mobileDpad,
    #left:has(#battleWindow.active) #hotbar {
        display: none;
    }

    #top {
        justify-content: flex-start;
        gap: 6px;
        overflow-x: auto;
        overflow-y: hidden;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
    }

    #top::-webkit-scrollbar {
        display: none;
    }

    .top-icons-left,
    .top-icons-right,
    .top-online-count {
        flex-shrink: 0;
    }

    .top-icons-right {
        margin-left: auto;
    }

    .top-icons-left button,
    .top-icons-right button {
        flex-shrink: 0;
        white-space: nowrap;
    }

    .top-online-count-label {
        display: none;
    }

    .map-location-label {
        display: none;
    }

    .map-location-info {
        display: flex;
        flex: 0 1 auto;
        align-items: center;
        gap: 4px;
        min-width: 0;
    }

    .map-location-info > .map-tooltip-wrapper {
        flex: 0 0 auto;
    }

    .map-location-info .map-icon {
        margin-left: 0;
    }

    .icon {
        font-size: 16px;
    }

    .modal-overlay.stash-mode {
        flex-direction: column;
        gap: 8px;
        overflow: hidden;
        padding: 8px 0;
    }

    .modal-overlay.stash-mode .inventory-modal-box,
    .modal-overlay.stash-mode .stash-box {
        box-sizing: border-box;
        width: 94vw;
        max-width: 94vw;
        max-height: calc(100dvh - 70px);
    }

    .modal-overlay.stash-mode .stash-box {
        padding: 14px;
    }

    .modal-overlay.stash-mode.stash-mobile-view-inventory .stash-box,
    .modal-overlay.stash-mode.stash-mobile-view-stash .inventory-modal-box {
        display: none;
    }

    .modal-overlay.stash-mode .inventory-modal-box .equipment-slots,
    .modal-overlay.stash-mode .inventory-modal-box .inventory-divider {
        display: none;
    }

    .modal-overlay.stash-mode .stash-mobile-switch {
        display: flex;
    }

    .modal-box-worldmap {
        width: 96vw;
        max-width: 96vw;
        max-height: 92dvh;
        padding: 10px;
    }

    .worldmap-layout {
        grid-template-columns: 1fr;
        height: auto;
        max-height: none;
        overflow-y: auto;
    }

    .worldmap-grid-wrap {
        height: calc(42vh - 60px);
        min-height: 0;
        max-height: calc(42vh - 60px);
    }

    .worldmap-details {
        max-height: 34vh;
    }
}

@media (max-width: 440px) {
    .login-box {
        padding: 32px 24px;
    }

    .character-select-box {
        padding: 24px;
    }
}

@media (max-width: 410px) {
    #top {
        padding: 6px;
    }

    .top-icons-left,
    .top-icons-right {
        gap: 2px;
    }

    .top-icons-left button,
    .top-icons-right button {
        padding: 8px 10px;
    }

    .top-online-count {
        padding: 8px 6px;
    }
}

/* Na ekranie dotykowym podswietlenie :hover nie moze pozostawac po tapnieciu.
   Selektor tooltipa ma taka sama specyficznosc jak pozniejsza regula bazowa. */
@media (hover: none) {
    .worldmap-tile:hover,
    .worldmap-nested-item:hover {
        border-color: #1f2a36;
    }

    .item-tooltip-wrapper {
        -webkit-user-select: none;
        user-select: none;
        -webkit-touch-callout: none;
    }

    .item-tooltip-wrapper:hover .item-tooltip:not(:empty) {
        display: none;
    }
}
