@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Space+Grotesk:wght@400;500;600;700&display=swap');
:root {
  --ink: #23364f;
  --blue: #2563eb;
  --muted: #8090a4;
  --line: #dce5ef;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: #f6f8fb;
  color: var(--ink);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
}
button,
a {
  -webkit-tap-highlight-color: transparent;
}
button {
  font: inherit;
  cursor: pointer;
}
button:disabled {
  opacity: 0.4;
  cursor: default;
}
button:focus-visible,
a:focus-visible {
  outline: 3px solid #6692f1;
  outline-offset: 4px;
}
header {
  height: 82px;
  max-width: 1280px;
  margin: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding: 0 32px;
}
.brand {
  font-size: 24px;
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
  letter-spacing: -1px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand-icon {
  background: #2563eb;
  color: white;
  border-radius: 10px;
  width: 29px;
  height: 29px;
  font-size: 28px;
  line-height: 26px;
}
.brand small {
  font-size: 15px;
  color: #8c9caf;
  font-weight: 400;
  letter-spacing: 0;
}
.header-note {
  font-size: 9px;
  letter-spacing: 2px;
  color: var(--muted);
}
.quiet {
  border: 0;
  background: none;
  color: #68809f;
  font-size: 12px;
  padding: 8px;
}
.quiet:hover {
  color: var(--blue);
}
header .quiet span {
  display: inline-grid;
  place-items: center;
  border: 1px solid #c4d4e7;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  margin-left: 7px;
}
main {
  max-width: 1150px;
  margin: auto;
  padding: 0 30px;
}
.intro {
  margin: 42px 0 30px;
}
.eyebrow {
  font-size: 9px;
  letter-spacing: 2px;
  font-weight: 700;
  color: #8495aa;
}
.intro h1 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 54px;
  letter-spacing: -3px;
  font-weight: 500;
  margin: 12px 0 13px;
  line-height: 1.05;
}
h1 span {
  color: var(--blue);
}
.intro > p:last-child {
  font-size: 14px;
  color: #8794a5;
}
.workshop {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 30px;
}
.bench {
  background: #edf3fa;
  border: 1px solid #dce6f2;
  border-radius: 18px;
  overflow: hidden;
}
.bench-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 28px 0;
}
.bench-top h2 {
  font-size: 20px;
  font-weight: 500;
  letter-spacing: -0.6px;
  margin: 8px 0 0;
}
.difficulty {
  border: 1px solid #d4e0ef;
  background: #f4f8fd;
  padding: 7px 12px;
  border-radius: 30px;
  font-size: 10px;
  color: #7890ad;
}
.canvas-wrap {
  position: relative;
  max-width: 610px;
  margin: auto;
  background-image: radial-gradient(#c8d6e7 0.8px, transparent 0.8px);
  background-size: 22px 22px;
  background-position: center;
}
#scene {
  display: block;
  width: 100%;
  max-height: 520px;
  touch-action: pan-y;
  overflow: visible;
}
.part {
  cursor: pointer;
  filter: url(#shadow);
  outline: none;
  transform-box: view-box;
  transform-origin: var(--cx) var(--cy);
  transition: filter 0.16s;
}
.part:hover {
  filter: url(#shadow) brightness(1.06);
}
.part:focus-visible {
  filter: drop-shadow(0 0 6px #2563eb);
}
.part text {
  pointer-events: none;
  user-select: none;
}
.part.shake {
  animation: shake 0.32s;
}
.part.leaving {
  animation: leave 0.42s ease-in forwards;
  pointer-events: none;
}
.part.hint {
  animation: hint 1s ease-in-out 3;
}
.corner {
  position: absolute;
  width: 13px;
  height: 13px;
  border-color: #afc3dc;
  pointer-events: none;
}
.tl {
  top: 22px;
  left: 26px;
  border-top: 1px solid;
  border-left: 1px solid;
}
.tr {
  top: 22px;
  right: 26px;
  border-top: 1px solid;
  border-right: 1px solid;
}
.bl {
  bottom: 22px;
  left: 26px;
  border-bottom: 1px solid;
  border-left: 1px solid;
}
.br {
  bottom: 22px;
  right: 26px;
  border-bottom: 1px solid;
  border-right: 1px solid;
}
.bench-bottom {
  border-top: 1px solid #dce6f2;
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 22px;
  font-size: 11px;
  color: #6c829f;
}
.bench-bottom > span {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 75%;
}
.live-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #6692f1;
  flex-shrink: 0;
}
.bench-bottom .quiet {
  white-space: nowrap;
  font-size: 11px;
}
aside {
  padding: 10px 0;
  display: flex;
  flex-direction: column;
}
.count {
  display: flex;
  gap: 10px;
  align-items: baseline;
  margin: 14px 0;
}
.count strong {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 42px;
  font-weight: 500;
  letter-spacing: -2px;
}
.count > span {
  font-size: 12px;
  color: #8d9baf;
}
.progress {
  height: 3px;
  border-radius: 3px;
  background: #e2e9f3;
  overflow: hidden;
}
.progress > div {
  height: 100%;
  background: #6692f1;
  transition: width 0.3s;
}
.tray {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 9px;
  margin: 23px 0 26px;
}
.tray-cell {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 1px dashed #d7e0ed;
  border-radius: 10px;
  color: #bcc9d9;
  font-size: 24px;
  overflow: hidden;
}
.tray-cell svg {
  width: 90%;
  height: 90%;
}
.tray-cell.collected {
  border: 1px solid #d8e4f4;
  background: #edf3fc;
  animation: pop 0.25s ease-out;
}
.discovery {
  border-top: 1px solid var(--line);
  padding: 24px 0;
}
.discovery h3 {
  font-size: 17px;
  font-weight: 500;
  margin: 15px 0 10px;
  letter-spacing: -0.4px;
}
.discovery p {
  font-size: 12px;
  line-height: 1.8;
  color: #8593a7;
  margin: 0;
}
.aside-bottom {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--line);
  padding-top: 12px;
  font-size: 9px;
  color: #97a4b7;
}
.aside-bottom .quiet {
  font-size: 10px;
  padding-right: 0;
}
.shelf {
  margin-top: 34px;
}
.shelf-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}
.shelf-label > span:last-child {
  font-size: 11px;
  color: #94a0b2;
}
.level-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.level {
  display: flex;
  text-align: left;
  align-items: center;
  gap: 14px;
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 12px;
  padding: 17px 16px;
  color: var(--ink);
  transition: background 0.15s;
}
.level:hover {
  background: #edf3fb;
}
.level.active {
  border-color: #9bbaf1;
  background: #edf3ff;
}
.level-symbol {
  font-family: 'Space Grotesk', sans-serif;
  color: #7198d4;
  background: #e5edf8;
  border-radius: 9px;
  width: 39px;
  height: 45px;
  display: grid;
  place-items: center;
  font-size: 26px;
  flex-shrink: 0;
}
.level small {
  font-size: 8px;
  letter-spacing: 1.5px;
  color: #91a0b5;
  display: block;
  margin-bottom: 6px;
}
.level b {
  font-size: 13px;
  font-weight: 500;
  display: block;
}
.level em {
  display: none;
}
.level-check {
  margin-left: auto;
  font-size: 11px;
  color: #91a6c4;
}
.level.active .level-check {
  color: #2563eb;
}
footer {
  display: flex;
  justify-content: space-between;
  margin-top: 35px;
  border-top: 1px solid var(--line);
  padding: 23px 0;
  color: #99a5b6;
  font-size: 10px;
}
.complete {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  background: #edf3faee;
  padding: 25px;
}
.complete[hidden] {
  display: none;
}
.complete-icon {
  font-size: 30px;
  width: 64px;
  height: 64px;
  border: 1px solid #a6c2ed;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #2563eb;
  margin-bottom: 18px;
}
.complete h2 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 29px;
  letter-spacing: -1px;
  font-weight: 500;
  margin: 10px 0;
}
.complete > p:not(.eyebrow) {
  font-size: 12px;
  color: #8193aa;
  margin-bottom: 25px;
}
.primary {
  border: 0;
  background: #2563eb;
  color: white;
  border-radius: 8px;
  padding: 13px 22px;
  font-size: 12px;
}
.complete .quiet {
  margin-top: 12px;
}
dialog {
  border: 1px solid #d6e3f4;
  border-radius: 18px;
  max-width: 440px;
  width: calc(100% - 32px);
  padding: 32px;
  color: var(--ink);
  background: #f6f9ff;
}
dialog::backdrop {
  background: #22365266;
  backdrop-filter: blur(4px);
}
dialog h2 {
  font-size: 26px;
  letter-spacing: -1px;
  font-weight: 500;
}
dialog p {
  line-height: 1.7;
  font-size: 13px;
  color: #71859f;
}
dialog .primary {
  margin-top: 10px;
}
.close {
  position: absolute;
  right: 15px;
  top: 12px;
  font-size: 25px;
}
.muted {
  font-size: 11px !important;
}
@keyframes leave {
  0% {
    opacity: 1;
    transform: translate(0, 0) rotate(0) scale(1);
  }
  35% {
    opacity: 1;
    transform: translate(0, -12px) rotate(0) scale(1.05);
  }
  100% {
    opacity: 0;
    transform: translate(var(--fly-x), -90px) rotate(var(--fly-rotate)) scale(0.65);
  }
}
@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25%,
  75% {
    transform: translateX(-3px);
  }
  50% {
    transform: translateX(3px);
  }
}
@keyframes hint {
  50% {
    filter: drop-shadow(0 0 9px #2563eb) brightness(1.2);
  }
}
@keyframes pop {
  0% {
    transform: scale(0.8);
    opacity: 0.4;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}
@media (max-width: 760px) {
  header {
    height: 65px;
    padding: 0 20px;
  }
  .header-note {
    display: none;
  }
  main {
    padding: 0 18px;
    max-width: 590px;
  }
  .intro {
    margin: 27px 0 23px;
  }
  .intro h1 {
    font-size: 41px;
    letter-spacing: -2px;
  }
  .intro > p:last-child {
    font-size: 12px;
  }
  .workshop {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .bench-top {
    padding: 20px 18px 0;
  }
  .bench-top h2 {
    font-size: 18px;
  }
  .difficulty {
    font-size: 9px;
    padding: 6px 9px;
  }
  .canvas-wrap {
    max-width: 450px;
  }
  #scene {
    max-height: 440px;
  }
  .bench-bottom {
    padding: 10px 12px;
    font-size: 10px;
    gap: 5px;
  }
  .bench-bottom > span {
    max-width: 70%;
  }
  .bench-bottom .quiet {
    font-size: 10px;
    padding: 5px;
  }
  aside {
    padding: 0;
    display: grid;
    grid-template-columns: 100px 1fr;
    gap: 15px;
  }
  .count strong {
    font-size: 31px;
  }
  .count {
    margin: 7px 0;
  }
  .tray {
    grid-template-columns: repeat(8, 1fr);
    gap: 5px;
    margin: 0;
    align-content: center;
  }
  .tray-cell {
    border-radius: 5px;
  }
  .discovery {
    grid-column: 1/-1;
    padding: 14px 0 0;
  }
  .discovery h3 {
    margin: 8px 0 5px;
    font-size: 16px;
  }
  .discovery p {
    font-size: 11px;
  }
  .aside-bottom {
    grid-column: 1/-1;
    padding-top: 8px;
  }
  .shelf {
    margin-top: 25px;
  }
  .shelf-label > span:last-child {
    display: none;
  }
  .level-list {
    gap: 7px;
  }
  .level {
    display: block;
    padding: 12px 10px;
    position: relative;
  }
  .level-symbol {
    width: 30px;
    height: 34px;
    font-size: 23px;
    margin-bottom: 10px;
  }
  .level small {
    font-size: 7px;
  }
  .level b {
    font-size: 11px;
  }
  .level-check {
    position: absolute;
    right: 10px;
    top: 15px;
  }
  .complete h2 {
    font-size: 24px;
  }
  .complete .eyebrow {
    font-size: 8px;
  }
  footer {
    font-size: 8px;
    margin-top: 22px;
  }
  .brand {
    font-size: 22px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition: none !important;
  }
}

.part {
  touch-action: none;
}
.part.selected {
  filter: drop-shadow(0 0 4px #2563eb);
}
.part.sliding {
  animation: slide-out 0.42s ease-in forwards;
  pointer-events: none;
}
#scene:focus {
  outline: none;
}
.stats {
  font-size: 10px;
  color: #7a8da6;
  margin: -9px 0 20px;
}
.tray {
  margin-bottom: 20px;
}
@keyframes slide-out {
  0% {
    opacity: 1;
    transform: translate(0, 0);
  }
  70% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(var(--fly-x), var(--fly-y));
  }
}
@media (max-width: 760px) {
  .stats {
    grid-column: 1/-1;
    margin: 0;
  }
  .tray {
    grid-template-columns: repeat(6, 1fr);
    margin: 0;
  }
  .bench-top {
    gap: 10px;
  }
  .difficulty {
    white-space: nowrap;
  }
  .shelf-label .eyebrow {
    font-size: 8px;
  }
}
@media (max-width: 370px) {
}

.play-guide {
  margin: 18px 28px 0;
  padding: 10px 14px;
  border-radius: 9px;
  background: #dfeafd;
  color: #305b99;
  display: flex;
  flex-wrap: wrap;
  gap: 5px 12px;
  font-size: 11px;
  line-height: 1.5;
}
.play-guide b {
  font-weight: 600;
}
.play-guide span {
  color: #58769d;
}
.bench-bottom {
  font-size: 12px;
  color: #405f87;
}
.part:active {
  filter: drop-shadow(0 0 5px #6692f1);
}
@media (max-width: 760px) {
  .play-guide {
    margin: 14px 18px 0;
    font-size: 10px;
  }
  .bench-bottom {
    font-size: 11px;
  }
}

/* Larger workshop: frame each object tightly instead of shrinking it inside empty space. */
main {
  max-width: 1370px;
  padding: 0 24px;
}
.intro {
  margin: 24px 0 22px;
}
.intro h1 {
  font-size: 44px;
}
.workshop {
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 24px;
}
.canvas-wrap {
  max-width: none;
  width: 100%;
  margin: 12px auto 0;
}
#scene {
  height: 800px;
  max-height: none;
  width: 100%;
  overflow: hidden;
}
#scene[data-object='camera'] {
  height: 640px;
}
.bench-top h2 {
  font-size: 25px;
}
.eyebrow {
  font-size: 11px;
}
.play-guide {
  font-size: 13px;
}
.quiet {
  font-size: 14px;
}
.bench-bottom {
  font-size: 14px;
  min-height: 70px;
}
.bench-bottom .quiet {
  font-size: 14px;
  min-height: 44px;
}
.discovery h3 {
  font-size: 20px;
}
.discovery p {
  font-size: 14px;
}
.stats {
  font-size: 12px;
}
.tray {
  grid-template-columns: repeat(3, 1fr);
}
.corner {
  display: none;
}
@media (max-width: 1000px) {
  .workshop {
    grid-template-columns: minmax(0, 1fr) 220px;
    gap: 16px;
  }
  #scene {
    height: 720px;
  }
  .tray {
    gap: 7px;
  }
}
@media (max-width: 760px) {
  header {
    padding: 0 14px;
  }
  main {
    max-width: 660px;
    padding: 0 8px;
  }
  .intro {
    margin: 20px 10px;
  }
  .intro h1 {
    font-size: 36px;
  }
  .workshop {
    grid-template-columns: 1fr;
  }
  .bench {
    border-radius: 14px;
  }
  .bench-top {
    padding: 18px 14px 0;
  }
  .bench-top h2 {
    font-size: 22px;
  }
  .difficulty {
    font-size: 10px;
  }
  .play-guide {
    margin: 12px 10px 0;
    font-size: 12px;
    padding: 9px 10px;
  }
  .canvas-wrap {
    max-width: none;
    margin-top: 10px;
  }
  #scene {
    height: 570px;
    max-height: none;
  }
  #scene[data-object='camera'] {
    height: 360px;
  }
  #scene[data-object='rocket'] {
    height: 610px;
  }
  .bench-bottom {
    padding: 10px;
    font-size: 12px;
  }
  .bench-bottom .quiet {
    font-size: 12px;
    min-width: 100px;
  }
  .tray {
    grid-template-columns: repeat(4, 1fr);
    gap: 7px;
  }
  aside {
    margin: 0 8px;
    grid-template-columns: 90px 1fr;
  }
  .stats {
    font-size: 12px;
  }
  .shelf {
    margin: 24px 8px 0;
  }
  .discovery p {
    font-size: 13px;
  }
  .level b {
    font-size: 12px;
  }
  footer {
    margin-left: 8px;
    margin-right: 8px;
  }
}

/* Header links: "tapalog" goes to tapalog.com, "/ play" to the games page. */
.brand a {
  color: inherit;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
footer a {
  color: inherit;
}

/* Mistakes meter: four per object, the fourth snaps it back together. */
.bench-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}
.strikes {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  color: #7890ad;
}
.strikes small {
  font-size: 9px;
  letter-spacing: 1.6px;
}
.strikes b {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.pips {
  display: flex;
  gap: 4px;
}
.pips i {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1.5px solid #b9c9de;
  background: #f4f8fd;
  transition: background 0.2s, border-color 0.2s;
}
.pips i.used {
  border-color: #c2413b;
  background: #e0605a;
  box-shadow: inset 0 0 0 2px #fbe9e8;
}
.strikes.warn b {
  color: #c2413b;
}
.strikes.bump .pips {
  animation: shake 0.32s;
}
.snapped .complete-icon {
  color: #c2413b;
  border-color: #eab3af;
}
#scene.snap .part {
  animation: pop 0.35s ease-out;
}
@media (max-width: 760px) {
  .strikes small {
    display: none;
  }
}

/* Header: puzzle label (or help) and the theme toggle. */
.top-actions{display:flex;align-items:center;gap:14px}

/* Dark theme (data-theme=dark on <html>, set by /theme.js): generated from the light colours above —
   backgrounds flipped dark, text light, accents kept. Hand-tuned rules follow it. */
:root[data-theme=dark]{--ink:#d9e1eb;--blue:#2563eb;--muted:#738193;--line:#212a33}
:root[data-theme=dark] body{background:#11151a}
:root[data-theme=dark] button:focus-visible,:root[data-theme=dark] a:focus-visible{outline:3px solid #6692f1}
:root[data-theme=dark] .brand-icon{background:#2563eb}
:root[data-theme=dark] .brand small{color:#667588}
:root[data-theme=dark] .quiet{color:#7f90a6}
:root[data-theme=dark] header .quiet span{border:1px solid #2d3a49}
:root[data-theme=dark] .eyebrow{color:#6b7c90}
:root[data-theme=dark] .intro > p:last-child{color:#707d8d}
:root[data-theme=dark] .bench{background:#131a23;border:1px solid #1e2733}
:root[data-theme=dark] .difficulty{border:1px solid #232d3a;background:#0d151e;color:#6a809b}
:root[data-theme=dark] .canvas-wrap{background-image:radial-gradient(#2d3845 0.8px, transparent 0.8px)}
:root[data-theme=dark] .corner{border-color:#3c4a5c}
:root[data-theme=dark] .bench-bottom{border-top:1px solid #1e2733;color:#7e8ea3}
:root[data-theme=dark] .live-dot{background:#6692f1}
:root[data-theme=dark] .count > span{color:#667387}
:root[data-theme=dark] .progress{background:#1c232d}
:root[data-theme=dark] .progress > div{background:#6692f1}
:root[data-theme=dark] .tray-cell{border:1px dashed #242c37;color:#3c4652}
:root[data-theme=dark] .tray-cell.collected{border:1px solid #1d2836;background:#101824}
:root[data-theme=dark] .discovery p{color:#6e7c8f}
:root[data-theme=dark] .aside-bottom{color:#5d6a7c}
:root[data-theme=dark] .shelf-label > span:last-child{color:#626e80}
:root[data-theme=dark] .level:hover{background:#111924}
:root[data-theme=dark] .level.active{border-color:#2c436b;background:#0b1426}
:root[data-theme=dark] .level-symbol{color:#a0bae2;background:#161f2b}
:root[data-theme=dark] .level small{color:#5f6e83}
:root[data-theme=dark] .level-check{color:#506482}
:root[data-theme=dark] .level.active .level-check{color:#5d8bf0}
:root[data-theme=dark] footer{color:#5e6a7a}
:root[data-theme=dark] .complete{background:#131a23ee}
:root[data-theme=dark] .complete-icon{border:1px solid #2e4262;color:#5d8bf0}
:root[data-theme=dark] .complete > p:not(.eyebrow){color:#6b7d93}
:root[data-theme=dark] .primary{background:#2563eb}
:root[data-theme=dark] dialog{border:1px solid #1d2938;background:#09101e}
:root[data-theme=dark] dialog::backdrop{background:#d7dfeb66}
:root[data-theme=dark] dialog p{color:#7c8b9f}
:root[data-theme=dark] .stats{color:#728298}
:root[data-theme=dark] .play-guide{background:#111d31;color:#4277c4}
:root[data-theme=dark] .play-guide span{color:#8699b2}
:root[data-theme=dark] .bench-bottom{color:#9fb2ca}
:root[data-theme=dark] .strikes{color:#6a809b}
:root[data-theme=dark] .pips i{border:1.5px solid #384453;background:#0d151e}
:root[data-theme=dark] .pips i.used{border-color:#c2413b;background:#e0605a;box-shadow:inset 0 0 0 2px #281312}
:root[data-theme=dark] .strikes.warn b{color:#d16e69}
:root[data-theme=dark] .snapped .complete-icon{color:#d16e69;border-color:#5b322f}
/* Hand-tuned */
:root[data-theme=dark]{--blue:#4f86f7}

/* Narrow headers with the language toggle: the help button keeps only its "?", and a long hint wraps. */
.help-text{font-style:normal}
.brand small{white-space:nowrap}
@media(max-width:520px){
  header .quiet .help-text{display:none}
  .bench-bottom .quiet{white-space:normal;text-align:right}
}
