:root {
  --paper: #f7f0df;
  --paper-strong: #fffaf0;
  --ink: #1e3a34;
  --muted: #6c7168;
  --line: rgba(30, 58, 52, 0.2);
  --green: #2f7f6f;
  --red: #d8582a;
  --gold: #d39a19;
  --shadow: 0 22px 60px rgba(44, 37, 22, 0.16);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(30, 58, 52, .045) 1px, transparent 1px) 0 0 / 28px 28px,
    linear-gradient(0deg, rgba(30, 58, 52, .035) 1px, transparent 1px) 0 0 / 28px 28px,
    var(--paper);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  letter-spacing: 0;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  content: "";
  background:
    radial-gradient(circle at 18% 12%, rgba(216, 88, 42, .11), transparent 28%),
    radial-gradient(circle at 83% 22%, rgba(47, 127, 111, .12), transparent 24%),
    linear-gradient(135deg, rgba(255, 250, 240, .7), rgba(247, 240, 223, .15));
}

a {
  color: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px clamp(16px, 4vw, 48px);
  border-bottom: 1px solid var(--line);
  background: rgba(247, 240, 223, .88);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.35rem;
  font-weight: 800;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 7px;
  color: var(--paper-strong);
  background: var(--ink);
  box-shadow: 4px 4px 0 var(--gold);
}

nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

nav a {
  padding: 9px 12px;
  border-radius: 7px;
  color: var(--muted);
  font-size: .94rem;
  font-weight: 700;
  text-decoration: none;
}

nav a:hover,
nav a.active {
  color: var(--ink);
  background: rgba(255, 250, 240, .72);
}

main {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: clamp(24px, 5vw, 54px) 0 72px;
}

.hero-shell {
  display: grid;
  grid-template-columns: minmax(0, .9fr) minmax(360px, 1.1fr);
  align-items: center;
  gap: clamp(28px, 5vw, 64px);
  min-height: calc(100vh - 120px);
}

.hero-copy,
.listing-hero {
  max-width: 710px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--red);
  font-size: .76rem;
  font-weight: 900;
  letter-spacing: .14em;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  letter-spacing: 0;
}

h1 {
  max-width: 830px;
  font-size: clamp(1.85rem, 4.5vw, 3.6rem);
  line-height: 1.05;
}

h2 {
  font-size: clamp(1.45rem, 3vw, 2.4rem);
  line-height: 1.05;
}

h3 {
  font-size: 1.05rem;
}

.lede {
  max-width: 650px;
  margin: 22px 0 0;
  color: #3e4a43;
  font-size: clamp(1.04rem, 2vw, 1.24rem);
  line-height: 1.58;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 28px;
}

.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 11px 16px;
  border: 2px solid var(--ink);
  border-radius: 7px;
  box-shadow: 4px 4px 0 rgba(30, 58, 52, .25);
  cursor: pointer;
  font: inherit;
  font-weight: 850;
  text-decoration: none;
  transition: transform .16s ease, box-shadow .16s ease;
}

.button:hover {
  transform: translate(-1px, -1px);
  box-shadow: 6px 6px 0 rgba(30, 58, 52, .25);
}

.button.primary {
  color: var(--paper-strong);
  background: var(--ink);
}

.button.secondary {
  color: var(--ink);
  background: var(--paper-strong);
}

.button.wide {
  width: 100%;
}

.hero-board {
  overflow: hidden;
  padding: clamp(14px, 2vw, 24px);
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--paper-strong);
  box-shadow: var(--shadow), 10px 10px 0 rgba(211, 154, 25, .34);
  transform: rotate(1.25deg);
}

.hero-board svg {
  display: block;
  width: 100%;
}

.section-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 24px;
}

.panel,
.tool-panel,
.ad-slot,
.skill-card,
.rail-card,
.standard-card,
.standards-panel,
.teacher-notes article,
.series-strip,
.level-node {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 240, .74);
}

.panel {
  padding: 22px;
}

.panel p,
.skill-card span,
.rail-card span,
.rail-card em {
  color: var(--muted);
  line-height: 1.5;
}

.listing-hero {
  padding: 30px 0 22px;
}

.standard-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 330px);
  gap: 18px;
  align-items: stretch;
  margin-bottom: 18px;
}

.standard-copy {
  padding: clamp(24px, 4vw, 42px);
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--paper-strong);
  box-shadow: var(--shadow);
}

.standard-copy h1 {
  font-size: clamp(1.7rem, 4vw, 3.2rem);
}

.standard-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 22px;
}

.standard-tags span {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(247, 240, 223, .84);
  color: var(--ink);
  font-size: .82rem;
  font-weight: 900;
}

.standard-card {
  display: grid;
  align-content: center;
  padding: 24px;
  border-color: var(--ink);
  background:
    linear-gradient(135deg, rgba(211, 154, 25, .24), rgba(255, 250, 240, .86));
}

.standard-card strong {
  display: block;
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.4rem, 5vw, 3.6rem);
  line-height: .9;
}

.standard-card span {
  display: block;
  margin-top: 12px;
  color: var(--muted);
  font-weight: 800;
}

.standards-panel,
.series-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 18px;
  padding: 20px;
}

.standards-panel p,
.series-strip p {
  max-width: 760px;
  color: var(--muted);
  line-height: 1.55;
}

.series-strip {
  border: 2px solid var(--ink);
  border-left: 12px solid var(--accent);
}

.episode-map {
  margin-top: 28px;
}

.level-map {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.level-node {
  position: relative;
  display: grid;
  min-height: 174px;
  gap: 8px;
  align-content: start;
  padding: 16px;
  overflow: hidden;
  color: var(--ink);
  text-decoration: none;
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}

.level-node::before {
  position: absolute;
  inset: 0;
  width: 9px;
  content: "";
  background: var(--accent);
}

.level-node:hover,
.level-node.active {
  border-color: var(--ink);
  box-shadow: 5px 5px 0 rgba(30, 58, 52, .16);
  transform: translate(-1px, -1px);
}

.node-number {
  display: inline-grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 7px;
  color: var(--paper-strong);
  background: var(--accent);
  font-weight: 950;
}

.level-node strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.25rem;
  line-height: 1;
}

.level-node em {
  color: var(--muted);
  font-style: normal;
  font-weight: 900;
  text-transform: uppercase;
}

.node-stars {
  margin-top: auto;
  color: var(--gold);
  font-size: 1.05rem;
  font-weight: 900;
}

.teacher-notes {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 26px;
}

.content-band {
  display: grid;
  gap: 16px;
  margin-top: 28px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 240, .8);
}

.content-band p {
  max-width: 900px;
  color: var(--muted);
  line-height: 1.58;
}

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

.content-columns article {
  padding: 18px;
  border: 1px solid rgba(30, 58, 52, .12);
  border-radius: 7px;
  background: rgba(247, 240, 223, .7);
}

.teacher-notes article {
  padding: 20px;
}

.teacher-notes p,
.standard-mini p,
.standard-mini span {
  color: var(--muted);
  line-height: 1.5;
}

.info-page {
  max-width: none;
  margin: 0 auto;
  padding: 34px 0 12px;
}

.info-sections {
  display: grid;
  gap: 14px;
  margin-top: 28px;
}

.info-sections article {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 240, .78);
}

.info-sections h2 {
  font-size: clamp(1.25rem, 2.4vw, 1.7rem);
}

.info-sections p {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.62;
}

.info-sections a {
  color: var(--ink);
  font-weight: 850;
  overflow-wrap: anywhere;
}

.site-footer {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto 24px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 240, .82);
}

.site-footer strong {
  display: block;
  margin-bottom: 6px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.2rem;
}

.site-footer p {
  max-width: 560px;
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.site-footer nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.site-footer nav a {
  padding: 7px 10px;
  border-radius: 7px;
  color: var(--muted);
  text-decoration: none;
  font-size: .9rem;
  font-weight: 700;
}

.site-footer nav a:hover {
  color: var(--ink);
  background: rgba(247, 240, 223, .9);
}

.standard-mini p {
  margin: 0 0 8px;
  color: var(--ink);
  font-weight: 900;
}

.skill-list {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  margin-top: 24px;
}

.skill-card {
  position: relative;
  display: grid;
  min-height: 210px;
  align-content: start;
  gap: 12px;
  padding: 18px;
  overflow: hidden;
  text-decoration: none;
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}

.skill-card::before {
  position: absolute;
  inset: 0;
  width: 8px;
  content: "";
  background: var(--accent);
}

.skill-card:hover,
.rail-card:hover {
  border-color: var(--ink);
  box-shadow: 5px 5px 0 rgba(30, 58, 52, .16);
  transform: translate(-1px, -1px);
}

.skill-card strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.55rem;
  line-height: 1;
}

.skill-card em {
  align-self: end;
  color: var(--accent);
  font-size: .86rem;
  font-style: normal;
  font-weight: 900;
  text-transform: uppercase;
}

.grade-mark {
  display: inline-grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 7px;
  color: var(--paper-strong);
  background: var(--accent);
  font-weight: 900;
}

.play-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 330px);
  gap: 18px;
  align-items: start;
}

.level-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}

.level-heading h1 {
  font-size: clamp(1.6rem, 3.5vw, 2.8rem);
}

.level-heading p:not(.eyebrow) {
  max-width: 620px;
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.level-statbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.level-statbar span {
  min-width: 88px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 250, 240, .8);
  color: var(--muted);
  font-size: .88rem;
  font-weight: 800;
  text-align: center;
}

.level-statbar b {
  color: var(--ink);
}

.game-shell {
  padding: clamp(10px, 2vw, 18px);
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--paper-strong);
  box-shadow: var(--shadow);
}

#maze-canvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 4px;
  touch-action: none;
}

.touch-pad {
  display: grid;
  grid-template-columns: repeat(3, 64px);
  grid-template-rows: repeat(3, 52px);
  gap: 6px;
  justify-content: center;
  margin-top: 12px;
}

.touch-pad button {
  border: 2px solid var(--ink);
  border-radius: 7px;
  color: var(--ink);
  background: #eadfca;
  cursor: pointer;
  font-size: 1.2rem;
  font-weight: 900;
  transition: background .1s ease, transform .1s ease;
}

.touch-pad button:active {
  background: #f7d37b;
  transform: scale(0.93);
}

.touch-pad [data-move="n"] { grid-column: 2; grid-row: 1; }
.touch-pad [data-move="w"] { grid-column: 1; grid-row: 2; }
.touch-pad [data-move="s"] { grid-column: 2; grid-row: 2; }
.touch-pad [data-move="e"] { grid-column: 3; grid-row: 2; }

.side-panel {
  display: grid;
  gap: 14px;
  position: sticky;
  top: 82px;
}

.ad-slot {
  display: grid;
  min-height: 94px;
  place-items: center;
  border-style: dashed;
  color: rgba(30, 58, 52, .52);
  font-size: .8rem;
  font-weight: 900;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.tool-panel {
  padding: 16px;
}

.tool-panel h2 {
  margin-bottom: 12px;
  font-size: 1.35rem;
}

.tool-panel .button + .button {
  margin-top: 10px;
}

.question-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.question-list li {
  padding: 10px;
  border: 1px solid rgba(30, 58, 52, .14);
  border-radius: 7px;
  background: rgba(247, 240, 223, .72);
}

.question-list span {
  display: block;
  color: var(--muted);
  font-size: .74rem;
  font-weight: 900;
  text-transform: uppercase;
}

.question-list strong {
  display: block;
  margin-top: 3px;
  font-size: .95rem;
}

.modal-layer {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(30, 58, 52, .48);
}

.modal-layer[hidden] {
  display: none;
}

.modal-card {
  position: relative;
  width: min(540px, 100%);
  padding: clamp(22px, 4vw, 34px);
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--paper-strong);
  box-shadow: 12px 12px 0 rgba(30, 58, 52, .24);
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 7px;
  color: var(--ink);
  background: #eadfca;
  cursor: pointer;
  font: inherit;
  font-size: 1.4rem;
  font-weight: 900;
  line-height: 1;
}

.modal-close:hover {
  background: #f7d37b;
}

.modal-card h2 {
  font-size: clamp(1.5rem, 4vw, 2.2rem);
}

.answer-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 22px;
}

.answer-choice {
  min-height: 58px;
  border: 2px solid var(--ink);
  border-radius: 7px;
  color: var(--ink);
  background: #eadfca;
  cursor: pointer;
  font: inherit;
  font-size: 1.15rem;
  font-weight: 900;
}

.answer-choice:hover {
  background: #f7d37b;
}

.hint-line {
  margin: 16px 0 0;
  color: var(--muted);
  font-weight: 700;
}

.shake {
  animation: shake .34s ease;
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-8px);
  }
  75% {
    transform: translateX(8px);
  }
}

.correct-flash {
  animation: correctPop .52s ease;
}

@keyframes correctPop {
  0% {
    transform: scale(1);
  }
  30% {
    transform: scale(1.04);
  }
  100% {
    transform: scale(1);
  }
}

.correct-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 18px;
  padding: 14px;
  border: 2px solid var(--green);
  border-radius: 8px;
  background: #d9eadf;
  color: #1a5c4a;
  font-size: 1.15rem;
  font-weight: 900;
}

.correct-badge .check-icon {
  display: inline-grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 50%;
  background: var(--green);
  color: #fffaf0;
  font-size: 1.1rem;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

.score-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 18px;
}

.score-grid span {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(247, 240, 223, .74);
  color: var(--muted);
  font-size: .86rem;
  font-weight: 800;
  text-align: center;
}

.score-grid b {
  display: block;
  color: var(--ink);
  font-size: 1.15rem;
}

.worksheet-section {
  margin-top: 28px;
}

.worksheet-paper {
  padding: clamp(18px, 3vw, 28px);
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: #fffdf5;
  box-shadow: var(--shadow);
}

.worksheet-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.worksheet-header span {
  color: var(--muted);
  font-weight: 900;
}

.worksheet-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(250px, .8fr);
  gap: 22px;
  margin-top: 20px;
}

.print-maze svg {
  display: block;
  width: 100%;
  border: 1px solid #111;
}

.print-questions {
  display: grid;
  align-content: start;
  gap: 10px;
}

.print-questions ol {
  margin: 0 0 8px;
  padding-left: 22px;
  line-height: 1.6;
}

.answer-key-sheet {
  margin-top: 18px;
}

.print-footer-note {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: .85rem;
  font-weight: 700;
}

.rail {
  margin-top: 34px;
}

.rail-heading {
  margin-bottom: 14px;
}

.rail-cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.rail-card {
  display: grid;
  gap: 6px;
  padding: 15px;
  border-left: 8px solid var(--accent);
  text-decoration: none;
}

.rail-card strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.2rem;
}

.rail-card em {
  font-style: normal;
  font-weight: 900;
}

@media (max-width: 980px) {
  .hero-shell,
  .standard-hero,
  .play-layout,
  .worksheet-grid {
    grid-template-columns: 1fr;
  }

  .hero-shell {
    min-height: auto;
  }

  .hero-board {
    transform: none;
  }

  .section-grid,
  .skill-list,
  .rail-cards,
  .level-map,
  .teacher-notes {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .standards-panel,
  .series-strip {
    align-items: start;
    flex-direction: column;
  }

  .content-columns {
    grid-template-columns: 1fr;
  }

  .side-panel {
    position: static;
  }
}

@media (max-width: 620px) {
  .site-header {
    align-items: start;
    flex-direction: column;
  }

  nav {
    width: 100%;
    justify-content: space-between;
  }

  nav a {
    padding-inline: 8px;
    font-size: .86rem;
  }

  main {
    width: min(100% - 20px, 1180px);
    padding-top: 22px;
  }

  .section-grid,
  .skill-list,
  .rail-cards,
  .level-map,
  .teacher-notes,
  .content-columns,
  .answer-grid,
  .score-grid {
    grid-template-columns: 1fr;
  }

  .site-footer {
    align-items: start;
    flex-direction: column;
    width: min(100% - 20px, 1180px);
  }

  .level-heading {
    align-items: start;
    flex-direction: column;
  }

  .level-statbar {
    justify-content: stretch;
    width: 100%;
  }

  .level-statbar span {
    flex: 1;
  }

  .touch-pad {
    grid-template-columns: repeat(3, 56px);
    grid-template-rows: repeat(3, 46px);
  }
}

@media print {
  body {
    background: #fff;
  }

  .site-header,
  .site-footer,
  .play-layout,
  .rail,
  .modal-layer,
  .hero-shell,
  .standard-hero,
  .episode-map,
  .standards-panel,
  .teacher-notes,
  .content-band,
  .series-strip,
  .section-grid,
  .listing-hero,
  .skill-list {
    display: none !important;
  }

  main {
    width: 100%;
    padding: 0;
  }

  .worksheet-section {
    margin: 0;
  }

  .worksheet-paper {
    padding: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .answer-key-sheet {
    margin-top: 0;
    break-before: page;
    page-break-before: always;
  }

  .print-footer-note {
    margin-top: 10px;
    color: #444;
    font-size: .78rem;
  }

  .worksheet-grid {
    grid-template-columns: 1.15fr .85fr;
  }
}
