/**
 * WPMType - Modern High-Performance Stylesheet
 * Pure Clean Light Theme, fluid responsive typography, zero-dependency.
 */

:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --text: #0f172a;
  --text-muted: #475569;
  --border: #e2e8f0;
  --accent: #0284c7;
  --accent-2: #2563eb;

  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --bg-elevated: #f1f5f9;
  
  --border-subtle: #e2e8f0;
  --border-hover: rgba(2, 132, 199, 0.4);
  --border-active: #0284c7;

  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-dim: #94a3b8;

  --accent-cyan: #0284c7;
  --accent-cyan-glow: rgba(2, 132, 199, 0.15);
  --accent-blue: #2563eb;
  --accent-emerald: #059669;
  --accent-emerald-glow: rgba(5, 150, 105, 0.15);
  --accent-red: #dc2626;
  --accent-red-glow: rgba(220, 38, 38, 0.15);
  --accent-amber: #d97706;

  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Inter", "Helvetica Neue", sans-serif;
  --font-mono: "JetBrains Mono", "Cascadia Code", "Fira Code", "Roboto Mono", Consolas, monospace;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.08);
  --shadow-glow: 0 0 20px rgba(2, 132, 199, 0.12);

  --max-width: 1240px;
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;

  --input-bg: #ffffff;
  --input-text: #0f172a;
  --input-border: #cbd5e1;
  --input-border-focus: #0284c7;
  --input-placeholder: #64748b;
  color-scheme: light;
}

[data-theme="light"],
:root {
  color-scheme: light;
}

.site-header {
  background: #ffffff !important;
  border-bottom: 1px solid var(--border-subtle);
}

.btn-primary {
  background: var(--accent-cyan);
  color: #ffffff;
}

.btn-primary:hover {
  background: #0369a1;
  color: #ffffff;
}

/* Reset & Box Sizing */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-sans);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Accessibility: focus ring */
:focus-visible {
  outline: 2px solid var(--accent-cyan);
  outline-offset: 3px;
}

a {
  color: var(--accent-cyan);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: #67e8f9;
}

img, svg {
  display: block;
  max-width: 100%;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

/* Global Form Input Architecture */
input[type="text"],
input[type="email"],
input[type="number"],
input[type="password"],
input[type="search"],
textarea,
select,
.form-input,
.calc-input {
  background-color: var(--input-bg);
  color: var(--input-text);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  font-family: inherit;
  font-size: 1rem;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background-color var(--transition-fast), color var(--transition-fast);
}

.calc-input {
  width: 100%;
  font-family: var(--font-mono);
  font-size: 1.2rem;
  font-weight: 700 !important;
  color: #0f172a !important;
  background-color: #ffffff !important;
  border: 1.5px solid #cbd5e1 !important;
}

input::placeholder,
textarea::placeholder {
  color: var(--input-placeholder);
  opacity: 1;
}

input:focus,
textarea:focus,
select:focus,
.form-input:focus,
.calc-input:focus {
  border-color: var(--input-border-focus);
  box-shadow: 0 0 0 3px rgba(0, 240, 255, 0.15);
}

[data-theme="light"] input:focus,
[data-theme="light"] textarea:focus,
[data-theme="light"] select:focus,
[data-theme="light"] .form-input:focus,
[data-theme="light"] .calc-input:focus {
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

/* Result Modal Notice States */
.result-leaderboard-notice.success {
  background: rgba(16, 185, 129, 0.15);
  border-color: rgba(16, 185, 129, 0.4);
  color: #10b981;
}

[data-theme="light"] .result-leaderboard-notice.success {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.35);
  color: #065f46;
}

.result-leaderboard-notice.error {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.4);
  color: #ef4444;
}

[data-theme="light"] .result-leaderboard-notice.error {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.35);
  color: #b91c1c;
}

/* Layout Utilities */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin-left: auto;
  margin-right: auto;
  padding-left: 1.5rem;
  padding-right: 1.5rem;
}

.site-main {
  flex: 1;
  padding-top: 2rem;
  padding-bottom: 4rem;
}

/* ===================================================
   NAVIGATION / HEADER
   =================================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #ffffff !important;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid #e2e8f0 !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  transition: border-color var(--transition-normal);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 72px;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
}

.brand-logo-img {
  display: block;
  height: 38px;
  width: auto;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 1.75rem;
}

.nav-link {
  color: #334155 !important;
  font-weight: 500;
  font-size: 0.95rem;
  transition: color var(--transition-fast);
  position: relative;
  padding: 0.35rem 0;
  text-decoration: none;
}

.nav-link:hover {
  color: #0284c7 !important;
}

.nav-link.active {
  color: #0284c7 !important;
  font-weight: 600;
}

.nav-link.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 100%;
  height: 2px;
  background: #0284c7;
  border-radius: var(--radius-full);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Language selector dropdown in header */
.lang-selector-wrap {
  position: relative;
}

.lang-select-btn {
  background: #ffffff !important;
  border: 1px solid #cbd5e1 !important;
  color: #1e293b !important;
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  max-width: 220px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.lang-select-btn:hover {
  background: #f8fafc !important;
  color: #0284c7 !important;
  border-color: #0284c7 !important;
}

.lang-flag {
  flex-shrink: 0;
  font-size: 1.15rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.lang-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lang-chevron {
  flex-shrink: 0;
  transition: transform var(--transition-fast);
}

.lang-selector-wrap.open .lang-chevron {
  transform: rotate(180deg);
}

.lang-dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  width: 290px;
  max-width: 90vw;
  padding: 0.5rem 0 0.25rem 0;
  display: none;
  z-index: 101;
  overflow: hidden;
}

.lang-dropdown-menu.show {
  display: block;
}

.lang-search-box {
  padding: 0.35rem 0.75rem 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
}

.lang-search-input {
  width: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.75rem;
  font-size: 0.825rem;
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition-fast);
}

.lang-search-input:focus {
  border-color: var(--accent-cyan);
}

.lang-list-scroll {
  max-height: 320px;
  overflow-y: auto;
  padding: 0.35rem 0;
  overscroll-behavior: contain;
}

.lang-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 1rem;
  color: var(--text-secondary);
  font-size: 0.85rem;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
  text-decoration: none;
}

.lang-item:hover,
.lang-item.active {
  background: var(--bg-elevated);
  color: var(--accent-cyan);
}

.lang-names {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.lang-native {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.85rem;
  line-height: 1.2;
}

.lang-english {
  font-size: 0.75rem;
  color: var(--text-muted);
}


/* Mobile Toggle */
.mobile-nav-toggle {
  display: none;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.5rem;
}

/* ===================================================
   HERO SECTION
   =================================================== */
.hero-section {
  text-align: center;
  padding: 2.5rem 0 2rem 0;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(2, 132, 199, 0.08);
  border: 1px solid rgba(2, 132, 199, 0.2);
  color: var(--accent-cyan);
  padding: 0.35rem 1rem;
  border-radius: var(--radius-full);
  font-size: 0.825rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  margin-bottom: 1.25rem;
  text-transform: uppercase;
}

.hero-title {
  font-size: clamp(2rem, 5vw, 3.25rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin-bottom: 1rem;
  color: var(--text-primary);
}

.hero-title .gradient-text {
  background: linear-gradient(135deg, #0284c7 0%, #2563eb 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-subtitle {
  font-size: 1.15rem;
  color: var(--text-secondary);
  max-width: 680px;
  margin: 0 auto 2rem auto;
  line-height: 1.6;
}

/* Hero Action CTAs */
.hero-cta-group {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  flex-wrap: wrap;
  margin: 2.25rem 0 3rem 0;
}

.btn-hero-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  font-size: 1.15rem;
  font-weight: 700;
  padding: 0.95rem 2.25rem;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, #0284c7 0%, #2563eb 100%);
  color: #ffffff !important;
  border: none;
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.25);
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
}

.btn-hero-primary:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 8px 24px rgba(2, 132, 199, 0.35);
  color: #ffffff !important;
}

.btn-hero-secondary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.05rem;
  font-weight: 600;
  padding: 0.9rem 1.75rem;
  border-radius: var(--radius-full);
  background: var(--bg-card);
  color: var(--text-primary) !important;
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn-hero-secondary:hover {
  background: var(--bg-elevated);
  border-color: var(--accent-cyan);
  transform: translateY(-2px);
  color: var(--text-primary) !important;
}

/* Trust / Feature Strip */
.trust-strip-container {
  margin: 2.5rem 0 4.5rem 0;
  padding: 1.75rem 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
}

.trust-strip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1.75rem;
  align-items: center;
}

.trust-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  text-align: left;
}

.trust-icon {
  font-size: 1.75rem;
  line-height: 1;
  flex-shrink: 0;
}

.trust-label {
  font-size: 0.925rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.15rem;
}

.trust-desc {
  font-size: 0.775rem;
  color: var(--text-muted);
}

/* How It Works 3-Step Section */
.how-it-works-section {
  margin: 4.5rem 0;
  text-align: center;
}

.how-it-works-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 2rem;
  margin-top: 2.5rem;
  text-align: left;
}

.how-step-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 2.25rem 2rem;
  transition: transform var(--transition-normal), border-color var(--transition-normal), box-shadow var(--transition-normal);
}

.how-step-card:hover {
  transform: translateY(-4px);
  border-color: rgba(0, 240, 255, 0.4);
  box-shadow: 0 8px 24px rgba(0, 240, 255, 0.08);
}

.how-step-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.15) 0%, rgba(59, 130, 246, 0.15) 100%);
  border: 1px solid rgba(0, 240, 255, 0.3);
  color: var(--accent-cyan);
  font-weight: 800;
  font-size: 1.15rem;
  margin-bottom: 1.25rem;
}

.how-step-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.65rem;
}

.how-step-desc {
  font-size: 0.925rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* ===================================================
   FEATURE & BENCHMARK CARDS
   =================================================== */
.section-title {
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.75rem;
  color: var(--text-primary);
}

.section-subtitle {
  color: var(--text-secondary);
  font-size: 1rem;
  margin-bottom: 2rem;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin: 3.5rem 0;
}

.feature-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 2rem;
  transition: transform var(--transition-normal), border-color var(--transition-normal), box-shadow var(--transition-normal);
}

.feature-card:hover {
  transform: translateY(-4px);
  border-color: var(--border-hover);
  box-shadow: var(--shadow-md);
}

.feature-icon-wrap {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: rgba(0, 240, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-cyan);
  margin-bottom: 1.25rem;
  font-size: 1.35rem;
}

.feature-card h3 {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 0.65rem;
  color: var(--text-primary);
}

.feature-card p {
  color: var(--text-secondary);
  font-size: 0.925rem;
  line-height: 1.55;
}

/* Certificate Tiers Grid */
.tier-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin: 2.5rem 0;
}

.tier-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  text-align: center;
  position: relative;
  overflow: hidden;
  transition: transform var(--transition-fast);
}

.tier-card:hover {
  transform: translateY(-3px);
}

.tier-badge {
  font-size: 2rem;
  margin-bottom: 0.75rem;
}

.tier-title {
  font-weight: 700;
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
}

.tier-speed {
  font-family: var(--font-mono);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent-cyan);
  margin-bottom: 0.35rem;
}

.tier-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* FAQ Accordion */
.faq-section {
  max-width: 860px;
  margin: 4rem auto 2rem auto;
}

.faq-item {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  margin-bottom: 1rem;
  overflow: hidden;
  transition: border-color var(--transition-fast);
}

.faq-item:hover {
  border-color: var(--border-hover);
}

.faq-question {
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  padding: 1.25rem 1.5rem;
  color: var(--text-primary);
  font-weight: 600;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}

.faq-chevron {
  transition: transform var(--transition-normal);
  font-size: 0.9rem;
  color: var(--accent-cyan);
}

.faq-item.active .faq-chevron {
  transform: rotate(180deg);
}

.faq-answer {
  padding: 0 1.5rem 1.25rem 1.5rem;
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.6;
  display: none;
}

.faq-item.active .faq-answer {
  display: block;
}

/* ===================================================
   FOOTER
   =================================================== */
.site-footer {
  background: #f8fafc !important;
  border-top: 1px solid #e2e8f0 !important;
  padding: 4rem 0 2rem 0;
  margin-top: auto;
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr repeat(3, 1fr);
  gap: 3rem;
  margin-bottom: 3rem;
}

.footer-brand p {
  color: #475569;
  font-size: 0.9rem;
  margin-top: 1rem;
  max-width: 320px;
}

.footer-col h4 {
  color: #0f172a;
  font-size: 0.95rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 1.25rem;
}

.footer-links {
  list-style: none;
}

.footer-links li {
  margin-bottom: 0.75rem;
}

.footer-links a {
  color: #475569;
  font-size: 0.9rem;
  transition: color var(--transition-fast);
}

.footer-links a:hover {
  color: #0284c7;
}

.footer-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 2rem;
  border-top: 1px solid #e2e8f0;
  font-size: 0.85rem;
  color: #64748b;
  flex-wrap: wrap;
  gap: 1rem;
}

.footer-badge-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.badge-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--accent-emerald);
  box-shadow: 0 0 8px var(--accent-emerald);
}

/* Generic Button Styles */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.4rem;
  font-weight: 600;
  font-size: 0.95rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
}

.btn-primary {
  background: #0284c7;
  color: #ffffff !important;
  font-weight: 600;
}

.btn-primary:hover {
  background: #0369a1;
  color: #ffffff !important;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.25);
}

.btn-secondary {
  background: #ffffff;
  border-color: #cbd5e1;
  color: #0f172a;
  font-weight: 600;
}

.btn-secondary:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
  color: #0f172a;
}

/* Alert / Flash Boxes */
.alert {
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.alert-success {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
}

.alert-danger {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}

.alert-info {
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  color: #075985;
}

/* ===================================================
   RESPONSIVE DESIGN (320px, 375px, 768px, 1024px)
   =================================================== */
@media (max-width: 900px) {
  .footer-grid {
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
  }
}

@media (max-width: 768px) {
  .header-inner {
    height: 64px;
  }

  .mobile-nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: var(--radius-sm);
    color: #0f172a;
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.45rem 0.65rem;
    transition: all var(--transition-fast);
  }

  .mobile-nav-toggle:hover {
    background: #f8fafc;
    border-color: #0284c7;
    color: #0284c7;
  }

  .main-nav {
    position: fixed;
    top: 64px;
    left: 0;
    right: 0;
    background: #ffffff !important;
    border-bottom: 1px solid #e2e8f0 !important;
    padding: 1.5rem;
    flex-direction: column;
    align-items: flex-start;
    gap: 1.25rem;
    display: none;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08);
  }

  .main-nav.show {
    display: flex;
  }

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

@media (max-width: 480px) {
  .container {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .hero-section {
    padding: 1.5rem 0 1rem 0;
  }

  .hero-title {
    font-size: 1.85rem;
  }
}

/* ===================================================
   TYPING TEST LAYOUT & OPTIONAL SIDEBAR
   =================================================== */
.typing-layout-wrapper {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 2rem;
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
}

.typing-main-col {
  flex: 1;
  min-width: 0;
  max-width: 1040px;
}

.typing-sidebar-col {
  width: 300px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

@media (max-width: 1080px) {
  .typing-layout-wrapper {
    flex-direction: column;
    align-items: center;
  }
  .typing-sidebar-col {
    width: 100%;
    max-width: 728px;
    margin-top: 1.5rem;
  }
}

/* ===================================================
   LEADERBOARD FULL SYSTEM STYLING
   =================================================== */
.leaderboard-filters-bar {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-sm);
}

.leaderboard-filters-form {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.filter-controls-grid {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
  flex: 1;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 140px;
}

.filter-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.filter-select {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.85rem;
  font-size: 0.875rem;
  color: var(--text-primary);
  outline: none;
  cursor: pointer;
  transition: border-color var(--transition-fast);
}

.filter-select:focus {
  border-color: var(--accent-cyan);
}

.leaderboard-table-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  margin-bottom: 2rem;
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.leaderboard-table th {
  background: var(--bg-secondary);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
}

.leaderboard-table td {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.95rem;
  vertical-align: middle;
}

.leaderboard-table tbody tr:last-child td {
  border-bottom: none;
}

.leaderboard-row {
  transition: background var(--transition-fast);
}

.leaderboard-row:hover {
  background: var(--bg-card-hover) !important;
}

/* Fixed Width Rank & Trophy Column: Zero Overlap Guaranteed */
.leaderboard-table th:first-child,
.leaderboard-table td.rank-cell {
  width: 100px;
  min-width: 100px;
  max-width: 100px;
  text-align: center;
  padding-left: 0.75rem;
  padding-right: 0.75rem;
}

.rank-badge-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-weight: 700;
  white-space: nowrap;
}

.trophy-symbol {
  font-size: 1.2rem;
  line-height: 1;
  display: inline-block;
  flex-shrink: 0;
}

.rank-number {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-muted);
}

.rank-number.top-three {
  font-weight: 800;
}

/* Top 3 Distinct Styling */
.rank-top-gold {
  background: rgba(245, 158, 11, 0.05);
}

.rank-top-gold .rank-number {
  color: #f59e0b;
}

.rank-top-silver {
  background: rgba(148, 163, 184, 0.04);
}

.rank-top-silver .rank-number {
  color: #94a3b8;
}

.rank-top-bronze {
  background: rgba(217, 119, 6, 0.04);
}

.rank-top-bronze .rank-number {
  color: #d97706;
}

/* Legacy rank badges */
.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  font-weight: 700;
  font-size: 0.825rem;
  line-height: 1;
}

.rank-badge-gold {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #000;
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.4);
}

.rank-badge-silver {
  background: linear-gradient(135deg, #94a3b8, #64748b);
  color: #fff;
}

.rank-badge-bronze {
  background: linear-gradient(135deg, #b45309, #78350f);
  color: #fff;
}

.rank-badge-normal {
  background: var(--bg-secondary);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
}

/* Typist Name */
.typist-cell {
  font-weight: 600;
  color: var(--text-primary);
}

.typist-display-name {
  display: inline-block;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}

/* WPM Score */
.wpm-cell {
  white-space: nowrap;
}

.wpm-number {
  font-family: var(--font-mono);
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--accent-cyan);
}

.wpm-unit {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-left: 0.2rem;
}

/* Accuracy & Error count */
.acc-cell, .err-cell {
  font-family: var(--font-mono);
  white-space: nowrap;
}

.acc-number {
  font-weight: 700;
  color: var(--accent-emerald);
}

.err-number.zero-errors {
  color: var(--text-muted);
}

.err-number.has-errors {
  color: var(--accent-red);
  font-weight: 700;
}

/* Meta Pills (Lang, Difficulty) */
.meta-pill {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-full);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.03em;
}

/* Mobile Card View */
.leaderboard-mobile-view {
  display: none;
  flex-direction: column;
  gap: 0.85rem;
  margin-bottom: 2rem;
}

.mobile-lb-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1rem 1.15rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.mobile-lb-row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.mobile-lb-rank-wrap {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 50px;
}

.mobile-lb-name {
  flex: 1;
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mobile-lb-wpm {
  font-family: var(--font-mono);
  color: var(--accent-cyan);
  font-size: 1.15rem;
  text-align: right;
  white-space: nowrap;
}

.mobile-lb-wpm small {
  font-size: 0.725rem;
  color: var(--text-muted);
}

.mobile-lb-row-bottom {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
  flex-wrap: wrap;
  border-top: 1px solid var(--border-subtle);
  padding-top: 0.5rem;
}

.mobile-lb-stat {
  font-family: var(--font-mono);
}

.mobile-lb-stat.err {
  color: var(--accent-red);
}

.mobile-lb-tag {
  color: var(--text-muted);
  margin-left: auto;
  font-size: 0.75rem;
}

.mobile-lb-empty {
  text-align: center;
  padding: 3rem 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
}

/* Pagination Controls */
.pagination-wrapper {
  display: flex;
  justify-content: center;
  margin: 2.5rem 0 3rem 0;
}

.pagination-nav {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  justify-content: center;
}

.page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  height: 38px;
  padding: 0 0.75rem;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  transition: all var(--transition-fast);
}

.page-link:hover:not(.disabled) {
  background: var(--bg-card-hover);
  color: var(--accent-cyan);
  border-color: var(--border-hover);
}

.page-link.active {
  background: var(--accent-cyan);
  color: #0b0f17;
  border-color: var(--accent-cyan);
  box-shadow: 0 0 12px var(--accent-cyan-glow);
}

.page-link.disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* Responsive Table vs Mobile Cards */
@media (max-width: 768px) {
  .leaderboard-desktop-view {
    display: none !important;
  }

  .leaderboard-mobile-view {
    display: flex !important;
  }

  .leaderboard-filters-form {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-controls-grid {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-group {
    width: 100%;
  }

  .filter-actions-wrap .btn {
    width: 100%;
    justify-content: center;
  }
}

/* ===================================================
   LIGHT MODE CONTRAST PASS - SITEWIDE
   =================================================== */
[data-theme="light"] .hero-title {
  color: #0f172a;
}

[data-theme="light"] .hero-badge {
  background: rgba(2, 132, 199, 0.08);
  border-color: rgba(2, 132, 199, 0.25);
  color: #0284c7;
}

[data-theme="light"] .card,
[data-theme="light"] .feature-card,
[data-theme="light"] .faq-item,
[data-theme="light"] .leaderboard-table-card,
[data-theme="light"] .mobile-lb-card {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.08);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .faq-question {
  color: #0f172a;
}

[data-theme="light"] .faq-answer {
  color: #334155;
}

[data-theme="light"] .section-title {
  color: #0f172a;
}

[data-theme="light"] .section-subtitle {
  color: #475569;
}

[data-theme="light"] .site-footer {
  background: #f1f5f9;
  border-top-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .footer-col h4 {
  color: #0f172a;
}

[data-theme="light"] .footer-links a {
  color: #475569;
}

[data-theme="light"] .footer-links a:hover {
  color: #0284c7;
}

[data-theme="light"] .footer-brand p {
  color: #475569;
}

[data-theme="light"] .footer-bottom {
  border-top-color: rgba(0, 0, 0, 0.08);
  color: #64748b;
}

[data-theme="light"] .nav-link {
  color: #334155;
}

[data-theme="light"] .nav-link:hover,
[data-theme="light"] .nav-link.active {
  color: #0284c7;
}

[data-theme="light"] .lang-select-btn {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.1);
  color: #334155;
}

[data-theme="light"] .lang-select-btn:hover {
  background: #f8fafc;
  color: #0f172a;
  border-color: rgba(2, 132, 199, 0.4);
}

[data-theme="light"] .lang-dropdown-menu {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.1);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12);
}

[data-theme="light"] .lang-search-input {
  background: #f1f5f9;
  border-color: rgba(0, 0, 0, 0.1);
  color: #0f172a;
}

[data-theme="light"] .lang-item {
  color: #334155;
}

[data-theme="light"] .lang-item:hover,
[data-theme="light"] .lang-item.active {
  background: #e0f2fe;
  color: #0284c7;
}

[data-theme="light"] .lang-native {
  color: #0f172a;
}


[data-theme="light"] .leaderboard-table th {
  background: #f8fafc;
  color: #475569;
  border-bottom-color: #e2e8f0;
}

[data-theme="light"] .leaderboard-table td {
  border-bottom-color: #f1f5f9;
  color: #1e293b;
}

[data-theme="light"] .leaderboard-row:hover {
  background: #f8fafc !important;
}

[data-theme="light"] .filter-select {
  background: #ffffff;
  border-color: #cbd5e1;
  color: #0f172a;
}

[data-theme="light"] .meta-pill {
  background: #e2e8f0;
  color: #334155;
}

[data-theme="light"] .page-link {
  background: #ffffff;
  border-color: #cbd5e1;
  color: #475569;
}

[data-theme="light"] .page-link:hover:not(.disabled) {
  background: #f8fafc;
  color: #0284c7;
  border-color: #0284c7;
}

[data-theme="light"] .page-link.active {
  background: #0284c7;
  color: #ffffff;
  border-color: #0284c7;
}

[data-theme="light"] .page-link.disabled {
  background: #f1f5f9;
  color: #94a3b8;
  border-color: #e2e8f0;
}

[data-theme="light"] .rank-badge-normal {
  background: #f1f5f9;
  color: #475569;
  border-color: #cbd5e1;
}

[data-theme="light"] .wpm-number {
  color: #0284c7;
}

[data-theme="light"] .mobile-lb-wpm {
  color: #0284c7;
}

[data-theme="light"] .mobile-lb-row-bottom {
  border-top-color: #f1f5f9;
  color: #475569;
}

/* ===================================================
   RTL SUPPORT (Arabic, Hebrew, Persian)
   =================================================== */
[dir="rtl"] {
  text-align: right;
}

[dir="rtl"] .main-nav {
  direction: rtl;
}

[dir="rtl"] .lang-dropdown-menu {
  right: auto;
  left: 0;
}

[dir="rtl"] .lang-select-btn {
  flex-direction: row-reverse;
}

/* ===================================================
   TYPING TEST CONTROLS & FONT SELECTOR
   =================================================== */
.test-controls-bar {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 0.65rem 1.25rem;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  box-shadow: var(--shadow-sm);
  position: relative;
  z-index: 40;
  overflow: visible;
}

.control-group {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.font-control-group {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.font-select-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.font-select-btn {
  appearance: none;
  -webkit-appearance: none;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-full);
  font-size: 0.825rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  cursor: pointer;
  outline: none;
  line-height: 1.2;
  transition: all var(--transition-fast);
}

.font-select-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--border-hover);
}

.font-select-btn.open,
.font-select-btn[aria-expanded="true"] {
  border-color: var(--accent-cyan);
  color: var(--text-primary);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.15);
}

.font-btn-chevron {
  transition: transform var(--transition-fast);
  color: var(--text-muted);
  flex-shrink: 0;
}

.font-select-btn.open .font-btn-chevron,
.font-select-btn[aria-expanded="true"] .font-btn-chevron {
  transform: rotate(180deg);
  color: var(--accent-cyan);
}

.font-dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
  min-width: 220px;
  max-width: 300px;
  max-height: 280px;
  overflow-y: auto;
  padding: 0.35rem;
  display: none;
  z-index: 250;
}

.font-dropdown-menu.show {
  display: block !important;
}

.font-option-item {
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: background var(--transition-fast);
  margin-bottom: 2px;
}

.font-option-item:hover,
.font-option-item.active {
  background: var(--bg-elevated);
}

.font-option-item.active .font-option-name {
  color: var(--accent-cyan);
}

.font-option-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
}

.font-option-preview {
  font-size: 0.775rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

[data-theme="light"] .font-select-btn {
  background: #f8fafc;
  border-color: rgba(0, 0, 0, 0.12);
  color: #334155;
}

[data-theme="light"] .font-select-btn:hover {
  background: #ffffff;
  border-color: rgba(2, 132, 199, 0.4);
  color: #0f172a;
}

[data-theme="light"] .font-select-btn.open,
[data-theme="light"] .font-select-btn[aria-expanded="true"] {
  border-color: #0284c7;
  color: #0284c7;
  box-shadow: 0 0 10px rgba(2, 132, 199, 0.15);
}

[data-theme="light"] .font-dropdown-menu {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.12);
  color: #0f172a;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12);
}

[data-theme="light"] .font-option-item:hover,
[data-theme="light"] .font-option-item.active {
  background: #f1f5f9;
}

[data-theme="light"] .font-option-item.active .font-option-name {
  color: #0284c7;
}

[data-theme="light"] .font-option-name {
  color: #0f172a;
}

[data-theme="light"] .font-option-preview {
  color: #64748b;
}

@media (max-width: 768px) {
  .test-controls-bar {
    flex-direction: column;
    align-items: stretch;
    padding: 0.85rem 1rem;
    gap: 0.75rem;
  }

  .ctrl-divider {
    display: none;
  }

  .control-group {
    width: 100%;
    margin-bottom: 0;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem;
  }

  .font-control-group {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-start;
  }

  .font-dropdown-menu {
    left: 0;
    right: auto;
    width: 100%;
    max-width: 100%;
  }
}

@media (max-width: 480px) {
  .test-controls-bar {
    padding: 0.75rem 0.85rem;
    gap: 0.65rem;
  }

  .ctrl-btn {
    padding: 0.25rem 0.55rem;
    font-size: 0.775rem;
  }

  .control-label {
    font-size: 0.7rem;
    min-width: 65px;
  }

  .font-select-btn {
    padding: 0.3rem 0.7rem;
    font-size: 0.775rem;
    max-width: 100%;
  }

  .font-select-wrap {
    max-width: calc(100% - 75px);
  }
}
