-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
240 lines (231 loc) · 7.95 KB
/
index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Sudoku</title>
<script src="https://cdn.tailwindcss.com"></script>
<link
href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600&display=swap"
rel="stylesheet"
/>
<style>
.game-font {
font-family: "Poppins", sans-serif;
}
.cell {
transition: all 0.2s ease;
}
.cell:hover {
background-color: #f0f9ff;
}
.cell.fixed {
background-color: #f8fafc;
}
.cell.selected {
background-color: #e0f2fe !important;
}
.cell.highlighted {
background-color: #f0f9ff;
}
.cell.error {
color: #ef4444;
}
.same-number {
background-color: #f1f5f9;
}
</style>
</head>
<body class="bg-gradient-to-br from-blue-50 to-indigo-100 min-h-screen">
<div class="container mx-auto px-4 py-8">
<h1
class="text-center game-font text-5xl mb-8 text-transparent bg-clip-text bg-gradient-to-r from-blue-600 to-indigo-600"
>
Sudoku
</h1>
<div class="flex flex-col md:flex-row justify-center items-start gap-8">
<!-- Game Board -->
<div class="bg-white p-4 rounded-2xl shadow-xl">
<div id="board" class="grid grid-cols-9 gap-0.5 bg-gray-300">
<!-- Cells will be generated by JavaScript -->
</div>
</div>
<!-- Control Panel -->
<div class="bg-white p-6 rounded-2xl shadow-xl space-y-6 min-w-[300px]">
<!-- Timer -->
<div
class="bg-gradient-to-r from-blue-50 to-indigo-50 p-6 rounded-xl"
>
<p class="text-gray-600 text-sm mb-1">TIME</p>
<p id="timer" class="game-font text-4xl text-blue-600">00:00</p>
</div>
<!-- Difficulty & Mistakes -->
<div class="flex gap-4">
<div
class="flex-1 bg-gradient-to-r from-blue-50 to-indigo-50 p-4 rounded-xl"
>
<p class="text-gray-600 text-sm mb-1">LEVEL</p>
<p id="difficulty" class="game-font text-2xl text-indigo-600">
Easy
</p>
</div>
<div
class="flex-1 bg-gradient-to-r from-blue-50 to-indigo-50 p-4 rounded-xl"
>
<p class="text-gray-600 text-sm mb-1">MISTAKES</p>
<p id="mistakes" class="game-font text-2xl text-indigo-600">
0/3
</p>
</div>
</div>
<!-- Number Pad -->
<div class="grid grid-cols-3 gap-2">
<button
class="number-btn bg-blue-50 hover:bg-blue-100 text-blue-600 font-bold py-4 rounded-xl transition-colors"
>
1
</button>
<button
class="number-btn bg-blue-50 hover:bg-blue-100 text-blue-600 font-bold py-4 rounded-xl transition-colors"
>
2
</button>
<button
class="number-btn bg-blue-50 hover:bg-blue-100 text-blue-600 font-bold py-4 rounded-xl transition-colors"
>
3
</button>
<button
class="number-btn bg-blue-50 hover:bg-blue-100 text-blue-600 font-bold py-4 rounded-xl transition-colors"
>
4
</button>
<button
class="number-btn bg-blue-50 hover:bg-blue-100 text-blue-600 font-bold py-4 rounded-xl transition-colors"
>
5
</button>
<button
class="number-btn bg-blue-50 hover:bg-blue-100 text-blue-600 font-bold py-4 rounded-xl transition-colors"
>
6
</button>
<button
class="number-btn bg-blue-50 hover:bg-blue-100 text-blue-600 font-bold py-4 rounded-xl transition-colors"
>
7
</button>
<button
class="number-btn bg-blue-50 hover:bg-blue-100 text-blue-600 font-bold py-4 rounded-xl transition-colors"
>
8
</button>
<button
class="number-btn bg-blue-50 hover:bg-blue-100 text-blue-600 font-bold py-4 rounded-xl transition-colors"
>
9
</button>
</div>
<!-- Control Buttons -->
<div class="flex gap-2">
<button
id="eraseBtn"
class="flex-1 bg-gray-100 hover:bg-gray-200 text-gray-600 font-bold py-3 px-4 rounded-xl transition-colors"
>
Erase
</button>
<button
id="hintBtn"
class="flex-1 bg-indigo-100 hover:bg-indigo-200 text-indigo-600 font-bold py-3 px-4 rounded-xl transition-colors"
>
Hint (3)
</button>
</div>
<!-- New Game Button -->
<div class="space-y-2">
<button
onclick="startNewGame('easy')"
class="w-full bg-blue-100 hover:bg-blue-200 text-blue-600 font-bold py-3 rounded-xl transition-colors"
>
New Easy Game
</button>
<button
onclick="startNewGame('medium')"
class="w-full bg-indigo-100 hover:bg-indigo-200 text-indigo-600 font-bold py-3 rounded-xl transition-colors"
>
New Medium Game
</button>
<button
onclick="startNewGame('hard')"
class="w-full bg-violet-100 hover:bg-violet-200 text-violet-600 font-bold py-3 rounded-xl transition-colors"
>
New Hard Game
</button>
</div>
</div>
</div>
</div>
<!-- Win Modal -->
<div
id="winModal"
class="hidden fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center"
>
<div class="bg-white p-8 rounded-2xl shadow-2xl max-w-sm w-full mx-4">
<h2 class="game-font text-3xl text-center mb-6 text-blue-600">
Congratulations!
</h2>
<div class="space-y-4 mb-6">
<div
class="bg-gradient-to-r from-blue-50 to-indigo-50 p-4 rounded-xl"
>
<p class="text-gray-600 text-sm mb-1">TIME</p>
<p id="finalTime" class="game-font text-2xl text-blue-600">00:00</p>
</div>
<div
class="bg-gradient-to-r from-blue-50 to-indigo-50 p-4 rounded-xl"
>
<p class="text-gray-600 text-sm mb-1">MISTAKES</p>
<p id="finalMistakes" class="game-font text-2xl text-indigo-600">
0
</p>
</div>
</div>
<div class="flex gap-2">
<button
onclick="startNewGame(currentDifficulty)"
class="flex-1 bg-blue-500 hover:bg-blue-600 text-white font-bold py-3 rounded-xl transition-colors"
>
New Game
</button>
<button
onclick="closeWinModal()"
class="flex-1 bg-gray-100 hover:bg-gray-200 text-gray-600 font-bold py-3 rounded-xl transition-colors"
>
Continue
</button>
</div>
</div>
</div>
<!-- Game Over Modal -->
<div
id="gameOverModal"
class="hidden fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center"
>
<div class="bg-white p-8 rounded-2xl shadow-2xl max-w-sm w-full mx-4">
<h2 class="game-font text-3xl text-center mb-6 text-red-600">
Game Over
</h2>
<p class="text-center text-gray-600 mb-6">
You've made too many mistakes!
</p>
<button
onclick="startNewGame(currentDifficulty)"
class="w-full bg-blue-500 hover:bg-blue-600 text-white font-bold py-3 rounded-xl transition-colors"
>
Try Again
</button>
</div>
</div>
<script src="sudoku.js"></script>
</body>
</html>