:root {
  --red: #ff4d6d;
  --orange: #ff9f1c;
  --yellow: #ffd60a;
  --green: #2dc653;
  --blue: #2f80ed;
  --indigo: #5a55e6;
  --violet: #9b5de5;
  --ink: #253046;
  --muted: #667085;
  --paper: #ffffff;
  --soft: #f7f8fc;
  --line: #e5e7eb;
  --success: #177245;
  --danger: #b42318;
  --shadow: 0 18px 50px rgba(40, 52, 85, 0.14);
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Fredoka", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 15%, rgba(255, 77, 109, .16), transparent 24%),
    radial-gradient(circle at 87% 18%, rgba(47, 128, 237, .16), transparent 22%),
    radial-gradient(circle at 80% 84%, rgba(45, 198, 83, .13), transparent 26%),
    linear-gradient(145deg, #fff 0%, #fbfbff 55%, #f8fbff 100%);
}

button, input { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, a:focus-visible {
  outline: 4px solid rgba(47, 128, 237, .28);
  outline-offset: 3px;
}

.app-shell {
  width: min(1080px, calc(100% - 28px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 22px 0 26px;
}

.brand-bar {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 18px;
  align-items: center;
  padding: 16px 18px;
  border-radius: 28px;
  background:
    linear-gradient(90deg,
      rgba(255,77,109,.28),
      rgba(255,159,28,.28),
      rgba(255,214,10,.30),
      rgba(45,198,83,.25),
      rgba(47,128,237,.25),
      rgba(90,85,230,.25),
      rgba(155,93,229,.28));
  border: 2px solid rgba(255,255,255,.9);
  box-shadow: var(--shadow);
}

.brand-bar::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 7px;
  background: linear-gradient(90deg, var(--red), var(--orange), var(--yellow), var(--green), var(--blue), var(--indigo), var(--violet));
}

.brand {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 132px;
  height: 88px;
  border-radius: 18px;
  text-decoration: none;
}

.brand-logo {
  display: block;
  max-width: 126px;
  max-height: 84px;
  object-fit: contain;
  /* The supplied logo has a white background. Multiply makes white visually
     disappear into the rainbow panel while preserving the dark logo artwork. */
  mix-blend-mode: multiply;
}

.brand-copy h1 {
  margin: 0 0 3px;
  font-size: clamp(1.45rem, 3vw, 2.35rem);
  line-height: 1;
  letter-spacing: .01em;
}

.brand-copy a {
  color: var(--ink);
  font-weight: 600;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.icon-button,
.primary-button,
.secondary-button,
.answer-button {
  border: 0;
  border-radius: 16px;
  font-weight: 700;
  transition: transform .15s ease, box-shadow .15s ease, opacity .15s ease;
}

.icon-button:hover,
.primary-button:hover,
.secondary-button:hover,
.answer-button:hover { transform: translateY(-2px); }

.icon-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 14px;
  background: rgba(255,255,255,.88);
  color: var(--ink);
  box-shadow: 0 7px 18px rgba(37,48,70,.10);
}

.quiz-card {
  margin-top: 22px;
  padding: clamp(18px, 3vw, 30px);
  background: rgba(255,255,255,.94);
  border: 1px solid rgba(255,255,255,.9);
  border-radius: 30px;
  box-shadow: var(--shadow);
}

.quiz-topline {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
}

.eyebrow {
  display: inline-block;
  margin: 0 0 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: #fff4cf;
  color: #8a5b00;
  font-size: .9rem;
  font-weight: 700;
}

.quiz-topline h2 {
  margin: 0;
  font-size: clamp(1.45rem, 3vw, 2.15rem);
}

.score-box {
  min-width: 92px;
  padding: 10px 13px;
  text-align: center;
  background: linear-gradient(145deg, #f7f2ff, #eef5ff);
  border-radius: 18px;
}

.score-box span { display: block; font-size: .8rem; color: var(--muted); }
.score-box strong { display: block; font-size: 1.6rem; }

.progress-row { margin: 18px 0 22px; }
#progressText { display: block; margin-bottom: 7px; font-size: .95rem; font-weight: 600; color: var(--muted); }
.progress-track { height: 12px; overflow: hidden; background: #edf0f5; border-radius: 999px; }
.progress-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--red), var(--orange), var(--yellow), var(--green), var(--blue), var(--violet));
  transition: width .28s ease;
}

.quiz-stage {
  min-height: 390px;
  display: grid;
  place-items: center;
}

.question-panel,
.result-panel,
.loading-card,
.error-card {
  width: min(760px, 100%);
  border-radius: 26px;
  background: var(--soft);
  border: 2px solid #eef0f5;
  padding: clamp(18px, 3vw, 28px);
}

.question-image-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 18px;
}

.question-image {
  display: block;
  max-width: min(480px, 100%);
  width: auto;
  max-height: clamp(180px, 32vh, 310px);
  object-fit: contain;
  border-radius: 22px;
  box-shadow: 0 10px 28px rgba(37,48,70,.14);
}

.question-number {
  margin: 0 0 6px;
  color: var(--blue);
  font-size: .9rem;
  font-weight: 700;
}

.question-text {
  margin: 0 0 20px;
  font-size: clamp(1.25rem, 2.7vw, 1.8rem);
  line-height: 1.28;
}

.answer-grid { display: grid; gap: 12px; }
.answer-button {
  width: 100%;
  padding: 14px 16px;
  text-align: left;
  background: #fff;
  color: var(--ink);
  border: 2px solid #e7eaf0;
  box-shadow: 0 5px 12px rgba(37,48,70,.06);
}

.answer-button:nth-child(7n+1) { border-left: 8px solid var(--red); }
.answer-button:nth-child(7n+2) { border-left: 8px solid var(--orange); }
.answer-button:nth-child(7n+3) { border-left: 8px solid var(--yellow); }
.answer-button:nth-child(7n+4) { border-left: 8px solid var(--green); }
.answer-button:nth-child(7n+5) { border-left: 8px solid var(--blue); }
.answer-button:nth-child(7n+6) { border-left: 8px solid var(--indigo); }
.answer-button:nth-child(7n) { border-left: 8px solid var(--violet); }

.answer-button:disabled { cursor: default; opacity: .82; transform: none; }
.answer-button.correct { background: #e9f9ef; border-color: #65c98a; }
.answer-button.incorrect { background: #fff0f0; border-color: #ef8b8b; }

.typed-form { display: flex; gap: 10px; }
.typed-input {
  flex: 1;
  min-width: 0;
  padding: 14px 16px;
  border: 2px solid #dbe0e8;
  border-radius: 16px;
  background: #fff;
  color: var(--ink);
}

.check-button {
  padding: 13px 18px;
  border: 0;
  border-radius: 16px;
  background: var(--blue);
  color: #fff;
  font-weight: 700;
}

.feedback {
  margin-top: 16px;
  padding: 13px 15px;
  border-radius: 16px;
  line-height: 1.45;
}
.feedback.correct { background: #e9f9ef; color: var(--success); }
.feedback.incorrect { background: #fff0f0; color: var(--danger); }
.feedback strong { display: block; margin-bottom: 2px; }

.action-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 20px;
}

.primary-button,
.secondary-button { padding: 12px 18px; }
.primary-button {
  background: linear-gradient(90deg, var(--blue), var(--violet));
  color: #fff;
  box-shadow: 0 8px 18px rgba(90,85,230,.24);
}
.primary-button:disabled { cursor: not-allowed; opacity: .4; transform: none; }
.secondary-button { background: #eef1f6; color: var(--ink); }

.result-panel { text-align: center; }
.result-emoji { font-size: 3.4rem; }
.result-panel h3 { margin: 6px 0; font-size: 2rem; }
.result-score { margin: 12px 0 4px; font-size: 1.25rem; }
.result-score strong { font-size: 1.8rem; }

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 8px 0;
  color: var(--muted);
  font-size: .9rem;
}

/* Fullscreen-specific layout */
.app-shell:fullscreen {
  width: min(1180px, calc(100% - 24px));
  height: 100dvh;
  min-height: 0;
  padding: 12px 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.app-shell:fullscreen .brand-bar {
  flex: 0 0 auto;
}

.app-shell:fullscreen .quiz-card {
  flex: 1 1 auto;
  min-height: 0;
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.app-shell:fullscreen .quiz-stage {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  align-items: start;
  justify-items: center;
  padding-bottom: 8px;
}

.app-shell:fullscreen .action-row {
  flex: 0 0 auto;
  margin-top: 12px;
  padding-top: 8px;
  background: rgba(255,255,255,.96);
}

.app-shell:fullscreen .site-footer {
  display: none;
}

/* Catalogue quiz thumbnails */
.catalogue-image-wrap {
  width: 100%;
  max-width: 360px;
  margin: 0 auto 18px;
  border-radius: 22px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 10px 28px rgba(40, 52, 85, 0.12);
}

.catalogue-image {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

/* Playful catalogue typography */
.catalogue-page .brand-copy h1,
.catalogue-page .quiz-topline h2 {
  font-family: "Fredoka", sans-serif;
  font-weight: 700;
}

.catalogue-page .level-pill,
.catalogue-page .quiz-topline p {
  font-family: "Fredoka", sans-serif;
  font-weight: 500;
}

@media (max-width: 720px) {
  .app-shell { width: min(100% - 18px, 1080px); padding-top: 10px; }
  .brand-bar { grid-template-columns: 86px 1fr auto; gap: 10px; padding: 12px; border-radius: 22px; }
  .brand { width: 82px; height: 62px; }
  .brand-logo { max-width: 80px; max-height: 58px; }
  .button-label { display: none; }
  .icon-button { padding: 10px 12px; font-size: 1.2rem; }
  .quiz-card { margin-top: 12px; border-radius: 24px; }
  .typed-form { flex-direction: column; }
  .site-footer { flex-direction: column; }
}

@media (max-width: 470px) {
  .brand-copy h1 { font-size: 1.15rem; }
  .brand-copy a { font-size: .76rem; }
  .quiz-topline { align-items: center; }
  .score-box { min-width: 74px; }
  .question-panel { padding: 16px; }
  .action-row { flex-direction: column-reverse; }
  .primary-button, .secondary-button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
