:root {
      --blue: #149bd7;
      --ink: #102131;
      --muted: #5c6b78;
      --paper: #fbfcfe;
      --panel: #ffffff;
      --line: #d8e2ea;
      --shadow: 0 12px 32px rgba(15, 33, 49, 0.12);
      --tile-gap: 4px;
      --wall-scale: 1;
      --wall-width: 1120px;
      --radius: 8px;
      --touch: 48px;
    }

    * {
      box-sizing: border-box;
    }

    html,
    body {
      min-height: 100%;
      margin: 0;
      color: var(--ink);
      background: #eef4f8;
      font-family: Arial, Helvetica, sans-serif;
      letter-spacing: 0;
      touch-action: manipulation;
    }

    body {
      overflow: hidden;
    }

    button,
    input,
    select {
      font: inherit;
    }

    button {
      min-height: var(--touch);
      border: 2px solid transparent;
      border-radius: var(--radius);
      background: #ffffff;
      color: var(--ink);
      cursor: pointer;
      user-select: none;
      -webkit-tap-highlight-color: transparent;
    }

    button:focus-visible,
    select:focus-visible,
    input:focus-visible {
      outline: 4px solid rgba(20, 155, 215, 0.35);
      outline-offset: 2px;
    }

    .app {
      display: grid;
      grid-template-rows: auto auto 1fr;
      height: 100vh;
      height: 100dvh;
      min-width: 320px;
    }

    .topbar {
      display: grid;
      grid-template-columns: minmax(190px, 1fr) auto;
      align-items: center;
      gap: 16px;
      padding: 12px 18px;
      background: #071018;
      color: #ffffff;
    }

    .brand {
      display: flex;
      align-items: center;
      gap: 14px;
      min-width: 0;
    }

    .brand img {
      width: 142px;
      height: auto;
      display: block;
      object-fit: contain;
      flex: 0 0 auto;
    }

    
  .brand-logo {
    display: inline-flex;
    border-radius: 6px;
  }

  .brand-logo:focus-visible {
    outline: 4px solid rgba(20, 155, 215, 0.35);
    outline-offset: 3px;
  }

  .home-button {
    min-height: var(--touch, 48px);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 14px;
    border: 2px solid #263d51;
    border-radius: 8px;
    background: #122436;
    color: #ffffff;
    text-decoration: none;
    font-weight: 800;
    white-space: nowrap;
  }

  .home-button:hover,
  .home-button:focus-visible {
    background: var(--blue, #149bd7);
    border-color: #8fd8f3;
    color: #06111a;
  }.title-block {
      min-width: 0;
    }

    h1 {
      margin: 0;
      font-size: clamp(1.35rem, 2vw, 2.05rem);
      line-height: 1.05;
      font-weight: 800;
    }
.top-actions {
      display: flex;
      gap: 8px;
      align-items: center;
      justify-content: end;
      flex-wrap: wrap;
    }

    .icon-button {
      width: var(--touch);
      padding: 0;
      display: inline-grid;
      place-items: center;
      background: #122436;
      color: #ffffff;
      border-color: #263d51;
    }

    .icon-button:hover,
    .icon-button[aria-pressed="true"] {
      background: var(--blue);
      border-color: #8fd8f3;
      color: #06111a;
    }

    .icon {
      width: 24px;
      height: 24px;
      display: block;
      pointer-events: none;
    }

    .toolbar {
      display: grid;
      grid-template-columns: minmax(310px, 1.2fr) minmax(290px, 1fr) auto;
      gap: 12px;
      align-items: stretch;
      padding: 12px 18px;
      background: #ffffff;
      border-bottom: 1px solid var(--line);
      box-shadow: 0 6px 14px rgba(15, 33, 49, 0.06);
      z-index: 3;
    }

    .control-group {
      display: flex;
      align-items: center;
      gap: 8px;
      min-width: 0;
      flex-wrap: wrap;
    }

    .control-label {
      color: var(--muted);
      font-weight: 700;
      font-size: 0.9rem;
    }

    .segmented {
      display: inline-grid;
      grid-auto-flow: column;
      grid-auto-columns: 1fr;
      border: 1px solid var(--line);
      border-radius: var(--radius);
      overflow: hidden;
      background: #edf4f8;
    }

    .segmented button {
      min-width: 72px;
      border: 0;
      border-radius: 0;
      background: transparent;
      color: var(--ink);
      padding: 0 12px;
      font-weight: 800;
    }

    .segmented button[aria-pressed="true"] {
      background: var(--blue);
      color: #06111a;
    }

    .wide-button {
      padding: 0 14px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
      border-color: var(--line);
      font-weight: 800;
      background: #f8fbfd;
      white-space: nowrap;
    }

    .wide-button:hover,
    .wide-button[aria-pressed="true"] {
      border-color: var(--blue);
      background: #e5f6fc;
    }

    .zoom-set {
      display: inline-grid;
      grid-template-columns: var(--touch) minmax(86px, 1fr) var(--touch);
      align-items: center;
      gap: 6px;
      min-width: 190px;
    }

    .zoom-readout {
      display: none;
    }

    .workspace {
      min-height: 0;
      overflow: auto;
      overscroll-behavior: contain;
      padding: 18px;
      background:
        linear-gradient(#dce8f0 1px, transparent 1px),
        linear-gradient(90deg, #dce8f0 1px, transparent 1px);
      background-size: 34px 34px;
    }

    .stage {
      min-width: var(--wall-width);
      width: max-content;
      margin: 0 auto;
    }

    .teacher-strip {
      display: grid;
      grid-template-columns: minmax(360px, 1fr) auto;
      align-items: center;
      gap: 12px;
      width: var(--wall-width);
      margin-bottom: 12px;
      zoom: var(--wall-scale);
    }

    .callout {
      min-height: 64px;
      display: flex;
      align-items: center;
      gap: 12px;
      padding: 10px 14px;
      border: 2px solid #b9d7e5;
      border-radius: var(--radius);
      background: rgba(255, 255, 255, 0.92);
      box-shadow: 0 8px 18px rgba(15, 33, 49, 0.08);
    }

    .callout strong {
      display: block;
      font-size: clamp(1rem, 1.4vw, 1.25rem);
      line-height: 1.1;
    }

    .callout span {
      color: var(--muted);
      font-size: 0.92rem;
    }

    .prompt-fraction {
      min-width: 70px;
      min-height: 44px;
      padding: 6px 10px;
      display: inline-grid;
      place-items: center;
      border-radius: 6px;
      background: var(--ink);
      color: #ffffff;
      font-size: 1.35rem;
      font-weight: 900;
    }

    .challenge-actions {
      display: flex;
      gap: 8px;
      align-items: center;
    }

    .wall-shell {
      width: var(--wall-width);
      zoom: var(--wall-scale);
      border-radius: var(--radius);
      background: rgba(255, 255, 255, 0.78);
      box-shadow: var(--shadow);
      padding: 12px;
    }

    .fraction-wall {
      display: block;
      width: 100%;
    }

    .fraction-wall .fraction-wall-model {
      width: 100%;
      margin: 0;
    }

    #fraction-wallModel[data-fraction-wall-ready="false"] .fraction-wall-model {
      visibility: hidden;
    }

    .fraction-wall .fraction-wall-model > figcaption {
      position: absolute;
      width: 1px;
      height: 1px;
      padding: 0;
      margin: -1px;
      overflow: hidden;
      clip: rect(0, 0, 0, 0);
      white-space: nowrap;
      border: 0;
    }

    .fraction-wall .interactive-fraction-wall-visual {
      display: block;
      width: 100%;
      height: auto;
    }

    .wall-row {
      min-height: 58px;
    }

    .pieces {
      display: grid;
      gap: var(--tile-gap);
      min-width: 0;
    }

    .piece {
      position: relative;
      min-width: 0;
      min-height: 58px;
      border: 2px solid rgba(6, 17, 26, 0.24);
      border-radius: 6px;
      background: var(--tile-colour);
      color: #06111a;
      display: grid;
      place-items: center;
      overflow: hidden;
      padding: 4px;
      box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.08);
    }

    .piece::after {
      content: "";
      position: absolute;
      inset: 0;
      background: linear-gradient(160deg, rgba(255, 255, 255, 0.42), rgba(255, 255, 255, 0));
      pointer-events: none;
    }

    .piece-label {
      position: relative;
      z-index: 1;
      display: grid;
      justify-items: center;
      gap: 1px;
      width: 100%;
      line-height: 1;
      font-weight: 900;
      text-align: center;
      text-wrap: balance;
    }

    .fraction {
      display: inline-grid;
      grid-template-rows: auto 2px auto;
      gap: 2px;
      align-items: center;
      justify-items: center;
      min-width: 22px;
      font-size: clamp(0.82rem, 1.22vw, 1.08rem);
    }

    .fraction .bar {
      width: 100%;
      min-width: 18px;
      height: 2px;
      background: currentColor;
    }

    .decimal,
    .percent {
      font-size: clamp(0.72rem, 1vw, 0.92rem);
      font-weight: 800;
      opacity: 0.92;
    }

    .piece.is-selected {
      border-color: #071018;
      box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.12), 0 0 0 4px rgba(20, 155, 215, 0.32);
      z-index: 2;
    }

    .piece.is-equivalent {
      border-color: #071018;
      filter: saturate(1.12);
      box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.1), 0 0 0 4px rgba(255, 216, 77, 0.72);
      z-index: 1;
    }

    .piece.is-dimmed {
      opacity: 0.28;
    }

    .piece.is-covered .piece-label {
      visibility: hidden;
    }

    .piece.is-covered::before {
      content: "?";
      position: absolute;
      inset: 6px;
      z-index: 2;
      display: grid;
      place-items: center;
      border-radius: 5px;
      background: rgba(255, 255, 255, 0.82);
      color: var(--ink);
      font-size: 1.35rem;
      font-weight: 900;
    }

    .side-panel {
      display: grid;
      grid-template-columns: minmax(0, 1fr);
      gap: 12px;
      padding: 12px 18px;
      background: #ffffff;
      border-top: 1px solid var(--line);
      box-shadow: 0 -6px 14px rgba(15, 33, 49, 0.06);
      z-index: 4;
    }

    .denominator-bank {
      display: flex;
      align-items: center;
      gap: 7px;
      min-width: 0;
      overflow-x: auto;
      padding-bottom: 2px;
      scrollbar-width: thin;
    }

    .denominator-bank .control-label {
      flex: 0 0 auto;
    }

    .den-button {
      flex: 0 0 var(--touch);
      width: var(--touch);
      padding: 0;
      border-color: var(--line);
      font-weight: 900;
      background: #f8fbfd;
    }

    .den-button[aria-pressed="true"] {
      background: var(--blue);
      border-color: #0d75a2;
      color: #06111a;
    }

    .selection-panel {
      display: none;
    }

    .copyright {
      white-space: nowrap;
      color: var(--muted);
      font-size: 0.84rem;
      font-weight: 700;
    }

    .print-logo {
      display: none;
    }

    .print-copyright {
      display: none;
    }

    .fraction-wall-page-print-logo,
    .fraction-wall-page-print-copyright {
      display: none;
    }

    .fraction-wall-worksheet {
      display: none;
    }

    .worksheet-toolbar-button {
      margin-left: auto;
    }

    .instructions-dialog.worksheet-print-dialog {
      width: min(620px, calc(100vw - 24px));
      max-height: min(760px, calc(100vh - 24px));
    }

    .worksheet-print-form {
      display: grid;
      min-width: 0;
    }

    .worksheet-print-options {
      display: grid;
      gap: 14px;
    }

    .worksheet-print-options > p {
      margin: 0;
      color: var(--muted);
      font-weight: 700;
    }

    .worksheet-option-group {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 10px;
      margin: 0;
      padding: 12px;
      border: 2px solid var(--line);
      border-radius: var(--radius);
    }

    .worksheet-option-group legend {
      padding: 0 6px;
      color: var(--ink);
      font-weight: 900;
    }

    .worksheet-option {
      min-height: 72px;
      display: grid;
      grid-template-columns: auto minmax(0, 1fr);
      gap: 10px;
      align-items: center;
      padding: 10px;
      border: 2px solid var(--line);
      border-radius: var(--radius);
      background: #f8fbfd;
      cursor: pointer;
    }

    .worksheet-option:has(input:checked) {
      border-color: var(--blue);
      background: #e9f7fd;
    }

    .worksheet-option input {
      width: 22px;
      height: 22px;
      margin: 0;
      accent-color: var(--blue);
    }

    .worksheet-option span,
    .worksheet-option small {
      display: block;
    }

    .worksheet-option small {
      margin-top: 3px;
      color: var(--muted);
      line-height: 1.25;
    }

    .worksheet-print-actions {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 10px;
    }

    .instructions-dialog {
      width: min(820px, calc(100vw - 32px));
      max-height: min(780px, calc(100vh - 32px));
      border: 0;
      border-radius: var(--radius);
      padding: 0;
      color: var(--ink);
      background: #ffffff;
      box-shadow: 0 24px 70px rgba(6, 17, 26, 0.32);
    }

    .instructions-dialog::backdrop {
      background: rgba(6, 17, 26, 0.5);
    }

    .instructions-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      padding: 14px 16px;
      background: #071018;
      color: #ffffff;
    }

    .instructions-header h2 {
      margin: 0;
      font-size: 1.25rem;
      line-height: 1.15;
    }

    .instructions-body {
      max-height: calc(min(780px, 100vh - 32px) - 76px);
      overflow: auto;
      padding: 16px 18px 20px;
      line-height: 1.45;
    }

    .instructions-body h3 {
      margin: 16px 0 8px;
      font-size: 1.05rem;
    }

    .instructions-body h3:first-child {
      margin-top: 0;
    }

    .instructions-body p,
    .instructions-body ul,
    .instructions-body ol {
      margin: 0 0 10px;
    }

    .instructions-body li {
      margin-bottom: 6px;
    }

    .instructions-body strong {
      color: #06111a;
    }

    @media (max-width: 920px) {
      body {
        overflow: auto;
      }

      .app {
        min-height: 100vh;
        height: auto;
        grid-template-rows: auto auto minmax(520px, 1fr) auto;
      }

      .topbar,
      .toolbar,
      .side-panel {
        grid-template-columns: 1fr;
      }

      .top-actions,
      .toolbar .control-group {
        justify-content: start;
      }

      .brand img {
        width: 116px;
      }
.workspace {
        padding: 12px;
      }

      .side-panel {
        position: sticky;
        bottom: 0;
      }

      .instructions-dialog {
        width: calc(100vw - 20px);
        max-height: calc(100vh - 20px);
      }
    }

    @media (max-width: 520px) {
      .toolbar {
        padding: 10px 12px;
      }

      .toolbar .control-group {
        width: 100%;
        align-items: stretch;
      }

      .toolbar .control-label {
        flex: 0 0 100%;
      }

      .segmented {
        width: 100%;
        grid-auto-columns: minmax(0, 1fr);
      }

      .segmented button {
        min-width: 0;
        padding: 0 5px;
        font-size: 0.78rem;
      }

      .worksheet-option-group,
      .worksheet-print-actions {
        grid-template-columns: minmax(0, 1fr);
      }
    }

    @media print {
      @page {
        size: A4 portrait;
        margin: 8mm;
      }

      @page fraction-wall-print {
        size: A4 portrait;
        margin: 8mm;
      }

      @page fraction-wall-worksheet-portrait {
        size: A4 portrait;
        margin: 8mm;
      }

      @page fraction-wall-worksheet-landscape {
        size: A4 landscape;
        margin: 8mm;
      }

      html[data-spire-print-page="a4-portrait"],
      html[data-spire-print-page="a4-portrait"] body {
        page: fraction-wall-print;
        width: 194mm !important;
        height: 281mm !important;
        min-height: 0 !important;
        max-height: 281mm !important;
        margin: 0 !important;
        overflow: hidden !important;
      }

      html[data-spire-print-page="fraction-wall-portrait"],
      html[data-spire-print-page="fraction-wall-portrait"] body {
        page: fraction-wall-worksheet-portrait;
        width: 194mm !important;
        height: 281mm !important;
        min-height: 0 !important;
        max-height: 281mm !important;
        margin: 0 !important;
        overflow: hidden !important;
      }

      html[data-spire-print-page="fraction-wall-landscape"],
      html[data-spire-print-page="fraction-wall-landscape"] body {
        page: fraction-wall-worksheet-landscape;
        width: 281mm !important;
        height: 194mm !important;
        min-height: 0 !important;
        max-height: 194mm !important;
        margin: 0 !important;
        overflow: hidden !important;
      }

      body {
        overflow: visible;
        background: #ffffff;
      }

      .topbar,
      .toolbar,
      .side-panel {
        display: none;
      }

      .app {
        display: grid;
        grid-template-rows: auto minmax(0, 1fr) auto;
        gap: 4mm;
        width: 100% !important;
        height: 281mm !important;
        min-height: 0 !important;
        max-height: 281mm !important;
        overflow: hidden !important;
        break-inside: avoid-page;
        page-break-inside: avoid;
      }

      .workspace {
        width: 100%;
        height: auto;
        min-height: 0;
        overflow: hidden;
        padding: 0;
        background: #ffffff;
      }

      .stage {
        display: block;
        min-width: 0 !important;
        min-height: 0 !important;
        width: 100% !important;
        height: 100% !important;
        margin: 0;
        overflow: hidden;
      }

      .teacher-strip {
        display: none;
      }

      #fraction-wallModel .print-logo,
      #fraction-wallModel .print-copyright {
        display: none !important;
      }

      .fraction-wall-page-print-logo {
        display: block;
        width: 34mm;
        height: auto;
        margin: 0;
        object-fit: contain;
      }

      .fraction-wall-page-print-copyright {
        display: block;
        margin: 0;
        color: #000000;
        font-size: 8pt;
        font-weight: 700;
        text-align: right;
      }

      .wall-shell {
        transform: none;
        zoom: 1;
        width: 100%;
        min-height: 0;
        height: 100%;
        padding: 3mm;
        display: grid;
        place-items: center;
        overflow: hidden;
        box-shadow: none;
        border: 1px solid #000;
      }

      .fraction-wall,
      .fraction-wall .fraction-wall-model {
        width: 100%;
        height: 100%;
        min-height: 0;
      }

      .fraction-wall .fraction-wall-model {
        display: grid;
        place-items: center;
      }

      .fraction-wall .interactive-fraction-wall-visual {
        width: 100% !important;
        height: 100% !important;
        max-width: none;
        max-height: none;
        margin: 0;
      }

      .print-logo {
        display: block;
        width: 34mm;
        margin: 0;
      }

      .print-copyright {
        display: block;
        margin: 0;
        color: #000000;
        font-size: 8pt;
        font-weight: 700;
        text-align: right;
      }

      body[data-fraction-print-mode="worksheet"] .app,
      body[data-fraction-print-mode="worksheet"] dialog,
      body[data-fraction-print-mode="worksheet"] .spire-shared-print-logo,
      body[data-fraction-print-mode="worksheet"] .spire-shared-print-copyright {
        display: none !important;
      }

      body[data-fraction-print-mode="worksheet"] .fraction-wall-worksheet {
        width: 100%;
        min-width: 0;
        min-height: 0;
        display: grid;
        gap: 6mm;
        overflow: hidden;
        break-inside: avoid-page;
        page-break-inside: avoid;
      }

      body[data-fraction-print-layout="single"] .fraction-wall-worksheet {
        height: 281mm;
        grid-template-columns: minmax(0, 1fr);
      }

      body[data-fraction-print-layout="double"] .fraction-wall-worksheet {
        height: 194mm;
        grid-template-columns: repeat(2, minmax(0, 1fr));
      }

      .fraction-wall-worksheet-copy {
        min-width: 0;
        min-height: 0;
        height: 100%;
        display: grid;
        grid-template-rows: auto minmax(0, 1fr) auto;
        gap: 3mm;
        padding: 3mm;
        overflow: hidden;
        border: 1px solid #000000;
        background: #ffffff;
        break-inside: avoid-page;
        page-break-inside: avoid;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
      }

      .fraction-wall-worksheet-brand {
        min-height: 0;
      }

      .fraction-wall-worksheet-brand img {
        display: block;
        width: 30mm;
        height: auto;
        margin: 0;
      }

      body[data-fraction-print-layout="double"] .fraction-wall-worksheet-brand img {
        width: 24mm;
      }

      .fraction-wall-worksheet-model-frame,
      .fraction-wall-worksheet-model {
        min-width: 0;
        min-height: 0;
        width: 100%;
        height: 100%;
        margin: 0;
        overflow: hidden;
      }

      .fraction-wall-worksheet-model-frame,
      .fraction-wall-worksheet-model {
        display: grid;
        place-items: center;
      }

      .fraction-wall-worksheet-model > figcaption {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
      }

      .fraction-wall-worksheet-model > svg {
        display: block;
        width: 100% !important;
        height: 100% !important;
        max-width: none !important;
        max-height: none !important;
      }

      .fraction-wall-worksheet-copyright {
        color: #000000;
        font-size: 8pt;
        font-weight: 700;
        text-align: right;
      }

      .fraction-wall-worksheet[data-print-style="outline"] .fraction-wall-piece {
        opacity: 1 !important;
        filter: none !important;
      }

      .fraction-wall-worksheet[data-print-style="outline"] .fraction-wall-cell {
        fill: #ffffff !important;
        stroke: #000000 !important;
        stroke-width: 1.4 !important;
        filter: none !important;
      }

      .fraction-wall-worksheet[data-print-style="outline"] svg text {
        fill: #000000 !important;
      }

      .fraction-wall-worksheet[data-print-style="outline"] .fraction-wall-cover-label {
        stroke: #ffffff !important;
      }
    }
