Magneticdogson commited on
Commit
a398606
·
verified ·
1 Parent(s): bbc4ed1

улучши код, доюбавь свои предложения и переведи на русский язык

Browse files
Files changed (2) hide show
  1. README.md +9 -5
  2. index.html +535 -18
README.md CHANGED
@@ -1,10 +1,14 @@
1
  ---
2
- title: Undefined
3
- emoji: 🐢
4
- colorFrom: pink
5
- colorTo: gray
6
  sdk: static
7
  pinned: false
 
 
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
1
  ---
2
+ title: undefined
3
+ colorFrom: green
4
+ colorTo: yellow
5
+ emoji: 🐳
6
  sdk: static
7
  pinned: false
8
+ tags:
9
+ - deepsite-v3
10
  ---
11
 
12
+ # Welcome to your new DeepSite project!
13
+ This project was created with [DeepSite](https://deepsite.hf.co).
14
+
index.html CHANGED
@@ -1,19 +1,536 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  </html>
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Math Whiskers: Гениальные математические котики</title>
7
+ <script src="https://cdn.tailwindcss.com"></script>
8
+ <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap" rel="stylesheet">
9
+ <style>
10
+ body {
11
+ font-family: 'Inter', sans-serif;
12
+ background-color: #f3f4f6;
13
+ overflow-x: hidden;
14
+ }
15
+ .container {
16
+ max-width: 600px;
17
+ }
18
+ .vibrant-button {
19
+ background-image: linear-gradient(to right, #4ade80, #16a34a);
20
+ transition: all 0.3s ease-in-out;
21
+ }
22
+ .vibrant-button:hover {
23
+ transform: scale(1.05);
24
+ box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
25
+ }
26
+ @keyframes bounce {
27
+ 0%, 100% {
28
+ transform: translateY(-25%);
29
+ animation-timing-function: cubic-bezier(0.8, 0, 1, 1);
30
+ }
31
+ 50% {
32
+ transform: translateY(0);
33
+ animation-timing-function: cubic-bezier(0, 0, 0.2, 1);
34
+ }
35
+ }
36
+ .animate-bounce-slow {
37
+ animation: bounce 2s infinite;
38
+ }
39
+ @keyframes pop-up {
40
+ 0% { transform: scale(1); }
41
+ 50% { transform: scale(1.1); }
42
+ 100% { transform: scale(1); }
43
+ }
44
+ .animate-pop {
45
+ animation: pop-up 0.5s ease-in-out;
46
+ }
47
+ @keyframes shake {
48
+ 10%, 90% { transform: translate3d(-1px, 0, 0); }
49
+ 20%, 80% { transform: translate3d(2px, 0, 0); }
50
+ 30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
51
+ 40%, 60% { transform: translate3d(4px, 0, 0); }
52
+ }
53
+ .animate-shake {
54
+ animation: shake 0.82s cubic-bezier(.36,.07,.19,.97) both;
55
+ }
56
+ @keyframes slide-in {
57
+ from { transform: translateX(100%); opacity: 0; }
58
+ to { transform: translateX(0); opacity: 1; }
59
+ }
60
+ .animate-slide-in {
61
+ animation: slide-in 0.5s ease-out forwards;
62
+ }
63
+ .correct-answer-button {
64
+ background-color: #10b981;
65
+ color: white;
66
+ animation: pop-up 0.5s ease-in-out;
67
+ }
68
+ .incorrect-answer-button {
69
+ background-color: #ef4444;
70
+ color: white;
71
+ animation: shake 0.5s ease-in-out;
72
+ }
73
+ .confetti {
74
+ position: absolute;
75
+ width: 10px;
76
+ height: 10px;
77
+ background-color: var(--color);
78
+ border-radius: 50%;
79
+ opacity: 0;
80
+ animation: confetti-fall 2.5s ease-out forwards;
81
+ }
82
+ @keyframes confetti-fall {
83
+ 0% {
84
+ transform: translateY(0) rotate(0deg);
85
+ opacity: 1;
86
+ }
87
+ 100% {
88
+ transform: translateY(100vh) rotate(720deg);
89
+ opacity: 0;
90
+ }
91
+ }
92
+ </style>
93
+ </head>
94
+ <body class="flex items-center justify-center min-h-screen p-4">
95
+ <div id="app" class="bg-white p-6 rounded-3xl shadow-2xl w-full container text-center transform transition-all duration-500 ease-in-out scale-100">
96
+ <div id="loading-screen" class="space-y-4">
97
+ <h1 class="text-2xl font-bold text-gray-800">Math Whiskers</h1>
98
+ <p class="text-gray-600 flex items-center justify-center">
99
+ Загружаем пушистый интеллект...
100
+ <span class="animate-bounce-slow ml-2 text-2xl">🐱</span>
101
+ </p>
102
+ </div>
103
+
104
+ <div id="settings-screen" class="hidden space-y-6">
105
+ <h1 class="text-3xl font-bold text-gray-800">Math Whiskers 😺</h1>
106
+ <p class="text-gray-600">Отточи свои математические навыки с пушистыми друзьями!</p>
107
+ <div class="space-y-4">
108
+ <h2 class="text-xl font-semibold text-gray-700">Выбери своего математического зверя</h2>
109
+ <div class="flex justify-center space-x-4">
110
+ <label class="cursor-pointer">
111
+ <input type="radio" name="avatar" value="🐱" class="hidden" checked>
112
+ <span class="text-5xl transition-transform transform hover:scale-125 duration-200">🐱</span>
113
+ </label>
114
+ <label class="cursor-pointer">
115
+ <input type="radio" name="avatar" value="🦁" class="hidden">
116
+ <span class="text-5xl transition-transform transform hover:scale-125 duration-200">🦁</span>
117
+ </label>
118
+ <label class="cursor-pointer">
119
+ <input type="radio" name="avatar" value="🐻" class="hidden">
120
+ <span class="text-5xl transition-transform transform hover:scale-125 duration-200">🐻</span>
121
+ </label>
122
+ <label class="cursor-pointer">
123
+ <input type="radio" name="avatar" value="🐰" class="hidden">
124
+ <span class="text-5xl transition-transform transform hover:scale-125 duration-200">🐰</span>
125
+ </label>
126
+ </div>
127
+ </div>
128
+
129
+ <div class="space-y-4">
130
+ <h2 class="text-xl font-semibold text-gray-700">Уровень сложности</h2>
131
+ <div class="flex justify-center space-x-4">
132
+ <label class="flex items-center space-x-2">
133
+ <input type="radio" name="difficulty" value="easy" class="form-radio text-blue-600 h-5 w-5" checked>
134
+ <span class="text-gray-700">Котёнок (до 10)</span>
135
+ </label>
136
+ <label class="flex items-center space-x-2">
137
+ <input type="radio" name="difficulty" value="medium" class="form-radio text-blue-600 h-5 w-5">
138
+ <span class="text-gray-700">Кот (до 20)</span>
139
+ </label>
140
+ <label class="flex items-center space-x-2">
141
+ <input type="radio" name="difficulty" value="hard" class="form-radio text-blue-600 h-5 w-5">
142
+ <span class="text-gray-700">Тигр (до 50)</span>
143
+ </label>
144
+ </div>
145
+ </div>
146
+
147
+ <div class="space-y-4">
148
+ <h2 class="text-xl font-semibold text-gray-700">Математические операции</h2>
149
+ <div class="flex justify-center space-x-4">
150
+ <label class="flex items-center space-x-2">
151
+ <input type="radio" name="operation" value="+" class="form-radio text-blue-600 h-5 w-5" checked>
152
+ <span class="text-gray-700">Сложение</span>
153
+ </label>
154
+ <label class="flex items-center space-x-2">
155
+ <input type="radio" name="operation" value="-" class="form-radio text-blue-600 h-5 w-5">
156
+ <span class="text-gray-700">Вычитание</span>
157
+ </label>
158
+ <label class="flex items-center space-x-2">
159
+ <input type="radio" name="operation" value="both" class="form-radio text-blue-600 h-5 w-5">
160
+ <span class="text-gray-700">Обе операции</span>
161
+ </label>
162
+ </div>
163
+ </div>
164
+
165
+ <div class="space-y-4">
166
+ <h2 class="text-xl font-semibold text-gray-700">Количество вопросов</h2>
167
+ <div class="flex justify-center space-x-4">
168
+ <label class="flex items-center space-x-2">
169
+ <input type="radio" name="numQuestions" value="10" class="form-radio text-blue-600 h-5 w-5" checked>
170
+ <span class="text-gray-700">10</span>
171
+ </label>
172
+ <label class="flex items-center space-x-2">
173
+ <input type="radio" name="numQuestions" value="15" class="form-radio text-blue-600 h-5 w-5">
174
+ <span class="text-gray-700">15</span>
175
+ </label>
176
+ <label class="flex items-center space-x-2">
177
+ <input type="radio" name="numQuestions" value="20" class="form-radio text-blue-600 h-5 w-5">
178
+ <span class="text-gray-700">20</span>
179
+ </label>
180
+ </div>
181
+ </div>
182
+ <button id="start-btn" class="w-full bg-blue-600 hover:bg-blue-700 text-white font-bold py-3 px-6 rounded-full shadow-lg transition-all duration-300 transform hover:scale-105 focus:outline-none focus:ring-4 focus:ring-blue-300">
183
+ Начать тренировку
184
+ </button>
185
+ </div>
186
+
187
+ <div id="quiz-screen" class="hidden space-y-6">
188
+ <div class="flex flex-col items-center mb-4">
189
+ <div id="quiz-avatar-display" class="text-7xl mb-4"></div>
190
+ </div>
191
+
192
+ <h2 id="question-text" class="text-5xl font-bold text-gray-800 mb-6"></h2>
193
+
194
+ <div id="answer-buttons" class="grid grid-cols-2 gap-4"></div>
195
+
196
+ <p id="message-text" class="min-h-[2rem] text-xl font-semibold"></p>
197
+ <button id="show-hint-btn" class="mt-4 bg-yellow-400 hover:bg-yellow-500 text-white font-bold py-2 px-4 rounded-full shadow-md transition-all duration-300 transform hover:scale-105">
198
+ Подсказка 🐾
199
+ </button>
200
+ <div id="emoji-hint-display" class="text-6xl flex items-center justify-center hidden"></div>
201
+
202
+ <div class="space-y-2 mt-4">
203
+ <p class="text-sm text-gray-600">Correct: <span id="correct-count">0</span> | Incorrect: <span id="incorrect-count">0</span></p>
204
+ <div id="score-cells-container" class="flex justify-center flex-wrap gap-1"></div>
205
+ </div>
206
+ </div>
207
+
208
+ <div id="results-screen" class="hidden space-y-6">
209
+ <h2 class="text-3xl font-bold text-gray-800">Тренировка завершена!</h2>
210
+ <p id="final-feedback" class="text-2xl font-semibold text-gray-700"></p>
211
+ <p id="final-score" class="text-xl text-gray-600 mt-2"></p>
212
+
213
+ <p class="text-sm text-gray-500 mb-2 flex items-center justify-center">
214
+ Ваш профиль: <span id="user-avatar-display" class="ml-2 text-2xl"></span>
215
+ </p>
216
+
217
+ <button id="restart-btn" class="w-full bg-blue-600 hover:bg-blue-700 text-white font-bold py-3 px-6 rounded-full shadow-lg transition-all duration-300 transform hover:scale-105 focus:outline-none focus:ring-4 focus:ring-blue-300">
218
+ Попробовать снова
219
+ </button>
220
+ </div>
221
+ </div>
222
+
223
+ <div id="confetti-container" class="absolute inset-0 z-50 pointer-events-none"></div>
224
+
225
+ <script>
226
+ // Elements
227
+ const loadingScreen = document.getElementById('loading-screen');
228
+ const settingsScreen = document.getElementById('settings-screen');
229
+ const quizScreen = document.getElementById('quiz-screen');
230
+ const resultsScreen = document.getElementById('results-screen');
231
+ const startBtn = document.getElementById('start-btn');
232
+ const restartBtn = document.getElementById('restart-btn');
233
+ const questionText = document.getElementById('question-text');
234
+ const answerButtons = document.getElementById('answer-buttons');
235
+ const messageText = document.getElementById('message-text');
236
+ const correctCount = document.getElementById('correct-count');
237
+ const incorrectCount = document.getElementById('incorrect-count');
238
+ const scoreCellsContainer = document.getElementById('score-cells-container');
239
+ const finalFeedbackText = document.getElementById('final-feedback');
240
+ const finalScoreText = document.getElementById('final-score');
241
+ const userAvatarDisplay = document.getElementById('user-avatar-display');
242
+ const quizAvatarDisplay = document.getElementById('quiz-avatar-display');
243
+ const emojiHintDisplay = document.getElementById('emoji-hint-display');
244
+ const showHintBtn = document.getElementById('show-hint-btn');
245
+ const confettiContainer = document.getElementById('confetti-container');
246
+
247
+ // Audio Context
248
+ const audioContext = new (window.AudioContext || window.webkitAudioContext)();
249
+ function playSound(frequency, duration) {
250
+ const oscillator = audioContext.createOscillator();
251
+ const gainNode = audioContext.createGain();
252
+
253
+ oscillator.type = 'sine';
254
+ oscillator.frequency.setValueAtTime(frequency, audioContext.currentTime);
255
+
256
+ gainNode.gain.setValueAtTime(0, audioContext.currentTime);
257
+ gainNode.gain.linearRampToValueAtTime(1, audioContext.currentTime + 0.01);
258
+ gainNode.gain.linearRampToValueAtTime(0, audioContext.currentTime + duration);
259
+
260
+ oscillator.connect(gainNode);
261
+ gainNode.connect(audioContext.destination);
262
+
263
+ oscillator.start(audioContext.currentTime);
264
+ oscillator.stop(audioContext.currentTime + duration);
265
+ }
266
+
267
+ // State
268
+ let currentQuestionIndex = 0;
269
+ let score = { correct: 0, incorrect: 0 };
270
+ let questions = [];
271
+ let numQuestions = 10;
272
+ let difficulty = 'easy';
273
+ let operation = '+';
274
+ let avatar = '🐱';
275
+ let questionResults = [];
276
+
277
+ // Helper functions
278
+ function shuffleArray(array) {
279
+ for (let i = array.length - 1; i > 0; i--) {
280
+ const j = Math.floor(Math.random() * (i + 1));
281
+ [array[i], array[j]] = [array[j], array[i]];
282
+ }
283
+ }
284
+
285
+ function generateAppleEmojis(count) {
286
+ return '🍎'.repeat(count);
287
+ }
288
+
289
+ function generateQuestion(index) {
290
+ let startMax, endMax;
291
+ if (difficulty === 'easy') {
292
+ startMax = 5;
293
+ endMax = 10;
294
+ } else if (difficulty === 'medium') {
295
+ startMax = 10;
296
+ endMax = 20;
297
+ } else {
298
+ startMax = 20;
299
+ endMax = 50;
300
+ }
301
+
302
+ const progressionFactor = index / (numQuestions - 1);
303
+ const currentMaxNumber = Math.floor(startMax + (endMax - startMax) * progressionFactor);
304
+
305
+ let a = Math.floor(Math.random() * currentMaxNumber) + 1;
306
+ let b = Math.floor(Math.random() * currentMaxNumber) + 1;
307
+
308
+ let selectedOperation = operation;
309
+ if (selectedOperation === 'both') {
310
+ selectedOperation = Math.random() > 0.5 ? '+' : '-';
311
+ }
312
+
313
+ if (selectedOperation === '-') {
314
+ if (b > a) {
315
+ [a, b] = [b, a];
316
+ }
317
+ }
318
+
319
+ let correctAnswer;
320
+ if (selectedOperation === '+') {
321
+ correctAnswer = a + b;
322
+ } else {
323
+ correctAnswer = a - b;
324
+ }
325
+
326
+ let answers = [correctAnswer];
327
+ while (answers.length < 4) {
328
+ let incorrectAnswer = correctAnswer + Math.floor(Math.random() * 5) * (Math.random() > 0.5 ? 1 : -1);
329
+ if (!answers.includes(incorrectAnswer) && incorrectAnswer >= 0) {
330
+ answers.push(incorrectAnswer);
331
+ }
332
+ }
333
+ shuffleArray(answers);
334
+
335
+ return {
336
+ text: `${a} ${selectedOperation} ${b} = ?`,
337
+ correctAnswer: correctAnswer,
338
+ answers: answers,
339
+ a: a,
340
+ b: b,
341
+ operation: selectedOperation
342
+ };
343
+ }
344
+
345
+ function startTest() {
346
+ // Get settings
347
+ difficulty = document.querySelector('input[name="difficulty"]:checked').value;
348
+ numQuestions = parseInt(document.querySelector('input[name="numQuestions"]:checked').value);
349
+ avatar = document.querySelector('input[name="avatar"]:checked').value;
350
+ operation = document.querySelector('input[name="operation"]:checked').value;
351
+
352
+ currentQuestionIndex = 0;
353
+ score = { correct: 0, incorrect: 0 };
354
+ questionResults = [];
355
+ questions = [];
356
+ for (let i = 0; i < numQuestions; i++) {
357
+ questions.push(generateQuestion(i));
358
+ }
359
+
360
+ settingsScreen.classList.add('hidden');
361
+ quizScreen.classList.remove('hidden');
362
+ quizScreen.classList.add('animate-slide-in');
363
+ userAvatarDisplay.textContent = avatar;
364
+ quizAvatarDisplay.textContent = avatar;
365
+ showQuestion();
366
+ updateScoreCells();
367
+ }
368
+
369
+ function showQuestion() {
370
+ if (currentQuestionIndex >= numQuestions) {
371
+ showResults();
372
+ return;
373
+ }
374
+
375
+ messageText.textContent = '';
376
+ answerButtons.innerHTML = '';
377
+ emojiHintDisplay.classList.add('hidden');
378
+
379
+ const currentQuestion = questions[currentQuestionIndex];
380
+ questionText.textContent = currentQuestion.text;
381
+ questionText.classList.remove('animate-pop', 'animate-shake');
382
+
383
+ if (currentQuestion.a <= 10 && currentQuestion.b <= 10) {
384
+ const aEmojis = generateAppleEmojis(currentQuestion.a);
385
+ const bEmojis = generateAppleEmojis(currentQuestion.b);
386
+ const opEmoji = currentQuestion.operation === '+' ? '➕' : '➖';
387
+ emojiHintDisplay.innerHTML = `${aEmojis} ${opEmoji} ${bEmojis} = `;
388
+ } else {
389
+ emojiHintDisplay.innerHTML = '';
390
+ }
391
+
392
+ currentQuestion.answers.forEach(answer => {
393
+ const button = document.createElement('button');
394
+ button.textContent = answer;
395
+ button.classList.add('bg-gray-200', 'hover:bg-gray-300', 'text-gray-800', 'font-bold', 'py-4', 'px-4', 'rounded-xl', 'transition-all', 'duration-200', 'transform', 'hover:scale-105', 'text-2xl', 'focus:outline-none');
396
+ button.onclick = () => checkAnswer(button, answer, currentQuestion.correctAnswer);
397
+ answerButtons.appendChild(button);
398
+ });
399
+ }
400
+
401
+ function checkAnswer(selectedButton, selectedAnswer, correctAnswer) {
402
+ Array.from(answerButtons.children).forEach(btn => btn.disabled = true);
403
+
404
+ const isCorrect = selectedAnswer === correctAnswer;
405
+ questionResults.push(isCorrect);
406
+ if (isCorrect) {
407
+ messageText.textContent = `Правильно! Мур-р-р! 🎉`;
408
+ messageText.classList.add('text-green-600');
409
+ messageText.classList.remove('text-red-600');
410
+ score.correct++;
411
+ playSound(440, 0.2);
412
+ questionText.classList.add('animate-pop');
413
+ selectedButton.classList.remove('hover:bg-gray-300');
414
+ selectedButton.classList.add('correct-answer-button');
415
+ } else {
416
+ messageText.textContent = `Ошибка... 😿 Правильный ответ: ${correctAnswer}.`;
417
+ messageText.classList.add('text-red-600');
418
+ messageText.classList.remove('text-green-600');
419
+ score.incorrect++;
420
+ playSound(220, 0.2);
421
+ questionText.classList.add('animate-shake');
422
+ selectedButton.classList.remove('hover:bg-gray-300');
423
+ selectedButton.classList.add('incorrect-answer-button');
424
+
425
+ Array.from(answerButtons.children).forEach(btn => {
426
+ if (parseInt(btn.textContent) === correctAnswer) {
427
+ btn.classList.add('border-4', 'border-green-500');
428
+ }
429
+ });
430
+ }
431
+
432
+ updateScoreCells();
433
+
434
+ setTimeout(() => {
435
+ currentQuestionIndex++;
436
+ showQuestion();
437
+ }, 2000);
438
+ }
439
+
440
+ function updateScoreCells() {
441
+ scoreCellsContainer.innerHTML = '';
442
+
443
+ questionResults.forEach(isCorrect => {
444
+ const cell = document.createElement('div');
445
+ cell.classList.add('w-6', 'h-6', 'rounded-full', 'shadow-md');
446
+ if (isCorrect) {
447
+ cell.classList.add('bg-green-500');
448
+ } else {
449
+ cell.classList.add('bg-red-500');
450
+ }
451
+ scoreCellsContainer.appendChild(cell);
452
+ });
453
+
454
+ const remainingQuestions = numQuestions - questionResults.length;
455
+ for (let i = 0; i < remainingQuestions; i++) {
456
+ const cell = document.createElement('div');
457
+ cell.classList.add('w-6', 'h-6', 'rounded-full', 'bg-gray-300');
458
+ scoreCellsContainer.appendChild(cell);
459
+ }
460
+
461
+ correctCount.textContent = score.correct;
462
+ incorrectCount.textContent = score.incorrect;
463
+ }
464
+
465
+ function startConfettiAnimation() {
466
+ const colors = ['#f44336', '#e91e63', '#9c27b0', '#673ab7', '#3f51b5', '#2196f3', '#03a9f4', '#00bcd4', '#009688', '#4caf50', '#8bc34a', '#cddc39', '#ffeb3b', '#ffc107', '#ff9800', '#ff5722'];
467
+ const numberOfConfetti = 50;
468
+ for (let i = 0; i < numberOfConfetti; i++) {
469
+ const confetti = document.createElement('div');
470
+ confetti.classList.add('confetti');
471
+ confetti.style.left = `${Math.random() * 100}vw`;
472
+ confetti.style.animationDelay = `${Math.random() * 2.5}s`;
473
+ confetti.style.setProperty('--color', colors[Math.floor(Math.random() * colors.length)]);
474
+ confettiContainer.appendChild(confetti);
475
+ }
476
+ setTimeout(() => {
477
+ confettiContainer.innerHTML = '';
478
+ }, 3000);
479
+ }
480
+
481
+ function showResults() {
482
+ quizScreen.classList.add('hidden');
483
+ resultsScreen.classList.remove('hidden');
484
+ finalScoreText.textContent = `Your score: ${score.correct} out of ${numQuestions}`;
485
+
486
+ const percentage = (score.correct / numQuestions) * 100;
487
+ let feedbackText = '';
488
+ if (percentage >= 80) {
489
+ feedbackText = 'Идеально! Ты математический гений! 🎉';
490
+ startConfettiAnimation();
491
+ } else if (percentage >= 70) {
492
+ feedbackText = 'Отличный результат! Продолжай тренироваться! ✨';
493
+ } else {
494
+ feedbackText = 'Не переживай - с каждой тренировкой будет лучше! 💪';
495
+ }
496
+ finalFeedbackText.textContent = feedbackText;
497
+ }
498
+
499
+ function resetGame() {
500
+ resultsScreen.classList.add('hidden');
501
+ settingsScreen.classList.remove('hidden');
502
+ currentQuestionIndex = 0;
503
+ score = { correct: 0, incorrect: 0 };
504
+ questions = [];
505
+ questionResults = [];
506
+ messageText.textContent = '';
507
+ updateScoreCells();
508
+ }
509
+
510
+ // Event listeners
511
+ startBtn.addEventListener('click', startTest);
512
+ restartBtn.addEventListener('click', resetGame);
513
+ showHintBtn.addEventListener('click', () => {
514
+ emojiHintDisplay.classList.remove('hidden');
515
+ });
516
+
517
+ document.querySelectorAll('input[name="avatar"]').forEach(radio => {
518
+ radio.addEventListener('change', () => {
519
+ document.querySelectorAll('input[name="avatar"] + span').forEach(label => {
520
+ label.classList.remove('ring-4', 'ring-blue-500', 'ring-offset-2');
521
+ });
522
+ if (radio.checked) {
523
+ radio.nextElementSibling.classList.add('ring-4', 'ring-blue-500', 'ring-offset-2');
524
+ }
525
+ });
526
+ });
527
+
528
+ // Initialize
529
+ window.onload = function() {
530
+ loadingScreen.classList.add('hidden');
531
+ settingsScreen.classList.remove('hidden');
532
+ document.querySelector('input[name="avatar"]:checked').nextElementSibling.classList.add('ring-4', 'ring-blue-500', 'ring-offset-2');
533
+ };
534
+ </script>
535
+ </body>
536
  </html>