/**
 * ============================================
 * REACTION SPEED TEST - LIGHT THEME
 * ============================================
 * 
 * Clean, calming light design for low cognitive load
 * Warm and inviting with soft shadows
 */

/* ============================================
   1. CSS VARIABLES
   ============================================ */
:root {
  /* Light Theme Core */
  --color-bg: #fafafa;
  --color-bg-warm: #fef7ed;
  /* Warm cream */
  --color-bg-card: #ffffff;
  --color-bg-subtle: #f5f5f5;

  /* Text Colors */
  --color-text: #1f2937;
  /* Dark gray, not pure black */
  --color-text-muted: #6b7280;
  --color-text-subtle: #9ca3af;

  /* Accent Colors - Warm & Friendly */
  --color-primary: #10b981;
  /* Emerald green */
  --color-primary-light: #d1fae5;
  --color-secondary: #8b5cf6;
  /* Purple */
  --color-accent: #f59e0b;
  /* Amber */

  /* State Colors */
  --color-waiting: #ef4444;
  /* Red */
  --color-waiting-text: #ffffff;
  --color-ready: #22c55e;
  /* Green */
  --color-ready-text: #ffffff;
  --color-early: #dc2626;

  /* Shadows - Soft & Subtle */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 10px 10px -5px rgba(0, 0, 0, 0.03);

  /* Ranking Colors */
  --rank-god: #ec4899;
  --rank-superhuman: #06b6d4;
  --rank-elite: #f59e0b;
  --rank-above: #10b981;
  --rank-average: #3b82f6;
  --rank-below: #f97316;
  --rank-slow: #ef4444;

  /* Typography - Nunito: Warm, Rounded, Inviting */
  --font-main: 'Nunito', system-ui, -apple-system, sans-serif;
  --font-display: 'Nunito', system-ui, -apple-system, sans-serif;

  /* Sizing */
  --stats-height: 64px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-full: 9999px;
}

/* Skip Link - Accessibility */
.skip-link {
  position: absolute;
  top: -100px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-primary);
  color: white;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-full);
  font-weight: 700;
  text-decoration: none;
  z-index: 9999;
  transition: top 0.2s ease;
}

.skip-link:focus {
  top: 1rem;
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* ============================================
   2. BASE STYLES
   ============================================ */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font-main);
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
  overflow: hidden;
  /* Optimize for smooth animations */
  -webkit-tap-highlight-color: transparent;
}

#main-content {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  position: relative;
  padding-bottom: 80px;
  /* Space for fixed stats bar */
}

/* ============================================
   3. AMBIENT BACKGROUND - Subtle & Calming
   ============================================ */
.ambient-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
  background: linear-gradient(135deg, var(--color-bg) 0%, var(--color-bg-warm) 50%, var(--color-bg) 100%);
}

.ambient-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.3;
  animation: float 25s ease-in-out infinite;
}

.ambient-orb--1 {
  width: 500px;
  height: 500px;
  background: var(--color-primary-light);
  top: -150px;
  right: -150px;
}

.ambient-orb--2 {
  width: 400px;
  height: 400px;
  background: #fef3c7;
  /* Warm amber tint */
  bottom: -100px;
  left: -100px;
  animation-delay: -8s;
}

.ambient-orb--3 {
  width: 300px;
  height: 300px;
  background: #ede9fe;
  /* Soft purple tint */
  top: 40%;
  left: 40%;
  animation-delay: -16s;
  opacity: 0.2;
}

@keyframes float {

  0%,
  100% {
    transform: translate(0, 0) scale(1);
  }

  33% {
    transform: translate(20px, -20px) scale(1.02);
  }

  66% {
    transform: translate(-15px, 15px) scale(0.98);
  }
}

/* ============================================
   4. HERO TEST AREA
   ============================================ */
.hero-test {
  flex: 1;
  display: flex;
  position: relative;
  z-index: 1;
}

.test-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  contain: layout style paint;
  will-change: background-color;
  touch-action: manipulation;
}

.test-area:focus {
  outline: none;
}

.test-content {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1.5rem;
  width: 100%;
  max-width: 400px;
}

/* ============================================
   5. IDLE STATE - Simple Full-Screen
   ============================================ */
.test-area--idle {
  background: transparent;
  /* Transition removed for optimal first-click performance (1-2ms gain) */
}

.test-area--idle:hover {
  background: rgba(16, 185, 129, 0.03);
}

.test-area--idle .test-content--idle {
  display: flex;
  animation: fadeIn 0.5s ease;
  max-width: none;
}

.idle-content {
  text-align: center;
}

.idle-emoji {
  font-size: 5rem;
  margin-bottom: 1.5rem;
  animation: float-gentle 4s ease-in-out infinite, pulse-glow 2s ease-in-out infinite;
}

@keyframes float-gentle {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-8px);
  }
}

@keyframes pulse-glow {

  0%,
  100% {
    filter: drop-shadow(0 0 0 transparent);
    transform: scale(1);
  }

  50% {
    filter: drop-shadow(0 0 20px rgba(16, 185, 129, 0.6));
    transform: scale(1.05);
  }
}

.idle-title {
  font-family: var(--font-main);
  font-size: clamp(2.5rem, 8vw, 4rem);
  font-weight: 800;
  color: var(--color-text);
  margin: 0 0 1rem;
}

.idle-subtitle {
  color: var(--color-text-muted);
  font-size: 1.25rem;
  margin: 0;
  animation: pulse-fade 2.5s ease-in-out infinite;
}

/* Ghost hint - shows only on first visit */
.ghost-hint {
  color: var(--color-primary);
  font-size: 0.9rem;
  /* Reduced from 1rem - more subtle */
  font-weight: 600;
  margin: 3rem 0 0;
  /* Increased spacing from 2rem to 3rem */
  opacity: 0;
  animation: ghostFadeIn 1s ease-out 1s forwards;
  /* One-time animation */
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(16, 185, 129, 0.05));
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-full);
  border: 1px solid rgba(16, 185, 129, 0.2);
  display: inline-block;
  pointer-events: none;
  /* Don't block clicks */
}

.ghost-hint.hidden {
  display: none;
}

@keyframes ghostFadeIn {
  0% {
    opacity: 0;
    transform: translateY(10px);
  }

  100% {
    opacity: 0.85;
    /* Reduced from 1 - subtle, tooltip-like */
    transform: translateY(0);
  }
}

/* Subtle pulsing fade animation */
@keyframes pulse-fade {

  0%,
  100% {
    opacity: 0.5;
  }

  50% {
    opacity: 1;
  }
}

/* ============================================
   6. WAITING STATE (RED)
   ============================================ */
.test-area--waiting {
  background: var(--color-waiting);
}

.test-area--waiting .test-content--waiting {
  display: flex;
  animation: fadeIn 0.15s ease;
}

.waiting-content {
  color: var(--color-waiting-text);
}

.waiting-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
  animation: wiggle 0.6s ease-in-out infinite;
}

@keyframes wiggle {

  0%,
  100% {
    transform: rotate(-2deg);
  }

  50% {
    transform: rotate(2deg);
  }
}

.waiting-text {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 5vw, 2.25rem);
  font-weight: 700;
  margin-bottom: 1rem;
}

.waiting-progress {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  margin-bottom: 1.5rem;
}

.progress-dot {
  width: 8px;
  height: 8px;
  background: rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  animation: dotPulse 1.4s ease-in-out infinite;
}

.progress-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.progress-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes dotPulse {

  0%,
  100% {
    opacity: 0.4;
    transform: scale(1);
  }

  50% {
    opacity: 1;
    transform: scale(1.3);
  }
}

.attempt-badge {
  display: inline-block;
  padding: 0.5rem 1rem;
  background: rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-full);
  font-size: 0.9rem;
  font-weight: 500;
}

/* ============================================
   7. READY STATE (GREEN) - Instant, Clean
   ============================================ */
.test-area--ready {
  background: var(--color-ready);
}

.test-area--ready .test-content--ready {
  display: flex;
}

.ready-content {
  color: var(--color-ready-text);
}

.ready-icon {
  font-size: 4.5rem;
  margin-bottom: 0.5rem;
}

.ready-text {
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 10vw, 4.5rem);
  font-weight: 900;
  letter-spacing: 0.05em;
}

/* ============================================
   8. RESULT STATE
   ============================================ */
.test-area--result {
  background: transparent;
}

.test-area--result .test-content--result {
  display: flex;
  animation: fadeUp 0.3s ease;
}

.result-card {
  background: var(--color-bg-card);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: var(--radius-xl);
  padding: 2rem;
  width: 100%;
  box-shadow: var(--shadow-xl);
}

.result-emoji {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
  animation: bounce 0.5s ease;
}

@keyframes bounce {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-8px);
  }
}

.result-time {
  font-family: var(--font-display);
  font-size: clamp(3rem, 12vw, 4.5rem);
  font-weight: 900;
  color: var(--color-primary);
  line-height: 1;
}

.result-unit {
  font-size: 0.35em;
  color: var(--color-text-muted);
  margin-left: 0.1em;
}

.result-rating {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-primary);
  margin: 0.5rem 0 1.5rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.result-rating--incredible {
  color: var(--rank-god);
}

.result-rating--excellent {
  color: var(--rank-superhuman);
}

.result-rating--great {
  color: var(--rank-above);
}

.result-rating--good {
  color: var(--rank-average);
}

.result-rating--slow {
  color: var(--rank-below);
}

.result-progress {
  margin-bottom: 1rem;
}

.progress-bar {
  height: 6px;
  background: var(--color-bg-subtle);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-primary), var(--color-secondary));
  border-radius: inherit;
  transition: width 0.3s ease;
}

.progress-text {
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

.result-continue {
  font-size: 0.85rem;
  color: var(--color-text-subtle);
}

/* ============================================
   9. EARLY STATE
   ============================================ */
.test-area--early {
  background: var(--color-early);
}

.test-area--early .test-content--early {
  display: flex;
  animation: shake 0.4s ease;
}

.early-card {
  color: white;
}

.early-emoji {
  font-size: 4rem;
  margin-bottom: 1rem;
}

.early-title {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.early-subtitle {
  font-size: 1rem;
  opacity: 0.9;
  margin-bottom: 1.5rem;
}

.early-retry {
  font-size: 0.9rem;
  opacity: 0.7;
}

/* ============================================
   10. CALCULATING STATE
   ============================================ */
.test-area--calculating {
  background: transparent;
}

.test-area--calculating .test-content--calculating {
  display: flex;
}

.calc-content {
  text-align: center;
}

.calc-spinner {
  width: 50px;
  height: 50px;
  border: 3px solid var(--color-bg-subtle);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 1.5rem;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.calc-text {
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--color-text-muted);
}

/* ============================================
   11. FINAL RESULTS
   ============================================ */
.test-area--final {
  background: transparent;
}

.test-area--final .test-content--final {
  display: flex;
  animation: fadeUp 0.5s ease;
  max-width: 420px;
  max-height: calc(100vh - 120px);
  /* Account for stats bar + padding */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.final-card {
  background: var(--color-bg-card);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: var(--radius-xl);
  padding: 1.25rem;
  width: 100%;
  box-shadow: var(--shadow-xl);
}

.final-header {
  text-align: center;
  margin-bottom: 0.25rem;
}

.final-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--color-text-subtle);
}

.final-score {
  text-align: center;
  margin-bottom: 0.5rem;
}

.score-number {
  font-family: var(--font-display);
  font-size: clamp(3rem, 15vw, 4.5rem);
  font-weight: 900;
  color: var(--color-primary);
  line-height: 1;
}

.score-unit {
  font-size: 1.25rem;
  color: var(--color-text-muted);
  margin-left: 0.25rem;
}

/* Rank Stamp */
.rank-stamp {
  text-align: center;
  margin: 0.5rem 0;
  animation: stampIn 0.4s ease-out 0.2s both;
}

.stamp-text {
  display: inline-block;
  font-family: var(--font-display);
  font-size: clamp(1.1rem, 4vw, 1.5rem);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.5rem 1.25rem;
  border: 3px solid currentColor;
  border-radius: var(--radius-sm);
  transform: rotate(-2deg);
}

@keyframes stampIn {
  0% {
    transform: scale(2) rotate(-8deg);
    opacity: 0;
  }

  70% {
    transform: scale(0.95) rotate(-2deg);
  }

  100% {
    transform: scale(1) rotate(-2deg);
    opacity: 1;
  }
}

/* Stamp colors */
.rank-stamp--god .stamp-text {
  color: var(--rank-god);
  background: #fdf2f8;
}

.rank-stamp--superhuman .stamp-text {
  color: var(--rank-superhuman);
  background: #ecfeff;
}

.rank-stamp--elite .stamp-text {
  color: var(--rank-elite);
  background: #fffbeb;
}

.rank-stamp--above-average .stamp-text {
  color: var(--rank-above);
  background: #ecfdf5;
}

.rank-stamp--average .stamp-text {
  color: var(--rank-average);
  background: #eff6ff;
}

.rank-stamp--below-average .stamp-text {
  color: var(--rank-below);
  background: #fff7ed;
}

.rank-stamp--slow .stamp-text {
  color: var(--rank-slow);
  background: #fef2f2;
}

.rank-stamp--very-slow .stamp-text {
  color: var(--rank-slow);
  background: #fef2f2;
}

.final-message {
  text-align: center;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-bottom: 1rem;
  line-height: 1.4;
  animation: fadeIn 0.5s ease 0.4s both;
}

/* Distribution */
.distribution {
  margin-bottom: 1rem;
  animation: fadeIn 0.5s ease 0.5s both;
}

.dist-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--color-text-subtle);
  text-align: center;
  margin-bottom: 0.5rem;
}

.dist-bar {
  height: 10px;
  background: linear-gradient(90deg,
      #fce7f3 0%,
      /* God - pink tint */
      #cffafe 20%,
      /* Superhuman - cyan tint */
      #fef3c7 35%,
      /* Elite - amber tint */
      #d1fae5 50%,
      /* Above - green tint */
      #dbeafe 65%,
      /* Average - blue tint */
      #ffedd5 80%,
      /* Below - orange tint */
      #fee2e2 100%
      /* Slow - red tint */
    );
  border-radius: var(--radius-full);
  position: relative;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.dist-fill {
  display: none;
}

.dist-marker {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  transition: left 0.8s ease 0.6s;
}

.marker-label {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-text);
  color: white;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  margin-bottom: 4px;
  white-space: nowrap;
}

.dist-marker::after {
  content: '';
  display: block;
  width: 18px;
  height: 18px;
  background: white;
  border: 3px solid var(--color-text);
  border-radius: 50%;
  box-shadow: var(--shadow-md);
}

.dist-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.65rem;
  color: var(--color-text-subtle);
  margin-top: 0.4rem;
}

/* Stats Grid */
.final-stats {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
  animation: fadeIn 0.5s ease 0.7s both;
}

.stat-box {
  flex: 1;
  background: var(--color-bg-subtle);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  text-align: center;
}

.stat-box .stat-icon {
  display: block;
  font-size: 1.2rem;
  margin-bottom: 0.2rem;
}

.stat-box .stat-value {
  display: block;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-text);
}

.stat-box .stat-label {
  display: block;
  font-size: 0.6rem;
  text-transform: uppercase;
  color: var(--color-text-subtle);
  letter-spacing: 0.1em;
}

/* Attempts */
.final-attempts {
  margin-bottom: 0.75rem;
  animation: fadeIn 0.5s ease 0.8s both;
}

.attempts-title {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-subtle);
  text-align: center;
  margin-bottom: 0.5rem;
}

.attempts-row {
  display: flex;
  justify-content: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.attempt-chip {
  padding: 0.25rem 0.5rem;
  background: var(--color-bg-subtle);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-muted);
}

.attempt-chip--best {
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-weight: 700;
}

.attempt-chip--worst {
  background: #fee2e2;
  color: var(--rank-slow);
}

/* Actions */
.final-actions {
  text-align: center;
  animation: fadeIn 0.5s ease 0.9s both;
}

.btn-primary {
  background: var(--color-primary);
  color: white;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.75rem 2rem;
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.25);
  transition: transform 0.2s, box-shadow 0.2s;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.35);
}

/* ============================================
   SOCIAL SHARE BUTTONS
   ============================================ */
.share-section {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  animation: fadeIn 0.5s ease 1s both;
}

.share-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-muted);
  text-align: center;
  margin-bottom: 0.75rem;
}

.share-buttons {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.share-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  border-radius: var(--radius-full);
  transition: all 0.2s ease;
  color: white;
}

.share-btn svg {
  flex-shrink: 0;
}

.share-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.share-btn:active {
  transform: translateY(0);
}

/* X/Twitter - Black */
.share-btn--twitter {
  background: #000000;
}

.share-btn--twitter:hover {
  background: #1a1a1a;
}

/* Facebook - Blue */
.share-btn--facebook {
  background: #1877F2;
}

.share-btn--facebook:hover {
  background: #166fe5;
}

/* Discord - Blurple */
.share-btn--discord {
  background: #5865F2;
  border: none;
  cursor: pointer;
}

.share-btn--discord:hover {
  background: #4752c4;
}

/* Copy feedback message */
.copy-feedback {
  text-align: center;
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--color-success);
  min-height: 1.25rem;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.copy-feedback.show {
  opacity: 1;
}

/* Download Score Card Button */
.btn-download {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  margin-top: 1rem;
  padding: 0.75rem 1.5rem;
  background: linear-gradient(135deg, var(--color-primary) 0%, #059669 100%);
  color: white;
  border: none;
  border-radius: var(--radius-full);
  font-family: var(--font-main);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
}

.btn-download:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.45);
}

.btn-download:active {
  transform: translateY(0);
}

.btn-download svg {
  flex-shrink: 0;
}

/* ============================================
   12. STATS BAR - Bigger & More Readable
   ============================================ */
.stats-bar {
  height: 80px;
  background: var(--color-bg-card);
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 1.5rem;
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  z-index: 100;
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.04);
}

.stats-inner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  max-width: 900px;
  width: 100%;
  justify-content: center;
  flex-wrap: wrap;
}

/* Balanced layout: Back | Stats | More Tests */
.stats-inner--balanced {
  justify-content: space-between;
}

.stats-center {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Tab Buttons */
.btn-tab {
  background: var(--color-bg-subtle);
  color: var(--color-text);
  font-family: var(--font-main);
  font-size: 1rem;
  font-weight: 600;
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius-full);
  text-decoration: none;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn-tab:hover {
  background: rgba(0, 0, 0, 0.08);
}

.btn-tab--primary {
  background: var(--color-primary);
  color: white;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
  font-weight: 700;
}

.btn-tab--primary:hover {
  background: #0d9668;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

.stat-chip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  background: var(--color-bg-subtle);
  border-radius: var(--radius-full);
  font-size: 1rem;
}

.chip-icon {
  font-size: 1.1rem;
}

.chip-label {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  font-weight: 500;
}

.chip-value {
  font-weight: 700;
  color: var(--color-text);
  font-size: 1rem;
}

.btn-reset {
  background: var(--color-bg-subtle);
  border: none;
  color: var(--color-text);
  font-family: var(--font-main);
  font-size: 1rem;
  font-weight: 600;
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.2s;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.btn-reset:hover {
  background: rgba(0, 0, 0, 0.08);
  transform: translateY(-2px);
}

/* Control Group - groups Reset, Sound, More Tests together */
.controls-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
  padding-left: 1rem;
  border-left: 1px solid rgba(0, 0, 0, 0.08);
}

/* ========================
   LANGUAGE SELECTOR
   ======================== */
.lang-selector {
  position: relative;
  display: inline-block;
}

.btn-lang {
  background: var(--color-bg-subtle);
  border: none;
  border-radius: var(--radius-full);
  padding: 0.6rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 1.1rem;
  outline: none;
  min-width: 56px;
  height: auto;
}

.btn-lang:hover {
  background: rgba(0, 0, 0, 0.08);
  transform: translateY(-2px);
}

.lang-dropdown {
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  padding: 8px 0;
  min-width: 160px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: all 0.2s;
  z-index: 1000;
}

.lang-dropdown.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.lang-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  cursor: pointer;
  transition: background 0.2s;
  font-family: var(--font-main);
  font-size: 0.9rem;
  color: var(--color-text);
}

.lang-option:hover {
  background: #f3f4f6;
}

.lang-option.active {
  background: #d1fae5;
  color: #059669;
  font-weight: 700;
}

.lang-option .lang-flag {
  font-size: 18px;
  line-height: 1;
}

/* Stats separator line */
.stats-divider {
  width: 1px;
  height: 32px;
  background: rgba(0, 0, 0, 0.1);
  margin: 0 0.5rem;
}

.btn-more {
  background: var(--color-primary);
  border: none;
  color: white;
  font-family: var(--font-main);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.5rem 1.25rem;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.btn-more:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

/* Back Button - Top Left */
.btn-back {
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 100;
  background: var(--color-primary);
  color: white;
  font-family: var(--font-main);
  font-size: 1rem;
  font-weight: 600;
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius-full);
  text-decoration: none;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
  transition: all 0.2s;
}

.btn-back:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(16, 185, 129, 0.35);
}

/* ============================================
   13. ANIMATIONS
   ============================================ */
@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {

  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.05);
  }
}

@keyframes shake {

  0%,
  100% {
    transform: translateX(0);
  }

  20%,
  60% {
    transform: translateX(-6px);
  }

  40%,
  80% {
    transform: translateX(6px);
  }
}

/* ============================================
   14. RESPONSIVE
   ============================================ */

/* Tablet and small desktop */
@media (max-width: 768px) {
  .stats-bar {
    height: auto;
    min-height: 70px;
    padding: 0.75rem 1rem;
  }

  .stats-inner {
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
  }

  .controls-group {
    margin-left: 0;
    padding-left: 0;
    border-left: none;
    margin-top: 0.5rem;
    width: 100%;
    justify-content: center;
  }
}

/* Mobile phones */
@media (max-width: 480px) {

  /* Reduce title size */
  .idle-title {
    font-size: clamp(1.8rem, 6vw, 2.5rem);
  }

  /* Smaller emoji on mobile */
  .idle-emoji {
    font-size: 3.5rem;
    margin-bottom: 1rem;
  }

  /* Compact idle content */
  .idle-content {
    padding: 0 1rem;
  }

  .idle-subtitle {
    font-size: 1rem;
  }

  /* Hide idle info on mobile - too crowded */
  .idle-info {
    display: none;
  }

  /* Compact stats bar */
  .stats-bar {
    padding: 0.5rem;
  }

  .stats-inner {
    gap: 0.3rem;
  }

  .stat-chip {
    padding: 0.25rem 0.5rem;
    font-size: 0.85rem;
  }

  .chip-label {
    display: none;
  }

  .chip-icon {
    font-size: 0.9rem;
  }

  /* Controls stay centered */
  .controls-group {
    gap: 0.5rem;
    margin-top: 0.4rem;
  }

  .btn-reset,
  .btn-tab {
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
  }

  .btn-sound {
    padding: 0.3rem 0.5rem;
    font-size: 1rem;
  }

  /* Result screen mobile fixes */
  .result-time {
    font-size: 3.5rem;
  }

  .result-card {
    padding: 1.5rem 1rem;
    min-width: auto;
    width: 90%;
    max-width: 280px;
  }

  .final-card {
    padding: 1.5rem 1rem;
    min-width: auto;
    width: 90%;
    max-width: 280px;
  }

  .final-title {
    font-size: 1.5rem;
  }

  .final-time {
    font-size: 2.5rem;
  }

  /* Smaller buttons on mobile */
  .btn-primary {
    padding: 0.75rem 1.5rem;
    font-size: 0.95rem;
  }
}

/* Very small screens - iPhone SE, older devices */
@media (max-width: 360px) {
  .idle-title {
    font-size: 1.5rem;
  }

  .idle-emoji {
    font-size: 3rem;
  }

  .stat-chip {
    padding: 0.2rem 0.4rem;
    font-size: 0.75rem;
  }

  .controls-group {
    gap: 0.3rem;
  }

  .btn-reset,
  .btn-tab {
    padding: 0.4rem 0.6rem;
    font-size: 0.75rem;
  }
}

/* Short screens / Landscape mobile */
@media (max-height: 650px) {
  .idle-info {
    display: none;
  }

  .idle-emoji {
    font-size: 3rem;
    margin-bottom: 0.75rem;
  }

  .idle-title {
    font-size: clamp(1.5rem, 5vw, 2rem);
    margin-bottom: 0.5rem;
  }

  .idle-subtitle {
    font-size: 0.9rem;
  }

  .final-attempts {
    display: none;
  }

  .final-card {
    padding: 1rem;
    gap: 0.75rem;
  }

  .result-card {
    padding: 1rem;
  }
}

/* ============================================
   15. SOUND TOGGLE BUTTON
   ============================================ */
.btn-sound {
  background: var(--color-bg-subtle);
  border: none;
  font-size: 1.1rem;
  padding: 0.6rem 1rem;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.2s;
  line-height: 1;
}

.btn-sound:hover {
  background: rgba(0, 0, 0, 0.08);
  transform: translateY(-2px);
}

.btn-sound:active {
  transform: scale(0.95);
}

/* ============================================
   16. LANDSCAPE MOBILE - Compact Layout
   ============================================ */
@media (orientation: landscape) and (max-height: 500px) {
  #main-content {
    padding-bottom: 50px;
  }

  .stats-bar {
    height: 50px;
    min-height: 50px;
    padding: 0.25rem 0.75rem;
  }

  .stats-inner {
    gap: 0.3rem;
    flex-wrap: nowrap;
  }

  .stat-chip {
    padding: 0.2rem 0.5rem;
  }

  .chip-label {
    display: none;
  }

  .controls-group {
    margin-top: 0;
    width: auto;
    margin-left: auto;
    padding-left: 0.5rem;
    border-left: 1px solid rgba(0, 0, 0, 0.08);
  }

  .btn-reset,
  .btn-tab {
    padding: 0.4rem 0.6rem;
    font-size: 0.8rem;
  }

  /* Idle state compact */
  .idle-emoji {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
  }

  .idle-title {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
  }

  .idle-subtitle {
    font-size: 0.85rem;
  }

  .ghost-hint {
    display: none;
  }

  /* Result card compact */
  .result-card {
    padding: 0.75rem;
  }

  .result-emoji {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
  }

  .result-time {
    font-size: 2.5rem;
  }

  /* Final results - very compact */
  .test-content--final {
    max-height: calc(100vh - 60px);
    max-width: 90vw;
  }

  .final-card {
    padding: 0.75rem;
    max-height: calc(100vh - 70px);
    overflow-y: auto;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    align-items: start;
  }

  .final-header {
    grid-column: 1 / -1;
    margin-bottom: 0;
  }

  .final-score {
    grid-column: 1;
    margin-bottom: 0;
  }

  .rank-stamp {
    grid-column: 2;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .stamp-text {
    font-size: 0.9rem;
    padding: 0.3rem 0.6rem;
  }

  .score-number {
    font-size: 2rem;
  }

  .final-message {
    display: none;
  }

  .distribution {
    grid-column: 1 / -1;
    margin-bottom: 0.25rem;
  }

  .dist-title {
    font-size: 0.65rem;
  }

  .dist-bar {
    height: 10px;
  }

  .final-stats {
    grid-column: 1 / -1;
    gap: 0.5rem;
  }

  .stat-box {
    padding: 0.4rem;
  }

  .stat-icon {
    font-size: 1rem;
  }

  .stat-value {
    font-size: 0.9rem;
  }

  .final-attempts {
    display: none;
  }

  .final-actions {
    grid-column: 1 / -1;
  }

  .btn-primary {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
  }

  .share-section {
    display: none;
  }
}