:root {
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
}

button,
input,
select,
textarea {
    font-family: 'Noto Sans', sans-serif;
}

html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    margin: 0;
    padding: 0;
    min-height: 100%;
    min-height: 100dvh;
    min-height: -webkit-fill-available;
    background-color: #1a0a2e;
    background: linear-gradient(135deg, #000000 0%, #764ba2 100%);
    background-attachment: fixed;
    background-size: cover;
    background-repeat: no-repeat;
}

body {
    font-family: 'Noto Sans', sans-serif;
    margin: 0;
    padding: 0;
    min-height: 100vh;
    min-height: 100dvh;
    min-height: -webkit-fill-available;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.8s ease;
    overflow-x: hidden;
    overflow-y: auto;
    color: white;
    background: transparent;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* Strony - wrapper przezroczysty, centruje zawartość */
.page {
    display: none;
    animation: fadeIn 0.5s ease-in;
    width: 100%;
}

.page.active {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh;
}

/* Container */
.container {
    width: 100%;
    max-width: 600px;
    padding: 20px;
    padding-top: calc(20px + env(safe-area-inset-top));
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
    padding-left: calc(20px + env(safe-area-inset-left));
    padding-right: calc(20px + env(safe-area-inset-right));
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== Strona główna ===== */
#homePage {
    text-align: center;
}

#homePage h1 {
    color: white;
    font-size: 1.6rem;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.subtitle {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1rem;
    margin-bottom: 30px;
}

.buttons-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

.difficulty-btn {
    padding: 24px 20px;
    font-size: 1rem;
    font-weight: 600;
    color: white;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid white;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.difficulty-btn:hover {
    background: rgba(255, 255, 255, 0.4);
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.difficulty-btn:active {
    transform: translateY(-2px);
}

/* ===== Strona quizu ===== */
/* Karta quizu — styl na .container, nie na .page */
#quizPage .container {
    background: #131110;
    border-radius: 15px;
    padding: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 600px;
    width: calc(100% - 32px);
    margin: 0 auto;
}

.quiz-header {
    margin-bottom: 14px;
}

.btn-back {
    background: none;
    border: none;
    color: #667eea;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    padding: 5px 0;
    margin-bottom: 10px;
    transition: color 0.3s ease;
}

.btn-back:hover {
    color: #764ba2;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #5D534E;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    width: 33.33%;
    transition: width 0.3s ease;
}

.question-counter {
    text-align: right;
    color: white;
    font-size: 0.9rem;
}

#questionText {
    color: white;
    margin-bottom: 14px;
    font-size: 1rem;
    line-height: 1.4;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: none;
    -webkit-hyphens: none;
}

.answers-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.answer-btn {
    display: flex;
    align-items: center;
    padding: 12px 14px;
    background: #131110;
    border: 2px solid #5D534E;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    font-size: 0.9rem;
    min-height: 44px;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.answer-btn:active {
    background: #5D534E;
    border-color: #667eea;
}

.answer-btn.disabled {
    cursor: not-allowed;
    opacity: 0.7;
}

.answer-letter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 50%;
    margin-right: 12px;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.answer-text {
    color: white;
    font-weight: 500;
}

.answer-btn.selected {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: #667eea;
}

.answer-btn.selected .answer-letter {
    background: white;
    color: #667eea;
}

/* ===== Strona wyniku ===== */
.result-card {
    background: #131110;
    border-radius: 20px;
    padding: 30px 20px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 450px;
    width: 100%;
    margin: 0 auto;
    animation: scaleIn 0.5s ease;
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.result-emoji {
    font-size: 3.5rem;
    margin-bottom: 16px;
}

.result-title {
    font-size: 1.4rem;
    color: white;
    margin-bottom: 12px;
    animation: slideUp 0.6s ease 0.2s both;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.result-description {
    font-size: 0.95rem;
    color: white;
    line-height: 1.6;
    margin-bottom: 24px;
    animation: slideUp 0.6s ease 0.4s both;
}

.btn-restart {
    padding: 14px 36px;
    font-size: 1rem;
    font-weight: 600;
    color: white;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    animation: slideUp 0.6s ease 0.6s both;
    min-height: 48px;
}

.btn-restart:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.4);
}

.btn-next {
    padding: 12px 36px;
    font-size: 1rem;
    font-weight: 600;
    color: white;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 48px;
}

.btn-next:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.4);
}

.btn-next:active {
    transform: translateY(-1px);
}

/* ===== Responsywność ===== */

/* 375px+ (iPhone SE, iPhone 8) */
@media (min-width: 375px) {
    #homePage h1 {
        font-size: 1.8rem;
    }

    .subtitle {
        font-size: 1.1rem;
    }

    #quizPage .container {
        padding: 24px;
    }

    #questionText {
        font-size: 1.05rem;
    }

    .answer-btn {
        padding: 15px 18px;
        font-size: 1rem;
    }

    .answer-letter {
        width: 35px;
        height: 35px;
        font-size: 0.9rem;
    }

    .result-card {
        padding: 36px 24px;
    }

    .result-emoji {
        font-size: 4rem;
    }

    .result-title {
        font-size: 1.5rem;
    }

    .result-description {
        font-size: 1rem;
    }
}

/* 430px+ (iPhone 12/13/14/15) */
@media (min-width: 430px) {
    #homePage h1 {
        font-size: 2rem;
    }

    .difficulty-btn {
        padding: 28px 20px;
        font-size: 1.1rem;
    }

    #quizPage .container {
        padding: 28px;
    }

    .quiz-header {
        margin-bottom: 25px;
    }

    #questionText {
        font-size: 1.15rem;
        margin-bottom: 25px;
    }

    .result-card {
        padding: 40px 28px;
    }
}

/* 768px+ (iPad Mini, iPad) */
@media (min-width: 768px) {
    .container {
        padding: 24px;
        padding-top: calc(24px + env(safe-area-inset-top));
        padding-bottom: calc(24px + env(safe-area-inset-bottom));
        padding-left: calc(24px + env(safe-area-inset-left));
        padding-right: calc(24px + env(safe-area-inset-right));
    }

    #homePage h1 {
        font-size: 2.5rem;
    }

    .subtitle {
        font-size: 1.2rem;
        margin-bottom: 40px;
    }

    .buttons-grid {
        grid-template-columns: 1fr 1fr;
        gap: 20px;
    }

    .difficulty-btn {
        padding: 35px 24px;
        font-size: 1.15rem;
        border-radius: 14px;
    }

    #quizPage .container {
        padding: 36px;
    }

    .quiz-header {
        margin-bottom: 30px;
    }

    #questionText {
        font-size: 1.3rem;
        margin-bottom: 30px;
    }

    .answers-container {
        gap: 14px;
    }

    .answer-btn {
        padding: 18px 22px;
        font-size: 1.05rem;
        border-radius: 12px;
    }

    .answer-letter {
        width: 40px;
        height: 40px;
        margin-right: 16px;
        font-size: 1rem;
    }

    .result-card {
        padding: 50px 40px;
        border-radius: 24px;
    }

    .result-emoji {
        font-size: 5rem;
        margin-bottom: 24px;
    }

    .result-title {
        font-size: 2rem;
        margin-bottom: 16px;
    }

    .result-description {
        font-size: 1.15rem;
        margin-bottom: 32px;
    }

    .btn-restart {
        padding: 16px 44px;
        font-size: 1.05rem;
    }

    .btn-next {
        padding: 14px 44px;
        font-size: 1.05rem;
    }
}

/* 1024px+ (iPad Pro 11" i większe) */
@media (min-width: 1024px) {
    #homePage h1 {
        font-size: 3rem;
    }

    .difficulty-btn {
        padding: 40px 28px;
        font-size: 1.2rem;
    }

    #quizPage .container {
        padding: 40px;
    }

    #questionText {
        font-size: 1.4rem;
    }

    .answer-btn {
        padding: 20px 24px;
        font-size: 1.1rem;
    }

    .result-emoji {
        font-size: 6rem;
    }

    .result-title {
        font-size: 2.2rem;
    }

    .result-description {
        font-size: 1.2rem;
    }
}

/* Landscape na telefonach */
@media (max-height: 500px) and (orientation: landscape) {
    body {
        align-items: flex-start;
        padding-top: 10px;
    }

    .page.active {
        align-items: flex-start;
        min-height: auto;
    }

    #quizPage .container {
        padding: 16px;
    }

    .quiz-header {
        margin-bottom: 10px;
    }

    #questionText {
        margin-bottom: 12px;
        font-size: 1rem;
    }

    .answers-container {
        gap: 6px;
    }

    .answer-btn {
        padding: 10px 14px;
    }

    .result-card {
        padding: 20px 16px;
    }

    .result-emoji {
        font-size: 2.5rem;
        margin-bottom: 8px;
    }

    .result-title {
        font-size: 1.2rem;
        margin-bottom: 6px;
    }

    .result-description {
        font-size: 0.85rem;
        margin-bottom: 12px;
    }
}