/*
 * SumReflex sketchbook theme
 *
 * The visual language is based on the supplied Ruler Rumble reference:
 * graph paper, dark hand-drawn outlines, sunny yellow and mint accents,
 * offset shadows, and friendly display type.
 *
 * This file intentionally does not restyle MathQuill's internal nodes,
 * MathJax/KaTeX output, formula canvases, or SVG text. Those components keep
 * the carefully tuned typography and geometry from their own stylesheets.
 */

:root {
  --ink: #22304a;
  --paper: #f4f8fc;
  --grid: #dce8f4;
  --grid2: #c7daec;
  --yellow: #ffc940;
  --yellow-soft: #ffe9a8;
  --yellow-deep: #e8a825;
  --mint: #74e0c8;
  --mint-soft: #c9f3e9;
  --teal: #12a594;
  --red: #e8484f;
  --red-soft: #ffd9d9;
  --blue: #2d7ff9;
  --green: #3dbe6c;

  --bg0: var(--paper);
  --bg1: var(--paper);
  --card: #ffffff;
  --card2: #fffdf6;
  --stroke: var(--ink);
  --text: var(--ink);
  --muted: #5b6b87;
  --muted2: #74829a;
  --accent: var(--teal);
  --accent2: var(--blue);
  --accent3: var(--yellow-deep);
  --danger: var(--red);
  --shadow: 7px 7px 0 rgba(34, 48, 74, .13);
  --soft-shadow: 4px 4px 0 rgba(34, 48, 74, .11);
  --radius2: 18px;
  --sans: "Nunito", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --display: "Lilita One", "Nunito", system-ui, sans-serif;
  --ui-font: var(--sans);
}

html {
  background:
    linear-gradient(var(--grid2) 1.5px, transparent 1.5px) 0 0 / 120px 120px,
    linear-gradient(90deg, var(--grid2) 1.5px, transparent 1.5px) 0 0 / 120px 120px,
    linear-gradient(var(--grid) 1px, transparent 1px) 0 0 / 24px 24px,
    linear-gradient(90deg, var(--grid) 1px, transparent 1px) 0 0 / 24px 24px,
    var(--paper) !important;
  background-attachment: fixed !important;
}

body.sr-page {
  color: var(--ink);
  font-family: var(--sans);
  font-weight: 700;
}

body.sr-page :focus-visible {
  outline: 3px dashed var(--blue);
  outline-offset: 3px;
}

body.sr-page :is(input, textarea, select):focus,
body.sr-page :is(input, textarea, select):focus-visible {
  outline: none;
}

.bg {
  display: block;
}

.bg-grid {
  background: none;
  -webkit-mask-image: none;
  mask-image: none;
}

.bg-tools {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.bg-tool {
  position: absolute;
  display: block;
  width: var(--tool-size);
  height: auto;
  opacity: .48;
  transform: rotate(var(--tool-rotation));
  transform-origin: center;
  animation: sr-tool-float var(--tool-duration) ease-in-out infinite;
  animation-delay: var(--tool-delay, 0s);
  will-change: transform;
}

.bg-tool-pencil {
  --tool-size: 96px;
  --tool-rotation: -14deg;
  --tool-duration: 9s;
  top: 11%;
  left: 2.5%;
}

.bg-tool-set-square {
  --tool-size: 104px;
  --tool-rotation: 8deg;
  --tool-duration: 12s;
  --tool-delay: 1s;
  top: 58%;
  right: 3%;
}

.bg-tool-protractor {
  --tool-size: 88px;
  --tool-rotation: -5deg;
  --tool-duration: 11s;
  --tool-delay: 2s;
  bottom: 6%;
  left: 5%;
}

.bg-tool-paperclip {
  --tool-size: 64px;
  --tool-rotation: 16deg;
  --tool-duration: 8s;
  --tool-delay: .5s;
  top: 16%;
  right: 9%;
}

@keyframes sr-tool-float {
  0%,
  100% {
    transform: translateY(0) rotate(var(--tool-rotation));
  }

  50% {
    transform: translateY(-16px) rotate(calc(var(--tool-rotation) + 5deg));
  }
}

.bg-float span {
  color: rgba(18, 165, 148, .22);
  font-family: var(--display);
  font-weight: 400;
}

/*
 * Typography is assigned to known interface headings instead of every element.
 * Formula renderers below are also explicitly isolated from UI typography.
 */
:where(
  .sr-brand-name,
  .site-menu-title,
  .site-menu-link-title,
  .sr-home-panel h1,
  .sr-directory-hero h1,
  .sr-section-head h2,
  .sr-printable-hero h1,
  .sr-chart-article-head h1,
  .sr-learning-hero h1,
  .sr-lesson-hero h1,
  .sr-static-hero h1,
  .sr-calc-heading h1,
  .calc-suite-title,
  .sr-home-card-title,
  .sr-printable-category-title,
  .sr-times-chart-card-title,
  .sr-learning-card-title,
  .sr-game-category-title,
  .sr-game-card-title,
  .sr-feature-title,
  .sr-link-group h2,
  .sr-chart-content h2,
  .sr-lesson-section h2,
  .sr-game-copy-card h2,
  .sr-guide-card h3,
  .sr-calculator-guide h2,
  .sr-choice-question-heading h3,
  .sr-choice-answer h4
) {
  font-family: var(--display);
  font-weight: 400;
  letter-spacing: .01em !important;
}

:where(
  .sr-home-panel h1,
  .sr-directory-hero h1,
  .sr-printable-hero h1,
  .sr-chart-article-head h1,
  .sr-learning-hero h1,
  .sr-lesson-hero h1,
  .sr-static-hero h1,
  .sr-calc-heading h1,
  .calc-suite-title
) {
  color: var(--ink) !important;
  line-height: 1.04;
  text-shadow: 2px 2px 0 #ffffff;
}

:where(.mq-math-mode, .mq-editable-field, .mathquill-editable, .mathquill-rendered-math),
:where(.mq-math-mode, .mq-editable-field, .mathquill-editable, .mathquill-rendered-math) *,
:where(mjx-container, .MathJax, .MathJax_Display, .katex, .katex-display),
:where(mjx-container, .MathJax, .MathJax_Display, .katex, .katex-display) * {
  letter-spacing: normal !important;
}

/* Header and navigation */
.sr-header {
  width: min(1280px, calc(100% - var(--site-gutter-total)));
  min-height: 76px;
  margin-top: 16px;
  padding: 9px 12px;
  border: 2px solid var(--ink);
  border-radius: 18px;
  background:
    linear-gradient(105deg, rgba(255, 233, 168, .38), rgba(255, 255, 255, .97) 28%, rgba(255, 255, 255, .97) 70%, rgba(201, 243, 233, .46));
  box-shadow: 0 12px 28px rgba(34, 48, 74, .1);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
}

.sr-brand {
  gap: 10px;
  padding-right: 4px;
}

.sr-logo,
.sr-feature-icon,
.calc-hero-icon,
.empty-icon {
  color: var(--ink) !important;
  border: 3px solid var(--ink);
  border-radius: 13px !important;
  background: var(--yellow);
  box-shadow: 3px 3px 0 rgba(34, 48, 74, .18);
}

.sr-logo {
  width: 44px;
  height: 44px;
  font-family: var(--display);
  font-size: 25px;
  font-weight: 400;
  transform: rotate(-2deg);
}

.sr-brand-name {
  color: var(--ink);
  font-size: 22px;
  line-height: 1;
}

.sr-brand-sub {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.sr-site-search-field {
  min-height: 44px;
  border: 2px solid #bccbda;
  border-radius: 13px;
  background: #ffffff;
  color: var(--ink);
  box-shadow: inset 0 2px 0 rgba(34, 48, 74, .04);
}

.sr-site-search-field:focus-within {
  border-color: var(--ink);
  box-shadow: 0 0 0 4px rgba(45, 127, 249, .12);
}

.sr-site-search-field input:focus,
.sr-site-search-field input:focus-visible {
  outline: none;
}

.sr-site-search-icon {
  color: var(--teal);
}

.sr-site-search-field input {
  color: var(--ink);
  font: 800 14px/1.3 var(--sans);
}

/* Shared category and directory search fields */
.sr-game-search {
  gap: 7px;
}

.sr-game-search > span {
  color: #0b7a6c;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.sr-game-search input {
  min-height: 50px;
  border: 2px solid #bccbda;
  border-radius: 13px;
  background: rgba(255, 255, 255, .96);
  color: var(--ink);
  padding: 0 14px;
  box-shadow: inset 0 2px 0 rgba(34, 48, 74, .04);
}

.sr-game-search input:focus,
.sr-game-search input:focus-visible,
input[data-sr-filter]:focus-visible {
  border-color: var(--ink);
  outline: none;
  box-shadow: 0 0 0 4px rgba(45, 127, 249, .12);
}

.sr-site-search-submit,
.sr-search-page-form button,
.sr-sample-btn,
.sr-primary-link,
.sr-contact-submit {
  min-height: 44px;
  border: 3px solid var(--ink);
  border-radius: 14px;
  background: var(--yellow);
  color: var(--ink);
  font-family: var(--display);
  font-weight: 400;
  box-shadow: 0 4px 0 var(--ink);
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}

.sr-site-search-submit:hover,
.sr-site-search-submit:focus-visible,
.sr-search-page-form button:hover,
.sr-search-page-form button:focus-visible,
.sr-sample-btn:hover,
.sr-primary-link:hover,
.sr-contact-submit:hover {
  background: #ffd75e;
  color: var(--ink);
  transform: translateY(-2px);
  box-shadow: 0 6px 0 var(--ink);
}

.sr-site-search-submit {
  min-height: 44px;
  border-width: 2px;
  border-radius: 13px;
  box-shadow: 0 3px 0 var(--ink);
}

.sr-nav {
  gap: 2px;
  padding: 4px;
  border: 1.5px solid #d8e3ee;
  border-radius: 14px;
  background: rgba(255, 255, 255, .8);
}

.sr-nav a {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border: 1.5px solid transparent;
  border-radius: 10px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
}

.sr-nav a:hover,
.sr-nav a.active {
  border-color: var(--ink);
  background: var(--yellow-soft);
  color: var(--ink);
  box-shadow: 2px 2px 0 rgba(34, 48, 74, .1);
}

.icon-btn {
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: #ffffff;
  color: var(--ink);
  box-shadow: 2px 2px 0 rgba(34, 48, 74, .12);
}

.site-menu-backdrop {
  background: rgba(34, 48, 74, .38);
  -webkit-backdrop-filter: blur(7px);
  backdrop-filter: blur(7px);
}

.site-menu-panel {
  top: 88px;
  right: max(16px, calc((100vw - 1280px) / 2));
  width: min(390px, calc(100vw - 32px));
  padding: 16px;
  border: 2.5px solid var(--ink);
  border-radius: 20px;
  background:
    linear-gradient(145deg, rgba(255, 233, 168, .3), #ffffff 28%, #ffffff 72%, rgba(201, 243, 233, .4)) !important;
  box-shadow: 0 24px 60px rgba(34, 48, 74, .2);
}

.site-menu-head {
  margin-bottom: 12px;
  padding: 2px 2px 14px;
  border-bottom: 2px dashed var(--grid2);
}

.site-menu-title {
  color: var(--ink);
  font-size: 27px;
}

.site-menu-close {
  background: var(--red-soft);
  color: var(--red);
}

.site-menu-kicker,
.sr-eyebrow,
.calc-suite-kicker {
  width: fit-content;
  margin-bottom: 10px;
  padding: 5px 11px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--mint-soft);
  color: #0b7a6c !important;
  font-size: 11px !important;
  font-weight: 900 !important;
  line-height: 1.2;
  text-transform: uppercase;
  box-shadow: 2px 2px 0 rgba(34, 48, 74, .12);
}

.site-menu-link {
  padding: 12px;
  border: 1.5px solid #d8e3ee;
  border-radius: 14px;
  background: rgba(255, 255, 255, .92) !important;
  box-shadow: none;
}

.site-menu-link:hover {
  border-color: var(--ink);
  background: var(--mint-soft) !important;
  transform: translateY(-1px);
}

.site-menu-link.featured {
  border-color: var(--ink);
  background: var(--yellow-soft) !important;
}

.site-menu-link-icon {
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: var(--yellow);
  color: var(--ink);
  box-shadow: 2px 2px 0 rgba(34, 48, 74, .14);
}

.site-menu-link:nth-child(2) .site-menu-link-icon { background: var(--mint); }
.site-menu-link:nth-child(3) .site-menu-link-icon { background: #b9d3ff; }
.site-menu-link:nth-child(4) .site-menu-link-icon { background: #ffb8c5; }
.site-menu-link:nth-child(5) .site-menu-link-icon { background: #bcebc9; }
.site-menu-link:nth-child(6) .site-menu-link-icon { background: #ffd7a6; }

.site-menu-link-title {
  color: var(--ink);
  font-size: 17px;
}

.site-menu-link-desc {
  color: var(--muted);
  font-size: 12.5px;
}

.site-menu-link-arrow {
  color: var(--red);
  font-family: var(--display);
  font-size: 22px;
}

/* Shared cards and page surfaces */
:where(
  .panel,
  .sr-home-panel,
  .sr-directory-hero,
  .sr-link-directory,
  .sr-related-inner,
  .sr-printable-hero,
  .sr-chart-article-head,
  .sr-chart-content,
  .sr-learning-hero,
  .sr-lesson-hero,
  .sr-lesson-section,
  .sr-static-hero,
  .sr-policy-content article,
  .sr-contact-note,
  .sr-contact-form,
  .sr-games-hero,
  .sr-game-detail-hero,
  .sr-game-copy-card,
  .sr-calculator-guide,
  .sr-choice-question-card
) {
  border: 3px solid var(--ink) !important;
  border-radius: 20px !important;
  background: #ffffff;
  box-shadow: var(--shadow) !important;
}

.sr-main {
  margin-top: 28px;
}

.sr-home-panel,
.sr-printable-hero,
.sr-learning-hero,
.sr-lesson-hero,
.sr-static-hero,
.sr-games-hero,
.sr-game-detail-hero {
  background:
    radial-gradient(circle at 94% 10%, rgba(116, 224, 200, .55), transparent 25%),
    radial-gradient(circle at 7% 100%, rgba(255, 201, 64, .48), transparent 30%),
    #ffffff !important;
}

.sr-directory-hero {
  background:
    linear-gradient(135deg, rgba(255, 233, 168, .95), rgba(255, 255, 255, .96) 48%, rgba(201, 243, 233, .96)) !important;
  color: var(--ink);
}

.sr-directory-hero h1 {
  color: var(--ink) !important;
  letter-spacing: .01em !important;
  text-shadow: 2px 2px 0 #ffffff;
}

.sr-directory-hero .sr-eyebrow {
  color: #0b7a6c !important;
  font-size: 11px !important;
  letter-spacing: normal !important;
}

.sr-directory-hero .sr-lead,
.sr-feature-text,
.sr-lead,
.sr-calc-heading p,
.calc-suite-sub {
  color: var(--muted) !important;
  font-weight: 700;
}

.sr-feature-card {
  border: 3px solid var(--ink);
  border-radius: 16px;
  background: #ffffff;
  color: var(--ink);
  box-shadow: 4px 4px 0 rgba(34, 48, 74, .13);
  animation: none;
}

.sr-feature-card:hover {
  border-color: var(--ink);
  background: #fffbee;
  box-shadow: 6px 6px 0 rgba(34, 48, 74, .15);
}

.sr-feature-arrow {
  color: var(--red);
}

.sr-section-head {
  border-bottom: 3px dashed var(--grid2);
}

/* Shared directory and listing cards */
:is(
  .sr-home-card,
  .sr-printable-category-card,
  .sr-times-chart-card,
  .sr-learning-card,
  .sr-game-category-card,
  .sr-game-card,
  .sr-search-page-card,
  .sr-tracing-sheet-card
) {
  box-sizing: border-box;
  border: 2px solid var(--ink);
  border-radius: 16px;
  background-color: #ffffff;
  box-shadow: 0 10px 24px rgba(34, 48, 74, .09);
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}

:is(
  .sr-home-card,
  .sr-printable-category-card,
  .sr-times-chart-card,
  .sr-learning-card,
  .sr-game-category-card,
  .sr-game-card,
  .sr-search-page-card,
  .sr-tracing-sheet-card
):hover {
  border-color: var(--ink);
  background-color: #fffbee;
  transform: translateY(-3px);
  box-shadow: 0 14px 30px rgba(34, 48, 74, .13);
}

.sr-printable-category-card:nth-child(3n + 1),
.sr-learning-card:nth-child(3n + 1),
.sr-game-category-card:nth-child(3n + 1) {
  background-color: #fff9e6;
}

.sr-printable-category-card:nth-child(3n + 2),
.sr-learning-card:nth-child(3n + 2),
.sr-game-category-card:nth-child(3n + 2) {
  background-color: #edfbf7;
}

.sr-home-card-mark,
.sr-game-category-icon,
.sr-printable-category-icon,
.sr-times-chart-card-art,
.sr-learning-card-placeholder {
  border: 2.5px solid var(--ink);
  border-radius: 13px;
  background: var(--yellow);
  color: var(--ink);
  box-shadow: 3px 3px 0 rgba(34, 48, 74, .15);
}

.sr-game-category-card:nth-child(even) .sr-game-category-icon,
.sr-printable-category-card:nth-child(even) .sr-printable-category-icon {
  background: var(--mint);
}

.sr-home-card-arrow,
.sr-printable-category-arrow,
.sr-times-chart-card-arrow {
  color: var(--red);
}

/* Image-led category cards used by charts, worksheets, and printables. */
.sr-printable-category-grid {
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 18px;
}

.sr-printable-category-card {
  gap: 0;
  padding: 10px;
  background:
    linear-gradient(155deg, #ffffff 0%, color-mix(in srgb, var(--sr-chart-accent, var(--yellow)) 7%, white) 100%);
}

.sr-printable-category-card .sr-listing-thumb {
  box-sizing: border-box;
  border: 1.5px solid var(--ink);
  border-radius: 12px;
  background: #ffffff;
  box-shadow: none;
}

.sr-printable-category-card .sr-listing-thumb img {
  transition: transform .2s ease;
}

.sr-printable-category-card:hover .sr-listing-thumb img,
.sr-printable-category-card:focus-visible .sr-listing-thumb img {
  transform: scale(1.025);
}

.sr-printable-category-copy {
  min-height: 66px;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  justify-items: start;
  gap: 10px;
  padding: 13px 7px 4px;
  text-align: left;
}

.sr-printable-category-copy::after {
  content: "→";
  color: var(--red);
  font-family: var(--display);
  font-size: 22px;
  line-height: 1;
}

.sr-printable-category-title {
  color: var(--ink);
  font-size: 19px;
}

/* Photo and illustration cards used by lessons and live worksheets. */
.sr-learning-card {
  background: #ffffff;
}

.sr-learning-card-media {
  border-bottom: 2px solid var(--ink);
}

.sr-learning-card-body {
  background:
    linear-gradient(135deg, #ffffff, var(--paper));
}

.sr-learning-card-title {
  color: var(--ink);
  font-size: 19px;
}

.sr-isosceles-diagram {
  width: min(100%, 860px);
  min-width: 0;
  margin-inline: auto;
  border: 0;
  border-radius: 16px;
  background: #ffffff;
  box-shadow: 0 12px 28px rgba(34, 48, 74, .1);
}

.sr-lesson-image-figure img[src$="/isosceles-trapezium-rule.jpg"],
.sr-lesson-image-figure img[src*="/isosceles-trapezium-property-chart.jpg"],
.sr-lesson-image-figure img[src*="/isosceles-trapezium-angle-example.jpg"],
.sr-lesson-image-figure img[src$="/isosceles-trapezium-equal-diagonals.jpg"] {
  width: min(100%, 860px);
  border: 0;
  border-radius: 16px;
}

.sr-isosceles-diagram text,
.sr-isosceles-interactive-diagram text {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: normal !important;
}

/* Text-led category cards used by the games directory. */
.sr-game-category-card {
  align-items: center;
  padding: 16px;
  background:
    linear-gradient(135deg, #ffffff 0%, #f8fbff 100%);
}

.sr-game-category-icon {
  align-self: start;
}

.sr-game-category-count {
  border: 1.5px solid var(--ink);
  background: var(--mint-soft);
  color: var(--ink);
  box-shadow: 2px 2px 0 rgba(34, 48, 74, .09);
}

.sr-game-card-grid {
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}

.sr-game-card {
  grid-template-columns: 1fr;
  gap: 0;
  overflow: hidden;
  padding: 10px;
  background:
    linear-gradient(155deg, #ffffff 0%, #f4fbfa 100%);
}

.sr-game-card-media {
  width: 100%;
  aspect-ratio: 10 / 11;
  border: 1.5px solid var(--ink);
  border-radius: 12px;
}

.sr-game-card-media.has-thumbnail {
  background-color: #f8fbff;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
}

.sr-game-card .sr-game-card-copy {
  align-content: start;
  gap: 7px;
  padding: 14px 7px 8px;
}

.sr-game-card-title {
  color: var(--ink);
  font-size: 22px;
}

.sr-game-card-meta {
  width: auto;
  max-width: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.4;
  box-shadow: none;
  overflow-wrap: anywhere;
}

/* Home section cards */
.sr-home-card-list {
  grid-template-columns: 1fr;
  gap: 16px;
}

.sr-home-card {
  --sr-home-tone: var(--yellow);
  --sr-home-soft: #fff8df;
  box-sizing: border-box;
  min-height: 150px;
  grid-template:
    "mark copy arrow" 1fr / auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 20px;
  padding: 24px;
  border: 2px solid var(--ink);
  border-radius: 18px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, .98) 0%, rgba(255, 255, 255, .93) 55%, rgba(255, 255, 255, .68) 100%),
    var(--sr-home-card-art) right center / auto 100% no-repeat,
    var(--sr-home-soft);
  box-shadow: 0 10px 24px rgba(34, 48, 74, .09);
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}

.sr-home-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 8px;
  background: var(--sr-home-tone);
}

.sr-home-card:hover,
.sr-home-card:focus-visible {
  border-color: var(--ink);
  background-color: var(--sr-home-soft);
  transform: translateY(-3px);
  box-shadow: 0 14px 30px rgba(34, 48, 74, .13);
}

.sr-home-card-copy {
  grid-area: copy;
  align-self: center;
  gap: 9px;
}

.sr-home-card-title {
  color: var(--ink);
  font-size: 26px;
}

.sr-home-card-summary {
  max-width: 780px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 750;
  line-height: 1.5;
}

.sr-home-card-mark {
  grid-area: mark;
  width: 56px;
  height: 56px;
  border: 2.5px solid var(--ink);
  border-radius: 14px;
  background: var(--sr-home-tone);
  color: var(--ink);
  font-family: var(--display);
  font-size: 26px;
  font-weight: 400;
  box-shadow: 3px 3px 0 rgba(34, 48, 74, .14);
}

.sr-home-card-arrow {
  grid-area: arrow;
  width: 40px;
  height: 40px;
  align-self: center;
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: #ffffff;
  color: var(--red);
  box-shadow: 2px 2px 0 rgba(34, 48, 74, .1);
}

.sr-home-card:hover .sr-home-card-arrow,
.sr-home-card:focus-visible .sr-home-card-arrow {
  background: var(--sr-home-tone);
  color: var(--ink);
}

.sr-home-card-calculators {
  --sr-home-tone: var(--yellow);
  --sr-home-soft: #fff8df;
}

.sr-home-card-games {
  --sr-home-tone: var(--mint);
  --sr-home-soft: #eafbf7;
}

.sr-home-card-charts {
  --sr-home-tone: #b9d3ff;
  --sr-home-soft: #eef4ff;
}

.sr-home-card-worksheets {
  --sr-home-tone: #ffb8c5;
  --sr-home-soft: #fff0f3;
}

.sr-home-card-live {
  --sr-home-tone: #bcebc9;
  --sr-home-soft: #eefaf1;
}

.sr-home-card-lessons {
  --sr-home-tone: #ffd7a6;
  --sr-home-soft: #fff5e8;
}

.sr-link-directory {
  background: rgba(255, 255, 255, .96) !important;
}

.sr-category-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 270px), 1fr));
  gap: 18px;
}

.sr-link-group {
  padding: 22px 16px 16px;
  border: 2px solid var(--ink);
  border-radius: 16px;
  background: rgba(255, 255, 255, .98);
  box-shadow: 0 10px 22px rgba(34, 48, 74, .08);
  transition: border-color .15s ease, box-shadow .15s ease;
}

.sr-link-group::before {
  height: 7px;
  background: var(--cat-accent, var(--yellow));
}

.sr-link-group:hover {
  border-color: var(--ink);
  box-shadow: 0 12px 26px rgba(34, 48, 74, .1);
  transform: none;
}

.sr-link-group:nth-child(6n + 1) { --cat-accent: var(--yellow); }
.sr-link-group:nth-child(6n + 2) { --cat-accent: var(--mint); }
.sr-link-group:nth-child(6n + 3) { --cat-accent: #b9d3ff; }
.sr-link-group:nth-child(6n + 4) { --cat-accent: #ffb8c5; }
.sr-link-group:nth-child(6n + 5) { --cat-accent: #bcebc9; }
.sr-link-group:nth-child(6n + 6) { --cat-accent: #ffd7a6; }

.sr-category-title-row {
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 2px dashed var(--grid2);
}

.sr-link-group h2 {
  color: var(--ink);
  font-size: 22px;
}

.sr-category-title-row span {
  min-width: 34px;
  height: 30px;
  border: 2px solid var(--ink);
  background: var(--cat-accent);
  color: var(--ink);
  box-shadow: 2px 2px 0 rgba(34, 48, 74, .1);
}

.sr-link-group ul {
  gap: 7px;
}

.sr-link-group li {
  width: 100%;
  min-width: 0;
}

.sr-link-group a {
  box-sizing: border-box;
  width: 100%;
  max-width: none;
  min-height: 44px;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 11px;
  border: 1.5px solid #dce6f0;
  border-radius: 10px;
  background: #f8fbff;
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 800;
  text-align: left;
}

.sr-link-group a::after {
  content: "→";
  flex: 0 0 auto;
  color: var(--teal);
  font-family: var(--display);
  font-size: 18px;
  line-height: 1;
  opacity: .65;
  transition: transform .15s ease, opacity .15s ease;
}

.sr-link-group a:hover {
  border-color: var(--cat-accent);
  background: var(--yellow-soft);
  color: var(--ink);
  transform: none;
}

.sr-link-group a:hover::after {
  opacity: 1;
  transform: translateX(2px);
}

.sr-link-group-wide ul {
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
}

.sr-link-group-wide a {
  justify-content: space-between;
  text-align: left;
}

.sr-related-links a {
  border: 2px solid transparent;
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
  font-weight: 800;
}

.sr-related-links a:hover {
  border-color: var(--ink);
  background: var(--yellow-soft);
  color: var(--ink);
}

/*
 * Calculator shell: cosmetic only; formula dimensions stay untouched.
 * Structural wrappers stay borderless so a calculator is not rendered as
 * several tightly nested cards.
 */
.sr-step-panel,
.calc-suite-panel {
  border: 3px solid var(--ink) !important;
  border-radius: 20px !important;
  background: #ffffff !important;
  box-shadow: 0 12px 28px rgba(34, 48, 74, .09) !important;
}

.sr-calc-heading,
.calc-suite-hero {
  border: 3px solid var(--ink);
  border-radius: 16px;
  background:
    linear-gradient(135deg, var(--yellow-soft), #ffffff 52%, var(--mint-soft));
  box-shadow: none;
}

.input-bar.sr-step-input-bar {
  border: 3px solid var(--ink);
  border-radius: 16px;
  background: #ffffff;
  box-shadow: inset 0 3px 0 rgba(34, 48, 74, .06);
}

.calc-builder {
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.calc-field :is(input, textarea, select):focus,
.calc-field :is(input, textarea, select):focus-visible,
.calc-mode-wrap select:focus,
.calc-mode-wrap select:focus-visible {
  border-color: var(--ink) !important;
  outline: none;
  box-shadow: 0 0 0 4px rgba(45, 127, 249, .12) !important;
}

.input-bar.sr-step-input-bar:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(45, 127, 249, .12);
}

.tab {
  border: 2.5px solid var(--ink);
  border-radius: 12px;
  background: #ffffff;
  color: var(--ink);
  font-family: var(--display);
  font-weight: 400;
  box-shadow: 0 3px 0 var(--ink);
}

.tab.active {
  border-color: var(--ink);
  background: var(--yellow);
  color: var(--ink);
}

.primary {
  border: 3px solid var(--ink);
  border-radius: 14px;
  background: var(--yellow);
  color: var(--ink);
  font-family: var(--display);
  font-weight: 400;
  box-shadow: 0 5px 0 var(--ink);
}

.primary:hover {
  background: #ffd75e;
  filter: none;
  transform: translateY(-2px);
  box-shadow: 0 7px 0 var(--ink);
}

.ibtn,
.kbtn,
.action-btn,
.chip {
  border-color: var(--ink);
  color: var(--ink);
}

.ibtn {
  border-width: 2px;
  border-radius: 10px;
  background: var(--paper);
  box-shadow: 2px 2px 0 rgba(34, 48, 74, .13);
}

.ibtn.upload {
  background: var(--mint-soft);
  color: #0b7a6c;
}

.preview-box,
.inline-answer-box,
.answer-box,
.fc-num,
.answer-mode-select,
.fc-select,
.fc-decimal-input {
  border: 2px solid var(--ink) !important;
  border-radius: 12px !important;
  background: #fffdf6 !important;
  color: var(--ink) !important;
}

.drawer-card {
  border: 3px solid var(--ink) !important;
  border-bottom: 0 !important;
  border-radius: 20px 20px 0 0 !important;
  background: rgba(255, 255, 255, .98) !important;
  box-shadow: 0 -7px 0 rgba(34, 48, 74, .12) !important;
}

.sr-guide-icon {
  border: 2.5px solid var(--ink);
  border-radius: 13px;
  background: var(--mint);
  color: var(--ink);
  box-shadow: 3px 3px 0 rgba(34, 48, 74, .14);
}

.sr-guide-card,
.sr-calculator-article-section {
  border-color: var(--grid2);
}

.sr-guide-card {
  border-width: 2px;
  border-radius: 15px;
  background: #fffdf6;
}

/*
 * MathQuill needs a symbol-capable base face for operators. Its own stylesheet
 * continues to choose Times New Roman for variables and text-mode fragments.
 * MathJax, KaTeX, formula blocks, SVG text, and canvases are deliberately not
 * given any font-family here, so their renderer-specific stacks remain intact.
 */
.mq-math-mode,
.mq-editable-field,
.mathquill-editable,
.mathquill-rendered-math {
  font-family: Symbola, "Times New Roman", serif;
  text-shadow: none;
}

/* Worksheets, lesson interactives, tables, and feedback */
.sr-lesson-table,
.sr-choice-given-table {
  overflow: hidden;
  border: 3px solid var(--ink);
  border-radius: 14px;
}

.sr-lesson-table th,
.sr-choice-given-table th {
  background: var(--yellow-soft);
  color: var(--ink);
}

.sr-rounding-solver-form,
.sr-rounding-solver-result,
.sr-probability-form,
.sr-probability-result,
.sr-clock-quiz-card,
.sr-clock-quiz-form,
.sr-associative-question-card,
.sr-associative-answer-panel,
.sr-reflex-stage,
.sr-reflex-controls,
.sr-live-question,
.sr-choice-challenges-intro {
  border: 2.5px solid var(--ink);
  border-radius: 16px;
  background: #ffffff;
  box-shadow: 4px 4px 0 rgba(34, 48, 74, .1);
}

.sr-rounding-solver-actions button,
.sr-probability-actions button,
.sr-clock-quiz-entry button,
.sr-clock-quiz-actions button,
.sr-associative-options button,
.sr-associative-answer-panel > button,
.sr-reflex-presets button,
.sr-choice-answer-button {
  border: 2.5px solid var(--ink);
  border-radius: 12px;
  background: var(--yellow);
  color: var(--ink);
  font-family: var(--sans);
  font-weight: 900;
  box-shadow: 0 4px 0 var(--ink);
}

.sr-reflex-presets button.is-active,
.sr-reflex-presets button[aria-pressed="true"] {
  border-color: var(--ink);
  background: var(--teal);
  color: #ffffff;
  box-shadow: 0 2px 0 var(--ink);
  transform: translateY(2px);
}

.sr-choice-question-heading,
.sr-choice-given-list,
.sr-choice-given-sets div {
  background: var(--paper);
  border-color: var(--grid2);
}

.sr-choice-answer {
  border-top: 3px solid var(--ink);
  background: #eaf9ef;
}

.sr-live-sheet {
  border: 3px solid var(--ink);
  border-radius: 18px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.sr-live-question.is-correct {
  border-color: var(--green);
  background: #eaf9ef;
}

.sr-live-question.is-wrong {
  border-color: var(--red);
  background: #fff0f0;
}

/* Game directory and play frame */
.sr-game-category-count,
.sr-lesson-meta span,
.sr-times-chart-card-grade {
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--mint-soft);
  color: var(--ink);
  font-weight: 900;
  box-shadow: 2px 2px 0 rgba(34, 48, 74, .1);
}

.sr-game-play-shell {
  overflow: hidden;
  border: 3px solid var(--ink);
  border-radius: 20px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.sr-game-start-layer {
  background:
    linear-gradient(var(--grid2) 1.5px, transparent 1.5px) 0 0 / 120px 120px,
    linear-gradient(90deg, var(--grid2) 1.5px, transparent 1.5px) 0 0 / 120px 120px,
    linear-gradient(var(--grid) 1px, transparent 1px) 0 0 / 24px 24px,
    linear-gradient(90deg, var(--grid) 1px, transparent 1px) 0 0 / 24px 24px,
    var(--paper);
}

.sr-game-start-inner {
  border: 3px solid var(--ink);
  border-radius: 14px;
  background: var(--yellow);
  color: var(--ink);
  box-shadow: 0 6px 0 var(--ink);
  font-family: var(--display);
  font-weight: 400;
}

.sr-game-fullscreen-bar {
  border-top: 3px solid var(--ink);
  background: #ffffff;
  color: var(--ink);
}

.sr-game-fullscreen-action {
  color: var(--teal);
}

/* Footer */
.sr-footer {
  position: relative;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
  padding: 16px 18px;
  border: 2px solid var(--ink);
  border-radius: 18px;
  background:
    linear-gradient(105deg, rgba(255, 233, 168, .45), rgba(255, 255, 255, .96) 28%, rgba(255, 255, 255, .96) 70%, rgba(201, 243, 233, .5));
  color: var(--muted);
  box-shadow: 0 12px 28px rgba(34, 48, 74, .09);
}

.sr-footer a {
  color: var(--ink);
  font-weight: 900;
}

.sr-footer-brand {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.sr-footer-logo {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: var(--yellow);
  color: var(--ink);
  font-family: var(--display);
  font-size: 23px;
  box-shadow: 2px 2px 0 rgba(34, 48, 74, .12);
  transform: rotate(-2deg);
}

.sr-footer-brand-copy {
  display: grid;
  gap: 2px;
}

.sr-footer-brand-copy strong {
  font-family: var(--display);
  font-size: 19px;
  font-weight: 400;
  line-height: 1;
}

.sr-footer-brand-copy small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.sr-footer-links {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 5px;
}

.sr-footer-links a {
  padding: 7px 9px;
  border: 1.5px solid transparent;
  border-radius: 9px;
  font-size: 12px;
  line-height: 1;
  text-decoration: none;
}

.sr-footer-links a:hover,
.sr-footer-links a:focus-visible {
  border-color: var(--ink);
  background: var(--yellow-soft);
  color: var(--ink);
}

@media (max-width: 760px) {
  .sr-header {
    width: calc(100% - 24px);
    border-radius: 16px;
    box-shadow: 0 10px 24px rgba(34, 48, 74, .1);
  }

  .site-menu-panel {
    top: 12px;
    right: 12px;
    width: calc(100vw - 24px);
    max-height: calc(100dvh - 24px);
    overflow: auto;
  }

  .sr-main {
    margin-top: 22px;
  }

  .sr-home-card-list {
    grid-template-columns: 1fr;
  }

  .sr-home-card {
    min-height: 178px;
    grid-template:
      "mark arrow" auto
      "copy copy" 1fr / 1fr auto;
    align-items: start;
    gap: 18px;
    padding: 20px;
  }

  .sr-home-card-title {
    font-size: 23px;
  }

  :where(
    .panel,
    .sr-home-panel,
    .sr-directory-hero,
    .sr-link-directory,
    .sr-related-inner,
    .sr-printable-hero,
    .sr-chart-article-head,
    .sr-chart-content,
    .sr-learning-hero,
    .sr-lesson-hero,
    .sr-lesson-section,
    .sr-static-hero,
    .sr-games-hero,
    .sr-game-detail-hero,
    .sr-game-copy-card,
    .sr-calculator-guide
  ) {
    border-radius: 16px !important;
    box-shadow: 5px 5px 0 rgba(34, 48, 74, .11) !important;
  }

  .sr-footer {
    align-items: flex-start;
    gap: 14px;
    padding: 16px;
  }

  .sr-footer-links {
    justify-content: flex-start;
  }
}

@media (prefers-reduced-motion: reduce) {
  .bg-tool {
    animation: none;
  }

  .bg-float span {
    animation: none;
    opacity: .16;
  }

  :where(
    .sr-home-card,
    .sr-printable-category-card,
    .sr-times-chart-card,
    .sr-learning-card,
    .sr-game-category-card,
    .sr-game-card
  ) {
    transition: none;
  }
}

@media print {
  html,
  body.sr-page {
    background: #ffffff !important;
  }

  .bg-tools {
    display: none;
  }

  .sr-live-sheet {
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
}
