/* CSS Variables - Your Color Scheme */
:root {
  /* Core Neutral Palette */
  --text: #f5f5f5; /* Clean white text */
  --background: #0a0a0a; /* Pure black background */
  --surface: rgba(255, 255, 255, 0.05); /* Glassy surface (frosted effect) */
  --border: rgba(255, 255, 255, 0.15); /* Subtle frosted border */

  /* Primary & Secondary (Glassy look) */
  --primary: rgba(255, 255, 255, 0.7); /* Semi-white for buttons/links */
  --secondary: rgba(255, 255, 255, 0.4); /* Muted secondary text */

  /* Interactive states */
  --hover: rgba(255, 255, 255, 0.9); /* Bright white hover effect */
  --accent: rgba(255, 255, 255, 0.25); /* Glass highlight */

  /* Feedback colors */
  --success: #22c55e; /* Professional green */
  --error: #ef4444; /* Professional red */
  --warning: #f59e0b; /* Optional amber */
  --info: #3b82f6; /* Optional blue */
}

.glass {
  background: var(--surface);
  backdrop-filter: blur(12px) saturate(150%);
  -webkit-backdrop-filter: blur(12px) saturate(150%);
  border: 1px solid var(--border);
  border-radius: 12px;
}

/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    sans-serif;
  background: var(--background);
  color: var(--text);
  line-height: 1.6;
  overflow-x: hidden;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

/* Header */
.header {
  text-align: center;
  margin-bottom: 30px;
  border-bottom: 2px solid var(--primary);
  padding-bottom: 20px;
}

.title {
  font-size: 2.5rem;
  font-weight: 600;
  letter-spacing: 2px;
  color: var(--primary);
  text-shadow: 0 0 20px rgba(125, 173, 234, 0.3);
}

/* Stats Bar */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 20px;
  background: var(--surface);
  padding: 20px;
  border-radius: 12px;
  margin-bottom: 30px;
  border: 1px solid var(--border);
}

.stat-item {
  background: var(--primary);
  color: var(--background);
  padding: 15px;
  border-radius: 8px;
  text-align: center;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(125, 173, 234, 0.2);
}

.stat-item:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(125, 173, 234, 0.3);
}

.stat-label {
  font-size: 0.9rem;
  opacity: 0.8;
  display: block;
  margin-bottom: 5px;
  font-weight: 500;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  display: block;
}

.badges {
  background: var(--accent) !important;
  color: var(--text) !important;
}

.badges .stat-label,
.badges .stat-value {
  color: var(--text) !important;
}

.badge-icon {
  font-size: 1.2rem;
  margin-right: 5px;
}

/* Difficulty Indicator */
.difficulty-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
  font-size: 0.9rem;
  color: var(--text);
}

.difficulty-dots {
  margin-left: 10px;
}

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin: 0 3px;
  background: var(--border);
  transition: all 0.3s ease;
}

.dot.filled {
  background: var(--primary);
  box-shadow: 0 0 10px rgba(125, 173, 234, 0.5);
}

/* Control Buttons */
.control-buttons {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-bottom: 30px;
}

.control-btn {
  padding: 12px 30px;
  background: var(--primary);
  color: var(--background);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 1rem;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(125, 173, 234, 0.2);
}

.control-btn:hover {
  background: var(--hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(125, 173, 234, 0.3);
}

.control-btn:disabled {
  background: var(--border);
  color: var(--text);
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.control-btn.reset {
  background: var(--secondary);
  color: var(--text);
}

.control-btn.reset:hover {
  background: var(--accent);
}

/* Typing Section */
.typing-section {
  background: var(--surface);
  border: 2px solid var(--primary);
  border-radius: 12px;
  padding: 40px;
  margin-bottom: 30px;
  position: relative;
  min-height: 250px;
  max-height: 350px;
  overflow: hidden;
  box-shadow: 0 8px 30px rgba(125, 173, 234, 0.1);
}

.text-display {
  font-family: "JetBrains Mono", "Courier New", monospace;
  font-size: 1.4rem;
  line-height: 1.8;
  margin-bottom: 25px;
  min-height: 150px;
  max-height: 200px;
  overflow-y: auto;
  overflow-x: hidden;
  word-wrap: break-word;
  white-space: pre-wrap;
  user-select: none;
  padding: 15px;
  background: var(--background);
  border-radius: 8px;
  border: 1px solid var(--border);
}

/* Character Styling */
.character {
  position: relative;
  transition: all 0.15s ease;
  display: inline;
}

.character.correct {
  background: var(--success);
  color: var(--background);
  padding: 2px 1px;
  border-radius: 3px;
}

.character.incorrect {
  background: var(--error);
  color: var(--text);
  padding: 2px 1px;
  border-radius: 3px;
  animation: shake 0.3s ease-in-out;
}

.character.current {
  background: transparent;
  color: var(--accent);
  border-bottom: 3px solid var(--accent);
  animation: blink 1.2s infinite;
  font-weight: 600;
}

.character.pending {
  color: var(--text);
  opacity: 0.6;
}

@keyframes blink {
  0%,
  50% {
    border-bottom-color: var(--accent);
    opacity: 1;
  }
  51%,
  100% {
    border-bottom-color: transparent;
    opacity: 0.7;
  }
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-3px);
  }
  75% {
    transform: translateX(3px);
  }
}

.typing-input {
  width: 100%;
  padding: 15px;
  font-family: "JetBrains Mono", monospace;
  font-size: 1.2rem;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: var(--background);
  color: var(--text);
  transition: all 0.3s ease;
}

.typing-input:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 15px rgba(125, 173, 234, 0.2);
}

.typing-input::placeholder {
  color: var(--text);
  opacity: 0.5;
}

/* Progress Section */
.progress-section {
  margin-bottom: 30px;
}

.progress-bar {
  width: 100%;
  height: 10px;
  background: var(--surface);
  border-radius: 5px;
  overflow: hidden;
  margin-bottom: 10px;
  border: 1px solid var(--border);
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary) 0%, var(--accent) 100%);
  width: 0%;
  transition: width 0.4s ease;
  border-radius: 5px;
  box-shadow: 0 0 10px rgba(125, 173, 234, 0.3);
}

.progress-text {
  text-align: center;
  color: var(--text);
  font-size: 0.95rem;
  opacity: 0.8;
}

/* Mode Selector */
.mode-selector {
  display: flex;
  justify-content: center;
  gap: 15px;
  margin-bottom: 30px;
  flex-wrap: wrap;
}

.mode-btn {
  padding: 12px 24px;
  background: var(--surface);
  color: var(--text);
  border: 2px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: 500;
  font-size: 0.9rem;
}

.mode-btn:hover {
  background: var(--primary);
  color: var(--background);
  border-color: var(--primary);
}

.mode-btn.active {
  background: var(--accent);
  color: var(--text);
  border-color: var(--accent);
  box-shadow: 0 4px 15px rgba(226, 71, 168, 0.3);
}

/* Achievement Popup */
.achievement-popup {
  position: fixed;
  bottom: 30px;
  right: 30px;
  background: var(--accent);
  color: var(--text);
  padding: 20px;
  border-radius: 12px;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.4s ease;
  z-index: 1000;
  max-width: 300px;
  border: 2px solid var(--primary);
  box-shadow: 0 10px 30px rgba(226, 71, 168, 0.2);
}

.achievement-popup.show {
  transform: translateY(0);
  opacity: 1;
}

.achievement-icon {
  font-size: 1.5rem;
  margin-right: 10px;
}

.achievement-text {
  font-weight: 600;
}

/* Results Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(2, 7, 13, 0.9);
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  z-index: 1000;
  backdrop-filter: blur(5px);
}

.modal-overlay.show {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  background: var(--surface);
  padding: 40px;
  border-radius: 16px;
  max-width: 600px;
  width: 90%;
  text-align: center;
  border: 2px solid var(--primary);
  box-shadow: 0 20px 60px rgba(125, 173, 234, 0.2);
}

.modal-content h2 {
  margin-bottom: 30px;
  font-size: 2rem;
  color: var(--primary);
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.result-item {
  background: var(--background);
  padding: 20px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.result-label {
  display: block;
  color: var(--text);
  font-size: 0.9rem;
  margin-bottom: 8px;
  opacity: 0.7;
}

.result-value {
  display: block;
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--primary);
}

.modal-actions {
  display: flex;
  gap: 20px;
  justify-content: center;
}

.btn-primary,
.btn-secondary {
  padding: 12px 30px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.3s ease;
  border: none;
  font-size: 1rem;
}

.btn-primary {
  background: var(--primary);
  color: var(--background);
}

.btn-primary:hover {
  background: var(--hover);
  transform: translateY(-2px);
}

.btn-secondary {
  background: var(--secondary);
  color: var(--text);
}

.btn-secondary:hover {
  background: var(--accent);
}

/* Footer */
footer {
  text-align: center;
  padding: 30px 20px;
  color: var(--text);
  opacity: 0.6;
  font-size: 0.9rem;
  border-top: 1px solid var(--border);
  margin-top: 40px;
}

/* Responsive Design */
@media (max-width: 768px) {
  .container {
    padding: 15px;
  }

  .title {
    font-size: 2rem;
  }

  .typing-section {
    padding: 20px;
  }

  .text-display {
    font-size: 1.2rem;
    line-height: 1.6;
    padding: 15px;
  }

  .stats-bar {
    grid-template-columns: repeat(2, 1fr);
  }

  .mode-selector {
    flex-direction: column;
    align-items: center;
  }

  .mode-btn {
    width: 100%;
    max-width: 200px;
  }

  .control-buttons {
    flex-direction: column;
    align-items: center;
  }

  .control-btn {
    width: 200px;
  }

  .modal-content {
    padding: 30px 20px;
  }

  .results-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .title {
    font-size: 1.7rem;
    letter-spacing: 1px;
  }

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

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

  .stats-bar {
    grid-template-columns: 1fr;
  }

  .achievement-popup {
    bottom: 20px;
    right: 20px;
    left: 20px;
    max-width: none;
  }
}

/* Scrollbar Styling */
.text-display::-webkit-scrollbar {
  width: 6px;
}

.text-display::-webkit-scrollbar-track {
  background: var(--surface);
}

.text-display::-webkit-scrollbar-thumb {
  background: var(--primary);
  border-radius: 3px;
}

.text-display::-webkit-scrollbar-thumb:hover {
  background: var(--hover);
}
