* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: #1a1a2e;
  color: #e0e0e0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  padding: 16px;
}

.container {
  max-width: 700px;
  width: 100%;
  padding: 40px;
  background: #16213e;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  cursor: text;
}

h1 {
  text-align: center;
  margin-bottom: 24px;
  color: #e94560;
  font-size: 1.8rem;
  letter-spacing: 1px;
}

.stats {
  display: flex;
  justify-content: center;
  gap: 40px;
  margin-bottom: 24px;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: #8a8a9a;
  margin-bottom: 4px;
}

.stat-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: #e94560;
}

/* Text display: fixed height, scrollable window */
.text-display {
  background: #0f3460;
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 16px;
  font-size: 1.15rem;
  line-height: 1.8;
  height: 180px;
  overflow: hidden;
  letter-spacing: 0.5px;
  user-select: none;
  position: relative;
}

.text-display .word {
  display: inline-block;
  white-space: nowrap;
}

.text-display .char {
  transition: color 0.05s;
}

.text-display .char.correct {
  color: #4ecca3;
}

.text-display .char.incorrect {
  color: #e94560;
  text-decoration: underline;
}

.text-display .char.current {
  background: rgba(233, 69, 96, 0.3);
  border-radius: 2px;
}

.text-display .char.pending {
  color: #5a6a8a;
}

/* Tap prompt for mobile */
.tap-prompt {
  text-align: center;
  font-size: 0.85rem;
  color: #5a6a8a;
  margin-bottom: 12px;
  animation: pulse 2s ease-in-out infinite;
}

.tap-prompt.hidden {
  display: none;
}

@keyframes pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* Hidden textarea - still focusable */
.input-field {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.retry-btn {
  display: block;
  margin: 20px auto 0;
  padding: 12px 36px;
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  background: #e94560;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.retry-btn:hover {
  background: #c73652;
  transform: translateY(-1px);
}

.results {
  max-width: 700px;
  width: 100%;
  margin-top: 20px;
  padding: 24px 40px;
  background: #16213e;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  text-align: center;
}

.results h2 {
  color: #4ecca3;
  margin-bottom: 16px;
}

.results p {
  font-size: 1.05rem;
  margin: 8px 0;
  color: #c0c0d0;
}

.results strong {
  color: #e94560;
}

/* ===== Mobile ===== */
@media (max-width: 600px) {
  body {
    padding: 12px;
    align-items: flex-start;
    padding-top: 24px;
  }

  .container {
    padding: 20px;
    border-radius: 12px;
  }

  h1 {
    font-size: 1.3rem;
    margin-bottom: 16px;
  }

  .stats {
    gap: 24px;
    margin-bottom: 16px;
  }

  .stat-value {
    font-size: 1.4rem;
  }

  .stat-label {
    font-size: 0.65rem;
  }

  .text-display {
    font-size: 1rem;
    line-height: 1.7;
    height: 150px;
    padding: 16px;
  }

  .results {
    padding: 20px;
  }

  .results p {
    font-size: 0.95rem;
  }
}

@media (max-width: 380px) {
  .text-display {
    height: 130px;
    font-size: 0.9rem;
    padding: 12px;
  }

  h1 {
    font-size: 1.1rem;
    margin-bottom: 12px;
  }

  .stats {
    gap: 16px;
    margin-bottom: 12px;
  }

  .stat-value {
    font-size: 1.2rem;
  }
}
