:root {
    --paper: #EEF1E4;
    --paper-card: #F7F8F0;
    --ink: #232F1D;
    --line: #C7CFB4;
    --move: #6B4C7A;
    --hydro: #2A6F74;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: 'IBM Plex Sans', sans-serif;
}

.page {
    max-width: 560px;
    margin: 0 auto;
    padding-bottom: 40px;
}

.entete {
    padding: 20px 18px 14px;
    border-bottom: 1px solid var(--line);
}

.profil-row { display: flex; gap: 8px; margin-bottom: 14px; }

.pastille-profil {
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 5px 14px;
    font-size: 13px;
    font-family: 'IBM Plex Mono', monospace;
    color: var(--ink);
    text-decoration: none;
}

.pastille-profil--active { background: var(--ink); color: var(--paper); border-color: var(--ink); }

h1 {
    font-family: 'Fraunces', serif;
    font-weight: 600;
    font-size: 28px;
    margin: 0;
    letter-spacing: -0.01em;
}

h2 {
    font-family: 'Fraunces', serif;
    font-weight: 600;
    font-size: 17px;
    margin: 0 0 12px;
}

.contenu {
    padding: 18px 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.carte {
    background: var(--paper-card);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 16px;
}

.carte-discrete { opacity: 0.85; }

.texte-discret { font-size: 13px; opacity: 0.7; line-height: 1.5; margin: 0 0 14px; }

.formulaire { display: flex; flex-direction: column; gap: 10px; }

.formulaire label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 12.5px;
    font-family: 'IBM Plex Mono', monospace;
    opacity: 0.8;
}

.formulaire input {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 14px;
    background: var(--paper);
    color: var(--ink);
    font-family: 'IBM Plex Sans', sans-serif;
}

.formulaire-ligne { flex-direction: row; margin-bottom: 14px; }
.formulaire-ligne input { flex: 1; }

.bouton-principal {
    border: none;
    background: var(--ink);
    color: var(--paper);
    border-radius: 8px;
    padding: 9px 16px;
    font-size: 13.5px;
    cursor: pointer;
    font-family: 'IBM Plex Sans', sans-serif;
}

.carte-progression { }

.progression-entete {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.etiquette { font-family: 'IBM Plex Mono', monospace; font-size: 12.5px; opacity: 0.75; }
.valeur-mono { font-family: 'IBM Plex Mono', monospace; font-size: 20px; font-weight: 600; }

.barre-track {
    height: 8px;
    background: var(--line);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 12px;
}

.barre-fill { height: 100%; background: var(--move); border-radius: 4px; transition: width 0.3s ease; }

.progression-details {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 12.5px;
    font-family: 'IBM Plex Mono', monospace;
    opacity: 0.85;
}

.grille-badges { display: flex; flex-wrap: wrap; gap: 10px; }

.badge {
    display: flex;
    align-items: center;
    gap: 7px;
    border: 1.5px solid var(--line);
    background: var(--paper-card);
    border-radius: 14px;
    padding: 8px 14px 8px 10px;
    font-size: 12.5px;
    font-family: 'IBM Plex Mono', monospace;
    opacity: 0.45;
    filter: grayscale(1);
    transform: scale(0.97);
    animation: badge-entree 0.4s ease backwards;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.badge__icone { font-size: 17px; line-height: 1; }

.badge--debloque {
    opacity: 1;
    filter: grayscale(0);
    transform: scale(1);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 3px 0 rgba(0,0,0,0.12);
}

.badge--debloque:hover { transform: translateY(-2px) scale(1.02); }

.badge--couleur-0.badge--debloque { background: linear-gradient(135deg, #F5A623, #E8871E); }
.badge--couleur-1.badge--debloque { background: linear-gradient(135deg, #58CC02, #3FA000); }
.badge--couleur-2.badge--debloque { background: linear-gradient(135deg, #1CB0F6, #0E8FD1); }
.badge--couleur-3.badge--debloque { background: linear-gradient(135deg, var(--move), #543A61); }

@keyframes badge-entree {
    from { opacity: 0; transform: translateY(6px) scale(0.9); }
}

summary { cursor: pointer; font-family: 'IBM Plex Mono', monospace; font-size: 13px; }

.bandeau-erreur {
    margin: 12px 16px 0;
    padding: 8px 12px;
    background: #F3D9CC;
    border-radius: 8px;
    font-size: 13px;
}

canvas { margin-top: 14px; max-height: 120px; }

/* --- Dynamisme général : entrée des cartes, bouton, barre de progression --- */

.carte {
    animation: carte-entree 0.45s cubic-bezier(0.16, 1, 0.3, 1) backwards;
}
.contenu > .carte:nth-child(1) { animation-delay: 0.02s; }
.contenu > .carte:nth-child(2) { animation-delay: 0.08s; }
.contenu > .carte:nth-child(3) { animation-delay: 0.14s; }
.contenu > .carte:nth-child(4) { animation-delay: 0.2s; }
.contenu > .carte:nth-child(5) { animation-delay: 0.26s; }

@keyframes carte-entree {
    from { opacity: 0; transform: translateY(10px); }
}

.bouton-principal {
    transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.15s ease;
    box-shadow: 0 3px 0 rgba(0,0,0,0.25);
}
.bouton-principal:hover { transform: translateY(-1px); }
.bouton-principal:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0,0,0,0.25); }

.barre-fill {
    background: linear-gradient(90deg, var(--move), #8E6BA0);
    box-shadow: 0 0 12px rgba(107, 76, 122, 0.5);
}

/* --- Écran de célébration --- */

.celebration {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(35, 47, 29, 0.55);
    backdrop-filter: blur(2px);
    animation: celebration-fond 0.25s ease;
    padding: 20px;
}

@keyframes celebration-fond {
    from { opacity: 0; }
}

.celebration__confettis {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}

.confetti {
    position: absolute;
    top: -10%;
    width: 9px;
    height: 9px;
    border-radius: 2px;
    animation: confetti-chute 2.6s ease-in forwards infinite;
}

.confetti--0 { background: #F5A623; }
.confetti--1 { background: #58CC02; }
.confetti--2 { background: #1CB0F6; }
.confetti--3 { background: var(--move); }

@keyframes confetti-chute {
    from { transform: translateY(0) rotate(0deg); opacity: 1; }
    to { transform: translateY(110vh) rotate(540deg); opacity: 0.3; }
}

.celebration__carte {
    position: relative;
    background: var(--paper-card);
    border-radius: 22px;
    padding: 32px 28px 26px;
    max-width: 380px;
    width: 100%;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0,0,0,0.3);
    animation: celebration-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
    animation-delay: 0.1s;
}

@keyframes celebration-pop {
    from { opacity: 0; transform: scale(0.7) translateY(20px); }
}

.celebration__mascotte {
    font-size: 64px;
    animation: mascotte-rebond 1.1s ease infinite;
}

@keyframes mascotte-rebond {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    30% { transform: translateY(-10px) rotate(-6deg); }
    60% { transform: translateY(0) rotate(4deg); }
}

.celebration__titre {
    font-size: 24px;
    margin: 10px 0 4px;
    color: var(--move);
}

.celebration__soustitre {
    font-size: 14px;
    opacity: 0.75;
    margin: 0 0 18px;
}

.celebration__badges {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
}

.celebration__badge {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--paper);
    border-radius: 12px;
    padding: 10px 14px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 13px;
    font-weight: 500;
    animation: badge-entree 0.4s ease backwards;
    animation-delay: 0.3s;
}

.celebration__badge-icone { font-size: 22px; }

.bouton-principal--celebration {
    width: 100%;
    padding: 12px;
    font-size: 14px;
    background: var(--move);
}

@media (prefers-reduced-motion: reduce) {
    .barre-fill, .badge, .carte, .celebration, .celebration__carte, .confetti, .celebration__mascotte, .celebration__badge {
        animation: none !important;
        transition: none !important;
    }
}
