Files
InfoGenie/InfoGenie-frontend/public/smallgame/贪吃蛇/styles.css
2025-09-15 19:08:47 +08:00

258 lines
4.5 KiB
CSS

* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Arial', sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
touch-action: manipulation;
-webkit-tap-highlight-color: transparent;
}
.game-container {
background: rgba(255, 255, 255, 0.95);
border-radius: 20px;
padding: 20px;
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
max-width: 400px;
width: 95%;
margin: 20px auto;
}
.game-header {
text-align: center;
margin-bottom: 20px;
}
.game-header h1 {
color: #333;
font-size: 2.5rem;
margin-bottom: 15px;
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}
.score-board {
display: flex;
justify-content: space-around;
background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
padding: 12px;
border-radius: 15px;
color: white;
font-weight: bold;
font-size: 1.1rem;
}
.score-board span {
display: flex;
flex-direction: column;
align-items: center;
}
.game-canvas-container {
display: flex;
justify-content: center;
margin: 20px 0;
}
#gameCanvas {
border: 3px solid #333;
border-radius: 10px;
background: #222;
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}
.game-controls {
margin: 20px 0;
}
.control-row {
display: flex;
justify-content: center;
margin: 8px 0;
}
.control-btn {
width: 70px;
height: 70px;
margin: 0 10px;
border: none;
border-radius: 50%;
background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
color: white;
font-size: 1.5rem;
font-weight: bold;
cursor: pointer;
transition: all 0.3s ease;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}
.control-btn:hover {
transform: scale(1.1);
box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}
.control-btn:active {
transform: scale(0.95);
}
#pauseBtn {
background: linear-gradient(135deg, #ff9a9e 0%, #fad0c4 100%);
color: #333;
font-size: 1.2rem;
}
.game-instructions {
text-align: center;
color: #666;
font-size: 0.9rem;
margin-top: 15px;
}
.modal {
display: none;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.8);
z-index: 1000;
justify-content: center;
align-items: center;
}
.modal-content {
background: white;
padding: 30px;
border-radius: 20px;
text-align: center;
max-width: 400px;
width: 90%;
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}
.modal-content h2 {
color: #e74c3c;
margin-bottom: 20px;
font-size: 2rem;
}
.stats p {
margin: 10px 0;
font-size: 1.1rem;
color: #333;
}
.stats span {
font-weight: bold;
color: #e74c3c;
}
.restart-btn {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
border: none;
padding: 15px 30px;
border-radius: 25px;
font-size: 1.2rem;
font-weight: bold;
cursor: pointer;
margin-top: 20px;
transition: all 0.3s ease;
}
.restart-btn:hover {
transform: scale(1.05);
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
}
/* 手机端优化 */
@media (max-width: 768px) {
.game-container {
padding: 15px;
margin: 10px;
border-radius: 15px;
}
.game-header h1 {
font-size: 2rem;
}
.score-board {
font-size: 0.9rem;
padding: 8px;
}
.control-btn {
width: 60px;
height: 60px;
font-size: 1.3rem;
margin: 0 8px;
}
#pauseBtn {
font-size: 1rem;
}
#gameCanvas {
width: 280px;
height: 400px;
}
}
/* 超小屏幕优化 */
@media (max-width: 480px) {
.game-header h1 {
font-size: 1.8rem;
}
.score-board {
flex-direction: column;
gap: 5px;
}
.control-btn {
width: 50px;
height: 50px;
font-size: 1.1rem;
margin: 0 5px;
}
#gameCanvas {
width: 250px;
height: 350px;
}
.modal-content {
padding: 20px;
}
.modal-content h2 {
font-size: 1.5rem;
}
}
/* 防止文本选择 */
.control-btn, .restart-btn {
user-select: none;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
}
/* 动画效果 */
@keyframes pulse {
0% { transform: scale(1); }
50% { transform: scale(1.05); }
100% { transform: scale(1); }
}
.score-board {
animation: pulse 2s infinite;
}