html, body {
  width: 100vw;
  overflow-x: hidden;
  box-sizing: border-box;
}
*, *:before, *:after {
  box-sizing: inherit;
}
body {
  font-family: 'Noto Sans Sinhala', 'Roboto', -apple-system, BlinkMacSystemFont, sans-serif;
  background: linear-gradient(135deg, #f7f7fa 0%, #e0e7ef 100%);
  color: var(--text-primary);
  line-height: 1.6;
  margin: 0;
  padding: 0;
  min-height: 100vh;
  transition: all 0.3s ease;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
:root {
  --bg: #f7f7fa;
  --text: #222;
  --primary: #4f46e5;
  --secondary: #06b6d4;
  --accent: #f59e42;
  --card: #fff;
  --input-bg: #f1f5f9;
  --primary-gradient: linear-gradient(90deg, #4f8cff 0%, #38e8ff 100%);
  --primary-glow: 0 2px 16px rgba(79,140,255,0.13);
  --card-glass: rgba(255,255,255,0.85);
  --card-glass-dark: rgba(39,52,73,0.92);
  --badge-gradient: linear-gradient(90deg, #facc15 0%, #fbbf24 100%);
  --badge-shadow: 0 1px 6px rgba(251,191,36,0.13);
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-tertiary: #f1f5f9;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --border-dark: #cbd5e1;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-2xl: 1.5rem;
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.25rem;
  --font-size-2xl: 1.5rem;
  --font-size-3xl: 1.875rem;
  --font-size-4xl: 2.25rem;
}
body.dark {
  --bg: #18181b;
  --text: #f3f4f6;
  --primary: #818cf8;
  --secondary: #22d3ee;
  --accent: #fbbf24;
  --card: #23232b;
  --input-bg: #27272a;
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --border: #334155;
  --border-dark: #475569;
}
body.dark {
  background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
  color: var(--text-primary);
}
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-sm) var(--space-xl);
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  box-shadow: var(--shadow-lg);
  position: sticky;
  top: 0;
  margin-bottom: -25px;
  z-index: 100%;
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  flex-wrap: wrap;
  gap: 1rem;
}

/* Light mode specific header style */
body:not(.dark) header {
  background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
  color: #1e293b;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}
.logo-title {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  flex-wrap: wrap;
  flex: 1;
  min-width: 0;
}
.logo {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  box-shadow: var(--shadow-md);
  transition: transform 0.3s ease;
}
.logo:hover {
  transform: scale(1.07);
}
h1 {
  font-size: var(--font-size-3xl);
  font-weight: 700;
  margin: 0;
  color: var(--text-primary);
  letter-spacing: -0.025em;
}

header h1 {
  color: white;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Light mode specific header h1 style */
body:not(.dark) header h1 {
  color: #1e293b;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.5);
  font-weight: 800;
}

body.dark h1 {
  color: var(--text-primary);
}

body.dark header h1 {
  color: white;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-xl);
  display: flex;
  flex-direction: column;
  gap: var(--space-xl);
}
main.blur-background {
  filter: blur(5px);
  transition: filter 0.3s ease-out;
}
.difficulty-select {
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}
#difficulty {
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  border: 1px solid var(--primary);
  background: var(--input-bg);
  color: var(--text);
  font-size: 1rem;
}
.typing-area {
  margin-bottom: 1.5rem;
}
#sentence-display {
  font-size: 1.2rem;
  margin-bottom: 1rem;
  min-height: 2.5rem;
  background: var(--input-bg);
  padding: 1rem;
  border-radius: 0.5rem;
  margin-left: 10px;
  margin-right: 10px;
}
#typing-input {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1.1rem;
  border-radius: 0.5rem;
  border: 1px solid var(--primary);
  background: var(--input-bg);
  color: var(--text);
  margin-bottom: 0.5rem;
  margin-left: 10px;
  margin-right: 10px;
}
.feedback {
  min-height: 1.2rem;
  color: var(--accent);
  font-size: 1rem;
}
.stats {
  display: flex;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  font-size: 1.1rem;
}
/* .controls {
  display: flex;
  gap: 1rem;
  justify-content: center;
} */
/* .controls button {
  padding: 0.7rem 1.5rem;
  border-radius: 0.5rem;
  border: none;
  background: var(--primary);
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s;
} */
/* .controls button:hover {
  background: var(--secondary);
} */
footer {
  text-align: center;
  margin: 0;
  color: #888;
  display: flex;
  justify-content: center;
  align-items: center;
 
  background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-primary) 100%);
  padding: var(--space-sm);
  border-top: 1px solid var(--border);
  margin-top: auto;

}
footer a {
  color: var(--primary);
  text-decoration: none;

}

.about-page {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
}
.about-card {
  background: var(--card);
  padding: 2rem;
  border-radius: 1rem;
  box-shadow: 0 4px 24px rgba(0,0,0,0.07);
  max-width: 500px;

}
.about-card a {
  color: var(--primary);
  text-decoration: none;
  display: inline-block;
  margin-top: 1rem;
}
.leaderboard-section {
  margin-top: 2rem;
}
.leaderboard-section h2 {
  text-align: center;
  margin-bottom: 1rem;
  color: var(--primary);
}
#leaderboard {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border-radius: 0.5rem;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.03);
}
#leaderboard th, #leaderboard td {
  padding: 0.5rem 0.7rem;
  text-align: center;
}
#leaderboard th {
  background: var(--input-bg);
  color: var(--primary);
  font-weight: 700;
}
#leaderboard tr:nth-child(even) {
  background: var(--input-bg);
}
#leaderboard tr:nth-child(odd) {
  background: var(--card);
}
.custom-text-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.2rem;
}
#custom-text-input {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1.1rem;
  border-radius: 0.5rem;
  border: 1px solid var(--primary);
  background: var(--input-bg);
  color: var(--text);
  resize: vertical;
}
.timer-section {
  display: flex;
  align-items: center;
  gap: 1rem;
  justify-content: center;
  margin-bottom: 1.2rem;
}
#timer-display {
  font-size: 1.2rem;
  font-weight: bold;
  color: var(--accent);
  background: var(--input-bg);
  padding: 0.3rem 0.8rem;
  border-radius: 0.5rem;
  min-width: 70px;
  text-align: center;

}
#time-select {
  padding: 0.3rem 0.7rem;
  border-radius: 0.5rem;
  border: 1px solid var(--primary);
  background: var(--input-bg);
  color: var(--text);
  font-size: 1rem;
}
.keyboard-section {

  align-items: center;
  gap: 1rem;
  justify-content: center;
  margin-bottom: 1.2rem;
}
#keyboard-method {
  padding: 0.3rem 0.7rem;
  border-radius: 0.5rem;
  border: 1px solid var(--primary);
  background: var(--input-bg);
  color: var(--text);
  font-size: 1rem;
}
.correct-char {
  color: var(--text);
}
.mistake-char {
  color: #e11d48;
  background: #fee2e2;
  border-radius: 2px;
}
.pending-char {
  color: #a3a3a3;
}
#help-btn {
  position:fixed;
  bottom:10px;
  right:20px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #6366f1;
  color: #fff;
  font-size: 2rem;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.1s;
}
#help-btn:hover {
  background: #818cf8;
  transform: scale(1.07);
}
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.6);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-content {
  background: var(--card);
  padding: 2rem;
  border-radius: 1rem;
  max-width: 500px;
  width: 90%;
  position: relative;
  box-shadow: 0 5px 20px rgba(0,0,0,0.2);
}
.close-modal {
  position: absolute;
  top: 10px;
  right: 15px;
  font-size: 2rem;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text);
}
.modal-content h2, .modal-content h3 {
  color: var(--primary);
}
.modal-content table {
  width: 100%;
  text-align: left;
}
.modal-content code {
  background: var(--input-bg);
  padding: 2px 6px;
  border-radius: 4px;
}
.progress-bar-bg {
  width: 100%;
  height: 12px;
  background: #e0e7ef;
  border-radius: 6px;
  margin-bottom: 0.5rem;
  margin-top: 0.5rem;
  overflow: hidden;
}
#progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  border-radius: 6px;
  transition: width 0.2s;
}
.modal-content .report-level {
  font-size: 1.3rem;
  text-align: center;
  margin-bottom: 1rem;
}
.report-level span {
  font-weight: bold;
  color: var(--accent);
  border-bottom: 2px solid var(--accent);
}
.modal-content .report-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 1rem;
  font-size: 1.1rem;
}
.report-stats div {
  background: var(--input-bg);
  padding: 0.8rem;
  border-radius: 0.5rem;
}
.report-stats span {
  font-weight: bold;
  color: var(--primary);
}


.controls-card {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  justify-content: center;
  background: #f8fafc;
  box-shadow: none;
  padding: 1rem 2rem;
  margin-bottom: 0.5rem;
}
.typing-area-card {
  background: #f0f4ff;
  border: 1px solid #e0e7ef;
}
.stats-card {
  display: flex;
  gap: 2rem;
  justify-content: center;
  background: #f8fafc;
  box-shadow: none;
  padding: 1rem 2rem;
}
.leaderboard-card {
  background: #f5f7fa;
  box-shadow: none;
  padding: 1.5rem 2rem;
}


/* Sinhala badge */
.sinhala-badge {
  display: inline-block;
  background: #facc15;
  color: #1e293b;
  font-weight: 700;
  border-radius: 8px;
  padding: 0.2rem 0.8rem;
  margin-right: 0.7rem;
  font-size: 1.1rem;
  letter-spacing: 0.02em;
}
/* Level badge emoji */
.level-badge {
  display: inline-block;
  background: #38bdf8;
  color: #fff;
  border-radius: 8px;
  padding: 0.2rem 1rem;
  font-weight: 700;
  margin-left: 0.5rem;
  font-size: 1.1rem;
}

/* Buttons */
button {
  background: linear-gradient(90deg, #4f8cff, #38e8ff);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.75rem 2rem;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s, transform 0.1s;
  box-shadow: 0 2px 8px rgba(79,140,255,0.08);
}
button:hover, .footer-btn:hover, button:focus, .footer-btn:focus {
  background: linear-gradient(90deg, #2563eb, #06b6d4);
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 4px 16px rgba(56,232,255,0.12);
}
button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
/* Button active state */
button:active {
  transform: scale(0.97);
}

/* Inputs */
input[type="text"], textarea, select {
  font-size: 1.2rem;
  padding: 0.75rem;
  border-radius: 8px;
  border: 2px solid #e0e0e0;
  width: 100%;
  margin-bottom: 1rem;
  background: #f8fafc;
  transition: border 0.2s;
}
input[type="text"]:focus, textarea:focus, select:focus {
  border: 2px solid #4f8cff;
  outline: none;
}

/* Progress Bar */
.progress-bar-bg {
  background: #e0e0e0;
  border-radius: 8px;
  height: 16px;
  margin: 1rem 0;
  width: 100%;
  overflow: hidden;
}



#progress-bar {
  background: linear-gradient(90deg, #4f8cff, #38e8ff);
  height: 100%;
  border-radius: 8px;
  transition: width 0.3s;
}
/* Progress bar animation */
#progress-bar {
  transition: width 0.4s cubic-bezier(.4,2,.6,1), background 0.3s;
}
#progress-bar:hover {
  filter: brightness(1.1) drop-shadow(0 0 6px #38e8ff);
}

/* Leaderboard */
#leaderboard {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
}
#leaderboard th, #leaderboard td {
  padding: 0.75rem 1rem;
  text-align: center;
}
#leaderboard th {
  background: #e0e7ef;
  color: #1e293b;
  font-weight: 700;
}
#leaderboard tr:nth-child(1) td { background: #fef08a; font-weight: 700; }
#leaderboard tr:nth-child(2) td { background: #bae6fd; font-weight: 600; }
#leaderboard tr:nth-child(3) td { background: #bbf7d0; font-weight: 600; }
#leaderboard tr {
  border-bottom: 1px solid #e0e0e0;
}
/* Highlight user-score row */
#leaderboard tr.user-score {
  background: #dbeafe !important;
  font-weight: 700;
}
body.dark #leaderboard tr.user-score {
  background: #0ea5e9 !important;
  color: #fff;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(30,41,59,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(2px);
}
.modal-content.card {
  max-width: 400px;
  width: 100%;
  padding: 2rem 2.5rem;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(30,41,59,0.18);
  background: #fff;
  position: relative;
}
.close-modal {
  position: absolute;
  top: 10px;
  right: 15px;
  font-size: 2rem;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text);
}
.close-modal-report, .close-modal-about, .close-modal-help, .close-modal-premium {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  color: #64748b;
  font-size: 2rem;
  border: none;
  cursor: pointer;
  transition: color 0.2s;
}
.close-modal-report:hover, .close-modal-about:hover, .close-modal-help:hover, .close-modal-premium:hover {
  color: #e11d48;
}
/* Modal fade-in animation */
.modal-overlay.fade-in {
  animation: fadeIn 0.35s;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Feedback */
.feedback {
  margin-top: 1rem;
  font-size: 1.1rem;
  font-weight: 500;
  min-height: 1.5rem;
}

/* Responsive */
@media (max-width: 700px) {
  .card {
    padding: 1rem;
    max-width: 98vw;
  }
  .header-card, .footer-card, .leaderboard-card, .controls-card, .stats-card {
    padding: 0.75rem 1rem;
  }
  .modal-content.card {
    padding: 1rem 0.5rem;
  }
}

/* Dark mode */
body.dark {
  background: #1e293b;
  color: #f1f5f9;
}
body.dark .card, body.dark .modal-content.card {
  background: var(--card);
  color: var(--text-primary);
  box-shadow: 0 4px 24px rgba(0,0,0,0.18);
}
body.dark .header-card, body.dark .footer-card, body.dark .leaderboard-card, body.dark .controls-card, body.dark .stats-card {
  background: var(--bg-tertiary);
}
body.dark .stat-badge {
  background: #334155;
  color: #f1f5f9;
}
body.dark .level-badge {
  background: var(--primary);
  color: white;
}
body.dark input[type="text"], body.dark textarea, body.dark select {
  background: var(--input-bg);
  color: var(--text-primary);
  border: 2px solid var(--border);
}
body.dark input[type="text"]:focus, body.dark textarea:focus, body.dark select:focus {
  border: 2px solid var(--primary);
}
body.dark .progress-bar-bg {
  background: var(--border);
}
body.dark #progress-bar {
  background: linear-gradient(90deg, var(--primary), var(--secondary));
}
body.dark #leaderboard th {
  background: var(--border);
  color: var(--text-primary);
}
body.dark #leaderboard tr:nth-child(1) td { background: #facc15; color: #1e293b; }
body.dark #leaderboard tr:nth-child(2) td { background: #38bdf8; color: #1e293b; }
body.dark #leaderboard tr:nth-child(3) td { background: #4ade80; color: #1e293b; } 

/* Mistake shake animation */
@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-8px); }
  40%, 60% { transform: translateX(8px); }
}
.mistake-char.shake {
  animation: shake 0.4s;
}



/* Subtle background gradient */
body {
  background: linear-gradient(135deg, #f7f7fa 0%, #e0e7ef 100%);
}
body.dark {
  background: linear-gradient(135deg, #1e293b 0%, #273449 100%);
}

/* Accessibility focus ring */
button:focus {
  outline: 3px solid #38bdf8;
  outline-offset: 2px;
}

/* Mobile font size improvements */
@media (max-width: 700px) {
  body, input, textarea, select, button {
    font-size: 1.08rem;
  }
  h1, h2, h3 {
    font-size: 1.1rem;
  }
} 

.premium-badge {
  display: inline-block;
  background: #facc15;
  color: #3b3b3b;
  font-weight: 700;
  border-radius: 6px;
  padding: 0.18em 0.85em;
  margin-left: 0.7rem;
  font-size: 1.02rem;
  letter-spacing: 0.01em;
  box-shadow: 0 1px 4px rgba(251,191,36,0.10);
  vertical-align: middle;
  font-family: inherit;
  line-height: 1.2;
  border: none;
  outline: none;
}

/* Light mode specific premium badge style */
body:not(.dark) .premium-badge {
  background: #1e293b;
  color: #facc15;
  box-shadow: 0 1px 4px rgba(30, 41, 59, 0.2);
  border: 1px solid #334155;
}

.header-title-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
} 

/* --- Modern, colorful, mobile-friendly UI enhancements --- */

:root {
  --primary-gradient: linear-gradient(90deg, #4f8cff 0%, #38e8ff 100%);
  --primary-glow: 0 2px 16px rgba(79,140,255,0.13);
  --card-glass: rgba(255,255,255,0.85);
  --card-glass-dark: rgba(39,52,73,0.92);
  --badge-gradient: linear-gradient(90deg, #facc15 0%, #fbbf24 100%);
  --badge-shadow: 0 1px 6px rgba(251,191,36,0.13);
}

/* Card glassmorphism effect */
.card, .modal-content.card {
  background: var(--card-glass);
  backdrop-filter: blur(6px) saturate(1.2);
  box-shadow: 0 8px 32px rgba(30,41,59,0.10), var(--primary-glow);
  border: 1.5px solid #e0e7ef;
  transition: background 0.3s, box-shadow 0.3s;
}
body.dark .card, body.dark .modal-content.card {
  background: var(--card-glass-dark);
  box-shadow: 0 8px 32px rgba(59, 30, 30, 0.22), var(--primary-glow);
  border: 1.5px solid #334155;
}



/* Icon buttons */
#mode-toggle, .close-modal, .close-modal-report, .close-modal-about, .close-modal-help, .close-modal-premium {
  background: none;
  color: var(--primary);
  font-size: 1.2rem;
  border: none;
  box-shadow: none;
  padding: 0.2em 0.2em;
  border-radius: 100%;
  transition: background 0.18s, color 0.18s;
}



body.dark #mode-toggle, body.dark #help-btn, body.dark .close-modal, body.dark .close-modal-report, body.dark .close-modal-about, body.dark .close-modal-help, body.dark .close-modal-premium {
  color: #38bdf8;
}
body.dark #mode-toggle:hover, body.dark #help-btn:hover, body.dark .close-modal:hover, body.dark .close-modal-report:hover, body.dark .close-modal-about:hover, body.dark .close-modal-help:hover, body.dark .close-modal-premium:hover {
  background: #334155;
  color: #facc15;
}


/* Input fields */
input[type="text"], textarea, select {
  font-size: 1.13rem;
  padding: 0.85rem;
  border-radius: 10px;
  border: 2px solid #e0e0e0;
  background: #f8fafc;
  color: #1e293b;
  margin-bottom: 1rem;
  box-shadow: 0 1px 4px rgba(56,232,255,0.04);
  transition: border 0.2s, box-shadow 0.2s;
}
input[type="text"]:focus, textarea:focus, select:focus {
  border: 2px solid #4f8cff;
  box-shadow: 0 2px 8px rgba(79,140,255,0.10);
}
body.dark input[type="text"], body.dark textarea, body.dark select {
  background: var(--input-bg);
  color: var(--text-primary);
  border: 2px solid var(--border);
}
body.dark input[type="text"]:focus, body.dark textarea:focus, body.dark select:focus {
  border: 2px solid var(--primary);
}

/* Custom badges */
.sinhala-badge {
  background: var(--badge-gradient);
  color: #1e293b;
  font-weight: 700;
  border-radius: 10px;
  padding: 0.22rem 1.1rem;
  margin-right: 0.7rem;
  font-size: 1.13rem;
  letter-spacing: 0.02em;
  box-shadow: var(--badge-shadow);
  border: none;
}
/* .premium-badge {
  background: var(--badge-gradient);
  color: #3b3b3b;
  font-weight: 700;
  border-radius: 8px;
  padding: 0.18em 1.1em;
  margin-left: 0.7rem;
  font-size: 1.05rem;
  letter-spacing: 0.01em;
  box-shadow: var(--badge-shadow);
  vertical-align: middle;
  font-family: inherit;
  line-height: 1.2;
  border: none;
  outline: none;
} */
.level-badge {
  background: linear-gradient(90deg, #38bdf8, #818cf8);
  color: #fff;
  border-radius: 10px;
  padding: 0.22rem 1.1rem;
  font-weight: 700;
  margin-left: 0.5rem;
  font-size: 1.13rem;
  box-shadow: 0 1px 6px rgba(56,189,248,0.13);
}

/* Progress bar */
.progress-bar-bg {
  background: #e0e0e0;
  border-radius: 10px;
  height: 18px;
  margin: 1rem 0;
  width: 100%;
  overflow: hidden;
  box-shadow: 0 1px 6px rgba(56,232,255,0.07);
}
#progress-bar {
  background: var(--primary-gradient);
  height: 100%;
  border-radius: 10px;
  transition: width 0.4s cubic-bezier(.4,2,.6,1), background 0.3s;
  box-shadow: 0 1px 6px rgba(56,232,255,0.13);
}
#progress-bar:hover {
  filter: brightness(1.1) drop-shadow(0 0 6px #38e8ff);
}

/* Leaderboard */
#leaderboard {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin-top: 0rem;
  background: transparent;
  border-radius: 12px;
  overflow: hidden;
  align-items: center;
  justify-content: center;

}
#leaderboard th, #leaderboard td {
  padding: 0.5rem 1.1rem;
  text-align: center;
  font-size: 1.08rem;
}
#leaderboard th {
  background: #e0e7ef;
  color: #1250b4;
  font-weight: 700;
  border-bottom: 2px solid #4f8cff;
}
#leaderboard tr:nth-child(1) td { background: #fef08a; font-weight: 700; }
#leaderboard tr:nth-child(2) td { background: #bae6fd; font-weight: 600; }
#leaderboard tr:nth-child(3) td { background: #bbf7d0; font-weight: 600; }
#leaderboard tr {
  border-bottom: 1px solid #e0e0e0;
  transition: background 0.18s;
}
#leaderboard tr:hover {
  background: #f1f5f9;
  color: #1e293b;
}
body.dark #leaderboard tr:hover {
  background: #334155 !important;
  color: #f1f5f9 !important;
}
#leaderboard tr.user-score {
  background: #dbeafe !important;
  font-weight: 700;
}
body.dark #leaderboard th {
  background: var(--border);
  color: var(--text-primary);
}
body.dark #leaderboard tr:nth-child(1) td { background: #facc15; color: #1e293b; }
body.dark #leaderboard tr:nth-child(2) td { background: #38bdf8; color: #1e293b; }
body.dark #leaderboard tr:nth-child(3) td { background: #4ade80; color: #1e293b; }
body.dark #leaderboard tr.user-score {
  background: #0ea5e9 !important;
  color: #fff;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(30,41,59,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(2px);
}
.modal-content.card, .modal-content {
  max-width: 420px;
  width: 100%;
  padding: 2.2rem 2.5rem;
  border-radius: 18px;
  box-shadow: 0 8px 32px rgba(30,41,59,0.18);
  background: var(--card-glass);
  position: relative;
  border: 1.5px solid #e0e7ef;
  animation: modalPop 0.35s cubic-bezier(.4,2,.6,1);
}
@keyframes modalPop {
  0% { transform: scale(0.85) translateY(40px); opacity: 0; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}
body.dark .modal-content.card, body.dark .modal-content {
  background: var(--card-glass-dark);
  border: 1.5px solid #334155;
}

/* Stat badges */
.stat-badge {
  background: #e0e7ef;
  color: #1e293b;
  border-radius: 10px;
  padding: 0.7rem 1.7rem;
  font-weight: 600;
  font-size: 1.13rem;
  margin: 0 0.5rem;
  box-shadow: 0 1px 6px rgba(56,232,255,0.07);
}



body.dark .stat-badge {
  background: var(--border);
  color: var(--text-primary);
}

/* Feedback */
.feedback {
  margin-top: 1rem;
  font-size: 1.13rem;
  font-weight: 500;
  min-height: 1.5rem;
  color: var(--accent);
  letter-spacing: 0.01em;
  transition: color 0.2s;
}

/* Responsive improvements */
@media (max-width: 700px) {
  .card, .modal-content.card, .modal-content {
    padding: 1rem 0.5rem;
    max-width: 99vw;
    border-radius: 12px;
  }
  .header-card, .footer-card, .leaderboard-card, .controls-card, .stats-card {
    padding: 0.75rem 0.5rem;
  }
  #leaderboard th, #leaderboard td {
    padding: 0.5rem 0.3rem;
    font-size: 0.97rem;
  }

  .sinhala-badge, .level-badge {
    font-size: 1.01rem;
    padding: 0.18rem 0.7rem;
  }
}

/* Subtle icon animation */
#help-btn {
  animation: helpBtnPulse 2.5s infinite;
}
@keyframes helpBtnPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(56,232,255,0.18); }
  50% { box-shadow: 0 0 0 12px rgba(56,232,255,0.10); }
}

/* Custom scrollbar */
::-webkit-scrollbar {
  width: 10px;
  background: #3b689b;
  border-radius: 8px;


}
::-webkit-scrollbar-thumb {
  background: #b6c6e3;
  border-radius: 8px;
}
body.dark ::-webkit-scrollbar {
  background: #222b3a;
}
body.dark ::-webkit-scrollbar-thumb {
  background: #334155;
}

/* background */
main {
  max-width: 100vw;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  background: none;
  padding: 0;
}
.main-card {
  max-width: 800px;
  width: 100%;
  margin: 2.5rem auto 2rem auto;
  padding: 2.2rem 1.5rem 2rem 1.5rem;
  border-radius: 18px;
  box-shadow: 0 8px 32px rgba(30,41,59,0.13), var(--primary-glow);
  background: var(--card-glass);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.7rem;
}

.timer-section {
  display: flex;
  align-items: center;
  gap: 1.2rem;
  justify-content: center;
  margin-bottom: 0.7rem;
  width: 100%;

}
.stats-card.stats {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-bottom: 1.2rem;
  width: 100%;
}
.difficulty-select, .keyboard-section, .custom-text-section {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 1rem;
  justify-content: center;
}
.typing-area-card {
  width: 100%;
  margin-bottom: 1.2rem;
  background: var(--input-bg);
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(79,140,255,0.07);
  padding: 1.2rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}
#sentence-display {
  font-size: 1.2rem;
  min-height: 2.5rem;
  background: none;
  padding: 0.5rem 0;
  border-radius: 0.5rem;
  margin-bottom: 0.2rem;
  text-align: center;
  justify-content: center;
}
#typing-input {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1.1rem;
  border-radius: 0.5rem;
  border: 1px solid var(--primary);
  background: var(--input-bg);
  color: var(--text);

}
.controls-card.controls {
  width: 100%;
  display: flex;
  justify-content: center;
  margin-bottom: 1.2rem;
  background: none;
  box-shadow: none;
  padding: 0;
}
.leaderboard-card.leaderboard-section {
  width: 100%;
  margin-top: 0rem;
  background: var(--card-glass);
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(79,140,255,0.07);
  padding: 1.2rem 1rem;
}
#leaderboard {
  width: 100%;
  margin-top:auto;
}














@media (max-width: 700px) {
  main {
    padding-left: 0.7rem !important;
    padding-right: 0.7rem !important;
  }
  .main-card {
    max-width: 99vw;
    padding: 1.1rem 0.2rem 1.2rem 0.2rem;
    border-radius: 10px;
  }
  .main-heading {
    font-size: 1.3rem;
    margin-bottom: 0.7rem;
  }
  .stats-card.stats {
    gap: 0.7rem;
    font-size: 0.97rem;
  }
  .leaderboard-card.leaderboard-section {
    padding: 0.7rem 0.2rem;
    border-radius: 8px;
  }
  .typing-area-card {
    padding: 0.7rem 0.2rem;
    border-radius: 7px;
  }
}

/* Remove two-column, flex, and old layout styles */
.main-flex, .main-left, .main-right {
  display: none !important;
}

/* --- End single-column, centered, user-friendly layout --- */ 

/* --- Subtle link-style premium button --- */
.premium-link-btn {
  background: none !important;
  border: none !important;
  color: var(--primary);
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 0.7rem;
  padding: 0;
  text-decoration: underline dotted transparent;
  transition: color 0.18s, text-decoration-color 0.18s;
  box-shadow: none;
  display: inline;
}
.premium-link-btn:hover, .premium-link-btn:focus {
  color: var(--secondary);
  text-decoration-color: var(--secondary);
  outline: none;
}
.premium-link-btn:active {
  color: var(--accent);
}

.stats-card_stats2{
display: flex;
justify-content: center;
background: none;
}

.select{
  display: flex;
  flex-direction: row;
  justify-content: center;
  gap: 1rem;
}

/* --- MOBILE-ONLY OVERRIDES: width < 700px --- */
@media (max-width: 700px) {
  main {
    padding-left: 0.7rem !important;
    padding-right: 0.7rem !important;
  }
  .main-card, .card, .typing-area-card, .leaderboard-card, .footer-card, .header-card {
    width: 100% !important;
    max-width: 100% !important;
    min-width: unset !important;
    margin: 0 !important;
    padding-left: 0.7rem !important;
    padding-right: 0.7rem !important;
    border-radius: 6px !important;
    box-sizing: border-box;
  }
  .modal-content, .modal-content.card, .modal-overlay {
    width: 100% !important;
    max-width: 100% !important;
    min-width: unset !important;
    left: 0 !important;
    right: 0 !important;
    border-radius: 8px !important;
    padding-left: 0.7rem !important;
    padding-right: 0.7rem !important;
    margin: 0 !important;
    box-sizing: border-box;
  }
  #leaderboard {
    width: 100% !important;
    max-width: 100% !important;
    min-width: unset !important;
    overflow-x: auto !important;
    display: block !important;
    padding-left: 0.7rem !important;
    padding-right: 0.7rem !important;
    box-sizing: border-box;
  }
  #leaderboard th, #leaderboard td {
    min-width: 60px !important;
    font-size: 0.85rem !important;
    padding: 0.3rem 0.2rem !important;
  }
  /* No width: 100vw or min-width: 100vw anywhere! */
}



#about-btn {
  background: none !important;
  border: none !important;
  box-shadow: none !important;
  color: var(--primary) !important;
  font-size: inherit !important;
  padding: 0 !important;
  margin: 0 0.5rem !important;
  text-decoration: underline dotted transparent;
  cursor: pointer;
  transition: color 0.18s, text-decoration-color 0.18s;
  display: inline;
}
#about-btn:hover, #about-btn:focus {
  color: var(--secondary) !important;
  text-decoration-color: var(--secondary);
  outline: none;
}

/* --- Start/Reset Button Row --- */
.start-reset-row {
  display: flex;
  gap: 1rem;
  justify-content: center;
  align-items: center;
  margin: 1rem 0;
}
#restart-btn {
  font-size: 1.5rem;
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  padding: 0.4em 0.7em;
  border-radius: 8px;
  transition: background 0.18s, color 0.18s;
  box-shadow: none;
  display: flex;
  align-items: center;
  justify-content: center;
}
#restart-btn:hover, #restart-btn:focus {
  background: #e0e7ef;
  color: #2563eb;
  outline: none;
}
@media (max-width: 700px) {
  .start-reset-row {
    gap: 0.5rem;
  }
  #restart-btn {
    font-size: 1.1rem;
    padding: 0.2em 0.4em;
  }
}

/* --- Modern Session Report Modal --- */
.report-modern {
  max-width: 420px;
  width: 100%;
  padding: 2.2rem 2.5rem;
  border-radius: 18px;
  box-shadow: 0 8px 32px rgba(30,41,59,0.18);
  background: var(--card-glass, #fff);
  position: relative;
  border: 1.5px solid #e0e7ef;
  animation: modalPop 0.35s cubic-bezier(.4,2,.6,1);
  text-align: center;
}

/* Light mode specific report modern style */
body:not(.dark) .report-modern {
  background: #ffffff;
  border: 1.5px solid #e2e8f0;
  box-shadow: 0 8px 32px rgba(30,41,59,0.12);
}

.report-modern h2#report-heading {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
  color: #2563eb;
  letter-spacing: 0.01em;
}

/* Light mode specific report heading style */
body:not(.dark) .report-modern h2#report-heading {
  color: #1e40af;
}

#report-summary {
  font-size: 1.08rem;
  color: #ffffff;
  margin-bottom: 1.2rem;
}

/* Light mode specific report summary style */
body:not(.dark) #report-summary {
  color: #1e293b;
  font-weight: 500;
}

/* --- Colorful Stat Badges for Report Modal --- */
.report-stat-badge.wpm {
  background: linear-gradient(90deg, #2563eb 0%, #38bdf8 100%);
  color: #fff;
}
.report-stat-badge.cpm {
  background: linear-gradient(90deg, #22c55e 0%, #4ade80 100%);
  color: #fff;
}
.report-stat-badge.accuracy {
  background: linear-gradient(90deg, #f59e42 0%, #fbbf24 100%);
  text-align: center;
  font-size: 1.2rem;
  justify-content: center;
  color: #db1515;
  font-weight: 900;
}

/* Light mode specific report stat badge styles */
body:not(.dark) .report-stat-badge.accuracy {
  color: #dc2626;
}

body:not(.dark) .report-stat-badge {
  box-shadow: 0 2px 12px rgba(30,41,59,0.08);
}

.report-stat-badge {
  display:flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  font-size: 1.25rem;
  font-weight: 700;
  padding: 1em 1.5em;
  box-shadow: 0 2px 12px rgba(30,41,59,0.10);
  margin-bottom: 0.5rem;
  min-width: 110px;
  transition: background 0.2s, color 0.2s;

}
.report-stat-badge span {
  font-size: 1.3em;
  margin-right: 0.2em;
}
.report-share-row {
  margin-bottom: 1.2rem;
}
.report-share-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  width: 2.8rem;
  height: 2.8rem;
  border-radius: 50%;
  margin: 0 0.2rem;
  min-width: 2.8rem;
  min-height: 2.8rem;
  line-height: 1;
  position: relative;
  overflow: hidden;
}
.report-share-btn svg {
  width: 1.2em !important;
  height: 1.2em !important;
  position: relative;
  z-index: 1;
}

/* Make the inner icon content perfectly circular */
.report-share-btn::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 1.8rem;
  height: 1.8rem;
  border-radius: 50%;
  background: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Ensure the icon text is perfectly centered */
.report-share-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: 'FontAwesome', 'Arial', sans-serif;
  font-size: 1.2rem;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background: #e0e7ef;
  color: #2563eb;
  margin: 0 0.3rem;
  text-align: center;
  transition: all 0.18s ease;
  text-decoration: none;
  position: relative;
  overflow: hidden;
  line-height: 1;
}
.report-share-btn.fb { color: #1877f3; }
.report-share-btn.li { color: #0a66c2; }
.report-share-btn.tw { color: #1da1f2; }
.report-share-btn:hover, .report-share-btn:focus {
  background: #2563eb;
  color: #fff;
}
.report-leaderboard-link {
  color: #2563eb;
  font-weight: 600;
  text-decoration: underline dotted;
  font-size: 1rem;
  transition: color 0.18s;
}
.report-leaderboard-link:hover { color: #f59e42; }
.report-btn-try {
  background: #fff;
  color: #2563eb;
  border: 2px solid #2563eb;
  font-weight: 700;
  font-size: 1.1rem;
  border-radius: 10px;
  padding: 0.7em 2.2em;
  transition: background 0.18s, color 0.18s, border 0.18s;
}
.report-btn-try:hover, .report-btn-try:focus {
  background: #2563eb;
  color: #fff;
}
.report-btn-save {
  background: #2563eb;
  color: #fff;
  font-weight: 700;
  font-size: 1.1rem;
  border-radius: 10px;
  padding: 0.7em 2.2em;
  border: none;
  transition: background 0.18s, color 0.18s;
}
.report-btn-save:hover, .report-btn-save:focus {
  background: #f59e42;
  color: #fff;
}
#report-illustration {
  min-height: 90px;
  margin-bottom: 0.7rem;
}


/* --- Custom Reset Modal --- */
#reset-modal.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(30,41,59,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1200;
  backdrop-filter: blur(2px);
}
#reset-modal .modal-content.card {
  max-width: 350px;
  width: 96vw;
  padding: 2rem 1.2rem 1.5rem 1.2rem;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(30,41,59,0.18);
  background: var(--card-glass, #fff);
  position: relative;
  text-align: center;
  border: 1.5px solid #e0e7ef;
  animation: modalPop 0.35s cubic-bezier(.4,2,.6,1);
}
#reset-modal input[type="password"] {
  width: 90%;
  padding: 0.6em;
  margin-bottom: 0.5em;
  border-radius: 7px;
  border: 1.5px solid #e0e7ef;
  font-size: 1.08rem;
  background: #f8fafc;
  color: #222;
  transition: border 0.2s;
}
#reset-modal input[type="password"]:focus {
  border: 1.5px solid #2563eb;
  outline: none;
}
#reset-error-msg {
  color: #e11d48;
  min-height: 1.2em;
  margin-bottom: 0.5em;
  font-size: 0.98em;
}
#reset-modal .footer-btn {
  min-width: 90px;
  font-size: 1.05rem;
  border-radius: 8px;
  padding: 0.5em 1.2em;
  margin: 0;
}
#reset-modal .close-modal-reset {
  position: absolute;
  top: 1rem;
  right: 1rem;
  font-size: 1.5rem;
  background: none;
  border: none;
  color: #888;
  cursor: pointer;
  transition: color 0.2s;
}
#reset-modal .close-modal-reset:hover {
  color: #e11d48;
}
@media (max-width: 700px) {
  #reset-modal .modal-content.card {
    padding: 1.1rem 0.3rem 1rem 0.3rem;
    border-radius: 10px;
  }
  #reset-modal .footer-btn {
    font-size: 0.97rem;
    padding: 0.4em 0.7em;
    min-width: 60px;
  }
}

/* --- Mobile Stats Cards Optimization --- */
@media (max-width: 600px) {
  .stats-cards, .stats-card_stats2 {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    max-width: 100vw;
    box-sizing: border-box;
    padding: 0.2rem;
    margin-bottom: 1.2rem;
  }
  .stat-card, .stats-card_stats2 > div {
    background: #23232b;
    color: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(30,41,59,0.10);
    padding: 0.7em 0.7em;
    font-size: 1.1rem;
    font-weight: 700;
    text-align: center;
    flex: 1 1 110px;
    min-width: 90px;
    max-width: 160px;
    margin: 0 auto;
  }
}

@media (max-width: 700px) {
  .report-modern {
    padding: 1.1rem 0.5rem;
    border-radius: 10px;
  }
  .report-modern h2#report-heading {
    font-size: 1.2rem;
  }
  .report-stat-badge {
    font-size: 0.97rem;
    padding: 0.4em 0.7em;
  }
  .report-share-btn {
    font-size: 0.97rem;
    padding: 0.3em 0.7em;
    min-width: 36px;
    min-height: 36px;
    border-radius: 1.2em;
    margin: 0 0.08em;
  }
  .report-share-btn svg {
    width: 1.1em !important;
    height: 1.1em !important;
  }
}

@media (max-width: 400px) {
  .main-card, .card, .typing-area-card, .leaderboard-card, .footer-card, .header-card {
    padding: 0.2rem 0.05rem;
    border-radius: 4px;
  }
  .main-heading, h1, h2, h3 {
    font-size: 0.85rem;
  }
  button{
    font-size: 0.8rem;
    padding: 0.3rem 0.5rem;
  }
}

.ad-blend {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--card-bg, #fff);
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  margin: 1.2rem auto 1.2rem auto;
  padding: 0.7rem 0.5rem 0.5rem 0.5rem;
  max-width: 350px;
  box-shadow: 0 1px 4px rgba(30,41,59,0.06);
  transition: box-shadow 0.2s, transform 0.2s;
}
.ad-label {
  font-size: 0.93rem;
  color: #888;
  margin-bottom: 0.18rem;
  letter-spacing: 0.04em;
  font-weight: 500;
  text-align: center;
  width: 100%;
}
.ad-video {
  width: 100%;
  max-width: 320px;
  height: 90px;
  border-radius: 6px;
  background: #000;
  display: block;
  margin-left: auto;
  margin-right: auto;
}
.ad-video-col {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  align-items: center;
  width: 100%;
}
.ad-video-row {
  display: flex;
  flex-direction: row;
  gap: 0.6rem;
  align-items: center;
  justify-content: center;
  width: 100%;
}
.ad-video {
  width: 90px;
  height: 60px;
  border-radius: 6px;
  background: #000;
  display: block;
  margin-left: 0;
  margin-right: 0;
}
@media (max-width: 600px) {
  .ad-video-row {
    flex-wrap: wrap;
    gap: 0.4rem;
  }
  .ad-video {
    width: 60px;
    height: 40px;
  }
}

.main-ad-row {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  justify-content: center;
  gap: 2.2rem;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
}
.main-ad-row main {
  flex: 1 1 0;
  min-width: 0;
}
.main-ad-row #ad-container {
  margin-top: 2.5rem;
  min-width: 340px;
  max-width: 350px;
}
@media (max-width: 900px) {
  .main-ad-row {
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
  }
  .main-ad-row #ad-container {
    margin-top: 0.7rem;
    min-width: 0;
    max-width: 98vw;
    width: 100%;
  }
}

.leaderboard-btn-row {
  display: flex;
  gap: 0.7rem;
  align-items: center;
  margin-top: 0.5rem;
  margin-bottom: 1.75rem;
  justify-content: center;
}
/* #reset-leaderboard-btn, #save-leaderboard-btn {
  padding: 0.38em 0.9em;
  font-size: 0.91rem;
  min-width: 90px;
  min-height: 34px;
  border-radius: 1.5em;
} */
@media (max-width: 600px) {
  .leaderboard-btn-row {
    flex-direction: column;
    gap: 0.4rem;
    width: 100%;
    align-items: stretch;
  }
  #reset-leaderboard-btn, #save-leaderboard-btn {
    min-width: 0;
    width: 100%;
    font-size: 0.89rem;
    min-height: 32px;
    padding: 0.32em 0.5em;
    margin: 0 auto;
    border-radius: 1.2em;
  }
}

#reset-leaderboard-btn {
  background: linear-gradient(90deg, #e11d48 0%, #f43f5e 100%);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 0.85em 2.2em;
  font-size: 1.08rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 12px rgba(225,29,72,0.10);
  transition: background 0.18s, transform 0.12s, box-shadow 0.18s;
  display: flex;
  align-items: center;
  gap: 0.7em;
  outline: none;
  margin-top: 1rem;
}
#reset-leaderboard-btn:hover, #reset-leaderboard-btn:focus {
  background: linear-gradient(90deg, #be123c 0%, #e11d48 100%);
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 4px 20px rgba(225,29,72,0.18);
}
#reset-leaderboard-btn:active {
  transform: scale(0.97);
}
#reset-leaderboard-btn .reset-icon {
  font-size: 1.2em;
  margin-right: 0.2em;
  display: inline-block;
}

#save-leaderboard-btn {
  background: linear-gradient(90deg, #2563eb 0%, #38bdf8 100%);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 0.85em 4em;
  font-size: 1.08rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 12px rgba(37,99,235,0.10);
  transition: background 0.18s, transform 0.12s, box-shadow 0.18s;
  display: flex;
  align-items: center;
  gap: 0.7em;
  outline: none;
  margin-top: 1rem;
}
#save-leaderboard-btn:hover, #save-leaderboard-btn:focus {
  background: linear-gradient(90deg, #1d4ed8 0%, #2563eb 100%);
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 4px 20px rgba(37,99,235,0.18);
}
#save-leaderboard-btn:active {
  transform: scale(0.97);
}
#save-leaderboard-btn .save-icon {
  font-size: 1.2em;
  margin-right: 0.2em;
  display: inline-block;
}

@media print {
  body * {
    visibility: hidden !important;
  }
  .leaderboard-card, .leaderboard-card * {
    visibility: visible !important;
  }
  .leaderboard-card {
    position: absolute !important;
    left: 0; right: 0; top: 0;
    margin: 0 auto !important;
    width: 100% !important;
    box-shadow: none !important;
    background: #fff !important;
    color: #222 !important;
    z-index: 9999 !important;
  }
}

@media print {
  body.print-report-modal * {
    visibility: hidden !important;
  }
  body.print-report-modal #session-report-modal,
  body.print-report-modal #session-report-modal * {
    visibility: visible !important;
  }
  body.print-report-modal #session-report-modal {
    position: absolute !important;
    left: 0; right: 0; top: 0;
    margin: 0 auto !important;
    width: 100% !important;
    box-shadow: none !important;
    background: #fff !important;
    color: #222 !important;
    z-index: 9999 !important;
    display: block !important;
    opacity: 1 !important;
  }
}

#timer-display {
  font-family: 'Roboto Mono', 'Consolas', monospace;
  font-size: 1.45rem;
  font-weight: 700;
  color: #00ff11;
  background: #23232b;
  padding: 0.20em 1.5em;
  border-radius: 0.6em;
  box-shadow: 0 2px 12px rgba(72, 69, 62, 0.1);
  letter-spacing: 0.04em;
  display: inline-block;
  min-width: 200px;
  text-align: center;
  justify-self:center;
  border: 2.5px solid #fbbf24;
  transition: background 0.18s, color 0.18s, border 0.18s, box-shadow 0.18s;
}
#timer-display.pulse {
  animation: timerPulse 0.7s infinite alternate;
}
@keyframes timerPulse {
  0% { box-shadow: 0 0 0 0 #fbbf24; }
  100% { box-shadow: 0 0 16px 4px #fbbf24; }
}
#timer-display.red {
  color: #fff;
  background: #e11d48;
  border-color: #e11d48;
  animation: timerPulseRed 0.5s infinite alternate;
}
@keyframes timerPulseRed {
  0% { box-shadow: 0 0 0 0 #e11d48; }
  100% { box-shadow: 0 0 16px 4px #e11d48; }
}

#mode-toggle-mobile {
  display: none;
}
@media (max-width: 700px) {
  #mode-toggle {
    display: none !important;
  }
  #mode-toggle-mobile {
    display: flex !important;
    position: fixed;
    top: 0.4rem;
    right: 0.5rem;
    z-index: 1200;
    width: 30px;
    height: 30px;
    font-size: 1.1rem;
    border-radius: 50%;
    background: none;
    color: #fbbf24;
    box-shadow: 0 2px 8px rgba(30,41,59,0.10);
    border: none;
    align-items: center;
    justify-content: center;
    padding: 0.1;
  }
}
@media (min-width: 700px) {
  #mode-toggle {
    display: inline-block !important;
  }
  #mode-toggle-mobile {
    display: none !important;
  }
}

.toast {
  position: fixed;
  bottom: 2.2rem;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(90deg, #22c55e 0%, #16a34a 100%);
  color: #fff;
  padding: 1em 2.2em;
  border-radius: 2em;
  font-size: 1.08rem;
  font-weight: 600;
  box-shadow: 0 4px 24px rgba(34,197,94,0.13);
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, bottom 0.3s;
  display: none;
}
.toast.show {
  display: block;
  opacity: 1;
  bottom: 3.5rem;
  pointer-events: auto;
}
@media (max-width: 600px) {
  .toast {
    font-size: 0.97rem;
    padding: 0.7em 1.2em;
    bottom: 1.2rem;
  }
  .toast.show {
    bottom: 2.2rem;
  }
}

.premium-pill-btn {
  background: linear-gradient(90deg, #ffd700 0%, #fbbf24 100%);
  color: #ffffff;
  border: 2px solid #ffd700;
  border-radius: 999px;
  padding: 0.4em 1em;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 2px 20px #ffd70044, 0 0 24px #fbbf2444, 0 0 0 0 #ffd700;
  transition: background 0.18s, transform 0.13s, box-shadow 0.18s, border 0.18s;
  display: block;
  /* margin: 1.4rem auto 0rem auto; */
  width: fit-content;
  text-align: center;
  gap: 0.2em;
  outline: none;
  letter-spacing: 0.01;
  overflow: hidden;
  animation: premiumGlow 2.3s infinite alternate;
  margin-left: 20%;
}

/* Light mode specific premium pill button style */
body:not(.dark) .premium-pill-btn {
  background: linear-gradient(90deg, #1e293b 0%, #334155 100%);
  color: #facc15;
  border: 2px solid #334155;
  box-shadow: 0 2px 20px rgba(30, 41, 59, 0.3), 0 0 24px rgba(51, 65, 85, 0.2);
}

body:not(.dark) .premium-pill-btn:hover, body:not(.dark) .premium-pill-btn:focus {
  background: linear-gradient(90deg, #334155 0%, #475569 100%);
  color: #fbbf24;
  border-color: #475569;
  box-shadow: 0 12px 48px rgba(30, 41, 59, 0.4), 0 0 32px rgba(51, 65, 85, 0.3);
}

@keyframes premiumGlow {
  0% { box-shadow: 0 4px 32px #ffd70044, 0 0 24px #fbbf2444, 0 0 0 0 #ffd700; }
  100% { box-shadow: 0 8px 48px #ffd70077, 0 0 32px #fbbf2477, 0 0 16px 8px #ffd700; }
}
.premium-pill-btn:hover, .premium-pill-btn:focus {
  background: linear-gradient(90deg, #ffd700 0%, #fbbf24 100%);
  transform: translateY(-0.7px) scale(0.99);
  box-shadow: 0 12px 48px #ffd70077, 0 0 32px #fbbf2477, 0 0 24px 12px #ffd700;
  border-color: #ffd700;
}
.premium-pill-btn:active {
  transform: scale(0.97);
}
.premium-badge {
  background: linear-gradient(90deg, #ffd700 0%, #fbbf24 100%);
  color: #d01111;
  font-weight: 900;
  border-radius: 1em;
  padding: 0.18em 1.1em;
  margin-left: 0.7rem;
  font-size: 1.05rem;
  letter-spacing: 0.01em;
  box-shadow: 0 1px 4px #ffd70044;
  vertical-align: middle;
  border: none;
  outline: none;
  display: flex;
  align-items: center;
  gap: 0.3em;



}
.premium-badge .crown {
  font-size: 1.2em;
  margin-right: 0.2em;
}
@media (max-width: 600px) {
  .premium-pill-btn {
    width: 100%;
    font-size: 1.03rem;
    padding: 0.7em 1.1em;
    min-height: 40px;
    justify-content: center;
    white-space: nowrap;
  }
}

.premium-modal-badge {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 0.7rem;
}
.premium-modal-badge .premium-crown {
  font-size: 2.2rem;
  color: #fbbf24;
  filter: drop-shadow(0 0 6px #fbbf24aa);
}
#premium-modal .modal-content {
  border: 2.5px solid #fbbf24;
  box-shadow: 0 8px 32px #fbbf2433, 0 0 24px #fbbf2444;
  background: rgba(39,52,73,0.97);
  border-radius: 1.3rem;
  padding-top: 2.2rem;
}
#premium-modal h2 {
  font-size: 2rem;
  font-weight: 900;
  background: linear-gradient(90deg, #fbbf24 0%, #818cf8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-fill-color: transparent;
  text-align: center;
  margin-bottom: 0.7rem;
  letter-spacing: 0.01em;
  text-shadow: 0 2px 12px #fbbf2444;
}
#premium-code-input {
  width: 100%;
  padding: 0.8em 1.1em;
  border-radius: 1em;
  border: 2px solid #fbbf24;
  background: #23232b;
  color: #fff;
  font-size: 1.1rem;
  margin-bottom: 1.1rem;
  box-shadow: 0 2px 8px #fbbf2411;
  transition: border 0.2s, box-shadow 0.2s;
}
#premium-code-input:focus {
  border: 2px solid #fbbf24;
  box-shadow: 0 0 0 3px #fbbf2444;
  outline: none;
}
#submit-premium-code {
  background: linear-gradient(90deg, #2563eb 0%, #38bdf8 100%);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 0.7em 2.2em;
  font-size: 1.08rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 12px #2563eb22;
  transition: background 0.18s, transform 0.12s, box-shadow 0.18s;
  margin: 0 auto;
  display: block;
}
#submit-premium-code:hover, #submit-premium-code:focus {
  background: linear-gradient(90deg, #1d4ed8 0%, #2563eb 100%);
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 4px 20px #2563eb33;
}

.premium-badge {
  margin-left: 0.5em;
  display: inline-flex;
  align-items: center;
  gap: 0.2em;
}
@media (max-width: 600px) {
  .premium-pill-btn {
    width: 100%;
    font-size: 1.03rem;
    padding: 0.7em 1.1em;
    min-height: 40px;
    justify-content: center;
    white-space: nowrap;
  }
}

@media (max-width: 480px) {
  .premium-pill-btn {
    font-size: 0.85rem;
    gap: 0.1rem;
    max-width: 59vw;
    margin: auto;
    margin-left: 0;
    margin-right: 0;
    text-align: center;
    justify-content: center;
    align-items: center;
    margin-right: 0rem;
    margin-left: 2.5rem;
  }
}

/* --- Leaderboard mobile horizontal scroll --- */
@media (max-width: 700px) {
  #leaderboard {
    overflow-x: auto !important;
    display: block !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    box-shadow: 0 2px 8px rgba(79,140,255,0.07);
    border-radius: 10px;
  }
  #leaderboard th, #leaderboard td {
    min-width: 80px !important;
    font-size: 0.95rem !important;
    padding: 0.3rem 0.2rem !important;
  }
}

/* --- Animated gradient buttons --- */
button {
  background: linear-gradient(270deg, #4f8cff, #38e8ff, #fbbf24, #4f8cff);
  background-size: 600% 600%;
  animation: gradientMove 6s ease infinite;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.75rem 4rem;
  font-size: 1.3rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s, transform 0.1s;
  box-shadow: 0 2px 8px rgba(79,140,255,0.08);
}
@keyframes gradientMove {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* --- Animated stripes for progress bar --- */
#progress-bar {
  background: repeating-linear-gradient(
    135deg,
    #4f8cff 0px,
    #38e8ff 20px,
    #fbbf24 40px,
    #4f8cff 60px
  );
  background-size: 80px 80px;
  animation: stripesMove 1.2s linear infinite;
  height: 100%;
  border-radius: 10px;
  transition: width 0.4s cubic-bezier(.4,2,.6,1), background 0.3s;
  box-shadow: 0 1px 6px rgba(56,232,255,0.13);
}
@keyframes stripesMove {
  0% { background-position: 0 0; }
  100% { background-position: 80px 0; }
}

/* --- EXTRA SMALL MOBILE OPTIMIZATION: width < 500px --- */
@media (max-width: 500px) {
  main {
    padding-left: 0.5rem !important;
    padding-right: 0.5rem !important;
  }
  .main-card {
    padding: 1rem 0.5rem !important;
    border-radius: 8px !important;
    margin: 1rem auto !important;
  }
  .main-heading, h1 {
    font-size: 1.2rem !important;
    margin-bottom: 0.5rem !important;
  }
  .stats-card.stats {
    gap: 0.5rem !important;
    flex-wrap: wrap !important;
  }
  .stat-badge {
    font-size: 0.9rem !important;
    padding: 0.5rem 0.8rem !important;
    margin: 0.2rem !important;
  }
  .sinhala-badge, .level-badge {
    font-size: 0.9rem !important;
    padding: 0.15rem 0.6rem !important;
  }
  .typing-area-card {
    padding: 0.8rem 0.5rem !important;
  }
  #sentence-display {
    font-size: 1rem !important;
    min-height: 2rem !important;
    padding: 0.3rem 0 !important;
  }
  #typing-input {
    font-size: 1rem !important;
    padding: 0.6rem 0.8rem !important;
  }
  .timer-section {
    gap: 0.8rem !important;
    margin-bottom: 0.5rem !important;
  }
  #timer-display {
    font-size: 1.2rem !important;
    padding: 0.15em 1em !important;
    min-width: 150px !important;
  }
  .difficulty-select, .keyboard-section, .custom-text-section {
    gap: 0.5rem !important;
    flex-wrap: wrap !important;
  }
  input[type="text"], textarea, select {
    font-size: 1rem !important;
    padding: 0.6rem 0.8rem !important;
  }
  button {
    font-size: 1rem !important;
    padding: 0.6rem 1.5rem !important;
  }
  .leaderboard-card.leaderboard-section {
    padding: 0.8rem 0.5rem !important;
  }
  #leaderboard th, #leaderboard td {
    font-size: 0.8rem !important;
    padding: 0.25rem 0.15rem !important;
    min-width: 50px !important;
  }
  .modal-content.card, .modal-content {
    padding: 1.5rem 1rem !important;
    border-radius: 12px !important;
  }
  .report-modern {
    padding: 1rem 0.5rem !important;
  }
  .report-stat-badge {
    font-size: 0.9rem !important;
    padding: 0.4em 0.6em !important;
    min-width: 90px !important;
  }
  .premium-pill-btn {
    font-size: 0.95rem !important;
    padding: 0.6em 1em !important;
    margin-left: 10% !important;
  }
  #help-btn {
    width: 50px !important;
    height: 50px !important;
    font-size: 1.5rem !important;
    right: 15px !important;
    bottom: 8px !important;
  }
  .toast {
    font-size: 0.9rem !important;
    padding: 0.6em 1em !important;
    bottom: 1rem !important;
  }
  .toast.show {
    bottom: 1.8rem !important;
  }
}

/* --- ULTRA SMALL MOBILE OPTIMIZATION: width < 400px --- */
@media (max-width: 400px) {
  main {
    padding-left: 0.3rem !important;
    padding-right: 0.3rem !important;
  }
  .main-card {
    padding: 0.8rem 0.3rem !important;
    border-radius: 6px !important;
    margin: 0.5rem auto !important;
  }
  .main-heading, h1 {
    font-size: 1.1rem !important;
    margin-bottom: 0.4rem !important;
  }
  .stats-card.stats {
    gap: 0.3rem !important;
    flex-direction: column !important;
    align-items: center !important;
  }
  .stat-badge {
    font-size: 0.85rem !important;
    padding: 0.4rem 0.6rem !important;
    margin: 0.1rem !important;
    min-width: 80px !important;
  }
  .sinhala-badge, .level-badge {
    font-size: 0.85rem !important;
    padding: 0.12rem 0.5rem !important;
  }
  .typing-area-card {
    padding: 0.6rem 0.3rem !important;
  }
  #sentence-display {
    font-size: 0.95rem !important;
    min-height: 1.8rem !important;
    padding: 0.2rem 0 !important;
  }
  #typing-input {
    font-size: 0.95rem !important;
    padding: 0.5rem 0.6rem !important;
  }
  .timer-section {
    gap: 0.6rem !important;
    margin-bottom: 0.4rem !important;
  }
  #timer-display {
    font-size: 1.1rem !important;
    padding: 0.12em 0.8em !important;
    min-width: 120px !important;
  }
  .difficulty-select, .keyboard-section, .custom-text-section {
    gap: 0.4rem !important;
    flex-direction: column !important;
    align-items: center !important;
  }
  input[type="text"], textarea, select {
    font-size: 0.95rem !important;
    padding: 0.5rem 0.6rem !important;
  }
  button {
    font-size: 0.95rem !important;
    padding: 0.5rem 1.2rem !important;
  }
  .leaderboard-card.leaderboard-section {
    padding: 0.6rem 0.3rem !important;
  }
  #leaderboard {
    font-size: 0.75rem !important;
  }
  #leaderboard th, #leaderboard td {
    font-size: 0.75rem !important;
    padding: 0.2rem 0.1rem !important;
    min-width: 45px !important;
  }
  .modal-content.card, .modal-content {
    padding: 1.2rem 0.8rem !important;
    border-radius: 8px !important;
  }
  .report-modern {
    padding: 0.8rem 0.4rem !important;
  }
  .report-modern h2#report-heading {
    font-size: 1.1rem !important;
  }
  .report-stat-badge {
    font-size: 0.85rem !important;
    padding: 0.3em 0.5em !important;
    min-width: 80px !important;
  }
  .premium-pill-btn {
    font-size: 0.9rem !important;
    padding: 0.5em 0.8em !important;
    margin-left: 5% !important;
  }
  #help-btn {
    width: 45px !important;
    height: 45px !important;
    font-size: 1.3rem !important;
    right: 12px !important;
    bottom: 6px !important;
  }
  .toast {
    font-size: 0.85rem !important;
    padding: 0.5em 0.8em !important;
    bottom: 0.8rem !important;
  }
  .toast.show {
    bottom: 1.5rem !important;
  }
  .start-reset-row {
    gap: 0.4rem !important;
  }
  #restart-btn {
    font-size: 1rem !important;
    padding: 0.15em 0.3em !important;
  }
  .leaderboard-btn-row {
    gap: 0.4rem !important;
    flex-direction: column !important;
  }
  #reset-leaderboard-btn, #save-leaderboard-btn {
    font-size: 0.85rem !important;
    padding: 0.4em 0.8em !important;
    min-width: 80px !important;
  }
  .select {
    flex-direction: column !important;
    gap: 0.5rem !important;
  }
  .ad-blend {
    padding: 0.5rem 0.3rem !important;
    margin: 0.8rem auto !important;
  }
  .ad-video {
    width: 50px !important;
    height: 35px !important;
  }
}

/* --- EXTREME SMALL MOBILE OPTIMIZATION: width < 350px --- */
@media (max-width: 350px) {
  main {
    padding-left: 0.2rem !important;
    padding-right: 0.2rem !important;
  }
  .main-card {
    padding: 0.6rem 0.2rem !important;
    border-radius: 4px !important;
    margin: 0.3rem auto !important;
  }
  .main-heading, h1 {
    font-size: 1rem !important;
    margin-bottom: 0.3rem !important;
  }
  .stats-card.stats {
    gap: 0.2rem !important;
  }
  .stat-badge {
    font-size: 0.8rem !important;
    padding: 0.3rem 0.5rem !important;
    margin: 0.05rem !important;
    min-width: 70px !important;
  }
  .sinhala-badge, .level-badge {
    font-size: 0.8rem !important;
    padding: 0.1rem 0.4rem !important;
  }
  .typing-area-card {
    padding: 0.5rem 0.2rem !important;
  }
  #sentence-display {
    font-size: 0.9rem !important;
    min-height: 1.6rem !important;
    padding: 0.15rem 0 !important;
  }
  #typing-input {
    font-size: 0.9rem !important;
    padding: 0.4rem 0.5rem !important;
  }
  .timer-section {
    gap: 0.5rem !important;
    margin-bottom: 0.3rem !important;
  }
  #timer-display {
    font-size: 1rem !important;
    padding: 0.1em 0.6em !important;
    min-width: 100px !important;
  }
  input[type="text"], textarea, select {
    font-size: 0.9rem !important;
    padding: 0.4rem 0.5rem !important;
  }
  button {
    font-size: 0.9rem !important;
    padding: 0.4rem 1rem !important;
  }
  #leaderboard th, #leaderboard td {
    font-size: 0.7rem !important;
    padding: 0.15rem 0.08rem !important;
    min-width: 40px !important;
  }
  .modal-content.card, .modal-content {
    padding: 1rem 0.6rem !important;
    border-radius: 6px !important;
  }
  .report-modern {
    padding: 0.6rem 0.3rem !important;
  }
  .report-modern h2#report-heading {
    font-size: 1rem !important;
  }
  .report-stat-badge {
    font-size: 0.8rem !important;
    padding: 0.25em 0.4em !important;
    min-width: 70px !important;
  }
  .premium-pill-btn {
    font-size: 0.85rem !important;
    padding: 0.4em 0.7em !important;
    margin-left: 2% !important;
  }
  #help-btn {
    width: 40px !important;
    height: 40px !important;
    font-size: 1.2rem !important;
    right: 10px !important;
    bottom: 5px !important;
  }
  .toast {
    font-size: 0.8rem !important;
    padding: 0.4em 0.7em !important;
    bottom: 0.6rem !important;
  }
  .toast.show {
    bottom: 1.2rem !important;
  }
  #reset-leaderboard-btn, #save-leaderboard-btn {
    font-size: 0.8rem !important;
    padding: 0.3em 0.6em !important;
    min-width: 70px !important;
  }
  .ad-video {
    width: 45px !important;
    height: 30px !important;
  }
}
@media (max-width: 600px) {
  main {
    padding: 1rem;
    margin: 1rem;
  }
  header {
    flex-direction: column;
    gap: 0.5rem;
    padding: 1rem;
  }

  .leaderboard-section h2 {
    font-size: 1rem;
  }
  #leaderboard th, #leaderboard td {
    padding: 0.3rem 0.3rem;
    font-size: 0.9rem;
  }
} 
/* --- HORIZONTAL SCROLL FIX FOR SMALL SCREENS --- */
@media (max-width: 500px) {
  body {
    overflow-x: hidden !important;
  }
  html {
    overflow-x: hidden !important;
  }
  .main-card, .card, .typing-area-card, .leaderboard-card, .footer-card, .header-card {
    overflow-x: hidden !important;
  }
  #leaderboard {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: thin !important;
  }
  #leaderboard::-webkit-scrollbar {
    height: 4px !important;
  }
  #leaderboard::-webkit-scrollbar-thumb {
    background: #cbd5e1 !important;
    border-radius: 2px !important;
  }
}

/* --- TOUCH FRIENDLY BUTTONS FOR MOBILE --- */
@media (max-width: 500px) {
  button, #help-btn, .close-modal, .close-modal-report, .close-modal-about, .close-modal-help, .close-modal-premium {
    min-height: 44px !important;
    min-width: 44px !important;
  }
  input[type="text"], textarea, select {
    min-height: 44px !important;
  }
}

/* --- IMPROVED MODAL FOR SMALL SCREENS --- */
@media (max-width: 400px) {
  .modal-overlay {
    padding: 0.5rem !important;
  }
  .modal-content.card, .modal-content {
    max-width: 95vw !important;
    width: 95vw !important;
  }
}

/* --- BETTER FONT RENDERING FOR SMALL SCREENS --- */
@media (max-width: 500px) {
  body {
    -webkit-text-size-adjust: 100% !important;
    -ms-text-size-adjust: 100% !important;
    text-size-adjust: 100% !important;
  }
}

/* --- FIXED POSITION ELEMENTS FOR SMALL SCREENS --- */
@media (max-width: 400px) {
  #help-btn {
    position: fixed !important;
    z-index: 1000 !important;
  }
  .toast {
    position: fixed !important;
    z-index: 9999 !important;
  }
}

/* --- IMPROVED CARD SPACING FOR SMALL SCREENS --- */
@media (max-width: 500px) {
  .main-card {
    margin-top: 1rem !important;
    margin-bottom: 1rem !important;
  }
  .typing-area-card {
    margin-bottom: 0.8rem !important;
  }
  .leaderboard-card.leaderboard-section {
    margin-top: 0.8rem !important;
  }
}

/* --- BETTER INPUT FOCUS FOR MOBILE --- */
@media (max-width: 500px) {
  input[type="text"]:focus, textarea:focus, select:focus {
    outline: 2px solid #4f8cff !important;
    outline-offset: 2px !important;
  }
}

/* --- IMPROVED BUTTON TOUCH TARGETS --- */
@media (max-width: 500px) {
  .start-reset-row button {
    padding: 0.8rem 1.5rem !important;
    margin: 0.2rem !important;
  }
  .leaderboard-btn-row button {
    padding: 0.7rem 1.2rem !important;
    margin: 0.1rem !important;
  }
}

/* --- BETTER PROGRESS BAR FOR SMALL SCREENS --- */
@media (max-width: 400px) {
  .progress-bar-bg {
    height: 12px !important;
    margin: 0.5rem 0 !important;
  }
  #progress-bar {
    border-radius: 6px !important;
  }
}

/* --- IMPROVED STATS LAYOUT FOR SMALL SCREENS --- */
@media (max-width: 400px) {
  .stats-card.stats {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 0.3rem !important;
  }
  .stat-badge {
    text-align: center !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
  }
}

/* --- BETTER MODAL CLOSE BUTTONS --- */
@media (max-width: 400px) {
  .close-modal, .close-modal-report, .close-modal-about, .close-modal-help, .close-modal-premium {
    position: absolute !important;
    top: 0.5rem !important;
    right: 0.5rem !important;
    font-size: 1.5rem !important;
    padding: 0.5rem !important;
    min-width: 44px !important;
    min-height: 44px !important;
  }
}

/* --- IMPROVED FORM ELEMENTS FOR MOBILE --- */
@media (max-width: 400px) {
  .difficulty-select select, .keyboard-section select, .timer-section select {
    font-size: 0.9rem !important;
    padding: 0.4rem 0.6rem !important;
    min-height: 44px !important;
  }
  .custom-text-section textarea {
    font-size: 0.9rem !important;
    padding: 0.4rem 0.6rem !important;
    min-height: 60px !important;
  }
}

/* --- BETTER ADAPTIVE LAYOUT FOR EXTREME SMALL SCREENS --- */
@media (max-width: 350px) {
  .main-card {
    display: flex !important;
    flex-direction: column !important;
    gap: 0.5rem !important;
  }
  .stats-card.stats {
    grid-template-columns: 1fr !important;
    gap: 0.2rem !important;
  }
  .difficulty-select, .keyboard-section, .custom-text-section {
    width: 100% !important;
  }
  .timer-section {
    width: 100% !important;
    justify-content: center !important;
  }
}

/* --- IMPROVED ACCESSIBILITY FOR MOBILE --- */
@media (max-width: 500px) {
  button:focus, input:focus, select:focus, textarea:focus {
    outline: 2px solid #4f8cff !important;
    outline-offset: 2px !important;
  }
  .modal-overlay:focus {
    outline: none !important;
  }
}

/* --- BETTER SCROLLING EXPERIENCE --- */
@media (max-width: 500px) {
  html {
    scroll-behavior: smooth !important;
  }
  .main-card {
    scroll-margin-top: 1rem !important;
  }
}

/* --- IMPROVED PERFORMANCE FOR SMALL SCREENS --- */
@media (max-width: 500px) {
  * {
    -webkit-transform: translateZ(0) !important;
    transform: translateZ(0) !important;
  }
  .card, .modal-content {
    will-change: auto !important;
  }
}

/* Dark mode styles for report share buttons */
body.dark .report-share-btn {
  background: #334155;
  color: #f1f5f9;
}

body.dark .report-share-btn:hover, body.dark .report-share-btn:focus {
  background: #475569;
  color: #ffffff;
}

body.dark .report-share-btn.fb { 
  color: #60a5fa; 
}

body.dark .report-share-btn.li { 
  color: #38bdf8; 
}

body.dark .report-share-btn.tw { 
  color: #22d3ee; 
}

nav {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.nav {
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.2s ease;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 80px;
}

/* Light mode specific nav styles */
body:not(.dark) .nav {
  background: rgba(30, 41, 59, 0.1);
  color: #1e293b;
  border: 1px solid rgba(30, 41, 59, 0.2);
}

body:not(.dark) .nav:hover, body:not(.dark) .nav:focus {
  background: rgba(30, 41, 59, 0.2);
  border-color: rgba(30, 41, 59, 0.4);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.nav:hover, .nav:focus {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.4);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.nav:active {
  transform: translateY(0);
}

@media (max-width: 700px) {
  nav {
    gap: 0.5rem;
  }
  
  .nav {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    min-width: 60px;
  }
}

.header-title-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex-wrap: wrap;
}

#mode-toggle {
  flex-shrink: 0;
  margin-left: auto;
}

@media (max-width: 700px) {
  header {
    flex-direction: column;
    gap: 0.8rem;
    padding: 0.8rem 1rem;
  }
  
  .logo-title {
    flex: none;
    width: 100%;
    justify-content: center;
  }
  
  nav {
    flex: none;
    width: 100%;
    justify-content: center;
    gap: 0.5rem;
  }
  
  .nav {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    min-width: 60px;
  }
  
  #mode-toggle {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
  }
  
  .header-title-row {
    justify-content: center;
  }
}

/* Lessons Page Styles */
body.lessons-page {
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  color: white;
  min-height: 100vh;
  overflow-x: hidden;
}

.lessons-header {
  text-align: center;
  margin-bottom: 2rem;
  padding: 1rem 0;
}

.title-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.title-icon {
  font-size: 2.5rem;
  display: block;
}

.lessons-title {
  color: white;
  margin: 0;
  font-size: 2.5rem;
  font-weight: 700;
  line-height: 1.2;
}

.lessons-subtitle {
  color: rgba(255, 255, 255, 0.9);
  font-size: 1.1rem;
  margin: 0;
  line-height: 1.4;
}

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

.lesson-card {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
  transition: all 0.3s ease;
  border: 1px solid var(--border);
}

.lesson-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary);
}

.lesson-card h3 {
  color: var(--text-primary);
  margin: 0 0 0.5rem 0;
  font-size: var(--font-size-lg);
  font-weight: 600;
}

.lesson-card p {
  color: var(--text-secondary);
  margin: 0 0 1rem 0;
  line-height: 1.5;
}

.lesson-btn {
  background: var(--primary);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  width: 100%;
}

.lesson-btn:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.lesson-btn:active {
  transform: translateY(0);
}

/* Dark mode support for lessons */
body.dark .lesson-card {
  background: var(--card);
  border-color: var(--border);
}

body.dark .lesson-card:hover {
  border-color: var(--primary);
}

body.dark .lesson-card h3 {
  color: var(--text-primary);
}

body.dark .lesson-card p {
  color: var(--text-secondary);
}

/* Mobile responsive lessons */
@media (max-width: 768px) {
  .lessons-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-top: 1.5rem;
  }
  
  .lesson-card {
    padding: 1.25rem;
  }
  
  .lesson-card h3 {
    font-size: var(--font-size-base);
  }
  
  .lesson-card p {
    font-size: var(--font-size-sm);
  }
  
  .lesson-btn {
    padding: 0.625rem 1.25rem;
    font-size: var(--font-size-sm);
  }
}

@media (max-width: 480px) {
  .lessons-grid {
    gap: 0.875rem;
  }
  
  .lesson-card {
    padding: 1rem;
  }
  
  .lesson-card h3 {
    font-size: var(--font-size-sm);
  }
  
  .lesson-card p {
    font-size: var(--font-size-xs);
  }
  
  .lesson-btn {
    padding: 0.5rem 1rem;
    font-size: var(--font-size-xs);
  }
}

/* Light mode specific report button styles */
body:not(.dark) .report-btn-try {
  background: #ffffff;
  color: #1e40af;
  border: 2px solid #1e40af;
}

body:not(.dark) .report-btn-try:hover, body:not(.dark) .report-btn-try:focus {
  background: #1e40af;
  color: #ffffff;
}

body:not(.dark) .report-btn-save {
  background: #1e40af;
  color: #ffffff;
}

body:not(.dark) .report-btn-save:hover, body:not(.dark) .report-btn-save:focus {
  background: #dc2626;
  color: #ffffff;
}

/* Light mode specific report share button styles */
body:not(.dark) .report-share-btn {
  background: #f1f5f9;
  color: #1e40af;
}

body:not(.dark) .report-share-btn:hover, body:not(.dark) .report-share-btn:focus {
  background: #1e40af;
  color: #ffffff;
}

/* Light mode specific report leaderboard link style */
body:not(.dark) .report-leaderboard-link {
  color: #1e40af;
}

body:not(.dark) .report-leaderboard-link:hover {
  color: #dc2626;
}

/* Mobile Touch-Friendly Button Styles */
@media (max-width: 700px) {
  /* Touch targets - minimum 44px for accessibility */
  button, .nav, select, input[type="text"], textarea, .footer-btn, .premium-pill-btn {
    min-height: 44px;
    min-width: 44px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }
  
  /* Better touch feedback */
  button:active, .nav:active, .footer-btn:active, .premium-pill-btn:active {
    transform: scale(0.95);
    transition: transform 0.1s ease;
  }
  
  /* Improved button padding for mobile */
  button {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    border-radius: 8px;
    position: relative;
    overflow: hidden;
  }
  
  /* Touch area expansion */
  button::before {
    content: '';
    position: absolute;
    top: -10px;
    left: -10px;
    right: -10px;
    bottom: -10px;
    z-index: -1;
  }
  
  /* Better focus management */
  button:focus, .nav:focus, .footer-btn:focus, .premium-pill-btn:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
  }
  
  /* Improved navigation buttons */
  .nav {
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    min-width: 60px;
    text-align: center;
    position: relative;
  }
  
  /* Footer buttons */
  .footer-btn {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    min-height: 44px;
  }
  
  /* Premium pill button */
  .premium-pill-btn {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    min-height: 44px;
    width: 100%;
    justify-content: center;
  }
  
  /* Help button improvements */
  #help-btn {
    width: 50px;
    height: 50px;
    font-size: 1.2rem;
    bottom: 1rem;
    right: 1rem;
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    position: fixed;
    z-index: 1000;
  }
  
  /* Mode toggle button */
  #mode-toggle {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
  }
  
  /* Close modal buttons */
  .close-modal, .close-modal-report, .close-modal-about, .close-modal-help, .close-modal-premium {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    position: absolute;
    top: 1rem;
    right: 1rem;
  }
  
  /* Start/Reset buttons */
  .start-reset-row {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    width: 100%;
  }
  
  .start-reset-row button {
    width: 100%;
    max-width: none;
    padding: 0.75rem;
    font-size: 1rem;
  }
  
  /* Leaderboard buttons */
  .leaderboard-btn-row {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    width: 100%;
  }
  
  .leaderboard-btn-row button {
    width: 100%;
    max-width: none;
    padding: 0.75rem;
    font-size: 1rem;
  }
  
  /* Form elements */
  select, input[type="text"], textarea {
    min-height: 44px;
    padding: 0.75rem;
    font-size: 1rem;
    border-radius: 8px;
    border-width: 2px;
  }
  
  /* Better touch area for small buttons */
  #restart-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
  }
  
  /* Improved button groups */
  .difficulty-select, .keyboard-section, .timer-section {
    margin-bottom: 1rem;
  }
  
  /* Better spacing for touch */
  .typing-area-card > * {
    margin-bottom: 0.75rem;
  }
  
  .typing-area-card > *:last-child {
    margin-bottom: 0;
  }
}

/* Small mobile devices */
@media (max-width: 480px) {
  button, .nav, .footer-btn, .premium-pill-btn {
    min-height: 48px;
    font-size: 0.9rem;
  }
  
  .nav {
    padding: 0.6rem 0.8rem;
    font-size: 0.8rem;
    min-width: 50px;
  }
  
  .footer-btn {
    padding: 0.6rem 1.2rem;
    font-size: 0.9rem;
  }
  
  .premium-pill-btn {
    padding: 0.6rem 1.2rem;
    font-size: 0.9rem;
  }
  
  #help-btn {
    width: 45px;
    height: 45px;
    font-size: 1.1rem;
  }
  
  #mode-toggle {
    width: 40px;
    height: 40px;
    font-size: 1.1rem;
  }
  
  .close-modal, .close-modal-report, .close-modal-about, .close-modal-help, .close-modal-premium {
    width: 40px;
    height: 40px;
    font-size: 1.3rem;
  }
  
  #restart-btn {
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
  }
}

/* Extra small mobile devices */
@media (max-width: 350px) {
  button, .nav, .footer-btn, .premium-pill-btn {
    min-height: 44px;
    font-size: 0.85rem;
  }
  
  .nav {
    padding: 0.5rem 0.6rem;
    font-size: 0.75rem;
    min-width: 45px;
  }
  
  .footer-btn {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
  }
  
  .premium-pill-btn {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
  }
  
  #help-btn {
    width: 40px;
    height: 40px;
    font-size: 1rem;
  }
  
  #mode-toggle {
    width: 36px;
    height: 36px;
    font-size: 1rem;
  }
  
  .close-modal, .close-modal-report, .close-modal-about, .close-modal-help, .close-modal-premium {
    width: 36px;
    height: 36px;
    font-size: 1.2rem;
  }
  
  #restart-btn {
    width: 36px;
    height: 36px;
    font-size: 1.1rem;
  }
}