The development of Computational Thinking Skills (CTS) is increasingly important in Coding and Artificial Intelligence (AI) learning; however, students’ CTS remains influenced by multiple interrelated learning factors. Previous studies have generally examined these factors separately, leaving limited evidence on their integration within a single model in the context of Coding and AI learning at the high school level. This study contributes a novel integrated model that examines digital literacy, learning motivation, self-efficacy, and cognitive engagement in relation to students’ CTS through the implementation of problem-based gamified quizzes in Coding and AI learning. This study employed a quantitative approach with an associative research design. Data were collected from 151 tenth-grade students at SMA Pertiwi 1 Padang using a five-point Likert-scale questionnaire. The data were analyzed using Structural Equation Modeling–Partial Least Squares (SEM-PLS) with SmartPLS 3. The results showed that digital literacy had a positive and significant effect on CTS (β = 0.475, t = 3.838, p < 0.001), while learning motivation also had a positive and significant effect on CTS (β = 0.340, t = 2.967, p = 0.003). Digital literacy significantly affected self-efficacy (β = 0.509, t = 6.190, p < 0.001) and cognitive engagement (β = 0.508, t = 3.612, p < 0.001), while learning motivation significantly affected self-efficacy (β = 0.395, t = 4.681, p < 0.001) and cognitive engagement (β = 0.359, t = 2.695, p = 0.007). Self-efficacy did not significantly affect CTS (β = 0.109, t = 1.278, p = 0.201), whereas cognitive engagement had the strongest positive effect on CTS (β = 0.826, t = 11.066, p < 0.001). These findings indicate that strengthening CTS in Coding and AI learning requires not only adequate digital literacy and learning motivation but also active cognitive engagement. Problem-based gamified quizzes can therefore provide a learning context that encourages students to actively understand concepts, analyze problems, and develop computational thinking