        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
            padding: 20px;
            direction: rtl;
        }
        
        .container {
            max-width: 1200px;
            margin: 0 auto;
        }
        
        /* Header avec titre et gamification */
        .header {
            background: white;
            border-radius: 20px;
            padding: 25px;
            margin-bottom: 20px;
            box-shadow: 0 10px 40px rgba(0,0,0,0.2);
            display: flex;
            justify-content: space-between;
            align-items: center;
            flex-wrap: wrap;
        }
        
        .header h1 {
            color: #667eea;
            font-size: 2em;
            display: flex;
            align-items: center;
            gap: 15px;
        }
        
        .header-icon {
            font-size: 1.2em;
            animation: pulse 2s infinite;
        }
        
        @keyframes pulse {
            0%, 100% { transform: scale(1); }
            50% { transform: scale(1.1); }
        }
        
        /* Système de gamification */
        .gamification-panel {
            display: flex;
            gap: 20px;
            align-items: center;
            flex-wrap: wrap;
        }
        
        .score-display {
            background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
            color: white;
            padding: 15px 25px;
            border-radius: 15px;
            font-size: 1.3em;
            font-weight: bold;
            box-shadow: 0 5px 15px rgba(240,147,251,0.4);
            display: flex;
            align-items: center;
            gap: 10px;
        }
        
        .stars-display {
            display: flex;
            gap: 5px;
            font-size: 1.5em;
        }
        
        .star {
            color: #ffd700;
            filter: drop-shadow(0 0 5px rgba(255,215,0,0.5));
            transition: transform 0.3s;
        }
        
        .star.earned {
            animation: starEarn 0.5s ease-out;
        }
        
        @keyframes starEarn {
            0% { transform: scale(0) rotate(0deg); }
            50% { transform: scale(1.5) rotate(180deg); }
            100% { transform: scale(1) rotate(360deg); }
        }
        
        .progress-bar-container {
            background: rgba(255,255,255,0.3);
            border-radius: 10px;
            height: 20px;
            width: 200px;
            overflow: hidden;
            position: relative;
        }
        
        .progress-bar {
            background: linear-gradient(90deg, #00c6ff 0%, #0072ff 100%);
            height: 100%;
            width: 0%;
            transition: width 0.5s ease-out;
            border-radius: 10px;
        }
        
        .progress-text {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            color: white;
            font-weight: bold;
            font-size: 0.9em;
            text-shadow: 0 1px 3px rgba(0,0,0,0.5);
        }
        
        /* Zone principale */
        .main-content {
            display: grid;
            grid-template-columns: 1fr;
            gap: 20px;
        }
        
        /* Énoncé */
        .enonce-section {
            background: white;
            border-radius: 20px;
            padding: 30px;
            box-shadow: 0 10px 40px rgba(0,0,0,0.2);
            border: 3px solid #667eea;
        }
        
        .enonce-section h2 {
            color: #667eea;
            margin-bottom: 20px;
            font-size: 1.5em;
            display: flex;
            align-items: center;
            gap: 10px;
        }
        
        .operation-display {
            background: linear-gradient(135deg, #e0e7ff 0%, #f3e7ff 100%);
            padding: 25px;
            border-radius: 15px;
            font-size: 1.8em;
            text-align: center;
            border: 2px solid #667eea;
            box-shadow: inset 0 2px 10px rgba(102,126,234,0.1);
        }
        
        /* Instructions */
        .instructions {
            background: linear-gradient(135deg, #fff3cd 0%, #ffe8a1 100%);
            padding: 20px;
            border-radius: 15px;
            margin-top: 20px;
            border-right: 5px solid #ffc107;
        }
        
        .instructions h3 {
            color: #856404;
            margin-bottom: 10px;
            display: flex;
            align-items: center;
            gap: 10px;
        }
        
        .instructions p {
            color: #856404;
            line-height: 1.6;
        }
        
        /* Zone des cartes à ordonner */
        .cards-section {
            background: white;
            border-radius: 20px;
            padding: 30px;
            box-shadow: 0 10px 40px rgba(0,0,0,0.2);
        }
        
        .cards-section h2 {
            color: #764ba2;
            margin-bottom: 20px;
            font-size: 1.5em;
            display: flex;
            align-items: center;
            gap: 10px;
        }
        
        .cards-pool {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
            gap: 15px;
            min-height: 200px;
            padding: 20px;
            background: linear-gradient(135deg, #f5f7fa 0%, #e9ecef 100%);
            border-radius: 15px;
            border: 2px dashed #764ba2;
        }
        
        .card {
            background: white;
            padding: 20px;
            border-radius: 12px;
            box-shadow: 0 5px 15px rgba(0,0,0,0.1);
            cursor: pointer;
            transition: all 0.3s ease;
            border: 2px solid #e0e0e0;
            position: relative;
            overflow: hidden;
        }
        
        .card::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: linear-gradient(135deg, rgba(102,126,234,0.1) 0%, rgba(118,75,162,0.1) 100%);
            opacity: 0;
            transition: opacity 0.3s;
        }
        
        .card:hover {
            transform: translateY(-5px) scale(1.02);
            box-shadow: 0 10px 30px rgba(102,126,234,0.3);
            border-color: #667eea;
        }
        
        .card:hover::before {
            opacity: 1;
        }
        
        .card.selected {
            border-color: #28a745;
            background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
            box-shadow: 0 8px 25px rgba(40,167,69,0.4);
        }
        
        .card.error {
            animation: shake 0.5s;
            border-color: #dc3545;
            background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
        }
        
        @keyframes shake {
            0%, 100% { transform: translateX(0); }
            25% { transform: translateX(-10px); }
            75% { transform: translateX(10px); }
        }
        
        .card.flying {
            animation: flyToTarget 0.6s cubic-bezier(0.4, 0, 0.2, 1);
        }
        
        @keyframes flyToTarget {
            0% {
                transform: scale(1);
                opacity: 1;
            }
            50% {
                transform: scale(1.2) translateY(-20px);
                opacity: 0.7;
            }
            100% {
                transform: scale(1);
                opacity: 1;
            }
        }
        
        .card-number {
            position: absolute;
            top: 5px;
            right: 5px;
            background: #667eea;
            color: white;
            width: 25px;
            height: 25px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 0.9em;
            font-weight: bold;
        }
        
        .card-content {
            position: relative;
            z-index: 1;
            font-size: 1.1em;
            color: #333;
            line-height: 1.6;
        }
        
        /* Zone de construction */
        .construction-section {
            background: white;
            border-radius: 20px;
            padding: 30px;
            box-shadow: 0 10px 40px rgba(0,0,0,0.2);
        }
        
        .construction-section h2 {
            color: #28a745;
            margin-bottom: 20px;
            font-size: 1.5em;
            display: flex;
            align-items: center;
            gap: 10px;
        }
        
        .construction-zone {
            min-height: 300px;
            padding: 20px;
            background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
            border-radius: 15px;
            border: 3px dashed #28a745;
            display: flex;
            flex-direction: column;
            gap: 15px;
        }
        
        .construction-zone.empty {
            display: flex;
            align-items: center;
            justify-content: center;
            color: #666;
            font-size: 1.2em;
        }
        
        .construction-zone.empty::before {
            content: '👆 انقر على الخطوات أعلاه لترتيبها هنا';
            font-style: italic;
        }
        
        .placed-card {
            background: white;
            padding: 20px;
            border-radius: 12px;
            box-shadow: 0 5px 15px rgba(0,0,0,0.15);
            border-right: 5px solid #28a745;
            position: relative;
            animation: slideIn 0.5s ease-out;
        }
        
        @keyframes slideIn {
            from {
                transform: translateX(50px);
                opacity: 0;
            }
            to {
                transform: translateX(0);
                opacity: 1;
            }
        }
        
        .placed-card-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 10px;
        }
        
        .placed-card-order {
            background: #28a745;
            color: white;
            padding: 5px 12px;
            border-radius: 20px;
            font-weight: bold;
        }
        
        .remove-card-btn {
            background: #dc3545;
            color: white;
            border: none;
            padding: 5px 15px;
            border-radius: 20px;
            cursor: pointer;
            font-size: 0.9em;
            transition: all 0.3s;
        }
        
        .remove-card-btn:hover {
            background: #c82333;
            transform: scale(1.05);
        }
        
        .placed-card-content {
            font-size: 1.1em;
            color: #333;
            line-height: 1.6;
        }
        
        /* Boutons d'action */
        .action-buttons {
            display: flex;
            gap: 15px;
            margin-top: 20px;
            flex-wrap: wrap;
        }
        
        .btn {
            padding: 15px 30px;
            border: none;
            border-radius: 12px;
            font-size: 1.1em;
            font-weight: bold;
            cursor: pointer;
            transition: all 0.3s;
            display: flex;
            align-items: center;
            gap: 10px;
            box-shadow: 0 5px 15px rgba(0,0,0,0.2);
        }
        
        .btn:hover {
            transform: translateY(-3px);
            box-shadow: 0 8px 25px rgba(0,0,0,0.3);
        }
        
        .btn-validate {
            background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
            color: white;
        }
        
        .btn-reset {
            background: linear-gradient(135deg, #6c757d 0%, #495057 100%);
            color: white;
        }
        
        .btn-hint {
            background: linear-gradient(135deg, #ffc107 0%, #ff9800 100%);
            color: white;
        }
        
        .btn-video {
            background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
            color: white;
        }
        
        .btn:disabled {
            opacity: 0.5;
            cursor: not-allowed;
            transform: none !important;
        }
        
        /* Avatar intelligent */
        .avatar-container {
            position: fixed;
            bottom: 30px;
            left: 30px;
            z-index: 1000;
            transition: all 0.3s;
        }
        
        .avatar {
            width: 120px;
            height: 120px;
            border-radius: 50%;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 3em;
            cursor: pointer;
            box-shadow: 0 10px 30px rgba(102,126,234,0.5);
            transition: all 0.3s;
            animation: float 3s ease-in-out infinite;
        }
        
        @keyframes float {
            0%, 100% { transform: translateY(0); }
            50% { transform: translateY(-10px); }
        }
        
        .avatar:hover {
            transform: scale(1.1);
        }
        
        .avatar-message {
            position: absolute;
            bottom: 140px;
            left: 0;
            background: white;
            padding: 20px;
            border-radius: 15px;
            box-shadow: 0 10px 30px rgba(0,0,0,0.2);
            max-width: 300px;
            opacity: 0;
            transform: translateY(20px);
            transition: all 0.3s;
            pointer-events: none;
            border: 2px solid #667eea;
        }
        
        .avatar-message.show {
            opacity: 1;
            transform: translateY(0);
            pointer-events: all;
        }
        
        .avatar-message::after {
            content: '';
            position: absolute;
            bottom: -10px;
            left: 50px;
            width: 0;
            height: 0;
            border-left: 10px solid transparent;
            border-right: 10px solid transparent;
            border-top: 10px solid white;
        }
        
        .avatar-message-text {
            color: #333;
            line-height: 1.6;
            margin-bottom: 10px;
        }
        
        .avatar-close-btn {
            background: #667eea;
            color: white;
            border: none;
            padding: 8px 15px;
            border-radius: 8px;
            cursor: pointer;
            font-size: 0.9em;
            float: left;
        }
        
        /* Modal de résultat */
        .result-modal {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0,0,0,0.8);
            z-index: 2000;
            justify-content: center;
            align-items: center;
        }
        
        .result-modal.show {
            display: flex;
        }
        
        .result-content {
            background: white;
            padding: 40px;
            border-radius: 20px;
            max-width: 600px;
            width: 90%;
            text-align: center;
            box-shadow: 0 20px 60px rgba(0,0,0,0.5);
            animation: modalAppear 0.5s ease-out;
        }
        
        @keyframes modalAppear {
            from {
                transform: scale(0.8);
                opacity: 0;
            }
            to {
                transform: scale(1);
                opacity: 1;
            }
        }
        
        .result-icon {
            font-size: 5em;
            margin-bottom: 20px;
        }
        
        .result-title {
            font-size: 2em;
            margin-bottom: 15px;
            color: #333;
        }
        
        .result-message {
            font-size: 1.2em;
            color: #666;
            margin-bottom: 20px;
            line-height: 1.6;
        }
        
        .result-score {
            font-size: 2.5em;
            font-weight: bold;
            color: #667eea;
            margin: 20px 0;
        }
        
        .confetti {
            position: fixed;
            width: 10px;
            height: 10px;
            background: #f0f;
            position: absolute;
            animation: confetti-fall 3s linear infinite;
        }
        
        @keyframes confetti-fall {
            to {
                transform: translateY(100vh) rotate(360deg);
                opacity: 0;
            }
        }
        
        /* Modal vidéo */
        .video-modal {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0,0,0,0.9);
            z-index: 2000;
            justify-content: center;
            align-items: center;
        }
        
        .video-modal.show {
            display: flex;
        }
        
        .video-content {
            background: white;
            padding: 20px;
            border-radius: 15px;
            max-width: 800px;
            width: 90%;
        }
        
        .video-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 15px;
        }
        
        .video-close-btn {
            background: #dc3545;
            color: white;
            border: none;
            padding: 10px 20px;
            border-radius: 8px;
            cursor: pointer;
            font-size: 1em;
        }
        
        .video-container {
            position: relative;
            padding-bottom: 56.25%;
            height: 0;
            overflow: hidden;
        }
        
        .video-container iframe {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            border-radius: 10px;
        }
        
        /* Responsive */
        @media (max-width: 768px) {
            .header {
                flex-direction: column;
                gap: 15px;
            }
            
            .gamification-panel {
                width: 100%;
                justify-content: center;
            }
            
            .cards-pool {
                grid-template-columns: 1fr;
            }
            
            .avatar-container {
                bottom: 15px;
                left: 15px;
            }
            
            .avatar {
                width: 80px;
                height: 80px;
                font-size: 2em;
            }
            
            .action-buttons {
                flex-direction: column;
            }
            
            .btn {
                width: 100%;
                justify-content: center;
            }
        }
        
        /* Animations de succès */
        .success-animation {
            animation: successPulse 0.6s ease-out;
        }
        
        @keyframes successPulse {
            0%, 100% { transform: scale(1); }
            50% { transform: scale(1.05); }
        }
        
        /* Badge de niveau */
        .level-badge {
            background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
            color: white;
            padding: 8px 15px;
            border-radius: 20px;
            font-weight: bold;
            display: flex;
            align-items: center;
            gap: 8px;
        }