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

:root {
    --primary: #000000;
    --primary-hover: #1a1a1a;
    --bg: #f5f5f0;
    --card: #ffffff;
    --border: #e0ddd5;
    --text: #1a1a1a;
    --text-soft: #666;
    --accent: #d4a017;
    --correct: #2d7a3e;
    --wrong: #c83838;
    --bayern-blue: #0066b3;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

header {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 10;
}

header h1 {
    font-size: 1.4rem;
    font-weight: 600;
}

.land {
    color: var(--bayern-blue);
    font-weight: 700;
}

#mode-switch button {
    background: transparent;
    border: 1px solid var(--border);
    padding: 0.4rem 1rem;
    cursor: pointer;
    border-radius: 4px;
    margin-left: 0.5rem;
    font-size: 0.9rem;
}

#mode-switch button.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

#mode-switch {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: nowrap;
    white-space: nowrap;
}

#mode-switch button {
    margin-left: 0;
}

#mode-switch .btn-home {
    background: var(--bayern-blue, #0070b8);
    color: white;
    border-color: var(--bayern-blue, #0070b8);
    font-weight: 600;
}

#mode-switch .btn-home:hover {
    filter: brightness(1.1);
}

/* Language toggle — sits next to Home */
.lang-toggle {
    display: inline-flex;
    align-items: stretch;
    gap: 0;
    padding: 3px;
    background: rgba(0,112,184,0.08);
    border: 1px solid rgba(0,112,184,0.2);
    border-radius: 999px;
    overflow: hidden;
}

#mode-switch .lang-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    margin: 0;
    border: none;
    border-radius: 999px;
    padding: 0.3rem 0.75rem;
    font-size: 0.82rem;
    font-weight: 600;
    line-height: 1;
    background: transparent;
    color: var(--text, #333);
    cursor: pointer;
    transition: background 0.15s, color 0.15s, transform 0.1s;
}

#mode-switch .lang-btn .flag {
    font-size: 1rem;
    line-height: 1;
}

#mode-switch .lang-btn .code {
    letter-spacing: 0.5px;
}

#mode-switch .lang-btn:hover {
    background: rgba(255,255,255,0.7);
}

#mode-switch .lang-btn.active {
    background: var(--bayern-blue, #0070b8);
    color: white;
    box-shadow: 0 1px 4px rgba(0,112,184,0.3);
}

#mode-switch .lang-btn.active:hover {
    background: var(--bayern-blue, #0070b8);
    filter: brightness(1.05);
}

@media (max-width: 640px) {
    header {
        padding: 0.6rem 0.75rem;
        gap: 0.5rem;
    }
    header h1 {
        font-size: 1.05rem;
    }
    #mode-switch {
        gap: 0.3rem;
    }
    #mode-switch .lang-btn .code {
        display: none;
    }
    #mode-switch .lang-btn {
        padding: 0.35rem 0.45rem;
    }
    #mode-switch .btn-home {
        padding: 0.4rem 0.55rem;
        font-size: 0.85rem;
    }
    #mode-switch button {
        padding: 0.4rem 0.6rem;
        font-size: 0.8rem;
        margin-left: 0;
    }
}

/* Very narrow phones — only show icons for Lernmodus / Prüfungsmodus */
@media (max-width: 460px) {
    header h1 {
        font-size: 0.95rem;
    }
    #btn-mode-study,
    #btn-mode-exam {
        font-size: 0;
        padding: 0.4rem 0.5rem;
    }
    #btn-mode-study::before {
        content: "📖";
        font-size: 1rem;
    }
    #btn-mode-exam::before {
        content: "📝";
        font-size: 1rem;
    }
    #mode-switch .btn-home {
        font-size: 0;
        padding: 0.4rem 0.5rem;
    }
    #mode-switch .btn-home::before {
        content: "🏠";
        font-size: 1rem;
    }
}

/* Welcome screen */
#screen-welcome {
    max-width: 900px;
    margin: 2rem auto;
    padding: 0 1.5rem;
}

.welcome-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 2.5rem 2rem;
    box-shadow: 0 4px 18px rgba(0,0,0,0.06);
}

.welcome-card h2 {
    font-size: 1.8rem;
    text-align: center;
    margin: 0 0 1rem;
    color: var(--bayern-blue, #0070b8);
}

.welcome-lead {
    text-align: center;
    font-size: 1.05rem;
    margin: 0 0 2rem;
    color: var(--text, #333);
}

.welcome-bilingual {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.welcome-col h3 {
    margin-top: 0;
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}

.welcome-col p {
    font-size: 0.95rem;
    line-height: 1.5;
    margin: 0 0 0.75rem;
}

.welcome-lang {
    border-top: 1px solid var(--border);
    padding-top: 1.5rem;
    text-align: center;
}

.welcome-lang h3 {
    margin: 0 0 0.5rem;
    font-size: 1.15rem;
}

.welcome-lang-hint {
    font-size: 0.85rem;
    color: #666;
    margin: 0 0 1.25rem;
    line-height: 1.5;
}

.welcome-lang-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.welcome-lang-btn {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.9rem 1.8rem;
    font-size: 1.05rem;
    background: var(--card);
    border: 2px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
    font-weight: 600;
}

.welcome-lang-btn:hover {
    border-color: var(--bayern-blue, #0070b8);
    background: rgba(0,112,184,0.05);
    transform: translateY(-2px);
}

.welcome-lang-btn .flag {
    font-size: 1.6rem;
    line-height: 1;
}

@media (max-width: 700px) {
    .welcome-bilingual {
        grid-template-columns: 1fr;
    }
    .welcome-card {
        padding: 1.5rem 1rem;
    }
    .lang-toggle {
        margin-right: 0.25rem;
    }
}

main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 2rem;
    margin-bottom: 1rem;
}

h2 {
    font-size: 1.6rem;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--text-soft);
    margin-bottom: 2rem;
}

.modes {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.mode-card {
    border: 1px solid var(--border);
    padding: 1.5rem;
    border-radius: 6px;
    background: #fafaf7;
}

.mode-card h3 {
    margin-bottom: 0.7rem;
    font-size: 1.2rem;
}

.mode-card p {
    color: var(--text-soft);
    font-size: 0.95rem;
    margin-bottom: 1.2rem;
}

.btn-primary, .btn-secondary {
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}

.btn-secondary:hover {
    background: #f0ede5;
}

.quiz-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--card);
    padding: 0.8rem 1.2rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 1rem;
}

.quiz-toolbar button {
    background: transparent;
    border: 1px solid var(--border);
    padding: 0.4rem 0.9rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    margin-left: 0.5rem;
}

#progress {
    color: var(--text-soft);
    font-size: 0.9rem;
    margin-left: 1rem;
}

#timer {
    font-family: "Courier New", monospace;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--wrong);
    margin-right: 1rem;
}

.quiz-layout {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 1rem;
}

.quiz-main {
    min-width: 0;
}

.question-card {
    margin-bottom: 1rem;
}

.question-number {
    color: var(--text-soft);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.6rem;
}

.question-text {
    font-size: 1.15rem;
    line-height: 1.6;
    margin-bottom: 1rem;
}

.question-text .word {
    cursor: help;
    border-bottom: 1px dotted transparent;
    transition: border-color 0.15s;
    padding: 0 1px;
    border-radius: 2px;
}

.question-text .word:hover {
    border-bottom-color: var(--accent);
    background: rgba(212, 160, 23, 0.1);
}

.question-translation {
    background: #fdf8e8;
    border-left: 3px solid var(--accent);
    padding: 0.8rem 1rem;
    margin-bottom: 1rem;
    color: #5a4a1a;
    font-style: italic;
}

.options {
    list-style: none;
}

.options li {
    border: 1px solid var(--border);
    padding: 0.7rem 0.8rem;
    margin-bottom: 0.5rem;
    border-radius: 5px;
    transition: background 0.12s, border-color 0.12s;
    display: flex;
    gap: 0.7rem;
    align-items: flex-start;
}

.options li.selected {
    background: #e8f0fa;
    border-color: var(--bayern-blue);
}

.options li.correct {
    background: #e6f4e8;
    border-color: var(--correct);
}

.options li.wrong {
    background: #fae6e6;
    border-color: var(--wrong);
}

.opt-select {
    flex-shrink: 0;
    width: 2.4rem;
    height: 2.4rem;
    border: 2px solid var(--border);
    background: #fafaf7;
    color: var(--text);
    font-weight: 700;
    font-size: 1rem;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.opt-select:hover {
    border-color: var(--bayern-blue);
    background: #e8f0fa;
}

.options li.selected .opt-select {
    background: var(--bayern-blue);
    color: #fff;
    border-color: var(--bayern-blue);
}

.options li.correct .opt-select {
    background: var(--correct);
    color: #fff;
    border-color: var(--correct);
}

.options li.wrong .opt-select {
    background: var(--wrong);
    color: #fff;
    border-color: var(--wrong);
}

.opt-content {
    flex: 1;
    min-width: 0;
    padding-top: 0.3rem;
}

.opt-text {
    line-height: 1.5;
}

.opt-translation {
    color: #5a4a1a;
    font-size: 0.9rem;
    font-style: italic;
    margin-top: 0.4rem;
    padding: 0.4rem 0.6rem;
    background: #fdf8e8;
    border-left: 2px solid var(--accent);
    border-radius: 3px;
}

.opt-translate-btn {
    flex-shrink: 0;
    width: 2.4rem;
    height: 2.4rem;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text-soft);
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
}

.opt-translate-btn:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.opt-translate-btn.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.feedback {
    margin-top: 1rem;
    padding: 0.8rem 1rem;
    border-radius: 5px;
    font-weight: 500;
}

.feedback.correct {
    background: #e6f4e8;
    color: var(--correct);
}

.feedback.wrong {
    background: #fae6e6;
    color: var(--wrong);
}

.quiz-nav {
    display: flex;
    justify-content: space-between;
    margin-top: 1rem;
}

.quiz-nav button {
    background: transparent;
    border: 1px solid var(--border);
    padding: 0.6rem 1.3rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.95rem;
}

.quiz-nav .btn-primary {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.glossary {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.2rem;
    height: fit-content;
    position: sticky;
    top: 5rem;
}

.glossary h3 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

.glossary .hint {
    font-size: 0.8rem;
    color: var(--text-soft);
    margin-bottom: 0.8rem;
}

#glossary-list,
#home-glossary-list {
    list-style: none;
    max-height: 400px;
    overflow-y: auto;
}

#glossary-list li,
#home-glossary-list li {
    padding: 0.5rem 0;
    border-bottom: 1px solid #f0ede5;
    font-size: 0.9rem;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

#glossary-list li .glossary-word,
#home-glossary-list li .glossary-word {
    flex: 1;
    min-width: 0;
}

#glossary-list li .de,
#home-glossary-list li .de {
    font-weight: 600;
    color: var(--text);
    word-break: break-word;
}

#glossary-list li .pt,
#home-glossary-list li .pt {
    color: var(--text-soft);
    display: block;
    font-size: 0.85rem;
    margin-top: 0.15rem;
    word-break: break-word;
}

.glossary-delete {
    flex-shrink: 0;
    width: 1.5rem;
    height: 1.5rem;
    border: none;
    background: transparent;
    color: var(--text-soft);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    opacity: 0.5;
}

#glossary-list li:hover .glossary-delete,
#home-glossary-list li:hover .glossary-delete {
    opacity: 1;
}

.glossary-delete:hover {
    background: var(--wrong);
    color: #fff;
    opacity: 1 !important;
}

.glossary-count {
    background: var(--accent);
    color: #fff;
    font-size: 0.75rem;
    padding: 0.05rem 0.5rem;
    border-radius: 999px;
    font-weight: 600;
    margin-left: 0.4rem;
    vertical-align: middle;
}

#btn-clear-glossary,
#btn-clear-home-glossary {
    margin-top: 0.8rem;
    width: 100%;
    font-size: 0.85rem;
    padding: 0.4rem;
}

/* Home 2-column layout (main + Wortschatz sidebar) */
.home-layout {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 1rem;
    align-items: start;
}

.home-main {
    min-width: 0;
}

.home-sidebar {
    min-width: 0;
}

.home-glossary {
    position: sticky;
    top: 5rem;
    max-height: calc(100vh - 7rem);
    display: flex;
    flex-direction: column;
}

.home-glossary #home-glossary-list {
    flex: 1;
    max-height: none;
    min-height: 0;
}

.tooltip {
    position: fixed;
    background: #1a1a1a;
    color: #fff;
    padding: 0.4rem 0.7rem;
    border-radius: 4px;
    font-size: 0.85rem;
    pointer-events: none;
    z-index: 100;
    max-width: 250px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.tooltip::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #1a1a1a;
}

.tooltip.no-trans {
    background: #555;
    color: #ccc;
    font-style: italic;
}

.tooltip.no-trans::after {
    border-top-color: #555;
}

.result-card {
    text-align: center;
}

.score-display {
    margin: 2rem 0;
}

.score-number {
    font-size: 3rem;
    font-weight: 700;
}

.score-status {
    margin-top: 0.6rem;
    font-size: 1.2rem;
    font-weight: 500;
}

.score-status.passed {
    color: var(--correct);
}

.score-status.failed {
    color: var(--wrong);
}

.result-actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.5rem;
}

.hidden {
    display: none !important;
}

/* -- QUESTION IMAGES -- */
.question-image {
    margin: 0.75rem 0;
    text-align: center;
}

.question-image img {
    max-width: 100%;
    max-height: 320px;
    border-radius: 6px;
    border: 1px solid var(--border);
    object-fit: contain;
    background: #f9f9f7;
}

.question-image.img-error::after {
    content: '(Bild nicht verfügbar)';
    display: block;
    color: var(--text-soft);
    font-size: 0.85rem;
    padding: 1rem;
    border: 1px dashed var(--border);
    border-radius: 6px;
}

/* -- OPTION IMAGES -- */
.opt-has-image {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.25rem 0;
    min-width: 0;
    flex: 1;
}

.opt-image {
    max-width: 140px;
    max-height: 120px;
    object-fit: contain;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: #f9f9f7;
}

#q-options li:has(.opt-image) {
    align-items: center;
    padding: 0.5rem 0.75rem;
}

/* Feedback image (shown when answer is wrong) */
.feedback-img {
    max-height: 60px;
    max-width: 80px;
    vertical-align: middle;
    margin-left: 0.4rem;
    border-radius: 3px;
    border: 1px solid currentColor;
    opacity: 0.9;
}

/* -- FAVORITES (star button + dashboard grid) -- */
.question-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 0.6rem;
}

.question-header .question-number {
    margin-bottom: 0;
}

.btn-favorite {
    background: transparent;
    border: 1px solid var(--border);
    width: 2.2rem;
    height: 2.2rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 1;
    color: var(--text-soft);
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.btn-favorite:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(212, 160, 23, 0.08);
}

.btn-favorite.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.favorites-card {
    margin-top: 1.5rem;
}

.favorites-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.4rem;
}

.favorites-header h2 {
    margin-bottom: 0;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.favorites-count {
    background: var(--accent);
    color: #fff;
    font-size: 0.85rem;
    padding: 0.1rem 0.6rem;
    border-radius: 999px;
    font-weight: 600;
}

.favorites-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 0.9rem;
    margin-top: 1rem;
}

.favorite-item {
    position: relative;
    background: #fafaf7;
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: 6px;
    padding: 0.9rem 0.9rem 0.9rem 0.9rem;
    cursor: pointer;
    transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.favorite-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border-color: var(--accent);
}

.fav-delete {
    position: absolute;
    top: 0.4rem;
    right: 0.4rem;
    width: 1.6rem;
    height: 1.6rem;
    border: none;
    background: transparent;
    color: var(--text-soft);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.fav-delete:hover {
    background: var(--wrong);
    color: #fff;
}

.fav-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    padding-right: 1.6rem;
}

.fav-tag {
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.1rem 0.45rem;
    border-radius: 3px;
    font-weight: 600;
    font-size: 0.7rem;
}

.fav-tag-general {
    background: #e0e0d8;
    color: var(--text);
}

.fav-tag-bayern {
    background: var(--bayern-blue);
    color: #fff;
}

.fav-id {
    color: var(--text-soft);
    font-weight: 500;
}

.fav-text {
    font-size: 0.92rem;
    line-height: 1.4;
    color: var(--text);
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

@media (max-width: 850px) {
    .quiz-layout,
    .home-layout {
        grid-template-columns: 1fr;
    }
    .glossary,
    .home-glossary {
        position: static;
        max-height: none;
    }
    .home-glossary #home-glossary-list {
        max-height: 320px;
    }
    .modes {
        grid-template-columns: 1fr;
    }
    main {
        padding: 1rem;
    }
}

/* === MOBILE — study-friendly tweaks (≤600px) === */
@media (max-width: 600px) {
    main {
        padding: 0.75rem;
    }
    .card {
        padding: 1.1rem;
        border-radius: 8px;
    }
    h2 {
        font-size: 1.3rem;
    }
    .subtitle {
        font-size: 0.95rem;
        margin-bottom: 1.2rem;
    }

    /* Question text — readable but compact */
    .question-text {
        font-size: 1.05rem;
        line-height: 1.55;
    }

    /* Make word taps obvious on touch */
    .question-text .word {
        border-bottom: 1px dotted rgba(212, 160, 23, 0.45);
        padding: 0 2px;
    }
    .question-text .word:active {
        background: rgba(212, 160, 23, 0.2);
    }

    /* Option list — bigger touch target */
    .options li {
        padding: 0.7rem;
        gap: 0.55rem;
    }
    .opt-select {
        width: 2.6rem;
        height: 2.6rem;
        font-size: 1.05rem;
    }
    .opt-text {
        font-size: 0.98rem;
    }
    .opt-translate-btn {
        min-width: 2.4rem;
        min-height: 2.4rem;
    }

    /* Favorite button — bigger tap target */
    .btn-favorite {
        width: 2.6rem;
        height: 2.6rem;
        font-size: 1.4rem;
    }

    /* Quiz toolbar — let it wrap on tight screens */
    .quiz-toolbar {
        flex-wrap: wrap;
        gap: 0.4rem;
        padding: 0.6rem 0.75rem;
    }
    .quiz-toolbar .left,
    .quiz-toolbar .right {
        display: flex;
        align-items: center;
        gap: 0.4rem;
    }
    .quiz-toolbar button {
        margin-left: 0;
        padding: 0.5rem 0.7rem;
        font-size: 0.85rem;
        min-height: 2.4rem;
    }
    #progress {
        margin-left: 0;
        font-size: 0.85rem;
    }
    #timer {
        margin-right: 0;
    }
    #btn-translate {
        font-size: 0;
        padding: 0.5rem 0.7rem;
    }
    #btn-translate::before {
        content: "🌐";
        font-size: 1rem;
    }

    /* Quiz nav — full-width primary, compact prev */
    .quiz-nav {
        gap: 0.5rem;
    }
    .quiz-nav button {
        padding: 0.7rem 1rem;
        font-size: 0.95rem;
        min-height: 2.75rem;
    }
    .quiz-nav .btn-primary {
        flex: 1;
    }

    /* Glossary panel below quiz — compact */
    .home-glossary #home-glossary-list,
    #glossary-list {
        max-height: 240px;
    }

    /* Mode cards on home — tighter */
    .mode-card {
        padding: 1rem;
    }
    .mode-card h3 {
        font-size: 1.1rem;
    }
    .mode-card p {
        font-size: 0.9rem;
    }
    .btn-primary, .btn-secondary {
        min-height: 2.75rem;
    }

    /* Welcome screen — compact */
    #screen-welcome {
        margin: 1rem auto;
        padding: 0 0.75rem;
    }
    .welcome-card h2 {
        font-size: 1.4rem;
    }
    .welcome-lead {
        font-size: 0.98rem;
        margin-bottom: 1.2rem;
    }
    .welcome-col p {
        font-size: 0.9rem;
    }
    .welcome-lang h3 {
        font-size: 1rem;
    }
    .welcome-lang-btn {
        flex: 1;
        min-width: 0;
        padding: 0.8rem 1rem;
        font-size: 0.95rem;
        justify-content: center;
    }
    .welcome-lang-buttons {
        gap: 0.6rem;
    }

    /* Tooltip — bigger and positioned safely on small screens */
    .tooltip {
        font-size: 0.95rem;
        padding: 0.6rem 0.9rem;
        max-width: 92vw;
    }
}

/* Avoid horizontal scroll caused by long words */
html, body {
    overflow-x: hidden;
}
.question-text, .opt-text {
    overflow-wrap: break-word;
    word-break: break-word;
}
