/* 重置默认边距 */ body, html { margin: 0; padding: 0; height: 100%; background-color: #f5f5f5; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; } /* 应用容器填满整个视口并居中 */ .app-container { width: 100%; height: 100vh; display: flex; flex-direction: column; justify-content: center; align-items: center; position: relative; } /* 重置body样式 */ body { margin: 0; padding: 0; overflow: hidden; } /* 网格容器 - 响应式布局 */ .grid-container { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 400px)); grid-template-rows: repeat(auto-fit, minmax(300px, 400px)); gap: 20px; padding: 20px; background-color: #e0e0e0; min-height: 100vh; width: 100vw; box-sizing: border-box; margin: 0 auto; place-content: center; transition: all 0.3s ease; } /* 响应式设计 */ @media (max-width: 1200px) { .grid-container { grid-template-columns: repeat(2, 1fr); grid-template-rows: repeat(2, 1fr); gap: 15px; padding: 15px; } } @media (max-width: 768px) { .grid-container { grid-template-columns: 1fr; grid-template-rows: repeat(4, 1fr); gap: 10px; padding: 10px; } } /* 正方形样式 */ .square { width: 100%; height: 100%; min-width: 300px; min-height: 300px; max-width: 400px; max-height: 400px; background-color: #ffffff; background-image: linear-gradient(to right, #ddd 1px, transparent 1px), linear-gradient(to bottom, #ddd 1px, transparent 1px); background-size: 20px 20px; border: 5px solid #555; border-radius: 15px; position: relative; box-shadow: 0 6px 12px rgba(0,0,0,0.15); transition: all 0.3s ease; overflow: hidden; } .square:hover { transform: translateY(-2px); box-shadow: 0 8px 16px rgba(0,0,0,0.2); } /* 连接状态圆点 */ .connection-dot { position: absolute; top: 15px; right: 15px; width: 20px; height: 20px; border-radius: 50%; background-color: #ff4444; /* 默认断开状态-红色 */ transition: all 0.3s ease; box-shadow: 0 2px 4px rgba(0,0,0,0.2); z-index: 10; } .connection-dot.connected { background-color: #44ff44; /* 连接状态-绿色 */ animation: pulse 2s infinite; } @keyframes pulse { 0% { transform: scale(1); } 50% { transform: scale(1.1); } 100% { transform: scale(1); } } /* 加载指示器 */ .loading-indicator { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 5; } .spinner { width: 40px; height: 40px; border: 4px solid #f3f3f3; border-top: 4px solid #3498db; border-radius: 50%; animation: spin 1s linear infinite; } @keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } } /* 游戏动态圆点 */ .game-dot { position: absolute; width: 12px; height: 12px; background: linear-gradient(45deg, #ff6b6b, #ff8e8e); border-radius: 50%; pointer-events: none; box-shadow: 0 2px 4px rgba(0,0,0,0.3); animation: dotAppear 0.3s ease-out; z-index: 5; /* 平滑移动效果 */ transition: left 0.08s linear, top 0.08s linear; will-change: left, top, transform; /* 启用GPU加速 */ transform: translate3d(-50%, -50%, 0); backface-visibility: hidden; } /* 标记为玩家控制的点 */ .game-dot.player-controlled { background: linear-gradient(45deg, #4a90e2, #63b3ed); box-shadow: 0 0 10px rgba(74, 144, 226, 0.6); width: 14px; height: 14px; /* 为玩家控制的点设置更快的响应速度 */ transition: left 0.06s linear, top 0.06s linear; } @keyframes dotAppear { 0% { transform: translate3d(-50%, -50%, 0) scale(0); opacity: 0; } 50% { transform: translate3d(-50%, -50%, 0) scale(1.2); opacity: 0.8; } 100% { transform: translate3d(-50%, -50%, 0) scale(1); opacity: 1; } } /* 状态栏 */ .status-bar { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: rgba(0, 0, 0, 0.8); color: white; padding: 10px 20px; border-radius: 25px; display: flex; gap: 20px; font-size: 14px; backdrop-filter: blur(10px); box-shadow: 0 4px 8px rgba(0,0,0,0.3); z-index: 100; transition: all 0.3s ease; } .status-item { display: flex; align-items: center; gap: 5px; } .status-item::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background-color: #44ff44; } /* 键盘快捷键提示 */ .keyboard-hints { position: fixed; top: 20px; right: 20px; background: rgba(0, 0, 0, 0.8); color: white; padding: 15px; border-radius: 10px; font-size: 12px; backdrop-filter: blur(10px); z-index: 100; opacity: 0.8; transition: opacity 0.3s ease; } .keyboard-hints:hover { opacity: 1; } .keyboard-hints h4 { margin: 0 0 10px 0; font-size: 14px; } .keyboard-hints ul { margin: 0; padding-left: 20px; } .keyboard-hints li { margin: 5px 0; } /* 错误状态样式 */ .square.error { border-color: #ff4444; animation: errorShake 0.5s ease-in-out; } @keyframes errorShake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } } /* 性能优化 */ .square { will-change: transform; } .game-dot { will-change: transform, opacity; } /* 无障碍支持 */ @media (prefers-reduced-motion: reduce) { .spinner, .game-dot, .connection-dot.connected { animation: none; } .square:hover { transform: none; } } /* 高对比度模式支持 */ @media (prefers-contrast: high) { .square { border-width: 3px; border-color: #000; } .game-dot { background: #000; box-shadow: 0 0 0 2px #fff; } }