/* ===== THEME VARIABLES ===== */
:root {
  /* Default: Light Theme (Black & White) */
  --bg-primary: #ffffff;
  --bg-secondary: #f5f5f5;
  --bg-tertiary: #e8e8e8;
  --text-primary: #000000;
  --text-secondary: #333333;
  --text-tertiary: #666666;
  --border-color: #cccccc;
  --border-light: #dddddd;
  --accent-color: #000000;
  --accent-secondary: #333333;
  --input-bg: #ffffff;
  --input-border: #cccccc;
  --input-focus: #000000;
  --label-color: #333333;
  --button-primary: #000000;
  --button-primary-hover: #222222;
  --button-primary-text: #ffffff;
  --button-warning: #333333;
  --button-warning-text: #ffffff;
  --button-danger: #dd0000;
  --button-danger-text: #ffffff;
  --shadow: rgba(0, 0, 0, 0.1);
  --shadow-dark: rgba(0, 0, 0, 0.3);
  --stats-bg: #f0f0f0;
  --stats-border: #d0d0d0;
  --success-color: #008000;
  --success-light: #90EE90;
  --error-color: #dd0000;
}

.dark-theme {
  /* Dark Theme */
  --bg-primary: #1a1f2e;
  --bg-secondary: #252d3d;
  --bg-tertiary: #2d3748;
  --text-primary: #e2e8f0;
  --text-secondary: #cbd5e1;
  --text-tertiary: #94a3b8;
  --border-color: #3d4455;
  --border-light: #4a5568;
  --accent-color: #60a5fa;
  --accent-secondary: #3b82f6;
  --input-bg: #1a1f2e;
  --input-border: #3d4455;
  --input-focus: #60a5fa;
  --label-color: #94a3b8;
  --button-primary: #1a1f2e;
  --button-primary-hover: #252d3d;
  --button-primary-text: #e2e8f0;
  --button-warning: #fbbf24;
  --button-warning-text: #1a1f2e;
  --button-danger: #ef4444;
  --button-danger-text: #ffffff;
  --shadow: rgba(0, 0, 0, 0.3);
  --shadow-dark: rgba(0, 0, 0, 0.6);
  --stats-bg: #1e2938;
  --stats-border: #3d4455;
  --success-color: #4ade80;
  --success-light: #22c55e;
  --error-color: #ef4444;
}

/* ===== RESET & BASE ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  transition: background-color 0.5s ease, color 0.5s ease, border-color 0.5s ease;
}


html,
body {
  width: 100%;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica', sans-serif;
}


body {
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow-y: auto;
  overflow-x: hidden;
  transition: background-color 0.6s cubic-bezier(0.4, 0, 0.2, 1),
    color 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}


/* ===== HIDE ALL SCROLLBARS EXCEPT SELECT ===== */
*:not(select) {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

*:not(select)::-webkit-scrollbar {
  display: none;
}

/* ===== CUSTOM SCROLLBAR FOR SELECT DROPDOWN ===== */
select {
  scrollbar-width: thin;
  scrollbar-color: var(--border-light) var(--bg-secondary);
}

select::-webkit-scrollbar {
  width: 8px;
}

select::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

select::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 4px;
}

select::-webkit-scrollbar-thumb:hover {
  background: var(--border-color);
}


/* ===== SCREEN SYSTEM ===== */
.screen {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}


.screen.active {
  display: block;
  animation: fadeIn 0.4s ease;
}


@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes keyPressEffect {
  0% {
    transform: scale(1);
  }

  50% {
    transform: scale(0.98);
  }

  100% {
    transform: scale(1);
  }
}

@keyframes buttonClick {
  0% {
    transform: translateY(0);
    background-color: #60a5fa;
  }

  100% {
    transform: translateY(-2px);
    background-color: #3b82f6;
  }
}

@keyframes pulse {

  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(96, 165, 250, 0.7);
  }

  50% {
    box-shadow: 0 0 0 8px rgba(96, 165, 250, 0);
  }
}

@keyframes slideInStats {
  from {
    opacity: 0;
    transform: translateX(10px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes glow {

  0%,
  100% {
    text-shadow: 0 0 5px #60a5fa;
  }

  50% {
    text-shadow: 0 0 15px #60a5fa, 0 0 25px rgba(96, 165, 250, 0.6);
  }
}

@keyframes rotateSpin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

@keyframes zoomPulse {

  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.15);
  }
}

/* SVG Animations */
.stat-row:nth-child(1) svg {
  animation: rotateSpin 3s linear infinite;
}

.stat-row:nth-child(1) svg:hover {
  animation: rotateSpin 2s linear infinite;
}

.stat-row:nth-child(2) svg {
  animation: zoomPulse 1.5s ease-in-out infinite;
  transition: all 0.3s ease;
}

.stat-row:nth-child(3) svg {
  animation: zoomPulse 1.5s ease-in-out infinite;
  transition: all 0.3s ease;
}

.stat-row:nth-child(3) svg.no-rotation {
  animation: none;
  opacity: 0.5;
}


/* ========================================
   SELECTION SCREEN - DARK THEME
   ======================================== */
#selectionScreen.active {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
}


.container {
  background: var(--bg-secondary);
  border-radius: 20px;
  padding: 18px 24px;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 20px 60px var(--shadow-dark);
  border: 1px solid var(--border-color);
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}


.container h1 {
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 8px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  width: 100%;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-row .selection-brand-name {
  margin-bottom: 0;
  font-size: 24px;
  font-weight: 700;
  white-space: nowrap;
  margin-right: 8px;
  color: var(--text-primary);
}

.header-separator {
  width: 1px;
  height: 24px;
  background: var(--border-color);
  margin: 0 4px;
  opacity: 0.6;
}





/* Profile & Logout Icons - Perfect Parity */
.profile-icon,
.logout-btn {
  width: 36px !important;
  height: 36px !important;
  border-radius: 50% !important;
  box-sizing: border-box !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  cursor: pointer !important;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
  padding: 0 !important;
  border: 2px solid transparent !important;
  /* Base border property */
}

/* Red Logout Button Styling - Filled Red */
.logout-btn {
  background: #ff4d4d !important;
  color: white !important;
  border-color: #ff4d4d !important;
  box-shadow: 0 2px 6px rgba(255, 77, 77, 0.2);
}

.logout-btn:hover {
  background: #cc3d3d !important;
  border-color: #cc3d3d !important;
  box-shadow: 0 4px 12px rgba(255, 77, 77, 0.4) !important;
  transform: translateY(-2px) scale(1.05);
}

.logout-btn svg {
  width: 18px;
  height: 18px;
}


.logo-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
}



.theme-toggle-btn,
.control-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

.theme-toggle-btn:hover,
.control-btn:hover {
  background: var(--bg-primary);
  border-color: var(--accent-color);
  transform: translateY(-2px);
}

.theme-toggle-btn:active {
  transform: scale(0.95);
}

/* Theme icon sizing and transition */
.theme-icon {
  width: 18px;
  height: 18px;
  position: absolute;
  transition: transform 0.4s ease, opacity 0.4s ease;
}

/* Sun icon - visible in light mode, hidden in dark */
.sun-icon {
  opacity: 1;
  transform: rotate(0deg) scale(1);
  color: #f59e0b;
}

/* Moon icon - hidden in light mode, visible in dark */
.moon-icon {
  opacity: 0;
  transform: rotate(-90deg) scale(0.5);
  color: #a78bfa;
}

/* Dark theme - swap icons */
.dark-theme .sun-icon {
  opacity: 0;
  transform: rotate(90deg) scale(0.5);
}

.dark-theme .moon-icon {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

.logo-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  transition: all 0.2s;
}

.logo-icon:hover {
  transform: translateY(-2px) scale(1.05);
}

/* Profile Icon specific overrides */
.profile-icon {
  background: linear-gradient(135deg, var(--accent-color), var(--accent-secondary)) !important;
  border: 2px solid var(--border-color) !important;
  overflow: hidden !important;
}

.profile-icon:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 4px 12px var(--shadow);
}

.profile-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover !important;
}

.profile-icon span {
  color: white;
  font-weight: 700;
  font-size: 16px;
  /* Slightly smaller font for 36px */
}

/* Header Separator - Uniform */
.header-separator {
  width: 1px;
  height: 28px;
  background: var(--border-color);
  margin: 0 8px;
}


.pwa-btn {
  display: block;
  margin: 0 auto 12px;
  padding: 4px 12px;
  border: none;
  border-radius: 20px;
  background: var(--button-primary);
  color: var(--button-primary-text);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.pwa-btn[hidden] {
  display: none !important;
}

.req-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  color: var(--accent-color);
  background: rgba(96, 165, 250, 0.1);
  border-radius: 6px;
  flex-shrink: 0;
}

.req-icon svg {
  width: 100%;
  height: 100%;
  stroke: currentColor;
}


.pwa-btn:hover {
  background: var(--button-primary-hover);
  transform: scale(1.05);
}


/* ===== INPUT ROWS ===== */
.row {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
  align-items: center;
}


.num {
  width: 32px;
  height: 32px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  flex-shrink: 0;
  border: 1px solid var(--border-light);
}


.field {
  flex: 1;
}


.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--label-color);
  margin-bottom: 4px;
}


.field select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--input-border);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  max-height: 200px;
  overflow-y: auto;
}


.field select:focus {
  outline: none;
  border-color: var(--input-focus);
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.2);
}


.field select option {
  background: var(--bg-secondary);
  color: var(--text-primary);
}


#testSelect {
  background: var(--input-bg) !important;
  color: var(--text-primary) !important;
  border: 1px solid var(--input-border) !important;
  font-weight: 500 !important;
}


#testSelect option {
  background: var(--bg-secondary) !important;
  color: var(--text-primary) !important;
}


/* ===== LABEL WITH INFO ICON ===== */
.label-with-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.label-with-info label {
  margin-bottom: 0 !important;
}

.info-icon {
  width: 18px;
  height: 18px;
  color: var(--accent-color);
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease;
}

.info-icon:hover {
  transform: scale(1.1);
}

.info-icon svg {
  width: 100%;
  height: 100%;
}

/* ===== EXAM POPOVER ===== */
.exam-popover {
  position: absolute;
  top: calc(100% + 10px);
  /* Changed from bottom to top */
  right: -10px;
  width: 240px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 12px 16px;
  box-shadow: 0 10px 30px var(--shadow-dark);
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  /* Changed entry animation direction */
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

.info-icon:hover .exam-popover,
.info-icon.active .exam-popover {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.exam-popover::after {
  content: '';
  position: absolute;
  bottom: 100%;
  /* Changed from top to bottom */
  right: 13px;
  border-width: 6px;
  border-style: solid;
  border-color: transparent transparent var(--border-color) transparent;
  /* Point up */
}

.exam-popover strong {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.exam-popover p,
.req-item {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 4px;
  line-height: 1.4;
}

.req-item strong {
  margin-bottom: 0;
  display: inline;
  text-transform: none;
  font-size: inherit;
  color: var(--text-primary);
}

.req-desc {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-light);
  font-size: 11px;
  color: var(--text-tertiary);
  line-height: 1.4;
  font-style: italic;
}

@media (max-width: 480px) {
  .exam-popover {
    right: -50px;
    width: 200px;
  }

  .exam-popover::after {
    right: 53px;
  }
}



/* ===== START BUTTON - SPACE KEY STYLE ===== */
#startBtn,
.space-key-btn {
  width: 100%;
  padding: 16px 24px;
  margin-top: 10px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(180deg,
      var(--button-primary) 0%,
      color-mix(in srgb, var(--button-primary) 85%, black) 100%);
  color: var(--button-primary-text);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.1s ease;
  position: relative;

  /* 3D Keyboard Key Effect */
  box-shadow:
    0 6px 0 color-mix(in srgb, var(--button-primary) 60%, black),
    0 8px 15px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  transform: translateY(0);
}

#startBtn::before,
.space-key-btn::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 8px;
  right: 8px;
  height: 40%;
  background: linear-gradient(180deg,
      rgba(255, 255, 255, 0.15) 0%,
      transparent 100%);
  border-radius: 10px 10px 50% 50%;
  pointer-events: none;
}

#startBtn:hover,
.space-key-btn:hover {
  background: linear-gradient(180deg,
      var(--button-primary-hover) 0%,
      color-mix(in srgb, var(--button-primary-hover) 85%, black) 100%);
  box-shadow:
    0 6px 0 color-mix(in srgb, var(--button-primary-hover) 60%, black),
    0 10px 20px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

#startBtn:active,
.space-key-btn:active {
  transform: translateY(4px);
  box-shadow:
    0 2px 0 color-mix(in srgb, var(--button-primary) 60%, black),
    0 4px 8px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}


/* ===== COMPLETED LIST ===== */
.completed {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border-color);
}


.completed h3 {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-tertiary);
  margin-bottom: 6px;
}


.list {
  background: var(--input-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  max-height: 100px;
  overflow-y: auto;
}


.item {
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text-tertiary);
  border-bottom: 1px solid var(--border-color);
}

.item:hover {
  background: var(--bg-tertiary);
}

.item:last-child {
  border-bottom: none;
}


/* ===== SELECTION SCREEN FOOTER ===== */
.selection-footer {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
  text-align: center;
}

.performance-chart-wrapper {
  width: 100%;
  height: 300px;
  background: var(--bg-secondary);
  border-radius: 12px;
  padding: 10px;
  border: 1px solid var(--border-color);
  margin-bottom: 24px;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
}

#performanceChart {
  width: 100% !important;
  height: 100% !important;
}

.chart-container {
  display: flex;
  gap: 12px;
  justify-content: center;
  align-items: flex-end;
  height: 220px;
  padding: 0 10px 30px 10px;
  overflow: visible;
  background: var(--bg-primary);
  border-radius: 12px;
  border: 1px solid var(--border-color);
  box-shadow: inset 0 2px 4px var(--shadow);
}

.chart-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  max-width: 40px;
  position: relative;
}

.bar {
  width: 100%;
  border-radius: 6px 6px 2px 2px;
  transition: height 1s cubic-bezier(0.34, 1.56, 0.64, 1);
  cursor: help;
}

.bar-percent {
  font-size: 10px;
  font-weight: 800;
  color: var(--text-secondary);
  margin-bottom: 6px;
  opacity: 0.9;
}

.bar-label {
  margin-top: 10px;
  font-size: 14px;
  font-weight: 800;
  color: var(--text-primary);
  text-shadow: 0 1px 2px var(--shadow);
}

.perfect-score-msg {
  text-align: center;
  width: 100%;
  padding: 60px 0;
  color: var(--success-color);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.footer-links {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.footer-links a {
  color: var(--text-tertiary);
  text-decoration: none;
  font-size: 12px;
  font-weight: 500;
  transition: color 0.2s;
}

.footer-links a:hover {
  color: var(--text-primary);
}

.footer-separator {
  color: var(--text-tertiary);
  font-size: 12px;
}

.footer-copyright {
  font-size: 11px;
  color: var(--text-tertiary);
  margin: 0;
}


/* ===== AUTH FOOTER ===== */
.auth-footer {
  margin-top: 40px;
  padding: 20px 0;
  border-top: 1px solid var(--border-color);
}

.auth-footer .footer-content {
  text-align: center;
}

.auth-footer .footer-links-row {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.auth-footer .footer-links-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.auth-footer .footer-links-row a {
  color: var(--text-tertiary);
  text-decoration: none;
  font-size: 12px;
  font-weight: 500;
  transition: color 0.2s;
}

.auth-footer .footer-links-row a:hover {
  color: var(--text-primary);
  text-decoration: underline;
}

.auth-footer .footer-separator {
  color: var(--text-tertiary);
  font-size: 12px;
}

.auth-footer .footer-copyright {
  font-size: 11px;
  color: var(--text-tertiary);
  margin: 8px 0 0 0;
}

/* Mobile stacking for footer */
@media (max-width: 600px) {
  .auth-footer .footer-links-row.mobile-stack {
    flex-direction: column;
    gap: 12px;
  }

  .auth-footer .pc-only {
    display: none;
  }
}


/* ========================================
   TYPING SCREEN - DARK THEME
   ======================================== */
#typingScreen.active {
  display: flex;
}


.main-layout {
  display: flex;
  width: 100%;
  height: 100vh;
  overflow: hidden;
}


/* ===== LEFT PANEL - DARK ===== */
.left-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
  overflow: hidden;
  transition: background-color 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}


/* ===== PARAGRAPH DISPLAY ===== */
.paragraph-display {
  flex: 1;
  padding: 30px 50px;
  font-size: 20px;
  line-height: 1.9;
  color: var(--text-secondary);
  overflow-y: auto;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
}


.menu-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  background: var(--bg-secondary);
  color: var(--text-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 20px;
  cursor: pointer;
  display: none;
  transition: all 0.2s;
  z-index: 10;
}


.menu-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}


.menu-btn.hidden {
  opacity: 0;
  pointer-events: none;
}


.line {
  margin-bottom: 12px;
}


.word {
  display: inline;
  padding: 2px 0;
  transition: all 0.15s;
}


.word.current {
  background: var(--bg-secondary);
  border-bottom: 3px solid var(--accent-color);
  padding: 2px 4px;
}


.word.correct {
  color: var(--success-color);
}


.word.incorrect {
  color: var(--error-color);
  text-decoration: line-through;
}


/* ===== SEPARATOR ===== */
.separator {
  height: 1px;
  background: var(--border-color);
  margin: 0 50px;
  flex-shrink: 0;
}


/* ===== TYPING INPUT ===== */
.typed-wrapper {
  padding: 20px 50px 30px;
  background: var(--bg-secondary);
  flex-shrink: 0;
  border-top: 1px solid var(--border-color);
}


.typed-input {
  width: 100%;
  padding: 16px 18px;
  border: 2px solid var(--input-border);
  border-radius: 12px;
  background: var(--input-bg);
  font-size: 20px;
  line-height: 1.9;
  color: var(--text-primary);
  font-family: inherit;
  resize: none;
  height: 140px;
  outline: none;
  transition: all 0.25s ease;
}


.typed-input:focus {
  border-color: var(--input-focus);
  background: var(--bg-primary);
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.2);
}


.typed-input.wrong-word {
  animation: shake 0.3s;
  border-color: var(--error-color);
}

.typed-input.key-pressed {
  animation: keyPressEffect 0.15s ease-out;
  border-color: var(--input-focus);
  box-shadow: 0 0 12px rgba(96, 165, 250, 0.3);
}


@keyframes shake {

  0%,
  100% {
    transform: translateX(0);
  }

  25% {
    transform: translateX(-4px);
  }

  75% {
    transform: translateX(4px);
  }
}


/* ========================================
   RIGHT PANEL - DARK SIDEBAR
   ======================================== */
.right-panel {
  width: 260px;
  background: var(--bg-secondary);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  box-shadow: -4px 0 20px var(--shadow-dark);
  flex-shrink: 0;
  border-left: 1px solid var(--border-color);
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}


.close-btn {
  display: none;
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: none;
  border-radius: 6px;
  font-size: 16px;
  cursor: pointer;
  z-index: 10;
}


/* ===== TIME DISPLAY ===== */
.time-section {
  background: var(--stats-bg);
  border: 1px solid var(--stats-border);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
  box-shadow: 0 2px 8px var(--shadow);
  transition: all 0.3s ease;
}

.time-section:hover {
  border-color: var(--accent-color);
  box-shadow: 0 4px 16px var(--shadow);
}

.time-section .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-tertiary);
  font-weight: 600;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.time-section .label svg {
  color: var(--accent-color);
  stroke-linecap: round;
  stroke-linejoin: round;
}

.time-section .value {
  font-size: 36px;
  font-weight: 700;
  font-family: 'Courier New', monospace;
  color: var(--text-primary);
  transition: all 0.2s ease;
}


/* ===== LIVE STATS CARD ===== */
.live-stats-card {
  background: var(--stats-bg);
  border: 1px solid var(--stats-border);
  border-radius: 12px;
  padding: 14px;
  box-shadow: 0 2px 8px var(--shadow);
  transition: all 0.3s ease;
}

.live-stats-card:hover {
  border-color: var(--accent-color);
  box-shadow: 0 4px 16px var(--shadow);
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  transition: all 0.2s ease;
}


.stat-row:not(:last-child) {
  border-bottom: 1px solid var(--stats-border);
}


.stat-label {
  font-size: 12px;
  color: var(--text-tertiary);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat-label svg {
  color: var(--accent-color);
  stroke-linecap: round;
  stroke-linejoin: round;
}

.stat-row:hover .stat-label svg {
  color: var(--accent-secondary);
}


.stat-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  transition: all 0.3s ease;
}

.stat-value:hover {
  animation: slideInStats 0.3s ease;
}

/* WPM Color States */
.live-wpm {
  color: #4ade80;
  transition: all 0.4s ease;
}

.live-wpm:hover {
  color: #22c55e;
  text-shadow: 0 0 8px rgba(34, 197, 94, 0.4);
}

.live-wpm.wpm-excellent {
  color: #10b981;
  text-shadow: 0 0 10px rgba(16, 185, 129, 0.5);
}

.live-wpm.wpm-good {
  color: #4ade80;
  text-shadow: 0 0 8px rgba(74, 222, 128, 0.4);
}

.live-wpm.wpm-fair {
  color: #f59e0b;
  text-shadow: 0 0 8px rgba(245, 158, 11, 0.4);
}

.live-wpm.wpm-poor {
  color: #ef4444;
  text-shadow: 0 0 8px rgba(239, 68, 68, 0.4);
}

/* Accuracy Color States */
#liveAccuracy {
  transition: all 0.4s ease;
  color: #4ade80;
}

#liveAccuracy.accuracy-excellent {
  color: #10b981;
  text-shadow: 0 0 10px rgba(16, 185, 129, 0.5);
}

#liveAccuracy.accuracy-good {
  color: #4ade80;
  text-shadow: 0 0 8px rgba(74, 222, 128, 0.4);
}

#liveAccuracy.accuracy-fair {
  color: #f59e0b;
  text-shadow: 0 0 8px rgba(245, 158, 11, 0.4);
}

#liveAccuracy.accuracy-poor {
  color: #ef4444;
  text-shadow: 0 0 8px rgba(239, 68, 68, 0.4);
}

.streak-row {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 10px 12px;
  margin-top: 8px;
  transition: all 0.3s ease;
}

/* Streak Color States */
.streak-value {
  color: #94a3b8;
  font-size: 20px;
  transition: all 0.4s ease;
}

.streak-value.streak-low {
  color: #94a3b8;
  opacity: 0.7;
}

.streak-value.streak-medium {
  color: #f59e0b;
  text-shadow: 0 0 8px rgba(245, 158, 11, 0.4);
}

.streak-value.streak-high {
  color: #4ade80;
  text-shadow: 0 0 10px rgba(74, 222, 128, 0.5);
}

.streak-value.streak-fire {
  color: #f97316;
  text-shadow: 0 0 12px rgba(249, 115, 22, 0.6);
  animation: pulse 0.8s ease-in-out infinite;
}

/* Timer Color Warning */
.time-section .value {
  transition: all 0.3s ease;
  color: var(--text-primary);
}

.time-section.time-warning {
  border-color: #ef4444;
  background: rgba(239, 68, 68, 0.05);
  animation: warningPulse 1s ease-in-out infinite;
  box-shadow: 0 0 16px rgba(239, 68, 68, 0.3);
}

.time-section.time-warning .label {
  color: #ef4444;
}

.time-section.time-warning .value {
  color: #ef4444;
  text-shadow: 0 0 12px rgba(239, 68, 68, 0.6);
}

.time-section.time-warning .label svg {
  color: #ef4444;
  animation: warningPulse 1s ease-in-out infinite;
}

@keyframes warningPulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.6;
  }
}


/* ===== PROGRESS CIRCLE - PERFECTLY CENTERED ===== */
.progress-circle-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 10px 0;
  width: 100%;
  flex-shrink: 0;
  min-height: 170px;
}

.progress-circle {
  display: block;
  transform: rotate(-90deg);
  margin: 0 auto;
}


.progress-bg {
  fill: none;
  stroke: var(--border-light);
  stroke-width: 8;
}


.progress-bar {
  fill: none;
  stroke: #4ade80;
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 408;
  stroke-dashoffset: 408;
  transition: stroke 0.6s ease, stroke-dashoffset 0.4s ease;
}

.progress-bar.progress-warning {
  stroke: #f59e0b;
}

.progress-bar.progress-danger {
  stroke: #ef4444;
  animation: pulse 1s ease-in-out infinite;
}


.progress-text {
  fill: var(--text-primary);
  font-size: 22px;
  font-weight: 700;
  text-anchor: middle;
  transform: rotate(90deg);
  transform-origin: center;
}


/* ===== SOUND TOGGLE ===== */
.control-row {
  background: var(--stats-bg);
  border: 1px solid var(--stats-border);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 8px var(--shadow);
}


.control-label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 600;
}


.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
}


.toggle-switch input {
  display: none;
}


.toggle-slider {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--border-light);
  border-radius: 24px;
  cursor: pointer;
  transition: 0.3s;
}


.toggle-slider:before {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  bottom: 3px;
  background: var(--text-primary);
  border-radius: 50%;
  transition: 0.3s;
}


input:checked+.toggle-slider {
  background: #4ade80;
}


input:checked+.toggle-slider:before {
  transform: translateX(20px);
  background: #ffffff;
}


/* ===== BUTTONS ===== */
.btn {
  width: 100%;
  padding: 11px;
  border: none;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 0.2s ease,
    background-color 0.2s ease,
    color 0.2s ease;
  box-shadow: 0 2px 6px var(--shadow);
}


.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 14px var(--shadow-dark);
}


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


.btn-warning {
  background: var(--button-warning);
  color: var(--button-warning-text);
}

.btn-warning:hover {
  background: #999999;
  color: #ffffff;
}

.btn-warning:active {
  background: #777777;
}


.btn-primary {
  background: var(--button-primary);
  color: var(--button-primary-text);
}

.btn-primary:hover {
  background: var(--button-primary-hover);
  box-shadow: 0 6px 20px var(--shadow);
}

.btn-primary:active {
  background: #111111;
  opacity: 0.9;
}


.btn-secondary {
  background: var(--border-light);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: var(--border-color);
}

.btn-secondary:active {
  background: #999999;
}

.btn-danger {
  background: var(--button-danger);
  color: var(--button-danger-text);
  border: 1px solid var(--error-color);
}

.btn-danger:hover {
  background: #bb0000;
  box-shadow: 0 6px 20px var(--shadow);
}

.btn-danger:active {
  background: #880000;
}

/* ===== DARK THEME BUTTON OVERRIDES ===== */
body.dark-theme .btn-primary {
  background: #1a1f2e;
  color: #e2e8f0;
  border: 1px solid #3d4455;
}

body.dark-theme .btn-primary:hover {
  background: #252d3d;
  border-color: #60a5fa;
}

body.dark-theme .btn-primary:active {
  background: #1a1f2e;
  border-color: #60a5fa;
  opacity: 0.7;
}

/* ========================================
   PAUSE OVERLAY
   ======================================== */
.pause-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(8px);
  z-index: 3000;
  align-items: center;
  justify-content: center;
}


.pause-overlay.show {
  display: flex;
}


.pause-content {
  background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-tertiary) 100%);
  border: 2px solid var(--accent-color);
  padding: 50px 70px;
  border-radius: 24px;
  text-align: center;
  box-shadow: 0 25px 80px var(--shadow), 0 0 60px var(--shadow);
  position: relative;
  animation: scaleIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-width: 500px;
}

.pause-content::before {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  border-radius: 24px;
  background: linear-gradient(135deg, var(--accent-color), var(--accent-secondary), var(--accent-color));
  z-index: -1;
  opacity: 0.2;
  animation: glow 3s ease-in-out infinite;
}

@keyframes scaleIn {
  from {
    transform: scale(0.8);
    opacity: 0;
  }

  to {
    transform: scale(1);
    opacity: 1;
  }
}

.pause-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 30px;
  padding: 20px;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 12px;
  border: 1px solid rgba(96, 165, 250, 0.2);
}

.pause-stat-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  text-align: center;
}

.pause-stat-label {
  font-size: 11px;
  color: var(--text-tertiary);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
}

.pause-stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--accent-color);
  font-family: 'Courier New', monospace;
}

.pause-icon {
  font-size: 56px;
  margin-bottom: 20px;
  animation: bounce 1.2s ease-in-out infinite;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100px;
  height: 100px;
  margin-left: auto;
  margin-right: auto;
  background: linear-gradient(135deg, rgba(96, 165, 250, 0.15), rgba(96, 165, 250, 0.05));
  border: 2px solid rgba(96, 165, 250, 0.2);
  border-radius: 16px;
}

.pause-icon svg {
  width: 56px;
  height: 56px;
  color: var(--accent-color);
  stroke: currentColor;
  fill: currentColor;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

@keyframes bounce {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-10px);
  }
}

.pause-content h2 {
  font-size: 32px;
  margin-bottom: 12px;
  color: var(--accent-color);
  font-weight: 700;
}


.pause-content p {
  font-size: 16px;
  color: var(--text-secondary);
  margin-bottom: 30px;
  font-weight: 500;
}


/* ========================================
   POPUP
   ======================================== */
.popup {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(5px);
  z-index: 2000;
  align-items: center;
  justify-content: center;
}


.popup.show {
  display: flex;
}


.popup-box {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  padding: 35px 55px;
  border-radius: 20px;
  text-align: center;
  box-shadow: 0 20px 60px var(--shadow-dark);
}


.popup-box h2 {
  font-size: 24px;
  margin-bottom: 8px;
  color: var(--text-primary);
}


.popup-box p {
  font-size: 14px;
  color: var(--text-tertiary);
  margin-bottom: 20px;
}


/* ========================================
   RESULTS SCREEN - DARK THEME
   ======================================== */
#resultsScreen {
  padding: 0;
  overflow: hidden;
}


#resultsScreen.active {
  display: block;
  background: var(--bg-primary);
}


.results-layout {
  display: flex;
  width: 100%;
  height: 100vh;
  overflow: hidden;
  gap: 20px;
  padding: 20px;
}


/* ===== RESULTS LEFT ===== */
.results-left {
  flex: 1;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 25px 30px;
  overflow-y: auto;
  box-shadow: 0 10px 40px var(--shadow-dark);
}


.results-header-row .results-title {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
}

#okBtn {
  color: var(--text-primary);
}


.results-left h1 {
  font-size: 24px;
  margin-bottom: 16px;
  color: var(--text-primary);
}


/* ===== STATUS BOX - BRIGHT & CLEAR ===== */
.status-box {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  background: var(--error-color);
  border: 3px solid var(--error-color);
  border-radius: 10px;
  margin-bottom: 16px;
  box-shadow: 0 0 25px rgba(239, 68, 68, 0.8);
}

.status-box.pass {
  background: var(--success-color);
  border: 3px solid var(--success-color);
  box-shadow: 0 0 25px rgba(74, 222, 128, 0.8);
}

.status-box .icon {
  font-size: 24px;
  color: #ffffff;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
  font-weight: bold;
}

.status-box.pass .icon {
  color: #ffffff;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}


.status-box strong {
  display: block;
  font-size: 16px;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 4px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
  letter-spacing: 0.5px;
}

.status-box.pass strong {
  color: #ffffff;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}


.status-box p {
  font-size: 13px;
  color: #ffffff;
  margin: 0;
  font-weight: 500;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.status-box.pass p {
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}


/* ===== STATS TABLE ===== */
.stats-table {
  width: 100%;
  border-top: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
  padding: 10px 0;
  margin-bottom: 16px;
  background: linear-gradient(to bottom, rgba(60, 82, 125, 0.1), rgba(96, 165, 250, 0.05));
  border-radius: 8px;
  transition: all 0.3s ease;
}

.stats-table:hover {
  background: linear-gradient(to bottom, rgba(60, 82, 125, 0.15), rgba(96, 165, 250, 0.1));
  border-color: var(--accent-color);
}

.stats-table tr {
  display: flex;
  justify-content: space-between;
  padding: 10px 12px;
  font-size: 13px;
  transition: all 0.2s ease;
  border-radius: 4px;
}

.stats-table tr:hover {
  background: rgba(96, 165, 250, 0.08);
}

.stats-table td:first-child {
  font-weight: 600;
  color: var(--text-tertiary);
}


.stats-table td:last-child {
  font-weight: 700;
  color: var(--accent-color);
  text-shadow: 0 0 8px rgba(96, 165, 250, 0.3);
}


/* ===== CHARTS ===== */
.results-left h3 {
  font-size: 15px;
  font-weight: 700;
  margin: 16px 0 10px;
  color: var(--text-secondary);
}


.chart-container {
  background: var(--input-bg);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 12px;
  min-height: 140px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 6px;
  margin-bottom: 12px;
}


.chart-bar {
  width: 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: all 0.2s ease;
}

.chart-bar:hover {
  transform: scale(1.1);
}

.bar {
  width: 100%;
  background: linear-gradient(180deg, #4ade80, #22c55e);
  border-radius: 4px 4px 0 0;
  transition: all 0.3s;
  box-shadow: 0 -2px 8px rgba(74, 222, 128, 0.3);
}


.bar:hover {
  transform: translateY(-3px);
  box-shadow: 0 2px 12px rgba(74, 222, 128, 0.5);
}


.bar.red {
  background: linear-gradient(180deg, #f87171, #ef4444);
  box-shadow: 0 -2px 8px rgba(239, 68, 68, 0.3);
}

.bar.red:hover {
  box-shadow: 0 2px 12px rgba(239, 68, 68, 0.5);
}

.bar-label {
  font-size: 11px;
  font-weight: 700;
  margin-top: 4px;
  color: #94a3b8;
}


/* ===== RESULTS RIGHT ===== */
.results-right {
  width: 280px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 25px 20px;
  overflow-y: auto;
  box-shadow: 0 10px 40px var(--shadow-dark);
  flex-shrink: 0;
}


.comment-header {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text-primary);
}


.comment-body p {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-secondary);
  padding: 10px 12px;
  background: var(--bg-tertiary);
  border-radius: 8px;
  border-left: 3px solid var(--accent-color);
  margin-bottom: 8px;
}


/* ===== OVERLAY ===== */
.overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 999;
}


.overlay.show {
  display: block;
}


/* ========================================
   RESPONSIVE - Mobile Adjustments
   ======================================== */
@media (max-width: 768px) {
  .main-layout {
    flex-direction: column;
  }


  .left-panel {
    height: 65vh;
  }


  .right-panel {
    width: 100%;
    height: 35vh;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 10px;
  }


  .menu-btn {
    display: flex;
  }


  .results-layout {
    flex-direction: column;
    height: auto;
    overflow-y: auto;
  }


  .results-right {
    width: 100%;
  }
}


/* ========================================
   ADVANCED ANALYSIS TOOLS
   ======================================== */
.advanced-analysis-toggle {
  margin: 24px 0 12px;
  display: flex;
  justify-content: center;
}

.toggle-analysis-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  padding: 10px 20px;
  border-radius: 30px;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.toggle-analysis-btn:hover {
  background: var(--input-bg);
  border-color: var(--accent-color);
  color: var(--text-primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px var(--shadow-dark);
}

.toggle-analysis-btn .toggle-icon {
  width: 16px;
  height: 16px;
  transition: transform 0.3s ease;
}

.advanced-analysis-content {
  overflow: hidden;
  transition: max-height 0.5s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease, padding 0.3s ease;
  background: rgba(15, 23, 42, 0.3);
  border-radius: 16px;
  border: 1px solid transparent;
}

.advanced-analysis-content.collapsed {
  max-height: 0;
  opacity: 0;
  padding: 0 16px;
  pointer-events: none;
}

.advanced-analysis-content.expanded {
  max-height: 2000px;
  opacity: 1;
  padding: 24px 16px;
  /* Increased padding for elegance */
  border-color: var(--border-color);
  margin-top: 12px;
  pointer-events: all;
}

.advanced-analysis-toggle .toggle-analysis-btn.active .toggle-icon {
  transform: rotate(180deg);
}

.analysis-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.analysis-section-header h4 {
  margin: 0;
  font-size: 16px;
  color: var(--text-primary);
  font-weight: 700;
  letter-spacing: 0.5px;
}

.heatmap-legend {
  display: flex;
  gap: 12px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-tertiary);
}

.color-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.color-dot.red {
  background: #ef4444;
}

.color-dot.yellow {
  background: #f59e0b;
}

.color-dot.green {
  background: #10b981;
}

.heatmap-keyboard-container {
  background: var(--bg-secondary);
  border-radius: 16px;
  padding: 24px;
  /* Generous padding for premium feel */
  border: 1px solid var(--border-color);
  overflow-x: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 30px;
  padding-top: 40px;
  /* Crucial fix for tooltip clipping */
}

.kb-row {
  display: flex;
  justify-content: center;
  gap: 6px;
}

.kb-key {
  width: 44px;
  /* Restored to comfortable size */
  height: 44px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--border-color);
  /* Premium key look */
}

.kb-key:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 0 var(--border-color), 0 8px 24px var(--shadow-dark);
  border-color: var(--accent-color);
  z-index: 10;
}

.kb-key.wide {
  min-width: 65px;
  flex-grow: 1;
}

.kb-key.space {
  min-width: 200px;
  height: 40px;
  flex-grow: 1.5;
}

/* Premium Tooltip */
.kb-key::after {
  content: attr(data-acc);
  position: absolute;
  bottom: 120%;
  left: 50%;
  transform: translateX(-50%) translateY(5px);
  background: var(--text-primary);
  color: var(--bg-primary);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s ease;
  white-space: nowrap;
  box-shadow: 0 4px 12px var(--shadow-dark);
  z-index: 20;
}

.kb-key:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.section-desc {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 4px;
}

.latency-grid {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  /* 9 columns for desktop (straight line) */
  gap: 6px;
  margin-top: 12px;
}

/* Premium Premium Latency Cards with Severity Coloring */
.latency-card {
  background: rgba(30, 41, 59, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 8px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  min-height: 48px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.latency-card:hover {
  transform: translateY(-4px) scale(1.05);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2), 0 10px 10px -5px rgba(0, 0, 0, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
  z-index: 2;
}

/* Severity Markers and Glows */
.latency-card.low {
  border-bottom: 2px solid #10b981;
}

.latency-card.mid {
  border-bottom: 2px solid #f59e0b;
}

.latency-card.high {
  border-bottom: 2px solid #ef4444;
}

.latency-card.low:hover {
  background: rgba(16, 185, 129, 0.15);
  border-color: #10b981;
}

.latency-card.mid:hover {
  background: rgba(245, 158, 11, 0.15);
  border-color: #f59e0b;
}

.latency-card.high:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: #ef4444;
}

.latency-key {
  font-size: 14px;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--text-secondary);
  opacity: 0.9;
  letter-spacing: 0.5px;
}

.latency-value-container {
  display: flex;
  align-items: baseline;
  gap: 1px;
}

.latency-value {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.latency-unit {
  font-size: 9px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: lowercase;
}

.latency-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 10px;
  color: var(--text-tertiary);
  font-style: italic;
  font-size: 13px;
}

@media (max-width: 1024px) {
  .latency-grid {
    grid-template-columns: repeat(3, 1fr);
    /* Transition to 3 on tablets (3x3 grid) */
  }
}

@media (max-width: 768px) {
  .kb-key {
    width: 36px;
    height: 36px;
    font-size: 11px;
  }

  .kb-row {
    gap: 4px;
  }

  .latency-grid {
    grid-template-columns: repeat(3, 1fr);
    /* 3x3 Grid on mobile */
  }
}

@media (max-width: 480px) {
  .kb-key {
    width: 28px;
    height: 28px;
    font-size: 10px;
    box-shadow: 0 2px 0 var(--border-color);
  }

  .kb-key.space {
    min-width: 100px;
  }

  .latency-grid {
    grid-template-columns: repeat(3, 1fr);
    /* 3x3 Grid on mobile */
    gap: 6px;
  }

  .latency-card {
    padding: 6px 4px;
    min-height: 40px;
  }

  .latency-key,
  .latency-value {
    font-size: 13px;
  }
}


/* ========================================
   PROFILE MODAL - PREMIUM DESIGN
   ======================================== */

/* Profile Modal Overlay */
#profileModal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  z-index: 2000;
  justify-content: center;
  align-items: center;
  padding: 20px;
  overflow-y: auto;
}

#profileModal.show {
  display: flex;
  animation: fadeIn 0.3s ease;
}

/* Profile Card */
.profile-card {
  background: var(--bg-secondary);
  border-radius: 20px;
  padding: 24px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 25px 80px rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-color);
  animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.95);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}



/* Close Button */
.close-profile-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  background: transparent;
  border: none;
  font-size: 24px;
  color: var(--text-tertiary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  z-index: 10;
}

.close-profile-btn:hover {
  color: var(--text-primary);
  transform: scale(1.1);
  background: var(--bg-tertiary);
  border-radius: 8px;
  /* Rounded square instead of circle */
}

/* Profile Header */
.profile-header {
  text-align: center;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 20px;
}

.profile-avatar-large {
  width: 90px;
  height: 90px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-color), var(--accent-secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: 0 8px 25px rgba(96, 165, 250, 0.3);
  border: 3px solid var(--bg-primary);
}

.profile-avatar-large img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-avatar-large #profileInitials {
  font-size: 36px;
  font-weight: 700;
  color: white;
  text-transform: uppercase;
}

#profileName {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.profile-since {
  font-size: 12px;
  color: var(--text-tertiary);
  margin: 0;
}

/* Stats Grid */
.profile-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.profile-stat {
  background: var(--bg-tertiary);
  border-radius: 12px;
  padding: 12px 6px;
  text-align: center;
  border: 1px solid var(--border-color);
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.profile-stat:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px var(--shadow);
}


.profile-stat .stat-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.profile-stat .stat-label {
  font-size: 10px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Profile Sections */
.profile-section {
  margin-bottom: 20px;
}

.section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title svg {
  width: 18px;
  height: 18px;
  color: var(--accent-color);
}

/* Personal Bests - Premium Style */
.personal-bests {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.best-item {
  background: linear-gradient(135deg, var(--bg-tertiary) 0%, var(--bg-secondary) 100%);
  border-radius: 16px;
  padding: 16px;
  text-align: center;
  border: 1px solid var(--border-color);
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.best-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--accent-color);
  opacity: 0.5;
}

.best-item:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
  border-color: var(--accent-color);
}

.best-label {
  display: block;
  font-size: 11px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
  font-weight: 600;
}

.best-value {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-primary);
}

/* Improvement Cards - Premium Style */
.improvement-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.improvement-card {
  background: var(--bg-tertiary);
  border-radius: 20px;
  padding: 24px 20px;
  text-align: center;
  border: 1px solid var(--border-color);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.improvement-card:hover {
  transform: translateY(-5px) scale(1.02);
  box-shadow: 0 15px 35px var(--shadow-dark);
}

.improvement-card.positive {
  border-color: rgba(16, 185, 129, 0.4);
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.15) 0%, var(--bg-tertiary) 100%);
}

.improvement-card.positive:hover {
  box-shadow: 0 15px 35px rgba(16, 185, 129, 0.25);
  border-color: rgba(16, 185, 129, 0.6);
}

.improvement-card.negative {
  border-color: rgba(239, 68, 68, 0.4);
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.15) 0%, var(--bg-tertiary) 100%);
}

.improvement-card.negative:hover {
  box-shadow: 0 15px 35px rgba(239, 68, 68, 0.25);
  border-color: rgba(239, 68, 68, 0.6);
}

.improvement-bg-icon {
  position: absolute;
  right: -10px;
  bottom: -10px;
  width: 100px;
  height: 100px;
  opacity: 0.1;
  transform: rotate(-15deg);
  pointer-events: none;
  transition: all 0.5s ease;
}

.improvement-card:hover .improvement-bg-icon {
  transform: rotate(0deg) scale(1.2);
  opacity: 0.2;
}

.improvement-bg-icon svg {
  width: 100%;
  height: 100%;
  color: var(--accent-color);
}

.positive .improvement-bg-icon svg {
  color: #10b981;
}

.negative .improvement-bg-icon svg {
  color: #ef4444;
}

.improvement-info {
  position: relative;
  z-index: 1;
}


.improvement-value {
  font-size: 32px;
  font-weight: 800;
  display: inline-block;
  vertical-align: middle;
  letter-spacing: -1px;
}

.improvement-label {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 4px;
  display: block;
  font-weight: 500;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.positive .improvement-arrow,
.positive .improvement-value {
  color: #10b981;
  text-shadow: 0 2px 10px rgba(16, 185, 129, 0.3);
}

.negative .improvement-arrow,
.negative .improvement-value {
  color: #ef4444;
  text-shadow: 0 2px 10px rgba(239, 68, 68, 0.3);
}

/* Badges Grid - SHINING EFFECT */
.badges-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.badge-item {
  position: relative;
  background: var(--bg-tertiary);
  border-radius: 12px;
  padding: 12px 8px;
  text-align: center;
  border: 1px solid var(--border-color);
  overflow: hidden;
  transition: all 0.3s;
}

.badge-item.locked {
  opacity: 0.5;
  filter: grayscale(1);
}

.badge-item.earned {
  background: linear-gradient(135deg, rgba(96, 165, 250, 0.15), var(--bg-tertiary));
  border-color: var(--accent-color);
}

/* Shining Animation for Earned Badges */
.badge-item.earned::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(45deg,
      transparent 30%,
      rgba(255, 255, 255, 0.15) 50%,
      transparent 70%);
  animation: badgeShine 3s ease-in-out infinite;
  pointer-events: none;
}

@keyframes badgeShine {
  0% {
    transform: translateX(-100%) rotate(45deg);
  }

  50%,
  100% {
    transform: translateX(100%) rotate(45deg);
  }
}

.badge-icon {
  width: 36px;
  height: 36px;
  margin: 0 auto 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-color), var(--accent-secondary));
  box-shadow: 0 4px 12px rgba(96, 165, 250, 0.3);
}

.badge-icon svg {
  width: 20px;
  height: 20px;
  color: white;
  stroke: white;
  fill: none;
}

.badge-item.locked .badge-icon {
  background: var(--bg-secondary);
  box-shadow: none;
}

.badge-item.locked .badge-icon svg {
  color: var(--text-tertiary);
  stroke: var(--text-tertiary);
}

.badge-name {
  font-size: 9px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-item:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px var(--shadow);
}

/* Badge Tooltip */
.badge-item[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-5px);
  background: var(--text-primary);
  color: var(--bg-primary);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 10px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s;
  z-index: 100;
}

.badge-item:hover[data-tooltip]::after {
  opacity: 1;
  transform: translateX(-50%) translateY(-10px);
}

/* Challenge Card */
.challenge-card {
  background: var(--bg-tertiary);
  border-radius: 12px;
  padding: 16px;
  border: 1px solid var(--border-color);
}

.challenge-title {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 10px;
}

.challenge-progress-bar {
  width: 100%;
  height: 8px;
  background: var(--bg-secondary);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 8px;
}

.challenge-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-color), var(--success-color));
  border-radius: 4px;
  transition: width 0.5s ease;
}

.challenge-status {
  font-size: 12px;
  color: var(--text-tertiary);
}

/* Profile Settings */
.profile-settings {
  background: var(--bg-tertiary);
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 20px;
  border: 1px solid var(--border-color);
}

.setting-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.setting-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.setting-label svg {
  width: 18px;
  height: 18px;
  color: var(--text-tertiary);
}

/* Profile Action Buttons */
.profile-actions {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}

.profile-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid var(--border-color);
}

.profile-btn svg {
  width: 18px;
  height: 18px;
}

.cert-btn {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: white;
  border-color: #d97706;
}

.cert-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(245, 158, 11, 0.4);
}

.share-btn {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

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

/* Recent Tests List */
.recent-tests-list {
  background: var(--bg-tertiary);
  border-radius: 12px;
  border: 1px solid var(--border-color);
  max-height: 180px;
  overflow-y: auto;
}

.no-tests {
  padding: 20px;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 13px;
}

.recent-test-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-color);
  transition: background 0.2s;
}

.recent-test-item:last-child {
  border-bottom: none;
}

.recent-test-item:hover {
  background: var(--bg-secondary);
}

.test-info {
  flex: 1;
}

.test-date {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-bottom: 2px;
}

.test-duration {
  font-size: 12px;
  color: var(--text-secondary);
}

.test-stats {
  display: flex;
  gap: 12px;
  text-align: right;
}

.test-wpm,
.test-acc {
  font-size: 13px;
  font-weight: 600;
}

.test-wpm {
  color: var(--accent-color);
}

.test-acc {
  color: var(--success-color);
}

/* Make profile icon clickable */
#userProfileIcon {
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

#userProfileIcon:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(96, 165, 250, 0.3);
}

/* Special Badge Colors */
.badge-speed .badge-icon {
  background: linear-gradient(135deg, #f59e0b, #fbbf24);
}

.badge-accuracy .badge-icon {
  background: linear-gradient(135deg, #10b981, #34d399);
}

.badge-marathon .badge-icon {
  background: linear-gradient(135deg, #8b5cf6, #a78bfa);
}

.badge-perfect .badge-icon {
  background: linear-gradient(135deg, #ec4899, #f472b6);
}

.badge-streak .badge-icon {
  background: linear-gradient(135deg, #ef4444, #f87171);
}

.badge-consistent .badge-icon {
  background: linear-gradient(135deg, #3b82f6, #60a5fa);
}

.badge-early .badge-icon {
  background: linear-gradient(135deg, #f97316, #fb923c);
}

.badge-night .badge-icon {
  background: linear-gradient(135deg, #6366f1, #818cf8);
}

/* ===== DAILY TASKS STYLING ===== */
.daily-reset-timer {
  margin-left: auto;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-tertiary);
  background: var(--bg-tertiary);
  padding: 4px 10px;
  border-radius: 12px;
}

.daily-tasks-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.daily-task {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg-tertiary);
  border-radius: 10px;
  border: 1px solid var(--border-color);
  transition: all 0.2s;
}

.daily-task.completed {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(16, 185, 129, 0.05));
  border-color: rgba(16, 185, 129, 0.3);
}

.daily-task .task-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-secondary);
  border: 2px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.daily-task.completed .task-icon {
  background: #10b981;
  border-color: #10b981;
  color: white;
}

.daily-task .task-info {
  flex: 1;
}

.daily-task .task-title {
  font-weight: 600;
  font-size: 13px;
  color: var(--text-primary);
}

.daily-task .task-desc {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

.daily-task .task-count {
  font-size: 11px;
  color: var(--accent-color);
  font-weight: 600;
  margin-top: 4px;
}

.daily-task .task-progress-bar {
  width: 60px;
  height: 6px;
  background: var(--bg-primary);
  border-radius: 3px;
  overflow: hidden;
  flex-shrink: 0;
}

.daily-task .task-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-color), var(--accent-secondary));
  border-radius: 3px;
  transition: width 0.3s ease;
}

.daily-task.completed .task-progress-fill {
  background: #10b981;
}

/* ===== BADGE TOOLTIP (Hover Info) ===== */
.badge-item {
  position: relative;
  cursor: pointer;
}

.badge-item .badge-tooltip {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px 12px;
  min-width: 180px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
  z-index: 100;
  pointer-events: none;
}

.badge-item:hover .badge-tooltip {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(-4px);
}

.badge-tooltip .tooltip-title {
  font-weight: 700;
  font-size: 13px;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.badge-tooltip .tooltip-desc {
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.badge-tooltip .tooltip-criteria {
  font-size: 10px;
  color: var(--accent-color);
  font-weight: 600;
  padding: 4px 8px;
  background: rgba(96, 165, 250, 0.1);
  border-radius: 4px;
  display: inline-block;
}

.badge-tooltip .tooltip-progress {
  margin-top: 8px;
  height: 4px;
  background: var(--bg-tertiary);
  border-radius: 2px;
  overflow: hidden;
}

.badge-tooltip .tooltip-progress-fill {
  height: 100%;
  background: var(--accent-color);
  border-radius: 2px;
}

.badge-tooltip .tooltip-season {
  margin-top: 6px;
  font-size: 10px;
  color: var(--text-tertiary);
  font-style: italic;
}

/* Badge Category Colors */
.badge-item[data-category="streak"] .badge-icon {
  background: linear-gradient(135deg, #3b82f6, #60a5fa);
}

.badge-item[data-category="accuracy"] .badge-icon {
  background: linear-gradient(135deg, #10b981, #34d399);
}

.badge-item[data-category="speed"] .badge-icon {
  background: linear-gradient(135deg, #f59e0b, #fbbf24);
}

.badge-item[data-category="endurance"] .badge-icon {
  background: linear-gradient(135deg, #8b5cf6, #a78bfa);
}

.badge-item[data-category="time"] .badge-icon {
  background: linear-gradient(135deg, #ec4899, #f472b6);
}

.badge-item[data-category="milestone"] .badge-icon {
  background: linear-gradient(135deg, #06b6d4, #22d3ee);
}

.badge-item[data-category="recovery"] .badge-icon {
  background: linear-gradient(135deg, #ef4444, #f87171);
}

.badge-item[data-category="leaderboard"] .badge-icon {
  background: linear-gradient(135deg, #f97316, #fb923c);
}

.badge-item[data-category="special"] .badge-icon {
  background: linear-gradient(135deg, #6366f1, #818cf8);
}

/* ===== ACHIEVEMENTS BUTTON - PREMIUM UPGRADE ===== */
.achievements-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
  background: linear-gradient(135deg, var(--bg-tertiary), var(--bg-secondary));
  border: 1px solid var(--border-color);
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

/* Shining Effect */
.achievements-btn::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -60%;
  width: 20%;
  height: 200%;
  background: linear-gradient(to right,
      rgba(255, 255, 255, 0) 0%,
      rgba(255, 255, 255, 0.15) 50%,
      rgba(255, 255, 255, 0) 100%);
  transform: rotate(25deg);
  transition: all 0.7s ease;
}

.achievements-btn:hover::after {
  left: 120%;
}

.achievements-btn:hover {
  border-color: var(--accent-color);
  transform: translateY(-4px) scale(1.01);
  box-shadow: 0 12px 30px var(--shadow-dark);
}

.achievements-btn-icon {
  width: 50px;
  height: 50px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent-color), var(--accent-secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.4s ease;
  box-shadow: 0 4px 12px var(--shadow);
}

.achievements-btn:hover .achievements-btn-icon {
  transform: rotate(10deg) scale(1.1);
  box-shadow: 0 6px 15px rgba(96, 165, 250, 0.4);
}

.achievements-btn-icon svg {
  width: 28px;
  height: 28px;
  color: white;
  stroke: white;
}

.achievements-btn-info {
  flex: 1;
  text-align: left;
}

.achievements-btn-title {
  display: block;
  font-size: 17px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.achievements-btn-count {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-tertiary);
  margin-top: 2px;
  opacity: 0.8;
}

.achievements-btn-arrow {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  transition: all 0.3s ease;
  border: 1px solid var(--border-color);
}

.achievements-btn:hover .achievements-btn-arrow {
  background: var(--accent-color);
  color: white !important;
  border-color: var(--accent-color);
  transform: translateX(4px);
}

.achievements-btn:hover .achievements-btn-arrow svg {
  color: white !important;
  stroke: white !important;
}

.achievements-btn-arrow svg {
  width: 20px;
  height: 20px;
}

/* ===== DAILY TASKS ===== */
.daily-tasks-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 20px;
}

.daily-task {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
}

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

.daily-task.completed {
  border-color: var(--accent-color);
  background: rgba(96, 165, 250, 0.05);
}

.task-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.daily-task.completed .task-icon {
  background: var(--accent-color);
  color: white;
}

.task-icon svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

.task-info {
  flex: 1;
}

.task-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.task-desc {
  font-size: 11px;
  color: var(--text-tertiary);
}

.task-count {
  font-size: 11px;
  color: var(--accent-color);
  font-weight: 600;
  margin-top: 2px;
}

.task-progress-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: transparent;
}

.task-progress-fill {
  height: 100%;
  background: var(--accent-color);
  width: 0%;
  transition: width 0.5s ease;
}

.achievements-btn-arrow {
  width: 20px;
  height: 20px;
  color: var(--text-tertiary);
  flex-shrink: 0;
  transition: transform 0.2s;
}

.achievements-btn:hover .achievements-btn-arrow {
  transform: translateX(4px);
  color: var(--accent-color);
}

/* ===== ACHIEVEMENTS MODAL ===== */
.achievements-card {
  width: 90%;
  max-width: 600px;
  max-height: 85vh;
  background: var(--bg-secondary);
  border-radius: 16px;
  border: 1px solid var(--border-color);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.achievements-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-tertiary);
}

.achievements-header h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  flex: 1;
}

.achievements-header h2 svg {
  width: 24px;
  height: 24px;
  color: var(--accent-color);
}

.achievements-progress {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-color);
  background: rgba(96, 165, 250, 0.1);
  padding: 6px 12px;
  border-radius: 20px;
}

.close-achievements-btn {
  width: 32px;
  height: 32px;
  background: transparent;
  border: none;
  font-size: 24px;
  color: var(--text-tertiary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.close-achievements-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-radius: 8px;
}

.achievements-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
}

/* Badge Categories */
.badge-category {
  margin-bottom: 24px;
}

.badge-category:last-child {
  margin-bottom: 0;
}

.category-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-secondary);
  margin: 0 0 12px 0;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
}

/* Badges Grid inside modal */
.achievements-content .badges-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(85px, 1fr));
  gap: 10px;
}

.achievements-content .badge-item {
  padding: 10px 8px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  text-align: center;
  transition: all 0.2s;
  position: relative;
  cursor: pointer;
  opacity: 0.5;
}

.achievements-content .badge-item.earned {
  opacity: 1;
  background: linear-gradient(135deg, rgba(96, 165, 250, 0.1), var(--bg-tertiary));
  border-color: var(--accent-color);
}

.achievements-content .badge-icon {
  width: 32px;
  height: 32px;
  margin: 0 auto 6px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.achievements-content .badge-icon svg {
  width: 18px;
  height: 18px;
  stroke: white;
}

.achievements-content .badge-name {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-secondary);
  line-height: 1.2;
}

/* Badge Tooltip */
/* Global Tooltip (JS positioned) */
.global-tooltip {
  position: fixed;
  /* Fixed to viewport to avoid clipping */
  z-index: 10000;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  padding: 12px;
  border-radius: 12px;
  width: 200px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
  text-align: left;
}

.global-tooltip.visible {
  opacity: 1;
  visibility: visible;
}

.tooltip-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.tooltip-desc {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  line-height: 1.4;
}

.tooltip-criteria {
  font-size: 11px;
  color: var(--accent-color);
  font-weight: 600;
  background: rgba(96, 165, 250, 0.1);
  padding: 4px 8px;
  border-radius: 6px;
  display: inline-block;
  margin-bottom: 8px;
}

.tooltip-progress {
  width: 100%;
  height: 4px;
  background: var(--bg-secondary);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 4px;
}

.tooltip-progress-fill {
  height: 100%;
  background: var(--accent-color);
  width: 0%;
}

.tooltip-season {
  font-size: 10px;
  color: var(--text-tertiary);
  margin-top: 6px;
  font-style: italic;
}

/* Mobile Adjustments */
@media (max-width: 768px) {
  .profile-icon {
    width: 44px;
    height: 44px;
  }
}

/* ===== DAILY CLAIM SECTION ===== */
.daily-claim-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: linear-gradient(135deg, var(--bg-tertiary) 0%, var(--bg-secondary) 100%);
  border-radius: 12px;
  margin-bottom: 12px;
  border: 1px solid var(--border-color);
}

.daily-claim-streak {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(0, 0, 0, 0.2);
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid var(--border-color);
}

.streak-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.streak-value {
  font-size: 16px;
  font-weight: 800;
  color: #FF6B6B;
  display: flex;
  align-items: center;
  gap: 4px;
}

.streak-value::before {
  content: '🔥';
  font-size: 16px;
  animation: flamePulse 1.5s infinite;
}

@keyframes flamePulse {
  0% {
    transform: scale(1);
    filter: brightness(100%);
  }

  50% {
    transform: scale(1.2);
    filter: brightness(120%);
  }

  100% {
    transform: scale(1);
    filter: brightness(100%);
  }
}

.daily-claim-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
  border: none;
  border-radius: 25px;
  color: #1a1a1a;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(255, 215, 0, 0.3);
}

.daily-claim-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(255, 215, 0, 0.5);
}

.daily-claim-btn:disabled {
  background: var(--bg-tertiary);
  color: var(--text-tertiary);
  cursor: not-allowed;
  box-shadow: none;
}

.daily-claim-btn svg {
  width: 16px;
  height: 16px;
}

/* ===== DAILY TASKS LIST ===== */
.daily-tasks-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.daily-task {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 14px;
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
}

.daily-task:hover {
  transform: translateX(4px);
  border-color: var(--accent-color);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.daily-task.completed {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), var(--bg-tertiary));
  border-color: rgba(16, 185, 129, 0.3);
}

.task-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
  background: var(--bg-primary);
  color: var(--text-tertiary);
  border: 2px solid var(--border-color);
}

.daily-task.completed .task-icon {
  background: #10B981;
  color: white;
  border-color: #10B981;
}

.task-info {
  flex: 1;
}

.task-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.task-desc {
  font-size: 11px;
  color: var(--text-tertiary);
}

.task-count {
  font-size: 10px;
  color: var(--accent-color);
  font-weight: 600;
  margin-top: 2px;
}

.task-progress-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: rgba(0, 0, 0, 0.1);
}

.task-progress-fill {
  height: 100%;
  background: var(--accent-color);
  transition: width 0.5s ease;
}

.daily-task.completed .task-progress-fill {
  background: #10B981;
}

/* ===== PUBLIC BADGE INFO MODAL ===== */
#publicBadgeInfoModal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  justify-content: center;
  align-items: center;
  z-index: 10000;
  padding: 20px;
}

.badge-info-card {
  background: var(--bg-primary);
  border: 2px solid var(--border-color);
  border-radius: 12px;
  padding: 30px;
  max-width: 350px;
  box-shadow: 0 10px 40px var(--shadow-dark);
  position: relative;
  animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.close-badge-info-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  font-size: 28px;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s ease;
}

.close-badge-info-btn:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.badge-info-content {
  text-align: center;
}

.badge-info-icon {
  font-size: 60px;
  margin-bottom: 15px;
  display: block;
}

.badge-info-card h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 10px 0;
}

.badge-info-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 12px 0;
  line-height: 1.4;
}

.badge-info-stats {
  margin-top: 20px;
  padding-top: 15px;
  border-top: 1px solid var(--border-light);
}

.badge-info-criteria {
  margin: 18px 0;
  padding: 12px;
  background: var(--bg-secondary);
  border-radius: 8px;
  border-left: 3px solid var(--accent-color);
}

.criteria-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.criteria-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.criteria-value {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-color);
  background: var(--bg-primary);
  padding: 4px 10px;
  border-radius: 4px;
  white-space: nowrap;
}

.progress-info {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.progress-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.progress-bar-small {
  width: 100%;
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #4CAF50, #81C784);
  border-radius: 4px;
  transition: width 0.3s ease;
}

.progress-value {
  font-size: 12px;
  color: var(--text-tertiary);
  font-weight: 600;
}

.badge-earned-text {
  font-size: 14px;
  font-weight: 600;
  color: #10B981;
  padding: 10px;
  background: rgba(16, 185, 129, 0.1);
  border-radius: 6px;
}

/* ===== UPDATE NOTIFICATION ===== */
.update-notification {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 4px 12px var(--shadow-dark);
  color: var(--text-primary);
  z-index: 10000;
  display: flex;
  align-items: center;
  gap: 12px;
  animation: slideInUpdate 0.3s ease-out;
  max-width: 300px;
}

@keyframes slideInUpdate {
  from {
    transform: translateY(100%);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.update-text {
  font-size: 13px;
  font-weight: 500;
}

.update-btn {
  background: var(--button-primary);
  color: var(--button-primary-text);
  border: none;
  border-radius: 4px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.update-btn:hover {
  background: var(--button-primary-hover);
}

.update-close {
  background: none;
  border: none;
  color: var(--text-tertiary);
  font-size: 18px;
  cursor: pointer;
  padding: 0;
  margin-left: 4px;
  line-height: 1;
}

.update-close:hover {
  color: var(--text-primary);
}

/* ========================================
   HISTORY MODAL - PREMIUM DESIGN
   ======================================== */
#historyModal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  z-index: 2050;
  /* Higher than profile modal */
  justify-content: center;
  align-items: center;
  padding: 20px;
}

#historyModal.show {
  display: flex;
  animation: fadeIn 0.3s ease;
}

.history-card {
  background: var(--bg-secondary);
  border-radius: 20px;
  padding: 24px;
  width: 100%;
  max-width: 420px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow: 0 25px 80px rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-color);
  animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.history-header {
  text-align: center;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 0;
  flex-shrink: 0;
}

.history-header h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.history-header p {
  font-size: 13px;
  color: var(--text-tertiary);
  margin: 0;
}

.history-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  background: var(--bg-tertiary);
  border-radius: 12px;
  border: 1px solid var(--border-color);
  transition: transform 0.2s;
}

.history-item:hover {
  transform: translateX(4px);
  border-color: var(--accent-color);
}

.history-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.history-source {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  text-transform: capitalize;
}

.history-time {
  font-size: 11px;
  color: var(--text-tertiary);
}

.history-amount {
  font-size: 15px;
  font-weight: 700;
}

.history-amount.positive {
  color: var(--success-color);
}

.history-amount.negative {
  color: var(--error-color);
}

.history-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-tertiary);
  font-size: 14px;
}

.close-history-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  background: transparent;
  border: none;
  font-size: 24px;
  color: var(--text-tertiary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  z-index: 10;
}

.close-history-btn:hover {
  color: var(--text-primary);
  transform: scale(1.1);
  background: var(--bg-tertiary);
  border-radius: 8px;
}


/* ========================================
   NEURAL DWELL HEATMAP
   ======================================== */
.heatmap-container {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 20px 0;
  overflow-x: auto;
  /* Allow scrolling on very small screens */
}

.heatmap-row {
  display: flex;
  gap: 6px;
  justify-content: center;
}

.heatmap-key {
  width: 40px;
  height: 40px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  /* Rounded squares */
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Roboto Mono', monospace;
  font-weight: 700;
  font-size: 14px;
  color: var(--text-secondary);
  transition: all 0.3s ease;
  user-select: none;
}

/* Key Sizes */
.key-space {
  width: 220px;
}

.key-shift {
  width: 85px;
}

.key-caps {
  width: 40px;
}

/* Simplification */

/* Heat Levels - Matches Neural Dwell Aesthetic (Orange/Brown) */
.heat-0 {
  /* No errors */
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

.heat-1 {
  /* Low Error Count */
  background: #ffedd5;
  /* Very Light Orange */
  border-color: #fed7aa;
  color: #c2410c;
}

.heat-2 {
  /* Medium Error Count */
  background: #fdba74;
  /* Orange */
  border-color: #fb923c;
  color: #7c2d12;
  box-shadow: 0 0 10px rgba(253, 186, 116, 0.4);
}

.heat-3 {
  /* High Error Count - Hot! */
  background: #ea580c;
  /* Dark Orange/Red */
  border-color: #c2410c;
  color: white;
  box-shadow: 0 0 15px rgba(234, 88, 12, 0.6);
  transform: scale(1.05);
  /* Pop out slightly */
  z-index: 2;
}

/* Dark Mode Adjustments for Heatmap */
body.dark-mode .heat-1 {
  background: #431407;
  border-color: #7c2d12;
  color: #fdba74;
}

body.dark-mode .heat-2 {
  background: #9a3412;
  border-color: #ea580c;
  color: white;
}

body.dark-mode .heat-3 {
  background: #ea580c;
  border-color: #f97316;
  color: white;
}

/* Mobile Responsiveness */
@media (max-width: 600px) {
  .heatmap-key {
    width: 28px;
    height: 32px;
    font-size: 11px;
    border-radius: 4px;
    gap: 3px;
  }

  .heatmap-row {
    gap: 3px;
  }

  .key-space {
    width: 140px;
  }

  .key-shift {
    width: 45px;
  }
}

@media (max-width: 380px) {
  .heatmap-key {
    width: 24px;
    height: 28px;
    font-size: 10px;
  }
}


/* ========================================
   DEEP ANALYSIS & MOBILE FIXES
   ======================================== */

/* Mobile Overflow Fix */
.heatmap-container {
  overflow-x: auto;
  padding: 10px;
  -webkit-overflow-scrolling: touch;
  /* Ensure it doesn't get cut off */
  max-width: 100%;
  box-sizing: border-box;
}

/* Theme-Aware Heatmap Colors */
/* We use the theme's accent color with different opacities */
.heat-1 {
  /* Low Heat */
  background: color-mix(in srgb, var(--accent-color) 20%, var(--bg-tertiary));
  color: var(--text-primary);
  border-color: color-mix(in srgb, var(--accent-color) 40%, transparent);
}

.heat-2 {
  /* Medium Heat */
  background: color-mix(in srgb, var(--accent-color) 50%, var(--bg-tertiary));
  color: var(--bg-primary);
  /* Contrast text */
  border-color: var(--accent-color);
  font-weight: 800;
}

.heat-3 {
  /* High Heat */
  background: var(--accent-color);
  color: var(--bg-primary);
  /* Contrast text */
  box-shadow: 0 0 15px color-mix(in srgb, var(--accent-color) 60%, transparent);
  transform: scale(1.05);
  font-weight: 900;
}

/* Fallback for browsers not supporting color-mix (Optional, but good practice) */
@supports not (color: color-mix(in srgb, red, blue)) {
  .heat-1 {
    background: rgba(255, 165, 0, 0.2);
  }

  .heat-2 {
    background: rgba(255, 165, 0, 0.6);
  }

  .heat-3 {
    background: rgb(255, 69, 0);
    color: white;
  }
}


/* Deep Analysis Cards */
.deep-analysis-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 15px;
  margin-top: 20px;
  width: 100%;
}

.latency-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 15px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  transition: transform 0.2s ease;
}

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

.latency-key {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.latency-value {
  font-size: 1.15rem;
  font-weight: 900;
  color: var(--accent-color);
}

.latency-label {
  font-size: 0.8rem;
  color: var(--text-tertiary);
  margin-top: 4px;
}

/* Logo Highlight part */
.text-highlight {
  color: #1976d2;
  /* Default Blue for Light Theme */
}

body.dark-theme .text-highlight {
  color: #60a5fa;
  /* Default Blue for Dark Theme */
}

/* Allow themes to override */
body[data-shop-theme] .text-highlight {
  color: var(--accent-color);
}

/* Discord Connect Styles */
.discord-status-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(88, 101, 242, 0.1);
  border: 1px solid rgba(88, 101, 242, 0.2);
  border-radius: 12px;
  padding: 16px;
  margin-top: 10px;
  transition: all 0.3s ease;
}

.discord-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.discord-logo {
  color: #5865F2;
  filter: drop-shadow(0 2px 4px rgba(88, 101, 242, 0.3));
}

.discord-text {
  display: flex;
  flex-direction: column;
}

.discord-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.discord-tag {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.discord-btn {
  background: #5865F2;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 13px;
}

.discord-btn:hover {
  background: #4752C4;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(88, 101, 242, 0.4);
}

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

.discord-btn.linked {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  cursor: default;
}

.discord-btn.linked:hover {
  transform: none;
  box-shadow: none;
}

.discord-bonus-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, #5865F2, #854CF2);
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
  margin-top: 8px;
  width: fit-content;
  animation: pulse-border 2s infinite;
}

@keyframes pulse-border {
  0% {
    box-shadow: 0 0 0 0 rgba(88, 101, 242, 0.4);
  }

  70% {
    box-shadow: 0 0 0 6px rgba(88, 101, 242, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(88, 101, 242, 0);
  }
}

/* Dark theme adjustments */
body.dark-theme .discord-status-card {
  background: rgba(88, 101, 242, 0.15);
  border-color: rgba(88, 101, 242, 0.3);
}

/* Toast Notification System */
.toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: none;
}

.toast {
  min-width: 300px;
  max-width: 400px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  transform: translateX(120%);
  transition: all 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  pointer-events: auto;
  backdrop-filter: blur(8px);
}

.toast.show {
  transform: translateX(0);
}

.toast-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.toast-success .toast-icon {
  background: rgba(74, 222, 128, 0.15);
  color: #4ade80;
}

.toast-error .toast-icon {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

.toast-discord .toast-icon {
  background: rgba(88, 101, 242, 0.15);
  color: #5865F2;
}

.toast-content {
  flex: 1;
}

.toast-title {
  font-weight: 700;
  font-size: 14px;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.toast-message {
  font-size: 13px;
  color: var(--text-tertiary);
  line-height: 1.4;
}

.toast-close {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 4px;
  font-size: 18px;
  line-height: 1;
  transition: color 0.2s;
}

.toast-close:hover {
  color: var(--text-primary);
}

@keyframes toast-progress {
  from {
    width: 100%;
  }

  to {
    width: 0%;
  }
}

.toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: var(--accent-color);
  border-radius: 0 0 0 12px;
}

.toast-success .toast-progress {
  background: #4ade80;
}

.toast-error .toast-progress {
  background: #ef4444;
}

.toast-discord .toast-progress {
  background: #5865F2;
}

@media (max-width: 480px) {
  .toast-container {
    top: auto;
    bottom: 24px;
    right: 12px;
    left: 12px;
  }

  .toast {
    min-width: 0;
    width: 100%;
  }
}

/* Custom Confirmation Modal */
.custom-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  backdrop-filter: blur(4px);
}

.custom-modal-overlay.show {
  opacity: 1;
  visibility: visible;
}

.custom-modal-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  width: 90%;
  max-width: 380px;
  padding: 30px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  transform: translateY(20px);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  text-align: center;
}

.custom-modal-overlay.show .custom-modal-card {
  transform: translateY(0);
}

.custom-modal-icon {
  width: 60px;
  height: 60px;
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  margin: 0 auto 20px;
}

.custom-modal-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.custom-modal-body {
  font-size: 15px;
  color: var(--text-tertiary);
  line-height: 1.5;
  margin-bottom: 30px;
}

.custom-modal-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.custom-modal-btn {
  flex: 1;
  padding: 12px 0;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
}

.custom-modal-btn-cancel {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.custom-modal-btn-cancel:hover {
  background: var(--border-color);
}

.custom-modal-btn-confirm {
  background: #ef4444;
  color: white;
}

.custom-modal-btn-confirm:hover {
  background: #dc2626;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

/* Guest Conversion UI */
.guest-conversion-card {
  border: 2px solid #1976d2 !important;
  position: relative;
  overflow: hidden;
  background: rgba(25, 118, 210, 0.05) !important;
}

.dark-theme .guest-conversion-card {
  background: rgba(96, 165, 250, 0.1) !important;
  border-color: #60a5fa !important;
}

.guest-hook-cta-btn {
  margin-top: 0.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #1976d2;
  color: white !important;
  padding: 0.6rem 1.25rem;
  border-radius: 8px;
  font-weight: 700;
  text-decoration: none;
  font-size: 0.9rem;
  transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(25, 118, 210, 0.2);
  width: fit-content;
}

.dark-theme .guest-hook-cta-btn {
  background: #60a5fa;
  box-shadow: 0 4px 12px rgba(96, 165, 250, 0.2);
}

.guest-hook-cta-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(25, 118, 210, 0.3);
  text-decoration: none;
  opacity: 0.9;
}

.dark-theme .guest-hook-cta-btn:hover {
  box-shadow: 0 6px 16px rgba(96, 165, 250, 0.4);
}