* {
  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;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  color: #333;
}

#app {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
}

.screen {
  display: none;
  animation: fadeIn 0.3s ease-in;
}

.screen.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.container {
  background: white;
  border-radius: 20px;
  padding: 40px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.game-container {
  background: white;
  border-radius: 20px;
  padding: 30px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.title {
  font-size: 3rem;
  font-weight: 800;
  text-align: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 10px;
}

.subtitle {
  text-align: center;
  font-size: 1.2rem;
  color: #666;
  margin-bottom: 40px;
}

h2.title {
  font-size: 2rem;
}

h3 {
  color: #667eea;
  margin-bottom: 15px;
  font-size: 1.2rem;
}

.name-input-section,
.input-section {
  margin-bottom: 30px;
}

input[type="text"] {
  width: 100%;
  padding: 15px 20px;
  font-size: 1.1rem;
  border: 2px solid #e0e0e0;
  border-radius: 10px;
  transition: all 0.3s ease;
  outline: none;
}

input[type="text"]:focus {
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.button-group {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.btn {
  padding: 15px 30px;
  font-size: 1.1rem;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.btn-secondary {
  background: #e0e0e0;
  color: #333;
}

.btn-success {
  background: #4caf50;
  color: white;
}

.btn-danger {
  background: #f44336;
  color: white;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Lobby Screen */
.lobby-header {
  text-align: center;
  margin-bottom: 30px;
}

.room-code-display {
  font-size: 1.3rem;
  font-weight: 600;
  color: #667eea;
  margin-top: 10px;
  padding: 10px;
  background: #f5f5f5;
  border-radius: 10px;
}

.players-section {
  margin-bottom: 30px;
}

.players-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.player-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px;
  background: #f9f9f9;
  border-radius: 10px;
  border: 2px solid transparent;
  transition: all 0.3s ease;
}

.player-item.ready {
  border-color: #4caf50;
  background: #f1f8f4;
}

.player-item.host {
  border-color: #667eea;
  background: #f0f2ff;
}

.player-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.player-name {
  font-weight: 600;
  font-size: 1.1rem;
}

.player-badge {
  font-size: 0.8rem;
  padding: 4px 10px;
  border-radius: 20px;
  font-weight: 600;
}

.badge-host {
  background: #667eea;
  color: white;
}

.badge-ready {
  background: #4caf50;
  color: white;
}

.kick-btn {
  padding: 5px 15px;
  font-size: 0.9rem;
  background: #f44336;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-weight: 600;
}

.kick-btn:hover {
  background: #d32f2f;
}

.lobby-controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.lobby-controls .btn {
  flex: 1;
  min-width: 150px;
}

/* Game Screen */
.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  padding: 15px;
  background: #f5f5f5;
  border-radius: 10px;
}

.timer,
.wpm-display {
  font-size: 1.5rem;
  font-weight: 700;
  color: #667eea;
}

.text-display-section {
  margin-bottom: 20px;
}

.text-display {
  font-size: 1.3rem;
  line-height: 2;
  padding: 30px;
  background: #f9f9f9;
  border-radius: 10px;
  min-height: 150px;
  font-family: 'Courier New', monospace;
  letter-spacing: 1px;
  word-wrap: break-word;
}

.char {
  position: relative;
}

.char.correct {
  color: #4caf50;
}

.char.incorrect {
  color: #f44336;
  background: #ffebee;
}

.char.current {
  background: #667eea;
  color: white;
  animation: blink 0.8s infinite;
}

@keyframes blink {
  0%, 50% {
    opacity: 1;
  }
  51%, 100% {
    opacity: 0.3;
  }
}

.typing-input {
  width: 100%;
  padding: 20px;
  font-size: 1.2rem;
  border: 2px solid #e0e0e0;
  border-radius: 10px;
  resize: none;
  font-family: 'Courier New', monospace;
  outline: none;
  transition: all 0.3s ease;
  min-height: 100px;
}

.typing-input:focus {
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.players-progress {
  margin-top: 30px;
}

.progress-list {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.progress-item {
  padding: 10px;
  background: #f9f9f9;
  border-radius: 10px;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.progress-name {
  font-weight: 600;
  font-size: 1rem;
}

.progress-stats {
  font-size: 0.9rem;
  color: #666;
}

.progress-bar-container {
  width: 100%;
  height: 20px;
  background: #e0e0e0;
  border-radius: 10px;
  overflow: hidden;
  position: relative;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  transition: width 0.3s ease;
  border-radius: 10px;
}

.progress-item.finished .progress-bar {
  background: linear-gradient(135deg, #4caf50 0%, #45a049 100%);
}

.progress-percentage {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.8rem;
  font-weight: 600;
  color: white;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

/* Results Screen */
.results-list {
  margin-bottom: 30px;
}

.result-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  margin-bottom: 15px;
  background: #f9f9f9;
  border-radius: 10px;
  border-left: 5px solid #667eea;
}

.result-item:first-child {
  border-left-color: #ffd700;
  background: linear-gradient(135deg, #fff9e6 0%, #fff3cc 100%);
}

.result-item:first-child .result-rank {
  color: #ffd700;
  font-size: 2rem;
}

.result-rank {
  font-size: 1.5rem;
  font-weight: 700;
  color: #667eea;
  min-width: 40px;
}

.result-info {
  flex: 1;
  margin: 0 20px;
}

.result-name {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 5px;
}

.result-stats {
  display: flex;
  gap: 20px;
  color: #666;
}

.stat-item {
  display: flex;
  flex-direction: column;
}

.stat-label {
  font-size: 0.8rem;
  text-transform: uppercase;
}

.stat-value {
  font-size: 1.1rem;
  font-weight: 600;
  color: #667eea;
}

/* Responsive Design */
@media (max-width: 600px) {
  .container,
  .game-container {
    padding: 20px;
  }

  .title {
    font-size: 2rem;
  }

  h2.title {
    font-size: 1.5rem;
  }

  .text-display {
    font-size: 1.1rem;
    padding: 20px;
  }

  .typing-input {
    font-size: 1rem;
  }

  .lobby-controls {
    flex-direction: column;
  }

  .lobby-controls .btn {
    width: 100%;
  }

  .result-stats {
    flex-direction: column;
    gap: 5px;
  }
}
