@font-face {
  font-family: Fredoka;
  src: url("fonts/Fredoka.ttf") format("truetype");
  font-weight: 300 700;
  font-display: swap;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  --page: #efece3; --ink: #173d38; --accent: #22584d; --mat: url("art/classic.webp");
  --cloth: #f5ecd8; --thread: #bea98a; --flap: #f7c654;
  margin: 0; min-height: 100vh; color: var(--ink); background: var(--page);
  font: 500 1rem/1.4 Fredoka, "Trebuchet MS", sans-serif;
}
body[data-board="meadow"] {
  --page: #f4efdd; --ink: #394728; --accent: #566638; --mat: url("art/meadow.webp");
  --cloth: #fcf3da; --thread: #bdac86; --flap: #ffcb8b;
}
body[data-board="midnight"] {
  --page: #232239; --ink: #fff3de; --accent: #54456b; --mat: url("art/wool.webp");
  --cloth: #36344d; --thread: #77718f; --flap: #ffcf62;
}
button, input, select { font: inherit; }
button, select, a { touch-action: manipulation; }
button, select { cursor: pointer; }
:focus-visible { outline: 3px solid #2687cf; outline-offset: 4px; }
.bar { display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: .8rem max(4vw, calc((100vw - 77rem) / 2)); border-bottom: 1px solid color-mix(in srgb, var(--ink) 20%, transparent); }
.brand { display: inline-flex; align-items: center; gap: .75rem; font-size: 1.12rem; font-weight: 650; white-space: nowrap; }
.patch-mark { width: 1.5rem; height: 1.5rem; border-radius: 5px; background: #ecb443; border: 2px dashed #805828; transform: rotate(-9deg); box-shadow: -3px 3px #618276, -5px 5px #214a42; }
nav { display: flex; align-items: center; gap: .2rem; padding: .22rem; border-radius: .9rem; background: color-mix(in srgb, var(--ink) 8%, transparent); }
nav a { min-height: 44px; display: flex; gap: .48rem; align-items: center; padding: .4rem .9rem; color: inherit; text-decoration: none; border-radius: .7rem; font-size: .92rem; font-weight: 550; }
nav a:hover { text-decoration: underline; }
nav a[aria-current] { background: var(--ink); color: var(--page); box-shadow: 0 1px 3px #0003; }
nav i { width: .85rem; height: .85rem; border: 1px dashed #fff9; border-radius: 3px; background: #287465; box-shadow: 0 0 0 1px #0002; }
nav [href="#meadow"] i { background: #99a85e; }
nav [href="#midnight"] i { background: #615489; }
main { width: min(92%,77rem); margin: auto; padding-bottom: 1.8rem; }
.tools { display: flex; align-items: center; justify-content: space-between; gap: 1.2rem; margin: clamp(1rem,3vh,2.5rem) 0 1.3rem; }
h1 { margin: 0; font-size: clamp(2.3rem,4.7vw,4.25rem); line-height: 1.04; letter-spacing: -.045em; font-weight: 650; }
#description { margin: .4rem 0 0; font-size: clamp(1rem,1.6vw,1.3rem); font-weight: 450; }
.choices { display: flex; gap: .7rem; }
.choices label { color: var(--ink); position: relative; display: grid; gap: .2rem; font-size: .9rem; }
.choices select { min-width: 8.4rem; appearance: none; border: 1px solid var(--thread); border-bottom-width: 3px; border-radius: .65rem; min-height: 46px; padding: .4rem 2.1rem .4rem .85rem; font-size: 1.08rem; font-weight: 550; background-color: var(--cloth); color: var(--ink); }
.choices label::after { content: ""; position: absolute; right: .9rem; bottom: 1.2rem; width: .45rem; height: .45rem; border: solid currentColor; border-width: 0 2px 2px 0; transform: rotate(45deg); pointer-events: none; }
.activity { display: flex; flex-direction: column; gap: .9rem; }
.mat { padding: clamp(1.7rem,4vh,3rem) clamp(1rem,5vw,5rem); position: relative;
  border: 4px solid var(--accent); border-radius: 1.5rem; background-color: var(--accent);
  background-image: var(--mat); background-size: 100% 100%; box-shadow: 0 4px 0 color-mix(in srgb,var(--accent) 75%,black),0 9px 16px #1f20151b; }
#groups { display: grid; grid-template-columns: repeat(var(--columns),minmax(0,1fr)); justify-content: center; align-items: end; gap: 1rem; }
figure { margin: 0; width: 100%; max-width: 17rem; justify-self: center; text-align: center; animation: place .28s both; }
.vessel { --vessel: url("art/basket.webp"); aspect-ratio: 1.22; width: 100%; position: relative; background-image: var(--vessel); background-size: 100% 100%; background-repeat: no-repeat; filter: drop-shadow(0 4px 2px #07100e55); }
.box .vessel { --vessel: url("art/box.webp"); }
.bag .vessel { --vessel: url("art/bag.webp"); }
.jar .vessel { --vessel: url("art/jar.webp"); }
.bucket .vessel { --vessel: url("art/bucket.webp"); }
.bowl .vessel { --vessel: url("art/bowl.webp"); }
.items { position: absolute; inset: 36% 12% 10%; display: grid; grid-auto-rows: minmax(0,1fr); gap: 3%; align-items: center; justify-items: center; }
.bag .items, .bucket .items { top: 42%; }
.jar .items { top: 31%; }
.bowl .items { inset: 34% 22% 16%; }
.items img { display: block; object-fit: contain; width: 100%; height: 100%; min-height: 0; min-width: 0; filter: drop-shadow(0 2px 1px #0003); animation: place .2s backwards; animation-delay: var(--item-delay); }
figcaption { display: inline-block; margin-top: .45rem; color: #fff6df; font-size: .94rem; font-weight: 550; }
.equation { display: flex; align-items: center; justify-content: center; gap: clamp(.6rem,2vw,2rem);
  padding: .8rem 1rem; border: 1px solid var(--thread); outline: 1px dashed var(--thread); outline-offset: -6px;
  background: var(--cloth); border-radius: 1.15rem; box-shadow: 0 3px 0 #24221d1a; }
.factor { display: grid; justify-items: center; gap: .2rem; }
.factor label { font-size: .95rem; font-weight: 550; }
.stepper { display: flex; align-items: center; gap: .25rem; }
.step, input, .answer button, output { border-radius: .65rem; text-align: center; color: #243c34; }
.step { border: 1px solid #c7b998; min-width: 44px; min-height: 44px; color: #37483d; background: #e8dfcc; font-size: 1.7rem; line-height: 1; }
.step:hover { background: #fffbef; }
input { width: 3.6rem; height: 3.6rem; border: 1px solid #c9b99a; outline: 1px dashed #c1af89; outline-offset: -5px; background: #fff6df; font-size: 2.3rem; font-weight: 650; appearance: textfield; box-shadow: 0 2px 0 #989079; }
input:focus-visible, #reveal:focus-visible { outline: 3px solid #2687cf; outline-offset: 2px; }
input::-webkit-inner-spin-button, input::-webkit-outer-spin-button { appearance: none; }
.operator { margin-top: 1.2rem; font-weight: 600; font-size: 2.1rem; line-height: 1; }
.answer { align-self: center; position: relative; }
.answer button, output { display: grid; place-content: center; width: 5.1rem; height: 4.7rem; background: var(--flap); border: 1px solid #987533; outline: 2px dashed #b48a3b; outline-offset: -6px; box-shadow: 1px 3px 0 #ac823d; }
.answer b, output { font-size: 2.4rem; line-height: 1; font-weight: 650; }
.answer span { font-size: .88rem; }
.answer button { transform: rotate(-2deg); transition: transform .16s; }
.answer button:hover { transform: rotate(0) translateY(-2px); }
.answer.open::after { content: ""; position: absolute; inset: 0; border-radius: .65rem; pointer-events: none; background: var(--flap); border: 2px dashed #af843b; transform-origin: top; animation: lift .38s ease-in forwards; }
@keyframes lift { to { transform: perspective(270px) rotateX(105deg); opacity: 0; } }
@keyframes place { from { opacity: 0; transform: translateY(4px); } }
[data-board="meadow"] .mat { border-radius: 2.5rem .9rem 2.5rem .9rem; }
[data-board="meadow"] figure { padding: .4rem .5rem; border-radius: 1rem; background: #fff4cfdf; outline: 2px dashed #889156; outline-offset: -5px; box-shadow: 2px 4px 1px #28351038; }
[data-board="meadow"] figcaption { color: #3a4c30; }
[data-board="midnight"] .equation { order: -1; }
[data-board="midnight"] .mat {
  background-color: #34304d;
  background-blend-mode: soft-light;
  background-size: 112px 112px;
  padding-top: max(2.25rem, 4vh);
}
[data-board="midnight"] .mat::before {
  content: "";
  position: absolute;
  top: 3px;
  right: 8px;
  width: 30px;
  height: 32px;
  pointer-events: none;
  /* Show only the stitched crescent in the top corner of the original artwork. */
  background: url("art/midnight.webp") right top / 320px auto no-repeat;
  mask-image: radial-gradient(ellipse at 50% 48%, black 45%, transparent 74%);
}
[data-board="midnight"] figcaption { color: #ffe59c; }
@media (min-width: 76rem) and (min-height: 50rem) {
  main { padding-top: 1rem; }
  .mat { padding-block: 3.6rem; }
  figure { max-width: 19rem; }
}
@media (max-width: 48rem) {
  .bar { justify-content: center; flex-wrap: wrap; gap: .65rem; }
  .brand { font-size: 1rem; }
  .tools { align-items: flex-start; }
  .choices select { min-width: 6.3rem; }
  .mat { padding-inline: .8rem; }
  #groups { gap: .5rem; }
}
@media (max-width: 38rem) {
  main { width: calc(100% - 1rem); }
  .bar { padding: .65rem .25rem; }
  nav a { padding: .3rem .5rem; font-size: .875rem; gap: .3rem; }
  nav i { width: .65rem; height: .65rem; }
  .tools { flex-direction: column; gap: .8rem; margin: 1.2rem .45rem 1rem; }
  .choices { width: 100%; }
  .choices label { flex: 1; }
  #groups { grid-template-columns: repeat(min(2, var(--columns)), minmax(0,1fr)); }
  .mat { padding: 1.45rem .65rem; }
  .equation { gap: .45rem; padding: .75rem .45rem; }
  .stepper { display: grid; grid-template-columns: repeat(2,44px); gap: .15rem; }
  .stepper input { grid-row: 1; grid-column: span 2; justify-self: center; width: 3rem; height: 3rem; }
  .step { font-size: 1.35rem; }
  .operator { margin-top: -.65rem; font-size: 1.55rem; }
  .answer button, output { width: 3.9rem; }
  figure { max-width: 13rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::after { animation-duration: .001ms !important; animation-delay: 0s !important; transition-duration: 0s !important; }
}
.equation, .answer button, .answer output {
  background-image: linear-gradient(#ffffffa8, #ffffffa8), url("art/wool.webp");
  background-size: auto, 110px 110px;
  background-blend-mode: soft-light, soft-light;
}
