@import url('https://fonts.googleapis.com/css2?family=Handlee&family=Patrick+Hand&display=swap');

html,
body {
  margin: 0;
  padding: 0;
  font-family: 'Patrick Hand', cursive, sans-serif;
}

canvas {
  width: 100%;
  height: 100%:
}

body.in-game {
  overflow: hidden;
}

*:focus-visible {
  outline: 2px solid blue;
}

main {
  text-align: center;
}

h1 {
  font-family: 'Handlee', cursive, sans-serif;
  font-size: 3rem;
  font-weight: normal;
}

/* Form to play */

form {
  margin-top: 1rem;
  position: sticky;
  top: 0;
  z-index: 1;

  background: #fff;
  font-size: 1.5rem;
}

form img {
  width: 1.5rem;
  height: 1.5rem;
  margin-bottom: -.2rem;
  border-radius: 50%;
}

form button, form a {
  display: inline-block;

  height: 3rem;
  padding: 0 2rem;
  margin-top: 0.5rem;
  background: white;

  border: 2px solid black;
  border-radius: 2rem;
  box-sizing: border-box;
  box-shadow: black 0 1px 0;

  font-family: 'Patrick Hand', cursive, sans-serif;
  font-size: 1.5rem;
  color: black;
  text-decoration: none;
  letter-spacing: 1px;
  line-height: 2.5rem;

  cursor: pointer;

  &:hover {
    scale: 1.125;
  }

  transition: scale 0.1s;
}

form a svg {
  height: 1.5rem;
  margin-bottom: -.3rem;
}

/* Scoreboard */

#scores {
  position: absolute;
  top: 0;
  right: 0;
  width: min(10rem, 20vw);

  list-style: none;
  margin: 0;
  padding: 1rem;
}

#scores li {
  display: flex;
  gap: 0.5rem;
}

#scores li img {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
}

#scores .spacer {
  flex-grow: 1;
}

/* UI overlay */

.indicator {
  overflow: hidden;

  box-sizing: border-box;
  border-radius: 1rem;
  border: 2px solid black;
  border-bottom: 3px solid black;

  background-color: rgba(0, 0, 0, 0.1);

  cursor: pointer;
}

#boost_indicator {
  --capacity: 0;
  --treshold: 0;
  --boost: 0;
  --scale: 0.5px;

  position: absolute;
  bottom: 0;
  left: 0;
  width: calc(var(--capacity) * var(--scale));
  height: 4rem;

  @media (min-width: 512px) {
    --scale: 1px;
    height: 2.5rem;
  }

  &.boosting {
    border-color: #2563EB;
  }
}

#boost_indicator div {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 4rem;

  @media (min-width: 512px) {
    height: 2.5rem;
  }
}

#boost_indicator div:nth-child(1) {
  width: calc(var(--treshold) * var(--scale));
  background-color: #2563EB;
  opacity: 0.4;
}

#boost_indicator div:nth-child(2) {
  width: calc(var(--boost) * var(--scale));
  background-color: #2563EB;
}

#sacrifice_indicator {
  --capacity: 0;
  --countdown: 0;
  --scale: 0.5px;

  position: absolute;
  bottom: 4rem;
  left: 0;
  width: calc(var(--capacity) * var(--scale));
  height: 4rem;

  @media (min-width: 512px) {
    --scale: 1px;
    bottom: 2.5rem;
    height: 2.5rem;
  }
}

#sacrifice_indicator div {
  position: absolute;
  bottom: 0;
  left: 0;
  width: calc(var(--countdown) * var(--scale));
  height: 4rem;
  background-color: green;

  @media (min-width: 512px) {
    height: 2.5rem;
  }
}

/* Instructions */

article {
  margin-left: auto;
  margin-right: auto;
  max-width: 45rem;
}

h2 {
  font-size: 2rem;
  margin-top: 3rem;
}

figure {
  margin-left: 1rem;
  margin-right: 1rem;
  margin-bottom: 2rem;
}

figcaption {
  text-align: left;
  font-size: 1.5rem;
}

strong {
  /* Makes the font looks better in bold */
  letter-spacing: 1px;
}

/* Instruction animations */

.animation {
  width: 100%;
  aspect-ratio: 3;
  position: relative;
}

/* Width: 8x. Height: 2.666x */
.animation-unit {
  position: absolute;
  width: 12.5%;
  left: -6.25%;
}

.animation-finger {
  position: absolute;
  background-color: #cccc00;
  width: 4%;
  height: 12%;
  border-radius: 100%;
  left: -2%;
  top: -6%;
}

.catch-animation img {
  animation-duration: 5s;
  animation-iteration-count: infinite;
}

@keyframes a {
  0% {
    transform: translate(100%, 100%);
  }
  10% {
    transform: translate(100%, 100%);
  }
  40% {
    transform: translate(500%, 100%);
  }
  55% {
    transform: translate(500%, 100%) scale(1);
  }
  60% {
    transform: translate(500%, 100%) scale(0);
  }
  100% {
    transform: translate(500%, 100%) scale(0);
  }
}
.catch-animation img:nth-child(1) {
  animation-name: a;
}

@keyframes b {
  0% {
    transform: translate(700%, 100%);
  }
  50% {
    transform: translate(700%, 100%);
  }
  80% {
    transform: translate(300%, 100%);
  }
  100% {
    transform: translate(300%, 100%);
  }
}
.catch-animation img:nth-child(2) {
  animation-name: b;
}

@keyframes c {
  0% {
    transform: translate(400%, 100%) scale(1);
  }
  20% {
    transform: translate(400%, 100%) scale(1);
  }
  25% {
    transform: translate(400%, 100%) scale(0);
  }
  100% {
    transform: translate(400%, 100%) scale(0);
  }
}
.catch-animation img:nth-child(3) {
  animation-name: c;
}

@keyframes d {
  0% {
    transform: translate(400%, 100%) scale(0);
  }
  25% {
    transform: translate(400%, 100%) scale(0);
  }
  30% {
    transform: translate(400%, 100%) scale(1);
  }
  60% {
    transform: translate(400%, 100%) scale(1);
  }
  65% {
    transform: translate(400%, 100%) scale(0);
  }
  100% {
    transform: translate(400%, 100%) scale(0);
  }
}
.catch-animation img:nth-child(4) {
  animation-name: d;
}

@keyframes e {
  0% {
    transform: translate(500%, 100%) scale(0);
  }
  60% {
    transform: translate(500%, 100%) scale(0);
  }
  65% {
    transform: translate(500%, 100%) scale(1);
  }
  100% {
    transform: translate(500%, 100%) scale(1);
  }
}
.catch-animation img:nth-child(5) {
  animation-name: e;
}

@keyframes f {
  0% {
    transform: translate(400%, 100%) scale(0);
  }
  65% {
    transform: translate(400%, 100%) scale(0);
  }
  70% {
    transform: translate(400%, 100%) scale(1);
  }
  100% {
    transform: translate(400%, 100%) scale(1);
  }
}
.catch-animation img:nth-child(6) {
  animation-name: f;
}

.collect-animation img,
.collect-animation div {
  animation-duration: 4s;
  animation-iteration-count: infinite;
}

@keyframes g {
  0% {
    transform: translate(100%, 100%);
  }
  10% {
    transform: translate(100%, 100%);
  }
  90% {
    transform: translate(700%, 100%);
  }
  100% {
    transform: translate(700%, 100%);
  }
}
.collect-animation img:nth-child(1) {
  animation-name: g;
}

@keyframes h {
  0% {
    transform: translate(400%, 100%) scale(0);
  }
  36% {
    transform: translate(400%, 100%) scale(0);
  }
  56% {
    transform: translate(500%, 100%) scale(1);
  }
  100% {
    transform: translate(500%, 100%) scale(1);
  }
}
.collect-animation img:nth-child(2) {
  animation-name: h;
}

@keyframes ha {
  0% {
    transform: translate(600%, 400%) scale(1);
  }
  18% {
    transform: translate(600%, 400%) scale(1);
  }
  23% {
    transform: translate(600%, 400%) scale(0);
  }
  100% {
    transform: translate(600%, 400%) scale(0);
  }
}
.collect-animation div:nth-child(3) {
  animation-name: ha;
}

@keyframes hb {
  0% {
    transform: translate(800%, 400%) scale(1);
  }
  21% {
    transform: translate(800%, 400%) scale(1);
  }
  26% {
    transform: translate(800%, 400%) scale(0);
  }
  100% {
    transform: translate(800%, 400%) scale(0);
  }
}
.collect-animation div:nth-child(4) {
  animation-name: hb;
}

@keyframes hc {
  0% {
    transform: translate(1000%, 400%) scale(1);
  }
  25% {
    transform: translate(1000%, 400%) scale(1);
  }
  30% {
    transform: translate(1000%, 400%) scale(0);
  }
  100% {
    transform: translate(1000%, 400%) scale(0);
  }
}
.collect-animation div:nth-child(5) {
  animation-name: hc;
}

@keyframes hd {
  0% {
    transform: translate(1200%, 400%) scale(1);
  }
  28% {
    transform: translate(1200%, 400%) scale(1);
  }
  33% {
    transform: translate(1200%, 400%) scale(0);
  }
  100% {
    transform: translate(1200%, 400%) scale(0);
  }
}
.collect-animation div:nth-child(6) {
  animation-name: hd;
}

@keyframes he {
  0% {
    transform: translate(1400%, 400%) scale(1);
  }
  31% {
    transform: translate(1400%, 400%) scale(1);
  }
  36% {
    transform: translate(1400%, 400%) scale(0);
  }
  100% {
    transform: translate(1400%, 400%) scale(0);
  }
}
.collect-animation div:nth-child(7) {
  animation-name: he;
}

.boost-animation img {
  animation-duration: 1.5s;
  animation-iteration-count: infinite;
}

@keyframes i {
  0% {
    transform: translate(100%, 100%) rotate(90deg);
  }
  50% {
    transform: translate(250%, 100%) rotate(90deg);
  }
  100% {
    transform: translate(700%, 100%) rotate(90deg);
  }
}
.boost-animation img:nth-child(1) {
  animation-name: i;
  animation-timing-function: linear;
}

@keyframes j {
  0% {
    transform: translate(300%, 100%) scale(1);
  }
  75% {
    transform: translate(525%, 100%) scale(1);
  }
  85% {
    transform: translate(550%, 100%) scale(0);
  }
  100% {
    transform: translate(550%, 100%) scale(0);
  }
}
.boost-animation img:nth-child(2) {
  animation-name: j;
  animation-timing-function: linear;
}

.sacrifice-animation img {
  animation-duration: 3s;
  animation-iteration-count: infinite;
}

@keyframes k {
  0% {
    transform: translate(350%, 50%) scale(1);
  }
  73% {
    transform: translate(350%, 50%) scale(1);
  }
  83% {
    transform: translate(350%, 50%) scale(0);
  }
  100% {
    transform: translate(350%, 50%) scale(0);
  }
}
@keyframes l {
  0% {
    transform: translate(450%, 50%) scale(1);
  }
  76% {
    transform: translate(450%, 50%) scale(1);
  }
  86% {
    transform: translate(450%, 50%) scale(0);
  }
  100% {
    transform: translate(450%, 50%) scale(0);
  }
}
@keyframes m {
  0% {
    transform: translate(350%, 150%) scale(1);
  }
  74% {
    transform: translate(350%, 150%) scale(1);
  }
  84% {
    transform: translate(350%, 150%) scale(0);
  }
  100% {
    transform: translate(350%, 150%) scale(0);
  }
}
@keyframes n {
  0% {
    transform: translate(450%, 150%) scale(1);
  }
  70% {
    transform: translate(450%, 150%) scale(1);
  }
  80% {
    transform: translate(450%, 150%) scale(0);
  }
  100% {
    transform: translate(450%, 150%) scale(0);
  }
}
.sacrifice-animation img:nth-child(1) {
  animation-name: k;
}
.sacrifice-animation img:nth-child(2) {
  animation-name: l;
}
.sacrifice-animation img:nth-child(3) {
  animation-name: m;
}
.sacrifice-animation img:nth-child(4) {
  animation-name: n;
}

@keyframes o {
  0% {
    transform: translate(350%, 50%) scale(0);
  }
  83% {
    transform: translate(350%, 50%) scale(0);
  }
  93% {
    transform: translate(350%, 50%) scale(1);
  }
  100% {
    transform: translate(350%, 50%) scale(1);
  }
}
@keyframes p {
  0% {
    transform: translate(450%, 150%) scale(0);
  }
  80% {
    transform: translate(450%, 150%) scale(0);
  }
  90% {
    transform: translate(450%, 150%) scale(1);
  }
  100% {
    transform: translate(450%, 150%) scale(1);
  }
}
.sacrifice-animation img:nth-child(5) {
  animation-name: o;
}
.sacrifice-animation img:nth-child(6) {
  animation-name: p;
}
