:root {
    --bg: #1a1c19;
    --bg-deep: #141614;
    --surface: #2c312c;
    --surface-2: #353b34;
    --text: #f2f4f1;
    --muted: #9aa39a;
    --accent: #70db97;
    --accent-soft: rgba(112, 219, 151, 0.18);
    --border: rgba(255, 255, 255, 0.06);
    --card: #252925;
    --nav: #1f241f;
    --shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}

body.light-theme {
    --bg: #f3f5f2;
    --bg-deep: #e8ebe6;
    --surface: #ffffff;
    --surface-2: #f0f3ef;
    --text: #142016;
    --muted: #5b675c;
    --accent: #1f9d57;
    --accent-soft: rgba(31, 157, 87, 0.14);
    --border: rgba(0, 0, 0, 0.08);
    --card: #ffffff;
    --nav: #ffffff;
    --shadow: 0 8px 24px rgba(20, 32, 22, 0.1);
}

* { box-sizing: border-box; }

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    padding-bottom: 78px;
}

button, input, select { font: inherit; }
button { border: 0; outline: none; background: none; color: inherit; cursor: pointer; }

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ===== Professional top bar ===== */
.app-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 14px 10px;
}

.app-header-text {
    min-width: 0;
    flex: 1;
}

.app-header-text h1 {
    margin: 0;
    font-size: 1.45rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.app-header-text p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 0.84rem;
    line-height: 1.35;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.header-icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--surface);
    border: 1px solid var(--border);
    display: grid;
    place-items: center;
    font-size: 1.05rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.15);
    transition: transform 0.15s ease, border-color 0.15s ease;
}

.header-icon-btn:active {
    transform: scale(0.96);
}

.settings-panel {
    position: relative;
    z-index: 1200;
}

.settings-drawer {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: min(280px, calc(100vw - 24px));
    display: grid;
    gap: 14px;
    padding: 16px;
    border-radius: 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    transform: translateY(-6px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: 0.2s ease;
}

.settings-panel.open .settings-drawer {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.settings-drawer h2 { margin: 0; font-size: 1.05rem; }
.settings-group { display: grid; gap: 8px; }
.settings-label { color: var(--muted); font-size: 0.82rem; }

.segmented-control {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.settings-option {
    min-height: 40px;
    border-radius: 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
}

.settings-option.active {
    background: var(--accent);
    color: #0c1510;
    border-color: var(--accent);
    font-weight: 700;
}

#languageSelect {
    width: 100%;
    background: var(--bg-deep);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
}

/* ===== Content ===== */
.app-content {
    padding: 4px 14px 20px;
}

.search-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface);
    border-radius: 999px;
    padding: 12px 16px;
    border: 1px solid var(--border);
    margin-bottom: 16px;
}

.search-icon { opacity: 0.55; font-size: 0.95rem; }

#searchInput {
    flex: 1;
    border: 0;
    outline: none;
    background: transparent;
    color: var(--text);
    font-size: 16px;
    min-width: 0;
}

#searchInput::placeholder { color: var(--muted); }

.region-label {
    color: var(--muted);
    font-size: 0.82rem;
    margin-bottom: 8px;
}

.region-chips {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 6px;
    margin-bottom: 12px;
    scrollbar-width: none;
}

.region-chips::-webkit-scrollbar { display: none; }

.chip {
    flex-shrink: 0;
    padding: 8px 14px;
    border-radius: 999px;
    background: var(--surface);
    color: var(--text);
    font-size: 0.88rem;
    font-weight: 600;
    border: 1px solid var(--border);
    white-space: nowrap;
}

.chip.active {
    background: var(--accent);
    color: #0c1510;
    border-color: var(--accent);
}

.hidden-filters {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
    clip: rect(0 0 0 0) !important;
    white-space: nowrap !important;
}

.list-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    color: var(--muted);
    font-size: 0.88rem;
}

.sort-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 6px 10px;
    color: var(--text);
    font-size: 0.82rem;
    font-weight: 600;
}

/* ===== Cards ===== */
.results-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.country-card {
    background: var(--card);
    border-radius: 18px;
    overflow: hidden;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: transform 0.2s ease;
}

.country-card:active { transform: scale(0.98); }

.card-flag {
    width: 100%;
    height: 96px;
    object-fit: cover;
    display: block;
}

.card-content { padding: 10px 11px 12px; }

.card-title {
    margin: 0 0 4px;
    font-size: 0.98rem;
    font-weight: 800;
    line-height: 1.25;
}

.card-meta {
    display: grid;
    gap: 5px;
    color: var(--muted);
    font-size: 0.76rem;
    line-height: 1.35;
}

.card-meta p { margin: 0; }

.card-meta strong {
    color: var(--accent);
    font-weight: 700;
}

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px 16px;
    color: var(--muted);
    background: var(--surface);
    border-radius: 16px;
    border: 1px dashed var(--border);
}

.alert {
    margin-bottom: 12px;
    padding: 12px 14px;
    border-radius: 14px;
    font-size: 0.9rem;
    background: var(--accent-soft);
    border: 1px solid rgba(112, 219, 151, 0.25);
    color: var(--text);
}

.alert.hidden { display: none; }
.alert.error {
    background: rgba(248, 113, 113, 0.12);
    border-color: rgba(248, 113, 113, 0.3);
    color: #fecaca;
}
.alert.success { background: var(--accent-soft); }
.alert.info {
    background: rgba(59, 130, 246, 0.12);
    border-color: rgba(59, 130, 246, 0.25);
}

/* ===== Bottom nav ===== */
.bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: 68px;
    background: var(--nav);
    border-top: 1px solid var(--border);
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    z-index: 900;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--muted);
    font-size: 0.68rem;
    font-weight: 600;
    border-radius: 14px;
    padding: 4px 2px;
}

.nav-item .nav-icon { font-size: 1.2rem; line-height: 1; }
.nav-item.active {
    color: var(--accent);
    background: var(--accent-soft);
}

/* ===== Modals ===== */
.modal {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: end center;
    background: rgba(0, 0, 0, 0.72);
    opacity: 0;
    visibility: hidden;
    transition: 0.25s ease;
    z-index: 1000;
    padding: 0;
}

.modal.show {
    opacity: 1;
    visibility: visible;
}

.modal-window {
    width: 100%;
    max-height: 92vh;
    overflow: hidden;
    border-radius: 22px 22px 0 0;
    background: var(--bg);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: relative;
}

.close-button {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--surface);
    color: var(--text);
    font-size: 1.4rem;
    display: grid;
    place-items: center;
    z-index: 2;
}

.modal-header {
    padding: 20px 16px 12px;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.35rem;
    padding-right: 40px;
}

.modal-header p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.modal-badge {
    align-self: flex-start;
    padding: 7px 12px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 0.8rem;
    font-weight: 700;
}

.modal-body {
    overflow-y: auto;
    padding: 14px 16px 28px;
}

.detail-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 14px;
    margin-bottom: 12px;
}

.detail-section h3 {
    margin: 0 0 10px;
    color: var(--accent);
    font-size: 0.95rem;
}

.detail-section p,
.detail-section li {
    margin: 0 0 8px;
    line-height: 1.6;
    font-size: 0.92rem;
}

.detail-section ul { list-style: none; padding: 0; margin: 0; }

.section-highlight {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 12px;
}

.section-card {
    flex: 1 1 140px;
    background: var(--bg-deep);
    border-radius: 12px;
    padding: 12px;
    border: 1px solid var(--border);
}

.section-card strong {
    display: block;
    font-size: 0.78rem;
    color: var(--muted);
    margin-bottom: 4px;
}

.section-card span {
    font-size: 1rem;
    font-weight: 700;
}

.section-group { display: grid; gap: 12px; }

#countryMap,
.map-placeholder {
    min-height: 200px;
    border-radius: 14px;
    background: var(--bg-deep);
    border: 1px solid var(--border);
    position: relative;
}

.country-map-wrapper { margin-top: 10px; }
.country-map-wrapper h4 {
    margin: 0 0 8px;
    color: var(--muted);
    font-size: 0.9rem;
}

.button-primary {
    width: 100%;
    min-height: 46px;
    background: var(--accent);
    color: #0c1510;
    border-radius: 14px;
    font-weight: 800;
    padding: 12px;
}

.button-secondary {
    width: 100%;
    min-height: 44px;
    background: var(--surface);
    color: var(--text);
    border-radius: 14px;
    border: 1px solid var(--border);
    padding: 12px;
    font-weight: 600;
}

.books-body { display: grid; gap: 12px; }
.books-list { display: grid; gap: 10px; }

.book-card {
    width: 100%;
    text-align: left;
    padding: 14px;
    border-radius: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 12px;
    color: var(--text);
}

.book-card.active, .book-card:hover { border-color: var(--accent); }

.book-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: var(--accent-soft);
    color: var(--accent);
    display: grid;
    place-items: center;
    font-size: 1.2rem;
}

.book-card-title { display: block; font-weight: 800; }
.book-card p, .book-details p { margin: 6px 0 0; color: var(--muted); font-size: 0.88rem; }
.book-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.book-meta span {
    padding: 4px 8px;
    border-radius: 999px;
    background: rgba(255,255,255,0.06);
    font-size: 0.75rem;
    color: var(--muted);
}

.book-details {
    background: var(--surface);
    border-radius: 16px;
    border: 1px solid var(--border);
    padding: 14px;
    display: grid;
    gap: 12px;
}

.book-detail-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: var(--accent-soft);
    color: var(--accent);
    display: grid;
    place-items: center;
    font-size: 1.5rem;
}

.book-actions { display: grid; gap: 8px; }

.book-action {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: 14px;
    background: var(--accent);
    color: #0c1510;
    text-decoration: none;
    font-weight: 700;
    padding: 10px;
}

.book-action.secondary {
    background: var(--surface-2);
    color: var(--text);
}

.quiz-body { min-height: auto; }
.quiz-app { display: grid; gap: 12px; }

.quiz-sidebar,
.quiz-stage,
.quiz-locked {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 14px;
}

.quiz-input {
    width: 100%;
    min-height: 44px;
    background: var(--bg-deep);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 12px;
    font-size: 16px;
}

.quiz-scoreboard { display: grid; gap: 8px; margin-top: 8px; }
.quiz-score-card {
    padding: 12px;
    border-radius: 12px;
    background: var(--bg-deep);
    border: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.85rem;
    display: grid;
    gap: 4px;
}
.quiz-score-card.active {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--text);
}
.quiz-score-card strong { color: var(--text); }

.quiz-empty, .quiz-locked, .quiz-result {
    display: grid;
    gap: 12px;
    text-align: center;
    align-content: center;
    min-height: 180px;
}

.quiz-progress { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.quiz-progress span {
    padding: 6px 10px;
    border-radius: 999px;
    background: var(--bg-deep);
    color: var(--muted);
    font-size: 0.8rem;
}

.quiz-question { display: grid; gap: 12px; }
.quiz-options { display: grid; gap: 8px; }

.quiz-option {
    width: 100%;
    min-height: 50px;
    display: grid;
    grid-template-columns: 32px 1fr;
    gap: 10px;
    align-items: center;
    text-align: left;
    background: var(--bg-deep);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 10px;
    color: var(--text);
}

.quiz-option span {
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 800;
}

.quiz-option.correct {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.quiz-option.wrong {
    border-color: #f87171;
    background: rgba(248, 113, 113, 0.12);
}

.quiz-feedback {
    padding: 12px;
    border-radius: 12px;
    display: grid;
    gap: 4px;
}
.quiz-feedback.correct {
    background: var(--accent-soft);
    border: 1px solid rgba(112, 219, 151, 0.35);
}
.quiz-feedback.wrong {
    background: rgba(248, 113, 113, 0.12);
    border: 1px solid rgba(248, 113, 113, 0.3);
    color: #fecaca;
}

.quiz-winner { color: var(--accent); font-weight: 800; margin: 0; }
.quiz-review { display: grid; gap: 12px; text-align: left; }
.quiz-review-player { display: grid; gap: 8px; }
.quiz-review-row {
    padding: 10px;
    border-radius: 12px;
    background: var(--bg-deep);
    border: 1px solid var(--border);
    display: grid;
    gap: 4px;
}
.quiz-review-row.correct { border-color: rgba(112, 219, 151, 0.4); }
.quiz-review-row.wrong { border-color: rgba(248, 113, 113, 0.35); }
.quiz-review-row span { color: var(--muted); font-size: 0.85rem; }

.auth-layout { display: grid; gap: 12px; }
.auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px;
    display: grid;
    gap: 10px;
}
.auth-card h3 { margin: 0 0 4px; }
.auth-card label { color: var(--muted); font-size: 0.84rem; }
.auth-card input {
    width: 100%;
    min-height: 46px;
    background: var(--bg-deep);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 12px;
    font-size: 16px;
}

.auth-message {
    padding: 12px;
    border-radius: 12px;
    background: var(--accent-soft);
    border: 1px solid rgba(112, 219, 151, 0.3);
}
.auth-message.error {
    background: rgba(248, 113, 113, 0.12);
    border-color: rgba(248, 113, 113, 0.3);
    color: #fecaca;
}

.auth-message.hidden,
.auth-profile.hidden,
.auth-layout.hidden,
.quiz-app.hidden,
.quiz-locked.hidden { display: none; }

.auth-profile { text-align: center; justify-items: center; }
.auth-avatar {
    width: 64px;
    height: 64px;
    border-radius: 18px;
    background: var(--accent-soft);
    color: var(--accent);
    display: grid;
    place-items: center;
    font-size: 1.8rem;
    margin: 0 auto 8px;
}
.auth-profile p { margin: 0; color: var(--muted); }

@media (min-width: 520px) {
    .results-grid { gap: 14px; }
    .card-flag { height: 110px; }
}

/* =========================================================
   DESKTOP ONLY — richer design + animations
   Mobile styles above stay untouched
   ========================================================= */
@media (min-width: 900px) {
    body {
        padding-bottom: 0;
        background:
            radial-gradient(ellipse 80% 50% at 50% -10%, rgba(112, 219, 151, 0.14), transparent 55%),
            radial-gradient(ellipse 40% 30% at 90% 20%, rgba(112, 219, 151, 0.06), transparent 50%),
            linear-gradient(180deg, #141614 0%, #1a1c19 40%, #121412 100%);
    }

    body.light-theme {
        background:
            radial-gradient(ellipse 80% 50% at 50% -10%, rgba(31, 157, 87, 0.1), transparent 55%),
            linear-gradient(180deg, #f8faf7 0%, #f3f5f2 50%, #eef1ec 100%);
    }

    .bottom-nav { display: none; }

    /* Header */
    .app-header {
        max-width: 1180px;
        margin: 0 auto;
        padding: 36px 28px 18px;
        align-items: center;
    }

    .app-header-text h1 {
        font-size: 2.35rem;
        background: linear-gradient(135deg, #f2f4f1 30%, #70db97 100%);
        -webkit-background-clip: text;
        background-clip: text;
        color: transparent;
        animation: fadeSlideDown 0.55s ease both;
    }

    body.light-theme .app-header-text h1 {
        background: linear-gradient(135deg, #142016 20%, #1f9d57 100%);
        -webkit-background-clip: text;
        background-clip: text;
    }

    .app-header-text p {
        font-size: 1rem;
        margin-top: 8px;
        animation: fadeSlideDown 0.55s ease 0.08s both;
    }

    .header-actions {
        gap: 10px;
        animation: fadeSlideDown 0.55s ease 0.12s both;
    }

    .header-icon-btn {
        width: 48px;
        height: 48px;
        font-size: 1.15rem;
        border-radius: 16px;
        transition: transform 0.22s ease, border-color 0.22s ease, box-shadow 0.22s ease, background 0.22s ease;
    }

    .header-icon-btn:hover {
        transform: translateY(-3px) scale(1.05);
        border-color: rgba(112, 219, 151, 0.45);
        box-shadow: 0 12px 28px rgba(112, 219, 151, 0.15);
        background: var(--surface-2);
    }

    .settings-drawer {
        top: calc(100% + 12px);
        border-radius: 20px;
        padding: 20px;
        backdrop-filter: blur(12px);
    }

    /* Content shell */
    .app-content {
        max-width: 1180px;
        margin: 0 auto;
        padding: 8px 28px 56px;
    }

    /* Search */
    .search-wrap {
        padding: 16px 22px;
        border-radius: 20px;
        margin-bottom: 22px;
        transition: border-color 0.25s ease, box-shadow 0.25s ease;
        animation: fadeSlideUp 0.5s ease 0.1s both;
    }

    .search-wrap:focus-within {
        border-color: rgba(112, 219, 151, 0.5);
        box-shadow: 0 0 0 4px rgba(112, 219, 151, 0.12), 0 16px 40px rgba(0,0,0,0.2);
    }

    #searchInput { font-size: 1.05rem; }

    .region-label {
        font-size: 0.9rem;
        margin-bottom: 10px;
        animation: fadeSlideUp 0.5s ease 0.15s both;
    }

    .region-chips {
        gap: 10px;
        margin-bottom: 18px;
        animation: fadeSlideUp 0.5s ease 0.18s both;
    }

    .chip {
        padding: 10px 18px;
        font-size: 0.92rem;
        transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
    }

    .chip:hover {
        transform: translateY(-2px);
        box-shadow: 0 8px 20px rgba(0,0,0,0.18);
    }

    .chip.active {
        box-shadow: 0 8px 22px rgba(112, 219, 151, 0.25);
    }

    .list-meta {
        margin-bottom: 18px;
        font-size: 0.95rem;
        animation: fadeSlideUp 0.5s ease 0.2s both;
    }

    .sort-btn {
        padding: 8px 14px;
        border-radius: 12px;
        transition: transform 0.2s ease, border-color 0.2s ease;
    }

    .sort-btn:hover {
        transform: translateY(-1px);
        border-color: rgba(112, 219, 151, 0.4);
    }

    /* Cards grid */
    .results-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 22px;
    }

    .country-card {
        border-radius: 22px;
        transition:
            transform 0.35s cubic-bezier(0.22, 1, 0.36, 1),
            box-shadow 0.35s ease,
            border-color 0.35s ease;
        animation: cardIn 0.5s ease both;
    }

    .country-card:nth-child(1) { animation-delay: 0.05s; }
    .country-card:nth-child(2) { animation-delay: 0.09s; }
    .country-card:nth-child(3) { animation-delay: 0.13s; }
    .country-card:nth-child(4) { animation-delay: 0.17s; }
    .country-card:nth-child(5) { animation-delay: 0.21s; }
    .country-card:nth-child(6) { animation-delay: 0.25s; }
    .country-card:nth-child(n+7) { animation-delay: 0.28s; }

    .country-card:hover {
        transform: translateY(-10px) scale(1.015);
        border-color: rgba(112, 219, 151, 0.45);
        box-shadow:
            0 24px 50px rgba(0, 0, 0, 0.35),
            0 0 0 1px rgba(112, 219, 151, 0.12),
            0 12px 40px rgba(112, 219, 151, 0.1);
    }

    .country-card:active { transform: translateY(-4px) scale(1.01); }

    .card-flag {
        height: 150px;
        transition: transform 0.45s ease;
    }

    .country-card:hover .card-flag {
        transform: scale(1.06);
    }

    .card-content { padding: 16px 18px 18px; }

    .card-title {
        font-size: 1.2rem;
        margin-bottom: 8px;
    }

    .card-meta {
        font-size: 0.88rem;
        gap: 7px;
    }

    /* Modal desktop */
    .modal {
        place-items: center;
        padding: 28px;
        backdrop-filter: blur(6px);
    }

    .modal-window {
        max-width: 980px;
        border-radius: 26px;
        max-height: 90vh;
        box-shadow: 0 40px 100px rgba(0, 0, 0, 0.5);
        animation: modalPop 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
    }

    .modal.show .modal-window {
        animation: modalPop 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
    }

    .close-button {
        width: 44px;
        height: 44px;
        transition: transform 0.2s ease, background 0.2s ease;
    }

    .close-button:hover {
        transform: rotate(90deg) scale(1.08);
        background: var(--surface-2);
    }

    .modal-header {
        padding: 28px 28px 16px;
        flex-direction: row;
        align-items: flex-start;
        justify-content: space-between;
    }

    .modal-header h2 { font-size: 1.85rem; }
    .modal-body { padding: 20px 28px 32px; }

    .detail-section {
        padding: 20px;
        border-radius: 18px;
        transition: border-color 0.25s ease, box-shadow 0.25s ease;
    }

    .detail-section:hover {
        border-color: rgba(112, 219, 151, 0.28);
        box-shadow: 0 8px 28px rgba(0,0,0,0.15);
    }

    .section-card {
        transition: transform 0.2s ease, border-color 0.2s ease;
    }

    .section-card:hover {
        transform: translateY(-2px);
        border-color: rgba(112, 219, 151, 0.3);
    }

    #countryMap, .map-placeholder {
        min-height: 280px;
        border-radius: 18px;
    }

    .button-primary,
    .button-secondary,
    .book-action {
        transition: transform 0.2s ease, box-shadow 0.2s ease;
    }

    .button-primary:hover,
    .book-action:hover {
        transform: translateY(-2px);
        box-shadow: 0 12px 28px rgba(112, 219, 151, 0.28);
    }

    .button-secondary:hover {
        transform: translateY(-2px);
        border-color: rgba(112, 219, 151, 0.35);
    }

    .book-card {
        transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
    }

    .book-card:hover {
        transform: translateY(-4px);
        box-shadow: 0 16px 36px rgba(0,0,0,0.2);
    }

    .quiz-option {
        transition: transform 0.2s ease, border-color 0.2s ease;
    }

    .quiz-option:hover:not(:disabled) {
        transform: translateX(4px);
        border-color: rgba(112, 219, 151, 0.45);
    }

    .auth-layout {
        grid-template-columns: 1fr 1fr;
        gap: 18px;
    }

    .books-body {
        grid-template-columns: 0.95fr 1.05fr;
        gap: 18px;
    }

    .quiz-app {
        grid-template-columns: 0.75fr 1.25fr;
        gap: 18px;
    }
}

/* Desktop animations */
@keyframes fadeSlideDown {
    from {
        opacity: 0;
        transform: translateY(-14px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeSlideUp {
    from {
        opacity: 0;
        transform: translateY(14px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes cardIn {
    from {
        opacity: 0;
        transform: translateY(18px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes modalPop {
    from {
        opacity: 0;
        transform: translateY(24px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
