/* ========================================
   WEIMERTYPE - TYPING PRACTICE
   CSS Stylesheet
   ======================================== */

/* ========================================
   1. CSS VARIABLES (THEME)
   ======================================== */

:root {
  /* Background colors */
  --bg: #0f172a;
  --panel: #111827;
  --panel-2: #1f2937;

  /* Card colors */
  --card: #0b1222;
  --card-border: #23324f;

  /* Text colors */
  --text: #e5e7eb;
  --muted: #9ca3af;

  /* Accent colors */
  --accent: #60a5fa;
  --accent-2: #34d399;

  /* Future: Difficulty level colors */
  --difficulty-beginner: #34d399;
  --difficulty-intermediate: #60a5fa;
  --difficulty-advanced: #f59e0b;
}

/* ========================================
   2. RESET & BASE STYLES
   ======================================== */

* {
  box-sizing: border-box;
}

/* Screen reader only - visually hidden but accessible to screen readers */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  font-family: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  background: #0b1020;
  color: var(--text);
  display: grid;
  grid-template-areas:
    "header header header header"
    ". sidebar main .";
  grid-template-columns: minmax(20px, 1fr) 260px minmax(auto, 800px) minmax(20px, 1fr);
  grid-template-rows: auto 1fr;
  gap: 0 20px;
  height: 100vh;
  overflow: hidden;
}

body.no-sidebar {
  grid-template-areas:
    "header header header"
    ". main .";
  grid-template-columns: minmax(20px, 1fr) minmax(auto, 1200px) minmax(20px, 1fr);
  gap: 0;
}

body.no-sidebar .site-header {
  grid-template-columns: minmax(20px, 1fr) minmax(auto, 1200px) minmax(20px, 1fr);
  gap: 0;
}

body.no-sidebar .header-bar {
  grid-column: 2 / 3; /* Span only the main column when no sidebar */
}

p {
  margin: 5px 0;
}

/* ========================================
   3. LAYOUT
   ======================================== */

.container {
  grid-area: main;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px;
  width: 100%;
  /* Hide scrollbar for Chrome, Safari and Opera */
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE and Edge */
}

.container::-webkit-scrollbar {
  display: none; /* Chrome, Safari, Opera */
}

/* ========================================
   4. HEADER & NAVIGATION
   ======================================== */

.site-header {
  grid-area: header;
  width: 100%;
  background: linear-gradient(90deg,
    rgba(11, 16, 32, 0.95) 0%,
    rgba(26, 34, 56, 0.95) 100%);
  border-bottom: 1px solid var(--card-border);
  z-index: 50;
  display: grid;
  grid-template-columns: minmax(20px, 1fr) 260px minmax(auto, 1200px) minmax(20px, 1fr);
  gap: 0 20px;
}

/* Fallback for browsers that don't support backdrop-filter */
@supports not (backdrop-filter: blur(1px)) {
  .site-header {
    background: #0b1020; /* solid fallback */
  }
}

.header-bar {
  grid-column: 2 / 4; /* Span from sidebar column to main column */
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 18px 0;
  gap: 100px; /* Adjust this value to control spacing between logo and nav buttons */
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo-text {
  width: 44px;
  height: 44px;
  border: 2px solid var(--accent);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 1.4rem;
  color: var(--accent);
}

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

.title {
  font-size: 1.9rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: 0.5px;
}

.title::after {
  content: "";
  display: block;
  width: 45%;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  margin-top: 4px;
  border-radius: 2px;
}

.user-greeting {
  font-size: 0.95rem;
  color: var(--accent);
  font-weight: 600;
}

.total-time {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 400;
  margin-top: 2px;
}

nav {
  display: flex;
  gap: 12px; /* Spacing between nav buttons */
}

nav button {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid #263247;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s ease;
}

nav button:hover {
  background: #233046;
}

/* ========================================
   5. HOME VIEW - CATEGORY GRID
   ======================================== */

#cardGrid {
  display: block;
  width: 100%;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

/* Level sections */
.level-section {
  margin-bottom: 40px;
  width: 100%;
}

.level-section:last-child {
  margin-bottom: 0;
}

/* Legacy: Difficulty sections (kept for backwards compatibility) */
.difficulty-section {
  margin-bottom: 32px;
}

.difficulty-section h2 {
  margin: 0 0 16px 0;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--card-border);
}

/* ========================================
   6. CATEGORY CARDS
   ======================================== */

.card {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 16px;
  transition: border-color 0.2s ease, transform 0.2s ease, background 0.2s ease;
}

.card.completed {
  background: #131b2e; /* Slightly lighter than var(--card) which is #0b1222 */
}

.card-top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.card h3 {
  margin: 8px 0;
  font-size: 1.1rem;
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  padding-top: 10px;
}

.wpm-container {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-actions .wpm {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.95rem;
}

.wpm-change {
  font-size: 0.85rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
}

.wpm-change-up {
  color: var(--accent-2);
  background: rgba(52, 211, 153, 0.1);
}

.wpm-change-down {
  color: #f87171;
  background: rgba(248, 113, 113, 0.1);
}

.wpm-change-flat {
  color: var(--muted);
  background: rgba(156, 163, 175, 0.1);
}

.card-datetime {
  min-height: 1.2rem;
  margin-top: 8px;
  margin-bottom: 4px;
  text-align: left;
  color: var(--muted);
  font-size: 0.85rem;
}

.card-datetime.newly-completed {
  color: var(--accent-2);
  font-weight: 600;
}

/* ========================================
   7. BUTTONS
   ======================================== */

.btn {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid #263247;
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.2s ease, transform 0.1s ease;
}

.btn:hover {
  background: #233046;
}

.btn:active {
  transform: scale(0.98);
}

/* ========================================
   8. PRACTICE VIEW LAYOUT
   ======================================== */

/* Header row that aligns titles with columns */
.practice-head {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: end;
  margin: 0 0 0px 0;
}

.practice-head h2,
.practice-head h3 {
  margin: 0;
}

.prompt-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: 12px; /* Match panel padding */
}

.prompt-title-row h2 {
  margin: 0 10px 0 0;
}

/* Progress circles */
.progress-circles {
  display: flex;
  gap: 6px;
  align-items: center;
}

.progress-circle {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--muted);
  background: transparent;
  transition: all 0.3s ease;
  transform:translateY(25%);
  margin-right: 6px;
}

.progress-circle.completed {
  background: var(--accent);
  border-color: var(--accent);
}

/* Two-column layout for typing area and prompt */
.practice-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
  margin: -40px 0 0 0;
}

/* Responsive: Stack on small screens */
@media (max-width: 800px) {
  .practice-layout {
    grid-template-columns: 1fr;
  }

  .practice-head {
    grid-template-columns: 1fr;
  }

  .practice-head h3 {
    margin-top: 4px;
  }

  .prompt-title-row {
    margin-left: 0;
    margin-top: 12px;
  }
}

/* ========================================
   9. PANELS (TYPING BOX & PROMPT BOX)
   ======================================== */

.panel,
.prompt-box,
.typing-box {
  background: var(--panel-2);
  border: 1px solid #263247;
  border-radius: 10px;
  padding: 12px;
  margin-top: 50px;
}

/* ========================================
   10. TEXTAREA (TYPING AREA)
   ======================================== */

textarea {
  width: 100%;
  min-height: 420px;
  resize: vertical;
  background: #0a1222;
  color: var(--text);
  border: 1px solid #263247;
  border-radius: 10px;
  padding: 12px;
  font-family: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  font-size: 14px;
  line-height: 1.5;
  transition: opacity 0.3s ease;
}

textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

textarea.completed {
  opacity: 0.5;
}

/* ========================================
   11. CODE DISPLAY (PROMPT)
   ======================================== */

pre {
  margin: 0;
  font-family: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  font-size: 14px;
  white-space: pre-wrap;
}

code {
  color: #cbd5e1;
}

/* Prevent copying from prompt */
.nocopy,
.nocopy * {
  user-select: none;
  -webkit-user-select: none;
}

/* ========================================
   12. PROMPT LINE HIGHLIGHTING
   ======================================== */

.prompt-line {
  display: inline-block;
  width: 100%;
  margin-left: -6px;
  margin-right: -6px;
  padding: 2px 6px;
  transition: background-color 0.25s ease;
}

.current-line {
  background-color: rgba(96, 165, 250, 0.18);
  border-radius: 4px;
}

/* ========================================
   13. FEEDBACK AREA
   ======================================== */

.feedback {
  margin-top: 12px;
  border-top: 1px dashed #22304a;
  padding-top: 12px;
}

.feedback .ok {
  background: rgba(52, 211, 153, 0.1);
  padding: 2px 4px;
  border-radius: 4px;
}

.feedback .bad {
  background: rgba(248, 113, 113, 0.12);
  padding: 2px 4px;
  border-radius: 3px;
}

.feedback .miss {
  background: rgba(251, 191, 36, 0.12);
  padding: 2px 4px;
  border-radius: 3px;
}

/* ========================================
   14. ACTIONS ROW (NEXT BUTTON & WPM)
   ======================================== */

.actions-right {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
}

.actions-right .wpm-badge {
  color: var(--muted);
  font-weight: 600;
}

.wpm-badge .wpm-avg {
  font-size: 0.85rem;
  color: var(--muted);
  opacity: 0.7;
  font-weight: 400;
}

/* ========================================
   15. ANIMATIONS
   ======================================== */

/* Shake animation for incorrect input */
@keyframes shake {
  0%, 100% {
    transform: translateX(0);
  }
  20%, 60% {
    transform: translateX(-5px);
  }
  40%, 80% {
    transform: translateX(5px);
  }
}

.shake {
  animation: shake 0.3s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

/* Future: Success celebration animation */
@keyframes celebrate {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

/* ========================================
   16. UTILITY CLASSES
   ======================================== */

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.9rem;
}

/* Future: WPM trend indicators */
.wpm-trend-up {
  color: var(--accent-2);
}

.wpm-trend-down {
  color: #f87171;
}

.wpm-trend-same {
  color: var(--muted);
}

/* Future: Progress indicators */
.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--panel);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 8px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.3s ease;
}

/* Future: Difficulty badges */
.difficulty-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.difficulty-badge.beginner {
  background: rgba(52, 211, 153, 0.15);
  color: var(--difficulty-beginner);
}

.difficulty-badge.intermediate {
  background: rgba(96, 165, 250, 0.15);
  color: var(--difficulty-intermediate);
}

.difficulty-badge.advanced {
  background: rgba(245, 158, 11, 0.15);
  color: var(--difficulty-advanced);
}

/* ========================================
   17. LOGIN VIEW
   ======================================== */

#loginView,
#newKeyView {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 80vh;
}

.login-container {
  width: 100%;
  max-width: 500px;
  margin:auto;
}

.login-box {
  background: var(--panel-2);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 32px;
  margin-top: 50px;
}

.login-box h1 {
  margin: 0 0 8px 0;
  font-size: 1.8rem;
  text-align: center;
}

.login-box > p {
  text-align: center;
  margin-bottom: 24px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-form label {
  font-weight: 600;
  margin-bottom: 4px;
}

.login-form input {
  width: 100%;
  padding: 12px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  font-size: 1rem;
  font-family: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
}

.login-form input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.login-error {
  color: #f87171;
  font-size: 0.9rem;
  min-height: 1.2rem;
  margin-top: -8px;
}

.login-actions {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}

.btn-primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  flex: 1;
}

.btn-primary:hover {
  background: #3b82f6;
}

.btn-secondary {
  background: transparent;
  border-color: var(--muted);
  color: var(--muted);
  flex: 1;
}

.btn-secondary:hover {
  background: rgba(156, 163, 175, 0.1);
}

/* Login Sections */
.login-section {
  margin-bottom: 0;
}

.login-section-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--accent);
  margin: 0 0 12px 0;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--card-border);
}

/* Login Divider */
.login-divider {
  display: flex;
  align-items: center;
  margin: 24px 0;
}

.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--card-border);
}

.login-divider span {
  padding: 0 16px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* ========================================
   18. KEY MODAL
   ======================================== */

.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.modal-content {
  background: var(--panel-2);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 32px;
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-content h2 {
  margin: 0 0 8px 0;
  text-align: center;
}

.modal-content > p {
  text-align: center;
  margin-bottom: 20px;
}

.key-display-box {
  margin: 20px 0;
}

.key-display-box textarea {
  width: 100%;
  padding: 12px;
  background: var(--bg);
  color: var(--accent);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  resize: vertical;
  min-height: 100px;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 20px;
  justify-content: center;
}

.modal-actions button {
  width: 100%;
}

.btn-danger {
  background: #ef4444;
  color: white;
  border-color: #ef4444;
}

.btn-danger:hover {
  background: #dc2626;
}

.copy-feedback {
  text-align: center;
  margin-top: 12px;
  color: var(--accent-2);
  font-size: 0.9rem;
  min-height: 1.2rem;
}

/* ========================================
   19. STAR RATING
   ======================================== */

.star-rating {
  display: flex;
  align-items: center;
  gap: 2px;
}

.star {
  font-size: 1.0rem;
  line-height: 1;
  display: inline-block;
}

.star-filled {
  color: #fbbf24;
}

.star-empty {
  color: #4b5563;
}

.star-half {
  position: relative;
  color: #4b5563;
  display: inline-block;
}

.star-half-inner {
  position: absolute;
  left: 0;
  top: 0;
  width: 50%;
  overflow: hidden;
  color: #fbbf24;
  white-space: nowrap;
}

/* ========================================
   20. SIDEBAR
   ======================================== */

#sidebar {
  grid-area: sidebar;
  background: transparent;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 6px 0;
  display: none; /* Hidden by default */
  /* Hide scrollbar for Chrome, Safari and Opera */
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE and Edge */
}

#sidebar::-webkit-scrollbar {
  display: none; /* Chrome, Safari, Opera */
}

#sidebar.visible {
  display: block; /* Show when visible class is added */
}

.sidebar-content {
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-btn {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--card-border);
  padding: 10px 14px;
  border-radius: 14px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  text-align: left;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
  width: 100%;
}

.sidebar-btn:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.sidebar-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 20px;
}

.sidebar-heading {
  margin: 0 0 10px 0;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--card-border);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
}

.level-btn {
  font-size: 0.95rem;
  padding: 10px 14px;
}

.sort-selector {
  width: 100%;
  padding: 10px 14px;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.sort-selector:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.sort-selector:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Tag Filters */
.tag-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-btn {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--card-border);
  padding: 6px 12px;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.tag-btn:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.tag-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* Responsive: Hide sidebar on small screens */
@media (max-width: 1000px) {
  body {
    grid-template-areas:
      "header header header"
      ". main .";
    grid-template-columns: minmax(20px, 1fr) minmax(auto, 100%) minmax(20px, 1fr);
    gap: 0;
  }

  body.no-sidebar {
    grid-template-areas:
      "header header header"
      ". main .";
    grid-template-columns: minmax(20px, 1fr) minmax(auto, 100%) minmax(20px, 1fr);
    gap: 0;
  }

  .site-header,
  body.no-sidebar .site-header {
    grid-template-columns: minmax(20px, 1fr) minmax(auto, 100%) minmax(20px, 1fr);
    gap: 0;
  }

  .header-bar,
  body.no-sidebar .header-bar {
    grid-column: 2 / 3; /* Span only the main column on small screens */
    padding: 12px 0;
  }

  #sidebar.visible {
    display: none !important; /* Force hide on small screens even if visible class is present */
  }

  .container {
    padding: 24px 16px; /* Reduce horizontal padding on smaller screens */
  }
}



/* ========================================
   17. ABOUT PAGE
   ======================================== */

#aboutView {
  padding: 0;
}

.about-content {
  max-width: 800px;
  margin: 0 auto;
}

.about-content h1 {
  font-size: 2.5rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: 2rem;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.about-section {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.about-section h2 {
  color: var(--accent);
  font-size: 1.5rem;
  margin-top: 0;
  margin-bottom: 1rem;
  font-weight: 700;
}

.about-section h3 {
  color: var(--accent-2);
  font-size: 1.2rem;
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  font-weight: 600;
}

.about-section p {
  line-height: 1.7;
  margin: 0.75rem 0;
  color: var(--text);
}

.about-section ul {
  margin: 0.75rem 0;
  padding-left: 1.5rem;
  color: var(--text);
}

.about-section li {
  margin: 0.5rem 0;
  line-height: 1.6;
}

.about-section strong {
  color: #fff;
  font-weight: 600;
}

/* ========================================
   18. LEVEL PROGRESS CIRCLES
   ======================================== */

.level-heading {
  border-bottom: 2px solid var(--card-border);
  padding-bottom: 1rem;
  margin-bottom: 1.5rem;
}

.level-title-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 0;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
}

.level-progress-circles {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-top: 5px;
}

.level-progress-circle {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--muted);
  background: transparent;
  transition: all 0.2s ease;
}

.level-progress-circle.completed {
  background: var(--accent);
}

.level-stats-summary {
  display: flex;
  gap: 2rem;
  margin-top: 0.75rem;
  font-size: 0.875rem;
}

.level-stat {
  color: var(--muted);
  font-weight: 500;
}

.level-wpm-change {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 2px 5px;
  border-radius: 4px;
  white-space: nowrap;
  margin-left: 6px;
}

/* ========================================
   19. STATS PAGE
   ======================================== */

#statsView {
  padding: 0;
}

.stats-content {
  max-width: 800px;
  margin: 0 auto;
}

.stats-content h1 {
  font-size: 2.5rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: 2rem;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stats-overview,
.level-stats {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.stats-overview h2,
.level-stats h2 {
  color: var(--accent);
  font-size: 1.5rem;
  margin-top: 0;
  margin-bottom: 1rem;
  font-weight: 700;
}

.level-stats h2 {
  color: var(--accent-2);
}

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

.stat-item {
  background: var(--panel);
  border: 1px solid var(--card-border);
  border-radius: 6px;
  padding: 1rem;
  text-align: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-item:hover {
  transform: translateY(-2px);
}

.stat-label {
  font-size: 0.875rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: #fff;
  line-height: 1;
}

.stat-percent {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--accent-2);
  opacity: 0.85;
}

/* ========================================
   20. BADGES VIEW
   ======================================== */

#badgesView {
  padding: 0;
}

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

.badges-header {
  margin-bottom: 2rem;
}

.badges-header h1 {
  font-size: 2.5rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: 0.5rem;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.badges-summary {
  font-size: 1.1rem;
  color: var(--muted);
}

.badge-category-section {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.badge-category-title {
  color: var(--accent);
  font-size: 1.3rem;
  margin-top: 0;
  margin-bottom: 1rem;
  font-weight: 700;
  border-bottom: 1px solid var(--card-border);
  padding-bottom: 0.75rem;
}

.badge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 1rem;
}

.badge-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease;
}

.badge-item:hover {
  background: var(--panel-2);
  transform: translateY(-2px);
}

.badge-item.earned {
  /* Earned badges have full color */
}

.badge-item.locked {
  opacity: 0.6;
}

.badge-image {
  width: 80px;
  height: 80px;
  object-fit: contain;
  margin-bottom: 0.5rem;
  transition: filter 0.2s ease;
}

.badge-image.grayscale {
  filter: grayscale(100%) brightness(0.7);
}

.badge-item:hover .badge-image.grayscale {
  filter: grayscale(50%) brightness(0.85);
}

.badge-name {
  font-size: 0.8rem;
  color: var(--text);
  font-weight: 500;
  line-height: 1.2;
}

/* ========================================
   21. BADGE DETAIL MODAL
   ======================================== */

.badge-modal-content {
  max-width: 400px;
}

.badge-detail {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.badge-detail-image {
  width: 180px;
  height: 180px;
  object-fit: contain;
  margin-bottom: 1rem;
}

.badge-detail-image.grayscale {
  filter: grayscale(100%) brightness(0.7);
}

.badge-detail-name {
  font-size: 1.5rem;
  font-weight: 700;
  color: #fff;
  margin: 0 0 0.5rem 0;
}

.badge-detail-description {
  font-size: 1rem;
  color: var(--text);
  margin: 0 0 1rem 0;
  line-height: 1.5;
}

.badge-detail-category {
  font-size: 0.85rem;
  color: var(--accent);
  background: rgba(96, 165, 250, 0.15);
  padding: 4px 12px;
  border-radius: 12px;
  margin-bottom: 0.75rem;
}

.badge-detail-earned {
  font-size: 0.9rem;
  color: var(--accent-2);
  font-weight: 500;
}

.badge-detail-locked {
  font-size: 0.9rem;
  color: var(--muted);
}

/* ========================================
   22. BADGE EARNED CELEBRATION MODAL
   ======================================== */

.badge-earned-content {
  max-width: 400px;
  text-align: center;
}

.badge-earned-celebration {
  padding: 1rem 0;
}

.badge-earned-header {
  font-size: 1.8rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: 1.5rem;
  background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: celebratePulse 0.6s ease-out;
}

.badge-earned-image {
  margin-bottom: 1rem;
}

.badge-earned-img {
  width: 200px;
  height: 200px;
  object-fit: contain;
  animation: badgeBounce 0.6s ease-out;
}

.badge-earned-name {
  font-size: 1.4rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 0.5rem;
}

.badge-earned-description {
  font-size: 1rem;
  color: var(--text);
  line-height: 1.5;
}

/* Badge earned animations */
@keyframes celebratePulse {
  0% {
    transform: scale(0.8);
    opacity: 0;
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes badgeBounce {
  0% {
    transform: scale(0) rotate(-10deg);
    opacity: 0;
  }
  50% {
    transform: scale(1.15) rotate(5deg);
  }
  75% {
    transform: scale(0.95) rotate(-2deg);
  }
  100% {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
}

/* ========================================
   23. BADGES RESPONSIVE ADJUSTMENTS
   ======================================== */

@media (max-width: 600px) {
  .badge-grid {
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 0.75rem;
  }

  .badge-image {
    width: 60px;
    height: 60px;
  }

  .badge-name {
    font-size: 0.7rem;
  }

  .badge-earned-img {
    width: 150px;
    height: 150px;
  }

  .badge-detail-image {
    width: 140px;
    height: 140px;
  }
}
