/* Styles CSS pour EQUAELIBRE */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Zone de message de succès intégrée - positionnée au centre */
.success-message-area {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60%; /* Largeur raisonnable */
    background: linear-gradient(135deg, rgba(76, 175, 80, 0.8), rgba(69, 160, 73, 0.8)); /* 80% transparent */
    border: 3px solid rgba(46, 125, 50, 0.8); /* Bordure aussi 80% transparente */
    border-radius: 15px; /* Coins arrondis partout */
    margin: 0;
    padding: 20px;
    text-align: center;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3); /* Ombre marquée */
    z-index: 100; /* Au-dessus du contenu */
    /* Suppression de l'animation */
}

.success-text h2 {
    color: white;
    font-size: 32px; /* Augmenté de 24px à 32px */
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.success-text div {
    color: white;
    font-size: 20px; /* Augmenté de 16px à 20px */
    margin: 8px 0;
    font-weight: bold;
}

.success-btn {
    background: #FFC107;
    border: 2px solid #FF8F00;
    border-radius: 8px;
    padding: 10px 20px;
    font-size: 16px;
    font-weight: bold;
    color: #333;
    cursor: pointer;
    margin-top: 15px;
    transition: all 0.3s ease;
}

.success-btn:hover {
    background: #FFD54F;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

@keyframes successSlideDown {
    from {
        opacity: 0;
        transform: translateY(-100%);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

body {
    font-family: 'Comic Sans MS', cursive, sans-serif;
    background: linear-gradient(135deg, #d6f4f4 0%, #a8e6e6 100%);
    min-height: 100vh;
    /* Supprimé overflow: hidden pour permettre le scroll de page */
}

#game-container {
    width: 1000px;
    min-height: 700px; /* Hauteur minimale au lieu de hauteur fixe */
    margin: 50px auto 20px; /* Marge en bas pour éviter que ça colle */
    position: relative;
    background-color: #d6f4f4;
    border: 2px solid #333;
    box-shadow: 0 0 20px rgba(0,0,0,0.3);
}

/* Gestion des écrans */
.screen {
    width: 100%;
    min-height: 100%;
    display: none;
    background-color: #d6f4f4;
    padding: 0;
    flex-direction: column;
}

.screen.active {
    display: flex;
}

/* Écran de jeu avec positionnement relatif pour les messages de succès */
#game-screen {
    position: relative;
}

/* Écran d'introduction */
.intro-content {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    width: 100%;
    padding: 0;
    margin: 0;
}

.intro-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.intro-content h1 {
    display: none;
}

.author {
    display: none;
}

/* Menu principal */
.menu-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    padding: 20px;
    box-sizing: border-box;
    overflow-y: auto;
}

.menu-container h1 {
    font-size: 2.5rem;
    color: #644a96;
    margin-bottom: 30px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    text-align: center;
}

.menu-options {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
    max-width: 700px;
}

.menu-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    height: 140px;
    width: 100%;
    background: linear-gradient(135deg, #e8f4f4 0%, #d0e8e8 100%);
    border: 3px solid #644a96;
    border-radius: 15px;
    font-family: 'Comic Sans MS', cursive, sans-serif;
    font-size: 1.8rem;
    font-weight: bold;
    color: #644a96;
    cursor: pointer;
    transition: all 0.3s ease;
    text-shadow: 1px 1px 2px rgba(255,255,255,0.8);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.menu-button:hover {
    background: linear-gradient(135deg, #f0f6f6 0%, #d8f0f0 100%);
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.15);
    color: #d2b50b;
}

.menu-button img {
    width: 50px;
    height: 50px;
}

/* Menu de configuration */
.config-container {
    padding: 20px;
    height: 100%;
    overflow-y: auto;
}

.config-container h2 {
    text-align: center;
    color: #644a96;
    font-size: 2rem;
    margin-bottom: 20px;
}

.config-content {
    display: flex;
    gap: 40px;
    height: calc(100% - 80px);
}

.config-explanation {
    flex: 2;
    font-size: 1rem;
    color: #644a96;
    font-weight: bold;
    line-height: 1.4;
}

.config-explanation p {
    margin-bottom: 10px;
}

.config-explanation hr {
    margin: 15px 0;
    border: 1px solid #644a96;
}

.level-list {
    margin: 10px 0;
}

.config-inputs {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 30px;
}

/* Questions oui/non du menu de niveau */
.config-questions {
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
}

.config-question {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.config-question__label {
    font-size: 1.2rem;
    font-weight: bold;
    color: #644a96;
}

/* Sélecteur Oui/Non façon pastilles segmentées (remplace le menu déroulant) */
.toggle-pill {
    display: inline-flex;
    border: 3px solid #644a96;
    border-radius: 999px;
    overflow: hidden;
    background: #fff;
}

.toggle-pill input {
    display: none;
}

.toggle-pill label {
    padding: 8px 26px;
    font-size: 1.1rem;
    font-weight: bold;
    color: #644a96;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s ease, color 0.2s ease;
    font-family: 'Comic Sans MS', cursive, sans-serif;
}

.toggle-pill label:first-of-type {
    border-right: 2px solid #644a96;
}

.toggle-pill label:hover {
    background: rgba(100, 74, 150, 0.12);
}

.toggle-pill input:checked + label {
    background: linear-gradient(135deg, #44a857 0%, #3d9650 100%);
    color: #fff;
}

.toggle-pill input:checked + label:hover {
    background: linear-gradient(135deg, #4eb85f 0%, #47a557 100%);
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.input-group label {
    font-size: 1rem;
    font-weight: bold;
    color: #644a96;
}

.config-input {
    padding: 12px;
    font-size: 1.2rem;
    border: 3px solid #644a96;
    border-radius: 5px;
    background-color: #fdce24;
    color: #333;
    font-weight: bold;
    text-align: center;
}

.start-button {
    padding: 20px 40px;
    font-size: 1.5rem;
    font-weight: bold;
    background: linear-gradient(135deg, #44a857 0%, #3d9650 100%);
    color: white;
    border: 3px solid #2d7040;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Comic Sans MS', cursive, sans-serif;
}

.start-button:hover {
    background: linear-gradient(135deg, #4eb85f 0%, #47a557 100%);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

/* Boutons de sélection de niveau (0-30) */
.level-buttons {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.level-button {
    padding: 12px 0;
    font-size: 1.2rem;
    font-weight: bold;
    background: linear-gradient(135deg, #5a8fd4 0%, #4a7dc0 100%);
    color: white;
    border: 3px solid #3a64a0;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Comic Sans MS', cursive, sans-serif;
}

.level-button:hover {
    background: linear-gradient(135deg, #6a9de0 0%, #5a8fd4 100%);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

.level-button--selected {
    background: linear-gradient(135deg, #44a857 0%, #3d9650 100%);
    border-color: #2d7040;
}

.level-button--selected:hover {
    background: linear-gradient(135deg, #4eb85f 0%, #47a557 100%);
}

/* Écran de jeu */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: linear-gradient(135deg, #b8e0e0 0%, #a0d0d0 100%);
    border-bottom: 2px solid #644a96;
    font-weight: bold;
    font-size: 1.25rem;
}

.game-info, .score-info {
    display: flex;
    gap: 30px;
    color: #333;
}

.game-content {
    display: flex;
    flex-direction: row;
    height: calc(100% - 80px);
    padding: 20px;
    gap: 20px;
}

.calculation-steps {
    flex: 1;
    background: white;
    border: 2px solid #644a96;
    border-radius: 10px;
    padding: 20px;
    /* Supprimé overflow-y: auto pour permettre la croissance */
}

.calculation-steps h3 {
    color: #644a96;
    font-size: 0.9rem; /* Diminué encore plus de 1.1rem à 0.9rem */
    margin-bottom: 15px;
}

.calculation-step {
    display: flex;
    align-items: baseline; /* Changé de flex-start à baseline */
    gap: 10px;
    margin: 10px 0;
    padding: 10px;
    background: #f8f8f8;
    border-radius: 5px;
    min-height: auto;
    overflow: visible;
}

/* Layout spécifique pour les étapes d'équation */
.calculation-step.equation-step {
    display: block;
}

.step-text {
    color: #644a96;
    font-weight: bold;
    font-size: 1.3rem; /* Augmenté de 1.1rem à 1.3rem */
    flex-shrink: 0;
    line-height: 1.4; /* Assurer une ligne de base cohérente */
}

.step-expression {
    color: #d2b50b;
    font-weight: bold;
    font-size: 1.6rem !important; /* Ajusté de 1.8rem à 1.6rem */
    line-height: 1.4 !important;
    min-height: 2em;
    display: flex;
    align-items: baseline; /* Alignement à la ligne de base */
    overflow: visible;
}

.operation-panel {
    width: 300px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    height: 100%;
    flex-shrink: 0;
}

.right-panel {
    width: 200px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    height: 100%;
    flex-shrink: 0;
    margin-left: auto;
}

.operation-panel h3 {
    color: #644a96;
    font-size: 1.4rem; /* Augmenté de 1.3rem à 1.4rem */
    text-align: center;
    margin: 0;
}

.operation-inputs {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: white;
    border: 2px solid #644a96;
    border-radius: 10px;
    padding: 15px;
}

.operation-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    background: white;
    border: 2px solid #644a96;
    border-radius: 5px;
    justify-content: center;
}

.operation-icon {
    width: 30px;
    height: 30px;
}

.operation-label {
    flex: 1;
    font-weight: bold;
    color: #644a96;
}

.operation-input {
    width: 80px;
    padding: 8px;
    border: 2px solid #999;
    border-radius: 3px;
    text-align: center;
    font-size: 0.9rem;
    font-weight: bold;
}

.operation-input::placeholder {
    font-size: 0.75rem;
    color: #999;
    font-weight: normal;
}

.operation-input:focus {
    border-color: #644a96;
    outline: none;
    background-color: #fffacd;
}

.operation-input.active {
    border-color: #000;
    background-color: #fffacd;
}

.game-controls {
    display: flex;
    flex-direction: row;
    gap: 10px;
    background: white;
    border: 2px solid #644a96;
    border-radius: 10px;
    padding: 15px;
    justify-content: center;
}

.control-btn {
    padding: 8px 12px;
    font-size: 0.9rem;
    font-weight: bold;
    border: 2px solid #333;
    border-radius: 5px;
    cursor: pointer;
    font-family: 'Comic Sans MS', cursive, sans-serif;
    transition: all 0.2s ease;
}

#undo-btn {
    background-color: #ccc;
    color: #000;
}

#reset-btn {
    background-color: #ff0000;
    color: white;
}

#back-menu-btn {
    background-color: #4a90e2;
    color: white;
}

.control-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 3px 10px rgba(0,0,0,0.2);
}

.target-expression {
    background: white;
    border: 2px solid #644a96;
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 0px;
}

.target-expression h3 {
    color: #644a96;
    font-size: 1.2rem;
    margin-bottom: 10px;
}

.target-label {
    font-weight: bold;
    color: #333;
}

#target-math {
    color: #d2b50b;
    font-weight: bold;
    font-size: 1.4rem !important;
    line-height: 1.4 !important;
    min-height: 2em;
    display: flex;
    align-items: center;
    overflow: visible;
}

/* Écrans de succès et records */
.success-content, .record-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    text-align: center;
    padding: 40px;
}

.success-content h1 {
    font-size: 5rem;
    color: #ff0000;
    margin-bottom: 30px;
    text-shadow: 3px 3px 6px rgba(0,0,0,0.3);
}

#success-message, #success-score {
    font-size: 1.5rem;
    color: #ff0000;
    font-weight: bold;
    margin: 10px 0;
}

.success-btn, #save-record-btn {
    padding: 20px 40px;
    font-size: 1.5rem;
    font-weight: bold;
    background: linear-gradient(135deg, #44a857 0%, #3d9650 100%);
    color: white;
    border: 3px solid #2d7040;
    border-radius: 10px;
    cursor: pointer;
    margin-top: 30px;
    font-family: 'Comic Sans MS', cursive, sans-serif;
    transition: all 0.3s ease;
}

.success-btn:hover, #save-record-btn:hover {
    background: linear-gradient(135deg, #4eb85f 0%, #47a557 100%);
    transform: translateY(-2px);
}

.record-content h2 {
    font-size: 3rem;
    color: #4a90e2;
    margin-bottom: 20px;
}

#record-message {
    font-size: 1.3rem;
    color: #4a90e2;
    font-weight: bold;
    margin-bottom: 30px;
}

.name-input {
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
}

.name-input label {
    font-size: 1.3rem;
    font-weight: bold;
    color: #4a90e2;
}

#player-name {
    padding: 12px;
    font-size: 1.2rem;
    border: 3px solid #4a90e2;
    border-radius: 5px;
    text-align: center;
    width: 300px;
    max-width: 90%;
}

/* Styles pour les opérations colorées */
.operations-good {
    color: #44a857 !important;
}

.operations-bad {
    color: #ff0000 !important;
}

/* Responsive design */
@media (max-width: 1020px) {
    #game-container {
        width: 100vw;
        height: 100vh;
        border: none;
    }
    
    .menu-container h1 {
        font-size: 2.2rem;
        margin-bottom: 25px;
    }
    
    .menu-button {
        font-size: 1.6rem;
        height: 120px;
    }
    
    .menu-button img {
        width: 45px;
        height: 45px;
    }
}

@media (max-width: 768px) {
    /* Tablettes */
    .config-content {
        flex-direction: column;
        gap: 20px;
    }
    
    .config-explanation {
        font-size: 0.9rem;
    }
    
    .menu-container {
        padding: 15px;
    }
    
    .menu-container h1 {
        font-size: 2rem;
        margin-bottom: 20px;
    }
    
    .menu-button {
        font-size: 1.4rem;
        height: 110px;
        gap: 15px;
    }
    
    .menu-button img {
        width: 40px;
        height: 40px;
    }
    
    .game-content {
        flex-direction: column;
        padding: 10px;
        gap: 15px;
    }
    
    .calculation-steps {
        flex: none;
        height: 40%;
        min-height: 200px;
    }
    
    .operation-panel {
        flex: none;
    }
    
    .operation-inputs {
        gap: 8px;
    }
    
    .operation-row {
        padding: 6px;
        gap: 6px;
    }
    
    .operation-input {
        width: 55px;
        font-size: 0.8rem;
        padding: 6px;
    }
    
    .control-btn {
        padding: 8px 12px;
        font-size: 0.9rem;
    }
    
    .operation-input::placeholder {
        font-size: 0.7rem;
    }
}

@media (max-width: 480px) {
    /* Mobiles */
    .intro-content {
        padding: 0;
    }
    
    .intro-image {
        width: 100%;
        height: 100%;
    }
    
    .menu-container {
        padding: 10px;
    }
    
    .menu-container h1 {
        font-size: 1.8rem;
        margin-bottom: 20px;
    }
    
    .menu-options {
        max-width: 100%;
        gap: 10px;
    }
    
    .menu-button {
        font-size: 1.2rem;
        height: 100px;
        gap: 10px;
        flex-direction: row;
        text-align: center;
        padding: 10px;
    }
    
    .menu-button img {
        width: 35px;
        height: 35px;
    }
    
    .config-container {
        padding: 10px;
    }
    
    .config-explanation {
        font-size: 0.8rem;
        line-height: 1.3;
    }
    
    .config-explanation p {
        margin-bottom: 8px;
    }
    
    .config-input {
        padding: 10px;
        font-size: 1rem;
    }
    
    .input-group label {
        font-size: 0.9rem;
    }
    
    .start-button {
        padding: 15px 30px;
        font-size: 1.2rem;
    }
    
    .game-header {
        flex-direction: column;
        gap: 10px;
        text-align: center;
        font-size: 1rem;
    }
    
    .game-info, .score-info {
        flex-direction: column;
        gap: 5px;
    }
    
    .operation-label {
        font-size: 0.9rem;
    }
    
    .operation-input {
        width: 45px;
        padding: 5px;
        font-size: 0.75rem;
    }
    
    .game-controls {
        flex-wrap: wrap;
        gap: 6px;
    }
    
    .control-btn {
        padding: 8px 12px;
        font-size: 0.8rem;
    }
    
    .target-expression {
        padding: 10px;
        margin-bottom: 15px;
    }
    
    .target-expression h3 {
        font-size: 1rem;
        margin-bottom: 8px;
    }
    
    .success-content h1 {
        font-size: 3rem;
    }
    
    #success-message, #success-score {
        font-size: 1.2rem;
    }
}

@media (max-width: 320px) {
    /* Très petits écrans */
    .menu-container h1 {
        font-size: 1.5rem;
        margin-bottom: 15px;
    }
    
    .menu-options {
        gap: 8px;
    }
    
    .menu-button {
        font-size: 1rem;
        height: 85px;
        padding: 8px;
        gap: 8px;
    }
    
    .menu-button img {
        width: 28px;
        height: 28px;
    }
    
    .config-explanation {
        font-size: 0.75rem;
    }
    
    .operation-input {
        width: 40px;
        padding: 4px;
        font-size: 0.7rem;
    }
    
    .operation-label {
        font-size: 0.75rem;
    }
    
    .control-btn {
        padding: 6px 10px;
        font-size: 0.75rem;
    }
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.screen.active {
    animation: fadeIn 0.5s ease-in-out;
}

/* Configuration MathJax pour éviter le redimensionnement automatique */
.MathJax_Display {
    text-align: center !important;
    margin: 0.5em 0 !important;
}

.MathJax {
    font-size: 1.6rem !important; /* Augmenté de 1.2rem à 1.6rem */
    line-height: inherit !important;
    overflow: visible !important;
}

.MathJax_SVG {
    font-size: 1.6rem !important; /* Augmenté de 1.2rem à 1.6rem */
}

.MathJax_SVG_Display {
    text-align: center !important;
    margin: 0.5em 0 !important;
}

/* Forcer MathJax à maintenir une taille constante pour toutes les fractions */
.MathJax_SVG .MJX-tex-math {
    font-size: 1.2rem !important;
    transform: scale(1) !important;
}

/* Styles spécifiques pour MathJax 3 (CHTML) */
mjx-container {
    font-size: 1.6rem !important; /* Ajusté de 1.8rem à 1.6rem */
    line-height: 1.4 !important;
}

mjx-container mjx-math {
    font-size: 1.6rem !important; /* Ajusté de 1.8rem à 1.6rem */
}

/* Empêcher la réduction des fractions imbriquées */
mjx-container mjx-mfrac,
mjx-container mjx-mfrac mjx-num,
mjx-container mjx-mfrac mjx-den {
    font-size: 1.6rem !important; /* Ajusté de 1.8rem à 1.6rem */
    transform: scale(1) !important;
}

/* Forcer une taille constante pour tous les éléments mathématiques */
mjx-container * {
    font-size: inherit !important;
}

/* Règles plus spécifiques pour forcer la taille des expressions */
.step-expression mjx-container,
.target-math-inline mjx-container {
    font-size: 1.6rem !important; /* Ajusté de 1.8rem à 1.6rem */
}

.step-expression mjx-container mjx-math,
.target-math-inline mjx-container mjx-math {
    font-size: 1.6rem !important; /* Ajusté de 1.8rem à 1.6rem */
}

/* Section du haut avec expression et boutons */
.top-section {
    display: flex;
    gap: 15px;
    margin-bottom: 0;
    align-items: flex-start;
}

/* Expression cible - largeur ajustée */
.target-expression-top {
    flex: 1; /* Prend l'espace disponible moins le bouton */
    background: white;
    border: 3px solid #644a96;
    border-radius: 10px;
    padding: 10px 15px;
    display: flex;
    align-items: baseline; /* Changé de center à baseline pour un meilleur alignement */
    gap: 15px;
    min-height: 50px;
    overflow: visible; /* Changé de hidden à visible */
}

.target-label {
    color: #644a96;
    font-size: 1.4rem; /* Augmenté de 1.2rem à 1.4rem */
    font-weight: bold;
    flex-shrink: 0;
    white-space: nowrap;
    line-height: 1.4; /* Assurer une ligne de base cohérente */
}

.target-math-inline {
    flex: 1;
    display: flex;
    align-items: baseline; /* Alignement à la ligne de base */
    color: #d2b50b;
    font-weight: bold;
    font-size: 1.6rem !important; /* Ajusté de 1.8rem à 1.6rem */
    line-height: 1.4 !important; /* Cohérent avec le label */
    overflow: visible;
    min-height: 30px;
    /* Supprimé overflow-x: auto pour éviter le scroll */
    max-width: 100%;
}

/* Container pour les boutons du haut */
.top-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 80px;
}

/* Bouton reset repositionné */
.reset-btn-top {
    width: 80px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #ff0000;
    color: white;
    border: 3px solid #cc0000;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Comic Sans MS', cursive, sans-serif;
}

.reset-btn-top:hover {
    background-color: #ff3333;
    transform: translateY(-2px);
    box-shadow: 0 3px 10px rgba(0,0,0,0.2);
}

/* Bouton menu repositionné */
.menu-btn-top {
    width: 80px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #4a90e2;
    color: white;
    border: 3px solid #357abd;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Comic Sans MS', cursive, sans-serif;
}

.menu-btn-top:hover {
    background-color: #5ba0f2;
    transform: translateY(-2px);
    box-shadow: 0 3px 10px rgba(0,0,0,0.2);
}

/* Bouton aide (lien vers la vidéo explicative) */
.help-btn-top {
    width: 80px;
    height: 35px;
    margin-top: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #44a857;
    color: white;
    border: 3px solid #2d7040;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Comic Sans MS', cursive, sans-serif;
}

.help-btn-top:hover {
    background-color: #4eb85f;
    transform: translateY(-2px);
    box-shadow: 0 3px 10px rgba(0,0,0,0.2);
}

/* Layout pour le jeu de construction */
.construction-layout {
    display: flex;
    flex: 1;
    gap: 20px;
    /* Supprimé height fixe pour permettre la croissance automatique */
}

/* Classes utilitaires pour les notifications */
.notification {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: #644a96;
    color: white;
    text-align: center;
    padding: 15px;
    font-weight: bold;
    font-size: 1.2rem;
    z-index: 1000;
    transform: translateY(-100%);
    transition: transform 0.3s ease;
}

.notification.show {
    transform: translateY(0);
}

.notification.error {
    background: #ff0000;
}

.notification.success {
    background: #44a857;
}

.notification.warning {
    background: #ff8c00;
}

/* Interface de résolution symétrique - 3 colonnes */
.equation-learning-layout {
    display: grid;
    grid-template-columns: 100px 1fr 100px;
    gap: 15px;
    flex: 1;
    padding: 15px;
}

/* Ligne du bas avec solution directe et boutons */
.bottom-controls-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    gap: 20px;
}

/* Solution directe à gauche */
.direct-solution {
    display: flex;
    align-items: center;
    gap: 8px;
    background: white;
    border: 2px solid #28a745;
    border-radius: 8px;
    padding: 8px 12px;
}

.solution-label {
    color: #28a745;
    font-weight: bold;
    font-size: 1.1rem;
}

.direct-solution .operation-icon {
    width: 20px;
    height: 20px;
}

.direct-solution .equation-input {
    border-color: #28a745;
    background: #f8fff9;
    width: 60px;
}

/* Boutons de contrôle à droite */
.game-controls-right {
    display: flex;
    gap: 10px;
}

/* Panneau d'opérations à droite pour construction/déconstruction */
.right-operations-panel {
    width: 100px;
    display: flex;
    flex-direction: column;
    background: white;
    border: 2px solid #644a96;
    border-radius: 8px;
    padding: 8px;
}

.right-operations-panel h4 {
    color: #644a96;
    font-size: 0.9rem;
    text-align: center;
    margin-bottom: 8px;
    font-weight: bold;
}

.right-operations-panel .operation-column {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.right-operations-panel .operation-row-eq {
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 4px;
    background: #f8f8f8;
    border: 1px solid #ddd;
    border-radius: 4px;
    min-height: 30px;
}

.right-operations-panel .operation-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.right-operations-panel .equation-input {
    width: 45px;
    padding: 4px 2px;
    border: 2px solid #ced4da;
    border-radius: 3px;
    text-align: center;
    font-size: 0.85rem;
    background: white;
    font-weight: bold;
}

/* Interface largeur complète pour construction/déconstruction */
.wide-calculation-steps {
    flex: 1;
    background: white;
    border: 2px solid #644a96;
    border-radius: 10px;
    padding: 20px;
    overflow-y: auto;
    margin-bottom: 15px;
}

.wide-calculation-steps h3 {
    color: #644a96;
    font-size: 1.5rem;
    margin-bottom: 15px;
}

.bottom-section {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.operations-section {
    flex: 1;
}

.operations-section h4 {
    color: #644a96;
    font-size: 1.2rem;
    margin-bottom: 10px;
    font-weight: bold;
}

.operations-grid {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.operation-row-compact {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    background: white;
    border: 2px solid #644a96;
    border-radius: 5px;
}

.operation-row-compact .operation-icon {
    width: 20px;
    height: 20px;
}

.operation-row-compact .equation-input {
    width: 60px;
    padding: 6px 8px;
    border: 2px solid #ced4da;
    border-radius: 3px;
    text-align: center;
    font-size: 0.9rem;
    background: white;
    font-weight: bold;
}

.target-and-controls, .controls-only {
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: flex-end;
}

.target-and-controls .target-expression {
    background: white;
    border: 2px solid #644a96;
    border-radius: 10px;
    padding: 15px;
    min-width: 200px;
}

.controls-only .game-controls, .target-and-controls .game-controls {
    display: flex;
    gap: 10px;
}

/* Colonnes latérales d'opérations */
.left-operations, .right-operations {
    display: flex;
    flex-direction: column;
    background: white;
    border: 2px solid #644a96;
    border-radius: 8px;
    padding: 8px;
}

.left-operations h4, .right-operations h4 {
    color: #644a96;
    font-size: 0.9rem;
    text-align: center;
    margin-bottom: 8px;
    font-weight: bold;
}

.operation-column {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

/* Lignes d'opérations dans l'interface symétrique */
.operation-row-eq {
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 4px;
    background: #f8f8f8;
    border: 1px solid #ddd;
    border-radius: 4px;
    min-height: 30px;
}

.operation-row-eq .operation-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* Inputs pour l'interface symétrique */
.equation-input {
    width: 45px;
    padding: 4px 2px;
    border: 2px solid #ced4da;
    border-radius: 3px;
    text-align: center;
    font-size: 0.85rem;
    background: white;
    font-weight: bold;
}

.equation-input:focus {
    outline: none;
    border-color: #644a96;
    background-color: #fffacd;
    box-shadow: 0 0 0 0.2rem rgba(100, 74, 150, 0.25);
}

/* Input spécial pour la solution */
.equation-input[data-operation="solve"] {
    border-color: #28a745;
    background: #f8fff9;
    font-weight: bold;
}

.equation-input[data-operation="solve"]:focus {
    border-color: #20c997;
    background: #e8f5e8;
    box-shadow: 0 0 0 0.2rem rgba(32, 201, 151, 0.25);
}

/* Colonne centrale - programme de calcul */
.calculation-steps {
    background: white;
    border: 2px solid #644a96;
    border-radius: 10px;
    padding: 20px;
    overflow-y: auto;
}

.calculation-steps h3 {
    color: #644a96;
    font-size: 1.5rem;
    margin-bottom: 15px;
    text-align: center;
}

/* Étapes d'équation */
.equation-step {
    margin: 10px 0;
    padding: 10px;
    background: #f8f8f8;
    border-radius: 5px;
    border-left: 4px solid #644a96;
}

.equation-step .step-text {
    display: block;
    margin-bottom: 8px;
    color: #644a96;
    font-weight: bold;
    font-size: 1.1rem;
}

.equation-display {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 10px;
    min-height: auto;
}

.equation-left, .equation-right {
    color: #d2b50b;
    font-weight: bold;
    font-size: 1.2rem !important;
    line-height: 1.4 !important;
    min-height: 2em;
    display: flex;
    align-items: center;
    overflow: visible;
}

.equation-equals {
    color: #644a96;
    font-weight: bold;
    font-size: 1.2rem !important;
    line-height: 1.4 !important;
    min-height: 2em;
    display: flex;
    align-items: center;
    padding-top: 2px;
}

/* Responsive pour l'interface symétrique */
@media (max-width: 768px) {
    .equation-learning-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
        gap: 15px;
        padding: 10px;
    }
    
    .left-operations, .right-operations {
        padding: 10px;
    }
    
    .operation-row-eq {
        padding: 6px;
        min-height: 40px;
    }
    
    .equation-input {
        font-size: 0.9rem;
        padding: 6px 8px;
    }
}

@media (max-width: 480px) {
    .equation-learning-layout {
        gap: 10px;
        padding: 5px;
    }
    
    .left-operations h4, .right-operations h4 {
        font-size: 1rem;
        margin-bottom: 10px;
    }
    
    .operation-row-eq .operation-icon {
        width: 20px;
        height: 20px;
    }
    
    .equation-input {
        font-size: 0.8rem;
        padding: 5px 6px;
        min-width: 50px;
    }
}

/* ====== STYLES POUR LE JEU DE DÉVELOPPEMENT ====== */

.development-layout {
    display: flex;
    gap: 20px;
    height: 100%;
}

.development-layout .calculation-steps {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.expression-to-develop {
    flex: 1;
    background: white;
    border: 3px solid #644a96;
    border-radius: 10px;
    padding: 10px 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 50px;
    overflow: visible;
    margin-bottom: 0;
}

.expression-header {
    display: flex;
    align-items: baseline;
    gap: 45px;
    min-height: 30px;
}

.source-expression {
    flex: 1;
    display: flex;
    align-items: baseline;
    color: #d2b50b;
    font-weight: bold;
    font-size: 1.6rem !important;
    line-height: 1.4 !important;
    overflow: visible;
}

.source-expression .math-expression {
    color: #d2b50b !important;
    font-size: 2rem !important;
    font-weight: bold !important;
}

/* Assurer que les expressions mathématiques dans development sont jaunes */
.source-expression mjx-container,
.source-expression mjx-container mjx-math,
.source-expression mjx-container mjx-math * {
    color: #d2b50b !important;
}

.answer-construction {
    background: white;
    border: 2px solid #644a96;
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 0px;
}

.answer-construction h4 {
    color: #644a96;
    font-size: 1.4rem;
    margin-bottom: 10px;
    font-weight: bold;
}

.answer-fields {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    justify-content: center;
    flex-wrap: wrap;
}

.development-input {
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid #4CAF50;
    border-radius: 5px;
    padding: 10px;
    font-size: 1.1rem;
    width: 50px;
    text-align: center;
}

.development-input.sign-input {
    width: 50px;
}

.development-input:focus {
    outline: none;
    border-color: #FF9800;
    box-shadow: 0 0 5px rgba(255, 152, 0, 0.5);
}

.multiply-symbol {
    color: white;
    font-size: 1.5rem;
    font-weight: bold;
}

.variable-drop-zone {
    background: rgba(255, 255, 255, 0.1);
    border: 2px dashed #4CAF50;
    border-radius: 5px;
    padding: 10px;
    width: 50px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.variable-drop-zone.drag-over {
    background: rgba(76, 175, 80, 0.3);
    border-color: #8BC34A;
}

.variable-drop-zone.has-variable {
    background: rgba(76, 175, 80, 0.2);
    border-style: solid;
}

.drop-hint {
    color: #aaa;
    font-style: italic;
    font-size: 0.9rem;
}

.selected-variable {
    color: white;
    font-size: 1.2rem;
    font-weight: bold;
}

.validate-btn {
    background-color: #4CAF50;
    color: white;
    padding: 9px 18px;
    font-size: 1.05rem;
    font-weight: bold;
    border: 2px solid #333;
    border-radius: 5px;
    cursor: pointer;
    font-family: 'Comic Sans MS', cursive, sans-serif;
    transition: all 0.2s ease;
}

/* « Aller à la ligne » à gauche, « Valider » à droite */
.answer-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
}

.validate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

/* Bouton « ← » (Retour arrière) à gauche d'Étape suivante */
#backspace-btn.backspace-btn {
    background-color: #644a96;
    color: #fff;
    padding: 6px 10px;
    min-width: 80px;
    font-size: 0.85rem;
    font-weight: bold;
    border: 2px solid #333;
    border-radius: 5px;
    cursor: pointer;
    font-family: 'Comic Sans MS', cursive, sans-serif;
    transition: all 0.2s ease;
}

.backspace-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

/* Bouton Étape suivante (à la place de l'ancien bouton Calcul) */
.next-step-btn {
    background-color: #2196F3;
    color: white;
    padding: 9px 18px;
    font-size: 1.05rem;
    font-weight: bold;
    border: 2px solid #333;
    border-radius: 5px;
    cursor: pointer;
    font-family: 'Comic Sans MS', cursive, sans-serif;
    transition: all 0.2s ease;
}

.next-step-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

/* Lignes d'étapes figées (= ...) empilées sous l'expression source */
.development-steps {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.step-line {
    display: flex;
    align-items: baseline;
    gap: 10px;
}

.step-expr {
    color: #d2b50b;
    font-weight: bold;
    font-size: 1.4rem !important;
    line-height: 1.4 !important;
    display: flex;
    align-items: baseline;
}

.step-expr mjx-container,
.step-expr mjx-container mjx-math,
.step-expr mjx-container mjx-math * {
    color: #d2b50b !important;
}

/* Ligne du résultat attendu (victoire), en vert, sous la dernière ligne du joueur */
.final-result {
    display: flex;
    align-items: baseline;
    gap: 10px;
    min-height: 30px;
}

.final-result .equals-sign {
    color: #4CAF50;
}

.final-expression {
    color: #4CAF50;
    font-weight: bold;
    font-size: 1.4rem !important;
    line-height: 1.4 !important;
    display: flex;
    align-items: baseline;
}

.final-expression mjx-container,
.final-expression mjx-container mjx-math,
.final-expression mjx-container mjx-math * {
    color: #4CAF50 !important;
}

/* Barre horizontale des boutons Reset/Menu/Aide, tout en haut de la fenêtre */
.top-bar {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
}

/* Zone des animations (+N, PERFECT!) au milieu de la barre, entre la jauge
   (à gauche) et les boutons (à droite). Sert d'ancre de positionnement. */
.badge-zone {
    flex: 1;
    align-self: stretch;
    position: relative;
    overflow: visible;
}

/* Boutons Reset/Menu/Aide en ligne, collés à droite */
.top-bar-buttons {
    display: flex;
    flex-direction: row;
    gap: 10px;
}

/* En ligne horizontale, annuler le décalage vertical hérité du bouton Aide */
.top-bar-buttons .help-btn-top {
    margin-top: 0;
}

/* Jauge de score : libellé « Score » à gauche + barre HORIZONTALE de 12 briques
   VERTICALES collées (35×60) */
.score-gauge {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
}

/* « Score » présenté comme un petit badge dessiné (plaque dorée, raccord briques) */
.gauge-title {
    font-family: 'Comic Sans MS', cursive, sans-serif;
    font-weight: 900;
    font-size: 1.3rem;
    color: #fff;
    background: linear-gradient(135deg, #ffd54f, #ff9800);
    border: 3px solid #e65100;
    border-radius: 10px;
    padding: 6px 14px;
    transform: rotate(-4deg);
    text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.25);
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.15);
}

/* Badge « Score » : clignote + vibre à chaque point gagné */
.gauge-title--celebrate {
    animation: score-celebrate 0.5s ease-in-out 3;
}

@keyframes score-celebrate {
    0%   { transform: rotate(-4deg) translateX(0);    opacity: 1; }
    25%  { transform: rotate(3deg)  translateX(-3px); opacity: 0.3; }
    50%  { transform: rotate(-8deg) translateX(3px);  opacity: 1; }
    75%  { transform: rotate(2deg)  translateX(-2px); opacity: 0.3; }
    100% { transform: rotate(-4deg) translateX(0);    opacity: 1; }
}

.gauge-bricks {
    display: flex;
    flex-direction: row;
    gap: 0; /* briques collées */
}

.gauge-brick {
    width: 35px;
    height: 60px;
    border: 3px solid #b0a06a;
    border-radius: 8px;
    background: #e8e8e8;
    box-sizing: border-box;
    transition: background 0.15s ease;
}

.gauge-brick--filled {
    background: var(--fill);
    border-color: rgba(0, 0, 0, 0.35);
}

.gauge-brick--pop {
    animation: gauge-pop 0.25s ease;
}

@keyframes gauge-pop {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.5); }
    100% { transform: scale(1); }
}

.gauge-brick--flash {
    animation: gauge-flash 0.4s ease-in-out 3;
}

/* La jauge pleine ne change PAS de couleur : elle clignote (opacité) le temps
   du passage au niveau suivant, en gardant la couleur de chaque brique */
@keyframes gauge-flash {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.2; }
}

.gauge-float {
    position: absolute;
    top: -14px;
    right: -6px;
    font-family: 'Comic Sans MS', cursive, sans-serif;
    font-weight: 900;
    font-size: 1.6rem;
    color: #4CAF50;
    opacity: 0;
    pointer-events: none;
}

.gauge-float--show {
    animation: gauge-float-up 0.9s ease-out;
}

@keyframes gauge-float-up {
    0%   { opacity: 0; transform: translateY(8px) scale(0.6); }
    25%  { opacity: 1; transform: translateY(-4px) scale(1.1); }
    100% { opacity: 0; transform: translateY(-28px) scale(1); }
}

/* --- Animation « PERFECT MATCH » --- */

/* Le container doit être positionné pour ancrer le badge */
.expression-to-develop {
    position: relative;
}

/* Calque de dessin (annotations : entourer/barrer) au-dessus des expressions.
   Transparent, curseur « stylo » vert, purement visuel. */
.draw-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M3 21l3-1L19 7l-2-2L4 18z" fill="%234CAF50" stroke="%231b5e20"/><path d="M3 21l3-1-2-2z" fill="%231b5e20"/></svg>') 3 21, crosshair;
}

/* Clignotement commun à la ligne du joueur et au résultat Algebrite (~2 s) */
@keyframes perfect-blink {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.1; }
}

.perfect-blink {
    animation: perfect-blink 0.4s ease-in-out 5;
}

/* Badge manga en étoile, en ligne juste à côté de la note « Excellent! » */
.perfect-badge {
    width: 200px;
    height: 200px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    align-self: center;
    flex-shrink: 0;
    position: relative;
    margin-left: 45px;
    top: -30px;
    pointer-events: none;
    background: radial-gradient(circle, #ffeb3b 0%, #ff9800 65%, #f57c00 100%);
    clip-path: polygon(50% 0%, 61% 18%, 83% 12%, 78% 35%, 100% 38%, 82% 53%, 96% 73%, 72% 70%, 68% 93%, 50% 78%, 32% 93%, 28% 70%, 4% 73%, 18% 53%, 0% 38%, 22% 35%, 17% 12%, 39% 18%);
    transform: rotate(-12deg) scale(0);
}

/* Animation distincte de celle du badge « +N » (qui, lui, fait pop + wobble) */
.perfect-badge--show {
    animation: perfect-zoom 0.5s cubic-bezier(0.2, 1.6, 0.4, 1) forwards;
}

@keyframes perfect-zoom {
    0%   { transform: rotate(12deg)  scale(0); }
    55%  { transform: rotate(-8deg)  scale(1.2); }
    100% { transform: rotate(-6deg)  scale(1); }
}

@keyframes perfect-pop {
    0%   { transform: translate(-50%, -50%) rotate(-12deg) scale(0); }
    100% { transform: translate(-50%, -50%) rotate(-12deg) scale(1); }
}

@keyframes perfect-wobble {
    0%, 100% { transform: translate(-50%, -50%) rotate(-12deg) scale(1); }
    50%      { transform: translate(-50%, -50%) rotate(-4deg)  scale(1.08); }
}

.perfect-pow {
    font-family: 'Comic Sans MS', cursive, sans-serif;
    font-size: 1.6rem;
    font-weight: 900;
    color: #d32f2f;
    line-height: 1;
    transform: rotate(-6deg);
    white-space: nowrap;
    text-shadow: 1px 1px 0 #fff, -1px -1px 0 #fff, 1px -1px 0 #fff, -1px 1px 0 #fff;
}

.perfect-text {
    font-family: 'Comic Sans MS', cursive, sans-serif;
    font-size: 0.85rem;
    font-weight: 900;
    color: #1a237e;
    text-transform: uppercase;
    margin-top: 6px;
    text-align: center;
}

/* Badge manga « +N » (même style étoile que WOW), une couleur par valeur */
.points-badge {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 135px;
    height: 135px;
    align-items: center;
    justify-content: center;
    z-index: 52;
    pointer-events: none;
    clip-path: polygon(50% 0%, 61% 18%, 83% 12%, 78% 35%, 100% 38%, 82% 53%, 96% 73%, 72% 70%, 68% 93%, 50% 78%, 32% 93%, 28% 70%, 4% 73%, 18% 53%, 0% 38%, 22% 35%, 17% 12%, 39% 18%);
    transform: translate(-50%, -50%) rotate(-12deg) scale(0);
}

.points-badge--1 { background: radial-gradient(circle, #a5d6a7 0%, #4CAF50 65%, #2e7d32 100%); }
.points-badge--2 { background: radial-gradient(circle, #90caf9 0%, #2196F3 65%, #1565c0 100%); }
.points-badge--3 { background: radial-gradient(circle, #ce93d8 0%, #9c27b0 65%, #6a1b9a 100%); }
.points-badge--4 { background: radial-gradient(circle, #b39ddb 0%, #644a96 60%, #4a3570 100%); }
.points-badge--minus { background: radial-gradient(circle, #777 0%, #222 60%, #000 100%); }

.points-badge--show {
    animation: perfect-pop 0.45s cubic-bezier(0.2, 1.5, 0.4, 1) forwards,
               perfect-wobble 0.5s ease-in-out 0.45s 3;
}

.points-text {
    font-family: 'Comic Sans MS', cursive, sans-serif;
    font-size: 1.7rem;
    font-weight: 900;
    color: #fff;
    transform: rotate(-4deg);
    text-shadow: 2px 2px 0 rgba(0,0,0,0.35), -1px -1px 0 rgba(0,0,0,0.35);
}

/* Annotation manuscrite « style prof » à côté de la dernière expression du joueur */
.teacher-note {
    font-family: 'Segoe Script', 'Bradley Hand', 'Comic Sans MS', cursive;
    font-size: 1.4rem;
    font-weight: bold;
    color: #d32f2f;
    transform: rotate(-3deg);
    margin-left: 14px;
    line-height: 1.2;
    opacity: 0;
}

.teacher-note--show {
    animation: teacher-write 0.5s ease-out forwards;
}

@keyframes teacher-write {
    0%   { opacity: 0; transform: rotate(-3deg) translateX(-10px) scale(0.9); }
    100% { opacity: 1; transform: rotate(-3deg) translateX(0) scale(1); }
}

/* Croix rouge signalant la ligne fausse (sur l'écho de la grille) */
.step-cross {
    color: #e53935;
    font-size: 1.6rem;
    font-weight: bold;
    flex-shrink: 0;
    margin-left: 12px;
}

/* Bouton Annuler dans le cadre blanc */
.development-layout .game-controls .control-btn {
    background-color: #ccc;
    color: #000;
    padding: 6px 10px;
    min-width: 80px;
    font-size: 0.85rem;
    font-weight: bold;
    border: 2px solid #333;
    border-radius: 5px;
    cursor: pointer;
    font-family: 'Comic Sans MS', cursive, sans-serif;
    transition: all 0.2s ease;
}

.development-layout .game-controls .control-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}


/* Panneau de droite identique au jeu 1 */
.development-layout .right-panel {
    width: 200px;
}

.development-layout .right-panel h3 {
    color: #644a96;
    font-size: 1.4rem;
    text-align: center;
    margin: 0;
    margin-bottom: 15px;
}

.development-layout .variable-tiles {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

.variable-tile {
    background: linear-gradient(135deg, #FF9800, #F57C00);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: grab;
    user-select: none;
    border: 2px solid #E65100;
    transition: all 0.3s ease;
    text-align: center;
    width: 50px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
}

.variable-tile:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.variable-tile.dragging {
    opacity: 0.5;
    transform: rotate(5deg);
}

/* Boutons Reset/Menu en haut SANS cadre */
.top-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-left: 20px;
}

/* Bouton Annuler AVEC cadre blanc */
.development-layout .game-controls {
    display: flex;
    flex-direction: row;
    gap: 10px;
    background: white;
    border: 2px solid #644a96;
    border-radius: 10px;
    padding: 15px;
    justify-content: center;
}

/* Styles pour boutons Reset/Menu en haut */
.reset-btn-top, .menu-btn-top {
    padding: 8px 12px;
    font-size: 0.9rem;
    font-weight: bold;
    border: 2px solid #333;
    border-radius: 5px;
    cursor: pointer;
    font-family: 'Comic Sans MS', cursive, sans-serif;
    transition: all 0.2s ease;
}

.reset-btn-top:hover, .menu-btn-top:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

/* Suppression de l'ancien style du bouton valider dans le panneau */

/* Résultat dynamique dans le container expression-to-develop */
.dynamic-result {
    display: flex;
    align-items: baseline;
    gap: 10px;
    min-height: 30px;
    padding-left: 0;
    border-top: 1px solid #e0e0e0;
    padding-top: 10px;
    margin-top: 5px;
}

.equals-sign {
    color: #4CAF50;
    font-size: 1.4rem;
    font-weight: bold;
    flex-shrink: 0;
}

.dynamic-expression {
    flex: 0 1 auto;
    color: #d2b50b;
    font-weight: bold;
    font-size: 1.4rem !important;
    line-height: 1.4 !important;
    display: flex;
    align-items: baseline;
}

/* Assurer que les expressions mathématiques dynamiques sont jaunes */
.dynamic-expression mjx-container,
.dynamic-expression mjx-container mjx-math,
.dynamic-expression mjx-container mjx-math * {
    color: #d2b50b !important;
}

/* Container des vignettes d'éléments */
.elements-container {
    background: white;
    border: 2px solid #4CAF50;
    border-radius: 8px;
    padding: 10px 15px;
    margin-top: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.element-tiles {
    display: flex;
    gap: 5px;
    justify-content: center;
    align-items: center;
}

/* Badge « Take A Brick! » sur sa propre ligne, au-dessus des tuiles, à gauche —
   orange exact des tuiles */
.tiles-badge {
    align-self: flex-start;
    font-family: 'Comic Sans MS', cursive, sans-serif;
    font-weight: 900;
    font-size: 1.2rem;
    color: #fff;
    background: linear-gradient(135deg, #FF9800, #F57C00);
    border: 3px solid #E65100;
    border-radius: 10px;
    padding: 6px 14px;
    transform: rotate(-3deg);
    text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.25);
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.15);
    white-space: nowrap;
    cursor: default;
}

/* Vibration au survol de la souris */
.tiles-badge:hover {
    animation: brick-shake 0.35s ease-in-out infinite;
}

.element-tile {
    background: linear-gradient(135deg, #FF9800, #F57C00);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 1.5rem;
    font-weight: bold;
    border: 2px solid #E65100;
    text-align: center;
    min-width: 30px;
    font-family: 'Latin Modern Math', 'Computer Modern', 'Times New Roman', serif;
    font-style: italic;
}

/* Vibration des tuiles oranges au survol — seulement les tuiles déplaçables
   (les parenthèses, interdites/non déplaçables, ne vibrent pas) */
.element-tile[draggable="true"]:hover {
    animation: brick-shake 0.35s ease-in-out infinite;
}

/* Badge « Put it there! » (remplace le titre « Votre développement »),
   même look que « Move The Bricks! » mais en flux normal */
.put-badge {
    display: inline-block;
    margin-bottom: 10px;
    font-family: 'Comic Sans MS', cursive, sans-serif;
    font-weight: 900;
    font-size: 1.3rem;
    color: #fff;
    background: linear-gradient(135deg, #FF9800, #F57C00);
    border: 3px solid #E65100;
    border-radius: 10px;
    padding: 6px 14px;
    transform: rotate(-3deg);
    text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.25);
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.15);
    cursor: default;
}

.put-badge:hover {
    animation: brick-shake 0.35s ease-in-out infinite;
}

@keyframes brick-shake {
    0%, 100% { transform: rotate(0deg)  translateX(0); }
    25%      { transform: rotate(4deg)  translateX(-2px); }
    50%      { transform: rotate(-4deg) translateX(2px); }
    75%      { transform: rotate(2deg)  translateX(-1px); }
}

.element-tile-fraction-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
}

.element-tile-frac-line {
    width: 100%;
    height: 3px;
    background-color: #644a96;
    margin: 1px 0;
}

/* ====== NOUVEAU SYSTÈME DRAG & DROP ====== */

/* Vignettes déplaçables dans le panneau de droite */
.draggable-elements {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
}

.draggable-tile {
    background: linear-gradient(135deg, #FF9800, #F57C00);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: grab;
    user-select: none;
    border: 2px solid #E65100;
    transition: all 0.3s ease;
    text-align: center;
    width: 50px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
}

.draggable-tile.sign-tile {
    background: linear-gradient(135deg, #4CAF50, #45a049);
    border-color: #2E7D32;
}

.draggable-tile:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.draggable-tile.dragging {
    opacity: 0.5;
    transform: rotate(5deg);
}

/* Zone de construction de la réponse */
.answer-construction-area {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    justify-content: center;
    flex-wrap: wrap;
}

/* Zones de dépôt */
.drop-zone {
    background: rgba(255, 255, 255, 0.1);
    border: 2px dashed #4CAF50;
    border-radius: 5px;
    padding: 10px;
    width: 50px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    cursor: pointer;
}

.drop-zone.drag-over {
    background: rgba(76, 175, 80, 0.3);
    border-color: #8BC34A;
    border-style: solid;
}

.drop-zone.filled {
    background: rgba(76, 175, 80, 0.2);
    border-style: solid;
}

.drop-hint {
    color: #aaa;
    font-style: italic;
    font-size: 0.8rem;
}

.dropped-element {
    color: white;
    font-size: 1.1rem;
    font-weight: bold;
}

.operator {
    color: white;
    font-size: 1.5rem;
    font-weight: bold;
}

/* Tableau de développement */
/* Fenêtre coulissante : 12 colonnes visibles sur les 37 du track */
.development-grid {
    overflow: hidden;
    width: 648px; /* 12 colonnes de 54px (50px + 2×2px de bordure) */
    max-width: 100%;
    margin: 20px auto;
}

.grid-track {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    position: relative; /* offsetLeft des colonnes relatif au track */
    width: max-content;
    transition: transform 0.3s ease;
}

.grid-column {
    display: flex;
    flex-direction: column;
    height: 104px;
}

.grid-column.centre-mode {
    justify-content: center;
}

.grid-column.fraction-mode {
    justify-content: flex-start;
}

.fraction-line-col {
    width: auto;
    min-width: 50px;
    align-self: stretch;
    height: 4px;
    background-color: #644a96;
    flex-shrink: 0;
}

.grid-cell {
    width: auto;
    min-width: 50px;
    height: 50px;
    border: 2px solid #4CAF50;
    background: rgba(255, 255, 255, 0.1);
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.grid-cell:hover {
    background: rgba(76, 175, 80, 0.2);
}

/* Dénominateur vide d'une fraction au numérateur rempli : « 1 » par défaut (placeholder
   visuel atténué, remplacé dès qu'on tape un vrai dénominateur) */
.grid-cell[data-row="denominator"].den-default-one::after {
    content: '1';
    color: #b09a09;
    opacity: 0.5;
    font-size: 1.3rem;
    font-weight: bold;
    font-family: 'Latin Modern Math', 'Computer Modern', 'Times New Roman', 'Times', serif;
}

.grid-cell.drag-over {
    background: rgba(76, 175, 80, 0.4);
    border-color: #4CAF50;
}

.grid-cell--target {
    background: rgba(100, 74, 150, 0.25);
    border-color: #644a96;
    border-style: dashed;
}

.grid-cell--selected {
    background: rgba(100, 74, 150, 0.4);
    border-color: #644a96;
    border-style: solid;
    box-shadow: 0 0 6px rgba(100, 74, 150, 0.7);
}

.fraction-line {
    height: 4px;
    background-color: #644a96;
    padding: 0;
    border: none;
}

.brick-toggle {
    background: linear-gradient(135deg, #FF9800, #F57C00) !important;
    border-color: #E65100 !important;
    color: white !important;
    font-style: normal !important;
    font-size: 1rem !important;
}

.brick-toggle--den {
    background: linear-gradient(135deg, #e65100, #bf360c) !important;
    border-color: #7f0000 !important;
}

.brick-ent {
    background: linear-gradient(135deg, #ffa726, #fb8c00) !important;
    border-color: #e65100 !important;
    color: #fff !important;
    font-family: 'Comic Sans MS', cursive, sans-serif !important;
    font-style: normal !important;
    font-size: 1.05rem !important;
}

.brick-toggle--ctr {
    background: linear-gradient(135deg, #4CAF50, #388E3C) !important;
    border-color: #2E7D32 !important;
}

.intermediate-wrapper {
    display: flex;
    justify-content: center;
    margin-bottom: 12px;
}

.intermediate-tile {
    min-width: 50px;
    height: 50px;
    padding: 0 10px;
    border: 2px dashed #644a96;
    border-radius: 5px;
    background: rgba(255,255,255,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Latin Modern Math', 'Computer Modern', 'STIX Two Math', 'Times New Roman', serif;
    font-style: italic;
    font-size: 1.3rem;
    font-weight: bold;
    color: white;
    cursor: default;
}

/* Tiret clignotant façon zone de saisie */
.intermediate-tile::after {
    content: '';
    display: inline-block;
    width: 12px;
    height: 2px;
    background: #644a96;
    margin-left: 3px;
    align-self: flex-end;
    margin-bottom: 13px;
    animation: cursor-blink 1s steps(1) infinite;
}

@keyframes cursor-blink {
    0%, 49% { opacity: 1; }
    50%, 100% { opacity: 0; }
}

.intermediate-tile--filled {
    background: linear-gradient(135deg, #f0d020, #d2b50b);
    border: 2px solid #b09a09;
    cursor: pointer;
}

.intermediate-tile--filled::after {
    background: #4a3570;
}

.intermediate-tile--filled:hover {
    transform: scale(1.08);
    box-shadow: 0 3px 8px rgba(0,0,0,0.3);
}

/* Clavier de briques */
.brick-keyboard {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    background: white;
    border: 2px solid #644a96;
    border-radius: 10px;
    padding: 10px;
}

.brick-spacer {
    height: 38px;
}

.brick-tile {
    height: 38px;
    background: linear-gradient(135deg, #644a96, #4a3570);
    color: white;
    border: 2px solid #3a2560;
    border-radius: 5px;
    font-size: 1.3rem;
    font-weight: bold;
    font-family: 'Latin Modern Math', 'Computer Modern', 'STIX Two Math', 'Times New Roman', 'Times', serif;
    font-style: italic;
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.brick-tile:hover {
    transform: scale(1.1);
    box-shadow: 0 3px 6px rgba(0,0,0,0.3);
}

.grid-cell .brick-tile {
    width: 100%;
    height: 100%;
    padding: 0 6px;
    white-space: nowrap;
    border-radius: 3px;
    font-size: 1.3rem;
    cursor: grab;
    background: linear-gradient(135deg, #f0d020, #d2b50b);
    border-color: #b09a09;
    color: white;
}