:root {
  /* Word Dojo's palette is driven by the shared theme variables (theme.css) so the
     universal colour theme picker applies here too. Word Dojo's card/text styling is
     intentionally always-dark by design (white text on translucent overlays), so
     --white/--text-dim stay fixed rather than following the light/dark toggle; only the
     primary/accent hues (and correct/wrong feedback, which stays fixed on purpose) change. */
  --purple-dark: var(--theme-primary-dark);
  --purple: var(--theme-primary);
  --purple-mid: color-mix(in srgb, var(--theme-primary) 75%, white 25%);
  --purple-light: color-mix(in srgb, var(--theme-primary) 55%, white 45%);
  --gold: var(--theme-accent);
  --gold-dark: var(--theme-accent-dark);
  --white: #ffffff;
  --green: #3ddc84;
  --green-dark: #1f9e5a;
  --red: #ff5470;
  --red-dark: #d6294a;
  --text-dim: #d9c6f0;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: Arial, Helvetica, sans-serif;
  background: radial-gradient(circle at top, var(--purple-mid) 0%, var(--purple-dark) 70%);
  color: var(--white);
}

#app {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.screen {
  display: none;
  width: 100%;
  max-width: 640px;
}
.screen.active {
  display: block;
  animation: fadeIn 0.25s ease-out;
}

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

.card {
  background: rgba(255, 255, 255, 0.06);
  border: 2px solid var(--gold);
  border-radius: 20px;
  padding: 32px 28px;
  text-align: center;
  box-shadow: 0 8px 30px rgba(0,0,0,0.4);
}

.title {
  font-size: 2.4em;
  margin: 0 0 4px;
  color: var(--gold);
  text-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

.subtitle {
  font-size: 1.2em;
  margin: 0 0 6px;
  color: var(--white);
}

.tagline {
  color: var(--text-dim);
  font-size: 0.95em;
  margin-bottom: 20px;
}

.belt-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(255, 201, 74, 0.12);
  border: 1px solid var(--gold);
  border-radius: 14px;
  padding: 12px;
  margin: 12px 0;
}
.belt-emoji { font-size: 2em; }
.belt-name { font-size: 1.3em; font-weight: bold; color: var(--gold); }

.belt-progress-wrap { margin: 8px 0 20px; }
.belt-progress-bar {
  background: rgba(255,255,255,0.15);
  border-radius: 8px;
  height: 10px;
  overflow: hidden;
}
.belt-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold-dark), var(--gold));
  width: 0%;
  transition: width 0.4s ease;
}
.belt-progress-label {
  font-size: 0.8em;
  color: var(--text-dim);
  margin: 6px 0 0;
}

.stats-row, .progress-stats-row {
  display: flex;
  gap: 12px;
  margin: 18px 0;
}
.stat-box {
  flex: 1;
  background: rgba(255,255,255,0.06);
  border-radius: 12px;
  padding: 12px 8px;
}
.stat-value {
  display: block;
  font-size: 1.6em;
  font-weight: bold;
  color: var(--white);
}
.stat-label {
  display: block;
  font-size: 0.75em;
  color: var(--text-dim);
  margin-top: 4px;
}

.btn {
  display: block;
  width: 100%;
  min-height: 48px;
  border: none;
  border-radius: 14px;
  font-size: 1.05em;
  font-weight: bold;
  cursor: pointer;
  margin-top: 12px;
  padding: 12px 16px;
  transition: transform 0.08s ease, filter 0.15s ease;
  font-family: inherit;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(180deg, var(--gold), var(--gold-dark));
  color: var(--purple-dark);
}
.btn-primary:hover { filter: brightness(1.08); }

.btn-large { font-size: 1.2em; padding: 16px; }

.btn-secondary {
  background: rgba(255,255,255,0.1);
  color: var(--white);
  border: 1px solid var(--text-dim);
}
.btn-secondary:hover { background: rgba(255,255,255,0.18); }

.btn-danger {
  background: var(--red);
  color: var(--white);
}
.btn-danger:hover { background: var(--red-dark); }

/* SESSION SCREEN */
.session-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.session-progress-wrap { flex: 1; }
.session-progress-bar {
  background: rgba(255,255,255,0.15);
  border-radius: 8px;
  height: 10px;
  overflow: hidden;
}
.session-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--purple-light), var(--gold));
  width: 0%;
  transition: width 0.3s ease;
}
.session-progress-label {
  font-size: 0.8em;
  color: var(--text-dim);
  margin-top: 4px;
  display: block;
}
.timer {
  font-size: 1.4em;
  font-weight: bold;
  color: var(--gold);
  background: rgba(0,0,0,0.3);
  border-radius: 10px;
  padding: 6px 14px;
  min-width: 80px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.timer.timer-warn { color: var(--red); animation: pulse 1s infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.q-type-badge {
  display: inline-block;
  background: var(--purple-light);
  color: var(--white);
  font-size: 0.7em;
  font-weight: bold;
  letter-spacing: 0.5px;
  padding: 4px 12px;
  border-radius: 20px;
  margin-bottom: 14px;
}

.q-prompt {
  font-size: 1.35em;
  line-height: 1.4;
  margin: 0 0 22px;
  color: var(--white);
}

.options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 480px) {
  .options-grid { grid-template-columns: 1fr; }
}

.option-btn {
  min-height: 48px;
  border-radius: 14px;
  border: 2px solid var(--purple-light);
  background: rgba(255,255,255,0.05);
  color: var(--white);
  font-size: 1em;
  font-weight: bold;
  padding: 14px 10px;
  cursor: pointer;
  transition: all 0.12s ease;
  font-family: inherit;
}
.option-btn:hover:not(:disabled) {
  background: var(--purple-light);
  transform: translateY(-2px);
}
.option-btn:active:not(:disabled) { transform: scale(0.96); }
.option-btn:disabled { cursor: default; }

.option-btn.correct {
  background: var(--green);
  border-color: var(--green-dark);
  color: var(--purple-dark);
}
.option-btn.wrong {
  background: var(--red);
  border-color: var(--red-dark);
  color: var(--white);
}

.text-input-wrap {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}
.text-input {
  flex: 1;
  min-height: 48px;
  border-radius: 14px;
  border: 2px solid var(--purple-light);
  background: rgba(255,255,255,0.08);
  color: var(--white);
  font-size: 1.1em;
  padding: 0 16px;
  font-family: inherit;
  text-transform: uppercase;
}
.text-input:focus { outline: none; border-color: var(--gold); }
.text-input-wrap .btn { width: auto; margin-top: 0; padding-left: 24px; padding-right: 24px; }

.feedback {
  margin-top: 18px;
  padding: 16px;
  border-radius: 14px;
  animation: popIn 0.2s ease-out;
}
.feedback.correct { background: rgba(61, 220, 132, 0.15); border: 2px solid var(--green); }
.feedback.wrong { background: rgba(255, 84, 112, 0.15); border: 2px solid var(--red); }

@keyframes popIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.feedback-headline {
  font-size: 1.2em;
  font-weight: bold;
  margin: 0 0 8px;
}
.feedback.correct .feedback-headline { color: var(--green); }
.feedback.wrong .feedback-headline { color: var(--red); }
.feedback-explanation {
  color: var(--text-dim);
  margin: 0 0 12px;
  line-height: 1.4;
}

/* FLASH */
.flash-correct { animation: flashGreen 0.35s ease-out; }
.flash-wrong { animation: flashRed 0.35s ease-out; }
@keyframes flashGreen {
  0% { box-shadow: 0 0 0 0 rgba(61,220,132,0.8); }
  100% { box-shadow: 0 0 0 30px rgba(61,220,132,0); }
}
@keyframes flashRed {
  0% { box-shadow: 0 0 0 0 rgba(255,84,112,0.8); }
  100% { box-shadow: 0 0 0 30px rgba(255,84,112,0); }
}

/* END SCREEN */
.end-score {
  font-size: 2.6em;
  font-weight: bold;
  color: var(--gold);
  margin: 8px 0;
}
.end-message {
  color: var(--text-dim);
  margin: 14px 0 20px;
  font-size: 1.05em;
}

/* PROGRESS SCREEN */
.section-heading {
  font-size: 1em;
  color: var(--gold);
  text-align: left;
  margin: 22px 0 10px;
}
.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 140px;
  background: rgba(0,0,0,0.2);
  border-radius: 12px;
  padding: 10px;
}
.bar-chart-empty {
  color: var(--text-dim);
  margin: auto;
  font-size: 0.9em;
}
.bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
}
.bar {
  width: 100%;
  border-radius: 6px 6px 0 0;
  background: linear-gradient(180deg, var(--gold), var(--purple-light));
  min-height: 4px;
}
.bar-label {
  font-size: 0.65em;
  color: var(--text-dim);
  margin-top: 4px;
}

.type-breakdown {
  text-align: left;
}
.type-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: rgba(255,255,255,0.05);
  border-radius: 10px;
  margin-bottom: 8px;
  font-size: 0.9em;
}
.type-row .type-count {
  color: var(--red);
  font-weight: bold;
}
.type-breakdown-empty {
  color: var(--text-dim);
  font-size: 0.9em;
  text-align: center;
  padding: 10px;
}

/* MODAL */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal-box {
  background: var(--purple-dark);
  border: 2px solid var(--red);
  border-radius: 16px;
  padding: 24px;
  max-width: 400px;
  text-align: center;
}
.modal-box p { color: var(--text-dim); }
.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}
.modal-actions .btn { margin-top: 0; }
