: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 {
      min-height: var(--touch);
      display: grid;
      place-items: center;
      border: 1px solid var(--line);
      border-radius: var(--radius);
      background: #f8fbfd;
      font-weight: 800;
      color: var(--ink);
    }

    .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;
      transform-origin: top left;
    }

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

    .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);
      transform: scale(var(--wall-scale));
      transform-origin: top left;
      border-radius: var(--radius);
      background: rgba(255, 255, 255, 0.78);
      box-shadow: var(--shadow);
      padding: 12px;
    }

    .fraction-wall {
      display: grid;
      gap: var(--tile-gap);
      width: 100%;
    }

    .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(520px, 1fr) minmax(260px, 0.45fr);
      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 {
      min-height: 56px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      padding: 8px 12px;
      border: 1px solid var(--line);
      border-radius: var(--radius);
      background: #f8fbfd;
      min-width: 0;
    }

    .selection-text {
      min-width: 0;
      font-size: 0.95rem;
      color: var(--muted);
    }

    .selection-text strong {
      color: var(--ink);
      font-size: 1.2rem;
    }

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

    .print-logo {
      display: none;
    }

    .print-copyright {
      display: none;
    }

    .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 print {
      body {
        overflow: visible;
        background: #ffffff;
      }

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

      .app {
        display: block;
        height: auto;
      }

      .workspace {
        overflow: visible;
        padding: 0;
        background: #ffffff;
      }

      .stage {
        min-width: 0;
        width: 100%;
        margin: 0;
      }

      .teacher-strip {
        display: none;
      }

      .wall-shell {
        transform: none;
        width: 100%;
        box-shadow: none;
        border: 1px solid #000;
      }

      .print-logo {
        display: block;
        width: 150px;
        margin-bottom: 12px;
      }

      .print-copyright {
        display: block;
        margin-top: 12px;
        color: #000000;
        font-size: 11pt;
        font-weight: 700;
        text-align: right;
      }
    }
