:root {
    --navy: #001A48;
    --blue: #0091DE;
    --accent: #FF7A45;
    --green: #2E8B57;
    --red: #D64545;
    --bg: #F5F8FC;
    --card: #FFFFFF;
    --text: #1A2436;
    --muted: #6B7686;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, "Segoe UI", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

.wrap {
    max-width: 720px;
    margin: 0 auto;
    padding: 24px 16px 64px;
}

header.app-header {
    background: var(--navy);
    color: #fff;
    padding: 18px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

header.app-header .brand {
    font-weight: 700;
    font-size: 1.1rem;
}

header.app-header a {
    color: #cfe4f7;
    text-decoration: none;
    font-size: 0.9rem;
}

h1 { font-size: 1.5rem; margin: 0 0 4px; }
h2 { font-size: 1.15rem; margin: 28px 0 12px; color: var(--navy); }
p.lead { color: var(--muted); margin-top: 0; }

.card {
    background: var(--card);
    border-radius: 14px;
    padding: 18px 20px;
    box-shadow: 0 1px 3px rgba(0,26,72,0.08);
    margin-bottom: 16px;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.stat {
    text-align: center;
}
.stat .num {
    font-size: 2rem;
    font-weight: 700;
    color: var(--blue);
}
.stat .label {
    color: var(--muted);
    font-size: 0.85rem;
}

.btn {
    display: inline-block;
    background: var(--blue);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 12px 20px;
    font-size: 1rem;
    text-decoration: none;
    cursor: pointer;
    font-weight: 600;
}
.btn:hover { background: #007bbf; }
.btn.secondary {
    background: transparent;
    color: var(--blue);
    border: 2px solid var(--blue);
}
.btn.accent { background: var(--accent); }
.btn.block { display: block; width: 100%; text-align: center; }

.list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 0;
    border-bottom: 1px solid #EAEFF5;
}
.list-item:last-child { border-bottom: none; }
.list-item .title { font-weight: 600; }
.list-item .meta { color: var(--muted); font-size: 0.85rem; }

.question-block {
    margin-bottom: 24px;
}
.question-block .prompt {
    font-weight: 600;
    margin-bottom: 10px;
}
.option-row {
    display: block;
    padding: 10px 12px;
    border: 2px solid #E2E8F0;
    border-radius: 10px;
    margin-bottom: 8px;
    cursor: pointer;
}
.option-row.correct { border-color: var(--green); background: #EAF7EF; }
.option-row.incorrect { border-color: var(--red); background: #FCEAEA; }
.option-row input { margin-right: 8px; }

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}
.badge.green { background: #EAF7EF; color: var(--green); }
.badge.red { background: #FCEAEA; color: var(--red); }
.badge.blue { background: #E7F4FC; color: var(--blue); }

.flashcard {
    background: var(--navy);
    color: #fff;
    border-radius: 16px;
    padding: 48px 24px;
    text-align: center;
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 18px;
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.flashcard .example {
    display: block;
    font-size: 0.95rem;
    font-weight: 400;
    color: #cfe4f7;
    margin-top: 10px;
}

.review-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.review-buttons button {
    padding: 14px;
    border: none;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    color: #fff;
}
.rb-again { background: var(--red); }
.rb-hard { background: #E0A100; }
.rb-good { background: var(--blue); }
.rb-easy { background: var(--green); }

.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.bar-row .bar-label { width: 90px; font-size: 0.8rem; color: var(--muted); flex-shrink: 0; }
.bar-track { flex: 1; background: #EAEFF5; border-radius: 6px; overflow: hidden; height: 14px; }
.bar-fill { height: 100%; background: var(--blue); }

form.stack { display: flex; flex-direction: column; gap: 12px; }
input[type=text], input[type=password] {
    padding: 12px 14px;
    border: 2px solid #E2E8F0;
    border-radius: 10px;
    font-size: 1rem;
}
.error-msg { color: var(--red); font-size: 0.9rem; }
.empty-state { color: var(--muted); text-align: center; padding: 24px 0; }

/* ---- Mascotte + XP ---- */
.mascot-card {
    display: flex;
    align-items: center;
    gap: 16px;
}
.mascot-card .mascot-img { flex-shrink: 0; }
.mascot-info { flex: 1; }
.mascot-name { font-weight: 700; color: var(--navy); }
.mascot-level { color: var(--muted); font-size: 0.85rem; margin-bottom: 6px; }
.xp-track {
    background: #EAEFF5;
    border-radius: 8px;
    height: 16px;
    overflow: hidden;
    position: relative;
}
.xp-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--blue), var(--accent));
    transition: width 0.4s ease;
}
.xp-label { font-size: 0.75rem; color: var(--muted); margin-top: 4px; }

/* ---- Badges ---- */
.badge-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}
.badge-tile {
    text-align: center;
    padding: 16px 8px;
    border-radius: 14px;
    background: #F5F8FC;
}
.badge-tile.unlocked { background: #FFF7ED; box-shadow: 0 1px 3px rgba(0,26,72,0.08); }
.badge-tile .icon { font-size: 2rem; filter: grayscale(1); opacity: 0.35; }
.badge-tile.unlocked .icon { filter: none; opacity: 1; }
.badge-tile .title { font-weight: 600; font-size: 0.85rem; margin-top: 6px; }
.badge-tile .desc { font-size: 0.7rem; color: var(--muted); margin-top: 2px; }
.badge-count { color: var(--muted); font-size: 0.9rem; }

/* ---- Popups (badge débloqué / niveau supérieur) ---- */
.badge-popup-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,26,72,0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
}
.badge-popup {
    background: #fff;
    border-radius: 20px;
    padding: 32px 28px;
    text-align: center;
    max-width: 320px;
    animation: pop-in 0.25s ease;
}
.badge-popup.levelup { background: var(--navy); color: #fff; }
.badge-popup-icon { font-size: 3.5rem; }
.badge-popup-label { color: var(--accent); font-weight: 700; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; margin-top: 8px; }
.badge-popup-title { font-size: 1.3rem; font-weight: 700; margin: 6px 0; }
.badge-popup-desc { color: var(--muted); font-size: 0.9rem; margin-bottom: 16px; }
.badge-popup.levelup .badge-popup-desc { color: #cfe4f7; }
@keyframes pop-in {
    from { transform: scale(0.7); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

#sound-toggle {
    background: none;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    color: #fff;
}
