* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  color: #333;
}

#app {
  width: 100%;
  min-height: 100vh;
}

.screen {
  width: 100%;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hidden {
  display: none !important;
}

.login-container {
  background: white;
  padding: 40px;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  text-align: center;
}

.login-container h1 {
  font-size: 2rem;
  margin-bottom: 30px;
  color: #667eea;
}

.input-group {
  margin-bottom: 20px;
}

.input-group input {
  width: 100%;
  padding: 12px 16px;
  font-size: 1rem;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  outline: none;
  transition: border-color 0.3s;
}

.input-group input:focus {
  border-color: #667eea;
}

.btn {
  padding: 12px 32px;
  font-size: 1rem;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s;
  font-weight: 600;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

.btn:active, .btn.active {
  opacity: 0.9;
  transform: scale(0.98);
}

.btn-primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
  background: #f0f0f0;
  color: #333;
}

.btn-secondary:hover {
  background: #e0e0e0;
}

.btn-small {
  padding: 6px 16px;
  font-size: 0.875rem;
}

.game-container {
  display: flex;
  gap: 20px;
  padding: 20px;
  max-width: 1400px;
  width: 100%;
}

.left-panel,
.right-panel {
  background: white;
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.left-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.right-panel {
  width: 320px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.room-info h2 {
  color: #667eea;
  margin-bottom: 8px;
}

.role-badge {
  display: inline-block;
  background: #667eea;
  color: white;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 0.875rem;
}

.players-panel h3 {
  margin-bottom: 12px;
  color: #333;
}

.player-slot {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 8px;
  background: #f5f5f5;
  margin-bottom: 8px;
  transition: all 0.3s;
}

.player-slot.active {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.player-label {
  font-weight: 600;
  width: 70px;
}

.player-name {
  flex: 1;
}

.player-score {
  font-size: 1.25rem;
  font-weight: bold;
}

.turn-indicator {
  text-align: center;
  padding: 12px;
  background: #f0f0f0;
  border-radius: 8px;
  font-weight: 600;
  color: #667eea;
}

.game-board-container {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  background: #f5f5f5;
  border-radius: 8px;
  position: relative;
}

.game-board {
  display: inline-grid;
  gap: 2px;
  background: #999;
  padding: 2px;
  border-radius: 4px;
}

.cell {
  width: 30px;
  height: 30px;
  background: #c0c0c0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  cursor: pointer;
  font-size: 14px;
  user-select: none;
  border: 2px outset #fff;
}

.cell:hover:not(.revealed) {
  background: #d0d0d0;
}

.cell.revealed {
  background: #e0e0e0;
  border: 1px solid #999;
  cursor: default;
}

.cell.mine {
  background: #ff6b6b;
  color: white;
}

.cell.flagged {
  color: #ff6b6b;
}

.cell.num-1 { color: #0000ff; }
.cell.num-2 { color: #008000; }
.cell.num-3 { color: #ff0000; }
.cell.num-4 { color: #000080; }
.cell.num-5 { color: #800000; }
.cell.num-6 { color: #008080; }
.cell.num-7 { color: #000000; }
.cell.num-8 { color: #808080; }

.countdown-display {
  font-size: 24px;
  font-weight: bold;
  color: #ff5722;
  text-align: center;
  margin: 10px 0;
  height: 30px;
}

.countdown-display.hidden {
  display: none;
}

.snake-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 20px 0;
}

.snake-controls.hidden {
  display: none;
}

.snake-control-row {
  display: flex;
  justify-content: center;
  margin-bottom: 10px;
}

.snake-control-btn {
  width: 80px;
  height: 80px;
  font-size: 28px;
  background: #4caf50;
  color: white;
  border: none;
  border-radius: 10px;
  margin: 0 10px;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
}

.snake-control-btn:hover {
  background: #45a049;
}

.snake-control-btn:active {
  background: #3d8b40;
  transform: scale(0.95);
}

@media (max-width: 768px) {
  .snake-control-btn {
    width: 70px;
    height: 70px;
    font-size: 24px;
    margin: 0 8px;
  }
  
  .snake-controls {
    margin: 15px 0;
  }
  
  .btn-small {
    padding: 10px 20px;
    font-size: 1rem;
    min-height: 44px;
    min-width: 44px;
  }
}

@media (max-width: 480px) {
  .snake-control-btn {
    width: 60px;
    height: 60px;
    font-size: 20px;
    margin: 0 6px;
  }
  
  .btn-small {
    padding: 8px 16px;
    font-size: 0.875rem;
  }
}

.game-controls {
  display: flex;
  justify-content: center;
}

.spectators-panel h3,
.join-requests-panel h3,
.chat-panel h3 {
  margin-bottom: 12px;
  color: #333;
}

.spectators-list {
  max-height: 100px;
  overflow-y: auto;
  margin-bottom: 12px;
}

.spectators-list.hidden {
  display: none;
}

.spectator {
  padding: 6px 10px;
  background: #f0f0f0;
  border-radius: 4px;
  margin-bottom: 4px;
  font-size: 0.875rem;
}

.spectator-actions {
  margin-top: 8px;
}

.join-request {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px;
  background: #f0f0f0;
  border-radius: 4px;
  margin-bottom: 8px;
}

.chat-messages {
  flex: 1;
  min-height: 200px;
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
  background: #fafafa;
}

.chat-message {
  margin-bottom: 8px;
  font-size: 0.875rem;
}

.chat-message strong {
  color: #667eea;
}

.chat-input-container {
  display: flex;
  gap: 8px;
}

.chat-input-container input {
  flex: 1;
  padding: 8px 12px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  outline: none;
  transition: border-color 0.3s;
}

.chat-input-container input:focus {
  border-color: #667eea;
}

.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: white;
  padding: 40px;
  border-radius: 16px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-content h2 {
  font-size: 2rem;
  margin-bottom: 16px;
  color: #667eea;
}

.modal-content p {
  margin-bottom: 24px;
  font-size: 1.125rem;
  color: #666;
}

/* 大厅样式 */
.lobby-container {
  background: white;
  padding: 40px;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  text-align: center;
  max-width: 800px;
  width: 100%;
}

.lobby-container h1 {
  font-size: 2rem;
  margin-bottom: 20px;
  color: #667eea;
}

.user-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  padding: 20px;
  background: #f5f5f5;
  border-radius: 12px;
}

.user-info p {
  font-size: 1.125rem;
  font-weight: 600;
  color: #333;
}

.user-info span {
  color: #667eea;
}

.rooms-panel {
  text-align: left;
}

.rooms-panel h2 {
  font-size: 1.5rem;
  margin-bottom: 20px;
  color: #333;
}

.rooms-list {
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid #e0e0e0;
  border-radius: 12px;
  padding: 20px;
  background: #fafafa;
  margin-bottom: 20px;
}

.loading-text {
  text-align: center;
  color: #666;
  font-style: italic;
}

.room-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px;
  background: white;
  border-radius: 8px;
  margin-bottom: 12px;
  border: 1px solid #e0e0e0;
  transition: all 0.3s;
}

.room-item:hover {
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
}

.room-info {
  flex: 1;
}

.room-id {
  font-weight: bold;
  color: #667eea;
  font-size: 1.125rem;
}

.room-stats {
  display: flex;
  gap: 20px;
  margin-top: 8px;
  font-size: 0.875rem;
  color: #666;
}

.room-actions {
  display: flex;
  gap: 10px;
}

.room-status {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

.room-status.waiting {
  background: #e8f5e9;
  color: #2e7d32;
}

.room-status.playing {
  background: #fff3e0;
  color: #f57c00;
}

.room-status.full {
  background: #ffebee;
  color: #c62828;
}

.refresh-actions {
  text-align: center;
}

/* 在线信息面板样式 */
.online-info-panel {
  margin-bottom: 20px;
}

.online-buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.online-list {
  max-height: 400px;
  overflow-y: auto;
  margin: 20px 0;
  padding: 15px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  background: #fafafa;
  text-align: left;
}

.online-player-item,
.online-room-item {
  padding: 12px;
  background: white;
  border-radius: 8px;
  margin-bottom: 10px;
  border: 1px solid #e0e0e0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.online-player-info,
.online-room-info {
  flex: 1;
}

.online-player-name {
  font-weight: bold;
  color: #333;
}

.online-player-room {
  color: #666;
  font-size: 0.875rem;
  margin-top: 4px;
}

.online-player-role {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 600;
  margin-left: 8px;
}

.online-player-role.player1 {
  background: #e3f2fd;
  color: #1565c0;
}

.online-player-role.player2 {
  background: #f3e5f5;
  color: #7b1fa2;
}

.online-player-role.spectator {
  background: #f1f8e9;
  color: #689f38;
}

.online-player-actions,
.online-room-actions {
  margin-left: 10px;
  display: flex;
  align-items: center;
}

.current-room-text {
  color: #666;
  font-size: 0.875rem;
  font-style: italic;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 20px;
}

/* 响应式设计 */
@media (max-width: 1024px) {
  .game-container {
    flex-direction: column;
  }
  
  .right-panel {
    width: 100%;
  }
  
  .game-board-container {
    padding: 10px;
  }
  
  .cell {
    width: 25px;
    height: 25px;
    font-size: 12px;
  }
}

@media (max-width: 768px) {
  .login-container {
    padding: 20px;
  }
  
  .login-container h1 {
    font-size: 1.5rem;
  }
  
  .game-container {
    padding: 10px;
    gap: 10px;
  }
  
  .left-panel,
  .right-panel {
    padding: 15px;
  }
  
  .player-slot {
    padding: 8px;
    gap: 8px;
  }
  
  .player-label {
    width: 60px;
  }
  
  .cell {
    width: 20px;
    height: 20px;
    font-size: 10px;
  }
  
  .modal-content {
    padding: 20px;
  }
  
  .modal-content h2 {
    font-size: 1.5rem;
  }
}

@media (max-width: 480px) {
  .cell {
    width: 18px;
    height: 18px;
    font-size: 9px;
  }
  
  .player-label {
    width: 50px;
  }
  
  .btn {
    padding: 10px 20px;
    font-size: 0.875rem;
  }
}

/* 游戏选择屏幕样式 */
.game-select-container {
  background: white;
  padding: 40px;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  text-align: center;
  max-width: 1000px;
  width: 100%;
}

.game-select-container h1 {
  font-size: 2rem;
  margin-bottom: 16px;
  color: #667eea;
}

.user-welcome {
  font-size: 1.125rem;
  margin-bottom: 30px;
  color: #666;
}

.user-welcome span {
  color: #667eea;
  font-weight: 600;
}

.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.game-card {
  background: #fafafa;
  border-radius: 16px;
  padding: 24px;
  text-align: center;
  border: 2px solid #e0e0e0;
  transition: all 0.3s;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.game-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
  border-color: #667eea;
}

.game-card.coming-soon {
  opacity: 0.7;
  background: #f5f5f5;
}

.game-icon {
  font-size: 3rem;
  margin-bottom: 16px;
}

.game-card h3 {
  font-size: 1.5rem;
  margin-bottom: 12px;
  color: #333;
}

.game-card p {
  font-size: 0.875rem;
  color: #666;
  margin-bottom: 16px;
  flex: 1;
}

.game-stats {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 16px;
  font-size: 0.75rem;
  color: #666;
}

.game-stats span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.game-select-actions {
  margin-top: 20px;
}

.game-card .btn {
  margin-top: auto;
}

/* 游戏类型显示 */
#gameTypeDisplay {
  display: inline-block;
  background: #e3f2fd;
  color: #1565c0;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 0.875rem;
  font-weight: 600;
  margin-left: 8px;
}

#currentGameTitle {
  color: #667eea;
}

#currentGameType {
  color: #667eea;
  font-weight: 600;
}

/* 蛇游戏特定样式 */
.snake-game-board {
  display: inline-grid;
  gap: 1px;
  background: #333;
  padding: 1px;
  border-radius: 4px;
}

.snake-cell {
  width: 20px;
  height: 20px;
  background: #222;
  display: flex;
  align-items: center;
  justify-content: center;
}

.snake-segment {
  background: #4caf50;
  border-radius: 2px;
}

.snake-head {
  background: #2e7d32;
  border-radius: 3px;
}

.food {
  background: #ff9800;
  border-radius: 50%;
}

.snake-countdown-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  z-index: 10;
  pointer-events: none;
}

.snake-countdown-text {
  font-size: 80px;
  font-weight: bold;
  color: #ff5722;
  text-shadow: 0 0 20px rgba(255, 87, 34, 0.8);
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

.minesweeper-countdown-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  z-index: 10;
  pointer-events: none;
}

.minesweeper-countdown-text {
  font-size: 80px;
  font-weight: bold;
  color: #ff5722;
  text-shadow: 0 0 20px rgba(255, 87, 34, 0.8);
  animation: pulse 1s infinite;
}

/* 排行榜排名样式 */
.rank-gold {
  background: linear-gradient(135deg, #ffd700 0%, #ffed4e 100%);
}

.rank-silver {
  background: linear-gradient(135deg, #c0c0c0 0%, #e0e0e0 100%);
}

.rank-bronze {
  background: linear-gradient(135deg, #cd7f32 0%, #e6a65c 100%);
}

.rank {
  display: inline-block;
  width: 24px;
  height: 24px;
  background: #667eea;
  color: white;
  border-radius: 50%;
  text-align: center;
  line-height: 24px;
  margin-right: 8px;
  font-weight: bold;
}