/* Shared UI for all Math Adventure mini-games: setup / quiz / results screens */

.quiz-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  gap: 10px;
  flex-wrap: wrap;
}

.quiz-topbar h1 {
  margin: 0;
  font-size: 1.5rem;
  color: var(--primary-dark);
  text-align: center;
  flex: 1;
}

.quiz-topbar a.btn {
  text-decoration: none;
}

.quiz-screen {
  display: flex;
  justify-content: center;
  padding: 10px 20px 50px;
}

.quiz-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 28px;
  max-width: 620px;
  width: 100%;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  text-align: center;
}

.quiz-card h2 { margin-top: 0; color: var(--primary-dark); }

/* Setup: choice buttons (operations / categories) */
.choice-row {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 14px 0 22px;
}

.choice-btn {
  flex: 1 1 100px;
  border: 3px solid transparent;
  background: #f1f1f1;
  border-radius: 16px;
  padding: 16px 10px;
  font-family: inherit;
  font-weight: bold;
  cursor: pointer;
  font-size: 1.6rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: transform 0.12s ease, border-color 0.12s ease;
}
.choice-btn span.label { font-size: 0.85rem; }
.choice-btn:hover { transform: translateY(-2px); }
.choice-btn.selected { border-color: var(--primary); background: #fff0eb; }

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f7fbff;
  border-radius: 14px;
  padding: 12px 16px;
  margin-bottom: 14px;
  font-weight: bold;
  text-align: left;
  gap: 12px;
}

.toggle-row .toggle-desc { font-weight: normal; font-size: 0.85rem; opacity: 0.75; margin-top: 2px; }

.switch {
  position: relative;
  width: 54px;
  height: 30px;
  flex: 0 0 auto;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch-track {
  position: absolute;
  inset: 0;
  background: #ccc;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s ease;
}
.switch-track::before {
  content: "";
  position: absolute;
  width: 24px;
  height: 24px;
  left: 3px;
  top: 3px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.switch input:checked + .switch-track { background: var(--secondary); }
.switch input:checked + .switch-track::before { transform: translateX(24px); }

.seconds-row {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 14px;
}
.seconds-btn {
  border: 3px solid transparent;
  background: #f1f1f1;
  border-radius: 12px;
  padding: 8px 16px;
  font-family: inherit;
  font-weight: bold;
  cursor: pointer;
}
.seconds-btn.selected { border-color: var(--secondary); background: #eaf7ff; }

/* Quiz in-progress */
.quiz-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-weight: bold;
  flex-wrap: wrap;
  gap: 8px;
}

.progress-pill {
  background: #fff0eb;
  color: var(--primary-dark);
  padding: 5px 14px;
  border-radius: 999px;
  font-size: 0.9rem;
}

.score-pill {
  background: #eafcef;
  color: #1f9d55;
  padding: 5px 14px;
  border-radius: 999px;
  font-size: 0.9rem;
}

.timer-wrap {
  height: 10px;
  background: #eee;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 18px;
}
.timer-fill {
  height: 100%;
  background: var(--secondary);
  width: 100%;
  transition: width 0.2s linear, background 0.2s ease;
}
.timer-fill.low { background: #ff5c5c; }

.question-text {
  font-size: 2rem;
  font-weight: bold;
  color: var(--text);
  margin: 6px 0 18px;
}

.visual-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  align-items: center;
  margin-bottom: 20px;
  min-height: 40px;
}
.visual-row .vgroup {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: center;
  padding: 8px;
  border-radius: 12px;
  background: #f7f7f7;
}
.visual-row .vsym {
  font-size: 1.6rem;
  font-weight: bold;
  padding: 0 4px;
}
.visual-row .vicon { font-size: 1.5rem; }
.visual-row .vicon.faded { opacity: 0.25; text-decoration: line-through; }

.shape-display {
  margin: 6px auto 22px;
  width: 180px;
  height: 180px;
}

.options-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-top: 6px;
}

.option-btn {
  border: 3px solid transparent;
  background: #f1f1f1;
  border-radius: 14px;
  padding: 16px 10px;
  font-family: inherit;
  font-weight: bold;
  font-size: 1.3rem;
  cursor: pointer;
  transition: transform 0.1s ease, border-color 0.1s ease, background 0.1s ease;
}
.option-btn:hover:not(:disabled) { transform: translateY(-2px); border-color: var(--secondary); }
.option-btn:disabled { cursor: default; }
.option-btn.correct { background: #d6f5df; border-color: #34c759; color: #1f7a3d; }
.option-btn.wrong { background: #ffd9d9; border-color: #ff5c5c; color: #b32a2a; }

/* Results screen */
.results-emoji { font-size: 4rem; margin-bottom: 8px; }
.results-score { font-size: 2.4rem; font-weight: bold; color: var(--primary-dark); margin-bottom: 4px; }
.results-msg { font-size: 1.1rem; margin-bottom: 20px; }

.btn-row {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

@media (max-width: 480px) {
  .options-grid { grid-template-columns: 1fr; }
  .question-text { font-size: 1.6rem; }
}
