html {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background-color: #1769e0;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  min-height: 100dvh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background-color: #1769e0;
  transition: background-color 250ms ease;
}

body.practice-mode {
  background-color: white;
}

html.practice-mode {
  background-color: white;
}

.top-bar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 10;
  width: 100%;
  height: 11.5vh;
  min-height: 72px;
  padding: 0 32px;
  display: flex;
  align-items: center;
  gap: 18px;
  background-color: white;
  border-radius: 0 0 22px 22px;
  transform: translateY(-110%);
}

.top-bar.bar-enter {
  animation: slide-down 1500ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.top-bar h1 {
  margin: 0;
  color: #1769e0;
  font-size: clamp(1.4rem, 3vw, 2.3rem);
}

.top-bar p {
  margin: 0;
  color: #1769e0;
  font-size: clamp(0.8rem, 1.6vw, 1.05rem);
}

.account-button {
  margin-left: auto;
  border: 1px solid #cfe0ff;
  border-radius: 999px;
  padding: 10px 15px;
  background: #1769e0;
  color: #fff;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 800;
  cursor: pointer;
}

.account-button.signed-in { background: #fff; color: #1769e0; }

.page {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  padding: calc(11.5vh + 30px) 32px 140px;
}

.page:not(.hidden) {
  animation: page-enter 440ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.main-panel:not(.hidden) {
  animation: panel-enter 360ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.math-atmosphere {
  position: fixed;
  z-index: 0;
  inset: 11.5vh 0 0;
  overflow: hidden;
  pointer-events: none;
}

.math-atmosphere span {
  position: absolute;
  color: #1769e0;
  font-size: clamp(3rem, 7vw, 7rem);
  font-weight: 850;
  opacity: 0.045;
  animation: symbol-float 9s ease-in-out infinite alternate;
}

.math-atmosphere span:nth-child(1) { left: 4%; top: 13%; }
.math-atmosphere span:nth-child(2) { right: 5%; top: 18%; animation-delay: -2s; }
.math-atmosphere span:nth-child(3) { left: 9%; bottom: 13%; animation-delay: -5s; }
.math-atmosphere span:nth-child(4) { right: 8%; bottom: 10%; animation-delay: -7s; }
.math-atmosphere span:nth-child(5) { left: 45%; top: 7%; font-size: clamp(2.5rem, 5vw, 5rem); animation-delay: -3s; }
.math-atmosphere span:nth-child(6) { right: 36%; bottom: 5%; font-size: clamp(2.5rem, 5vw, 5rem); animation-delay: -6s; }

body:not(.practice-mode) .math-atmosphere span {
  color: #fff;
  opacity: 0.075;
}

.home-page {
  background:
    radial-gradient(circle at 88% 14%, rgba(154, 210, 255, 0.24), transparent 31%),
    radial-gradient(circle at 9% 76%, rgba(109, 164, 255, 0.3), transparent 32%),
    #1769e0;
}

.main-panel {
  width: min(1120px, 100%);
  margin: 0 auto;
}

.home-hero {
  min-height: min(590px, calc(100dvh - 240px));
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(300px, 0.8fr);
  align-items: center;
  gap: clamp(32px, 7vw, 100px);
}

.hero-copy {
  color: white;
}

.eyebrow,
.section-label {
  margin: 0;
  color: #b9d7ff;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.13em;
}

.hero-copy h2 {
  max-width: 720px;
  margin: 16px 0;
  font-size: clamp(2.7rem, 6vw, 5rem);
  line-height: 1.02;
  letter-spacing: -0.055em;
}

.hero-intro {
  max-width: 620px;
  margin: 0;
  color: #e5f0ff;
  font-size: clamp(1rem, 1.9vw, 1.18rem);
  line-height: 1.65;
}

.hero-features {
  margin: 26px 0 30px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.hero-features span {
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.27);
  border-radius: 999px;
  color: white;
  font-size: 0.88rem;
  font-weight: 700;
}

.topic-button {
  min-width: clamp(250px, 27vw, 340px);
  min-height: 66px;
  padding: 16px 22px;
  border: 0;
  border-radius: 16px;
  background-color: white;
  color: #1769e0;
  font: inherit;
  font-size: clamp(1rem, 2vw, 1.15rem);
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 14px 28px rgba(4, 38, 102, 0.25);
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.topic-button span {
  margin-left: 14px;
  font-size: 1.25em;
}

.topic-button:hover {
  transform: translateY(-3px);
  box-shadow: 0 18px 36px rgba(4, 38, 102, 0.32);
}

.topic-button:active {
  transform: scale(0.98);
}

.hero-maths-card {
  position: relative;
  overflow: hidden;
  padding: clamp(28px, 4vw, 46px);
  border: 1px solid rgba(255, 255, 255, 0.62);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.94);
  color: #1769e0;
  box-shadow: 0 24px 60px rgba(3, 35, 97, 0.24);
  transform: rotate(1.8deg);
  animation: focus-card-drop 1050ms 180ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.hero-maths-card > :not(.card-math-rain) { position: relative; z-index: 1; }

.card-math-rain {
  position: absolute;
  z-index: 0;
  inset: 0;
  pointer-events: none;
}

.card-math-rain span {
  position: absolute;
  top: 0;
  color: #1769e0;
  font-size: clamp(1.7rem, 3vw, 2.8rem);
  font-weight: 850;
  opacity: 0;
  animation: card-symbol-drop 900ms cubic-bezier(0.2, 0.85, 0.35, 1.12) both;
}

.card-math-rain span:nth-child(1) { left: 8%; --fall: 78px; animation-delay: 650ms; }
.card-math-rain span:nth-child(2) { left: 30%; --fall: 132px; animation-delay: 760ms; }
.card-math-rain span:nth-child(3) { left: 52%; --fall: 62px; animation-delay: 880ms; }
.card-math-rain span:nth-child(4) { left: 76%; --fall: 116px; animation-delay: 990ms; }
.card-math-rain span:nth-child(5) { left: 18%; --fall: 214px; animation-delay: 1080ms; font-size: 1.55rem; }
.card-math-rain span:nth-child(6) { left: 69%; --fall: 226px; animation-delay: 1170ms; font-size: 1.55rem; }

.hero-maths-card > p:first-child {
  margin: 0;
  color: #6a82ab;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.hero-maths-card h3 {
  margin: 12px 0 36px;
  font-size: clamp(1.45rem, 3vw, 2.2rem);
  letter-spacing: -0.04em;
}

.hero-operation-set {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 0 0 28px;
}

.hero-operation-set span {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border-radius: 18px;
  background: #edf4ff;
  color: #1769e0;
  font-size: clamp(1.45rem, 3vw, 2.1rem);
  font-weight: 850;
  transition: transform 180ms ease, background-color 180ms ease;
}

.hero-maths-card:hover .hero-operation-set span:nth-child(1) { transform: translateY(-4px); }
.hero-maths-card:hover .hero-operation-set span:nth-child(2) { transform: translateY(3px); }
.hero-maths-card:hover .hero-operation-set span:nth-child(3) { transform: translateY(-2px); }
.hero-maths-card:hover .hero-operation-set span:nth-child(4) { transform: translateY(4px); }

.hero-equation {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 2vw, 22px);
  font-size: clamp(1.5rem, 3vw, 2.4rem);
  font-weight: 800;
}

.mini-fraction {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
}

.mini-fraction span:first-child {
  padding: 0 0.28em 0.14em;
  border-bottom: 3px solid currentColor;
}

.mini-fraction span:last-child {
  padding-top: 0.14em;
}

.mini-fraction.accent {
  color: #0b9b5e;
}

.hero-card-note {
  margin: 38px 0 0;
  color: #5a729f;
  font-size: 0.98rem;
  text-align: center;
}

.topic-preview {
  margin-top: 12px;
}

.topic-preview-card {
  margin-top: 12px;
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 18px;
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: 20px;
  background-color: rgba(255, 255, 255, 0.13);
  color: white;
}

.topic-symbol {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background-color: white;
  color: #1769e0;
  font-size: 1.8rem;
  font-weight: 800;
}

.topic-preview-card h3,
.topic-preview-card p {
  margin: 0;
}

.topic-preview-card h3 {
  font-size: 1.15rem;
}

.topic-preview-card p {
  margin-top: 4px;
  color: #d8e8ff;
  font-size: 0.92rem;
  line-height: 1.45;
}

.topic-status {
  margin-left: auto;
  padding: 7px 10px;
  border-radius: 999px;
  background-color: rgba(255, 255, 255, 0.18);
  font-size: 0.85rem;
  font-weight: 800;
  white-space: nowrap;
}

.progress-panel {
  color: white;
}

.progress-panel h2 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.5rem);
}

.profile-heading { display: flex; align-items: center; gap: 16px; max-width: 760px; margin-bottom: 18px; }
.profile-heading .eyebrow { margin: 0 0 4px; }
.profile-avatar { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; background: #fff; color: #1769e0; font-size: 1.6rem; font-weight: 850; }
.profile-name-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; max-width: 760px; margin: 12px 0; padding: 14px 16px; border: 1px solid rgba(255,255,255,.42); border-radius: 16px; background: rgba(255,255,255,.12); color: #fff; }
.profile-name-row span, .profile-name-row strong { display: block; }
.profile-name-row span { margin-bottom: 3px; font-size: .8rem; font-weight: 750; letter-spacing: .05em; text-transform: uppercase; color: rgba(255,255,255,.78); }
.profile-name-row strong { font-size: 1.08rem; }
.profile-name-row button, .profile-name-edit-form button { min-height: 42px; padding: 0 16px; border: 0; border-radius: 12px; background: #fff; color: #1769e0; font: inherit; font-weight: 800; cursor: pointer; }
.profile-name-edit-form { display: flex; align-items: end; flex-wrap: wrap; gap: 10px; max-width: 760px; margin: 12px 0; }
.profile-name-edit-form label { width: 100%; font-size: .9rem; font-weight: 750; }
.profile-name-edit-form input { flex: 1 1 200px; min-height: 44px; padding: 0 14px; border: 1px solid #cbdfff; border-radius: 12px; font: inherit; }
.device-save-note { max-width: 760px; margin: 8px 0 22px; color: rgba(255,255,255,0.82); }
.import-progress-button { margin: -10px 0 22px; border: 1px solid rgba(255,255,255,.72); border-radius: 12px; padding: 10px 14px; background: transparent; color: #fff; font: inherit; font-weight: 750; cursor: pointer; }
.profile-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; max-width: 760px; margin-bottom: 30px; }
.profile-course-card, .profile-stat { padding: 18px; border-radius: 18px; background: #fff; color: #1769e0; }
.profile-course-card { grid-column: span 2; display: flex; align-items: center; gap: 16px; }
.profile-course-card strong, .profile-stat strong { display: block; font-size: 1.55rem; }
.profile-course-card span, .profile-stat span { display: block; margin-top: 5px; font-size: 0.82rem; font-weight: 650; line-height: 1.35; }
.profile-ring { width: 64px; height: 64px; flex: 0 0 auto; }
.profile-ring::after { inset: 7px; }
.profile-ring span { margin: 0; font-size: 0.78rem; }
.record-heading { max-width: 760px; margin: 0 0 14px; font-size: 1.1rem; }
.profile-focus { max-width: 760px; margin: -12px 0 24px; padding: 14px 16px; border-radius: 14px; background: rgba(255,255,255,0.16); color: #fff; font-weight: 700; }

.practice-records {
  display: grid;
  gap: 14px;
  max-width: 760px;
  margin-right: auto;
}

.practice-record {
  width: 100%;
  padding: 20px 24px;
  border: 0;
  border-radius: 18px;
  background-color: white;
  color: #1769e0;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.practice-record:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 25px rgba(14, 42, 91, 0.18);
}

.practice-record h3,
.practice-record p {
  margin: 0;
}

.practice-record p {
  margin-top: 8px;
}

.empty-records {
  margin: 0;
  text-align: left;
  font-size: 1.1rem;
}

.bottom-nav {
  position: fixed;
  z-index: 8;
  left: 50%;
  bottom: 24px;
  width: min(520px, calc(100vw - 40px));
  padding: 10px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  transform: translateX(-50%);
  border-radius: 999px;
  background-color: white;
  box-shadow: 0 12px 35px rgba(14, 42, 91, 0.22);
}

.nav-tab {
  position: relative;
  padding: 20px 24px 12px;
  border: 0;
  border-radius: 999px;
  background-color: transparent;
  color: #6880aa;
  font: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
}

.nav-tab.active {
  color: #1769e0;
  background-color: #edf4ff;
}

.tab-indicator {
  position: absolute;
  top: 8px;
  left: 50%;
  width: 38px;
  height: 6px;
  transform: translateX(-50%);
  border-radius: 999px;
  background-color: transparent;
}

.nav-tab.active .tab-indicator {
  background-color: #1769e0;
}

.fraction-page h2,
.operation-page h2,
.practice-page h2 {
  margin: 0;
  color: #1769e0;
  font-size: clamp(2rem, 4vw, 3.5rem);
  text-align: center;
}

.fraction-page,
.operation-page,
.practice-page,
.easy-page,
.results-page {
  position: relative;
}

.operation-grid {
  height: auto;
  margin-top: 35px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.operation-button {
  position: relative;
  min-height: 220px;
  padding: 28px;
  display: grid;
  grid-template-columns: 58px 1fr;
  grid-template-rows: auto auto 1fr;
  column-gap: 20px;
  align-items: start;
  border: 1px solid #d7e6ff;
  border-radius: 24px;
  background: linear-gradient(145deg, #f7faff, #eaf3ff);
  color: #1769e0;
  font: inherit;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 14px 34px rgba(17, 72, 165, 0.09);
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.operation-button:hover { transform: translateY(-4px); border-color: #9fc5ff; box-shadow: 0 20px 42px rgba(17, 72, 165, 0.14); }
.operation-button:active { transform: scale(0.99); }
.operation-button strong { align-self: center; font-size: clamp(1.45rem, 2.8vw, 2rem); }
.operation-button small { grid-column: 2; margin-top: 12px; color: #54729f; font-size: 0.96rem; font-weight: 650; line-height: 1.5; }
.operation-number { position: absolute; top: 18px; right: 20px; color: #79a5e8; font-size: 0.78rem; font-weight: 850; letter-spacing: 0.08em; }
.operation-symbol { grid-row: 1 / span 3; display: grid; place-items: center; width: 58px; height: 58px; border-radius: 18px; background: #1769e0; color: #fff; font-size: 2rem; line-height: 1; }

.fraction-page-intro { width: min(760px, 100%); margin: 42px auto 24px; text-align: center; }
.fraction-page-intro .eyebrow { margin-bottom: 8px; }
.fraction-page-intro p:last-child { max-width: 580px; margin: 12px auto 0; color: #54729f; font-size: 1.05rem; line-height: 1.55; }

.operation-page-intro {
  width: min(860px, 100%);
  margin: 44px auto 28px;
  text-align: center;
}

.operation-page-intro h2 {
  margin: 8px 0 12px;
}

.operation-page-intro > p:last-child {
  margin: 0;
  color: #54729f;
  font-size: 1.05rem;
}

.skills-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  width: min(900px, 100%);
  margin: 0 auto 64px;
}

.skill-card {
  display: flex;
  flex-direction: column;
  position: relative;
  border: 1px solid #d9e6ff;
  min-height: 190px;
  padding: 28px;
  border-radius: 26px;
  background: linear-gradient(145deg, #ffffff, #f3f7ff);
  box-shadow: 0 12px 32px rgba(27, 77, 155, 0.08);
  text-align: left;
  font: inherit;
}

.skill-choice { cursor: pointer; transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease; }
.skill-choice:hover { transform: translateY(-3px); border-color: #8eb6ff; box-shadow: 0 18px 36px rgba(27, 77, 155, 0.14); }
.skill-choice:active { transform: scale(0.99); }

.skill-number {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 28px;
  border-radius: 99px;
  background: #e6efff;
  color: #2163d8;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.skill-card h3 {
  margin: 24px 0 9px;
  color: #2163d8;
  font-size: clamp(1.25rem, 2.5vw, 1.7rem);
}

.skill-card p {
  margin: 0;
  color: #54729f;
  line-height: 1.55;
}

.question-context {
  width: min(720px, 100%);
  margin: 34px auto -42px;
  padding: 13px 18px;
  border-radius: 15px;
  background: #edf4ff;
  color: #365f9f;
  font-size: 1rem;
  line-height: 1.5;
  text-align: center;
}

.past-paper-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #e8f0ff;
  color: #2163d8;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  vertical-align: middle;
}

.resource-link {
  display: inline-block;
  margin: 0.75rem 0 1rem;
  color: var(--blue-dark, #1f58c7);
  font-weight: 700;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.2em;
}

.mode-options {
  margin-top: 50px;
  display: flex;
  gap: 28px;
  justify-content: center;
  flex-wrap: wrap;
}

.mode-button {
  width: clamp(230px, 25vw, 350px);
  height: 105px;
  border: 0;
  border-radius: 22px;
  background-color: #1769e0;
  color: white;
  font: inherit;
  font-size: clamp(1.4rem, 3vw, 2.3rem);
  font-weight: 700;
  cursor: pointer;
}

.mode-button:active {
  transform: scale(0.98);
}

.mode-button,
.difficulty-button,
.settings-card button,
.results-actions button,
.save-progress-actions button {
  transition: transform 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
  box-shadow: 0 10px 24px rgba(23, 105, 224, 0.18);
}
.mode-button:hover,
.difficulty-button:hover,
.settings-card button:hover,
.results-actions button:hover,
.save-progress-actions button:hover {
  transform: translateY(-2px);
  box-shadow: 0 15px 30px rgba(23, 105, 224, 0.25);
}
.mode-button:focus-visible,
.difficulty-button:focus-visible,
.skill-choice:focus-visible,
.topic-button:focus-visible {
  outline: 4px solid rgba(37, 125, 236, 0.3);
  outline-offset: 3px;
}

.difficulty-options {
  margin-top: 42px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.difficulty-button {
  width: clamp(240px, 33.333vw, 480px);
  height: 88px;
  border: 0;
  border-radius: 22px;
  background-color: #1769e0;
  color: white;
  font: inherit;
  font-size: clamp(1.25rem, 2.4vw, 2rem);
  font-weight: 700;
  cursor: pointer;
}

.difficulty-button:active {
  transform: scale(0.98);
}

.topic-options {
  gap: 14px;
}

.topic-options .difficulty-button {
  height: 74px;
}

.settings-card {
  width: min(560px, 100%);
  margin: 38px auto;
  padding: 28px;
  display: grid;
  gap: 18px;
  border-radius: 24px;
  background: linear-gradient(145deg, #f5f9ff, #eaf3ff);
  border: 1px solid #d7e6ff;
  color: #1769e0;
  box-shadow: 0 16px 38px rgba(32, 89, 177, 0.1);
}

.settings-card label { display: grid; gap: 8px; font-weight: 800; }
.settings-card input { width: 100%; min-height: 52px; padding: 14px; border: 2px solid #b9d7ff; border-radius: 14px; background: #fff; font: inherit; color: #1769e0; }
.settings-card input:focus { outline: 0; border-color: #1769e0; box-shadow: 0 0 0 4px rgba(23, 105, 224, 0.12); }
.settings-card button { padding: 16px; border: 0; border-radius: 14px; background: #1769e0; color: white; font: inherit; font-weight: 800; cursor: pointer; }
.practice-timer { width: fit-content; margin: 10px auto 0; padding: 8px 14px; border-radius: 999px; background: #edf4ff; color: #1769e0; font-weight: 800; }

.results-page .results-chart { margin-top: 46px; background: linear-gradient(145deg, #fbfdff, #edf5ff); border-color: #cde0ff; }
.results-page .results-actions { margin-top: 28px; }
.results-page .quiz-review { border: 1px solid #ffd9dd; box-shadow: 0 12px 30px rgba(148, 59, 69, 0.08); }
.results-page .chart-row { min-height: 46px; }
.results-page .bar-track { box-shadow: inset 0 1px 2px rgba(29, 71, 132, 0.08); }

.practice-page > h2,
.setup-page > h2 {
  text-align: center;
}

.practice-topic-heading {
  margin: 0;
  color: #1769e0;
  font-size: clamp(1.5rem, 3vw, 2.3rem);
  text-align: center;
}

.progress-capsule {
  position: absolute;
  top: calc(11.5vh + 22px);
  left: 50%;
  width: min(70vw, 760px);
  padding: 18px 30px;
  transform: translateX(-50%);
  border: 2px solid #1769e0;
  border-radius: 999px;
  background-color: white;
}

.progress-track {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.progress-track::before {
  content: "";
  position: absolute;
  left: 9px;
  right: 9px;
  top: 50%;
  height: 2px;
  transform: translateY(-50%);
  background-color: #8e9fbd;
}

.progress-dot {
  position: relative;
  z-index: 1;
  width: 20px;
  height: 20px;
  border: 2px solid #1769e0;
  border-radius: 50%;
  background-color: white;
}

.progress-dot.active::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background-color: black;
}

.progress-dot.correct,
.progress-dot.wrong {
  display: grid;
  place-items: center;
  color: white;
  font-size: 13px;
  font-weight: 800;
}

.progress-dot.correct {
  border-color: #1f9d55;
  background-color: #1f9d55;
}

.progress-dot.wrong {
  border-color: #dc3545;
  background-color: #dc3545;
}

.question {
  position: absolute;
  top: 52%;
  left: 50%;
  display: flex;
  align-items: center;
  gap: 28px;
  transform: translate(-50%, -50%);
  color: #1769e0;
  font-size: clamp(3rem, 7vw, 6rem);
  font-weight: 700;
}

.fraction {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
  vertical-align: middle;
}

.fraction > span:first-child {
  padding: 0 12px 8px;
  border-bottom: 4px solid currentColor;
}

.fraction > span:last-child {
  padding-top: 8px;
}

.whole-number {
  display: inline-block;
  margin-right: 0.08em;
  vertical-align: middle;
  line-height: 1;
}

/* Shared interior-page layout */
.fraction-page,
.practice-page,
.easy-page,
.results-page {
  width: min(1120px, 100%);
  margin-inline: auto;
}

.fraction-page .operation-grid {
  width: min(920px, 100%);
  height: auto;
  min-height: 430px;
  margin: 38px auto 0;
}

.practice-page .difficulty-options,
.practice-page .mode-options {
  width: min(720px, 100%);
  margin: 38px auto;
}

#module-page .mode-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

#module-page .mode-button {
  position: relative;
  min-height: 178px;
  height: auto;
  padding: 26px 20px 22px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-end;
  border: 1px solid rgba(255, 255, 255, 0.32);
  text-align: left;
  overflow: hidden;
  isolation: isolate;
}

#module-page .mode-button::before {
  content: "";
  position: absolute;
  z-index: -1;
  width: 120px;
  height: 120px;
  top: -56px;
  right: -38px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 50%;
}

#module-page .mode-button strong {
  display: block;
  font-size: clamp(1.4rem, 2.7vw, 2rem);
  line-height: 1.1;
}

#module-page .mode-button small {
  display: block;
  min-height: 2.8em;
  margin-top: 10px;
  color: rgba(255, 255, 255, 0.84);
  font-size: 0.86rem;
  font-weight: 650;
  line-height: 1.4;
}

.mode-index {
  position: absolute;
  top: 18px;
  left: 20px;
  padding: 5px 8px;
  border: 1px solid rgba(255, 255, 255, 0.38);
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.88);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.08em;
}

#module-page .learning-mode-button { background: linear-gradient(135deg, #1554bc, #2b73df); }
#module-page .practice-mode-button { background: linear-gradient(135deg, #1769e0, #4388ed); }
#module-page .quiz-mode-button { background: linear-gradient(135deg, #1458a4, #1670c8); }

#module-page .mode-button:hover {
  transform: translateY(-4px);
}

.easy-page .practice-topic-heading {
  margin-bottom: 12px;
}

.easy-page .question {
  position: relative;
  top: auto;
  left: auto;
  transform: none;
  width: fit-content;
  min-width: min(620px, 100%);
  margin: 70px auto 0;
  padding: 32px 40px;
  justify-content: center;
  border-radius: 28px;
  background: #f5f9ff;
  box-shadow: 0 14px 35px rgba(17, 72, 165, 0.1);
}

.easy-page .question-context {
  width: min(720px, 100%);
  margin: 26px auto -40px;
  padding: 14px 18px;
  border-left: 4px solid #1769e0;
  border-radius: 0 16px 16px 0;
  background: #edf5ff;
  color: #315f9c;
  font-size: 1rem;
  font-weight: 650;
  line-height: 1.55;
}

.results-page .results-chart,
.results-page .results-actions,
.results-page .quiz-review {
  width: min(720px, 100%);
  margin-inline: auto;
}

.learning-page { padding-bottom: 90px; }
.learning-page .worked-steps > div { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.learning-page .worked-steps .fraction { flex: 0 0 auto; }

.answer-form {
  position: relative;
  right: auto;
  bottom: auto;
  width: min(720px, 100%);
  margin: 36px auto 0;
  padding: 14px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  border: 1px solid #dce9ff;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 14px 32px rgba(17, 72, 165, 0.08);
}

.answer-input-wrap {
  position: relative;
  width: min(260px, 100%);
}

.math-answer-editor {
  width: 100%;
  min-height: 50px;
  padding: 8px 52px 8px 16px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  border: 2px solid #1769e0;
  border-radius: 14px;
  color: #1769e0;
  font-size: 1.1rem;
  font-weight: 650;
  line-height: 1.2;
  outline: none;
  cursor: text;
}

.math-answer-editor:empty::before {
  content: attr(data-placeholder);
  color: #9aa8bd;
  font-weight: 500;
  pointer-events: none;
}

.math-answer-editor:focus {
  box-shadow: 0 0 0 4px rgba(23, 105, 224, 0.16);
}

.math-symbol-toggle {
  position: absolute;
  top: 50%;
  right: 7px;
  width: 36px;
  height: 36px;
  min-height: 0;
  padding: 0;
  display: grid;
  place-items: center;
  transform: translateY(-50%);
  border-radius: 11px;
  background: #edf4ff;
  color: #1769e0;
  font-size: 0;
  line-height: 1;
}

.math-symbol-toggle::before,
.math-symbol-toggle::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 15px;
  height: 2px;
  border-radius: 99px;
  background: currentColor;
  transform: translate(-50%, -50%);
}

.math-symbol-toggle::after { transform: translate(-50%, -50%) rotate(90deg); }
}

.math-symbol-toggle[aria-expanded="true"] { background: #1769e0; color: #fff; }

.math-symbol-panel {
  position: absolute;
  z-index: 15;
  right: 0;
  bottom: calc(100% + 10px);
  width: 252px;
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  border: 1px solid #cbdfff;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 18px 40px rgba(15, 55, 124, .22);
}

.math-symbol-panel.hidden { display: none; }

.math-symbol-panel button {
  min-height: 40px;
  padding: 0;
  border-radius: 10px;
  background: #edf4ff;
  color: #1769e0;
  font-size: 1.05rem;
  display: grid;
  place-items: center;
  line-height: 1;
}

.math-symbol-panel button:hover,
.math-symbol-panel button:focus-visible { background: #dbe9ff; }

/* Override the general answer-form button padding so all eight keys stay inside the tray. */
.answer-form .math-symbol-panel button {
  min-width: 0;
  min-height: 40px;
  padding: 0;
}

.button-fraction {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  min-width: 1.25em;
  line-height: .84;
  font-size: 1.05rem;
  font-weight: 800;
}

.button-fraction > span:first-child {
  width: 100%;
  padding: 0 2px 2px;
  border-bottom: 1.5px solid currentColor;
}

.button-fraction > span:last-child { padding-top: 2px; }

.button-root {
  display: inline-flex;
  align-items: flex-start;
  font-size: 1.35rem;
  font-weight: 800;
  line-height: .82;
}

.button-root > span {
  min-width: .6em;
  padding: 0 2px 2px 1px;
  border-top: 1.5px solid currentColor;
  font-size: .78rem;
  line-height: .7;
}

.math-fraction-editor {
  display: inline-flex;
  flex-direction: column;
  align-items: stretch;
  vertical-align: middle;
  min-width: 1.45em;
  line-height: 1;
}

.math-slot {
  width: max(1.4em, 2ch);
  min-width: 1.4em;
  height: 1.08em;
  padding: 0 2px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 700;
  line-height: 1;
  text-align: center;
  outline: none;
}

.math-fraction-editor .math-slot:first-child { border-bottom: 2px solid currentColor; }

.math-root-editor {
  display: inline-flex;
  align-items: flex-start;
  vertical-align: middle;
  color: inherit;
  font-size: 1.22em;
  line-height: 1;
}

.math-root-sign { transform: translateY(.08em); }

.math-root-editor .math-slot {
  width: .58em;
  min-width: 0;
  padding: 0 1px 2px 0;
  border-top: 2px solid currentColor;
  text-align: left;
}

/* The operator is optically centred on the fraction bar, rather than on the font baseline. */
.question .operator {
  display: inline-grid;
  place-items: center;
  height: 1em;
  line-height: 1;
  transform: translateY(-.08em);
}

.answer-form button {
  padding: 13px 22px;
  border: 0;
  border-radius: 14px;
  background-color: #1769e0;
  color: white;
  font: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
}

.easy-page .progress-capsule {
  box-shadow: 0 10px 25px rgba(17, 72, 165, 0.08);
}

.answer-form .next-button {
  border: 2px solid #1769e0;
  background-color: white;
  color: #1769e0;
}

.answer-form .next-button.hidden {
  display: none;
}

.answer-form .explanation-button {
  border: 2px solid #1769e0;
  background-color: #edf4ff;
  color: #1769e0;
}

.answer-form .explanation-button.hidden {
  display: none;
}

.explanation-modal {
  position: fixed;
  z-index: 30;
  inset: 0;
  padding: 24px;
  display: grid;
  place-items: center;
  background-color: rgba(9, 34, 78, 0.44);
}

.explanation-modal.hidden {
  display: none;
}

.stuck-check-modal {
  position: fixed;
  z-index: 34;
  inset: 0;
  padding: 24px;
  display: grid;
  place-items: center;
  background: rgba(9, 34, 78, .44);
}

.stuck-check-modal.hidden { display: none; }

.stuck-check-card {
  position: relative;
  width: min(580px, 100%);
  max-height: min(720px, calc(100dvh - 48px));
  overflow: auto;
  padding: 34px;
  border-radius: 24px;
  background: #fff;
  color: #173b7a;
  box-shadow: 0 24px 70px rgba(6, 29, 70, .32);
}

.stuck-check-card .eyebrow { color: #5f8edc; }
.stuck-check-card h2 { margin: 8px 0; color: #1769e0; font-size: clamp(1.65rem, 5vw, 2.25rem); }
.stuck-check-card > p:not(.eyebrow) { margin: 0; color: #61779d; line-height: 1.5; }
.close-stuck-check-button { position: absolute; top: 16px; right: 16px; width: 36px; height: 36px; border: 0; border-radius: 50%; background: #edf4ff; color: #1769e0; font-size: 1.7rem; line-height: 1; cursor: pointer; }
.stuck-check-options { display: grid; gap: 10px; margin: 22px 0 14px; }
.stuck-option { padding: 14px 16px; border: 1px solid #c8daf8; border-radius: 14px; background: #f8fbff; color: #174e9b; text-align: left; font: inherit; font-weight: 750; line-height: 1.4; cursor: pointer; }
.stuck-option:hover, .stuck-option:focus-visible { border-color: #1769e0; background: #edf4ff; }
.stuck-check-explanation-button { width: 100%; min-height: 44px; border: 0; border-radius: 12px; background: #1769e0; color: #fff; font: inherit; font-weight: 800; cursor: pointer; }

.save-progress-modal {
  position: fixed;
  z-index: 35;
  inset: 0;
  padding: 24px;
  display: grid;
  place-items: center;
  background-color: rgba(9, 34, 78, 0.44);
}

.save-progress-modal.hidden {
  display: none;
}

.save-progress-card {
  width: min(480px, 100%);
  padding: 34px;
  border-radius: 24px;
  background-color: white;
  color: #1769e0;
  text-align: center;
  box-shadow: 0 24px 70px rgba(6, 29, 70, 0.32);
}

.save-progress-card h2,
.save-progress-card p {
  margin: 0;
}

.save-progress-card h2 {
  font-size: clamp(1.6rem, 4vw, 2.2rem);
}

.save-progress-card p {
  margin-top: 12px;
  color: #24436f;
  line-height: 1.5;
}

.save-progress-actions {
  margin-top: 26px;
  display: flex;
  justify-content: center;
  gap: 14px;
}

.save-progress-actions button {
  min-width: 130px;
  padding: 14px 22px;
  border: 0;
  border-radius: 14px;
  background-color: #1769e0;
  color: white;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.save-progress-actions #quit-practice-button {
  border: 2px solid #1769e0;
  background-color: white;
  color: #1769e0;
}

.explanation-card {
  position: relative;
  width: min(1040px, 100%);
  max-height: min(740px, calc(100dvh - 48px));
  overflow-y: auto;
  padding: 38px;
  border-radius: 26px;
  background-color: white;
  box-shadow: 0 24px 70px rgba(6, 29, 70, 0.32);
}

.explanation-card h2 {
  margin: 0;
  color: #1769e0;
  font-size: clamp(1.8rem, 4vw, 2.7rem);
}

.close-explanation-button {
  position: absolute;
  top: 18px;
  right: 20px;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background-color: #edf4ff;
  color: #1769e0;
  font-size: 1.8rem;
  line-height: 1;
  cursor: pointer;
}

.explanation-summary {
  margin: 18px 0 14px;
  color: #1769e0;
  font-size: 1rem;
  font-weight: 700;
}

.explanation-disclaimer {
  margin: -2px 0 18px;
  padding: 11px 13px;
  border-left: 4px solid #e5a72a;
  border-radius: 8px;
  background: #fff8e8;
  color: #76520d;
  font-size: .9rem;
  font-weight: 650;
  line-height: 1.45;
}

.explanation-disclaimer.hidden { display: none; }

.explanation-steps {
  display: grid;
  gap: 12px;
}

.explanation-step {
  margin: 0;
  padding: 15px 18px;
  border-radius: 16px;
  background-color: #f2f7ff;
  color: #1769e0;
  font-size: clamp(1.05rem, 2vw, 1.3rem);
  font-weight: 700;
  line-height: 1.45;
}

.explanation-step.note {
  background-color: #fff5f5;
  color: #b4232f;
}

.explanation-step.final-answer {
  background-color: #eaf8ef;
  color: #177244;
}

.math-line {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  font-size: clamp(1.45rem, 4vw, 2.25rem);
  line-height: 1.1;
  text-align: center;
}

.math-fraction {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  min-width: 1.25em;
  vertical-align: middle;
  line-height: 1;
}

.math-fraction .top {
  padding: 0 0.15em 0.12em;
  border-bottom: 3px solid currentColor;
  white-space: nowrap;
}

.math-fraction .bottom {
  padding: 0.12em 0.15em 0;
  white-space: nowrap;
}

.math-hint {
  margin: 0;
  color: #1769e0;
  font-size: 0.98rem;
  font-weight: 700;
  text-align: center;
}

.math-cross {
  color: #b4232f;
  font-size: 1.35rem;
}

.math-red {
  color: #b4232f;
}

.math-green {
  color: #177244;
}

.math-tick {
  color: #177244;
  font-size: 1.35rem;
}

.explanation-comparison {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.process-panel {
  min-width: 0;
  padding: 18px;
  border-radius: 18px;
}

.process-panel h3 {
  margin: 0 0 14px;
  font-size: 1.1rem;
  text-align: center;
}

.your-process {
  background-color: #fff5f5;
}

.your-process h3 {
  color: #b4232f;
}

.correct-process {
  background-color: #eaf8ef;
}

.correct-process h3 {
  color: #177244;
}

.process-panel .explanation-step {
  padding: 12px 10px;
  background-color: rgba(255, 255, 255, 0.72);
}

.process-panel .math-line {
  gap: 7px;
  font-size: clamp(1.1rem, 2.8vw, 1.7rem);
}

.common-denominator-note {
  margin: 14px 0 8px;
  color: #177244;
  font-size: 0.92rem;
  line-height: 1.4;
}

.process-note {
  color: #b4232f;
}

.learner-confirmed-note {
  margin: 0 0 14px;
  padding: 12px 14px;
  border-left: 4px solid #1769e0;
  border-radius: 10px;
  background: #edf4ff;
  color: #174e9b;
  font-size: .92rem;
  font-weight: 700;
  line-height: 1.45;
}

.mistakes-heading {
  margin: 12px 0 4px;
  color: #b4232f;
  font-size: 1rem;
  font-weight: 800;
}

.mistakes-list {
  margin: 0 0 12px;
  padding-left: 1.25rem;
  color: #8e2631;
  font-size: 0.92rem;
  line-height: 1.45;
}

.process-panel .conversion-line {
  margin-bottom: 10px;
}

.feedback-card {
  position: absolute;
  z-index: 5;
  top: 52%;
  left: 50%;
  width: min(60vw, 760px);
  min-height: 300px;
  padding: 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  transform: translate(-50%, -50%);
  border: 3px solid #1769e0;
  border-radius: 24px;
  background-color: white;
  box-shadow: 0 18px 45px rgba(25, 48, 89, 0.2);
  text-align: center;
}

.feedback-card.show {
  animation: feedback-pop 1200ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.feedback-card.hidden {
  display: none;
}

.feedback-card.test-feedback {
  position: static;
  transform: none;
  width: min(720px, 100%);
  min-height: 0;
  box-sizing: border-box;
  margin: 24px auto;
  padding: 24px;
  gap: 18px;
  box-shadow: none;
}
.feedback-card.test-feedback p { font-size: 1.125rem; line-height: 1.6; }
.test-feedback .feedback-icon { display: none; }
#test-next-button { min-height: 48px; }
.question-position { text-align: center; font-size: 1rem; font-weight: 600; color: #465a73; }

.feedback-card p {
  margin: 0;
  color: #1769e0;
  font-size: clamp(1.4rem, 3vw, 2.4rem);
  font-weight: 700;
}

.feedback-icon {
  font-size: clamp(4rem, 9vw, 7rem);
  font-weight: 800;
  line-height: 1;
}

.feedback-icon.correct {
  color: #1f9d55;
}

.feedback-icon.wrong {
  color: #dc3545;
}

.results-page h2 {
  width: min(900px, 90%);
  margin: 0 auto;
  color: #1769e0;
  font-size: clamp(2rem, 4vw, 3.5rem);
  text-align: center;
}

.results-chart {
  width: min(70vw, 820px);
  margin: 90px auto 0;
  padding: 34px;
  display: grid;
  gap: 28px;
  border: 2px solid #1769e0;
  border-radius: 24px;
  background-color: #f7faff;
  box-shadow: 0 16px 36px rgba(32, 89, 177, 0.1);
}

.chart-row {
  display: grid;
  grid-template-columns: 85px 1fr 32px;
  align-items: center;
  gap: 16px;
  color: #1769e0;
}

.chart-label {
  font-weight: 700;
}

.bar-track {
  height: 34px;
  overflow: hidden;
  border-radius: 999px;
  background-color: #dfe9f8;
}

.bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  transition: width 700ms ease;
}

.correct-bar {
  background-color: #1f9d55;
}

.wrong-bar {
  background-color: #dc3545;
}

.results-actions {
  margin-top: 48px;
  display: flex;
  justify-content: center;
  gap: 20px;
}

.results-actions button {
  min-width: 150px;
  padding: 14px 24px;
  border: 0;
  border-radius: 999px;
  background-color: #1769e0;
  color: white;
  font: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
}

.results-actions button:disabled {
  opacity: 0.6;
  cursor: default;
}

@keyframes feedback-pop {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.72);
  }

  65% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.04);
  }

  100% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

.back-button {
  position: fixed;
  top: calc(max(11.5vh, 72px) + 12px);
  right: max(16px, env(safe-area-inset-right));
  z-index: 20;
  min-height: 44px;
  padding: 10px 22px;
  border: 0;
  border-radius: 14px;
  background-color: #1769e0;
  color: white;
  font: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
}

.back-button:active {
  transform: scale(0.97);
}

.hidden {
  display: none !important;
}

.course-heading { display: flex; align-items: center; justify-content: center; gap: 18px; }
.course-heading h2 { margin: 0; }
.course-ring { position: relative; display: grid; place-items: center; width: 78px; height: 78px; border-radius: 50%; background: conic-gradient(#1769e0 calc(var(--progress) * 1%), #dbe9ff 0); color: #1769e0; font-weight: 850; }
.course-ring::after { content: ""; position: absolute; inset: 9px; border-radius: 50%; background: #fff; }
.course-ring span { position: relative; z-index: 1; font-size: 0.95rem; }
.module-intro { margin: 20px auto 28px; text-align: center; color: #54729f; font-size: 1.05rem; }
.quiz-mode-button small { display: block; margin-top: 8px; font-size: 0.78rem; font-weight: 650; opacity: 0.8; }
.topic-choice { position: relative; }
.module-complete { border-color: #31865a !important; box-shadow: inset 0 0 0 2px #31865a; }
.module-tick { position: absolute; right: 16px; top: 50%; display: grid; place-items: center; width: 28px; height: 28px; transform: translateY(-50%); border-radius: 50%; background: #31865a; color: #fff; font-size: 1rem; }

.learning-page {
  max-width: 900px;
  margin: 0 auto;
  color: #1769e0;
}

.learning-intro {
  margin: 14px 0 28px;
  max-width: 620px;
}

.learning-intro h2 {
  margin: 6px 0 10px;
  font-size: clamp(2.2rem, 5vw, 3.7rem);
  line-height: 1.05;
}

.learning-intro p:last-child {
  margin: 0;
  font-size: 1.1rem;
}

.lesson-card,
.lesson-checklist {
  margin: 18px 0;
  padding: 24px;
  border: 1px solid #d9e8ff;
  border-radius: 24px;
  background: #f5f9ff;
  box-shadow: 0 12px 30px rgba(17, 72, 165, 0.08);
}

.lesson-card h3,
.lesson-checklist h3 {
  margin: 0 0 10px;
  font-size: 1.35rem;
}

.lesson-card p { line-height: 1.65; }
.lesson-number {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  margin: 0 0 12px;
  border-radius: 50%;
  background: #1769e0;
  color: #fff;
  font-weight: 800;
}

.lesson-equation,
.worked-steps {
  margin-top: 18px;
  padding: 18px;
  border-radius: 18px;
  background: #fff;
  font-size: 1.5rem;
  font-weight: 800;
}

.worked-steps { display: grid; gap: 14px; }
.learning-page .worked-steps {
  padding: clamp(18px, 3vw, 28px);
  background: linear-gradient(135deg, #ffffff, #f9fbff);
  border: 1px solid #e2edff;
}
.learning-page .math-step {
  min-height: 64px;
  justify-content: flex-start;
  color: #1769e0;
  font-size: clamp(1.25rem, 2.8vw, 1.85rem);
  line-height: 1.45;
}
.learning-page .final-math-step { color: #238250; }
.mixed-fraction { display: inline-flex; align-items: center; gap: 0.15em; }
.mixed-fraction > span:first-child { line-height: 1; }
.learning-page .lesson-card {
  background: linear-gradient(145deg, #f5f9ff, #edf4ff);
  border-color: #d8e7ff;
  box-shadow: 0 12px 30px rgba(37, 87, 167, 0.06);
}
.learning-page .lesson-card h3 { margin-bottom: 10px; }
.learning-page .lesson-card p { max-width: 850px; }
.compact-steps { font-size: 1.25rem; }
.answer-fraction { color: #238250; }
.lesson-note {
  margin-left: 8px;
  color: #54729f;
  font-size: 0.92rem;
  font-weight: 650;
}
.lesson-warning { color: #a93e47; font-weight: 650; }
.wrong-text { text-decoration: line-through; }
.factor-cancel {
  position: relative;
  display: inline-block;
  min-width: 1.1em;
  color: #b5424d;
}
.factor-cancel s {
  text-decoration-thickness: 3px;
  text-decoration-color: #d34755;
}
.factor-cancel b {
  position: absolute;
  left: 0.76em;
  top: -0.68em;
  color: #238250;
  font-size: 0.72em;
  line-height: 1;
}
.learning-rule {
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: 14px;
  background: #e8f2ff;
  color: #315f9c;
  font-size: 1rem;
  line-height: 1.55;
}
.lesson-checklist { margin-bottom: 40px; }
.lesson-checklist ol { padding-left: 24px; line-height: 1.8; font-weight: 650; }
.lesson-checklist .topic-button { margin-top: 10px; }

.quiz-review { width: min(720px, 100%); margin: 22px auto; padding: 22px; border-radius: 20px; background: #fff5f5; color: #943b45; }
.quiz-review h3 { margin: 0 0 8px; font-size: 1.25rem; }
.quiz-review p { margin: 8px 0; font-weight: 650; }

.lcm-guide { margin-top: 22px; padding: 20px; border-radius: 20px; background: #eaf3ff; }
.lcm-guide h4 { margin: 0 0 8px; font-size: 1.1rem; }
.factor-trees { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin: 16px 0; }
.factor-tree { padding: 16px 10px; border-radius: 16px; background: #fff; text-align: center; font-weight: 750; }
.factor-tree-diagram { display: block; width: min(240px, 100%); height: auto; margin: 0 auto; }
.factor-tree-diagram path { fill: none; stroke: #7ea8e8; stroke-width: 3; stroke-linecap: round; }
.factor-tree-diagram text { fill: #1769e0; font-family: inherit; font-size: 20px; font-weight: 800; text-anchor: middle; }
.factor-tree-diagram .tree-root-node { fill: #1769e0; }
.factor-tree-diagram .tree-root-node + text { fill: #fff; }
.factor-tree-diagram .tree-mid-node { fill: #dcecff; }
.factor-tree-diagram .tree-prime-node { fill: #dff4e7; }
.factor-tree p { margin: 12px 0 0; font-size: 0.88rem; }
.lcm-answer { color: #267a4c; }
.shortcut-toggle { margin-top: 6px; padding: 6px 0; border: 0; background: transparent; color: #1769e0; font: inherit; font-size: 0.9rem; font-weight: 750; text-decoration: underline; cursor: pointer; }
.short-division-guide { margin-top: 14px; padding: 16px; border-radius: 16px; background: #fff; }
.division-table { width: min(330px, 100%); margin: 14px 0; border: 1px solid #bcd6ff; border-radius: 10px; overflow: hidden; }
.division-table div { display: grid; grid-template-columns: 48px 1fr 1fr; text-align: center; border-bottom: 1px solid #dbe9ff; }
.division-table div:last-child { border-bottom: 0; }
.division-table strong { padding: 8px; border-right: 2px solid #1769e0; color: #267a4c; }
.division-table span { padding: 8px; }

@keyframes slide-down {
  from {
    transform: translateY(-100%);
  }

  to {
    transform: translateY(0);
  }
}

@keyframes page-enter {
  /* A transformed page would make fixed Back buttons scroll with it. */
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes panel-enter {
  from { opacity: 0; transform: translateX(12px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes symbol-float {
  from { transform: translate3d(0, -5px, 0) rotate(-4deg); }
  to { transform: translate3d(10px, 9px, 0) rotate(5deg); }
}

@keyframes focus-card-drop {
  0% { opacity: 0; transform: translateY(-130px) rotate(-8deg) scale(0.94); }
  68% { opacity: 1; transform: translateY(8px) rotate(2.8deg) scale(1.01); }
  84% { transform: translateY(-3px) rotate(1.2deg) scale(1); }
  100% { opacity: 1; transform: translateY(0) rotate(1.8deg) scale(1); }
}

@keyframes card-symbol-drop {
  0% { opacity: 0; transform: translateY(-70px) rotate(-18deg) scale(0.72); }
  72% { opacity: 0.13; transform: translateY(calc(var(--fall) + 7px)) rotate(5deg) scale(1.04); }
  100% { opacity: 0.09; transform: translateY(var(--fall)) rotate(0) scale(1); }
}

.mixed-operation-button {
  grid-column: 1 / -1;
  min-height: 170px;
  background: linear-gradient(135deg, #123f9e, #1769e0 58%, #4196ff);
}

.module-mastery-panel {
  width: min(760px, 92vw);
  margin: 22px auto 24px;
  padding: 18px 22px;
  border: 1px solid #cfe0ff;
  border-radius: 20px;
  background: #f5f8ff;
  color: #17417f;
}

.module-mastery-panel > div {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.module-mastery-panel p {
  margin: 9px 0 0;
  color: #57719e;
  line-height: 1.5;
}

.mastery-ladder {
  display: grid !important;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px !important;
  margin-top: 15px;
}

.mastery-ladder span {
  padding: 9px 8px;
  border-radius: 10px;
  text-align: center;
  background: #e6ecf6;
  color: #71809a;
  font-size: 0.78rem;
  font-weight: 800;
}

.mastery-ladder span.achieved {
  background: #dff6e8;
  color: #176037;
}

.question-level {
  width: fit-content;
  margin: 8px auto 0;
  padding: 7px 12px;
  border-radius: 999px;
  background: #eef4ff;
  color: #45638f;
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: capitalize;
}

.mastery-badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.status-new { color: #526581; background: #e7edf6; }
.status-completed { color: #805500; background: #fff0bd; }
.status-secure { color: #0f5f7d; background: #d9f4ff; }
.status-mastered { color: #176037; background: #dff6e8; }

.mastery-mode-button {
  border: 2px solid #1c8b50 !important;
  background: linear-gradient(145deg, #1c8b50, #126c3c) !important;
}

.mode-button[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none !important;
}

.skill-status {
  position: absolute;
  top: 17px;
  right: 17px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 30px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 850;
  letter-spacing: 0.035em;
  text-transform: uppercase;
}

.skill-status::before { font-size: .95em; line-height: 1; }

.skill-card.status-new-card .skill-status { color: #526581; background: #e7edf6; }
.skill-card.status-new-card .skill-status::before { content: "○"; }

.skill-card.status-started-card { border-color: #7ca8ef; background: linear-gradient(145deg, #ffffff, #eff6ff); }
.skill-card.status-started-card .skill-status { color: #185fc9; background: #dceaff; }
.skill-card.status-started-card .skill-status::before { content: "◔"; }

.skill-card.status-completed-card { border-color: #edc75b; background: linear-gradient(145deg, #fffdf5, #fff6d6); }
.skill-card.status-completed-card .skill-status { color: #805500; background: #fff0bd; }
.skill-card.status-completed-card .skill-status::before { content: "✓"; }

.skill-card.status-secure-card { border-color: #55b7d8; background: linear-gradient(145deg, #f8feff, #e2f8ff); box-shadow: 0 15px 36px rgba(25, 118, 167, .15); }
.skill-card.status-secure-card .skill-status { color: #075d7d; background: #cdf2ff; }
.skill-card.status-secure-card .skill-status::before { content: "◆"; }

.skill-card.status-mastered-card { border-color: #52c47b; background: linear-gradient(145deg, #fbfffc, #e2f8e9); box-shadow: 0 0 0 3px #52c47b, 0 18px 40px rgba(18, 100, 58, .16); }
.skill-card.status-mastered-card .skill-status { color: #176037; background: #dff6e8; }
.skill-card.status-mastered-card .skill-status::before { content: "★"; }

#quiz-review-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 20px; }
.review-question-card {
  display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center;
  width: 100%; padding: 18px; border: 1px solid #dfe7f3; border-radius: 16px;
  background: #fff; color: #273e60; font: inherit; text-align: left; cursor: pointer;
  box-shadow: 0 3px 10px rgba(32, 67, 118, .04); transition: border-color .15s, box-shadow .15s;
}
.review-question-card:hover { border-color: #1769e0; box-shadow: 0 5px 18px rgba(23,105,224,.12); }
.review-question-card:focus-visible { outline: 3px solid #1769e0; outline-offset: 3px; }
.review-question-status { padding: 4px 9px; border-radius: 7px; font-size: .75rem; font-weight: 750; background: #eef2f7; color: #607089; }
.review-question-card.wrong .review-question-status { background: #fff0f0; color: #a53141; }
.review-question-card.correct .review-question-status { background: #eaf7ee; color: #267443; }
.review-question-preview { grid-column: 1 / -1; font-size: .85rem; line-height: 1.5; font-weight: 400; color: #607089; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.review-question-action { grid-column: 1 / -1; color: #1769e0; font-size: .8rem; font-weight: 750; }
.explanation-question { padding: 14px 16px; background: #f0f5ff; border-radius: 12px; line-height: 1.6; color: #365379; }
#quiz-review-list > .quiz-review-item { grid-column: 1 / -1; }
@media (max-width: 560px) { #quiz-review-list { grid-template-columns: 1fr; } }
.quiz-review-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: start;
  padding: 14px 16px;
  margin-top: 10px;
  border-radius: 14px;
  background: #fff5f5;
  color: #8a2f37;
}

.quiz-review-count {
  min-width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #ba3341;
  color: white;
  font-weight: 800;
}

.review-method-button {
  margin-top: 16px;
  border: 0;
  border-radius: 12px;
  padding: 13px 18px;
  background: #1769e0;
  color: white;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.auth-modal {
  position: fixed;
  z-index: 80;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(13, 36, 83, .52);
  backdrop-filter: blur(8px);
}

.auth-modal.hidden { display: none; }

.auth-card {
  position: relative;
  width: min(480px, 100%);
  max-height: min(720px, calc(100dvh - 48px));
  overflow: auto;
  padding: 32px;
  border: 1px solid #d9e6ff;
  border-radius: 24px;
  background: #fff;
  color: #173b7a;
  box-shadow: 0 30px 80px rgba(3, 19, 56, .32);
}

.auth-card .eyebrow { color: #5f8edc; }
.auth-card h2 { margin: 10px 0 8px; color: #1769e0; font-size: clamp(2rem, 6vw, 2.8rem); }
.auth-card > p { margin: 0; color: #61779d; line-height: 1.5; }
.auth-close-button { position: absolute; top: 16px; right: 16px; width: 36px; height: 36px; border: 0; border-radius: 50%; background: #edf4ff; color: #1769e0; font-size: 1.7rem; line-height: 1; cursor: pointer; }
.auth-form { display: grid; gap: 8px; margin-top: 22px; }
.auth-form label { font-size: .9rem; font-weight: 800; color: #315789; }
.auth-form input { width: 100%; min-height: 46px; border: 1px solid #c8daf8; border-radius: 12px; padding: 0 13px; color: #183a75; font: inherit; }
.auth-form input:focus { outline: 3px solid rgba(42,105,218,.18); border-color: #1769e0; }
.auth-message { min-height: 1.35em; margin: 4px 0 0; color: #a83b3b; font-size: .9rem; font-weight: 650; }
.auth-message.success { color: #28784d; }
.auth-submit-button, .signed-in-actions button { min-height: 46px; margin-top: 6px; border: 0; border-radius: 12px; background: #1769e0; color: #fff; font: inherit; font-weight: 800; cursor: pointer; }
.auth-submit-button:disabled { opacity: .55; cursor: wait; }
.auth-links { display: flex; justify-content: space-between; gap: 14px; margin-top: 16px; }
.auth-links button { border: 0; padding: 0; background: transparent; color: #1769e0; font: inherit; font-size: .9rem; font-weight: 750; cursor: pointer; text-decoration: underline; }
.signed-in-actions { margin-top: 18px; padding-top: 18px; border-top: 1px solid #dbe7fa; }.signed-in-actions.hidden { display: none; }.signed-in-actions p { margin-bottom: 12px; font-size: .9rem; }

.status-stat strong { color: #1769e0; }

.mastery-explainer {
  width: min(900px, 92vw);
  margin: 18px auto 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.mastery-explainer div {
  padding: 14px;
  border-radius: 14px;
  background: #f5f8ff;
  border: 1px solid #d6e4ff;
  color: #45638f;
  font-size: 0.88rem;
}

@media (prefers-reduced-motion: reduce) {
  .top-bar,
  .page:not(.hidden),
  .main-panel:not(.hidden),
  .math-atmosphere span,
  .hero-maths-card,
  .card-math-rain span {
    transform: none;
    animation: none;
  }

  .card-math-rain { display: none; }
}

@media (max-width: 850px) {
  .page {
    padding: calc(11.5vh + 22px) 20px 128px;
  }

  .top-bar {
    padding: 0 20px;
    gap: 10px;
  }

  .top-bar h1 {
    font-size: 1.25rem;
  }

  .top-bar p {
    max-width: 145px;
    line-height: 1.2;
  }

  .account-button { padding: 8px 11px; font-size: .82rem; }

  .home-hero {
    min-height: auto;
    grid-template-columns: 1fr;
    gap: 30px;
    padding-top: 18px;
  }

  .hero-copy h2 {
    font-size: clamp(2.5rem, 12vw, 3.45rem);
  }

  .hero-maths-card {
    transform: none;
  }

  .topic-preview-card {
    align-items: flex-start;
    padding: 18px;
  }

  .topic-status {
    display: none;
  }

  .topic-button {
    width: 100%;
  }

  .explanation-comparison {
    grid-template-columns: 1fr;
  }

  .operation-grid {
    gap: 12px;
  }

  .progress-capsule {
    width: calc(100vw - 32px);
    padding-inline: 18px;
  }

  .progress-dot {
    width: 16px;
    height: 16px;
  }

  .answer-form {
    right: auto;
    bottom: auto;
  }

  .explanation-card {
    padding: 30px 22px;
  }

  .feedback-card {
    width: calc(100vw - 40px);
  }

  .profile-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .profile-course-card { grid-column: span 2; }

  #module-page .mode-options { grid-template-columns: 1fr; }
  #module-page .mode-button { min-height: 150px; }
  .fraction-page .operation-grid { min-height: 0; grid-template-columns: 1fr; grid-template-rows: none; }
  .operation-button { min-height: 150px; }
  .mixed-operation-button { grid-column: auto; }
  .mastery-explainer { grid-template-columns: 1fr; }
  .auth-card { padding: 28px 20px; border-radius: 20px; }
  .easy-page .question { min-width: 0; width: 100%; margin-top: 42px; padding: 28px 20px; font-size: clamp(2rem, 9vw, 3.5rem); }
  .skills-grid { grid-template-columns: 1fr; }
  .skill-card { min-height: 150px; padding: 24px; }
}

/* Topic selection and upcoming percentage training. */
.topic-picker-link { display: inline-flex; align-items: center; gap: 24px; text-decoration: none; }
#topic-selection { scroll-margin-top: 24px; }
.topic-selection-grid, .percentage-skills-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.topic-preview-card.topic-entry { display: flex; flex-direction: column; align-items: flex-start; gap: 20px; height: 100%; box-sizing: border-box; }
.topic-entry h3 { margin: 14px 0 8px; }
.topic-entry .topic-button { margin-top: auto; width: 100%; }
.percentage-entry .topic-symbol { background: #e4f1ff; color: #245ea6; }
.percentage-notice { padding: 22px 26px; margin: 24px 0; border: 1px solid #c5d9ee; border-radius: 18px; background: #edf5ff; color: #22456c; }
.percentage-notice p { margin: 8px 0 0; line-height: 1.6; }
.percentage-skill { padding: 26px; border: 1px solid #dce3eb; border-radius: 20px; background: #fff; }
.percentage-skill h3 { font-size: 20px; margin: 14px 0 10px; }
.percentage-skill p { line-height: 1.65; margin: 0 0 20px; color: #526174; }
.topic-entry button:focus-visible, .topic-picker-link:focus-visible { outline: 3px solid #245ea6; outline-offset: 5px; }
@media (max-width: 680px) {
  .topic-selection-grid, .percentage-skills-grid { grid-template-columns: 1fr; }
}
.topic-entry .topic-button { min-width: 0; }
.topic-entry .topic-status { display: inline-block; white-space: normal; }
.percentage-skill .section-label { color: #426590; }
.percentage-skill .topic-status { display: inline-block; background: #edf2f8; color: #426080; }

/* The fraction overview stays compact; each category opens five skill cards. */
.fraction-page .category-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: auto; min-height: 0; }
.category-choice { min-height: 220px; height: auto; }
.category-choice small { max-width: 34ch; }
.category-count, .category-progress { font-size: 0.875rem; line-height: 1.5; color: #465a73; }
.category-progress { margin-top: 8px; }
.tier-badge { display: inline-block; width: fit-content; margin: 8px 0; padding: 4px 10px; border-radius: 999px; font-size: 0.875rem; font-weight: 600; line-height: 1.4; }
.tier-foundation { color: #205c42; background: #e8f5ed; }
.tier-higher { color: #513c8a; background: #eee9fa; }
.skill-title .tier-badge { vertical-align: middle; margin: 0 0 0 4px; white-space: nowrap; }
.exam-tier-picker { width: min(920px, 100%); margin: 28px auto 0; padding: 22px; box-sizing: border-box; border-radius: 20px; background: #fff; border: 1px solid #dce3eb; text-align: left; }
.exam-tier-picker h3 { margin: 0 0 14px; font-size: 1.2rem; }
.exam-tier-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.exam-tier-button { padding: 16px; border: 2px solid #c9d4e0; border-radius: 14px; background: #fff; color: #243c57; font: inherit; font-weight: 700; text-align: left; cursor: pointer; }
.exam-tier-button span { display: block; margin-top: 6px; font-size: 0.875rem; font-weight: 400; line-height: 1.5; }
.exam-tier-button[aria-pressed="true"] { border-color: #245ea6; background: #edf5ff; }
.exam-tier-button:focus-visible { outline: 3px solid #245ea6; outline-offset: 3px; }
#exam-tier-summary { margin: 14px 0 0; color: #465a73; font-size: 0.9375rem; line-height: 1.6; }
@media (max-width: 520px) { .exam-tier-options { grid-template-columns: 1fr; } }

/* Question, entry and acknowledgement occupy separate rows: no overlap. */
.easy-page .question-context {
  box-sizing: border-box;
  margin: 28px auto 0;
  padding: 26px 28px;
  border: 1px solid #dce5ef;
  border-radius: 20px;
  background: #f5f8fc;
  color: #233d5a;
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1.75;
  text-align: left;
}

#module-page .mastery-mode-button.mastery-locked {
  background: linear-gradient(145deg, #52667e, #3d5069) !important;
  border-color: #71849b !important;
  opacity: 1;
}
#module-review-state { font-size: .85rem; font-weight: 750; }
.easy-page .question { box-sizing: border-box; margin-top: 24px; box-shadow: none; }
.easy-page .answer-form {
  box-sizing: border-box;
  margin-top: 18px;
  padding: 24px;
  justify-content: flex-start;
  align-items: center;
  gap: 14px;
  border: 1px solid #dce5ef;
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 6px 20px rgba(24, 48, 78, .04);
}
.answer-field-label { flex-basis: 100%; color: #52657b; font-size: .875rem; font-weight: 600; text-align: left; }
.easy-page .answer-input-wrap { flex: 1 1 240px; min-width: 0; width: auto; }
.easy-page .math-answer-editor { box-sizing: border-box; min-height: 56px; border: 1px solid #a9bdd5; border-radius: 12px; color: #203d61; }
.easy-page .math-answer-editor:focus-within { border-color: #1769e0; box-shadow: 0 0 0 3px #e5efff; }
.easy-page #submit-button { min-height: 56px; padding: 14px 28px; border-radius: 12px; }
.recorded-title { display: none; }
.test-continuation { width: min(720px, 100%); margin: 12px auto 0; text-align: right; }
.test-continuation:has(.hidden) { display: none; }
.save-progress-actions button.hidden { display: none; }
.easy-page .feedback-card.test-feedback {
  position: static;
  width: min(720px, 100%);
  margin: 18px auto 0;
  padding: 24px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 22px;
  border: 1px solid #dce5ef;
  border-radius: 20px;
  background: #fff;
  text-align: left;
  box-shadow: 0 6px 20px rgba(24, 48, 78, .04);
}
.test-feedback .recorded-title { display: block; margin-bottom: 6px; font-size: 1.0625rem; font-weight: 700; color: #233d5a; }
.easy-page .test-feedback p { color: #61738a; font-size: .9375rem; font-weight: 400; line-height: 1.6; }
.easy-page #test-next-button { width: auto; min-width: 176px; min-height: 52px; margin: 0; padding: 14px 22px; border: 0; border-radius: 12px; background: #1769e0; color: #fff; font: inherit; font-weight: 700; box-shadow: none; }
.easy-page #test-next-button:hover { background: #1155bb; transform: none; }
.easy-page #test-next-button:focus-visible { outline: 3px solid #9fc4fa; outline-offset: 3px; }
.easy-page .feedback-card.test-feedback.hidden { display: none; }
@media (max-width: 560px) {
  .easy-page .question-context { padding: 20px; font-size: 1rem; }
  .easy-page .answer-form, .easy-page .feedback-card.test-feedback { padding: 20px; }
  .easy-page .feedback-card.test-feedback { grid-template-columns: 1fr; gap: 16px; }
  .easy-page #test-next-button, .easy-page #submit-button { width: 100%; }
}
.category-choice:focus-visible, .skill-choice:focus-visible { outline: 3px solid #245ea6; outline-offset: 4px; }
.process-panel p { overflow-wrap: anywhere; line-height: 1.7; }
@media (max-width: 680px) {
  .fraction-page .category-grid { grid-template-columns: 1fr; }
  .category-choice { min-height: 180px; }
}
