/* ==========================================================================
   Math games pages (/math-games/…): the topic pages around the playable stage.
   Builds on styles.css (tokens, header, footer, FAQ accordion, store badges) and
   blog.css (breadcrumbs, sources block). The stage itself is styled by
   /games/bundle/embed.css, built from games/src/game.css.
   ========================================================================== */

.mg-page {
  padding-bottom: 24px;
}

/* ── Hero: H1, answer-first intro, quick facts ───────────────────────── */
.mg-hero {
  padding-top: 22px;
}

.mg-hero h1 {
  font-size: 44px;
  font-weight: 900;
  line-height: 1.15;
  color: var(--deep-blue);
  margin-bottom: 14px;
}

.mg-lead {
  max-width: 860px;
  font-size: 19px;
  line-height: 1.6;
  margin-bottom: 18px;
}


.mg-facts {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mg-facts li {
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--footer-bg);
  color: var(--deep-blue);
  font-size: 14.5px;
  font-weight: 600;
}


/* ── Play ─────────────────────────────────────────────────────────────── */
.mg-play {
  margin-top: 30px;
}

.mg-play-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin-bottom: 14px;
}

.mg-play-head h2 {
  text-wrap: balance;
  font-size: 28px;
  font-weight: 800;
  color: var(--deep-blue);
  scroll-margin-top: 100px;
}

.mg-play-head p {
  font-size: 15.5px;
}


.mg-noscript {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 10px;
  text-align: center;
  font-size: 14px;
  color: var(--deep-blue);
}

/* ── Content sections ─────────────────────────────────────────────────── */
.mg-section {
  margin-top: 72px;
}

.mg-section h2,
.mg-app h2,
.mg-faq h2 {
  font-size: 30px;
  font-weight: 800;
  line-height: 1.25;
  color: var(--deep-blue);
  margin-bottom: 18px;
  scroll-margin-top: 100px;
}

.mg-section h3 {
  font-size: 20px;
  font-weight: 700;
  color: var(--deep-blue);
  margin: 26px 0 8px;
}

.mg-prose p {
  font-size: 17px;
  line-height: 1.75;
  margin-bottom: 16px;
}

.mg-prose > p,
.mg-prose > ul {
  max-width: 780px;
}

.mg-prose ul {
  margin: 0 0 16px 22px;
  font-size: 17px;
  line-height: 1.65;
}

.mg-prose li {
  margin-bottom: 8px;
}

.mg-prose strong {
  color: var(--deep-blue);
}

.mg-prose a {
  color: var(--text-blue);
  font-weight: 600;
}

/* Other tables, right under the games */
.mg-tables {
  margin-top: 44px;
}

.mg-tables h2 {
  font-size: 22px;
  font-weight: 800;
  color: var(--deep-blue);
  margin-bottom: 14px;
}

.mg-app-label {
  display: inline-block;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--primary-blue);
}

/* Learn: strategies beside the full table */
.mg-learn {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 48px;
  align-items: start;
}

.mg-learn .mg-prose > :first-child {
  margin-top: 0;
}

.mg-table-card {
  position: sticky;
  top: 96px;
  padding: 22px 22px 18px;
  border-radius: 22px;
  background: linear-gradient(170deg, #EBFAFF 0%, #DDF5FF 100%);
}

.mg-table-card .table-scroll {
  margin: 0;
}

.mg-times-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 17px;
}

.mg-times-table caption {
  text-align: left;
  font-size: 18px;
  font-weight: 800;
  color: var(--deep-blue);
  padding: 0 4px 12px;
}

.mg-times-table th,
.mg-times-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid rgba(26, 52, 108, 0.08);
}

.mg-times-table thead th {
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #8A93A6;
}

.mg-times-table tbody th {
  font-weight: 600;
  color: var(--deep-blue);
  white-space: nowrap;
}

.mg-times-table tbody td:nth-child(2) {
  font-size: 20px;
  font-weight: 800;
  color: var(--primary-blue);
}

.mg-times-table tbody td:nth-child(3) {
  color: #6B7486;
  white-space: nowrap;
}

.mg-times-table tr.is-new th,
.mg-times-table tr.is-new td {
  background: rgba(255, 255, 255, 0.75);
}

.mg-times-table tr.is-beyond th,
.mg-times-table tr.is-beyond td {
  opacity: 0.55;
}

.mg-times-table tr.is-beyond:first-of-type th,
.mg-times-table tr.is-beyond:first-of-type td,
.mg-times-table tr:not(.is-beyond) + tr.is-beyond th,
.mg-times-table tr:not(.is-beyond) + tr.is-beyond td {
  border-top: 2px dashed rgba(26, 52, 108, 0.18);
}

.mg-table-note {
  margin-top: 12px;
  font-size: 14px;
  line-height: 1.5;
  color: #6B7486;
}

/* Multiplication chart (operation hubs): a 12 × 12 grid */
.mg-chart-card {
  max-width: 820px;
  padding: 22px 22px 18px;
  border-radius: 22px;
  background: linear-gradient(170deg, #EBFAFF 0%, #DDF5FF 100%);
}

.mg-chart-card .table-scroll {
  margin: 0;
}

.mg-chart {
  width: 100%;
  min-width: 520px;
  border-collapse: separate;
  border-spacing: 3px;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.mg-chart caption {
  text-align: left;
  font-size: 18px;
  font-weight: 800;
  color: var(--deep-blue);
  padding: 0 4px 12px;
}

.mg-chart th,
.mg-chart td {
  padding: 7px 2px;
  border-radius: 8px;
}

.mg-chart th {
  font-weight: 800;
  color: #fff;
  background: var(--primary-blue);
}

.mg-chart td {
  font-weight: 500;
  color: var(--deep-blue);
  background: rgba(255, 255, 255, 0.85);
}

.mg-chart td.is-square {
  font-weight: 800;
  background: #FFE3BF;
}

/* The finger trick: an inline SVG diagram of two hands */
.mg-hands {
  max-width: 640px;
  margin: 8px 0 24px;
  padding: 18px 18px 14px;
  border-radius: 20px;
  background: #F7F9FD;
}

.mg-hands-svg {
  display: block;
  width: 100%;
  height: auto;
}

.mg-hands figcaption {
  margin-top: 8px;
  font-size: 14px;
  line-height: 1.5;
  color: #6B7486;
}

.mg-prose ol {
  margin: 0 0 16px 22px;
  font-size: 17px;
  line-height: 1.65;
}

/* Grade: age, grade, standard, England */
.mg-grade-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 8px;
  max-width: 900px;
}

.mg-grade-row div {
  padding: 16px 18px;
  border-radius: 16px;
  background: #F7F9FD;
}

.mg-grade-row dt {
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #8A93A6;
  margin-bottom: 4px;
}

.mg-grade-row dd {
  font-size: 19px;
  font-weight: 700;
  color: var(--deep-blue);
}

/* Related links */
.mg-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.mg-chips a,
.mg-chips .is-current {
  padding: 9px 16px;
  border: 1.5px solid #D9E6F5;
  border-radius: 999px;
  font-size: 15.5px;
  font-weight: 500;
  color: var(--deep-blue);
  text-decoration: none;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.mg-chips a:hover,
.mg-chips a:focus-visible {
  border-color: var(--primary-blue);
  color: var(--primary-blue);
}

.mg-chips .is-current {
  border-color: var(--primary-blue);
  background: var(--primary-blue);
  color: #fff;
}

/* Parent quotes */
.mg-method {
  max-width: 780px;
  font-size: 15px;
  color: #6B7486;
  margin-bottom: 20px;
}

.mg-quotes {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.mg-quote {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
  padding: 24px;
  border-radius: 20px;
  background: #F7F9FD;
}

.mg-quote blockquote p {
  font-size: 16.5px;
  line-height: 1.6;
  color: var(--deep-blue);
}

.mg-quote figcaption {
  font-size: 13.5px;
  color: #8A93A6;
}

/* The app */
.mg-app {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  gap: 40px;
  align-items: center;
  margin-top: 48px;
  padding: 44px;
  border-radius: 28px;
  background: var(--method-bg);
  color: #fff;
}

.mg-app .mg-app-label {
  color: #CDE0FF;
}

.mg-app h2 {
  margin-top: 6px;
  color: #fff;
}

.mg-app p {
  font-size: 17px;
  line-height: 1.65;
  margin-bottom: 14px;
}

.mg-app-terms {
  font-weight: 600;
}

.mg-app .store-buttons {
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 12px 25px;
  margin: 20px 0 12px;
}

.mg-app-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 4px 0 18px;
  font-size: 16.5px;
  line-height: 1.45;
}

.mg-app-list li {
  position: relative;
  padding-left: 28px;
}

.mg-app-list strong {
  font-weight: 700;
  color: #fff;
}

.mg-app-list li::before {
  content: '';
  position: absolute;
  left: 2px;
  top: 5px;
  width: 14px;
  height: 7px;
  border-left: 3px solid #fff;
  border-bottom: 3px solid #fff;
  transform: rotate(-45deg);
}

.mg-app .mg-app-rating {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  opacity: 0.9;
}

.mg-app-rating a {
  color: #fff;
  font-weight: 600;
  white-space: nowrap;
}

.mg-app-shot img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 20px;
  box-shadow: 0 18px 40px rgba(10, 25, 80, 0.35);
}

/* FAQ */
.mg-faq {
  margin-top: 80px;
  max-width: 900px;
}

.mg-faq .faq-question {
  font-size: 18px;
  color: var(--deep-blue);
}

.mg-faq .faq-answer {
  font-size: 16.5px;
}

.mg-about {
  margin-top: 56px;
}

/* ── Responsive ───────────────────────────────────────────────────────── */
@media (max-width: 960px) {
  /* minmax(0, 1fr): a wide table scrolls inside its card instead of widening the page. */
  .mg-learn {
    grid-template-columns: minmax(0, 1fr);
    gap: 28px;
  }


  .mg-table-card {
    position: static;
    max-width: 480px;
  }

  .mg-quotes {
    grid-template-columns: 1fr;
  }

  .mg-app {
    grid-template-columns: 1fr;
    padding: 32px 28px;
  }

  .mg-app-shot {
    max-width: 460px;
  }
}

@media (max-width: 720px) {
  .mg-hero h1 {
    font-size: 32px;
  }

  .mg-lead {
    font-size: 17px;
  }

  .mg-facts {
    gap: 6px;
  }

  .mg-facts li {
    font-size: 13.5px;
    padding: 6px 12px;
  }

  .mg-play-head h2 {
    font-size: 23px;
  }

  .mg-section {
    margin-top: 56px;
  }

  .mg-section h2,
  .mg-app h2,
  .mg-faq h2 {
    font-size: 25px;
  }

  .mg-grade-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mg-hands {
    padding: 10px 8px 12px;
  }

  .mg-chart-card {
    padding: 14px 8px 12px;
  }

  .mg-chart {
    min-width: 0;
    border-spacing: 2px;
    font-size: 12px;
    letter-spacing: -0.02em;
  }

  .mg-chart caption {
    font-size: 16px;
  }

  .mg-chart th,
  .mg-chart td {
    padding: 6px 0;
    border-radius: 6px;
  }

  .mg-hands figcaption {
    padding: 0 6px;
  }

  .mg-chips.is-tables {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .mg-chips.is-tables .is-all {
    grid-column: 1 / -1;
  }

  /* Long labels ("multiplication by 8 games") wrap onto a second line instead of overflowing. */
  .mg-chips.is-tables a,
  .mg-chips.is-tables .is-current {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 7px 8px;
    border-radius: 16px;
    font-size: 13.5px;
    line-height: 1.25;
    text-align: center;
  }

  .mg-tables {
    margin-top: 36px;
  }

  .mg-tables h2 {
    font-size: 20px;
  }

  .mg-app {
    margin-top: 36px;
    padding: 28px 22px;
    border-radius: 22px;
  }

  .mg-faq {
    margin-top: 60px;
  }

  .mg-faq .faq-answer {
    margin-left: 0;
  }
}
