Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -114,138 +114,58 @@ body, .gradio-container {
|
|
| 114 |
padding: 1rem 1.5rem;
|
| 115 |
box-sizing: border-box;
|
| 116 |
min-height: 100vh;
|
| 117 |
-
display: flex;
|
| 118 |
-
justify-content: center;
|
| 119 |
-
align-items: center;
|
| 120 |
-
flex-direction: column;
|
| 121 |
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
| 122 |
-
color: #
|
| 123 |
}
|
| 124 |
|
| 125 |
-
/*
|
| 126 |
-
|
| 127 |
-
font-size: clamp(
|
| 128 |
color: #db2777;
|
| 129 |
-
margin-bottom: 0.2rem;
|
| 130 |
-
text-align: center;
|
| 131 |
font-weight: 700;
|
| 132 |
-
user-select: none;
|
| 133 |
-
}
|
| 134 |
-
|
| 135 |
-
.subtext {
|
| 136 |
-
font-size: clamp(1rem, 3vw, 1.1rem);
|
| 137 |
-
color: #9d174d;
|
| 138 |
text-align: center;
|
| 139 |
-
margin-bottom:
|
| 140 |
-
user-select: none;
|
| 141 |
-
}
|
| 142 |
-
|
| 143 |
-
/* Board container: perfect square, responsive */
|
| 144 |
-
#board-container {
|
| 145 |
-
display: grid;
|
| 146 |
-
grid-template-columns: repeat(3, 1fr);
|
| 147 |
-
grid-template-rows: repeat(3, 1fr);
|
| 148 |
-
gap: 12px;
|
| 149 |
-
width: 90vw;
|
| 150 |
-
max-width: 480px;
|
| 151 |
-
height: 90vw;
|
| 152 |
-
max-height: 480px;
|
| 153 |
-
margin: 0 auto 1.5rem auto;
|
| 154 |
-
}
|
| 155 |
-
|
| 156 |
-
/* Buttons fill cells fully, keep perfect squares */
|
| 157 |
-
.game-btn {
|
| 158 |
-
width: 100%;
|
| 159 |
-
height: 100%;
|
| 160 |
-
font-size: clamp(2rem, 6vw, 3.5rem) !important;
|
| 161 |
-
border-radius: 12px !important;
|
| 162 |
-
background: #fff0f5 !important;
|
| 163 |
-
border: 2px solid #f9a8d4 !important;
|
| 164 |
-
transition: background 0.2s ease-in-out;
|
| 165 |
-
padding: 0;
|
| 166 |
-
display: flex;
|
| 167 |
-
justify-content: center;
|
| 168 |
-
align-items: center;
|
| 169 |
-
user-select: none;
|
| 170 |
-
}
|
| 171 |
-
.game-btn:hover {
|
| 172 |
-
background: #fbcfe8 !important;
|
| 173 |
-
border-color: #ec4899 !important;
|
| 174 |
-
}
|
| 175 |
-
|
| 176 |
-
/* Mode Buttons */
|
| 177 |
-
.neat-button {
|
| 178 |
-
padding: 12px 16px;
|
| 179 |
-
border-radius: 8px;
|
| 180 |
-
font-size: clamp(0.9rem, 3vw, 1.1rem);
|
| 181 |
-
margin: 6px 0;
|
| 182 |
-
background: #fce7f3;
|
| 183 |
-
border: 1px solid #f472b6;
|
| 184 |
-
color: #be185d;
|
| 185 |
-
font-weight: 600;
|
| 186 |
-
width: 100%;
|
| 187 |
-
box-sizing: border-box;
|
| 188 |
user-select: none;
|
| 189 |
}
|
| 190 |
-
.neat-button:hover {
|
| 191 |
-
background: #f9a8d4;
|
| 192 |
-
border-color: #ec4899;
|
| 193 |
-
cursor: pointer;
|
| 194 |
-
}
|
| 195 |
|
| 196 |
-
/*
|
| 197 |
-
#
|
| 198 |
-
font-size: clamp(
|
| 199 |
-
|
| 200 |
-
color: #db2777;
|
| 201 |
text-align: center;
|
| 202 |
-
margin:
|
| 203 |
user-select: none;
|
|
|
|
|
|
|
| 204 |
}
|
| 205 |
|
| 206 |
-
/* Player legend
|
| 207 |
-
|
| 208 |
-
font-size: clamp(
|
| 209 |
-
color: #
|
| 210 |
margin-top: 0.5rem;
|
| 211 |
user-select: none;
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
@media (max-width: 768px) {
|
| 215 |
-
#board-container {
|
| 216 |
-
width: 90vw;
|
| 217 |
-
height: 90vw;
|
| 218 |
-
max-width: 320px;
|
| 219 |
-
max-height: 320px;
|
| 220 |
-
gap: 8px;
|
| 221 |
-
}
|
| 222 |
-
.game-btn {
|
| 223 |
-
font-size: clamp(1.8rem, 7vw, 2.5rem) !important;
|
| 224 |
-
}
|
| 225 |
-
.neat-button {
|
| 226 |
-
font-size: clamp(0.85rem, 4vw, 1rem);
|
| 227 |
-
}
|
| 228 |
-
#status {
|
| 229 |
-
font-size: clamp(0.95rem, 4vw, 1.1rem);
|
| 230 |
-
}
|
| 231 |
}
|
| 232 |
"""
|
| 233 |
|
| 234 |
-
with gr.Blocks(
|
| 235 |
-
|
| 236 |
-
<h1>๐ TIC TAC TOE
|
| 237 |
-
|
| 238 |
-
""
|
| 239 |
|
|
|
|
| 240 |
with gr.Row():
|
| 241 |
with gr.Column(scale=1, min_width=220):
|
| 242 |
-
gr.Markdown("### ๐ฎ Choose Game Mode", elem_id="
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
|
| 247 |
gr.Markdown("""
|
| 248 |
-
<div
|
| 249 |
<ul>
|
| 250 |
<li><strong>Player 1:</strong> โ</li>
|
| 251 |
<li><strong>Player 2 / Computer:</strong> โญ</li>
|
|
@@ -253,28 +173,4 @@ with gr.Blocks(title="Tic Tac Toe", css=CSS) as demo:
|
|
| 253 |
</div>
|
| 254 |
""")
|
| 255 |
|
| 256 |
-
|
| 257 |
-
status_display = gr.Markdown("๐ฎ Select a game mode to begin", elem_id="status")
|
| 258 |
-
|
| 259 |
-
with gr.Column(elem_id="board-container"):
|
| 260 |
-
btn0 = gr.Button("", elem_classes=["game-btn"])
|
| 261 |
-
btn1 = gr.Button("", elem_classes=["game-btn"])
|
| 262 |
-
btn2 = gr.Button("", elem_classes=["game-btn"])
|
| 263 |
-
btn3 = gr.Button("", elem_classes=["game-btn"])
|
| 264 |
-
btn4 = gr.Button("", elem_classes=["game-btn"])
|
| 265 |
-
btn5 = gr.Button("", elem_classes=["game-btn"])
|
| 266 |
-
btn6 = gr.Button("", elem_classes=["game-btn"])
|
| 267 |
-
btn7 = gr.Button("", elem_classes=["game-btn"])
|
| 268 |
-
btn8 = gr.Button("", elem_classes=["game-btn"])
|
| 269 |
-
|
| 270 |
-
buttons = [btn0, btn1, btn2, btn3, btn4, btn5, btn6, btn7, btn8]
|
| 271 |
-
all_outputs = buttons + [status_display]
|
| 272 |
-
|
| 273 |
-
for i, btn in enumerate(buttons):
|
| 274 |
-
btn.click(fn=lambda i=i: handle_click(i), outputs=all_outputs)
|
| 275 |
-
|
| 276 |
-
vs_friend_btn.click(fn=start_vs_friend, outputs=all_outputs)
|
| 277 |
-
vs_computer_btn.click(fn=start_vs_computer, outputs=all_outputs)
|
| 278 |
-
reset_btn.click(fn=reset_current_game, outputs=all_outputs)
|
| 279 |
-
|
| 280 |
-
demo.launch()
|
|
|
|
| 114 |
padding: 1rem 1.5rem;
|
| 115 |
box-sizing: border-box;
|
| 116 |
min-height: 100vh;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 117 |
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
| 118 |
+
color: #4a002a;
|
| 119 |
}
|
| 120 |
|
| 121 |
+
/* Header text style */
|
| 122 |
+
#header-title {
|
| 123 |
+
font-size: clamp(2rem, 6vw, 2.8rem);
|
| 124 |
color: #db2777;
|
|
|
|
|
|
|
| 125 |
font-weight: 700;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 126 |
text-align: center;
|
| 127 |
+
margin-bottom: 0.3rem;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
user-select: none;
|
| 129 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 130 |
|
| 131 |
+
/* Subtext style */
|
| 132 |
+
#header-subtext {
|
| 133 |
+
font-size: clamp(1.2rem, 5vw, 1.3rem);
|
| 134 |
+
color: #7a104d;
|
|
|
|
| 135 |
text-align: center;
|
| 136 |
+
margin-bottom: 1.8rem;
|
| 137 |
user-select: none;
|
| 138 |
+
padding: 0 8px;
|
| 139 |
+
line-height: 1.4;
|
| 140 |
}
|
| 141 |
|
| 142 |
+
/* Player legend */
|
| 143 |
+
#player-legend {
|
| 144 |
+
font-size: clamp(1rem, 4vw, 1.1rem);
|
| 145 |
+
color: #631746;
|
| 146 |
margin-top: 0.5rem;
|
| 147 |
user-select: none;
|
| 148 |
+
padding: 0 6px;
|
| 149 |
+
line-height: 1.3;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 150 |
}
|
| 151 |
"""
|
| 152 |
|
| 153 |
+
with gr.Blocks(css=CSS) as demo:
|
| 154 |
+
# Header title
|
| 155 |
+
gr.Markdown("<h1 id='header-title'>๐ TIC TAC TOE</h1>")
|
| 156 |
+
# Subtext below header
|
| 157 |
+
gr.Markdown("<p id='header-subtext'>Play solo or with a friend โ may the best player win!</p>")
|
| 158 |
|
| 159 |
+
# Buttons placeholder (not functional here)
|
| 160 |
with gr.Row():
|
| 161 |
with gr.Column(scale=1, min_width=220):
|
| 162 |
+
gr.Markdown("### ๐ฎ Choose Game Mode", elem_id="header-subtext")
|
| 163 |
+
gr.Button("๐ฅ Play vs Friend", elem_classes=["neat-button"])
|
| 164 |
+
gr.Button("๐ค Play vs Computer", elem_classes=["neat-button"])
|
| 165 |
+
gr.Button("๐ Reset Game", elem_classes=["neat-button"])
|
| 166 |
|
| 167 |
gr.Markdown("""
|
| 168 |
+
<div id="player-legend">
|
| 169 |
<ul>
|
| 170 |
<li><strong>Player 1:</strong> โ</li>
|
| 171 |
<li><strong>Player 2 / Computer:</strong> โญ</li>
|
|
|
|
| 173 |
</div>
|
| 174 |
""")
|
| 175 |
|
| 176 |
+
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|