File tree Expand file tree Collapse file tree 2 files changed +16
-16
lines changed
Expand file tree Collapse file tree 2 files changed +16
-16
lines changed Original file line number Diff line number Diff line change @@ -130,20 +130,16 @@ document.addEventListener('keydown', (e) => {
130130// Add touch event listeners for mobile support
131131let touchStartX = 0 ;
132132let touchStartY = 0 ;
133- let touchEndX = 0 ;
134- let touchEndY = 0 ;
135133
136134function handleTouchStart ( e ) {
137135 touchStartX = e . touches [ 0 ] . clientX ;
138136 touchStartY = e . touches [ 0 ] . clientY ;
139137}
140138
141- function handleTouchMove ( e ) {
142- touchEndX = e . touches [ 0 ] . clientX ;
143- touchEndY = e . touches [ 0 ] . clientY ;
144- }
139+ function handleTouchEnd ( e ) {
140+ const touchEndX = e . changedTouches [ 0 ] . clientX ;
141+ const touchEndY = e . changedTouches [ 0 ] . clientY ;
145142
146- function handleTouchEnd ( ) {
147143 const dx = touchEndX - touchStartX ;
148144 const dy = touchEndY - touchStartY ;
149145 const absDx = Math . abs ( dx ) ;
@@ -167,7 +163,6 @@ function handleTouchEnd() {
167163}
168164
169165document . addEventListener ( 'touchstart' , handleTouchStart , false ) ;
170- document . addEventListener ( 'touchmove' , handleTouchMove , false ) ;
171166document . addEventListener ( 'touchend' , handleTouchEnd , false ) ;
172167
173168function initGame ( ) {
Original file line number Diff line number Diff line change 1313 padding : 30px ;
1414 border-radius : 15px ;
1515 text-align : center;
16-
16+ width : 100% ;
17+ max-width : 500px ;
1718}
1819
1920.game-container {
@@ -26,24 +27,28 @@ body {
2627
2728# grid-container {
2829 display : grid;
29- grid-template-columns : repeat (4 , 100 px );
30- grid-template-rows : repeat (4 , 100 px );
30+ grid-template-columns : repeat (4 , 1 fr );
31+ grid-template-rows : repeat (4 , 1 fr );
3132 gap : 10px ;
33+ width : 100% ;
34+ max-width : 400px ;
3235}
3336
37+ /* Ensure grid cells maintain a square aspect ratio */
3438.grid-cell {
35- width : 100 px ;
36- height : 100 px ;
39+ width : 100 % ;
40+ padding-bottom : 100 % ; /* Creates a square aspect ratio */
3741 background-color : # cdc1b4 ;
3842 border-radius : 6px ;
3943 display : flex;
4044 justify-content : center;
4145 align-items : center;
42- font-size : 30 px ;
46+ font-size : 1.5 rem ; /* Adjust font size for better visibility */
4347 font-weight : bold;
4448 color : # 776e65 ;
4549}
4650
51+ /* Color specific rules for different cell values */
4752.grid-cell [data-value = "2" ] { background-color : # eee4da ; color : # 776e65 ; }
4853.grid-cell [data-value = "4" ] { background-color : # ede0c8 ; color : # 776e65 ; }
4954.grid-cell [data-value = "8" ] { background-color : # f2b179 ; color : # f9f6f2 ; }
5863
5964.score-container {
6065 margin-top : 20px ;
61- font-size : 24 px ;
66+ font-size : 1.5 rem ; /* Adjusted for better readability on mobile */
6267 font-weight : bold;
63- }
68+ }
You can’t perform that action at this time.
0 commit comments