@media only screen and (max-width: 768px) {
    /* Specyficzna korekta wysokości dla elementu #p252270 na mobilu */
    #p252270 {
        height: 150px !important;           /* zmniejszona wysokość (dopasuj w razie potrzeby) */
        overflow: hidden !important;
    }
    #p252270 img,
    #p252270 .user_photo {
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;       /* przytnij obraz zamiast rozciągać */
        display: block !important;
    }
    /* Zapewnij odstęp treści pod stałymi paskami (usermenu + quick-links) – użyj padding, nie margin (zapobiega kolapsowi) */
    #bd {
        padding-top: 140px !important; /* zwiększony odstęp, żeby guziki były w pełni widoczne */
        margin-top: 0 !important;
    }
    /* Pokaż pasek szybkich linków GW/GN i ustaw go pod usermenu */
    #quick-gallery-links {
        display: block !important;
        position: fixed !important;
        top: 52px !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        z-index: 999 !important;
    }
    /* Ukryj cały picker kategorii na mobilu, żeby pod paskiem były od razu przyciski sortowania */
    #category_picker {
        display: none !important;
    }
    .mobile-hide {
        display: none !important;
    }

    /* === STRONA GŁÓWNA - 2 miniatury w rzędzie === */
    /* Sekcje ze zdjęciami na stronie głównej */
    /* Sekcje foto na stronie głównej (bez :has - działa wszędzie) */
    #bodyWrapper .section > .photo {
        display: inline-block !important;
        width: calc(50% - 12px) !important;
        margin: 6px !important;
        padding: 8px !important;
        box-sizing: border-box !important;
        vertical-align: top !important;
        background-color: #171717 !important;
        border-radius: 12px !important;
        position: relative !important;
    }
    
    #bodyWrapper .section > .photo .title,
    #bodyWrapper .section > .photo .date,
    #bodyWrapper .section > .photo .stats {
        margin: 6px 0 0 0 !important;
        padding: 0 !important;
        width: 100% !important;
        text-align: center !important;
    }
    
    #bodyWrapper .section > .photo .title {
        font-size: 13px !important;
        font-weight: 600 !important;
        color: #fff !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }
    
    #bodyWrapper .section > .photo .date {
        font-size: 11px !important;
        color: rgba(255,255,255,0.65) !important;
    }
    
    #bodyWrapper .section > .photo .stats {
        display: inline-flex !important;
        justify-content: center !important;
        align-items: center !important;
        gap: 6px !important;
        font-size: 11px !important;
        color: rgba(255,255,255,0.85) !important;
        flex-wrap: wrap !important;
    }
    
    #bodyWrapper .section > .photo .stats img {
        width: 14px !important;
        height: 14px !important;
    }
    
    #bodyWrapper .section > .photo img.user_photo,
    #bodyWrapper .section > .photo a.photo-link img {
        display: block !important;
        width: 100% !important;
        height: auto !important;
        border-radius: 8px !important;
    }
    
    #bodyWrapper .section > .photo img.badge,
    #bodyWrapper .section > .photo a img.badge {
        position: absolute !important;
        right: 8px !important;
        bottom: 8px !important;
        width: 24px !important;
        height: 24px !important;
        z-index: 50 !important;
        pointer-events: none !important;
    }

    body.mobile-gallery {
        background-color: #0b0b0d;
    }

    body.mobile-gallery #page {
        width: 100%;
        max-width: 100%;
        padding: 0 16px 48px;
        margin: 0 auto;
        box-sizing: border-box;
    }

    body.mobile-gallery #bd,
    body.mobile-gallery #main,
    body.mobile-gallery .gallery-wrapper {
        width: 100% !important;
        max-width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
        box-sizing: border-box !important;
    }

    body.mobile-gallery #sidepanel,
    body.mobile-gallery .gallery-ad,
    body.mobile-gallery .top-pane,
    body.mobile-gallery .bottom-pane,
    body.mobile-gallery .darkColumn,
    body.mobile-gallery .komLista,
    body.mobile-gallery .ad-pane {
        display: none !important;
    }

    body.mobile-gallery .gallery {
        padding: 0 !important;
        margin: 0 !important;
    }

    body.mobile-gallery #category_picker {
        margin: 12px 0 18px;
        padding: 12px 16px;
        background: rgba(255,255,255,0.04);
        border-radius: 12px;
        border: 1px solid rgba(255,255,255,0.08);
    }

    body.mobile-gallery #category_picker #cPickerSort {
        font-size: 0;
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }

    body.mobile-gallery #category_picker #cPickerSort .main_group {
        font-size: 13px;
        padding: 8px 14px;
        border-radius: 999px;
        background: rgba(255,255,255,0.08);
        border: 1px solid rgba(255,255,255,0.12);
        color: #fff;
        text-decoration: none;
        flex: 1 1 auto;
        text-align: center;
    }

    body.mobile-gallery #category_picker #cPickerSort .main_group.selected {
        background: #c00;
        border-color: #f44;
    }

    body.mobile-gallery .image_list {
        list-style: none;
        padding: 0;
        margin: 0;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
        width: 100%;
        box-sizing: border-box;
    }

    body.mobile-gallery .gallery,
    body.mobile-gallery .newgallery,
    body.mobile-gallery div.gallery {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 12px !important;
        padding: 5px !important;
        box-sizing: border-box !important;
        width: 100% !important;
        margin: 0 auto !important;
    }
    
    body.mobile-gallery .lista_kategorie,
    body.mobile-gallery .darkColumn,
    body.mobile-gallery .komLista {
        display: none !important;
    }
    
    body.mobile-gallery #cPickerSort {
        display: flex !important;
        gap: 12px !important;
        flex-wrap: nowrap !important;
        margin: 14px 5px 18px !important;
        padding: 0 8px !important;
        align-items: center !important;
        width: 100% !important;
        box-sizing: border-box !important;
        font-size: 0 !important;
        position: relative !important;
        z-index: 1002 !important;
        justify-content: space-between !important;
    }
    
    body.mobile-gallery #cPickerSort .main_group {
        display: none !important;
    }
    
    body.mobile-gallery #cPickerSort #gr_najnowsze,
    body.mobile-gallery #cPickerSort #gr_polecane {
        display: inline-flex !important;
        flex: 1 1 calc(50% - 6px) !important;
        justify-content: center !important;
        align-items: center !important;
        padding: 12px 14px !important;
        border-radius: 999px !important;
        border: 1px solid #333 !important;
        background: #1c1c1c !important;
        color: #ffffff !important;
        text-decoration: none !important;
        text-transform: uppercase !important;
        font-size: 12px !important;
        letter-spacing: 0.5px !important;
        box-shadow: 0 4px 14px rgba(0,0,0,0.35);
    }
    
    body.mobile-gallery #cPickerSort #gr_najnowsze.selected,
    body.mobile-gallery #cPickerSort #gr_polecane.selected {
        background: #c01616 !important;
        border-color: #f04c4c !important;
    }
    
    body.mobile-gallery #cPickerSort .expand,
    body.mobile-gallery #cPickerSort a:not(#gr_najnowsze):not(#gr_polecane) {
        display: none !important;
    }
    
    body.mobile-gallery .mobile-sort-buttons {
        display: flex;
        gap: 10px;
        width: 100%;
    }
    
    body.mobile-gallery .mobile-sort-buttons a {
        flex: 1 1 calc(50% - 5px);
        justify-content: center;
        align-items: center;
        padding: 10px 12px;
        border-radius: 999px;
        border: 1px solid #333;
        background: #1c1c1c;
        color: #ffffff;
        text-decoration: none;
        text-transform: uppercase;
        font-size: 12px;
        letter-spacing: 0.5px;
        display: inline-flex;
    }
    
    body.mobile-gallery .mobile-sort-buttons a.selected {
        background: #c01616;
        border-color: #f04c4c;
    }
    
    body.mobile-gallery .gallery .photo,
    body.mobile-gallery .image_list .photo {
        position: relative;
        width: 100%;
        margin: 0;
        padding: 12px;
        background: #171717;
        border-radius: 16px;
        display: flex;
        flex-direction: column;
        gap: 8px;
        box-shadow: 0 10px 30px rgba(0,0,0,0.35);
        transition: transform .2s ease, box-shadow .2s ease;
        height: auto !important;
        min-height: 0 !important;
    }
    
    body.mobile-gallery .gallery .photo:hover,
    body.mobile-gallery .image_list .photo:hover {
        transform: translateY(-2px);
        box-shadow: 0 15px 30px rgba(0,0,0,0.55);
    }
    
    body.mobile-gallery .gallery .photo a,
    body.mobile-gallery .gallery .photo a.photo-link,
    body.mobile-gallery .image_list .photo a,
    body.mobile-gallery .image_list .photo a.photo-link {
        display: block;
        width: 100%;
        color: inherit;
        text-decoration: none;
        line-height: normal;
        padding: 0;
    }
    
    body.mobile-gallery .gallery .photo a img.user_photo,
    body.mobile-gallery .image_list .photo a img.user_photo {
        border-radius: 10px;
        display: block;
        width: 100%;
        height: auto;
    }
    
    body.mobile-gallery .gallery .photo .title,
    body.mobile-gallery .image_list .photo .title,
    body.mobile-gallery .gallery .photo .date,
    body.mobile-gallery .image_list .photo .date {
        display: none !important;
    }
    
    body.mobile-gallery .gallery .photo .stats,
    body.mobile-gallery .image_list .photo .stats {
        display: block !important;            /* 2 wiersze: login, potem statystyki */
        text-align: center !important;
        font-size: 12px !important;
        line-height: 1.1 !important;
        color: rgba(255,255,255,0.9) !important;
        margin: 2px 0 0 0 !important;
        padding: 0 !important;
        width: 100% !important;
    }

    body.mobile-gallery .gallery .photo .stats a,
    body.mobile-gallery .image_list .photo .stats a {
        display: none !important;
    }
    body.mobile-gallery .gallery .photo .stats a.userlogin,
    body.mobile-gallery .image_list .photo .stats a.userlogin,
    body.mobile-gallery .gallery .photo .stats a[href*="/portfolio/"],
    body.mobile-gallery .image_list .photo .stats a[href*="/portfolio/"],
    body.mobile-gallery .gallery .photo .stats a:first-child,
    body.mobile-gallery .image_list .photo .stats a:first-child {
        display: block !important;                 /* login jako pierwszy wiersz */
        color: #ff6464 !important;
        font-weight: 700 !important;
        text-decoration: none !important;
        margin: 0 0 2px 0 !important;              /* odstęp nad statystykami */
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }
    /* Gwarantowany margines 2px między loginem a statystykami */
    body.mobile-gallery .gallery .photo .stats a.userlogin,
    body.mobile-gallery .image_list .photo .stats a.userlogin {
        margin-bottom: 2px !important;
        line-height: 1.1 !important;   /* ciaśniejszy wiersz loginu */
        padding: 0 !important;         /* bez dodatkowego pionu */
    }

    /* Dodatkowo – usuń marginesy na pierwszym wierszu statów, jeśli występują jako kontener */
    body.mobile-gallery .gallery .photo .stats .stats-row:first-child,
    body.mobile-gallery .image_list .photo .stats .stats-row:first-child {
        margin-top: 0 !important;
    }

    body.mobile-gallery .gallery .photo .stats span,
    body.mobile-gallery .image_list .photo .stats span {
        display: none !important;
    }
    
    body.mobile-gallery .gallery .photo .stats span:nth-of-type(1),
    body.mobile-gallery .image_list .photo .stats span:nth-of-type(1) {
        display: inline-flex !important;
        align-items: center !important;
        gap: 6px !important;
        font-weight: 600 !important;
        color: #fff !important;
    }
    
    body.mobile-gallery .gallery .photo .stats span:nth-of-type(1) + img,
    body.mobile-gallery .image_list .photo .stats span:nth-of-type(1) + img {
        display: inline-block !important;
        width: 14px !important;
        height: auto !important;
        vertical-align: middle !important;
    }
    
    body.mobile-gallery .gallery .photo .stats span:last-of-type:not(:first-of-type),
    body.mobile-gallery .image_list .photo .stats span:last-of-type:not(:first-of-type) {
        display: inline-flex !important;
        align-items: center !important;
        gap: 6px !important;
        font-weight: 600 !important;
        color: #fff !important;
    }
    
    body.mobile-gallery .gallery .photo .stats span:last-of-type:not(:first-of-type) + img,
    body.mobile-gallery .image_list .photo .stats span:last-of-type:not(:first-of-type) + img {
        display: inline-block !important;
        width: 14px !important;
        height: auto !important;
        vertical-align: middle !important;
    }

    body.mobile-gallery .gallery .photo .stats span:nth-of-type(2),
    body.mobile-gallery .image_list .photo .stats span:nth-of-type(2),
    body.mobile-gallery .gallery .photo .stats span:nth-of-type(3),
    body.mobile-gallery .image_list .photo .stats span:nth-of-type(3),
    body.mobile-gallery .gallery .photo .stats span:nth-of-type(2) + img,
    body.mobile-gallery .image_list .photo .stats span:nth-of-type(2) + img,
    body.mobile-gallery .gallery .photo .stats span:nth-of-type(3) + img,
    body.mobile-gallery .image_list .photo .stats span:nth-of-type(3) + img {
        display: none !important;
    }
    
    body.mobile-gallery .gallery .photo .stats img,
    body.mobile-gallery .image_list .photo .stats img {
        width: 14px !important;
        height: auto !important;
        vertical-align: middle !important;
    }

    body.mobile-gallery .image_list .photo img.user_photo {
        width: 100%;
        height: auto;
        display: block;
    }

    body.mobile-gallery .image_list .photo img.badge {
        width: 28px;
        height: 28px;
        position: absolute;
        right: 10px;
        bottom: 10px;
        z-index: 50;
        pointer-events: none;
    }
}

/* Mobile Gallery - 2 miniatury obok siebie + ZERO bocznych paneli + Infinite Scroll */
@media only screen and (max-width: 768px) {
    
    /* === MENU - Logo po lewej, Flaga+LOGIN po prawej === */
    #usermenu ul li#menuitem-langs {
        margin-left: auto !important;
    }
    
    /* === UKRYJ PAGINACJĘ (infinite scroll zamiast tego) === */
    .paginacja,
    div.paginacja {
        display: none !important;
    }
    
    
    /* === UKRYJ ABSOLUTNIE WSZYSTKO CO BOCZNE === */
    
    /* ULTRA-MEGA-AGRESYWNE ukrycie #sidepanel (lewa kolumna z komentarzami) */
    /* NADPISANIE BŁĘDNEJ DEFINICJI: #sidepanel.hidden { margin-right: -220px; } */
    /* PHP dodaje class="hidden" na mobile - teraz naprawdę ukrywamy */
    html body #sidepanel,
    html body #sidepanel.hidden,
    html body div#sidepanel,
    html body div#sidepanel.hidden,
    body #sidepanel,
    body #sidepanel.hidden,
    body div#sidepanel,
    body div#sidepanel.hidden,
    #sidepanel,
    #sidepanel.hidden,
    #sidepanel *,
    div#sidepanel,
    div#sidepanel.hidden,
    .side-pane,
    .top-pane,
    .bottom-pane,
    .top-pane-wrapper,
    .bottom-pane-wrapper,
    .comments-pane,
    .gallery-ad,
    .darkColumn,
    .komLista,
    .rounded-top,
    h2.rounded-top,
    .ad-pane,
    aside,
    [class*="sidebar"],
    [class*="side-"],
    [id*="sidebar"],
    [id*="side"] {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        width: 0 !important;
        min-width: 0 !important;
        max-width: 0 !important;
        height: 0 !important;
        min-height: 0 !important;
        max-height: 0 !important;
        margin: 0 !important;
        margin-right: 0 !important;
        padding: 0 !important;
        position: absolute !important;
        left: -99999px !important;
        top: -99999px !important;
        overflow: hidden !important;
        z-index: -9999 !important;
        transform: translateX(-9999px) !important;
    }
    
    /* UKRYJ GŁÓWNE MENU NAWIGACYJNE NA MOBILE (#mainmenu) */
    #mainmenu,
    div#mainmenu,
    #mainmenu *,
    div#mainmenu *,
    #mainmenu ul,
    #mainmenu li,
    #mainmenu a,
    [id*="mainmenu"] {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        width: 0 !important;
        height: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        position: fixed !important;
        left: -99999px !important;
        top: -99999px !important;
        overflow: hidden !important;
        z-index: -9999 !important;
    }
    
    /* UKRYJ LEWĄ KOLUMNĘ Z ANALIZAMI (.lista_kategorie) */
    .lista_kategorie,
    div.lista_kategorie,
    .lista_kategorie *,
    div.lista_kategorie *,
    .lista_kategorie h2,
    .lista_kategorie .last_item,
    [class*="lista_kategorie"],
    [id*="lista_kategorie"] {
        display: none !important;
        visibility: hidden !important;
        width: 0 !important;
        height: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        position: absolute !important;
        left: -99999px !important;
        overflow: hidden !important;
    }
    
    /* UPORZĄDKUJ FILTROWANIE - PROSTSZE NA MOBILE */
    #category_picker,
    .szaraBelka#category_picker {
        width: 100% !important;
        margin: 100px 0 10px !important; /* większy odstęp od menu ~100px */
        padding: 0 !important; /* usuń wewnętrzny padding, żeby przyciski były równo z krawędzią */
        background: transparent !important; /* bez tła skrzynki */
        border-radius: 0 !important;
        border: none !important; /* bez ramki */
        box-shadow: none !important;
        display: block !important;
        font-size: 13px !important;
        clear: both !important; /* w razie gdyby elementy powyżej były floatowane */
    }
    
    /* UKRYJ KATEGORIE NA MOBILE */
    #category_picker #cPickerCategory {
        display: none !important;
        visibility: hidden !important;
        height: 0 !important;
        overflow: hidden !important;
    }
    
    #category_picker .kat_kategorie {
        display: none !important;
        visibility: hidden !important;
    }
    
    /* KOLEJNOŚĆ (SORTOWANIE) - z dropdown (jak kategorie) */
    #category_picker #cPickerSort {
        display: flex !important;
        flex-wrap: nowrap !important;
        justify-content: space-between !important;
        gap: 0 !important; /* iOS Safari nie wspiera flex-gap — użyjemy marginesów na dzieciach */
        width: 100% !important;
        margin: 12px 0 10px !important;
        padding: 0 12px !important; /* lekki odsęp boczny */
        float: none !important;
        font-size: 0 !important; /* Ukryj tekst "Wyświetl wg kolejności:" */
    }
    
    /* Główne przyciski sortowania - UKRYJ WSZYSTKIE domyślnie */
    #category_picker #cPickerSort .main_group {
        display: none !important;
    }
    
    /* Pokaż TYLKO 2 grupy: Najnowsze (#gr_najnowsze) i Polecane (#gr_polecane) */
    #category_picker #cPickerSort #gr_najnowsze,
    #category_picker #cPickerSort a[id*=\"najnowsze\"],
    #category_picker #cPickerSort #gr_polecane,
    #category_picker #cPickerSort a[id*=\"polecane\"] {
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        flex: 0 0 auto !important;          /* szerokość zgodna z treścią */
        min-width: max-content !important;  /* nie ścinaj napisu */
        box-sizing: border-box !important;
        height: auto !important;
        padding: 10px 16px !important;
        margin: 0 6px !important;           /* odstęp między przyciskami */
        background: #2a2a2a !important;
        border: 1px solid #3a3a3a !important;
        border-radius: 999px !important;    /* „pigułka” */
        color: #fff !important;
        text-decoration: none !important;
        font-size: 13px !important;
        font-weight: 700 !important;
        letter-spacing: 0.3px !important;
        text-transform: uppercase !important;
        white-space: nowrap !important;
        line-height: 1.2 !important;
        box-shadow: 0 2px 8px rgba(0,0,0,0.25) !important;
        transition: background .15s ease, transform .1s ease, box-shadow .15s ease !important;
        touch-action: manipulation !important;
    }

    /* Odstęp między przyciskami zapewniają marginesy 0 6px na każdym z nich */
    
    #category_picker #cPickerSort #gr_najnowsze:active,
    #category_picker #cPickerSort a[id*="najnowsze"]:active,
    #category_picker #cPickerSort #gr_polecane:active,
    #category_picker #cPickerSort a[id*="polecane"]:active {
        background: #444 !important;
        transform: translateY(1px) scale(0.98) !important;
    }
    
    #category_picker #cPickerSort #gr_najnowsze.selected,
    #category_picker #cPickerSort a[id*="najnowsze"].selected,
    #category_picker #cPickerSort #gr_polecane.selected,
    #category_picker #cPickerSort a[id*="polecane"].selected {
        background: #c01616 !important;
        border-color: #f04c4c !important;
        box-shadow: 0 6px 16px rgba(192,22,22,0.45) !important;
    }
    
    /* Dropdown dla sortowania - ukryty domyślnie, pokazuje się po kliknięciu */
    #category_picker #cPickerSort .expand {
        display: none !important;
        position: fixed !important;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
        width: 90% !important;
        max-width: 300px !important;
        margin: 0 !important;
        padding: 10px !important;
        background: #2a2a2a !important;
        border: 2px solid #444 !important;
        border-radius: 8px !important;
        box-shadow: 0 8px 24px rgba(0,0,0,0.8) !important;
        z-index: 9999 !important;
    }
    
    
    /* UKRYJ wszystkie opcje w expand (dropdown) */
    #category_picker #cPickerSort .expand a {
        display: none !important;
    }
    
    /* Pokaż tylko opcje dla grup Najnowsze i Polecane w ich dropdownach */
    #category_picker #cPickerSort .expand.gr_najnowsze a,
    #category_picker #cPickerSort .expand.gr_polecane a {
        display: block !important;
        padding: 10px 12px !important;
        margin: 3px 0 !important;
        background: #333 !important;
        border: 1px solid #555 !important;
        border-radius: 4px !important;
        color: #fff !important;
        text-decoration: none !important;
        font-size: 14px !important;
        touch-action: manipulation !important;
    }
    
    #category_picker #cPickerSort .expand.gr_najnowsze a:active,
    #category_picker #cPickerSort .expand.gr_polecane a:active {
        background: #555 !important;
    }
    
    #category_picker #cPickerSort .expand.gr_najnowsze a.selected,
    #category_picker #cPickerSort .expand.gr_polecane a.selected {
        background: #c00 !important;
        border-color: #e00 !important;
        font-weight: bold !important;
    }
    
    /* PAGINACJA - lepsze na mobile */
    .paginacja {
        width: 100% !important;
        margin: 10px 0 !important;
        padding: 8px 5px !important;
        text-align: center !important;
        display: flex !important;
        flex-wrap: wrap !important;
        justify-content: center !important;
        align-items: center !important;
        gap: 5px !important;
    }
    
    .paginacja a,
    .paginacja .pagebutton {
        display: inline-block !important;
        padding: 8px 12px !important;
        margin: 2px !important;
        background: #333 !important;
        border: 1px solid #555 !important;
        border-radius: 4px !important;
        color: #fff !important;
        text-decoration: none !important;
        font-size: 14px !important;
        min-width: 40px !important;
        text-align: center !important;
        cursor: pointer !important;
        touch-action: manipulation !important;
        user-select: none !important;
    }
    
    .paginacja a:active,
    .paginacja .pagebutton:active {
        background: #555 !important;
        transform: scale(0.95) !important;
    }
    
    .paginacja a.yellow,
    .paginacja .pagebutton.yellow {
        background: #c00 !important;
        border-color: #e00 !important;
        font-weight: bold !important;
    }
    
    .paginacja a.fback,
    .paginacja a.ffoward,
    .paginacja a.firsturl,
    .paginacja a.fend {
        font-size: 12px !important;
        min-width: 50px !important;
    }
    
    /* === GALERIA NA PEŁNĄ SZEROKOŚĆ === */
    
    /* USUŃ WSZYSTKIE MARGINESY I PADDINGI lewej kolumny */
    body,
    #bd,
    #main,
    .main-pane,
    .major,
    .page-wrapper,
    .page,
    .gallery-wrapper,
    .gallery-wrapper.ad,
    .gallery,
    #galleryPane,
    .flex-grow,
    .newgallery,
    .image_list {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        padding-left: 5px !important;
        padding-right: 5px !important;
        float: none !important;
        position: relative !important;
        box-sizing: border-box !important;
    }
    
    /* .newgallery - usunięcie lewego float/marginesu */
    .newgallery {
        padding: 0 5px !important;
    }
    
    /* .image_list - pełna szerokość */
    .image_list {
        width: 100% !important;
        margin-left: 0 !important;
        padding-left: 0 !important;
    }
    
    /* Gallery - reset wszystkiego */
    .gallery {
        padding: 0 5px !important;
    }
    
    /* Ukryj kolumnę z reklamą/komentarzami całkowicie */
    .gallery-ad {
        display: none !important;
        width: 0 !important;
        height: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        position: absolute !important;
        left: -9999px !important;
    }
    
    /* Wrapper.ad - zachowuj się jak normalny wrapper */
    .gallery-wrapper.ad {
        display: block !important;
        width: 100% !important;
    }
    
    /* Główny kontener na 100% - ZERO paddingów */
    #bd {
        padding: 0 !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
        padding-top: 0 !important;
        padding-bottom: 0 !important;
        margin: 0 !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        width: 100% !important;
    }
    
    /* Main też */
    #main {
        padding: 0 !important;
        margin: 0 !important;
        width: 100% !important;
    }
    
    /* Usuń wszystkie kolumny - tylko jedna kolumna */
    [class*="col-"],
    [class*="column"] {
        width: 100% !important;
        margin: 0 !important;
        padding: 0 5px !important;
    }
    
    /* Wymuś jednowierszowy layout */
    * {
        box-sizing: border-box !important;
    }
    
    /* AGRESYWNE usuwanie lewego marginesu który tworzy "kolumnę" */
    #galleryPane,
    #galleryPane *,
    div[id*="gallery"],
    div[class*="gallery"] {
        margin-left: 0 !important;
        padding-left: 5px !important;
    }
    
    /* Wrapper gdy ma reklamę - normalnie ma float i margin-left */
    .gallery-wrapper.ad {
        float: none !important;
        margin-left: 0 !important;
    }
    
    /* Div z reklamą nie powinien przesuwać galerii */
    .gallery-ad + .gallery,
    .gallery-ad ~ .gallery {
        margin-left: 0 !important;
        padding-left: 5px !important;
    }
    
    /* === MINIATURY ZDJĘĆ - 2 w rzędzie === */
    
    /* GALERIE - grid 2 kolumny (strona główna + podstrony) */
    .gallery,
    div.gallery,
    .newgallery,
    div.newgallery,
    .image_list,
    div.image_list,
    .section:has(.photo) {
        width: 100% !important;
        max-width: 100% !important;
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
        padding: 5px !important;
        box-sizing: border-box !important;
    }
    
    /* W GW .image_list jest WEWNĄTRZ .newgallery - NIE powinien być gridem */
    .newgallery .image_list,
    div.newgallery div.image_list {
        display: contents !important;
        padding: 0 !important;
        gap: 0 !important;
    }
    
    /* H2 w galeriach - span na 2 kolumny */
    .gallery h2,
    .newgallery h2,
    .image_list h2,
    .section:has(.photo) h2,
    h2.decor {
        grid-column: 1 / -1 !important;
        width: 100% !important;
        border-left: none !important;
        padding-left: 0 !important;
    }
    
    /* === NEWS TICKER - rozciągnij na całą szerokość === */
    /* Sekcja z newstickerem musi być gridem żeby grid-column zadziałał */
    .section:has(#news-wrapper) {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
    }
    
    /* H2 i newsticker w sekcji - pełna szerokość */
    .section:has(#news-wrapper) h2,
    #news-wrapper,
    #news-wrapper .newsticker_wrapper {
        grid-column: 1 / -1 !important;
        width: 100% !important;
        max-width: 100% !important;
    }
    
    /* === RANKING UŻYTKOWNIKÓW - 8 avatarów, 4 w rzędzie, 2 ostatnie ukryte na mobile === */
    /* NADPISZ desktop CSS: .section.high_ranked { grid-template-columns: 201px 201px; width: 420px } */
    #teaser .section.high_ranked,
    div#teaser div.section.high_ranked,
    .section.high_ranked,
    div.section.high_ranked {
        display: grid !important;
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 10px !important;
        width: 100% !important;
        max-width: 100% !important;
        padding: 10px 5px !important;
        box-sizing: border-box !important;
    }
    
    /* UKRYJ <br> - powoduje rozjazd */
    .section.high_ranked br {
        display: none !important;
    }
    
    .section.high_ranked > a {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: flex-start !important;
        text-align: center !important;
        text-decoration: none !important;
        width: auto !important;
        height: auto !important;
        margin: 0 !important;
        padding: 5px !important;
        background-color: #1a1a1a !important;
        border-radius: 8px !important;
        box-sizing: border-box !important;
    }
    
    /* UKRYJ 7. i 8. element na mobile (2 ostatnie) */
    .section.high_ranked > a:nth-child(7),
    .section.high_ranked > a:nth-child(8) {
        display: none !important;
    }
    
    .section.high_ranked .avatar {
        width: 60px !important;
        height: 60px !important;
        border-radius: 50% !important;
        background-size: cover !important;
        background-position: center !important;
        display: block !important;
        margin-bottom: 5px !important;
    }
    
    .section.high_ranked .label {
        font-size: 11px !important;
        margin: 3px 0 !important;
        display: block !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        max-width: 100% !important;
    }
    
    .section.high_ranked span:last-child {
        font-size: 9px !important;
        color: #999 !important;
    }
    
    /* User-list (alternatywna struktura) */
    ul.user-list,
    section ul.user-list {
        display: grid !important;
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 10px !important;
        list-style: none !important;
        padding: 10px 5px !important;
        margin: 0 !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }
    
    ul.user-list li {
        display: block !important;
        width: auto !important;
        margin: 0 !important;
    }
    
    /* UKRYJ 7. i 8. <li> na mobile */
    ul.user-list li:nth-child(7),
    ul.user-list li:nth-child(8) {
        display: none !important;
    }
    
    /* UKRYJ <br> w user-list */
    ul.user-list br {
        display: none !important;
    }
    
    ul.user-list li a {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: flex-start !important;
        text-align: center !important;
        text-decoration: none !important;
        width: auto !important;
        height: auto !important;
        margin: 0 !important;
        padding: 5px !important;
        background-color: #1a1a1a !important;
        border-radius: 8px !important;
        box-sizing: border-box !important;
    }
    
    ul.user-list .head {
        width: 60px !important;
        height: 60px !important;
        border-radius: 50% !important;
        background-size: cover !important;
        background-position: center !important;
        display: block !important;
        margin-bottom: 5px !important;
    }
    
    ul.user-list .name {
        font-size: 11px !important;
        margin: 3px 0 !important;
        display: block !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        max-width: 100% !important;
    }
    
    ul.user-list .points {
        font-size: 9px !important;
        color: #999 !important;
    }
    
    /* === FIXED ELEMENTY - nie blokuj klikania na mobile === */
    
    /* Cookie Banner - obniżony z-index i zmniejszona wysokość */
    #cookie-consent-banner {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        z-index: 100 !important; /* OBNIŻONY z 999999 do 100 */
        max-height: 30vh !important; /* Zmniejszony z 50vh do 30vh */
        pointer-events: auto !important;
        padding: 10px !important;
    }
    
    /* Przyciski w bannerze muszą być klikalne */
    #cookie-consent-banner * {
        pointer-events: auto !important;
    }
    
    /* Quick Gallery Links - WŁĄCZ na mobile i nadaj stałą wysokość pod nawigacją */
    #quick-gallery-links {
        display: block !important;
        position: fixed !important;
        top: 52px !important; /* wysokość usermenu */
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        z-index: 900 !important;
        padding: 8px 10px !important;
        box-sizing: border-box !important;
    }
    
    /* Treść strony ZAWSZE klikalna */
    body,
    #bodyWrapper,
    #teaser,
    #bd,
    .main-pane,
    .section,
    .photo,
    a {
        pointer-events: auto !important;
    }
    
    /* Dodaj padding-bottom do body aby treść nie być zasłonięta przez banner */
    body {
        padding-bottom: 150px !important; /* Miejsce na cookie banner */
    }
    
    /* ZDJĘCIE - Grid automatycznie ustala szerokość */
    .photo {
        width: 100% !important;
        height: auto !important;
        min-height: 0 !important;      /* było 200px — usuń zbędną wysokość */
        margin: 0 !important;
        padding: 5px !important;
        background-color: #171717 !important;
        box-sizing: border-box !important;
        float: none !important;
        position: relative !important;
    }
    
    /* Obrazki ZDJĘĆ w galeriach - pełna szerokość komórki */
    /* Najpierw ustaw wszystkie obrazki w linkach na 100% */
    .gallery .photo a img,
    .newgallery .photo a img,
    .image_list .photo a img,
    .section:has(.photo) .photo a img {
        width: 100% !important;
        height: auto !important;
        display: block !important;
        max-width: 100% !important;
    }
    
    /* Potem wykluczenia - badge (ikona zdjęcia dnia) */
    .photo img.badge,
    .photo a img.badge,
    img.badge {
        width: 24px !important;
        height: 24px !important;
        max-width: 24px !important;
        min-width: 24px !important;
        position: absolute !important;
        top: auto !important;
        left: auto !important;
        right: 8px !important;
        bottom: 8px !important;
        z-index: 50 !important;
        pointer-events: none !important;
    }
    
    /* Ikonki statystyk - zachowaj oryginalny rozmiar */
    .photo .stats img,
    .photo p.stats img {
        width: auto !important;
        height: auto !important;
        max-width: 16px !important;
        min-width: auto !important;
    }
    
    /* Usuń clearfix - Grid go nie potrzebuje */
    .clearfix {
        display: none !important;
    }
    
    /* Obrazki responsywne */
    .photo img.user_photo {
        max-width: 100% !important;
        height: auto !important;
        width: 100% !important;
    }
    
    .photo a.photo-link,
    .photo a {
        width: 100% !important;
        height: auto !important;
        min-height: 140px !important;
        line-height: normal !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    
    /* Tytuł i stats mniejsze */
    .photo .title {
        font-size: 11px !important;
        padding: 3px 0 !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }
    
    .photo .stats {
        font-size: 9px !important;
        padding-top: 3px !important;
    }
    
    .photo .stats img {
        width: 12px !important;
        height: auto !important;
    }
    
    .photo .date {
        font-size: 9px !important;
    }
    
    /* Section - bez górnego paddingu */
    .section {
        padding: 10px 5px !important;
    }
    
    .section h2 {
        font-size: 16px !important;
        margin-bottom: 10px !important;
    }
    
    /* Clear po każdych 2 zdjęciach */
    .photo:nth-child(2n)::after {
        content: "";
        display: table;
        clear: both;
    }
}

@media only screen and (max-width: 768px) {
    body.mobile-gallery .gallery .photo .stats span,
    body.mobile-gallery .image_list .photo .stats span,
    body.mobile-gallery .gallery .photo .stats img,
    body.mobile-gallery .image_list .photo .stats img {
        display: none !important;
    }
    
    body.mobile-gallery .gallery .photo .stats span:first-of-type,
    body.mobile-gallery .image_list .photo .stats span:first-of-type,
    body.mobile-gallery .gallery .photo .stats span:first-of-type,
    body.mobile-gallery .image_list .photo .stats span:first-of-type,
    body.mobile-gallery .gallery .photo .stats span:last-of-type,
    body.mobile-gallery .image_list .photo .stats span:last-of-type {
        display: inline-flex !important;
        align-items: center !important;
        gap: 6px !important;
        font-weight: 600 !important;
        color: #fff !important;
    }
    
    body.mobile-gallery .gallery .photo .stats span:first-of-type + img,
    body.mobile-gallery .image_list .photo .stats span:first-of-type + img,
    body.mobile-gallery .gallery .photo .stats span:last-of-type + img,
    body.mobile-gallery .image_list .photo .stats span:last-of-type + img {
        display: inline-block !important;
        width: 14px !important;
        height: auto !important;
    }
    
    body.mobile-gallery .gallery .photo .stats span:nth-of-type(n+2):not(:last-of-type),
    body.mobile-gallery .image_list .photo .stats span:nth-of-type(n+2):not(:last-of-type),
    body.mobile-gallery .gallery .photo .stats span:nth-of-type(n+2):not(:last-of-type) + img,
    body.mobile-gallery .image_list .photo .stats span:nth-of-type(n+2):not(:last-of-type) + img {
        display: none !important;
    }
}
/* --- FINAL MOBILE OVERRIDES (ensure GW layout matches homepage) --- */
@media only screen and (max-width: 768px) {
    /* Pełna szerokość belki filtrów na mobilu */
    body.mobile-gallery #category_picker,
    body.mobile-gallery #category_picker.szaraBelka,
    body.mobile-gallery #cPickerCategory,
    body.mobile-gallery #cPickerSort {
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        box-sizing: border-box !important;
    }

    body.mobile-gallery .lista_kategorie,
    body.mobile-gallery .darkColumn,
    body.mobile-gallery .komLista {
        display: none !important;
    }

    body.mobile-gallery #cPickerSort {
        display: flex !important;
        gap: 0 !important; /* bez gap — używamy marginesów na przyciskach */
        margin: 8px 0 12px !important;
        padding: 0 12px !important;
        font-size: 0 !important;
        justify-content: space-between !important;
    }

    body.mobile-gallery #cPickerSort .main_group {
        display: none !important;
    }

    body.mobile-gallery #cPickerSort #gr_najnowsze,
    body.mobile-gallery #cPickerSort #gr_polecane {
        display: inline-flex !important;
        flex: 0 0 auto !important;
        min-width: max-content !important;
        box-sizing: border-box !important;
        justify-content: center !important;
        align-items: center !important;
        height: auto !important;
        padding: 10px 16px !important;
        margin: 0 6px !important;
        border-radius: 999px !important;
        border: 1px solid #333 !important;
        background: #1c1c1c !important;
        color: #fff !important;
        text-decoration: none !important;
        text-transform: uppercase !important;
        font-size: 13px !important;
        letter-spacing: 0.3px !important;
        white-space: nowrap !important;
        line-height: 1.2 !important;
    }

    body.mobile-gallery #cPickerSort #gr_najnowsze.selected,
    body.mobile-gallery #cPickerSort #gr_polecane.selected {
        background: #c01616 !important;
        border-color: #f04c4c !important;
    }

    body.mobile-gallery .gallery,
    body.mobile-gallery .newgallery,
    body.mobile-gallery .image_list {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 12px !important;
        padding: 5px !important;
        box-sizing: border-box !important;
        width: 100% !important;
        margin: 0 auto !important;
    }

    body.mobile-gallery .gallery .photo,
    body.mobile-gallery .image_list .photo {
        width: 100% !important;
        margin: 0 !important;
        padding: 8px !important; /* mniejsze wewnętrzne odstępy */
        border-radius: 16px !important;
        background: #171717 !important;
        display: flex !important;
        flex-direction: column !important;
        gap: 6px !important; /* mniejszy pionowy odstęp między elementami */
        height: auto !important;
        min-height: 0 !important;
    }

    body.mobile-gallery .gallery .photo a.photo-link,
    body.mobile-gallery .image_list .photo a.photo-link {
        display: block !important;
        width: 100% !important;
        height: auto !important;
        min-height: 0 !important;
        line-height: normal !important;
        padding: 0 !important;
    }

    body.mobile-gallery .gallery .photo .title,
    body.mobile-gallery .image_list .photo .title,
    body.mobile-gallery .gallery .photo .date,
    body.mobile-gallery .image_list .photo .date {
        display: none !important;
    }

    body.mobile-gallery .gallery .photo .stats,
    body.mobile-gallery .image_list .photo .stats {
        display: block !important;
        text-align: center !important;
        font-size: 12px !important;
        color: rgba(255,255,255,0.9) !important;
        margin: 2px 0 0 0 !important;
        padding: 0 !important;
        width: 100% !important;
    }

    body.mobile-gallery .gallery .photo .stats a,
    body.mobile-gallery .image_list .photo .stats a {
        display: none !important;
    }
    body.mobile-gallery .gallery .photo .stats a.userlogin,
    body.mobile-gallery .image_list .photo .stats a.userlogin,
    body.mobile-gallery .gallery .photo .stats a[href*="/portfolio/"],
    body.mobile-gallery .image_list .photo .stats a[href*="/portfolio/"],
    body.mobile-gallery .gallery .photo .stats a:first-child,
    body.mobile-gallery .image_list .photo .stats a:first-child {
        display: block !important;                 /* login jako pierwszy wiersz */
        color: #ff6464 !important;
        font-weight: 700 !important;
        text-decoration: none !important;
        margin: 0 0 2px 0 !important;              /* odstęp nad statystykami */
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }
    /* Gwarantowany margines 2px między loginem a statystykami */
    body.mobile-gallery .gallery .photo .stats a.userlogin,
    body.mobile-gallery .image_list .photo .stats a.userlogin {
        margin-bottom: 2px !important;
        line-height: 1.1 !important;   /* ciaśniejszy wiersz loginu */
        padding: 0 !important;         /* bez dodatkowego pionu */
    }

    /* Dodatkowo – usuń marginesy na pierwszym wierszu statów, jeśli występują jako kontener */
    body.mobile-gallery .gallery .photo .stats .stats-row:first-child,
    body.mobile-gallery .image_list .photo .stats .stats-row:first-child {
        margin-top: 0 !important;
    }

    body.mobile-gallery .gallery .photo .stats .stats-row,
    body.mobile-gallery .image_list .photo .stats .stats-row {
        display: inline-flex !important;
        align-items: center !important;
        gap: 6px !important;
        font-size: 11px !important;
        color: rgba(255,255,255,0.85) !important;
    }

    body.mobile-gallery .gallery .photo .stats .stats-row .stats-value,
    body.mobile-gallery .image_list .photo .stats .stats-row .stats-value {
        font-weight: 600 !important;
        color: #fff !important;
        display: inline-block !important;
    }

    body.mobile-gallery .gallery .photo .stats .stats-row img,
    body.mobile-gallery .image_list .photo .stats .stats-row img {
        width: 14px !important;
        height: auto !important;
        display: inline-block !important;
    }

    /* GLOBALNIE: ujednolicenie wysokości miniatur pod zdjęciem na mobilu */
    body.mobile-gallery .gallery .photo a img.user_photo,
    body.mobile-gallery .image_list .photo a img.user_photo,
    body.mobile-gallery .gallery .photo a img,
    body.mobile-gallery .image_list .photo a img {
        max-height: 150px !important;
        width: 100% !important;
        height: auto !important;
        object-fit: cover !important;
        display: block !important;
    }

    /* (Revert) GN: usunięto kopiowane ustawienia ze strony głównej */
}

@media only screen and (max-width: 768px) {
    /* GN refined: zachowaj grid, ale ujednolić karty i odstępy */
    body.mobile-gallery .newgallery .image_list { 
        display: contents !important; /* nie psuj grida w kontenerze */
    }
    body.mobile-gallery .newgallery .photo {
        padding: 8px !important;
        gap: 6px !important;
    }
    body.mobile-gallery .newgallery .photo p,
    body.mobile-gallery .newgallery .photo a { 
        margin: 0 !important; 
        padding: 0 !important; 
    }
    body.mobile-gallery .newgallery .photo .stats {
        text-align: center !important;
        margin-top: 2px !important;
        line-height: 1.1 !important;
    }
    body.mobile-gallery .newgallery .photo .stats a.userlogin {
        display: block !important;
        margin-bottom: 2px !important; /* dokładnie 2px */
        line-height: 1.1 !important;
    }
    body.mobile-gallery .newgallery .photo .stats br { display: none !important; }
}

@media only screen and (max-width: 768px) {
/* Zmniejsz wysokość linku loginu z klasą .art w stats (czasem ma sztuczną wysokość ~167px) */
body.mobile-gallery .gallery .photo .stats a.art,
body.mobile-gallery .image_list .photo .stats a.art,
body.mobile-gallery .newgallery .photo .stats a.art {
    display: block !important;
    height: 20px !important;
    max-height: 20px !important;
    line-height: 20px !important;
    padding: 0 !important;
    margin: 0 0 2px 0 !important;
    overflow: hidden !important;
}
}

@media only screen and (max-width: 768px) {
  /* FINAL: zmniejsz karty .photo na mobilu */
  body.mobile-gallery .gallery .photo,
  body.mobile-gallery .image_list .photo {
    padding: 6px !important;
    gap: 4px !important;
    border-radius: 12px !important;
  }
  body.mobile-gallery .gallery .photo a,
  body.mobile-gallery .image_list .photo a {
    min-height: 120px !important; /* było 140 – mniejsza karta */
  }
}
