/**
 * CSS commun pour tous les mini-jeux
 * Outils Pour La Classe - v1.2.0
 * Réduit la duplication de code entre les 130+ jeux
 *
 * AMÉLIORATIONS v1.2.0:
 * - Optimisations GPU avec will-change
 * - Meilleure gestion du scrolling et touch
 * - Support amélioré des safe-areas
 * - Écran de pause
 * - Animations plus fluides
 *
 * NOTE: Ce fichier ne contient PAS de reset global
 * pour éviter les conflits avec les styles spécifiques des jeux.
 * Toutes les classes sont préfixées par .game-
 */

/* =============================================
   OPTIMISATIONS GPU DE BASE
============================================= */

/* Éléments qui seront animés fréquemment */
.game-feedback,
.game-combo,
.game-particle,
.game-end-star,
.game-loading-icon,
.game-progress-fill,
.game-timer-fill {
    will-change: transform, opacity;
}

/* Conteneurs avec beaucoup d'enfants animés */
.game-area,
.game-end-screen {
    will-change: contents;
}

/* Désactiver will-change quand pas nécessaire (économie mémoire) */
.game-feedback:not(.show),
.game-combo:not(.show) {
    will-change: auto;
}

/* =============================================
   VARIABLES CSS (DESIGN TOKENS)
============================================= */
:root {
    /* Couleurs primaires */
    --game-primary: #F59E0B;
    --game-primary-light: #FCD34D;
    --game-primary-dark: #D97706;
    --game-success: #22C55E;
    --game-danger: #EF4444;
    --game-warning: #FBBF24;

    /* Couleurs de fond */
    --game-bg-dark: #0F0F23;
    --game-bg-medium: #1a1a2e;
    --game-bg-light: #16213e;

    /* Tailles responsive */
    --game-btn-size: 50px;
    --game-btn-font: 1.4rem;
    --game-stat-padding: 0.3rem 0.6rem;
    --game-header-padding: 0.5rem 1rem;
    --game-life-size: 1.1rem;
    --game-calc-size: 1.4rem;

    /* Espacements */
    --game-gap-sm: 0.5rem;
    --game-gap-md: 0.8rem;
    --game-gap-lg: 1rem;

    /* Rayons de bordure */
    --game-radius-sm: 10px;
    --game-radius-md: 15px;
    --game-radius-lg: 20px;
    --game-radius-xl: 30px;
}

/* Variables pour tablettes */
@media (min-width: 600px) and (max-width: 1024px) {
    :root {
        --game-btn-size: 60px;
        --game-btn-font: 1.6rem;
        --game-stat-padding: 0.4rem 0.8rem;
        --game-life-size: 1.3rem;
        --game-calc-size: 1.6rem;
    }
}

/* Variables pour petits smartphones */
@media (max-width: 400px) {
    :root {
        --game-btn-size: 44px;
        --game-btn-font: 1.2rem;
        --game-stat-padding: 0.25rem 0.5rem;
        --game-header-padding: 0.4rem 0.75rem;
        --game-life-size: 0.95rem;
        --game-calc-size: 1.2rem;
        --game-gap-sm: 0.4rem;
        --game-gap-md: 0.5rem;
    }
}

/* Variables pour très petits écrans */
@media (max-width: 350px) {
    :root {
        --game-calc-size: 1.1rem;
        --game-gap-sm: 0.3rem;
    }
}

/* Variables pour écrans courts (paysage) */
@media (max-height: 600px) {
    :root {
        --game-header-padding: 0.35rem 0.75rem;
        --game-calc-size: 1.15rem;
    }
}

/* =============================================
   HEADER COMMUN
============================================= */
.game-header {
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(10px);
    padding: 0.5rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    z-index: 20;
    box-shadow: 0 2px 15px rgba(0,0,0,0.1);
}

.game-header.dark {
    background: rgba(0,0,0,0.7);
    color: white;
    border-bottom: 2px solid rgba(245,158,11,0.3);
}

/* Bouton quitter */
.quit-btn {
    background: linear-gradient(135deg, #EF4444, #DC2626);
    border: none;
    color: white;
    width: 50px;
    height: 50px;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 700;
    font-size: 1.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(239,68,68,0.3);
    transition: transform 0.2s;
}

.quit-btn:active {
    transform: scale(0.9);
}

/* Stats */
.game-stats {
    display: flex;
    gap: 0.8rem;
    align-items: center;
}

.game-stat {
    text-align: center;
    background: rgba(245,158,11,0.15);
    padding: 0.3rem 0.6rem;
    border-radius: 10px;
    border: 1px solid rgba(245,158,11,0.2);
}

.game-stat-value {
    font-size: 1rem;
    font-weight: 800;
    color: #FCD34D;
}

.game-stat-label {
    font-size: 0.55rem;
    text-transform: uppercase;
    opacity: 0.7;
}

/* Vies */
.game-lives {
    display: flex;
    gap: 0.3rem;
}

.game-life {
    font-size: 1.1rem;
    transition: transform 0.3s, opacity 0.3s;
    filter: drop-shadow(0 2px 4px rgba(239,68,68,0.3));
}

.game-life.lost {
    transform: scale(0) rotate(180deg);
    opacity: 0;
}

/* =============================================
   BARRE DE PROGRESSION
============================================= */
.game-progress-bar {
    position: fixed;
    top: 52px;
    left: 0;
    right: 0;
    height: 4px;
    background: rgba(0,0,0,0.3);
    z-index: 15;
}

.game-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #F59E0B, #FBBF24, #FCD34D);
    width: 0%;
    transition: width 0.3s ease-out;
    box-shadow: 0 0 10px rgba(245,158,11,0.5);
}

/* =============================================
   TIMER
============================================= */
.game-timer-bar {
    height: 4px;
    background: rgba(255,255,255,0.1);
    border-radius: 2px;
    margin-top: 0.5rem;
    overflow: hidden;
    max-width: 300px;
    margin-left: auto;
    margin-right: auto;
}

.game-timer-fill {
    height: 100%;
    background: linear-gradient(90deg, #22C55E, #4ADE80);
    width: 100%;
    transition: width 0.1s linear;
    border-radius: 2px;
}

.game-timer-fill.warning {
    background: linear-gradient(90deg, #F59E0B, #FBBF24);
}

.game-timer-fill.danger {
    background: linear-gradient(90deg, #EF4444, #F87171);
}

/* =============================================
   COMBO INDICATOR
============================================= */
.game-combo {
    position: fixed;
    top: 120px;
    right: 10px;
    background: linear-gradient(135deg, #F59E0B, #D97706);
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-weight: 800;
    font-size: 0.9rem;
    color: white;
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 50;
    box-shadow: 0 4px 20px rgba(245,158,11,0.4);
}

.game-combo.show {
    opacity: 1;
    transform: scale(1);
}

.game-combo.super {
    background: linear-gradient(135deg, #EF4444, #F59E0B);
    animation: combo-pulse 0.5s ease-in-out infinite;
}

@keyframes combo-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* =============================================
   FEEDBACK POPUP
============================================= */
.game-feedback {
    position: fixed;
    top: 35%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    z-index: 100;
    text-align: center;
    pointer-events: none;
}

.game-feedback.show {
    animation: feedback-pop 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
}

@keyframes feedback-pop {
    0% { transform: translate(-50%, -50%) scale(0) rotate(-10deg); opacity: 0; }
    50% { transform: translate(-50%, -50%) scale(1.2) rotate(5deg); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(1) rotate(0); opacity: 0; }
}

.game-feedback-emoji {
    font-size: 4rem;
    display: block;
}

.game-feedback-text {
    font-size: 1.1rem;
    font-weight: 800;
    color: white;
    text-shadow: 0 2px 10px rgba(0,0,0,0.5);
    margin-top: 0.2rem;
}

.game-feedback-points {
    font-size: 1.4rem;
    font-weight: 800;
    color: #FCD34D;
    text-shadow: 0 0 20px rgba(252,211,77,0.5);
}

/* =============================================
   ECRAN DE FIN
============================================= */
.game-end-screen {
    position: fixed;
    inset: 0;
    background: rgba(15,15,35,0.98);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 200;
    color: white;
    padding: 1rem;
}

.game-end-screen.show {
    display: flex;
    animation: fade-in 0.5s ease-out;
}

@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.game-end-content {
    background: linear-gradient(135deg, rgba(245,158,11,0.2), rgba(217,119,6,0.1));
    border: 2px solid rgba(245,158,11,0.3);
    border-radius: 30px;
    padding: 2rem;
    text-align: center;
    max-width: 350px;
    width: 100%;
}

.game-end-icon {
    font-size: 4rem;
    margin-bottom: 0.5rem;
    animation: end-icon-bounce 1s ease-in-out infinite;
}

@keyframes end-icon-bounce {
    0%, 100% { transform: translateY(0) rotate(-5deg); }
    50% { transform: translateY(-10px) rotate(5deg); }
}

.game-end-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: #FCD34D;
    margin-bottom: 0.5rem;
}

.game-end-subtitle {
    font-size: 0.9rem;
    color: #FBBF24;
    margin-bottom: 1.5rem;
    opacity: 0.8;
}

.game-end-stars {
    font-size: 2.5rem;
    margin-bottom: 1.5rem;
}

.game-end-star {
    display: inline-block;
    opacity: 0.3;
    transition: all 0.5s;
}

.game-end-star.earned {
    opacity: 1;
    animation: star-pop 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes star-pop {
    0% { transform: scale(0) rotate(-180deg); }
    100% { transform: scale(1) rotate(0); }
}

.game-end-stats {
    display: flex;
    gap: 0.8rem;
    margin-bottom: 1.5rem;
    justify-content: center;
    flex-wrap: wrap;
}

.game-end-stat {
    text-align: center;
    padding: 0.8rem 1rem;
    background: rgba(255,255,255,0.05);
    border-radius: 15px;
    min-width: 70px;
}

.game-end-stat-value {
    font-size: 1.6rem;
    font-weight: 800;
    color: #FCD34D;
}

.game-end-stat-label {
    font-size: 0.65rem;
    opacity: 0.7;
    text-transform: uppercase;
}

.game-end-buttons {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
}

.game-end-btn {
    padding: 1rem 1.6rem;
    border-radius: 15px;
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    border: none;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: transform 0.2s, box-shadow 0.2s;
    min-height: 55px;
}

.game-end-btn:active {
    transform: scale(0.95);
}

.game-end-btn-play {
    background: linear-gradient(135deg, #F59E0B, #D97706);
    box-shadow: 0 4px 20px rgba(245,158,11,0.4);
}

.game-end-btn-quit {
    background: rgba(255,255,255,0.1);
}

/* =============================================
   ECRAN DE CHARGEMENT (AMÉLIORÉ)
============================================= */
.game-loading {
    position: fixed;
    inset: 0;
    background: linear-gradient(180deg, #0F0F23, #1a1a2e);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 300;
    transition: opacity 0.5s, visibility 0.5s;
}

.game-loading.hide,
.game-loading.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.game-loading-icon {
    font-size: 4rem;
    animation: loading-bounce 0.5s ease-in-out infinite alternate;
}

@keyframes loading-bounce {
    0% { transform: rotate(-20deg) scale(1); }
    100% { transform: rotate(20deg) scale(1.1); }
}

.game-loading-text {
    margin-top: 1rem;
    font-size: 1.1rem;
    color: #FCD34D;
    font-weight: 600;
    animation: loading-pulse 1.5s ease-in-out infinite;
}

@keyframes loading-pulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

/* Barre de progression du chargement */
.game-loading-bar {
    width: 200px;
    height: 8px;
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
    margin-top: 1.5rem;
    overflow: hidden;
}

.game-loading-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--game-primary), var(--game-primary-light));
    width: 0%;
    border-radius: 4px;
    transition: width 0.3s ease-out;
}

/* =============================================
   ECRAN DE PAUSE
============================================= */
.game-pause-screen {
    position: fixed;
    inset: 0;
    background: rgba(15,15,35,0.95);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 250;
    color: white;
    padding: 1rem;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.game-pause-screen.show {
    display: flex;
    animation: fade-in 0.3s ease-out;
}

.game-pause-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    animation: pause-pulse 2s ease-in-out infinite;
}

@keyframes pause-pulse {
    0%, 100% { transform: scale(1); opacity: 0.8; }
    50% { transform: scale(1.1); opacity: 1; }
}

.game-pause-title {
    font-size: 1.8rem;
    font-weight: 800;
    color: #FCD34D;
    margin-bottom: 0.5rem;
}

.game-pause-subtitle {
    font-size: 1rem;
    opacity: 0.7;
    margin-bottom: 2rem;
}

.game-pause-buttons {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
}

.game-pause-btn {
    padding: 1rem 2rem;
    border-radius: 15px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    border: none;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: transform 0.2s, box-shadow 0.2s;
    min-height: 55px;
}

.game-pause-btn:active {
    transform: scale(0.95);
}

.game-pause-btn-resume {
    background: linear-gradient(135deg, #22C55E, #16A34A);
    box-shadow: 0 4px 20px rgba(34,197,94,0.4);
}

.game-pause-btn-restart {
    background: linear-gradient(135deg, #F59E0B, #D97706);
    box-shadow: 0 4px 20px rgba(245,158,11,0.4);
}

.game-pause-btn-quit {
    background: rgba(255,255,255,0.1);
}

/* =============================================
   CALCUL / QUESTION
============================================= */
.game-calc-bar {
    background: rgba(0,0,0,0.8);
    backdrop-filter: blur(10px);
    padding: 0.6rem 1rem;
    text-align: center;
    position: relative;
    z-index: 10;
    border-bottom: 1px solid rgba(245,158,11,0.2);
}

.game-calc-bar.light {
    background: rgba(255,255,255,0.95);
    border-bottom: none;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

.game-calc {
    font-size: 1.4rem;
    font-weight: 800;
    color: #FCD34D;
}

.game-calc-bar.light .game-calc {
    color: #F59E0B;
}

/* =============================================
   BOUTONS COMMUNS
============================================= */
.game-btn {
    padding: 1rem 1.5rem;
    border-radius: 15px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    border: none;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.game-btn:active {
    transform: scale(0.95);
}

.game-btn-primary {
    background: linear-gradient(135deg, #F59E0B, #D97706);
    color: white;
    box-shadow: 0 4px 15px rgba(245,158,11,0.4);
}

.game-btn-secondary {
    background: rgba(255,255,255,0.1);
    color: white;
}

/* =============================================
   PARTICULES DE SUCCES
============================================= */
.game-particle {
    position: fixed;
    pointer-events: none;
    z-index: 60;
    animation: particle-fly 0.5s ease-out forwards;
}

@keyframes particle-fly {
    0% { transform: translate(0, 0) scale(1) rotate(0); opacity: 1; }
    100% { transform: translate(var(--tx), var(--ty)) scale(0) rotate(180deg); opacity: 0; }
}

/* =============================================
   PREFERS-REDUCED-MOTION
   Accessibilite: desactiver les animations
============================================= */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    .game-loading-icon,
    .game-end-icon,
    .game-combo.super,
    .game-end-star.earned {
        animation: none !important;
    }
}

/* =============================================
   MEDIA QUERIES RESPONSIVE
============================================= */

/* Tablettes (600-1024px) */
@media (min-width: 600px) and (max-width: 1024px) {
    .quit-btn { width: 60px; height: 60px; font-size: 1.6rem; }
    .game-stat { padding: 0.4rem 0.8rem; }
    .game-stat-value { font-size: 1.2rem; }
    .game-life { font-size: 1.3rem; }
    .game-calc { font-size: 1.6rem; }
    .game-combo { padding: 0.5rem 1rem; font-size: 1rem; }
    .game-feedback-emoji { font-size: 5rem; }
    .game-end-icon { font-size: 5rem; }
    .game-end-title { font-size: 1.8rem; }
    .game-end-stars { font-size: 3rem; }
    .game-end-stat-value { font-size: 1.9rem; }
    .game-end-btn { padding: 1.2rem 1.8rem; font-size: 1.15rem; min-height: 60px; }
}

/* Petits smartphones (< 400px) */
@media (max-width: 400px) {
    .game-header { padding: 0.4rem 0.75rem; }
    .quit-btn { width: 44px; height: 44px; font-size: 1.2rem; }
    .game-stats { gap: 0.5rem; }
    .game-stat { padding: 0.25rem 0.5rem; }
    .game-stat-value { font-size: 0.9rem; }
    .game-life { font-size: 0.95rem; }
    .game-lives { gap: 0.2rem; }
    .game-progress-bar { top: 50px; }
    .game-calc-bar { padding: 0.5rem 0.8rem; }
    .game-calc { font-size: 1.2rem; }
    .game-combo { top: 110px; right: 8px; padding: 0.3rem 0.6rem; font-size: 0.8rem; }
    .game-feedback-emoji { font-size: 3.5rem; }
    .game-end-content { padding: 1.5rem; }
    .game-end-icon { font-size: 3.5rem; }
    .game-end-title { font-size: 1.3rem; }
    .game-end-subtitle { font-size: 0.8rem; }
    .game-end-stars { font-size: 2rem; margin-bottom: 1rem; }
    .game-end-stats { gap: 0.6rem; }
    .game-end-stat { padding: 0.6rem 0.8rem; min-width: 60px; }
    .game-end-stat-value { font-size: 1.4rem; }
    .game-end-btn { padding: 0.85rem 1.3rem; font-size: 0.95rem; min-height: 50px; }
}

/* Tres petits ecrans (< 350px) */
@media (max-width: 350px) {
    .game-calc { font-size: 1.1rem; }
    .game-end-stats { gap: 0.5rem; }
    .game-end-stat { padding: 0.5rem 0.6rem; }
    .game-end-stat-value { font-size: 1.2rem; }
    .game-end-buttons { gap: 0.6rem; }
    .game-end-btn { padding: 0.75rem 1rem; font-size: 0.9rem; }
}

/* Mode paysage / ecran court (< 600px hauteur) */
@media (max-height: 600px) {
    .game-header { padding: 0.35rem 0.75rem; }
    .game-progress-bar { top: 48px; }
    .game-calc-bar { padding: 0.4rem 0.6rem; }
    .game-calc { font-size: 1.15rem; }
    .game-timer-bar { margin-top: 0.3rem; }
    .game-combo { top: 100px; }
    .game-feedback { top: 35%; }
    .game-feedback-emoji { font-size: 3rem; }
    .game-end-content { padding: 1.2rem; }
    .game-end-icon { font-size: 3rem; margin-bottom: 0.3rem; }
    .game-end-title { font-size: 1.2rem; }
    .game-end-subtitle { margin-bottom: 0.8rem; }
    .game-end-stars { font-size: 2rem; margin-bottom: 0.8rem; }
    .game-end-stats { gap: 0.5rem; margin-bottom: 1rem; }
    .game-end-stat { padding: 0.5rem; }
    .game-end-stat-value { font-size: 1.3rem; }
}

/* Support explicite safe-area (iPhone X+) */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .game-end-screen {
        padding-bottom: env(safe-area-inset-bottom);
    }
    .game-end-buttons {
        padding-bottom: calc(env(safe-area-inset-bottom) + 10px);
    }
}

/* =============================================
   CLASSES UTILITAIRES RESPONSIVE
   Utilisez ces classes pour éviter de dupliquer
   les media queries dans chaque jeu
============================================= */

/* Flexbox layouts */
.game-flex { display: flex; }
.game-flex-col { display: flex; flex-direction: column; }
.game-flex-center { display: flex; align-items: center; justify-content: center; }
.game-flex-between { display: flex; justify-content: space-between; align-items: center; }
.game-flex-wrap { flex-wrap: wrap; }
.game-gap-sm { gap: var(--game-gap-sm); }
.game-gap-md { gap: var(--game-gap-md); }
.game-gap-lg { gap: var(--game-gap-lg); }

/* Tailles de texte responsive */
.game-text-xs { font-size: 0.65rem; }
.game-text-sm { font-size: 0.8rem; }
.game-text-md { font-size: 1rem; }
.game-text-lg { font-size: 1.2rem; }
.game-text-xl { font-size: 1.5rem; }
.game-text-2xl { font-size: 2rem; }

@media (max-width: 400px) {
    .game-text-xs { font-size: 0.55rem; }
    .game-text-sm { font-size: 0.7rem; }
    .game-text-md { font-size: 0.9rem; }
    .game-text-lg { font-size: 1rem; }
    .game-text-xl { font-size: 1.2rem; }
    .game-text-2xl { font-size: 1.5rem; }
}

@media (min-width: 600px) and (max-width: 1024px) {
    .game-text-lg { font-size: 1.4rem; }
    .game-text-xl { font-size: 1.8rem; }
    .game-text-2xl { font-size: 2.5rem; }
}

/* Font weights */
.game-font-bold { font-weight: 700; }
.game-font-extrabold { font-weight: 800; }

/* Couleurs de texte */
.game-text-primary { color: var(--game-primary-light); }
.game-text-success { color: var(--game-success); }
.game-text-danger { color: var(--game-danger); }
.game-text-muted { opacity: 0.7; }

/* Espacements */
.game-p-sm { padding: 0.5rem; }
.game-p-md { padding: 1rem; }
.game-p-lg { padding: 1.5rem; }
.game-m-auto { margin: auto; }
.game-mt-sm { margin-top: 0.5rem; }
.game-mt-md { margin-top: 1rem; }
.game-mb-sm { margin-bottom: 0.5rem; }
.game-mb-md { margin-bottom: 1rem; }

/* Arrondis */
.game-rounded { border-radius: var(--game-radius-md); }
.game-rounded-full { border-radius: 50%; }

/* Ombres */
.game-shadow { box-shadow: 0 4px 15px rgba(0,0,0,0.2); }
.game-shadow-glow { box-shadow: 0 0 20px rgba(245,158,11,0.5); }

/* Transitions */
.game-transition { transition: all 0.2s ease; }
.game-transition-fast { transition: all 0.1s ease; }

/* Positionnement */
.game-fixed { position: fixed; }
.game-absolute { position: absolute; }
.game-relative { position: relative; }
.game-inset-0 { inset: 0; }
.game-z-10 { z-index: 10; }
.game-z-50 { z-index: 50; }
.game-z-100 { z-index: 100; }

/* Visibilité */
.game-hidden { display: none !important; }
.game-invisible { visibility: hidden; }
.game-pointer-none { pointer-events: none; }

/* Touch */
.game-touch-none { touch-action: none; }
.game-touch-manipulation { touch-action: manipulation; }
.game-select-none { user-select: none; -webkit-user-select: none; }

/* Backgrounds courants */
.game-bg-overlay { background: rgba(0,0,0,0.5); }
.game-bg-overlay-dark { background: rgba(0,0,0,0.8); }
.game-bg-blur { backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }

/* Bordures */
.game-border-primary { border: 2px solid rgba(245,158,11,0.3); }

/* Animation de pulsation */
.game-pulse {
    animation: game-pulse-anim 1s ease-in-out infinite;
}
@keyframes game-pulse-anim {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* Animation de rebond */
.game-bounce {
    animation: game-bounce-anim 0.5s ease-in-out infinite alternate;
}
@keyframes game-bounce-anim {
    0% { transform: translateY(0); }
    100% { transform: translateY(-10px); }
}

/* Animation de shake (erreur) */
.game-shake {
    animation: game-shake-anim 0.3s ease-out;
}
@keyframes game-shake-anim {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

/* Animation de pop (succès) */
.game-pop {
    animation: game-pop-anim 0.3s ease-out;
}
@keyframes game-pop-anim {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* Désactiver les animations */
@media (prefers-reduced-motion: reduce) {
    .game-pulse,
    .game-bounce,
    .game-shake,
    .game-pop {
        animation: none !important;
    }
}

/* =============================================
   OPTIMISATIONS TOUCH MOBILE
============================================= */

/* Empêcher le scroll accidentel pendant le jeu */
.game-body-locked {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
    touch-action: none;
}

/* Zone de jeu optimisée pour le touch */
.game-touch-area {
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* Boutons avec zone de tap agrandie */
.game-tap-target {
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Feedback visuel au tap */
.game-tap-feedback {
    transition: transform 0.1s ease-out, opacity 0.1s ease-out;
}

.game-tap-feedback:active {
    transform: scale(0.95);
    opacity: 0.9;
}

/* =============================================
   PERFORMANCES SCROLLING
============================================= */

/* Conteneur avec scroll optimisé */
.game-scroll-container {
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    scroll-behavior: smooth;
}

/* Désactiver le scroll smooth si reduced-motion */
@media (prefers-reduced-motion: reduce) {
    .game-scroll-container {
        scroll-behavior: auto;
    }
}

/* =============================================
   BOUTON PAUSE
============================================= */

.game-pause-btn-header {
    background: rgba(255,255,255,0.1);
    border: none;
    color: white;
    width: 50px;
    height: 50px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, background 0.2s;
}

.game-pause-btn-header:hover {
    background: rgba(255,255,255,0.2);
}

.game-pause-btn-header:active {
    transform: scale(0.9);
}

/* =============================================
   INDICATEURS DE STATUT
============================================= */

/* Indicateur hors-ligne */
.game-offline-indicator {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(239,68,68,0.9);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    z-index: 500;
    display: none;
    align-items: center;
    gap: 0.5rem;
    backdrop-filter: blur(10px);
}

.game-offline-indicator.show {
    display: flex;
    animation: slide-up 0.3s ease-out;
}

@keyframes slide-up {
    from { transform: translateX(-50%) translateY(20px); opacity: 0; }
    to { transform: translateX(-50%) translateY(0); opacity: 1; }
}

/* =============================================
   FOCUS VISIBLE (ACCESSIBILITÉ)
============================================= */

/* Focus visible pour navigation clavier */
.game-focusable:focus-visible {
    outline: 3px solid var(--game-primary-light);
    outline-offset: 3px;
}

/* Supprimer outline par défaut */
.game-focusable:focus:not(:focus-visible) {
    outline: none;
}

/* =============================================
   SUPPORT SAFE AREA (NOTCH, HOME BAR)
============================================= */

@supports (padding-top: env(safe-area-inset-top)) {
    .game-header {
        padding-top: max(0.5rem, env(safe-area-inset-top));
    }
}

@supports (padding-left: env(safe-area-inset-left)) {
    .game-header,
    .game-end-screen,
    .game-pause-screen {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
    }
}

/* =============================================
   TRANSITIONS FLUIDES ENTRE ÉCRANS
============================================= */

/* Conteneur de transition */
.game-screen {
    transition: opacity 0.3s ease-out, transform 0.3s ease-out;
}

.game-screen.entering {
    opacity: 0;
    transform: scale(0.95);
}

.game-screen.visible {
    opacity: 1;
    transform: scale(1);
}

.game-screen.exiting {
    opacity: 0;
    transform: scale(1.05);
}

/* Transition slide */
.game-screen-slide {
    transition: opacity 0.4s ease-out, transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.game-screen-slide.entering {
    opacity: 0;
    transform: translateY(30px);
}

.game-screen-slide.visible {
    opacity: 1;
    transform: translateY(0);
}

/* =============================================
   MEILLEUR SCORE BADGE
============================================= */

.game-best-score {
    position: fixed;
    top: 70px;
    left: 10px;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.9), rgba(124, 58, 237, 0.9));
    padding: 0.4rem 0.8rem;
    border-radius: 15px;
    font-size: 0.75rem;
    font-weight: 700;
    color: white;
    z-index: 25;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    box-shadow: 0 2px 10px rgba(139, 92, 246, 0.3);
}

.game-best-score-icon {
    font-size: 1rem;
}

.game-best-score-value {
    color: #FCD34D;
}

/* =============================================
   BOUTON SON
============================================= */

.game-sound-btn {
    background: rgba(255,255,255,0.1);
    border: none;
    color: white;
    width: 50px;
    height: 50px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, background 0.2s;
}

.game-sound-btn:hover {
    background: rgba(255,255,255,0.2);
}

.game-sound-btn:active {
    transform: scale(0.9);
}

.game-sound-btn.muted {
    opacity: 0.5;
}

/* =============================================
   ANIMATIONS DE SCORE
============================================= */

/* Score qui pop */
.game-score-pop {
    animation: score-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes score-pop {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); color: #FCD34D; }
    100% { transform: scale(1); }
}

/* Points flottants */
.game-floating-points {
    position: fixed;
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--game-success);
    pointer-events: none;
    z-index: 100;
    text-shadow: 0 2px 10px rgba(0,0,0,0.5);
    animation: float-up 1s ease-out forwards;
}

.game-floating-points.combo {
    color: var(--game-primary-light);
    font-size: 1.6rem;
}

.game-floating-points.error {
    color: var(--game-danger);
}

@keyframes float-up {
    0% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translateY(-60px) scale(0.8);
        opacity: 0;
    }
}

/* =============================================
   NOUVEAU RECORD
============================================= */

.game-new-record {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(135deg, #F59E0B, #D97706);
    padding: 1rem 2rem;
    border-radius: 20px;
    font-size: 1.5rem;
    font-weight: 800;
    color: white;
    z-index: 300;
    display: none;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 10px 40px rgba(245, 158, 11, 0.5);
    animation: new-record 1s ease-out;
}

.game-new-record.show {
    display: flex;
}

@keyframes new-record {
    0% {
        transform: translate(-50%, -50%) scale(0) rotate(-10deg);
        opacity: 0;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.2) rotate(5deg);
    }
    100% {
        transform: translate(-50%, -50%) scale(1) rotate(0);
        opacity: 1;
    }
}

/* =============================================
   DARK MODE AMÉLIORÉ
============================================= */

@media (prefers-color-scheme: dark) {
    .game-header:not(.dark) {
        background: rgba(0,0,0,0.7);
        color: white;
    }

    .game-stat:not(.light) {
        background: rgba(245,158,11,0.15);
        border-color: rgba(245,158,11,0.2);
    }
}

/* =============================================
   PRINT STYLES (CACHER POUR IMPRESSION)
============================================= */

@media print {
    .game-header,
    .game-progress-bar,
    .game-timer-bar,
    .game-combo,
    .game-feedback,
    .game-particle,
    .game-loading,
    .game-pause-screen,
    .game-offline-indicator {
        display: none !important;
    }
}

/* =============================================
   MODE BASSE PERFORMANCE (VIEILLES TABLETTES)
   Classe ajoutée automatiquement par PerformanceManager
============================================= */

/* Désactiver tous les backdrop-filter (très coûteux) */
.low-performance .game-header,
.low-performance .game-pause-screen,
.low-performance .game-calc-bar,
.low-performance .game-offline-indicator {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

/* Remplacer par des fonds opaques */
.low-performance .game-header {
    background: #0a0a1a !important;
}

.low-performance .game-pause-screen {
    background: #0f0f23 !important;
}

.low-performance .game-calc-bar {
    background: #0a0a1a !important;
}

/* Désactiver les ombres complexes */
.low-performance .game-end-btn,
.low-performance .game-pause-btn,
.low-performance .game-best-score,
.low-performance .game-new-record {
    box-shadow: none !important;
}

/* Simplifier les animations - durées réduites */
.low-performance .game-feedback,
.low-performance .game-combo,
.low-performance .game-particle,
.low-performance .game-end-star {
    animation-duration: 0.3s !important;
}

/* Désactiver will-change (consomme de la mémoire GPU) */
.low-performance .game-feedback,
.low-performance .game-combo,
.low-performance .game-particle,
.low-performance .game-end-star,
.low-performance .game-loading-icon,
.low-performance .game-progress-fill,
.low-performance .game-timer-fill {
    will-change: auto !important;
}

/* Désactiver les animations de pulse et bounce */
.low-performance .game-loading-icon,
.low-performance .game-pause-icon {
    animation: none !important;
}

/* Simplifier les transitions */
.low-performance * {
    transition-duration: 0.15s !important;
}

/* Animation de particules simplifiée pour low-perf */
.low-performance .game-particle {
    animation: particle-fly-simple 0.4s ease-out forwards !important;
}

@keyframes particle-fly-simple {
    0% {
        opacity: 1;
        transform: scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(var(--tx, 0), var(--ty, -40px)) scale(0.5);
    }
}

/* Classe pour animation alternative (évite le reflow) */
.game-particle-animate {
    animation: particle-fly-simple 0.4s ease-out forwards;
}

/* Désactiver les gradients complexes sur basse perf */
.low-performance .game-progress-fill,
.low-performance .game-timer-fill {
    background: var(--game-primary) !important;
}

.low-performance .game-timer-fill.warning {
    background: #F59E0B !important;
}

.low-performance .game-timer-fill.danger {
    background: #EF4444 !important;
}

/* Points flottants simplifiés */
.low-performance .game-floating-points {
    animation-duration: 0.6s !important;
    text-shadow: none !important;
}

/* Nouveau record sans animation complexe */
.low-performance .game-new-record {
    animation: fade-in 0.3s ease-out !important;
}

/* =============================================
   MODE PERFORMANCE MOYENNE
============================================= */

/* Garder le blur mais réduire la qualité */
.medium-performance .game-header,
.medium-performance .game-pause-screen {
    backdrop-filter: blur(5px) !important;
    -webkit-backdrop-filter: blur(5px) !important;
}

/* Réduire les ombres */
.medium-performance .game-end-btn,
.medium-performance .game-pause-btn {
    box-shadow: 0 2px 10px rgba(0,0,0,0.2) !important;
}

/* Animations légèrement plus rapides */
.medium-performance .game-feedback,
.medium-performance .game-combo,
.medium-performance .game-particle {
    animation-duration: 0.4s !important;
}

/* =============================================
   OPTIMISATIONS SUPPLÉMENTAIRES TABLETTES
============================================= */

/* Réduire la complexité sur les petits écrans lents */
@media (max-width: 768px) and (max-height: 1024px) {
    /* Simplifier les gradients sur tablettes */
    .game-end-content {
        background: rgba(30, 30, 50, 0.95);
    }

    /* Réduire les animations par défaut */
    .game-feedback.show {
        animation-duration: 0.4s;
    }
}

/* Optimisations pour écrans tactiles */
@media (pointer: coarse) {
    /* Augmenter les zones de tap */
    .game-pause-btn-header,
    .game-sound-btn {
        min-width: 48px;
        min-height: 48px;
    }

    /* Feedback tactile plus visible */
    .game-tap-feedback:active {
        transform: scale(0.92);
    }
}

/* =============================================
   FEEDBACK PÉDAGOGIQUE ENRICHI (P5.4)
   Explications après mauvaise réponse
============================================= */

.pedagogical-feedback {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    width: calc(100% - 40px);
    max-width: 500px;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border-radius: 16px;
    padding: 20px;
    box-shadow:
        0 10px 40px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    gap: 15px;
    align-items: flex-start;
}

.pedagogical-feedback.show {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.pedagogical-feedback.hide {
    opacity: 0;
    transform: translateX(-50%) translateY(100px);
}

/* Icône du feedback */
.pf-icon {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

/* Contenu principal */
.pf-content {
    flex: 1;
    min-width: 0;
}

.pf-title {
    font-size: 14px;
    font-weight: 600;
    color: #a0aec0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.pf-explanation {
    font-size: 16px;
    line-height: 1.6;
    color: #fff;
    margin-bottom: 12px;
}

.pf-hint {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 12px;
    background: rgba(102, 126, 234, 0.15);
    border-radius: 10px;
    border-left: 3px solid #667eea;
}

.pf-hint-icon {
    font-size: 18px;
    flex-shrink: 0;
}

.pf-hint-text {
    font-size: 14px;
    line-height: 1.5;
    color: #cbd5e0;
}

/* Section ressources "Voir aussi" */
.pf-resources {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.pf-resources-title {
    font-size: 12px;
    font-weight: 600;
    color: #a0aec0;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.pf-resources-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.pf-resource-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: rgba(102, 126, 234, 0.2);
    border: 1px solid rgba(102, 126, 234, 0.3);
    border-radius: 20px;
    color: #a5b4fc;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s ease;
}

.pf-resource-link:hover {
    background: rgba(102, 126, 234, 0.4);
    color: #fff;
    transform: translateY(-1px);
}

.pf-resource-link:active {
    transform: translateY(0);
}

/* Bouton fermer */
.pf-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 28px;
    height: 28px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: #a0aec0;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.pf-close:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

/* Mode succès (pour réponse correcte avec explication bonus) */
.pedagogical-feedback.success .pf-icon {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    box-shadow: 0 4px 15px rgba(72, 187, 120, 0.4);
}

.pedagogical-feedback.success .pf-hint {
    background: rgba(72, 187, 120, 0.15);
    border-left-color: #48bb78;
}

/* Mode erreur (plus visible) */
.pedagogical-feedback.error .pf-icon {
    background: linear-gradient(135deg, #fc8181 0%, #f56565 100%);
    box-shadow: 0 4px 15px rgba(252, 129, 129, 0.4);
}

.pedagogical-feedback.error .pf-hint {
    background: rgba(252, 129, 129, 0.1);
    border-left-color: #fc8181;
}

/* Responsive mobile */
@media (max-width: 480px) {
    .pedagogical-feedback {
        bottom: 10px;
        width: calc(100% - 20px);
        padding: 16px;
        gap: 12px;
    }

    .pf-icon {
        width: 40px;
        height: 40px;
        font-size: 20px;
        border-radius: 10px;
    }

    .pf-explanation {
        font-size: 15px;
    }

    .pf-hint {
        padding: 10px;
    }

    .pf-hint-text {
        font-size: 13px;
    }
}

/* Animation d'entrée avec rebond */
@keyframes pf-slide-in {
    0% {
        opacity: 0;
        transform: translateX(-50%) translateY(100px) scale(0.9);
    }
    70% {
        transform: translateX(-50%) translateY(-10px) scale(1.02);
    }
    100% {
        opacity: 1;
        transform: translateX(-50%) translateY(0) scale(1);
    }
}

.pedagogical-feedback.animate-in {
    animation: pf-slide-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* Dark mode ajustements */
.dark-mode .pedagogical-feedback {
    background: linear-gradient(135deg, #0d0d1a 0%, #121228 100%);
    box-shadow:
        0 10px 40px rgba(0, 0, 0, 0.6),
        0 0 0 1px rgba(255, 255, 255, 0.05),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

/* Mode performance réduite */
.reduced-motion .pedagogical-feedback {
    transition: opacity 0.2s ease;
}

.reduced-motion .pedagogical-feedback.show {
    transform: translateX(-50%) translateY(0);
}

.reduced-motion .pedagogical-feedback.animate-in {
    animation: none;
}
