/* ============================================
   Matter Study App — Science Exam 🧪
   Matter=#3498db  Mass=#27ae60  Volume=#f39c12
   Density=#8e44ad  Air=#5dade2
   Correct=#27ae60  Incorrect=#e74c3c
   ============================================ */

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

body {
  font-family: 'Segoe UI', 'Arial Rounded MT Bold', Arial, sans-serif;
  background: linear-gradient(135deg, #eaf6ff 0%, #fff 50%, #fef9e7 100%);
  color: #222;
  min-height: 100vh;
  padding: 16px;
  font-size: 18px;
  line-height: 1.5;
}

/* ---- Views ---- */
.view {
  display: none;
  max-width: 800px;
  margin: 0 auto;
  padding: 20px;
  animation: fadeIn 0.3s ease;
}
.view.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---- Typography ---- */
h1 {
  font-size: 2.2rem;
  text-align: center;
  color: #2c3e50;
  margin-bottom: 8px;
}
h2 {
  font-size: 1.6rem;
  text-align: center;
  color: #2c3e50;
  margin-bottom: 16px;
}
h3 {
  font-size: 1.25rem;
  margin: 20px 0 8px;
  padding-bottom: 4px;
}
h4 {
  font-size: 1.05rem;
  color: #555;
  margin: 12px 0 6px;
}
.subtitle {
  text-align: center;
  font-size: 1.15rem;
  color: #555;
  margin-bottom: 24px;
}

/* ---- Main Menu Grid ---- */
.menu-grid {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 8px;
}
.menu-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 220px;
  padding: 24px 16px;
  border: none;
  border-radius: 16px;
  cursor: pointer;
  font-family: inherit;
  font-size: 1rem;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  color: #fff;
}
.menu-btn:hover,
.menu-btn:focus {
  transform: translateY(-4px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.15);
  outline: 3px solid #2c3e50;
}
.menu-btn--guide {
  background: linear-gradient(135deg, #3498db, #5dade2);
}
.menu-btn--tests {
  background: linear-gradient(135deg, #e74c3c, #ec7063);
}
.menu-emoji { font-size: 2.5rem; }
.menu-title { font-size: 1.2rem; font-weight: 700; }

/* ---- Exercise Menu Grid ---- */
.exercise-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 8px;
}
.exercise-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 24px 16px;
  border: none;
  border-radius: 16px;
  cursor: pointer;
  font-family: inherit;
  font-size: 1rem;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  color: #fff;
}
.exercise-btn:hover,
.exercise-btn:focus {
  transform: translateY(-4px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.15);
  outline: 3px solid #2c3e50;
}
.exercise-btn--definitions {
  background: linear-gradient(135deg, #27ae60, #2ecc71);
}
.exercise-btn--units {
  background: linear-gradient(135deg, #f39c12, #f1c40f);
}
.exercise-btn--calculations {
  background: linear-gradient(135deg, #8e44ad, #a569bd);
}

/* ---- Back Button ---- */
.btn-back {
  display: inline-block;
  padding: 8px 16px;
  font-size: 1rem;
  font-family: inherit;
  border: 2px solid #3498db;
  border-radius: 10px;
  background: transparent;
  color: #3498db;
  cursor: pointer;
  margin-bottom: 12px;
  transition: background 0.15s, color 0.15s;
}
.btn-back:hover,
.btn-back:focus {
  background: #3498db;
  color: #fff;
  outline: none;
}

/* ---- Guide Content ---- */
.guide-content {
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}

/* ---- Guide Sections (colour-coded per topic) ---- */
.guide-section {
  margin-bottom: 28px;
  border-radius: 12px;
  padding: 18px;
}

/* Matter — Blue */
.guide-section--matter {
  background: #eaf4fc;
  border-left: 5px solid #3498db;
}
.guide-section--matter h3 { color: #3498db; border-bottom: 2px solid #3498db; }

/* Mass — Green */
.guide-section--mass {
  background: #eafaf1;
  border-left: 5px solid #27ae60;
}
.guide-section--mass h3 { color: #27ae60; border-bottom: 2px solid #27ae60; }

/* Volume — Orange */
.guide-section--volume {
  background: #fef9e7;
  border-left: 5px solid #f39c12;
}
.guide-section--volume h3 { color: #f39c12; border-bottom: 2px solid #f39c12; }

/* Density — Purple */
.guide-section--density {
  background: #f5eef8;
  border-left: 5px solid #8e44ad;
}
.guide-section--density h3 { color: #8e44ad; border-bottom: 2px solid #8e44ad; }

/* Air — Light Blue */
.guide-section--air {
  background: #ebf5fb;
  border-left: 5px solid #5dade2;
}
.guide-section--air h3 { color: #5dade2; border-bottom: 2px solid #5dade2; }

/* ---- Guide Box (explanations) ---- */
.guide-box {
  background: rgba(255,255,255,0.7);
  border-radius: 10px;
  padding: 14px 18px;
  margin: 10px 0 16px;
  font-size: 1.05rem;
}
.guide-box p { margin-bottom: 6px; }
.guide-box p:last-child { margin-bottom: 0; }
.guide-box ul {
  margin: 6px 0 6px 20px;
}
.guide-box li {
  margin-bottom: 4px;
}

/* ---- Definition Panel ---- */
.definition-panel {
  background: rgba(255,255,255,0.85);
  border-radius: 10px;
  padding: 14px 18px;
  margin: 10px 0;
  font-size: 1.1rem;
  font-weight: 600;
  border: 2px dashed #bbb;
}

/* ---- Worked Example Box ---- */
.worked-example {
  background: rgba(255,255,255,0.8);
  border: 1px dashed #bbb;
  border-radius: 10px;
  padding: 12px 16px;
  margin: 10px 0;
  font-size: 1.05rem;
}
.worked-example h4 {
  margin-bottom: 8px;
  color: #2c3e50;
}
.worked-example .steps {
  list-style: none;
  padding: 0;
}
.worked-example .steps li {
  padding: 4px 0;
  padding-left: 20px;
  position: relative;
}
.worked-example .steps li::before {
  content: "➡️";
  position: absolute;
  left: 0;
}

/* ---- Tip Box ---- */
.tip-box {
  background: #fff3cd;
  border-radius: 10px;
  padding: 12px 16px;
  margin: 10px 0;
  font-size: 1.05rem;
  border-left: 4px solid #ffc107;
}
.tip-box::before {
  content: "💡 ";
}

/* ---- Triangle Method ---- */
.triangle-box {
  background: #f5eef8;
  border-radius: 10px;
  padding: 14px 18px;
  margin: 10px 0;
  text-align: center;
  font-size: 1.1rem;
  font-weight: 600;
  border: 2px solid #8e44ad;
}

/* ---- Properties / Importance Lists ---- */
.properties-list,
.importance-list {
  list-style: none;
  padding: 0;
  margin: 10px 0;
}
.properties-list li,
.importance-list li {
  padding: 8px 12px;
  margin-bottom: 6px;
  background: rgba(255,255,255,0.8);
  border-radius: 8px;
  font-size: 1.05rem;
}
.properties-list li::before {
  content: "✅ ";
}
.importance-list li {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.importance-list .point-title {
  font-weight: 700;
  color: #2c3e50;
}
.importance-list .point-explanation {
  font-size: 0.95rem;
  color: #555;
}

/* ---- Score Display ---- */
.score-display {
  text-align: center;
  font-size: 1.3rem;
  font-weight: 700;
  color: #3498db;
  background: #eaf4fc;
  border-radius: 10px;
  padding: 8px 16px;
  margin-bottom: 16px;
}

/* ---- Exercise Area ---- */
.exercise-area {
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}

/* ---- Question Display ---- */
.question-display {
  text-align: center;
  margin-bottom: 20px;
}
.question-label {
  font-size: 1rem;
  color: #777;
  margin-bottom: 6px;
}
.question-text {
  font-size: 1.4rem;
  font-weight: 700;
  color: #2c3e50;
  background: #f8f9fa;
  border-radius: 10px;
  padding: 14px 18px;
  border: 2px dashed #bbb;
}

/* ---- Formula Reminder ---- */
.formula-reminder {
  text-align: center;
  font-size: 1.1rem;
  font-weight: 600;
  color: #8e44ad;
  background: #f5eef8;
  border-radius: 10px;
  padding: 8px 16px;
  margin-bottom: 16px;
}

/* ---- Option Buttons (Multiple Choice) ---- */
.options-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
.option-btn {
  padding: 14px 18px;
  font-size: 1.15rem;
  font-family: inherit;
  font-weight: 600;
  border: 2px solid #3498db;
  border-radius: 12px;
  background: #fff;
  color: #3498db;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.1s, border-color 0.15s;
}
.option-btn:hover,
.option-btn:focus {
  background: #eaf4fc;
  transform: translateY(-2px);
  outline: none;
}
.option-btn:disabled {
  cursor: default;
  transform: none;
}
.option-btn.option-correct {
  border-color: #27ae60 !important;
  background: #eafaf1 !important;
  color: #27ae60 !important;
}
.option-btn.option-incorrect {
  border-color: #e74c3c !important;
  background: #fdedec !important;
  color: #e74c3c !important;
}

/* ---- Form Inputs ---- */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 14px;
}
.form-group label {
  font-size: 0.95rem;
  font-weight: 600;
  color: #444;
}
.form-input {
  padding: 10px 14px;
  font-size: 1.1rem;
  font-family: inherit;
  border: 2px solid #ccc;
  border-radius: 10px;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: #fff;
}
.form-input:focus {
  outline: none;
  border-color: #3498db;
  box-shadow: 0 0 0 3px rgba(52,152,219,0.15);
}

/* Correct / Incorrect field states */
.field-correct {
  border-color: #27ae60 !important;
  background: #eafaf1 !important;
}
.field-incorrect {
  border-color: #e74c3c !important;
  background: #fdedec !important;
}

/* ---- Feedback ---- */
.feedback {
  min-height: 24px;
  margin-bottom: 12px;
  font-size: 1.1rem;
  font-weight: 600;
  text-align: center;
  border-radius: 10px;
  padding: 8px;
}
.feedback-correct {
  color: #27ae60;
  background: #eafaf1;
}
.feedback-incorrect {
  color: #c0392b;
  background: #fdedec;
}

/* ---- Calculation Steps (shown in feedback) ---- */
.calculation-steps {
  text-align: left;
  font-size: 1rem;
  font-weight: 400;
  margin-top: 8px;
  padding: 10px 14px;
  background: #f8f9fa;
  border-radius: 8px;
}
.calculation-steps p {
  margin-bottom: 4px;
}

/* ---- Completion Message ---- */
.completion-message {
  text-align: center;
  font-size: 1.3rem;
  padding: 24px;
  color: #27ae60;
}

/* ---- Buttons ---- */
.btn-row {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}
.btn-primary {
  padding: 12px 28px;
  font-size: 1.15rem;
  font-family: inherit;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  background: #3498db;
  color: #fff;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.btn-primary:hover,
.btn-primary:focus {
  background: #2980b9;
  outline: none;
}
.btn-primary:active {
  transform: scale(0.97);
}
.btn-next {
  padding: 12px 28px;
  font-size: 1.15rem;
  font-family: inherit;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  background: #27ae60;
  color: #fff;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.btn-next:hover,
.btn-next:focus {
  background: #1e8449;
  outline: none;
}
.btn-next:active {
  transform: scale(0.97);
}

.hidden {
  display: none !important;
}

/* ============================================
   Responsive Design
   ============================================ */

@media (max-width: 600px) {
  body {
    padding: 10px;
    font-size: 16px;
  }
  h1 { font-size: 1.7rem; }
  h2 { font-size: 1.3rem; }
  h3 { font-size: 1.1rem; }

  .menu-grid {
    flex-direction: column;
    align-items: center;
  }
  .menu-btn {
    width: 100%;
    max-width: 300px;
  }

  .exercise-grid {
    grid-template-columns: 1fr;
  }

  .guide-content {
    padding: 14px;
  }
  .guide-section {
    padding: 12px;
  }

  .exercise-area {
    padding: 16px;
  }
  .question-text {
    font-size: 1.15rem;
    padding: 10px 14px;
  }

  .options-grid {
    grid-template-columns: 1fr;
  }

  .btn-row {
    flex-direction: column;
    align-items: stretch;
  }
  .btn-primary,
  .btn-next {
    width: 100%;
    text-align: center;
  }
}

@media (min-width: 601px) and (max-width: 900px) {
  .menu-btn {
    width: 180px;
  }
  .exercise-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
