/* MIDE — Manitoba blues & greens, clean mobile-first */
:root {
  --mb-blue: #003f87;
  --mb-blue-mid: #1a5fad;
  --mb-blue-soft: #e8f1fb;
  --mb-green: #2d6a4f;
  --mb-green-mid: #40916c;
  --mb-green-soft: #e8f5ef;
  --gold: #c9a227;
  --ink: #1a2332;
  --muted: #5a6a7a;
  --line: #d4dde8;
  --card: #ffffff;
  --bg: #f4f7fb;
  --danger: #b42318;
  --danger-soft: #fef3f2;
  --ok: #1b7a3d;
  --ok-soft: #ecfdf3;
  --warn: #b54708;
  --warn-soft: #fffaeb;
  --radius: 14px;
  --shadow: 0 8px 24px rgba(0, 40, 90, 0.08);
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: linear-gradient(180deg, #eef4fb 0%, var(--bg) 180px);
  min-height: 100vh;
  line-height: 1.55;
}

img {
  max-width: 100%;
  height: auto;
}

a {
  color: var(--mb-blue-mid);
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: #000;
  color: #fff;
  padding: 0.5rem 1rem;
  z-index: 1000;
}
.skip-link:focus {
  left: 0;
}

.container {
  width: min(1080px, calc(100% - 2rem));
  margin-inline: auto;
}

/* Header */
.site-header {
  background: linear-gradient(120deg, var(--mb-blue) 0%, #0a4d9c 55%, var(--mb-green) 140%);
  color: #fff;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.65rem 0;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: #fff;
  text-decoration: none;
}

.brand-mascot {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.65);
  background: #fff;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-text strong {
  font-size: 1.25rem;
  letter-spacing: 0.04em;
}

.brand-sub {
  font-size: 0.72rem;
  opacity: 0.9;
  max-width: 14rem;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 0.35rem 0.85rem;
  flex-wrap: wrap;
}

.site-nav a {
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  opacity: 0.95;
}

.site-nav a:hover {
  text-decoration: underline;
}

.nav-user {
  font-size: 0.85rem;
  opacity: 0.85;
  margin-left: 0.25rem;
}

.nav-toggle {
  display: none;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.35);
  color: #fff;
  border-radius: 8px;
  padding: 0.4rem 0.75rem;
  font-weight: 600;
  cursor: pointer;
}

/* Main */
.site-main {
  padding: 1.5rem 0 3rem;
}

.site-footer {
  border-top: 1px solid var(--line);
  background: #fff;
  padding: 1.5rem 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.footer-inner {
  display: grid;
  gap: 0.75rem;
}

.footer-brand {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  color: var(--ink);
}

.footer-mascot {
  border-radius: 50%;
  object-fit: cover;
  width: 40px;
  height: 40px;
}

.footer-note a {
  color: var(--mb-blue);
}

/* Typography */
h1,
h2,
h3 {
  line-height: 1.25;
  color: var(--mb-blue);
  margin-top: 0;
}

.lead {
  font-size: 1.1rem;
  color: var(--muted);
  max-width: 42rem;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--mb-green);
  margin: 0 0 0.35rem;
}

/* Cards & layout */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem 1.35rem;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s ease;
}

.card + .card {
  margin-top: 1rem;
}

.hero {
  display: grid;
  grid-template-columns: 1.4fr 0.8fr;
  gap: 1.5rem;
  align-items: center;
  margin-bottom: 1.5rem;
}

.hero-card {
  background: linear-gradient(145deg, #fff 0%, var(--mb-blue-soft) 100%);
  border: 1px solid #c9daf0;
  border-radius: calc(var(--radius) + 4px);
  padding: 1.75rem;
  box-shadow: var(--shadow);
}

.mascot-panel {
  text-align: center;
  background: #fff;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  padding: 1rem;
  box-shadow: var(--shadow);
}

.mascot-panel img,
.mascot-panel .mascot-hero-img,
.mascot-panel .mascot-hero-video {
  width: 160px;
  height: 160px;
  object-fit: cover;
  border-radius: 50%;
  border: 3px solid var(--mb-green-mid);
  display: block;
  margin: 0 auto;
  background: #f7faf8;
}

.mascot-panel p {
  margin: 0.75rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

/* Hero moments — richer motion than lesson bob (still fallback when no video) */
.mascot-hero-stage {
  position: relative;
  width: 160px;
  height: 160px;
  margin: 0 auto;
}

.mascot-hero-img.middy-hero-wave {
  animation: middy-hero-wave 2.8s ease-in-out infinite;
}
.mascot-hero-img.middy-hero-study {
  animation: middy-hero-study 3.4s ease-in-out infinite;
}
.mascot-hero-img.middy-hero-celebrate {
  animation: middy-hero-celebrate 1.6s ease-in-out infinite;
}

@keyframes middy-hero-wave {
  0%, 100% { transform: translateY(0) rotate(0deg) scale(1); }
  15% { transform: translateY(-4px) rotate(-6deg) scale(1.02); }
  30% { transform: translateY(-2px) rotate(7deg) scale(1.03); }
  45% { transform: translateY(-5px) rotate(-5deg) scale(1.02); }
  60% { transform: translateY(-1px) rotate(4deg) scale(1.01); }
  80% { transform: translateY(-3px) rotate(-2deg) scale(1.02); }
}

@keyframes middy-hero-study {
  0%, 100% { transform: translateY(0) scale(1); }
  25% { transform: translateY(-3px) scale(1.03); }
  50% { transform: translateY(-1px) scale(1.01) rotate(-1deg); }
  75% { transform: translateY(-4px) scale(1.04) rotate(1deg); }
}

@keyframes middy-hero-celebrate {
  0%, 100% { transform: translateY(0) scale(1) rotate(0deg); }
  20% { transform: translateY(-10px) scale(1.08) rotate(-4deg); }
  40% { transform: translateY(-2px) scale(1.04) rotate(4deg); }
  60% { transform: translateY(-12px) scale(1.1) rotate(-3deg); }
  80% { transform: translateY(-3px) scale(1.05) rotate(2deg); }
}

.mascot-hero-video,
.middy-reaction-video {
  object-fit: cover;
}

/* Hide static poster when GIF/video is shown.
   Must beat `.mascot-panel img { display:block }` specificity. */
.mascot-panel .mascot-hero-fallback,
.middy-reaction .middy-reaction-fallback {
  display: none !important;
}

/* Animated GIFs: no extra CSS bob (motion is in the file) */
.mascot-panel .mascot-hero-gif,
.middy-reaction .middy-reaction-gif {
  animation: none;
}

@media (prefers-reduced-motion: reduce) {
  .mascot-hero-img.middy-hero-wave,
  .mascot-hero-img.middy-hero-study,
  .mascot-hero-img.middy-hero-celebrate {
    animation: none;
  }
  .mascot-panel .mascot-hero-video,
  .middy-reaction .middy-reaction-video,
  .mascot-panel .mascot-hero-gif,
  .middy-reaction .middy-reaction-gif {
    display: none !important;
  }
  /* Static JPG only when user prefers reduced motion */
  .mascot-panel .mascot-hero-fallback,
  .middy-reaction .middy-reaction-fallback {
    display: block !important;
    position: static;
  }
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
}

.stat {
  background: var(--mb-blue-soft);
  border-radius: 12px;
  padding: 0.9rem 1rem;
  border: 1px solid #c9daf0;
}

.stat .num {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--mb-blue);
  line-height: 1.1;
}

.stat .label {
  font-size: 0.82rem;
  color: var(--muted);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border-radius: 10px;
  padding: 0.65rem 1.1rem;
  font-weight: 700;
  font-size: 0.95rem;
  text-decoration: none;
  border: 2px solid transparent;
  cursor: pointer;
  font-family: inherit;
}

.btn-primary {
  background: var(--mb-blue);
  color: #fff;
}
.btn-primary:hover {
  background: var(--mb-blue-mid);
}

.btn-secondary {
  background: var(--mb-green);
  color: #fff;
}
.btn-secondary:hover {
  background: var(--mb-green-mid);
}

.btn-ghost {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.45);
  color: #fff;
}

.btn-outline {
  background: #fff;
  border-color: var(--mb-blue);
  color: var(--mb-blue);
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.85rem;
}

.btn-block {
  width: 100%;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1rem;
}

/* Forms */
label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.3rem;
  font-size: 0.92rem;
}

.form-group {
  margin-bottom: 1rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
  background: #fff;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--mb-blue-mid);
  outline-offset: 1px;
}

.help {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

.form-card {
  max-width: 440px;
  margin: 0 auto;
}

/* Alerts */
.alert {
  border-radius: 10px;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  font-weight: 600;
}

.alert-success {
  background: var(--ok-soft);
  color: var(--ok);
  border: 1px solid #abefc6;
}
.alert-error {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid #fecdca;
}
.alert-info {
  background: var(--mb-blue-soft);
  color: var(--mb-blue);
  border: 1px solid #b2ccf0;
}

/* Module list */
.module-list {
  display: grid;
  gap: 0.85rem;
}

.module-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 1rem;
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.module-card:hover {
  transform: translateY(-3px);
  border-color: var(--mb-blue-mid);
  box-shadow: 0 12px 28px rgba(0, 40, 90, 0.12);
}

.module-card:hover .lesson-thumb,
.module-card:hover .module-thumb {
  transform: scale(1.06) rotate(-2deg);
  border-color: var(--mb-blue-mid);
}

.lesson-thumb,
.module-thumb {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 50%;
  border: 2px solid var(--mb-green-mid, #2d8a54);
  background: #fff;
  flex-shrink: 0;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.module-num {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(145deg, var(--mb-green-soft), #d4f0e2);
  color: var(--mb-green);
  display: grid;
  place-items: center;
  font-weight: 800;
  box-shadow: inset 0 0 0 2px rgba(45, 106, 79, 0.12);
}

.module-num-wrap {
  position: relative;
  width: 56px;
  height: 56px;
  flex-shrink: 0;
}

.module-num-wrap .module-thumb {
  width: 56px;
  height: 56px;
}

.module-num-wrap .module-num-badge {
  position: absolute;
  right: -4px;
  bottom: -4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--mb-blue);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 800;
  display: grid;
  place-items: center;
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0, 40, 90, 0.2);
}

.module-card h3 {
  margin: 0 0 0.2rem;
  font-size: 1.05rem;
}

.module-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.progress-bar {
  height: 8px;
  background: #e5ebf3;
  border-radius: 99px;
  overflow: hidden;
  margin-top: 0.5rem;
  max-width: 220px;
}

.progress-bar > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--mb-green-mid), var(--mb-blue-mid));
  border-radius: 99px;
}

.badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: var(--mb-blue-soft);
  color: var(--mb-blue);
}

.badge-ok {
  background: var(--ok-soft);
  color: var(--ok);
}
.badge-warn {
  background: var(--warn-soft);
  color: var(--warn);
}
.btn-danger {
  background: #a32020;
  color: #fff;
  border: 1px solid #8a1a1a;
}
.btn-danger:hover {
  background: #8a1a1a;
  color: #fff;
}

.badge-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.module-page-head {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.module-page-mascot {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--mb-green-mid);
  background: #fff;
  box-shadow: 0 6px 16px rgba(45, 106, 79, 0.15);
  flex-shrink: 0;
  animation: middy-bob 4.5s ease-in-out infinite;
}

@media (max-width: 600px) {
  .module-page-head {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* Lessons — compact mascot floats beside content (no tall caption block) */
.lesson-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 1rem;
  margin-bottom: 0.75rem;
}

.lesson-title-row h1 {
  margin: 0;
}

.lesson-body {
  font-size: 1.02rem;
}

.lesson-with-mascot {
  display: flow-root; /* contain float */
  overflow: hidden;
}

.lesson-mascot {
  float: left;
  width: 132px;
  margin: 0 1.15rem 0.85rem 0;
  shape-outside: margin-box;
}

.lesson-mascot img {
  width: 132px;
  height: 132px;
  object-fit: cover;
  border-radius: 50%;
  border: 3px solid var(--mb-green-mid);
  background: #fff;
  box-shadow: 0 8px 20px rgba(45, 106, 79, 0.18);
  animation: middy-bob 4.5s ease-in-out infinite;
}

.lesson-content > *:first-child {
  margin-top: 0;
}

@keyframes middy-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

@media (prefers-reduced-motion: reduce) {
  .lesson-mascot img {
    animation: none;
  }
  .module-card:hover {
    transform: none;
  }
}

@media (max-width: 640px) {
  .lesson-mascot {
    float: none;
    width: 96px;
    margin: 0 auto 1rem;
  }
  .lesson-mascot img {
    width: 96px;
    height: 96px;
    display: block;
    margin-inline: auto;
  }
  .lesson-content {
    text-align: left;
  }
}

.callout.middy-tip {
  background: linear-gradient(135deg, var(--mb-green-soft) 0%, #fff 70%);
  border-left: 4px solid var(--mb-green-mid, #2d8a54);
  padding: 0.75rem 1rem;
}

.middy-tip-row {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.middy-tip-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--mb-green-mid, #2d8a54);
  box-shadow: 0 3px 10px rgba(45, 106, 79, 0.18);
  flex-shrink: 0;
  background: #fff;
}

.middy-tip-body {
  flex: 1;
  min-width: 0;
  padding-top: 0.15rem;
}

.middy-tip-label {
  color: var(--mb-green, #1a5c3a);
  font-weight: 700;
  margin-right: 0.15rem;
}

.callout.callout-table {
  padding: 0.65rem 0.85rem;
  overflow-x: auto;
}

.callout.callout-table table.data {
  margin: 0;
}

.lesson-body h3 {
  margin-top: 1.5rem;
}

.lesson-body ul,
.lesson-body ol {
  padding-left: 1.25rem;
}

/* Playful card polish */
.card:hover {
  box-shadow: 0 10px 28px rgba(0, 40, 90, 0.08);
}

.badge-ok {
  animation: badge-pop 0.45s ease;
}

@keyframes badge-pop {
  0% { transform: scale(0.85); opacity: 0.6; }
  60% { transform: scale(1.06); }
  100% { transform: scale(1); opacity: 1; }
}

.lesson-body li {
  margin-bottom: 0.35rem;
}

.callout {
  background: var(--mb-green-soft);
  border-left: 4px solid var(--mb-green);
  padding: 0.85rem 1rem;
  border-radius: 0 10px 10px 0;
  margin: 1rem 0;
}

.callout.handbook {
  background: linear-gradient(135deg, #e8f1fb 0%, #f0f7ff 55%, #e8f5ef 100%);
  border-left-color: var(--mb-blue);
  border: 1px solid #b2ccf0;
  border-left-width: 5px;
  box-shadow: 0 4px 14px rgba(0, 63, 135, 0.08);
}

.callout strong {
  color: var(--mb-blue);
}

/* MPI + book badge icon */
.mpi-handbook-icon {
  display: inline-block;
  width: 1.35em;
  height: 1.35em;
  vertical-align: -0.28em;
  flex-shrink: 0;
  object-fit: contain;
}

/* Clickable handbook chips (in lessons + callouts) */
.handbook-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0.2rem 0.35rem 0.2rem 0;
  padding: 0.35rem 0.7rem 0.35rem 0.4rem;
  background: #fff;
  border: 2px solid var(--mb-blue-mid);
  border-radius: 999px;
  color: var(--mb-blue);
  font-weight: 700;
  font-size: 0.95em;
  text-decoration: none;
  box-shadow: 0 2px 8px rgba(0, 63, 135, 0.12);
  transition: transform 0.12s ease, background 0.12s ease, box-shadow 0.12s ease;
  max-width: 100%;
}

.handbook-link:hover,
.handbook-link:focus-visible {
  background: var(--mb-blue);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0, 63, 135, 0.2);
  outline: none;
}

.handbook-link:hover .mpi-handbook-icon,
.handbook-link:focus-visible .mpi-handbook-icon {
  filter: brightness(1.08);
}

.handbook-link-text {
  line-height: 1.25;
}

.handbook-link-ext {
  font-size: 0.85em;
  opacity: 0.75;
  font-weight: 600;
}

.handbook-callout {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  margin-top: 1rem;
  padding: 1rem 1.15rem;
}

.handbook-callout > .mpi-handbook-icon {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  vertical-align: top;
  filter: drop-shadow(0 2px 4px rgba(0, 63, 135, 0.15));
}

.handbook-callout-body {
  min-width: 0;
  flex: 1;
}

.handbook-callout-title {
  display: block;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--mb-blue);
  margin-bottom: 0.35rem;
}

.handbook-callout-link {
  margin: 0.15rem 0;
}

.handbook-callout-note {
  margin: 0.45rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.lesson-content .help .handbook-link,
.lesson-content p .handbook-link {
  margin-top: 0.35rem;
}

.lesson-nav {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 1.25rem;
}

/* Quiz / exam questions */
.question {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
  background: #fff;
}

.question-num {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--mb-green);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.question h3 {
  font-size: 1.05rem;
  margin: 0.25rem 0 0.75rem;
  color: var(--ink);
}

.choices {
  display: grid;
  gap: 0.45rem;
}

.choice {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  background: #fafbfd;
}

.choice:hover {
  border-color: var(--mb-blue-mid);
  background: var(--mb-blue-soft);
}

.choice input {
  margin-top: 0.2rem;
}

.exam-toolbar {
  position: sticky;
  top: 68px;
  z-index: 40;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.75rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}

.timer {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  font-size: 1.35rem;
  color: var(--mb-blue);
}

.timer-warn {
  color: var(--warn);
}
.timer-critical {
  color: var(--danger);
  animation: pulse 1s infinite;
}

@keyframes pulse {
  50% {
    opacity: 0.65;
  }
}

/* Results */
.result-hero {
  text-align: center;
  padding: 1.5rem 1.25rem 1.75rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: #fff;
}

.result-hero-pass {
  background: linear-gradient(160deg, #ecfdf3, #fff 55%);
  border-color: #abefc6;
}

.result-hero-close {
  background: linear-gradient(160deg, #fffaeb, #fff 55%);
  border-color: #f7d070;
}

.result-hero-try {
  background: linear-gradient(160deg, #e8f1fb, #fff 55%);
  border-color: #b2ccf0;
}

/* Legacy classes (if any remain) */
.result-hero.pass {
  background: linear-gradient(160deg, #ecfdf3, #fff);
  border: 1px solid #abefc6;
}
.result-hero.fail {
  background: linear-gradient(160deg, #e8f1fb, #fff);
  border: 1px solid #b2ccf0;
}

.result-score {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--mb-blue);
  margin-top: 0.5rem;
}

/* Middy score reaction */
.middy-reaction {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 1rem 1.25rem;
  margin-bottom: 0.5rem;
  text-align: left;
}

.middy-reaction-stage {
  position: relative;
  width: 148px;
  height: 148px;
  flex-shrink: 0;
}

.middy-reaction-img {
  width: 140px;
  height: 140px;
  object-fit: cover;
  border-radius: 50%;
  border: 4px solid var(--mb-green-mid);
  background: #fff;
  box-shadow: 0 10px 24px rgba(0, 40, 90, 0.15);
  position: relative;
  z-index: 1;
}

.middy-speech {
  flex: 1 1 220px;
  max-width: 28rem;
  background: #fff;
  border: 2px solid var(--mb-blue-soft);
  border-radius: 18px;
  padding: 0.85rem 1.1rem;
  box-shadow: 0 6px 18px rgba(0, 40, 90, 0.08);
  position: relative;
}

.middy-speech::before {
  content: "";
  position: absolute;
  left: -10px;
  top: 36px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-left: 2px solid var(--mb-blue-soft);
  border-bottom: 2px solid var(--mb-blue-soft);
  transform: rotate(45deg);
}

@media (max-width: 560px) {
  .middy-reaction {
    flex-direction: column;
    text-align: center;
  }
  .middy-speech::before {
    left: 50%;
    top: -9px;
    margin-left: -9px;
    border-left: 2px solid var(--mb-blue-soft);
    border-bottom: none;
    border-top: 2px solid var(--mb-blue-soft);
  }
}

.middy-speech-title {
  margin: 0 0 0.35rem;
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--mb-blue);
}

.middy-speech-text {
  margin: 0;
  color: var(--ink);
  line-height: 1.45;
}

.middy-speech-extra {
  margin: 0.45rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.middy-reaction-pass .middy-speech-title {
  color: var(--ok);
}
.middy-reaction-close .middy-speech-title {
  color: var(--warn);
}
.middy-reaction-try .middy-speech-title {
  color: var(--mb-blue);
}

/* Sparkles on strong passes */
.middy-reaction-sparkles {
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 2;
}
.middy-reaction-sparkles span {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--gold);
  opacity: 0;
}
.middy-reaction-pass .middy-reaction-sparkles span {
  animation: middy-sparkle 1.6s ease-in-out infinite;
}
.middy-reaction-sparkles span:nth-child(1) { top: 8%; left: 12%; animation-delay: 0s; }
.middy-reaction-sparkles span:nth-child(2) { top: 4%; right: 14%; animation-delay: 0.35s; }
.middy-reaction-sparkles span:nth-child(3) { bottom: 18%; left: 6%; animation-delay: 0.7s; }
.middy-reaction-sparkles span:nth-child(4) { bottom: 12%; right: 8%; animation-delay: 1s; }

@keyframes middy-sparkle {
  0%, 100% { opacity: 0; transform: scale(0.4) rotate(0deg); }
  40% { opacity: 1; transform: scale(1) rotate(20deg); }
  70% { opacity: 0.7; transform: scale(0.85) rotate(-10deg); }
}

/* Motion: cheer / encourage / nod */
.middy-anim-cheer {
  animation: middy-cheer 0.9s ease-in-out 0s 3, middy-bob 3.5s ease-in-out 2.7s infinite;
}
.middy-anim-encourage {
  animation: middy-encourage 1.2s ease-in-out 0s 2, middy-bob 4s ease-in-out 2.4s infinite;
}
.middy-anim-nod {
  animation: middy-nod 1s ease-in-out 0s 2, middy-bob 4s ease-in-out 2s infinite;
}

@keyframes middy-cheer {
  0%, 100% { transform: translateY(0) scale(1) rotate(0deg); }
  25% { transform: translateY(-14px) scale(1.06) rotate(-4deg); }
  50% { transform: translateY(-4px) scale(1.02) rotate(3deg); }
  75% { transform: translateY(-12px) scale(1.05) rotate(-2deg); }
}

@keyframes middy-encourage {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  30% { transform: translateY(-6px) rotate(-5deg); }
  60% { transform: translateY(-6px) rotate(5deg); }
}

@keyframes middy-nod {
  0%, 100% { transform: translateY(0); }
  40% { transform: translateY(6px); }
  70% { transform: translateY(-3px); }
}

@media (prefers-reduced-motion: reduce) {
  .middy-anim-cheer,
  .middy-anim-encourage,
  .middy-anim-nod,
  .middy-reaction-pass .middy-reaction-sparkles span {
    animation: none;
  }
}

.review-item {
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 0.75rem;
  border: 1px solid var(--line);
  background: #fff;
}

.review-item.correct {
  border-color: #abefc6;
  background: #f6fef9;
}

.review-item.wrong {
  border-color: #fecdca;
  background: #fffaf9;
}

.review-item .meta {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.5rem;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

table.data th,
table.data td {
  text-align: left;
  padding: 0.55rem 0.65rem;
  border-bottom: 1px solid var(--line);
}

table.data th {
  background: var(--mb-blue-soft);
  color: var(--mb-blue);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Auth split */
.auth-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  align-items: start;
}

/* Road signs gallery & image questions */
.sign-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.sign-card {
  background: #fafbfd;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.85rem;
  text-align: center;
}

.sign-card-img {
  background: #eef2f6;
  border-radius: 10px;
  padding: 0.65rem;
  margin-bottom: 0.5rem;
  border: 1px solid #d4dde8;
  min-height: 150px;
  display: grid;
  place-items: center;
}

.sign-card-img img,
.sign-img {
  width: 140px;
  height: 140px;
  object-fit: contain;
}

.sign-card h3 {
  font-size: 0.95rem;
  margin: 0.35rem 0 0.25rem;
  color: var(--mb-blue);
}

.sign-card p {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
  text-align: left;
  line-height: 1.35;
}

.sign-source {
  margin-top: 0.4rem !important;
  font-size: 0.7rem !important;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 700;
  color: var(--mb-green) !important;
}

.mpi-credit {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0.5rem 0 0;
  line-height: 1.45;
}

.mpi-credit a {
  color: var(--mb-blue-mid);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.mpi-credit a:hover {
  color: var(--mb-blue);
}

.mpi-credit-inline {
  margin: 0 0 0.5rem;
  font-weight: 600;
  color: var(--mb-blue);
}

.sign-source a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.commons-credit-list {
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.45;
  margin: 0.5rem 0 1.25rem;
  padding-left: 1.25rem;
}

.commons-credit-list li {
  margin-bottom: 0.4rem;
}

.commons-credit-list a {
  color: var(--mb-blue-mid);
  font-weight: 600;
}

.commons-credit-list code {
  font-size: 0.8em;
  background: var(--mb-blue-soft);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  color: var(--mb-blue);
}

.sign-card-img img,
.sign-figure .sign-img {
  background: transparent;
}

.sign-figure {
  display: flex;
  justify-content: center;
  margin: 0.75rem 0 1rem;
  padding: 0.75rem;
  background: linear-gradient(180deg, #fff, var(--mb-blue-soft));
  border: 1px solid #c9daf0;
  border-radius: 12px;
}

.sign-figure .sign-img {
  width: 160px;
  height: 160px;
  filter: drop-shadow(0 4px 10px rgba(0, 40, 90, 0.12));
}

.question .sign-figure {
  max-width: 280px;
  margin-left: auto;
  margin-right: auto;
}

/* Responsive */
@media (max-width: 800px) {
  .hero,
  .grid-2,
  .grid-3,
  .auth-layout {
    grid-template-columns: 1fr;
  }

  .nav-toggle {
    display: inline-block;
  }

  .site-nav {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: flex-start;
    padding-bottom: 0.75rem;
  }

  .site-nav.is-open {
    display: flex;
  }

  .module-card {
    grid-template-columns: auto 1fr;
  }

  .module-card .module-cta {
    grid-column: 1 / -1;
  }

  .module-num-wrap {
    grid-row: span 1;
  }

  .brand-sub {
    display: none;
  }
}
