Add surrender and rematch UI - Part 1

- Add surrender button to game controls
- Add game-over modal with stats and rematch option
- Add surrender confirmation modal
- Add all CSS styling for new modals and buttons
- Add surrender-rematch.js with global helper functions
- Update multiplayer.js constructor to track opponent for rematch
This commit is contained in:
2025-12-22 17:39:43 +11:00
parent 6c4aedec1d
commit 622a7e4094
5 changed files with 554 additions and 70 deletions

View File

@@ -453,3 +453,200 @@
padding: 2rem 1.5rem;
}
}
/* Surrender Button */
.surrender-btn {
padding: 0.75rem 1.5rem;
background: linear-gradient(135deg, #dc2626 0%, #991b1b 100%);
border: none;
border-radius: 10px;
color: white;
font-weight: 600;
font-size: 0.95rem;
cursor: pointer;
transition: all 0.3s ease;
font-family: "Inter", sans-serif;
display: flex;
align-items: center;
gap: 0.5rem;
box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3);
}
.surrender-btn:hover {
transform: translateY(-2px);
box-shadow: 0 6px 20px rgba(220, 38, 38, 0.5);
}
/* Game Over Modal */
.game-over-modal {
max-width: 450px;
text-align: center;
}
.game-over-icon {
font-size: 4rem;
margin-bottom: 1rem;
animation: bounce 1s ease-in-out;
}
@keyframes bounce {
0%, 100% { transform: translateY(0); }
50% { transform: translateY(-20px); }
}
.game-over-modal h2 {
font-size: 2rem;
margin-bottom: 0.5rem;
background: var(--accent-gradient);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
.game-over-subtitle {
color: var(--text-secondary);
font-size: 1.1rem;
margin-bottom: 1.5rem;
}
.game-over-stats {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 1rem;
padding: 1.5rem;
background: var(--bg-tertiary);
border-radius: 12px;
margin-bottom: 1.5rem;
border: 1px solid var(--border-light);
}
.game-over-stats .stat-item {
display: flex;
flex-direction: column;
gap: 0.5rem;
align-items: center;
}
.game-over-stats .stat-label {
color: var(--text-secondary);
font-size: 0.85rem;
font-weight: 600;
text-transform: uppercase;
}
.game-over-stats .stat-value {
color: var(--accent-primary);
font-size: 1.5rem;
font-weight: 700;
}
.game-over-actions {
display: flex;
flex-direction: column;
gap: 0.75rem;
}
.rematch-btn,
.lobby-btn {
padding: 1rem 2rem;
border: none;
border-radius: 12px;
font-weight: 600;
font-size: 1rem;
cursor: pointer;
transition: all 0.3s ease;
font-family: "Inter", sans-serif;
display: flex;
align-items: center;
justify-content: center;
gap: 0.5rem;
}
.rematch-btn {
background: var(--accent-gradient);
color: var(--text-primary);
box-shadow: 0 4px 16px rgba(147, 51, 234, 0.3);
}
.rematch-btn:hover {
transform: translateY(-2px);
box-shadow: 0 6px 24px rgba(147, 51, 234, 0.5);
}
.lobby-btn {
background: var(--bg-tertiary);
color: var(--text-primary);
border: 2px solid var(--border-light);
}
.lobby-btn:hover {
border-color: var(--accent-primary);
transform: translateY(-2px);
box-shadow: 0 4px 12px rgba(147, 51, 234, 0.2);
}
/* Surrender Confirmation Modal */
.surrender-modal {
max-width: 400px;
text-align: center;
}
.surrender-icon {
font-size: 4rem;
margin-bottom: 1rem;
animation: shake 0.5s ease-in-out;
}
@keyframes shake {
0%, 100% { transform: translateX(0); }
25% { transform: translateX(-10px); }
75% { transform: translateX(10px); }
}
.surrender-modal h2 {
font-size: 1.75rem;
margin-bottom: 0.75rem;
color: var(--danger);
}
.surrender-actions {
display: flex;
gap: 0.75rem;
margin-top: 1.5rem;
}
.confirm-surrender-btn,
.cancel-surrender-btn {
flex: 1;
padding: 0.875rem 1.5rem;
border: none;
border-radius: 10px;
font-weight: 600;
font-size: 1rem;
cursor: pointer;
transition: all 0.3s ease;
font-family: "Inter", sans-serif;
}
.confirm-surrender-btn {
background: linear-gradient(135deg, #dc2626 0%, #991b1b 100%);
color: white;
box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3);
}
.confirm-surrender-btn:hover {
transform: translateY(-2px);
box-shadow: 0 6px 20px rgba(220, 38, 38, 0.5);
}
.cancel-surrender-btn {
background: var(--bg-tertiary);
color: var(--text-primary);
border: 2px solid var(--border-light);
}
.cancel-surrender-btn:hover {
border-color: var(--accent-primary);
transform: translateY(-2px);
box-shadow: 0 4px 12px rgba(147, 51, 234, 0.2);
}