File size: 7,585 Bytes
eaf45d5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
/* web_app/static/css/style.css */
body {
    font-family: 'Tahoma', sans-serif; /* یک فونت فارسی خوانا */
    display: flex;
    justify-content: center;
    align-items: flex-start; /* تغییر به flex-start برای جلوگیری از کشیدگی عمودی اولیه */
    min-height: 100vh;
    margin: 0;
    background-color: #f0f0f0;
    direction: rtl;
    padding-top: 20px; /* کمی فاصله از بالا */
}

.container {
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 0 15px rgba(0,0,0,0.1);
    text-align: center;
    width: auto; /* اجازه می‌دهد محتوا عرض را تعیین کند */
    max-width: 500px; /* حداکثر عرض برای جلوگیری از کشیدگی زیاد در صفحات بزرگ */
}

h1 {
    color: #333;
    margin-bottom: 20px;
}

.game-controls {
    margin-bottom: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px; /* فاصله بین انتخابگر سطح و دکمه */
    flex-wrap: wrap; /* اجازه شکستن در صفحات کوچکتر */
}

.difficulty-selector {
    display: flex;
    align-items: center;
    gap: 5px;
}

#sudoku-board-container {
    margin-bottom: 20px;
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    grid-template-rows: repeat(9, 1fr);
    width: 360px; /* اندازه ثابت برای جدول */
    height: 360px; /* ارتفاع ثابت برای جدول */
    border: 3px solid #333; /* خط بیرونی ضخیم تر */
    margin-left: auto;
    margin-right: auto;
    box-sizing: border-box;
}

.sudoku-cell {
    box-sizing: border-box;
    border: 1px solid #ccc;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.4em;
    cursor: pointer;
    background-color: #fff;
    transition: background-color 0.2s;
}

.sudoku-cell input {
    width: 100%; /* ورودی تمام خانه را بگیرد */
    height: 100%;
    text-align: center;
    border: none;
    outline: none;
    font-size: inherit; /* ارث‌بری اندازه فونت از والد */
    padding: 0;
    margin: 0;
    background-color: transparent; /* ورودی شفاف */
    cursor: pointer;
    color: #007bff; /* رنگ آبی برای اعداد وارد شده توسط کاربر */
}

.sudoku-cell.pre-filled input {
    font-weight: bold;
    color: #000; /* رنگ مشکی و ضخیم برای اعداد ثابت */
    cursor: not-allowed;
}

.sudoku-cell.selected {
    background-color: #e0f0ff; /* رنگ پس‌زمینه برای خانه انتخاب شده */
    outline: 2px solid #007bff; /* یک حاشیه برای تاکید بیشتر */
    z-index: 1;
}

/* خطوط ضخیم‌تر برای جدا کردن بلوک‌های 3x3 */
/* ردیف ها */
#sudoku-board-container .sudoku-cell:nth-child(n+19):nth-child(-n+27), /* مرز پایین ردیف 3 */
#sudoku-board-container .sudoku-cell:nth-child(n+46):nth-child(-n+54)  /* مرز پایین ردیف 6 */
{
    border-bottom: 2px solid #333;
}

/* ستون ها */
#sudoku-board-container .sudoku-cell:nth-child(3n) {
    border-left: 2px solid #333; /* مرز چپ ستون 3 و 6 (چون rtl هستیم، چپ می شود) */
}
/* اصلاح برای اینکه خط بیرونی جدول را دوباره نکشد */
#sudoku-board-container .sudoku-cell:nth-child(9n) {
     border-left: 1px solid #ccc; /* برگرداندن به خط عادی برای آخرین ستون در هر ردیف */
}
/* خطوط برای اولین ستون در حالت rtl */
#sudoku-board-container .sudoku-cell:nth-child(9n-8) {
    border-right: none; /* حذف خط راست پیش فرض */
}


.ingame-controls {
    margin-top: 15px;
    margin-bottom: 15px;
}

#numbers-panel {
    display: flex;
    justify-content: center;
    gap: 5px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

#numbers-panel button {
    width: 40px; /* کمی بزرگتر */
    height: 40px;
    font-size: 1.3em;
    border-radius: 5px; /* کمی گردتر */
}

.action-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.action-buttons button, .game-controls button, #numbers-panel button {
    padding: 8px 12px;
    font-size: 1em;
    cursor: pointer;
    border: 1px solid #ccc;
    border-radius: 4px;
    background-color: #f9f9f9;
    transition: background-color 0.2s, box-shadow 0.2s;
    box-shadow: 0 2px 2px rgba(0,0,0,0.05);
}

.action-buttons button:hover, .game-controls button:hover, #numbers-panel button:hover {
    background-color: #e9e9e9;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
.action-buttons button:active, .game-controls button:active, #numbers-panel button:active {
    background-color: #ddd;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
}


.action-buttons button:disabled, #numbers-panel button:disabled {
    background-color: #e9ecef;
    cursor: not-allowed;
    color: #6c757d;
    box-shadow: none;
}
#new-game-btn { /* دکمه بازی جدید را کمی متمایز کنیم */
    background-color: #28a745;
    color: white;
    border-color: #28a745;
}
#new-game-btn:hover {
    background-color: #218838;
    border-color: #1e7e34;
}


#timer-section {
    font-size: 1.1em;
    margin-bottom: 15px;
    color: #555;
}

#message-area {
    margin-top: 15px;
    padding: 10px 15px;
    min-height: 24px;
    border-radius: 4px;
    font-weight: 500; /* کمی خواناتر */
    text-align: right; /* برای پیام‌های فارسی */
    visibility: hidden; /* در ابتدا مخفی */
    opacity: 0;
    transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
}
#message-area.visible {
    visibility: visible;
    opacity: 1;
}


.message-success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.message-error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.message-info {
    background-color: #e2e3e5;
    color: #383d41;
    border: 1px solid #d6d8db;
}

.sudoku-cell.error input {
    color: red !important;
    font-weight: bold;
    animation: shake 0.5s;
}

@keyframes shake {
  0%, 100% {transform: translateX(0);}
  25% {transform: translateX(-3px);}
  75% {transform: translateX(3px);}
}

.sudoku-cell.hint-cell {
    background-color: #d1eaff !important;
    animation: pulse 0.8s ease-in-out;
}

@keyframes pulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(0, 123, 255, 0.7); }
    50% { transform: scale(1.05); box-shadow: 0 0 5px 10px rgba(0, 123, 255, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(0, 123, 255, 0); }
}

/* Responsive adjustments */
@media (max-width: 540px) { /* نقطه شکست را کمی تغییر دادم */
    .container {
        width: 98%; /* کمی بیشتر فضا بدهیم */
        padding: 10px;
    }
    #sudoku-board-container {
        width: 100%;
        max-width: 360px;
        height: auto;
        aspect-ratio: 1 / 1;
    }
    .sudoku-cell {
        font-size: max(3.5vw, 1em); /* اندازه فونت واکنش‌گرا با حداقل سایز */
    }
    .game-controls, .ingame-controls, .action-buttons, #numbers-panel {
        gap: 8px; /* فاصله کمتر در موبایل */
    }
    .action-buttons button, .game-controls button, #numbers-panel button {
        padding: 6px 10px;
        font-size: 0.9em;
    }
     #numbers-panel button {
        width: 35px;
        height: 35px;
        font-size: 1.1em;
    }
}