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 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Guess the Location Game</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        }

        :root {
            --primary: #4361ee;
            --secondary: #3a0ca3;
            --accent: #f72585;
            --light: #f8f9fa;
            --dark: #212529;
            --success: #4cc9f0;
            --warning: #f8961e;
            --danger: #e63946;
        }

        body {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
            padding: 20px;
            color: var(--light);
        }

        .container {
            max-width: 800px;
            width: 100%;
            background: rgba(255, 255, 255, 0.1);
            backdrop-filter: blur(10px);
            border-radius: 20px;
            box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
            overflow: hidden;
            padding: 30px;
        }

        .header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding-bottom: 20px;
            border-bottom: 1px solid rgba(255, 255, 255, 0.2);
            margin-bottom: 30px;
        }

        .logo {
            display: flex;
            align-items: center;
            gap: 10px;
            font-size: 24px;
            font-weight: 700;
        }

        .logo i {
            color: var(--accent);
        }

        .anycoder-link {
            font-size: 14px;
            color: var(--light);
            text-decoration: none;
            background: rgba(255, 255, 255, 0.1);
            padding: 8px 15px;
            border-radius: 20px;
            transition: all 0.3s ease;
        }

        .anycoder-link:hover {
            background: rgba(255, 255, 255, 0.2);
            transform: translateY(-2px);
        }

        .game-container {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 30px;
        }

        @media (max-width: 768px) {
            .game-container {
                grid-template-columns: 1fr;
            }
        }

        .image-container {
            position: relative;
            border-radius: 15px;
            overflow: hidden;
            box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
            height: 300px;
            background: var(--dark);
            display: flex;
            justify-content: center;
            align-items: center;
        }

        .location-image {
            width: 100%;
            height: 100%;
            object-fit: cover;
            transition: all 0.5s ease;
        }

        .image-placeholder {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            color: rgba(255, 255, 255, 0.7);
            padding: 20px;
            text-align: center;
        }

        .image-placeholder i {
            font-size: 60px;
            margin-bottom: 15px;
            color: rgba(255, 255, 255, 0.5);
        }

        .game-info {
            display: flex;
            flex-direction: column;
            gap: 20px;
        }

        .score-container {
            background: rgba(255, 255, 255, 0.1);
            border-radius: 15px;
            padding: 20px;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .score-item {
            text-align: center;
        }

        .score-value {
            font-size: 28px;
            font-weight: 700;
            margin-bottom: 5px;
        }

        .score-label {
            font-size: 14px;
            opacity: 0.8;
        }

        .input-container {
            display: flex;
            flex-direction: column;
            gap: 15px;
        }

        .input-group {
            display: flex;
            gap: 10px;
        }

        input {
            flex: 1;
            padding: 15px 20px;
            border: none;
            border-radius: 12px;
            background: rgba(255, 255, 255, 0.1);
            color: var(--light);
            font-size: 16px;
            outline: none;
            transition: all 0.3s ease;
        }

        input::placeholder {
            color: rgba(255, 255, 255, 0.6);
        }

        input:focus {
            background: rgba(255, 255, 255, 0.15);
            box-shadow: 0 0 0 2px var(--accent);
        }

        button {
            padding: 15px 25px;
            border: none;
            border-radius: 12px;
            background: var(--primary);
            color: white;
            font-weight: 600;
            font-size: 16px;
            cursor: pointer;
            transition: all 0.3s ease;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
        }

        button:hover {
            background: var(--secondary);
            transform: translateY(-2px);
        }

        button:active {
            transform: translateY(0);
        }

        button:disabled {
            background: rgba(255, 255, 255, 0.2);
            cursor: not-allowed;
            transform: none;
        }

        .hint-container {
            background: rgba(255, 255, 255, 0.1);
            border-radius: 15px;
            padding: 20px;
        }

        .hint-title {
            display: flex;
            align-items: center;
            gap: 10px;
            margin-bottom: 15px;
            font-weight: 600;
        }

        .hint-text {
            line-height: 1.6;
            opacity: 0.9;
        }

        .result-container {
            background: rgba(255, 255, 255, 0.1);
            border-radius: 15px;
            padding: 20px;
            text-align: center;
            display: none;
        }

        .result-icon {
            font-size: 50px;
            margin-bottom: 15px;
        }

        .result-text {
            font-size: 18px;
            margin-bottom: 20px;
        }

        .controls {
            display: flex;
            gap: 15px;
            margin-top: 20px;
        }

        .controls button {
            flex: 1;
        }

        .btn-success {
            background: var(--success);
        }

        .btn-warning {
            background: var(--warning);
        }

        .btn-danger {
            background: var(--danger);
        }

        .fade-in {
            animation: fadeIn 0.5s ease;
        }

        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(10px); }
            to { opacity: 1; transform: translateY(0); }
        }

        .pulse {
            animation: pulse 1.5s infinite;
        }

        @keyframes pulse {
            0% { transform: scale(1); }
            50% { transform: scale(1.05); }
            100% { transform: scale(1); }
        }

        .level-indicator {
            display: flex;
            justify-content: center;
            gap: 10px;
            margin-top: 15px;
        }

        .level-dot {
            width: 12px;
            height: 12px;
            border-radius: 50%;
            background: rgba(255, 255, 255, 0.3);
        }

        .level-dot.active {
            background: var(--accent);
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="header">
            <div class="logo">
                <i class="fas fa-globe-americas"></i>
                <span>Guess the Location</span>
            </div>
            <a href="https://huggingface.co/spaces/akhaliq/anycoder" class="anycoder-link">Built with anycoder</a>
        </div>

        <div class="game-container">
            <div class="image-container">
                <div class="image-placeholder">
                    <i class="fas fa-map-marked-alt"></i>
                    <p>Get ready to guess the location!</p>
                </div>
                <img class="location-image" src="" alt="Location to guess" style="display: none;">
            </div>

            <div class="game-info">
                <div class="score-container">
                    <div class="score-item">
                        <div class="score-value" id="score">0</div>
                        <div class="score-label">Score</div>
                    </div>
                    <div class="score-item">
                        <div class="score-value" id="round">1/5</div>
                        <div class="score-label">Round</div>
                    </div>
                    <div class="score-item">
                        <div class="score-value" id="streak">0</div>
                        <div class="score-label">Streak</div>
                    </div>
                </div>

                <div class="input-container">
                    <input type="text" id="guess-input" placeholder="Enter your guess...">
                    <div class="input-group">
                        <button id="submit-btn">
                            <i class="fas fa-paper-plane"></i>
                            Submit Guess
                        </button>
                        <button id="hint-btn">
                            <i class="fas fa-lightbulb"></i>
                            Hint
                        </button>
                    </div>
                </div>

                <div class="hint-container">
                    <div class="hint-title">
                        <i class="fas fa-info-circle"></i>
                        <span>Location Hint</span>
                    </div>
                    <div class="hint-text" id="hint-text">
                        Click the hint button to get a clue about this location.
                    </div>
                </div>

                <div class="result-container" id="result-container">
                    <div class="result-icon" id="result-icon"></div>
                    <div class="result-text" id="result-text"></div>
                    <div class="controls">
                        <button class="btn-success" id="next-btn">
                            <i class="fas fa-forward"></i>
                            Next Location
                        </button>
                        <button class="btn-warning" id="restart-btn">
                            <i class="fas fa-redo"></i>
                            Restart Game
                        </button>
                    </div>
                </div>

                <div class="level-indicator">
                    <div class="level-dot active"></div>
                    <div class="level-dot"></div>
                    <div class="level-dot"></div>
                    <div class="level-dot"></div>
                    <div class="level-dot"></div>
                </div>
            </div>
        </div>
    </div>

    <script>
        // Game data - locations with images and hints
        const locations = [
            {
                name: "Eiffel Tower",
                image: "https://images.unsplash.com/photo-1543349689-9a4d426bee8e?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=1000&q=80",
                hint: "This iconic iron lattice tower is located in a European capital known as the City of Light.",
                country: "France",
                city: "Paris"
            },
            {
                name: "Statue of Liberty",
                image: "https://images.unsplash.com/photo-1547471080-7cc2caa01a7e?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=1000&q=80",
                hint: "This colossal neoclassical sculpture was a gift from France to the United States and stands on an island in New York Harbor.",
                country: "United States",
                city: "New York"
            },
            {
                name: "Great Wall of China",
                image: "https://images.unsplash.com/photo-1518638150340-f706e86654de?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=1000&q=80",
                hint: "This ancient series of fortifications stretches across the northern borders of an Asian country.",
                country: "China",
                city: "Beijing (near)"
            },
            {
                name: "Taj Mahal",
                image: "https://images.unsplash.com/photo-1564507592333-c60657eea523?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=1000&q=80",
                hint: "This ivory-white marble mausoleum was built by a Mughal emperor in memory of his favorite wife.",
                country: "India",
                city: "Agra"
            },
            {
                name: "Sydney Opera House",
                image: "https://images.unsplash.com/photo-1528072164453-f4e8ef0d475a?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=1000&q=80",
                hint: "This multi-venue performing arts centre is known for its distinctive shell-like roofs and is located in a major Australian city.",
                country: "Australia",
                city: "Sydney"
            }
        ];

        // Game state
        let currentLocationIndex = 0;
        let score = 0;
        let streak = 0;
        let gameActive = true;
        let hintsUsed = 0;

        // DOM elements
        const locationImage = document.querySelector('.location-image');
        const imagePlaceholder = document.querySelector('.image-placeholder');
        const guessInput = document.getElementById('guess-input');
        const submitBtn = document.getElementById('submit-btn');
        const hintBtn = document.getElementById('hint-btn');
        const hintText = document.getElementById('hint-text');
        const resultContainer = document.getElementById('result-container');
        const resultIcon = document.getElementById('result-icon');
        const resultText = document.getElementById('result-text');
        const nextBtn = document.getElementById('next-btn');
        const restartBtn = document.getElementById('restart-btn');
        const scoreElement = document.getElementById('score');
        const roundElement = document.getElementById('round');
        const streakElement = document.getElementById('streak');
        const levelDots = document.querySelectorAll('.level-dot');

        // Initialize the game
        function initGame() {
            loadLocation(currentLocationIndex);
            updateUI();
            gameActive = true;
        }

        // Load a location
        function loadLocation(index) {
            const location = locations[index];
            
            // Show loading state
            locationImage.style.display = 'none';
            imagePlaceholder.style.display = 'flex';
            
            // Load image
            locationImage.src = location.image;
            locationImage.onload = function() {
                imagePlaceholder.style.display = 'none';
                locationImage.style.display = 'block';
                locationImage.classList.add('fade-in');
            };
            
            // Reset hint
            hintText.textContent = "Click the hint button to get a clue about this location.";
            hintsUsed = 0;
            
            // Clear input
            guessInput.value = '';
            guessInput.focus();
            
            // Hide result container
            resultContainer.style.display = 'none';
            
            // Update level indicator
            levelDots.forEach((dot, i) => {
                if (i <= index) {
                    dot.classList.add('active');
                } else {
                    dot.classList.remove('active');
                }
            });
        }

        // Update UI elements
        function updateUI() {
            scoreElement.textContent = score;
            roundElement.textContent = `${currentLocationIndex + 1}/${locations.length}`;
            streakElement.textContent = streak;
        }

        // Submit a guess
        function submitGuess() {
            if (!gameActive) return;
            
            const guess = guessInput.value.trim().toLowerCase();
            const correctLocation = locations[currentLocationIndex];
            
            // Check if guess is correct
            const isCorrect = 
                guess.includes(correctLocation.name.toLowerCase()) ||
                guess.includes(correctLocation.country.toLowerCase()) ||
                guess.includes(correctLocation.city.toLowerCase());
            
            // Show result
            showResult(isCorrect, correctLocation);
            
            // Update score
            if (isCorrect) {
                score += 10 - (hintsUsed * 3);
                streak++;
            } else {
                streak = 0;
            }
            
            updateUI();
            gameActive = false;
        }

        // Show hint
        function showHint() {
            if (!gameActive || hintsUsed >= 2) return;
            
            const correctLocation = locations[currentLocationIndex];
            
            if (hintsUsed === 0) {
                hintText.textContent = correctLocation.hint;
            } else if (hintsUsed === 1) {
                hintText.textContent = `This location is in ${correctLocation.country}.`;
            }
            
            hintsUsed++;
        }

        // Show result
        function showResult(isCorrect, location) {
            resultContainer.style.display = 'block';
            resultContainer.classList.add('fade-in');
            
            if (isCorrect) {
                resultIcon.className = 'result-icon fas fa-check-circle';
                resultIcon.style.color = 'var(--success)';
                resultText.textContent = `Correct! This is the ${location.name} in ${location.city}, ${location.country}.`;
                resultContainer.style.background = 'rgba(76, 201, 240, 0.2)';
            } else {
                resultIcon.className = 'result-icon fas fa-times-circle';
                resultIcon.style.color = 'var(--danger)';
                resultText.textContent = `Sorry, that's incorrect. This is the ${location.name} in ${location.city}, ${location.country}.`;
                resultContainer.style.background = 'rgba(230, 57, 70, 0.2)';
            }
        }

        // Next location
        function nextLocation() {
            if (currentLocationIndex < locations.length - 1) {
                currentLocationIndex++;
                loadLocation(currentLocationIndex);
                gameActive = true;
            } else {
                // Game completed
                showGameCompleted();
            }
        }

        // Restart game
        function restartGame() {
            currentLocationIndex = 0;
            score = 0;
            streak = 0;
            initGame();
        }

        // Show game completed
        function showGameCompleted() {
            resultContainer.style.display = 'block';
            resultContainer.classList.add('fade-in');
            resultIcon.className = 'result-icon fas fa-trophy';
            resultIcon.style.color = 'var(--warning)';
            resultText.textContent = `Congratulations! You completed the game with a score of ${score}.`;
            resultContainer.style.background = 'rgba(248, 150, 30, 0.2)';
            
            nextBtn.disabled = true;
            nextBtn.innerHTML = '<i class="fas fa-flag-checkered"></i> Game Completed';
        }

        // Event listeners
        submitBtn.addEventListener('click', submitGuess);
        hintBtn.addEventListener('click', showHint);
        nextBtn.addEventListener('click', nextLocation);
        restartBtn.addEventListener('click', restartGame);

        // Allow submitting with Enter key
        guessInput.addEventListener('keypress', function(e) {
            if (e.key === 'Enter') {
                submitGuess();
            }
        });

        // Initialize the game
        initGame();
    </script>
</body>
</html>