/* Common Test Shell Layout */
.test-shell {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.test-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  border-bottom: 1px solid var(--glass-border);
  padding-bottom: 1.25rem;
}

.test-title-area {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.test-title-icon {
  width: 32px;
  height: 32px;
  color: var(--accent);
}

.test-title-icon svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
}

.test-title {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.test-stats-row {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-top: 0.5rem;
}

.test-stat-item {
  display: flex;
  flex-direction: column;
}

.test-stat-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  margin-bottom: 0.1rem;
}

.test-stat-value {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.test-body {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 320px;
  width: 100%;
  border-radius: var(--border-radius-md);
  background: rgba(0, 0, 0, 0.01);
  border: 1px solid var(--glass-border);
  padding: 2rem;
  box-sizing: border-box;
}

[data-theme="dark"] .test-body {
  background: rgba(255, 255, 255, 0.01);
}

/* 1. Click Speed Test (CPS) UI */
.click-test-area {
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: transform var(--transition-fast), border-color var(--transition-normal), background var(--transition-normal);
}

.click-test-area:hover {
  border-color: var(--accent);
  box-shadow: 0 0 16px var(--accent-glow);
}

.click-test-area:active {
  transform: scale(0.995);
  background: rgba(129, 140, 248, 0.03);
}

[data-theme="dark"] .click-test-area:active {
  background: rgba(129, 140, 248, 0.05);
}

.click-test-finished {
  cursor: default !important;
  pointer-events: none !important;
  transform: none !important;
  box-shadow: none !important;
  border-color: var(--glass-border) !important;
  background: rgba(0, 0, 0, 0.01) !important;
}

.click-start-prompt {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text);
  text-align: center;
  pointer-events: none;
  animation: pulsePrompt 2s infinite ease-in-out;
}

@keyframes pulsePrompt {
  0%, 100% { opacity: 0.85; }
  50% { opacity: 0.5; }
}

.click-active-label {
  font-size: 3.5rem;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -0.02em;
  pointer-events: none;
}

.click-active-subtext {
  font-size: 1.1rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 0.5rem;
  pointer-events: none;
}

/* Particle Ripple Effects for CPS clicks */
.click-ripple {
  position: absolute;
  border-radius: 50%;
  background: var(--accent);
  pointer-events: none;
  opacity: 0.08; /* Low opacity since it covers the entire grey rect */
  transform: translate(-50%, -50%) scale(0);
  animation: rippleAnimation 0.6s cubic-bezier(0.1, 0.8, 0.3, 1) forwards;
  z-index: 1;
}

@keyframes rippleAnimation {
  to {
    transform: translate(-50%, -50%) scale(1.2);
    opacity: 0;
  }
}

.click-particle {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  pointer-events: none;
  z-index: 3;
  animation: particleAnimation 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes particleAnimation {
  0% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
  100% {
    transform: translate(var(--dx), var(--dy)) scale(0);
    opacity: 0;
  }
}


/* 2. Typing Speed Test (WPM) UI */
.typing-passage-container {
  width: 100%;
  max-width: 760px;
  font-size: 1.75rem;
  line-height: 1.8;
  letter-spacing: 0.01em;
  word-spacing: 0.05em;
  user-select: none;
  -webkit-user-select: none;
  text-align: left;
  position: relative;
  height: 155px;
  overflow-y: hidden;
}

.typing-passage-text {
  color: var(--text);
  opacity: 0.95;
}

.char-correct {
  color: var(--text-muted);
  opacity: 0.45;
  background: transparent;
  border-radius: 2px;
}

[data-theme="dark"] .char-correct {
  color: var(--text-muted);
  opacity: 0.35;
  background: transparent;
}

.char-incorrect {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.15);
  text-decoration: underline wavy var(--danger);
  border-radius: 2px;
}

.char-current {
  position: relative;
  color: var(--accent);
  background: rgba(99, 102, 241, 0.15);
  border-radius: 2px;
}

.char-current::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background-color: var(--accent);
  animation: cursorBlink 1s step-end infinite;
}

@keyframes cursorBlink {
  50% { opacity: 0; }
}

/* Invisible text area overlay for input handling */
.typing-input {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  z-index: 10;
  cursor: default;
}


/* 3. Scroll Speed Test UI */
.scroll-viewport {
  width: 100%;
  max-width: 500px;
  height: 280px;
  border-radius: var(--border-radius-md);
  border: 2px solid var(--glass-border);
  background: var(--surface);
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .scroll-viewport {
  background: rgba(0, 0, 0, 0.2);
}

.scroll-track-container {
  width: 100%;
  height: 100%;
  overflow-y: scroll;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE and Edge */
  scroll-behavior: auto; /* Absolute control of scroll pos */
}

/* Hide scrollbar for Chrome, Safari and Opera */
.scroll-track-container::-webkit-scrollbar {
  display: none;
}

.scroll-content {
  width: 100%;
  height: 5000px; /* Tall virtual container */
  position: relative;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 49px,
    var(--glass-border) 49px,
    var(--glass-border) 50px
  );
}

.scroll-marker {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 500;
  pointer-events: none;
}

.scroll-instruction-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.02);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10;
  pointer-events: none;
  transition: opacity var(--transition-normal);
  text-align: center;
}

.scroll-instruction-overlay svg {
  width: 48px;
  height: 48px;
  margin-bottom: 0.75rem;
  fill: var(--text-muted);
  animation: bounceScroll 1.5s infinite;
}

@keyframes bounceScroll {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}


/* 4. Reaction Time Test UI */
.reaction-pad {
  width: 100%;
  height: 320px;
  border-radius: var(--border-radius-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: background var(--transition-fast), transform var(--transition-fast);
  text-align: center;
  padding: 2rem;
  box-sizing: border-box;
}

.reaction-pad-waiting {
  background: #374151; /* Dark Grey/Blue */
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.reaction-pad-waiting:hover {
  background: #4b5563;
}

.reaction-pad-click {
  background: var(--success);
  color: #fff;
  animation: pulseGreen 1s infinite alternate;
}

@keyframes pulseGreen {
  from { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
  to { box-shadow: 0 0 20px 10px rgba(16, 185, 129, 0.6); }
}

.reaction-pad-early {
  background: var(--danger);
  color: #fff;
}

.reaction-pad-title {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
  letter-spacing: -0.02em;
}

.reaction-pad-icon {
  width: 64px;
  height: 64px;
  margin-bottom: 1rem;
  fill: currentColor;
}
