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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #333;
  min-height: 100vh;
  padding: 1rem;
}

.back-link {
  position: fixed;
  top: 1rem;
  right: 1rem;
  padding: 0.5rem 1rem;
  background: rgba(255, 255, 255, 0.9);
  color: #667eea;
  text-decoration: none;
  border-radius: 6px;
  font-weight: 600;
  z-index: 100;
  transition: all 0.3s ease;
}

.back-link:hover {
  background: white;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.container {
  max-width: 900px;
  margin: 0 auto;
}

h1 {
  text-align: center;
  font-size: 2.5rem;
  color: white;
  margin: 2rem 0 0.5rem;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.subtitle {
  text-align: center;
  color: rgba(255, 255, 255, 0.9);
  font-size: 1.1rem;
  margin-bottom: 2rem;
}

.menu {
  padding: 2rem;
}

.test-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
}

.test-btn {
  padding: 2rem 1rem;
  background: white;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  font-size: 1.2rem;
  font-weight: 600;
  color: #333;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.test-btn:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.test-btn small {
  font-size: 0.75rem;
  color: #999;
  font-weight: 400;
}

.test-container {
  background: white;
  border-radius: 12px;
  padding: 3rem 2rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  min-height: 400px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

#test-content {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.reaction-area {
  width: 100%;
  max-width: 400px;
  height: 300px;
  background: #f0f0f0;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 2rem 0;
  cursor: pointer;
  user-select: none;
  font-size: 2rem;
  font-weight: 700;
}

.reaction-area.ready {
  background: #ffe74c;
  color: #333;
}

.reaction-area.waiting {
  background: #ff6b6b;
  color: white;
}

.reaction-area.clicked {
  background: #51cf66;
  color: white;
}

.color-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  max-width: 300px;
  margin: 2rem 0;
}

.color-box {
  width: 70px;
  height: 70px;
  border-radius: 8px;
  cursor: pointer;
  border: none;
}

.memory-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  max-width: 300px;
  margin: 2rem 0;
}

.memory-tile {
  width: 60px;
  height: 60px;
  background: #ddd;
  border: 2px solid #999;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  user-select: none;
}

.memory-tile:hover {
  background: #ccc;
}

.memory-tile.active {
  background: #667eea;
  color: white;
  border-color: #667eea;
}

.memory-tile.correct {
  background: #51cf66;
  border-color: #51cf66;
}

.memory-tile.wrong {
  background: #ff6b6b;
  border-color: #ff6b6b;
}

.focus-canvas {
  border: 2px solid #ddd;
  border-radius: 8px;
  background: #fafafa;
  margin: 2rem 0;
  max-width: 100%;
}

.typing-box {
  width: 100%;
  max-width: 500px;
  padding: 1rem;
  font-size: 1.1rem;
  border: 2px solid #ddd;
  border-radius: 8px;
  margin: 1rem 0;
  font-family: 'Courier New', monospace;
  background: #f9f9f9;
}

.button-group {
  display: flex;
  gap: 1rem;
  margin-top: 2rem;
  justify-content: center;
  flex-wrap: wrap;
}

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

.btn-primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

.btn-secondary {
  background: #f0f0f0;
  color: #333;
  border: 1px solid #ddd;
}

.btn-secondary:hover {
  background: #e0e0e0;
}

.results {
  background: white;
  border-radius: 12px;
  padding: 3rem 2rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.results h2 {
  text-align: center;
  margin-bottom: 2rem;
  color: #1a1a2e;
}

#results-content {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.result-card {
  background: #f9f9f9;
  padding: 1.5rem;
  border-radius: 8px;
  border-left: 4px solid #667eea;
  text-align: center;
}

.result-card h3 {
  font-size: 0.9rem;
  color: #999;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
}

.result-card .score {
  font-size: 2rem;
  font-weight: 700;
  color: #667eea;
  margin: 1rem 0;
}

.result-card .details {
  font-size: 0.85rem;
  color: #666;
}

.timer {
  font-size: 3rem;
  font-weight: 700;
  color: #667eea;
  text-align: center;
  margin: 2rem 0;
  font-family: 'Courier New', monospace;
}

.instructions {
  text-align: center;
  color: #666;
  margin: 2rem 0;
  font-size: 1.1rem;
  max-width: 500px;
}

.progress {
  width: 100%;
  height: 8px;
  background: #f0f0f0;
  border-radius: 4px;
  overflow: hidden;
  margin: 2rem 0;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #667eea, #764ba2);
  transition: width 0.3s ease;
}

@media (max-width: 600px) {
  h1 {
    font-size: 1.8rem;
  }

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

  .test-container {
    padding: 1.5rem;
    min-height: auto;
  }

  .color-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .color-box {
    width: 50px;
    height: 50px;
  }

  .memory-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .memory-tile {
    width: 50px;
    height: 50px;
  }
}
