-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstyle.css
More file actions
244 lines (217 loc) · 5.54 KB
/
style.css
File metadata and controls
244 lines (217 loc) · 5.54 KB
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
:root {
--grid-size: 4;
--grid-gap: 15px;
}
/* General Body Styles */
body {
font-family: 'Arial', sans-serif;
background-color: #faf8ef;
color: #776e65;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
margin: 0;
padding: 10px;
box-sizing: border-box;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
/* Main Game Container */
.container {
width: 100%;
max-width: 500px;
margin: 0 auto;
text-align: center;
padding: 10px;
box-sizing: border-box;
}
/* Heading Section */
.heading {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 20px;
}
h1 {
font-size: 3em;
margin: 0;
color: #776e65;
}
/* Score and Best Score Boxes */
.scores-container {
display: flex;
gap: 10px;
}
.score, .best {
background-color: #bbada0;
color: #eee4da;
padding: 10px 15px;
border-radius: 5px;
font-size: 1em;
text-align: center;
min-width: 100px;
}
.score div, .best div {
font-size: 1.5em;
font-weight: bold;
color: #ffffff;
}
/* Game Controls */
.game-controls {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 20px;
flex-wrap: wrap;
gap: 10px;
}
.difficulty-container {
display: flex;
align-items: center;
gap: 10px;
}
#difficulty {
padding: 8px;
border-radius: 5px;
border: 1px solid #bbada0;
background-color: #fff;
min-width: 120px;
}
#restart-button {
background-color: #8f7a66;
color: #f9f6f2;
border: none;
padding: 10px 20px;
border-radius: 5px;
font-weight: bold;
cursor: pointer;
transition: background-color 0.3s;
}
#restart-button:hover {
background-color: #9f8b77;
}
/* Game Board */
.game-container {
position: relative;
background-color: #bbada0;
border-radius: 6px;
padding: var(--grid-gap);
box-sizing: border-box;
width: 100%;
aspect-ratio: 1 / 1;
margin: 0 auto;
}
.grid-container {
display: grid;
grid-template-columns: repeat(var(--grid-size), 1fr);
grid-template-rows: repeat(var(--grid-size), 1fr);
gap: var(--grid-gap);
width: 100%;
height: 100%;
}
.grid-cell {
background-color: #cdc1b4;
border-radius: 3px;
grid-row: var(--y) / span 1;
grid-column: var(--x) / span 1;
}
.tile {
display: flex;
justify-content: center;
align-items: center;
font-weight: bold;
border-radius: 3px;
font-size: 2em;
grid-row: var(--y) / span 1;
grid-column: var(--x) / span 1;
transition: transform 0.1s ease-in-out;
z-index: 10;
}
/* Animation */
.tile.new {
animation: appear 0.2s ease-in;
}
.tile.merged {
animation: pop 0.2s ease-out;
}
@keyframes appear {
from {
transform: scale(0);
}
to {
transform: scale(1);
}
}
@keyframes pop {
0% {
transform: scale(1);
}
50% {
transform: scale(1.2);
}
100% {
transform: scale(1);
}
}
/* Tile Colors */
.tile[data-value="2"] { background-color: #eee4da; color: #776e65; }
.tile[data-value="4"] { background-color: #ede0c8; color: #776e65; }
.tile[data-value="8"] { background-color: #f2b179; color: #f9f6f2; }
.tile[data-value="16"] { background-color: #f59563; color: #f9f6f2; }
.tile[data-value="32"] { background-color: #f67c5f; color: #f9f6f2; }
.tile[data-value="64"] { background-color: #f65e3b; color: #f9f6f2; }
.tile[data-value="128"] { background-color: #edcf72; color: #f9f6f2; font-size: 1.8em; }
.tile[data-value="256"] { background-color: #edcc61; color: #f9f6f2; font-size: 1.8em; }
.tile[data-value="512"] { background-color: #edc850; color: #f9f6f2; font-size: 1.8em; }
.tile[data-value="1024"] { background-color: #edc53f; color: #f9f6f2; font-size: 1.5em; }
.tile[data-value="2048"] { background-color: #edc22e; color: #f9f6f2; font-size: 1.5em; }
.tile[data-value="4096"] { background-color: #3c3a32; color: #f9f6f2; font-size: 1.5em; }
.tile[data-value="8192"] { background-color: #3c3a32; color: #f9f6f2; font-size: 1.5em; }
/* Game Over/Win Screen */
.game-over, .game-won {
display: none;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(238, 228, 218, 0.73);
z-index: 100;
flex-direction: column;
justify-content: center;
align-items: center;
border-radius: 6px;
}
.game-over h2, .game-won h2 { font-size: 2.5em; color: #776e65; margin: 0; }
.game-over p, .game-won p { font-size: 1.5em; color: #776e65; margin: 10px 0; }
#try-again-button, #keep-playing {
background-color: #8f7a66;
color: #f9f6f2;
border: none;
padding: 10px 20px;
border-radius: 5px;
font-weight: bold;
cursor: pointer;
transition: background-color 0.3s;
}
#try-again-button:hover, #keep-playing:hover { background-color: #9f8b77; }
#keep-playing { margin-top: 20px; }
/* Responsive Design */
@media (max-width: 600px) {
:root { --grid-gap: 10px; }
h1 { font-size: 2.5em; }
.score, .best { padding: 8px 12px; min-width: 80px; }
.score div, .best div { font-size: 1.2em; }
.tile { font-size: 1.5em; }
}
@media (max-width: 480px) {
:root { --grid-gap: 8px; }
h1 { font-size: 2em; }
.heading { flex-direction: column; gap: 10px; }
.scores-container { width: 100%; justify-content: space-between; }
.score, .best { padding: 5px 10px; min-width: 70px; }
.tile { font-size: 1.2em; }
.game-controls { flex-direction: column; align-items: stretch; }
#difficulty, #restart-button { width: 100%; }
}