maths fractions game

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Fraction Frenzy: The Great Snack Adventure!</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <style>
        @import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap');
        body {
            font-family: 'Inter', sans-serif;
            background: #fdf5e6;
            color: #4a4a4a;
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
            padding: 1rem;
        }
        .container {
            background: #fff;
            border-radius: 2rem;
            box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
            padding: 2rem;
            max-width: 900px;
            width: 100%;
            text-align: center;
            border: 4px solid #ffcc66;
            overflow: hidden;
        }
        h1 {
            color: #ff6347;
            text-shadow: 2px 2px #ffb399;
        }
        h2 {
            color: #ffa500;
        }
        .btn {
            padding: 0.75rem 2rem;
            border-radius: 9999px;
            font-weight: bold;
            transition: transform 0.2s, box-shadow 0.2s;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
            cursor: pointer;
            text-transform: uppercase;
        }
        .btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 6px 10px rgba(0, 0, 0, 0.15);
        }
        .btn-primary {
            background-color: #4CAF50;
            color: white;
        }
        .btn-language {
            background-color: #1e90ff;
            color: white;
        }
        .btn-correct {
            background-color: #4CAF50;
            color: white;
        }
        .btn-incorrect {
            background-color: #FF5722;
            color: white;
        }
        .options-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
            gap: 1rem;
            margin-top: 1.5rem;
        }
        .feedback {
            margin-top: 1.5rem;
            padding: 1rem;
            border-radius: 1rem;
            border: 2px dashed #ccc;
            background: #f9f9f9;
        }
        .score-box {
            background: #ffe0b2;
            border: 2px solid #ff9800;
            border-radius: 1rem;
            padding: 0.5rem 1rem;
            font-weight: bold;
            margin-top: 1rem;
            display: inline-block;
        }
        .level-card {
            background: #e1f5fe;
            border-radius: 1.5rem;
            padding: 1.5rem;
            border: 3px solid #81d4fa;
            cursor: pointer;
            transition: transform 0.2s, box-shadow 0.2s;
            text-align: center;
        }
        .level-card:hover {
            transform: translateY(-5px) scale(1.02);
            box-shadow: 0 8px 15px rgba(0, 0, 0, 0.1);
        }
        .feast-image {
            max-height: 400px;
            object-fit: contain;
            margin-top: 2rem;
            border-radius: 1rem;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
        }
        .next-btn {
            background-color: #03a9f4;
            color: white;
            margin-top: 1.5rem;
        }
        .language-btn-container {
            display: flex;
            justify-content: center;
            gap: 1rem;
            margin-top: 2rem;
        }
        .title-text {
            font-size: 2.5rem;
            line-height: 1.2;
        }
    </style>
</head>
<body class="bg-gray-100 flex items-center justify-center min-h-screen">

<div id="game-container" class="container">
    <!-- Game content will be rendered here by JavaScript -->
</div>

<script>
    const gameContainer = document.getElementById('game-container');
    let language = 'en'; // Default language
    let currentQuestionIndex = 0;
    let currentLevel = null;
    let score = 0;
    let questions = [];

    const translations = {
        en: {
            title: "Fraction Frenzy: The Great Snack Adventure!",
            welcome: "Welcome, Mini-Chef! Snacktopia needs YOUR help to make the Feast of Flavors the best ever! But first, we need to master the art of delicious fractions!",
            languageSelect: "Select your language:",
            properFractions: "1. Proper Pizza Parlor",
            improperFractions: "2. Impressive Ingredient Stack",
            mixedFractions: "3. Marvelous Mixed-Up Meals",
            unitFractions: "4. Unique Unit Bites",
            likeFractions: "5. Lovely Like-Denominator Lanes",
            unlikeFractions: "6. Unraveling Unlike Orders",
            equivalentFractions: "7. Excited Equivalent Eats",
            selectLevel: "Choose your 'Fraction Kitchen' to start:",
            score: "Snack Journal: Ingredients Collected",
            feastTitle: "The Grand Feast is Ready!",
            feastMessage: "You've successfully helped prepare for the Feast of Flavors! Thank you, Mini-Chef! All the ingredients you've collected have made this the grandest feast Snacktopia has ever seen!",
            playAgain: "Play Again!",
            nextQuestion: "Next Question",
            correctAnswer: "Excellent! That's the correct answer! 🎉",
            incorrectAnswer: "Oops, that's not quite right. Try again!",
            correctExplanation: "Correct Answer:",
            incorrectReason: "Reason:",
            nextButton: "Next",
            checkAnswer: "Check Answer",
        },
        ml: {
            title: "ഫ്രാക്ഷൻ ഫ്രെൻസി: രുചികരമായ ലഘുഭക്ഷണ സാഹസിക യാത്ര!",
            welcome: "സ്വാഗതം, മിനി-ഷെഫ്! ഫീസ്റ്റ് ഓഫ് ഫ്ലേവേഴ്‌സ് എക്കാലത്തെയും മികച്ചതാക്കാൻ സ്നാക്ടോപ്പിയക്ക് നിങ്ങളുടെ സഹായം ആവശ്യമാണ്! എന്നാൽ അതിനുമുമ്പ്, രുചികരമായ ഭിന്നസംഖ്യകൾ നമുക്ക് പഠിക്കാം!",
            languageSelect: "നിങ്ങളുടെ ഭാഷ തിരഞ്ഞെടുക്കുക:",
            properFractions: "1. ശരിയായ പിസ്സ പാർലർ",
            improperFractions: "2. അനുചിതമായ ചേരുവകൾ",
            mixedFractions: "3. അത്ഭുതകരമായ മിക്സഡ്-അപ്പ് വിഭവങ്ങൾ",
            unitFractions: "4. അദ്വിതീയ യൂണിറ്റ് ബൈറ്റുകൾ",
            likeFractions: "5. ഒരേ ഛേദമുള്ള ഭിന്നസംഖ്യകൾ",
            unlikeFractions: "6. വ്യത്യസ്ത ഛേദമുള്ള ഭിന്നസംഖ്യകൾ",
            equivalentFractions: "7. തുല്യമായ ഭിന്നസംഖ്യകൾ",
            selectLevel: "'ഫ്രാക്ഷൻ കിച്ചൺ' തിരഞ്ഞെടുത്ത് തുടങ്ങാം:",
            score: "സ്നാക്ക് ജേണൽ: ശേഖരിച്ച ചേരുവകൾ",
            feastTitle: "ഗംഭീരമായ വിരുന്ന് തയ്യാറായി!",
            feastMessage: "ഫീസ്റ്റ് ഓഫ് ഫ്ലേവേഴ്‌സിനായി തയ്യാറെടുക്കാൻ നിങ്ങൾ വിജയകരമായി സഹായിച്ചു! നന്ദി, മിനി-ഷെഫ്! നിങ്ങൾ ശേഖരിച്ച എല്ലാ ചേരുവകളും സ്നാക്ടോപ്പിയ കണ്ടിട്ടുള്ളതിൽ വച്ച് ഏറ്റവും ഗംഭീരമായ വിരുന്നാക്കി മാറ്റി!",
            playAgain: "വീണ്ടും കളിക്കുക!",
            nextQuestion: "അടുത്ത ചോദ്യം",
            correctAnswer: "അത് ഗംഭീരം! അത് ശരിയായ ഉത്തരമാണ്! 🎉",
            incorrectAnswer: "അയ്യോ, അത് ശരിയല്ല. വീണ്ടും ശ്രമിക്കുക!",
            correctExplanation: "ശരിയായ ഉത്തരം:",
            incorrectReason: "കാരണം:",
            nextButton: "അടുത്തത്",
            checkAnswer: "ഉത്തരം പരിശോധിക്കുക",
        }
    };

    const allQuestions = {
        proper: [
            {
                scenario: "Chef Paolo baked a delicious pepperoni pizza and cut it into 8 equal slices. He needs to pack a small box with only 3 slices.",
                visual: "https://placehold.co/400x250/ffb399/ff6347?text=Pizza+3/8",
                question: "What fraction of the pizza is in the small box?",
                options: ["8/3", "3/8", "1/8", "3/3"],
                answer: "3/8",
                explanation: "The pizza is divided into 8 equal parts (the denominator). You have 3 of those parts (the numerator). So the fraction is 3/8."
            },
            {
                scenario: "Grandma Gaia made a berry pie and divided it into 6 equal pieces. Her grandson ate 2 pieces.",
                visual: "https://placehold.co/400x250/b38867/6f4f28?text=Pie+2/6",
                question: "What fraction of the pie did her grandson eat?",
                options: ["6/2", "2/6", "1/6", "4/6"],
                answer: "2/6",
                explanation: "The pie is divided into 6 equal parts. The grandson ate 2 of those parts. So the fraction is 2/6."
            },
            {
                scenario: "A basket has 10 juicy apples. You pick out 4 apples for a snack.",
                visual: "https://placehold.co/400x250/ff4d4d/ffffff?text=Apples+4/10",
                question: "What fraction of the apples did you pick?",
                options: ["10/4", "4/10", "1/10", "6/10"],
                answer: "4/10",
                explanation: "The total number of apples is 10. The number you picked is 4. So the fraction is 4/10."
            },
            {
                scenario: "A chocolate bar has 5 equal squares. You decide to eat 1 square.",
                visual: "https://placehold.co/400x250/8b4513/ffffff?text=Chocolate+1/5",
                question: "What fraction of the chocolate bar did you eat?",
                options: ["5/1", "1/5", "4/5", "5/5"],
                answer: "1/5",
                explanation: "The chocolate bar is divided into 5 equal squares. You ate 1 square. So the fraction is 1/5."
            },
            {
                scenario: "A pitcher holds 7 glasses of lemonade. You pour out 5 glasses for your friends.",
                visual: "https://placehold.co/400x250/ffff99/ffc107?text=Lemonade+5/7",
                question: "What fraction of the lemonade did you pour out?",
                options: ["7/5", "5/7", "1/7", "2/7"],
                answer: "5/7",
                explanation: "The pitcher holds 7 glasses. You poured out 5. So the fraction is 5/7."
            }
        ],
        improper: [
            {
                scenario: "You have 3 whole loaves of bread. Each loaf is cut into 4 slices. You use all the slices from 2 loaves and 3 slices from the third loaf to make a giant sandwich.",
                visual: "https://placehold.co/400x250/d2b48c/4a2c1a?text=Bread+11/4",
                question: "Express the total number of slices you used as an improper fraction.",
                options: ["11/4", "3/4", "2/4", "12/4"],
                answer: "11/4",
                explanation: "Two whole loaves have 2 * 4 = 8 slices. You add 3 more slices from the third loaf. Total slices are 8 + 3 = 11. The size of each slice is 1/4 of a loaf. So the improper fraction is 11/4."
            },
            {
                scenario: "Each pie is cut into 6 slices. Chef Immy baked 2 whole pies and 1 extra slice from a third pie.",
                visual: "https://placehold.co/400x250/f4b3e4/7c4f6a?text=Pies+13/6",
                question: "How many slices of pie are there in total, expressed as an improper fraction?",
                options: ["12/6", "13/6", "1/6", "2/6"],
                answer: "13/6",
                explanation: "2 whole pies have 2 * 6 = 12 slices. You have 1 extra slice. Total slices are 12 + 1 = 13. Each slice is 1/6 of a pie. So the improper fraction is 13/6."
            },
            {
                scenario: "A recipe calls for 1/2 cup of sugar per batch of cookies. You are making 3 batches.",
                visual: "https://placehold.co/400x250/fffafa/c4889c?text=Sugar+3/2",
                question: "How much sugar do you need in total, as an improper fraction?",
                options: ["3/1", "2/3", "3/2", "1/2"],
                answer: "3/2",
                explanation: "You need 1/2 cup for each of the 3 batches. This is (1/2) + (1/2) + (1/2) = 3/2."
            },
            {
                scenario: "Each carton holds 8 eggs. You have 1 full carton and 5 extra eggs from another carton.",
                visual: "https://placehold.co/400x250/fdfd96/7b6f3c?text=Eggs+13/8",
                question: "How many eggs do you have in total, as an improper fraction of a carton?",
                options: ["8/5", "13/8", "5/8", "1/8"],
                answer: "13/8",
                explanation: "One full carton is 8/8. You have 5 extra eggs, which is 5/8 of a carton. Total is 8/8 + 5/8 = 13/8."
            },
            {
                scenario: "A ribbon is cut into pieces, each 1/5 meter long. You have 7 of these pieces.",
                visual: "https://placehold.co/400x250/ff99ff/cc00cc?text=Ribbon+7/5",
                question: "What is the total length of ribbon, expressed as an improper fraction of a meter?",
                options: ["5/7", "7/5", "1/5", "2/5"],
                answer: "7/5",
                explanation: "Each piece is 1/5 meter long. You have 7 pieces. The total length is (1/5) * 7 = 7/5 meters."
            }
        ],
        mixed: [
            {
                scenario: "You have 2 whole pizzas, and an additional 1/2 of another pizza.",
                visual: "https://placehold.co/400x250/ff8c66/e84a22?text=Pizza+2+1/2",
                question: "How many pizzas do you have in total, expressed as a mixed fraction?",
                options: ["2\\frac{1}{2}", "1\\frac{2}{2}", "1/2", "2/2"],
                answer: "2\\frac{1}{2}",
                explanation: "You have 2 whole pizzas and 1/2 of another. The mixed fraction is 2 and 1/2."
            },
            {
                scenario: "Chef Mixie baked 3 whole cakes, and 2/3 of another cake.",
                visual: "https://placehold.co/400x250/f7cac9/7c4f6a?text=Cakes+3+2/3",
                question: "How many cakes does Chef Mixie have, as a mixed fraction?",
                options: ["3\\frac{2}{3}", "2\\frac{3}{3}", "2/3", "3/2"],
                answer: "3\\frac{2}{3}",
                explanation: "You have 3 whole cakes and 2/3 of another. The mixed fraction is 3 and 2/3."
            },
            {
                scenario: "You planted 4 full rows of flowers, and 1/4 of another row.",
                visual: "https://placehold.co/400x250/c0d998/5c6b41?text=Flowers+4+1/4",
                question: "How many rows of flowers did you plant in total, as a mixed fraction?",
                options: ["4\\frac{1}{4}", "1\\frac{4}{4}", "1/4", "4/1"],
                answer: "4\\frac{1}{4}",
                explanation: "You have 4 full rows and 1/4 of another. The mixed fraction is 4 and 1/4."
            },
            {
                scenario: "A recipe calls for 1 full cup of flour and 3/4 of another cup.",
                visual: "https://placehold.co/400x250/f5f5dc/4a4a4a?text=Flour+1+3/4",
                question: "How much flour is needed, as a mixed fraction?",
                options: ["1\\frac{3}{4}", "3\\frac{1}{4}", "3/4", "1/3"],
                answer: "1\\frac{3}{4}",
                explanation: "You need 1 full cup and 3/4 of a cup. The mixed fraction is 1 and 3/4."
            },
            {
                scenario: "You walked for 2 full hours, and then for an additional 1/3 of an hour.",
                visual: "https://placehold.co/400x250/a9a9a9/ffffff?text=Walked+2+1/3+hours",
                question: "How long did you walk in total, as a mixed fraction?",
                options: ["2\\frac{1}{3}", "1\\frac{2}{3}", "1/3", "3/2"],
                answer: "2\\frac{1}{3}",
                explanation: "You walked 2 full hours and 1/3 of an hour. The mixed fraction is 2 and 1/3."
            }
        ],
        unit: [
            {
                scenario: "Chef Unity cut a giant chocolate bar into 8 equal pieces. He gives you one piece.",
                visual: "https://placehold.co/400x250/a0522d/ffffff?text=Chocolate+1/8",
                question: "What fraction represents the single piece you received?",
                options: ["8/1", "1/8", "2/8", "7/8"],
                answer: "1/8",
                explanation: "A unit fraction has a numerator of 1. Here, the whole is divided into 8 pieces, and you have 1 piece, so the fraction is 1/8."
            },
            {
                scenario: "A pizza is divided into 4 equal slices. What fraction represents just one slice?",
                visual: "https://placehold.co/400x250/ff9966/ff6347?text=Pizza+1/4",
                question: "What fraction represents one slice of pizza?",
                options: ["4/1", "1/4", "2/4", "3/4"],
                answer: "1/4",
                explanation: "The pizza is divided into 4 equal slices. One slice is 1/4 of the whole pizza."
            },
            {
                scenario: "A cake is cut into 12 equal portions. What fraction represents one portion?",
                visual: "https://placehold.co/400x250/f7cac9/7c4f6a?text=Cake+1/12",
                question: "What fraction represents one portion of cake?",
                options: ["12/1", "1/12", "2/12", "11/12"],
                answer: "1/12",
                explanation: "The cake is cut into 12 equal portions. One portion is 1/12 of the whole cake."
            },
            {
                scenario: "You have a bag with 10 marbles. You pick out just one marble.",
                visual: "https://placehold.co/400x250/b19cd9/4b387e?text=Marbles+1/10",
                question: "What fraction of the marbles did you pick out?",
                options: ["10/1", "1/10", "2/10", "9/10"],
                answer: "1/10",
                explanation: "There are 10 marbles in total. You picked out 1. The fraction is 1/10."
            },
            {
                scenario: "A giant sandwich is divided into 6 equal sections. You eat one section.",
                visual: "https://placehold.co/400x250/d2b48c/4a2c1a?text=Sandwich+1/6",
                question: "What fraction of the sandwich did you eat?",
                options: ["6/1", "1/6", "2/6", "5/6"],
                answer: "1/6",
                explanation: "The sandwich is divided into 6 sections. You ate 1. The fraction is 1/6."
            }
        ],
        like: [
            {
                scenario: "You have 2/5 of a chocolate cake and your friend gives you another 1/5 of the same cake.",
                visual: "https://placehold.co/400x250/8b4513/ffffff?text=Cake+2/5+%2B+1/5",
                question: "How much chocolate cake do you have in total?",
                options: ["3/5", "1/5", "3/10", "2/5"],
                answer: "3/5",
                explanation: "When adding fractions with the same denominator, you just add the numerators. So, 2/5 + 1/5 = 3/5."
            },
            {
                scenario: "A pitcher has 4/7 full of orange juice. You drink 1/7 of the pitcher.",
                visual: "https://placehold.co/400x250/ffa500/ffffff?text=Juice+4/7+-+1/7",
                question: "How much orange juice is left in the pitcher?",
                options: ["5/7", "3/7", "4/7", "1/7"],
                answer: "3/7",
                explanation: "When subtracting fractions with the same denominator, you subtract the numerators. So, 4/7 - 1/7 = 3/7."
            },
            {
                scenario: "You painted 3/8 of a wall blue and then painted another 2/8 of the wall green.",
                visual: "https://placehold.co/400x250/336699/ffffff?text=Wall+3/8+%2B+2/8",
                question: "What fraction of the wall have you painted in total?",
                options: ["5/8", "1/8", "5/16", "2/8"],
                answer: "5/8",
                explanation: "You simply add the numerators: 3/8 + 2/8 = 5/8."
            },
            {
                scenario: "You had 7/10 of a giant submarine sandwich. You ate 3/10 of it for lunch.",
                visual: "https://placehold.co/400x250/d2b48c/4a2c1a?text=Sandwich+7/10+-+3/10",
                question: "How much of the submarine sandwich is left?",
                options: ["4/10", "10/10", "7/10", "3/10"],
                answer: "4/10",
                explanation: "Subtract the numerators: 7/10 - 3/10 = 4/10."
            },
            {
                scenario: "1/6 of the flowers in a garden are red, and 3/6 are yellow.",
                visual: "https://placehold.co/400x250/ff4d4d/ffffff?text=Flowers+1/6+%2B+3/6",
                question: "What fraction of the garden has red or yellow flowers?",
                options: ["4/6", "2/6", "4/12", "1/6"],
                answer: "4/6",
                explanation: "Add the numerators: 1/6 + 3/6 = 4/6."
            }
        ],
        unlike: [
            {
                scenario: "You have 1/2 of a large pizza and your friend has 3/4 of a medium pizza. Which one is more?",
                visual: "https://placehold.co/400x250/ffb399/ff6347?text=Pizza+1/2+vs+3/4",
                question: "Which fraction represents the larger amount of pizza?",
                options: ["1/2", "3/4"],
                answer: "3/4",
                explanation: "To compare, convert to a common denominator. 1/2 is the same as 2/4. Since 3/4 is greater than 2/4, your friend has more pizza."
            },
            {
                scenario: "You need to pour 1/3 cup of sugar and 2/6 cup of flour. Are these amounts the same?",
                visual: "https://placehold.co/400x250/fffafa/c4889c?text=1/3+vs+2/6",
                question: "Are 1/3 and 2/6 equivalent fractions?",
                options: ["Yes", "No"],
                answer: "Yes",
                explanation: "To find an equivalent fraction, you can multiply or divide the numerator and denominator by the same number. If you multiply the numerator and denominator of 1/3 by 2, you get 2/6. So they are equivalent."
            },
            {
                scenario: "Chef Uni has three different types of fruit pies: a blueberry pie (2/3 left), an apple pie (5/6 left), and a cherry pie (1/2 left). She wants to serve them from least amount to greatest amount.",
                visual: "https://placehold.co/400x250/b38867/6f4f28?text=Pies+1/2,2/3,5/6",
                question: "Order the remaining pie amounts from least to greatest.",
                options: ["1/2, 2/3, 5/6", "1/2, 5/6, 2/3", "2/3, 1/2, 5/6", "5/6, 2/3, 1/2"],
                answer: "1/2, 2/3, 5/6",
                explanation: "To order these, we find a common denominator, which is 6. 1/2 = 3/6, 2/3 = 4/6, and 5/6 stays the same. The order from least to greatest is 3/6, 4/6, 5/6, which corresponds to 1/2, 2/3, 5/6."
            },
            {
                scenario: "You spent 1/4 of your allowance on a toy and 2/5 on candy. Which cost you more?",
                visual: "https://placehold.co/400x250/ff4d4d/ffffff?text=Money+1/4+vs+2/5",
                question: "Which fraction is larger, 1/4 or 2/5?",
                options: ["1/4", "2/5"],
                answer: "2/5",
                explanation: "To compare, convert to a common denominator, which is 20. 1/4 = 5/20 and 2/5 = 8/20. Since 8/20 is greater than 5/20, 2/5 is the larger fraction."
            },
            {
                scenario: "Two friends are sharing a cake. Friend A eats 3/8 of the cake. Friend B eats 1/3 of the cake. Who ate more cake?",
                visual: "https://placehold.co/400x250/f7cac9/7c4f6a?text=Cake+3/8+vs+1/3",
                question: "Who ate more?",
                options: ["Friend A", "Friend B"],
                answer: "Friend A",
                explanation: "To compare, convert to a common denominator, which is 24. 3/8 = 9/24 and 1/3 = 8/24. Since 9/24 is greater than 8/24, Friend A ate more."
            }
        ],
        equivalent: [
            {
                scenario: "You have 1/2 of a sandwich. Which of these pictures shows the exact same amount of sandwich?",
                visual: "https://placehold.co/400x250/d2b48c/4a2c1a?text=1/2+vs+2/4",
                question: "Select the image that shows an equivalent fraction to 1/2.",
                options: ["2/4", "1/3", "3/8", "None of the above"],
                answer: "2/4",
                explanation: "To find an equivalent fraction, you can multiply the numerator and denominator by the same number. 1/2 * 2/2 = 2/4. Both fractions represent the same amount."
            },
            {
                scenario: "A giant cookie is cut into 3 equal pieces, and you have 1 piece (1/3). If you cut that piece into 2 smaller pieces, what equivalent fraction do you have?",
                visual: "https://placehold.co/400x250/ffe0b2/ff9800?text=Cookie+1/3+to+2/6",
                question: "1/3 is equivalent to which of these?",
                options: ["2/6", "1/6", "3/3", "2/3"],
                answer: "2/6",
                explanation: "If you cut the whole cookie into smaller pieces of the same size, each original piece will be divided equally. Cutting 1/3 into two pieces means the whole is now in 6 pieces, so you have 2/6. 1/3 * 2/2 = 2/6."
            },
            {
                scenario: "You have 2/4 of a pizza. Which fraction is equivalent to this amount in its simplest form?",
                visual: "https://placehold.co/400x250/ffb399/ff6347?text=Pizza+2/4",
                question: "Find the simplest equivalent fraction for 2/4.",
                options: ["1/2", "4/8", "1/4", "2/2"],
                answer: "1/2",
                explanation: "To simplify a fraction, divide the numerator and denominator by their greatest common divisor. Both 2 and 4 can be divided by 2. 2/2 = 1 and 4/2 = 2, so the simplest form is 1/2."
            },
            {
                scenario: "A cake is divided into 8 slices. You have 4 slices (4/8). What is another way to write this fraction?",
                visual: "https://placehold.co/400x250/f7cac9/7c4f6a?text=Cake+4/8",
                question: "Select an equivalent fraction for 4/8.",
                options: ["1/2", "2/4", "Both A and B", "None of the above"],
                answer: "Both A and B",
                explanation: "Both 1/2 and 2/4 are equivalent to 4/8. 4/8 simplifies to 1/2, and multiplying 1/2 by 2/2 gives you 2/4."
            },
            {
                scenario: "You are sharing a chocolate bar that has 6 squares. You want 2/6 of it. Which fraction below represents the same amount in simplest form?",
                visual: "https://placehold.co/400x250/8b4513/ffffff?text=Chocolate+2/6",
                question: "What is the simplest equivalent fraction for 2/6?",
                options: ["1/3", "4/12", "2/3", "1/2"],
                answer: "1/3",
                explanation: "To simplify 2/6, divide the numerator and denominator by 2. 2/2 = 1 and 6/2 = 3. So the simplest form is 1/3."
            }
        ],
    };

    function switchLanguage(lang) {
        language = lang;
        renderLanguageSelection();
    }

    function renderLanguageSelection() {
        const t = translations[language];
        gameContainer.innerHTML = `
            <h1 class="text-4xl md:text-5xl font-extrabold mb-4 title-text">${t.title}</h1>
            <p class="text-lg md:text-xl mb-8">${t.welcome}</p>
            <div class="language-btn-container">
                <button onclick="switchLanguage('en')" class="btn btn-language transition-transform duration-200 ease-in-out hover:scale-105">English</button>
                <button onclick="switchLanguage('ml')" class="btn btn-language transition-transform duration-200 ease-in-out hover:scale-105">മലയാളം</button>
            </div>
            <div id="start-button-container" class="mt-8">
                <button onclick="renderLevelSelection()" class="btn btn-primary transition-transform duration-200 ease-in-out hover:scale-105">Start Game</button>
            </div>
        `;
    }

    function renderLevelSelection() {
        const t = translations[language];
        gameContainer.innerHTML = `
            <h2 class="text-3xl md:text-4xl font-bold mb-6">${t.selectLevel}</h2>
            <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
                <div class="level-card" onclick="startLevel('proper')">
                    <h3 class="font-bold text-xl">${t.properFractions}</h3>
                    <p class="text-sm mt-2">Proper Fractions</p>
                </div>
                <div class="level-card" onclick="startLevel('improper')">
                    <h3 class="font-bold text-xl">${t.improperFractions}</h3>
                    <p class="text-sm mt-2">Improper Fractions</p>
                </div>
                <div class="level-card" onclick="startLevel('mixed')">
                    <h3 class="font-bold text-xl">${t.mixedFractions}</h3>
                    <p class="text-sm mt-2">Mixed Fractions</p>
                </div>
                <div class="level-card" onclick="startLevel('unit')">
                    <h3 class="font-bold text-xl">${t.unitFractions}</h3>
                    <p class="text-sm mt-2">Unit Fractions</p>
                </div>
                <div class="level-card" onclick="startLevel('like')">
                    <h3 class="font-bold text-xl">${t.likeFractions}</h3>
                    <p class="text-sm mt-2">Like Fractions</p>
                </div>
                <div class="level-card" onclick="startLevel('unlike')">
                    <h3 class="font-bold text-xl">${t.unlikeFractions}</h3>
                    <p class="text-sm mt-2">Unlike Fractions</p>
                </div>
                <div class="level-card" onclick="startLevel('equivalent')">
                    <h3 class="font-bold text-xl">${t.equivalentFractions}</h3>
                    <p class="text-sm mt-2">Equivalent Fractions</p>
                </div>
            </div>
        `;
        document.querySelector('.container').classList.add('p-8');
    }

    function startLevel(level) {
        currentLevel = level;
        questions = shuffleArray(allQuestions[level]).slice(0, 5); // Take 5 random questions
        currentQuestionIndex = 0;
        renderQuestion();
    }

    function renderQuestion() {
        if (currentQuestionIndex >= questions.length) {
            renderFeastFinale();
            return;
        }

        const t = translations[language];
        const questionData = questions[currentQuestionIndex];
        const scenario = getLocalizedScenario(questionData.scenario);
        const questionText = getLocalizedQuestion(questionData.question);
        
        const optionsHtml = questionData.options.map(option => {
            return `<button class="btn btn-primary transition-transform duration-200 ease-in-out hover:scale-105" onclick="checkAnswer('${option.replace('\\', '\\\\')}')">${option}</button>`;
        }).join('');

        gameContainer.innerHTML = `
            <div class="flex flex-col md:flex-row items-center justify-between mb-4">
                <div class="score-box">Score: ${score}</div>
                <h2 class="text-3xl font-bold text-center my-4">${getLocalizedLevelTitle(currentLevel)}</h2>
                <p class="text-sm">Question ${currentQuestionIndex + 1} of ${questions.length}</p>
            </div>
            <div class="mb-6 bg-blue-50 p-6 rounded-xl border-2 border-blue-200">
                <p class="text-lg text-left font-semibold">${scenario}</p>
                <img src="${questionData.visual}" alt="Visual for the question" class="my-4 rounded-lg shadow-md w-full">
                <p class="text-xl font-bold text-orange-500 text-left">${questionText}</p>
            </div>
            <div class="options-grid" id="options-container">
                ${optionsHtml}
            </div>
            <div id="feedback-container"></div>
        `;
    }

    function checkAnswer(selectedAnswer) {
        const t = translations[language];
        const questionData = questions[currentQuestionIndex];
        const feedbackContainer = document.getElementById('feedback-container');
        const optionsContainer = document.getElementById('options-container');

        // Disable options
        Array.from(optionsContainer.children).forEach(btn => {
            btn.disabled = true;
            btn.classList.remove('btn-primary');
            if (btn.textContent === selectedAnswer) {
                if (selectedAnswer === questionData.answer) {
                    btn.classList.add('btn-correct');
                } else {
                    btn.classList.add('btn-incorrect');
                }
            }
        });

        if (selectedAnswer === questionData.answer) {
            score++;
            feedbackContainer.innerHTML = `
                <div class="feedback bg-green-100 border-green-400 text-green-700">
                    <p class="text-2xl font-bold mb-2">${t.correctAnswer}</p>
                    <p class="font-semibold">${t.correctExplanation}</p>
                    <p>${getLocalizedExplanation(questionData.explanation)}</p>
                </div>
                <button onclick="nextQuestion()" class="btn next-btn transition-transform duration-200 ease-in-out hover:scale-105">${t.nextQuestion}</button>
            `;
        } else {
            feedbackContainer.innerHTML = `
                <div class="feedback bg-red-100 border-red-400 text-red-700">
                    <p class="text-2xl font-bold mb-2">${t.incorrectAnswer}</p>
                    <p class="font-semibold">${t.correctExplanation}</p>
                    <p>${getLocalizedExplanation(questionData.explanation)}</p>
                </div>
                <button onclick="nextQuestion()" class="btn next-btn transition-transform duration-200 ease-in-out hover:scale-105">${t.nextQuestion}</button>
            `;
        }
    }

    function nextQuestion() {
        currentQuestionIndex++;
        renderQuestion();
    }
    
    function renderFeastFinale() {
        const t = translations[language];
        gameContainer.innerHTML = `
            <h1 class="text-4xl md:text-5xl font-extrabold mb-4 title-text">${t.feastTitle}</h1>
            <p class="text-xl mb-4">${t.feastMessage}</p>
            <div class="score-box text-xl">Final Score: ${score} / ${questions.length}</div>
            <img src="https://placehold.co/600x400/ffe0b2/ff9800?text=Feast+of+Flavors" alt="Feast of Flavors" class="feast-image mx-auto">
            <button onclick="restartGame()" class="btn btn-primary mt-8 transition-transform duration-200 ease-in-out hover:scale-105">${t.playAgain}</button>
        `;
    }

    function restartGame() {
        score = 0;
        currentQuestionIndex = 0;
        currentLevel = null;
        renderLanguageSelection();
    }

    // Helper functions for localization and utility
    function getLocalizedScenario(enText) {
        const mlTranslations = {
            "Chef Paolo baked a delicious pepperoni pizza and cut it into 8 equal slices. He needs to pack a small box with only 3 slices.": "ചെഫ് പൗലോ ഒരു രുചികരമായ പെപ്പറോണി പിസ്സ ഉണ്ടാക്കി അതിനെ 8 തുല്യ കഷണങ്ങളായി മുറിച്ചു. അദ്ദേഹത്തിന് ഒരു ചെറിയ പെട്ടിയിൽ 3 കഷണങ്ങൾ മാത്രം വെക്കണം.",
            "Grandma Gaia made a berry pie and divided it into 6 equal pieces. Her grandson ate 2 pieces.": "മുത്തശ്ശി ഗായ ഒരു ബെറി പൈ ഉണ്ടാക്കി അതിനെ 6 തുല്യ കഷണങ്ങളായി മുറിച്ചു. അവരുടെ പേരക്കുട്ടി 2 കഷണങ്ങൾ കഴിച്ചു.",
            "A basket has 10 juicy apples. You pick out 4 apples for a snack.": "ഒരു കുട്ടയിൽ 10 ആപ്പിളുകൾ ഉണ്ട്. നിങ്ങൾ ലഘുഭക്ഷണത്തിനായി 4 ആപ്പിളുകൾ എടുത്തു.",
            "A chocolate bar has 5 equal squares. You decide to eat 1 square.": "ഒരു ചോക്ലേറ്റ് ബാറിന് 5 തുല്യ ചതുരങ്ങളുണ്ട്. നിങ്ങൾ അതിൽ നിന്ന് 1 ചതുരം കഴിക്കാൻ തീരുമാനിച്ചു.",
            "A pitcher holds 7 glasses of lemonade. You pour out 5 glasses for your friends.": "ഒരു പാത്രത്തിൽ 7 ഗ്ലാസ് നാരങ്ങാവെള്ളം ഉണ്ട്. നിങ്ങൾ 5 ഗ്ലാസ് നിങ്ങളുടെ കൂട്ടുകാർക്കായി ഒഴിച്ചു.",
            "You have 3 whole loaves of bread. Each loaf is cut into 4 slices. You use all the slices from 2 loaves and 3 slices from the third loaf to make a giant sandwich.": "നിങ്ങളുടെ അടുത്ത് 3 മുഴുവൻ ബ്രെഡ് ലോഫുകളുണ്ട്. ഓരോ ലോഫും 4 കഷണങ്ങളായി മുറിച്ചിരിക്കുന്നു. നിങ്ങൾ 2 ലോഫുകളിലെയും കഷണങ്ങളും മൂന്നാമത്തെ ലോഫിൽ നിന്ന് 3 കഷണങ്ങളും ഒരു ഭീമാകാരമായ സാൻഡ്‌വിച്ച് ഉണ്ടാക്കാൻ ഉപയോഗിച്ചു.",
            "Each pie is cut into 6 slices. Chef Immy baked 2 whole pies and 1 extra slice from a third pie.": "ഓരോ പൈയും 6 കഷണങ്ങളായി മുറിച്ചിരിക്കുന്നു. ചെഫ് ഇമ്മി 2 മുഴുവൻ പൈകളും ഒരു മൂന്നാമത്തെ പൈയിൽ നിന്ന് 1 അധിക കഷണവും ഉണ്ടാക്കി.",
            "A recipe calls for 1/2 cup of sugar per batch of cookies. You are making 3 batches.": "ഒരു പാചകക്കുറിപ്പിൽ ഒരു ബാച്ച് കുക്കീസിന് 1/2 കപ്പ് പഞ്ചസാരയാണ് വേണ്ടത്. നിങ്ങൾ 3 ബാച്ചുകൾ ഉണ്ടാക്കുന്നു.",
            "Each carton holds 8 eggs. You have 1 full carton and 5 extra eggs from another carton.": "ഓരോ കാർട്ടണിലും 8 മുട്ടകൾ വീതമുണ്ട്. നിങ്ങളുടെ അടുത്ത് ഒരു മുഴുവൻ കാർട്ടണും മറ്റൊരു കാർട്ടണിൽ നിന്ന് 5 അധിക മുട്ടകളും ഉണ്ട്.",
            "A ribbon is cut into pieces, each 1/5 meter long. You have 7 of these pieces.": "ഒരു റിബൺ 1/5 മീറ്റർ നീളമുള്ള കഷണങ്ങളായി മുറിച്ചിരിക്കുന്നു. നിങ്ങളുടെ അടുത്ത് അത്തരം 7 കഷണങ്ങളുണ്ട്.",
            "You have 2 whole pizzas, and an additional 1/2 of another pizza.": "നിങ്ങളുടെ അടുത്ത് 2 മുഴുവൻ പിസ്സകളും, കൂടാതെ ഒരു പിസ്സയുടെ 1/2 ഭാഗവുമുണ്ട്.",
            "Chef Mixie baked 3 whole cakes, and 2/3 of another cake.": "ചെഫ് മിക്സി 3 മുഴുവൻ കേക്കുകളും, കൂടാതെ ഒരു കേക്കിന്റെ 2/3 ഭാഗവും ഉണ്ടാക്കി.",
            "You planted 4 full rows of flowers, and 1/4 of another row.": "നിങ്ങൾ 4 മുഴുവൻ നിരകളിൽ പൂക്കൾ നട്ടു, കൂടാതെ ഒരു നിരയുടെ 1/4 ഭാഗവും.",
            "A recipe calls for 1 full cup of flour and 3/4 of another cup.": "ഒരു പാചകക്കുറിപ്പിൽ 1 മുഴുവൻ കപ്പ് മാവും മറ്റൊരു കപ്പിന്റെ 3/4 ഭാഗവും വേണം.",
            "You walked for 2 full hours, and then for an additional 1/3 of an hour.": "നിങ്ങൾ 2 മുഴുവൻ മണിക്കൂർ നടന്നു, തുടർന്ന് ഒരു മണിക്കൂറിന്റെ 1/3 ഭാഗം കൂടി നടന്നു.",
            "Chef Unity cut a giant chocolate bar into 8 equal pieces. He gives you one piece.": "ചെഫ് യൂണിറ്റി ഒരു ഭീമാകാരമായ ചോക്ലേറ്റ് ബാർ 8 തുല്യ കഷണങ്ങളായി മുറിച്ചു. അദ്ദേഹം നിങ്ങൾക്ക് ഒരു കഷണം തരുന്നു.",
            "A pizza is divided into 4 equal slices. What fraction represents just one slice?": "ഒരു പിസ്സയെ 4 തുല്യ കഷണങ്ങളായി തിരിച്ചിരിക്കുന്നു. ഒരു കഷണം മാത്രം എന്ത് ഭിന്നസംഖ്യയെയാണ് സൂചിപ്പിക്കുന്നത്?",
            "A cake is cut into 12 equal portions. What fraction represents one portion?": "ഒരു കേക്കിനെ 12 തുല്യ ഭാഗങ്ങളായി മുറിച്ചിരിക്കുന്നു. ഒരു ഭാഗം എന്ത് ഭിന്നസംഖ്യയെയാണ് സൂചിപ്പിക്കുന്നത്?",
            "You have a bag with 10 marbles. You pick out just one marble.": "ഒരു സഞ്ചിയിൽ 10 ഗോലികളുണ്ട്. നിങ്ങൾ അതിൽ നിന്ന് ഒരു ഗോലി മാത്രം എടുത്തു.",
            "A giant sandwich is divided into 6 equal sections. You eat one section.": "ഒരു ഭീമാകാരമായ സാൻഡ്‌വിച്ചിനെ 6 തുല്യ ഭാഗങ്ങളായി തിരിച്ചിരിക്കുന്നു. നിങ്ങൾ ഒരു ഭാഗം കഴിച്ചു.",
            "You have 2/5 of a chocolate cake and your friend gives you another 1/5 of the same cake.": "നിങ്ങളുടെ അടുത്ത് ഒരു ചോക്ലേറ്റ് കേക്കിന്റെ 2/5 ഭാഗവും നിങ്ങളുടെ കൂട്ടുകാരൻ അതേ കേക്കിന്റെ 1/5 ഭാഗം കൂടി തരുന്നു.",
            "A pitcher has 4/7 full of orange juice. You drink 1/7 of the pitcher.": "ഒരു പാത്രത്തിൽ 4/7 ഭാഗം ഓറഞ്ച് ജ്യൂസ് ഉണ്ട്. നിങ്ങൾ പാത്രത്തിന്റെ 1/7 ഭാഗം കുടിച്ചു.",
            "You painted 3/8 of a wall blue and then painted another 2/8 of the wall green.": "നിങ്ങൾ ഒരു ഭിത്തിയുടെ 3/8 ഭാഗം നീല നിറത്തിൽ പെയിന്റ് ചെയ്തു, തുടർന്ന് ഭിത്തിയുടെ മറ്റൊരു 2/8 ഭാഗം പച്ച നിറത്തിൽ പെയിന്റ് ചെയ്തു.",
            "You had 7/10 of a giant submarine sandwich. You ate 3/10 of it for lunch.": "നിങ്ങളുടെ അടുത്ത് ഒരു ഭീമാകാരമായ സബ്മറൈൻ സാൻഡ്‌വിച്ചിന്റെ 7/10 ഭാഗം ഉണ്ടായിരുന്നു. ഉച്ചഭക്ഷണത്തിന് നിങ്ങൾ അതിന്റെ 3/10 ഭാഗം കഴിച്ചു.",
            "1/6 of the flowers in a garden are red, and 3/6 are yellow.": "ഒരു തോട്ടത്തിലെ പൂക്കളുടെ 1/6 ഭാഗം ചുവപ്പാണ്, 3/6 ഭാഗം മഞ്ഞയാണ്.",
            "You have 1/2 of a large pizza and your friend has 3/4 of a medium pizza. Which one is more?": "നിങ്ങളുടെ അടുത്ത് ഒരു വലിയ പിസ്സയുടെ 1/2 ഭാഗവും നിങ്ങളുടെ കൂട്ടുകാരന്റെ അടുത്ത് ഒരു ഇടത്തരം പിസ്സയുടെ 3/4 ഭാഗവുമുണ്ട്. ഏതാണ് കൂടുതൽ?",
            "You need to pour 1/3 cup of sugar and 2/6 cup of flour. Are these amounts the same?": "നിങ്ങൾക്ക് 1/3 കപ്പ് പഞ്ചസാരയും 2/6 കപ്പ് മാവും ഒഴിക്കണം. ഈ അളവുകൾ തുല്യമാണോ?",
            "Chef Uni has three different types of fruit pies: a blueberry pie (2/3 left), an apple pie (5/6 left), and a cherry pie (1/2 left). She wants to serve them from least amount to greatest amount.": "ചെഫ് യൂണിക്ക് മൂന്ന് തരം ഫ്രൂട്ട് പൈകളുണ്ട്: ഒരു ബ്ലൂബെറി പൈ (2/3 ബാക്കി), ഒരു ആപ്പിൾ പൈ (5/6 ബാക്കി), ഒരു ചെറി പൈ (1/2 ബാക്കി). അവ കുറഞ്ഞ അളവിൽ നിന്ന് കൂടിയ അളവിലേക്ക് വിളമ്പാൻ അവൾ ആഗ്രഹിക്കുന്നു.",
            "You spent 1/4 of your allowance on a toy and 2/5 on candy. Which cost you more?": "നിങ്ങളുടെ അലവൻസിന്റെ 1/4 ഭാഗം ഒരു കളിപ്പാട്ടത്തിനും 2/5 ഭാഗം മിഠായിക്കും വേണ്ടി നിങ്ങൾ ചെലവഴിച്ചു. ഏതിനാണ് കൂടുതൽ വില?",
            "Two friends are sharing a cake. Friend A eats 3/8 of the cake. Friend B eats 1/3 of the cake. Who ate more cake?": "രണ്ട് കൂട്ടുകാർ ഒരു കേക്ക് പങ്കിടുകയാണ്. കൂട്ടുകാരൻ A കേക്കിന്റെ 3/8 ഭാഗം കഴിച്ചു. കൂട്ടുകാരൻ B കേക്കിന്റെ 1/3 ഭാഗം കഴിച്ചു. ആരാണ് കൂടുതൽ കേക്ക് കഴിച്ചത്?",
            "You have 1/2 of a sandwich. Which of these pictures shows the exact same amount of sandwich?": "നിങ്ങളുടെ അടുത്ത് ഒരു സാൻഡ്‌വിച്ചിന്റെ 1/2 ഭാഗമുണ്ട്. ഈ ചിത്രങ്ങളിൽ ഏതാണ് അതേ അളവ് സാൻഡ്‌വിച്ച് കാണിക്കുന്നത്?",
            "A giant cookie is cut into 3 equal pieces, and you have 1 piece (1/3). If you cut that piece into 2 smaller pieces, what equivalent fraction do you have?": "ഒരു ഭീമാകാരമായ കുക്കി 3 തുല്യ കഷണങ്ങളായി മുറിച്ചു, നിങ്ങളുടെ അടുത്ത് 1 കഷണം (1/3) ഉണ്ട്. നിങ്ങൾ ആ കഷണം 2 ചെറിയ കഷണങ്ങളായി മുറിച്ചാൽ, നിങ്ങൾക്ക് എന്ത് തുല്യമായ ഭിന്നസംഖ്യയാണ് ലഭിക്കുക?",
            "You have 2/4 of a pizza. Which fraction is equivalent to this amount in its simplest form?": "നിങ്ങളുടെ അടുത്ത് ഒരു പിസ്സയുടെ 2/4 ഭാഗമുണ്ട്. ഇതിന് തുല്യമായ ഏറ്റവും ലളിതമായ ഭിന്നസംഖ്യ ഏതാണ്?",
            "A cake is divided into 8 slices. You have 4 slices (4/8). What is another way to write this fraction?": "ഒരു കേക്കിനെ 8 കഷണങ്ങളായി തിരിച്ചിരിക്കുന്നു. നിങ്ങളുടെ അടുത്ത് 4 കഷണങ്ങളുണ്ട് (4/8). ഈ ഭിന്നസംഖ്യ എഴുതാൻ മറ്റൊരു വഴി എന്താണ്?",
            "You are sharing a chocolate bar that has 6 squares. You want 2/6 of it. Which fraction below represents the same amount in simplest form?": "നിങ്ങൾ 6 ചതുരങ്ങളുള്ള ഒരു ചോക്ലേറ്റ് ബാർ പങ്കിടുകയാണ്. നിങ്ങൾക്ക് അതിന്റെ 2/6 ഭാഗം വേണം. ഏറ്റവും ലളിതമായ രൂപത്തിൽ ഇതേ അളവിനെ സൂചിപ്പിക്കുന്ന ഭിന്നസംഖ്യ താഴെ പറയുന്നവയിൽ ഏതാണ്?",
        };
        return language === 'ml' ? mlTranslations[enText] || enText : enText;
    }

    function getLocalizedQuestion(enText) {
        const mlTranslations = {
            "What fraction of the pizza is in the small box?": "പിസ്സയുടെ ഏത് ഭിന്നസംഖ്യയാണ് ചെറിയ പെട്ടിയിലുള്ളത്?",
            "What fraction of the pie did her grandson eat?": "അവരുടെ പേരക്കുട്ടി പൈയുടെ ഏത് ഭിന്നസംഖ്യയാണ് കഴിച്ചത്?",
            "What fraction of the apples did you pick?": "നിങ്ങൾ എടുത്ത ആപ്പിളുകളുടെ ഭിന്നസംഖ്യ ഏതാണ്?",
            "What fraction of the chocolate bar did you eat?": "നിങ്ങൾ കഴിച്ച ചോക്ലേറ്റ് ബാറിന്റെ ഭിന്നസംഖ്യ ഏതാണ്?",
            "What fraction of the lemonade did you pour out?": "നിങ്ങൾ ഒഴിച്ച നാരങ്ങാവെള്ളത്തിന്റെ ഭിന്നസംഖ്യ ഏതാണ്?",
            "What fraction of the books have you read?": "നിങ്ങൾ വായിച്ച പുസ്തകങ്ങളുടെ ഭിന്നസംഖ്യ ഏതാണ്?",
            "What fraction of the balloons are red?": "ബലൂണുകളുടെ ഏത് ഭിന്നസംഖ്യയാണ് ചുവപ്പ് നിറത്തിലുള്ളത്?",
            "What fraction of the marbles are blue?": "ഗോലികളുടെ ഏത് ഭിന്നസംഖ്യയാണ് നീല നിറത്തിലുള്ളത്?",
            "What fraction of the cookies did you grab?": "നിങ്ങൾ എടുത്ത കുക്കികളുടെ ഭിന്നസംഖ്യ ഏതാണ്?",
            "What fraction of the children are wearing hats?": "തൊപ്പി വെച്ച കുട്ടികളുടെ ഭിന്നസംഖ്യ ഏതാണ്?",
            "Express the total number of slices you used as an improper fraction.": "നിങ്ങൾ ഉപയോഗിച്ച മൊത്തം കഷണങ്ങളെ അനുചിതമായ ഭിന്നസംഖ്യയായി പ്രകടിപ്പിക്കുക.",
            "How many slices of pie are there in total, expressed as an improper fraction?": "മൊത്തം എത്ര കഷണം പൈ ഉണ്ട്, അത് അനുചിതമായ ഭിന്നസംഖ്യയായി പ്രകടിപ്പിക്കുക?",
            "How much sugar do you need in total, as an improper fraction?": "മൊത്തം എത്ര പഞ്ചസാര വേണം, അത് അനുചിതമായ ഭിന്നസംഖ്യയായി പ്രകടിപ്പിക്കുക?",
            "How many eggs do you have in total, as an improper fraction of a carton?": "മൊത്തം എത്ര മുട്ടകൾ ഉണ്ട്, അത് ഒരു കാർട്ടണിന്റെ അനുചിതമായ ഭിന്നസംഖ്യയായി പ്രകടിപ്പിക്കുക?",
            "What is the total length of ribbon, expressed as an improper fraction of a meter?": "റിബണിന്റെ മൊത്തം നീളം എത്രയാണ്, അത് ഒരു മീറ്ററിന്റെ അനുചിതമായ ഭിന്നസംഖ്യയായി പ്രകടിപ്പിക്കുക?",
            "What is the total height of your block tower, as an improper fraction?": "നിങ്ങളുടെ ബ്ലോക്ക് ടവറിൻ്റെ ആകെ ഉയരം, അനുചിതമായ ഭിന്നസംഖ്യയായി പ്രകടിപ്പിക്കുക?",
            "How many gallons of juice do you have in total, as an improper fraction?": "മൊത്തം എത്ര ഗാലൺ ജ്യൂസ് ഉണ്ട്, അത് അനുചിതമായ ഭിന്നസംഖ്യയായി പ്രകടിപ്പിക്കുക?",
            "How much yogurt do you need, as an improper fraction?": "മൊത്തം എത്ര തൈര് വേണം, അത് അനുചിതമായ ഭിന്നസംഖ്യയായി പ്രകടിപ്പിക്കുക?",
            "What is the total length of the fence, as an improper fraction of a meter?": "വേലിയുടെ മൊത്തം നീളം എത്രയാണ്, അത് ഒരു മീറ്ററിന്റെ അനുചിതമായ ഭിന്നസംഖ്യയായി പ്രകടിപ്പിക്കുക?",
            "How much of the giant cookie is needed, as an improper fraction?": "ഭീമാകാരമായ കുക്കിയുടെ എത്ര ഭാഗം വേണം, അത് അനുചിതമായ ഭിന്നസംഖ്യയായി പ്രകടിപ്പിക്കുക?",
            "How many pizzas do you have in total, expressed as a mixed fraction?": "മൊത്തം എത്ര പിസ്സകൾ ഉണ്ട്, അത് മിശ്ര ഭിന്നസംഖ്യയായി പ്രകടിപ്പിക്കുക?",
            "How many cakes does Chef Mixie have, as a mixed fraction?": "ചെഫ് മിക്സിയുടെ അടുത്ത് എത്ര കേക്കുകൾ ഉണ്ട്, അത് മിശ്ര ഭിന്നസംഖ്യയായി പ്രകടിപ്പിക്കുക?",
            "How many rows of flowers did you plant in total, as a mixed fraction?": "മൊത്തം എത്ര നിരകളിൽ പൂക്കൾ നട്ടു, അത് മിശ്ര ഭിന്നസംഖ്യയായി പ്രകടിപ്പിക്കുക?",
            "How much flour is needed, as a mixed fraction?": "എത്ര മാവാണ് വേണ്ടത്, അത് മിശ്ര ഭിന്നസംഖ്യയായി പ്രകടിപ്പിക്കുക?",
            "How long did you walk in total, as a mixed fraction?": "മൊത്തം എത്ര നേരം നിങ്ങൾ നടന്നു, അത് മിശ്ര ഭിന്നസംഖ്യയായി പ്രകടിപ്പിക്കുക?",
            "How many baskets of apples did the farmer harvest, as a mixed fraction?": "കർഷകൻ എത്ര കൊട്ട ആപ്പിളുകളാണ് ശേഖരിച്ചത്, അത് മിശ്ര ഭിന്നസംഖ്യയായി പ്രകടിപ്പിക്കുക?",
            "How many chapters did you read in total, as a mixed fraction?": "മൊത്തം എത്ര അധ്യായങ്ങൾ നിങ്ങൾ വായിച്ചു, അത് മിശ്ര ഭിന്നസംഖ്യയായി പ്രകടിപ്പിക്കുക?",
            "How many lemons are used, as a mixed fraction?": "എത്ര നാരങ്ങകളാണ് ഉപയോഗിച്ചത്, അത് മിശ്ര ഭിന്നസംഖ്യയായി പ്രകടിപ്പിക്കുക?",
            "What was the total duration you watched, as a mixed fraction of an hour?": "നിങ്ങൾ കണ്ട മൊത്തം സമയം എത്രയായിരുന്നു, അത് ഒരു മണിക്കൂറിന്റെ മിശ്ര ഭിന്നസംഖ്യയായി പ്രകടിപ്പിക്കുക?",
            "How much wood was used in total, as a mixed fraction?": "മൊത്തം എത്ര മരം ഉപയോഗിച്ചു, അത് മിശ്ര ഭിന്നസംഖ്യയായി പ്രകടിപ്പിക്കുക?",
            "What fraction represents the single piece you received?": "നിങ്ങൾക്ക് ലഭിച്ച ഒരു കഷണത്തെ സൂചിപ്പിക്കുന്ന ഭിന്നസംഖ്യ ഏതാണ്?",
            "What fraction represents one slice of pizza?": "ഒരു കഷണം പിസ്സയെ സൂചിപ്പിക്കുന്ന ഭിന്നസംഖ്യ ഏതാണ്?",
            "What fraction represents one portion of cake?": "ഒരു ഭാഗം കേക്കിനെ സൂചിപ്പിക്കുന്ന ഭിന്നസംഖ്യ ഏതാണ്?",
            "What fraction of the marbles did you pick out?": "നിങ്ങൾ എടുത്ത ഗോലികളുടെ ഭിന്നസംഖ്യ ഏതാണ്?",
            "What fraction of the sandwich did you eat?": "നിങ്ങൾ കഴിച്ച സാൻഡ്‌വിച്ചിന്റെ ഭിന്നസംഖ്യ ഏതാണ്?",
            "What fraction of the pie does each friend get?": "ഓരോ കൂട്ടുകാരനും പൈയുടെ ഏത് ഭിന്നസംഖ്യയാണ് ലഭിക്കുന്നത്?",
            "What fraction of the original string did you cut off?": "നിങ്ങൾ മുറിച്ചെടുത്ത യഥാർത്ഥ നൂലിന്റെ ഭിന്നസംഖ്യ ഏതാണ്?",
            "What fraction of the loaf is the piece you took?": "നിങ്ങൾ എടുത്ത ബ്രെഡ് ലോഫിന്റെ ഭിന്നസംഖ്യ ഏതാണ്?",
            "What fraction of the candies did you pick out?": "നിങ്ങൾ എടുത്ത മിഠായികളുടെ ഭിന്നസംഖ്യ ഏതാണ്?",
            "What fraction of the garden are you planting flowers in?": "നിങ്ങൾ പൂക്കൾ നടുന്ന തോട്ടത്തിന്റെ ഭിന്നസംഖ്യ ഏതാണ്?",
            "How much chocolate cake do you have in total?": "മൊത്തം എത്ര ചോക്ലേറ്റ് കേക്ക് നിങ്ങളുടെ അടുത്ത് ഉണ്ട്?",
            "How much orange juice is left in the pitcher?": "പാത്രത്തിൽ എത്ര ഓറഞ്ച് ജ്യൂസ് ബാക്കിയുണ്ട്?",
            "What fraction of the wall have you painted in total?": "മൊത്തം ഭിത്തിയുടെ ഏത് ഭിന്നസംഖ്യയാണ് നിങ്ങൾ പെയിന്റ് ചെയ്തത്?",
            "How much of the submarine sandwich is left?": "സബ്മറൈൻ സാൻഡ്‌വിച്ചിന്റെ എത്ര ഭാഗം ബാക്കിയുണ്ട്?",
            "What fraction of the garden has red or yellow flowers?": "തോട്ടത്തിന്റെ ഏത് ഭിന്നസംഖ്യയിൽ ചുവപ്പ് അല്ലെങ്കിൽ മഞ്ഞ പൂക്കളുണ്ട്?",
            "What fraction of the water bottle was poured out in total?": "മൊത്തം കുപ്പിയുടെ ഏത് ഭിന്നസംഖ്യയാണ് ഒഴിച്ചത്?",
            "What fraction of the path is still covered with stones?": "വഴിയുടെ ഏത് ഭിന്നസംഖ്യയാണ് ഇപ്പോഴും കല്ലുകൾ കൊണ്ട് മൂടിയിരിക്കുന്നത്?",
            "How many hours did you practice in total?": "മൊത്തം എത്ര മണിക്കൂർ നിങ്ങൾ പരിശീലിച്ചു?",
            "How much more milk do you need?": "നിങ്ങൾക്ക് എത്ര പാൽ കൂടി വേണം?",
            "What fraction of the students like either apples or oranges?": "വിദ്യാർത്ഥികളുടെ ഏത് ഭിന്നസംഖ്യക്കാണ് ആപ്പിൾ അല്ലെങ്കിൽ ഓറഞ്ച് ഇഷ്ടം?",
            "Which fraction represents the larger amount of pizza?": "ഏത് ഭിന്നസംഖ്യയാണ് പിസ്സയുടെ വലിയ അളവിനെ സൂചിപ്പിക്കുന്നത്?",
            "Are 1/3 and 2/6 equivalent fractions?": "1/3 ഉം 2/6 ഉം തുല്യ ഭിന്നസംഖ്യകളാണോ?",
            "Order the remaining pie amounts from least to greatest.": "ബാക്കിയുള്ള പൈകളുടെ അളവുകൾ കുറഞ്ഞതിൽ നിന്ന് കൂടിയതിലേക്ക് ക്രമീകരിക്കുക.",
            "Which fraction is larger, 1/4 or 2/5?": "1/4 ഓ 2/5 ഓ ഏതാണ് വലിയ ഭിന്നസംഖ്യ?",
            "Who ate more?": "ആരാണ് കൂടുതൽ കഴിച്ചത്?",
            "Which fraction is smaller, 2/5 or 1/2?": "2/5 ഓ 1/2 ഓ ഏതാണ് ചെറിയ ഭിന്നസംഖ്യ?",
            "Are 1/6 and 2/12 equivalent?": "1/6 ഉം 2/12 ഉം തുല്യമാണോ?",
            "Order the fractions from least to greatest.": "ഭിന്നസംഖ്യകൾ കുറഞ്ഞതിൽ നിന്ന് കൂടിയതിലേക്ക് ക്രമീകരിക്കുക.",
            "Which fraction is the largest: 2/3, 5/6, or 1/2?": "2/3, 5/6, അല്ലെങ്കിൽ 1/2 എന്നിവയിൽ ഏതാണ് ഏറ്റവും വലിയ ഭിന്നസംഖ്യ?",
            "Are 4/10 and 2/5 equivalent?": "4/10 ഉം 2/5 ഉം തുല്യമാണോ?",
            "Select the image that shows an equivalent fraction to 1/2.": "1/2 ന് തുല്യമായ ഭിന്നസംഖ്യ കാണിക്കുന്ന ചിത്രം തിരഞ്ഞെടുക്കുക.",
            "1/3 is equivalent to which of these?": "1/3 ഇതിൽ ഏതിനാണ് തുല്യമായത്?",
            "Find the simplest equivalent fraction for 2/4.": "2/4 ന് തുല്യമായ ഏറ്റവും ലളിതമായ ഭിന്നസംഖ്യ കണ്ടെത്തുക.",
            "Select an equivalent fraction for 4/8.": "4/8 ന് തുല്യമായ ഒരു ഭിന്നസംഖ്യ തിരഞ്ഞെടുക്കുക.",
            "What is the simplest equivalent fraction for 2/6?": "2/6 ന് തുല്യമായ ഏറ്റവും ലളിതമായ ഭിന്നസംഖ്യ ഏതാണ്?",
            "Which of these fractions is equivalent to 3/9?": "ഈ ഭിന്നസംഖ്യകളിൽ ഏതാണ് 3/9 ന് തുല്യമായത്?",
            "Simplify 2/10.": "2/10 നെ ലളിതമാക്കുക.",
            "Simplify 6/12.": "6/12 നെ ലളിതമാക്കുക.",
            "Select an equivalent fraction for 4/16.": "4/16 ന് തുല്യമായ ഒരു ഭിന്നസംഖ്യ തിരഞ്ഞെടുക്കുക.",
            "What is 5/5 equivalent to?": "5/5 ന് തുല്യമായത് എന്താണ്?",
        };
        return language === 'ml' ? mlTranslations[enText] || enText : enText;
    }
    function getLocalizedExplanation(enText) {
        const mlTranslations = {
            "The pizza is divided into 8 equal parts (the denominator). You have 3 of those parts (the numerator). So the fraction is 3/8.": "പിസ്സയെ 8 തുല്യ ഭാഗങ്ങളായി തിരിച്ചിരിക്കുന്നു (ഛേദം). നിങ്ങൾക്ക് അതിൽ 3 ഭാഗങ്ങളുണ്ട് (അംശം). അതിനാൽ ഭിന്നസംഖ്യ 3/8 ആണ്.",
            "The pie is divided into 6 equal parts. The grandson ate 2 of those parts. So the fraction is 2/6.": "പൈയെ 6 തുല്യ ഭാഗങ്ങളായി തിരിച്ചിരിക്കുന്നു. പേരക്കുട്ടി ആ ഭാഗങ്ങളിൽ 2 എണ്ണം കഴിച്ചു. അതിനാൽ ഭിന്നസംഖ്യ 2/6 ആണ്.",
            "The total number of apples is 10. The number you picked is 4. So the fraction is 4/10.": "മൊത്തം ആപ്പിളുകളുടെ എണ്ണം 10 ആണ്. നിങ്ങൾ എടുത്ത ആപ്പിളുകളുടെ എണ്ണം 4 ആണ്. അതിനാൽ ഭിന്നസംഖ്യ 4/10 ആണ്.",
            "The chocolate bar is divided into 5 equal squares. You ate 1 square. So the fraction is 1/5.": "ചോക്ലേറ്റ് ബാർ 5 തുല്യ ചതുരങ്ങളായി തിരിച്ചിരിക്കുന്നു. നിങ്ങൾ 1 ചതുരം കഴിച്ചു. അതിനാൽ ഭിന്നസംഖ്യ 1/5 ആണ്.",
            "The pitcher holds 7 glasses. You poured out 5. So the fraction is 5/7.": "പാത്രത്തിൽ 7 ഗ്ലാസ് വെള്ളം കൊള്ളും. നിങ്ങൾ 5 ഗ്ലാസ് ഒഴിച്ചു. അതിനാൽ ഭിന്നസംഖ്യ 5/7 ആണ്.",
            "Two whole loaves have 2 * 4 = 8 slices. You add 3 more slices from the third loaf. Total slices are 8 + 3 = 11. The size of each slice is 1/4 of a loaf. So the improper fraction is 11/4.": "രണ്ട് മുഴുവൻ ലോഫുകൾക്ക് 2 * 4 = 8 കഷണങ്ങളുണ്ട്. നിങ്ങൾ മൂന്നാമത്തെ ലോഫിൽ നിന്ന് 3 കഷണങ്ങൾ കൂടി ചേർക്കുന്നു. മൊത്തം കഷണങ്ങൾ 8 + 3 = 11 ആണ്. ഓരോ കഷണത്തിന്റെയും വലുപ്പം ഒരു ലോഫിന്റെ 1/4 ആണ്. അതിനാൽ അനുചിതമായ ഭിന്നസംഖ്യ 11/4 ആണ്.",
            "Two whole pies have 2 * 6 = 12 slices. You have 1 extra slice. Total slices are 12 + 1 = 13. Each slice is 1/6 of a pie. So the improper fraction is 13/6.": "രണ്ട് മുഴുവൻ പൈകൾക്ക് 2 * 6 = 12 കഷണങ്ങളുണ്ട്. നിങ്ങൾക്ക് 1 അധിക കഷണം ഉണ്ട്. മൊത്തം കഷണങ്ങൾ 12 + 1 = 13 ആണ്. ഓരോ കഷണവും ഒരു പൈയുടെ 1/6 ഭാഗമാണ്. അതിനാൽ അനുചിതമായ ഭിന്നസംഖ്യ 13/6 ആണ്.",
            "You need 1/2 cup for each of the 3 batches. This is (1/2) + (1/2) + (1/2) = 3/2.": "3 ബാച്ചുകൾക്കും 1/2 കപ്പ് വീതം വേണം. ഇത് (1/2) + (1/2) + (1/2) = 3/2 ആണ്.",
            "One full carton is 8/8. You have 5 extra eggs, which is 5/8 of a carton. Total is 8/8 + 5/8 = 13/8.": "ഒരു മുഴുവൻ കാർട്ടൺ 8/8 ആണ്. നിങ്ങൾക്ക് 5 അധിക മുട്ടകൾ ഉണ്ട്, അത് ഒരു കാർട്ടണിന്റെ 5/8 ഭാഗമാണ്. മൊത്തം 8/8 + 5/8 = 13/8 ആണ്.",
            "Each piece is 1/5 meter long. You have 7 pieces. The total length is (1/5) * 7 = 7/5 meters.": "ഓരോ കഷണത്തിനും 1/5 മീറ്റർ നീളമുണ്ട്. നിങ്ങൾക്ക് 7 കഷണങ്ങളുണ്ട്. മൊത്തം നീളം (1/5) * 7 = 7/5 മീറ്ററാണ്.",
            "You have 2 whole pizzas and 1/2 of another. The mixed fraction is 2 and 1/2.": "നിങ്ങളുടെ അടുത്ത് 2 മുഴുവൻ പിസ്സകളും ഒരു പിസ്സയുടെ 1/2 ഭാഗവുമുണ്ട്. മിശ്ര ഭിന്നസംഖ്യ 2, 1/2 ആണ്.",
            "You have 3 whole cakes and 2/3 of another. The mixed fraction is 3 and 2/3.": "നിങ്ങളുടെ അടുത്ത് 3 മുഴുവൻ കേക്കുകളും മറ്റൊരു കേക്കിന്റെ 2/3 ഭാഗവുമുണ്ട്. മിശ്ര ഭിന്നസംഖ്യ 3, 2/3 ആണ്.",
            "You have 4 full rows and 1/4 of another. The mixed fraction is 4 and 1/4.": "നിങ്ങളുടെ അടുത്ത് 4 മുഴുവൻ നിരകളും മറ്റൊരു നിരയുടെ 1/4 ഭാഗവുമുണ്ട്. മിശ്ര ഭിന്നസംഖ്യ 4, 1/4 ആണ്.",
            "You need 1 full cup and 3/4 of a cup. The mixed fraction is 1 and 3/4.": "നിങ്ങൾക്ക് 1 മുഴുവൻ കപ്പും ഒരു കപ്പിന്റെ 3/4 ഭാഗവും വേണം. മിശ്ര ഭിന്നസംഖ്യ 1, 3/4 ആണ്.",
            "You walked 2 full hours and 1/3 of an hour. The mixed fraction is 2 and 1/3.": "നിങ്ങൾ 2 മുഴുവൻ മണിക്കൂറും ഒരു മണിക്കൂറിന്റെ 1/3 ഭാഗവും നടന്നു. മിശ്ര ഭിന്നസംഖ്യ 2, 1/3 ആണ്.",
            "A unit fraction has a numerator of 1. Here, the whole is divided into 8 pieces, and you have 1 piece, so the fraction is 1/8.": "ഒരു യൂണിറ്റ് ഭിന്നസംഖ്യയുടെ അംശം 1 ആണ്. ഇവിടെ, മുഴുവൻ ഭാഗത്തെയും 8 കഷണങ്ങളായി തിരിച്ചിരിക്കുന്നു, നിങ്ങൾക്ക് 1 കഷണം ഉണ്ട്, അതിനാൽ ഭിന്നസംഖ്യ 1/8 ആണ്.",
            "The pizza is divided into 4 equal slices. One slice is 1/4 of the whole pizza.": "പിസ്സയെ 4 തുല്യ കഷണങ്ങളായി തിരിച്ചിരിക്കുന്നു. ഒരു കഷണം മുഴുവൻ പിസ്സയുടെ 1/4 ഭാഗമാണ്.",
            "The cake is cut into 12 equal portions. One portion is 1/12 of the whole cake.": "കേക്കിനെ 12 തുല്യ ഭാഗങ്ങളായി മുറിച്ചിരിക്കുന്നു. ഒരു ഭാഗം മുഴുവൻ കേക്കിന്റെ 1/12 ഭാഗമാണ്.",
            "There are 10 marbles in total. You picked out 1. The fraction is 1/10.": "മൊത്തം 10 ഗോലികളുണ്ട്. നിങ്ങൾ 1 എണ്ണം എടുത്തു. ഭിന്നസംഖ്യ 1/10 ആണ്.",
            "The sandwich is divided into 6 sections. You ate 1. The fraction is 1/6.": "സാൻഡ്‌വിച്ചിനെ 6 ഭാഗങ്ങളായി തിരിച്ചിരിക്കുന്നു. നിങ്ങൾ 1 എണ്ണം കഴിച്ചു. ഭിന്നസംഖ്യ 1/6 ആണ്.",
            "When adding fractions with the same denominator, you just add the numerators. So, 2/5 + 1/5 = 3/5.": "ഒരേ ഛേദമുള്ള ഭിന്നസംഖ്യകൾ കൂട്ടുമ്പോൾ, അംശങ്ങൾ മാത്രം കൂട്ടിയാൽ മതി. അതിനാൽ, 2/5 + 1/5 = 3/5.",
            "When subtracting fractions with the same denominator, you subtract the numerators. So, 4/7 - 1/7 = 3/7.": "ഒരേ ഛേദമുള്ള ഭിന്നസംഖ്യകൾ കുറയ്ക്കുമ്പോൾ, അംശങ്ങൾ കുറച്ചാൽ മതി. അതിനാൽ, 4/7 - 1/7 = 3/7.",
            "You simply add the numerators: 3/8 + 2/8 = 5/8.": "അംശങ്ങൾ കൂട്ടുക: 3/8 + 2/8 = 5/8.",
            "Subtract the numerators: 7/10 - 3/10 = 4/10.": "അംശങ്ങൾ കുറയ്ക്കുക: 7/10 - 3/10 = 4/10.",
            "Add the numerators: 1/6 + 3/6 = 4/6.": "അംശങ്ങൾ കൂട്ടുക: 1/6 + 3/6 = 4/6.",
            "To compare, convert to a common denominator. 1/2 is the same as 2/4. Since 3/4 is greater than 2/4, your friend has more pizza.": "താരതമ്യം ചെയ്യാൻ, ഒരു പൊതു ഛേദത്തിലേക്ക് മാറ്റുക. 1/2 എന്നത് 2/4 ന് തുല്യമാണ്. 3/4 എന്നത് 2/4 നെക്കാൾ വലുതായതിനാൽ, നിങ്ങളുടെ കൂട്ടുകാരന്റെ അടുത്ത് കൂടുതൽ പിസ്സയുണ്ട്.",
            "To find an equivalent fraction, you can multiply or divide the numerator and denominator by the same number. If you multiply the numerator and denominator of 1/3 by 2, you get 2/6. So they are equivalent.": "തുല്യമായ ഭിന്നസംഖ്യ കണ്ടെത്താൻ, അംശത്തെയും ഛേദത്തെയും ഒരേ സംഖ്യകൊണ്ട് ഗുണിക്കുകയോ ഹരിക്കുകയോ ചെയ്യാം. നിങ്ങൾ 1/3 ന്റെ അംശത്തെയും ഛേദത്തെയും 2 കൊണ്ട് ഗുണിച്ചാൽ, നിങ്ങൾക്ക് 2/6 ലഭിക്കും. അതിനാൽ അവ തുല്യമാണ്.",
            "To order these, we find a common denominator, which is 6. 1/2 = 3/6, 2/3 = 4/6, and 5/6 stays the same. The order from least to greatest is 3/6, 4/6, 5/6, which corresponds to 1/2, 2/3, 5/6.": "ഇവയെ ക്രമീകരിക്കാൻ, നമ്മൾ ഒരു പൊതു ഛേദം കണ്ടെത്തുന്നു, അത് 6 ആണ്. 1/2 = 3/6, 2/3 = 4/6, കൂടാതെ 5/6 അതേപടി നിലനിൽക്കുന്നു. കുറഞ്ഞതിൽ നിന്ന് കൂടിയതിലേക്കുള്ള ക്രമം 3/6, 4/6, 5/6 ആണ്, ഇത് 1/2, 2/3, 5/6 എന്നിവയുമായി പൊരുത്തപ്പെടുന്നു.",
            "To compare, convert to a common denominator, which is 20. 1/4 = 5/20 and 2/5 = 8/20. Since 8/20 is greater than 5/20, 2/5 is the larger fraction.": "താരതമ്യം ചെയ്യാൻ, ഒരു പൊതു ഛേദത്തിലേക്ക് മാറ്റുക, അത് 20 ആണ്. 1/4 = 5/20 ഉം 2/5 = 8/20 ഉം ആണ്. 8/20 എന്നത് 5/20 നെക്കാൾ വലുതായതിനാൽ, 2/5 ആണ് വലിയ ഭിന്നസംഖ്യ.",
            "To compare, convert to a common denominator, which is 24. 3/8 = 9/24 and 1/3 = 8/24. Since 9/24 is greater than 8/24, Friend A ate more.": "താരതമ്യം ചെയ്യാൻ, ഒരു പൊതു ഛേദത്തിലേക്ക് മാറ്റുക, അത് 24 ആണ്. 3/8 = 9/24 ഉം 1/3 = 8/24 ഉം ആണ്. 9/24 എന്നത് 8/24 നെക്കാൾ വലുതായതിനാൽ, കൂട്ടുകാരൻ A കൂടുതൽ കഴിച്ചു.",
            "To find an equivalent fraction, you can multiply the numerator and denominator by the same number. 1/2 * 2/2 = 2/4. Both fractions represent the same amount.": "തുല്യമായ ഭിന്നസംഖ്യ കണ്ടെത്താൻ, അംശത്തെയും ഛേദത്തെയും ഒരേ സംഖ്യകൊണ്ട് ഗുണിക്കുക. 1/2 * 2/2 = 2/4. രണ്ട് ഭിന്നസംഖ്യകളും ഒരേ അളവിനെയാണ് സൂചിപ്പിക്കുന്നത്.",
            "If you cut the whole cookie into smaller pieces of the same size, each original piece will be divided equally. Cutting 1/3 into two pieces means the whole is now in 6 pieces, so you have 2/6. 1/3 * 2/2 = 2/6.": "നിങ്ങൾ മുഴുവൻ കുക്കിയെയും ഒരേ വലുപ്പമുള്ള ചെറിയ കഷണങ്ങളായി മുറിച്ചാൽ, ഓരോ യഥാർത്ഥ കഷണത്തെയും തുല്യമായി വിഭജിക്കും. 1/3 നെ രണ്ട് കഷണങ്ങളായി മുറിക്കുമ്പോൾ, മുഴുവൻ ഭാഗവും ഇപ്പോൾ 6 കഷണങ്ങളായി മാറുന്നു, അതിനാൽ നിങ്ങൾക്ക് 2/6 ലഭിക്കുന്നു. 1/3 * 2/2 = 2/6.",
            "To simplify a fraction, divide the numerator and denominator by their greatest common divisor. Both 2 and 4 can be divided by 2. 2/2 = 1 and 4/2 = 2, so the simplest form is 1/2.": "ഒരു ഭിന്നസംഖ്യയെ ലളിതമാക്കാൻ, അംശത്തെയും ഛേദത്തെയും അവയുടെ ഏറ്റവും വലിയ പൊതു ഹാരകം കൊണ്ട് ഹരിക്കുക. 2 നെയും 4 നെയും 2 കൊണ്ട് ഹരിക്കാം. 2/2 = 1 ഉം 4/2 = 2 ഉം ആയതിനാൽ, ഏറ്റവും ലളിതമായ രൂപം 1/2 ആണ്.",
            "Both 1/2 and 2/4 are equivalent to 4/8. 4/8 simplifies to 1/2, and multiplying 1/2 by 2/2 gives you 2/4.": "1/2 ഉം 2/4 ഉം 4/8 ന് തുല്യമാണ്. 4/8 നെ ലളിതമാക്കുമ്പോൾ 1/2 ലഭിക്കുന്നു, കൂടാതെ 1/2 നെ 2/2 കൊണ്ട് ഗുണിച്ചാൽ 2/4 ലഭിക്കുന്നു.",
            "To simplify 2/6, divide the numerator and denominator by 2. 2/2 = 1 and 6/2 = 3. So the simplest form is 1/3.": "2/6 നെ ലളിതമാക്കാൻ, അംശത്തെയും ഛേദത്തെയും 2 കൊണ്ട് ഹരിക്കുക. 2/2 = 1 ഉം 6/2 = 3 ഉം ആണ്. അതിനാൽ ഏറ്റവും ലളിതമായ രൂപം 1/3 ആണ്.",
        };
        return language === 'ml' ? mlTranslations[enText] || enText : enText;
    }

    function getLocalizedLevelTitle(enText) {
        const mlTranslations = {
            "proper": "ശരിയായ പിസ്സ പാർലർ",
            "improper": "അനുചിതമായ ചേരുവകൾ",
            "mixed": "അത്ഭുതകരമായ മിക്സഡ്-അപ്പ് വിഭവങ്ങൾ",
            "unit": "അദ്വിതീയ യൂണിറ്റ് ബൈറ്റുകൾ",
            "like": "ഒരേ ഛേദമുള്ള ഭിന്നസംഖ്യകൾ",
            "unlike": "വ്യത്യസ്ത ഛേദമുള്ള ഭിന്നസംഖ്യകൾ",
            "equivalent": "തുല്യമായ ഭിന്നസംഖ്യകൾ"
        };
        return language === 'ml' ? mlTranslations[enText] || enText : enText;
    }

    function shuffleArray(array) {
        for (let i = array.length - 1; i > 0; i--) {
            const j = Math.floor(Math.random() * (i + 1));
            [array[i], array[j]] = [array[j], array[i]];
        }
        return array;
    }

    // Initial render
    renderLanguageSelection();

</script>

</body>
</html>

Comments