/* ==========================================================================
   QUIZBOT: RAINFOREST EDITION
   Palette: emerald #0B3D2E, jungle #1B5E3B, moss #6FA33B, fern #A3C96A,
            gold #F2B33D, mist #F4F8EE, canopy #06201A
   ========================================================================== */

:root {
  --emerald: #0B3D2E;
  --jungle: #1B5E3B;
  --moss: #6FA33B;
  --fern: #A3C96A;
  --gold: #F2B33D;
  --mist: #F4F8EE;
  --canopy: #06201A;

  --glass-card: rgba(11, 61, 46, 0.55);
  --glass-card-hover: rgba(27, 94, 59, 0.6);
  --glass-border: rgba(244, 248, 238, 0.16);

  --correct: #6FA33B;
  --correct-bg: rgba(111, 163, 59, 0.18);
  --correct-border: rgba(163, 201, 106, 0.6);
  --wrong: #E2574C;
  --wrong-bg: rgba(226, 87, 76, 0.16);
  --wrong-border: rgba(226, 87, 76, 0.55);

  --text-primary: #F4F8EE;
  --text-secondary: #C5D6B4;
  --text-muted: #8FA886;

  --font-display: 'Baloo 2', 'Nunito', system-ui, sans-serif;
  --font-body: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

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

html,
body {
  min-height: 100vh;
  color: var(--text-primary, #F4F8EE);
  font-family: var(--font-body, 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

body {
  position: relative;
  background-color: var(--canopy, #06201A);
  background-image:
    radial-gradient(900px 500px at 85% -5%, rgba(242, 179, 61, 0.16), transparent 60%),
    radial-gradient(800px 600px at 0% 100%, rgba(111, 163, 59, 0.18), transparent 60%),
    linear-gradient(160deg, var(--canopy, #06201A) 0%, var(--emerald, #0B3D2E) 55%, var(--jungle, #1B5E3B) 100%);
  background-attachment: fixed;
}

/* Ambient glow blobs (soft light through the canopy) */
.canopy-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(90px);
  pointer-events: none;
  z-index: 1;
  opacity: .55;
  animation: floatGlow 22s ease-in-out infinite alternate;
}

.glow-1 {
  top: -10%;
  left: -6%;
  width: 520px;
  height: 520px;
  background: radial-gradient(circle, rgba(163, 201, 106, .28), transparent 70%);
}

.glow-2 {
  bottom: -15%;
  right: -6%;
  width: 620px;
  height: 620px;
  background: radial-gradient(circle, rgba(242, 179, 61, .2), transparent 70%);
  animation-delay: -8s;
}

.glow-3 {
  top: 40%;
  left: 58%;
  width: 420px;
  height: 420px;
  background: radial-gradient(circle, rgba(111, 163, 59, .2), transparent 70%);
  animation-delay: -13s;
}

@keyframes floatGlow {
  0% {
    transform: translate(0, 0) scale(1);
  }

  50% {
    transform: translate(28px, -22px) scale(1.07);
  }

  100% {
    transform: translate(-20px, 26px) scale(.95);
  }
}

.app-container {
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  padding: 90px 20px 40px;
}

/* ---------- Header ---------- */
.forest-hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: rgba(6, 32, 26, 0.72);
  backdrop-filter: blur(16px) saturate(150%);
  -webkit-backdrop-filter: blur(16px) saturate(150%);
  border-bottom: 1px solid var(--glass-border, rgba(244, 248, 238, 0.16));
  box-shadow: 0 4px 28px rgba(0, 0, 0, .4);
}

.hud-content {
  max-width: 1080px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.brand-leaf {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 22px;
  background: radial-gradient(circle at 30% 30%, var(--fern, #A3C96A), var(--jungle, #1B5E3B));
  border: 2px solid var(--gold, #F2B33D);
  box-shadow: 0 0 0 4px rgba(242, 179, 61, .14), 0 6px 14px rgba(0, 0, 0, .35);
}

.brand-title-group {
  display: flex;
  flex-direction: column;
  line-height: 1;
}

.brand-title {
  font-family: var(--font-display, 'Baloo 2', 'Nunito', system-ui, sans-serif);
  font-size: 21px;
  font-weight: 800;
  letter-spacing: .02em;
  color: var(--mist, #F4F8EE);
}

.brand-sub {
  margin-top: 4px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--gold, #F2B33D);
}

.hud-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.hud-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 13px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--jungle, #1B5E3B), var(--emerald, #0B3D2E));
  border: 1px solid rgba(111, 163, 59, .6);
  font-size: 13px;
  font-weight: 800;
  color: var(--mist, #F4F8EE);
  transition: transform .2s ease;
}

.hud-pill.streak {
  border-color: var(--gold, #F2B33D);
  color: var(--gold, #F2B33D);
}

.hud-pill.score {
  color: var(--fern, #A3C96A);
}

.hud-pill.health {
  font-size: 12px;
  font-weight: 700;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--moss, #6FA33B);
  box-shadow: 0 0 8px var(--moss, #6FA33B);
  animation: pulseDot 2s infinite;
}

@keyframes pulseDot {

  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }

  50% {
    opacity: .5;
    transform: scale(.85);
  }
}

.hud-icon-btn {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: rgba(244, 248, 238, .08);
  border: 1px solid var(--glass-border, rgba(244, 248, 238, 0.16));
  color: var(--mist, #F4F8EE);
  font-size: 16px;
  cursor: pointer;
  transition: all .2s ease;
}

.hud-icon-btn:hover {
  border-color: var(--gold, #F2B33D);
  background: rgba(242, 179, 61, .14);
  transform: translateY(-1px);
}

.hud-icon-btn[aria-pressed="true"] {
  background: rgba(242, 179, 61, .24);
  border-color: var(--gold, #F2B33D);
}

.hud-icon-btn:focus-visible,
.chip:focus-visible,
.segmented-btn:focus-visible,
.btn-primary:focus-visible,
.btn-next:focus-visible,
.btn-secondary:focus-visible,
.option-card:focus-visible,
.forest-input:focus-visible {
  outline: 3px solid var(--gold, #F2B33D);
  outline-offset: 2px;
}

/* ---------- Growing vine progress ---------- */
.progress-container {
  position: relative;
  width: 100%;
  height: 6px;
  background: rgba(244, 248, 238, .08);
  overflow: visible;
}

.progress-bar {
  position: relative;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--jungle, #1B5E3B), var(--moss, #6FA33B) 60%, var(--fern, #A3C96A));
  border-radius: 0 999px 999px 0;
  box-shadow: 0 0 12px rgba(163, 201, 106, .55);
  transition: width .6s cubic-bezier(.3, .9, .3, 1);
}

.progress-comet {
  /* the leaf at the tip of the vine */
  position: absolute;
  right: -10px;
  top: -11px;
  width: 24px;
  height: 24px;
  font-size: 20px;
  line-height: 24px;
  text-align: center;
  transform-origin: 20% 80%;
  animation: sway 2.4s ease-in-out infinite;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .45));
}

.progress-comet::before {
  content: "🌿";
}

@keyframes sway {

  0%,
  100% {
    transform: rotate(-14deg);
  }

  50% {
    transform: rotate(16deg);
  }
}

/* ---------- Glass panel ---------- */
.glass-panel {
  position: relative;
  width: 100%;
  max-width: 700px;
  padding: 40px;
  background: var(--glass-card, rgba(11, 61, 46, 0.55));
  backdrop-filter: blur(18px) saturate(130%);
  -webkit-backdrop-filter: blur(18px) saturate(130%);
  border: 1px solid var(--glass-border, rgba(244, 248, 238, 0.16));
  border-radius: 28px;
  box-shadow: 0 28px 70px -15px rgba(0, 0, 0, .7), inset 0 1px 0 rgba(255, 255, 255, .14);
  overflow: hidden;
}

.panel-header {
  margin-bottom: 24px;
}

.badge-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 13px;
  margin-bottom: 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--gold, #F2B33D);
  background: rgba(242, 179, 61, .1);
  border: 1px solid rgba(242, 179, 61, .35);
}

h1.panel-title {
  font-family: var(--font-display, 'Baloo 2', 'Nunito', system-ui, sans-serif);
  font-size: 36px;
  font-weight: 800;
  line-height: 1.15;
  margin-bottom: 8px;
  color: var(--mist, #F4F8EE);
}

p.panel-subtitle {
  color: var(--text-secondary, #C5D6B4);
  font-size: 16px;
  line-height: 1.55;
}

/* ---------- Topic chips ---------- */
.topic-chips-label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--fern, #A3C96A);
}

.topic-chips-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 15px;
  border-radius: 999px;
  background: rgba(244, 248, 238, .07);
  border: 1px solid rgba(244, 248, 238, .16);
  color: var(--mist, #F4F8EE);
  font-family: var(--font-body, 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all .2s ease;
}

.chip:hover {
  background: rgba(111, 163, 59, .28);
  border-color: var(--fern, #A3C96A);
  transform: translateY(-2px);
}

.chip.active {
  background: rgba(242, 179, 61, .2);
  border-color: var(--gold, #F2B33D);
}

/* ---------- Form controls ---------- */
.form-group {
  margin-bottom: 22px;
}

.form-label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 800;
  color: var(--text-secondary, #C5D6B4);
}

.input-glow-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon {
  position: absolute;
  left: 16px;
  font-size: 17px;
  pointer-events: none;
}

.forest-input {
  width: 100%;
  padding: 14px 16px 14px 46px;
  background: rgba(6, 32, 26, .65);
  border: 2px solid rgba(163, 201, 106, .28);
  border-radius: 16px;
  color: var(--mist, #F4F8EE);
  font-family: var(--font-body, 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif);
  font-size: 16px;
  font-weight: 600;
  outline: none;
  transition: border-color .2s ease, box-shadow .2s ease;
}

.forest-input:focus {
  border-color: var(--gold, #F2B33D);
  box-shadow: 0 0 0 4px rgba(242, 179, 61, .16);
}

.forest-input::placeholder {
  color: rgba(244, 248, 238, .45);
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 6px;
  background: rgba(6, 32, 26, .5);
  border: 1px solid var(--glass-border, rgba(244, 248, 238, 0.16));
  border-radius: 16px;
}

.segmented-btn {
  padding: 11px 12px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 12px;
  color: var(--text-secondary, #C5D6B4);
  font-family: var(--font-body, 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif);
  font-size: 14px;
  font-weight: 800;
  text-align: center;
  cursor: pointer;
  transition: all .2s ease;
}

.segmented-btn:hover:not(.active) {
  color: var(--mist, #F4F8EE);
  background: rgba(244, 248, 238, .07);
}

.segmented-btn.active {
  color: var(--mist, #F4F8EE);
  background: rgba(111, 163, 59, .35);
  border-color: var(--fern, #A3C96A);
}

/* ---------- Buttons ---------- */
.btn-primary {
  position: relative;
  width: 100%;
  margin-top: 26px;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--gold, #F2B33D), #F7C968);
  color: var(--canopy, #06201A);
  font-family: var(--font-display, 'Baloo 2', 'Nunito', system-ui, sans-serif);
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 10px 26px rgba(242, 179, 61, .3);
  transition: transform .2s ease, filter .2s ease;
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  filter: brightness(1.05);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(1px);
}

.btn-primary:disabled {
  opacity: .6;
  cursor: not-allowed;
}

.btn-primary.is-loading::after,
.btn-next.is-loading::after {
  content: "🍃";
  display: inline-block;
  animation: spinLeaf 1s linear infinite;
}

.btn-secondary {
  flex: 1;
  padding: 14px 20px;
  border-radius: 999px;
  background: rgba(244, 248, 238, .08);
  border: 2px solid var(--glass-border, rgba(244, 248, 238, 0.16));
  color: var(--mist, #F4F8EE);
  font-family: var(--font-display, 'Baloo 2', 'Nunito', system-ui, sans-serif);
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  transition: all .2s ease;
}

.btn-secondary:hover {
  background: rgba(244, 248, 238, .15);
  border-color: var(--fern, #A3C96A);
  transform: translateY(-1px);
}

/* ---------- Quiz screen ---------- */
.quiz-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
}

.sector-indicator {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--fern, #A3C96A);
}

.meta-badges {
  display: flex;
  align-items: center;
  gap: 8px;
}

.difficulty-pill {
  padding: 4px 12px;
  border: 1px solid;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.difficulty-pill.easy {
  color: var(--fern, #A3C96A);
  background: var(--correct-bg, rgba(111, 163, 59, 0.18));
  border-color: var(--correct-border, rgba(163, 201, 106, 0.6));
}

.difficulty-pill.medium {
  color: var(--gold, #F2B33D);
  background: rgba(242, 179, 61, .14);
  border-color: rgba(242, 179, 61, .45);
}

.difficulty-pill.hard {
  color: #FF8A7F;
  background: var(--wrong-bg, rgba(226, 87, 76, 0.16));
  border-color: var(--wrong-border, rgba(226, 87, 76, 0.55));
}

.fallback-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  color: var(--gold, #F2B33D);
  background: rgba(242, 179, 61, .12);
  border: 1px solid rgba(242, 179, 61, .35);
}

.question-heading {
  margin-bottom: 26px;
  font-family: var(--font-display, 'Baloo 2', 'Nunito', system-ui, sans-serif);
  font-size: 25px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--mist, #F4F8EE);
}

.options-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.option-card {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  padding: 15px 18px;
  background: rgba(6, 32, 26, .5);
  border: 2px solid rgba(163, 201, 106, .26);
  border-radius: 18px;
  color: var(--mist, #F4F8EE);
  font-family: var(--font-body, 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.4;
  text-align: left;
  cursor: pointer;
  transition: transform .15s ease, border-color .15s ease, background .15s ease, box-shadow .15s ease;
}

.option-card:hover:not(:disabled) {
  background: var(--glass-card-hover, rgba(27, 94, 59, 0.6));
  border-color: var(--fern, #A3C96A);
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(0, 0, 0, .3);
}

.option-card:disabled {
  cursor: default;
}

.option-letter-badge {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: rgba(244, 248, 238, .1);
  border: 1px solid rgba(244, 248, 238, .18);
  font-family: var(--font-display, 'Baloo 2', 'Nunito', system-ui, sans-serif);
  font-size: 16px;
  font-weight: 800;
  color: var(--fern, #A3C96A);
}

.option-text {
  flex: 1;
}

.option-shortcut {
  padding: 2px 8px;
  border-radius: 8px;
  background: rgba(244, 248, 238, .06);
  border: 1px solid rgba(244, 248, 238, .12);
  font-size: 12px;
  font-weight: 800;
  color: var(--text-muted, #8FA886);
}

.option-card.selected {
  background: rgba(242, 179, 61, .16);
  border-color: var(--gold, #F2B33D);
  box-shadow: 0 0 0 4px rgba(242, 179, 61, .16);
  transform: translateY(-2px);
}

.option-card.selected .option-letter-badge {
  background: var(--gold, #F2B33D);
  border-color: var(--gold, #F2B33D);
  color: var(--canopy, #06201A);
}

.option-card.correct {
  background: linear-gradient(135deg, rgba(111, 163, 59, .55), rgba(27, 94, 59, .7));
  border-color: var(--fern, #A3C96A);
  animation: popIn .4s ease;
}

.option-card.correct .option-letter-badge {
  background: var(--fern, #A3C96A);
  border-color: var(--fern, #A3C96A);
  color: var(--canopy, #06201A);
}

.option-card.wrong {
  background: var(--wrong-bg, rgba(226, 87, 76, 0.16));
  border-color: var(--wrong, #E2574C);
  animation: shake .4s ease;
}

.option-card.wrong .option-letter-badge {
  background: var(--wrong, #E2574C);
  border-color: var(--wrong, #E2574C);
  color: #fff;
}

.option-card:disabled:not(.correct):not(.wrong):not(.selected) {
  opacity: .6;
}

@keyframes popIn {
  50% {
    transform: scale(1.025);
  }
}

@keyframes shake {

  20%,
  60% {
    transform: translateX(-6px);
  }

  40%,
  80% {
    transform: translateX(6px);
  }
}

/* ---------- Feedback ---------- */
.feedback-box {
  margin-top: 18px;
  padding: 18px 22px;
  border: 1px solid;
  border-radius: 18px;
  animation: slideDown .35s ease;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.feedback-box.correct {
  background: var(--correct-bg, rgba(111, 163, 59, 0.18));
  border-color: var(--correct-border, rgba(163, 201, 106, 0.6));
}

.feedback-box.wrong {
  background: var(--wrong-bg, rgba(226, 87, 76, 0.16));
  border-color: var(--wrong-border, rgba(226, 87, 76, 0.55));
}

.feedback-header {
  margin-bottom: 6px;
  font-family: var(--font-display, 'Baloo 2', 'Nunito', system-ui, sans-serif);
  font-size: 18px;
  font-weight: 800;
}

.feedback-box.correct .feedback-header {
  color: var(--fern, #A3C96A);
}

.feedback-box.wrong .feedback-header {
  color: #FF8A7F;
}

.feedback-explanation {
  font-size: 15px;
  line-height: 1.55;
  color: var(--text-secondary, #C5D6B4);
}

.btn-next {
  width: 100%;
  margin-top: 18px;
  padding: 13px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 2px solid var(--gold, #F2B33D);
  border-radius: 999px;
  background: rgba(242, 179, 61, .14);
  color: var(--mist, #F4F8EE);
  font-family: var(--font-display, 'Baloo 2', 'Nunito', system-ui, sans-serif);
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  transition: all .2s ease;
}

.btn-next:hover:not(:disabled) {
  background: rgba(242, 179, 61, .3);
  transform: translateY(-1px);
}

.btn-next:disabled {
  opacity: .6;
  cursor: not-allowed;
}

/* ---------- Debrief ---------- */
.debrief-panel {
  text-align: center;
}

.rank-badge-large {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  padding: 8px 20px;
  border-radius: 999px;
  background: rgba(242, 179, 61, .14);
  border: 1px solid rgba(242, 179, 61, .45);
  color: var(--gold, #F2B33D);
  font-family: var(--font-display, 'Baloo 2', 'Nunito', system-ui, sans-serif);
  font-size: 17px;
  font-weight: 800;
}

.score-display-huge {
  margin: 12px 0;
  font-family: var(--font-display, 'Baloo 2', 'Nunito', system-ui, sans-serif);
  font-size: 76px;
  font-weight: 800;
  line-height: 1;
  color: var(--gold, #F2B33D);
  text-shadow: 0 4px 24px rgba(242, 179, 61, .35);
}

.high-score-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  border-radius: 999px;
  background: rgba(163, 201, 106, .18);
  border: 1px solid var(--fern, #A3C96A);
  color: var(--fern, #A3C96A);
  font-size: 14px;
  font-weight: 800;
}

.debrief-metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 28px 0;
}

.metric-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 16px 12px;
  background: rgba(6, 32, 26, .5);
  border: 1px solid var(--glass-border, rgba(244, 248, 238, 0.16));
  border-radius: 18px;
}

.metric-val {
  font-family: var(--font-display, 'Baloo 2', 'Nunito', system-ui, sans-serif);
  font-size: 24px;
  font-weight: 800;
  color: var(--mist, #F4F8EE);
}

.metric-lbl {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-muted, #8FA886);
}

.debrief-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

.debrief-actions .btn-primary {
  flex: 1;
  width: auto;
}

/* ---------- Chat ---------- */
.chat-messages-container {
  background: rgba(6, 32, 26, .45);
  border: 1px solid var(--glass-border, rgba(244, 248, 238, 0.16));
  border-radius: 20px;
  overflow: hidden;
}

.chat-messages {
  height: 340px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  scroll-behavior: smooth;
}

.chat-message {
  display: flex;
  max-width: 90%;
  animation: slideDown .25s ease;
}

.chat-message.user-message {
  align-self: flex-end;
}

.chat-message.bot-message {
  align-self: flex-start;
}

.message-content {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.user-message .message-content {
  flex-direction: row-reverse;
}

.message-avatar {
  flex: none;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 21px;
  background: radial-gradient(circle at 30% 30%, var(--gold, #F2B33D), var(--moss, #6FA33B));
  border: 2px solid var(--fern, #A3C96A);
}

.message-bubble {
  padding: 10px 15px;
  background: rgba(27, 94, 59, .65);
  border: 1px solid rgba(163, 201, 106, .28);
  border-radius: 18px;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.message-bubble p {
  white-space: pre-wrap;
  margin: 0;
}

.bot-message .message-bubble {
  border-top-left-radius: 6px;
}

.user-message .message-bubble {
  background: rgba(242, 179, 61, .2);
  border-color: rgba(242, 179, 61, .45);
  border-top-right-radius: 6px;
}

.chat-message.error-message .message-bubble {
  background: var(--wrong-bg, rgba(226, 87, 76, 0.16));
  border-color: var(--wrong-border, rgba(226, 87, 76, 0.55));
}

.loading-message {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--fern, #A3C96A);
}

.loading-spinner-small {
  width: 20px;
  height: 20px;
  font-size: 18px;
  line-height: 20px;
  animation: spinLeaf 1s linear infinite;
}

.loading-spinner-small::before {
  content: "🍃";
}

.chat-input-area {
  margin-top: 14px;
}

.chat-input-wrapper {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.chat-input-wrapper .forest-input {
  padding-left: 18px;
}

.chat-input-wrapper .btn-primary {
  width: auto;
  margin-top: 0;
  padding: 12px 22px;
  font-size: 16px;
}

.chat-input-wrapper .forest-input:disabled {
  opacity: .55;
}

.chat-status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted, #8FA886);
}

.chat-status.connecting .status-dot {
  background: var(--gold, #F2B33D);
  box-shadow: 0 0 8px var(--gold, #F2B33D);
}

.chat-status.error .status-dot {
  background: var(--wrong, #E2574C);
  box-shadow: 0 0 8px var(--wrong, #E2574C);
  animation: none;
}

/* ---------- Loading: rotating leaf + skeleton ---------- */
.loading-indicator {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: rgba(6, 32, 26, .82);
  backdrop-filter: blur(8px);
  pointer-events: none;
}

.loading-spinner {
  width: 56px;
  height: 56px;
  font-size: 48px;
  line-height: 56px;
  text-align: center;
  animation: spinLeaf 1.1s linear infinite;
}

.loading-spinner::before {
  content: "🍃";
}

.loading-text {
  font-size: 17px;
  font-weight: 800;
  color: var(--fern, #A3C96A);
}

@keyframes spinLeaf {
  to {
    transform: rotate(360deg);
  }
}

.skeleton-layer {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.skeleton-shimmer {
  background: linear-gradient(90deg, rgba(244, 248, 238, .05) 25%, rgba(244, 248, 238, .14) 50%, rgba(244, 248, 238, .05) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 14px;
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }

  100% {
    background-position: -200% 0;
  }
}

/* ---------- Error banner ---------- */
.error-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  padding: 14px 18px;
  background: var(--wrong-bg, rgba(226, 87, 76, 0.16));
  border: 1px solid var(--wrong-border, rgba(226, 87, 76, 0.55));
  border-radius: 16px;
  color: #FFB3AB;
  font-size: 15px;
  font-weight: 700;
  animation: slideDown .3s ease;
}

/* ---------- Leaf confetti (used by rainforest.js) ---------- */
.rf-confetti {
  position: absolute;
  inset: 0;
  z-index: 40;
  overflow: hidden;
  pointer-events: none;
}

.rf-confetti span {
  position: absolute;
  top: -40px;
  will-change: transform;
  animation: leafFall linear forwards;
}

@keyframes leafFall {
  to {
    transform: translate3d(var(--dx, 0), 110vh, 0) rotate(var(--rot, 540deg));
    opacity: .9;
  }
}

.hidden {
  display: none !important;
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .app-container {
    padding: 80px 14px 24px;
  }

  .hud-content {
    padding: 10px 14px;
    gap: 8px;
  }

  .brand-sub,
  .hud-pill.health,
  .option-shortcut {
    display: none;
  }

  .hud-actions {
    gap: 6px;
  }

  .hud-icon-btn {
    width: 34px;
    height: 34px;
  }

  .glass-panel {
    padding: 24px 18px;
    border-radius: 22px;
  }

  h1.panel-title {
    font-size: 27px;
  }

  .question-heading {
    font-size: 20px;
  }

  .debrief-metrics-grid {
    grid-template-columns: 1fr;
  }

  .debrief-actions {
    flex-direction: column;
  }

  .score-display-huge {
    font-size: 56px;
  }

  .chat-messages {
    height: 300px;
  }
}

@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }

  .rf-confetti {
    display: none;
  }
}

/* ==========================================================================
   OPTIONAL PHOTO BACKGROUNDS
   After you generate the images, copy them into public/images/ and uncomment.
   ==========================================================================
body {
  background-image:
    linear-gradient(rgba(6, 32, 26, .78), rgba(6, 32, 26, .9)),
    url('/images/quiz-bg.webp');
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
}
.message-avatar { background: url('/images/bot-avatar.webp') center / cover; font-size: 0; }
*/