/* ===== Design tokens (shared with the main site) ===== */
:root {
  --yellow: #ffbc26;
  --yellow-dark: #e6a610;
  --red: #da251d;
  --green: #2e7d32;
  --ink: #1a1a1a;
  --slate: #5b6470;
  --bg-soft: #faf7f2;
  --card: #ffffff;
  --line: #ececec;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
}

*,
*::before,
*::after { box-sizing: border-box; }

/* Author display rules must not defeat the hidden attribute. */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: "Gabarito", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg-soft);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3, .brand-name {
  font-family: "Paytone One", "Gabarito", sans-serif;
  font-weight: 400;
  line-height: 1.1;
}

.screen h1 {
  font-size: clamp(1.55rem, 6vw, 2.1rem);
  overflow-wrap: anywhere;
}

/* ===== Header ===== */
.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}

.brand-logo { display: block; }
.brand-name { font-size: 1.2rem; }

.mango-counter {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 1.1rem;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 14px;
}

/* ===== Shell / screens ===== */
.game-shell {
  max-width: 560px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 14px 56px;
}

.screen {
  position: relative; /* anchors the floating mango-gain animation */
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 18px;
  text-align: center;
  max-width: 100%;
  overflow-wrap: break-word;
}

.screen-sub { color: var(--slate); }

.status-msg { min-height: 1.4em; color: var(--slate); font-size: 0.95rem; }
.status-msg.err { color: var(--red); }

/* ===== Assessment mode / level selects ===== */
.intro-selects {
  display: flex;
  flex-direction: column;
  flex-wrap: wrap;
  gap: 16px;
  margin: 24px 0 8px;
  text-align: left;
  min-width: 0;
}

.intro-select {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 700;
  color: var(--ink);
  min-width: 0;
  width: 100%;
}

.intro-select select {
  font: inherit;
  font-weight: 500;
  padding: 12px 14px;
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.intro-select select:focus {
  outline: 2px solid var(--yellow);
  outline-offset: 2px;
}

/* Legacy radio picker kept for any leftover markup */
.mode-picker {
  border: none;
  margin: 24px 0 8px;
  padding: 0;
  display: grid;
  gap: 10px;
  text-align: left;
}

.mode-picker-legend {
  font-weight: 700;
  padding: 0;
  margin-bottom: 8px;
}

.mode-option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.mode-option:has(input:checked) {
  border-color: var(--yellow);
  background: var(--bg-soft);
}

.mode-option.is-disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.mode-option input {
  accent-color: var(--yellow-dark);
  margin-top: 4px;
}

.mode-option-title { display: block; font-weight: 700; }

.mode-option-detail {
  display: block;
  color: var(--slate);
  font-size: 0.9rem;
  line-height: 1.45;
}

/* ===== Buttons ===== */
.btn {
  font: inherit;
  font-weight: 600;
  border: none;
  border-radius: 999px;
  padding: 12px 28px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.btn:disabled { opacity: 0.55; cursor: default; }

.btn-primary { background: var(--yellow); color: var(--ink); }
.btn-primary:hover:not(:disabled) { background: var(--yellow-dark); }

.btn-secondary {
  background: transparent;
  color: var(--ink);
  border: 2px solid var(--line);
}
.btn-secondary:hover:not(:disabled) { border-color: var(--yellow); }

.btn:active:not(:disabled) { transform: scale(0.98); }

/* ===== Question screen ===== */
.question-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 12px;
  color: var(--slate);
  font-size: 0.9rem;
  margin-bottom: 8px;
}

.progress-track {
  position: relative;
  height: 8px;
  background: var(--bg-soft);
  border-radius: 999px;
  margin: 6px 0 28px;
}

.progress-fill {
  height: 100%;
  width: 0;
  background: var(--yellow);
  border-radius: 999px;
  transition: width 0.6s ease;
}

/* The scooter rides the leading edge of the progress fill. */
.progress-scooter {
  position: absolute;
  top: 50%;
  left: 0;
  font-size: 1.5rem;
  line-height: 1;
  /* scaleX(-1) so the emoji faces the direction of travel */
  transform: translate(-50%, -58%) scaleX(-1);
  transition: left 0.6s ease;
}

.question-instruction {
  color: var(--slate);
  margin-bottom: 4px;
}

.question-content {
  font-size: clamp(1.25rem, 5.5vw, 1.9rem);
  font-weight: 700;
  margin: 8px 0 20px;
  min-height: 1.2em;
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* translate_choice: text starts blurred; tapping toggles the peek. */
.question-content.is-blurred {
  filter: blur(10px);
  cursor: pointer;
  user-select: none;
}

/* Word-by-word pronunciation drills: underline the active word, check off each. */
.question-content.drill-words {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  justify-content: center;
  align-items: baseline;
}

.drill-word {
  font-size: inherit;
  font-weight: inherit;
  line-height: 1.4;
  padding: 0 2px;
  border-bottom: 3px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.drill-word .drill-keyword {
  border-bottom: 3px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.drill-word.is-current {
  color: inherit;
  border-bottom-color: transparent;
}

.drill-word.is-current .drill-keyword {
  color: var(--yellow-dark);
  border-bottom-color: var(--yellow-dark);
}

.drill-word.is-done {
  color: var(--green);
}

.drill-word.is-done .drill-keyword {
  color: var(--green);
  border-bottom-color: transparent;
}

.drill-word.is-done::after {
  content: " ✓";
  font-size: 0.85em;
  font-weight: 700;
}

/* Third-try skip: stay yellow-underlined so it reads as "moved on", not fail. */
.drill-word.is-skipped {
  color: var(--slate);
  opacity: 0.9;
}

.drill-word.is-skipped .drill-keyword {
  color: var(--yellow-dark);
  border-bottom-color: var(--yellow-dark);
}

/* ?debug=1 only — shows which roots a question maps to, for content review. */
.question-debug-roots {
  font-size: 0.8rem;
  font-family: monospace;
  color: var(--yellow, #b8860b);
  background: rgba(0, 0, 0, 0.06);
  border-radius: 6px;
  padding: 6px 10px;
  margin: -12px 0 16px;
  white-space: pre-wrap;
}

.choices {
  display: grid;
  gap: 10px;
  margin: 16px 0;
}

.choice-button {
  font: inherit;
  font-size: 1.1rem;
  padding: 12px;
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.choice-button:hover:not(:disabled) { border-color: var(--yellow); }
.choice-button.is-correct { border-color: var(--green); background: #edf7ee; }
.choice-button.is-wrong { border-color: var(--red); background: #fdeeee; }
.choice-button:disabled { cursor: default; }

.speak-controls { margin: 16px 0; }

.speak-controls-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.btn-icon {
  font: inherit;
  font-size: 1.2rem;
  line-height: 1;
  padding: 10px 14px;
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.btn-icon:hover { border-color: var(--yellow); }

.type-answer-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 12px;
}

#type-answer-input {
  font: inherit;
  padding: 10px 14px;
  border: 2px solid var(--line);
  border-radius: 999px;
  min-width: 0;
  flex: 1 1 160px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

#type-answer-input:focus { outline: none; border-color: var(--yellow); }

.keyboard-help-link {
  flex-basis: 100%;
  font-size: 0.85rem;
  color: var(--slate);
  text-decoration: underline;
}

#record-button.is-recording {
  background: var(--red);
  color: #fff;
  animation: pulse 1.2s ease infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(218, 37, 29, 0.35); }
  50% { box-shadow: 0 0 0 12px rgba(218, 37, 29, 0); }
}

.speak-hint {
  color: var(--slate);
  font-size: 0.9rem;
  min-height: 1.3em;
  margin: 10px 0 0;
}

.answer-feedback {
  font-weight: 600;
  margin: 16px 0;
}

/* ===== Mango gain animation =====
   Floats up from the middle of the question card after each answer.
   Perfect answers get a bigger, golden pop; misses drift up small and grey. */
.mango-float {
  position: absolute;
  left: 50%;
  top: 45%;
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--yellow-dark);
  pointer-events: none;
  animation: mango-float-up 1.4s ease-out forwards;
}

.mango-float--perfect {
  font-size: 2.2rem;
  color: var(--yellow-dark);
  text-shadow: 0 0 14px rgba(255, 188, 38, 0.75);
  animation: mango-float-up 1.6s ease-out forwards, mango-pop 0.35s ease-out;
}

.mango-float--zero {
  font-size: 1.15rem;
  color: var(--slate);
}

@keyframes mango-float-up {
  0%   { opacity: 0; transform: translate(-50%, 10px); }
  15%  { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -90px); }
}

@keyframes mango-pop {
  0%   { scale: 0.4; }
  60%  { scale: 1.25; }
  100% { scale: 1; }
}

/* ===== Results screen ===== */
.overall-score {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 20px 0;
}

#overall-score-value {
  font-family: "Paytone One", sans-serif;
  font-size: 4rem;
  color: var(--yellow-dark);
  line-height: 1;
}

.overall-score-max {
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--slate);
  margin-left: 2px;
}

.overall-score-label { color: var(--slate); }

.beta-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 10px;
  font-family: Gabarito, sans-serif;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  vertical-align: middle;
  color: var(--ink);
  background: var(--yellow);
  border-radius: 999px;
}

.tutor-banner {
  margin: 0 0 16px;
  padding: 10px 14px;
  background: #fff8e6;
  border: 1px solid rgba(230, 166, 16, 0.35);
  border-radius: var(--radius-sm);
  font-weight: 600;
  color: var(--ink);
}

.tutor-signup-link-wrap {
  margin-top: 22px;
  text-align: center;
}

.tutor-signup-link {
  color: var(--slate);
  font-size: 0.95rem;
}

.question-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  align-items: center;
  margin-top: 8px;
}

.skip-button {
  opacity: 0.75;
}

.share-card-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin: 24px 0;
}

.share-canvas {
  width: 100%;
  max-width: 280px;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.share-card-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.tutor-feedback-cta {
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  padding: 18px;
  text-align: center;
  margin-top: 20px;
}

.tutor-feedback-cta p { margin: 0 0 14px; color: var(--slate); }

/* translate_listen per-question review — tutor-facing, not a chart */
.answer-review-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.answer-review-row {
  padding: 14px 16px;
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
}

.answer-review-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.85rem;
  color: var(--slate);
  margin-bottom: 6px;
}

.answer-review-number { font-weight: 700; color: var(--ink); }

.answer-review-prompt {
  margin: 0 0 8px;
  font-weight: 600;
}

.answer-review-response {
  margin: 0 0 6px;
  color: var(--slate);
  font-size: 0.95rem;
}

.answer-review-response--ai { font-style: italic; }

.answer-review-scores {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 8px;
  font-size: 0.95rem;
}

.answer-review-audio {
  display: block;
  width: 100%;
  margin-top: 10px;
}

/* Per-question review for translate_listen — no roots to bar-chart, so a
   tutor gets the raw material instead: each prompt, what was said, the
   instant score, and the AI-refined score once assess-game is deployed. */
.translate-review { margin-top: 20px; }

.translate-review-row {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 12px;
}

.translate-review-prompt { font-weight: 600; margin: 0 0 6px; }

.translate-review-heard {
  color: var(--slate);
  font-size: 0.9rem;
  margin: 0 0 6px;
}

.translate-review-scores {
  font-size: 0.9rem;
  font-weight: 600;
  margin: 0 0 6px;
}

.translate-review-row audio { width: 100%; margin-top: 4px; }

.email-gate {
  border-top: 1px solid var(--line);
  margin-top: 28px;
  padding-top: 20px;
}

/* No score block shown above yet (results held back until verification) —
   drop the separator so the email gate isn't dangling a line under nothing. */
#results-score-block[hidden] + .email-gate {
  border-top: none;
  margin-top: 0;
  padding-top: 0;
}

#email-gate-form {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

#gate-email {
  font: inherit;
  padding: 11px 16px;
  border: 2px solid var(--line);
  border-radius: 999px;
  min-width: 0;
  flex: 1 1 180px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

#gate-email:focus { outline: none; border-color: var(--yellow); }

.dev-magic-link {
  display: inline-block;
  margin-top: 14px;
  padding: 10px 18px;
  border: 2px dashed var(--yellow-dark);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
}

.detailed-report {
  border-top: 1px solid var(--line);
  margin-top: 28px;
  padding-top: 20px;
  text-align: left;
}

.ai-summary-label {
  margin: 0 0 6px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--slate);
}

.report-summary {
  background: var(--bg-soft);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 20px;
  font-weight: 600;
  line-height: 1.5;
}

.report-missing-answers {
  margin: 0 0 16px;
  color: var(--slate);
  line-height: 1.45;
}

.report-link-row {
  margin: 8px 0 20px;
}

.report-link-label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--slate);
}

.report-link-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.report-link-controls input {
  flex: 1 1 180px;
  min-width: 0;
  font: inherit;
  padding: 11px 14px;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: #fff;
  max-width: 100%;
  box-sizing: border-box;
}

.report-link-controls .btn {
  flex: 0 0 auto;
}

.category-block { margin-bottom: 20px; }

.category-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 12px;
  font-weight: 700;
  margin-bottom: 8px;
}

.category-name { text-transform: capitalize; }

.root-row {
  margin: 6px 0;
  font-size: 0.95rem;
}

.root-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

.root-name { flex: 1 1 100px; min-width: 0; }

.root-bar-track {
  flex: 1.4 1 120px;
  min-width: 80px;
  height: 8px;
  background: var(--bg-soft);
  border-radius: 999px;
  overflow: hidden;
}

.root-bar-fill {
  height: 100%;
  background: var(--yellow);
  border-radius: 999px;
}

.root-score-value {
  width: 36px;
  text-align: right;
  font-weight: 600;
}

/* Sample recordings per root — lets a tutor hear an actual attempt. */
.root-audio-samples {
  margin: 6px 0 10px;
  padding-left: 4px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.root-audio-sample {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.root-audio-label {
  font-size: 0.8rem;
  color: var(--text-muted, #888);
}

.root-audio-sample audio {
  height: 32px;
  max-width: min(220px, 100%);
}

#play-again-button { margin-top: 10px; }

@media (max-width: 480px) {
  .game-header {
    padding: 12px 14px;
  }

  .game-shell {
    padding: 16px 10px 48px;
  }

  .screen {
    padding: 22px 14px;
    border-radius: 14px;
  }

  .btn {
    max-width: 100%;
  }

  .share-card-actions .btn,
  .share-card-actions a.btn {
    flex: 1 1 140px;
    text-align: center;
  }

  .beta-badge {
    margin-left: 4px;
    padding: 2px 8px;
    font-size: 0.75rem;
  }

  .tutor-signup-link {
    display: inline-block;
    max-width: 100%;
    overflow-wrap: anywhere;
  }
}
