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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}

.container {
  background: #ffffff;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  padding: 24px 32px;
  max-width: 800px;
  width: 100%;
}

header {
  text-align: center;
  margin-bottom: 16px;
}

header h1 {
  font-size: 1.9rem;
  color: #667eea;
  letter-spacing: 2px;
}

.subtitle {
  color: #999;
  font-size: 1rem;
  font-weight: normal;
  letter-spacing: 0;
  margin-left: 8px;
}

.difficulty-selector {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.diff-btn {
  padding: 8px 22px;
  border: 2px solid #667eea;
  background: #ffffff;
  color: #667eea;
  border-radius: 30px;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s;
}

.diff-btn:hover {
  background: #f0f0ff;
}

.diff-btn.active {
  background: #667eea;
  color: #ffffff;
}

.stats-panel {
  display: flex;
  justify-content: space-around;
  background: #f7f7fb;
  border-radius: 12px;
  padding: 12px 20px;
  margin-bottom: 16px;
}

.stat {
  display: flex;
  flex-direction: row;
  align-items: baseline;
  gap: 6px;
}

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

.stat-label {
  font-size: 0.85rem;
  color: #999;
}

.typing-area {
  position: relative;
  margin-bottom: 16px;
}

.text-display {
  font-size: 1.5rem;
  line-height: 2rem;
  letter-spacing: 1px;
  font-family: "Courier New", monospace;
  background: #f7f7fb;
  border-radius: 12px;
  padding: 20px;
  min-height: 90px;
  cursor: text;
  user-select: none;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.text-display .char {
  color: #bbb;
  transition: color 0.1s;
}

.text-display .char.correct {
  color: #2ecc71;
}

.text-display .char.incorrect {
  color: #e74c3c;
  background: rgba(231, 76, 60, 0.15);
  border-radius: 3px;
}

.text-display .char.current {
  background: #667eea;
  color: #ffffff;
  border-radius: 3px;
  animation: blink 1s infinite;
}

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

.controls {
  display: flex;
  gap: 15px;
  justify-content: center;
  margin-bottom: 10px;
}

.control-btn {
  padding: 9px 26px;
  border: none;
  background: #667eea;
  color: #ffffff;
  border-radius: 10px;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s;
}

.control-btn:hover {
  background: #556cd6;
  transform: translateY(-2px);
}

.hint {
  text-align: center;
  color: #aaa;
  font-size: 0.9rem;
}

.text-display.complete {
  background: rgba(46, 204, 113, 0.1);
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-overlay.show {
  display: flex;
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  background: #ffffff;
  border-radius: 20px;
  padding: 30px;
  max-width: 480px;
  width: 90%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  animation: popIn 0.3s ease;
}

@keyframes popIn {
  from { transform: scale(0.8); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal h2 {
  color: #667eea;
  font-size: 2rem;
  margin-bottom: 12px;
}

.modal-encourage {
  color: #555;
  font-size: 1.15rem;
  margin-bottom: 8px;
  min-height: 1.4rem;
}

.modal-best {
  color: #f39c12;
  font-size: 0.95rem;
  margin-bottom: 25px;
  min-height: 1.2rem;
}

.keyboard {
  background: #f7f7fb;
  border-radius: 12px;
  padding: 10px;
  margin-bottom: 14px;
  user-select: none;
}

.kb-row {
  display: flex;
  justify-content: center;
  gap: 5px;
  margin-bottom: 5px;
}

.kb-row:last-child {
  margin-bottom: 0;
}

.kb-key {
  min-width: 36px;
  height: 38px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  border: 1px solid #ddd;
  border-bottom: 3px solid #ccc;
  border-radius: 7px;
  font-size: 0.85rem;
  color: #555;
  font-family: "Courier New", monospace;
  transition: all 0.1s;
}

.kb-wide {
  min-width: 64px;
  font-size: 0.75rem;
}

.kb-space {
  min-width: 300px;
  font-size: 0.8rem;
}

.kb-top {
  font-size: 0.7rem;
  color: #999;
  line-height: 1;
}

.kb-bottom {
  font-size: 0.85rem;
  line-height: 1.1;
}

.kb-key.kb-next {
  background: #2ecc71;
  border-color: #27ae60;
  border-bottom-color: #1e8449;
  color: #ffffff;
  transform: translateY(1px);
  box-shadow: 0 0 12px rgba(46, 204, 113, 0.6);
}

.kb-key.kb-next .kb-top,
.kb-key.kb-next .kb-bottom {
  color: #ffffff;
}

.kb-key.kb-shift-next {
  background: #f39c12;
  border-color: #e67e22;
  border-bottom-color: #d35400;
  color: #ffffff;
  box-shadow: 0 0 12px rgba(243, 156, 18, 0.6);
}

.modal-stats {
  display: flex;
  justify-content: space-around;
  background: #f7f7fb;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 25px;
}

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

.modal-stat-value {
  font-size: 1.7rem;
  font-weight: bold;
  color: #667eea;
}

.modal-stat-label {
  font-size: 0.8rem;
  color: #999;
  margin-top: 4px;
}
