* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --oxygenated: #dc2626;
  --deoxygenated: #0284c7;
  --bg-light: #f0f9ff;
  --bg-white: #ffffff;
  --border: #e5e7eb;
  --text-dark: #1f2937;
  --text-light: #6b7280;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  color: var(--text-dark);
}

.simulator-container {
  min-height: 100vh;
  padding: 20px;
  max-width: 1400px;
  margin: 0 auto;
}

/* Header */
.sim-header {
  background: var(--bg-white);
  padding: 20px;
  border-radius: 12px;
  margin-bottom: 24px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.sim-header h1 {
  font-size: 24px;
  margin: 0;
  flex: 1;
  text-align: center;
}

.header-info {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-light);
  padding: 8px 16px;
  border-radius: 8px;
}

#pulseRate {
  font-weight: 600;
  color: var(--text-dark);
  font-family: 'Courier New', monospace;
}

/* Main Content */
.sim-content {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}

/* Diagram */
.diagram-container {
  background: var(--bg-white);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.circulation-svg {
  width: 100%;
  height: auto;
  min-height: 400px;
  max-height: 600px;
}

.interactive-element {
  cursor: pointer;
  transition: opacity 0.2s;
}

.interactive-element:hover {
  opacity: 0.8;
}

/* Path highlighting */
.path-highlight {
  stroke-width: 12;
  opacity: 1;
  filter: drop-shadow(0 0 8px rgba(0, 0, 0, 0.3));
}

.path-fade {
  opacity: 0.2;
}

/* Info Panels */
.info-panels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 16px;
}

.panel {
  background: var(--bg-white);
  padding: 20px;
  border-radius: 12px;
  border-left: 4px solid var(--primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  transition: all 0.2s;
}

.panel:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
}

#panel-oxygenated {
  border-left-color: var(--oxygenated);
}

#panel-oxygenated h3 {
  color: var(--oxygenated);
}

#panel-deoxygenated {
  border-left-color: var(--deoxygenated);
}

#panel-deoxygenated h3 {
  color: var(--deoxygenated);
}

#panel-heart {
  border-left-color: #db2777;
}

#panel-heart h3 {
  color: #db2777;
}

.panel h3 {
  margin-bottom: 12px;
  font-size: 18px;
}

.panel p {
  font-size: 14px;
  color: var(--text-light);
  line-height: 1.6;
  margin-bottom: 8px;
}

.panel p:last-child {
  margin-bottom: 0;
}

.panel p strong {
  color: var(--text-dark);
}

/* Controls Section */
.controls-section {
  background: var(--bg-white);
  padding: 24px;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.controls-section h3 {
  margin-top: 0;
  margin-bottom: 12px;
  color: var(--text-dark);
  font-size: 16px;
}

.controls-section h3:not(:first-of-type) {
  margin-top: 20px;
}

/* Pulse Controls */
.pulse-controls {
  background: var(--bg-light);
  padding: 16px;
  border-radius: 8px;
  margin-bottom: 16px;
}

.pulse-controls label {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 500;
  font-size: 14px;
}

.pulse-controls input[type="range"] {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: #dbeafe;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.pulse-controls input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.pulse-controls input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  border: none;
}

#pulseValue {
  background: var(--primary);
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-weight: 600;
  font-family: 'Courier New', monospace;
  min-width: 50px;
  text-align: center;
}

/* Button Group */
.button-group {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}

.btn-outline {
  background: transparent;
  border: 2px solid var(--border);
  color: var(--text-dark);
  padding: 10px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  transition: all 0.2s;
}

.btn-outline:hover {
  border-color: var(--primary);
  background: var(--primary);
  color: white;
}

.btn-primary {
  width: 100%;
  padding: 12px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.btn-small {
  padding: 6px 12px;
  font-size: 13px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

.btn {
  padding: 8px 16px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s;
}

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

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: var(--bg-white);
  border-radius: 16px;
  padding: 32px;
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  position: relative;
}

.close-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-light);
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s;
}

.close-btn:hover {
  background: var(--bg-light);
  color: var(--text-dark);
}

.modal-content h2 {
  margin-bottom: 24px;
  color: var(--text-dark);
}

#quizContent {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.quiz-question {
  font-weight: 600;
  color: var(--text-dark);
  margin-bottom: 12px;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.quiz-option {
  padding: 12px;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: var(--bg-white);
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
  font-size: 14px;
}

.quiz-option:hover {
  border-color: var(--primary);
  background: var(--bg-light);
}

.quiz-option.selected {
  border-color: var(--primary);
  background: #dbeafe;
  color: var(--primary);
}

.quiz-option.correct {
  border-color: #10b981;
  background: #ecfdf5;
  color: #047857;
}

.quiz-option.incorrect {
  border-color: #ef4444;
  background: #fee2e2;
  color: #991b1b;
}

.quiz-feedback {
  padding: 12px;
  border-radius: 8px;
  font-size: 14px;
  margin-top: 8px;
}

.quiz-feedback.correct {
  background: #ecfdf5;
  color: #047857;
  border-left: 4px solid #10b981;
  padding-left: 12px;
}

.quiz-feedback.incorrect {
  background: #fee2e2;
  color: #991b1b;
  border-left: 4px solid #ef4444;
  padding-left: 12px;
}

/* Responsive */
@media (max-width: 1024px) {
  .sim-header {
    flex-direction: column;
    align-items: stretch;
  }

  .sim-header h1 {
    text-align: center;
  }

  .header-info {
    justify-content: center;
  }

  .info-panels {
    grid-template-columns: 1fr;
  }

  .circulation-svg {
    min-height: 300px;
  }
}

@media (max-width: 640px) {
  .simulator-container {
    padding: 12px;
  }

  .sim-header {
    padding: 12px;
  }

  .sim-header h1 {
    font-size: 18px;
  }

  .modal-content {
    padding: 20px;
  }

  .diagram-container {
    padding: 12px;
  }

  .controls-section {
    padding: 16px;
  }

  .button-group {
    grid-template-columns: 1fr;
  }
}
