* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

body {
  color: #333;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.container {
  max-width: 900px;
  width: 100%;
  background: white;
  border-radius: 16px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.2);
  padding: 30px;
  position: relative;
  overflow: hidden;
}

header {
  text-align: center;
  margin-bottom: 30px;
  transition: opacity 0.5s ease;
}

h1 {
  color: #2c3e50;
  font-size: 36px;
  margin-bottom: 10px;
}

.description {
  color: #7f8c8d;
  font-size: 18px;
  margin-bottom: 20px;
}

.time-selection {
  display: flex;
  justify-content: center;
  gap: 15px;
  margin-bottom: 30px;
  transition: opacity 0.5s ease;
}

.time-btn {
  padding: 12px 20px;
  background: #f8f9fa;
  color: #7f8c8d;
  border: 2px solid #ddd;
  border-radius: 8px;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.3s;
}

.time-btn.active {
  background: #3498db;
  color: white;
  border-color: #3498db;
}

.time-btn:hover:not(.active) {
  background: #e8f4fc;
  border-color: #3498db;
}

.stats-container {
  display: flex;
  justify-content: space-between;
  margin-bottom: 20px;
  padding: 20px;
  background: #f8f9fa;
  border-radius: 12px;
}

.stat {
  text-align: center;
  flex: 1;
}

.stat-value {
  font-size: 28px;
  font-weight: bold;
  color: #2c3e50;
}

.stat-label {
  font-size: 16px;
  color: #7f8c8d;
}

.text-display {
  background: #f8f9fa;
  padding: 25px;
  border-radius: 12px;
  margin-bottom: 20px;
  font-size: 24px;
  line-height: 1.6;
  min-height: 180px;
  position: relative;
  overflow: hidden;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.word {
  display: inline-block;
  margin: 0 8px 8px 0;
  padding: 5px 8px;
  border-radius: 6px;
}

.current {
  background-color: #e6f7ff;
  position: relative;
}

.current::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 2px;
  background: #3498db;
  animation: blink 1s infinite;
}

@keyframes blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
}

.correct {
  color: #27ae60;
}

.incorrect {
  color: #e74c3c;
  text-decoration: underline;
}

.input-area {
  margin-bottom: 20px;
  position: relative;
}

#typing-input {
  width: 100%;
  padding: 18px;
  font-size: 20px;
  border: 2px solid #ddd;
  border-radius: 10px;
  outline: none;
  transition: border-color 0.3s;
}

#typing-input:focus {
  border-color: #3498db;
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}

.controls {
  display: flex;
  justify-content: center;
  gap: 20px;
}

button {
  padding: 15px 30px;
  background: #3498db;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  gap: 8px;
}

button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

button#reset-btn {
  background: #e74c3c;
}

button#reset-btn:hover {
  background: #c0392b;
}

.timer {
  font-size: 52px;
  text-align: center;
  margin: 20px 0;
  color: #2c3e50;
  font-weight: bold;
}

.results {
  text-align: center;
  padding: 25px;
  background: #f8f9fa;
  border-radius: 12px;
  margin-top: 20px;
  display: none;
}

.results h2 {
  margin-bottom: 20px;
  color: #2c3e50;
  font-size: 28px;
}

.result-stats {
  display: flex;
  justify-content: space-around;
  margin-bottom: 20px;
}

.result-stat {
  text-align: center;
}

.result-value {
  font-size: 32px;
  font-weight: bold;
  color: #3498db;
}

.result-label {
  font-size: 18px;
  color: #7f8c8d;
}

.start-message {
  text-align: center;
  color: #7f8c8d;
  font-style: italic;
  margin-top: 20px;
  font-size: 20px;
}

.cursor {
  display: inline-block;
  width: 3px;
  height: 26px;
  background: #3498db;
  margin-left: 3px;
  vertical-align: middle;
  animation: blink 1s infinite;
}

footer {
  margin-top: 30px;
  text-align: center;
  color: rgba(255, 255, 255, 0.8);
  font-size: 16px;
}

.instructions {
  background: #f8f9fa;
  padding: 15px;
  border-radius: 8px;
  margin-bottom: 20px;
  transition: opacity 0.5s ease;
}

.instructions h3 {
  color: #2c3e50;
  margin-bottom: 10px;
}

.instructions ul {
  padding-left: 20px;
  color: #7f8c8d;
}

.instructions li {
  margin-bottom: 8px;
}

.hidden {
  opacity: 0;
  height: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

@media (max-width: 768px) {
  .container {
    padding: 20px;
  }

  h1 {
    font-size: 28px;
  }

  .time-selection {
    flex-wrap: wrap;
  }

  .stat-value {
    font-size: 22px;
  }

  .text-display {
    font-size: 20px;
    padding: 15px;
  }

  .timer {
    font-size: 42px;
  }

  button {
    padding: 12px 20px;
    font-size: 16px;
  }
}
