* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Nunito', sans-serif;
  background: linear-gradient(to bottom, #e8f5e9, #c8e6c9);
  color: #1b5e20;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.main-container {
  width: 100%;
  max-width: 800px;
}

h1 {
  font-size: 2.5rem;
  margin: 0 0 10px 0;
  color: #1b5e20;
  text-align: center;
}

.description {
  text-align: center;
  font-size: 1rem;
  color: #388e3c;
  margin: 0 0 30px 0;
}

.game-container {
  background: white;
  border-radius: 15px;
  padding: 30px;
  box-shadow: 0 10px 30px rgba(27, 94, 32, 0.1);
  border: 1px solid #a5d6a7;
}

.duration-options {
  display: flex;
  gap: 12px;
  margin-bottom: 25px;
  flex-wrap: wrap;
}

.duration-button {
  flex: 1;
  min-width: 80px;
  padding: 10px 15px;
  border: none;
  border-radius: 25px;
  background: #e8f5e9;
  color: #1b5e20;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.duration-button:hover {
  background: #c8e6c9;
}

.duration-button.active {
  background: #22b14c;
  color: white;
}

.stats-area {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 25px;
}

.stat-box {
  background: #f1f8e9;
  border: 1px solid #c5e1a5;
  border-radius: 12px;
  padding: 15px;
  text-align: center;
}

.stat-number {
  font-size: 1.8rem;
  font-weight: 700;
  font-family: 'Special Elite', monospace;
  color: #22b14c;
  margin-bottom: 5px;
}

.stat-label {
  font-size: 0.75rem;
  color: #558b2f;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-weight: 600;
}

.timer-bar {
  width: 100%;
  height: 8px;
  background: #c8e6c9;
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 25px;
}

.timer-progress {
  width: 100%;
  height: 100%;
  background: linear-gradient(to right, #22b14c, #7cb342);
  transition: width 1s linear;
}

.text-container {
  background: #f9fff9;
  border: 2px dashed #a5d6a7;
  border-radius: 12px;
  padding: 20px;
  min-height: 140px;
  font-size: 1.2rem;
  line-height: 1.8;
  font-family: 'Special Elite', monospace;
  color: #558b2f;
  cursor: text;
  user-select: none;
  margin-bottom: 20px;
}

.character {
  position: relative;
  transition: all 0.1s ease;
}

.character.active {
  border-left: 3px solid #22b14c;
  padding-left: 3px;
  animation: cursorFlash 1s steps(1) infinite;
}

.character.correct {
  color: #1b5e20;
  font-weight: 600;
}

.character.incorrect {
  color: #d32f2f;
  background: #ffebee;
  border-radius: 3px;
  padding: 2px 4px;
}

@keyframes cursorFlash {
  0%, 49% { border-left-color: #22b14c; }
  50%, 100% { border-left-color: transparent; }
}

#userInput {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

.helper-text {
  text-align: center;
  font-size: 0.95rem;
  color: #558b2f;
  margin-bottom: 20px;
  min-height: 1.5rem;
}

.action-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.action-button {
  padding: 12px 24px;
  border: none;
  border-radius: 10px;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

.restart-button {
  background: #22b14c;
  color: white;
}

.restart-button:hover {
  background: #1e9c41;
}

.next-button {
  background: #ffcdd2;
  color: #c62828;
}

.next-button:hover {
  background: #ef9a9a;
}

.full-width {
  width: 100%;
}

.results-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(27, 94, 32, 0.35);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
}

.results-overlay.show {
  display: flex;
}

.results-content {
  background: white;
  border-radius: 15px;
  padding: 35px;
  text-align: center;
  box-shadow: 0 15px 40px rgba(27, 94, 32, 0.25);
  border: 1px solid #a5d6a7;
  width: 100%;
  max-width: 420px;
}

.results-content h2 {
  margin: 0 0 20px 0;
  font-size: 1.3rem;
  color: #388e3c;
}

.your-score {
  font-size: 4.5rem;
  font-weight: 700;
  color: #22b14c;
  font-family: 'Special Elite', monospace;
  margin: 15px 0;
}

.score-unit {
  color: #558b2f;
  font-size: 1rem;
  margin: 0 0 20px 0;
}

.performance-message {
  font-size: 1rem;
  color: #388e3c;
  margin: 20px 0;
  line-height: 1.6;
}

.results-breakdown {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 25px 0;
}

.result-detail {
  background: #f1f8e9;
  border: 1px solid #c5e1a5;
  border-radius: 10px;
  padding: 15px;
}

.result-detail strong {
  display: block;
  font-size: 1.4rem;
  color: #22b14c;
  margin-bottom: 5px;
}

.result-detail span {
  display: block;
  font-size: 0.8rem;
  color: #558b2f;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
}

@media (max-width: 768px) {
  h1 {
    font-size: 1.8rem;
  }

  .stats-area {
    grid-template-columns: repeat(2, 1fr);
  }

  .text-container {
    font-size: 1rem;
    min-height: 100px;
  }

  .game-container {
    padding: 20px;
  }

  .results-content {
    padding: 25px;
  }

  .your-score {
    font-size: 3.5rem;
  }
}
