* {
  padding: 0;
  margin: 0;
  box-sizing: border-box;
  font-family: "Trebuchet MS", "Lucida Sans Unicode", "Lucida Grande",
    "Lucida Sans", Arial, sans-serif;
  border: none;
}

body {
  background: linear-gradient(rgb(92, 32, 126), rgb(6, 88, 142));
  background-size: cover;
  min-height: 100vh;
  background-repeat: no-repeat;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow-x: hidden;
}

.link {
  text-decoration: underline;
  color: rgb(240, 26, 26);
  display: flex;
  justify-content: end;
}
.link:hover {
  text-decoration-style: double;
}

main {
  background-color: white;
  padding: 3rem;
  border-radius: 0.4rem;
  box-shadow: 0 10px 15px rgba(0, 0, 0, 0.5),
    -15px -20px 15px rgba(0, 0, 0, 0.2);

  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  width: 90%;
  max-width: 450px;
  position: relative;
}

main > span,
input {
  border: 1px solid rgb(203, 199, 199);
  padding: 1rem;
  text-align: right;
  font-size: 1.9rem;
  color: gray;
  border-radius: 0.3rem;
}

input:disabled {
  background-color: rgb(208, 206, 206);
  padding-block: 1.5rem;
}

main > span {
  margin-top: -2rem;
  border: none;
  font-size: 3rem;
  color: rgb(82, 70, 70);
  padding-inline: 0;
}

div {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}

button {
  padding: 0.8rem;
  display: grid;
  place-items: center;
  transition: box-shadow 0.6s, border-color 0.5s;
  border: 1px solid transparent;
  border-radius: 0.2rem;
  font-size: 1.3rem;
  cursor: pointer;
  color: rgb(78, 83, 97);
}

button:hover {
  box-shadow: 0 0 4px rgba(27, 3, 67, 0.2);
  border-color: rgba(26, 75, 191, 0.5);
}

button.op:hover {
  border-color: rgba(214, 218, 225, 0.9);
}

button.op {
  background-color: rgb(106, 95, 95);
  color: white;
}

button.eq {
  background-color: rgb(26, 75, 191);
  grid-column: 4 /5;
  grid-row: 2 / span 4;
}

button.clear {
  background-color: rgb(241, 50, 43);
}
button.history {
  color: white;
  max-width: max-content;
  position: absolute;
  top: 0.3rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.8rem;
  padding: 0.3rem 0.6rem;
}
section.history {
  position: absolute;
  background-color: white;
  height: 380px;
  width: 280px;
  left: 2rem;
  overflow-y: auto;
  border-radius: 0.2rem;
  padding: 3rem 0.5rem 1rem;
  color: rgb(161, 161, 161);
  font-size: 1.2rem;
}

section.history > * {
  border-bottom: 1px solid rgb(209, 207, 207);
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0.3rem;
}

section.history::before {
  content: "History";
  position: absolute;
  top: 0.9rem;
  left: 50%;
  transform: translateX(-50%);
  color: rgb(26, 75, 191);
}

@media screen and (max-width: 780px) {
  main {
    padding: 1rem;
  }
  section.history {
    overflow: hidden;
    width: 4.5rem;
    height: 4.5rem;
    padding: 1rem;
    top: 1rem;
    left: 1rem;
    transition: all 0.6s;
    border-radius: 50%;
    box-shadow: 0 0 12px rgba(27, 3, 67, 0.1);
  }

  section.history > *,
  section.history::before {
    display: none;
  }

  section.history::after {
    content: "Open";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.9rem;
    color: rgb(26, 75, 191);
  }

  section.history.active {
    height: 380px;
    width: 280px;
    overflow-y: auto;
    border-radius: 0;
  }
  section.history.active > *,
  section.history.active::before {
    display: flex;
  }
  section.history.active::after {
    display: none;
  }
}
