@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;700&family=Inter:wght@300;400;600&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg: #050505;
  --surface: rgba(255, 255, 255, 0.03);
  --surface-hover: rgba(255, 255, 255, 0.08);
  --border: rgba(255, 255, 255, 0.1);
  --primary: #00f2ff;
  --secondary: #bc13fe;
  --accent: #ff007a;
  --text: #f0f0f0;
  --text-muted: #888;
  --green: #00ff88;
  --red: #ff3e3e;
  --font-heading: 'Space Grotesk', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

.bg-decoration {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.bg-decoration::before, .bg-decoration::after {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  border-radius: 50%;
  filter: blur(180px);
  opacity: 0.12;
  animation: float 25s infinite alternate;
}

.bg-decoration::before {
  background: var(--primary);
  top: -10%; left: -10%;
}

.bg-decoration::after {
  background: var(--secondary);
  bottom: -10%; right: -10%;
  animation-delay: -12s;
}

@keyframes float {
  0% { transform: translate(0, 0) scale(1) rotate(0deg); }
  100% { transform: translate(150px, 100px) scale(1.3) rotate(45deg); }
}

#app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 20px;
}

/* Header & Typography */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 40px;
  flex-wrap: wrap;
  gap: 20px;
}

h1, #home-title {
  font-family: var(--font-heading);
  font-size: 2.5rem;
  font-weight: 700;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  cursor: pointer;
  letter-spacing: -1px;
}

/* Controls */
.controls {
  display: flex;
  gap: 12px;
  align-items: center;
}

select, button {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 16px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  backdrop-filter: blur(8px);
  transition: var(--transition);
  outline: none;
}

select:hover, button:hover {
  background: var(--surface-hover);
  border-color: var(--primary);
  transform: translateY(-2px);
}

button {
  cursor: pointer;
  font-weight: 600;
  background: linear-gradient(135deg, rgba(0, 242, 255, 0.1), rgba(188, 19, 254, 0.1));
}

button:active {
  transform: translateY(0);
}

/* Home Page */
.home-page {
  display: grid;
  gap: 40px;
}

.home-hero {
  padding: 60px 40px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  backdrop-filter: blur(12px);
  text-align: center;
}

.home-hero h2 {
  font-family: var(--font-heading);
  font-size: 3.5rem;
  margin-bottom: 12px;
  color: var(--text);
}

.home-hero p {
  font-size: 1.2rem;
  color: var(--text-muted);
}

.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

.home-action {
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 30px;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  overflow: hidden;
}

.home-action::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  opacity: 0;
  transition: var(--transition);
  z-index: 0;
}

.home-action:hover {
  transform: translateY(-8px);
  border-color: var(--primary);
  box-shadow: 0 10px 30px rgba(0, 242, 255, 0.1);
}

.home-action:hover::before {
  opacity: 0.05;
}

.home-action * {
  position: relative;
  z-index: 1;
}

.home-action strong {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  color: var(--primary);
}

.home-action span {
  font-size: 0.95rem;
  color: var(--text-muted);
}

/* Typing Area */
.text-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  min-height: 300px;
  padding: 40px;
  font-family: var(--font-mono);
  font-size: 2.2rem;
  line-height: 1.6;
  color: var(--text-muted);
  margin-bottom: 30px;
  backdrop-filter: blur(12px);
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.2);
}

.pending { color: var(--text-muted); }
.correct { color: var(--text); }
.wrong { 
  color: var(--red); 
  background: rgba(255, 62, 62, 0.1);
  border-radius: 4px;
}

.current {
  color: var(--primary);
  border-bottom: 3px solid var(--primary);
  animation: pulse-border 1.5s infinite;
}

@keyframes pulse-border {
  0%, 100% { border-color: var(--primary); }
  50% { border-color: transparent; }
}

/* Metrics */
.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 15px;
}

.metrics div {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  text-align: center;
  backdrop-filter: blur(8px);
}

.metrics strong {
  display: block;
  font-family: var(--font-heading);
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.metrics span {
  font-family: var(--font-heading);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--secondary);
}

/* Results & Others */
.result-screen {
  background: var(--surface);
  border: 2px solid var(--primary);
  border-radius: 24px;
  padding: 40px;
  margin-top: 20px;
  animation: slide-up 0.5s ease-out;
}

@keyframes slide-up {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.message {
  min-height: 32px;
  margin-top: 10px;
  color: var(--primary);
  font-weight: 500;
  text-align: center;
}

.hidden { display: none !important; }

/* Custom Scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb {
  background: var(--surface-hover);
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover { background: var(--border); }

/* Input Overlay (Keep hidden) */
.input-overlay {
  position: absolute;
  top: 0; left: 0;
  width: 1px; height: 1px;
  opacity: 0;
  pointer-events: none;
}

.space-missed {
  color: var(--red) !important;
  background: rgba(255, 62, 62, 0.2) !important;
  border-radius: 4px;
}

/* Specialized Menus */
.drill-menu, .custom-builder {
  display: flex;
  flex-direction: column;
  gap: 15px;
  max-width: 600px;
  margin: 40px auto;
}

.drill-menu h2, .custom-builder h2 {
  font-family: var(--font-heading);
  font-size: 2rem;
  color: var(--primary);
  text-align: center;
  margin-bottom: 20px;
}

.drill {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 18px 24px;
  font-size: 1.1rem;
  text-align: left;
  border-radius: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: var(--transition);
  width: 100%;
}

.drill:hover {
  background: var(--surface-hover);
  border-color: var(--primary);
  padding-left: 32px;
  color: var(--primary);
}

.drill::after {
  content: 'â†’';
  opacity: 0;
  transition: var(--transition);
}

.drill:hover::after {
  opacity: 1;
}

textarea {
  min-height: 200px;
  background: rgba(0, 0, 0, 0.3);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  font-family: var(--font-mono);
  font-size: 1.1rem;
  outline: none;
  transition: var(--transition);
  width: 100%;
}

textarea:focus {
  border-color: var(--secondary);
  box-shadow: 0 0 20px rgba(188, 19, 254, 0.1);
}

#custom-start {
  margin-top: 10px;
  padding: 15px;
  font-size: 1.1rem;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: var(--bg);
  border: none;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
  #app {
    padding: 20px 15px;
  }

  h1, #home-title {
    font-size: 1.8rem;
  }

  header {
    flex-direction: column;
    align-items: flex-start;
    gap: 15px;
  }

  .controls {
    width: 100%;
    justify-content: space-between;
  }

  .home-hero {
    padding: 40px 20px;
  }

  .home-hero h2 {
    font-size: 2.2rem;
  }

  .text-container {
    padding: 20px;
    font-size: 1.5rem;
    min-height: 200px;
  }

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

  .metrics div {
    padding: 15px;
  }

  .metrics span {
    font-size: 1.4rem;
  }

  .drill-menu, .custom-builder {
    margin: 20px auto;
  }
}

@media (max-width: 480px) {
  .metrics {
    grid-template-columns: 1fr;
  }

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