When grouping several details elements, you can do so with the name attribute. For some reason, it doesn’t work on Anki (not supported I suppose), which makes grouping those elements unnecessarily harder, needing to rely on JavaScript.
If is something on Anki’s side, please consider supporting the attribute. If it depends on a third party then there is nothing to do I guess.
As I said before, it can be solved with JavaScript, but the HTML native solution is much more convenient.