:root {
    --granat: #002f73;
    --niebieski: #02cabf;
    --niebieski2: #017494;
    --label-bg: #e0fbfb;
    --white: #ffffff;
    --grey-locked: #888888;
}

* { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
}

body, html { 
    width: 100%; 
    height: 100%; 
    font-family: 'Open Sans', sans-serif; 
    overflow-y: hidden; 
    overflow-x: hidden;
}

/* Jasny gradient tła strony */
.main-bg {
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%;
    background: linear-gradient(180deg, #d4f1f4 0%, #ffffff 100%); 
    z-index: -1;
}

#app-content {
    width: 100%;
    height: 100%;
    position: relative;
}

.screen { 
    position: absolute;
    top: 0;
    left: 0;
    width: 100%; 
    height: 100%; 
    display: flex; 
    flex-direction: column; 
    justify-content: center; 
    align-items: center; 
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: scale(0.96);
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                visibility 0.4s ease-in-out;
}

.screen.active { 
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: scale(1);
}

/* Zapobieganie miganiu ekranu startowego (Flash of Home Screen) */
html.route-game #screen-home,
html.route-teachers #screen-home {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    transform: scale(0.96) !important;
}
html.route-game #screen-map {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    transform: scale(1) !important;
}
html.route-teachers #screen-teachers {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    transform: scale(1) !important;
}

/* --- STRONA GŁÓWNA (HOME) --- */
.menu-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    z-index: 10;
}

.logo-box { 
    width: 100%; 
    max-width: 550px; 
    margin-bottom: 5px; 
}

.logo-box img { 
    width: 100%; 
    height: auto; 
}

.buttons {
    display: flex;
    flex-direction: row;
    justify-content: center;
    gap: 30px;
}

.btn-main {
    background: var(--granat); 
    color: white; 
    border: none; 
    padding: 18px 50px;
    font-weight: 700; 
    cursor: pointer; 
    border-radius: 4px; 
    text-transform: uppercase;
    transition: all 0.3s ease;
    min-width: 240px;
    font-size: 1.1rem;
}

.btn-main:hover {
    background: var(--niebieski2);
    box-shadow: 0 6px 20px rgba(1, 116, 148, 0.3);
    transform: translateY(-2px);
}

.btn-main.outline { 
    background: white; 
    border: 2px solid var(--granat); 
    color: var(--granat); 
}

.btn-main.outline:hover {
    background: var(--granat);
    color: white;
    box-shadow: 0 6px 20px rgba(0, 47, 115, 0.2);
    transform: translateY(-2px);
}

.btn-main.fail-btn {
    background: #d9534f;
}

.btn-main.fail-btn:hover {
    background: #c9302c;
    box-shadow: 0 6px 20px rgba(217, 83, 79, 0.3);
    transform: translateY(-2px);
}

#screen-home .menu-container {
    position: relative;
    top: -50px;
}

/* --- LOGOTYPY I FINANSOWANIE --- */
.home-funding {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 40px);
    max-width: 800px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    z-index: 10;
}

.funding-text {
    font-size: 0.72rem;
    color: #4b5563;
    line-height: 1.5;
    text-align: center;
    margin: 0;
    font-weight: 400;
    max-width: 650px;
}

.funding-logos {
    width: 100%;
    max-width: 380px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.funding-logos img {
    width: 100%;
    height: auto;
    display: block;
}

.home-links {
    margin-top: -8px; /* Zbliżenie do logotypów */
    display: flex;
    gap: 15px;
    font-size: 0.75rem;
    color: #4b5563;
}

.home-links a {
    color: #4b5563;
    text-decoration: none;
    transition: color 0.2s ease;
    font-weight: 500;
}

.home-links a:hover {
    color: var(--niebieski2);
    text-decoration: none;
}

.home-links .separator {
    color: #cbd5e1;
    user-select: none;
}

/* --- MAPA (SKALOWANIE DO WYSOKOŚCI) --- */
.map-wrapper { 
    width: 100%; 
    height: 100vh; 
    overflow-y: hidden; 
    overflow-x: auto;   
    display: flex; 
    justify-content: flex-start; 
    align-items: center; 
    background: transparent;
}

/* Styl podpowiedzi przewijania mapy */
.scroll-hint {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 200;
    pointer-events: none; /* Pozwala na interakcję pod elementem gdy zanika */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.scroll-hint.show {
    opacity: 1;
    visibility: visible;
}

.hint-content {
    background: rgba(0, 47, 115, 0.85);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    color: white;
    padding: 16px 24px;
    border-radius: 50px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.2);
    text-align: center;
}

.hint-icon {
    height: 36px;
    width: auto;
    animation: swipeAnim 1.5s infinite ease-in-out;
    display: inline-block;
}

.hint-text {
    font-size: 0.95rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

@keyframes swipeAnim {
    0% { transform: translateX(-15px); }
    50% { transform: translateX(15px); }
    100% { transform: translateX(-15px); }
}

.map-container {
    position: relative; 
    height: calc(100vh * var(--map-zoom, 1)); 
    width: calc(100vh * var(--map-zoom, 1) * (1920 / 1080));
    background-image: url('mapa.png'); 
    background-size: cover; 
    background-repeat: no-repeat; 
    background-position: center; 
    flex-shrink: 0;
    margin: 0 auto;
}

.map-controls { 
    position: absolute; 
    top: 35px; 
    left: 35px; 
    z-index: 100; 
    display: flex; 
    flex-direction: column;
    gap: 15px; 
}

.controls-row {
    display: flex;
    gap: 15px;
}

.control-btn { 
    padding: 11px 20px; 
    background: var(--granat); 
    color: white; 
    border: none; 
    cursor: pointer; 
    font-weight: bold; 
    border-radius: 4px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
    font-size: 0.9rem;
}

.control-btn:hover {
    background: var(--niebieski2);
    box-shadow: 0 6px 15px rgba(1, 116, 148, 0.3);
    transform: translateY(-2px);
}

.control-btn.reset-btn {
    background: #d9534f;
}

.control-btn.reset-btn:hover {
    background: #c9302c;
    box-shadow: 0 6px 15px rgba(217, 83, 79, 0.3);
    transform: translateY(-2px);
}

.pin { 
    position: absolute; 
    width: 2.2vh; 
    height: 2.2vh; 
    background: var(--niebieski); 
    border-radius: 50%; 
    border: 0.3vh solid white; 
    cursor: pointer; 
    transform: translate(-50%, -50%); 
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 0 0 rgba(2, 202, 191, 0);
}

.pin:not(.locked):hover {
    background: var(--niebieski2);
    transform: translate(-50%, -50%) scale(1.12);
    box-shadow: 0 0 1.5vh rgba(2, 202, 191, 0.6);
}

/* NOWOŚĆ: Szary styl dla zablokowanych miast */
.pin.locked {
    background: var(--grey-locked) !important;
    border-color: #ccc !important;
    cursor: not-allowed;
}

.pin-label { 
    position: absolute; 
    left: 2.8vh; 
    top: 50%; 
    transform: translateY(-50%); 
    background: var(--label-bg); 
    color: var(--granat); 
    padding: 0.5vh 1.2vh; 
    border-radius: 2vh; 
    font-size: 1.4vh; 
    font-weight: 700; 
    border: 0.1vh solid var(--niebieski2); 
    white-space: nowrap; 
    transition: all 0.3s ease;
}

.pin:not(.locked):hover .pin-label {
    background: var(--granat);
    color: white;
    border-color: var(--granat);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

/* Szara etykieta dla zablokowanych miast */
.pin.locked .pin-label {
    background: #f0f0f0 !important;
    color: #999 !important;
    border-color: #ccc !important;
    opacity: 0.8;
}

.pin.label-left .pin-label {
    left: auto;
    right: 2.8vh;
}

/* Blenda przewijania mapy w tle */
body.overlay-open .map-wrapper {
    overflow: hidden !important;
}

/* --- OVERLAY (ARTYKUŁ I QUIZ) --- */
.overlay { 
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%; 
    background: rgba(0, 47, 115, 0.85); 
    z-index: 9500; 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.overlay.open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.overlay-content { 
    background: white; 
    width: 90%; 
    max-width: 1100px; /* Nieco szerzej dla efektu gazety */
    max-height: 90vh; 
    border-radius: 12px; 
    padding: 60px; /* Duży padding dla oddechu */
    overflow-y: auto; 
    position: relative; 
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    transform: translateY(30px) scale(0.95);
    opacity: 0;
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
}

.overlay.open .overlay-content {
    transform: translateY(0) scale(1);
    opacity: 1;
}

.overlay.no-anim, .overlay.no-anim .overlay-content {
    transition: none !important;
}

/* PRZYCISKI ZAMKNIĘCIA X W HEADERACH */
.close-x, .close-x-quiz { 
    position: static; 
    font-size: 40px; 
    font-weight: 300;
    cursor: pointer; 
    border: none; 
    background: none; 
    color: var(--granat);
    line-height: 1;
    transition: transform 0.2s;
}
.close-x:hover, .close-x-quiz:hover { transform: scale(1.2); color: #d9534f; }

/* STRUKTURA ARTYKUŁU */
.article-layout h1 { 
    text-align: center; 
    color: var(--granat); 
    font-size: 3.5rem; /* Bardzo duży tytuł */
    margin-bottom: 40px; 
    font-weight: 700;
    border-bottom: 3px solid var(--granat);
    padding-bottom: 15px;
}

.article-layout p { 
    text-align: justify; /* Wyjustowanie tekstu */
    line-height: 1.8; 
    margin-bottom: 25px; 
    font-size: 1.15rem; 
    color: #222;
    hyphens: auto; /* Dzielenie wyrazów dla lepszego wyglądu gazety */
}

/* OBRAZKI W TEKŚCIE */
.article-img-inline-left { 
    float: left; 
    width: 32%; /* Zajmuje 32% szerokości tekstu */
    max-width: 280px;
    margin: 0 30px 20px 0; /* Odstęp z prawej i na dole */
    border-radius: 4px; 
    border: 1px solid #ddd;
    padding: 5px;
    background: #fff;
}

.article-img-inline-right { 
    float: right; 
    width: 32%; 
    max-width: 280px;
    margin: 0 0 20px 30px; /* Odstęp z lewej i na dole */
    border-radius: 4px; 
    border: 1px solid #ddd;
    padding: 5px;
    background: #fff;
}

/* STOPKA ARTYKUŁU - ODDALENIE PRZYCISKU */
.article-footer {
    clear: both; /* Czyści opływanie obrazków */
    margin-top: 60px; /* Duży odstęp od tekstu */
    padding-top: 30px;
    border-top: 1px dashed #ccc;
    text-align: center;
}

.hidden { display: none !important; }

/* NAV (STICKY HEADER DLA ARTYKUŁU I QUIZU) */
.article-nav, .quiz-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    border-bottom: 1px dashed #ddd;
    padding-bottom: 20px;
    position: sticky;
    top: -60px;
    background: white;
    z-index: 100;
    margin-left: -60px;
    margin-right: -60px;
    padding-left: 60px;
    padding-right: 60px;
    margin-top: -60px;
    padding-top: 30px;
}

.back-arrow {
    background: var(--niebieski);
    border: none;
    color: var(--granat);
    padding: 10px 22px;
    font-weight: 700;
    border-radius: 4px;
    cursor: pointer;
    text-transform: uppercase;
    font-size: 0.85rem;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.back-arrow:hover {
    background: var(--granat);
    color: white;
    transform: translateX(-3px);
    box-shadow: 0 4px 12px rgba(0, 47, 115, 0.2);
}

.quiz-layout h2 { 
    text-align: center; 
    color: var(--granat); 
    font-size: 3.5rem; /* Taki sam jak w artykule */
    margin-bottom: 40px; 
    font-weight: 700;
    border-bottom: 3px solid var(--granat);
    padding-bottom: 15px;
}

.q-box {
    margin-bottom: 40px;
    padding-bottom: 30px;
    border-bottom: 1px dashed #e2e8f0;
}

.q-box:last-of-type {
    border-bottom: none;
    margin-bottom: 20px;
    padding-bottom: 10px;
}

.q-box p {
    font-size: 1.3rem; /* Większe pytania */
    color: var(--granat);
    margin-bottom: 20px;
    line-height: 1.5;
}

.answers-grid { 
    display: grid; 
    grid-template-columns: 1fr 1fr; 
    gap: 15px; 
}

.ans-option { 
    border: 2px solid #e2e8f0; 
    padding: 16px 20px; 
    border-radius: 8px; 
    cursor: pointer; 
    background: #f8fafc; 
    text-align: left; 
    font-size: 1.05rem;
    font-weight: 500;
    line-height: 1.4;
    color: #334155;
    transition: all 0.25s ease;
}

.ans-option:hover {
    border-color: var(--niebieski2);
    background: #f0fdfa;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

.ans-option.selected { 
    border-color: var(--granat); 
    background: #eef7ff; 
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--granat);
    box-shadow: 0 4px 12px rgba(0, 47, 115, 0.1);
}

.ans-option.correct { 
    background: #ecfdf5 !important; 
    border-color: #10b981 !important; 
    color: #065f46 !important;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.ans-option.incorrect { 
    background: #fef2f2 !important; 
    border-color: #ef4444 !important; 
    color: #991b1b !important;
    font-weight: 700;
    letter-spacing: -0.02em;
}

#quiz-footer {
    margin-top: 40px;
    text-align: center;
    border-top: 1px dashed #ccc;
    padding-top: 30px;
}

#quiz-feedback {
    margin-bottom: 25px;
    padding: 15px 20px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 1.2rem;
    text-align: center;
}

#quiz-feedback.success {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #10b981;
}

#quiz-feedback.fail {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #ef4444;
}

/* --- SYSTEM STEPUSIA (SKALOWALNY) --- */
#stepus-container {
    position: fixed; 
    bottom: 0; 
    right: 0;  
    display: flex; 
    flex-direction: row; 
    align-items: flex-end; 
    pointer-events: none; 
    z-index: 9800; 
    transition: filter 0.3s ease, opacity 0.3s ease, z-index 0.3s ease;
}

/* Dim Stepuś and move below overlays only when confirm or alert dialogs (komunikaty) are open */
body:has(#overlay-confirm.open, #overlay-alert.open) #stepus-container {
    z-index: 4000 !important;
    filter: brightness(0.4);
    pointer-events: none;
}

body:has(#overlay-confirm.open, #overlay-alert.open) #stepus-character {
    z-index: 4000 !important;
}

/* For lightbox, keep Stepuś on top of the darkened background but dim him */
body:has(#overlay-lightbox.open) #stepus-container {
    z-index: 9800 !important;
    filter: brightness(0.3);
    pointer-events: none;
}

body:has(#overlay-lightbox.open) #stepus-character {
    z-index: 9800 !important;
}

.bubble-wrapper { 
    position: relative; 
    width: 25vh; 
    margin-right: -2vh; 
    margin-bottom: 22vh; 
}

#stepus-bubble { 
    width: 100%; 
    filter: drop-shadow(0 0 2px var(--granat));
}

#stepus-text {
    position: absolute; 
    top: 40%; 
    left: 50%; 
    transform: translate(-50%, -50%);
    width: 75%; 
    text-align: center; 
    font-size: 1.3vh; 
    font-weight: 700; 
    color: var(--granat);
    line-height: 1.2;
    white-space: pre-line;
}

#stepus-text.sharp {
    top: 48%;
}

#stepus-character { 
    height: 35vh; 
    width: auto; 
    display: block;
    transition: opacity 0.3s ease;
}

#top-right-logo {
    position: fixed;
    top: 35px;
    right: 35px;
    z-index: 4000;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

#top-right-logo img {
    height: 70px; /* Zwiększona wysokość na desktopie */
    width: auto;
    display: block;
    filter: drop-shadow(0 0 1px #ffffff) drop-shadow(0 0 1px #ffffff);
}

#top-right-logo:hover {
    transform: scale(1.05);
    opacity: 0.9;
}

.map-wrapper.zoomed {
    overflow-y: auto;
    align-items: flex-start;
}

.zoom-controls {
    position: absolute;
    bottom: 25px;
    left: 25px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.zoom-btn {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--white);
    border: 2px solid var(--granat);
    color: var(--granat);
    font-size: 1.5rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    user-select: none;
}

@media (hover: hover) {
    .zoom-btn:hover {
        background: var(--granat);
        color: var(--white);
        transform: scale(1.08);
        box-shadow: 0 6px 16px rgba(0, 47, 115, 0.3);
    }
}

.zoom-btn:active {
    background: var(--granat);
    color: var(--white);
    transform: scale(0.95);
}


.zoom-btn:disabled {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: #94a3b8;
    cursor: not-allowed;
    box-shadow: none;
    transform: none !important;
    filter: grayscale(1);
    opacity: 0.5;
}

.article-section {
    clear: both;
    display: flow-root;
    margin-top: 35px;
}
.article-section:first-of-type {
    margin-top: 0;
}

.article-subheading {
    font-size: 1.6rem;
    color: var(--granat);
    margin-top: 0;
    margin-bottom: 15px;
    font-weight: 700;
}

.did-you-know-box {
    background: #f0fdf4;
    border-left: 4px solid #10b981;
    padding: 15px 20px;
    margin: 25px 0;
    border-radius: 4px;
    font-size: 1.05rem;
    line-height: 1.6;
    clear: both;
}

.did-you-know-box strong {
    color: #065f46;
    display: block;
    margin-bottom: 5px;
}

.did-you-know-box p {
    margin-bottom: 0 !important;
    text-align: justify;
    line-height: 1.6;
    font-size: 1.05rem !important;
}

/* MOBILKI */
@media (max-width: 1024px) {
    :root {
        --bubble-height: 95px;
    }
    body {
        display: flex;
        flex-direction: column;
        height: 100dvh;
        overflow: hidden;
    }
    
    #app-content {
        flex: 1;
        min-height: 0;
        position: relative;
        width: 100%;
        overflow: hidden;
    }

    .screen {
        height: 100% !important;
        width: 100%;
    }
    .pin::after {
        content: '';
        position: absolute;
        top: -15px;
        bottom: -15px;
        left: -15px;
        right: -15px;
        border-radius: 50%;
    }
    .map-wrapper {
        height: 100%;
    }
    .map-container {
        height: calc(100% * var(--map-zoom, 1));
        width: calc((100dvh - var(--bubble-height, 95px)) * var(--map-zoom, 1) * (1920 / 1080));
    }

    .buttons { flex-direction: column; gap: 10px; }
    .btn-main { min-width: 180px; padding: 12px 20px; font-size: 0.8rem; }
    
    #stepus-container {
        position: relative;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        max-width: 100%;
        z-index: 9800;
    }

    #stepus-character { 
        position: absolute;
        bottom: 100%;
        right: 0px;
        height: 24vh; 
        width: auto;
        pointer-events: none;
        z-index: 7000;
    }

    .bubble-wrapper { 
        width: 100%; 
        height: 95px; /* Stała wysokość zapobiega skakaniu mapy przy zmianie tekstu */
        margin: 0;
        background: white;
        border: none;
        border-top: 3px solid var(--granat);
        border-radius: 0;
        padding: 10px 15px;
        box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.15);
        display: flex;
        align-items: center;
        justify-content: center;
        box-sizing: border-box;
    }

    #stepus-bubble { 
        display: none; 
    }

    #stepus-text {
        position: static;
        transform: none;
        width: 100%;
        font-size: 0.9rem;
        color: var(--granat);
        line-height: 1.35;
        text-align: center;
    }

    .logo-box {
        max-width: 220px; /* decreased from 300px to save vertical space on mobile home */
        margin-bottom: 2px;
    }

    .map-controls {
        flex-direction: column;
        gap: 8px;
        top: 15px;
        left: 15px;
    }

    .controls-row {
        flex-direction: column;
        gap: 8px;
    }

    .control-btn {
        padding: 8px 12px;
        font-size: 0.8rem;
    }

    .article-img-inline-left, .article-img-inline-right {
        float: none;
        width: 100%;
        max-width: none;
        margin: 15px 0;
        order: -1;
    }
    .answers-grid { grid-template-columns: 1fr; }
    
    #top-right-logo {
        top: 15px;
        right: 15px;
    }

    #top-right-logo img {
        height: 48px; /* Zwiększone na komórkach */
    }

    /* ULEPSZENIA DLA MOBILEK (ARTYKUŁ I QUIZ) */
    .overlay {
        position: fixed;
        align-items: center;
        height: 100% !important;
        background: rgba(0, 47, 115, 0.85); 
        z-index: 9500; 
        display: flex; 
        justify-content: center;
        padding: 0;
    }

    #overlay-article, #overlay-quiz, #overlay-congrats {
        align-items: flex-start;
        padding: 20px 15px 0 15px;
    }

    .overlay-content {
        padding: 20px;
        max-height: 90%;
        width: 88%;
    }

    #overlay-article .overlay-content,
    #overlay-quiz .overlay-content,
    #overlay-congrats .overlay-content {
        width: 90%;
        max-height: calc(100dvh - var(--bubble-height, 95px) - 40px);
    }

    .article-layout h1 {
        font-size: 1.8rem; /* Zmniejszony tytuł artykułu */
        margin-bottom: 20px;
    }

    .article-layout p {
        font-size: 1.05rem; /* Zwiększona czcionka artykułu dla lepszej czytelności */
        line-height: 1.6;
        margin-bottom: 15px;
    }

    .quiz-layout h2 {
        font-size: 1.8rem; /* Zmniejszony tytuł quizu */
        margin-bottom: 20px;
    }

    .article-layout .article-nav, .quiz-layout .quiz-nav {
        position: sticky;
        top: -20px;
        margin-left: -20px;
        margin-right: -20px;
        padding-left: 20px;
        padding-right: 20px;
        margin-top: -20px;
        padding-top: 15px;
        padding-bottom: 15px;
    }

    .back-arrow {
        font-size: 0.75rem; /* Zmniejszony przycisk powrotu */
        padding: 6px 12px;
    }

    .close-x, .close-x-quiz {
        font-size: 28px; /* Odpowiedni rozmiar X na komórkach */
    }

    .btn-main {
        font-size: 1.05rem; /* Większe, łatwe do kliknięcia przyciski */
        padding: 14px 28px;
        min-width: 200px;
        width: 100%;
        max-width: 320px;
        margin: 0 auto;
        display: block;
    }

    .zoom-controls {
        bottom: 15px;
        left: 15px;
        gap: 8px;
    }

    .zoom-btn {
        width: 48px;
        height: 48px;
        font-size: 1.3rem;
    }

    .article-section {
        display: flex;
        flex-direction: column;
        margin-top: 25px;
    }
    .article-section:first-of-type {
        margin-top: 0;
    }

    .article-subheading {
        font-size: 1.3rem;
        margin-top: 0;
        margin-bottom: 10px;
        order: -2;
    }

    .did-you-know-box {
        padding: 12px 16px;
        margin: 20px 0;
        font-size: 0.95rem;
    }

    .did-you-know-box p {
        font-size: 0.95rem !important;
    }

    #screen-home.funding-active {
        z-index: 8000;
    }
    
    #stepus-container.funding-active #stepus-character {
        opacity: 0.15;
    }
    
    #screen-home .menu-container {
        top: -30px; /* shifted slightly up on mobile to avoid overlapping bottom funding text */
    }

    .home-funding {
        position: absolute;
        bottom: 8px;
        left: 50%;
        transform: translateX(-50%);
        width: calc(100% - 30px);
        max-width: 280px;
        gap: 4px;
        z-index: 10;
    }
    
    .home-funding.active {
        transform: translate(-50%, 0); /* override transform if needed, or keep same */
        z-index: 8000;
    }
    
    .funding-text {
        font-size: 0.52rem;
        line-height: 1.4;
    }
    
    .funding-logos {
        max-width: 160px;
    }

    .home-links {
        font-size: 0.58rem;
        gap: 10px;
        margin-top: -5px;
    }

    .cert-btn-group {
        flex-direction: column;
        align-items: center;
        gap: 10px;
        width: 100%;
        margin-top: 10px;
    }
    .cert-btn {
        min-width: 0 !important;
        width: 100% !important;
        max-width: 320px;
        margin: 0 auto !important;
    }
}

/* EKRAN KOŃCOWY - GRATULACJE */
.congrats-layout {
    text-align: center;
    max-width: 540px !important;
    padding: 50px 30px 40px 30px !important;
    background: white !important;
    border: 4px solid var(--granat) !important;
    box-shadow: 0 15px 40px rgba(0, 47, 108, 0.15), 0 10px 25px rgba(0, 0, 0, 0.15) !important;
}
.close-congrats {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 32px;
}
.congrats-layout h2 {
    font-size: 2.2rem;
    color: #ff9f00; /* Pozostaje żółte/gratulacyjne */
    margin: 0 0 5px 0;
    font-weight: 700;
    letter-spacing: 2px;
}
.congrats-layout h3 {
    font-size: 1.25rem;
    color: var(--granat);
    margin: 0 0 20px 0;
    font-weight: 400;
    line-height: 1.4;
}
.congrats-img-wrapper {
    margin: 20px auto;
    width: 130px;
    height: 130px;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(0, 47, 108, 0.05);
    border-radius: 50%;
    border: 2px dashed var(--granat);
    padding: 10px;
    animation: congratsPulseNavy 2s infinite ease-in-out;
}
.congrats-image {
    height: 100%;
    width: auto;
    object-fit: contain;
}
.congrats-desc {
    font-size: 1rem;
    color: var(--ciemny-szary);
    line-height: 1.6;
    margin: 15px 0 25px 0;
}
.restart-btn {
    background: var(--granat) !important;
    color: white !important;
    border: none !important;
    font-weight: 700 !important;
    box-shadow: 0 4px 15px rgba(0, 47, 108, 0.2) !important;
    font-size: 1.1rem !important;
    padding: 14px 40px !important;
    transition: transform 0.2s, box-shadow 0.2s !important;
}
.restart-btn:hover {
    background: var(--niebieski2) !important;
    transform: translateY(-2px) scale(1.03);
    box-shadow: 0 6px 20px rgba(1, 116, 148, 0.4) !important;
}
.restart-btn:active {
    transform: translateY(1px);
}

@keyframes congratsStarsPop {
    0% { transform: scale(0); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}
@keyframes congratsPulseNavy {
    0% { box-shadow: 0 0 0 0 rgba(0, 47, 108, 0.2); }
    70% { box-shadow: 0 0 0 15px rgba(0, 47, 108, 0); }
    100% { box-shadow: 0 0 0 0 rgba(0, 47, 108, 0); }
}

/* STYLOWANIE FORMULARZA CERTYFIKATU */
.cert-step {
    margin-top: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    animation: congratsStarsPop 0.4s ease;
}
.cert-step.hidden {
    display: none !important;
}
.cert-step-desc {
    font-size: 0.95rem;
    color: var(--ciemny-szary);
    margin-bottom: 12px;
}
.cert-input {
    width: 90%;
    max-width: 320px;
    padding: 12px 18px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1rem;
    margin-bottom: 12px;
    outline: none;
    text-align: center;
    color: var(--granat);
    font-family: 'Open Sans', sans-serif;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.cert-input:focus {
    border-color: #ff9f00;
    box-shadow: 0 0 0 3px rgba(255, 159, 0, 0.2);
}
.cert-btn-group {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    justify-content: center;
    flex-wrap: wrap;
    width: 100%;
}
.cert-btn {
    padding: 10px 30px !important;
    font-size: 0.95rem !important;
    margin-top: 5px;
    min-width: 210px !important; /* Override default 240px min-width to allow side-by-side placement inside congrats container */
}
.cert-success-icon {
    font-size: 40px;
    margin-bottom: 10px;
    animation: congratsStarsPop 0.6s ease;
}
.cert-success-desc {
    font-size: 1.05rem;
    color: #27ae60;
    font-weight: 700;
    margin: 5px 0;
    line-height: 1.5;
    max-width: 400px;
}

.outline-btn {
    background: transparent !important;
    border: 2px solid var(--granat) !important;
    color: var(--granat) !important;
    box-shadow: none !important;
}
.outline-btn:hover {
    background: rgba(0, 47, 108, 0.05) !important;
    transform: translateY(-2px) scale(1.03);
}

.cert-privacy-note {
    font-size: 0.72rem;
    color: #718096;
    max-width: 340px;
    line-height: 1.4;
    text-align: center;
    margin-top: 12px;
}

/* --- LIGHTBOX (PODGLĄD OBRAZKA W ARTYKULE) --- */
.lightbox-overlay {
    background: transparent !important; /* Przezroczyste tło głównego kontenera */
    z-index: 9950 !important; /* Wyżej niż Stepuś (9800), aby zdjęcie i przycisk zamknięcia były nad nim */
}

/* Ciemne tło lightboxa umieszczone pod Stepusiem (9800), ale nad resztą strony */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 20, 50, 0.9); /* Ciemnoniebieskie eleganckie tło */
    z-index: 9500;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

body:has(#overlay-lightbox.open)::after {
    opacity: 1;
    visibility: visible;
}

.lightbox-close {
    position: absolute !important;
    top: 25px;
    right: 35px;
    color: white !important;
    font-size: 55px !important;
    z-index: 9610;
    line-height: 0.8 !important;
}
.lightbox-close:hover {
    color: #ff4d4d !important;
    transform: scale(1.2);
}

.lightbox-content {
    max-width: 90%;
    max-height: 85vh;
    display: flex;
    justify-content: center;
    align-items: center;
    transform: scale(0.9);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.1, 0.8, 0.25, 1), opacity 0.3s ease;
}

.lightbox-overlay.open .lightbox-content {
    transform: scale(1);
    opacity: 1;
}

.lightbox-content img {
    max-width: 100%;
    max-height: 85vh;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
    border: 4px solid white;
    background: white;
}

/* Klikalność obrazków w artykule */
.article-img-inline-left, .article-img-inline-right {
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}
.article-img-inline-left:hover, .article-img-inline-right:hover {
    transform: scale(1.03);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    filter: brightness(1.05);
}

/* --- INLINE ERROR MESSAGES & CUSTOM OVERLAYS --- */
.cert-error-msg {
    color: #e53e3e; 
    background: #fff5f5; 
    border: 1px solid #fed7d7;
    border-radius: 6px;
    padding: 10px 15px;
    font-size: 0.88rem;
    margin-bottom: 12px;
    text-align: left;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: slideDownFade 0.25s ease-out;
}
@keyframes slideDownFade {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.confirm-layout, .alert-layout {
    background: white;
    width: 90%;
    max-width: 420px !important;
    padding: 35px !important;
    border-radius: 12px;
    border: 4px solid var(--granat);
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    transform: translateY(30px) scale(0.95);
    opacity: 0;
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
}

.overlay.open .confirm-layout, .overlay.open .alert-layout {
    transform: translateY(0) scale(1);
    opacity: 1;
}

.confirm-heading, .alert-heading {
    font-size: 1.35rem;
    color: var(--granat);
    margin-top: 0;
    margin-bottom: 15px;
    font-weight: bold;
}

.confirm-desc, .alert-desc {
    font-size: 1.05rem;
    color: #4a5568;
    margin-bottom: 25px;
    line-height: 1.5;
}

.confirm-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
}

.confirm-buttons .btn-main, .alert-layout .btn-main {
    padding: 10px 25px;
    font-size: 0.95rem;
    margin: 0;
    min-width: 130px; /* Override the default min-width of 240px to prevent card overflow */
}

/* --- BANER COOKIE --- */
.cookie-banner {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 9900;
    background: var(--white);
    border: 3px solid var(--granat);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    max-width: 450px;
    width: calc(100% - 40px);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s ease;
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
}

.cookie-banner.hidden {
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    pointer-events: none;
}

.cookie-content {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.cookie-content p {
    font-size: 0.9rem;
    color: #4a5568;
    line-height: 1.45;
    margin: 0;
}

.cookie-content p a {
    color: var(--niebieski2);
    font-weight: 700;
    text-decoration: underline;
    transition: color 0.2s ease;
}

.cookie-content p a:hover {
    color: var(--niebieski);
}

.cookie-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.cookie-buttons .btn-main {
    padding: 8px 16px;
    font-size: 0.85rem;
    min-width: auto;
    margin: 0;
}

/* RWD dla Banera Cookie */
@media (max-width: 600px) {
    .cookie-banner {
        bottom: 15px;
        left: 15px;
        width: calc(100% - 30px);
        padding: 15px;
        text-align: center;
    }
    .cookie-buttons {
        flex-direction: column;
        gap: 8px;
        align-items: center;
    }
    .cookie-buttons .btn-main {
        width: 100%;
        max-width: 280px;
        text-align: center;
        align-self: center;
    }
}

/* --- DLA NAUCZYCIELI - STRONA GŁÓWNA --- */
.teachers-btn-wrapper {
    margin-top: 25px;
    width: 100%;
    display: flex;
    justify-content: center;
}

.btn-teachers-home {
    width: 100%;
    max-width: 510px; /* aligns with the two home buttons above (240px + 240px + 30px gap) */
    font-size: 0.9rem !important;
    letter-spacing: 0.5px;
    border-color: var(--granat) !important;
    white-space: normal;
    line-height: 1.3;
    padding: 14px 20px !important;
}

/* Ukrycie logo w prawym górnym rogu na podstronie nauczycieli */
html.route-teachers #top-right-logo {
    display: none !important;
}

/* --- DLA NAUCZYCIELI - EKRAN --- */
#screen-teachers {
    display: flex !important; /* flex layout on desktop for centering */
    flex-direction: column;
    align-items: center;
    justify-content: flex-start !important; /* top-aligned flex to allow normal overflow scrolling */
    overflow-y: auto !important; /* enable scrolling for the entire screen */
    -webkit-overflow-scrolling: touch; /* smooth scrolling on iOS Safari */
    height: 100%;
    width: 100%;
    padding: 0 !important; /* spacing handled by flex spacers */
}

#screen-teachers::before,
#screen-teachers::after {
    content: '';
    flex-grow: 1; /* spacer grows to center card vertically if there is space */
    min-height: 60px; /* guarantees at least 60px spacing at top and bottom */
    flex-shrink: 0;
}

.teachers-container {
    background: white;
    width: 84%; /* decreased from 90% for larger margins */
    max-width: 1000px;
    max-height: none !important; /* let container expand fully */
    flex-shrink: 0; /* prevent card from shrinking */
    margin: 0 auto !important; /* horizontal centering, vertical margins handled by spacers */
    border-radius: 12px;
    border: 4px solid var(--granat);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 10;
}

.teachers-header {
    display: flex;
    flex-direction: column; /* stack button and title vertically */
    align-items: flex-start; /* align both elements to the left */
    justify-content: center;
    border-bottom: 2px solid var(--granat);
    padding: 30px 40px 20px 40px; /* reduced bottom padding */
    background: #f8fafc;
    gap: 12px; /* slightly smaller gap */
}

.teachers-header .back-btn {
    position: static !important; /* reset absolute positioning from before */
    width: auto !important;
    min-width: 130px;
    padding: 10px 20px !important;
    text-align: center;
}

.teachers-title {
    font-size: 1.45rem; /* decreased from 1.6rem for slightly lower/smaller look */
    color: var(--granat);
    font-weight: 700;
    margin: 0;
    text-align: left; /* align title text to the left */
}

.teachers-scroll-content {
    overflow-y: visible !important; /* no internal scroll */
    padding: 30px 40px 40px 40px;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.teachers-body {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.teachers-p {
    font-size: 1.12rem; /* increased from 1rem */
    color: #334155;
    line-height: 1.65;
    text-align: justify;
}

.teachers-p.highlight {
    font-weight: 700;
    font-size: 1.25rem; /* increased from 1.1rem */
    color: var(--granat);
}

.teachers-signature {
    font-weight: 700;
    font-size: 1rem;
    color: var(--granat);
    margin-top: 10px;
    text-align: right;
}

/* --- SCENARIUSZE DO POBRANIA --- */
.scenarios-section {
    border-top: 2px dashed #cbd5e1;
    padding-top: 30px;
}

.scenarios-heading {
    font-size: 1.3rem;
    color: var(--granat);
    font-weight: 700;
    margin-bottom: 20px;
    text-align: center;
}

.scenarios-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
}

.scenario-card {
    background: #f8fafc;
    border: 2px solid #cbd5e1;
    border-radius: 8px;
    padding: 25px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    transition: all 0.3s ease;
    gap: 15px;
}

.scenario-card:hover {
    border-color: var(--niebieski2);
    box-shadow: 0 4px 15px rgba(2, 202, 191, 0.15);
    transform: translateY(-2px);
}

.scenario-icon-wrapper {
    background: var(--label-bg);
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.scenario-icon {
    font-size: 28px;
}

.scenario-details {
    flex-grow: 1;
}

.scenario-title {
    font-size: 1.1rem;
    color: var(--granat);
    font-weight: 700;
    margin-bottom: 8px;
}

.scenario-desc {
    font-size: 0.85rem;
    color: #64748b;
    line-height: 1.4;
}

.scenario-actions {
    display: flex;
    gap: 10px;
    width: 100%;
    justify-content: center;
    margin-top: 10px;
}

.scenario-action-btn {
    flex: 1;
    min-width: auto !important;
    padding: 10px 15px !important;
    font-size: 0.85rem !important;
    text-align: center;
    text-decoration: none;
    display: inline-flex;
    justify-content: center;
    align-items: center;
}

/* --- RESPONSIVELOUT / RWD --- */
@media (max-width: 1024px) {
    .btn-teachers-home {
        font-size: 0.74rem !important;
        min-width: auto !important;
        width: 172px;
        max-width: 100%;
        padding: 11px 12px !important;
    }
    .teachers-btn-wrapper {
        margin-top: 15px;
        padding: 0;
    }
    #screen-teachers {
        display: block !important; /* block layout to prevent flexbox scrolling bugs */
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch; /* smooth scrolling on iOS Safari */
        height: 100%;
        width: 100%;
        padding: 0 !important; /* override desktop padding to remove large gap */
    }
    #screen-teachers::before,
    #screen-teachers::after {
        display: none !important; /* hide flex spacers on mobile */
    }
    .teachers-container {
        width: 90%;
        max-height: none !important;
        margin: 20px auto !important; /* reduce mobile vertical margin to 20px */
    }
    .teachers-header {
        flex-direction: column;
        align-items: flex-start; /* align button and title to the left */
        padding: 25px 20px 15px 20px !important; /* reduced bottom padding */
        gap: 10px; /* slightly smaller gap */
        position: relative;
    }
    .teachers-title {
        font-size: 1.15rem; /* decreased from 1.25rem for slightly lower/smaller look */
        text-align: left; /* align title text to the left */
    }
    .teachers-header .back-btn {
        position: static !important;
        width: auto !important;
        min-width: 120px !important;
        padding: 8px 16px !important;
        text-align: center;
        margin-top: 0 !important; /* reset margin-top */
    }
    .teachers-scroll-content {
        padding: 20px 15px 30px 15px;
        gap: 20px;
        overflow-y: visible !important; /* no internal scroll */
    }
    .teachers-p {
        font-size: 0.95rem; /* increased from 0.85rem */
        line-height: 1.5;
        text-align: left;
    }
    .teachers-p.highlight {
        font-size: 1.05rem; /* increased from 0.95rem */
    }
    .teachers-signature {
        font-size: 0.95rem; /* increased from 0.85rem */
    }
    .scenarios-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    .scenario-card {
        padding: 20px 15px;
    }
    .scenario-title {
        font-size: 1rem;
    }
    .scenario-desc {
        font-size: 0.75rem;
    }
    .scenario-actions {
        flex-direction: column;
        gap: 8px;
    }
    .scenario-action-btn {
        width: 100%;
    }
}

/* --- TABLET SPECIFIC OVERRIDES (769px - 1024px) --- */
@media (min-width: 769px) and (max-width: 1024px) {
    .logo-box {
        max-width: 360px !important;
        margin-bottom: 15px !important;
    }
    #screen-home .menu-container {
        top: 0 !important;
    }
    .btn-teachers-home {
        font-size: 0.88rem !important;
        width: auto !important;
        min-width: 260px !important;
        max-width: 90% !important;
        padding: 13px 25px !important;
    }
    .teachers-btn-wrapper {
        margin-top: 20px !important;
    }
}