/* Compatibility note: this legacy-named sheet still contains unscoped
   site-wide rules such as .page-title. Keep it loaded until those selectors
   are moved to their owning components. */
.page-eeg_lead_practice {
  display: flex;
  flex-direction: column;
  max-width: 1440px;
  margin: 0 auto;
  position: relative;
  padding: 0 20px;
}

.page-title {
  text-align: center;
  font-size: 2.2rem;
  margin: 2rem 0 2rem 0;
  color: var(--primary-color);
  position: relative;
  padding-bottom: 12px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.page-title:after {
  content: '';
  position: absolute;
  width: 120px;
  height: 4px;
  background: linear-gradient(90deg, transparent, var(--accent-color), transparent);
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  border-radius: 2px;
}

#lead-practice-container {
  max-width: 1200px;
  margin: 0 auto 4rem;
  padding: 2rem;
  background: var(--card-bg);
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

/* App Introduction */
.app-intro {
  text-align: center;
  max-width: 800px;
  margin: 0 auto 2rem;
  line-height: 1.6;
  position: relative;
}

.tutorial-button {
  position: absolute;
  top: 20px;
  right: 20px;
  background: var(--accent-color);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
}

.tutorial-button i {
  font-size: 1.2rem;
}

.tutorial-button:hover {
  background: var(--accent-color-dark, #0056b3);
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.welcome-message {
  background-color: #e3f2fd;
  border-left: 4px solid var(--accent-color);
  padding: 15px 20px;
  margin: 0 0 20px 0;
  border-radius: 6px;
  text-align: left;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  animation: pulse 2s infinite;
}

.welcome-message h3 {
  color: var(--accent-color);
  margin: 0 0 8px 0;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  gap: 10px;
}

.welcome-message p {
  margin: 0;
  font-size: 1rem;
}

.welcome-message strong {
  color: var(--accent-color);
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(0, 136, 255, 0.4);
  }

  70% {
    box-shadow: 0 0 0 8px rgba(0, 136, 255, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(0, 136, 255, 0);
  }
}

/* Practice Area Styles */
.practice-area {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

@media (min-width: 992px) {
  .practice-area {
    flex-direction: row;
  }
}

/* Controls Section */
.controls-section {
  flex: 1;
  min-width: 250px;
}

.montage-selector {
  margin-bottom: 2rem;
}

.montage-selector select {
  width: 100%;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background-color: var(--card-bg);
  color: var(--text-color);
  font-size: 1rem;
}

/* Difficulty Selector Styles */
.difficulty-selector {
  margin-bottom: 2rem;
}

.difficulty-selector select {
  width: 100%;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background-color: var(--card-bg);
  color: var(--text-color);
  font-size: 1rem;
  margin-bottom: 10px;
}

.difficulty-info {
  background-color: var(--card-bg);
  border-left: 4px solid #17a2b8;
  padding: 10px 15px;
  border-radius: 4px;
  font-size: 0.9rem;
  transition: all 0.3s ease;
}

.difficulty-info.easy {
  border-left-color: #28a745;
  background-color: rgba(40, 167, 69, 0.1);
}

.difficulty-info.medium {
  border-left-color: #17a2b8;
  background-color: rgba(23, 162, 184, 0.1);
}

.difficulty-info.hard {
  border-left-color: #fd7e14;
  background-color: rgba(253, 126, 20, 0.1);
}

.difficulty-info.expert {
  border-left-color: #dc3545;
  background-color: rgba(220, 53, 69, 0.1);
}

/* Practice Mode Selector Styles */
.mode-selector {
  margin-bottom: 2rem;
}

.mode-selector select {
  width: 100%;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background-color: var(--card-bg);
  color: var(--text-color);
  font-size: 1rem;
  margin-bottom: 10px;
}

.mode-info {
  background-color: var(--card-bg);
  border-left: 4px solid #6c757d;
  padding: 10px 15px;
  border-radius: 4px;
  font-size: 0.9rem;
  margin-bottom: 15px;
  transition: all 0.3s ease;
}

.mode-info.standard {
  border-left-color: #6c757d;
  background-color: rgba(108, 117, 125, 0.1);
}

.mode-info.timed {
  border-left-color: #007bff;
  background-color: rgba(0, 123, 255, 0.1);
}

.mode-info.random {
  border-left-color: #6f42c1;
  background-color: rgba(111, 66, 193, 0.1);
}

.mode-info.guided {
  border-left-color: #20c997;
  background-color: rgba(32, 201, 151, 0.1);
}

.start-btn {
  background-color: var(--accent-color);
  color: white;
  padding: 12px 20px;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.start-btn:hover {
  background-color: var(--accent-color-dark, #0056b3);
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

/* Mode-specific UI elements */
.mode-specific-container {
  margin-bottom: 2rem;
}

.timer-display {
  font-size: 2.5rem;
  font-weight: bold;
  text-align: center;
  margin: 15px 0;
  color: #007bff;
  font-family: monospace;
  background-color: rgba(0, 123, 255, 0.1);
  border-radius: 8px;
  padding: 10px;
  border: 2px solid #007bff;
  transition: all 0.3s ease;
}

.timer-display.active {
  animation: pulse-timer 1s infinite alternate;
}

.timer-display.warning {
  color: #fd7e14;
  background-color: rgba(253, 126, 20, 0.1);
  border-color: #fd7e14;
}

.timer-display.danger {
  color: #dc3545;
  background-color: rgba(220, 53, 69, 0.1);
  border-color: #dc3545;
  animation: pulse-danger 0.5s infinite alternate;
}

@keyframes pulse-timer {
  from {
    opacity: 0.8;
  }

  to {
    opacity: 1;
  }
}

@keyframes pulse-danger {
  from {
    opacity: 0.7;
    transform: scale(0.98);
  }

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

.mode-prompt {
  background-color: var(--info-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 15px;
  margin-bottom: 15px;
  text-align: center;
  font-size: 1.1rem;
}

.mode-prompt.active {
  animation: highlight-prompt 2s infinite alternate;
}

.mode-prompt.success {
  background-color: rgba(40, 167, 69, 0.1);
  border-color: #28a745;
  color: #28a745;
}

@keyframes highlight-prompt {
  from {
    box-shadow: 0 0 0 rgba(0, 123, 255, 0.4);
  }

  to {
    box-shadow: 0 0 10px rgba(0, 123, 255, 0.7);
  }
}

/* Lead selection styles for practice modes */
.lead-item.highlight {
  transform: scale(1.1);
  box-shadow: 0 0 15px rgba(0, 123, 255, 0.7);
  border: 3px solid #007bff;
  animation: pulse-highlight 1.5s infinite alternate;
}

.lead-item.disabled {
  opacity: 0.3;
  cursor: not-allowed;
  background-color: #999;
}

@keyframes pulse-highlight {
  from {
    box-shadow: 0 0 5px rgba(0, 123, 255, 0.5);
  }

  to {
    box-shadow: 0 0 20px rgba(0, 123, 255, 0.9);
  }
}

/* Animations for correct/incorrect placements */
.eeg-lead.shake {
  animation: shake 0.5s cubic-bezier(.36, .07, .19, .97) both;
}

@keyframes shake {

  10%,
  90% {
    transform: translate(-51%, -51%) translate3d(-1px, 0, 0);
  }

  20%,
  80% {
    transform: translate(-49%, -51%) translate3d(2px, 0, 0);
  }

  30%,
  50%,
  70% {
    transform: translate(-51%, -49%) translate3d(-3px, 0, 0);
  }

  40%,
  60% {
    transform: translate(-49%, -49%) translate3d(3px, 0, 0);
  }
}

/* Lead Selection */
.leads-container {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  margin-bottom: 1.5rem;
  justify-content: center;
}

.lead-item {
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--accent-color);
  color: white;
  border: 2px solid var(--border-color);
  border-radius: 50%;
  cursor: move;
  transition: all 0.2s ease;
  font-weight: bold;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  user-select: none;
  position: relative;
  z-index: 10;
  touch-action: none;
  /* Important for mobile drag */
  -webkit-touch-callout: none;
  /* Prevent callout on long press */
}

.lead-item:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.lead-item.selected {
  background-color: var(--accent-color-dark, #0056b3);
  transform: scale(1.1);
}

.lead-item.placed {
  opacity: 0.5;
  background-color: #999;
  cursor: not-allowed;
}

/* Head Model Area */
.head-model-area {
  flex: 2;
  position: relative;
  min-height: 500px;
  background-color: var(--info-bg);
  border-radius: 12px;
  overflow: visible;
  display: flex;
  justify-content: center;
  align-items: center;
  touch-action: none;
  /* Prevent scrolling when dragging over head model */
}

.head-model {
  position: relative;
  width: 100%;
  max-width: 600px;
  aspect-ratio: 1 / 1;
}

.head-outline {
  position: absolute;
  top: 10%;
  left: 10%;
  width: 80%;
  height: 80%;
  border: 3px solid var(--text-color);
  border-radius: 50%;
  opacity: 0.7;
  background-color: rgba(255, 255, 255, 0.2);
}

/* Nose triangle at nasion position */
.head-outline:before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translate(-50%, -70%);
  width: 30px;
  height: 30px;
  background-color: var(--text-color);
  clip-path: polygon(0% 100%, 50% 0%, 100% 100%);
  opacity: 0.7;
  z-index: 2;
}

/* Cross lines for orientation */
.head-outline:after {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  background:
    linear-gradient(to right, transparent 49.5%, var(--text-color) 49.5%, var(--text-color) 50.5%, transparent 50.5%),
    linear-gradient(to bottom, transparent 49.5%, var(--text-color) 49.5%, var(--text-color) 50.5%, transparent 50.5%);
  opacity: 0.5;
  pointer-events: none;
}

/* Head direction indicators */
.direction-indicator {
  position: absolute;
  font-size: 1rem;
  color: var(--text-color);
  font-weight: bold;
  background-color: rgba(255, 255, 255, 0.9);
  padding: 3px 8px;
  border-radius: 4px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  z-index: 10;
  border: 1px solid var(--border-color);
}

.indicator-front {
  top: -35px;
  left: 50%;
  transform: translateX(-50%);
}

.indicator-back {
  bottom: -35px;
  left: 50%;
  transform: translateX(-50%);
}

.indicator-left {
  top: 50%;
  left: -40px;
  transform: translateY(-50%);
}

.indicator-right {
  top: 50%;
  right: -40px;
  transform: translateY(-50%);
}

/* Dropped Lead Styles */
.eeg-lead {
  position: absolute;
  width: 50px;
  height: 50px;
  background-color: var(--accent-color);
  color: white;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  cursor: grab;
  z-index: 5;
  user-select: none;
  touch-action: none;
  /* Important for mobile drag */
  -webkit-touch-callout: none;
  /* Prevent callout to copy image on long press */
}

.eeg-lead:hover {
  z-index: 6;
  transform: translate(-50%, -50%) scale(1.1);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.eeg-lead.correct {
  background-color: #28a745;
  border-color: #28a745;
  color: white;
  box-shadow: 0 0 10px rgba(40, 167, 69, 0.5);
}

.eeg-lead.incorrect {
  background-color: #dc3545;
  border-color: #dc3545;
  color: white;
  box-shadow: 0 0 10px rgba(220, 53, 69, 0.5);
}

/* Connection Line Styles */
.connection-line {
  position: absolute;
  height: 2px;
  background: rgba(0, 102, 204, 0.6);
  transform-origin: 0 0;
  z-index: 1;
  box-shadow: 0 0 3px rgba(0, 102, 204, 0.3);
}

/* Action Buttons */
.action-buttons {
  display: flex;
  gap: 1rem;
  margin-top: 1.5rem;
}

.action-btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.check-btn {
  background-color: var(--accent-color);
  color: white;
}

.reset-btn {
  background-color: #f8f9fa;
  color: #dc3545;
  border: 2px solid #dc3545;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-weight: 600;
}

.reset-btn:hover {
  background-color: #dc3545;
  color: white;
}

.action-btn:hover {
  opacity: 0.9;
  transform: translateY(-2px);
}

/* Meme Success Modal */
.meme-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.meme-modal.active {
  display: flex;
  opacity: 1;
}

.meme-content {
  background-color: white;
  max-width: 500px;
  width: 90%;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
  animation: pop-in 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  text-align: center;
}

@keyframes pop-in {
  0% {
    transform: scale(0.5);
    opacity: 0;
  }

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

.meme-image {
  width: 100%;
  height: auto;
  border-bottom: 1px solid #eee;
}

.meme-text {
  padding: 20px;
  font-weight: bold;
  font-size: 1.2rem;
  color: #333;
}

.meme-close {
  display: block;
  margin: 0 auto 20px;
  padding: 10px 25px;
  background-color: var(--accent-color);
  color: white;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.meme-close:hover {
  background-color: var(--accent-color-dark, #0056b3);
  transform: translateY(-2px);
}

/* Tutorial Mode Styles */
.tutorial-mode {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  display: none;
  justify-content: center;
  align-items: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.tutorial-mode.active {
  display: flex;
  opacity: 1;
}

.tutorial-content {
  background-color: white;
  max-width: 700px;
  width: 90%;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  animation: pop-in 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  padding-bottom: 20px;
}

.tutorial-header {
  background: linear-gradient(135deg, var(--accent-color), var(--accent-color-dark, #0056b3));
  color: white;
  padding: 20px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.tutorial-header h3 {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
}

.tutorial-close {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0.9;
  transition: all 0.2s ease;
}

.tutorial-close:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.1);
}

.tutorial-body {
  padding: 24px;
  max-height: 60vh;
  overflow-y: auto;
  color: var(--text-color);
  position: relative;
}

.tutorial-step {
  display: none;
  animation: fade-in 0.3s ease;
  opacity: 0;
  transform: translateY(10px);
  position: absolute;
  width: 100%;
  left: 0;
  top: 0;
}

.tutorial-step.active {
  display: block;
  opacity: 1;
  transform: translateY(0);
  position: relative;
}

.tutorial-step h4 {
  margin-top: 0;
  color: var(--accent-color);
  font-size: 1.2rem;
  border-bottom: 2px solid var(--accent-color);
  padding-bottom: 10px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tutorial-step h4 i {
  font-size: 1.1rem;
  width: 24px;
  text-align: center;
}

.tutorial-step p {
  margin-bottom: 16px;
  line-height: 1.6;
  font-size: 1rem;
}

.tutorial-step img {
  max-width: 100%;
  border-radius: 10px;
  margin: 16px 0;
  border: 1px solid var(--border-color);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.tutorial-step ul,
.tutorial-step ol {
  padding-left: 24px;
  margin-bottom: 16px;
}

.tutorial-step li {
  margin-bottom: 8px;
  line-height: 1.5;
}

.tutorial-highlight {
  background-color: rgba(255, 245, 157, 0.5);
  color: #5a4500;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 500;
}

.tutorial-navigation {
  display: flex;
  justify-content: space-between;
  padding: 0 24px 12px;
}

.tutorial-nav-btn {
  background: var(--accent-color);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
}

.tutorial-nav-btn:hover {
  background: var(--accent-color-dark, #0056b3);
  transform: translateY(-2px);
  box-shadow: 0 5px 12px rgba(0, 0, 0, 0.2);
}

.tutorial-nav-btn:disabled {
  background: #ccc;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.tutorial-progress {
  display: flex;
  justify-content: center;
  margin-top: 20px;
  gap: 8px;
}

.progress-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ddd;
  transition: all 0.3s ease;
  cursor: pointer;
}

.progress-dot:hover {
  transform: scale(1.2);
}

.progress-dot.active {
  background: var(--accent-color);
  transform: scale(1.2);
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

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

.tutorial-diagram {
  margin: 30px auto;
  padding: 20px;
  background-color: #ffffff;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  max-width: 550px;
  position: relative;
}

.diagram-head {
  position: relative;
  width: 100%;
  padding-bottom: 100%;
  border: 2px solid #666;
  border-radius: 50%;
  margin: 0 auto;
  max-width: 500px;
  background-color: #ffffff;
}

.diagram-nose {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translate(-50%, -70%);
  width: 24px;
  height: 24px;
  background-color: #666;
  clip-path: polygon(0% 100%, 50% 0%, 100% 100%);
  opacity: 0.8;
  z-index: 2;
}

/* Direction indicators for the tutorial diagram */
.tutorial-diagram .direction-label {
  position: absolute;
  font-size: 0.85rem;
  color: #333;
  font-weight: bold;
  background-color: rgba(255, 255, 255, 0.9);
  padding: 2px 6px;
  border-radius: 3px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  z-index: 10;
  border: 1px solid #ccc;
}

.tutorial-diagram .label-front {
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
}

.tutorial-diagram .label-back {
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
}

.tutorial-diagram .label-left {
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
}

.tutorial-diagram .label-right {
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
}

.diagram-head:before,
.diagram-head:after {
  content: '';
  position: absolute;
  background-color: #666;
  opacity: 0.4;
}

.diagram-head:before {
  top: 50%;
  left: 0;
  right: 0;
  height: 2px;
}

.diagram-head:after {
  left: 50%;
  top: 0;
  bottom: 0;
  width: 2px;
}

.diagram-point {
  position: absolute;
  width: 40px;
  height: 40px;
  background-color: var(--accent-color);
  color: white;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 14px;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2);
  z-index: 2;
}

.diagram-caption {
  text-align: center;
  margin-top: 20px;
  font-weight: 600;
  color: var(--accent-color);
  font-size: 1.1rem;
}

.instruction-box {
  background: var(--info-bg);
  border-left: 4px solid var(--accent-color);
  border-radius: 8px;
  padding: 1.2rem;
  margin: 1.5rem auto;
  max-width: 800px;
}

.instruction-header {
  display: flex;
  align-items: center;
  margin-bottom: 1rem;
  color: var(--accent-color);
}

.instruction-header i {
  font-size: 1.2rem;
  margin-right: 0.5rem;
}

.instruction-header h3 {
  margin: 0;
  font-size: 1.1rem;
}

.instruction-box ol {
  margin: 0;
  padding-left: 1.5rem;
}

.instruction-box li {
  margin-bottom: 0.5rem;
  line-height: 1.4;
}

.instruction-box li:last-child {
  margin-bottom: 0;
}

/* ====== EEG Lessons and Phase Reversal Simulator ====== */
.eeg-lessons-container {
  max-width: 1200px;
  margin: 40px auto;
  padding: 20px;
  background-color: #fff;
  border-radius: 10px;
  box-shadow: 0 2px 15px rgba(0, 0, 0, 0.1);
}

.section-title {
  text-align: center;
  color: var(--primary-color);
  margin-bottom: 25px;
  font-size: 2rem;
  font-weight: 600;
}

/* Lesson tabs */
.lesson-tabs {
  display: flex;
  border-bottom: 2px solid var(--gray-lighter);
  margin-bottom: 25px;
}

.lesson-tab {
  padding: 12px 20px;
  margin-right: 5px;
  background: var(--gray-lightest);
  border: none;
  border-top-left-radius: 5px;
  border-top-right-radius: 5px;
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-color);
  cursor: pointer;
  transition: all 0.2s ease;
}

.lesson-tab:hover {
  background: var(--gray-lighter);
}

.lesson-tab.active {
  background: var(--primary-color);
  color: white;
  border-bottom: 2px solid var(--primary-color);
  margin-bottom: -2px;
}

/* Lesson content */
.lesson-content {
  display: none;
  animation: fadeIn 0.3s ease;
}

.lesson-content.active {
  display: block;
}

.lesson-content h3 {
  color: var(--primary-color);
  font-size: 1.7rem;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--gray-lighter);
  padding-bottom: 10px;
}

.lesson-content h4 {
  color: var(--accent-color);
  font-size: 1.4rem;
  margin: 25px 0 15px;
}

.lesson-intro {
  font-size: 1.1rem;
  line-height: 1.6;
  margin-bottom: 25px;
  color: var(--text-color);
}

/* Concept explanation */
.concept-explanation {
  background-color: var(--gray-lightest);
  padding: 20px;
  border-radius: 8px;
  margin-bottom: 30px;
}

.key-points {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin-top: 20px;
}

.key-point {
  display: flex;
  align-items: flex-start;
  gap: 15px;
}

.point-number {
  background: var(--accent-color);
  color: white;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  flex-shrink: 0;
}

.point-text {
  flex: 1;
  padding-top: 5px;
}

/* Phase reversal simulator */
.phase-reversal-simulator {
  margin-top: 30px;
}

.simulator-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-bottom: 20px;
}

.head-diagram {
  width: 400px;
  height: 400px;
  background-color: #f8f8f8;
  border-radius: 50%;
  position: relative;
  margin: 0 auto 20px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  border: 1px solid #ddd;
}

.electrode {
  position: absolute;
  width: 40px;
  height: 40px;
  background-color: #ffffff;
  border: 2px solid #0066cc;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: bold;
  color: #333;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transform: translate(-50%, -50%);
  z-index: 2;
}

.electrode:hover {
  background-color: #e6f2ff;
  transform: translate(-50%, -50%) scale(1.1);
}

.electrode.active {
  background-color: #ff6b6b;
  border-color: #e74c3c;
  color: white;
  z-index: 3;
}

.activity-source {
  position: absolute;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(255, 0, 0, 0.7) 0%, rgba(255, 0, 0, 0) 70%);
  pointer-events: none;
  opacity: 0;
  z-index: 1;
  transition: opacity 0.3s ease;
}

.activity-source.visible {
  opacity: 1;
}

/* New layout with controls below the head diagram */
.simulation-controls {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  padding: 15px;
  background-color: #f8f8f8;
  border-radius: 8px;
  border: 1px solid #ddd;
}

.control-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 15px;
  margin-bottom: 15px;
}

.control-row>div {
  flex: 1;
  min-width: 200px;
}

.eeg-display {
  flex: 1;
  min-width: 300px;
  background-color: #f8f8f8;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 15px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  color: #333;
  margin-top: 20px;
}

/* Discharge type toggle */
.discharge-type {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 15px;
}

.discharge-type span {
  font-size: 0.9rem;
  color: #333;
  min-width: 110px;
}

.toggle-container {
  position: relative;
  width: 200px;
}

.discharge-toggle {
  position: absolute;
  opacity: 0;
  height: 0;
  width: 0;
}

.toggle-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  width: 100%;
  background: #e6e6e6;
  border-radius: 20px;
  position: relative;
  padding: 5px;
  transition: all 0.3s ease;
}

.toggle-option {
  padding: 6px 12px;
  z-index: 1;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: 15px;
  transition: color 0.3s ease;
  flex: 1;
  color: #777;
}

.toggle-option.active {
  color: white;
}

.toggle-slider {
  position: absolute;
  left: 5px;
  top: 5px;
  width: calc(50% - 5px);
  height: calc(100% - 10px);
  background: #0066cc;
  border-radius: 15px;
  transition: all 0.3s ease;
}

/* Important: Make sure the slider appears on the left (negative) side by default */
.discharge-toggle:not(:checked)+.toggle-label .toggle-slider {
  left: 5px;
  background: #0066cc;
}

.discharge-toggle:checked+.toggle-label .toggle-slider {
  left: calc(50% + 0px);
  background: #e74c3c;
}

.discharge-toggle:not(:checked)+.toggle-label .toggle-option.negative {
  color: white;
}

.discharge-toggle:not(:checked)+.toggle-label .toggle-option.positive {
  color: #777;
}

.discharge-toggle:checked+.toggle-label .toggle-option.negative {
  color: #777;
}

.discharge-toggle:checked+.toggle-label .toggle-option.positive {
  color: white;
}

.instructions {
  background-color: #f0f0f0;
  padding: 12px;
  border-radius: 6px;
  margin-bottom: 20px;
  font-size: 0.9rem;
  color: #555;
  border-left: 3px solid #0066cc;
}

.waveform-display {
  height: 800px;
  background-color: #fff;
  border: 1px solid #ddd;
  border-radius: 4px;
  overflow-y: auto;
  position: relative;
  padding: 10px 0;
}

.waveform-header {
  position: sticky;
  top: 0;
  background-color: #f0f0f0;
  color: #0066cc;
  text-align: center;
  padding: 6px 0;
  margin-bottom: 8px;
  z-index: 10;
  border-bottom: 1px solid #ddd;
}

.waveform-header h5 {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 500;
}

.waveform-group-label {
  padding: 3px 10px;
  background-color: #f5f5f5;
  color: #0066cc;
  font-size: 0.8rem;
  font-weight: bold;
  margin: 8px 0 2px 0;
  border-left: 3px solid #0066cc;
  position: sticky;
  left: 0;
  z-index: 5;
}

.waveform-row {
  display: flex;
  height: 50px;
  margin: 3px 0;
  position: relative;
  transition: background-color 0.2s ease;
  border-bottom: 1px solid #eee;
}

.waveform-row:hover {
  background-color: rgba(0, 102, 204, 0.05);
}

.waveform-row.has-phase-reversal {
  background-color: rgba(231, 76, 60, 0.15);
  animation: highlight-reversal 1.5s ease-in-out infinite;
  border-left: 3px solid #e74c3c;
  box-shadow: 0 0 8px rgba(231, 76, 60, 0.3);
}

@keyframes highlight-reversal {

  0%,
  100% {
    background-color: rgba(231, 76, 60, 0.15);
  }

  50% {
    background-color: rgba(231, 76, 60, 0.25);
  }
}

.waveform-label {
  width: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #f0f0f0;
  color: #333;
  font-size: 0.85rem;
  font-weight: bold;
  border-right: 1px solid #ddd;
  user-select: none;
  position: sticky;
  left: 0;
  z-index: 5;
}

.waveform-graph {
  flex: 1;
  position: relative;
  height: 100%;
  background-image:
    linear-gradient(to right, rgba(200, 200, 200, 0.3) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(200, 200, 200, 0.3) 1px, transparent 1px);
  background-size: 50px 20px;
  overflow: hidden;
}

.waveform-graph.significant-waveform {
  background-color: rgba(240, 240, 240, 0.5);
}

.waveform-graph.phase-reversal-waveform {
  background-color: rgba(231, 76, 60, 0.08);
  box-shadow: inset 0 0 6px rgba(231, 76, 60, 0.2);
}

.baseline {
  position: absolute;
  top: 50%;
  left: 0;
  width: 100%;
  height: 1px;
  background-color: rgba(100, 100, 100, 0.4);
}

.waveform-svg {
  pointer-events: none;
}

.pulse-waveform {
  animation: pulse-wave 1.2s infinite alternate;
  filter: drop-shadow(0 0 2px rgba(231, 76, 60, 0.5));
}

@keyframes pulse-wave {
  0% {
    opacity: 0.8;
  }

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

.phase-reversal-indicator {
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  background-color: rgba(231, 76, 60, 0.9);
  color: white;
  font-size: 0.8rem;
  font-weight: bold;
  padding: 3px 8px;
  border-radius: 4px;
  pointer-events: none;
  z-index: 5;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
  animation: pulse-indicator 1.5s infinite alternate;
  border: 1px solid rgba(255, 255, 255, 0.5);
}

@keyframes pulse-indicator {
  0% {
    background-color: rgba(231, 76, 60, 0.9);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
  }

  100% {
    background-color: rgba(231, 76, 60, 1);
    box-shadow: 0 2px 8px rgba(231, 76, 60, 0.5);
  }
}

.phase-reversal-indicator span {
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.time-scale {
  height: 30px;
  padding: 5px 10px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border-top: 1px solid #ddd;
  background-color: #f5f5f5;
}

.scale-label {
  font-size: 0.75rem;
  color: #555;
  background: #f5f5f5;
  padding: 0 5px;
  position: relative;
  z-index: 2;
}

.scale-line {
  position: absolute;
  height: 1px;
  width: 100px;
  background-color: #777;
  left: 50%;
  transform: translateX(-50%);
}

/* Animation */
@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .simulator-container {
    flex-direction: column;
  }

  .head-diagram {
    width: 300px;
    height: 300px;
  }

  .electrode {
    width: 30px;
    height: 30px;
    font-size: 0.7rem;
  }

  .lesson-tab {
    padding: 10px 15px;
    font-size: 0.9rem;
  }
}

/* Explanation Section */
.simulator-explanation {
  background-color: #f8f8f8;
  padding: 20px;
  border-radius: 8px;
  margin-bottom: 25px;
  border-left: 4px solid var(--accent-color);
}

.reversal-types {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  margin-top: 20px;
}

.reversal-type {
  flex: 1;
  min-width: 250px;
  background-color: white;
  padding: 15px;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.reversal-type h5 {
  color: var(--accent-color);
  margin-bottom: 10px;
  font-size: 1.1rem;
}

.reversal-example {
  height: 80px;
  margin-top: 15px;
  background-color: #f5f5f5;
  position: relative;
  border: 1px solid #ddd;
  border-radius: 4px;
  overflow: hidden;
}

.reversal-example::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  width: 100%;
  height: 1px;
  background-color: rgba(0, 0, 0, 0.2);
}

.reversal-example.negative::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  width: 100%;
  height: 30px;
  background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 30"><path d="M0,15 Q25,25 50,15 Q75,5 100,15" fill="none" stroke="%230066cc" stroke-width="2"/></svg>') repeat-x;
  background-size: 100px 30px;
}

.reversal-example.positive::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  width: 100%;
  height: 30px;
  background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 30"><path d="M0,15 Q25,5 50,15 Q75,25 100,15" fill="none" stroke="%230066cc" stroke-width="2"/></svg>') repeat-x;
  background-size: 100px 30px;
}

.clinical-significance {
  background-color: rgba(0, 102, 204, 0.05);
  padding: 20px;
  border-radius: 8px;
  margin-top: 30px;
  border: 1px solid rgba(0, 102, 204, 0.1);
}

.clinical-significance h4 {
  color: var(--primary-color);
  margin-top: 0;
}

.clinical-significance ul {
  margin: 15px 0;
  padding-left: 20px;
}

.clinical-significance li {
  margin-bottom: 8px;
}

/* Voltage control slider */
.voltage-control {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 15px;
}

.voltage-control span {
  font-size: 0.9rem;
  color: #333;
  min-width: 110px;
}

.slider-container {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 15px;
}

.voltage-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: linear-gradient(to right, #0066cc, #e74c3c);
  border-radius: 3px;
  outline: none;
}

.voltage-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #333;
  border: 2px solid #fff;
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  transition: background 0.3s ease;
}

.voltage-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #333;
  border: 2px solid #fff;
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  transition: background 0.3s ease;
}

.voltage-slider:active::-webkit-slider-thumb {
  background: #0066cc;
}

.voltage-slider:active::-moz-range-thumb {
  background: #0066cc;
}

.slider-value {
  font-size: 0.9rem;
  color: #333;
  min-width: 60px;
  text-align: center;
  font-weight: 500;
}

/* Mathematical explanation styles */
.voltage-math-explanation {
  margin-top: 30px;
  padding: 20px;
  background-color: #f8f8f8;
  border-radius: 8px;
  border: 1px solid #ddd;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.voltage-math-explanation h4 {
  color: #0066cc;
  text-align: center;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 2px solid #0066cc;
  font-size: 1.4rem;
}

.math-content {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  justify-content: space-between;
}

.formula-section {
  flex: 1;
  min-width: 300px;
  background-color: white;
  padding: 15px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  margin-bottom: 20px;
}

.formula-section h5 {
  color: #0066cc;
  margin-top: 0;
  margin-bottom: 15px;
  font-size: 1.1rem;
  border-left: 3px solid #0066cc;
  padding-left: 10px;
}

.formula {
  background-color: rgba(240, 248, 255, 0.8);
  padding: 15px;
  border-radius: 5px;
  text-align: center;
  margin-bottom: 15px;
  border: 1px solid #d1e6ff;
}

.math-eq {
  font-size: 1.2rem;
  font-weight: 500;
  font-family: 'Times New Roman', Times, serif;
  line-height: 2;
}

.formula-explanation {
  font-size: 0.95rem;
  color: #333;
}

.formula-explanation p {
  margin: 10px 0;
}

.formula-explanation ul {
  padding-left: 20px;
  margin: 10px 0;
}

.formula-explanation li {
  margin-bottom: 8px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .math-content {
    flex-direction: column;
  }

  .formula-section {
    min-width: auto;
  }

  .math-eq {
    font-size: 1.1rem;
  }
}
