@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 { margin: 0; background: #fffbeb; font-family: Fredoka, sans-serif; }
main { padding: 2rem 1rem; text-align: center; }
h1 { margin: 0 0 2rem; font-size: clamp(1.875rem, 5vw, 2.25rem); line-height: 1.12; color: #065f46; }
button, input { font: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button:focus-visible, input:focus-visible { outline: 3px solid #174e78; outline-offset: 3px; }
.equation { display: flex; align-items: center; flex-wrap: wrap; justify-content: center; gap: 1rem; }
.factor { display: grid; justify-items: center; gap: .25rem; }
.first { --edge: #059669; --ink: #065f46; --hover: #d1fae5; }
.second { --edge: #7c3aed; --ink: #5b21b6; --hover: #ede9fe; }
.step { width: 3.5rem; height: 2.5rem; border: 0; border-radius: .35rem; background: transparent; color: var(--edge); display: grid; place-items: center; }
.step:hover { background: var(--hover); }
.step::after { content: ""; width: .82rem; height: .82rem; border: solid currentColor; border-width: 3px 3px 0 0; border-radius: 1px; }
.up::after { transform: translateY(3px) rotate(-45deg); }
.down::after { transform: translateY(-3px) rotate(135deg); }
input, .tile { width: 5rem; height: 5rem; border: 4px solid; border-radius: 1rem; text-align: center; font-size: 1.875rem; font-weight: 700; }
input { appearance: textfield; color: var(--ink); background: white; border-color: var(--edge); }
input::-webkit-inner-spin-button, input::-webkit-outer-spin-button { appearance: none; margin: 0; }
.times, .equals { font-size: 2.25rem; font-weight: 700; }
.times { color: #f43f5e; }
.equals { color: #6b7280; }
.answer { display: flex; align-items: center; gap: .5rem; }
.tile { display: grid; place-items: center; background: #fcd34d; color: #78350f; border-color: #fbbf24; }
#reveal:hover { background: #fbbf24; }
#reset { width: 4rem; height: 4rem; font: bold 2rem/1 sans-serif; border: none; border-radius: .5rem; background: #6b7280; color: white; }
#reset:hover { background: #4b5563; }
#description { color: #4b5563; margin: 1rem 0 1.5rem; font-size: 1.125rem; }
#groups { display: flex; flex-wrap: wrap; justify-content: center; gap: 1.25rem; max-width: 56rem; margin: 0 auto; }
.group { padding: 1rem; border: 2px solid #f3f4f6; border-radius: 1rem; background: white; box-shadow: 0 4px 6px -1px #0002, 0 2px 4px -2px #0002; animation: rise .4s both; animation-delay: var(--group-delay); }
.label { margin: 0 0 .5rem; font-weight: 600; font-size: .875rem; color: #626978; }
.dots { display: flex; flex-wrap: wrap; justify-content: center; gap: .5rem; max-width: 7.5rem; }
.dot { width: 1.5rem; height: 1.5rem; border-radius: 50%; background: var(--colour); animation: pop .3s both; animation-delay: calc(var(--group-delay) + var(--dot-delay)); }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }
@keyframes pop { 0% { opacity: 0; transform: scale(0); } 60% { transform: scale(1.3); } 100% { opacity: 1; transform: scale(1); } }
@media (max-width: 47.99rem) {
  .equation { gap: .5rem; }
  input, .tile { width: 4rem; height: 4rem; font-size: 1.5rem; }
  .times, .equals { font-size: 1.875rem; }
  .step { height: 2.75rem; }
  #reset { width: 2.75rem; height: 2.75rem; }
}
@media (max-width: 23rem) {
  main { padding-inline: .5rem; }
  .equation, .answer { gap: .3rem; }
  input, .tile { width: 3.5rem; height: 3.5rem; }
}
@media (prefers-reduced-motion: reduce) { .group, .dot { animation: none; } }
