* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

#app {
  width: 100%;
  max-width: 500px;
  background: white;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  overflow: hidden;
}

.screen {
  display: none;
  padding: 30px;
  text-align: center;
  animation: fadeIn 0.3s ease;
}

.screen.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

h1 {
  font-size: 2.5rem;
  margin-bottom: 10px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

h2 { margin-bottom: 20px; color: #333; }

input[type="text"] {
  width: 100%;
  padding: 12px 16px;
  margin: 15px 0;
  border: 2px solid #e0e0e0;
  border-radius: 10px;
  font-size: 1rem;
  transition: border-color 0.2s;
}

input[type="text"]:focus {
  outline: none;
  border-color: #667eea;
}

button {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  border: none;
  padding: 12px 30px;
  border-radius: 25px;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.2s;
  margin: 5px;
}

button:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(102, 126, 234, 0.4);
}

button:active { transform: translateY(0); }

.btn-secondary {
  background: #e0e0e0;
  color: #333;
}

/* Лобби */
.lobby-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 1px solid #eee;
}

.my-profile {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}

.status.online { color: #4caf50; font-size: 1.2rem; }

.players-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
  max-height: 400px;
  overflow-y: auto;
}

.player-card {
  background: #f8f9ff;
  padding: 15px 10px;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.player-card:hover {
  background: #eef1ff;
}

.player-avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea, #764ba2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: bold;
  font-size: 1.2rem;
}

.player-nickname {
  font-size: 0.9rem;
  font-weight: 500;
  color: #333;
}

/* Игра */
.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 25px;
  padding: 10px 15px;
  background: #f8f9ff;
  border-radius: 12px;
}

.score {
  font-size: 1.5rem;
  font-weight: bold;
  color: #667eea;
}

.round {
  color: #666;
  font-weight: 500;
}

.timer {
  background: #ff6b6b;
  color: white;
  padding: 5px 15px;
  border-radius: 20px;
  font-weight: bold;
  min-width: 50px;
}

.timer.warning {
  background: #ffa502;
  animation: pulse 0.5s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.letters {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 20px 0;
}

.letter {
  width: 45px;
  height: 45px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  font-weight: bold;
  text-transform: uppercase;
  user-select: none;
}

.input-area {
  display: flex;
  gap: 10px;
  margin: 20px 0;
}

.input-area input {
  flex: 1;
  margin: 0;
}

.feedback {
  min-height: 24px;
  margin-top: 10px;
  font-size: 0.9rem;
}

.feedback.error { color: #ff6b6b; }
.feedback.success { color: #4caf50; }

/* Результаты */
.final-score {
  font-size: 3rem;
  font-weight: bold;
  color: #667eea;
  margin: 20px 0;
}

.words-history {
  text-align: left;
  max-height: 200px;
  overflow-y: auto;
  margin: 20px 0;
  padding: 10px;
  background: #f8f9ff;
  border-radius: 10px;
}

.word-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid #eee;
  font-size: 0.95rem;
}

.word-row:last-child { border-bottom: none; }
.word-round { color: #666; width: 30px; }
.word-me { color: #667eea; font-weight: 500; }
.word-opponent { color: #764ba2; font-weight: 500; }

/* Модальное окно */
.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: 25px 30px;
  border-radius: 20px;
  text-align: center;
  max-width: 350px;
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal-buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin: 20px 0;
}

.timer-small {
  color: #ff6b6b;
  font-weight: bold;
  font-size: 1.2rem;
}

/* Адаптивность */
@media (max-width: 480px) {
  .screen { padding: 20px; }
  .letters { gap: 5px; }
  .letter { width: 40px; height: 40px; font-size: 1.1rem; }
  .game-header { flex-direction: column; gap: 10px; }
}